/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var X5 = function(e, t) {
  return X5 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(r, n) {
    r.__proto__ = n;
  } || function(r, n) {
    for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && (r[i] = n[i]);
  }, X5(e, t);
};
function ga(e, t) {
  if (typeof t != "function" && t !== null) throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
  function r() {
    this.constructor = e;
  }
  X5(e, t), e.prototype = t === null ? Object.create(t) : (r.prototype = t.prototype, new r());
}
var R = function() {
  return R = Object.assign || function(e) {
    for (var t, r = 1, n = arguments.length; r < n; r++) for (var i in t = arguments[r]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
    return e;
  }, R.apply(this, arguments);
};
function _e(e, t, r, n) {
  return new (r || (r = Promise))(function(i, a) {
    function o(c) {
      try {
        s(n.next(c));
      } catch (l) {
        a(l);
      }
    }
    function u(c) {
      try {
        s(n.throw(c));
      } catch (l) {
        a(l);
      }
    }
    function s(c) {
      var l;
      c.done ? i(c.value) : (l = c.value, l instanceof r ? l : new r(function(d) {
        d(l);
      })).then(o, u);
    }
    s((n = n.apply(e, [])).next());
  });
}
function ye(e, t) {
  var r, n, i, a, o = { label: 0, sent: function() {
    if (1 & i[0]) throw i[1];
    return i[1];
  }, trys: [], ops: [] };
  return a = { next: u(0), throw: u(1), return: u(2) }, typeof Symbol == "function" && (a[Symbol.iterator] = function() {
    return this;
  }), a;
  function u(s) {
    return function(c) {
      return function(l) {
        if (r) throw new TypeError("Generator is already executing.");
        for (; o; ) try {
          if (r = 1, n && (i = 2 & l[0] ? n.return : l[0] ? n.throw || ((i = n.return) && i.call(n), 0) : n.next) && !(i = i.call(n, l[1])).done) return i;
          switch (n = 0, i && (l = [2 & l[0], i.value]), l[0]) {
            case 0:
            case 1:
              i = l;
              break;
            case 4:
              return o.label++, { value: l[1], done: !1 };
            case 5:
              o.label++, n = l[1], l = [0];
              continue;
            case 7:
              l = o.ops.pop(), o.trys.pop();
              continue;
            default:
              if (i = o.trys, !((i = i.length > 0 && i[i.length - 1]) || l[0] !== 6 && l[0] !== 2)) {
                o = 0;
                continue;
              }
              if (l[0] === 3 && (!i || l[1] > i[0] && l[1] < i[3])) {
                o.label = l[1];
                break;
              }
              if (l[0] === 6 && o.label < i[1]) {
                o.label = i[1], i = l;
                break;
              }
              if (i && o.label < i[2]) {
                o.label = i[2], o.ops.push(l);
                break;
              }
              i[2] && o.ops.pop(), o.trys.pop();
              continue;
          }
          l = t.call(e, o);
        } catch (d) {
          l = [6, d], n = 0;
        } finally {
          r = i = 0;
        }
        if (5 & l[0]) throw l[1];
        return { value: l[0] ? l[1] : void 0, done: !0 };
      }([s, c]);
    };
  }
}
function j5(e) {
  var t = typeof Symbol == "function" && Symbol.iterator, r = t && e[t], n = 0;
  if (r) return r.call(e);
  if (e && typeof e.length == "number") return { next: function() {
    return e && n >= e.length && (e = void 0), { value: e && e[n++], done: !e };
  } };
  throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function c2(e, t) {
  var r = typeof Symbol == "function" && e[Symbol.iterator];
  if (!r) return e;
  var n, i, a = r.call(e), o = [];
  try {
    for (; (t === void 0 || t-- > 0) && !(n = a.next()).done; ) o.push(n.value);
  } catch (u) {
    i = { error: u };
  } finally {
    try {
      n && !n.done && (r = a.return) && r.call(a);
    } finally {
      if (i) throw i.error;
    }
  }
  return o;
}
function We(e, t, r) {
  if (r || arguments.length === 2) for (var n, i = 0, a = t.length; i < a; i++) !n && i in t || (n || (n = Array.prototype.slice.call(t, 0, i)), n[i] = t[i]);
  return e.concat(n || Array.prototype.slice.call(t));
}
function xc(e) {
  return typeof e == "function";
}
function IE(e) {
  var t = e(function(r) {
    Error.call(r), r.stack = new Error().stack;
  });
  return t.prototype = Object.create(Error.prototype), t.prototype.constructor = t, t;
}
var Sy = IE(function(e) {
  return function(t) {
    e(this), this.message = t ? t.length + ` errors occurred during unsubscription:
` + t.map(function(r, n) {
      return n + 1 + ") " + r.toString();
    }).join(`
  `) : "", this.name = "UnsubscriptionError", this.errors = t;
  };
});
function Y5(e, t) {
  if (e) {
    var r = e.indexOf(t);
    0 <= r && e.splice(r, 1);
  }
}
var _g = function() {
  function e(r) {
    this.initialTeardown = r, this.closed = !1, this._parentage = null, this._teardowns = null;
  }
  var t;
  return e.prototype.unsubscribe = function() {
    var r, n, i, a, o;
    if (!this.closed) {
      this.closed = !0;
      var u = this._parentage;
      if (u) if (this._parentage = null, Array.isArray(u)) try {
        for (var s = j5(u), c = s.next(); !c.done; c = s.next())
          c.value.remove(this);
      } catch (p) {
        r = { error: p };
      } finally {
        try {
          c && !c.done && (n = s.return) && n.call(s);
        } finally {
          if (r) throw r.error;
        }
      }
      else u.remove(this);
      var l = this.initialTeardown;
      if (xc(l)) try {
        l();
      } catch (p) {
        o = p instanceof Sy ? p.errors : [p];
      }
      var d = this._teardowns;
      if (d) {
        this._teardowns = null;
        try {
          for (var f = j5(d), m = f.next(); !m.done; m = f.next()) {
            var v = m.value;
            try {
              Y7(v);
            } catch (p) {
              o = o ?? [], p instanceof Sy ? o = We(We([], c2(o)), c2(p.errors)) : o.push(p);
            }
          }
        } catch (p) {
          i = { error: p };
        } finally {
          try {
            m && !m.done && (a = f.return) && a.call(f);
          } finally {
            if (i) throw i.error;
          }
        }
      }
      if (o) throw new Sy(o);
    }
  }, e.prototype.add = function(r) {
    var n;
    if (r && r !== this) if (this.closed) Y7(r);
    else {
      if (r instanceof e) {
        if (r.closed || r._hasParent(this)) return;
        r._addParent(this);
      }
      (this._teardowns = (n = this._teardowns) !== null && n !== void 0 ? n : []).push(r);
    }
  }, e.prototype._hasParent = function(r) {
    var n = this._parentage;
    return n === r || Array.isArray(n) && n.includes(r);
  }, e.prototype._addParent = function(r) {
    var n = this._parentage;
    this._parentage = Array.isArray(n) ? (n.push(r), n) : n ? [n, r] : r;
  }, e.prototype._removeParent = function(r) {
    var n = this._parentage;
    n === r ? this._parentage = null : Array.isArray(n) && Y5(n, r);
  }, e.prototype.remove = function(r) {
    var n = this._teardowns;
    n && Y5(n, r), r instanceof e && r._removeParent(this);
  }, e.EMPTY = ((t = new e()).closed = !0, t), e;
}(), EE = _g.EMPTY;
function ME(e) {
  return e instanceof _g || e && "closed" in e && xc(e.remove) && xc(e.add) && xc(e.unsubscribe);
}
function Y7(e) {
  xc(e) ? e() : e.unsubscribe();
}
var TE = { onUnhandledError: null, onStoppedNotification: null, Promise: void 0, useDeprecatedSynchronousErrorHandling: !1, useDeprecatedNextContext: !1 }, uU = { setTimeout: function() {
  for (var e = [], t = 0; t < arguments.length; t++) e[t] = arguments[t];
  return setTimeout.apply(void 0, We([], c2(e)));
}, clearTimeout: function(e) {
  return clearTimeout(e);
}, delegate: void 0 };
function l2() {
}
function jv(e) {
  e();
}
var PE = function(e) {
  function t(r) {
    var n = e.call(this) || this;
    return n.isStopped = !1, r ? (n.destination = r, ME(r) && r.add(n)) : n.destination = sU, n;
  }
  return ga(t, e), t.create = function(r, n, i) {
    return new W5(r, n, i);
  }, t.prototype.next = function(r) {
    this.isStopped || this._next(r);
  }, t.prototype.error = function(r) {
    this.isStopped || (this.isStopped = !0, this._error(r));
  }, t.prototype.complete = function() {
    this.isStopped || (this.isStopped = !0, this._complete());
  }, t.prototype.unsubscribe = function() {
    this.closed || (this.isStopped = !0, e.prototype.unsubscribe.call(this), this.destination = null);
  }, t.prototype._next = function(r) {
    this.destination.next(r);
  }, t.prototype._error = function(r) {
    try {
      this.destination.error(r);
    } finally {
      this.unsubscribe();
    }
  }, t.prototype._complete = function() {
    try {
      this.destination.complete();
    } finally {
      this.unsubscribe();
    }
  }, t;
}(_g), W5 = function(e) {
  function t(r, n, i) {
    var a, o = e.call(this) || this;
    if (xc(r)) a = r;
    else if (r) {
      var u;
      a = r.next, n = r.error, i = r.complete, o && TE.useDeprecatedNextContext ? (u = Object.create(r)).unsubscribe = function() {
        return o.unsubscribe();
      } : u = r, a = a == null ? void 0 : a.bind(u), n = n == null ? void 0 : n.bind(u), i = i == null ? void 0 : i.bind(u);
    }
    return o.destination = { next: a ? Cy(a) : l2, error: Cy(n ?? BE), complete: i ? Cy(i) : l2 }, o;
  }
  return ga(t, e), t;
}(PE);
function Cy(e, t) {
  return function() {
    for (var r = [], n = 0; n < arguments.length; n++) r[n] = arguments[n];
    try {
      e.apply(void 0, We([], c2(r)));
    } catch (i) {
      (function(a) {
        uU.setTimeout(function() {
          throw a;
        });
      })(i);
    }
  };
}
function BE(e) {
  throw e;
}
var sU = { closed: !0, next: l2, error: BE, complete: l2 }, cU = typeof Symbol == "function" && Symbol.observable || "@@observable";
function lU(e) {
  return e;
}
var W7 = function() {
  function e(t) {
    t && (this._subscribe = t);
  }
  return e.prototype.lift = function(t) {
    var r = new e();
    return r.source = this, r.operator = t, r;
  }, e.prototype.subscribe = function(t, r, n) {
    var i, a = this, o = (i = t) && i instanceof PE || function(u) {
      return u && xc(u.next) && xc(u.error) && xc(u.complete);
    }(i) && ME(i) ? t : new W5(t, r, n);
    return jv(function() {
      var u = a, s = u.operator, c = u.source;
      o.add(s ? s.call(o, c) : c ? a._subscribe(o) : a._trySubscribe(o));
    }), o;
  }, e.prototype._trySubscribe = function(t) {
    try {
      return this._subscribe(t);
    } catch (r) {
      t.error(r);
    }
  }, e.prototype.forEach = function(t, r) {
    var n = this;
    return new (r = Z7(r))(function(i, a) {
      var o = new W5({ next: function(u) {
        try {
          t(u);
        } catch (s) {
          a(s), o.unsubscribe();
        }
      }, error: a, complete: i });
      n.subscribe(o);
    });
  }, e.prototype._subscribe = function(t) {
    var r;
    return (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(t);
  }, e.prototype[cU] = function() {
    return this;
  }, e.prototype.pipe = function() {
    for (var t, r = [], n = 0; n < arguments.length; n++) r[n] = arguments[n];
    return ((t = r).length === 0 ? lU : t.length === 1 ? t[0] : function(i) {
      return t.reduce(function(a, o) {
        return o(a);
      }, i);
    })(this);
  }, e.prototype.toPromise = function(t) {
    var r = this;
    return new (t = Z7(t))(function(n, i) {
      var a;
      r.subscribe(function(o) {
        return a = o;
      }, function(o) {
        return i(o);
      }, function() {
        return n(a);
      });
    });
  }, e.create = function(t) {
    return new e(t);
  }, e;
}();
function Z7(e) {
  var t;
  return (t = e ?? TE.Promise) !== null && t !== void 0 ? t : Promise;
}
var dU = IE(function(e) {
  return function() {
    e(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
  };
}), ui = function(e) {
  function t() {
    var r = e.call(this) || this;
    return r.closed = !1, r.observers = [], r.isStopped = !1, r.hasError = !1, r.thrownError = null, r;
  }
  return ga(t, e), t.prototype.lift = function(r) {
    var n = new Q7(this, this);
    return n.operator = r, n;
  }, t.prototype._throwIfClosed = function() {
    if (this.closed) throw new dU();
  }, t.prototype.next = function(r) {
    var n = this;
    jv(function() {
      var i, a;
      if (n._throwIfClosed(), !n.isStopped) {
        var o = n.observers.slice();
        try {
          for (var u = j5(o), s = u.next(); !s.done; s = u.next())
            s.value.next(r);
        } catch (c) {
          i = { error: c };
        } finally {
          try {
            s && !s.done && (a = u.return) && a.call(u);
          } finally {
            if (i) throw i.error;
          }
        }
      }
    });
  }, t.prototype.error = function(r) {
    var n = this;
    jv(function() {
      if (n._throwIfClosed(), !n.isStopped) {
        n.hasError = n.isStopped = !0, n.thrownError = r;
        for (var i = n.observers; i.length; ) i.shift().error(r);
      }
    });
  }, t.prototype.complete = function() {
    var r = this;
    jv(function() {
      if (r._throwIfClosed(), !r.isStopped) {
        r.isStopped = !0;
        for (var n = r.observers; n.length; ) n.shift().complete();
      }
    });
  }, t.prototype.unsubscribe = function() {
    this.isStopped = this.closed = !0, this.observers = null;
  }, Object.defineProperty(t.prototype, "observed", { get: function() {
    var r;
    return ((r = this.observers) === null || r === void 0 ? void 0 : r.length) > 0;
  }, enumerable: !1, configurable: !0 }), t.prototype._trySubscribe = function(r) {
    return this._throwIfClosed(), e.prototype._trySubscribe.call(this, r);
  }, t.prototype._subscribe = function(r) {
    return this._throwIfClosed(), this._checkFinalizedStatuses(r), this._innerSubscribe(r);
  }, t.prototype._innerSubscribe = function(r) {
    var n = this, i = n.hasError, a = n.isStopped, o = n.observers;
    return i || a ? EE : (o.push(r), new _g(function() {
      return Y5(o, r);
    }));
  }, t.prototype._checkFinalizedStatuses = function(r) {
    var n = this, i = n.hasError, a = n.thrownError, o = n.isStopped;
    i ? r.error(a) : o && r.complete();
  }, t.prototype.asObservable = function() {
    var r = new W7();
    return r.source = this, r;
  }, t.create = function(r, n) {
    return new Q7(r, n);
  }, t;
}(W7), Q7 = function(e) {
  function t(r, n) {
    var i = e.call(this) || this;
    return i.destination = r, i.source = n, i;
  }
  return ga(t, e), t.prototype.next = function(r) {
    var n, i;
    (i = (n = this.destination) === null || n === void 0 ? void 0 : n.next) === null || i === void 0 || i.call(n, r);
  }, t.prototype.error = function(r) {
    var n, i;
    (i = (n = this.destination) === null || n === void 0 ? void 0 : n.error) === null || i === void 0 || i.call(n, r);
  }, t.prototype.complete = function() {
    var r, n;
    (n = (r = this.destination) === null || r === void 0 ? void 0 : r.complete) === null || n === void 0 || n.call(r);
  }, t.prototype._subscribe = function(r) {
    var n, i;
    return (i = (n = this.source) === null || n === void 0 ? void 0 : n.subscribe(r)) !== null && i !== void 0 ? i : EE;
  }, t;
}(ui), Ol = function(e) {
  function t(r) {
    var n = e.call(this) || this;
    return n._value = r, n;
  }
  return ga(t, e), Object.defineProperty(t.prototype, "value", { get: function() {
    return this.getValue();
  }, enumerable: !1, configurable: !0 }), t.prototype._subscribe = function(r) {
    var n = e.prototype._subscribe.call(this, r);
    return !n.closed && r.next(this._value), n;
  }, t.prototype.getValue = function() {
    var r = this, n = r.hasError, i = r.thrownError, a = r._value;
    if (n) throw i;
    return this._throwIfClosed(), a;
  }, t.prototype.next = function(r) {
    e.prototype.next.call(this, this._value = r);
  }, t;
}(ui), li = function() {
  if (typeof window < "u" && window.performance) {
    var e = window.performance;
    return function() {
      return e.now();
    };
  }
  return typeof process < "u" && process.hrtime !== "undefined" && typeof process.hrtime == "function" ? function() {
    var t = process.hrtime();
    return 1e3 * t[0] + t[1] / 1e6;
  } : Date.now ? function() {
    return Date.now();
  } : function() {
    return +/* @__PURE__ */ new Date();
  };
}(), pn = 1e-6;
function Ln(e, t, r) {
  return Math.abs(e - t) <= r;
}
var zn, ya, Cr, Ii, J7, Lp, $7 = Math.PI / 2, FE = Math.PI / 180;
function Bn(e) {
  return e * FE;
}
function xa(e) {
  return e / FE;
}
function NE(e, t) {
  return e * t;
}
function me() {
  return me.zero();
}
function Qa(e, t, r) {
  return Math.max(t, Math.min(r, e));
}
function Si(e, t, r) {
  return e + (t - e) * r;
}
function Yv(e, t, r, n, i, a) {
  var o = (r - e) * a, u = (n - t) * a, s = i * i;
  return (2 * t - 2 * r + o + u) * (i * s) + (-3 * t + 3 * r - 2 * o - u) * s + o * i + t;
}
function wy(e, t, r, n) {
  var i = 1 - n;
  return i * i * e + 2 * i * n * t + n * n * r;
}
function RE(e, t, r) {
  var n;
  return n = function(i, a, o) {
    return (i - a) / (o - a);
  }(r, e, t), (r = Qa(n, 0, 1)) * r * (3 - 2 * r);
}
function w() {
  return w.zero();
}
function Ti() {
  return Ti.zero();
}
function ke() {
  return ke.zero();
}
function Vt() {
  return Vt.zero();
}
function In() {
  return In.zero();
}
function fU(e, t) {
  return e - t;
}
function La(e, t) {
  e === void 0 && (e = 0), t === void 0 && (t = Number.MAX_SAFE_INTEGER);
  var r = e;
  return function() {
    var n = r;
    return r = (r + 1) % t, n;
  };
}
(function(e) {
  function t() {
    var p = [0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
    return p[0] = 0, p;
  }
  function r() {
    var p = t();
    return p[0] = 1, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = 1, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = 1, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }
  function n(p) {
    return p[0] = 1, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = 1, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = 1, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }
  function i(p) {
    for (var g = 0; g < 16; g++) p[g] = 0;
    return p;
  }
  e.zero = t, e.identity = r, e.setIdentity = n, e.setZero = i, e.ofRows = function(p) {
    for (var g = t(), h = 0; h < 4; h++) for (var y = p[h], x = 0; x < 4; x++) g[4 * x + h] = y[x];
    return g;
  };
  var a = r();
  function o(p, g, h) {
    for (var y = 0; y < 16; y++) if (Math.abs(p[y] - g[y]) > h) return !1;
    return !0;
  }
  function u(p, g, h, y) {
    p[4 * h + g] = y;
  }
  function s(p, g) {
    return p[0] = g[0], p[1] = g[1], p[2] = g[2], p[3] = g[3], p[4] = g[4], p[5] = g[5], p[6] = g[6], p[7] = g[7], p[8] = g[8], p[9] = g[9], p[10] = g[10], p[11] = g[11], p[12] = g[12], p[13] = g[13], p[14] = g[14], p[15] = g[15], p;
  }
  function c(p, g) {
    var h = g[0], y = g[1], x = g[2], A = g[3], b = g[4], _ = g[5], S = g[6], D = g[7], I = g[8], M = g[9], F = g[10], P = g[11], E = g[12], B = g[13], N = g[14], O = g[15], z = h * _ - y * b, V = h * S - x * b, U = h * D - A * b, H = y * S - x * _, K = y * D - A * _, j = x * D - A * S, X = I * B - M * E, W = I * N - F * E, Q = I * O - P * E, te = M * N - F * B, ee = M * O - P * B, $ = F * O - P * N, ie = z * $ - V * ee + U * te + H * Q - K * W + j * X;
    return !!ie && (ie = 1 / ie, p[0] = (_ * $ - S * ee + D * te) * ie, p[1] = (x * ee - y * $ - A * te) * ie, p[2] = (B * j - N * K + O * H) * ie, p[3] = (F * K - M * j - P * H) * ie, p[4] = (S * Q - b * $ - D * W) * ie, p[5] = (h * $ - x * Q + A * W) * ie, p[6] = (N * U - E * j - O * V) * ie, p[7] = (I * j - F * U + P * V) * ie, p[8] = (b * ee - _ * Q + D * X) * ie, p[9] = (y * Q - h * ee - A * X) * ie, p[10] = (E * K - B * U + O * z) * ie, p[11] = (M * U - I * K - P * z) * ie, p[12] = (_ * W - b * te - S * X) * ie, p[13] = (h * te - y * W + x * X) * ie, p[14] = (B * V - E * H - N * z) * ie, p[15] = (I * H - M * V + F * z) * ie, !0);
  }
  function l(p, g, h) {
    var y = g[0], x = g[1], A = g[2], b = g[3], _ = g[4], S = g[5], D = g[6], I = g[7], M = g[8], F = g[9], P = g[10], E = g[11], B = g[12], N = g[13], O = g[14], z = g[15], V = h[0], U = h[1], H = h[2], K = h[3];
    return p[0] = V * y + U * _ + H * M + K * B, p[1] = V * x + U * S + H * F + K * N, p[2] = V * A + U * D + H * P + K * O, p[3] = V * b + U * I + H * E + K * z, V = h[4], U = h[5], H = h[6], K = h[7], p[4] = V * y + U * _ + H * M + K * B, p[5] = V * x + U * S + H * F + K * N, p[6] = V * A + U * D + H * P + K * O, p[7] = V * b + U * I + H * E + K * z, V = h[8], U = h[9], H = h[10], K = h[11], p[8] = V * y + U * _ + H * M + K * B, p[9] = V * x + U * S + H * F + K * N, p[10] = V * A + U * D + H * P + K * O, p[11] = V * b + U * I + H * E + K * z, V = h[12], U = h[13], H = h[14], K = h[15], p[12] = V * y + U * _ + H * M + K * B, p[13] = V * x + U * S + H * F + K * N, p[14] = V * A + U * D + H * P + K * O, p[15] = V * b + U * I + H * E + K * z, p;
  }
  function d(p, g, h) {
    var y = h[0], x = h[1], A = h[2], b = Math.sqrt(y * y + x * x + A * A);
    if (Math.abs(b) < pn) return n(p);
    y *= b = 1 / b, x *= b, A *= b;
    var _ = Math.sin(g), S = Math.cos(g), D = 1 - S;
    return p[0] = y * y * D + S, p[1] = x * y * D + A * _, p[2] = A * y * D - x * _, p[3] = 0, p[4] = y * x * D - A * _, p[5] = x * x * D + S, p[6] = A * x * D + y * _, p[7] = 0, p[8] = y * A * D + x * _, p[9] = x * A * D - y * _, p[10] = A * A * D + S, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }
  e.isIdentity = function(p, g) {
    return o(p, a, g === void 0 ? pn : g);
  }, e.hasNaN = function(p) {
    for (var g = 0; g < 16; g++) if (isNaN(p[g])) return !0;
    return !1;
  }, e.areEqual = o, e.setValue = u, e.getValue = function(p, g, h) {
    return p[4 * h + g];
  }, e.toArray = function(p, g, h) {
    return g[h + 0] = p[0], g[h + 1] = p[1], g[h + 2] = p[2], g[h + 3] = p[3], g[h + 4] = p[4], g[h + 5] = p[5], g[h + 6] = p[6], g[h + 7] = p[7], g[h + 8] = p[8], g[h + 9] = p[9], g[h + 10] = p[10], g[h + 11] = p[11], g[h + 12] = p[12], g[h + 13] = p[13], g[h + 14] = p[14], g[h + 15] = p[15], g;
  }, e.fromArray = function(p, g, h) {
    return p[0] = g[h + 0], p[1] = g[h + 1], p[2] = g[h + 2], p[3] = g[h + 3], p[4] = g[h + 4], p[5] = g[h + 5], p[6] = g[h + 6], p[7] = g[h + 7], p[8] = g[h + 8], p[9] = g[h + 9], p[10] = g[h + 10], p[11] = g[h + 11], p[12] = g[h + 12], p[13] = g[h + 13], p[14] = g[h + 14], p[15] = g[h + 15], p;
  }, e.fromBasis = function(p, g, h, y) {
    return i(p), u(p, 0, 0, g[0]), u(p, 1, 0, g[1]), u(p, 2, 0, g[2]), u(p, 0, 1, h[0]), u(p, 1, 1, h[1]), u(p, 2, 1, h[2]), u(p, 0, 2, y[0]), u(p, 1, 2, y[1]), u(p, 2, 2, y[2]), u(p, 3, 3, 1), p;
  }, e.copy = s, e.clone = function(p) {
    return s(t(), p);
  }, e.getTranslation = function(p, g) {
    return p[0] = g[12], p[1] = g[13], p[2] = g[14], p;
  }, e.getScaling = function(p, g) {
    var h = g[0], y = g[1], x = g[2], A = g[4], b = g[5], _ = g[6], S = g[8], D = g[9], I = g[10];
    return p[0] = Math.sqrt(h * h + y * y + x * x), p[1] = Math.sqrt(A * A + b * b + _ * _), p[2] = Math.sqrt(S * S + D * D + I * I), p;
  }, e.getRotation = function(p, g) {
    var h = g[0] + g[5] + g[10], y = 0;
    return h > 0 ? (y = 2 * Math.sqrt(h + 1), p[3] = 0.25 * y, p[0] = (g[6] - g[9]) / y, p[1] = (g[8] - g[2]) / y, p[2] = (g[1] - g[4]) / y) : g[0] > g[5] && g[0] > g[10] ? (y = 2 * Math.sqrt(1 + g[0] - g[5] - g[10]), p[3] = (g[6] - g[9]) / y, p[0] = 0.25 * y, p[1] = (g[1] + g[4]) / y, p[2] = (g[8] + g[2]) / y) : g[5] > g[10] ? (y = 2 * Math.sqrt(1 + g[5] - g[0] - g[10]), p[3] = (g[8] - g[2]) / y, p[0] = (g[1] + g[4]) / y, p[1] = 0.25 * y, p[2] = (g[6] + g[9]) / y) : (y = 2 * Math.sqrt(1 + g[10] - g[0] - g[5]), p[3] = (g[1] - g[4]) / y, p[0] = (g[8] + g[2]) / y, p[1] = (g[6] + g[9]) / y, p[2] = 0.25 * y), p;
  }, e.extractRotation = function(p, g) {
    var h = 1 / Math.sqrt(g[0] * g[0] + g[1] * g[1] + g[2] * g[2]), y = 1 / Math.sqrt(g[4] * g[4] + g[5] * g[5] + g[6] * g[6]), x = 1 / Math.sqrt(g[8] * g[8] + g[9] * g[9] + g[10] * g[10]);
    return p[0] = g[0] * h, p[1] = g[1] * h, p[2] = g[2] * h, p[3] = 0, p[4] = g[4] * y, p[5] = g[5] * y, p[6] = g[6] * y, p[7] = 0, p[8] = g[8] * x, p[9] = g[9] * x, p[10] = g[10] * x, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }, e.transpose = function(p, g) {
    if (p === g) {
      var h = g[1], y = g[2], x = g[3], A = g[6], b = g[7], _ = g[11];
      p[1] = g[4], p[2] = g[8], p[3] = g[12], p[4] = h, p[6] = g[9], p[7] = g[13], p[8] = y, p[9] = A, p[11] = g[14], p[12] = x, p[13] = b, p[14] = _;
    } else p[0] = g[0], p[1] = g[4], p[2] = g[8], p[3] = g[12], p[4] = g[1], p[5] = g[5], p[6] = g[9], p[7] = g[13], p[8] = g[2], p[9] = g[6], p[10] = g[10], p[11] = g[14], p[12] = g[3], p[13] = g[7], p[14] = g[11], p[15] = g[15];
    return p;
  }, e.tryInvert = c, e.invert = function(p, g) {
    return c(p, g) || console.warn("non-invertible matrix.", g), p;
  }, e.mul = l, e.mulOffset = function(p, g, h, y, x, A) {
    var b = g[0 + x], _ = g[1 + x], S = g[2 + x], D = g[3 + x], I = g[4 + x], M = g[5 + x], F = g[6 + x], P = g[7 + x], E = g[8 + x], B = g[9 + x], N = g[10 + x], O = g[11 + x], z = g[12 + x], V = g[13 + x], U = g[14 + x], H = g[15 + x], K = h[0 + A], j = h[1 + A], X = h[2 + A], W = h[3 + A];
    return p[0 + y] = K * b + j * I + X * E + W * z, p[1 + y] = K * _ + j * M + X * B + W * V, p[2 + y] = K * S + j * F + X * N + W * U, p[3 + y] = K * D + j * P + X * O + W * H, K = h[4 + A], j = h[5 + A], X = h[6 + A], W = h[7 + A], p[4 + y] = K * b + j * I + X * E + W * z, p[5 + y] = K * _ + j * M + X * B + W * V, p[6 + y] = K * S + j * F + X * N + W * U, p[7 + y] = K * D + j * P + X * O + W * H, K = h[8 + A], j = h[9 + A], X = h[10 + A], W = h[11 + A], p[8 + y] = K * b + j * I + X * E + W * z, p[9 + y] = K * _ + j * M + X * B + W * V, p[10 + y] = K * S + j * F + X * N + W * U, p[11 + y] = K * D + j * P + X * O + W * H, K = h[12 + A], j = h[13 + A], X = h[14 + A], W = h[15 + A], p[12 + y] = K * b + j * I + X * E + W * z, p[13 + y] = K * _ + j * M + X * B + W * V, p[14 + y] = K * S + j * F + X * N + W * U, p[15 + y] = K * D + j * P + X * O + W * H, p;
  }, e.mul3 = function(p, g, h, y) {
    return l(p, l(p, g, h), y);
  }, e.translate = function(p, g, h) {
    var y, x, A, b, _, S, D, I, M, F, P, E, B = h[0], N = h[1], O = h[2];
    return g === p ? (p[12] = g[0] * B + g[4] * N + g[8] * O + g[12], p[13] = g[1] * B + g[5] * N + g[9] * O + g[13], p[14] = g[2] * B + g[6] * N + g[10] * O + g[14], p[15] = g[3] * B + g[7] * N + g[11] * O + g[15]) : (y = g[0], x = g[1], A = g[2], b = g[3], _ = g[4], S = g[5], D = g[6], I = g[7], M = g[8], F = g[9], P = g[10], E = g[11], p[0] = y, p[1] = x, p[2] = A, p[3] = b, p[4] = _, p[5] = S, p[6] = D, p[7] = I, p[8] = M, p[9] = F, p[10] = P, p[11] = E, p[12] = y * B + _ * N + M * O + g[12], p[13] = x * B + S * N + F * O + g[13], p[14] = A * B + D * N + P * O + g[14], p[15] = b * B + I * N + E * O + g[15]), p;
  }, e.fromTranslation = function(p, g) {
    return p[0] = 1, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = 1, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = 1, p[11] = 0, p[12] = g[0], p[13] = g[1], p[14] = g[2], p[15] = 1, p;
  }, e.setTranslation = function(p, g) {
    return p[12] = g[0], p[13] = g[1], p[14] = g[2], p;
  }, e.setAxes = function(p, g, h, y) {
    return p[0] = h[0], p[4] = h[1], p[8] = h[2], p[1] = y[0], p[5] = y[1], p[9] = y[2], p[2] = g[0], p[6] = g[1], p[10] = g[2], p;
  }, e.rotate = function(p, g, h, y) {
    var x = y[0], A = y[1], b = y[2], _ = Math.sqrt(x * x + A * A + b * b);
    if (Math.abs(_) < pn) return r();
    x *= _ = 1 / _, A *= _, b *= _;
    var S = Math.sin(h), D = Math.cos(h), I = 1 - D, M = g[0], F = g[1], P = g[2], E = g[3], B = g[4], N = g[5], O = g[6], z = g[7], V = g[8], U = g[9], H = g[10], K = g[11], j = x * x * I + D, X = A * x * I + b * S, W = b * x * I - A * S, Q = x * A * I - b * S, te = A * A * I + D, ee = b * A * I + x * S, $ = x * b * I + A * S, ie = A * b * I - x * S, ae = b * b * I + D;
    return p[0] = M * j + B * X + V * W, p[1] = F * j + N * X + U * W, p[2] = P * j + O * X + H * W, p[3] = E * j + z * X + K * W, p[4] = M * Q + B * te + V * ee, p[5] = F * Q + N * te + U * ee, p[6] = P * Q + O * te + H * ee, p[7] = E * Q + z * te + K * ee, p[8] = M * $ + B * ie + V * ae, p[9] = F * $ + N * ie + U * ae, p[10] = P * $ + O * ie + H * ae, p[11] = E * $ + z * ie + K * ae, g !== p && (p[12] = g[12], p[13] = g[13], p[14] = g[14], p[15] = g[15]), p;
  }, e.fromRotation = d, e.scale = function(p, g, h) {
    var y = h[0], x = h[1], A = h[2];
    return p[0] = g[0] * y, p[1] = g[1] * y, p[2] = g[2] * y, p[3] = g[3] * y, p[4] = g[4] * x, p[5] = g[5] * x, p[6] = g[6] * x, p[7] = g[7] * x, p[8] = g[8] * A, p[9] = g[9] * A, p[10] = g[10] * A, p[11] = g[11] * A, p[12] = g[12], p[13] = g[13], p[14] = g[14], p[15] = g[15], p;
  }, e.scaleUniformly = function(p, g, h) {
    return p[0] = g[0] * h, p[1] = g[1] * h, p[2] = g[2] * h, p[3] = g[3] * h, p[4] = g[4] * h, p[5] = g[5] * h, p[6] = g[6] * h, p[7] = g[7] * h, p[8] = g[8] * h, p[9] = g[9] * h, p[10] = g[10] * h, p[11] = g[11] * h, p[12] = g[12], p[13] = g[13], p[14] = g[14], p[15] = g[15], p;
  }, e.fromScaling = function(p, g) {
    return p[0] = g[0], p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = g[1], p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = g[2], p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }, e.fromUniformScaling = function(p, g) {
    return p[0] = g, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = g, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = g, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }, e.fromMat3 = function(p, g) {
    return p[0] = g[0], p[1] = g[1], p[2] = g[2], p[4] = g[3], p[5] = g[4], p[6] = g[5], p[8] = g[6], p[9] = g[7], p[10] = g[8], p;
  }, e.makeTable = function(p) {
    for (var g = "", h = 0; h < 4; h++) {
      for (var y = 0; y < 4; y++) g += p[4 * y + h].toString(), y < 3 && (g += " ");
      h < 3 && (g += `
`);
    }
    return g;
  }, e.determinant = function(p) {
    var g = p[0], h = p[1], y = p[2], x = p[3], A = p[4], b = p[5], _ = p[6], S = p[7], D = p[8], I = p[9], M = p[10], F = p[11], P = p[12], E = p[13], B = p[14], N = p[15];
    return (g * b - h * A) * (M * N - F * B) - (g * _ - y * A) * (I * N - F * E) + (g * S - x * A) * (I * B - M * E) + (h * _ - y * b) * (D * N - F * P) - (h * S - x * b) * (D * B - M * P) + (y * S - x * _) * (D * E - I * P);
  }, e.isRotationAndTranslation = function(p, g) {
    return function(h, y) {
      var x = h[0], A = h[1], b = h[2], _ = h[3], S = h[4], D = h[5], I = h[6], M = h[7], F = h[8], P = h[9], E = h[10], B = h[11], N = h[15];
      return !(!(Ln(N, 1, y) && Ln(_, 0, y) && Ln(M, 0, y) && Ln(B, 0, y)) || !Ln(Math.abs(x * (D * E - I * P) - A * (S * E - I * F) + b * (S * P - D * F)), 1, y));
    }(p, g !== void 0 ? g : pn);
  }, e.isTranslationAndUniformScaling = function(p, g) {
    return function(h, y) {
      var x = h[0];
      return Ln(h[1], 0, y) && Ln(h[2], 0, y) && Ln(h[3], 0, y) && Ln(h[4], 0, y) && Ln(h[5], x, y) && Ln(h[6], 0, y) && Ln(h[7], 0, y) && Ln(h[8], 0, y) && Ln(h[9], 0, y) && Ln(h[10], x, y) && Ln(h[11], 0, y) && Ln(h[15], 1, y);
    }(p, g !== void 0 ? g : pn);
  }, e.fromQuat = function(p, g) {
    var h = g[0], y = g[1], x = g[2], A = g[3], b = h + h, _ = y + y, S = x + x, D = h * b, I = y * b, M = y * _, F = x * b, P = x * _, E = x * S, B = A * b, N = A * _, O = A * S;
    return p[0] = 1 - M - E, p[1] = I + O, p[2] = F - N, p[3] = 0, p[4] = I - O, p[5] = 1 - D - E, p[6] = P + B, p[7] = 0, p[8] = F + N, p[9] = P - B, p[10] = 1 - D - M, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }, e.perspective = function(p, g, h, y, x, A, b) {
    var _ = 2 * A / (h - g), S = 2 * A / (y - x), D = (h + g) / (h - g), I = (y + x) / (y - x), M = -(b + A) / (b - A), F = -2 * b * A / (b - A);
    return p[0] = _, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = S, p[6] = 0, p[7] = 0, p[8] = D, p[9] = I, p[10] = M, p[11] = -1, p[12] = 0, p[13] = 0, p[14] = F, p[15] = 0, p;
  }, e.ortho = function(p, g, h, y, x, A, b) {
    var _ = 1 / (h - g), S = 1 / (y - x), D = 1 / (b - A), I = (h + g) * _, M = (y + x) * S, F = (b + A) * D;
    return p[0] = 2 * _, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = 2 * S, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = -2 * D, p[11] = 0, p[12] = -I, p[13] = -M, p[14] = -F, p[15] = 1, p;
  }, e.lookAt = function(p, g, h, y) {
    var x, A, b, _, S, D, I, M, F, P, E = g[0], B = g[1], N = g[2], O = y[0], z = y[1], V = y[2], U = h[0], H = h[1], K = h[2];
    return Math.abs(E - U) < pn && Math.abs(B - H) < pn && Math.abs(N - K) < pn ? n(p) : (I = E - U, M = B - H, F = N - K, x = z * (F *= P = 1 / Math.sqrt(I * I + M * M + F * F)) - V * (M *= P), A = V * (I *= P) - O * F, b = O * M - z * I, (P = Math.sqrt(x * x + A * A + b * b)) ? (x *= P = 1 / P, A *= P, b *= P) : (x = 0, A = 0, b = 0), _ = M * b - F * A, S = F * x - I * b, D = I * A - M * x, (P = Math.sqrt(_ * _ + S * S + D * D)) ? (_ *= P = 1 / P, S *= P, D *= P) : (_ = 0, S = 0, D = 0), p[0] = x, p[1] = _, p[2] = I, p[3] = 0, p[4] = A, p[5] = S, p[6] = M, p[7] = 0, p[8] = b, p[9] = D, p[10] = F, p[11] = 0, p[12] = -(x * E + A * B + b * N), p[13] = -(_ * E + S * B + D * N), p[14] = -(I * E + M * B + F * N), p[15] = 1, p);
  }, e.targetTo = function(p, g, h, y) {
    var x = g[0], A = g[1], b = g[2], _ = y[0], S = y[1], D = y[2], I = x - h[0], M = A - h[1], F = b - h[2], P = I * I + M * M + F * F;
    P > 0 && (I *= P = 1 / Math.sqrt(P), M *= P, F *= P);
    var E = S * F - D * M, B = D * I - _ * F, N = _ * M - S * I;
    return (P = E * E + B * B + N * N) > 0 && (E *= P = 1 / Math.sqrt(P), B *= P, N *= P), p[0] = E, p[1] = B, p[2] = N, p[3] = 0, p[4] = M * N - F * B, p[5] = F * E - I * N, p[6] = I * B - M * E, p[7] = 0, p[8] = I, p[9] = M, p[10] = F, p[11] = 0, p[12] = x, p[13] = A, p[14] = b, p[15] = 1, p;
  }, e.fromPermutation = function(p, g) {
    i(p);
    for (var h = 0; h < 4; h++)
      u(p, h, g[h], 1);
    return p;
  }, e.getMaxScaleOnAxis = function(p) {
    var g = p[0] * p[0] + p[1] * p[1] + p[2] * p[2], h = p[4] * p[4] + p[5] * p[5] + p[6] * p[6], y = p[8] * p[8] + p[9] * p[9] + p[10] * p[10];
    return Math.sqrt(Math.max(g, h, y));
  };
  var f = [1, 0, 0], m = [0, 1, 0], v = [0, 0, 1];
  e.rotX90 = d(t(), Bn(90), f), e.rotX180 = d(t(), Bn(180), f), e.rotY90 = d(t(), Bn(90), m), e.rotY180 = d(t(), Bn(180), m), e.rotY270 = d(t(), Bn(270), m), e.rotZ90 = d(t(), Bn(90), v), e.rotZ180 = d(t(), Bn(180), v), e.rotXY90 = l(t(), e.rotX90, e.rotY90), e.rotZY90 = l(t(), e.rotZ90, e.rotY90), e.rotZYZ90 = l(t(), e.rotZY90, e.rotZ90), e.rotZ90X180 = l(t(), e.rotZ90, e.rotX180), e.rotY90Z180 = l(t(), e.rotY90, e.rotZ180), e.id = r();
})(me || (me = {})), function(e) {
  function t() {
    var P = [0.1, 0, 0];
    return P[0] = 0, P;
  }
  function r(P, E, B) {
    var N = t();
    return N[0] = P, N[1] = E, N[2] = B, N;
  }
  function n(P, E) {
    return P[0] = E[0], P[1] = E[1], P[2] = E[2], P;
  }
  function i(P, E, B) {
    return P[0] = E[0] + B[0], P[1] = E[1] + B[1], P[2] = E[2] + B[2], P;
  }
  function a(P, E, B) {
    return P[0] = E[0] - B[0], P[1] = E[1] - B[1], P[2] = E[2] - B[2], P;
  }
  function o(P, E, B) {
    return P[0] = E[0] * B, P[1] = E[1] * B, P[2] = E[2] * B, P;
  }
  function u(P, E, B, N) {
    return P[0] = E[0] + B[0] * N, P[1] = E[1] + B[1] * N, P[2] = E[2] + B[2] * N, P;
  }
  function s(P) {
    var E = P[0], B = P[1], N = P[2];
    return E * E + B * B + N * N;
  }
  function c(P, E) {
    return P[0] = -E[0], P[1] = -E[1], P[2] = -E[2], P;
  }
  function l(P, E) {
    var B = E[0], N = E[1], O = E[2], z = B * B + N * N + O * O;
    return z > 0 && (z = 1 / Math.sqrt(z), P[0] = E[0] * z, P[1] = E[1] * z, P[2] = E[2] * z), P;
  }
  function d(P, E) {
    return P[0] * E[0] + P[1] * E[1] + P[2] * E[2];
  }
  function f(P, E, B) {
    var N = E[0], O = E[1], z = E[2], V = B[0], U = B[1], H = B[2];
    return P[0] = O * H - z * U, P[1] = z * V - N * H, P[2] = N * U - O * V, P;
  }
  e.zero = t, e.clone = function(P) {
    var E = t();
    return E[0] = P[0], E[1] = P[1], E[2] = P[2], E;
  }, e.hasNaN = function(P) {
    return isNaN(P[0]) || isNaN(P[1]) || isNaN(P[2]);
  }, e.setNaN = function(P) {
    return P[0] = NaN, P[1] = NaN, P[2] = NaN, P;
  }, e.fromObj = function(P) {
    return r(P.x, P.y, P.z);
  }, e.toObj = function(P) {
    return { x: P[0], y: P[1], z: P[2] };
  }, e.fromArray = function(P, E, B) {
    return P[0] = E[B + 0], P[1] = E[B + 1], P[2] = E[B + 2], P;
  }, e.toArray = function(P, E, B) {
    return E[B + 0] = P[0], E[B + 1] = P[1], E[B + 2] = P[2], E;
  }, e.create = r, e.ofArray = function(P) {
    var E = t();
    return E[0] = P[0], E[1] = P[1], E[2] = P[2], E;
  }, e.set = function(P, E, B, N) {
    return P[0] = E, P[1] = B, P[2] = N, P;
  }, e.copy = n, e.add = i, e.sub = a, e.mul = function(P, E, B) {
    return P[0] = E[0] * B[0], P[1] = E[1] * B[1], P[2] = E[2] * B[2], P;
  }, e.div = function(P, E, B) {
    return P[0] = E[0] / B[0], P[1] = E[1] / B[1], P[2] = E[2] / B[2], P;
  }, e.scale = o, e.scaleAndAdd = u, e.scaleAndSub = function(P, E, B, N) {
    return P[0] = E[0] - B[0] * N, P[1] = E[1] - B[1] * N, P[2] = E[2] - B[2] * N, P;
  }, e.addScalar = function(P, E, B) {
    return P[0] = E[0] + B, P[1] = E[1] + B, P[2] = E[2] + B, P;
  }, e.subScalar = function(P, E, B) {
    return P[0] = E[0] - B, P[1] = E[1] - B, P[2] = E[2] - B, P;
  }, e.round = function(P, E) {
    return P[0] = Math.round(E[0]), P[1] = Math.round(E[1]), P[2] = Math.round(E[2]), P;
  }, e.ceil = function(P, E) {
    return P[0] = Math.ceil(E[0]), P[1] = Math.ceil(E[1]), P[2] = Math.ceil(E[2]), P;
  }, e.floor = function(P, E) {
    return P[0] = Math.floor(E[0]), P[1] = Math.floor(E[1]), P[2] = Math.floor(E[2]), P;
  }, e.trunc = function(P, E) {
    return P[0] = Math.trunc(E[0]), P[1] = Math.trunc(E[1]), P[2] = Math.trunc(E[2]), P;
  }, e.abs = function(P, E) {
    return P[0] = Math.abs(E[0]), P[1] = Math.abs(E[1]), P[2] = Math.abs(E[2]), P;
  }, e.min = function(P, E, B) {
    return P[0] = Math.min(E[0], B[0]), P[1] = Math.min(E[1], B[1]), P[2] = Math.min(E[2], B[2]), P;
  }, e.max = function(P, E, B) {
    return P[0] = Math.max(E[0], B[0]), P[1] = Math.max(E[1], B[1]), P[2] = Math.max(E[2], B[2]), P;
  }, e.distance = function(P, E) {
    var B = E[0] - P[0], N = E[1] - P[1], O = E[2] - P[2];
    return Math.sqrt(B * B + N * N + O * O);
  }, e.squaredDistance = function(P, E) {
    var B = E[0] - P[0], N = E[1] - P[1], O = E[2] - P[2];
    return B * B + N * N + O * O;
  }, e.magnitude = function(P) {
    var E = P[0], B = P[1], N = P[2];
    return Math.sqrt(E * E + B * B + N * N);
  }, e.squaredMagnitude = s, e.setMagnitude = function(P, E, B) {
    return o(P, l(P, E), B);
  }, e.negate = c, e.inverse = function(P, E) {
    return P[0] = 1 / E[0], P[1] = 1 / E[1], P[2] = 1 / E[2], P;
  }, e.normalize = l, e.dot = d, e.cross = f, e.lerp = function(P, E, B, N) {
    var O = E[0], z = E[1], V = E[2];
    return P[0] = O + N * (B[0] - O), P[1] = z + N * (B[1] - z), P[2] = V + N * (B[2] - V), P;
  };
  var m = t();
  function v(P, E) {
    var B = Math.sqrt(s(P) * s(E));
    if (B === 0) return Math.PI / 2;
    var N = d(P, E) / B;
    return Math.acos(Qa(N, -1, 1));
  }
  e.slerp = function(P, E, B, N) {
    var O = Qa(d(E, B), -1, 1), z = Math.acos(O) * N;
    return u(m, B, E, -O), l(m, m), i(P, o(P, E, Math.cos(z)), o(m, m, Math.sin(z)));
  }, e.hermite = function(P, E, B, N, O, z) {
    var V = z * z, U = V * (2 * z - 3) + 1, H = V * (z - 2) + z, K = V * (z - 1), j = V * (3 - 2 * z);
    return P[0] = E[0] * U + B[0] * H + N[0] * K + O[0] * j, P[1] = E[1] * U + B[1] * H + N[1] * K + O[1] * j, P[2] = E[2] * U + B[2] * H + N[2] * K + O[2] * j, P;
  }, e.bezier = function(P, E, B, N, O, z) {
    var V = 1 - z, U = V * V, H = z * z, K = U * V, j = 3 * z * U, X = 3 * H * V, W = H * z;
    return P[0] = E[0] * K + B[0] * j + N[0] * X + O[0] * W, P[1] = E[1] * K + B[1] * j + N[1] * X + O[1] * W, P[2] = E[2] * K + B[2] * j + N[2] * X + O[2] * W, P;
  }, e.quadraticBezier = function(P, E, B, N, O) {
    return P[0] = wy(E[0], B[0], N[0], O), P[1] = wy(E[1], B[1], N[1], O), P[2] = wy(E[2], B[2], N[2], O), P;
  }, e.spline = function(P, E, B, N, O, z, V) {
    return P[0] = Yv(E[0], B[0], N[0], O[0], z, V), P[1] = Yv(E[1], B[1], N[1], O[1], z, V), P[2] = Yv(E[2], B[2], N[2], O[2], z, V), P;
  }, e.random = function(P, E) {
    var B = 2 * Math.random() * Math.PI, N = 2 * Math.random() - 1, O = Math.sqrt(1 - N * N) * E;
    return P[0] = Math.cos(B) * O, P[1] = Math.sin(B) * O, P[2] = N * E, P;
  }, e.transformMat4 = function(P, E, B) {
    var N = E[0], O = E[1], z = E[2], V = 1 / (B[3] * N + B[7] * O + B[11] * z + B[15] || 1);
    return P[0] = (B[0] * N + B[4] * O + B[8] * z + B[12]) * V, P[1] = (B[1] * N + B[5] * O + B[9] * z + B[13]) * V, P[2] = (B[2] * N + B[6] * O + B[10] * z + B[14]) * V, P;
  }, e.transformMat4Offset = function(P, E, B, N, O, z) {
    var V = E[0 + O], U = E[1 + O], H = E[2 + O], K = 1 / (B[3 + z] * V + B[7 + z] * U + B[11 + z] * H + B[15 + z] || 1);
    return P[0 + N] = (B[0 + z] * V + B[4 + z] * U + B[8 + z] * H + B[12 + z]) * K, P[1 + N] = (B[1 + z] * V + B[5 + z] * U + B[9 + z] * H + B[13 + z]) * K, P[2 + N] = (B[2 + z] * V + B[6 + z] * U + B[10 + z] * H + B[14 + z]) * K, P;
  }, e.transformMat3 = function(P, E, B) {
    var N = E[0], O = E[1], z = E[2];
    return P[0] = N * B[0] + O * B[3] + z * B[6], P[1] = N * B[1] + O * B[4] + z * B[7], P[2] = N * B[2] + O * B[5] + z * B[8], P;
  }, e.transformQuat = function(P, E, B) {
    var N = E[0], O = E[1], z = E[2], V = B[0], U = B[1], H = B[2], K = B[3], j = K * N + U * z - H * O, X = K * O + H * N - V * z, W = K * z + V * O - U * N, Q = -V * N - U * O - H * z;
    return P[0] = j * K + Q * -V + X * -H - W * -U, P[1] = X * K + Q * -U + W * -V - j * -H, P[2] = W * K + Q * -H + j * -U - X * -V, P;
  }, e.angle = v;
  var p = t(), g = t(), h = t(), y = t(), x = t(), A = t(), b = t();
  e.dihedralAngle = function(P, E, B, N) {
    a(p, P, E), a(g, B, E), a(h, E, B), a(y, N, B), f(x, p, g), f(A, h, y);
    var O = v(x, A);
    return f(b, x, A), d(g, b) > 0 ? O : -O;
  }, e.directionFromSpherical = function(P, E, B, N) {
    return e.set(P, N * Math.cos(B) * Math.sin(E), N * Math.sin(B) * Math.sin(E), N * Math.cos(E));
  }, e.exactEquals = function(P, E) {
    return P[0] === E[0] && P[1] === E[1] && P[2] === E[2];
  }, e.equals = function(P, E) {
    var B = P[0], N = P[1], O = P[2], z = E[0], V = E[1], U = E[2];
    return Math.abs(B - z) <= pn * Math.max(1, Math.abs(B), Math.abs(z)) && Math.abs(N - V) <= pn * Math.max(1, Math.abs(N), Math.abs(V)) && Math.abs(O - U) <= pn * Math.max(1, Math.abs(O), Math.abs(U));
  };
  var _ = t();
  e.makeRotation = function(P, E, B) {
    var N = v(E, B);
    if (Math.abs(N) < 1e-4) return me.setIdentity(P);
    if (Math.abs(N - Math.PI) < pn) return me.fromScaling(P, e.negUnit);
    var O = f(_, E, B);
    return me.fromRotation(P, N, O);
  }, e.isZero = function(P) {
    return P[0] === 0 && P[1] === 0 && P[2] === 0;
  }, e.projectPointOnVector = function(P, E, B, N) {
    return a(P, E, N), i(P, o(P, B, d(B, P) / s(B)), N);
  };
  var S = t();
  function D(P, E, B) {
    return o(P, B, d(B, E) / s(B));
  }
  e.projectPointOnPlane = function(P, E, B, N) {
    return l(S, B), a(P, E, N), a(P, E, o(S, S, d(P, S)));
  }, e.projectOnVector = D;
  var I = t();
  e.projectOnPlane = function(P, E, B) {
    return D(I, E, B), a(P, E, I);
  }, e.orthogonalize = function(P, E, B) {
    return l(P, f(P, f(P, E, B), E));
  }, e.matchDirection = function(P, E, B) {
    return d(E, B) > 0 ? n(P, E) : c(P, n(P, E)), P;
  };
  var M = t(), F = t();
  e.triangleNormal = function(P, E, B, N) {
    return a(M, B, E), a(F, N, E), l(P, f(P, M, F));
  }, e.toString = function(P, E) {
    return "[".concat(P[0].toPrecision(E), " ").concat(P[1].toPrecision(E), " ").concat(P[2].toPrecision(E), "]");
  }, e.origin = r(0, 0, 0), e.unit = r(1, 1, 1), e.negUnit = r(-1, -1, -1), e.unitX = r(1, 0, 0), e.unitY = r(0, 1, 0), e.unitZ = r(0, 0, 1), e.negUnitX = r(-1, 0, 0), e.negUnitY = r(0, -1, 0), e.negUnitZ = r(0, 0, -1);
}(w || (w = {})), function(e) {
  function t() {
    var b = [0.1, 0, 0, 0, 0, 0, 0, 0, 0];
    return b[0] = 0, b;
  }
  function r() {
    var b = t();
    return b[0] = 1, b[1] = 0, b[2] = 0, b[3] = 0, b[4] = 1, b[5] = 0, b[6] = 0, b[7] = 0, b[8] = 1, b;
  }
  function n(b, _) {
    return b[0] = _[0], b[1] = _[1], b[2] = _[2], b[3] = _[4], b[4] = _[5], b[5] = _[6], b[6] = _[8], b[7] = _[9], b[8] = _[10], b;
  }
  e.zero = t, e.identity = r, e.setIdentity = function(b) {
    return b[0] = 1, b[1] = 0, b[2] = 0, b[3] = 0, b[4] = 1, b[5] = 0, b[6] = 0, b[7] = 0, b[8] = 1, b;
  }, e.toArray = function(b, _, S) {
    return _[S + 0] = b[0], _[S + 1] = b[1], _[S + 2] = b[2], _[S + 3] = b[3], _[S + 4] = b[4], _[S + 5] = b[5], _[S + 6] = b[6], _[S + 7] = b[7], _[S + 8] = b[8], _;
  }, e.fromArray = function(b, _, S) {
    return b[0] = _[S + 0], b[1] = _[S + 1], b[2] = _[S + 2], b[3] = _[S + 3], b[4] = _[S + 4], b[5] = _[S + 5], b[6] = _[S + 6], b[7] = _[S + 7], b[8] = _[S + 8], b;
  }, e.fromMat4 = n, e.create = function(b, _, S, D, I, M, F, P, E) {
    var B = t();
    return B[0] = b, B[1] = _, B[2] = S, B[3] = D, B[4] = I, B[5] = M, B[6] = F, B[7] = P, B[8] = E, B;
  };
  var i = r();
  function a(b, _, S) {
    for (var D = 0; D < 9; D++) if (Math.abs(b[D] - _[D]) > S) return !1;
    return !0;
  }
  function o(b, _) {
    return b[0] = _[0], b[1] = _[1], b[2] = _[2], b[3] = _[3], b[4] = _[4], b[5] = _[5], b[6] = _[6], b[7] = _[7], b[8] = _[8], b;
  }
  function u(b, _) {
    if (b === _) {
      var S = _[1], D = _[2], I = _[5];
      b[1] = _[3], b[2] = _[6], b[3] = S, b[5] = _[7], b[6] = D, b[7] = I;
    } else b[0] = _[0], b[1] = _[3], b[2] = _[6], b[3] = _[1], b[4] = _[4], b[5] = _[7], b[6] = _[2], b[7] = _[5], b[8] = _[8];
    return b;
  }
  function s(b, _) {
    var S = _[0], D = _[1], I = _[2], M = _[3], F = _[4], P = _[5], E = _[6], B = _[7], N = _[8], O = N * F - P * B, z = -N * M + P * E, V = B * M - F * E, U = S * O + D * z + I * V;
    return U ? (U = 1 / U, b[0] = O * U, b[1] = (-N * D + I * B) * U, b[2] = (P * D - I * F) * U, b[3] = z * U, b[4] = (N * S - I * E) * U, b[5] = (-P * S + I * M) * U, b[6] = V * U, b[7] = (-B * S + D * E) * U, b[8] = (F * S - D * M) * U, b) : (console.warn("non-invertible matrix.", _), b);
  }
  function c(b) {
    var _ = b[0], S = b[1], D = b[2], I = b[3], M = b[4], F = b[5], P = b[6], E = b[7], B = b[8];
    return _ * (B * M - F * E) + S * (-B * I + F * P) + D * (E * I - M * P);
  }
  function l(b) {
    return b[0] + b[4] + b[8];
  }
  function d(b, _, S) {
    return b[0] = _[0] - S[0], b[1] = _[1] - S[1], b[2] = _[2] - S[2], b[3] = _[3] - S[3], b[4] = _[4] - S[4], b[5] = _[5] - S[5], b[6] = _[6] - S[6], b[7] = _[7] - S[7], b[8] = _[8] - S[8], b;
  }
  function f(b, _, S) {
    return b[0] = _[0] * S, b[1] = _[1] * S, b[2] = _[2] * S, b[3] = _[3] * S, b[4] = _[4] * S, b[5] = _[5] * S, b[6] = _[6] * S, b[7] = _[7] * S, b[8] = _[8] * S, b;
  }
  e.isIdentity = function(b, _) {
    return a(b, i, _ === void 0 ? pn : _);
  }, e.hasNaN = function(b) {
    for (var _ = 0; _ < 9; _++) if (isNaN(b[_])) return !0;
    return !1;
  }, e.clone = function(b) {
    return o(t(), b);
  }, e.areEqual = a, e.setValue = function(b, _, S, D) {
    b[3 * S + _] = D;
  }, e.getValue = function(b, _, S) {
    return b[3 * S + _];
  }, e.copy = o, e.transpose = u, e.invert = s, e.symmtricFromUpper = function(b, _) {
    return b === _ ? (b[3] = _[1], b[6] = _[2], b[7] = _[5]) : (b[0] = _[0], b[1] = _[1], b[2] = _[2], b[3] = _[1], b[4] = _[4], b[5] = _[5], b[6] = _[2], b[7] = _[5], b[8] = _[8]), b;
  }, e.symmtricFromLower = function(b, _) {
    return b === _ ? (b[1] = _[3], b[2] = _[6], b[5] = _[7]) : (b[0] = _[0], b[1] = _[3], b[2] = _[6], b[3] = _[3], b[4] = _[4], b[5] = _[7], b[6] = _[6], b[7] = _[7], b[8] = _[8]), b;
  }, e.determinant = c, e.trace = l, e.sub = d, e.add = function(b, _, S) {
    return b[0] = _[0] + S[0], b[1] = _[1] + S[1], b[2] = _[2] + S[2], b[3] = _[3] + S[3], b[4] = _[4] + S[4], b[5] = _[5] + S[5], b[6] = _[6] + S[6], b[7] = _[7] + S[7], b[8] = _[8] + S[8], b;
  }, e.mul = function(b, _, S) {
    var D = _[0], I = _[1], M = _[2], F = _[3], P = _[4], E = _[5], B = _[6], N = _[7], O = _[8], z = S[0], V = S[1], U = S[2], H = S[3], K = S[4], j = S[5], X = S[6], W = S[7], Q = S[8];
    return b[0] = z * D + V * F + U * B, b[1] = z * I + V * P + U * N, b[2] = z * M + V * E + U * O, b[3] = H * D + K * F + j * B, b[4] = H * I + K * P + j * N, b[5] = H * M + K * E + j * O, b[6] = X * D + W * F + Q * B, b[7] = X * I + W * P + Q * N, b[8] = X * M + W * E + Q * O, b;
  }, e.subScalar = function(b, _, S) {
    return b[0] = _[0] - S, b[1] = _[1] - S, b[2] = _[2] - S, b[3] = _[3] - S, b[4] = _[4] - S, b[5] = _[5] - S, b[6] = _[6] - S, b[7] = _[7] - S, b[8] = _[8] - S, b;
  }, e.addScalar = function(b, _, S) {
    return b[0] = _[0] + S, b[1] = _[1] + S, b[2] = _[2] + S, b[3] = _[3] + S, b[4] = _[4] + S, b[5] = _[5] + S, b[6] = _[6] + S, b[7] = _[7] + S, b[8] = _[8] + S, b;
  }, e.mulScalar = f;
  var m = Math.PI / 3, v = t();
  e.symmetricEigenvalues = function(b, _) {
    var S = _[1] * _[1] + _[2] * _[2] + _[5] * _[5];
    if (S === 0) b[0] = _[0], b[1] = _[4], b[2] = _[8];
    else {
      var D = l(_) / 3, I = _[0] - D, M = _[4] - D, F = _[8] - D, P = I * I + M * M + F * F + 2 * S, E = Math.sqrt(P / 6);
      f(v, e.Identity, D), d(v, _, v), f(v, v, 1 / E);
      var B = c(v) / 2, N = B <= -1 ? m : B >= 1 ? 0 : Math.acos(B) / 3;
      b[0] = D + 2 * E * Math.cos(N), b[2] = D + 2 * E * Math.cos(N + 2 * m), b[1] = 3 * D - b[0] - b[2];
    }
    return b;
  };
  var p = [0.1, 0, 0], g = [0.1, 0, 0], h = [0.1, 0, 0], y = [0.1, 0, 0], x = [0.1, 0, 0], A = [0.1, 0, 0];
  e.eigenvector = function(b, _, S) {
    w.set(p, _[0] - S, _[1], _[2]), w.set(g, _[1], _[4] - S, _[5]), w.set(h, _[2], _[5], _[8] - S), w.cross(y, p, g), w.cross(x, p, h), w.cross(A, g, h);
    var D = w.dot(y, y), I = w.dot(x, x), M = w.dot(A, A), F = D, P = 0;
    return I > F && (F = I, P = 1), M > F && (P = 2), P === 0 ? w.scale(b, y, 1 / Math.sqrt(D)) : P === 1 ? w.scale(b, x, 1 / Math.sqrt(I)) : w.scale(b, A, 1 / Math.sqrt(M)), b;
  }, e.directionTransform = function(b, _) {
    return n(b, _), s(b, b), u(b, b), b;
  }, e.Identity = r();
}(Ti || (Ti = {})), function(e) {
  function t() {
    var r = [0.1, 0];
    return r[0] = 0, r;
  }
  e.zero = t, e.clone = function(r) {
    var n = t();
    return n[0] = r[0], n[1] = r[1], n;
  }, e.create = function(r, n) {
    var i = t();
    return i[0] = r, i[1] = n, i;
  }, e.hasNaN = function(r) {
    return isNaN(r[0]) || isNaN(r[1]);
  }, e.toArray = function(r, n, i) {
    return n[i + 0] = r[0], n[i + 1] = r[1], n;
  }, e.fromArray = function(r, n, i) {
    return r[0] = n[i + 0], r[1] = n[i + 1], r;
  }, e.copy = function(r, n) {
    return r[0] = n[0], r[1] = n[1], r;
  }, e.set = function(r, n, i) {
    return r[0] = n, r[1] = i, r;
  }, e.add = function(r, n, i) {
    return r[0] = n[0] + i[0], r[1] = n[1] + i[1], r;
  }, e.sub = function(r, n, i) {
    return r[0] = n[0] - i[0], r[1] = n[1] - i[1], r;
  }, e.mul = function(r, n, i) {
    return r[0] = n[0] * i[0], r[1] = n[1] * i[1], r;
  }, e.div = function(r, n, i) {
    return r[0] = n[0] / i[0], r[1] = n[1] / i[1], r;
  }, e.scale = function(r, n, i) {
    return r[0] = n[0] * i, r[1] = n[1] * i, r;
  }, e.round = function(r, n) {
    return r[0] = Math.round(n[0]), r[1] = Math.round(n[1]), r;
  }, e.ceil = function(r, n) {
    return r[0] = Math.ceil(n[0]), r[1] = Math.ceil(n[1]), r;
  }, e.floor = function(r, n) {
    return r[0] = Math.floor(n[0]), r[1] = Math.floor(n[1]), r;
  }, e.distance = function(r, n) {
    var i = n[0] - r[0], a = n[1] - r[1];
    return Math.sqrt(i * i + a * a);
  }, e.squaredDistance = function(r, n) {
    var i = n[0] - r[0], a = n[1] - r[1];
    return i * i + a * a;
  }, e.magnitude = function(r) {
    var n = r[0], i = r[1];
    return Math.sqrt(n * n + i * i);
  }, e.squaredMagnitude = function(r) {
    var n = r[0], i = r[1];
    return n * n + i * i;
  }, e.inverse = function(r, n) {
    return r[0] = 1 / n[0], r[1] = 1 / n[1], r;
  }, e.areEqual = function(r, n) {
    return r[0] === n[0] && r[1] === n[1];
  }, e.toString = function(r, n) {
    return "[".concat(r[0].toPrecision(n), " ").concat(r[1].toPrecision(n), "}]");
  }, e.normalize = function(r, n) {
    var i = n[0], a = n[1], o = i * i + a * a;
    return o > 0 && (o = 1 / Math.sqrt(o), r[0] = n[0] * o, r[1] = n[1] * o), r;
  };
}(ke || (ke = {})), function(e) {
  function t() {
    var n = [0.1, 0, 0, 0];
    return n[0] = 0, n;
  }
  function r(n, i) {
    return n[0] = i.center[0], n[1] = i.center[1], n[2] = i.center[2], n[3] = i.radius, n;
  }
  e.zero = t, e.clone = function(n) {
    var i = t();
    return i[0] = n[0], i[1] = n[1], i[2] = n[2], i[3] = n[3], i;
  }, e.create = function(n, i, a, o) {
    var u = t();
    return u[0] = n, u[1] = i, u[2] = a, u[3] = o, u;
  }, e.fromSphere = r, e.ofSphere = function(n) {
    return r(t(), n);
  }, e.hasNaN = function(n) {
    return isNaN(n[0]) || isNaN(n[1]) || isNaN(n[2]) || isNaN(n[3]);
  }, e.toArray = function(n, i, a) {
    return i[a + 0] = n[0], i[a + 1] = n[1], i[a + 2] = n[2], i[a + 3] = n[3], i;
  }, e.fromArray = function(n, i, a) {
    return n[0] = i[a + 0], n[1] = i[a + 1], n[2] = i[a + 2], n[3] = i[a + 3], n;
  }, e.toVec3Array = function(n, i, a) {
    i[a + 0] = n[0], i[a + 1] = n[1], i[a + 2] = n[2];
  }, e.fromVec3Array = function(n, i, a) {
    return n[0] = i[a + 0], n[1] = i[a + 1], n[2] = i[a + 2], n[3] = 0, n;
  }, e.copy = function(n, i) {
    return n[0] = i[0], n[1] = i[1], n[2] = i[2], n[3] = i[3], n;
  }, e.set = function(n, i, a, o, u) {
    return n[0] = i, n[1] = a, n[2] = o, n[3] = u, n;
  }, e.add = function(n, i, a) {
    return n[0] = i[0] + a[0], n[1] = i[1] + a[1], n[2] = i[2] + a[2], n[3] = i[3] + a[3], n;
  }, e.distance = function(n, i) {
    var a = i[0] - n[0], o = i[1] - n[1], u = i[2] - n[2], s = i[3] - n[3];
    return Math.sqrt(a * a + o * o + u * u + s * s);
  }, e.scale = function(n, i, a) {
    return n[0] = i[0] * a, n[1] = i[1] * a, n[2] = i[2] * a, n[4] = i[4] * a, n;
  }, e.round = function(n, i) {
    return n[0] = Math.round(i[0]), n[1] = Math.round(i[1]), n[2] = Math.round(i[2]), n[3] = Math.round(i[3]), n;
  }, e.ceil = function(n, i) {
    return n[0] = Math.ceil(i[0]), n[1] = Math.ceil(i[1]), n[2] = Math.ceil(i[2]), n[3] = Math.ceil(i[3]), n;
  }, e.floor = function(n, i) {
    return n[0] = Math.floor(i[0]), n[1] = Math.floor(i[1]), n[2] = Math.floor(i[2]), n[3] = Math.floor(i[3]), n;
  }, e.squaredDistance = function(n, i) {
    var a = i[0] - n[0], o = i[1] - n[1], u = i[2] - n[2], s = i[3] - n[3];
    return a * a + o * o + u * u + s * s;
  }, e.norm = function(n) {
    var i = n[0], a = n[1], o = n[2], u = n[3];
    return Math.sqrt(i * i + a * a + o * o + u * u);
  }, e.squaredNorm = function(n) {
    var i = n[0], a = n[1], o = n[2], u = n[3];
    return i * i + a * a + o * o + u * u;
  }, e.transformMat4 = function(n, i, a) {
    var o = i[0], u = i[1], s = i[2], c = i[3];
    return n[0] = a[0] * o + a[4] * u + a[8] * s + a[12] * c, n[1] = a[1] * o + a[5] * u + a[9] * s + a[13] * c, n[2] = a[2] * o + a[6] * u + a[10] * s + a[14] * c, n[3] = a[3] * o + a[7] * u + a[11] * s + a[15] * c, n;
  }, e.dot = function(n, i) {
    return n[0] * i[0] + n[1] * i[1] + n[2] * i[2] + n[3] * i[3];
  }, e.inverse = function(n, i) {
    return n[0] = 1 / i[0], n[1] = 1 / i[1], n[2] = 1 / i[2], n[3] = 1 / i[3], n;
  }, e.exactEquals = function(n, i) {
    return n[0] === i[0] && n[1] === i[1] && n[2] === i[2] && n[3] === i[3];
  }, e.equals = function(n, i) {
    var a = n[0], o = n[1], u = n[2], s = n[3], c = i[0], l = i[1], d = i[2], f = i[3];
    return Math.abs(a - c) <= pn * Math.max(1, Math.abs(a), Math.abs(c)) && Math.abs(o - l) <= pn * Math.max(1, Math.abs(o), Math.abs(l)) && Math.abs(u - d) <= pn * Math.max(1, Math.abs(u), Math.abs(d)) && Math.abs(s - f) <= pn * Math.max(1, Math.abs(s), Math.abs(f));
  }, e.toString = function(n, i) {
    return "[".concat(n[0].toPrecision(i), " ").concat(n[1].toPrecision(i), " ").concat(n[2].toPrecision(i), "  ").concat(n[3].toPrecision(i), "]");
  };
}(Vt || (Vt = {})), function(e) {
  function t() {
    var v = [0.1, 0, 0, 0];
    return v[0] = 0, v;
  }
  function r() {
    var v = t();
    return v[3] = 1, v;
  }
  function n(v, p, g) {
    g *= 0.5;
    var h = Math.sin(g);
    return v[0] = h * p[0], v[1] = h * p[1], v[2] = h * p[2], v[3] = Math.cos(g), v;
  }
  function i(v, p, g, h) {
    var y, x, A, b, _, S = p[0], D = p[1], I = p[2], M = p[3], F = g[0], P = g[1], E = g[2], B = g[3];
    return (x = S * F + D * P + I * E + M * B) < 0 && (x = -x, F = -F, P = -P, E = -E, B = -B), 1 - x > 1e-6 ? (y = Math.acos(x), A = Math.sin(y), b = Math.sin((1 - h) * y) / A, _ = Math.sin(h * y) / A) : (b = 1 - h, _ = h), v[0] = b * S + _ * F, v[1] = b * D + _ * P, v[2] = b * I + _ * E, v[3] = b * M + _ * B, v;
  }
  function a(v, p) {
    var g, h = p[0] + p[4] + p[8];
    if (h > 0) g = Math.sqrt(h + 1), v[3] = 0.5 * g, g = 0.5 / g, v[0] = (p[5] - p[7]) * g, v[1] = (p[6] - p[2]) * g, v[2] = (p[1] - p[3]) * g;
    else {
      var y = 0;
      p[4] > p[0] && (y = 1), p[8] > p[3 * y + y] && (y = 2);
      var x = (y + 1) % 3, A = (y + 2) % 3;
      g = Math.sqrt(p[3 * y + y] - p[3 * x + x] - p[3 * A + A] + 1), v[y] = 0.5 * g, g = 0.5 / g, v[3] = (p[3 * x + A] - p[3 * A + x]) * g, v[x] = (p[3 * x + y] + p[3 * y + x]) * g, v[A] = (p[3 * A + y] + p[3 * y + A]) * g;
    }
    return v;
  }
  e.zero = t, e.identity = r, e.setIdentity = function(v) {
    v[0] = 0, v[1] = 0, v[2] = 0, v[3] = 1;
  }, e.hasNaN = function(v) {
    return isNaN(v[0]) || isNaN(v[1]) || isNaN(v[2]) || isNaN(v[3]);
  }, e.create = function(v, p, g, h) {
    var y = r();
    return y[0] = v, y[1] = p, y[2] = g, y[3] = h, y;
  }, e.setAxisAngle = n, e.getAxisAngle = function(v, p) {
    var g = 2 * Math.acos(p[3]), h = Math.sin(g / 2);
    return h !== 0 ? (v[0] = p[0] / h, v[1] = p[1] / h, v[2] = p[2] / h) : (v[0] = 1, v[1] = 0, v[2] = 0), g;
  }, e.multiply = function(v, p, g) {
    var h = p[0], y = p[1], x = p[2], A = p[3], b = g[0], _ = g[1], S = g[2], D = g[3];
    return v[0] = h * D + A * b + y * S - x * _, v[1] = y * D + A * _ + x * b - h * S, v[2] = x * D + A * S + h * _ - y * b, v[3] = A * D - h * b - y * _ - x * S, v;
  }, e.rotateX = function(v, p, g) {
    g *= 0.5;
    var h = p[0], y = p[1], x = p[2], A = p[3], b = Math.sin(g), _ = Math.cos(g);
    return v[0] = h * _ + A * b, v[1] = y * _ + x * b, v[2] = x * _ - y * b, v[3] = A * _ - h * b, v;
  }, e.rotateY = function(v, p, g) {
    g *= 0.5;
    var h = p[0], y = p[1], x = p[2], A = p[3], b = Math.sin(g), _ = Math.cos(g);
    return v[0] = h * _ - x * b, v[1] = y * _ + A * b, v[2] = x * _ + h * b, v[3] = A * _ - y * b, v;
  }, e.rotateZ = function(v, p, g) {
    g *= 0.5;
    var h = p[0], y = p[1], x = p[2], A = p[3], b = Math.sin(g), _ = Math.cos(g);
    return v[0] = h * _ + y * b, v[1] = y * _ - h * b, v[2] = x * _ + A * b, v[3] = A * _ - x * b, v;
  }, e.calculateW = function(v, p) {
    var g = p[0], h = p[1], y = p[2];
    return v[0] = g, v[1] = h, v[2] = y, v[3] = Math.sqrt(Math.abs(1 - g * g - h * h - y * y)), v;
  }, e.slerp = i, e.invert = function(v, p) {
    var g = p[0], h = p[1], y = p[2], x = p[3], A = g * g + h * h + y * y + x * x, b = A ? 1 / A : 0;
    return v[0] = -g * b, v[1] = -h * b, v[2] = -y * b, v[3] = x * b, v;
  }, e.conjugate = function(v, p) {
    return v[0] = -p[0], v[1] = -p[1], v[2] = -p[2], v[3] = p[3], v;
  }, e.fromMat3 = a;
  var o = [0, 0, 0];
  function u(v, p) {
    var g = p[0], h = p[1], y = p[2], x = p[3], A = g * g + h * h + y * y + x * x;
    return A > 0 && (A = 1 / Math.sqrt(A), v[0] = g * A, v[1] = h * A, v[2] = y * A, v[3] = x * A), v;
  }
  e.fromUnitVec3 = function(v, p, g) {
    var h = w.dot(p, g) + 1;
    return h < pn ? (h = 0, Math.abs(p[0]) > Math.abs(p[2]) ? w.set(o, -p[1], p[0], 0) : w.set(o, 0, -p[2], p[1])) : w.cross(o, p, g), v[0] = o[0], v[1] = o[1], v[2] = o[2], v[3] = h, u(v, v), v;
  }, e.clone = function(v) {
    var p = t();
    return p[0] = v[0], p[1] = v[1], p[2] = v[2], p[3] = v[3], p;
  }, e.toArray = function(v, p, g) {
    return p[g + 0] = v[0], p[g + 1] = v[1], p[g + 2] = v[2], p[g + 3] = v[3], p;
  }, e.fromArray = function(v, p, g) {
    return v[0] = p[g + 0], v[1] = p[g + 1], v[2] = p[g + 2], v[3] = p[g + 3], v;
  }, e.copy = function(v, p) {
    return v[0] = p[0], v[1] = p[1], v[2] = p[2], v[3] = p[3], v;
  }, e.set = function(v, p, g, h, y) {
    return v[0] = p, v[1] = g, v[2] = h, v[3] = y, v;
  }, e.exactEquals = function(v, p) {
    return v[0] === p[0] && v[1] === p[1] && v[2] === p[2] && v[3] === p[3];
  }, e.equals = function(v, p) {
    var g = v[0], h = v[1], y = v[2], x = v[3], A = p[0], b = p[1], _ = p[2], S = p[3];
    return Math.abs(g - A) <= pn * Math.max(1, Math.abs(g), Math.abs(A)) && Math.abs(h - b) <= pn * Math.max(1, Math.abs(h), Math.abs(b)) && Math.abs(y - _) <= pn * Math.max(1, Math.abs(y), Math.abs(_)) && Math.abs(x - S) <= pn * Math.max(1, Math.abs(x), Math.abs(S));
  }, e.add = function(v, p, g) {
    return v[0] = p[0] + g[0], v[1] = p[1] + g[1], v[2] = p[2] + g[2], v[3] = p[3] + g[3], v;
  }, e.normalize = u;
  var s = [0, 0, 0], c = [1, 0, 0], l = [0, 1, 0];
  e.rotationTo = function(v, p, g) {
    var h = w.dot(p, g);
    return h < -0.999999 ? (w.cross(s, c, p), w.magnitude(s) < 1e-6 && w.cross(s, l, p), w.normalize(s, s), n(v, s, Math.PI), v) : h > 0.999999 ? (v[0] = 0, v[1] = 0, v[2] = 0, v[3] = 1, v) : (w.cross(s, p, g), v[0] = s[0], v[1] = s[1], v[2] = s[2], v[3] = 1 + h, u(v, v));
  };
  var d = t(), f = t();
  e.sqlerp = function(v, p, g, h, y, x) {
    return i(d, p, y, x), i(f, g, h, x), i(v, d, f, 2 * x * (1 - x)), v;
  };
  var m = [0, 0, 0, 0, 0, 0, 0, 0, 0];
  e.setAxes = function(v, p, g, h) {
    return m[0] = g[0], m[3] = g[1], m[6] = g[2], m[1] = h[0], m[4] = h[1], m[7] = h[2], m[2] = -p[0], m[5] = -p[1], m[8] = -p[2], u(v, a(v, m));
  }, e.toString = function(v, p) {
    return "[".concat(v[0].toPrecision(p), " ").concat(v[1].toPrecision(p), " ").concat(v[2].toPrecision(p), "  ").concat(v[3].toPrecision(p), "]");
  }, e.Identity = r();
}(In || (In = {})), function(e) {
  function t(o, u, s) {
    var c = function(g, h, y) {
      for (var x = [], A = 0; A < h.length; A++) x[A] = h[h.length - A - 1];
      var b = [1];
      for (A = 1; A < g.length; A++) b[A] = g[x[A - 1]];
      return { dimensions: g, axisOrderFastToSlow: x, axisOrderSlowToFast: h, accessDimensions: b, defaultCtor: y || Float64Array };
    }(o, u, s), l = r(c), d = l.get, f = l.set, m = l.add, v = l.dataOffset, p = l.getCoords;
    return { rank: o.length, dimensions: o, axisOrderSlowToFast: u, create: n(c), get: d, set: f, add: m, dataOffset: v, getCoords: p };
  }
  function r(o) {
    var u = o.dimensions, s = o.axisOrderFastToSlow;
    switch (u.length) {
      case 1:
        return { get: function(E, B) {
          return E[B];
        }, set: function(E, B, N) {
          return E[B] = N;
        }, add: function(E, B, N) {
          return E[B] += N;
        }, dataOffset: function(E) {
          return E;
        }, getCoords: function(E, B) {
          return B[0] = E, B;
        } };
      case 2:
        if (s[0] === 0 && s[1] === 1) {
          var c = u[0];
          return { get: function(E, B, N) {
            return E[N * c + B];
          }, set: function(E, B, N, O) {
            return E[N * c + B] = O;
          }, add: function(E, B, N, O) {
            return E[N * c + B] += O;
          }, dataOffset: function(E, B) {
            return B * c + E;
          }, getCoords: function(E, B) {
            return B[0] = E % c, B[1] = Math.floor(E / c), B;
          } };
        }
        if (s[0] === 1 && s[1] === 0) {
          var l = u[1];
          return { get: function(E, B, N) {
            return E[B * l + N];
          }, set: function(E, B, N, O) {
            return E[B * l + N] = O;
          }, add: function(E, B, N, O) {
            return E[B * l + N] += O;
          }, dataOffset: function(E, B) {
            return E * l + B;
          }, getCoords: function(E, B) {
            return B[0] = Math.floor(E / l), B[1] = E % l, B;
          } };
        }
        throw new Error("bad axis order");
      case 3:
        if (s[0] === 0 && s[1] === 1 && s[2] === 2) {
          var d = u[0], f = u[1], m = d * f;
          return { get: function(E, B, N, O) {
            return E[B + N * d + O * m];
          }, set: function(E, B, N, O, z) {
            return E[B + N * d + O * m] = z;
          }, add: function(E, B, N, O, z) {
            return E[B + N * d + O * m] += z;
          }, dataOffset: function(E, B, N) {
            return E + B * d + N * m;
          }, getCoords: function(E, B) {
            var N = Math.floor(E / d);
            return B[0] = E % d, B[1] = N % f, B[2] = Math.floor(N / f), B;
          } };
        }
        if (s[0] === 0 && s[1] === 2 && s[2] === 1) {
          var v = u[0], p = u[2], g = v * p;
          return { get: function(E, B, N, O) {
            return E[B + O * v + N * g];
          }, set: function(E, B, N, O, z) {
            return E[B + O * v + N * g] = z;
          }, add: function(E, B, N, O, z) {
            return E[B + O * v + N * g] += z;
          }, dataOffset: function(E, B, N) {
            return E + N * v + B * g;
          }, getCoords: function(E, B) {
            var N = Math.floor(E / v);
            return B[0] = E % v, B[1] = Math.floor(N / p), B[2] = N % p, B;
          } };
        }
        if (s[0] === 1 && s[1] === 0 && s[2] === 2) {
          var h = u[1], y = u[0], x = h * y;
          return { get: function(E, B, N, O) {
            return E[N + B * h + O * x];
          }, set: function(E, B, N, O, z) {
            return E[N + B * h + O * x] = z;
          }, add: function(E, B, N, O, z) {
            return E[N + B * h + O * x] += z;
          }, dataOffset: function(E, B, N) {
            return B + E * h + N * x;
          }, getCoords: function(E, B) {
            var N = Math.floor(E / h);
            return B[0] = N % y, B[1] = E % h, B[2] = Math.floor(N / y), B;
          } };
        }
        if (s[0] === 1 && s[1] === 2 && s[2] === 0) {
          var A = u[1], b = u[2], _ = A * b;
          return { get: function(E, B, N, O) {
            return E[N + O * A + B * _];
          }, set: function(E, B, N, O, z) {
            return E[N + O * A + B * _] = z;
          }, add: function(E, B, N, O, z) {
            return E[N + O * A + B * _] += z;
          }, dataOffset: function(E, B, N) {
            return B + N * A + E * _;
          }, getCoords: function(E, B) {
            var N = Math.floor(E / A);
            return B[0] = Math.floor(N / b), B[1] = E % A, B[2] = N % b, B;
          } };
        }
        if (s[0] === 2 && s[1] === 0 && s[2] === 1) {
          var S = u[2], D = u[0], I = S * D;
          return { get: function(E, B, N, O) {
            return E[O + B * S + N * I];
          }, set: function(E, B, N, O, z) {
            return E[O + B * S + N * I] = z;
          }, add: function(E, B, N, O, z) {
            return E[O + B * S + N * I] += z;
          }, dataOffset: function(E, B, N) {
            return N + E * S + B * I;
          }, getCoords: function(E, B) {
            var N = Math.floor(E / S);
            return B[0] = N % D, B[1] = Math.floor(N / D), B[2] = E % S, B;
          } };
        }
        if (s[0] === 2 && s[1] === 1 && s[2] === 0) {
          var M = u[2], F = u[1], P = M * F;
          return { get: function(E, B, N, O) {
            return E[O + N * M + B * P];
          }, set: function(E, B, N, O, z) {
            return E[O + N * M + B * P] = z;
          }, add: function(E, B, N, O, z) {
            return E[O + N * M + B * P] += z;
          }, dataOffset: function(E, B, N) {
            return N + B * M + E * P;
          }, getCoords: function(E, B) {
            var N = Math.floor(E / M);
            return B[0] = Math.floor(N / F), B[1] = N % F, B[2] = E % M, B;
          } };
        }
        throw new Error("bad axis order");
      default:
        return { get: function(E) {
          for (var B = [], N = 1; N < arguments.length; N++) B[N - 1] = arguments[N];
          return E[i(o, B)];
        }, set: function(E) {
          for (var B = [], N = 1; N < arguments.length; N++) B[N - 1] = arguments[N];
          return E[i(o, B)] = B[B.length - 1];
        }, add: function(E) {
          for (var B = [], N = 1; N < arguments.length; N++) B[N - 1] = arguments[N];
          return E[i(o, B)] += B[B.length - 1];
        }, dataOffset: function() {
          for (var E = [], B = 0; B < arguments.length; B++) E[B] = arguments[B];
          return i(o, E);
        }, getCoords: function(E, B) {
          return function(N, O, z) {
            for (var V = N.dimensions, U = N.axisOrderFastToSlow, H = V.length, K = O, j = 0; j < H; j++) {
              var X = V[U[j]];
              z[U[j]] = K % X, K = Math.floor(K / X);
            }
            return z[U[H + 1]] = K, z;
          }(o, E, B);
        } };
    }
  }
  function n(o) {
    for (var u = o.dimensions, s = 1, c = 0, l = u.length; c < l; c++) s *= u[c];
    return function(d) {
      return new (d || o.defaultCtor)(s);
    };
  }
  function i(o, u) {
    for (var s = o.accessDimensions, c = o.axisOrderFastToSlow, l = s.length - 1, d = s[l] * u[c[l]], f = l - 1; f >= 0; f--) d = (d + u[c[f]]) * s[f];
    return d;
  }
  function a(o, u) {
    for (var s = [], c = 0; c < o.length; c++) s[c] = o[u[c]];
    return s;
  }
  e.create = function(o, u) {
    return { space: o, data: u };
  }, e.Space = t, e.Data1 = function(o) {
    return o;
  }, e.Vector = function(o, u) {
    return t([o], [0], u);
  }, e.ColumnMajorMatrix = function(o, u, s) {
    return t([o, u], [1, 0], s);
  }, e.RowMajorMatrix = function(o, u, s) {
    return t([o, u], [0, 1], s);
  }, e.toMat4 = function(o, u, s) {
    if (u.rank !== 2) throw new Error("Invalid tensor rank");
    for (var c = Math.min(4, u.dimensions[0]), l = Math.min(4, u.dimensions[1]), d = 0; d < c; d++) for (var f = 0; f < l; f++) me.setValue(o, d, f, u.get(s, d, f));
    return o;
  }, e.toMat3 = function(o, u, s) {
    if (u.rank !== 2) throw new Error("Invalid tensor rank");
    for (var c = Math.min(3, u.dimensions[0]), l = Math.min(3, u.dimensions[1]), d = 0; d < c; d++) for (var f = 0; f < l; f++) Ti.setValue(o, d, f, u.get(s, d, f));
    return o;
  }, e.toVec3 = function(o, u, s) {
    if (u.rank !== 1) throw new Error("Invalid tensor rank");
    for (var c = Math.min(3, u.dimensions[0]), l = 0; l < c; l++) o[l] = s[l];
    return o;
  }, e.toVec4 = function(o, u, s) {
    if (u.rank !== 1) throw new Error("Invalid tensor rank");
    for (var c = Math.min(4, u.dimensions[0]), l = 0; l < c; l++) o[l] = s[l];
    return o;
  }, e.areEqualExact = function(o, u) {
    var s = o.length;
    if (s !== u.length) return !1;
    for (var c = 0; c < s; c++) if (o[c] !== u[c]) return !1;
    return !0;
  }, e.invertAxisOrder = function(o) {
    for (var u = [], s = 0; s < o.length; s++) u[s] = o[o.length - s - 1];
    return u;
  }, e.convertToCanonicalAxisIndicesFastToSlow = function(o) {
    for (var u = new Int32Array(o.length), s = 0; s < o.length; s++) u[o[s]] = s;
    return function(c) {
      return a(c, u);
    };
  }, e.convertToCanonicalAxisIndicesSlowToFast = function(o) {
    for (var u = new Int32Array(o.length), s = 0; s < o.length; s++) u[o[o.length - s - 1]] = s;
    return function(c) {
      return a(c, u);
    };
  };
}(zn || (zn = {})), function(e) {
  e.create = function(t) {
    return t;
  }, e.has = function(t, r) {
    return !!(t & r);
  }, e.hasAll = function(t, r) {
    return !!r && (t & r) === r;
  };
}(ya || (ya = {})), function(e) {
  e.create = function(i) {
    return i === void 0 && (i = 512), { current: [], offset: 0, capacity: i, chunks: [] };
  }, e.getString = function(i) {
    return i.chunks.length ? (i.offset > 0 && (i.chunks[i.chunks.length] = i.current.length === i.offset ? i.current.join("") : i.current.slice(0, i.offset).join("")), i.chunks.join("")) : i.current.length === i.offset ? i.current.join("") : i.current.splice(0, i.offset).join("");
  }, e.getSize = function(i) {
    for (var a = 0, o = 0, u = i.chunks; o < u.length; o++)
      a += u[o].length;
    for (var s = 0; s < i.offset; s++) a += i.current[s].length;
    return a;
  }, e.getChunks = function(i) {
    return i.offset > 0 && (i.current.length === i.offset ? i.chunks[i.chunks.length] = i.current.join("") : i.chunks[i.chunks.length] = i.current.slice(0, i.offset).join(""), i.offset = 0), i.chunks;
  };
  var t = [];
  function r(i, a) {
    a > 0 && n(i, t[a]);
  }
  function n(i, a) {
    i.offset === i.capacity && (i.chunks[i.chunks.length] = i.current.join(""), i.offset = 0), i.current[i.offset++] = a;
  }
  (function() {
    for (var i = "", a = 0; a < 512; a++) t[a] = i, i += " ";
  })(), e.newline = function(i) {
    n(i, `
`);
  }, e.whitespace = r, e.whitespace1 = function(i) {
    n(i, " ");
  }, e.write = function(i, a) {
    a && (i.offset === i.capacity && (i.chunks[i.chunks.length] = i.current.join(""), i.offset = 0), i.current[i.offset++] = a);
  }, e.writeSafe = n, e.writePadLeft = function(i, a, o) {
    a ? (r(i, o - a.length), n(i, a)) : r(i, o);
  }, e.writePadRight = function(i, a, o) {
    if (a) {
      var u = o - a.length;
      n(i, a), r(i, u);
    } else r(i, o);
  }, e.writeInteger = function(i, a) {
    n(i, "" + a);
  }, e.writeIntegerAndSpace = function(i, a) {
    n(i, a + " ");
  }, e.writeIntegerPadLeft = function(i, a, o) {
    var u = "" + a;
    r(i, o - u.length), n(i, u);
  }, e.writeIntegerPadRight = function(i, a, o) {
    var u = "" + a, s = o - u.length;
    n(i, u), r(i, s);
  }, e.writeFloat = function(i, a, o) {
    n(i, "" + Math.round(o * a) / o);
  }, e.writeFloatPadLeft = function(i, a, o, u) {
    var s = "" + Math.round(o * a) / o;
    r(i, u - s.length), n(i, s);
  }, e.writeFloatPadRight = function(i, a, o, u) {
    var s = "" + Math.round(o * a) / o, c = u - s.length;
    n(i, s), r(i, c);
  };
}(Cr || (Cr = {})), function(e) {
  var t = typeof btoa < "u" ? btoa : function(n) {
    return Buffer.from(n).toString("base64");
  }, r = [];
  e.create22 = function() {
    for (var n = +/* @__PURE__ */ new Date() + li(), i = 0; i < 16; i++) r[i] = String.fromCharCode((n + 255 * Math.random()) % 255 | 0), n = Math.floor(n / 255);
    return t(r.join("")).replace(/\+/g, "-").replace(/\//g, "_").substr(0, 22);
  }, e.createv4 = function() {
    var n = +/* @__PURE__ */ new Date() + li(), i = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(a) {
      var o = (n + 16 * Math.random()) % 16 | 0;
      return n = Math.floor(n / 16), (a === "x" ? o : 3 & o | 8).toString(16);
    });
    return i;
  }, e.is = function(n) {
    return typeof n == "string";
  };
}(Ii || (Ii = {})), function(e) {
  var t = function() {
    function s() {
      this.size = 0;
    }
    return s.prototype.has = function(c) {
      return !1;
    }, s.prototype.forEach = function(c, l) {
      return l;
    }, s;
  }(), r = function() {
    function s(c) {
      this.idx = c, this.size = 1;
    }
    return s.prototype.has = function(c) {
      return c === this.idx;
    }, s.prototype.forEach = function(c, l) {
      return c(this.idx, l), l;
    }, s;
  }(), n = function() {
    function s(c, l) {
      this.mask = c, this.size = l, this.length = c.length;
    }
    return s.prototype.has = function(c) {
      return c < this.length && !!this.mask[c];
    }, s.prototype._forEach = function(c, l) {
      for (var d = 0; d < this.length; d++) this.mask[d] && c(d, l);
    }, s.prototype.forEach = function(c, l) {
      return this._forEach(c, l), l;
    }, s;
  }(), i = function() {
    function s(c) {
      this.size = c;
    }
    return s.prototype.has = function(c) {
      return !0;
    }, s.prototype._forEach = function(c, l) {
      for (var d = 0; d < this.size; d++) c(d, l);
    }, s.prototype.forEach = function(c, l) {
      return this._forEach(c, l), l;
    }, s;
  }(), a = function() {
    function s(c) {
      this.set = c, this._flat = void 0, this.size = c.size;
    }
    return s.prototype.has = function(c) {
      return this.set.has(c);
    }, s.prototype._forEach = function(c, l) {
      for (var d = 0, f = this.flatten(); d < f.length; d++)
        c(f[d], l);
    }, s.prototype.flatten = function() {
      if (this._flat) return this._flat;
      var c = new Int32Array(this.size), l = 0;
      return this.set.forEach(function(d) {
        return c[l++] = d;
      }), function(d) {
        Array.prototype.sort.call(d, fU);
      }(c), this._flat = c, this._flat;
    }, s.prototype.forEach = function(c, l) {
      return this._forEach(c, l), l;
    }, s;
  }();
  function o(s) {
    return new a(s);
  }
  function u(s, c) {
    return new n(s, c);
  }
  e.always = function(s) {
    return new i(s);
  }, e.never = new t(), e.ofSet = o, e.singleton = function(s) {
    return new r(s);
  }, e.ofUniqueIndices = function(s) {
    var c = s.length;
    if (c === 0) return new t();
    if (c === 1) return new r(s[0]);
    for (var l = 0, d = 0, f = s; d < f.length; d++)
      (g = f[d]) > l && (l = g);
    if (c === l) return new i(c);
    if (c / l < 1 / 12) {
      for (var m = /* @__PURE__ */ new Set(), v = 0, p = s; v < p.length; v++) {
        var g = p[v];
        m.add(g);
      }
      return new a(m);
    }
    for (var h = new Int8Array(l + 1), y = 0, x = s; y < x.length; y++)
      h[g = x[y]] = 1;
    return new n(h, s.length);
  }, e.ofMask = u, e.hasAny = function(s, c) {
    for (var l = 0, d = c; l < d.length; l++) {
      var f = d[l];
      if (s.has(f)) return !0;
    }
    return !1;
  }, e.complement = function(s, c) {
    var l = 0, d = 0;
    if (c.forEach(function(v) {
      s.has(v) || (l++, v > d && (d = v));
    }), l / d < 1 / 12) {
      var f = /* @__PURE__ */ new Set();
      return c.forEach(function(v) {
        s.has(v) || f.add(v);
      }), o(f);
    }
    var m = new Uint8Array(d + 1);
    return c.forEach(function(v) {
      s.has(v) || (m[v] = 1);
    }), u(m, l);
  };
}(J7 || (J7 = {})), function(e) {
  e.create = function(t) {
    return { ref: t };
  }, e.set = function(t, r) {
    return t.ref = r, t;
  };
}(Lp || (Lp = {}));
var Ll, k, pU = La(0, 2147483647);
function Ji() {
  return Ji.zero();
}
function _s() {
  return _s.zero();
}
function He(e) {
  return e;
}
function fr(e, t, r, n) {
  return { label: e, description: r, list: n, type: t };
}
function xf(e, t, r) {
  var n = {};
  for (var i in e) {
    var a = e[i];
    a = He.saturate(a, t), a = He.darken(a, -r), n[i] = a;
  }
  return n;
}
(function(e) {
  e.create = function(t, r) {
    return { id: pU(), version: 0, value: t, metadata: r };
  }, e.withValue = function(t, r) {
    return { id: t.id, version: t.version + 1, value: r, metadata: t.metadata };
  };
})(Ll || (Ll = {})), function(e) {
  function t(r, n) {
    return Lp.set(r, Ll.withValue(r.ref, n));
  }
  e.create = function(r, n) {
    return Lp.create(Ll.create(r, n));
  }, e.update = t, e.set = function(r, n) {
    return Lp.set(r, n);
  }, e.updateIfChanged = function(r, n) {
    return r.ref.value !== n ? t(r, n) : r;
  };
}(k || (k = {})), function(e) {
  function t() {
    var y = [0.1, 0, 0];
    return y[0] = 0, y;
  }
  function r(y, x) {
    var A = x[0], b = x[1], _ = x[2], S = Math.sqrt(b * b + _ * _), D = (xa(Math.atan2(_, b)) + 360) % 360;
    return Math.round(1e4 * S) === 0 && (D = Number.NaN), y[0] = D, y[1] = S, y[2] = A, y;
  }
  function n(y, x, A) {
    return y[0] = x[0] - o * A, y[1] = x[1], y[2] = x[2], y;
  }
  e.zero = t, e.create = function(y, x, A) {
    var b = t();
    return b[0] = y, b[1] = x, b[2] = A, b;
  }, e.fromColor = function(y, x) {
    var A = He.toRgb(x), b = function(M, F, P) {
      M = g(M), F = g(F), P = g(P);
      var E = h((0.4124564 * M + 0.3575761 * F + 0.1804375 * P) / u), B = h((0.2126729 * M + 0.7151522 * F + 0.072175 * P) / s), N = h((0.0193339 * M + 0.119192 * F + 0.9503041 * P) / c);
      return [E, B, N];
    }(A[0], A[1], A[2]), _ = b[0], S = b[1], D = b[2], I = 116 * S - 16;
    return y[0] = I < 0 ? 0 : I, y[1] = 500 * (_ - S), y[2] = 200 * (S - D), y;
  }, e.fromHcl = function(y, x) {
    return _s.toLab(y, x);
  }, e.toColor = function(y) {
    var x = (y[0] + 16) / 116, A = isNaN(y[1]) ? x : x + y[1] / 500, b = isNaN(y[2]) ? x : x - y[2] / 200;
    x = s * p(x);
    var _ = v(3.2404542 * (A = u * p(A)) - 1.5371385 * x - 0.4985314 * (b = c * p(b))), S = v(-0.969266 * A + 1.8760108 * x + 0.041556 * b), D = v(0.0556434 * A - 0.2040259 * x + 1.0572252 * b);
    return He.fromRgb(Math.round(Qa(_, 0, 255)), Math.round(Qa(S, 0, 255)), Math.round(Qa(D, 0, 255)));
  }, e.toHcl = r, e.copy = function(y, x) {
    return y[0] = x[0], y[1] = x[1], y[2] = x[2], y;
  }, e.darken = n, e.lighten = function(y, x, A) {
    return n(y, x, -A);
  };
  var i = [0, 0, 0];
  function a(y, x, A) {
    return r(i, x), _s.toLab(y, _s.saturate(i, i, A));
  }
  e.saturate = a, e.desaturate = function(y, x, A) {
    return a(y, x, -A);
  };
  var o = 18, u = 0.95047, s = 1, c = 1.08883, l = 0.137931034, d = 0.206896552, f = 0.12841855, m = 8856452e-9;
  function v(y) {
    return 255 * (y <= 304e-5 ? 12.92 * y : 1.055 * Math.pow(y, 1 / 2.4) - 0.055);
  }
  function p(y) {
    return y > d ? y * y * y : f * (y - l);
  }
  function g(y) {
    return (y /= 255) <= 0.04045 ? y / 12.92 : Math.pow((y + 0.055) / 1.055, 2.4);
  }
  function h(y) {
    return y > m ? Math.pow(y, 1 / 3) : y / f + l;
  }
}(Ji || (Ji = {})), function(e) {
  function t() {
    var c = [0.1, 0, 0];
    return c[0] = 0, c;
  }
  e.zero = t, e.create = function(c, l, d) {
    var f = t();
    return f[0] = c, f[1] = l, f[2] = d, f;
  };
  var r = [0, 0, 0];
  e.fromColor = function(c, l) {
    return Ji.toHcl(c, Ji.fromColor(r, l));
  }, e.fromLab = function(c, l) {
    return Ji.toHcl(c, l);
  };
  var n = [0, 0, 0];
  function i(c, l) {
    var d = l[0], f = l[1], m = l[2];
    return isNaN(d) && (d = 0), d = Bn(d), c[0] = m, c[1] = Math.cos(d) * f, c[2] = Math.sin(d) * f, c;
  }
  function a(c, l, d) {
    return c[0] = l[0], c[1] = Math.max(0, l[1] + s * d), c[2] = l[2], c;
  }
  e.toColor = function(c) {
    return Ji.toColor(i(n, c));
  }, e.toLab = i, e.copy = function(c, l) {
    return c[0] = l[0], c[1] = l[1], c[2] = l[2], c;
  }, e.saturate = a, e.desaturate = function(c, l, d) {
    return a(c, l, -d);
  };
  var o = [0, 0, 0];
  function u(c, l, d) {
    return i(o, l), Ji.toHcl(c, Ji.darken(o, o, d));
  }
  e.darken = u, e.lighten = function(c, l, d) {
    return u(c, l, -d);
  };
  var s = 18;
}(_s || (_s = {})), function(e) {
  function t(c, l, d) {
    return c << 16 | l << 8 | d;
  }
  function r(c, l, d) {
    return 255 * c << 16 | 255 * l << 8 | 255 * d;
  }
  e.toStyle = function(c) {
    return "rgb(".concat(c >> 16 & 255, ", ").concat(c >> 8 & 255, ", ").concat(255 & c, ")");
  }, e.toHexString = function(c) {
    return "0x" + ("000000" + c.toString(16)).slice(-6);
  }, e.toRgbString = function(c) {
    return "RGB: ".concat(e.toRgb(c).join(", "));
  }, e.toRgb = function(c) {
    return [c >> 16 & 255, c >> 8 & 255, 255 & c];
  }, e.toRgbNormalized = function(c) {
    return [(c >> 16 & 255) / 255, (c >> 8 & 255) / 255, (255 & c) / 255];
  }, e.fromRgb = t, e.fromNormalizedRgb = r, e.fromArray = function(c, l) {
    return t(c[l], c[l + 1], c[l + 2]);
  }, e.fromNormalizedArray = function(c, l) {
    return r(c[l], c[l + 1], c[l + 2]);
  }, e.toArray = function(c, l, d) {
    return l[d] = c >> 16 & 255, l[d + 1] = c >> 8 & 255, l[d + 2] = 255 & c, l;
  }, e.toArrayNormalized = function(c, l, d) {
    return l[d] = (c >> 16 & 255) / 255, l[d + 1] = (c >> 8 & 255) / 255, l[d + 2] = (255 & c) / 255, l;
  }, e.toVec3 = function(c, l) {
    return c[0] = l >> 16 & 255, c[1] = l >> 8 & 255, c[2] = 255 & l, c;
  }, e.toVec3Normalized = function(c, l) {
    return c[0] = (l >> 16 & 255) / 255, c[1] = (l >> 8 & 255) / 255, c[2] = (255 & l) / 255, c;
  }, e.interpolate = function(c, l, d) {
    var f = c >> 16 & 255, m = c >> 8 & 255, v = 255 & c;
    return f + ((l >> 16 & 255) - f) * d << 16 | m + ((l >> 8 & 255) - m) * d << 8 | v + ((255 & l) - v) * d;
  };
  var n = [0, 0, 0];
  function i(c, l) {
    return _s.fromColor(n, c), _s.toColor(_s.saturate(n, n, l));
  }
  e.saturate = i, e.desaturate = function(c, l) {
    return i(c, -l);
  };
  var a = [0, 0, 0];
  function o(c, l) {
    return Ji.fromColor(a, c), Ji.toColor(Ji.darken(a, a, l));
  }
  function u(c) {
    return c < 0.04045 ? 0.0773993808 * c : Math.pow(0.9478672986 * c + 0.0521327014, 2.4);
  }
  function s(c) {
    return c < 31308e-7 ? 12.92 * c : 1.055 * Math.pow(c, 0.41666) - 0.055;
  }
  e.darken = o, e.lighten = function(c, l) {
    return o(c, -l);
  }, e.sRGBToLinear = function(c) {
    return r(u((c >> 16 & 255) / 255), u((c >> 8 & 255) / 255), u((255 & c) / 255));
  }, e.linearToSRGB = function(c) {
    return r(s((c >> 16 & 255) / 255), s((c >> 8 & 255) / 255), s((255 & c) / 255));
  };
}(He || (He = {}));
var mU = function(e) {
  return e.toUpperCase();
};
function e_(e) {
  return e.toLowerCase().replace(/^\w|\s\w/g, mU);
}
function Is(e) {
  return e_(function(t, r) {
    return r === void 0 && (r = " "), t.replace(/([a-z\xE0-\xFF])([A-Z\xC0\xDF])/g, "$1".concat(r, "$2"));
  }(function(t) {
    return t.replace(/_/g, " ");
  }(function(t) {
    return t.replace(/-/g, " ");
  }(e))));
}
function ai(e, t, r, n) {
  var i = n.length;
  if (i > r - t) return !1;
  for (var a = 0; a < i; a++) if (e.charCodeAt(t + a) !== n.charCodeAt(a)) return !1;
  return !0;
}
function t_(e) {
  return e.replace(/<\/?[^>]+>/g, "");
}
var Oe, bo = { "orange-red": fr("Orange-Red", "sequential", "Orange-Red, sequential color scheme from ColorBrewer 2.0", [16775148, 16705736, 16635038, 16628612, 16551257, 15689032, 14102559, 11730944, 8323072]), "purple-blue": fr("Purple-Blue", "sequential", "Purple-Blue, sequential color scheme from ColorBrewer 2.0", [16775163, 15525874, 13685222, 10927579, 7645647, 3576e3, 356528, 285325, 145496]), "blue-purple": fr("Blue-Purple", "sequential", "Blue-Purple, sequential color scheme from ColorBrewer 2.0", [16252157, 14740724, 12571622, 10403034, 9213638, 9202609, 8929693, 8458108, 5046347]), oranges: fr("Oranges", "sequential", "", [16774635, 16705230, 16634018, 16625259, 16616764, 15821075, 14239745, 10892803, 8333060]), "blue-green": fr("Blue-Green", "sequential", "", [16252157, 15070713, 13429990, 10082505, 6734500, 4304502, 2329413, 27948, 17435]), "yellow-orange-brown": fr("Yellow-Orange-Brown", "sequential", "", [16777189, 16775100, 16704401, 16696399, 16685353, 15495188, 13388802, 10040324, 6694150]), "yellow-green": fr("Yellow-Green", "sequential", "", [16777189, 16252089, 14282915, 11394446, 7915129, 4303709, 2327619, 26679, 17705]), reds: fr("Reds", "sequential", "", [16774640, 16703698, 16563105, 16552562, 16476746, 15678252, 13309981, 10817301, 6750221]), "red-purple": fr("Red-Purple", "sequential", "", [16775155, 16638173, 16565696, 16424885, 16214177, 14496919, 11403646, 7995767, 4784234]), greens: fr("Greens", "sequential", "", [16252149, 15070688, 13101504, 10607003, 7652470, 4303709, 2329413, 27948, 17435]), "yellow-green-blue": fr("Yellow-Green-Blue", "sequential", "", [16777177, 15595697, 13101492, 8375739, 4306628, 1937856, 2252456, 2438292, 531800]), purples: fr("Purples", "sequential", "", [16579581, 15724021, 14342891, 12369372, 10394312, 8420794, 6967715, 5515151, 4128893]), "green-blue": fr("Green-Blue", "sequential", "", [16252144, 14742491, 13429701, 11066805, 8113348, 5157843, 2854078, 551084, 540801]), greys: fr("Greys", "sequential", "", [16777215, 15790320, 14277081, 12434877, 9868950, 7566195, 5395026, 2434341, 0]), "yellow-orange-red": fr("Yellow-Orange-Red", "sequential", "", [16777164, 16772512, 16701814, 16691788, 16616764, 16535082, 14883356, 12386342, 8388646]), "purple-red": fr("Purple-Red", "sequential", "", [16250105, 15196655, 13941210, 13210823, 14640560, 15149450, 13505110, 9961539, 6750239]), blues: fr("Blues", "sequential", "", [16251903, 14609399, 13032431, 10406625, 7057110, 4362950, 2191797, 545180, 536683]), "purple-blue-green": fr("Purple-Blue-Green", "sequential", "", [16775163, 15524592, 13685222, 10927579, 6793679, 3576e3, 164234, 93273, 83510]), spectral: fr("Spectral", "diverging", "", [10355010, 13975119, 16018755, 16625249, 16703627, 16777151, 15136152, 11263396, 6734501, 3311805, 6180770]), "red-yellow-green": fr("Red-Yellow-Green", "diverging", "", [10813478, 14102567, 16018755, 16625249, 16703627, 16777151, 14282635, 10934634, 6733155, 1742928, 26679]), "red-blue": fr("Red-Blue", "diverging", "", [6750239, 11671595, 14049357, 16033154, 16636871, 16250871, 13755888, 9618910, 4428739, 2188972, 340065]), "pink-yellow-green": fr("Pink-Yellow-Green", "diverging", "", [9306450, 12917629, 14579630, 15840986, 16638191, 16250871, 15136208, 12116358, 8371265, 5083681, 2581529]), "purple-green": fr("Purple-Green", "diverging", "", [4194379, 7744131, 10055851, 12756431, 15193320, 16250871, 14282963, 10935200, 5942881, 1800247, 17435]), "red-yellow-blue": fr("Red-Yellow-Blue", "diverging", "Red-Yellow-Blue, diverging color scheme from ColorBrewer 2.0", [10813478, 14102567, 16018755, 16625249, 16703632, 16777151, 14742520, 11262441, 7646673, 4552116, 3225237]), "brown-white-green": fr("Brown-White-Green", "diverging", "", [5517317, 9195786, 12550445, 14664317, 16181443, 16119285, 13101797, 8441281, 3512207, 91742, 15408]), "red-grey": fr("Red-Grey", "diverging", "", [6750239, 11671595, 14049357, 16033154, 16636871, 16777215, 14737632, 12237498, 8882055, 5066061, 1710618]), "orange-purple": fr("Orange-Purple", "diverging", "", [8338184, 11753478, 14713364, 16627811, 16703670, 16250871, 14211819, 11709394, 8418220, 5515144, 2949195]), "set-2": fr("Set-2", "qualitative", "", [6734501, 16551266, 9281739, 15174339, 10934356, 16767279, 15058068, 11776947]), accent: fr("Accent", "qualitative", "", [8374655, 12496596, 16629894, 16777113, 3697840, 15729279, 12540695, 6710886]), "set-1": fr("Set-1", "qualitative", "", [14948892, 3636920, 5091146, 9981603, 16744192, 16777011, 10901032, 16220607, 10066329]), "set-3": fr("Set-3", "qualitative", "", [9294791, 16777139, 12499674, 16482418, 8434131, 16626786, 11787881, 16567781, 14277081, 12353725, 13429701, 16772463]), "dark-2": fr("Dark-2", "qualitative", "", [1810039, 14245634, 7696563, 15149450, 6727198, 15117058, 10909213, 6710886]), paired: fr("Paired", "qualitative", "", [10931939, 2062516, 11722634, 3383340, 16489113, 14883356, 16629615, 16744192, 13284054, 6962586, 16777113, 11622696]), "pastel-2": fr("Pastel-2", "qualitative", "", [11789005, 16633260, 13358568, 16042724, 15136201, 16773806, 15852236, 13421772]), "pastel-1": fr("Pastel-1", "qualitative", "", [16495790, 11783651, 13429701, 14601188, 16701862, 16777164, 15063229, 16636652, 15921906]), "many-distinct": fr("Many-Distinct", "qualitative", "", [8948459, 11646160, 16116990, 6994595, 6727198, 15117058, 10909213, 6710886, 14948892, 3636920, 5091146, 9981603, 16744192, 16777011, 10901032, 16220607, 10066329, 6734501, 16551266, 9281739, 15174339, 10934356, 16767279, 15058068, 11776947]), magma: fr("Magma", "sequential", "Perceptually uniform shades of black-red-white", [4329332, 4853881, 5378684, 5903742, 6363263, 6888576, 7413633, 7938689, 8463745, 8988801, 9513600, 10038655, 10563454, 11088508, 11613562, 12138360, 12728949, 13254258, 13714030, 14239338, 14699366, 15094114, 15489119, 15753309, 16017499, 16216411, 16350045, 16483424, 16551523, 16619368, 16621934, 16689780, 16692091, 16694402, 16696969, 16633746, 16636058, 16638371, 16575148, 16577461, 16514239]), inferno: fr("Inferno", "sequential", "Perceptually uniform shades of black-red-yellow", [4721514, 5246316, 5771373, 6296430, 6821486, 7346542, 7871597, 8396651, 8921450, 9446504, 9971557, 10496610, 10956127, 11481435, 12006486, 12466258, 12926285, 13386056, 13780802, 14241085, 14570295, 14965297, 15229227, 15558693, 15757342, 15956248, 16154897, 16288267, 16421638, 16489734, 16492043, 16494612, 16496926, 16368426, 16305463, 16111429, 15982678, 15853928, 15856253, 16119953, 16580260]), plasma: fr("Plasma", "sequential", "Perceptually uniform shades of blue-red-yellow", [1771148, 2426257, 3081365, 3671193, 4195228, 4784799, 5308834, 5833124, 6357158, 6815911, 7340200, 7864744, 8324007, 8783782, 9309348, 9769377, 10164126, 10624154, 11018902, 11413393, 11808141, 12137352, 12466307, 12795519, 13124730, 13453685, 13717361, 14046573, 14309992, 14573668, 14837344, 15035483, 15299159, 15497299, 15695438, 15893834, 16091974, 16224833, 16357693, 16425017, 16557877, 16625457, 16627245, 16629289, 16631334, 16567845, 16438820, 16310052, 16115494, 15921190, 15726625]), viridis: fr("Viridis", "sequential", "Perceptually uniform shades of blue-green-yellow", [4524123, 4656994, 4658793, 4726127, 4727668, 4663929, 4599933, 4535937, 4406404, 4276870, 4081800, 3952010, 3822475, 3627148, 3497356, 3302029, 3172237, 3042446, 2912654, 2782862, 2652814, 2523022, 2393229, 2328973, 2198924, 2069132, 2004874, 2005897, 2007175, 2139525, 2337154, 2666111, 3060348, 3520376, 4045684, 4570991, 5227369, 5883748, 6605661, 7392854, 8180303, 8967495, 9819967, 10672695, 11525166, 12443174, 13295646, 14148121, 15000344, 15852828, 16639780]), cividis: fr("Cividis", "sequential", "Perceptually uniform shades of blue-green-yellow, should look effectively identical to colorblind and non-colorblind users", [11367, 12400, 537456, 1455727, 2046574, 2571629, 3031404, 3425388, 3754092, 4148075, 4476779, 4805227, 5133932, 5396844, 5725549, 5988462, 6317166, 6580079, 6843249, 7171698, 7434867, 7697781, 7960951, 8289656, 8618104, 8881272, 9209976, 9538679, 9867127, 10195830, 10524533, 10853235, 11181938, 11510640, 11839343, 12168045, 12497002, 12891240, 13219941, 13548642, 13943134, 14271834, 14666326, 14995025, 15389516, 15718470, 16112703, 16507190, 16639799]), twilight: fr("Twilight", "sequential", "Perceptually uniform shades of white-blue-black-red-white, cyclic", [14670305, 14211037, 13554648, 12766675, 11847630, 10993866, 10139847, 9351365, 8628419, 8036290, 7509952, 7048895, 6718653, 6519739, 6386105, 6252470, 6184114, 6181293, 6112935, 6044831, 5976470, 5777291, 5447293, 5052270, 4592479, 4067665, 3674181, 3281211, 3150646, 3543352, 4067644, 4657728, 5379141, 6166345, 6953549, 7741007, 8463184, 9120336, 9777743, 10304079, 10830671, 11291984, 11687762, 12083541, 12348505, 12613471, 12878439, 13077872, 13211771, 13411209, 13545111, 13809830, 14074293, 14338756, 14537169, 14735067, 14801121]), turbo: fr("Turbo", "sequential", "Improved (smooth) rainbow colormap for visualization", [4866485, 4872413, 4354034, 3770361, 3120629, 2667241, 2475736, 2611140, 3073454, 3928216, 5109892, 6487408, 8126047, 9829201, 11531332, 13167162, 14605618, 15780908, 16693543, 16753699, 16748063, 16741916, 16146200, 15026195, 13644558, 12198408, 10818563, 9833728]), rainbow: fr("Rainbow", "sequential", "", [3367393, 3516485, 16383744, 15501073, 12526114]), "red-white-blue": fr("Red-White-Blue", "diverging", "", [12526114, 16777215, 3367393]) }, e9 = Object.keys(bo).map(function(e) {
  return [e, bo[e].label, e_(bo[e].type)];
});
function Ec(e) {
  return e in bo ? bo[e] : (console.warn("unknown color list named '".concat(e, "'")), bo["red-yellow-blue"]);
}
function is(e) {
  return { kind: "table-legend", table: e };
}
function Wv(e, t, r) {
  return e[t] - e[r];
}
function Zd(e, t, r) {
  var n = e[t];
  e[t] = e[r], e[r] = n;
}
function OE(e, t, r, n) {
  var i = r + n >> 1;
  return t(e, r, n) > 0 ? t(e, r, i) > 0 ? t(e, i, n) > 0 ? i : n : r : t(e, n, i) > 0 ? t(e, i, r) > 0 ? i : r : n;
}
function hU(e, t, r) {
  var n = e.cmp, i = e.swap, a = e.data, o = e.parts, u = t + 1, s = r;
  for (i(a, t, OE(a, n, t, r)); n(a, s, t) > 0; ) --s;
  for (var c = t + 1; c <= s; c++) {
    var l = n(a, c, t);
    if (l > 0) {
      for (i(a, c, s), --s; n(a, s, t) > 0; ) --s;
      c--;
    } else l === 0 && (i(a, c, u), u++);
  }
  for (c = t; c < u; c++) i(a, c, t + s - c);
  o[0] = s - u + t + 1, o[1] = s;
}
function vU(e, t, r) {
  for (var n = e.data, i = e.cmp, a = e.swap, o = t + 1; o <= r; o++) for (var u = o - 1; u >= t && i(n, u, u + 1) > 0; ) a(n, u, u + 1), u -= 1;
}
function d2(e, t, r) {
  for (var n = e.parts; t < r; ) {
    if (r - t < 16) return void vU(e, t, r);
    hU(e, t, r);
    var i = n[0], a = n[1];
    i - t < r - a ? (d2(e, t, i - 1), t = a + 1) : (d2(e, a + 1, r), r = i - 1);
  }
}
function gU(e, t, r, n) {
  var i = r + 1, a = n;
  Zd(e, r, OE(e, Wv, r, n));
  for (var o = e[r]; e[a] > o; ) --a;
  for (var u = r + 1; u <= a; u++) {
    var s = e[u];
    if (s > o) {
      for (Zd(e, u, a), --a; e[a] > o; ) --a;
      u--;
    } else s === o && (Zd(e, u, i), ++i);
  }
  for (u = r; u < i; u++) Zd(e, u, r + a - u);
  t[0] = a - i + r + 1, t[1] = a;
}
function yU(e, t, r) {
  for (var n = t + 1; n <= r; n++) {
    for (var i = e[n], a = n - 1; a >= t && e[a] > i; ) e[a + 1] = e[a], a -= 1;
    e[a + 1] = i;
  }
}
function Z5(e, t, r, n) {
  for (; r < n; ) {
    if (n - r < 16) return void yU(e, r, n);
    gU(e, t, r, n);
    var i = t[0], a = t[1];
    i - r < n - a ? (Z5(e, t, r, i - 1), r = a + 1) : (Z5(e, t, a + 1, n), n = i - 1);
  }
}
function es(e, t) {
  return t === void 0 && (t = Wv), function(r, n, i, a) {
    return a === void 0 && (a = Wv), a === Wv ? Z5(r, [0, 0], n, i - 1) : d2({ data: r, cmp: a, swap: Zd, parts: [0, 0] }, n, i - 1), r;
  }(e, 0, e.length, t);
}
function LE(e, t, r, n, i) {
  return d2({ data: e, cmp: n, swap: i, parts: [0, 0] }, t, r - 1), e;
}
function bU(e, t, r) {
  return e[t].key < e[r].key ? -1 : 1;
}
function Dy(e, t, r) {
  var n = r && r.start || 0, i = r && r.end || e.length;
  if (i - n <= 0) throw new Error("Can only bucket non-empty collections.");
  return function(a, o, u, s, c) {
    for (var l = /* @__PURE__ */ new Map(), d = [], f = o(a[0]), m = !0, v = s; v < c; v++) {
      var p = o(a[v]);
      if (l.has(p)) l.get(p).count++, f !== p && (m = !1);
      else {
        var g = { key: p, count: 1, offset: v };
        l.set(p, g), d[d.length] = g;
      }
      f = p;
    }
    var h = new Int32Array(d.length + 1);
    h[d.length] = c;
    var y = !0;
    if (u) {
      v = 1;
      for (var x = d.length; v < x; v++) if (d[v - 1].key > d[v].key) {
        y = !1;
        break;
      }
    }
    if (m && y) {
      for (v = 0; v < d.length; v++) h[v] = d[v].offset;
      return h;
    }
    u && !y && LE(d, 0, d.length, bU, Zd);
    var A = 0;
    for (v = 0; v < d.length; v++) {
      var b = d[v];
      b.offset = A, A += b.count;
    }
    var _ = new Int32Array(c - s);
    for (v = s; v < c; v++) p = o(a[v]), _[(g = l.get(p)).offset++] = a[v];
    for (v = 0, x = _.length; v < x; v++) a[v + s] = _[v];
    for (h[0] = s, v = 1; v < d.length; v++) h[v] = d[v - 1].offset + s;
    return h;
  }(e, t, !(!r || !r.sort), n, i);
}
e9.filter(function(e) {
  return bo[e[0]].type === "diverging" || bo[e[0]].type === "sequential";
}), e9.filter(function(e) {
  return bo[e[0]].type === "qualitative";
}), function(e) {
  function t(n) {
    var i = n.growBy * n.elementSize;
    n.currentSize = i, n.currentIndex = 0, n.currentChunk = new n.ctor(i), n.allocatedSize += i, n.chunks[n.chunks.length] = n.currentChunk;
  }
  function r(n, i) {
    var a = n.ctor, o = n.chunks, u = n.currentIndex;
    if (!o.length) return new a(0);
    if (o.length === 1 && (i || u === n.allocatedSize)) return o[0];
    for (var s = 0, c = 0, l = o.length - 1; c < l; c++) s += o[c].length;
    var d = new a(s += n.currentIndex), f = 0;
    if (d.buffer) for (c = 0, l = o.length - 1; c < l; c++) d.set(o[c], f), f += o[c].length;
    else for (c = 0, l = o.length - 1; c < l; c++) {
      for (var m = o[c], v = 0, p = m.length; v < p; v++) d[f + v] = m[v];
      f += m.length;
    }
    var g = o[o.length - 1];
    if (d.buffer && u >= n.currentSize) d.set(g, f);
    else for (v = 0, p = g.length; v < p; v++) d[f + v] = g[v];
    return d;
  }
  e.is = function(n) {
    return n.creator && n.chunkSize;
  }, e.add4 = function(n, i, a, o, u) {
    n.currentIndex >= n.currentSize && t(n);
    var s = n.currentChunk, c = n.currentIndex;
    return s[c] = i, s[c + 1] = a, s[c + 2] = o, s[c + 3] = u, n.currentIndex += 4, n.elementCount++;
  }, e.add3 = function(n, i, a, o) {
    n.currentIndex >= n.currentSize && t(n);
    var u = n.currentChunk, s = n.currentIndex;
    return u[s] = i, u[s + 1] = a, u[s + 2] = o, n.currentIndex += 3, n.elementCount++;
  }, e.add2 = function(n, i, a) {
    n.currentIndex >= n.currentSize && t(n);
    var o = n.currentChunk, u = n.currentIndex;
    return o[u] = i, o[u + 1] = a, n.currentIndex += 2, n.elementCount++;
  }, e.add = function(n, i) {
    return n.currentIndex >= n.currentSize && t(n), n.currentChunk[n.currentIndex] = i, n.currentIndex += 1, n.elementCount++;
  }, e.addRepeat = function(n, i, a) {
    for (var o = 0; o < i; o++) n.currentIndex >= n.currentSize && t(n), n.currentChunk[n.currentIndex++] = a, n.elementCount++;
    return n.elementCount;
  }, e.addMany = function(n, i) {
    for (var a = n.elementSize, o = 0, u = i.length; o < u; o += a) {
      n.currentIndex >= n.currentSize && t(n);
      for (var s = n.currentChunk, c = 0; c < a; c++) s[n.currentIndex++] = i[o + c];
      n.elementCount++;
    }
    return n.elementCount;
  }, e.compact = function(n, i) {
    return i === void 0 && (i = !1), r(n, i);
  }, e._compact = r, e.create = function(n, i, a, o) {
    var u = { ctor: n, elementSize: i, growBy: Math.max(1, Math.ceil(a)), allocatedSize: 0, elementCount: 0, currentSize: 0, currentChunk: void 0, currentIndex: 0, chunks: [] };
    if (o === void 0) return u;
    if (typeof o == "number") return u.currentChunk = new n(o * i), u.allocatedSize = o * i, u.currentSize = u.currentChunk.length, u.chunks[0] = u.currentChunk, u;
    var s = o;
    if (s.length % i != 0) throw new Error("initialChunk length must be a multiple of the element size.");
    return u.currentChunk = s, u.allocatedSize = s.length, u.currentSize = s.length, u.chunks[0] = s, u;
  };
}(Oe || (Oe = {}));
var oe, Or, Q5, di, _U = function() {
  function e(t, r) {
    this.getHash = t, this.areEqual = r, this.id = 0, this.byHash = /* @__PURE__ */ new Map(), this.groups = [];
  }
  return e.prototype.createGroup = function(t, r) {
    var n = this.id++, i = [t];
    return this.groups[n] = i, { id: n, keys: i, value: r };
  }, e.prototype.add = function(t, r) {
    var n = this.getHash(r);
    if (this.byHash.has(n)) {
      for (var i = this.byHash.get(n), a = 0, o = i.length; a < o; a++) {
        var u = i[a];
        if (this.areEqual(r, u.value)) return u.keys[u.keys.length] = t, u.value;
      }
      var s = this.createGroup(t, r);
      return i[i.length] = s, s.value;
    }
    return s = this.createGroup(t, r), this.byHash.set(n, [s]), s.value;
  }, e;
}();
function kE(e) {
  var t = e ^ e >> 4;
  return t = (3735928559 ^ t) + (t << 5), t ^= t >> 11;
}
function h0(e, t) {
  var r = 23;
  return r = 31 * (r = 31 * r + e | 0) + t | 0, r = (3735928559 ^ (r ^= r >> 4)) + (r << 5), r ^= r >> 11;
}
function J5(e) {
  for (var t = 0, r = 0, n = e.length; r < n; r++) t = (t << 5) - t + e.charCodeAt(r++) | 0;
  return t;
}
function Mu(e, t) {
  return (e + t) * (e + t + 1) / 2 + t;
}
function f2(e, t) {
  return e < t ? Mu(e, t) : Mu(t, e);
}
function Ra(e) {
  for (var t = 2166136261, r = 0, n = e.length; r < n; ++r) t ^= e[r], t += (t << 1) + (t << 4) + (t << 7) + (t << 8) + (t << 24);
  return t >>> 0;
}
function p2(e, t) {
  return { start: t && t.start !== void 0 ? Math.max(Math.min(t.start, e - 1), 0) : 0, end: t && t.end !== void 0 ? Math.min(t.end, e) : e };
}
function Am(e, t) {
  var r = t && t.array !== void 0 ? t.array : Array, n = p2(e, t), i = n.start, a = n.end;
  return { array: new r(a - i), start: i, end: a };
}
function $i(e, t, r) {
  var n = Am(e, r);
  return function(i, a, o) {
    for (var u = 0, s = a.length; u < s; u++) a[u] = i(o + u);
    return a;
  }(t, n.array, n.start);
}
function r_(e) {
  return !!e.buffer && typeof e.byteLength == "number" && typeof e.BYTES_PER_ELEMENT == "number";
}
function m2(e, t) {
  var r = e.constructor, n = e.buffer, i = e.length, a = e.byteOffset, o = e.BYTES_PER_ELEMENT, u = p2(i, t), s = u.start, c = u.end;
  return s === 0 && c === i ? e : new r(n, a + o * s, Math.min(i, c - s));
}
function qd(e, t, r) {
  for (; t < r && e.charCodeAt(t) === 32; ) t++;
  return Yl(e, t, r);
}
function Yl(e, t, r) {
  var n = t, i = 0, a = 1;
  for (e.charCodeAt(n) === 45 ? (a = -1, ++n) : e.charCodeAt(n) === 43 && ++n; n < r; n++) {
    var o = e.charCodeAt(n) - 48;
    if (o > 9 || o < 0) return a * i | 0;
    i = 10 * i + o | 0;
  }
  return a * i;
}
function t9(e, t, r, n) {
  return t.charCodeAt(r) === 43 && r++, e * Math.pow(10, Yl(t, r, n));
}
function ef(e, t, r) {
  var n = t, i = 1, a = 0, o = 0, u = 1;
  for (e.charCodeAt(n) === 45 ? (i = -1, ++n) : e.charCodeAt(n) === 43 && ++n; n < r; ) {
    var s = e.charCodeAt(n) - 48;
    if (!(s >= 0 && s < 10)) {
      if (s === -2) {
        for (++n; n < r; ) {
          if (!((s = e.charCodeAt(n) - 48) >= 0 && s < 10)) return s === 53 || s === 21 ? t9(i * (a + o / u), e, n + 1, r) : i * (a + o / u);
          o = 10 * o + s, u *= 10, ++n;
        }
        return i * (a + o / u);
      }
      if (s === 53 || s === 21) return t9(i * a, e, n + 1, r);
      break;
    }
    a = 10 * a + s, ++n;
  }
  return i * a;
}
function r9(e, t, r, n) {
  return { schema: r, __array: void 0, isDefined: n === 0, rowCount: t, value: function(i) {
    return e;
  }, valueKind: function(i) {
    return n;
  }, toArray: function(i) {
    for (var a = Am(t, i).array, o = 0, u = a.length; o < u; o++) a[o] = e;
    return a;
  }, areValuesEqual: function(i, a) {
    return !0;
  } };
}
function Rh(e) {
  var t = e.value, r = e.valueKind, n = e.areValuesEqual, i = e.rowCount;
  return { schema: e.schema, __array: void 0, isDefined: !0, rowCount: i, value: t, valueKind: r || function(a) {
    return 0;
  }, toArray: function(a) {
    for (var o = Am(i, a), u = o.array, s = o.start, c = 0, l = u.length; c < l; c++) u[c] = t(c + s);
    return u;
  }, areValuesEqual: n || function(a, o) {
    return t(a) === t(o);
  } };
}
function pc(e) {
  var t = e.array, r = e.schema, n = e.valueKind, i = t.length, a = r.valueType === "str" ? function(u) {
    var s = t[u];
    return typeof s == "string" ? s : "" + s;
  } : function(u) {
    return t[u];
  }, o = r_(t);
  return { schema: r, __array: t, isDefined: !0, rowCount: i, value: a, valueKind: n || function(u) {
    return 0;
  }, toArray: r.valueType === "str" ? function(u) {
    for (var s = p2(i, u), c = s.start, l = s.end, d = new (u && u.array !== void 0 ? u.array : t.constructor)(l - c), f = 0, m = l - c; f < m; f++) {
      var v = t[c + f];
      d[f] = typeof v == "string" ? v : "" + v;
    }
    return d;
  } : o ? function(u) {
    return m2(t, u);
  } : function(u) {
    var s = p2(i, u), c = s.start, l = s.end;
    if (c === 0 && l === t.length) return t;
    for (var d = new (u && u.array !== void 0 ? u.array : t.constructor)(l - c), f = 0, m = l - c; f < m; f++) d[f] = t[c + f];
    return d;
  }, areValuesEqual: function(u, s) {
    return t[u] === t[s];
  } };
}
function xU(e, t, r) {
  return e.isDefined ? t === 0 && r === e.rowCount ? e : e.__array && r_(e.__array) ? function(n, i, a) {
    var o = m2(n.__array, { start: i, end: a }), u = n.valueKind;
    return pc({ array: o, schema: n.schema, valueKind: function(s) {
      return u(i + s);
    } });
  }(e, t, r) : function(n, i, a) {
    var o = n.value, u = n.valueKind, s = n.areValuesEqual, c = i === 0 ? o : function(d) {
      return o(d + i);
    }, l = a - i;
    return { schema: n.schema, __array: void 0, isDefined: n.isDefined, rowCount: l, value: c, valueKind: i === 0 ? u : function(d) {
      return u(d + i);
    }, toArray: function(d) {
      for (var f = Am(l, d).array, m = 0, v = f.length; m < v; m++) f[m] = o(m + i);
      return f;
    }, areValuesEqual: i === 0 ? s : function(d, f) {
      return s(d + i, f + i);
    } };
  }(e, t, r) : oe.Undefined(r - t, e.schema);
}
function AU(e, t, r) {
  return e.rowCount === 0 || r && function(n, i) {
    if (n.length !== i) return !1;
    for (var a = 0, o = n.length; a < o; a++) if (n[a] !== a) return !1;
    return !0;
  }(t, e.rowCount) ? e : e.__array && typeof e.value(0) == typeof e.__array[0] ? function(n, i) {
    for (var a = n.__array, o = new a.constructor(i.length), u = 0, s = i.length; u < s; u++) o[u] = a[i[u]];
    var c = n.valueKind;
    return pc({ array: o, schema: n.schema, valueKind: function(l) {
      return c(i[l]);
    } });
  }(e, t) : function(n, i) {
    var a = n.value, o = n.valueKind, u = n.areValuesEqual, s = function(l) {
      return a(i[l]);
    }, c = i.length;
    return { schema: n.schema, __array: void 0, isDefined: n.isDefined, rowCount: c, value: s, valueKind: function(l) {
      return o(i[l]);
    }, toArray: function(l) {
      for (var d = Am(c, l).array, f = 0, m = d.length; f < m; f++) d[f] = a(i[f]);
      return d;
    }, areValuesEqual: function(l, d) {
      return u(i[l], i[d]);
    } };
  }(e, t);
}
function n_(e) {
  if (Array.from) return Array.from(e);
  for (var t = []; ; ) {
    var r = e.next(), n = r.done, i = r.value;
    if (n) break;
    t[t.length] = i;
  }
  return t;
}
function $5(e, t, r) {
  for (var n = t - e + 1, i = new Int32Array(n), a = 0; a < n; a++) i[a] = a + e;
  return i;
}
function SU(e, t) {
  for (var r = new (function(a) {
    var o = a.constructor;
    if (!o) throw new Error("data does not define a constructor and it should");
    return o;
  }(e))(t.length), n = 0, i = t.length; n < i; n++) r[n] = e[t[n]];
  return r;
}
(function(e) {
  var t;
  function r(i, a) {
    return r9(a.T, i, a, 1);
  }
  function n(i) {
    return Rh(i);
  }
  (function(i) {
    function a(o, u) {
      return u === void 0 && (u = i.float), { "@type": "tensor", T: o.create(), space: o, valueType: "tensor", baseType: u };
    }
    i.str = { "@type": "str", T: "", valueType: "str" }, i.int = { "@type": "int", T: 0, valueType: "int" }, i.coord = { "@type": "coord", T: 0, valueType: "float" }, i.float = { "@type": "float", T: 0, valueType: "float" }, i.Str = function(o) {
      return o === void 0 && (o = ""), { "@type": "str", T: o, valueType: "str" };
    }, i.Int = function(o) {
      return o === void 0 && (o = 0), { "@type": "int", T: o, valueType: "int" };
    }, i.Float = function(o) {
      return o === void 0 && (o = 0), { "@type": "float", T: o, valueType: "float" };
    }, i.Tensor = a, i.Vector = function(o, u) {
      return u === void 0 && (u = i.float), a(zn.Vector(o, u["@type"] === "int" ? Int32Array : Float64Array), u);
    }, i.Matrix = function(o, u, s) {
      return s === void 0 && (s = i.float), a(zn.ColumnMajorMatrix(o, u, s["@type"] === "int" ? Int32Array : Float64Array), s);
    }, i.Aliased = function(o, u) {
      return u !== void 0 ? R(R({}, o), { T: u }) : o;
    }, i.List = function(o, u, s) {
      return s === void 0 && (s = []), { "@type": "list", T: s, separator: o, itemParse: u, valueType: "list" };
    };
  })(t = e.Schema || (e.Schema = {})), e.is = function(i) {
    return !!i && !!i.schema && !!i.value;
  }, e.Undefined = r, e.ofConst = function(i, a, o) {
    return r9(i, a, o, 0);
  }, e.ofLambda = n, e.range = function(i, a) {
    return n({ value: function(o) {
      return o + i;
    }, rowCount: Math.max(a - i + 1, 0), schema: t.int });
  }, e.ofArray = function(i) {
    return pc(i);
  }, e.ofIntArray = function(i) {
    return pc({ array: i, schema: t.int });
  }, e.ofFloatArray = function(i) {
    return pc({ array: i, schema: t.float });
  }, e.ofStringArray = function(i) {
    return pc({ array: i, schema: t.str });
  }, e.ofStringAliasArray = function(i) {
    return pc({ array: i, schema: t.Aliased(t.str) });
  }, e.ofStringListArray = function(i, a) {
    return a === void 0 && (a = ","), pc({ array: i, schema: t.List(a, function(o) {
      return o;
    }) });
  }, e.ofIntTokens = function(i) {
    var a = i.count, o = i.data, u = i.indices;
    return Rh({ value: function(s) {
      return Yl(o, u[2 * s], u[2 * s + 1]) || 0;
    }, rowCount: a, schema: t.int });
  }, e.ofFloatTokens = function(i) {
    var a = i.count, o = i.data, u = i.indices;
    return Rh({ value: function(s) {
      return ef(o, u[2 * s], u[2 * s + 1]) || 0;
    }, rowCount: a, schema: t.float });
  }, e.ofStringTokens = function(i) {
    var a = i.count, o = i.data, u = i.indices;
    return Rh({ value: function(s) {
      var c = o.substring(u[2 * s], u[2 * s + 1]);
      return c === "." || c === "?" ? "" : c;
    }, rowCount: a, schema: t.str });
  }, e.window = function(i, a, o) {
    return xU(i, a, o);
  }, e.view = function(i, a, o) {
    return o === void 0 && (o = !0), AU(i, a, o);
  }, e.createFirstIndexMap = function(i) {
    return function(a) {
      for (var o = /* @__PURE__ */ new Map(), u = 0, s = a.rowCount; u < s; u++) {
        var c = a.value(u);
        o.has(c) || o.set(a.value(u), u);
      }
      return o;
    }(i);
  }, e.createIndexer = function(i) {
    return function(a) {
      for (var o = /* @__PURE__ */ new Map(), u = 0, s = a.rowCount; u < s; u++) {
        var c = a.value(u);
        o.has(c) || o.set(a.value(u), u);
      }
      return function(l) {
        return o.has(l) ? o.get(l) : -1;
      };
    }(i);
  }, e.mapToArray = function(i, a, o) {
    return function(u, s, c) {
      for (var l = new c(u.rowCount), d = 0, f = u.rowCount; d < f; d++) l[d] = s(u.value(d));
      return l;
    }(i, a, o || Array);
  }, e.areEqual = function(i, a) {
    return function(o, u) {
      return o === u || o.rowCount === u.rowCount && o.isDefined === u.isDefined && o.schema.valueType === u.schema.valueType && (o.__array && u.__array ? function(s, c) {
        for (var l = s.__array, d = c.__array, f = 0, m = s.rowCount; f < m; f++) if (l[f] !== d[f]) return !1;
        return !0;
      }(o, u) : function(s, c) {
        for (var l = s.value, d = c.value, f = 0, m = s.rowCount; f < m; f++) if (l(f) !== d(f)) return !1;
        return !0;
      }(o, u));
    }(i, a);
  }, e.indicesOf = function(i, a) {
    return function(o, u) {
      for (var s = [], c = o.value, l = 0, d = o.rowCount; l < d; l++) u(c(l)) && (s[s.length] = l);
      return s;
    }(i, a);
  }, e.asArrayColumn = function(i, a) {
    return i.__array ? i : i.isDefined ? pc({ array: i.toArray({ array: a }), schema: i.schema, valueKind: i.valueKind }) : r(i.rowCount, i.schema);
  }, e.copyToArray = function(i, a, o) {
    if (o === void 0 && (o = 0), i.isDefined) {
      var u = i.__array;
      if (u) for (var s = 0, c = u.length; s < c; s++) a[o + s] = u[s];
      else for (s = 0, c = i.rowCount; s < c; s++) a[o + s] = i.value(s);
    }
  }, e.isIdentity = function(i) {
    for (var a = 0, o = i.rowCount; a < o; a++) if (a !== i.value(a)) return !1;
    return !0;
  };
})(oe || (oe = {})), function(e) {
  function t(n, i, a) {
    var o = /* @__PURE__ */ Object.create(null), u = Object.keys(i);
    o._rowCount = a.length, o._columns = u, o._schema = i;
    for (var s = 0, c = u; s < c.length; s++) {
      var l = c[s];
      o[l] = oe.view(n[l], a);
    }
    return o;
  }
  function r(n, i) {
    for (var a = /* @__PURE__ */ Object.create(null), o = n._columns, u = 0; u < o.length; u++) {
      var s = o[u];
      a[s] = n[s].value(i);
    }
    return a;
  }
  e.is = function(n) {
    return n && typeof n._rowCount == "number" && !!n._columns && !!n._schema;
  }, e.pickColumns = function(n, i, a) {
    a === void 0 && (a = {});
    var o = /* @__PURE__ */ Object.create(null), u = Object.keys(n);
    o._rowCount = i._rowCount, o._columns = u, o._schema = n;
    for (var s = 0, c = u; s < c.length; s++) {
      var l = c[s];
      if (i[l]) o[l] = i[l];
      else {
        if (!a[l]) throw Error("Cannot find column '".concat(l, "'."));
        o[l] = a[l];
      }
    }
    return o;
  }, e.ofColumns = function(n, i) {
    var a = Object.keys(i), o = i[a[0]].rowCount;
    return R({ _rowCount: o, _columns: a, _schema: n }, i);
  }, e.ofPartialColumns = function(n, i, a) {
    var o = /* @__PURE__ */ Object.create(null), u = Object.keys(n);
    o._rowCount = a, o._columns = u, o._schema = n;
    for (var s = 0, c = u; s < c.length; s++) {
      var l = c[s];
      o[l] = l in i ? i[l] : oe.Undefined(a, n[l]);
    }
    return o;
  }, e.ofUndefinedColumns = function(n, i) {
    var a = /* @__PURE__ */ Object.create(null), o = Object.keys(n);
    a._rowCount = i, a._columns = o, a._schema = n;
    for (var u = 0, s = o; u < s.length; u++) {
      var c = s[u];
      a[c] = oe.Undefined(i, n[c]);
    }
    return a;
  }, e.ofRows = function(n, i) {
    var a = /* @__PURE__ */ Object.create(null), o = i.length, u = Object.keys(n);
    a._rowCount = o, a._columns = u, a._schema = n;
    for (var s = function(d) {
      a[d] = oe.ofLambda({ rowCount: o, schema: n[d], value: function(f) {
        return i[f][d];
      }, valueKind: function(f) {
        return i[f][d] === void 0 ? 1 : 0;
      } });
    }, c = 0, l = u; c < l.length; c++)
      s(l[c]);
    return a;
  }, e.ofArrays = function(n, i) {
    var a, o = /* @__PURE__ */ Object.create(null), u = Object.keys(n);
    o._rowCount = 0, o._columns = u, o._schema = n;
    for (var s = 0, c = u; s < c.length; s++) {
      var l = c[s];
      i[l] !== void 0 ? (o[l] = oe.ofArray({ array: i[l], schema: n[l] }), o._rowCount = (a = i[l]) === null || a === void 0 ? void 0 : a.length) : o[l] = oe.Undefined(o._rowCount, n[l]);
    }
    return o;
  }, e.view = t, e.pick = function(n, i, a) {
    for (var o = [], u = 0, s = n._rowCount; u < s; ++u) a(u) && o.push(u);
    return t(n, i, o);
  }, e.window = function(n, i, a, o) {
    if (a === 0 && o === n._rowCount) return n;
    var u = /* @__PURE__ */ Object.create(null), s = Object.keys(i);
    u._rowCount = o - a, u._columns = s, u._schema = i;
    for (var c = 0, l = s; c < l.length; c++) {
      var d = l[c];
      u[d] = oe.window(n[d], a, o);
    }
    return u;
  }, e.concat = function(n, i) {
    var a = /* @__PURE__ */ Object.create(null), o = Object.keys(i);
    a._rowCount = 0;
    for (var u = 0, s = n; u < s.length; u++) {
      var c = s[u];
      a._rowCount += c._rowCount;
    }
    for (var l = {}, d = 0, f = o; d < f.length; d++)
      l[f[d]] = new Array(a._rowCount);
    a._columns = o, a._schema = i;
    for (var m = 0, v = 0, p = n; v < p.length; v++) {
      c = p[v];
      for (var g = 0, h = o; g < h.length; g++) {
        var y = h[g];
        oe.copyToArray(c[y], l[y], m);
      }
      m += c._rowCount;
    }
    for (var x = 0, A = o; x < A.length; x++)
      a[y = A[x]] = oe.ofArray({ array: l[y], schema: i[y] });
    return a;
  }, e.columnToArray = function(n, i, a) {
    n[i] = oe.asArrayColumn(n[i], a);
  }, e.sort = function(n, i) {
    for (var a = new Int32Array(n._rowCount), o = 0, u = a.length; o < u; o++) a[o] = o;
    es(a, function(m, v, p) {
      return i(v, p);
    });
    var s = !0;
    for (o = 0, u = a.length; o < u; o++) if (a[o] !== o) {
      s = !1;
      break;
    }
    if (s) return n;
    var c = /* @__PURE__ */ Object.create(null);
    c._rowCount = n._rowCount, c._columns = n._columns, c._schema = n._schema;
    for (var l = 0, d = n._columns; l < d.length; l++) {
      var f = d[l];
      c[f] = oe.view(n[f], a, !1);
    }
    return c;
  }, e.areEqual = function(n, i) {
    if (n._rowCount !== i._rowCount || n._columns.length !== i._columns.length) return !1;
    for (var a = 0, o = n._columns; a < o.length; a++)
      if (!i[c = o[a]]) return !1;
    for (var u = 0, s = n._columns; u < s.length; u++) {
      var c = s[u];
      if (!oe.areEqual(n[c], i[c])) return !1;
    }
    return !0;
  }, e.getRow = r, e.pickRow = function(n, i) {
    for (var a = 0, o = n._rowCount; a < o; ++a) if (i(a)) return r(n, a);
  }, e.getRows = function(n) {
    for (var i = [], a = n._rowCount, o = 0; o < a; o++) i[o] = r(n, o);
    return i;
  }, e.toArrays = function(n) {
    for (var i = {}, a = n._columns, o = 0; o < a.length; o++) {
      var u = a[o];
      i[u] = n[u].toArray();
    }
    return i;
  }, e.formatToString = function(n) {
    var i = Cr.create(), a = n._columns, o = n._rowCount, u = 1;
    Cr.write(i, "|");
    for (var s = 0; s < a.length; s++) Cr.write(i, a[s]), Cr.write(i, "|"), u += a[s].length + 1;
    Cr.newline(i), Cr.write(i, new Array(u + 1).join("-")), Cr.newline(i);
    for (var c = 0; c < o; c++) {
      for (Cr.write(i, "|"), s = 0; s < a.length; s++) {
        var l = n[a[s]];
        l.valueKind(c) === 0 ? (Cr.write(i, l.value(c)), Cr.write(i, "|")) : Cr.write(i, ".|");
      }
      Cr.newline(i);
    }
    return Cr.getString(i);
  };
}(Or || (Or = {})), function(e) {
  e.ofTables = function(t, r, n) {
    var i = Object.keys(n), a = /* @__PURE__ */ Object.create(null), o = [];
    a._name = t, a._tableNames = o, a._schema = r;
    for (var u = 0, s = i; u < s.length; u++) {
      var c = s[u];
      Or.is(n[c]) && (a[c] = n[c], o[o.length] = c);
    }
    return a;
  }, e.getTablesAsRows = function(t) {
    for (var r = {}, n = 0, i = t._tableNames; n < i.length; n++) {
      var a = i[n];
      r[a] = Or.getRows(t[a]);
    }
    return r;
  };
}(Q5 || (Q5 = {})), function(e) {
  e.Zero = 0;
  var t, r, n = (t = new ArrayBuffer(8), r = new ArrayBuffer(8), { _int32: new Int32Array(t), _float64: new Float64Array(t), _int32_1: new Int32Array(r), _float64_1: new Float64Array(r) }), i = n._int32, a = n._float64, o = n._int32_1, u = n._float64_1;
  e.is = function(s) {
    return typeof s == "number";
  }, e.create = function(s, c) {
    return i[0] = s, i[1] = c, a[0];
  }, e.diff = function(s) {
    return a[0] = s, i[1] - i[0];
  }, e.fst = function(s) {
    return a[0] = s, i[0];
  }, e.snd = function(s) {
    return a[0] = s, i[1];
  }, e.areEqual = function(s, c) {
    return a[0] = s, u[0] = c, i[0] === o[0] && i[1] === o[1];
  }, e.compare = function(s, c) {
    a[0] = s, u[0] = c;
    var l = i[0] - o[0];
    return l !== 0 ? l : i[1] - o[1];
  }, e.compareInArray = function(s, c, l) {
    a[0] = s[c], u[0] = s[l];
    var d = i[0] - o[0];
    return d !== 0 ? d : i[1] - o[1];
  }, e.hashCode = function(s) {
    return a[0] = s, h0(i[0], i[1]);
  }, e.toString = function(s) {
    return a[0] = s, "(".concat(i[0], ", ").concat(i[1], ")");
  };
}(di || (di = {}));
var zE = di.Zero;
function n9(e, t) {
  return t < e ? di.create(e, e) : di.create(e, t + 1);
}
function i_(e, t) {
  return t <= e ? di.create(e, e) : di.create(e, t);
}
function CU(e) {
  return e < 0 ? di.create(0, 0) : di.create(0, e);
}
var wU = di.is, Mc = di.fst, ed = di.snd, h2 = di.fst;
function v2(e) {
  return di.snd(e) - 1;
}
var tf = di.diff, DU = di.hashCode, IU = di.toString;
function EU(e, t) {
  return di.fst(e) <= t && t < di.snd(e);
}
function MU(e, t) {
  var r = Mc(e);
  return t >= r && t < ed(e) ? t - r : -1;
}
function TU(e, t) {
  return di.fst(e) + t;
}
var Ae, PU = di.areEqual;
function GE(e, t) {
  var r = tf(e), n = tf(t);
  return r === 0 && n === 0 || r > 0 && n > 0 && v2(e) >= h2(t) && h2(e) <= v2(t);
}
function BU(e, t) {
  return tf(e) ? !tf(t) || Mc(e) <= Mc(t) && ed(e) >= ed(t) : tf(t) === 0;
}
function eb(e, t) {
  var r = Mc(e);
  if (t <= r) return 0;
  var n = ed(e);
  return t >= n ? n - r : t - r;
}
function FU(e, t, r) {
  var n = Mc(r), i = Mc(e);
  if (t <= n + i) return n;
  var a = ed(r);
  return t >= a + i ? a : t - i;
}
function VE(e, t, r) {
  return i_(eb(e, t), eb(e, r + 1));
}
function NU(e, t) {
  return GE(e, t) ? i_(Math.max(Mc(e), Mc(t)), Math.min(ed(e), ed(t))) : zE;
}
function RU(e, t) {
  return tf(VE(e, h2(t), v2(t)));
}
(function(e) {
  e.Empty = zE, e.ofSingleton = function(t) {
    return n9(t, t);
  }, e.ofRange = n9, e.ofBounds = i_, e.ofLength = CU, e.is = wU, e.has = EU, e.indexOf = MU, e.getAt = TU, e.start = Mc, e.end = ed, e.min = h2, e.max = v2, e.size = tf, e.hashCode = DU, e.toString = IU, e.areEqual = PU, e.areIntersecting = GE, e.isSubInterval = BU, e.findPredecessorIndex = eb, e.findPredecessorIndexInInterval = FU, e.findRange = VE, e.intersectionSize = RU, e.intersect = NU;
})(Ae || (Ae = {}));
var Jp = [];
function OU(e) {
  return [e];
}
function LU(e) {
  return e;
}
function kU(e) {
  return es(e), e;
}
function i9(e, t) {
  if (t < e) return [];
  for (var r = new Int32Array(t - e + 1), n = e; n <= t; n++) r[n - e] = n;
  return r;
}
function zU(e) {
  return e && (Array.isArray(e) || !!e.buffer);
}
function UE(e) {
  return e[e.length - 1] - e[0] + 1 === e.length;
}
function tb(e) {
  return e[0];
}
function rb(e) {
  return e[e.length - 1] + 1;
}
function GU(e) {
  return e[0];
}
function VU(e) {
  return e[e.length - 1];
}
function HE(e) {
  return e.length;
}
function UU(e) {
  var t = e.length;
  return t ? t > 2 ? function(r, n, i, a) {
    var o = 23;
    return o = 31 * (o = 31 * (o = 31 * (o = 31 * o + r | 0) + n | 0) + i | 0) + a | 0, o = (3735928559 ^ (o ^= o >> 4)) + (o << 5), o ^ o >> 11;
  }(t, e[0], e[t - 1], e[t >> 1]) : function(r, n, i) {
    var a = 23;
    return a = 31 * (a = 31 * (a = 31 * a + r | 0) + n | 0) + i | 0, a = (3735928559 ^ (a ^= a >> 4)) + (a << 5), a ^ a >> 11;
  }(t, e[0], e[t - 1]) : 0;
}
function HU(e) {
  var t = e.length;
  return t > 5 ? "[".concat(e[0], ", ").concat(e[1], ", ..., ").concat(e[t - 1], "], length ").concat(t) : "[".concat(e.join(", "), "]");
}
function qE(e, t) {
  var r = e.length;
  return r === 0 ? -1 : e[0] <= t && t <= e[r - 1] ? jE(e, t, 0, r) : -1;
}
function qU(e, t, r) {
  return KE(e, t, Ae.start(r), Ae.end(r));
}
function KE(e, t, r, n) {
  return e.length === 0 || n <= r ? -1 : e[r] <= t && t <= e[n - 1] ? jE(e, t, r, n) : -1;
}
function KU(e, t) {
  return qE(e, t) >= 0;
}
function XE(e, t) {
  if (e === t) return !0;
  var r = e.length;
  if (r !== t.length || e[0] !== t[0] || e[r - 1] !== t[r - 1]) return !1;
  if (UE(e)) return !0;
  r--;
  for (var n = 1; n < r; n++) if (e[n] !== t[n]) return !1;
  return !0;
}
function Qd(e, t) {
  var r = e.length;
  return t <= e[0] ? 0 : t > e[r - 1] ? r : YE(e, t, 0, r);
}
function XU(e, t, r) {
  var n = Ae.start(r), i = Ae.end(r), a = e[n];
  return t <= a ? n : i > n && t > e[i - 1] ? i : t - a <= 11 ? function(o, u, s, c) {
    for (var l = s; l < c; l++) if (u <= o[l]) return l;
    return c;
  }(e, t, n + 1, i) : YE(e, t, n, i);
}
function jU(e, t, r) {
  return Ae.ofBounds(Qd(e, t), Qd(e, r + 1));
}
function jE(e, t, r, n) {
  for (var i = r, a = n - 1; i <= a; ) {
    if (i + 11 > a) {
      for (var o = i; o <= a; o++) if (t === e[o]) return o;
      return -1;
    }
    var u = i + a >> 1, s = e[u];
    if (t < s) a = u - 1;
    else {
      if (!(t > s)) return u;
      i = u + 1;
    }
  }
  return -1;
}
function YE(e, t, r, n) {
  for (var i = r, a = n - 1; i < a; ) {
    if (i + 11 > a) {
      for (var o = i; o <= a; o++) if (t <= e[o]) return o;
      return a + 1;
    }
    var u = i + a >> 1, s = e[u];
    if (t < s) a = u - 1;
    else {
      if (!(t > s)) return u;
      i = u + 1;
    }
  }
  return i > a ? a + 1 : e[i] >= t ? i : i + 1;
}
function YU(e, t) {
  if (e === t) return !0;
  for (var r = Af(e, t), n = r.startI, i = r.startJ, a = r.endI, o = r.endJ; n < a && i < o; ) {
    var u = e[n], s = t[i];
    if (u < s) n++;
    else {
      if (!(u > s)) return !0;
      i++;
    }
  }
  return !1;
}
function WU(e, t) {
  if (e === t) return !0;
  var r = t.length, n = Af(e, t), i = n.startI, a = n.startJ, o = n.endI, u = n.endJ;
  if (u - a < r || o - i < r) return !1;
  for (var s = 0; i < o && a < u; ) {
    var c = e[i], l = t[a];
    c < l ? i++ : c > l ? a++ : (i++, a++, s++);
  }
  return s === r;
}
function WE(e, t) {
  if (e === t) return e;
  var r = e.length, n = t.length;
  if (r === 0) return t;
  if (n === 0) return e;
  if (e[0] > t[0]) return WE(t, e);
  var i = Af(e, t), a = i.startI, o = i.startJ, u = i.endI, s = i.endJ, c = a_(e, t, a, o, u, s);
  if (c === r && c === n || c === n) return e;
  if (c === r) return t;
  var l = new Int32Array(r + n - c), d = 0, f = 0, m = 0;
  for (d = 0; d < a; d++) l[m++] = e[d];
  for (; f < s && e[a] > t[f]; ) l[m++] = t[f++];
  for (; d < u && f < s; ) {
    var v = e[d], p = t[f];
    v < p ? (l[m++] = v, d++) : v > p ? (l[m++] = p, f++) : (l[m++] = v, d++, f++);
  }
  for (; d < u; d++) l[m++] = e[d];
  for (; f < s; f++) l[m++] = t[f];
  for (; d < r; d++) l[m++] = e[d];
  for (; f < n; f++) l[m++] = t[f];
  return l;
}
function ZU(e, t) {
  if (e === t) return HE(e);
  var r = Af(e, t);
  return a_(e, t, r.startI, r.startJ, r.endI, r.endJ);
}
function a_(e, t, r, n, i, a) {
  for (var o = r, u = n, s = 0; o < i && u < a; ) {
    var c = e[o], l = t[u];
    c < l ? o++ : c > l ? u++ : (o++, u++, s++);
  }
  return s;
}
function QU(e, t) {
  if (e === t) return e;
  var r = Af(e, t), n = r.startI, i = r.startJ, a = r.endI, o = r.endJ, u = a_(e, t, n, i, a, o), s = e.length, c = t.length;
  if (!u) return Jp;
  if (u === s && u === c || u === c) return t;
  if (u === s) return e;
  for (var l = new Int32Array(u), d = 0, f = n, m = i; f < a && m < o; ) {
    var v = e[f], p = t[m];
    v < p ? f++ : (v > p || (l[d++] = v, f++), m++);
  }
  return l;
}
function JU(e, t) {
  if (e === t) return Jp;
  for (var r = e.length, n = Af(e, t), i = n.startI, a = n.startJ, o = n.endI, u = n.endJ, s = i, c = a, l = 0; s < o && c < u; )
    (v = e[s]) < (p = t[c]) ? s++ : v > p ? c++ : (s++, c++, l++);
  if (!l) return e;
  if (l >= r) return Jp;
  for (var d = new Int32Array(r - l), f = 0, m = 0; m < i; m++) d[f++] = e[m];
  for (s = i, c = a; s < o && c < u; ) {
    var v, p;
    (v = e[s]) < (p = t[c]) ? (d[f++] = v, s++) : (v > p || s++, c++);
  }
  for (; s < r; s++) d[f++] = e[s];
  return d;
}
function $U(e) {
  if (e.length < 2) return e;
  for (var t = 1, r = 0, n = e.length - 1; r < n; r++) e[r] !== e[r + 1] && t++;
  if (t === e.length) return e;
  var i = new Int32Array(t), a = 0;
  for (r = 0, n = e.length - 1; r < n; r++) e[r] !== e[r + 1] && (i[a++] = e[r]);
  return i[a] = e[e.length - 1], i;
}
function eH(e, t) {
  if (XE(e, t)) return $5(0, e.length - 1);
  for (var r = Af(e, t), n = r.startI, i = r.startJ, a = r.endI, o = r.endJ, u = n, s = i, c = 0; u < a && s < o; )
    (m = e[u]) < (v = t[s]) ? u++ : m > v ? s++ : (u++, s++, c++);
  var l = e.length;
  if (!c) return Jp;
  if (c === l) return $5(0, e.length - 1);
  var d = new Int32Array(c), f = 0;
  for (u = n, s = i; u < a && s < o; ) {
    var m, v;
    (m = e[u]) < (v = t[s]) ? u++ : (m > v || (d[f++] = u, u++), s++);
  }
  return d;
}
var qe, Qs = { startI: 0, startJ: 0, endI: 0, endJ: 0 };
function Af(e, t) {
  var r = e.length, n = t.length, i = r / n;
  return r >= 128 || n >= 128 || i <= 0.34 || i >= 2.99 ? (Qs.startI = Qd(e, tb(t)), Qs.startJ = Qd(t, tb(e)), Qs.endI = Qd(e, rb(t)), Qs.endJ = Qd(t, rb(e))) : (Qs.startI = 0, Qs.startJ = 0, Qs.endI = r, Qs.endJ = n), Qs;
}
(function(e) {
  e.Empty = Jp, e.ofUnsortedArray = kU, e.ofSingleton = OU, e.ofSortedArray = LU, e.ofRange = i9, e.ofBounds = function(t, r) {
    return i9(t, r - 1);
  }, e.is = zU, e.isRange = UE, e.has = KU, e.indexOf = qE, e.indexOfInInterval = qU, e.indexOfInRange = KE, e.start = tb, e.end = rb, e.min = GU, e.max = VU, e.size = HE, e.hashCode = UU, e.toString = HU, e.areEqual = XE, e.areIntersecting = YU, e.isSubset = WU, e.union = WE, e.intersect = QU, e.subtract = JU, e.findPredecessorIndex = Qd, e.findPredecessorIndexInInterval = XU, e.findRange = jU, e.intersectionSize = ZU, e.deduplicate = $U, e.indicesOf = eH;
})(qe || (qe = {}));
var Le, ws = Ae.Empty, tH = Ae.ofSingleton, rH = Ae.ofRange, nH = Ae.ofBounds;
function Ju(e) {
  return e.length ? qe.isRange(e) ? Ae.ofRange(e[0], e[e.length - 1]) : e : ws;
}
function rf(e) {
  return Ae.is(e) ? Ae.size(e) : qe.size(e);
}
function iH(e, t) {
  return Ae.is(e) ? Ae.has(e, t) : qe.has(e, t);
}
function aH(e, t) {
  return Ae.is(e) ? Ae.indexOf(e, t) : qe.indexOf(e, t);
}
function nb(e, t) {
  return Ae.is(e) ? Ae.getAt(e, t) : e[t];
}
function V1(e) {
  return Ae.is(e) ? Ae.min(e) : qe.min(e);
}
function U1(e) {
  return Ae.is(e) ? Ae.max(e) : qe.max(e);
}
function oH(e) {
  return Ae.is(e) ? Ae.start(e) : qe.start(e);
}
function uH(e) {
  return Ae.is(e) ? Ae.end(e) : qe.end(e);
}
function sH(e) {
  return Ae.is(e) ? Ae.hashCode(e) : qe.hashCode(e);
}
function cH(e, t) {
  return Ae.is(e) ? Ae.is(t) ? Ae.areEqual(e, t) : a9(e, t) : Ae.is(t) ? a9(t, e) : qe.areEqual(e, t);
}
function lH(e, t) {
  return Ae.is(e) ? Ae.is(t) ? Ae.areIntersecting(e, t) : o9(t, e) : Ae.is(t) ? o9(e, t) : qe.areIntersecting(e, t);
}
function dH(e, t) {
  return Ae.is(e) ? Ae.is(t) ? Ae.isSubInterval(e, t) : function(r, n) {
    var i = Ae.min(r), a = Ae.max(r);
    if (a - i + 1 == 0) return !1;
    var o = qe.min(n), u = qe.max(n);
    return o >= i && u <= a;
  }(e, t) : Ae.is(t) ? function(r, n) {
    var i = Ae.min(n), a = Ae.max(n);
    if (a - i + 1 == 0) return !0;
    var o = qe.min(r), u = qe.max(r);
    if (i < o || a > u) return !1;
    var s = qe.findRange(r, i, a);
    return Ae.size(s) === Ae.size(n);
  }(e, t) : qe.isSubset(e, t);
}
function fH(e, t) {
  return Ae.is(e) ? Ae.findPredecessorIndex(e, t) : qe.findPredecessorIndex(e, t);
}
function pH(e, t, r) {
  return Ae.is(e) ? Ae.findPredecessorIndexInInterval(e, t, r) : qe.findPredecessorIndexInInterval(e, t, r);
}
function mH(e, t, r) {
  return Ae.is(e) ? Ae.findRange(e, t, r) : qe.findRange(e, t, r);
}
function hH(e, t) {
  return Ae.is(e) ? Ae.is(t) ? Ae.intersectionSize(e, t) : s9(t, e) : Ae.is(t) ? s9(e, t) : qe.intersectionSize(e, t);
}
function vH(e, t) {
  return Ae.is(e) ? Ae.is(t) ? function(r, n) {
    if (Ae.areEqual(r, n)) return r;
    var i = Ae.size(r), a = Ae.size(n);
    if (!a) return r;
    if (!i) return n;
    var o, u, s, c, l = Ae.min(r), d = Ae.min(n);
    if (function(v, p) {
      var g = rf(v), h = rf(p);
      return g === 0 && h === 0 || g > 0 && h > 0 && U1(v) >= V1(p) && V1(v) <= U1(p);
    }(r, n)) return Ae.ofRange(Math.min(l, d), Math.max(Ae.max(r), Ae.max(n)));
    l < d ? (o = i, u = l, s = a, c = d) : (o = a, u = d, s = i, c = l);
    for (var f = new Int32Array(i + a), m = 0; m < o; m++) f[m] = m + u;
    for (m = 0; m < s; m++) f[m + o] = m + c;
    return Ju(f);
  }(e, t) : u9(t, e) : Ae.is(t) ? u9(e, t) : Ju(qe.union(e, t));
}
function gH(e, t) {
  return Ae.is(e) ? Ae.is(t) ? Ae.intersect(e, t) : c9(t, e) : Ae.is(t) ? c9(e, t) : Ju(qe.intersect(e, t));
}
function yH(e, t) {
  return Ae.is(e) ? Ae.is(t) ? function(r, n) {
    if (Ae.areEqual(r, n)) return ws;
    if (!Ae.areIntersecting(r, n)) return r;
    var i = Ae.min(r), a = Ae.max(r), o = Ae.min(n), u = Ae.max(n);
    if (a < i || u < o) return r;
    if (Ae.isSubInterval(n, r)) return ws;
    if (Ae.isSubInterval(r, n)) {
      var s = o - i, c = a - u;
      if (s <= 0) return Ae.ofRange(u + 1, u + c);
      if (c <= 0) return Ae.ofRange(i, i + s - 1);
      for (var l = new Int32Array(s + c), d = 0, f = 0; f < s; f++) l[d++] = i + f;
      for (f = 1; f <= c; f++) l[d++] = u + f;
      return Ju(l);
    }
    return i < o ? Ae.ofRange(i, o - 1) : Ae.ofRange(u + 1, a);
  }(e, t) : function(r, n) {
    var i = Ae.min(r), a = Ae.max(r);
    if (a < i) return r;
    var o = a - i + 1, u = qe.findRange(n, i, a), s = Ae.start(u), c = Ae.end(u), l = c - s;
    if (l === 0) return r;
    var d = o - l;
    if (d <= 0) return ws;
    for (var f = new Int32Array(d), m = n.length - 1, v = n[Math.min(s, m)], p = n[Math.min(c, m)], g = 0, h = i; h < v; h++) f[g++] = h;
    for (h = v; h <= p; h++) qe.indexOfInInterval(n, h, u) < 0 && (f[g++] = h);
    for (h = p + 1; h <= a; h++) f[g++] = h;
    return Ju(f);
  }(e, t) : Ae.is(t) ? function(r, n) {
    var i = Ae.min(n), a = Ae.max(n);
    if (a < i) return r;
    var o = qe.findRange(r, i, a), u = Ae.start(o), s = Ae.end(o), c = r.length - (s - u);
    if (c <= 0) return ws;
    if (c === r.length) return r;
    for (var l = new Int32Array(c), d = 0, f = 0; f < u; f++) l[d++] = r[f];
    f = s;
    for (var m = r.length; f < m; f++) l[d++] = r[f];
    return Ju(l);
  }(e, t) : Ju(qe.subtract(e, t));
}
function a9(e, t) {
  return Ae.size(e) === qe.size(t) && Ae.start(e) === qe.start(t) && Ae.end(e) === qe.end(t);
}
function o9(e, t) {
  return e.length !== 0 && Ae.size(qe.findRange(e, Ae.min(t), Ae.max(t))) !== 0;
}
function bH(e, t) {
  return rf(e) ? !rf(t) || V1(e) <= V1(t) && U1(e) >= U1(t) : rf(t) === 0;
}
function u9(e, t) {
  var r = Ae.size(t);
  if (!r) return e;
  if (bH(t, e)) return t;
  for (var n = Ae.min(t), i = Ae.max(t), a = qe.findRange(e, n, i), o = Ae.start(a), u = Ae.end(a), s = new Int32Array(o + (e.length - u) + r), c = 0, l = 0; l < o; l++) s[c++] = e[l];
  for (l = n; l <= i; l++) s[c++] = l;
  l = u;
  for (var d = e.length; l < d; l++) s[c++] = e[l];
  return Ju(s);
}
function s9(e, t) {
  if (!Ae.size(t)) return 0;
  var r = qe.findRange(e, Ae.min(t), Ae.max(t));
  return Ae.end(r) - Ae.start(r);
}
function c9(e, t) {
  if (!Ae.size(t)) return ws;
  var r = qe.findRange(e, Ae.min(t), Ae.max(t)), n = Ae.start(r), i = Ae.end(r), a = i - n;
  if (!a) return ws;
  if (a === e.length) return e;
  for (var o = new Int32Array(a), u = 0, s = n; s < i; s++) o[u++] = e[s];
  return Ju(o);
}
function _H(e, t, r) {
  if (t === r) return e;
  var n = rf(e), i = t.length, a = r.length;
  if (n === 0 || i === 0 || a === 0) return ws;
  for (var o = qe.findPredecessorIndex(r, t[V1(e)]), u = qe.findPredecessorIndex(r, t[U1(e)] + 1), s = 0, c = 0, l = 0, d = o; l < n && d < u; )
    (m = t[nb(e, l)]) < (v = r[d]) ? l++ : (m > v || (s++, l++), d++);
  if (s === 0) return ws;
  if (s === i && s === a) return e;
  var f = new Int32Array(s);
  for (c = 0, l = 0, d = o; l < n && d < u; ) {
    var m, v;
    (m = t[nb(e, l)]) < (v = r[d]) ? l++ : (m > v || (f[c++] = d, l++), d++);
  }
  return Ju(f);
}
function ZE(e) {
  for (var t = qe.ofSortedArray(e), r = qe.max(t), n = new Int32Array(r), i = 0, a = e.length - 1; i < a; i++) for (var o = e[i], u = e[i + 1]; o < u; o++) n[o] = i;
  return { offsets: t, index: n, count: e.length - 1 };
}
function xH(e, t) {
  for (var r = Ae.start(t), n = new Int32Array(e.length + 1), i = 0, a = e.length; i < a; i++) n[i] = e[i] - r;
  return n[e.length] = Ae.end(t) - r, ZE(n);
}
function AH(e) {
  return e.count;
}
function SH(e, t) {
  return e.index[t];
}
function CH(e, t, r) {
  var n = e.offsets, i = r >= Le.max(n) ? -1 : Le.findPredecessorIndex(n, r - 1);
  return Le.findRange(t, Le.getAt(n, i), Le.getAt(n, i + 1) - 1);
}
(function(e) {
  e.Empty = ws, e.ofSingleton = tH, e.ofRange = rH, e.ofBounds = nH, e.ofSortedArray = Ju, e.has = iH, e.indexOf = aH, e.getAt = nb, e.min = V1, e.max = U1, e.start = oH, e.end = uH, e.size = rf, e.hashCode = sH, e.areEqual = cH, e.areIntersecting = lH, e.isSubset = dH, e.union = vH, e.intersect = gH, e.indexedIntersect = _H, e.subtract = yH, e.findPredecessorIndex = fH, e.findPredecessorIndexInInterval = pH, e.findRange = mH, e.intersectionSize = hH, e.forEach = function(t, r, n) {
    return function(i, a, o) {
      if (Ae.is(i)) for (var u = Ae.min(i), s = u, c = Ae.max(i); s <= c; s++) a(s, s - u, o);
      else for (s = 0, c = i.length; s < c; s++) a(i[s], s, o);
      return o;
    }(t, r, n);
  }, e.forEachSegment = function(t, r, n, i) {
    return function(a, o, u, s) {
      if (Ae.is(a)) for (var c = 0, l = Ae.min(a), d = Ae.max(a); l <= d; l++) {
        for (var f = o(l), m = l + 1; m < d && o(m) === f; ) m++;
        l = m - 1, u(f, c, s), c++;
      }
      else for (c = 0, l = 0, d = a.length; l < d; l++) {
        for (f = o(a[l]), m = l + 1; m < d && o(a[m]) === f; ) m++;
        l = m - 1, u(f, c, s), c++;
      }
      return s;
    }(t, r, n, i);
  }, e.isInterval = function(t) {
    return Ae.is(t);
  }, e.isSortedArray = function(t) {
    return !Ae.is(t);
  }, e.toArray = function(t) {
    var r = [];
    return e.forEach(t, function(n) {
      return r.push(n);
    }), r;
  }, e.toString = function(t) {
    return function(r) {
      return Ae.is(r) ? Ae.toString(r) : qe.toString(r);
    }(t);
  };
})(Le || (Le = {}));
var Zt, wH = function() {
  function e(t, r, n, i) {
    this.segments = t, this.segmentMap = r, this.set = n, this.segmentMin = 0, this.segmentMax = 0, this.setRange = Ae.Empty, this.value = { index: 0, start: 0, end: 0 }, this.hasNext = !1, this.setRange = i, this.updateSegmentRange();
  }
  return e.prototype.move = function() {
    for (; this.hasNext; ) {
      if (this.updateValue()) {
        this.value.index = this.segmentMin++, this.hasNext = this.segmentMax >= this.segmentMin && Ae.size(this.setRange) > 0;
        break;
      }
      this.updateSegmentRange();
    }
    return this.value;
  }, e.prototype.updateValue = function() {
    var t = this.segments[this.segmentMin + 1], r = Le.findPredecessorIndexInInterval(this.set, t, this.setRange);
    return this.value.start = Ae.start(this.setRange), this.value.end = r, this.setRange = Ae.ofBounds(r, Ae.end(this.setRange)), r > this.value.start;
  }, e.prototype.updateSegmentRange = function() {
    var t = Ae.min(this.setRange), r = Ae.max(this.setRange);
    r < t ? this.hasNext = !1 : (this.segmentMin = this.segmentMap[Le.getAt(this.set, t)], this.segmentMax = this.segmentMap[Le.getAt(this.set, r)], this.hasNext = this.segmentMax >= this.segmentMin);
  }, e.prototype.setSegment = function(t) {
    this.setRange = Ae.ofBounds(t.start, t.end), this.updateSegmentRange();
  }, e;
}();
function DH(e, t, r) {
  var n = r !== void 0 ? Ae.ofBounds(r.start, r.end) : Ae.ofBounds(0, Le.size(t));
  return new wH(e.offsets, e.index, t, n);
}
(function(e) {
  e.create = ZE, e.ofOffsets = xH, e.count = AH, e.getSegment = SH, e.projectValue = CH, e.transientSegments = DH;
})(Zt || (Zt = {}));
var Ps, IH = function() {
  function e(t) {
    this.head = t > 0 ? 0 : -1, this.prev = new Int32Array(t), this.next = new Int32Array(t);
    for (var r = 0; r < t; r++) this.next[r] = r + 1, this.prev[r] = r - 1;
    this.prev[0] = -1, this.next[t - 1] = -1;
  }
  return e.prototype.remove = function(t) {
    var r = this.prev, n = this.next, i = r[t], a = n[t];
    i >= 0 && (n[i] = a, r[t] = -1), a >= 0 && (r[a] = i, n[t] = -1), t === this.head && (this.head = i < 0 ? a : i);
  }, e.prototype.has = function(t) {
    return this.prev[t] >= 0 || this.next[t] >= 0 || this.head === t;
  }, e;
}();
(function(e) {
  function t() {
    return /* @__PURE__ */ new Map();
  }
  e.Empty = /* @__PURE__ */ new Map(), e.keyArray = function(r) {
    return n_(r.keys());
  }, e.Mutable = t, e.asImmutable = function(r) {
    return r;
  }, e.copy = function(r) {
    for (var n = t(), i = r.keys(); ; ) {
      var a = i.next(), o = a.done, u = a.value;
      if (o) break;
      n.set(u, r.get(u));
    }
    return n;
  }, e.addFrom = function(r, n) {
    for (var i = n.keys(); ; ) {
      var a = i.next(), o = a.done, u = a.value;
      if (o) break;
      r.set(u, n.get(u));
    }
    return r;
  };
})(Ps || (Ps = {}));
var g2, EH = function() {
  function e(t) {
    this.xs = [], this.index = -1, this.length = 0, this.hasNext = !1, this.length = t.length, this.hasNext = t.length > 0, this.xs = t, this.index = -1, this.lastValue = t.length > 0 ? t[0] : void 0;
  }
  return e.prototype.move = function() {
    return ++this.index, this.lastValue = this.xs[this.index], this.hasNext = this.index < this.length - 1, this.lastValue;
  }, e;
}(), l9 = function() {
  function e(t, r) {
    this.max = r, this.value = 0, this.hasNext = !1, this.value = t - 1, this.hasNext = r >= t;
  }
  return e.prototype.move = function() {
    return ++this.value, this.hasNext = this.value < this.max, this.value;
  }, e;
}(), MH = function() {
  function e(t) {
    this.value = t, this.hasNext = !0;
  }
  return e.prototype.move = function() {
    return this.hasNext = !1, this.value;
  }, e;
}(), TH = function() {
  function e(t, r) {
    this.base = t, this.f = r, this.hasNext = !1, this.hasNext = t.hasNext;
  }
  return e.prototype.move = function() {
    var t = this.f(this.base.move());
    return this.hasNext = this.base.hasNext, t;
  }, e;
}(), PH = function() {
  function e(t, r) {
    this.base = t, this.p = r, this.hasNext = this.findNext();
  }
  return e.prototype.move = function() {
    var t = this.next;
    return this.hasNext = this.findNext(), t;
  }, e.prototype.findNext = function() {
    for (; this.base.hasNext; ) if (this.next = this.base.move(), this.p(this.next)) return !0;
    return !1;
  }, e;
}();
(function(e) {
  e.Empty = new l9(0, -1), e.Array = function(t) {
    return new EH(t);
  }, e.Value = function(t) {
    return new MH(t);
  }, e.Range = function(t, r) {
    return new l9(t, r);
  }, e.map = function(t, r) {
    return new TH(t, r);
  }, e.filter = function(t, r) {
    return new PH(t, r);
  }, e.forEach = function(t, r, n) {
    for (; t.hasNext; )
      if (r(t.move(), n)) return n;
    return n;
  };
})(g2 || (g2 = {}));
var Bs, to, BH = { domain: [0, 1], reverse: !1, listOrName: "red-yellow-blue", minLabel: "", maxLabel: "" };
function o_(e) {
  return Object.keys(e);
}
function Hi(e) {
  throw new Error("unreachable");
}
function u_(e) {
  return typeof (e == null ? void 0 : e.then) == "function";
}
(function(e) {
  e.create = function(t) {
    var r = R(R({}, BH), t), n = r.domain, i = r.reverse, a = r.listOrName, o = typeof a == "string" ? Ec(a).list : a, u = i ? o.slice().reverse() : o, s = u.length - 1, c = 0, l = 0, d = 0;
    function f(b, _) {
      c = (d = _) - (l = b) || 1;
    }
    f(n[0], n[1]);
    var m, v = Ci(t.minLabel, l.toString()), p = Ci(t.maxLabel, d.toString()), g = u.every(function(b) {
      return Array.isArray(b);
    });
    if (g) {
      var h = We([], u, !0);
      h.sort(function(b, _) {
        return b[1] - _[1];
      });
      var y = h.map(function(b) {
        return b[0];
      }), x = qe.ofSortedArray(h.map(function(b) {
        return b[1];
      })), A = y.length - 1;
      m = function(b) {
        var _ = Qa((b - l) / c, 0, 1), S = qe.findPredecessorIndex(x, _);
        if (S === 0) return y[l];
        if (S > A) return y[A];
        var D = x[S - 1], I = Qa((_ - D) / (x[S] - D), 0, 1);
        return He.interpolate(y[S - 1], y[S], I);
      };
    } else m = function(b) {
      var _ = Math.min(u.length - 1, Math.max(0, (b - l) / c * s)), S = Math.floor(_), D = u[S], I = u[Math.ceil(_)];
      return He.interpolate(D, I, _ - S);
    };
    return { color: m, colorToArray: function(b, _, S) {
      He.toArray(m(b), _, S);
    }, normalizedColorToArray: function(b, _, S) {
      He.toArrayNormalized(m(b), _, S);
    }, setDomain: f, get legend() {
      return /* @__PURE__ */ function(b, _, S) {
        return { kind: "scale-legend", minLabel: b, maxLabel: _, colors: S };
      }(v, p, u);
    } };
  };
})(Bs || (Bs = {})), function(e) {
  e.toArray = function(t) {
    return n_(t.values());
  }, e.isSuperset = function(t, r) {
    var n = !0;
    return r.forEach(function(i) {
      t.has(i) || (n = !1);
    }), n;
  }, e.add = function(t) {
    for (var r = [], n = 1; n < arguments.length; n++) r[n - 1] = arguments[n];
    for (var i = 0; i < r.length; i++) r[i].forEach(function(a) {
      return t.add(a);
    });
    return t;
  }, e.union = function(t, r) {
    var n = new Set(t);
    return r.forEach(function(i) {
      return n.add(i);
    }), n;
  }, e.unionMany = function() {
    for (var t = [], r = 0; r < arguments.length; r++) t[r] = arguments[r];
    if (t.length === 0) return /* @__PURE__ */ new Set();
    t.length === 1 && new Set(t[0]);
    for (var n = new Set(t[0]), i = 1, a = t.length; i < a; i++) t[i].forEach(function(o) {
      return n.add(o);
    });
    return n;
  }, e.unionManyArrays = function(t) {
    if (t.length === 0) return /* @__PURE__ */ new Set();
    for (var r = new Set(t[0]), n = 1; n < t.length; n++) for (var i = 0, a = t[n]; i < a.length; i++) {
      var o = a[i];
      r.add(o);
    }
    return r;
  }, e.intersection = function(t, r) {
    var n = /* @__PURE__ */ new Set();
    return r.forEach(function(i) {
      t.has(i) && n.add(i);
    }), n;
  }, e.areIntersecting = function(t, r) {
    var n = !1;
    return r.forEach(function(i) {
      t.has(i) && (n = !0);
    }), n;
  }, e.intersectionSize = function(t, r) {
    var n = 0;
    return r.forEach(function(i) {
      t.has(i) && (n += 1);
    }), n;
  }, e.difference = function(t, r) {
    var n = new Set(t);
    return r.forEach(function(i) {
      return n.delete(i);
    }), n;
  }, e.differenceSize = function(t, r) {
    var n = t.size;
    return t.forEach(function(i) {
      r.has(i) && (n -= 1);
    }), n;
  }, e.areEqual = function(t, r) {
    if (t.size !== r.size) return !1;
    var n = !0;
    return r.forEach(function(i) {
      t.has(i) || (n = !1);
    }), n;
  };
}(to || (to = {}));
var s_ = function() {
};
function Ja(e, t) {
  var r = e.length;
  if (r !== t.length) return !1;
  for (var n = 0; n < r; n++) if (e[n] !== t[n]) return !1;
  return !0;
}
var QE = Object.prototype.hasOwnProperty;
function td(e, t) {
  if (e === t) return !0;
  var r = Array.isArray(e), n = Array.isArray(t);
  if (r && n) {
    if (e.length !== t.length) return !1;
    for (var i = 0; i < e.length; i++) if (!td(e[i], t[i])) return !1;
    return !0;
  }
  if (r !== n) return !1;
  if (e && t && typeof e == "object" && typeof t == "object") {
    var a = Object.keys(e);
    if (a.length !== Object.keys(t).length) return !1;
    var o = e instanceof Date, u = t instanceof Date;
    if (o && u) return e.getTime() === t.getTime();
    if (o !== u) return !1;
    var s = e instanceof RegExp, c = t instanceof RegExp;
    if (s && c) return e.toString() === t.toString();
    if (s !== c) return !1;
    for (i = 0; i < a.length; i++) if (!QE.call(t, a[i])) return !1;
    for (i = 0; i < a.length; i++) if (!td(e[a[i]], t[a[i]])) return !1;
    return !0;
  }
  return !1;
}
function ib(e, t) {
  if (e === t) return !0;
  var r = Array.isArray(e), n = Array.isArray(t);
  return r && n ? FH(e, t) : r === n && !(!e || !t || typeof e != "object" || typeof t != "object") && JE(e, t);
}
function JE(e, t) {
  if (e === t) return !0;
  if (!e || !t) return !1;
  var r = Object.keys(e);
  if (Object.keys(t).length !== r.length) return !1;
  for (var n = 0, i = r; n < i.length; n++) {
    var a = i[n];
    if (!QE.call(e, a) || e[a] !== t[a]) return !1;
  }
  return !0;
}
function FH(e, t) {
  if (e === t) return !0;
  if (!e || !t || e.length !== t.length) return !1;
  for (var r = 0, n = e.length; r < n; ++r) if (e[r] !== t[r]) return !1;
  return !0;
}
function Ci(e, t) {
  return e !== void 0 ? e : t;
}
function Iy(e) {
  if (typeof e == "object") {
    if ("buttons" in e) return e.buttons;
    if ("which" in e) {
      var t = e.which;
      if (t === 2) return 4;
      if (t === 3) return 2;
      if (t > 0) return 1 << t - 1;
    }
  }
  return 0;
}
function d9(e) {
  if (typeof e == "object" && "button" in e) {
    var t = e.button;
    if (t === 1) return 4;
    if (t === 2) return 2;
    if (t >= 0) return 1 << t;
  }
  return 0;
}
var H1, cf, f9 = { noScroll: !0, noMiddleClickScroll: !0, noContextMenu: !0, noPinchZoom: !0, noTextSelect: !0, preventGestures: !1, mask: function(e, t) {
  return !0;
}, pixelScale: 1 };
function p9() {
  return { drag: new ui(), interactionEnd: new ui(), click: new ui(), move: new ui(), wheel: new ui(), pinch: new ui(), gesture: new ui(), resize: new ui(), leave: new ui(), enter: new ui(), modifiers: new ui(), key: new ui() };
}
(function(e) {
  function t(r) {
    return r === void 0 && (r = {}), { shift: !!r.shift, alt: !!r.alt, control: !!r.control, meta: !!r.meta };
  }
  e.None = t(), e.areEqual = function(r, n) {
    return r.shift === n.shift && r.alt === n.alt && r.control === n.control && r.meta === n.meta;
  }, e.size = function(r) {
    if (!r) return 0;
    var n = 0;
    return r.shift && n++, r.alt && n++, r.control && n++, r.meta && n++, n;
  }, e.create = t;
})(H1 || (H1 = {})), function(e) {
  e.has = ya.has, e.create = ya.create;
}(cf || (cf = {}));
var ab, NH = ["Backspace", "Delete"];
function Vi() {
  return Vi.zero();
}
(function(e) {
  e.create = function(t) {
    t === void 0 && (t = {});
    var r = R(R({}, f9), t), n = r.noScroll, i = r.noContextMenu;
    return R(R({ noScroll: n, noContextMenu: i, width: 0, height: 0, pixelRatio: 1 }, p9()), { dispose: s_ });
  }, e.fromElement = function(t, r) {
    r === void 0 && (r = {});
    var n = R(R({}, f9), r), i = n.noScroll, a = n.noMiddleClickScroll, o = n.noContextMenu, u = n.noPinchZoom, s = n.noTextSelect, c = n.mask, l = n.pixelScale, d = n.preventGestures, f = t.clientWidth * _(), m = t.clientHeight * _(), v = 0, p = 0, g = ke(), h = ke(), y = ke(), x = ke(), A = ke(), b = { shift: !1, alt: !1, control: !1, meta: !1 };
    function _() {
      return window.devicePixelRatio * l;
    }
    function S() {
      return R({}, b);
    }
    var D, I, M = 0, F = !1, P = cf.create(0), E = 0, B = !1, N = p9(), O = N.drag, z = N.interactionEnd, V = N.wheel, U = N.pinch, H = N.gesture, K = N.click, j = N.move, X = N.leave, W = N.enter, Q = N.resize, te = N.modifiers, ee = N.key;
    return t.addEventListener("contextmenu", $, !1), t.addEventListener("wheel", ce, !1), t.addEventListener("mousedown", Fe, !1), window.addEventListener("mousemove", Je, !1), window.addEventListener("mouseup", Ne, !1), t.addEventListener("mouseenter", Ve, !1), t.addEventListener("mouseleave", ze, !1), t.addEventListener("touchstart", Ue, !1), t.addEventListener("touchmove", Ze, !1), t.addEventListener("touchend", Ke, !1), t.addEventListener("gesturechange", Se, !1), t.addEventListener("gesturestart", ve, !1), t.addEventListener("gestureend", Re, !1), window.addEventListener("blur", ae), window.addEventListener("keyup", le, !1), window.addEventListener("keydown", se, !1), window.addEventListener("keypress", pe, !1), window.addEventListener("resize", mt, !1), R(R({ get noScroll() {
      return i;
    }, set noScroll(De) {
      i = De;
    }, get noContextMenu() {
      return o;
    }, set noContextMenu(De) {
      o = De;
    }, get width() {
      return f;
    }, get height() {
      return m;
    }, get pixelRatio() {
      return _();
    } }, N), { dispose: function() {
      F || (F = !0, t.removeEventListener("contextmenu", $, !1), t.removeEventListener("wheel", ce, !1), t.removeEventListener("mousedown", Fe, !1), window.removeEventListener("mousemove", Je, !1), window.removeEventListener("mouseup", Ne, !1), t.removeEventListener("mouseenter", Ve, !1), t.removeEventListener("mouseleave", ze, !1), t.removeEventListener("touchstart", Ue, !1), t.removeEventListener("touchmove", Ze, !1), t.removeEventListener("touchend", Ke, !1), t.removeEventListener("gesturechange", Se, !1), t.removeEventListener("gesturestart", ve, !1), t.removeEventListener("gestureend", Re, !1), window.removeEventListener("blur", ae), window.removeEventListener("keyup", le, !1), window.removeEventListener("keydown", se, !1), window.removeEventListener("keypress", pe, !1), window.removeEventListener("resize", mt, !1));
    } });
    function $(De) {
      c(De.clientX, De.clientY) && o && De.preventDefault();
    }
    function ie(De) {
      b.alt = De.altKey, b.shift = De.shiftKey, b.control = De.ctrlKey, b.meta = De.metaKey;
    }
    function ae() {
      (P || b.shift || b.alt || b.meta || b.control) && (P = 0, b.shift = b.alt = b.control = b.meta = !1);
    }
    function se(De) {
      var ut = !1;
      !b.alt && De.altKey && (ut = !0, b.alt = !0), !b.shift && De.shiftKey && (ut = !0, b.shift = !0), !b.control && De.ctrlKey && (ut = !0, b.control = !0), !b.meta && De.metaKey && (ut = !0, b.meta = !0), ut && B && te.next(S());
    }
    function le(De) {
      var ut = !1;
      b.alt && !De.altKey && (ut = !0, b.alt = !1), b.shift && !De.shiftKey && (ut = !0, b.shift = !1), b.control && !De.ctrlKey && (ut = !0, b.control = !1), b.meta && !De.metaKey && (ut = !0, b.meta = !1), ut && B && te.next(S()), NH.includes(De.key) && pe(De);
    }
    function pe(De) {
      ee.next({ key: De.key, modifiers: S() });
    }
    function we(De) {
      var ut = De.touches[0], It = De.touches[1];
      return { clientX: (ut.clientX + It.clientX) / 2, clientY: (ut.clientY + It.clientY) / 2, pageX: (ut.pageX + It.pageX) / 2, pageY: (ut.pageY + It.pageY) / 2 };
    }
    function Ge(De) {
      var ut = De.touches[0].pageX - De.touches[1].pageX, It = De.touches[0].pageY - De.touches[1].pageY;
      return Math.sqrt(ut * ut + It * It);
    }
    function Ue(De) {
      if (De.preventDefault(), De.touches.length === 1) P = E = 1, re(De.touches[0]);
      else if (De.touches.length === 2) {
        P = 0, E = 2, re(we(De));
        var ut = Ge(De);
        v = ut, U.next({ distance: ut, fraction: 1, fractionDelta: 0, delta: 0, isStart: !0, buttons: P, button: E, modifiers: S() });
      } else De.touches.length === 3 && (P = E = 8, re(we(De)));
    }
    function Ke(De) {
      nt();
    }
    function Ze(De) {
      if (E = 0, u && (De.preventDefault(), De.stopPropagation(), De.originalEvent && (De.originalEvent.preventDefault(), De.originalEvent.stopPropagation())), De.touches.length === 1) P = 1, J(De.touches[0]);
      else if (De.touches.length === 2) {
        var ut = Ge(De), It = v - ut;
        if (Math.abs(It) < 4) P = 2, J(we(De));
        else {
          P = 4, ie(De);
          var ur = v / ut;
          U.next({ delta: It, fraction: ur, fractionDelta: p - ur, distance: ut, isStart: !1, buttons: P, button: E, modifiers: S() }), p = ur;
        }
        v = ut;
      } else De.touches.length === 3 && (P = 8, J(we(De)));
    }
    function Fe(De) {
      ie(De), P = Iy(De), E = d9(De), a && P === 4 && De.preventDefault, re(De);
    }
    function Je(De) {
      ie(De), P = Iy(De), E = 0, J(De);
    }
    function Ne(De) {
      ie(De), P = Iy(De), E = d9(De), function(ut) {
        if (M = 0, !!c(ut.clientX, ut.clientY) && (Ct(y, ut), ke.distance(y, g) < 4)) {
          var It = ut.pageX, ur = ut.pageY, nr = y[0], Er = y[1];
          K.next({ x: nr, y: Er, pageX: It, pageY: ur, buttons: P, button: E, modifiers: S() });
        }
      }(De), nt();
    }
    function nt() {
      z.next(void 0);
    }
    function re(De) {
      c(De.clientX, De.clientY) && (Ct(h, De), ke.copy(g, h), bt(h) && (M = 1));
    }
    function J(De) {
      var ut;
      Ct(y, De);
      var It, ur = De.pageX, nr = De.pageY, Er = y[0], dr = y[1], ln = bt(y);
      if (j.next({ x: Er, y: dr, pageX: ur, pageY: nr, buttons: P, button: E, modifiers: S(), inside: ln }), M !== 0 && (s && ((ut = De.preventDefault) === null || ut === void 0 || ut.call(De)), ke.div(x, ke.sub(x, y, h), ((It = A)[0] = t.clientWidth, It[1] = t.clientHeight, It)), !(ke.magnitude(x) < pn))) {
        var Gn = M === 1;
        if (!Gn || c(De.clientX, De.clientY)) {
          var Rn = x[0], Cn = x[1];
          O.next({ x: Er, y: dr, dx: Rn, dy: Cn, pageX: ur, pageY: nr, buttons: P, button: E, modifiers: S(), isStart: Gn }), ke.copy(h, y), M = 2;
        }
      }
    }
    function ce(De) {
      if (c(De.clientX, De.clientY)) {
        Ct(y, De);
        var ut = De.pageX, It = De.pageY, ur = y[0], nr = y[1];
        i && De.preventDefault();
        var Er = function(dr) {
          var ln = 10, Gn = 40, Rn = 800, Cn = 0, Jr = 0, ni = 0, $r = 0, en = 0;
          return "detail" in dr && (Jr = dr.detail), "wheelDelta" in dr && (Jr = -dr.wheelDelta / 120), "wheelDeltaY" in dr && (Jr = -dr.wheelDeltaY / 120), "wheelDeltaX" in dr && (Cn = -dr.wheelDeltaX / 120), "axis" in dr && dr.axis === dr.HORIZONTAL_AXIS && (Cn = Jr, Jr = 0), ni = Cn * ln, $r = Jr * ln, "deltaY" in dr && ($r = dr.deltaY), "deltaX" in dr && (ni = dr.deltaX), "deltaZ" in dr && (en = dr.deltaZ), (ni || $r || en) && dr.deltaMode && (dr.deltaMode === 1 ? (ni *= Gn, $r *= Gn, en *= Gn) : (ni *= Rn, $r *= Rn, en *= Rn)), ni && !Cn && (Cn = ni < 1 ? -1 : 1), $r && !Jr && (Jr = $r < 1 ? -1 : 1), { spinX: Cn, spinY: Jr, dx: ni, dy: $r, dz: en };
        }(De);
        P = E = 4, (Er.dx || Er.dy || Er.dz) && V.next(R(R({ x: ur, y: nr, pageX: ut, pageY: It }, Er), { buttons: P, button: E, modifiers: S() }));
      }
    }
    function de(De) {
      var ut, It;
      d && (De.preventDefault(), (ut = De.stopImmediatePropagation) === null || ut === void 0 || ut.call(De), (It = De.stopPropagation) === null || It === void 0 || It.call(De));
    }
    function ve(De) {
      de(De), D = De.scale, I = De.rotation, H.next({ scale: De.scale, rotation: De.rotation, deltaRotation: 0, deltaScale: 0, isStart: !0 });
    }
    function he(De, ut) {
      H.next({ scale: De.scale, rotation: De.rotation, deltaRotation: I - De.rotation, deltaScale: D - De.scale, isEnd: ut }), I = De.rotation, D = De.scale;
    }
    function Se(De) {
      de(De), he(De);
    }
    function Re(De) {
      de(De), he(De, !0);
    }
    function Ve(De) {
      B = !0, W.next(void 0);
    }
    function ze(De) {
      B = !1, X.next(void 0);
    }
    function mt(De) {
      Q.next({});
    }
    function bt(De) {
      if (t instanceof Window || t instanceof Document || t === document.body) return !0;
      var ut = t.getBoundingClientRect();
      return De[0] >= 0 && De[1] >= 0 && De[0] < ut.width && De[1] < ut.height;
    }
    function Ct(De, ut) {
      f = t.clientWidth * _(), m = t.clientHeight * _();
      var It = ut.clientX || 0, ur = ut.clientY || 0, nr = t.getBoundingClientRect();
      return De[0] = It - nr.left, De[1] = ur - nr.top, De;
    }
  };
})(ab || (ab = {})), function(e) {
  e.zero = function() {
    return { x: 0, y: 0, width: 0, height: 0 };
  }, e.create = function(t, r, n, i) {
    return { x: t, y: r, width: n, height: i };
  }, e.clone = function(t) {
    return R({}, t);
  }, e.copy = function(t, r) {
    return Object.assign(t, r);
  }, e.set = function(t, r, n, i, a) {
    return t.x = r, t.y = n, t.width = i, t.height = a, t;
  }, e.toVec4 = function(t, r) {
    return t[0] = r.x, t[1] = r.y, t[2] = r.width, t[3] = r.height, t;
  }, e.equals = function(t, r) {
    return t.x === r.x && t.y === r.y && t.width === r.width && t.height === r.height;
  };
}(Vi || (Vi = {}));
var ds = Vt();
function Ap(e, t, r, n) {
  var i = r.x, a = r.y, o = r.width, u = r.height, s = t[0] - i, c = u - t[1] - 1 - a, l = t[2];
  return e[0] = 2 * s / o - 1, e[1] = 2 * c / u - 1, e[2] = 2 * l - 1, w.transformMat4(e, e, n);
}
var $E = Object.prototype.hasOwnProperty;
function RH(e, t) {
  if (!e) return !t;
  if (!t) return !1;
  var r = Object.keys(e);
  if (Object.keys(t).length !== r.length) return !1;
  for (var n = 0, i = r; n < i.length; n++) {
    var a = i[n];
    if (!$E.call(e, a) || e[a] !== t[a]) return !1;
  }
  return !0;
}
function Tc(e) {
  if (e === null || typeof e != "object") return e;
  if (e instanceof Array) {
    for (var t = [], r = 0, n = e.length; r < n; r++) t[r] = Tc(e[r]);
    return t;
  }
  if (typeof e == "object" && !("prototype" in e)) {
    t = {};
    for (var i in e) $E.call(e, i) && (t[i] = Tc(e[i]));
    return t;
  }
  throw new Error(`Can't clone, type "`.concat(typeof e, '" unsupported'));
}
function eM(e, t) {
  if (e) for (var r = 0, n = Object.keys(e); r < n.length; r++) {
    var i = n[r];
    t(e[i], i);
  }
}
var ob = typeof setImmediate < "u" ? typeof window < "u" ? { setImmediate: function(e) {
  for (var t, r = [], n = 1; n < arguments.length; n++) r[n - 1] = arguments[n];
  return (t = window).setImmediate.apply(t, We([e], r, !1));
}, clearImmediate: function(e) {
  return window.clearImmediate(e);
} } : { setImmediate, clearImmediate } : function() {
  var e, t, r, n, i, a, o, u, s = (e = typeof window < "u" && window, t = typeof self < "u" && typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope && self, r = typeof global < "u" && global, e || r || t), c = {}, l = typeof document < "u" ? document : void 0, d = 1;
  function f(v) {
    delete c[v];
  }
  function m(v) {
    var p = c[v];
    f(v), function(g) {
      var h = g.callback, y = g.args;
      switch (y.length) {
        case 0:
          h();
          break;
        case 1:
          h(y[0]);
          break;
        case 2:
          h(y[0], y[1]);
          break;
        case 3:
          h(y[0], y[1], y[2]);
          break;
        default:
          h.apply(void 0, y);
      }
    }(p);
  }
  return typeof process < "u" && {}.toString.call(process) === "[object process]" ? n = function(v) {
    process.nextTick(function() {
      m(v);
    });
  } : function() {
    if (s && s.postMessage && !s.importScripts) {
      var v = !0, p = s.onmessage;
      return s.onmessage = function() {
        v = !1;
      }, s.postMessage("", "*"), s.onmessage = p, v;
    }
  }() ? (o = "setImmediate$" + Math.random() + "$", u = function(v) {
    v.source === s && typeof v.data == "string" && v.data.indexOf(o) === 0 && m(+v.data.slice(o.length));
  }, window.addEventListener ? window.addEventListener("message", u, !1) : window.attachEvent("onmessage", u), n = function(v) {
    window.postMessage(o + v, "*");
  }) : typeof MessageChannel < "u" ? ((a = new MessageChannel()).port1.onmessage = function(v) {
    m(v.data);
  }, n = function(v) {
    a.port2.postMessage(v);
  }) : l && "onreadystatechange" in l.createElement("script") ? (i = l.documentElement, n = function(v) {
    var p = l.createElement("script");
    p.onreadystatechange = function() {
      m(v), p.onreadystatechange = null, i.removeChild(p), p = null;
    }, i.appendChild(p);
  }) : n = function(v) {
    setTimeout(m, 0, v);
  }, { setImmediate: function(v) {
    for (var p = [], g = 1; g < arguments.length; g++) p[g - 1] = arguments[g];
    typeof v != "function" && (v = new Function("" + v));
    var h = { callback: v, args: p };
    return c[d] = h, n(d), d++;
  }, clearImmediate: f };
}();
function OH(e) {
  ob.setImmediate(e);
}
var kp, c_ = { setImmediate: ob.setImmediate, clearImmediate: ob.clearImmediate, immediatePromise: function() {
  return new Promise(OH);
}, delay: function(e, t) {
  return t === void 0 && (t = void 0), new Promise(function(r) {
    return setTimeout(r, e, t);
  });
} }, tM = function() {
  try {
    return !1;
  } catch {
    return !1;
  }
}(), Ir = function() {
  try {
    return !1;
  } catch {
    return !1;
  }
}(), Ey = typeof performance < "u" && !!performance.mark && performance.measure && !tM;
function LH(e, t, r) {
  r === void 0 && (r = 250);
  var n = function(i, a, o) {
    var u = { abortRequested: !1, treeAborted: !1, reason: "" };
    return { updateRateMs: o, lastNotified: li(), observer: a, abortToken: u, taskId: i.id, root: { progress: rM(i), children: [] }, tryAbort: kH(u) };
  }(e, t, r);
  return l_(e, new zH(n, n.root));
}
function rM(e) {
  return { taskId: e.id, taskName: e.name, message: "", startedTime: 0, canAbort: !0, isIndeterminate: !0, current: 0, max: 0 };
}
function kH(e) {
  return function(t) {
    e.abortRequested = !0, e.reason = t || e.reason;
  };
}
function nM(e) {
  return { progress: R({}, e.progress), children: e.children.map(nM) };
}
function iM(e) {
  return e.progress.canAbort && e.children.every(iM);
}
function l_(e, t) {
  return _e(this, 0, void 0, function() {
    var r, n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          kp.markStart(e), t.node.progress.startedTime = li(), i.label = 1;
        case 1:
          return i.trys.push([1, 3, , 7]), [4, e.f(t)];
        case 2:
          return r = i.sent(), kp.markEnd(e), kp.measure(e), t.info.abortToken.abortRequested && aM(t.info), [2, r];
        case 3:
          return n = i.sent(), er.isAbort(n) ? (t.isAborted = !0, t.node.children.length > 0 ? [4, new Promise(function(a) {
            t.onChildrenFinished = a;
          })] : [3, 5]) : [3, 6];
        case 4:
          i.sent(), i.label = 5;
        case 5:
          e.onAbort && e.onAbort(), i.label = 6;
        case 6:
          throw n;
        case 7:
          return [2];
      }
    });
  });
}
function aM(e) {
  throw e.abortToken.treeAborted || (e.abortToken.treeAborted = !0, oM(e.root), uM(e, li())), er.Aborted(e.abortToken.reason);
}
function oM(e) {
  var t = e.progress;
  t.isIndeterminate = !0, t.canAbort = !1, t.message = "Aborting...";
  for (var r = 0, n = e.children; r < n.length; r++)
    oM(n[r]);
}
function uM(e, t) {
  e.lastNotified = t;
  var r = function(n) {
    return { root: nM(n.root), canAbort: iM(n.root), requestAbort: n.tryAbort };
  }(e);
  e.observer(r);
}
(function(e) {
  function t(n) {
    return "startTask".concat(n.id);
  }
  function r(n) {
    return "endTask".concat(n.id);
  }
  e.markStart = function(n) {
    Ey && performance.mark(t(n));
  }, e.markEnd = function(n) {
    Ey && performance.mark(r(n));
  }, e.measure = function(n) {
    Ey && performance.measure("✳️ ".concat(n.name), t(n), r(n));
  };
})(kp || (kp = {}));
var er, m9, h9, zH = function() {
  function e(t, r) {
    this.isSynchronous = !1, this.isExecuting = !0, this.lastUpdatedTime = 0, this.onChildrenFinished = void 0, this.node = r, this.info = t;
  }
  return e.prototype.checkAborted = function() {
    this.info.abortToken.abortRequested && (this.isAborted = !0, aM(this.info));
  }, Object.defineProperty(e.prototype, "shouldUpdate", { get: function() {
    return this.checkAborted(), li() - this.lastUpdatedTime > this.info.updateRateMs;
  }, enumerable: !1, configurable: !0 }), e.prototype.updateProgress = function(t) {
    if (this.checkAborted(), t) {
      var r = this.node.progress;
      typeof t == "string" ? (r.message = t, r.isIndeterminate = !0) : (t.canAbort !== void 0 && (r.canAbort = t.canAbort), t.message !== void 0 && (r.message = t.message), t.current !== void 0 && (r.current = t.current), t.max !== void 0 && (r.max = t.max), r.isIndeterminate = r.current === void 0 || r.max === void 0, t.isIndeterminate !== void 0 && (r.isIndeterminate = t.isIndeterminate));
    }
  }, e.prototype.update = function(t, r) {
    if (this.lastUpdatedTime = li(), this.updateProgress(t), !r) return uM(this.info, this.lastUpdatedTime), this.checkAborted(), c_.immediatePromise();
  }, e.prototype.runChild = function(t, r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o, u, s, c;
      return ye(this, function(l) {
        switch (l.label) {
          case 0:
            this.updateProgress(r), n = { progress: rM(t), children: [] }, (i = this.node.children).push(n), a = new e(this.info, n), l.label = 1;
          case 1:
            return l.trys.push([1, 3, 4, 5]), [4, l_(t, a)];
          case 2:
            return [2, l.sent()];
          case 3:
            if (o = l.sent(), er.isAbort(o) && this.isAborted) return [2, void 0];
            throw o;
          case 4:
            if ((u = i.indexOf(n)) >= 0) {
              for (s = u, c = i.length - 1; s < c; s++) i[s] = i[s + 1];
              i.pop();
            }
            return i.length === 0 && this.onChildrenFinished && this.onChildrenFinished(), [7];
          case 5:
            return [2];
        }
      });
    });
  }, e;
}(), Ho = new (function() {
  function e() {
    this.shouldUpdate = !1, this.isSynchronous = !0;
  }
  return e.prototype.update = function(t, r) {
  }, e;
}())();
function $p(e, t, r, n, i) {
  return _e(this, 0, void 0, function() {
    var a, o, u, s, c, l, d;
    return ye(this, function(f) {
      switch (f.label) {
        case 0:
          if (a = Math.max(t, 0), o = 0, u = 0, e.isSynchronous) return n(Number.MAX_SAFE_INTEGER, r), [2, r];
          s = li(), c = 0, l = 0, f.label = 1;
        case 1:
          return (c = n(a, r)) > 0 ? (o += c, d = li() - s, l += d, u += d, e.shouldUpdate ? [4, i(e, r, o)] : [3, 3]) : [3, 4];
        case 2:
          f.sent(), a = Math.round(l * o / u) + 1, s = li(), l = 0, f.label = 3;
        case 3:
          return [3, 1];
        case 4:
          return e.shouldUpdate ? [4, i(e, r, o)] : [3, 6];
        case 5:
          f.sent(), f.label = 6;
        case 6:
          return [2, r];
      }
    });
  });
}
function kl(e, t) {
  return e[t] | e[t + 1] << 8;
}
function Yd(e, t) {
  return 16777216 * e[t + 3] + (e[t + 2] << 16 | e[t + 1] << 8 | e[t]);
}
function GH(e) {
  return e.length < 2 ? "0" + e : e;
}
function VH(e, t, r) {
  for (var n, i = "", a = 0; a < r; a++) i += "%" + GH(e[t + a].toString(16));
  try {
    n = decodeURIComponent(i);
  } catch {
    return function(u, s, c) {
      for (var l = "", d = 0; d < c; d++) l += String.fromCharCode(u[s + d]);
      return l;
    }(e, t, r);
  }
  return n;
}
(function(e) {
  var t = function() {
    function a(o, u, s) {
      this.name = o, this.f = u, this.onAbort = s, this.id = i();
    }
    return a.prototype.run = function(o, u) {
      return u === void 0 && (u = 250), o ? LH(this, o, u) : this.f(Ho);
    }, a.prototype.runAsChild = function(o, u) {
      return o.isSynchronous ? this.f(Ho) : function(s, c, l) {
        return s.runChild(c, l);
      }(o, this, u);
    }, a.prototype.runInContext = function(o) {
      return o.isSynchronous ? this.f(Ho) : function(u, s) {
        return l_(s, u);
      }(o, this);
    }, a;
  }();
  function r(a) {
    var o = a;
    return !!a && typeof o.id == "number" && typeof o.name == "string" && !!o.run;
  }
  function n(a, o, u) {
    return new t(a, o, u);
  }
  e.is = r, e.isAbort = function(a) {
    return !!a && !!a.isAborted;
  }, e.Aborted = function(a) {
    return { isAborted: !0, reason: a, toString: function() {
      return "Aborted".concat(a ? ": " + a : "");
    } };
  }, e.create = n, e.constant = function(a, o) {
    var u = this;
    return n(a, function(s) {
      return _e(u, 0, void 0, function() {
        return ye(this, function(c) {
          return [2, o];
        });
      });
    });
  }, e.empty = function() {
    var a = this;
    return n("", function(o) {
      return _e(a, 0, void 0, function() {
        return ye(this, function(u) {
          return [2];
        });
      });
    });
  }, e.fail = function(a, o) {
    var u = this;
    return n(a, function(s) {
      return _e(u, 0, void 0, function() {
        return ye(this, function(c) {
          throw new Error(o);
        });
      });
    });
  }, e.resolveInContext = function(a, o) {
    return r(a) ? o ? a.runInContext(o) : a.run() : a;
  };
  var i = La(0, 1073741823);
})(er || (er = {})), function(e) {
  e.Synchronous = Ho;
}(m9 || (m9 = {})), function(e) {
  function t(r, n) {
    n === void 0 && (n = "");
    var i = r.progress;
    if (!r.children.length) return i.isIndeterminate ? "".concat(n).concat(i.taskName, ": ").concat(i.message) : "".concat(n).concat(i.taskName, ": [").concat(i.current, "/").concat(i.max, "] ").concat(i.message);
    var a = n + "  |_ ", o = r.children.map(function(u) {
      return t(u, a);
    });
    return i.isIndeterminate ? "".concat(n).concat(i.taskName, ": ").concat(i.message, `
`).concat(o.join(`
`)) : "".concat(n).concat(i.taskName, ": [").concat(i.current, "/").concat(i.max, "] ").concat(i.message, `
`).concat(o.join(`
`));
  }
  e.format = function(r) {
    return t(r.root);
  };
}(h9 || (h9 = {}));
var UH = function() {
  for (var e = new Uint32Array(256), t = 0; t < 256; t++) {
    for (var r = t, n = 0; n < 8; n++) 1 & r ? r = 3988292384 ^ r >>> 1 : r >>>= 1;
    e[t] = r;
  }
  return e;
}();
function HH(e, t, r) {
  return 4294967295 ^ function(n, i, a, o) {
    for (var u = 0; u < o; u++) n = UH[255 & (n ^ i[a + u])] ^ n >>> 8;
    return n;
  }(4294967295, e, t, r);
}
var ou, Wf, Yt = (ou = Uint16Array, Wf = Uint32Array, { next_code: new ou(16), bl_count: new ou(16), ordr: [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], of0: [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 999, 999, 999], exb: [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0, 0], ldef: new ou(32), df0: [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 65535, 65535], dxb: [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 0, 0], ddef: new Wf(32), flmap: new ou(512), fltree: [], fdmap: new ou(32), fdtree: [], lmap: new ou(32768), ltree: [], ttree: [], dmap: new ou(32768), dtree: [], imap: new ou(512), itree: [], rev15: new ou(32768), lhst: new Wf(286), dhst: new Wf(30), ihst: new Wf(19), lits: new Wf(15e3), strt: new ou(65536), prev: new ou(32768) });
function zp(e, t, r) {
  for (var n = e.length, i = Yt.rev15, a = 0; a < n; a += 2) if (e[a + 1] !== 0) for (var o = a >> 1, u = e[a + 1], s = o << 4 | u, c = t - u, l = e[a] << c, d = l + (1 << c); l !== d; )
    r[i[l] >>> 15 - t] = s, l++;
}
function Gp(e, t) {
  for (var r = e.length, n = Yt.bl_count, i = 0; i <= t; i++) n[i] = 0;
  for (i = 1; i < r; i += 2) n[e[i]]++;
  var a = Yt.next_code, o = 0;
  n[0] = 0;
  for (var u = 1; u <= t; u++) o = o + n[u - 1] << 1, a[u] = o;
  for (var s = 0; s < r; s += 2) {
    var c = e[s + 1];
    c !== 0 && (e[s] = a[c], a[c]++);
  }
}
function v9(e, t) {
  for (var r = Yt.rev15, n = 15 - t, i = 0; i < e.length; i += 2) {
    var a = e[i] << t - e[i + 1];
    e[i] = r[a] >>> n;
  }
}
function qH(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          if (t[0] === 3 && t[1] === 0) return [2, r || new Uint8Array(0)];
          n = function(a, o) {
            var u = o === void 0;
            return o === void 0 && (o = new Uint8Array(a.length >>> 2 << 3)), { data: a, buf: o, noBuf: u, BFINAL: 0, off: 0, pos: 0 };
          }(t, r), i.label = 1;
        case 1:
          return n.BFINAL !== 0 ? [3, 4] : e.shouldUpdate ? [4, e.update({ message: "Inflating blocks...", current: n.pos, max: t.length })] : [3, 3];
        case 2:
          i.sent(), i.label = 3;
        case 3:
          return function(a, o) {
            for (var u = a.data, s = a.noBuf, c = a.buf, l = a.BFINAL, d = a.off, f = a.pos, m = 0; l === 0 && m < o; ) {
              var v = void 0, p = void 0, g = 0, h = 0;
              l = Ty(u, f, 1), m += 1;
              var y = Ty(u, f + 1, 2);
              if (f += 3, y !== 0) {
                if (s && (c = My(c, d + (1 << 17))), y === 1) v = Yt.flmap, p = Yt.fdmap, g = 511, h = 31;
                else {
                  if (y !== 2) throw new Error("unknown BTYPE ".concat(y));
                  var x = Tl(u, f, 5) + 257, A = Tl(u, f + 5, 5) + 1, b = Tl(u, f + 10, 4) + 4;
                  f += 14;
                  for (var _ = 0; _ < 38; _ += 2) Yt.itree[_] = 0, Yt.itree[_ + 1] = 0;
                  var S = 1;
                  for (_ = 0; _ < b; _++) {
                    var D = Tl(u, f + 3 * _, 3);
                    Yt.itree[1 + (Yt.ordr[_] << 1)] = D, D > S && (S = D);
                  }
                  f += 3 * b, Gp(Yt.itree, S), zp(Yt.itree, S, Yt.imap), v = Yt.lmap, p = Yt.dmap, f = KH(Yt.imap, (1 << S) - 1, x + A, u, f, Yt.ttree);
                  var I = g9(Yt.ttree, 0, x, Yt.ltree);
                  g = (1 << I) - 1;
                  var M = g9(Yt.ttree, x, A, Yt.dtree);
                  h = (1 << M) - 1, Gp(Yt.ltree, I), zp(Yt.ltree, I, v), Gp(Yt.dtree, M), zp(Yt.dtree, M, p);
                }
                for (; ; ) {
                  var F = v[ub(u, f) & g];
                  f += 15 & F;
                  var P = F >>> 4;
                  if (!(P >>> 8)) c[d++] = P;
                  else {
                    if (P === 256) break;
                    var E = d + P - 254;
                    if (P > 264) {
                      var B = Yt.ldef[P - 257];
                      E = d + (B >>> 3) + Tl(u, f, 7 & B), f += 7 & B;
                    }
                    var N = p[ub(u, f) & h];
                    f += 15 & N;
                    var O = N >>> 4, z = Yt.ddef[O], V = (z >>> 4) + Ty(u, f, 15 & z);
                    for (f += 15 & z, s && (c = My(c, d + (1 << 17))); d < E; ) c[d] = c[d++ - V], c[d] = c[d++ - V], c[d] = c[d++ - V], c[d] = c[d++ - V];
                    d = E;
                  }
                }
              } else {
                7 & f && (f += 8 - (7 & f));
                var U = 4 + (f >>> 3), H = u[U - 4] | u[U - 3] << 8;
                s && (c = My(c, d + H)), c.set(new Uint8Array(u.buffer, u.byteOffset + U, H), d), f = U + H << 3, d += H;
              }
            }
            a.buf = c, a.BFINAL = l, a.off = d, a.pos = f;
          }(n, 100), [3, 1];
        case 4:
          return [2, n.buf.length === n.off ? n.buf : n.buf.slice(0, n.off)];
      }
    });
  });
}
function My(e, t) {
  var r = e.length;
  if (t <= r) return e;
  var n = new Uint8Array(Math.max(r << 1, t));
  return n.set(e, 0), n;
}
function KH(e, t, r, n, i, a) {
  for (var o = 0; o < r; ) {
    var u = e[ub(n, i) & t];
    i += 15 & u;
    var s = u >>> 4;
    if (s <= 15) a[o] = s, o++;
    else {
      var c = 0, l = 0;
      s === 16 ? (l = 3 + Tl(n, i, 2), i += 2, c = a[o - 1]) : s === 17 ? (l = 3 + Tl(n, i, 3), i += 3) : s === 18 && (l = 11 + Tl(n, i, 7), i += 7);
      for (var d = o + l; o < d; ) a[o] = c, o++;
    }
  }
  return i;
}
function g9(e, t, r, n) {
  for (var i = 0, a = 0, o = n.length >>> 1; a < r; ) {
    var u = e[a + t];
    n[a << 1] = 0, n[1 + (a << 1)] = u, u > i && (i = u), a++;
  }
  for (; a < o; ) n[a << 1] = 0, n[1 + (a << 1)] = 0, a++;
  return i;
}
function Tl(e, t, r) {
  return (e[t >>> 3] | e[1 + (t >>> 3)] << 8) >>> (7 & t) & (1 << r) - 1;
}
function Ty(e, t, r) {
  return (e[t >>> 3] | e[1 + (t >>> 3)] << 8 | e[2 + (t >>> 3)] << 16) >>> (7 & t) & (1 << r) - 1;
}
function ub(e, t) {
  return (e[t >>> 3] | e[1 + (t >>> 3)] << 8 | e[2 + (t >>> 3)] << 16) >>> (7 & t);
}
function sM(e, t, r) {
  return r === void 0 && (r = !1), _e(this, 0, void 0, function() {
    var n, i, a, o, u, s, c, l, d, f, m, v, p;
    return ye(this, function(g) {
      switch (g.label) {
        case 0:
          for (n = /* @__PURE__ */ Object.create(null), i = new Uint8Array(t), a = i.length - 4; Yd(i, a) !== 101010256; ) a--;
          o = a, o += 4, u = kl(i, o += 4), o += 2, o += 2, s = Yd(i, o += 4), o += 4, o = s, c = 0, g.label = 1;
        case 1:
          return c < u ? (o += 4, o += 4, o += 4, o += 4, l = Yd(i, o += 4), d = Yd(i, o += 4), f = kl(i, o += 4), m = kl(i, o + 2), v = kl(i, o + 4), o += 6, p = Yd(i, o += 8), o += 4, o += f + m + v, [4, XH(e, i, p, n, l, d, r)]) : [3, 4];
        case 2:
          g.sent(), g.label = 3;
        case 3:
          return c++, [3, 1];
        case 4:
          return [2, n];
      }
    });
  });
}
function XH(e, t, r, n, i, a, o) {
  return _e(this, 0, void 0, function() {
    var u, s, c, l, d, f;
    return ye(this, function(m) {
      switch (m.label) {
        case 0:
          return r += 4, r += 2, u = kl(t, r += 2), r += 2, r += 4, r += 4, s = kl(t, r += 8), c = kl(t, r += 2), l = VH(t, r += 2, s), r += s, r += c, o ? (n[l] = { size: a, csize: i }, [2]) : (d = new Uint8Array(t.buffer, r), u !== 0 ? [3, 1] : (n[l] = new Uint8Array(d.buffer.slice(r, r + i)), [3, 4]));
        case 1:
          return u !== 8 ? [3, 3] : (f = new Uint8Array(a), [4, cM(e, d, f)]);
        case 2:
          return m.sent(), n[l] = f, [3, 4];
        case 3:
          throw new Error("unknown compression method: ".concat(u));
        case 4:
          return [2];
      }
    });
  });
}
function cM(e, t, r) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(n) {
      return [2, qH(e, t, r)];
    });
  });
}
function jH(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o, u, s, c, l, d;
    return ye(this, function(f) {
      switch (f.label) {
        case 0:
          if (n = t[3], i = 10, 4 & n && (a = kl(t, i), i += a), 8 & n) {
            for (o = i; t[o] !== 0; ) ++o;
            i = o + 1;
          }
          if (16 & n) {
            for (o = i; t[o] !== 0; ) ++o;
            i = o + 1;
          }
          return 1 & n && (i += 2), u = function(m) {
            return 0 | m;
          }(Yd(t, t.length - 8)), s = Yd(t, t.length - 4), r === void 0 && (r = new Uint8Array(s)), c = new Uint8Array(t.buffer, t.byteOffset + i, t.length - i - 8), [4, cM(e, c, r)];
        case 1:
          return l = f.sent(), d = HH(l, 0, l.length), u !== d && console.error("ungzip: checksums don't match"), [2, l];
      }
    });
  });
}
function Oh(e, t, r) {
  for (var n = 0, i = r.length; n < i; n++) {
    var a = r.charCodeAt(n);
    if (a < 128) e[t++] = a >>> 0 & 127;
    else if (a < 2048) e[t++] = a >>> 6 & 31 | 192, e[t++] = a >>> 0 & 63 | 128;
    else if (a < 65536) e[t++] = a >>> 12 & 15 | 224, e[t++] = a >>> 6 & 63 | 128, e[t++] = a >>> 0 & 63 | 128;
    else {
      if (!(a < 1114112)) throw new Error("bad codepoint " + a);
      e[t++] = a >>> 18 & 7 | 240, e[t++] = a >>> 12 & 63 | 128, e[t++] = a >>> 6 & 63 | 128, e[t++] = a >>> 0 & 63 | 128;
    }
  }
}
(function() {
  for (var e = 0; e < 32768; e++) {
    var t = e;
    t = (4278255360 & (t = (4042322160 & (t = (3435973836 & (t = (2863311530 & t) >>> 1 | (1431655765 & t) << 1)) >>> 2 | (858993459 & t) << 2)) >>> 4 | (252645135 & t) << 4)) >>> 8 | (16711935 & t) << 8, Yt.rev15[e] = (t >>> 16 | t << 16) >>> 17;
  }
  function r(n, i, a) {
    for (; i-- != 0; ) n.push(0, a);
  }
  for (e = 0; e < 32; e++) Yt.ldef[e] = Yt.of0[e] << 3 | Yt.exb[e], Yt.ddef[e] = Yt.df0[e] << 4 | Yt.dxb[e];
  r(Yt.fltree, 144, 8), r(Yt.fltree, 112, 9), r(Yt.fltree, 24, 7), r(Yt.fltree, 8, 8), Gp(Yt.fltree, 9), zp(Yt.fltree, 9, Yt.flmap), v9(Yt.fltree, 9), r(Yt.fdtree, 32, 5), Gp(Yt.fdtree, 5), zp(Yt.fdtree, 5, Yt.fdmap), v9(Yt.fdtree, 5), r(Yt.itree, 19, 0), r(Yt.ltree, 286, 0), r(Yt.dtree, 30, 0), r(Yt.ttree, 320, 0);
})();
var YH = function() {
  for (var e = [], t = 0; t < 1024; t++) e[t] = String.fromCharCode(t);
  return e;
}();
function lM(e) {
  throw new Error(e);
}
var y9 = typeof TextDecoder < "u" ? new TextDecoder() : void 0;
function dM(e, t, r) {
  if (y9) {
    var n = t || r !== e.length ? e.subarray(t, t + r) : e;
    return y9.decode(n);
  }
  return function(i, a, o) {
    for (var u = YH, s = void 0, c = 0, l = [], d = a, f = a + o; d < f; d++) {
      var m = i[d];
      128 & m ? (224 & m) == 192 ? l[c++] = u[(15 & m) << 6 | 63 & i[++d]] : (240 & m) == 224 ? l[c++] = String.fromCharCode((15 & m) << 12 | (63 & i[++d]) << 6 | 63 & i[++d]) : (248 & m) == 240 ? l[c++] = String.fromCharCode((7 & m) << 18 | (63 & i[++d]) << 12 | (63 & i[++d]) << 6 | 63 & i[++d]) : lM("Invalid byte " + m.toString(16)) : l[c++] = u[m], c === 512 && ((s = s || [])[s.length] = l.join(""), c = 0);
    }
    return s ? (c > 0 && (s[s.length] = l.slice(0, c).join("")), s.join("")) : l.slice(0, c).join("");
  }(e, t, r);
}
function fM(e) {
  for (var t = 0, r = 0, n = e.length; r < n; r++) {
    var i = e.charCodeAt(r);
    i < 128 ? t += 1 : i < 2048 ? t += 2 : i < 65536 ? t += 3 : i < 1114112 ? t += 4 : lM("bad codepoint " + i);
  }
  return t;
}
var Wu, WH = XMLHttpRequest;
function Lh(e, t) {
  return function(r, n) {
    var i = this, a = void 0;
    return er.create("Read File", function(o) {
      return _e(i, 0, void 0, function() {
        var u, s;
        return ye(this, function(c) {
          switch (c.label) {
            case 0:
              return c.trys.push([0, , 5, 6]), a = new FileReader(), u = n === "zip" ? Wu.None : (l = r.name, /\.gz$/i.test(l) ? Wu.Gzip : /\.zip$/i.test(l) ? Wu.Zip : Wu.None), n === "binary" || n === "zip" || u !== Wu.None ? a.readAsArrayBuffer(r) : a.readAsText(r), [4, o.update({ message: "Opening file...", canAbort: !0 })];
            case 1:
              return c.sent(), [4, pM(o, "Reading...", a)];
            case 2:
              return s = c.sent(), [4, o.update({ message: "Processing file...", canAbort: !1 })];
            case 3:
              return c.sent(), [4, JH(o, s, n, u)];
            case 4:
              return [2, c.sent()];
            case 5:
              return a = void 0, [7];
            case 6:
              return [2];
          }
          var l;
        });
      });
    }, function() {
      a && a.abort();
    });
  }(e, t);
}
function b9(e) {
  return typeof e == "string" ? x9(e, e, "string") : x9(e.title, e.url, e.type || "string", e.body, e.headers);
}
function _9(e) {
  return e ? "Failed to download data. Possible reasons: Resource is not available, or CORS is not allowed on the server." : "Failed to open file.";
}
function pM(e, t, r) {
  return new Promise(function(n, i) {
    if (function(u) {
      if (u instanceof FileReader) return u.readyState === FileReader.DONE;
      if (u instanceof XMLHttpRequest) return u.readyState === XMLHttpRequest.DONE;
      throw new Error("unknown data type");
    }(r)) {
      var a = r.error;
      a != null ? i(a ?? _9(r instanceof XMLHttpRequest)) : n(r);
    } else {
      var o = !1;
      r.onerror = function(u) {
        if (!o) {
          var s = u.target.error;
          i(s ?? _9(r instanceof XMLHttpRequest));
        }
      }, r.onprogress = function(u) {
        if (e.shouldUpdate && !o) try {
          u.lengthComputable ? e.update({ message: t, isIndeterminate: !1, current: u.loaded, max: u.total }) : e.update({ message: "".concat(t, " ").concat((u.loaded / 1024 / 1024).toFixed(2), " MB"), isIndeterminate: !0 });
        } catch (s) {
          o = !0, i(s);
        }
      }, r.onload = function(u) {
        n(r);
      };
    }
  });
}
(function(e) {
  e[e.None = 0] = "None", e[e.Gzip = 1] = "Gzip", e[e.Zip = 2] = "Zip";
})(Wu || (Wu = {}));
var ZH = /^(__MACOSX|.DS_Store)/;
function QH(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n, i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          switch (r) {
            case Wu.None:
              return [3, 1];
            case Wu.Gzip:
              return [3, 2];
            case Wu.Zip:
              return [3, 3];
          }
          return [3, 5];
        case 1:
          return [2, t];
        case 2:
          return [2, jH(e, t)];
        case 3:
          return [4, sM(e, t.buffer)];
        case 4:
          if (n = a.sent(), i = Object.keys(n).filter(function(o) {
            return !ZH.test(o);
          }), i.length !== 1) throw new Error("can only decompress zip files with a single entry");
          return [2, n[i[0]]];
        case 5:
          return [2];
      }
    });
  });
}
function JH(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    var i, a, o;
    return ye(this, function(u) {
      switch (u.label) {
        case 0:
          if (i = t.result, (a = i instanceof ArrayBuffer ? new Uint8Array(i) : i) === null) throw new Error("no data given");
          if (n === Wu.None) return [3, 4];
          if (!(a instanceof Uint8Array)) throw new Error("need Uint8Array for decompression");
          return [4, QH(e, a, n)];
        case 1:
          return o = u.sent(), r !== "string" ? [3, 3] : [4, e.update({ message: "Decoding text..." })];
        case 2:
          return u.sent(), a = dM(o, 0, o.length), [3, 4];
        case 3:
          a = o, u.label = 4;
        case 4:
          return r === "binary" && a instanceof Uint8Array ? [2, a] : [3, 5];
        case 5:
          return r === "zip" && a instanceof Uint8Array ? [4, sM(e, a.buffer)] : [3, 7];
        case 6:
          return [2, u.sent()];
        case 7:
          if (r === "string" && typeof a == "string") return [2, a];
          if (r === "xml" && typeof a == "string") return [2, new DOMParser().parseFromString(a, "application/xml")];
          if (r === "json" && typeof a == "string") return [2, JSON.parse(a)];
          u.label = 8;
        case 8:
          throw new Error("could not get requested response data '".concat(r, "'"));
      }
    });
  });
}
var Ku, Py = function() {
  function e() {
  }
  return e.get = function() {
    return this.pool.length ? this.pool.pop() : new WH();
  }, e.emptyFunc = function() {
  }, e.deposit = function(t) {
    this.pool.length < this.poolSize && (t.onabort = e.emptyFunc, t.onerror = e.emptyFunc, t.onload = e.emptyFunc, t.onprogress = e.emptyFunc, this.pool.push(t));
  }, e.pool = [], e.poolSize = 15, e;
}();
function x9(e, t, r, n, i) {
  var a = this, o = void 0;
  return er.create(e || "Download", function(u) {
    return _e(a, 0, void 0, function() {
      var s, c, l, d, f, m, v;
      return ye(this, function(p) {
        switch (p.label) {
          case 0:
            if ((o = Py.get()).open(n ? "post" : "get", t, !0), i) for (s = 0, c = i; s < c.length; s++) l = c[s], d = l[0], f = l[1], o.setRequestHeader(d, f);
            return o.responseType = function(g) {
              switch (g) {
                case "json":
                  return "json";
                case "xml":
                  return "document";
                case "string":
                  return "text";
                case "binary":
                case "zip":
                  return "arraybuffer";
              }
            }(r), o.send(n), [4, u.update({ message: "Waiting for server...", canAbort: !0 })];
          case 1:
            return p.sent(), [4, pM(u, "Downloading...", o)];
          case 2:
            return m = p.sent(), o = void 0, [4, u.update({ message: "Parsing response...", canAbort: !1 })];
          case 3:
            return p.sent(), v = function(g, h) {
              if (g.status >= 200 && g.status < 400) {
                var y = g.response;
                if (Py.deposit(g), (h === "binary" || h === "zip") && y instanceof ArrayBuffer) return new Uint8Array(y);
                if (h === "string" && typeof y == "string" || h === "xml" && y instanceof XMLDocument || h === "json" && typeof y == "object") return y;
                throw new Error("could not get requested response data '".concat(h, "'"));
              }
              throw Py.deposit(g), new Error("Download failed with status code ".concat(g.status));
            }(m, r), [2, v];
        }
      });
    });
  }, function() {
    o && (o.abort(), o = void 0);
  });
}
(function(e) {
  function t(r, n) {
    return R({ kind: "url", id: Ii.create22(), url: r }, n);
  }
  e.Url = t, e.File = function(r) {
    return { kind: "file", id: Ii.create22(), name: r.name, file: r };
  }, e.isUrl = function(r) {
    return (r == null ? void 0 : r.kind) === "url";
  }, e.isFile = function(r) {
    return (r == null ? void 0 : r.kind) === "file";
  }, e.Wrapper = function(r, n, i) {
    return { data: r, dispose: function() {
      i.release(n);
    } };
  }, e.getUrl = function(r) {
    return typeof r == "string" ? r : r.url;
  }, e.getUrlAsset = function(r, n, i) {
    return typeof n == "string" ? r.tryFindUrl(n, i) || t(n, { body: i }) : n;
  };
})(Ku || (Ku = {}));
var G, bc = function() {
  function e() {
    this._assets = /* @__PURE__ */ new Map();
  }
  return Object.defineProperty(e.prototype, "assets", { get: function() {
    return n_(this._assets.values());
  }, enumerable: !1, configurable: !0 }), e.prototype.tryFindUrl = function(t, r) {
    for (var n = this.assets.values(); ; ) {
      var i = n.next();
      if (i.done) return;
      var a = i.value.asset;
      if (Ku.isUrl(a) && a.url === t && (a.body || "") === (r || "")) return a;
    }
  }, e.prototype.set = function(t, r) {
    this._assets.set(t.id, { asset: t, file: r, refCount: 0 });
  }, e.prototype.get = function(t) {
    return this._assets.get(t);
  }, e.prototype.remove = function(t) {
    this._assets.delete(t);
  }, e.prototype.resolve = function(t, r, n) {
    var i = this;
    return n === void 0 && (n = !0), Ku.isUrl(t) ? er.create("Download ".concat(t.title || t.url), function(a) {
      return _e(i, 0, void 0, function() {
        var o, u, s, c, l, d, f, m, v;
        return ye(this, function(p) {
          switch (p.label) {
            case 0:
              return this._assets.has(t.id) ? ((o = this._assets.get(t.id)).refCount++, s = (u = Ku).Wrapper, [4, Lh(o.file, r).runInContext(a)]) : [3, 2];
            case 1:
              return [2, s.apply(u, [p.sent(), t, this])];
            case 2:
              return n ? [3, 4] : (l = (c = Ku).Wrapper, [4, b9(R(R({}, t), { type: r })).runInContext(a)]);
            case 3:
              return [2, l.apply(c, [p.sent(), t, this])];
            case 4:
              return [4, b9(R(R({}, t), { type: "binary" })).runInContext(a)];
            case 5:
              return d = p.sent(), f = new File([d], "raw-data"), this._assets.set(t.id, { asset: t, file: f, refCount: 1 }), v = (m = Ku).Wrapper, [4, Lh(f, r).runInContext(a)];
            case 6:
              return [2, v.apply(m, [p.sent(), t, this])];
          }
        });
      });
    }) : er.create("Read ".concat(t.name), function(a) {
      return _e(i, 0, void 0, function() {
        var o, u, s, c, l;
        return ye(this, function(d) {
          switch (d.label) {
            case 0:
              return this._assets.has(t.id) ? (o = this._assets.get(t.id), t.file = o.file, o.refCount++, s = (u = Ku).Wrapper, [4, Lh(o.file, r).runInContext(a)]) : [3, 2];
            case 1:
              return [2, s.apply(u, [d.sent(), t, this])];
            case 2:
              if (!(t.file instanceof File)) throw new Error("Cannot resolve file asset '".concat(t.name, "' (").concat(t.id, ")"));
              return n && this._assets.set(t.id, { asset: t, file: t.file, refCount: 1 }), l = (c = Ku).Wrapper, [4, Lh(t.file, r).runInContext(a)];
            case 3:
              return [2, l.apply(c, [d.sent(), t, this])];
          }
        });
      });
    });
  }, e.prototype.release = function(t) {
    var r = this._assets.get(t.id);
    r && (r.refCount--, r.refCount <= 0 && this._assets.delete(t.id));
  }, e;
}();
function y2(e) {
  for (var t = -1 / 0, r = 0, n = e.length; r < n; ++r) e[r] > t && (t = e[r]);
  return t;
}
function $H(e) {
  for (var t = 1 / 0, r = 0, n = e.length; r < n; ++r) e[r] < t && (t = e[r]);
  return t;
}
function Oo(e) {
  for (var t = 1 / 0, r = -1 / 0, n = 0, i = e.length; n < i; ++n) e[n] < t && (t = e[n]), e[n] > r && (r = e[n]);
  return [t, r];
}
function Zv(e, t, r) {
  t === void 0 && (t = 1), r === void 0 && (r = 0);
  for (var n = e.length, i = 0, a = r; a < n; a += t) i += e[a];
  return i;
}
function eq(e, t, r) {
  return t === void 0 && (t = 1), r === void 0 && (r = 0), Zv(e, t, r) / (e.length / t);
}
function tq(e) {
  for (var t = e.length, r = 0, n = 0; n < t; ++n) {
    var i = e[n];
    r += i * i;
  }
  return Math.sqrt(r / t);
}
function Fs(e, t) {
  for (var r = 0, n = t ? Math.min(t, e.length) : e.length; r < n; ++r) e[r] = r;
  return e;
}
function Su(e, t) {
  return !(e.indexOf(t) >= 0) && (e.push(t), !0);
}
function Qv(e, t) {
  var r = e.indexOf(t);
  if (r < 0) return !1;
  for (var n = r, i = e.length - 1; n < i; n++) e[n] = e[n + 1];
  return e.pop(), !0;
}
function b2(e, t) {
  for (var r = 0, n = 0, i = e.length; n < i; ++n) t.includes(e[n]) && (r += 1);
  return r;
}
(function(e) {
  function t(b, _) {
    return _ && (_.label && (b.label = _.label), _.description && (b.description = _.description), _.legend && (b.legend = _.legend), _.fieldLabels && (b.fieldLabels = _.fieldLabels), _.isHidden && (b.isHidden = _.isHidden), _.shortLabel && (b.shortLabel = _.shortLabel), _.twoColumns && (b.twoColumns = _.twoColumns), _.isEssential && (b.isEssential = _.isEssential), _.category && (b.category = _.category), _.hideIf && (b.hideIf = _.hideIf), _.help && (b.help = _.help)), b;
  }
  function r(b, _, S) {
    return t({ type: "select", defaultValue: A(b, _), options: _, cycle: S == null ? void 0 : S.cycle }, S);
  }
  function n(b, _) {
    return _ && (_.min !== void 0 && (b.min = _.min), _.max !== void 0 && (b.max = _.max), _.step !== void 0 && (b.step = _.step)), b;
  }
  function i(b, _) {
    var S = t({ type: "group", defaultValue: (_ == null ? void 0 : _.customDefault) || u(b), params: b }, _);
    return _ != null && _.presets && (S.presets = _.presets), _ != null && _.isExpanded && (S.isExpanded = _.isExpanded), _ != null && _.isFlat && (S.isFlat = _.isFlat), _ != null && _.pivot && (S.pivot = _.pivot), S;
  }
  function a() {
    return u(this.element);
  }
  function o() {
    throw new Error("getValue not set. Fix runtime.");
  }
  function u(b) {
    for (var _ = {}, S = 0, D = Object.keys(b); S < D.length; S++) {
      var I = D[S];
      b[I].isOptional || (_[I] = b[I].defaultValue);
    }
    return _;
  }
  function s(b, _) {
    return function() {
      return b(_);
    };
  }
  function c(b, _, S) {
    if (_) {
      if (b.type === "value-ref") (D = _).ref ? D.getValue = s(b.resolveRef, D.ref) : D.getValue = function() {
        throw new Error("Unset ref in ValueRef value.");
      };
      else if (b.type === "data-ref")
        (D = _).ref ? D.getValue = s(S, D.ref) : D.getValue = function() {
          throw new Error("Unset ref in ValueRef value.");
        };
      else if (b.type === "group") f(b.params, _, S);
      else if (b.type === "mapped") {
        var D = _;
        c(b.map(D.name), D.params, S);
      } else if (b.type === "object-list") {
        if (!d(b.element)) return;
        for (var I = 0, M = _; I < M.length; I++) {
          var F = M[I];
          f(b.element, F, S);
        }
      }
    }
  }
  function l(b) {
    if (b.type === "value-ref" || b.type === "data-ref") return !0;
    if (b.type === "group") {
      if (d(b.params)) return !0;
    } else if (b.type === "mapped") for (var _ = 0, S = b.select.options; _ < S.length; _++) {
      var D = S[_][0];
      if (l(b.map(D))) return !0;
    }
    else if (b.type === "object-list") return d(b.element);
    return !1;
  }
  function d(b) {
    for (var _ = 0, S = Object.keys(b); _ < S.length; _++)
      if (l(b[S[_]])) return !0;
    return !1;
  }
  function f(b, _, S) {
    for (var D = 0, I = Object.keys(b); D < I.length; D++) {
      var M = I[D];
      c(b[M], _ == null ? void 0 : _[M], S);
    }
  }
  function m(b, _, S) {
    if (_ === S) return !0;
    if (typeof _ != "object" || typeof S != "object") return !1;
    for (var D = 0, I = Object.keys(b); D < I.length; D++) {
      var M = I[D];
      if (!v(b[M], _[M], S[M])) return !1;
    }
    return !0;
  }
  function v(b, _, S) {
    if (_ === S) return !0;
    if (b.type === "group") return m(b.params, _, S);
    if (b.type === "mapped") {
      var D = S;
      return (P = _).name === D.name && v(b.map(P.name), P.params, D.params);
    }
    if (b.type === "multi-select") {
      if (D = S, (P = _).length !== D.length) return !1;
      if (P.length < 10) {
        for (var I = 0, M = P.length; I < M; I++) if (P[I] !== D[I] && D.indexOf(P[I]) < 0) return !1;
      } else {
        var F = new Set(D);
        for (I = 0, M = P.length; I < M; I++) if (P[I] !== D[I] && !F.has(P[I])) return !1;
      }
      return !0;
    }
    if (b.type === "interval") return _[0] === S[0] && _[1] === S[1];
    if (b.type === "line-graph") {
      if (D = S, (P = _).length !== D.length) return !1;
      for (I = 0, M = P.length; I < M; I++) if (!ke.areEqual(P[I], D[I])) return !1;
      return !0;
    }
    if (b.type === "vec3") return w.equals(_, S);
    if (b.type === "mat4") return me.areEqual(_, S, pn);
    if (b.type === "script")
      return D = S, (P = _).language === D.language && P.expression === D.expression;
    if (b.type === "object-list") {
      D = S;
      var P, E = (P = _).length;
      if (E !== D.length) return !1;
      for (I = 0; I < E; I++) if (!m(b.element, P[I], D[I])) return !1;
      return !0;
    }
    return typeof _ == "object" && typeof S == "object" && JE(_, S);
  }
  function p(b, _, S) {
    if (_ === void 0) return R({}, S);
    if (S === void 0) return R({}, _);
    for (var D = /* @__PURE__ */ Object.create(null), I = 0, M = Object.keys(b); I < M.length; I++) {
      var F = M[I];
      D[F] = g(b[F], _[F], S[F]);
    }
    return D;
  }
  function g(b, _, S) {
    if (_ === void 0) return typeof S != "object" || Array.isArray(S) ? S : R({}, S);
    if (S === void 0) return typeof _ != "object" || Array.isArray(_) ? _ : R({}, _);
    if (b.type === "group") return p(b.params, _, S);
    if (b.type === "mapped") {
      var D = _, I = S;
      if (D.name !== I.name) return R({}, I);
      var M = b.map(I.name);
      return { name: I.name, params: g(M, D.params, I.params) };
    }
    return b.type === "value" ? S : typeof _ == "object" && typeof S == "object" ? Array.isArray(S) ? S : R(R({}, _), S) : S;
  }
  function h(b, _) {
    for (var S = 0, D = b.options; S < D.length; S++)
      if (D[S][0] === _) return !0;
    return !1;
  }
  function y(b, _, S) {
    if (_ == null) return S ? b.defaultValue : void 0;
    if (b.type === "value") return _;
    if (b.type === "group") {
      for (var D = /* @__PURE__ */ Object.create(null), I = 0, M = Object.keys(b.params); I < M.length; I++) {
        var F = M[I], P = b.params[F];
        _[F] === void 0 ? S && (D[F] = P.defaultValue) : D[F] = y(P, _[F], S);
      }
      return D;
    }
    if (b.type === "mapped") {
      var E = _;
      return typeof E.name != "string" ? b.defaultValue : E.params === void 0 ? S ? b.defaultValue : void 0 : h(b.select, E.name) ? (P = b.map(E.name), { name: E.name, params: y(P, E.params, S) }) : b.defaultValue;
    }
    return b.type === "select" ? h(b, _) ? _ : b.defaultValue : b.type === "multi-select" ? Array.isArray(_) ? (D = _.filter(function(B) {
      return h(this, B);
    }, b), _.length > 0 && D.length === 0 ? b.defaultValue : D) : b.defaultValue : b.type === "object-list" ? Array.isArray(_) ? _.map(function(B) {
      return x(b.element, B, S ? "all" : "skip");
    }) : b.defaultValue : _;
  }
  function x(b, _, S) {
    if (typeof _ != "object" || _ === null) return S ? u(b) : _;
    for (var D = /* @__PURE__ */ Object.create(null), I = 0, M = Object.keys(b); I < M.length; I++) {
      var F = M[I], P = b[F];
      _[F] === void 0 ? S === "all" && (D[F] = P.defaultValue) : D[F] = y(P, _[F], S !== "skip");
    }
    return D;
  }
  function A(b, _) {
    for (var S = 0, D = _; S < D.length; S++)
      if (D[S][0] === b) return b;
    return _.length > 0 ? _[0][0] : void 0;
  }
  e.Essential = { isEssential: !0 }, e.Optional = function(b) {
    var _ = R({}, b);
    return _.isOptional = !0, _;
  }, e.Value = function(b, _) {
    return t({ type: "value", defaultValue: b }, _);
  }, e.Select = r, e.MultiSelect = function(b, _, S) {
    var D = t({ type: "multi-select", defaultValue: b, options: _ }, S);
    return S != null && S.emptyValue && (D.emptyValue = S.emptyValue), D;
  }, e.Boolean = function(b, _) {
    return t({ type: "boolean", defaultValue: b }, _);
  }, e.Text = function(b, _) {
    return b === void 0 && (b = ""), t({ type: "text", defaultValue: b }, _);
  }, e.Color = function(b, _) {
    var S = t({ type: "color", defaultValue: b }, _);
    return _ != null && _.isExpanded && (S.isExpanded = _.isExpanded), S;
  }, e.ColorList = function(b, _) {
    var S;
    if (typeof b == "string") {
      var D = Ec(b);
      S = { kind: D.type !== "qualitative" ? "interpolate" : "set", colors: D.list };
    } else S = b;
    return t({ type: "color-list", presetKind: (_ == null ? void 0 : _.presetKind) || "all", defaultValue: S, offsets: !!(_ != null && _.offsets) }, _);
  }, e.Vec3 = function(b, _, S) {
    return t(n({ type: "vec3", defaultValue: b }, _), S);
  }, e.Mat4 = function(b, _) {
    return t({ type: "mat4", defaultValue: b }, _);
  }, e.Url = function(b, _) {
    return t({ type: "url", defaultValue: typeof b == "string" ? Ku.Url(b) : Ku.Url(b.url, { body: b.body }) }, _);
  }, e.File = function(b) {
    var _ = t({ type: "file", defaultValue: null }, b);
    return b != null && b.accept && (_.accept = b.accept), _;
  }, e.FileList = function(b) {
    var _ = t({ type: "file-list", defaultValue: null }, b);
    return b != null && b.accept && (_.accept = b.accept), _;
  }, e.Numeric = function(b, _, S) {
    var D = t(n({ type: "number", defaultValue: b }, _), S);
    return S != null && S.immediateUpdate && (D.immediateUpdate = !0), D;
  }, e.Interval = function(b, _, S) {
    return t(n({ type: "interval", defaultValue: b }, _), S);
  }, e.LineGraph = function(b, _) {
    return t({ type: "line-graph", defaultValue: b }, _);
  }, e.Group = i, e.EmptyGroup = function(b) {
    return i({}, b);
  }, e.Mapped = function(b, _, S, D) {
    var I = A(b, _);
    return t({ type: "mapped", defaultValue: { name: I, params: S(I).defaultValue }, select: r(I, _, D), map: S }, D);
  }, e.MappedStatic = function(b, _, S) {
    var D = S != null && S.options ? S.options : Object.keys(_).map(function(M) {
      return [M, _[M].label || Is(M)];
    }), I = A(b, D);
    return t({ type: "mapped", defaultValue: { name: I, params: _[I].defaultValue }, select: r(I, D, S), map: function(M) {
      return _[M];
    } }, S);
  }, e.ObjectList = function(b, _, S) {
    return t({ type: "object-list", element: b, getLabel: _, ctor: a, defaultValue: (S == null ? void 0 : S.defaultValue) || [] }, S);
  }, e.ValueRef = function(b, _, S) {
    var D;
    return t({ type: "value-ref", defaultValue: { ref: (D = S == null ? void 0 : S.defaultRef) !== null && D !== void 0 ? D : "", getValue: o }, getOptions: b, resolveRef: _ }, S);
  }, e.DataRef = function(b) {
    var _;
    return t({ type: "data-ref", defaultValue: { ref: (_ = b == null ? void 0 : b.defaultRef) !== null && _ !== void 0 ? _ : "", getValue: o } }, b);
  }, e.Converted = function(b, _, S) {
    return { type: "converted", defaultValue: _(S.defaultValue), converted: S, fromValue: b, toValue: _ };
  }, e.Conditioned = function(b, _, S, D, I) {
    var M = Object.keys(_).map(function(F) {
      return [F, F];
    });
    return t({ type: "conditioned", select: r(S(b), M, I), defaultValue: b, conditionParams: _, conditionForValue: S, conditionedValue: D }, I);
  }, e.Script = function(b, _) {
    return t({ type: "script", defaultValue: b }, _);
  }, e.For = function(b) {
    return 0;
  }, e.getDefaultValues = u, e.resolveRefs = f, e.setDefaultValues = function(b, _) {
    for (var S = 0, D = Object.keys(b); S < D.length; S++) {
      var I = D[S];
      b[I].isOptional || (b[I].defaultValue = _[I]);
    }
  }, e.clone = function(b) {
    return Tc(b);
  }, e.validate = function(b, _) {
  }, e.areEqual = m, e.isParamEqual = v, e.merge = p, e.mergeParam = g, e.normalizeParams = x, e.objectToOptions = function(b, _) {
    for (var S = [], D = 0, I = Object.keys(b); D < I.length; D++) {
      var M = I[D];
      if (_) {
        var F = _(M, b[M]);
        S.push(typeof F == "string" ? [M, F] : [M, F[0], F[1]]);
      } else typeof b[M] == "string" ? S.push([M, b[M]]) : S.push([M, _ === null ? M : Is(M)]);
    }
    return S;
  }, e.arrayToOptions = function(b, _) {
    for (var S = [], D = 0, I = b; D < I.length; D++) {
      var M = I[D];
      _ ? S.push([M, _(M)]) : S.push([M, _ === null ? M : Is(M)]);
    }
    return S;
  }, e.optionLabel = function(b, _) {
    for (var S = 0, D = b.options; S < D.length; S++) {
      var I = D[S];
      if (I[0] === _) return I[1];
    }
    return "";
  };
})(G || (G = {}));
var sb, cb = { backgroundColor: G.Color(He(0), { description: "Background color of the 3D canvas" }), pickingAlphaThreshold: G.Numeric(0.3, { min: 0, max: 1, step: 0.01 }, { description: "The minimum opacity value needed for an object to be pickable." }), interiorDarkening: G.Numeric(0.5, { min: 0, max: 1, step: 0.01 }), interiorColorFlag: G.Boolean(!0, { label: "Use Interior Color" }), interiorColor: G.Color(He.fromNormalizedRgb(0.3, 0.3, 0.3)), highlightColor: G.Color(He.fromNormalizedRgb(1, 0.4, 0.6)), selectColor: G.Color(He.fromNormalizedRgb(0.2, 1, 0.1)), highlightStrength: G.Numeric(0.3, { min: 0, max: 1, step: 0.1 }), selectStrength: G.Numeric(0.3, { min: 0, max: 1, step: 0.1 }), markerPriority: G.Select(1, [[1, "Highlight"], [2, "Select"]]), xrayEdgeFalloff: G.Numeric(1, { min: 0, max: 3, step: 0.1 }), light: G.ObjectList({ inclination: G.Numeric(180, { min: 0, max: 180, step: 1 }), azimuth: G.Numeric(0, { min: 0, max: 360, step: 1 }), color: G.Color(He.fromNormalizedRgb(1, 1, 1)), intensity: G.Numeric(0.6, { min: 0, max: 1, step: 0.01 }) }, function(e) {
  return He.toHexString(e.color);
}, { defaultValue: [{ inclination: 180, azimuth: 0, color: He.fromNormalizedRgb(1, 1, 1), intensity: 0.6 }] }), ambientColor: G.Color(He.fromNormalizedRgb(1, 1, 1)), ambientIntensity: G.Numeric(0.45, { min: 0, max: 1, step: 0.01 }), invalidColor: G.Color(He(16410214)), invalidStrength: G.Numeric(0.2, { min: 0, max: 1, step: 0.1 }) }, A9 = w(), By = w();
function S9(e, t) {
  for (var r = t || { direction: new Array(15).fill(0), color: new Array(15).fill(0) }, n = r.direction, i = r.color, a = 0, o = e.length; a < o; ++a) {
    var u = e[a];
    w.directionFromSpherical(A9, Bn(u.inclination), Bn(u.azimuth), 1), w.toArray(A9, n, 3 * a), w.scale(By, He.toVec3Normalized(By, u.color), u.intensity), w.toArray(By, i, 3 * a);
  }
  return { count: e.length, direction: n, color: i };
}
function si(e, t, r) {
  return t === void 0 && (t = ""), r === void 0 && (r = ""), si.create(e, t, r);
}
(function(e) {
  e.create = function(t, r) {
    r === void 0 && (r = {});
    var n = t.gl, i = t.state, a = t.stats, o = G.merge(cb, G.getDefaultValues(cb), r), u = S9(o.light), s = Vi(), c = ke.create(n.drawingBufferWidth, n.drawingBufferHeight), l = He.toVec3Normalized(w(), o.backgroundColor), d = !1, f = t.resources.texture("image-depth", "depth", "ushort", "nearest"), m = [["tDepth", f]], v = me(), p = me(), g = me(), h = me(), y = me(), x = me(), A = me(), b = w(), _ = ke(), S = w();
    w.scale(S, He.toArrayNormalized(o.ambientColor, S, 0), o.ambientIntensity);
    var D = { uModel: k.create(me.identity()), uView: k.create(v), uInvView: k.create(p), uModelView: k.create(g), uInvModelView: k.create(h), uInvProjection: k.create(y), uProjection: k.create(me()), uModelViewProjection: k.create(x), uInvModelViewProjection: k.create(A), uIsOrtho: k.create(1), uViewOffset: k.create(_), uPixelRatio: k.create(t.pixelRatio), uViewport: k.create(Vi.toVec4(Vt(), s)), uDrawingBufferSize: k.create(c), uCameraPosition: k.create(w()), uCameraDir: k.create(b), uNear: k.create(1), uFar: k.create(1e4), uFogNear: k.create(1), uFogFar: k.create(1e4), uFogColor: k.create(l), uRenderWboit: k.create(!1), uMarkingDepthTest: k.create(!1), uPickType: k.create(0), uMarkingType: k.create(0), uTransparentBackground: k.create(!1), uLightDirection: k.create(u.direction), uLightColor: k.create(u.color), uAmbientColor: k.create(S), uPickingAlphaThreshold: k.create(o.pickingAlphaThreshold), uInteriorDarkening: k.create(o.interiorDarkening), uInteriorColorFlag: k.create(o.interiorColorFlag), uInteriorColor: k.create(He.toVec3Normalized(w(), o.interiorColor)), uHighlightColor: k.create(He.toVec3Normalized(w(), o.highlightColor)), uSelectColor: k.create(He.toVec3Normalized(w(), o.selectColor)), uHighlightStrength: k.create(o.highlightStrength), uSelectStrength: k.create(o.selectStrength), uMarkerPriority: k.create(o.markerPriority), uXrayEdgeFalloff: k.create(o.xrayEdgeFalloff), uInvalidColor: k.create(He.toVec3Normalized(w(), o.invalidColor)), uInvalidStrength: k.create(o.invalidStrength) }, I = Object.entries(D), M = !0, F = function(N, O) {
      if (!N.state.disposed && N.state.visible && (N.state.pickable || O !== "pick")) {
        var z = !1;
        N.values.dLightCount.ref.value !== u.count && (k.update(N.values.dLightCount, u.count), z = !0), z && N.update();
        var V = N.getProgram(O);
        if (i.currentProgramId !== V.id && (M = !0, V.use()), M && (V.setUniforms(I), M = !1), N.values.dGeometryType.ref.value === "directVolume") {
          if (O !== "colorWboit" && O !== "colorBlended") return;
          i.disable(n.CULL_FACE), i.frontFace(n.CCW), O === "colorBlended" && (i.disable(n.DEPTH_TEST), i.depthMask(!1));
        } else N.values.uDoubleSided ? N.values.uDoubleSided.ref.value || N.values.hasReflection.ref.value ? i.disable(n.CULL_FACE) : i.enable(n.CULL_FACE) : i.disable(n.CULL_FACE), N.values.dFlipSided && N.values.dFlipSided.ref.value ? (i.frontFace(n.CW), i.cullFace(n.FRONT)) : (i.frontFace(n.CCW), i.cullFace(n.BACK));
        N.render(O, m);
      }
    }, P = function(N, O, z, V, U) {
      (function(W, Q, te) {
        for (var ee = 0, $ = W.length; ee < $; ++ee) if (W[ee][0] === Q) return void (W[ee][1] = te);
        W.push([Q, te]);
      })(m, "tDepth", z || f), k.update(D.uModel, N.view), k.update(D.uModelView, me.mul(g, N.view, O.view)), k.update(D.uInvModelView, me.invert(h, g)), k.update(D.uModelViewProjection, me.mul(x, g, O.projection)), k.update(D.uInvModelViewProjection, me.invert(A, x)), k.updateIfChanged(D.uRenderWboit, V), k.updateIfChanged(D.uMarkingDepthTest, U), i.enable(n.SCISSOR_TEST), i.colorMask(!0, !0, !0, !0);
      var H = s.x, K = s.y, j = s.width, X = s.height;
      n.viewport(H, K, j, X), n.scissor(H, K, j, X), M = !0, i.currentRenderItemId = -1;
    }, E = function(N, O, z) {
      i.disable(n.BLEND), i.enable(n.DEPTH_TEST), i.depthMask(!0), P(N, O, z, !1, !1);
      for (var V = N.renderables, U = 0, H = V.length; U < H; ++U) {
        var K = V[U];
        K.state.opaque && F(K, "colorBlended");
      }
    }, B = function(N, O, z) {
      i.enable(n.DEPTH_TEST), P(N, O, z, !1, !1);
      var V = N.renderables;
      d ? i.blendFunc(n.ONE, n.ONE_MINUS_SRC_ALPHA) : i.blendFuncSeparate(n.SRC_ALPHA, n.ONE_MINUS_SRC_ALPHA, n.ONE, n.ONE_MINUS_SRC_ALPHA), i.enable(n.BLEND), i.depthMask(!0);
      for (var U = 0, H = V.length; U < H; ++U)
        !(K = V[U]).state.opaque && K.state.writeDepth && F(K, "colorBlended");
      for (i.depthMask(!1), U = 0, H = V.length; U < H; ++U) {
        var K;
        (K = V[U]).state.opaque || K.state.writeDepth || F(K, "colorBlended");
      }
    };
    return { clear: function(N, O) {
      i.enable(n.SCISSOR_TEST), i.enable(n.DEPTH_TEST), i.colorMask(!0, !0, !0, !0), i.depthMask(!0), d && !O ? i.clearColor(0, 0, 0, 0) : N ? i.clearColor(l[0], l[1], l[2], 1) : i.clearColor(1, 1, 1, 1), n.clear(n.COLOR_BUFFER_BIT | n.DEPTH_BUFFER_BIT);
    }, clearDepth: function() {
      i.enable(n.SCISSOR_TEST), i.enable(n.DEPTH_TEST), i.depthMask(!0), n.clear(n.DEPTH_BUFFER_BIT);
    }, update: function(N) {
      k.update(D.uView, N.view), k.update(D.uInvView, me.invert(p, N.view)), k.update(D.uProjection, N.projection), k.update(D.uInvProjection, me.invert(y, N.projection)), k.updateIfChanged(D.uIsOrtho, N.state.mode === "orthographic" ? 1 : 0), k.update(D.uViewOffset, N.viewOffset.enabled ? ke.set(_, 16 * N.viewOffset.offsetX, 16 * N.viewOffset.offsetY) : ke.set(_, 0, 0)), k.update(D.uCameraPosition, N.state.position), k.update(D.uCameraDir, w.normalize(b, w.sub(b, N.state.target, N.state.position))), k.updateIfChanged(D.uFar, N.far), k.updateIfChanged(D.uNear, N.near), k.updateIfChanged(D.uFogFar, N.fogFar), k.updateIfChanged(D.uFogNear, N.fogNear), k.updateIfChanged(D.uTransparentBackground, d);
    }, renderPick: function(N, O, z, V, U) {
      i.disable(n.BLEND), i.enable(n.DEPTH_TEST), i.depthMask(!0), P(N, O, V, !1, !1), k.updateIfChanged(D.uPickType, U);
      for (var H = N.renderables, K = 0, j = H.length; K < j; ++K) H[K].state.colorOnly || F(H[K], z);
    }, renderDepth: function(N, O, z) {
      i.disable(n.BLEND), i.enable(n.DEPTH_TEST), i.depthMask(!0), P(N, O, z, !1, !1);
      for (var V = N.renderables, U = 0, H = V.length; U < H; ++U) F(V[U], "depth");
    }, renderMarkingDepth: function(N, O, z) {
      i.disable(n.BLEND), i.enable(n.DEPTH_TEST), i.depthMask(!0), P(N, O, z, !1, !1), k.updateIfChanged(D.uMarkingType, 1);
      for (var V = N.renderables, U = 0, H = V.length; U < H; ++U)
        V[U].values.markerAverage.ref.value !== 1 && F(V[U], "marking");
    }, renderMarkingMask: function(N, O, z) {
      i.disable(n.BLEND), i.enable(n.DEPTH_TEST), i.depthMask(!0), P(N, O, z, !1, !!z), k.updateIfChanged(D.uMarkingType, 2);
      for (var V = N.renderables, U = 0, H = V.length; U < H; ++U)
        V[U].values.markerAverage.ref.value > 0 && F(V[U], "marking");
    }, renderBlended: function(N, O, z) {
      E(N, O, z), B(N, O, z);
    }, renderBlendedOpaque: E, renderBlendedTransparent: B, renderBlendedVolumeOpaque: function(N, O, z) {
      var V;
      i.blendFunc(n.ONE, n.ONE_MINUS_SRC_ALPHA), i.enable(n.BLEND), P(N, O, z, !1, !1);
      for (var U = N.renderables, H = 0, K = U.length; H < K; ++H) {
        var j = U[H];
        Qa(j.values.alpha.ref.value * j.state.alphaFactor, 0, 1) !== 1 || j.values.transparencyAverage.ref.value === 1 || !((V = j.values.dXrayShaded) === null || V === void 0) && V.ref.value || F(j, "colorBlended");
      }
    }, renderBlendedVolumeTransparent: function(N, O, z) {
      var V;
      i.blendFunc(n.ONE, n.ONE_MINUS_SRC_ALPHA), i.enable(n.BLEND), P(N, O, z, !1, !1);
      for (var U = N.renderables, H = 0, K = U.length; H < K; ++H) {
        var j = U[H];
        (Qa(j.values.alpha.ref.value * j.state.alphaFactor, 0, 1) < 1 || j.values.transparencyAverage.ref.value > 0 || !((V = j.values.dXrayShaded) === null || V === void 0) && V.ref.value) && F(j, "colorBlended");
      }
    }, renderWboitOpaque: function(N, O, z) {
      var V, U;
      i.disable(n.BLEND), i.enable(n.DEPTH_TEST), i.depthMask(!0), P(N, O, z, !1, !1);
      for (var H = N.renderables, K = 0, j = H.length; K < j; ++K) {
        var X = H[K];
        Qa(X.values.alpha.ref.value * X.state.alphaFactor, 0, 1) !== 1 || X.values.transparencyAverage.ref.value === 1 || X.values.dGeometryType.ref.value === "directVolume" || ((V = X.values.dPointStyle) === null || V === void 0 ? void 0 : V.ref.value) === "fuzzy" || !((U = X.values.dXrayShaded) === null || U === void 0) && U.ref.value || F(X, "colorWboit");
      }
    }, renderWboitTransparent: function(N, O, z) {
      var V, U;
      P(N, O, z, !0, !1);
      for (var H = N.renderables, K = 0, j = H.length; K < j; ++K) {
        var X = H[K];
        (Qa(X.values.alpha.ref.value * X.state.alphaFactor, 0, 1) < 1 || X.values.transparencyAverage.ref.value > 0 || X.values.dGeometryType.ref.value === "directVolume" || ((V = X.values.dPointStyle) === null || V === void 0 ? void 0 : V.ref.value) === "fuzzy" || X.values.uBackgroundColor || !((U = X.values.dXrayShaded) === null || U === void 0) && U.ref.value) && F(X, "colorWboit");
      }
    }, setProps: function(N) {
      N.backgroundColor !== void 0 && N.backgroundColor !== o.backgroundColor && (o.backgroundColor = N.backgroundColor, He.toVec3Normalized(l, o.backgroundColor), k.update(D.uFogColor, w.copy(D.uFogColor.ref.value, l))), N.pickingAlphaThreshold !== void 0 && N.pickingAlphaThreshold !== o.pickingAlphaThreshold && (o.pickingAlphaThreshold = N.pickingAlphaThreshold, k.update(D.uPickingAlphaThreshold, o.pickingAlphaThreshold)), N.interiorDarkening !== void 0 && N.interiorDarkening !== o.interiorDarkening && (o.interiorDarkening = N.interiorDarkening, k.update(D.uInteriorDarkening, o.interiorDarkening)), N.interiorColorFlag !== void 0 && N.interiorColorFlag !== o.interiorColorFlag && (o.interiorColorFlag = N.interiorColorFlag, k.update(D.uInteriorColorFlag, o.interiorColorFlag)), N.interiorColor !== void 0 && N.interiorColor !== o.interiorColor && (o.interiorColor = N.interiorColor, k.update(D.uInteriorColor, He.toVec3Normalized(D.uInteriorColor.ref.value, o.interiorColor))), N.highlightColor !== void 0 && N.highlightColor !== o.highlightColor && (o.highlightColor = N.highlightColor, k.update(D.uHighlightColor, He.toVec3Normalized(D.uHighlightColor.ref.value, o.highlightColor))), N.selectColor !== void 0 && N.selectColor !== o.selectColor && (o.selectColor = N.selectColor, k.update(D.uSelectColor, He.toVec3Normalized(D.uSelectColor.ref.value, o.selectColor))), N.highlightStrength !== void 0 && N.highlightStrength !== o.highlightStrength && (o.highlightStrength = N.highlightStrength, k.update(D.uHighlightStrength, o.highlightStrength)), N.selectStrength !== void 0 && N.selectStrength !== o.selectStrength && (o.selectStrength = N.selectStrength, k.update(D.uSelectStrength, o.selectStrength)), N.markerPriority !== void 0 && N.markerPriority !== o.markerPriority && (o.markerPriority = N.markerPriority, k.update(D.uMarkerPriority, o.markerPriority)), N.xrayEdgeFalloff !== void 0 && N.xrayEdgeFalloff !== o.xrayEdgeFalloff && (o.xrayEdgeFalloff = N.xrayEdgeFalloff, k.update(D.uXrayEdgeFalloff, o.xrayEdgeFalloff)), N.light === void 0 || td(N.light, o.light) || (o.light = N.light, Object.assign(u, S9(N.light, u)), k.update(D.uLightDirection, u.direction), k.update(D.uLightColor, u.color)), N.ambientColor !== void 0 && N.ambientColor !== o.ambientColor && (o.ambientColor = N.ambientColor, w.scale(S, He.toArrayNormalized(o.ambientColor, S, 0), o.ambientIntensity), k.update(D.uAmbientColor, S)), N.ambientIntensity !== void 0 && N.ambientIntensity !== o.ambientIntensity && (o.ambientIntensity = N.ambientIntensity, w.scale(S, He.toArrayNormalized(o.ambientColor, S, 0), o.ambientIntensity), k.update(D.uAmbientColor, S)), N.invalidColor !== void 0 && N.invalidColor !== o.invalidColor && (o.invalidColor = N.invalidColor, k.update(D.uInvalidColor, He.toVec3Normalized(D.uInvalidColor.ref.value, o.invalidColor))), N.invalidStrength !== void 0 && N.invalidStrength !== o.invalidStrength && (o.invalidStrength = N.invalidStrength, k.update(D.uInvalidStrength, o.invalidStrength));
    }, setViewport: function(N, O, z, V) {
      n.viewport(N, O, z, V), n.scissor(N, O, z, V), N === s.x && O === s.y && z === s.width && V === s.height || (Vi.set(s, N, O, z, V), k.update(D.uViewport, Vt.set(D.uViewport.ref.value, N, O, z, V)));
    }, setTransparentBackground: function(N) {
      d = N;
    }, setDrawingBufferSize: function(N, O) {
      N === c[0] && O === c[1] || k.update(D.uDrawingBufferSize, ke.set(c, N, O));
    }, setPixelRatio: function(N) {
      k.update(D.uPixelRatio, N);
    }, props: o, get stats() {
      return { programCount: t.stats.resourceCounts.program, shaderCount: t.stats.resourceCounts.shader, attributeCount: t.stats.resourceCounts.attribute, elementsCount: t.stats.resourceCounts.elements, framebufferCount: t.stats.resourceCounts.framebuffer, renderbufferCount: t.stats.resourceCounts.renderbuffer, textureCount: t.stats.resourceCounts.texture, vertexArrayCount: t.stats.resourceCounts.vertexArray, drawCount: a.drawCount, instanceCount: a.instanceCount, instancedDrawCount: a.instancedDrawCount };
    }, dispose: function() {
    } };
  };
})(sb || (sb = {})), function(e) {
  function t(n) {
    return n.triggers.map(r.format).join(" or ");
  }
  function r(n, i) {
    return r.create(n, i);
  }
  e.create = function(n, i, a) {
    return i === void 0 && (i = ""), a === void 0 && (a = ""), { triggers: n, action: i, description: a };
  }, e.Empty = { triggers: [], action: "", description: "" }, e.isEmpty = function(n) {
    return n.triggers.length === 0 || n.triggers.every(function(i) {
      return i.buttons === void 0 && i.modifiers === void 0;
    });
  }, e.match = function(n, i, a) {
    return n.triggers.some(function(o) {
      return r.match(o, i, a);
    });
  }, e.formatTriggers = t, e.format = function(n, i) {
    return i === void 0 && (i = ""), function(a, o) {
      var u = Object.keys(o), s = Object.values(o);
      return new (Function.bind.apply(Function, We(We([void 0], u, !1), ["return `".concat(a, "`;")], !1)))().apply(void 0, s);
    }(n.description || Is(i), { triggers: "<i>" + t(n) + "</i>" });
  }, e.Trigger = r, function(n) {
    n.create = function(i, a) {
      return { buttons: i, modifiers: a };
    }, n.Empty = {}, n.match = function(i, a, o) {
      var u = i.buttons, s = i.modifiers;
      return u !== void 0 && (u === a || cf.has(u, a)) && (!s || H1.areEqual(s, o));
    }, n.format = function(i) {
      var a = [], o = function(s) {
        var c = [];
        return s === void 0 ? c.push("any mouse button") : s === 0 ? c.push("mouse hover") : (kh.has(s, 1) && c.push("left mouse button"), kh.has(s, 2) && c.push("right mouse button"), kh.has(s, 4) && c.push("wheel/middle mouse button"), kh.has(s, 8) && c.push("three fingers")), c.join(" + ");
      }(i.buttons);
      o && a.push(o);
      var u = function(s, c) {
        var l = [];
        return s && (s.alt && l.push("alt key"), s.control && l.push("control key"), s.meta && l.push("meta/command key"), s.shift && l.push("shift key")), l.join(" + ");
      }(i.modifiers);
      return u && a.push(u), a.join(" + ");
    };
  }(r = e.Trigger || (e.Trigger = {}));
}(si || (si = {}));
var ro, kh = cf;
(function(e) {
  e.create = function() {
    var t = new rq(), r = function() {
      return t.create();
    };
    return r.dispose = function() {
      return t.dispose();
    }, r.behavior = function(n) {
      return t.behavior(n);
    }, r;
  };
})(ro || (ro = {}));
var lb, rq = function() {
  function e() {
    this._eventList = [], this._disposed = !1;
  }
  return e.prototype.create = function() {
    var t = new ui();
    return this._eventList.push(t), t;
  }, e.prototype.behavior = function(t) {
    var r = new Ol(t);
    return this._eventList.push(r), r;
  }, e.prototype.dispose = function() {
    if (!this._disposed) {
      for (var t = 0, r = this._eventList; t < r.length; t++)
        r[t].complete();
      this._disposed = !0;
    }
  }, e;
}(), ol = H1, ul = si.Trigger, nq = { dragRotate: si([ul(1, ol.create())], "Rotate", "Drag using ${triggers}"), dragRotateZ: si([ul(1, ol.create({ shift: !0 }))], "Rotate around z-axis", "Drag using ${triggers}"), dragPan: si([ul(2, ol.create()), ul(1, ol.create({ control: !0 }))], "Pan", "Drag using ${triggers}"), dragZoom: si.Empty, dragFocus: si([ul(8, ol.create())], "Focus", "Drag using ${triggers}"), dragFocusZoom: si([ul(4, ol.create())], "Focus and zoom", "Drag using ${triggers}"), scrollZoom: si([ul(4, ol.create())], "Zoom", "Scroll using ${triggers}"), scrollFocus: si([ul(4, ol.create({ shift: !0 }))], "Clip", "Scroll using ${triggers}"), scrollFocusZoom: si.Empty }, mM = { noScroll: G.Boolean(!0, { isHidden: !0 }), rotateSpeed: G.Numeric(5, { min: 1, max: 10, step: 1 }), zoomSpeed: G.Numeric(7, { min: 1, max: 15, step: 1 }), panSpeed: G.Numeric(1, { min: 0.1, max: 5, step: 0.1 }), animate: G.MappedStatic("off", { off: G.EmptyGroup(), spin: G.Group({ speed: G.Numeric(1, { min: -20, max: 20, step: 1 }) }, { description: "Spin the 3D scene around the x-axis in view space" }), rock: G.Group({ speed: G.Numeric(0.3, { min: -5, max: 5, step: 0.1 }), angle: G.Numeric(10, { min: 0, max: 90, step: 1 }, { description: "How many degrees to rotate in each direction." }) }, { description: "Rock the 3D scene around the x-axis in view space" }) }), staticMoving: G.Boolean(!0, { isHidden: !0 }), dynamicDampingFactor: G.Numeric(0.2, {}, { isHidden: !0 }), minDistance: G.Numeric(0.01, {}, { isHidden: !0 }), maxDistance: G.Numeric(1e150, {}, { isHidden: !0 }), gestureScaleFactor: G.Numeric(1, {}, { isHidden: !0 }), maxWheelDelta: G.Numeric(0.02, {}, { isHidden: !0 }), bindings: G.Value(nq, { isHidden: !0 }), autoAdjustMinMaxDistance: G.MappedStatic("on", { off: G.EmptyGroup(), on: G.Group({ minDistanceFactor: G.Numeric(0), minDistancePadding: G.Numeric(5), maxDistanceFactor: G.Numeric(10), maxDistanceMin: G.Numeric(20) }) }, { isHidden: !0 }) };
(function(e) {
  e.create = function(t, r, n) {
    n === void 0 && (n = {});
    var i = ro.create(), a = R(R({}, G.getDefaultValues(mM)), n), o = Vi.clone(r.viewport), u = !1, s = i.behavior(!1), c = i.behavior([]), l = i.behavior(!1), d = t.drag.subscribe(function(Fe) {
      var Je = Fe.x, Ne = Fe.y, nt = Fe.pageX, re = Fe.pageY, J = Fe.buttons, ce = Fe.modifiers, de = Fe.isStart, ve = le(Je, Ne);
      if (!(s.value && c.value.includes("drag") && (l.value || J !== 1)) && !(de && ve) && !(!de && !g)) {
        g = !0, Ze();
        var he = si.match(a.bindings.dragRotate, J, ce), Se = si.match(a.bindings.dragRotateZ, J, ce), Re = si.match(a.bindings.dragPan, J, ce), Ve = si.match(a.bindings.dragZoom, J, ce), ze = si.match(a.bindings.dragFocus, J, ce), mt = si.match(a.bindings.dragFocusZoom, J, ce);
        if (function(Ct, De) {
          ke.set(H, (Ct - 0.5 * o.width - o.x) / (0.5 * o.width), (o.height + 2 * (o.y - De)) / o.width);
        }(nt, re), function(Ct, De) {
          ke.set(U, (Ct - o.x) / o.width, (De - o.y) / o.height);
        }(nt, re), de && (he && (ke.copy(A, H), ke.copy(x, A)), Se && (ke.copy(D, H), ke.copy(S, D)), (Ve || mt) && (ke.copy(M, U), ke.copy(F, M)), ze && (ke.copy(P, U), ke.copy(E, P)), Re && (ke.copy(B, U), ke.copy(N, B))), he && ke.copy(A, H), Se && ke.copy(D, H), (Ve || mt) && ke.copy(F, U), ze && ke.copy(E, U), mt) {
          var bt = w.distance(r.state.position, r.state.target);
          r.setState({ radius: bt / 5 });
        }
        Re && ke.copy(N, U);
      }
    }), f = t.interactionEnd.subscribe(function() {
      g = !1;
    }), m = t.wheel.subscribe(function(Fe) {
      var Je = Fe.x, Ne = Fe.y, nt = Fe.spinX, re = Fe.spinY, J = Fe.dz, ce = Fe.buttons, de = Fe.modifiers;
      if (!le(Je, Ne)) {
        var ve = function() {
          for (var he = [], Se = 0; Se < arguments.length; Se++) he[Se] = arguments[Se];
          for (var Re = 0, Ve = 0, ze = 0, mt = he.length; ze < mt; ++ze) {
            var bt = he[ze], Ct = Math.abs(bt);
            Ct > Ve && (Re = bt, Ve = Ct);
          }
          return Re;
        }(0.075 * nt, 0.075 * re, 1e-4 * J);
        ve < -a.maxWheelDelta ? ve = -a.maxWheelDelta : ve > a.maxWheelDelta && (ve = a.maxWheelDelta), si.match(a.bindings.scrollZoom, ce, de) && (F[1] += ve), si.match(a.bindings.scrollFocus, ce, de) && (E[1] += ve);
      }
    }), v = t.pinch.subscribe(function(Fe) {
      var Je = Fe.fractionDelta, Ne = Fe.buttons, nt = Fe.modifiers;
      si.match(a.bindings.scrollZoom, Ne, nt) && (g = !0, F[1] += a.gestureScaleFactor * Je);
    }), p = t.gesture.subscribe(function(Fe) {
      var Je = Fe.deltaScale;
      g = !0, F[1] += a.gestureScaleFactor * Je;
    }), g = !1, h = w(), y = w(), x = ke(), A = ke(), b = w(), _ = 0, S = ke(), D = ke(), I = 0, M = ke(), F = ke(), P = ke(), E = ke(), B = ke(), N = ke(), O = w.clone(r.target), z = w.clone(r.position), V = w.clone(r.up), U = ke(), H = ke();
    function K() {
      var Fe = t.width / t.height;
      return a.rotateSpeed * t.pixelRatio * Fe;
    }
    var j = w(), X = In(), W = w(), Q = w(), te = w(), ee = w(), $ = In(), ie = ke(), ae = w(), se = w();
    function le(Fe, Je) {
      return Fe *= t.pixelRatio, Je *= t.pixelRatio, Fe > o.x + o.width || t.height - Je > o.y + o.height || Fe < o.x || t.height - Je < o.y;
    }
    var pe = -1;
    function we(Fe) {
      var Je, Ne, nt, re, J;
      pe !== Fe && (pe > 0 && (a.animate.name === "spin" ? function(ce) {
        if (!(a.animate.name !== "spin" || a.animate.params.speed === 0 || g)) {
          var de = a.animate.params.speed / 1e3;
          Ge[0] = 60 * Math.min(Math.abs(ce), 125) / 1e3 * de, ke.add(A, x, Ge);
        }
      }(Fe - pe) : a.animate.name === "rock" && function(ce) {
        if (!(a.animate.name !== "rock" || a.animate.params.speed === 0 || g)) {
          var de = ce / 1e3 * a.animate.params.speed, ve = Bn(a.animate.params.angle) / K(), he = Math.sin(Ue * Math.PI * 2) * ve, Se = Math.sin((Ue + de) * Math.PI * 2) * ve;
          Ke[0] = Se - he, ke.add(A, x, Ke), (Ue += de) >= 1 && (Ue = 0);
        }
      }(Fe - pe)), w.sub(y, r.position, r.target), function() {
        var ce = A[0] - x[0], de = A[1] - x[1];
        w.set(ee, ce, de, 0);
        var ve = w.magnitude(ee) * K();
        ve ? (w.sub(y, r.position, r.target), w.normalize(W, y), w.normalize(Q, r.up), w.normalize(te, w.cross(te, Q, W)), w.setMagnitude(Q, Q, de), w.setMagnitude(te, te, ce), w.add(ee, Q, te), w.normalize(j, w.cross(j, ee, y)), In.setAxisAngle(X, j, ve), w.transformQuat(y, y, X), w.transformQuat(r.up, r.up, X), w.copy(b, j), _ = ve) : !a.staticMoving && _ && (_ *= Math.sqrt(1 - a.dynamicDampingFactor), w.sub(y, r.position, r.target), In.setAxisAngle(X, b, _), w.transformQuat(y, y, X), w.transformQuat(r.up, r.up, X)), ke.copy(x, A);
      }(), Je = D[0] - S[0], Ne = D[1] - S[1], (nt = a.rotateSpeed * (-Je + Ne) * -0.05) ? (w.sub(y, r.position, r.target), In.setAxisAngle($, y, nt), w.transformQuat(r.up, r.up, $), I = nt) : !a.staticMoving && I && (I *= Math.sqrt(1 - a.dynamicDampingFactor), w.sub(y, r.position, r.target), In.setAxisAngle($, y, I), w.transformQuat(r.up, r.up, $)), ke.copy(S, D), (re = 1 + (F[1] - M[1]) * a.zoomSpeed) !== 1 && re > 0 && w.scale(y, y, re), a.staticMoving ? ke.copy(M, F) : M[1] += (F[1] - M[1]) * a.dynamicDampingFactor, function() {
        var ce = (E[1] - P[1]) * a.zoomSpeed;
        if (ce !== 0) {
          var de = Math.max(1, r.state.radius + r.state.radius * ce);
          r.setState({ radius: de });
        }
        a.staticMoving ? ke.copy(P, E) : P[1] += (E[1] - P[1]) * a.dynamicDampingFactor;
      }(), function() {
        if (ke.sub(ie, ke.copy(ie, N), B), ke.squaredMagnitude(ie)) {
          var ce = t.pixelRatio * a.panSpeed;
          ie[0] *= 1 / r.zoom * r.viewport.width * ce, ie[1] *= 1 / r.zoom * r.viewport.height * ce, w.cross(se, w.copy(se, y), r.up), w.setMagnitude(se, se, ie[0]), w.setMagnitude(ae, r.up, ie[1]), w.add(se, se, ae), w.add(r.position, r.position, se), w.add(r.target, r.target, se), a.staticMoving ? ke.copy(B, N) : (ke.sub(ie, N, B), ke.scale(ie, ie, a.dynamicDampingFactor), ke.add(B, B, ie));
        }
      }(), w.add(r.position, r.target, y), J = Math.min(Math.max(1e3 * r.state.radiusMax, 0.01), a.maxDistance), w.squaredMagnitude(y) > J * J && (w.setMagnitude(y, y, J), w.add(r.position, r.target, y), ke.copy(M, F), ke.copy(P, E)), w.squaredMagnitude(y) < a.minDistance * a.minDistance && (w.setMagnitude(y, y, a.minDistance), w.add(r.position, r.target, y), ke.copy(M, F), ke.copy(P, E)), w.squaredDistance(h, r.position) > pn && w.copy(h, r.position), pe = Fe);
    }
    var Ge = ke.create(5e-3, 0), Ue = 0, Ke = ke.create(5e-3, 0);
    function Ze() {
      Ue = 0;
    }
    return { viewport: o, get isAnimating() {
      return a.animate.name !== "off";
    }, get props() {
      return a;
    }, setProps: function(Fe) {
      var Je;
      ((Je = Fe.animate) === null || Je === void 0 ? void 0 : Je.name) === "rock" && a.animate.name !== "rock" && Ze(), Object.assign(a, Fe);
    }, get isEditing() {
      return s.value;
    }, get disabledInteraction() {
      return c.value;
    }, get isLockCamera() {
      return l.value;
    }, start: function(Fe) {
      pe = -1, we(Fe);
    }, update: we, reset: function() {
      w.copy(r.target, O), w.copy(r.position, z), w.copy(r.up, V), w.sub(y, r.position, r.target), w.copy(h, r.position);
    }, dispose: function() {
      u || (u = !0, d.unsubscribe(), m.unsubscribe(), v.unsubscribe(), p.unsubscribe(), f.unsubscribe());
    }, setEditState: function(Fe) {
      s.next(Fe);
    }, setLockCameraState: function(Fe) {
      l.next(Fe);
    }, setDisabledInteractionState: function(Fe) {
      c.next(Fe);
    } };
  };
})(lb || (lb = {}));
var hM = La(), iq = { apply_fog: `
float viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);
float fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));
float fogAlpha = (1.0 - fogFactor) * gl_FragColor.a;
float preFogAlpha = gl_FragColor.a;
if (!uTransparentBackground) {
    if (gl_FragColor.a < 1.0) {
        // transparent objects are blended with background color
        gl_FragColor.a = fogAlpha;
    } else {
        // mix opaque objects with background color
        gl_FragColor.rgb = mix(gl_FragColor.rgb, uFogColor, fogFactor);
    }
} else {
    // pre-multiplied alpha expected for transparent background
    gl_FragColor.rgb *= fogAlpha;
    gl_FragColor.a = fogAlpha;
}
`, apply_interior_color: `
if (interior) {
    if (uInteriorColorFlag) {
        gl_FragColor.rgb = uInteriorColor;
    } else {
        gl_FragColor.rgb *= 1.0 - uInteriorDarkening;
    }
}
`, apply_light_color: `
#ifdef dIgnoreLight
    gl_FragColor = material;
#else
    #ifdef bumpEnabled
        if (uBumpFrequency > 0.0 && uBumpAmplitude > 0.0) {
            vec3 bumpNormal = perturbNormal(-vViewPosition, normal, fbm(vModelPosition * uBumpFrequency), (uBumpAmplitude * bumpiness) / uBumpFrequency);
            #ifdef enabledFragDepth
                if (!isNaN(bumpNormal.x) && !isNaN(bumpNormal.y) && !isNaN(bumpNormal.z)) {
                    normal = bumpNormal;
                }
            #else
                normal = bumpNormal;
            #endif
        }
    #endif

    vec4 color = material;

    ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));

    PhysicalMaterial physicalMaterial;
    physicalMaterial.diffuseColor = color.rgb * (1.0 - metalness);
    #ifdef enabledFragDepth
        physicalMaterial.roughness = min(max(roughness, 0.0525), 1.0);
    #else
        vec3 dxy = max(abs(dFdx(normal)), abs(dFdy(normal)));
        float geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);
        physicalMaterial.roughness = min(max(roughness, 0.0525) + geometryRoughness, 1.0);
    #endif
    physicalMaterial.specularColor = mix(vec3(0.04), color.rgb, metalness);
    physicalMaterial.specularF90 = 1.0;

    GeometricContext geometry;
    geometry.position = -vViewPosition;
    geometry.normal = normal;
    geometry.viewDir = normalize(vViewPosition);

    IncidentLight directLight;
    #pragma unroll_loop_start
    for (int i = 0; i < dLightCount; ++i) {
        directLight.direction = uLightDirection[i];
        directLight.color = uLightColor[i] * PI; // * PI for punctual light
        RE_Direct_Physical(directLight, geometry, physicalMaterial, reflectedLight);
    }
    #pragma unroll_loop_end

    vec3 irradiance = uAmbientColor * PI; // * PI for punctual light
    RE_IndirectDiffuse_Physical(irradiance, geometry, physicalMaterial, reflectedLight);

    // indirect specular only metals
    vec3 radiance = uAmbientColor * metalness;
    vec3 iblIrradiance = uAmbientColor * metalness;
    vec3 clearcoatRadiance = vec3(0.0);
    RE_IndirectSpecular_Physical(radiance, iblIrradiance, clearcoatRadiance, geometry, physicalMaterial, reflectedLight);

    vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;

    gl_FragColor = vec4(outgoingLight, color.a);
#endif

#ifdef dXrayShaded
    gl_FragColor.a *= 1.0 - pow(abs(dot(normal, vec3(0.0, 0.0, 1.0))), uXrayEdgeFalloff);
#endif
`, apply_marker_color: `
if (marker > 0.0) {
    if (marker == 4.0) {
        gl_FragColor.rgb = mix(gl_FragColor.rgb, uInvalidColor, uInvalidStrength);
        gl_FragColor.a = max(gl_FragColor.a, uInvalidStrength * 0.002); // for direct-volume rendering
    } else if ((uMarkerPriority == 1 && marker != 2.0 && marker != 6.0) || (uMarkerPriority != 1 && (marker == 1.0 || marker == 5.0 || marker == 8.0))) {
        gl_FragColor.rgb = mix(gl_FragColor.rgb, uHighlightColor, uHighlightStrength);
        gl_FragColor.a = max(gl_FragColor.a, uHighlightStrength * 0.002); // for direct-volume rendering
    } else {
        gl_FragColor.rgb = mix(gl_FragColor.rgb, uSelectColor, uSelectStrength);
        gl_FragColor.a = max(gl_FragColor.a, uSelectStrength * 0.002); // for direct-volume rendering
    }
}
`, assign_clipping_varying: `
#if dClipObjectCount != 0 && defined(dClipping)
    vClipping = readFromTexture(tClipping, aInstance * float(uGroupCount) + group, uClippingTexDim).a;
#endif
`, assign_color_varying: `
#if defined(dRenderVariant_color)
    #if defined(dColorType_attribute)
        vColor.rgb = aColor;
    #elif defined(dColorType_instance)
        vColor.rgb = readFromTexture(tColor, aInstance, uColorTexDim).rgb;
    #elif defined(dColorType_group)
        vColor.rgb = readFromTexture(tColor, group, uColorTexDim).rgb;
    #elif defined(dColorType_groupInstance)
        vColor.rgb = readFromTexture(tColor, aInstance * float(uGroupCount) + group, uColorTexDim).rgb;
    #elif defined(dColorType_vertex)
        vColor.rgb = readFromTexture(tColor, VertexID, uColorTexDim).rgb;
    #elif defined(dColorType_vertexInstance)
        vColor.rgb = readFromTexture(tColor, int(aInstance) * uVertexCount + VertexID, uColorTexDim).rgb;
    #elif defined(dColorType_volume)
        vec3 cgridPos = (uColorGridTransform.w * (position - uColorGridTransform.xyz)) / uColorGridDim;
        vColor.rgb = texture3dFrom2dLinear(tColorGrid, cgridPos, uColorGridDim, uColorTexDim).rgb;
    #elif defined(dColorType_volumeInstance)
        vec3 cgridPos = (uColorGridTransform.w * (vModelPosition - uColorGridTransform.xyz)) / uColorGridDim;
        vColor.rgb = texture3dFrom2dLinear(tColorGrid, cgridPos, uColorGridDim, uColorTexDim).rgb;
    #endif

    #ifdef dUsePalette
        vPaletteV = ((vColor.r * 256.0 * 256.0 * 255.0 + vColor.g * 256.0 * 255.0 + vColor.b * 255.0) - 1.0) / 16777215.0;
    #endif

    #ifdef dOverpaint
        #if defined(dOverpaintType_groupInstance)
            vOverpaint = readFromTexture(tOverpaint, aInstance * float(uGroupCount) + group, uOverpaintTexDim);
        #elif defined(dOverpaintType_vertexInstance)
            vOverpaint = readFromTexture(tOverpaint, int(aInstance) * uVertexCount + VertexID, uOverpaintTexDim);
        #elif defined(dOverpaintType_volumeInstance)
            vec3 ogridPos = (uOverpaintGridTransform.w * (vModelPosition - uOverpaintGridTransform.xyz)) / uOverpaintGridDim;
            vOverpaint = texture3dFrom2dLinear(tOverpaintGrid, ogridPos, uOverpaintGridDim, uOverpaintTexDim);
        #endif

        // pre-mix to avoid darkening due to empty overpaint
        #ifdef dColorType_uniform
            vOverpaint.rgb = mix(uColor.rgb, vOverpaint.rgb, vOverpaint.a);
        #else
            vOverpaint.rgb = mix(vColor.rgb, vOverpaint.rgb, vOverpaint.a);
        #endif
    #endif

    #ifdef dSubstance
        #if defined(dSubstanceType_groupInstance)
            vSubstance = readFromTexture(tSubstance, aInstance * float(uGroupCount) + group, uSubstanceTexDim);
        #elif defined(dSubstanceType_vertexInstance)
            vSubstance = readFromTexture(tSubstance, int(aInstance) * uVertexCount + VertexID, uSubstanceTexDim);
        #elif defined(dSubstanceType_volumeInstance)
            vec3 sgridPos = (uSubstanceGridTransform.w * (vModelPosition - uSubstanceGridTransform.xyz)) / uSubstanceGridDim;
            vSubstance = texture3dFrom2dLinear(tSubstanceGrid, sgridPos, uSubstanceGridDim, uSubstanceTexDim);
        #endif

        // pre-mix to avoid artifacts due to empty substance
        vSubstance.rgb = mix(vec3(uMetalness, uRoughness, uBumpiness), vSubstance.rgb, vSubstance.a);
    #endif
#elif defined(dRenderVariant_pick)
    if (uPickType == 1) {
        vColor = vec4(packIntToRGB(float(uObjectId)), 1.0);
    } else if (uPickType == 2) {
        vColor = vec4(packIntToRGB(aInstance), 1.0);
    } else {
        vColor = vec4(packIntToRGB(group), 1.0);
    }
#endif

#ifdef dTransparency
    vGroup = group;

    #if defined(dTransparencyType_groupInstance)
        vTransparency = readFromTexture(tTransparency, aInstance * float(uGroupCount) + group, uTransparencyTexDim).a;
    #elif defined(dTransparencyType_vertexInstance)
        vTransparency = readFromTexture(tTransparency, int(aInstance) * uVertexCount + VertexID, uTransparencyTexDim).a;
    #elif defined(dTransparencyType_volumeInstance)
        vec3 tgridPos = (uTransparencyGridTransform.w * (vModelPosition - uTransparencyGridTransform.xyz)) / uTransparencyGridDim;
        vTransparency = texture3dFrom2dLinear(tTransparencyGrid, tgridPos, uTransparencyGridDim, uTransparencyTexDim).a;
    #endif
#endif
`, assign_group: `
#ifdef dGeometryType_textureMesh
    float group = unpackRGBToInt(readFromTexture(tGroup, VertexID, uGeoTexDim).rgb);
#else
    float group = aGroup;
#endif
`, assign_marker_varying: `
#if defined(dRenderVariant_color) || defined(dRenderVariant_marking)
    vMarker = readFromTexture(tMarker, aInstance * float(uGroupCount) + group, uMarkerTexDim).a;
#endif
`, assign_material_color: `
#if defined(dRenderVariant_color) || defined(dRenderVariant_marking)
    float marker = uMarker;
    if (uMarker == -1.0) {
        marker = floor(vMarker * 255.0 + 0.5); // rounding required to work on some cards on win
    }
#endif

#if defined(dRenderVariant_color)
    #if defined(dUsePalette)
        vec4 material = vec4(texture2D(tPalette, vec2(vPaletteV, 0.5)).rgb, uAlpha);
    #elif defined(dColorType_uniform)
        vec4 material = vec4(uColor, uAlpha);
    #elif defined(dColorType_varying)
        vec4 material = vec4(vColor.rgb, uAlpha);
    #endif

    // mix material with overpaint
    #if defined(dOverpaint)
        material.rgb = mix(material.rgb, vOverpaint.rgb, vOverpaint.a);
    #endif

    float metalness = uMetalness;
    float roughness = uRoughness;
    float bumpiness = uBumpiness;
    #ifdef dSubstance
        metalness = mix(metalness, vSubstance.r, vSubstance.a);
        roughness = mix(roughness, vSubstance.g, vSubstance.a);
        bumpiness = mix(bumpiness, vSubstance.b, vSubstance.a);
    #endif
#elif defined(dRenderVariant_pick)
    vec4 material = vColor;
#elif defined(dRenderVariant_depth)
    #ifdef enabledFragDepth
        vec4 material = packDepthToRGBA(gl_FragDepthEXT);
    #else
        vec4 material = packDepthToRGBA(gl_FragCoord.z);
    #endif
#elif defined(dRenderVariant_marking)
    vec4 material;
    if(uMarkingType == 1) {
        if (marker > 0.0)
            discard;
        #ifdef enabledFragDepth
            material = packDepthToRGBA(gl_FragDepthEXT);
        #else
            material = packDepthToRGBA(gl_FragCoord.z);
        #endif
    } else {
        if (marker == 0.0)
            discard;
        float depthTest = 1.0;
        if (uMarkingDepthTest) {
            depthTest = (fragmentDepth >= getDepth(gl_FragCoord.xy / uDrawingBufferSize)) ? 1.0 : 0.0;
        }
        bool isHighlight = intMod(marker, 2.0) > 0.1;
        float viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);
        float fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));
        if (fogFactor == 1.0)
            discard;
        material = vec4(0.0, depthTest, isHighlight ? 1.0 : 0.0, 1.0 - fogFactor);
    }
#endif

// apply screendoor transparency
#if defined(dTransparency)
    float ta = 1.0 - vTransparency;
    #if defined(dRenderVariant_colorWboit)
        if (vTransparency < 0.2) ta = 1.0; // hard cutoff looks better with wboit
    #endif

    #if defined(dRenderVariant_pick)
        if (ta < uPickingAlphaThreshold)
            discard; // ignore so the element below can be picked
    #else
        #if defined(dRenderVariant_colorBlended)
            float at = 0.0;

            // shift by view-offset during multi-sample rendering to allow for blending
            vec2 coord = gl_FragCoord.xy + uViewOffset * 0.25;

            const mat4 thresholdMatrix = mat4(
                1.0 / 17.0,  9.0 / 17.0,  3.0 / 17.0, 11.0 / 17.0,
                13.0 / 17.0,  5.0 / 17.0, 15.0 / 17.0,  7.0 / 17.0,
                4.0 / 17.0, 12.0 / 17.0,  2.0 / 17.0, 10.0 / 17.0,
                16.0 / 17.0,  8.0 / 17.0, 14.0 / 17.0,  6.0 / 17.0
            );
            int ci = int(intMod(coord.x, 4.0));
            int ri = int(intMod(coord.y, 4.0));
            #if __VERSION__ == 100
                vec4 i = vec4(float(ci * 4 + ri));
                vec4 v = thresholdMatrix[0] * vec4(equal(i, vec4(0.0, 1.0, 2.0, 3.0))) +
                    thresholdMatrix[1] * vec4(equal(i, vec4(4.0, 5.0, 6.0, 7.0))) +
                    thresholdMatrix[2] * vec4(equal(i, vec4(8.0, 9.0, 10.0, 11.0))) +
                    thresholdMatrix[3] * vec4(equal(i, vec4(12.0, 13.0, 14.0, 15.0)));
                at = v.x + v.y + v.z + v.w;
            #else
                at = thresholdMatrix[ci][ri];
            #endif

            if (ta < 0.99 && (ta < 0.01 || ta < at)) {
                discard;
            }
        #elif defined(dRenderVariant_colorWboit)
            material.a *= ta;
        #endif
    #endif
#endif
`, assign_position: `
mat4 model = uModel * aTransform;
mat4 modelView = uView * model;
#ifdef dGeometryType_textureMesh
    vec3 position = readFromTexture(tPosition, VertexID, uGeoTexDim).xyz;
#else
    vec3 position = aPosition;
#endif
vec4 position4 = vec4(position, 1.0);
// for accessing tColorGrid in vert shader and for clipping in frag shader
vModelPosition = (model * position4).xyz;
vec4 mvPosition = modelView * position4;
vViewPosition = mvPosition.xyz;
gl_Position = uProjection * mvPosition;
`, assign_size: `
#if defined(dSizeType_uniform)
    float size = uSize;
#elif defined(dSizeType_attribute)
    float size = aSize;
#elif defined(dSizeType_instance)
    float size = unpackRGBToInt(readFromTexture(tSize, aInstance, uSizeTexDim).rgb);
#elif defined(dSizeType_group)
    float size = unpackRGBToInt(readFromTexture(tSize, group, uSizeTexDim).rgb);
#elif defined(dSizeType_groupInstance)
    float size = unpackRGBToInt(readFromTexture(tSize, aInstance * float(uGroupCount) + group, uSizeTexDim).rgb);
#endif

#if defined(dSizeType_instance) || defined(dSizeType_group) || defined(dSizeType_groupInstance)
    size /= 100.0; // NOTE factor also set in TypeScript
#endif

size *= uSizeFactor;
`, check_picking_alpha: `
float viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);
float fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));
float alpha = (1.0 - fogFactor) * uAlpha;
if (uAlpha < uPickingAlphaThreshold || alpha < 0.1)
    discard; // ignore so the element below can be picked
`, clip_instance: `
#if defined(dClipVariant_instance) && dClipObjectCount != 0
    int flag = 0;
    #if defined(dClipping)
        flag = int(floor(vClipping * 255.0 + 0.5));
    #endif

    vec4 mCenter = uModel * aTransform * vec4(uInvariantBoundingSphere.xyz, 1.0);
    if (clipTest(vec4(mCenter.xyz, uInvariantBoundingSphere.w), flag))
        // move out of [ -w, +w ] to 'discard' in vert shader
        gl_Position.z = 2.0 * gl_Position.w;
#endif
`, clip_pixel: `
#if defined(dClipVariant_pixel) && dClipObjectCount != 0
    #if defined(dClipping)
        int clippingFlag = int(floor(vClipping * 255.0 + 0.5));
    #else
        int clippingFlag = 0;
    #endif

    if (clipTest(vec4(vModelPosition, 0.0), clippingFlag))
        discard;
#endif
`, color_frag_params: `
uniform float uMetalness;
uniform float uRoughness;
uniform float uBumpiness;
#ifdef bumpEnabled
    uniform float uBumpFrequency;
    uniform float uBumpAmplitude;
#endif

#if defined(dRenderVariant_color)
    #if defined(dColorType_uniform)
        uniform vec3 uColor;
    #elif defined(dColorType_varying)
        varying vec4 vColor;
    #endif

    #ifdef dUsePalette
        uniform sampler2D tPalette;
        varying float vPaletteV;
    #endif

    #ifdef dOverpaint
        varying vec4 vOverpaint;
    #endif

    #ifdef dSubstance
        varying vec4 vSubstance;
    #endif
#elif defined(dRenderVariant_pick)
    #if __VERSION__ == 100
        varying vec4 vColor;
    #else
        flat in vec4 vColor;
    #endif
#endif

#ifdef dTransparency
    varying float vGroup;
    varying float vTransparency;
#endif
`, color_vert_params: `
uniform float uMetalness;
uniform float uRoughness;
uniform float uBumpiness;

#if defined(dRenderVariant_color)
    #if defined(dColorType_uniform)
        uniform vec3 uColor;
    #elif defined(dColorType_attribute)
        varying vec4 vColor;
        attribute vec3 aColor;
    #elif defined(dColorType_texture)
        varying vec4 vColor;
        uniform vec2 uColorTexDim;
        uniform sampler2D tColor;
    #elif defined(dColorType_grid)
        varying vec4 vColor;
        uniform vec2 uColorTexDim;
        uniform vec3 uColorGridDim;
        uniform vec4 uColorGridTransform;
        uniform sampler2D tColorGrid;
    #endif

    #ifdef dUsePalette
        varying float vPaletteV;
    #endif

    #ifdef dOverpaint
        #if defined(dOverpaintType_groupInstance) || defined(dOverpaintType_vertexInstance)
            varying vec4 vOverpaint;
            uniform vec2 uOverpaintTexDim;
            uniform sampler2D tOverpaint;
        #elif defined(dOverpaintType_volumeInstance)
            varying vec4 vOverpaint;
            uniform vec2 uOverpaintTexDim;
            uniform vec3 uOverpaintGridDim;
            uniform vec4 uOverpaintGridTransform;
            uniform sampler2D tOverpaintGrid;
        #endif
    #endif

    #ifdef dSubstance
        #if defined(dSubstanceType_groupInstance) || defined(dSubstanceType_vertexInstance)
            varying vec4 vSubstance;
            uniform vec2 uSubstanceTexDim;
            uniform sampler2D tSubstance;
        #elif defined(dSubstanceType_volumeInstance)
            varying vec4 vSubstance;
            uniform vec2 uSubstanceTexDim;
            uniform vec3 uSubstanceGridDim;
            uniform vec4 uSubstanceGridTransform;
            uniform sampler2D tSubstanceGrid;
        #endif
    #endif
#elif defined(dRenderVariant_pick)
    #if __VERSION__ == 100
        varying vec4 vColor;
    #else
        flat out vec4 vColor;
    #endif
#endif

#ifdef dTransparency
    varying float vGroup;
    #if defined(dTransparencyType_groupInstance) || defined(dTransparencyType_vertexInstance)
        varying float vTransparency;
        uniform vec2 uTransparencyTexDim;
        uniform sampler2D tTransparency;
    #elif defined(dTransparencyType_volumeInstance)
        varying float vTransparency;
        uniform vec2 uTransparencyTexDim;
        uniform vec3 uTransparencyGridDim;
        uniform vec4 uTransparencyGridTransform;
        uniform sampler2D tTransparencyGrid;
    #endif
#endif
`, common_clip: `
#if dClipObjectCount != 0
    vec3 quaternionTransform(vec4 q, vec3 v) {
        vec3 t = 2.0 * cross(q.xyz, v);
        return v + q.w * t + cross(q.xyz, t);
    }

    vec4 computePlane(vec3 normal, vec3 inPoint) {
        return vec4(normalize(normal), -dot(normal, inPoint));
    }

    float planeSD(vec4 plane, vec3 center) {
        return -dot(plane.xyz, center - plane.xyz * -plane.w);
    }

    float sphereSD(vec3 position, vec4 rotation, vec3 size, vec3 center) {
        return (
            length(quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position) / size) - 1.0
        ) * min(min(size.x, size.y), size.z);
    }

    float cubeSD(vec3 position, vec4 rotation, vec3 size, vec3 center) {
        vec3 d = abs(quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position)) - size;
        return min(max(d.x, max(d.y, d.z)), 0.0) + length(max(d, 0.0));
    }

    float cylinderSD(vec3 position, vec4 rotation, vec3 size, vec3 center) {
        vec3 t = quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position);

        vec2 d = abs(vec2(length(t.xz), t.y)) - size.xy;
        return min(max(d.x, d.y), 0.0) + length(max(d, 0.0));
    }

    float infiniteConeSD(vec3 position, vec4 rotation, vec3 size, vec3 center) {
        vec3 t = quaternionTransform(vec4(-rotation.x, -rotation.y, -rotation.z, rotation.w), center - position);

        float q = length(t.xy);
        return dot(size.xy, vec2(q, t.z));
    }

    float getSignedDistance(vec3 center, int type, vec3 position, vec4 rotation, vec3 scale) {
        if (type == 1) {
            vec3 normal = quaternionTransform(rotation, vec3(0.0, 1.0, 0.0));
            vec4 plane = computePlane(normal, position);
            return planeSD(plane, center);
        } else if (type == 2) {
            return sphereSD(position, rotation, scale * 0.5, center);
        } else if (type == 3) {
            return cubeSD(position, rotation, scale * 0.5, center);
        } else if (type == 4) {
            return cylinderSD(position, rotation, scale * 0.5, center);
        } else if (type == 5) {
            return infiniteConeSD(position, rotation, scale * 0.5, center);
        } else {
            return 0.1;
        }
    }

    #if __VERSION__ == 100
        // 8-bit
        int bitwiseAnd(int a, int b) {
            int d = 128;
            int result = 0;
            for (int i = 0; i < 8; ++i) {
                if (d <= 0) break;
                if (a >= d && b >= d) result += d;
                if (a >= d) a -= d;
                if (b >= d) b -= d;
                d /= 2;
            }
            return result;
        }

        bool hasBit(int mask, int bit) {
            return bitwiseAnd(mask, bit) == 0;
        }
    #else
        bool hasBit(int mask, int bit) {
            return (mask & bit) == 0;
        }
    #endif

    // flag is a bit-flag for clip-objects to ignore (note, object ids start at 1 not 0)
    bool clipTest(vec4 sphere, int flag) {
        #pragma unroll_loop_start
        for (int i = 0; i < dClipObjectCount; ++i) {
            if (flag == 0 || hasBit(flag, UNROLLED_LOOP_INDEX + 1)) {
                // TODO take sphere radius into account?
                bool test = getSignedDistance(sphere.xyz, uClipObjectType[i], uClipObjectPosition[i], uClipObjectRotation[i], uClipObjectScale[i]) <= 0.0;
                if ((!uClipObjectInvert[i] && test) || (uClipObjectInvert[i] && !test)) {
                    return true;
                }
            }
        }
        #pragma unroll_loop_end
        return false;
    }
#endif
`, common_frag_params: `
uniform int uObjectId;
uniform int uInstanceCount;
uniform int uGroupCount;

uniform int uPickType;
uniform int uMarkingType;

#if dClipObjectCount != 0
    uniform int uClipObjectType[dClipObjectCount];
    uniform bool uClipObjectInvert[dClipObjectCount];
    uniform vec3 uClipObjectPosition[dClipObjectCount];
    uniform vec4 uClipObjectRotation[dClipObjectCount];
    uniform vec3 uClipObjectScale[dClipObjectCount];

    #if defined(dClipping)
        #if __VERSION__ == 100
            varying float vClipping;
        #else
            flat in float vClipping;
        #endif
    #endif
#endif

uniform vec3 uHighlightColor;
uniform vec3 uSelectColor;
uniform float uHighlightStrength;
uniform float uSelectStrength;
uniform int uMarkerPriority;
uniform vec3 uInvalidColor;
uniform float uInvalidStrength;

#if defined(dRenderVariant_color) || defined(dRenderVariant_marking)
    uniform float uMarker;
    #if __VERSION__ == 100
        varying float vMarker;
    #else
        flat in float vMarker;
    #endif
#endif

varying vec3 vModelPosition;
varying vec3 vViewPosition;

uniform vec2 uViewOffset;

uniform float uNear;
uniform float uFar;
uniform float uIsOrtho;

uniform float uFogNear;
uniform float uFogFar;
uniform vec3 uFogColor;

uniform float uAlpha;
uniform float uPickingAlphaThreshold;
uniform bool uTransparentBackground;

uniform bool uDoubleSided;
uniform float uInteriorDarkening;
uniform bool uInteriorColorFlag;
uniform vec3 uInteriorColor;
bool interior;

uniform float uXrayEdgeFalloff;

uniform mat4 uProjection;

uniform bool uRenderWboit;
uniform bool uMarkingDepthTest;

uniform sampler2D tDepth;
uniform vec2 uDrawingBufferSize;

float getDepth(const in vec2 coords) {
    // always packed due to merged depth from primitives and volumes
    return unpackRGBAToDepth(texture2D(tDepth, coords));
}

float calcDepth(const in vec3 pos) {
    vec2 clipZW = pos.z * uProjection[2].zw + uProjection[3].zw;
    return 0.5 + 0.5 * clipZW.x / clipZW.y;
}

// "Bump Mapping Unparametrized Surfaces on the GPU" Morten S. Mikkelsen
// https://mmikk.github.io/papers3d/mm_sfgrad_bump.pdf
vec3 perturbNormal(in vec3 position, in vec3 normal, in float height, in float scale) {
    vec3 sigmaS = dFdx(position);
    vec3 sigmaT = dFdy(position);

    vec3 r1 = cross(sigmaT, normal);
    vec3 r2 = cross(normal, sigmaS);
    float det = dot(sigmaS, r1);

    float bs = dFdx(height);
    float bt = dFdy(height);

    vec3 surfGrad = sign(det) * (bs * r1 + bt * r2);
    return normalize(abs(det) * normal - scale * surfGrad);
}

float hash(in float h) {
    return fract(sin(h) * 43758.5453123);
}

float noise(in vec3 x) {
    vec3 p = floor(x);
    vec3 f = fract(x);
    f = f * f * (3.0 - 2.0 * f);

    float n = p.x + p.y * 157.0 + 113.0 * p.z;
    return mix(
        mix(mix(hash(n + 0.0), hash(n + 1.0), f.x),
            mix(hash(n + 157.0), hash(n + 158.0), f.x), f.y),
        mix(mix(hash(n + 113.0), hash(n + 114.0), f.x),
            mix(hash(n + 270.0), hash(n + 271.0), f.x), f.y), f.z);
}

float fbm(in vec3 p) {
    float f = 0.0;
    f += 0.5 * noise(p);
    p *= 2.01;
    f += 0.25 * noise(p);
    p *= 2.02;
    f += 0.125 * noise(p);

    return f;
}
`, common_vert_params: `
uniform mat4 uProjection, uModel, uView;
uniform vec3 uCameraPosition;

uniform int uObjectId;
uniform int uVertexCount;
uniform int uInstanceCount;
uniform int uGroupCount;
uniform vec4 uInvariantBoundingSphere;

uniform bool uDoubleSided;
uniform int uPickType;

#if dClipObjectCount != 0
    uniform int uClipObjectType[dClipObjectCount];
    uniform bool uClipObjectInvert[dClipObjectCount];
    uniform vec3 uClipObjectPosition[dClipObjectCount];
    uniform vec4 uClipObjectRotation[dClipObjectCount];
    uniform vec3 uClipObjectScale[dClipObjectCount];

    #if defined(dClipping)
        uniform vec2 uClippingTexDim;
        uniform sampler2D tClipping;
        #if __VERSION__ == 100
            varying float vClipping;
        #else
            flat out float vClipping;
        #endif
    #endif
#endif

#if defined(dRenderVariant_color) || defined(dRenderVariant_marking)
    uniform float uMarker;
    uniform vec2 uMarkerTexDim;
    uniform sampler2D tMarker;
    #if __VERSION__ == 100
        varying float vMarker;
    #else
        flat out float vMarker;
    #endif
#endif

varying vec3 vModelPosition;
varying vec3 vViewPosition;

#if __VERSION__ == 100
    attribute float aVertex;
    #define VertexID int(aVertex)
#else
    // not using gl_VertexID but aVertex to ensure there is an active attribute with divisor 0
    // since FF 85 this is not needed anymore but lets keep it for backwards compatibility
    // https://bugzilla.mozilla.org/show_bug.cgi?id=1679693
    // see also note in src/mol-gl/webgl/render-item.ts
    attribute float aVertex;
    #define VertexID int(aVertex)
    // #define VertexID gl_VertexID
#endif
`, common: `
// TODO find a better place for these convenience defines

#if defined(dRenderVariant_colorBlended) || defined(dRenderVariant_colorWboit)
    #define dRenderVariant_color
#endif

#if defined(dColorType_instance) || defined(dColorType_group) || defined(dColorType_groupInstance) || defined(dColorType_vertex) || defined(dColorType_vertexInstance)
    #define dColorType_texture
#endif

#if defined(dColorType_volume) || defined(dColorType_volumeInstance)
    #define dColorType_grid
#endif

#if defined(dColorType_attribute) || defined(dColorType_texture) || defined(dColorType_grid)
    #define dColorType_varying
#endif

//

#define PI 3.14159265
#define RECIPROCAL_PI 0.31830988618
#define EPSILON 1e-6

#define saturate(a) clamp(a, 0.0, 1.0)

#if __VERSION__ == 100
    #define round(x) floor((x) + 0.5)
#endif

float intDiv(const in float a, const in float b) { return float(int(a) / int(b)); }
vec2 ivec2Div(const in vec2 a, const in vec2 b) { return vec2(ivec2(a) / ivec2(b)); }
float intMod(const in float a, const in float b) { return a - b * float(int(a) / int(b)); }
int imod(const in int a, const in int b) { return a - b * (a / b); }

float pow2(const in float x) { return x * x; }

vec3 packIntToRGB(in float value) {
    value = clamp(round(value), 0.0, 16777216.0 - 1.0) + 1.0;
    vec3 c = vec3(0.0);
    c.b = mod(value, 256.0);
    value = floor(value / 256.0);
    c.g = mod(value, 256.0);
    value = floor(value / 256.0);
    c.r = mod(value, 256.0);
    return c / 255.0;
}
float unpackRGBToInt(const in vec3 rgb) {
    return (floor(rgb.r * 255.0 + 0.5) * 256.0 * 256.0 + floor(rgb.g * 255.0 + 0.5) * 256.0 + floor(rgb.b * 255.0 + 0.5)) - 1.0;
}

vec2 packUnitIntervalToRG(const in float v) {
    vec2 enc;
    enc.xy = vec2(fract(v * 256.0), v);
    enc.y -= enc.x * (1.0 / 256.0);
    enc.xy *=  256.0 / 255.0;

    return enc;
}

float unpackRGToUnitInterval(const in vec2 enc) {
    return dot(enc, vec2(255.0 / (256.0 * 256.0), 255.0 / 256.0));
}

vec3 screenSpaceToViewSpace(const in vec3 ssPos, const in mat4 invProjection) {
    vec4 p = vec4(ssPos * 2.0 - 1.0, 1.0);
    p = invProjection * p;
    return p.xyz / p.w;
}

const float PackUpscale = 256.0 / 255.0; // fraction -> 0..1 (including 1)
const float UnpackDownscale = 255.0 / 256.0; // 0..1 -> fraction (excluding 1)
const vec3 PackFactors = vec3(256.0 * 256.0 * 256.0, 256.0 * 256.0,  256.0);
const vec4 UnpackFactors = UnpackDownscale / vec4(PackFactors, 1.0);
const float ShiftRight8 = 1.0 / 256.0;

vec4 packDepthToRGBA(const in float v) {
    vec4 r = vec4(fract(v * PackFactors), v);
    r.yzw -= r.xyz * ShiftRight8; // tidy overflow
    return r * PackUpscale;
}
float unpackRGBAToDepth(const in vec4 v) {
    return dot(v, UnpackFactors);
}

vec4 sRGBToLinear(const in vec4 c) {
    return vec4(mix(pow(c.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), c.rgb * 0.0773993808, vec3(lessThanEqual(c.rgb, vec3(0.04045)))), c.a);
}
vec4 linearTosRGB(const in vec4 c) {
    return vec4(mix(pow(c.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), c.rgb * 12.92, vec3(lessThanEqual(c.rgb, vec3(0.0031308)))), c.a);
}

float linearizeDepth(const in float depth, const in float near, const in float far) {
    return (2.0 * near) / (far + near - depth * (far - near));
}

float perspectiveDepthToViewZ(const in float invClipZ, const in float near, const in float far) {
    return (near * far) / ((far - near) * invClipZ - far);
}

float orthographicDepthToViewZ(const in float linearClipZ, const in float near, const in float far) {
    return linearClipZ * (near - far) - near;
}

float depthToViewZ(const in float isOrtho, const in float linearClipZ, const in float near, const in float far) {
    return isOrtho == 1.0 ? orthographicDepthToViewZ(linearClipZ, near, far) : perspectiveDepthToViewZ(linearClipZ, near, far);
}

#if __VERSION__ == 100
    // transpose

    float transpose(const in float m) {
        return m;
    }

    mat2 transpose2(const in mat2 m) {
        return mat2(
            m[0][0], m[1][0],
            m[0][1], m[1][1]
        );
    }

    mat3 transpose3(const in mat3 m) {
        return mat3(
            m[0][0], m[1][0], m[2][0],
            m[0][1], m[1][1], m[2][1],
            m[0][2], m[1][2], m[2][2]
        );
    }

    mat4 transpose4(const in mat4 m) {
        return mat4(
            m[0][0], m[1][0], m[2][0], m[3][0],
            m[0][1], m[1][1], m[2][1], m[3][1],
            m[0][2], m[1][2], m[2][2], m[3][2],
            m[0][3], m[1][3], m[2][3], m[3][3]
        );
    }

    // inverse

    float inverse(const in float m) {
        return 1.0 / m;
    }

    mat2 inverse2(const in mat2 m) {
        return mat2(m[1][1],-m[0][1],
                -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);
    }

    mat3 inverse3(const in mat3 m) {
        float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];
        float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];
        float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];

        float b01 = a22 * a11 - a12 * a21;
        float b11 = -a22 * a10 + a12 * a20;
        float b21 = a21 * a10 - a11 * a20;

        float det = a00 * b01 + a01 * b11 + a02 * b21;

        return mat3(b01, (-a22 * a01 + a02 * a21), (a12 * a01 - a02 * a11),
                    b11, (a22 * a00 - a02 * a20), (-a12 * a00 + a02 * a10),
                    b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;
    }

    mat4 inverse4(const in mat4 m) {
        float
            a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],
            a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],
            a20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],
            a30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3],

            b00 = a00 * a11 - a01 * a10,
            b01 = a00 * a12 - a02 * a10,
            b02 = a00 * a13 - a03 * a10,
            b03 = a01 * a12 - a02 * a11,
            b04 = a01 * a13 - a03 * a11,
            b05 = a02 * a13 - a03 * a12,
            b06 = a20 * a31 - a21 * a30,
            b07 = a20 * a32 - a22 * a30,
            b08 = a20 * a33 - a23 * a30,
            b09 = a21 * a32 - a22 * a31,
            b10 = a21 * a33 - a23 * a31,
            b11 = a22 * a33 - a23 * a32,

            det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;

        return mat4(
            a11 * b11 - a12 * b10 + a13 * b09,
            a02 * b10 - a01 * b11 - a03 * b09,
            a31 * b05 - a32 * b04 + a33 * b03,
            a22 * b04 - a21 * b05 - a23 * b03,
            a12 * b08 - a10 * b11 - a13 * b07,
            a00 * b11 - a02 * b08 + a03 * b07,
            a32 * b02 - a30 * b05 - a33 * b01,
            a20 * b05 - a22 * b02 + a23 * b01,
            a10 * b10 - a11 * b08 + a13 * b06,
            a01 * b08 - a00 * b10 - a03 * b06,
            a30 * b04 - a31 * b02 + a33 * b00,
            a21 * b02 - a20 * b04 - a23 * b00,
            a11 * b07 - a10 * b09 - a12 * b06,
            a00 * b09 - a01 * b07 + a02 * b06,
            a31 * b01 - a30 * b03 - a32 * b00,
            a20 * b03 - a21 * b01 + a22 * b00) / det;
    }

    #define isNaN(x) ((x) != (x))
    #define isInf(x) ((x) == (x) + 1.0)
#else
    #define transpose2(m) transpose(m)
    #define transpose3(m) transpose(m)
    #define transpose4(m) transpose(m)

    #define inverse2(m) inverse(m)
    #define inverse3(m) inverse(m)
    #define inverse4(m) inverse(m)

    #define isNaN isnan
    #define isInf isinf
#endif
`, float_to_rgba: `
    // floatToRgba adapted from https://github.com/equinor/glsl-float-to-rgba
    // MIT License, Copyright (c) 2020 Equinor

    float shiftRight (float v, float amt) {
    v = floor(v) + 0.5;
    return floor(v / exp2(amt));
    }
    float shiftLeft (float v, float amt) {
        return floor(v * exp2(amt) + 0.5);
    }
    float maskLast (float v, float bits) {
        return mod(v, shiftLeft(1.0, bits));
    }
    float extractBits (float num, float from, float to) {
        from = floor(from + 0.5); to = floor(to + 0.5);
        return maskLast(shiftRight(num, from), to - from);
    }

    vec4 floatToRgba(float texelFloat, bool littleEndian) {
        if (texelFloat == 0.0) return vec4(0.0, 0.0, 0.0, 0.0);
        float sign = texelFloat > 0.0 ? 0.0 : 1.0;
        texelFloat = abs(texelFloat);
        float exponent = floor(log2(texelFloat));
        float biased_exponent = exponent + 127.0;
        float fraction = ((texelFloat / exp2(exponent)) - 1.0) * 8388608.0;
        float t = biased_exponent / 2.0;
        float last_bit_of_biased_exponent = fract(t) * 2.0;
        float remaining_bits_of_biased_exponent = floor(t);
        float byte4 = extractBits(fraction, 0.0, 8.0) / 255.0;
        float byte3 = extractBits(fraction, 8.0, 16.0) / 255.0;
        float byte2 = (last_bit_of_biased_exponent * 128.0 + extractBits(fraction, 16.0, 23.0)) / 255.0;
        float byte1 = (sign * 128.0 + remaining_bits_of_biased_exponent) / 255.0;
        return (
            littleEndian
                ? vec4(byte4, byte3, byte2, byte1)
                : vec4(byte1, byte2, byte3, byte4)
        );
    }
`, light_frag_params: `
#if dLightCount != 0
    uniform vec3 uLightDirection[dLightCount];
    uniform vec3 uLightColor[dLightCount];
#endif
uniform vec3 uAmbientColor;

struct PhysicalMaterial {
    vec3 diffuseColor;
    float roughness;
    vec3 specularColor;
    float specularF90;
};

struct IncidentLight {
    vec3 color;
    vec3 direction;
};

struct ReflectedLight {
    vec3 directDiffuse;
    vec3 directSpecular;
    vec3 indirectDiffuse;
    vec3 indirectSpecular;
};

struct GeometricContext {
    vec3 position;
    vec3 normal;
    vec3 viewDir;
};

vec3 BRDF_Lambert(const in vec3 diffuseColor) {
    return RECIPROCAL_PI * diffuseColor;
}

vec3 F_Schlick(const in vec3 f0, const in float f90, const in float dotVH) {
    // Original approximation by Christophe Schlick '94
    // float fresnel = pow( 1.0 - dotVH, 5.0 );
    // Optimized variant (presented by Epic at SIGGRAPH '13)
    // https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf
    float fresnel = exp2((-5.55473 * dotVH - 6.98316) * dotVH);
    return f0 * (1.0 - fresnel) + (f90 * fresnel);
}

// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2
// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
float V_GGX_SmithCorrelated(const in float alpha, const in float dotNL, const in float dotNV) {
    float a2 = pow2(alpha);
    float gv = dotNL * sqrt(a2 + (1.0 - a2) * pow2(dotNV));
    float gl = dotNV * sqrt(a2 + (1.0 - a2) * pow2(dotNL));
    return 0.5 / max(gv + gl, EPSILON);
}

// Microfacet Models for Refraction through Rough Surfaces - equation (33)
// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
// alpha is "roughness squared" in Disney’s reparameterization
float D_GGX(const in float alpha, const in float dotNH) {
    float a2 = pow2(alpha);
    float denom = pow2(dotNH) * (a2 - 1.0) + 1.0; // avoid alpha = 0 with dotNH = 1
    return RECIPROCAL_PI * a2 / pow2(denom);
}

// GGX Distribution, Schlick Fresnel, GGX_SmithCorrelated Visibility
vec3 BRDF_GGX(const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness) {
    float alpha = pow2(roughness); // UE4's roughness
    vec3 halfDir = normalize( lightDir + viewDir);
    float dotNL = saturate(dot(normal, lightDir));
    float dotNV = saturate(dot(normal, viewDir));
    float dotNH = saturate(dot(normal, halfDir));
    float dotVH = saturate(dot(viewDir, halfDir));
    vec3 F = F_Schlick(f0, f90, dotVH);
    float V = V_GGX_SmithCorrelated(alpha, dotNL, dotNV);
    float D = D_GGX(alpha, dotNH);
    return F * (V * D);
}

// Analytical approximation of the DFG LUT, one half of the
// split-sum approximation used in indirect specular lighting.
// via 'environmentBRDF' from "Physically Based Shading on Mobile"
// https://www.unrealengine.com/blog/physically-based-shading-on-mobile
vec2 DFGApprox(const in vec3 normal, const in vec3 viewDir, const in float roughness) {
    float dotNV = saturate(dot(normal, viewDir));
    const vec4 c0 = vec4(-1, -0.0275, -0.572, 0.022);
    const vec4 c1 = vec4(1, 0.0425, 1.04, -0.04);
    vec4 r = roughness * c0 + c1;
    float a004 = min(r.x * r.x, exp2(-9.28 * dotNV)) * r.x + r.y;
    vec2 fab = vec2(-1.04, 1.04) * a004 + r.zw;
    return fab;
}

// Fdez-Agüera's "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting"
// Approximates multiscattering in order to preserve energy.
// http://www.jcgt.org/published/0008/01/03/
void computeMultiscattering(const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter) {
    vec2 fab = DFGApprox(normal, viewDir, roughness);
    vec3 FssEss = specularColor * fab.x + specularF90 * fab.y;
    float Ess = fab.x + fab.y;
    float Ems = 1.0 - Ess;
    vec3 Favg = specularColor + (1.0 - specularColor) * 0.047619; // 1/21
    vec3 Fms = FssEss * Favg / (1.0 - Ems * Favg);
    singleScatter += FssEss;
    multiScatter += Fms * Ems;
}

void RE_Direct_Physical(const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
    float dotNL = saturate(dot(geometry.normal, directLight.direction));
    vec3 irradiance = dotNL * directLight.color;
    reflectedLight.directSpecular += irradiance * BRDF_GGX(directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness);
    reflectedLight.directDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);
}

void RE_IndirectDiffuse_Physical(const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
    reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);
}

void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
    // Both indirect specular and indirect diffuse light accumulate here
    vec3 singleScattering = vec3(0.0);
    vec3 multiScattering = vec3(0.0);
    vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
    computeMultiscattering(geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering);
    vec3 diffuse = material.diffuseColor * (1.0 - ( singleScattering + multiScattering));
    reflectedLight.indirectSpecular += radiance * singleScattering;
    reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
    reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
`, matrix_scale: `
float matrixScale(in mat4 m){
    vec4 r = m[0];
    return sqrt(r[0] * r[0] + r[1] * r[1] + r[2] * r[2]);
}
`, normal_frag_params: `
varying vec3 vNormal;
`, read_from_texture: `
vec4 readFromTexture(const in sampler2D tex, const in float i, const in vec2 dim) {
    float x = intMod(i, dim.x);
    float y = floor(intDiv(i, dim.x));
    vec2 uv = (vec2(x, y) + 0.5) / dim;
    return texture2D(tex, uv);
}

vec4 readFromTexture(const in sampler2D tex, const in int i, const in vec2 dim) {
    int x = imod(i, int(dim.x));
    int y = i / int(dim.x);
    vec2 uv = (vec2(x, y) + 0.5) / dim;
    return texture2D(tex, uv);
}
`, rgba_to_float: `
    // rgbaToFloat adapted from https://github.com/ihmeuw/glsl-rgba-to-float
    // BSD 3-Clause License
    //
    // Copyright (c) 2019, Institute for Health Metrics and Evaluation All rights reserved.
    // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
    //  - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    //  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    //  - Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
    //
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
    // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
    // OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
    // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
    // OF THE POSSIBILITY OF SUCH DAMAGE.

    ivec4 floatsToBytes(vec4 inputFloats, bool littleEndian) {
        ivec4 bytes = ivec4(inputFloats * 255.0);
        return (
            littleEndian
                ? bytes.abgr
                : bytes
        );
    }

    // Break the four bytes down into an array of 32 bits.
    void bytesToBits(const in ivec4 bytes, out bool bits[32]) {
        for (int channelIndex = 0; channelIndex < 4; ++channelIndex) {
            float acc = float(bytes[channelIndex]);
            for (int indexInByte = 7; indexInByte >= 0; --indexInByte) {
                float powerOfTwo = exp2(float(indexInByte));
                bool bit = acc >= powerOfTwo;
                bits[channelIndex * 8 + (7 - indexInByte)] = bit;
                acc = mod(acc, powerOfTwo);
            }
        }
    }

    // Compute the exponent of the 32-bit float.
    float getExponent(bool bits[32]) {
        const int startIndex = 1;
        const int bitStringLength = 8;
        const int endBeforeIndex = startIndex + bitStringLength;
        float acc = 0.0;
        int pow2 = bitStringLength - 1;
        for (int bitIndex = startIndex; bitIndex < endBeforeIndex; ++bitIndex) {
            acc += float(bits[bitIndex]) * exp2(float(pow2--));
        }
        return acc;
    }

    // Compute the mantissa of the 32-bit float.
    float getMantissa(bool bits[32], bool subnormal) {
        const int startIndex = 9;
        const int bitStringLength = 23;
        const int endBeforeIndex = startIndex + bitStringLength;
        // Leading/implicit/hidden bit convention:
        // If the number is not subnormal (with exponent 0), we add a leading 1 digit.
        float acc = float(!subnormal) * exp2(float(bitStringLength));
        int pow2 = bitStringLength - 1;
        for (int bitIndex = startIndex; bitIndex < endBeforeIndex; ++bitIndex) {
            acc += float(bits[bitIndex]) * exp2(float(pow2--));
        }
        return acc;
    }

    // Parse the float from its 32 bits.
    float bitsToFloat(bool bits[32]) {
        float signBit = float(bits[0]) * -2.0 + 1.0;
        float exponent = getExponent(bits);
        bool subnormal = abs(exponent - 0.0) < 0.01;
        float mantissa = getMantissa(bits, subnormal);
        float exponentBias = 127.0;
        return signBit * mantissa * exp2(exponent - exponentBias - 23.0);
    }

    float rgbaToFloat(vec4 texelRGBA, bool littleEndian) {
        ivec4 rgbaBytes = floatsToBytes(texelRGBA, littleEndian);
        bool bits[32];
        bytesToBits(rgbaBytes, bits);
        return bitsToFloat(bits);
    }
`, size_vert_params: `
#if defined(dSizeType_uniform)
    uniform float uSize;
#elif defined(dSizeType_attribute)
    attribute float aSize;
#elif defined(dSizeType_instance) || defined(dSizeType_group) || defined(dSizeType_groupInstance)
    uniform vec2 uSizeTexDim;
    uniform sampler2D tSize;
#endif

uniform float uSizeFactor;
`, texture3d_from_1d_trilinear: `
vec4 texture3dFrom1dTrilinear(const in sampler2D tex, const in vec3 pos, const in vec3 gridDim, const in vec2 texDim, const in float offset) {
    float gdYZ = gridDim.z * gridDim.y;
    float gdZ = gridDim.z;
    vec3 p0 = floor(pos * gridDim);
    vec3 p1 = ceil(pos * gridDim);
    vec3 pd = (pos * gridDim - p0) / (p1 - p0);
    vec4 s000 = readFromTexture(tex, offset + p0.z + p0.y * gdZ + p0.x * gdYZ, texDim);
    vec4 s100 = readFromTexture(tex, offset + p0.z + p0.y * gdZ + p1.x * gdYZ, texDim);
    vec4 s001 = readFromTexture(tex, offset + p1.z + p0.y * gdZ + p0.x * gdYZ, texDim);
    vec4 s101 = readFromTexture(tex, offset + p1.z + p0.y * gdZ + p1.x * gdYZ, texDim);
    vec4 s010 = readFromTexture(tex, offset + p0.z + p1.y * gdZ + p0.x * gdYZ, texDim);
    vec4 s110 = readFromTexture(tex, offset + p0.z + p1.y * gdZ + p1.x * gdYZ, texDim);
    vec4 s011 = readFromTexture(tex, offset + p1.z + p1.y * gdZ + p0.x * gdYZ, texDim);
    vec4 s111 = readFromTexture(tex, offset + p1.z + p1.y * gdZ + p1.x * gdYZ, texDim);
    vec4 s00 = mix(s000, s100, pd.x);
    vec4 s01 = mix(s001, s101, pd.x);
    vec4 s10 = mix(s010, s110, pd.x);
    vec4 s11 = mix(s011, s111, pd.x);
    vec4 s0 = mix(s00, s10, pd.y);
    vec4 s1 = mix(s01, s11, pd.y);
    return mix(s0, s1, pd.z);
}
`, texture3d_from_2d_linear: `
vec4 texture3dFrom2dLinear(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) {
    float zSlice0 = floor(pos.z * gridDim.z);
    float column0 = intMod(zSlice0 * gridDim.x, texDim.x) / gridDim.x;
    float row0 = floor(intDiv(zSlice0 * gridDim.x, texDim.x));
    vec2 coord0 = (vec2(column0 * gridDim.x, row0 * gridDim.y) + (pos.xy * gridDim.xy)) / texDim;
    vec4 color0 = texture2D(tex, coord0);

    float zSlice1 = zSlice0 + 1.0;
    float column1 = intMod(zSlice1 * gridDim.x, texDim.x) / gridDim.x;
    float row1 = floor(intDiv(zSlice1 * gridDim.x, texDim.x));
    vec2 coord1 = (vec2(column1 * gridDim.x, row1 * gridDim.y) + (pos.xy * gridDim.xy)) / texDim;
    vec4 color1 = texture2D(tex, coord1);

    float delta0 = abs((pos.z * gridDim.z) - zSlice0);
    return mix(color0, color1, delta0);
}
`, texture3d_from_2d_nearest: `
vec4 texture3dFrom2dNearest(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) {
    float zSlice = floor(pos.z * gridDim.z + 0.5); // round to nearest z-slice
    float column = intMod(zSlice * gridDim.x, texDim.x) / gridDim.x;
    float row = floor(intDiv(zSlice * gridDim.x, texDim.x));
    vec2 coord = (vec2(column * gridDim.x, row * gridDim.y) + (pos.xy * gridDim.xy)) / texDim;
    return texture2D(tex, coord);
}
`, wboit_write: `
#if defined(dRenderVariant_colorWboit)
    if (!uRenderWboit) {
        if (preFogAlpha < 1.0) {
            discard;
        }
    } else if (uRenderWboit) {
        // the 'fragmentDepth > 0.99' check is to handle precision issues with packed depth
        if (preFogAlpha != 1.0 && !interior && (fragmentDepth < getDepth(gl_FragCoord.xy / uDrawingBufferSize) || fragmentDepth > 0.99)) {
            float alpha = gl_FragColor.a;
            float wboitWeight = alpha * clamp(pow(1.0 - fragmentDepth, 2.0), 0.01, 1.0);
            gl_FragColor = vec4(gl_FragColor.rgb * alpha * wboitWeight, alpha);
            // extra alpha is to handle pre-multiplied alpha
            #ifndef dGeometryType_directVolume
                gl_FragData[1] = vec4((uTransparentBackground ? alpha : 1.0) * alpha * wboitWeight);
            #else
                gl_FragData[1] = vec4(alpha * alpha * wboitWeight);
            #endif
        } else {
            discard;
        }
    }
#endif
` }, aq = /^(?!\/\/)\s*#include\s+(\S+)/gm, oq = /#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*\+\+i\s*\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g, uq = /[ \t]*\/\/.*\n/g, sq = /[ \t]*\/\*[\s\S]*?\*\//g, cq = /\n{2,}/g;
function C9(e) {
  return e.replace(aq, function(t, r) {
    var n = iq[r];
    if (!n) throw new Error("empty chunk, '".concat(r, "'"));
    return n;
  }).trim().replace(uq, `
`).replace(sq, `
`).replace(cq, `
`);
}
function lq(e, t, r, n) {
  for (var i = "", a = parseInt(t); a < parseInt(r); ++a) i += n.replace(/\[\s*i\s*\]/g, "[".concat(a, "]")).replace(/UNROLLED_LOOP_INDEX/g, "".concat(a));
  return i;
}
function w9(e, t) {
  return function(r) {
    return r.replace(oq, lq);
  }(function(r, n) {
    return n.dLightCount && (r = r.replace(/dLightCount/g, "".concat(n.dLightCount.ref.value))), n.dClipObjectCount && (r = r.replace(/dClipObjectCount/g, "".concat(n.dClipObjectCount.ref.value))), r;
  }(e, t));
}
function Sn(e, t, r, n, i, a) {
  return n === void 0 && (n = {}), i === void 0 && (i = {}), { id: hM(), name: e, vert: C9(t), frag: C9(r), extensions: n, outTypes: i, ignoreDefine: a };
}
function Sm(e, t, r) {
  var n;
  return t.startsWith("color") ? e === "dLightCount" && !!(!((n = r.dIgnoreLight) === null || n === void 0) && n.ref.value) : ["dColorType", "dUsePalette", "dLightCount", "dOverpaintType", "dOverpaint", "dSubstanceType", "dSubstance"].includes(e);
}
function xg(e, t, r) {
  return e === "dLightCount" || Sm(e, t, r);
}
var dq = Sn("points", `
precision highp float;
precision highp int;

#include common
#include read_from_texture
#include common_vert_params
#include color_vert_params
#include size_vert_params
#include common_clip

uniform float uPixelRatio;
uniform vec4 uViewport;

attribute vec3 aPosition;
attribute mat4 aTransform;
attribute float aInstance;
attribute float aGroup;

void main(){
    #include assign_group
    #include assign_color_varying
    #include assign_marker_varying
    #include assign_clipping_varying
    #include assign_position
    #include assign_size

    #ifdef dPointSizeAttenuation
        gl_PointSize = size * uPixelRatio * ((uViewport.w / 2.0) / -mvPosition.z) * 5.0;
    #else
        gl_PointSize = size * uPixelRatio;
    #endif
    gl_PointSize = max(1.0, gl_PointSize);

    gl_Position = uProjection * mvPosition;

    #include clip_instance
}
`, `
precision highp float;
precision highp int;

#include common
#include common_frag_params
#include color_frag_params
#include common_clip

const vec2 center = vec2(0.5);
const float radius = 0.5;

void main(){
    #include clip_pixel

    float fragmentDepth = gl_FragCoord.z;
    bool interior = false;
    #include assign_material_color

    #if defined(dPointStyle_circle)
        float dist = distance(gl_PointCoord, center);
        if (dist > radius) discard;
    #elif defined(dPointStyle_fuzzy)
        float dist = distance(gl_PointCoord, center);
        float fuzzyAlpha = 1.0 - smoothstep(0.0, radius, dist);
        if (fuzzyAlpha < 0.0001) discard;
    #endif

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
        gl_FragColor = material;
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color)
        gl_FragColor = material;

        #if defined(dPointStyle_fuzzy)
            gl_FragColor.a *= fuzzyAlpha;
        #endif

        #include apply_marker_color
        #include apply_fog
        #include wboit_write
    #endif
}
`, { drawBuffers: "optional" }, {}, xg), fq = Sn("spheres", `
precision highp float;
precision highp int;

#include common
#include read_from_texture
#include common_vert_params
#include color_vert_params
#include size_vert_params
#include common_clip

uniform mat4 uModelView;
uniform mat4 uInvProjection;

attribute vec3 aPosition;
attribute vec2 aMapping;
attribute mat4 aTransform;
attribute float aInstance;
attribute float aGroup;

varying float vRadius;
varying float vRadiusSq;
varying vec3 vPoint;
varying vec3 vPointViewPosition;

#include matrix_scale

const mat4 D = mat4(
    1.0, 0.0, 0.0, 0.0,
    0.0, 1.0, 0.0, 0.0,
    0.0, 0.0, 1.0, 0.0,
    0.0, 0.0, 0.0, -1.0
);

/**
 * Compute point size and center using the technique described in:
 * "GPU-Based Ray-Casting of Quadratic Surfaces" http://dl.acm.org/citation.cfm?id=2386396
 * by Christian Sigg, Tim Weyrich, Mario Botsch, Markus Gross.
 */
void quadraticProjection(const in float radius, const in vec3 position){
    vec2 xbc, ybc;

    mat4 T = mat4(
        radius, 0.0, 0.0, 0.0,
        0.0, radius, 0.0, 0.0,
        0.0, 0.0, radius, 0.0,
        position.x, position.y, position.z, 1.0
    );

    mat4 R = transpose4(uProjection * uModelView * aTransform * T);
    float A = dot(R[3], D * R[3]);
    float B = -2.0 * dot(R[0], D * R[3]);
    float C = dot(R[0], D * R[0]);
    xbc[0] = (-B - sqrt(B * B - 4.0 * A * C)) / (2.0 * A);
    xbc[1] = (-B + sqrt(B * B - 4.0 * A * C)) / (2.0 * A);
    float sx = abs(xbc[0] - xbc[1]) * 0.5;

    A = dot(R[3], D * R[3]);
    B = -2.0 * dot(R[1], D * R[3]);
    C = dot(R[1], D * R[1]);
    ybc[0] = (-B - sqrt(B * B - 4.0 * A * C)) / (2.0 * A);
    ybc[1] = (-B + sqrt(B * B - 4.0 * A * C)) / (2.0 * A);
    float sy = abs(ybc[0] - ybc[1]) * 0.5;

    gl_Position.xy = vec2(0.5 * (xbc.x + xbc.y), 0.5 * (ybc.x + ybc.y));
    gl_Position.xy -= aMapping * vec2(sx, sy);
    gl_Position.xy *= gl_Position.w;
}


void main(void){
    #include assign_group
    #include assign_color_varying
    #include assign_marker_varying
    #include assign_clipping_varying
    #include assign_size

    vRadius = size * matrixScale(uModelView);

    vec4 position4 = vec4(aPosition, 1.0);
    vec4 mvPosition = uModelView * aTransform * position4;
    mvPosition.z -= vRadius; // avoid clipping, added again in fragment shader

    gl_Position = uProjection * vec4(mvPosition.xyz, 1.0);
    quadraticProjection(size, aPosition);

    vRadiusSq = vRadius * vRadius;
    vec4 vPoint4 = uInvProjection * gl_Position;
    vPoint = vPoint4.xyz / vPoint4.w;
    vPointViewPosition = -mvPosition.xyz / mvPosition.w;

    vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader

    #include clip_instance
}
`, `
precision highp float;
precision highp int;

#define bumpEnabled

#include common
#include common_frag_params
#include color_frag_params
#include light_frag_params
#include common_clip

uniform mat4 uInvView;

varying float vRadius;
varying float vRadiusSq;
varying vec3 vPoint;
varying vec3 vPointViewPosition;

vec3 cameraPos;
vec3 cameraNormal;

bool Impostor(out vec3 cameraPos, out vec3 cameraNormal){
    vec3 cameraSpherePos = -vPointViewPosition;
    cameraSpherePos.z += vRadius;

    vec3 rayOrigin = mix(vec3(0.0, 0.0, 0.0), vPoint, uIsOrtho);
    vec3 rayDirection = mix(normalize(vPoint), vec3(0.0, 0.0, 1.0), uIsOrtho);
    vec3 cameraSphereDir = mix(cameraSpherePos, rayOrigin - cameraSpherePos, uIsOrtho);

    float B = dot(rayDirection, cameraSphereDir);
    float det = B * B + vRadiusSq - dot(cameraSphereDir, cameraSphereDir);

    if (det < 0.0){
        discard;
        return false;
    }

    float sqrtDet = sqrt(det);
    float posT = mix(B + sqrtDet, B + sqrtDet, uIsOrtho);
    float negT = mix(B - sqrtDet, sqrtDet - B, uIsOrtho);

    cameraPos = rayDirection * negT + rayOrigin;


    if (calcDepth(cameraPos) <= 0.0) {
        cameraPos = rayDirection * posT + rayOrigin;
        interior = true;
    } else {
        interior = false;
    }

    cameraNormal = normalize(cameraPos - cameraSpherePos);
    cameraNormal *= float(!interior) * 2.0 - 1.0;

    return !interior;
}

void main(void){
    #include clip_pixel

    bool flag = Impostor(cameraPos, cameraNormal);
    if (!uDoubleSided) {
        if (interior) discard;
    }

    vec3 vViewPosition = cameraPos;
    gl_FragDepthEXT = calcDepth(vViewPosition);
    if (!flag && gl_FragDepthEXT >= 0.0) {
        gl_FragDepthEXT = 0.0 + (0.0000001 / vRadius);
    }

    vec3 vModelPosition = (uInvView * vec4(vViewPosition, 1.0)).xyz;

    if (gl_FragDepthEXT < 0.0) discard;
    if (gl_FragDepthEXT > 1.0) discard;

    float fragmentDepth = gl_FragDepthEXT;
    #include assign_material_color

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
        gl_FragColor = material;
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color)
        vec3 normal = -cameraNormal;
        #include apply_light_color

        #include apply_interior_color
        #include apply_marker_color
        #include apply_fog
        #include wboit_write
    #endif
}
`, { fragDepth: "required", drawBuffers: "optional" }, {}, Sm), pq = Sn("cylinders", `
precision highp float;
precision highp int;

#include common
#include read_from_texture
#include common_vert_params
#include color_vert_params
#include size_vert_params
#include common_clip

uniform mat4 uModelView;

attribute mat4 aTransform;
attribute float aInstance;
attribute float aGroup;

attribute vec3 aMapping;
attribute vec3 aStart;
attribute vec3 aEnd;
attribute float aScale;
attribute float aCap;

varying mat4 vTransform;
varying vec3 vStart;
varying vec3 vEnd;
varying float vSize;
varying float vCap;

uniform float uIsOrtho;
uniform vec3 uCameraDir;

void main() {
    #include assign_group
    #include assign_color_varying
    #include assign_marker_varying
    #include assign_clipping_varying
    #include assign_size

    mat4 modelTransform = uModel * aTransform;

    vTransform = aTransform;
    vStart = (modelTransform * vec4(aStart, 1.0)).xyz;
    vEnd = (modelTransform * vec4(aEnd, 1.0)).xyz;
    vSize = size * aScale;
    vCap = aCap;

    vModelPosition = (vStart + vEnd) * 0.5;
    vec3 camDir = -mix(normalize(vModelPosition - uCameraPosition), uCameraDir, uIsOrtho);
    vec3 dir = vEnd - vStart;
    // ensure cylinder 'dir' is pointing towards the camera
    if(dot(camDir, dir) < 0.0) dir = -dir;

    vec3 left = cross(camDir, dir);
    vec3 up = cross(left, dir);
    left = vSize * normalize(left);
    up = vSize * normalize(up);

    // move vertex in object-space from center to corner
    vModelPosition += aMapping.x * dir + aMapping.y * left + aMapping.z * up;

    vec4 mvPosition = uView * vec4(vModelPosition, 1.0);
    vViewPosition = mvPosition.xyz;
    gl_Position = uProjection * mvPosition;

    #include clip_instance
}
`, `
precision highp float;
precision highp int;

#define bumpEnabled

uniform mat4 uView;

varying mat4 vTransform;
varying vec3 vStart;
varying vec3 vEnd;
varying float vSize;
varying float vCap;

uniform vec3 uCameraDir;
uniform vec3 uCameraPosition;
uniform mat4 uInvView;

#include common
#include common_frag_params
#include color_frag_params
#include light_frag_params
#include common_clip

// adapted from https://www.shadertoy.com/view/4lcSRn
// The MIT License, Copyright 2016 Inigo Quilez
bool CylinderImpostor(
    in vec3 rayOrigin, in vec3 rayDir,
    in vec3 start, in vec3 end, in float radius,
    out vec4 intersection, out bool interior
){
    vec3 ba = end - start;
    vec3 oc = rayOrigin - start;

    float baba = dot(ba, ba);
    float bard = dot(ba, rayDir);
    float baoc = dot(ba, oc);

    float k2 = baba - bard*bard;
    float k1 = baba * dot(oc, rayDir) - baoc * bard;
    float k0 = baba * dot(oc, oc) - baoc * baoc - radius * radius * baba;

    float h = k1 * k1 - k2 * k0;
    if (h < 0.0) return false;

    bool topCap = (vCap > 0.9 && vCap < 1.1) || vCap >= 2.9;
    bool bottomCap = (vCap > 1.9 && vCap < 2.1) || vCap >= 2.9;

    // body outside
    h = sqrt(h);
    float t = (-k1 - h) / k2;
    float y = baoc + t * bard;
    if (y > 0.0 && y < baba) {
        interior = false;
        intersection = vec4(t, (oc + t * rayDir - ba * y / baba) / radius);
        return true;
    }

    if (topCap && y < 0.0) {
        // top cap
        t = -baoc / bard;
        if (abs(k1 + k2 * t) < h) {
            interior = false;
            intersection = vec4(t, ba * sign(y) / baba);
            return true;
        }
    } else if(bottomCap && y >= 0.0) {
        // bottom cap
        t = (baba - baoc) / bard;
        if (abs(k1 + k2 * t) < h) {
            interior = false;
            intersection = vec4(t, ba * sign(y) / baba);
            return true;
        }
    }

    if (uDoubleSided) {
        // body inside
        h = -h;
        t = (-k1 - h) / k2;
        y = baoc + t * bard;
        if (y > 0.0 && y < baba) {
            interior = true;
            intersection = vec4(t, (oc + t * rayDir - ba * y / baba) / radius);
            return true;
        }

        // TODO: handle inside caps???
    }

    return false;
}

void main() {
    #include clip_pixel

    vec3 rayDir = mix(normalize(vModelPosition - uCameraPosition), uCameraDir, uIsOrtho);

    vec4 intersection;
    bool interior;
    bool hit = CylinderImpostor(vModelPosition, rayDir, vStart, vEnd, vSize, intersection, interior);
    if (!hit) discard;

    vec3 vViewPosition = vModelPosition + intersection.x * rayDir;
    vViewPosition = (uView * vec4(vViewPosition, 1.0)).xyz;
    gl_FragDepthEXT = calcDepth(vViewPosition);

    vec3 vModelPosition = (uInvView * vec4(vViewPosition, 1.0)).xyz;

    if (gl_FragDepthEXT < 0.0) discard;
    if (gl_FragDepthEXT > 1.0) discard;

    float fragmentDepth = gl_FragDepthEXT;
    #include assign_material_color

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
        gl_FragColor = material;
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color)
        mat3 normalMatrix = transpose3(inverse3(mat3(uView)));
        vec3 normal = normalize(normalMatrix * -normalize(intersection.yzw));
        #include apply_light_color

        #include apply_interior_color
        #include apply_marker_color
        #include apply_fog
        #include wboit_write
    #endif
}
`, { fragDepth: "required", drawBuffers: "optional" }, {}, Sm), mq = Sn("text", `
precision highp float;
precision highp int;

#include common
#include read_from_texture
#include common_vert_params
#include color_vert_params
#include size_vert_params
#include common_clip

uniform mat4 uModelView;

attribute vec3 aPosition;
attribute vec2 aMapping;
attribute float aDepth;
attribute vec2 aTexCoord;
attribute mat4 aTransform;
attribute float aInstance;
attribute float aGroup;

uniform float uOffsetX;
uniform float uOffsetY;
uniform float uOffsetZ;

// uniform bool ortho;
uniform float uPixelRatio;
uniform vec4 uViewport;

varying vec2 vTexCoord;

#include matrix_scale

void main(void){
    #include assign_group
    #include assign_color_varying
    #include assign_marker_varying
    #include assign_clipping_varying
    #include assign_size

    vTexCoord = aTexCoord;

    float scale = matrixScale(uModelView);

    float offsetX = uOffsetX * scale;
    float offsetY = uOffsetY * scale;
    float offsetZ = (uOffsetZ + aDepth * 0.95) * scale;

    vec4 position4 = vec4(aPosition, 1.0);
    vec4 mvPosition = uModelView * aTransform * position4;

    vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader

    // TODO
    // #ifdef FIXED_SIZE
    //     if (ortho) {
    //         scale /= pixelRatio * ((uViewport.w / 2.0) / -uCameraPosition.z) * 0.1;
    //     } else {
    //         scale /= pixelRatio * ((uViewport.w / 2.0) / -mvPosition.z) * 0.1;
    //     }
    // #endif

    vec4 mvCorner = vec4(mvPosition.xyz, 1.0);

    if (vTexCoord.x == 10.0) { // indicates background plane
        // move a bit to the back, taking distance to camera into account to avoid z-fighting
        offsetZ -= 0.001 * distance(uCameraPosition, (uProjection * mvCorner).xyz);
    }

    mvCorner.xy += aMapping * size * scale;
    mvCorner.x += offsetX;
    mvCorner.y += offsetY;

    // TODO
    // if(ortho){
    //     mvCorner.xyz += normalize(-uCameraPosition) * offsetZ;
    // } else {
    //     mvCorner.xyz += normalize(-mvCorner.xyz) * offsetZ;
    // }
    mvCorner.xyz += normalize(-mvCorner.xyz) * offsetZ;

    gl_Position = uProjection * mvCorner;

    vViewPosition = -mvCorner.xyz;

    #include clip_instance
}
`, `
precision highp float;
precision highp int;

#include common
#include common_frag_params
#include color_frag_params
#include common_clip

uniform sampler2D tFont;

uniform vec3 uBorderColor;
uniform float uBorderWidth;
uniform vec3 uBackgroundColor;
uniform float uBackgroundOpacity;

varying vec2 vTexCoord;

const float smoothness = 32.0;
const float gamma = 2.2;

void main2(){
    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}

void main(){
    #include clip_pixel

    float fragmentDepth = gl_FragCoord.z;
    bool interior = false;
    #include assign_material_color

    if (vTexCoord.x > 1.0) {
        gl_FragColor = vec4(uBackgroundColor, uBackgroundOpacity * material.a);
    } else {
        // retrieve signed distance
        float sdf = texture2D(tFont, vTexCoord).a + uBorderWidth;

        // perform adaptive anti-aliasing of the edges
        float w = clamp(smoothness * (abs(dFdx(vTexCoord.x)) + abs(dFdy(vTexCoord.y))), 0.0, 0.5);
        float a = smoothstep(0.5 - w, 0.5 + w, sdf);

        // gamma correction for linear attenuation
        a = pow(a, 1.0 / gamma);

        if (a < 0.5) discard;
        material.a *= a;

        // add border
        float t = 0.5 + uBorderWidth;
        if (uBorderWidth > 0.0 && sdf < t) {
            material.xyz = mix(uBorderColor, material.xyz, smoothstep(t - w, t, sdf));
        }

        gl_FragColor = material;
    }

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color)
        #include apply_marker_color
        #include apply_fog
        #include wboit_write
    #endif
}
`, { drawBuffers: "optional" }, {}, xg), hq = Sn("lines", `
precision highp float;
precision highp int;

#include common
#include read_from_texture
#include common_vert_params
#include color_vert_params
#include size_vert_params
#include common_clip

uniform float uPixelRatio;
uniform vec4 uViewport;

attribute mat4 aTransform;
attribute float aInstance;
attribute float aGroup;

attribute vec2 aMapping;
attribute vec3 aStart;
attribute vec3 aEnd;

void trimSegment(const in vec4 start, inout vec4 end) {
    // trim end segment so it terminates between the camera plane and the near plane
    // conservative estimate of the near plane
    float a = uProjection[2][2];  // 3rd entry in 3rd column
    float b = uProjection[3][2];  // 3rd entry in 4th column
    float nearEstimate = -0.5 * b / a;
    float alpha = (nearEstimate - start.z) / (end.z - start.z);
    end.xyz = mix(start.xyz, end.xyz, alpha);
}

void main(){
    float aspect = uViewport.z / uViewport.w;

    #include assign_group
    #include assign_color_varying
    #include assign_marker_varying
    #include assign_clipping_varying
    #include assign_size

    mat4 modelView = uView * uModel * aTransform;

    // camera space
    vec4 start = modelView * vec4(aStart, 1.0);
    vec4 end = modelView * vec4(aEnd, 1.0);

    // assign position
    vec4 position4 = vec4((aMapping.y < 0.5) ? aStart : aEnd, 1.0);
    vec4 mvPosition = modelView * position4;
    vViewPosition = mvPosition.xyz;

    vModelPosition = (uModel * aTransform * position4).xyz; // for clipping in frag shader

    // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
    // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
    // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
    // perhaps there is a more elegant solution -- WestLangley
    bool perspective = (uProjection[2][3] == -1.0); // 4th entry in the 3rd column
    if (perspective) {
        if (start.z < 0.0 && end.z >= 0.0) {
            trimSegment(start, end);
        } else if (end.z < 0.0 && start.z >= 0.0) {
            trimSegment(end, start);
        }
    }

    // clip space
    vec4 clipStart = uProjection * start;
    vec4 clipEnd = uProjection * end;

    // ndc space
    vec2 ndcStart = clipStart.xy / clipStart.w;
    vec2 ndcEnd = clipEnd.xy / clipEnd.w;

    // direction
    vec2 dir = ndcEnd - ndcStart;

    // account for clip-space aspect ratio
    dir.x *= aspect;
    dir = normalize(dir);

    // perpendicular to dir
    vec2 offset = vec2(dir.y, - dir.x);

    // undo aspect ratio adjustment
    dir.x /= aspect;
    offset.x /= aspect;

    // sign flip
    if (aMapping.x < 0.0) offset *= -1.0;

    // calculate linewidth
    float linewidth;
    #ifdef dLineSizeAttenuation
        linewidth = size * uPixelRatio * ((uViewport.w / 2.0) / -start.z) * 5.0;
    #else
        linewidth = size * uPixelRatio;
    #endif
    linewidth = max(1.0, linewidth);

    // adjust for linewidth
    offset *= linewidth;

    // adjust for clip-space to screen-space conversion
    offset /= uViewport.w;

    // select end
    vec4 clip = (aMapping.y < 0.5) ? clipStart : clipEnd;

    // back to clip space
    offset *= clip.w;
    clip.xy += offset;
    gl_Position = clip;

    #include clip_instance
}
`, `
precision highp float;
precision highp int;

#include common
#include common_frag_params
#include color_frag_params
#include common_clip

void main(){
    #include clip_pixel

    bool interior = false;
    float fragmentDepth = gl_FragCoord.z;
    #include assign_material_color

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
        gl_FragColor = material;
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color)
        gl_FragColor = material;

        #include apply_marker_color
        #include apply_fog
        #include wboit_write
    #endif
}
`, { drawBuffers: "optional" }, {}, xg), D9 = Sn("mesh", `
precision highp float;
precision highp int;
precision highp sampler2D;

#include common
#include read_from_texture
#include common_vert_params
#include color_vert_params
#include common_clip
#include texture3d_from_2d_linear

#ifdef dGeometryType_textureMesh
    uniform vec2 uGeoTexDim;
    uniform sampler2D tPosition;
    uniform sampler2D tGroup;
    uniform sampler2D tNormal;
#else
    attribute vec3 aPosition;
    attribute float aGroup;
    attribute vec3 aNormal;
#endif
attribute mat4 aTransform;
attribute float aInstance;

varying vec3 vNormal;

void main(){
    #include assign_group
    #include assign_marker_varying
    #include assign_clipping_varying
    #include assign_position
    #include assign_color_varying
    #include clip_instance

    #ifdef dGeometryType_textureMesh
        vec3 normal = readFromTexture(tNormal, VertexID, uGeoTexDim).xyz;
    #else
        vec3 normal = aNormal;
    #endif
    mat3 normalMatrix = transpose3(inverse3(mat3(modelView)));
    vec3 transformedNormal = normalize(normalMatrix * normalize(normal));
    #if defined(dFlipSided)
        if (!uDoubleSided) { // TODO checking uDoubleSided should not be required, ASR
            transformedNormal = -transformedNormal;
        }
    #endif
    vNormal = transformedNormal;
}
`, `
precision highp float;
precision highp int;

#define bumpEnabled

#include common
#include common_frag_params
#include color_frag_params
#include light_frag_params
#include normal_frag_params
#include common_clip

void main() {
    #include clip_pixel

    // Workaround for buggy gl_FrontFacing (e.g. on some integrated Intel GPUs)
    vec3 fdx = dFdx(vViewPosition);
    vec3 fdy = dFdy(vViewPosition);
    vec3 faceNormal = normalize(cross(fdx,fdy));
    bool frontFacing = dot(vNormal, faceNormal) > 0.0;

    #if defined(dFlipSided)
        interior = frontFacing;
    #else
        interior = !frontFacing;
    #endif

    float fragmentDepth = gl_FragCoord.z;
    #include assign_material_color

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
        gl_FragColor = material;
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color)
        #if defined(dFlatShaded)
            vec3 normal = -faceNormal;
        #else
            vec3 normal = -normalize(vNormal);
            if (uDoubleSided) normal *= float(frontFacing) * 2.0 - 1.0;
        #endif
        #include apply_light_color

        #include apply_interior_color
        #include apply_marker_color
        #include apply_fog
        #include wboit_write
    #endif
}
`, { drawBuffers: "optional" }, {}, Sm), vq = Sn("direct-volume", `
precision highp float;

attribute vec3 aPosition;
attribute mat4 aTransform;
attribute float aInstance;

uniform mat4 uModelView;
uniform mat4 uProjection;
uniform vec4 uInvariantBoundingSphere;

varying vec3 vOrigPos;
varying float vInstance;
varying vec4 vBoundingSphere;
varying mat4 vTransform;

uniform vec3 uBboxSize;
uniform vec3 uBboxMin;
uniform vec3 uBboxMax;
uniform vec3 uGridDim;
uniform mat4 uTransform;

uniform mat4 uUnitToCartn;

void main() {
    vec4 unitCoord = vec4(aPosition + vec3(0.5), 1.0);
    vec4 mvPosition = uModelView * aTransform * uUnitToCartn * unitCoord;

    vOrigPos = (aTransform * uUnitToCartn * unitCoord).xyz;
    vInstance = aInstance;
    vBoundingSphere = vec4(
        (aTransform * vec4(uInvariantBoundingSphere.xyz, 1.0)).xyz,
        uInvariantBoundingSphere.w
    );
    vTransform = aTransform;

    gl_Position = uProjection * mvPosition;

    // move z position to near clip plane (but not too close to get precision issues)
    gl_Position.z = gl_Position.w - 0.01;
}
`, `
precision highp float;
precision highp int;

#include common
#include light_frag_params

#if dClipObjectCount != 0
    uniform int uClipObjectType[dClipObjectCount];
    uniform bool uClipObjectInvert[dClipObjectCount];
    uniform vec3 uClipObjectPosition[dClipObjectCount];
    uniform vec4 uClipObjectRotation[dClipObjectCount];
    uniform vec3 uClipObjectScale[dClipObjectCount];
#endif
#include common_clip

#include read_from_texture
#include texture3d_from_1d_trilinear
#include texture3d_from_2d_nearest
#include texture3d_from_2d_linear

uniform mat4 uProjection, uTransform, uModelView, uModel, uView;
uniform vec3 uCameraDir;

uniform sampler2D tDepth;
uniform vec2 uDrawingBufferSize;

varying vec3 vOrigPos;
varying float vInstance;
varying vec4 vBoundingSphere;
varying mat4 vTransform;

uniform mat4 uInvView;
uniform vec3 uGridDim;
uniform vec3 uBboxSize;
uniform sampler2D tTransferTex;
uniform float uTransferScale;
uniform float uStepScale;
uniform float uJumpLength;

uniform int uObjectId;
uniform int uVertexCount;
uniform int uInstanceCount;
uniform int uGroupCount;

uniform vec3 uHighlightColor;
uniform vec3 uSelectColor;
uniform float uHighlightStrength;
uniform float uSelectStrength;
uniform int uMarkerPriority;

uniform vec3 uInvalidColor;
uniform float uInvalidStrength;

uniform float uMarker;
uniform vec2 uMarkerTexDim;
uniform sampler2D tMarker;

uniform float uMetalness;
uniform float uRoughness;

uniform float uFogNear;
uniform float uFogFar;
uniform vec3 uFogColor;

uniform float uAlpha;
uniform float uPickingAlphaThreshold;
uniform bool uTransparentBackground;
uniform float uXrayEdgeFalloff;

uniform float uInteriorDarkening;
uniform bool uInteriorColorFlag;
uniform vec3 uInteriorColor;

uniform bool uRenderWboit;
uniform bool uDoubleSided;

uniform float uNear;
uniform float uFar;
uniform float uIsOrtho;

uniform vec3 uCellDim;
uniform vec3 uCameraPosition;
uniform mat4 uCartnToUnit;

#if __VERSION__ != 100
    // for webgl1 this is given as a 'define'
    uniform int uMaxSteps;
#endif

#if defined(dGridTexType_2d)
    precision highp sampler2D;
    uniform sampler2D tGridTex;
    uniform vec3 uGridTexDim;
#elif defined(dGridTexType_3d)
    precision highp sampler3D;
    uniform sampler3D tGridTex;
#endif

#if defined(dColorType_uniform)
    uniform vec3 uColor;
#elif defined(dColorType_texture)
    uniform vec2 uColorTexDim;
    uniform sampler2D tColor;
#endif

#ifdef dOverpaint
    #if defined(dOverpaintType_groupInstance) || defined(dOverpaintType_vertexInstance)
        uniform vec2 uOverpaintTexDim;
        uniform sampler2D tOverpaint;
    #endif
#endif

#ifdef dUsePalette
    uniform sampler2D tPalette;
#endif

#if defined(dGridTexType_2d)
    vec4 textureVal(vec3 pos) {
        return texture3dFrom2dLinear(tGridTex, pos + (vec3(0.5, 0.5, 0.0) / uGridDim), uGridDim, uGridTexDim.xy);
    }
    vec4 textureGroup(vec3 pos) {
        return texture3dFrom2dNearest(tGridTex, pos + (vec3(0.5, 0.5, 0.0) / uGridDim), uGridDim, uGridTexDim.xy);
    }
#elif defined(dGridTexType_3d)
    vec4 textureVal(vec3 pos) {
        return texture(tGridTex, pos + (vec3(0.5) / uGridDim));
    }
    vec4 textureGroup(vec3 pos) {
        return texelFetch(tGridTex, ivec3(pos * uGridDim), 0);
    }
#endif

float calcDepth(const in vec3 pos) {
    vec2 clipZW = pos.z * uProjection[2].zw + uProjection[3].zw;
    return 0.5 + 0.5 * clipZW.x / clipZW.y;
}

float transferFunction(float value) {
    return texture2D(tTransferTex, vec2(value, 0.0)).a;
}

float getDepth(const in vec2 coords) {
    #ifdef depthTextureSupport
        if (!uRenderWboit) {
            // in case of opaque volumes (and depth texture support)
            return texture2D(tDepth, coords).r;
        } else {
            return unpackRGBAToDepth(texture2D(tDepth, coords));
        }
    #else
        return unpackRGBAToDepth(texture2D(tDepth, coords));
    #endif
}

const float gradOffset = 0.5;

vec3 v3m4(vec3 p, mat4 m) {
    return (m * vec4(p, 1.0)).xyz;
}

float preFogAlphaBlended = 0.0;

vec4 raymarch(vec3 startLoc, vec3 step, vec3 rayDir) {
    mat3 normalMatrix = transpose3(inverse3(mat3(uModelView * vTransform)));
    mat4 cartnToUnit = uCartnToUnit * inverse4(vTransform);
    #if defined(dClipVariant_pixel) && dClipObjectCount != 0
        mat4 modelTransform = uModel * vTransform * uTransform;
    #endif
    mat4 modelViewTransform = uModelView * vTransform * uTransform;

    vec3 scaleVol = vec3(1.0) / uGridDim;
    vec3 pos = startLoc;
    vec4 cell;
    float prevValue = -1.0;
    float value = 0.0;
    vec4 src = vec4(0.0);
    vec4 dst = vec4(0.0);
    float fragmentDepth;

    vec3 posMin = vec3(0.0);
    vec3 posMax = vec3(1.0) - vec3(1.0) / uGridDim;

    vec3 unitPos;

    vec3 nextPos;
    float nextValue;

    vec4 material;
    vec4 overpaint;
    float metalness = uMetalness;
    float roughness = uRoughness;

    vec3 gradient = vec3(1.0);
    vec3 dx = vec3(gradOffset * scaleVol.x, 0.0, 0.0);
    vec3 dy = vec3(0.0, gradOffset * scaleVol.y, 0.0);
    vec3 dz = vec3(0.0, 0.0, gradOffset * scaleVol.z);

    float maxDist = min(vBoundingSphere.w * 2.0, uFar - uNear);
    float maxDistSq = maxDist * maxDist;

    for (int i = 0; i < uMaxSteps; ++i) {
        // break when beyond bounding-sphere or far-plane
        vec3 distVec = startLoc - pos;
        if (dot(distVec, distVec) > maxDistSq) break;

        unitPos = v3m4(pos, cartnToUnit);

        // continue when outside of grid
        if (unitPos.x > posMax.x || unitPos.y > posMax.y || unitPos.z > posMax.z ||
            unitPos.x < posMin.x || unitPos.y < posMin.y || unitPos.z < posMin.z
        ) {
            prevValue = value;
            pos += step;
            continue;
        }

        cell = textureVal(unitPos);
        value = cell.a; // current voxel value

        if (uJumpLength > 0.0 && value < 0.01) {
            nextPos = pos + rayDir * uJumpLength;
            nextValue = textureVal(v3m4(nextPos, cartnToUnit)).a;
            if (nextValue < 0.01) {
                prevValue = nextValue;
                pos = nextPos;
                continue;
            }
        }

        vec4 mvPosition = modelViewTransform * vec4(unitPos * uGridDim, 1.0);
        if (calcDepth(mvPosition.xyz) > getDepth(gl_FragCoord.xy / uDrawingBufferSize))
            break;

        #if defined(dClipVariant_pixel) && dClipObjectCount != 0
            vec3 vModelPosition = v3m4(unitPos * uGridDim, modelTransform);
            if (clipTest(vec4(vModelPosition, 0.0), 0)) {
                prevValue = value;
                pos += step;
                continue;
            }
        #endif

        vec3 vViewPosition = mvPosition.xyz;
        material.a = transferFunction(value);

        #ifdef dPackedGroup
            float group = unpackRGBToInt(textureGroup(floor(unitPos * uGridDim + 0.5) / uGridDim).rgb);
        #else
            vec3 g = floor(unitPos * uGridDim + 0.5);
            // note that we swap x and z because the texture is flipped around y
            #if defined(dAxisOrder_012)
                float group = g.z + g.y * uGridDim.z + g.x * uGridDim.z * uGridDim.y; // 210
            #elif defined(dAxisOrder_021)
                float group = g.y + g.z * uGridDim.y + g.x * uGridDim.y * uGridDim.z; // 120
            #elif defined(dAxisOrder_102)
                float group = g.z + g.x * uGridDim.z + g.y * uGridDim.z * uGridDim.x; // 201
            #elif defined(dAxisOrder_120)
                float group = g.x + g.z * uGridDim.x + g.y * uGridDim.x * uGridDim.z; // 021
            #elif defined(dAxisOrder_201)
                float group = g.y + g.x * uGridDim.y + g.z * uGridDim.y * uGridDim.x; // 102
            #elif defined(dAxisOrder_210)
                float group = g.x + g.y * uGridDim.x + g.z * uGridDim.x * uGridDim.y; // 012
            #endif
        #endif

        #if defined(dColorType_direct) && defined(dUsePalette)
            material.rgb = texture2D(tPalette, vec2(value, 0.0)).rgb;
        #elif defined(dColorType_uniform)
            material.rgb = uColor;
        #elif defined(dColorType_instance)
            material.rgb = readFromTexture(tColor, vInstance, uColorTexDim).rgb;
        #elif defined(dColorType_group)
            material.rgb = readFromTexture(tColor, group, uColorTexDim).rgb;
        #elif defined(dColorType_groupInstance)
            material.rgb = readFromTexture(tColor, vInstance * float(uGroupCount) + group, uColorTexDim).rgb;
        #elif defined(dColorType_vertex)
            material.rgb = texture3dFrom1dTrilinear(tColor, isoPos, uGridDim, uColorTexDim, 0.0).rgb;
        #elif defined(dColorType_vertexInstance)
            material.rgb = texture3dFrom1dTrilinear(tColor, isoPos, uGridDim, uColorTexDim, vInstance * float(uVertexCount)).rgb;
        #endif

        #ifdef dOverpaint
            #if defined(dOverpaintType_groupInstance)
                overpaint = readFromTexture(tOverpaint, vInstance * float(uGroupCount) + group, uOverpaintTexDim);
            #elif defined(dOverpaintType_vertexInstance)
                overpaint = texture3dFrom1dTrilinear(tOverpaint, isoPos, uGridDim, uOverpaintTexDim, vInstance * float(uVertexCount));
            #endif

            material.rgb = mix(material.rgb, overpaint.rgb, overpaint.a);
        #endif

        if (material.a >= 0.01) {
            #ifdef dPackedGroup
                // compute gradient by central differences
                gradient.x = textureVal(unitPos - dx).a - textureVal(unitPos + dx).a;
                gradient.y = textureVal(unitPos - dy).a - textureVal(unitPos + dy).a;
                gradient.z = textureVal(unitPos - dz).a - textureVal(unitPos + dz).a;
            #else
                gradient = cell.xyz * 2.0 - 1.0;
            #endif
            vec3 normal = -normalize(normalMatrix * normalize(gradient));
            #include apply_light_color
        } else {
            gl_FragColor.rgb = material.rgb;
        }

        gl_FragColor.a = material.a * uAlpha * uTransferScale;

        float marker = uMarker;
        if (uMarker == -1.0) {
            marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;
            marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win
        }
        #include apply_marker_color

        preFogAlphaBlended = (1.0 - preFogAlphaBlended) * gl_FragColor.a + preFogAlphaBlended;
        fragmentDepth = calcDepth(mvPosition.xyz);
        #include apply_fog

        src = gl_FragColor;

        if (!uTransparentBackground) {
            // done in 'apply_fog' otherwise
            src.rgb *= src.a;
        }
        dst = (1.0 - dst.a) * src + dst; // standard blending

        // break if the color is opaque enough
        if (dst.a > 0.95)
            break;

        pos += step;
    }

    return dst;
}

// TODO: support float texture for higher precision values???
// TODO: support clipping exclusion texture support

void main() {
    if (gl_FrontFacing)
        discard;

    vec3 rayDir = mix(normalize(vOrigPos - uCameraPosition), uCameraDir, uIsOrtho);
    vec3 step = rayDir * uStepScale;

    float boundingSphereNear = distance(vBoundingSphere.xyz, uCameraPosition) - vBoundingSphere.w;
    float d = max(uNear, boundingSphereNear) - mix(0.0, distance(vOrigPos, uCameraPosition), uIsOrtho);
    vec3 start = mix(uCameraPosition, vOrigPos, uIsOrtho) + (d * rayDir);
    gl_FragColor = raymarch(start, step, rayDir);

    float fragmentDepth = calcDepth((uModelView * vec4(start, 1.0)).xyz);
    float preFogAlpha = clamp(preFogAlphaBlended, 0.0, 1.0);
    bool interior = false;
    #include wboit_write
}
`, { fragDepth: "optional", drawBuffers: "optional" }, {}, Sm), gq = Sn("image", `
precision highp float;
precision highp int;

#include common
#include common_vert_params

attribute vec3 aPosition;
attribute vec2 aUv;
attribute mat4 aTransform;
attribute float aInstance;

varying vec2 vUv;
varying float vInstance;

void main() {
    #include assign_position

    vUv = aUv;
    vInstance = aInstance;
}
`, `
precision highp float;
precision highp int;

#include common
#include read_from_texture
#include common_frag_params
#include common_clip

uniform vec2 uImageTexDim;
uniform sampler2D tImageTex;
uniform sampler2D tGroupTex;

uniform vec2 uMarkerTexDim;
uniform sampler2D tMarker;

varying vec2 vUv;
varying float vInstance;

#if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell) || defined(dInterpolation_bspline)
    #define dInterpolation_cubic
#endif

#if defined(dInterpolation_cubic)
    #if defined(dInterpolation_catmulrom) || defined(dInterpolation_mitchell)
        #if defined(dInterpolation_catmulrom)
            const float B = 0.0;
            const float C = 0.5;
        #elif defined(dInterpolation_mitchell)
            const float B = 0.333;
            const float C = 0.333;
        #endif

        float cubicFilter(float x){
            float f = x;
            if (f < 0.0) {
                f = -f;
            }
            if (f < 1.0) {
                return ((12.0 - 9.0 * B - 6.0 * C) * (f * f * f) +
                    (-18.0 + 12.0 * B + 6.0 * C) * (f * f) +
                    (6.0 - 2.0 * B)) / 6.0;
            }else if (f >= 1.0 && f < 2.0){
                return ((-B - 6.0 * C) * ( f * f * f)
                    + (6.0 * B + 30.0 * C) * (f * f) +
                    (-(12.0 * B) - 48.0 * C) * f +
                    8.0 * B + 24.0 * C) / 6.0;
            }else{
                return 0.0;
            }
        }
    #elif defined(dInterpolation_bspline)
        float cubicFilter(float x) {
            float f = x;
            if (f < 0.0) {
                f = -f;
            }
            if (f >= 0.0 && f <= 1.0){
                return (2.0 / 3.0) + (0.5) * (f * f * f) - (f * f);
            } else if (f > 1.0 && f <= 2.0) {
                return 1.0 / 6.0 * pow((2.0 - f), 3.0);
            }
            return 1.0;
        }
    #endif

    vec4 biCubic(sampler2D tex, vec2 texCoord) {
        vec2 texelSize = 1.0 / uImageTexDim;
        texCoord -= texelSize / 2.0;
        vec4 nSum = vec4(0.0);
        float nDenom = 0.0;
        vec2 cell = fract(texCoord * uImageTexDim);
        for (float m = -1.0; m <= 2.0; ++m) {
            for (float n = -1.0; n <= 2.0; ++n) {
                vec4 vecData = texture2D(tex, texCoord + texelSize * vec2(m, n));
                float c = cubicFilter(m - cell.x) * cubicFilter(-n + cell.y);
                nSum += vecData * c;
                nDenom += c;
            }
        }
        return nSum / nDenom;
    }
#endif

void main() {
    #include clip_pixel

    #if defined(dInterpolation_cubic)
        vec4 imageData = biCubic(tImageTex, vUv);
    #else
        vec4 imageData = texture2D(tImageTex, vUv);
    #endif
    imageData.a = clamp(imageData.a, 0.0, 1.0);
    if (imageData.a > 0.9) imageData.a = 1.0;

    float fragmentDepth = gl_FragCoord.z;
    bool interior = false;

    #if defined(dRenderVariant_pick)
        if (imageData.a < 0.3)
            discard;
        if (uPickType == 1) {
            gl_FragColor = vec4(packIntToRGB(float(uObjectId)), 1.0);
        } else if (uPickType == 2) {
            gl_FragColor = vec4(packIntToRGB(vInstance), 1.0);
        } else {
            gl_FragColor = vec4(texture2D(tGroupTex, vUv).rgb, 1.0);
        }
    #elif defined(dRenderVariant_depth)
        if (imageData.a < 0.05)
            discard;
        gl_FragColor = packDepthToRGBA(gl_FragCoord.z);
    #elif defined(dRenderVariant_marking)
        float marker = uMarker;
        if (uMarker == -1.0) {
            float group = unpackRGBToInt(texture2D(tGroupTex, vUv).rgb);
            marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;
            marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win
        }
        if (uMarkingType == 1) {
            if (marker > 0.0 || imageData.a < 0.05)
                discard;
            gl_FragColor = packDepthToRGBA(gl_FragCoord.z);
        } else {
            if (marker == 0.0 || imageData.a < 0.05)
                discard;
            float depthTest = 1.0;
            if (uMarkingDepthTest) {
                depthTest = (fragmentDepth >= getDepth(gl_FragCoord.xy / uDrawingBufferSize)) ? 1.0 : 0.0;
            }
            bool isHighlight = intMod(marker, 2.0) > 0.1;
            gl_FragColor = vec4(0.0, depthTest, isHighlight ? 1.0 : 0.0, 1.0);
        }
    #elif defined(dRenderVariant_color)
        if (imageData.a < 0.05)
            discard;
        gl_FragColor = imageData;
        gl_FragColor.a *= uAlpha;

        float marker = uMarker;
        if (uMarker == -1.0) {
            float group = unpackRGBToInt(texture2D(tGroupTex, vUv).rgb);
            marker = readFromTexture(tMarker, vInstance * float(uGroupCount) + group, uMarkerTexDim).a;
            marker = floor(marker * 255.0 + 0.5); // rounding required to work on some cards on win
        }

        #include apply_marker_color
        #include apply_fog
        #include wboit_write
    #endif
}
`, { drawBuffers: "optional" }, {}, xg);
function I9(e, t) {
  var r;
  if (e === void 0) return "";
  var n = ((r = e.dRenderVariant) === null || r === void 0 ? void 0 : r.ref.value) || "", i = [];
  for (var a in e) if (!(t != null && t(a, n, e))) {
    var o = e[a].ref.value;
    o !== void 0 && (typeof o == "string" ? i.push("#define ".concat(a, "_").concat(o)) : typeof o == "number" ? i.push("#define ".concat(a, " ").concat(o)) : typeof o == "boolean" ? o && i.push("#define ".concat(a)) : Hi());
  }
  return i.join(`
`) + `
`;
}
var yq = `#version 300 es
#define attribute in
#define varying out
#define texture2D texture
`, bq = `
#define varying in
#define texture2D texture
#define texture2DLodEXT textureLod

#define gl_FragColor out_FragData0
#define gl_FragDepthEXT gl_FragDepth

#define depthTextureSupport
`;
function _q(e, t, r, n) {
  var i = I9(r, n.ignoreDefine), a = I9(r, n.ignoreDefine), o = ir(e) ? yq : "", u = ir(e) ? function(c, l, d, f) {
    var m = ["#version 300 es", "layout(location = 0) out highp ".concat(f[0] || "vec4", " out_FragData0;")];
    if (d.fragDepth && m.push("#define enabledFragDepth"), d.drawBuffers) {
      m.push("#define requiredDrawBuffers");
      for (var v = 1, p = c.getParameter(c.MAX_DRAW_BUFFERS); v < p; ++v) m.push("layout(location = ".concat(v, ") out highp ").concat(f[v] || "vec4", " out_FragData").concat(v, ";"));
    }
    return d.shaderTextureLod && m.push("#define enabledShaderTextureLod"), m.push(bq), m.join(`
`) + `
`;
  }(e, 0, n.extensions, n.outTypes) : function(c, l) {
    var d = ["#extension GL_OES_standard_derivatives : enable"];
    if (l.fragDepth) {
      if (c.fragDepth) d.push("#extension GL_EXT_frag_depth : enable"), d.push("#define enabledFragDepth");
      else if (l.fragDepth === "required") throw new Error("required 'GL_EXT_frag_depth' extension not available");
    }
    if (l.drawBuffers) {
      if (c.drawBuffers) d.push("#extension GL_EXT_draw_buffers : require"), d.push("#define requiredDrawBuffers"), d.push("#define gl_FragColor gl_FragData[0]");
      else if (l.drawBuffers === "required") throw new Error("required 'GL_EXT_draw_buffers' extension not available");
    }
    if (l.shaderTextureLod) {
      if (c.shaderTextureLod) d.push("#extension GL_EXT_shader_texture_lod : enable"), d.push("#define enabledShaderTextureLod");
      else if (l.shaderTextureLod === "required") throw new Error("required 'GL_EXT_shader_texture_lod' extension not available");
    }
    return c.depthTexture && d.push("#define depthTextureSupport"), d.join(`
`) + `
`;
  }(t, n.extensions), s = ir(e) ? function(c) {
    return c.replace(/gl_FragData\[([0-9]+)\]/g, "out_FragData$1");
  }(n.frag) : n.frag;
  return { id: hM(), name: n.name, vert: "".concat(o).concat(i).concat(w9(n.vert, r)), frag: "".concat(u).concat(a).concat(w9(s, r)), extensions: n.extensions, outTypes: n.outTypes };
}
function xq(e, t) {
  switch (t) {
    case "b":
    case "b[]":
      return e.BOOL;
    case "f":
    case "f[]":
      return e.FLOAT;
    case "i":
    case "i[]":
      return e.INT;
    case "v2":
    case "v2[]":
      return e.FLOAT_VEC2;
    case "v3":
    case "v3[]":
      return e.FLOAT_VEC3;
    case "v4":
    case "v4[]":
      return e.FLOAT_VEC4;
    case "m3":
    case "m3[]":
      return e.FLOAT_MAT3;
    case "m4":
    case "m4[]":
      return e.FLOAT_MAT4;
    default:
      console.error("unknown uniform kind '".concat(t, "'"));
  }
}
function Aq(e, t, r) {
  e.uniform1f(t, r);
}
function Sq(e, t, r) {
  e.uniform1fv(t, r);
}
function Cq(e, t, r) {
  e.uniform1i(t, r);
}
function wq(e, t, r) {
  e.uniform1iv(t, r);
}
function Dq(e, t, r) {
  e.uniform2fv(t, r);
}
function Iq(e, t, r) {
  e.uniform3fv(t, r);
}
function Eq(e, t, r) {
  e.uniform4fv(t, r);
}
function Mq(e, t, r) {
  e.uniformMatrix3fv(t, !1, r);
}
function Tq(e, t, r) {
  e.uniformMatrix4fv(t, !1, r);
}
function E9(e) {
  switch (e) {
    case "f":
      return Aq;
    case "f[]":
      return Sq;
    case "i":
    case "t":
    case "b":
      return Cq;
    case "i[]":
    case "t[]":
    case "b[]":
      return wq;
    case "v2":
    case "v2[]":
      return Dq;
    case "v3":
    case "v3[]":
      return Iq;
    case "v4":
    case "v4[]":
      return Eq;
    case "m3":
    case "m3[]":
      return Mq;
    case "m4":
    case "m4[]":
      return Tq;
  }
}
var Pq = La();
function M9(e) {
  var t = e.createBuffer();
  if (t === null) throw new Error("Could not create WebGL buffer");
  return t;
}
function T9(e, t, r, n) {
  var i = M9(e), a = function(f, m) {
    switch (m) {
      case "static":
        return f.STATIC_DRAW;
      case "dynamic":
        return f.DYNAMIC_DRAW;
      case "stream":
        return f.STREAM_DRAW;
    }
  }(e, r), o = function(f, m) {
    switch (m) {
      case "attribute":
        return f.ARRAY_BUFFER;
      case "elements":
        return f.ELEMENT_ARRAY_BUFFER;
      case "uniform":
        return f.UNIFORM_BUFFER;
    }
  }(e, n), u = function(f, m) {
    return m instanceof Uint8Array ? f.UNSIGNED_BYTE : m instanceof Int8Array ? f.BYTE : m instanceof Uint16Array ? f.UNSIGNED_SHORT : m instanceof Int16Array ? f.SHORT : m instanceof Uint32Array ? f.UNSIGNED_INT : m instanceof Int32Array ? f.INT : m instanceof Float32Array ? f.FLOAT : void Hi();
  }(e, t), s = t.BYTES_PER_ELEMENT, c = t.length;
  function l(f) {
    e.bindBuffer(o, i), e.bufferData(o, f, a);
  }
  l(t);
  var d = !1;
  return { id: Pq(), _usageHint: a, _bufferType: o, _dataType: u, _bpe: s, length: c, getBuffer: function() {
    return i;
  }, updateData: l, updateSubData: function(f, m, v) {
    e.bindBuffer(o, i), v - m === f.length ? e.bufferSubData(o, 0, f) : e.bufferSubData(o, m * s, f.subarray(m, m + v));
  }, reset: function() {
    i = M9(e), l(t);
  }, destroy: function() {
    d || (e.deleteBuffer(i), d = !0);
  } };
}
function Bq(e, t, r) {
  switch (t) {
    case "int32":
      switch (r) {
        case 1:
          return e.INT;
        case 2:
          return e.INT_VEC2;
        case 3:
          return e.INT_VEC3;
        case 4:
          return e.INT_VEC4;
      }
      break;
    case "float32":
      switch (r) {
        case 1:
          return e.FLOAT;
        case 2:
          return e.FLOAT_VEC2;
        case 3:
          return e.FLOAT_VEC3;
        case 4:
          return e.FLOAT_VEC4;
        case 16:
          return e.FLOAT_MAT4;
      }
  }
  throw new Error("unknown attribute type for kind '".concat(t, "' and itemSize '").concat(r, "'"));
}
var Fq = La();
function db(e) {
  var t = e.createProgram();
  if (t === null) throw new Error("Could not create WebGL program");
  return t;
}
function Nq(e, t, r, n, i) {
  var a, o, u = i.defineValues, s = i.shaderCode, c = i.schema, l = db(e), d = Fq(), f = _q(e, r, u, s), m = n("vert", f.vert), v = n("frag", f.frag);
  function p() {
    m.attach(l), v.attach(l), e.linkProgram(l), Ir && function(h, y) {
      if (!h.getProgramParameter(y, h.LINK_STATUS)) throw new Error(`Could not compile WebGL program. 

`.concat(h.getProgramInfoLog(y)));
    }(e, l), a = function(h, y, x) {
      var A = {};
      return Object.keys(x).forEach(function(b) {
        var _ = x[b];
        if (_.type === "attribute") {
          var S = h.getAttribLocation(y, b);
          A[b] = S;
        } else _.type !== "uniform" && _.type !== "texture" || (S = h.getUniformLocation(y, b), A[b] = S);
      }), A;
    }(e, l, c), o = function(h) {
      var y = {};
      return Object.keys(h).forEach(function(x) {
        var A = h[x];
        A.type === "uniform" ? y[x] = E9(A.kind) : A.type === "texture" && (y[x] = E9("t"));
      }), y;
    }(c), Ir && (function(h, y, x) {
      for (var A = h.getProgramParameter(y, h.ACTIVE_ATTRIBUTES), b = 0; b < A; ++b) {
        var _ = h.getActiveAttrib(y, b);
        if (_) {
          var S = _.name, D = _.type;
          if (S.startsWith("__activeAttribute") || S === "gl_InstanceID" || S === "gl_VertexID") continue;
          var I = x[S];
          if (I === void 0) throw new Error("missing 'uniform' or 'texture' with name '".concat(S, "' in schema"));
          if (I.type !== "attribute") throw new Error("'".concat(S, "' must be of type 'attribute' but is '").concat(I.type, "'"));
          if (Bq(h, I.kind, I.itemSize) !== D) throw new Error("unexpected attribute type for ".concat(S));
        }
      }
    }(e, l, c), function(h, y, x) {
      for (var A = h.getProgramParameter(y, h.ACTIVE_UNIFORMS), b = 0; b < A; ++b) {
        var _ = h.getActiveUniform(y, b);
        if (_) {
          var S = _.name, D = _.type;
          if (S.startsWith("__activeUniform")) continue;
          var I = x[S.replace(/[[0-9]+\]$/, "")];
          if (I === void 0) throw new Error("missing 'uniform' or 'texture' with name '".concat(S, "' in schema"));
          if (I.type === "uniform") {
            if (xq(h, I.kind) !== D) throw new Error("unexpected uniform type for ".concat(S));
          } else {
            if (I.type !== "texture") throw new Error("'".concat(S, "' must be of type 'uniform' or 'texture' but is '").concat(I.type, "'"));
            if (I.kind === "image-float32" || I.kind === "image-uint8") {
              if (D !== h.SAMPLER_2D) throw new Error("unexpected sampler type for '".concat(S, "'"));
            } else if ((I.kind === "volume-float32" || I.kind === "volume-uint8") && D !== h.SAMPLER_3D) throw new Error("unexpected sampler type for '".concat(S, "'"));
          }
        }
      }
    }(e, l, c));
  }
  p();
  var g = !1;
  return { id: d, use: function() {
    t.currentProgramId = d, e.useProgram(l);
  }, setUniforms: function(h) {
    for (var y = 0, x = h.length; y < x; ++y) {
      var A = h[y], b = A[0], _ = A[1];
      if (_) {
        var S = a[b];
        S !== null && o[b](e, S, _.ref.value);
      }
    }
  }, bindAttributes: function(h) {
    t.clearVertexAttribsState();
    for (var y = 0, x = h.length; y < x; ++y) {
      var A = h[y], b = A[0], _ = A[1], S = a[b];
      S !== -1 && _.bind(S);
    }
    t.disableUnusedVertexAttribs();
  }, bindTextures: function(h, y) {
    for (var x = 0, A = h.length; x < A; ++x) {
      var b = h[x], _ = b[0], S = b[1], D = a[_];
      D != null && (S.bind(x + y), o[_](e, D, x + y));
    }
  }, reset: function() {
    l = db(e), p();
  }, destroy: function() {
    g || (m.destroy(), v.destroy(), e.deleteProgram(l), g = !0);
  } };
}
var Rq = La();
function _2(e, t) {
  var r = t.type, n = t.source, i = e.createShader(r === "vert" ? e.VERTEX_SHADER : e.FRAGMENT_SHADER);
  if (i === null) throw new Error("Error creating ".concat(r, " shader"));
  if (e.shaderSource(i, n), e.compileShader(i), Ir && e.getShaderParameter(i, e.COMPILE_STATUS) === !1) throw console.warn("'".concat(r, "' shader info log '").concat(e.getShaderInfoLog(i), `'
`).concat(function(a) {
    for (var o = a.split(`
`), u = 0; u < o.length; ++u) o[u] = u + 1 + ": " + o[u];
    return o.join(`
`);
  }(n))), new Error("Error compiling ".concat(r, " shader"));
  return i;
}
function Oq(e, t) {
  var r = _2(e, t);
  return { id: Rq(), attach: function(n) {
    e.attachShader(n, r);
  }, reset: function() {
    r = _2(e, t);
  }, destroy: function() {
    e.deleteShader(r);
  } };
}
function ir(e) {
  return typeof WebGL2RenderingContext < "u" && e instanceof WebGL2RenderingContext;
}
var Lq = `
attribute vec4 aPosition;

void main() {
    gl_Position = aPosition;
}`, kq = `
precision mediump float;
uniform vec4 uColor;
uniform sampler2D uTexture;

void main() {
    gl_FragColor = texture2D(uTexture, vec2(0.5, 0.5)) * uColor;
}`, zq = new Float32Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1]);
function P9(e, t) {
  var r = _2(e, { type: "vert", source: Lq }), n = _2(e, { type: "frag", source: kq });
  if (!r || !n) return !1;
  var i = db(e);
  e.attachShader(i, r), e.attachShader(i, n), e.linkProgram(i), e.useProgram(i);
  var a = e.getAttribLocation(i, "aPosition"), o = e.getUniformLocation(i, "uColor");
  if (!o) return Ir && console.log("error getting 'uColor' uniform location"), !1;
  var u = e.createBuffer();
  e.bindBuffer(e.ARRAY_BUFFER, u), e.bufferData(e.ARRAY_BUFFER, zq, e.STATIC_DRAW), e.enableVertexAttribArray(a), e.vertexAttribPointer(a, 2, e.FLOAT, !1, 0, 0);
  var s = e.createTexture(), c = new Uint8Array([255, 255, 255, 255]);
  e.bindTexture(e.TEXTURE_2D, s), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, 1, 1, 0, e.RGBA, e.UNSIGNED_BYTE, c);
  var l = e.createTexture();
  e.bindTexture(e.TEXTURE_2D, l), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, 1, 1, 0, e.RGBA, t, null), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.NEAREST);
  var d = e.createFramebuffer();
  if (e.bindFramebuffer(e.FRAMEBUFFER, d), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, l, 0), e.checkFramebufferStatus(e.FRAMEBUFFER) !== e.FRAMEBUFFER_COMPLETE) return Ir && console.log("error creating framebuffer for '".concat(t, "'")), !1;
  e.bindTexture(e.TEXTURE_2D, s), e.uniform4fv(o, [0, 10, 20, 1]), e.drawArrays(e.TRIANGLES, 0, 6), e.bindTexture(e.TEXTURE_2D, l), e.bindFramebuffer(e.FRAMEBUFFER, null), e.clearColor(1, 0, 0, 1), e.clear(e.COLOR_BUFFER_BIT), e.uniform4fv(o, [0, 0.1, 0.05, 1]), e.drawArrays(e.TRIANGLES, 0, 6);
  var f = new Uint8Array(4);
  if (e.readPixels(0, 0, 1, 1, e.RGBA, e.UNSIGNED_BYTE, f), f[0] !== 0 || f[1] < 248 || f[2] < 248 || f[3] < 254) return Ir && console.log("not able to actually render to '".concat(t, "' texture")), !1;
  if (t === e.FLOAT) {
    e.bindFramebuffer(e.FRAMEBUFFER, d);
    var m = new Float32Array(4);
    e.readPixels(0, 0, 1, 1, e.RGBA, e.FLOAT, m);
    var v = e.getError();
    if (v) return Ir && console.log("error reading float pixels: '".concat(bM(e, v), "'")), !1;
  }
  return !0;
}
var nf, vM = La();
function d_(e) {
  var t = e.checkFramebufferStatus(e.FRAMEBUFFER);
  if (t !== e.FRAMEBUFFER_COMPLETE) {
    var r = function(n, i) {
      switch (i) {
        case n.FRAMEBUFFER_COMPLETE:
          return "complete";
        case n.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
          return "incomplete attachment";
        case n.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
          return "incomplete missing attachment";
        case n.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
          return "incomplete dimensions";
        case n.FRAMEBUFFER_UNSUPPORTED:
          return "unsupported";
      }
      if (ir(n)) switch (i) {
        case n.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
          return "incomplete multisample";
        case n.RENDERBUFFER_SAMPLES:
          return "renderbuffer samples";
      }
      return "unknown error";
    }(e, t);
    throw new Error("Framebuffer status: ".concat(r));
  }
}
function B9(e) {
  var t = e.createFramebuffer();
  if (t === null) throw new Error("Could not create WebGL framebuffer");
  return t;
}
function F9(e) {
  var t = function(h) {
    if (ir(h)) return { drawArraysInstanced: h.drawArraysInstanced.bind(h), drawElementsInstanced: h.drawElementsInstanced.bind(h), vertexAttribDivisor: h.vertexAttribDivisor.bind(h), VERTEX_ATTRIB_ARRAY_DIVISOR: h.VERTEX_ATTRIB_ARRAY_DIVISOR };
    var y = h.getExtension("ANGLE_instanced_arrays");
    return y === null ? null : { drawArraysInstanced: y.drawArraysInstancedANGLE.bind(y), drawElementsInstanced: y.drawElementsInstancedANGLE.bind(y), vertexAttribDivisor: y.vertexAttribDivisorANGLE.bind(y), VERTEX_ATTRIB_ARRAY_DIVISOR: y.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE };
  }(e);
  if (t === null) throw new Error('Could not find support for "instanced_arrays"');
  var r = function(h) {
    return ir(h) ? {} : h.getExtension("OES_element_index_uint");
  }(e);
  if (r === null) throw new Error('Could not find support for "element_index_uint"');
  var n = function(h) {
    if (ir(h)) return { FRAGMENT_SHADER_DERIVATIVE_HINT: h.FRAGMENT_SHADER_DERIVATIVE_HINT };
    var y = h.getExtension("OES_standard_derivatives");
    return y === null ? null : { FRAGMENT_SHADER_DERIVATIVE_HINT: y.FRAGMENT_SHADER_DERIVATIVE_HINT_OES };
  }(e);
  if (n === null) throw new Error('Could not find support for "standard_derivatives"');
  var i = function(h) {
    return ir(h) ? {} : h.getExtension("OES_texture_float");
  }(e);
  Ir && i === null && console.log('Could not find support for "texture_float"');
  var a = function(h) {
    return h.getExtension("OES_texture_float_linear");
  }(e);
  Ir && a === null && console.log('Could not find support for "texture_float_linear"');
  var o = function(h) {
    if (ir(h)) return { HALF_FLOAT: h.HALF_FLOAT };
    var y = h.getExtension("OES_texture_half_float");
    return y === null ? null : { HALF_FLOAT: y.HALF_FLOAT_OES };
  }(e);
  Ir && o === null && console.log('Could not find support for "texture_half_float"');
  var u = function(h) {
    return h.getExtension("OES_texture_half_float_linear");
  }(e);
  Ir && u === null && console.log('Could not find support for "texture_half_float_linear"');
  var s = function(h) {
    if (ir(h)) return { UNSIGNED_INT_24_8: h.UNSIGNED_INT_24_8 };
    var y = h.getExtension("WEBGL_depth_texture");
    return y === null ? null : { UNSIGNED_INT_24_8: y.UNSIGNED_INT_24_8_WEBGL };
  }(e);
  Ir && s === null && console.log('Could not find support for "depth_texture"');
  var c = function(h) {
    if (ir(h)) return { MIN: h.MIN, MAX: h.MAX };
    var y = h.getExtension("EXT_blend_minmax");
    return y === null ? null : { MIN: y.MIN_EXT, MAX: y.MAX_EXT };
  }(e);
  Ir && c === null && console.log('Could not find support for "blend_minmax"');
  var l = function(h) {
    if (ir(h)) return { VERTEX_ARRAY_BINDING: h.VERTEX_ARRAY_BINDING, bindVertexArray: h.bindVertexArray.bind(h), createVertexArray: h.createVertexArray.bind(h), deleteVertexArray: h.deleteVertexArray.bind(h), isVertexArray: h.isVertexArray.bind(h) };
    var y = h.getExtension("OES_vertex_array_object");
    return y === null ? null : { VERTEX_ARRAY_BINDING: y.VERTEX_ARRAY_BINDING_OES, bindVertexArray: y.bindVertexArrayOES.bind(y), createVertexArray: y.createVertexArrayOES.bind(y), deleteVertexArray: y.deleteVertexArrayOES.bind(y), isVertexArray: y.isVertexArrayOES.bind(y) };
  }(e);
  Ir && l === null && console.log('Could not find support for "vertex_array_object"');
  var d = function(h) {
    return ir(h) ? {} : h.getExtension("EXT_frag_depth");
  }(e);
  Ir && d === null && console.log('Could not find support for "frag_depth"');
  var f = function(h) {
    if (ir(h)) return h.getExtension("EXT_color_buffer_float") === null ? null : (h.getExtension("EXT_float_blend"), { RGBA32F: h.RGBA32F });
    var y = h.getExtension("WEBGL_color_buffer_float");
    return y === null ? (h.getExtension("OES_texture_float"), P9(h, h.FLOAT) ? { RGBA32F: 34836 } : null) : (h.getExtension("EXT_float_blend"), { RGBA32F: y.RGBA32F_EXT });
  }(e);
  Ir && f === null && console.log('Could not find support for "color_buffer_float"');
  var m = function(h) {
    if (ir(h)) return h.getExtension("EXT_color_buffer_half_float") === null ? null : (h.getExtension("EXT_float_blend"), { RGBA16F: h.RGBA16F });
    var y = h.getExtension("EXT_color_buffer_half_float");
    return y === null ? (h.getExtension("OES_texture_half_float"), P9(h, 36193) ? { RGBA16F: 34842 } : null) : (h.getExtension("EXT_float_blend"), { RGBA16F: y.RGBA16F_EXT });
  }(e);
  Ir && m === null && console.log('Could not find support for "color_buffer_half_float"');
  var v = function(h) {
    if (ir(h)) return { drawBuffers: h.drawBuffers.bind(h), COLOR_ATTACHMENT0: h.COLOR_ATTACHMENT0, COLOR_ATTACHMENT1: h.COLOR_ATTACHMENT1, COLOR_ATTACHMENT2: h.COLOR_ATTACHMENT2, COLOR_ATTACHMENT3: h.COLOR_ATTACHMENT3, COLOR_ATTACHMENT4: h.COLOR_ATTACHMENT4, COLOR_ATTACHMENT5: h.COLOR_ATTACHMENT5, COLOR_ATTACHMENT6: h.COLOR_ATTACHMENT6, COLOR_ATTACHMENT7: h.COLOR_ATTACHMENT7, DRAW_BUFFER0: h.DRAW_BUFFER0, DRAW_BUFFER1: h.DRAW_BUFFER1, DRAW_BUFFER2: h.DRAW_BUFFER2, DRAW_BUFFER3: h.DRAW_BUFFER3, DRAW_BUFFER4: h.DRAW_BUFFER4, DRAW_BUFFER5: h.DRAW_BUFFER5, DRAW_BUFFER6: h.DRAW_BUFFER6, DRAW_BUFFER7: h.DRAW_BUFFER7, MAX_COLOR_ATTACHMENTS: h.MAX_COLOR_ATTACHMENTS, MAX_DRAW_BUFFERS: h.MAX_DRAW_BUFFERS };
    var y = h.getExtension("WEBGL_draw_buffers");
    return y === null ? null : { drawBuffers: y.drawBuffersWEBGL.bind(y), COLOR_ATTACHMENT0: y.COLOR_ATTACHMENT0_WEBGL, COLOR_ATTACHMENT1: y.COLOR_ATTACHMENT1_WEBGL, COLOR_ATTACHMENT2: y.COLOR_ATTACHMENT2_WEBGL, COLOR_ATTACHMENT3: y.COLOR_ATTACHMENT3_WEBGL, COLOR_ATTACHMENT4: y.COLOR_ATTACHMENT4_WEBGL, COLOR_ATTACHMENT5: y.COLOR_ATTACHMENT5_WEBGL, COLOR_ATTACHMENT6: y.COLOR_ATTACHMENT6_WEBGL, COLOR_ATTACHMENT7: y.COLOR_ATTACHMENT7_WEBGL, DRAW_BUFFER0: y.DRAW_BUFFER0_WEBGL, DRAW_BUFFER1: y.DRAW_BUFFER1_WEBGL, DRAW_BUFFER2: y.DRAW_BUFFER2_WEBGL, DRAW_BUFFER3: y.DRAW_BUFFER3_WEBGL, DRAW_BUFFER4: y.DRAW_BUFFER4_WEBGL, DRAW_BUFFER5: y.DRAW_BUFFER5_WEBGL, DRAW_BUFFER6: y.DRAW_BUFFER6_WEBGL, DRAW_BUFFER7: y.DRAW_BUFFER7_WEBGL, MAX_COLOR_ATTACHMENTS: y.MAX_COLOR_ATTACHMENTS_WEBGL, MAX_DRAW_BUFFERS: y.MAX_DRAW_BUFFERS_WEBGL };
  }(e);
  Ir && v === null && console.log('Could not find support for "draw_buffers"');
  var p = function(h) {
    return ir(h) ? {} : h.getExtension("EXT_shader_texture_lod");
  }(e);
  Ir && p === null && console.log('Could not find support for "shader_texture_lod"');
  var g = function(h) {
    if (ir(h)) return { FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: h.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, SRGB8_ALPHA8: h.SRGB8_ALPHA8, SRGB8: h.SRGB8, SRGB: h.SRGB };
    var y = h.getExtension("EXT_sRGB");
    return y === null ? null : { FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: y.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT, SRGB8_ALPHA8: y.SRGB8_ALPHA8_EXT, SRGB8: y.SRGB_ALPHA_EXT, SRGB: y.SRGB_EXT };
  }(e);
  return Ir && g === null && console.log('Could not find support for "sRGB"'), { instancedArrays: t, standardDerivatives: n, textureFloat: i, textureFloatLinear: a, textureHalfFloat: o, textureHalfFloatLinear: u, elementIndexUint: r, depthTexture: s, blendMinMax: c, vertexArrayObject: l, fragDepth: d, colorBufferFloat: f, colorBufferHalfFloat: m, drawBuffers: v, shaderTextureLod: p, sRGB: g };
}
function N9(e, t, r) {
  var n = /* @__PURE__ */ new Map();
  return { get: function(i) {
    var a, o, u = e(i), s = n.get(u);
    return s || (a = t(i), o === void 0 && (o = 0), s = { value: a, usageCount: o }, n.set(u, s)), s.usageCount += 1, function(c) {
      return { free: function() {
        c.usageCount -= 1;
      }, value: c.value };
    }(s);
  }, clear: function() {
    n.forEach(function(i, a) {
      i.usageCount <= 0 && (i.usageCount < 0 && console.warn("Reference usageCount below zero."), r(i.value), n.delete(a));
    });
  }, get count() {
    return n.size;
  }, dispose: function() {
    n.forEach(function(i) {
      return r(i.value);
    }), n.clear();
  } };
}
(function(e) {
  e.create = function(t, r, n) {
    return { array: t, width: r, height: n };
  }, e.flipY = function(t) {
    for (var r = t.array, n = t.width, i = t.height, a = 4 * n, o = 0, u = i / 2; o < u; ++o) for (var s = 0, c = a; s < c; ++s) {
      var l = o * a + s, d = (i - o - 1) * a + s, f = r[l];
      r[l] = r[d], r[d] = f;
    }
    return t;
  }, e.divideByAlpha = function(t) {
    for (var r = t.array, n = r instanceof Uint8Array ? 255 : 1, i = 0, a = r.length; i < a; i += 4) {
      var o = r[i + 3] / n;
      o !== 0 ? (r[i] /= o, r[i + 1] /= o, r[i + 2] /= o) : (r[i] = 0, r[i + 1] = 0, r[i + 2] = 0);
    }
    return t;
  };
})(nf || (nf = {}));
var Gq = La();
function R9(e) {
  var t = e.createRenderbuffer();
  if (t === null) throw new Error("Could not create WebGL renderbuffer");
  return t;
}
function Vq(e, t, r, n, i) {
  var a = R9(e), o = function() {
    return e.bindRenderbuffer(e.RENDERBUFFER, a);
  }, u = function(d, f) {
    switch (f) {
      case "depth16":
        return d.DEPTH_COMPONENT16;
      case "stencil8":
        return d.STENCIL_INDEX8;
      case "rgba4":
        return d.RGBA4;
      case "depth-stencil":
        return d.DEPTH_STENCIL;
      case "depth32f":
        if (ir(d)) return d.DEPTH_COMPONENT32F;
        throw new Error("WebGL2 needed for `depth32f` renderbuffer format");
    }
  }(e, t), s = function(d, f) {
    switch (f) {
      case "depth":
        return d.DEPTH_ATTACHMENT;
      case "stencil":
        return d.STENCIL_ATTACHMENT;
      case "depth-stencil":
        return d.DEPTH_STENCIL_ATTACHMENT;
      case "color0":
        return d.COLOR_ATTACHMENT0;
    }
  }(e, r);
  function c() {
    o(), e.renderbufferStorage(e.RENDERBUFFER, u, n, i);
  }
  c();
  var l = !1;
  return { id: Gq(), bind: o, attachFramebuffer: function(d) {
    d.bind(), o(), e.framebufferRenderbuffer(e.FRAMEBUFFER, s, e.RENDERBUFFER, a), Ir && d_(e);
  }, setSize: function(d, f) {
    n = d, i = f, c();
  }, reset: function() {
    a = R9(e), c();
  }, destroy: function() {
    l || (e.deleteRenderbuffer(a), l = !0);
  } };
}
var gM = La();
function O9(e, t, r) {
  switch (t) {
    case "alpha":
      return ir(e) && r === "float" ? e.RED : ir(e) && r === "int" ? e.RED_INTEGER : e.ALPHA;
    case "rgb":
      return ir(e) && r === "int" ? e.RGB_INTEGER : e.RGB;
    case "rgba":
      return ir(e) && r === "int" ? e.RGBA_INTEGER : e.RGBA;
    case "depth":
      return e.DEPTH_COMPONENT;
  }
}
function L9(e, t) {
  switch (t) {
    case "nearest":
      return e.NEAREST;
    case "linear":
      return e.LINEAR;
  }
}
function zh(e, t, r) {
  switch (r) {
    case "depth":
      return e.DEPTH_ATTACHMENT;
    case "stencil":
      return e.STENCIL_ATTACHMENT;
    case "color0":
    case 0:
      return e.COLOR_ATTACHMENT0;
  }
  if (t.drawBuffers) switch (r) {
    case "color1":
    case 1:
      return t.drawBuffers.COLOR_ATTACHMENT1;
    case "color2":
    case 2:
      return t.drawBuffers.COLOR_ATTACHMENT2;
    case "color3":
    case 3:
      return t.drawBuffers.COLOR_ATTACHMENT3;
    case "color4":
    case 4:
      return t.drawBuffers.COLOR_ATTACHMENT4;
    case "color5":
    case 5:
      return t.drawBuffers.COLOR_ATTACHMENT5;
    case "color6":
    case 6:
      return t.drawBuffers.COLOR_ATTACHMENT6;
    case "color7":
    case 7:
      return t.drawBuffers.COLOR_ATTACHMENT7;
  }
  throw new Error("unknown texture attachment");
}
function k9(e) {
  return typeof HTMLImageElement < "u" && e instanceof HTMLImageElement;
}
function z9(e, t, r) {
  return t === r.TEXTURE_3D;
}
function G9(e) {
  var t = e.createTexture();
  if (t === null) throw new Error("Could not create WebGL texture");
  return t;
}
function fb(e, t, r, n, i, a) {
  var o = gM(), u = G9(e);
  if (r.endsWith("float32") && i !== "float" || r.endsWith("float16") && i !== "fp16" || r.endsWith("uint8") && i !== "ubyte" || r.endsWith("int32") && i !== "int" || r.endsWith("depth") && i !== "ushort" && i !== "float") throw new Error("texture kind '".concat(r, "' and type '").concat(i, "' are incompatible"));
  var s = function(b, _) {
    switch (_) {
      case "image-uint8":
      case "image-float32":
      case "image-float16":
      case "image-depth":
        return b.TEXTURE_2D;
    }
    if (ir(b)) switch (_) {
      case "image-int32":
        return b.TEXTURE_2D;
      case "volume-uint8":
      case "volume-float32":
      case "volume-float16":
        return b.TEXTURE_3D;
    }
    throw new Error("unknown texture kind '".concat(_, "'"));
  }(e, r), c = L9(e, a), l = O9(e, n, i), d = function(b, _, S) {
    if (ir(b)) switch (_) {
      case "alpha":
        switch (S) {
          case "ubyte":
            return b.ALPHA;
          case "float":
            return b.R32F;
          case "fp16":
            return b.R16F;
          case "int":
            return b.R32I;
        }
      case "rgb":
        switch (S) {
          case "ubyte":
            return b.RGB;
          case "float":
            return b.RGB32F;
          case "fp16":
            return b.RGB16F;
          case "int":
            return b.RGB32I;
        }
      case "rgba":
        switch (S) {
          case "ubyte":
            return b.RGBA;
          case "float":
            return b.RGBA32F;
          case "fp16":
            return b.RGBA16F;
          case "int":
            return b.RGBA32I;
        }
      case "depth":
        switch (S) {
          case "ushort":
            return b.DEPTH_COMPONENT16;
          case "float":
            return b.DEPTH_COMPONENT32F;
        }
    }
    return O9(b, _, S);
  }(e, n, i), f = function(b, _, S) {
    switch (S) {
      case "ubyte":
        return b.UNSIGNED_BYTE;
      case "ushort":
        return b.UNSIGNED_SHORT;
      case "float":
        return b.FLOAT;
      case "fp16":
        if (_.textureHalfFloat) return _.textureHalfFloat.HALF_FLOAT;
        throw new Error('extension "texture_half_float" unavailable');
      case "int":
        if (ir(b)) return b.INT;
        throw new Error('texture type "int" requires webgl2');
    }
  }(e, t, i);
  function m() {
    e.bindTexture(s, u), e.texParameteri(s, e.TEXTURE_MAG_FILTER, c), e.texParameteri(s, e.TEXTURE_MIN_FILTER, c), e.texParameteri(s, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(s, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), e.bindTexture(s, null);
  }
  m();
  var v, p = 0, g = 0, h = 0, y = !1;
  function x(b, _, S) {
    if (b === 0 || _ === 0 || ir(e) && s === e.TEXTURE_3D && S === 0) throw new Error("empty textures are not allowed");
    if (p !== b || g !== _ || h !== (S || 0)) if (p = b, g = _, h = S || 0, e.bindTexture(s, u), s === e.TEXTURE_2D) e.texImage2D(s, 0, d, p, g, 0, l, f, null);
    else {
      if (!ir(e) || s !== e.TEXTURE_3D || h === void 0) throw new Error("unknown texture target");
      e.texImage3D(s, 0, d, p, g, h, 0, l, f, null);
    }
  }
  function A(b, _) {
    if (_ === void 0 && (_ = !1), b.width === 0 || b.height === 0 || !k9(b) && ir(e) && z9(0, s, e) && b.depth === 0) throw new Error("empty textures are not allowed");
    if (e.bindTexture(s, u), e.pixelStorei(e.UNPACK_ALIGNMENT, 1), e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL, e.NONE), e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), k9(b)) p = b.width, g = b.height, e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !1), e.bindTexture(e.TEXTURE_2D, u), e.texImage2D(e.TEXTURE_2D, 0, d, l, f, b);
    else if (function(D, I, M) {
      return I === M.TEXTURE_2D;
    }(0, s, e)) {
      var S = b.filter ? L9(e, b.filter) : c;
      e.texParameteri(s, e.TEXTURE_MAG_FILTER, S), e.texParameteri(s, e.TEXTURE_MIN_FILTER, S), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !!b.flipY), _ ? e.texSubImage2D(s, 0, 0, 0, b.width, b.height, l, f, b.array) : (p = b.width, g = b.height, e.texImage2D(s, 0, d, p, g, 0, l, f, b.array));
    } else {
      if (!ir(e) || !z9(0, s, e)) throw new Error("unknown texture target");
      e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !1), _ ? e.texSubImage3D(s, 0, 0, 0, 0, b.width, b.height, b.depth, l, f, b.array) : (p = b.width, g = b.height, h = b.depth, e.texImage3D(s, 0, d, p, g, h, 0, l, f, b.array));
    }
    e.bindTexture(s, null), v = b;
  }
  return x(1, 1, ir(e) && s === e.TEXTURE_3D ? 1 : 0), { id: o, target: s, format: l, internalFormat: d, type: f, filter: c, getWidth: function() {
    return p;
  }, getHeight: function() {
    return g;
  }, getDepth: function() {
    return h;
  }, getByteCount: function() {
    return function(b, _, S, D, I) {
      var M = function(F) {
        switch (F) {
          case "alpha":
            return 1;
          case "rgb":
            return 3;
          case "rgba":
          case "depth":
            return 4;
        }
      }(b) * function(F) {
        switch (F) {
          case "ubyte":
            return 1;
          case "ushort":
          case "fp16":
            return 2;
          case "float":
          case "int":
            return 4;
        }
      }(_);
      return M * S * D * (I || 1);
    }(n, i, p, g, h);
  }, define: x, load: A, bind: function(b) {
    e.activeTexture(e.TEXTURE0 + b), e.bindTexture(s, u);
  }, unbind: function(b) {
    e.activeTexture(e.TEXTURE0 + b), e.bindTexture(s, null);
  }, attachFramebuffer: function(b, _, S) {
    if (b.bind(), s === e.TEXTURE_2D) e.framebufferTexture2D(e.FRAMEBUFFER, zh(e, t, _), e.TEXTURE_2D, u, 0);
    else {
      if (!ir(e) || s !== e.TEXTURE_3D) throw new Error("unknown/unsupported texture target");
      if (S === void 0) throw new Error("need `layer` to attach 3D texture");
      e.framebufferTextureLayer(e.FRAMEBUFFER, zh(e, t, _), u, 0, S);
    }
  }, detachFramebuffer: function(b, _) {
    if (b.bind(), s === e.TEXTURE_2D) e.framebufferTexture2D(e.FRAMEBUFFER, zh(e, t, _), e.TEXTURE_2D, null, 0);
    else {
      if (!ir(e) || s !== e.TEXTURE_3D) throw new Error("unknown texture target");
      e.framebufferTextureLayer(e.FRAMEBUFFER, zh(e, t, _), null, 0, 0);
    }
  }, reset: function() {
    u = G9(e), m();
    var b = [p, g, h];
    p = 0, g = 0, h = 0, x(b[0], b[1], b[2]), v && A(v);
  }, destroy: function() {
    y || (e.deleteTexture(u), y = !0);
  } };
}
function V9(e, t, r) {
  var n = new Image();
  n.onload = function() {
    r.load(n), k.update(t, r);
  }, n.src = e;
}
function go(e) {
  var t, r = (t = e == null ? void 0 : e.TEXTURE_2D) !== null && t !== void 0 ? t : 3553;
  return { id: gM(), target: r, format: 0, internalFormat: 0, type: 0, filter: 0, getWidth: function() {
    return 0;
  }, getHeight: function() {
    return 0;
  }, getDepth: function() {
    return 0;
  }, getByteCount: function() {
    return 0;
  }, define: function() {
  }, load: function() {
  }, bind: function(n) {
    e && (e.activeTexture(e.TEXTURE0 + n), e.bindTexture(r, null));
  }, unbind: function(n) {
    e && (e.activeTexture(e.TEXTURE0 + n), e.bindTexture(r, null));
  }, attachFramebuffer: function() {
  }, detachFramebuffer: function() {
  }, reset: function() {
  }, destroy: function() {
  } };
}
var Uq = La();
function U9(e) {
  var t = e.vertexArrayObject;
  if (!t) throw new Error("VertexArrayObject not supported");
  var r = t.createVertexArray();
  if (!r) throw new Error("Could not create WebGL vertex array");
  return r;
}
function H9(e) {
  var t = e.vertexArrayObject;
  if (t === null) throw new Error("VertexArrayObject not supported");
  return t;
}
function q9(e) {
  return R(R({}, e.value), { destroy: function() {
    e.free();
  } });
}
function Hq(e, t, r, n) {
  var i = { attribute: /* @__PURE__ */ new Set(), elements: /* @__PURE__ */ new Set(), framebuffer: /* @__PURE__ */ new Set(), program: /* @__PURE__ */ new Set(), renderbuffer: /* @__PURE__ */ new Set(), shader: /* @__PURE__ */ new Set(), texture: /* @__PURE__ */ new Set(), vertexArray: /* @__PURE__ */ new Set() };
  function a(c, l) {
    return i[c].add(l), r.resourceCounts[c] += 1, R(R({}, l), { destroy: function() {
      l.destroy(), i[c].delete(l), r.resourceCounts[c] -= 1;
    } });
  }
  var o = N9(function(c) {
    return JSON.stringify(c);
  }, function(c) {
    return a("shader", Oq(e, c));
  }, function(c) {
    c.destroy();
  });
  function u(c, l) {
    return q9(o.get({ type: c, source: l }));
  }
  var s = N9(function(c) {
    var l, d = [c.shaderCode.id], f = ((l = c.defineValues.dRenderVariant) === null || l === void 0 ? void 0 : l.ref.value) || "";
    return Object.keys(c.defineValues).forEach(function(m) {
      var v, p;
      !((p = (v = c.shaderCode).ignoreDefine) === null || p === void 0) && p.call(v, m, f, c.defineValues) || d.push(J5(m), function(g) {
        return typeof g == "boolean" ? g ? 1 : 0 : typeof g == "number" ? 1e4 * g : J5(g);
      }(c.defineValues[m].ref.value));
    }), Ra(d).toString();
  }, function(c) {
    return a("program", Nq(e, t, n, u, c));
  }, function(c) {
    c.destroy();
  });
  return { attribute: function(c, l, d, f) {
    return a("attribute", function(m, v, p, g, h, y, x) {
      x === void 0 && (x = "dynamic");
      var A = p.instancedArrays, b = T9(m, g, x, "attribute"), _ = b._bufferType, S = b._dataType, D = b._bpe;
      return R(R({}, b), { bind: function(I) {
        if (m.bindBuffer(_, b.getBuffer()), h === 16) for (var M = 0; M < 4; ++M) v.enableVertexAttrib(I + M), m.vertexAttribPointer(I + M, 4, S, !1, 16 * D, 4 * M * D), A.vertexAttribDivisor(I + M, y);
        else v.enableVertexAttrib(I), m.vertexAttribPointer(I, h, S, !1, 0, 0), A.vertexAttribDivisor(I, y);
      } });
    }(e, t, n, c, l, d, f));
  }, elements: function(c, l) {
    return a("elements", function(d, f, m) {
      m === void 0 && (m = "static");
      var v = T9(d, f, m, "elements");
      return R(R({}, v), { bind: function() {
        d.bindBuffer(d.ELEMENT_ARRAY_BUFFER, v.getBuffer());
      } });
    }(e, c, l));
  }, framebuffer: function() {
    return a("framebuffer", function(c) {
      var l = B9(c), d = !1;
      return { id: vM(), bind: function() {
        return c.bindFramebuffer(c.FRAMEBUFFER, l);
      }, reset: function() {
        l = B9(c);
      }, destroy: function() {
        d || (c.deleteFramebuffer(l), d = !0);
      } };
    }(e));
  }, program: function(c, l, d) {
    return q9(s.get({ defineValues: c, shaderCode: l, schema: d }));
  }, renderbuffer: function(c, l, d, f) {
    return a("renderbuffer", Vq(e, c, l, d, f));
  }, shader: u, texture: function(c, l, d, f) {
    return a("texture", fb(e, n, c, l, d, f));
  }, vertexArray: function(c, l, d) {
    return a("vertexArray", function(f, m, v, p, g) {
      var h = Uq(), y = U9(m), x = H9(m);
      function A() {
        x.bindVertexArray(y), g && g.bind(), v.bindAttributes(p), x.bindVertexArray(null);
      }
      A();
      var b = !1;
      return { id: h, bind: function() {
        x.bindVertexArray(y);
      }, update: A, reset: function() {
        y = U9(m), x = H9(m), A();
      }, destroy: function() {
        b || (g && (x.bindVertexArray(y), f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, null)), x.deleteVertexArray(y), b = !0);
      } };
    }(e, n, c, l, d));
  }, getByteCounts: function() {
    var c = 0;
    i.texture.forEach(function(f) {
      c += f.getByteCount();
    });
    var l = 0;
    i.attribute.forEach(function(f) {
      l += 4 * f.length;
    });
    var d = 0;
    return i.elements.forEach(function(f) {
      d += 4 * f.length;
    }), { texture: c, attribute: l, elements: d };
  }, reset: function() {
    i.attribute.forEach(function(c) {
      return c.reset();
    }), i.elements.forEach(function(c) {
      return c.reset();
    }), i.framebuffer.forEach(function(c) {
      return c.reset();
    }), i.renderbuffer.forEach(function(c) {
      return c.reset();
    }), i.shader.forEach(function(c) {
      return c.reset();
    }), i.program.forEach(function(c) {
      return c.reset();
    }), i.vertexArray.forEach(function(c) {
      return c.reset();
    }), i.texture.forEach(function(c) {
      return c.reset();
    });
  }, destroy: function() {
    i.attribute.forEach(function(c) {
      return c.destroy();
    }), i.elements.forEach(function(c) {
      return c.destroy();
    }), i.framebuffer.forEach(function(c) {
      return c.destroy();
    }), i.renderbuffer.forEach(function(c) {
      return c.destroy();
    }), i.shader.forEach(function(c) {
      return c.destroy();
    }), i.program.forEach(function(c) {
      return c.destroy();
    }), i.vertexArray.forEach(function(c) {
      return c.destroy();
    }), i.texture.forEach(function(c) {
      return c.destroy();
    }), o.clear(), s.clear();
  } };
}
var yM = La();
function bM(e, t) {
  switch (t) {
    case e.NO_ERROR:
      return "no error";
    case e.INVALID_ENUM:
      return "invalid enum";
    case e.INVALID_VALUE:
      return "invalid value";
    case e.INVALID_OPERATION:
      return "invalid operation";
    case e.INVALID_FRAMEBUFFER_OPERATION:
      return "invalid framebuffer operation";
    case e.OUT_OF_MEMORY:
      return "out of memory";
    case e.CONTEXT_LOST_WEBGL:
      return "context lost";
  }
  return "unknown error";
}
function _M(e) {
  var t = e.getError();
  if (t !== e.NO_ERROR) throw new Error("WebGL error: '".concat(bM(e, t), "'"));
}
function Gh(e) {
  e.bindFramebuffer(e.FRAMEBUFFER, null);
}
var xM = new Uint8Array(4);
function AM(e, t, r) {
  e.getSyncParameter(t, e.SYNC_STATUS) === e.SIGNALED ? (e.deleteSync(t), r()) : c_.setImmediate(AM, e, t, r);
}
function K9(e, t) {
  var r = e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE, 0);
  r ? c_.setImmediate(AM, e, r, t) : (console.warn("Could not create a WebGLSync object"), e.readPixels(0, 0, 1, 1, e.RGBA, e.UNSIGNED_BYTE, xM), t());
}
var x2, X9, j9 = !1;
function Y9(e) {
  e.bindFramebuffer(e.FRAMEBUFFER, null), e.readPixels(0, 0, 1, 1, e.RGBA, e.UNSIGNED_BYTE, xM);
}
function Fy(e, t, r, n, i, a) {
  if (Ir && d_(e), a instanceof Uint8Array) e.readPixels(t, r, n, i, e.RGBA, e.UNSIGNED_BYTE, a);
  else if (a instanceof Float32Array) e.readPixels(t, r, n, i, e.RGBA, e.FLOAT, a);
  else {
    if (!(a instanceof Int32Array && ir(e))) throw new Error("unsupported readPixels buffer type");
    e.readPixels(t, r, n, i, e.RGBA_INTEGER, e.INT, a);
  }
  Ir && _M(e);
}
function qq(e, t) {
  var r = this;
  t === void 0 && (t = {});
  var n = F9(e), i = function(h) {
    var y = {}, x = h.getParameter(h.FRONT_FACE), A = h.getParameter(h.CULL_FACE_MODE), b = h.getParameter(h.DEPTH_WRITEMASK), _ = h.getParameter(h.COLOR_WRITEMASK), S = h.getParameter(h.COLOR_CLEAR_VALUE), D = h.getParameter(h.BLEND_SRC_RGB), I = h.getParameter(h.BLEND_DST_RGB), M = h.getParameter(h.BLEND_SRC_ALPHA), F = h.getParameter(h.BLEND_DST_ALPHA), P = h.getParameter(h.BLEND_EQUATION_RGB), E = h.getParameter(h.BLEND_EQUATION_ALPHA), B = h.getParameter(h.MAX_VERTEX_ATTRIBS), N = [], O = function() {
      for (var z = 0; z < B; ++z) N[z] = 0;
    };
    return O(), { currentProgramId: -1, currentMaterialId: -1, currentRenderItemId: -1, enable: function(z) {
      y[z] !== !0 && (h.enable(z), y[z] = !0);
    }, disable: function(z) {
      y[z] !== !1 && (h.disable(z), y[z] = !1);
    }, frontFace: function(z) {
      z !== x && (h.frontFace(z), x = z);
    }, cullFace: function(z) {
      z !== A && (h.cullFace(z), A = z);
    }, depthMask: function(z) {
      z !== b && (h.depthMask(z), b = z);
    }, colorMask: function(z, V, U, H) {
      z === _[0] && V === _[1] && U === _[2] && H === _[3] || (h.colorMask(z, V, U, H), _[0] = z, _[1] = V, _[2] = U, _[3] = H);
    }, clearColor: function(z, V, U, H) {
      z === S[0] && V === S[1] && U === S[2] && H === S[3] || (h.clearColor(z, V, U, H), S[0] = z, S[1] = V, S[2] = U, S[3] = H);
    }, blendFunc: function(z, V) {
      z === D && V === I && z === M && V === F || (h.blendFunc(z, V), D = z, I = V, M = z, F = V);
    }, blendFuncSeparate: function(z, V, U, H) {
      z === D && V === I && U === M && H === F || (h.blendFuncSeparate(z, V, U, H), D = z, I = V, M = U, F = H);
    }, blendEquation: function(z) {
      z === P && z === E || (h.blendEquation(z), P = z, E = z);
    }, blendEquationSeparate: function(z, V) {
      z === P && V === E || (h.blendEquationSeparate(z, V), P = z, E = V);
    }, enableVertexAttrib: function(z) {
      h.enableVertexAttribArray(z), N[z] = 1;
    }, clearVertexAttribsState: O, disableUnusedVertexAttribs: function() {
      for (var z = 0; z < B; ++z) N[z] === 0 && h.disableVertexAttribArray(z);
    }, reset: function() {
      y = {}, x = h.getParameter(h.FRONT_FACE), A = h.getParameter(h.CULL_FACE_MODE), b = h.getParameter(h.DEPTH_WRITEMASK), _ = h.getParameter(h.COLOR_WRITEMASK), S = h.getParameter(h.COLOR_CLEAR_VALUE), D = h.getParameter(h.BLEND_SRC_RGB), I = h.getParameter(h.BLEND_DST_RGB), M = h.getParameter(h.BLEND_SRC_ALPHA), F = h.getParameter(h.BLEND_DST_ALPHA), P = h.getParameter(h.BLEND_EQUATION_RGB), E = h.getParameter(h.BLEND_EQUATION_ALPHA), B = h.getParameter(h.MAX_VERTEX_ATTRIBS), N.length = 0;
      for (var z = 0; z < B; ++z) N[z] = 0;
    } };
  }(e), a = { resourceCounts: { attribute: 0, elements: 0, framebuffer: 0, program: 0, renderbuffer: 0, shader: 0, texture: 0, vertexArray: 0 }, drawCount: 0, instanceCount: 0, instancedDrawCount: 0 }, o = Hq(e, i, a, n), u = { maxTextureSize: e.getParameter(e.MAX_TEXTURE_SIZE), max3dTextureSize: ir(e) ? e.getParameter(e.MAX_3D_TEXTURE_SIZE) : 0, maxRenderbufferSize: e.getParameter(e.MAX_RENDERBUFFER_SIZE), maxDrawBuffers: n.drawBuffers ? e.getParameter(n.drawBuffers.MAX_DRAW_BUFFERS) : 0, maxTextureImageUnits: e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS), maxVertexTextureImageUnits: e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS) };
  if (u.maxVertexTextureImageUnits < 8) throw new Error('Need "MAX_VERTEX_TEXTURE_IMAGE_UNITS" >= 8');
  var s, c = !1, l = new Ol(0);
  if (ir(e)) {
    var d = e.createBuffer(), f = void 0, m = void 0, v = !1, p = function() {
      e.bindBuffer(e.PIXEL_PACK_BUFFER, d), e.getBufferSubData(e.PIXEL_PACK_BUFFER, 0, f), e.bindBuffer(e.PIXEL_PACK_BUFFER, null), v = !1, m(), m = void 0, f = void 0;
    };
    s = function(h, y, x, A, b) {
      return new Promise(function(_, S) {
        v ? S("Can not call multiple readPixelsAsync at the same time") : (v = !0, e.bindBuffer(e.PIXEL_PACK_BUFFER, d), e.bufferData(e.PIXEL_PACK_BUFFER, x * A * 4, e.STREAM_READ), e.readPixels(h, y, x, A, e.RGBA, e.UNSIGNED_BYTE, 0), e.bindBuffer(e.PIXEL_PACK_BUFFER, null), m = _, f = b, K9(e, p));
      });
    };
  } else s = function(h, y, x, A, b) {
    return _e(r, 0, void 0, function() {
      return ye(this, function(_) {
        return Fy(e, h, y, x, A, b), [2];
      });
    });
  };
  var g = /* @__PURE__ */ new Set();
  return { gl: e, isWebGL2: ir(e), get pixelRatio() {
    return (typeof window < "u" && window.devicePixelRatio || 1) * (t.pixelScale || 1);
  }, extensions: n, state: i, stats: a, resources: o, get maxTextureSize() {
    return u.maxTextureSize;
  }, get max3dTextureSize() {
    return u.max3dTextureSize;
  }, get maxRenderbufferSize() {
    return u.maxRenderbufferSize;
  }, get maxDrawBuffers() {
    return u.maxDrawBuffers;
  }, get maxTextureImageUnits() {
    return u.maxTextureImageUnits;
  }, namedComputeRenderables: /* @__PURE__ */ Object.create(null), namedFramebuffers: /* @__PURE__ */ Object.create(null), namedTextures: /* @__PURE__ */ Object.create(null), get isContextLost() {
    return c || e.isContextLost();
  }, contextRestored: l, setContextLost: function() {
    c = !0;
  }, handleContextRestored: function(h) {
    Object.assign(n, F9(e)), i.reset(), i.currentMaterialId = -1, i.currentProgramId = -1, i.currentRenderItemId = -1, o.reset(), g.forEach(function(y) {
      return y.reset();
    }), h == null || h(), c = !1, l.next(li());
  }, createRenderTarget: function(h, y, x, A, b) {
    var _ = function(S, D, I, M, F, P, E) {
      F === void 0 && (F = !0), P === void 0 && (P = "uint8"), E === void 0 && (E = "nearest");
      var B = D.framebuffer(), N = P === "fp16" ? D.texture("image-float16", "rgba", "fp16", E) : P === "float32" ? D.texture("image-float32", "rgba", "float", E) : D.texture("image-uint8", "rgba", "ubyte", E), O = F ? ir(S) ? D.renderbuffer("depth32f", "depth", I, M) : D.renderbuffer("depth16", "depth", I, M) : null;
      function z() {
        N.define(I, M), N.attachFramebuffer(B, "color0"), O && O.attachFramebuffer(B);
      }
      z();
      var V = !1;
      return { id: yM(), texture: N, framebuffer: B, getWidth: function() {
        return I;
      }, getHeight: function() {
        return M;
      }, bind: function() {
        B.bind();
      }, setSize: function(U, H) {
        I === U && M === H || (I = U, M = H, N.define(I, M), O && O.setSize(I, M));
      }, reset: function() {
        z();
      }, destroy: function() {
        V || (N.destroy(), B.destroy(), O && O.destroy(), V = !0);
      } };
    }(e, o, h, y, x, A, b);
    return g.add(_), R(R({}, _), { destroy: function() {
      _.destroy(), g.delete(_);
    } });
  }, unbindFramebuffer: function() {
    return Gh(e);
  }, readPixels: function(h, y, x, A, b) {
    Fy(e, h, y, x, A, b);
  }, readPixelsAsync: s, waitForGpuCommandsComplete: function() {
    return function(h) {
      return new Promise(function(y) {
        ir(h) ? K9(h, y) : (j9 || (console.info("Sync object not supported in WebGL"), j9 = !0), Y9(h), y());
      });
    }(e);
  }, waitForGpuCommandsCompleteSync: function() {
    return Y9(e);
  }, getDrawingBufferPixelData: function() {
    return function(h) {
      var y = h.drawingBufferWidth, x = h.drawingBufferHeight, A = new Uint8Array(y * x * 4);
      return Gh(h), h.viewport(0, 0, y, x), Fy(h, 0, 0, y, x, A), nf.flipY(nf.create(A, y, x));
    }(e);
  }, clear: function(h, y, x, A) {
    Gh(e), i.enable(e.SCISSOR_TEST), i.depthMask(!0), i.colorMask(!0, !0, !0, !0), i.clearColor(h, y, x, A), e.viewport(0, 0, e.drawingBufferWidth, e.drawingBufferHeight), e.scissor(0, 0, e.drawingBufferWidth, e.drawingBufferHeight), e.clear(e.COLOR_BUFFER_BIT | e.DEPTH_BUFFER_BIT);
  }, destroy: function(h) {
    var y, x;
    o.destroy(), function(A) {
      for (var b = A.getParameter(A.MAX_TEXTURE_IMAGE_UNITS), _ = 0; _ < b; ++_) A.activeTexture(A.TEXTURE0 + _), A.bindTexture(A.TEXTURE_2D, null), A.bindTexture(A.TEXTURE_CUBE_MAP, null), ir(A) && (A.bindTexture(A.TEXTURE_2D_ARRAY, null), A.bindTexture(A.TEXTURE_3D, null));
      var S = A.createBuffer();
      A.bindBuffer(A.ARRAY_BUFFER, S);
      var D = A.getParameter(A.MAX_VERTEX_ATTRIBS);
      for (_ = 0; _ < D; ++_) A.vertexAttribPointer(_, 1, A.FLOAT, !1, 0, 0);
      A.bindBuffer(A.ARRAY_BUFFER, null), A.bindBuffer(A.ELEMENT_ARRAY_BUFFER, null), A.bindRenderbuffer(A.RENDERBUFFER, null), Gh(A);
    }(e), h != null && h.doNotForceWebGLContextLoss || ((y = e.getExtension("WEBGL_lose_context")) === null || y === void 0 || y.loseContext(), (x = e.getExtension("STACKGL_destroy_context")) === null || x === void 0 || x.destroy());
  } };
}
function Ny(e, t) {
  return { value: e, unit: t };
}
function rs(e) {
  return e;
}
(function(e) {
  e.create = function(o, u, s) {
    var c = !!o[0].cell, l = !!o[0].velocities, d = !!o[0].forces;
    return { id: Ii.create22(), frames: o, hasCell: c, hasVelocities: l, hasForces: d, deltaTime: u, timeOffset: s };
  }, e.getAtomicConformation = function(o, u, s) {
    var c = o.x, l = o.y, d = o.z;
    return o.xyzOrdering.frozen ? s ? o.xyzOrdering.isIdentity ? (c = i(c, s), l = i(l, s), d = i(d, s)) : Ja(o.xyzOrdering.index, s) || (c = n(c, o.xyzOrdering.index, s), l = n(l, o.xyzOrdering.index, s), d = n(d, o.xyzOrdering.index, s)) : o.xyzOrdering.isIdentity || (c = a(c, o.xyzOrdering.index), l = a(l, o.xyzOrdering.index), d = a(d, o.xyzOrdering.index)) : s && (o.xyzOrdering.isIdentity ? (o.xyzOrdering.isIdentity = !1, o.xyzOrdering.index = s, r(c, s), r(l, s), r(d, s)) : Ja(o.xyzOrdering.index, s) || (c = n(c, o.xyzOrdering.index, s), l = n(l, o.xyzOrdering.index, s), d = n(d, o.xyzOrdering.index, s))), o.xyzOrdering.frozen = !0, { id: Ii.create22(), atomId: u, occupancy: oe.ofConst(1, o.elementCount, oe.Schema.int), B_iso_or_equiv: oe.ofConst(0, o.elementCount, oe.Schema.float), xyzDefined: !0, x: c, y: l, z: d };
  };
  var t = [0.123];
  function r(o, u) {
    for (var s = t, c = 0, l = o.length; c < l; c++) s[c] = o[u[c]];
    for (c = 0, l = o.length; c < l; c++) o[c] = s[c];
  }
  function n(o, u, s) {
    for (var c = new Float32Array(o.length), l = 0, d = o.length; l < d; l++) c[l] = o[u[s[l]]];
    return c;
  }
  function i(o, u) {
    for (var s = new Float32Array(o.length), c = 0, l = o.length; c < l; c++) s[c] = o[u[c]];
    return s;
  }
  function a(o, u) {
    for (var s = new Float32Array(o.length), c = 0, l = o.length; c < l; c++) s[u[c]] = o[c];
    return s;
  }
})(x2 || (x2 = {})), function(e) {
  e.create = function(t, r, n, i) {
    return { id: Ii.create22(), label: t, basic: r, sourceData: i, bonds: n };
  };
}(X9 || (X9 = {})), function(e) {
  e.getUUID = function(t) {
    return t.__key || (t.__key = Ii.create22()), t.__key;
  };
}(rs || (rs = {}));
var So, v0 = function() {
  function e() {
    this._list = [], this._set = /* @__PURE__ */ new Set(), this._refs = /* @__PURE__ */ new Map(), this._assets = /* @__PURE__ */ new Map();
  }
  return Object.defineProperty(e.prototype, "all", { get: function() {
    return this._list;
  }, enumerable: !1, configurable: !0 }), e.prototype.add = function(t) {
    this._set.has(t) || (this._list.push(t), this._set.add(t));
  }, e.prototype.reference = function(t, r) {
    var n = this._refs.get(t) || 0;
    n += r ? 1 : -1, this._refs.set(t, Math.max(n, 0));
  }, e.prototype.hasReference = function(t) {
    return (this._refs.get(t) || 0) > 0;
  }, e.prototype.has = function(t) {
    return this._set.has(t);
  }, e.prototype.assets = function(t, r) {
    var n = this._assets.get(t);
    if (n) for (var i = 0, a = n; i < a.length; i++)
      a[i].dispose();
    r ? this._assets.set(t, r) : this._assets.delete(t);
  }, e.prototype.dispose = function() {
    this._assets.forEach(function(t) {
      for (var r = 0, n = t; r < n.length; r++)
        n[r].dispose();
    });
  }, e;
}();
function SM(e, t, r, n, i) {
  for (var a = e.b, o = e.offset, u = [], s = 0, c = t.length; s < c; ++s) for (var l = t[s], d = o[l], f = o[l + 1]; d < f; ++d) {
    var m = a[d];
    if (!i.has(m)) {
      if (qe.has(r, m)) return !0;
      i.add(m), u[u.length] = m;
    }
  }
  return n > 1 && SM(e, u, r, n - 1, i);
}
(function(e) {
  e.areEqual = function(u, s) {
    if (u === s) return !0;
    if (u.vertexCount !== s.vertexCount || u.edgeCount !== s.edgeCount) return !1;
    for (var c = u.a, l = u.b, d = u.offset, f = s.a, m = s.b, v = s.offset, p = 0, g = u.a.length; p < g; p++) if (c[p] !== f[p]) return !1;
    for (p = 0, g = u.b.length; p < g; p++) if (l[p] !== m[p]) return !1;
    for (p = 0, g = u.offset.length; p < g; p++) if (d[p] !== v[p]) return !1;
    for (var h = 0, y = Object.keys(u.edgeProps); h < y.length; h++) {
      var x = y[h], A = u.edgeProps[x], b = s.edgeProps[x];
      if (!b) return !1;
      for (p = 0, g = A.length; p < g; p++) if (A[p] !== b[p]) return !1;
    }
    return !0;
  };
  var t = function() {
    function u(s, c, l, d, f, m) {
      this.offset = s, this.a = c, this.b = l, this.edgeCount = d, this.props = m, this.vertexCount = s.length - 1, this.edgeProps = f || {};
    }
    return u.prototype.getEdgeIndex = function(s, c) {
      var l, d;
      s < c ? (l = s, d = c) : (l = c, d = s);
      for (var f = this.offset[l], m = this.offset[l + 1]; f < m; f++) if (this.b[f] === d) return f;
      return -1;
    }, u.prototype.getDirectedEdgeIndex = function(s, c) {
      for (var l = this.offset[s], d = this.offset[s + 1]; l < d; l++) if (this.b[l] === c) return l;
      return -1;
    }, u.prototype.getVertexEdgeCount = function(s) {
      return this.offset[s + 1] - this.offset[s];
    }, u;
  }();
  function r(u, s, c, l, d, f) {
    return new t(u, s, c, l, d, f);
  }
  e.create = r;
  var n = function() {
    function u(s, c, l) {
      this.vertexCount = s, this.xs = c, this.ys = l, this.current = 0, this.curA = 0, this.curB = 0, this.edgeCount = c.length, this.offsets = new Int32Array(this.vertexCount + 1), this.bucketFill = new Int32Array(this.vertexCount);
      for (var d = new Int32Array(this.vertexCount), f = 0, m = this.xs.length; f < m; f++) d[this.xs[f]]++;
      for (f = 0, m = this.ys.length; f < m; f++) d[this.ys[f]]++;
      var v = 0;
      for (f = 0; f < this.vertexCount; f++) this.offsets[f] = v, v += d[f];
      this.offsets[this.vertexCount] = v, this.slotCount = v, this.a = new Int32Array(v), this.b = new Int32Array(v);
    }
    return u.prototype.createGraph = function(s, c) {
      return r(this.offsets, this.a, this.b, this.edgeCount, s, c);
    }, u.prototype.addNextEdge = function() {
      var s = this.xs[this.current], c = this.ys[this.current], l = this.offsets[s] + this.bucketFill[s], d = this.offsets[c] + this.bucketFill[c];
      this.a[l] = s, this.b[l] = c, this.bucketFill[s]++, this.a[d] = c, this.b[d] = s, this.bucketFill[c]++, this.current++, this.curA = l, this.curB = d;
    }, u.prototype.addAllEdges = function() {
      for (var s = 0; s < this.edgeCount; s++) this.addNextEdge();
    }, u.prototype.assignProperty = function(s, c) {
      s[this.curA] = c, s[this.curB] = c;
    }, u;
  }();
  e.EdgeBuilder = n;
  var i = function() {
    function u(s, c, l) {
      this.vertexCount = s, this.xs = c, this.ys = l, this.current = 0, this.curA = 0, this.edgeCount = c.length, this.offsets = new Int32Array(this.vertexCount + 1), this.bucketFill = new Int32Array(this.vertexCount);
      for (var d = new Int32Array(this.vertexCount), f = 0, m = this.xs.length; f < m; f++) d[this.xs[f]]++;
      var v = 0;
      for (f = 0; f < this.vertexCount; f++) this.offsets[f] = v, v += d[f];
      this.offsets[this.vertexCount] = v, this.slotCount = v, this.a = new Int32Array(v), this.b = new Int32Array(v);
    }
    return u.prototype.createGraph = function(s) {
      return r(this.offsets, this.a, this.b, this.edgeCount, s);
    }, u.prototype.addNextEdge = function() {
      var s = this.xs[this.current], c = this.ys[this.current], l = this.offsets[s] + this.bucketFill[s];
      this.a[l] = s, this.b[l] = c, this.bucketFill[s]++, this.current++, this.curA = l;
    }, u.prototype.addAllEdges = function() {
      for (var s = 0; s < this.edgeCount; s++) this.addNextEdge();
    }, u.prototype.assignProperty = function(s, c) {
      s[this.curA] = c;
    }, u;
  }();
  e.DirectedEdgeBuilder = i;
  var a = function() {
    function u(s) {
      this.vertexCount = s, this.xs = [], this.ys = [], this.included = /* @__PURE__ */ new Set();
    }
    return u.prototype.addEdge = function(s, c) {
      var l = s, d = c;
      s > c && (l = c, d = s);
      var f = Mu(l, d);
      return !this.included.has(f) && (this.included.add(f), this.xs[this.xs.length] = l, this.ys[this.ys.length] = d, !0);
    }, u.prototype.getGraph = function() {
      return o(this.vertexCount, this.xs, this.ys);
    }, u.prototype.getEdgeBuiler = function() {
      return new n(this.vertexCount, this.xs, this.ys);
    }, u;
  }();
  function o(u, s, c) {
    var l = new e.EdgeBuilder(u, s, c);
    return l.addAllEdges(), l.createGraph({});
  }
  e.UniqueEdgeBuilder = a, e.fromVertexPairs = o, e.induceByVertices = function(u, s) {
    for (var c = u.b, l = u.offset, d = u.vertexCount, f = u.edgeProps, m = new Int32Array(d), v = 0, p = s.length; v < p; v++) m[s[v]] = v + 1;
    var g = 0;
    for (v = 0; v < d; v++) if (m[v] !== 0) for (var h = l[v], y = l[v + 1]; h < y; h++) c[h] > v && m[c[h]] !== 0 && g++;
    var x = new Int32Array(s.length + 1), A = new Int32Array(2 * g), b = new Int32Array(2 * g), _ = new Int32Array(2 * g), S = 0, D = 0;
    for (v = 0; v < d; v++) if (m[v] !== 0) {
      var I = m[v] - 1;
      for (h = l[v], y = l[v + 1]; h < y; h++) {
        var M = m[c[h]];
        M !== 0 && (b[S] = I, _[S] = M - 1, A[S] = h, S++);
      }
      x[++D] = S;
    }
    for (var F = {}, P = 0, E = Object.keys(f); P < E.length; P++) {
      var B = E[P];
      F[B] = SU(f[B], A);
    }
    return r(x, b, _, g, F);
  }, e.connectedComponents = function(u) {
    var s = u.vertexCount;
    if (s === 0) return { componentCount: 0, componentIndex: new Int32Array(0) };
    if (u.edgeCount === 0) {
      for (var c = new Int32Array(s), l = 0, d = s; l < d; l++) c[l] = l;
      return { componentCount: s, componentIndex: c };
    }
    var f = new Int32Array(s);
    for (l = 0, d = s; l < d; l++) f[l] = -1;
    var m = 0;
    f[0] = m;
    var v = u.offset, p = u.b, g = [0], h = function(S) {
      return new IH(S);
    }(s);
    for (h.remove(0); g.length > 0; ) {
      for (var y = g.pop(), x = f[y], A = v[y], b = v[y + 1]; A < b; A++) {
        var _ = p[A];
        h.has(_) && (h.remove(_), g.push(_), f[_] = x);
      }
      g.length === 0 && h.head >= 0 && (g.push(h.head), f[h.head] = ++m, h.remove(h.head));
    }
    return { componentCount: s, componentIndex: f };
  }, e.areVertexSetsConnected = function(u, s, c, l) {
    if (qe.areIntersecting(s, c)) return !0;
    if (l < 1) return !1;
    for (var d = /* @__PURE__ */ new Set(), f = 0, m = s.length; f < m; ++f) d.add(s[f]);
    return SM(u, s, c, l, d);
  };
})(So || (So = {}));
var Es, Ei, st, R1, Kq = function() {
  function e() {
    this.map = /* @__PURE__ */ new Map(), this.applicable = /* @__PURE__ */ new Map();
  }
  return e.prototype.add = function(t, r, n) {
    this.map.set(t, r), n && this.applicable.set(t, n);
  }, e.prototype.remove = function(t) {
    this.map.delete(t), this.applicable.delete(t);
  }, e.prototype.get = function(t) {
    return this.map.get(t);
  }, e.prototype.isApplicable = function(t) {
    var r = this.applicable.get(t.sourceData.kind);
    return !r || r(t);
  }, e;
}();
function Xq(e, t, r, n) {
  for (var i = new So.EdgeBuilder(n, e, t), a = new Int32Array(i.slotCount), o = new Int8Array(i.slotCount), u = new Array(i.slotCount), s = new Array(i.slotCount), c = 0, l = i.edgeCount; c < l; c++) i.addNextEdge(), i.assignProperty(a, r.key ? r.key[c] : -1), i.assignProperty(o, r.order ? r.order[c] : 1), i.assignProperty(u, r.distance ? r.distance[c] : -1), i.assignProperty(s, r.flag ? r.flag[c] : 1);
  return i.createGraph({ key: a, order: o, distance: u, flag: s });
}
function Gr(e) {
  return function(t) {
    return function(r, n) {
      var i = r.data, a = r.indices, o = r.count, u = n.valueType, s = u === "str" ? function(c) {
        return i.substring(a[2 * c], a[2 * c + 1]);
      } : u === "int" ? function(c) {
        return Yl(i, a[2 * c], a[2 * c + 1]) || 0;
      } : function(c) {
        return ef(i, a[2 * c], a[2 * c + 1]) || 0;
      };
      return { schema: n, __array: void 0, isDefined: !0, rowCount: o, value: s, valueKind: function(c) {
        return 0;
      }, toArray: function(c) {
        return $i(o, s, c);
      }, areValuesEqual: CM(r) };
    }(e, t);
  };
}
function CM(e) {
  var t = e.data, r = e.indices;
  return function(n, i) {
    var a = r[2 * n], o = r[2 * i], u = r[2 * n + 1] - a;
    if (u !== r[2 * i + 1] - o) return !1;
    for (var s = 0; s < u; s++) if (t.charCodeAt(s + a) !== t.charCodeAt(s + o)) return !1;
    return !0;
  };
}
function jq(e) {
  for (var t = e.count, r = e.indices, n = 0; n < t; ++n) if (r[2 * n] !== r[2 * n + 1]) return !1;
  return !0;
}
function wM(e, t) {
  return { name: t, blocks: e };
}
function f_(e, t, r, n) {
  return n === void 0 && (n = []), { categoryNames: e, header: r, categories: t, saveFrames: n, getField: function(i) {
    var a = i.split("."), o = a[0], u = a[1];
    return t[o].getField(u || "");
  } };
}
function va(e, t, r, n) {
  return { rowCount: t, name: e, fieldNames: We([], r, !0), getField: function(i) {
    return n[i];
  } };
}
function Kd(e, t, r) {
  return function(n, i, a) {
    for (var o = /* @__PURE__ */ Object.create(null), u = 0, s = Object.keys(n); u < s.length; u++) {
      var c = s[u];
      o[c] = Zq(c, n[c], i, a);
    }
    return Q5.ofTables(i.header, n, o);
  }(e, t, r);
}
function Ry(e, t, r, n) {
  return { schema: e, __array: t.__array, isDefined: t.isDefined, rowCount: t.rowCount, value: r, valueKind: t.valueKind, areValuesEqual: t.areValuesEqual, toArray: n };
}
function Yq(e, t, r) {
  var n = e.space, i = t.fieldNames.includes("".concat(r, "[0]")) || t.fieldNames.includes("".concat(r, "[0][0]")) || t.fieldNames.includes("".concat(r, "[0][0][0]")), a = i ? 0 : 1, o = t.fieldNames.includes("".concat(r, "_1")) || t.fieldNames.includes("".concat(r, "_11")) || t.fieldNames.includes("".concat(r, "_111")) ? "underscore" : "brackets", u = function(l, d, f, m) {
    var v = f ? 0 : 1;
    switch (d) {
      case 1:
        return m === "brackets" ? function(p) {
          return "".concat(l, "[").concat(p + v, "]");
        } : function(p) {
          return "".concat(l, "_").concat(p + v);
        };
      case 2:
        return m === "brackets" ? function(p, g) {
          return "".concat(l, "[").concat(p + v, "][").concat(g + v, "]");
        } : function(p, g) {
          return "".concat(l, "_").concat(p + v).concat(g + v);
        };
      case 3:
        return m === "brackets" ? function(p, g, h) {
          return "".concat(l, "[").concat(p + v, "][").concat(g + v, "][").concat(h + v, "]");
        } : function(p, g, h) {
          return "".concat(l, "_").concat(p + v).concat(g + v).concat(h + v);
        };
      default:
        throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.");
    }
  }(r, n.rank, i, o), s = t.getField(u(a, a, a)) || oe.Undefined(t.rowCount, e), c = function(l) {
    return function(d, f, m, v) {
      var p = f.create();
      if (f.rank === 1) for (var g = f.dimensions[0], h = 0; h < g; h++) {
        var y = d.getField(v(h));
        f.set(p, h, y ? y.float(m) : 0);
      }
      else if (f.rank === 2) {
        g = f.dimensions[0];
        var x = f.dimensions[1];
        for (h = 0; h < g; h++) for (var A = 0; A < x; A++) y = d.getField(v(h, A)), f.set(p, h, A, y ? y.float(m) : 0);
      } else {
        if (f.rank !== 3) throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.");
        var b = f.dimensions[0], _ = f.dimensions[1], S = f.dimensions[2];
        for (h = 0; h < b; h++) for (A = 0; A < _; A++) for (var D = 0; D < S; D++) y = d.getField(v(h, A, D)), f.set(p, h, A, D, y ? y.float(m) : 0);
      }
      return p;
    }(t, n, l, u);
  };
  return { schema: e, __array: void 0, isDefined: s.isDefined, rowCount: t.rowCount, value: c, valueKind: s.valueKind, areValuesEqual: function(l, d) {
    return zn.areEqualExact(c(l), c(d));
  }, toArray: function(l) {
    return $i(t.rowCount, c, l);
  } };
}
(function(e) {
  e.create = function(t, r) {
    var n = t.name, i = new Kq();
    return { descriptor: t, formatRegistry: i, isApplicable: function(a) {
      return i.isApplicable(a);
    }, get: function(a) {
      var o = r != null && r.asDynamic ? a._dynamicPropertyData : a._staticPropertyData;
      if (o[n]) return o[n];
      if (!a.customProperties.has(t)) {
        var u = i.get(a.sourceData.kind);
        if (u) return o[n] = u(a), a.customProperties.add(t), o[n];
      }
    }, set: function(a, o) {
      r != null && r.asDynamic ? a._dynamicPropertyData[n] = o : a._staticPropertyData[n] = o;
    }, delete: function(a) {
      r != null && r.asDynamic ? delete a._dynamicPropertyData[n] : delete a._staticPropertyData[n];
    } };
  };
})(Es || (Es = {})), function(e) {
  e.Descriptor = { name: "index_pair_bonds" }, e.Provider = Es.create(e.Descriptor, { asDynamic: !0 }), e.DefaultProps = { maxDistance: -1 }, e.fromData = function(t, r) {
    r === void 0 && (r = {});
    var n = R(R({}, e.DefaultProps), r), i = t.pairs, a = t.count;
    return { bonds: Xq(i.indexA.toArray(), i.indexB.toArray(), { key: i.key && i.key.toArray(), order: i.order && i.order.toArray(), distance: i.distance && i.distance.toArray(), flag: i.flag && i.flag.toArray() }, a), maxDistance: n.maxDistance };
  };
}(Ei || (Ei = {})), function(e) {
  function t(r, n) {
    var i = Object.keys(n);
    return { rowCount: i.length > 0 ? n[i[0]].rowCount : 0, name: r, fieldNames: i, getField: function(a) {
      return n[a];
    } };
  }
  e.empty = function(r) {
    return { rowCount: 0, name: r, fieldNames: [], getField: function(n) {
    } };
  }, e.ofFields = t, e.ofTable = function(r, n) {
    for (var i = {}, a = 0, o = n._columns; a < o.length; a++) {
      var u = o[a];
      i[u] = st.ofColumn(n[u]);
    }
    return t(r, i);
  };
}(va || (va = {})), function(e) {
  function t(n) {
    var i = n.length, a = function(s) {
      var c = n[s];
      return c && c !== "." && c !== "?" ? c : "";
    }, o = function(s) {
      var c = n[s];
      return Yl(c, 0, c.length) || 0;
    }, u = function(s) {
      var c = n[s];
      return ef(c, 0, c.length) || 0;
    };
    return { __array: void 0, binaryEncoding: void 0, isDefined: !0, rowCount: i, str: a, int: o, float: u, valueKind: function(s) {
      var c = n[s], l = c.length;
      if (l > 1) return 0;
      if (l === 0) return 1;
      var d = c.charCodeAt(0);
      return d === 46 ? 1 : d === 63 ? 2 : 0;
    }, areValuesEqual: function(s, c) {
      return n[s] === n[c];
    }, toStringArray: function(s) {
      return s ? $i(i, a, s) : n;
    }, toIntArray: function(s) {
      return $i(i, o, s);
    }, toFloatArray: function(s) {
      return $i(i, u, s);
    } };
  }
  function r(n) {
    var i, a, o, u = n.rowCount, s = n.valueKind, c = n.areValuesEqual, l = n.isDefined;
    switch (n.schema.valueType) {
      case "float":
      case "int":
        i = function(f) {
          return "" + n.value(f);
        }, a = n.value, o = n.value;
        break;
      case "str":
        i = n.value, a = function(f) {
          var m = n.value(f);
          return Yl(m, 0, m.length) || 0;
        }, o = function(f) {
          var m = n.value(f);
          return ef(m, 0, m.length) || 0;
        };
        break;
      case "list":
        var d = n.schema.separator;
        i = function(f) {
          return n.value(f).join(d);
        }, a = function(f) {
          return NaN;
        }, o = function(f) {
          return NaN;
        };
        break;
      default:
        throw new Error("unsupported valueType '".concat(n.schema.valueType, "'"));
    }
    return { __array: void 0, binaryEncoding: void 0, isDefined: l, rowCount: u, str: i, int: a, float: o, valueKind: s, areValuesEqual: c, toStringArray: function(f) {
      return $i(u, i, f);
    }, toIntArray: function(f) {
      return $i(u, a, f);
    }, toFloatArray: function(f) {
      return $i(u, o, f);
    } };
  }
  e.ofString = function(n) {
    return t([n]);
  }, e.ofStrings = t, e.ofNumbers = function(n) {
    var i = n.length, a = function(s) {
      return "" + n[s];
    }, o = function(s) {
      return n[s];
    }, u = function(s) {
      return !s || s.array && n instanceof s.array ? n : $i(i, o, s);
    };
    return { __array: void 0, binaryEncoding: void 0, isDefined: !0, rowCount: i, str: a, int: o, float: o, valueKind: function(s) {
      return 0;
    }, areValuesEqual: function(s, c) {
      return n[s] === n[c];
    }, toStringArray: function(s) {
      return $i(i, a, s);
    }, toIntArray: u, toFloatArray: u };
  }, e.ofTokens = function(n) {
    var i = n.data, a = n.indices, o = n.count, u = function(l) {
      var d = i.substring(a[2 * l], a[2 * l + 1]);
      return d === "." || d === "?" ? "" : d;
    }, s = function(l) {
      return Yl(i, a[2 * l], a[2 * l + 1]) || 0;
    }, c = function(l) {
      return ef(i, a[2 * l], a[2 * l + 1]) || 0;
    };
    return { __array: void 0, binaryEncoding: void 0, isDefined: !0, rowCount: o, str: u, int: s, float: c, valueKind: function(l) {
      var d = a[2 * l], f = a[2 * l + 1] - d;
      if (f > 1) return 0;
      if (f === 0) return 1;
      var m = i.charCodeAt(d);
      return m === 46 ? 1 : m === 63 ? 2 : 0;
    }, areValuesEqual: CM(n), toStringArray: function(l) {
      return $i(o, u, l);
    }, toIntArray: function(l) {
      return $i(o, s, l);
    }, toFloatArray: function(l) {
      return $i(o, c, l);
    } };
  }, e.ofColumn = r, e.ofUndefined = function(n, i) {
    return r(oe.Undefined(n, i));
  };
}(st || (st = {})), function(e) {
  function t(r) {
    return r.replace(".", "_").replace(/\[/, "_").replace(/(\[|\])/g, "");
  }
  e.canonical = t, e.equal = function(r, n) {
    return t(r) === t(n);
  }, e.create = function(r, n, i) {
    i === void 0 && (i = !1);
    var a = "".concat(r).concat(n ? ".".concat(n) : "");
    return i ? t(a) : a;
  };
}(R1 || (R1 = {}));
var hn, DM = function(e, t, r) {
  this._isDefined = r;
  var n = Object.keys(t);
  this._rowCount = e.rowCount, this._columns = n, this._schema = t;
  for (var i = /* @__PURE__ */ Object.create(null), a = function(c) {
    Object.defineProperty(o, c, { get: function() {
      if (i[c]) return i[c];
      var l = t[c];
      if (l.valueType === "list") i[c] = function(m, v, p) {
        var g = m.separator, h = m.itemParse, y = v.getField(p), x = y ? function(A) {
          return y.str(A).split(g).map(function(b) {
            return h(b.trim());
          }).filter(function(b) {
            return !!b;
          });
        } : function(A) {
          return [];
        };
        return { schema: m, __array: void 0, isDefined: !!y, rowCount: v.rowCount, value: x, valueKind: y ? y.valueKind : function() {
          return 1;
        }, areValuesEqual: function(A, b) {
          return Ja(x(A), x(b));
        }, toArray: function(A) {
          return $i(v.rowCount, x, A);
        } };
      }(l, e, c);
      else if (l.valueType === "tensor") i[c] = Yq(l, e, c);
      else {
        var d = function(m) {
          switch (m.valueType) {
            case "str":
              return function(v, p, g) {
                return Ry(m, v, v.str, v.toStringArray);
              };
            case "int":
              return function(v, p, g) {
                return Ry(m, v, v.int, v.toIntArray);
              };
            case "float":
              return function(v, p, g) {
                return Ry(m, v, v.float, v.toFloatArray);
              };
            case "list":
              throw new Error("Use createListColumn instead.");
            case "tensor":
              throw new Error("Use createTensorColumn instead.");
          }
        }(l), f = e.getField(c);
        i[c] = f ? d(f, e, c) : oe.Undefined(e.rowCount, l);
      }
      return i[c];
    }, enumerable: !0, configurable: !1 });
  }, o = this, u = 0, s = n; u < s.length; u++) a(s[u]);
};
function Wq(e, t, r, n) {
  var i = R1.create(t, e), a = R1.canonical(i);
  if (a in r) return r[a];
  if (n && i in n) for (var o = 0, u = n[i]; o < u.length; o++) {
    var s = u[o], c = R1.canonical(s);
    if (c in r) return r[c];
  }
}
function Zq(e, t, r, n) {
  var i = r.categories[e];
  if (n) {
    for (var a = function(m) {
      for (var v = /* @__PURE__ */ Object.create(null), p = 0, g = Object.keys(m.categories); p < g.length; p++) for (var h = g[p], y = 0, x = m.categories[h].fieldNames; y < x.length; y++) {
        var A = x[y];
        v[R1.create(h, A, !0)] = m.categories[h].getField(A);
      }
      return v;
    }(r), o = /* @__PURE__ */ Object.create(null), u = [], s = 0, c = 0, l = Object.keys(t); c < l.length; c++) {
      var d = l[c], f = Wq(d, e, a, n);
      f && (o[d] = f, u.push(d), s = f.rowCount);
    }
    i = { rowCount: s, name: e, fieldNames: We([], u, !0), getField: function(m) {
      return o[m];
    } };
  }
  return new DM(i || va.empty(e), t, !!i);
}
function Oy(e, t, r) {
  for (var n = new Float32Array(e), i = 0; i < n.length; i++) n[i] = t + r * i;
  return n;
}
function Qq(e) {
  return 0;
}
function Ly(e) {
  return function(t) {
    return e[t];
  };
}
function Ag(e) {
  return e[3] === 0 && e[7] === 0 && e[11] === 0 && e[15] === 1;
}
function Jq(e, t) {
  var r = e.matrix, n = t.x, i = t.y, a = t.z, o = r[0], u = r[4], s = r[8], c = r[12];
  return Ag(r) ? function(l) {
    return o * n[l] + u * i[l] + s * a[l] + c;
  } : function(l) {
    var d = n[l], f = i[l], m = a[l], v = r[3] * d + r[7] * f + r[11] * m + r[15] || 1;
    return (o * d + u * f + s * m + c) / v;
  };
}
function $q(e, t) {
  var r = e.matrix, n = t.x, i = t.y, a = t.z, o = r[1], u = r[5], s = r[9], c = r[13];
  return Ag(r) ? function(l) {
    return o * n[l] + u * i[l] + s * a[l] + c;
  } : function(l) {
    var d = n[l], f = i[l], m = a[l], v = r[3] * d + r[7] * f + r[11] * m + r[15] || 1;
    return (o * d + u * f + s * m + c) / v;
  };
}
function eK(e, t) {
  var r = e.matrix, n = t.x, i = t.y, a = t.z, o = r[2], u = r[6], s = r[10], c = r[14];
  return Ag(r) ? function(l) {
    return o * n[l] + u * i[l] + s * a[l] + c;
  } : function(l) {
    var d = n[l], f = i[l], m = a[l], v = r[3] * d + r[7] * f + r[11] * m + r[15] || 1;
    return (o * d + u * f + s * m + c) / v;
  };
}
(function(e) {
  function t(o, u, s) {
    var c = s || {}, l = c.assembly, d = c.ncsId, f = c.hkl, m = c.spgrOp, v = f ? w.clone(f) : w();
    m = Ci(m, -1), d = d || -1;
    var p = me.isIdentity(u), g = function(h, y) {
      if (!h) return "";
      if (h.assembly) return function(S) {
        return !!S && !!S.matrix && !!S.inverse && typeof S.name == "string";
      }(h) ? h.suffix : y ? "" : "_".concat(h.assembly.operId);
      if (h.spgrOp !== void 0 && h.hkl !== void 0 && h.spgrOp !== -1) {
        var x = h.hkl, A = x[0], b = x[1], _ = x[2];
        return "-".concat(h.spgrOp + 1, "_").concat(5 + A).concat(5 + b).concat(5 + _);
      }
      return h.ncsId !== -1 ? "_".concat(h.ncsId) : "";
    }(s, p);
    return p ? { name: o, assembly: l, matrix: u, inverse: me.identity(), isIdentity: !0, hkl: v, spgrOp: m, ncsId: d, suffix: g } : (me.isRotationAndTranslation(u, e.RotationTranslationEpsilon) || console.warn("Symmetry operator (".concat(o, ") should be a composition of rotation and translation.")), { name: o, assembly: l, matrix: u, inverse: me.invert(me(), u), isIdentity: !1, hkl: v, spgrOp: m, ncsId: d, suffix: g });
  }
  e.DefaultName = "1_555", e.Default = t(e.DefaultName, me.identity()), e.RotationTranslationEpsilon = 5e-3, e.create = t, e.checkIfRotationAndTranslation = function(o, u) {
    for (var s = me.identity(), c = 0; c < 3; c++) for (var l = 0; l < 3; l++) me.setValue(s, c, l, Ti.getValue(o, c, l));
    return me.setTranslation(s, u), me.isRotationAndTranslation(s, e.RotationTranslationEpsilon);
  }, e.ofRotationAndOffset = function(o, u, s, c) {
    for (var l = me.identity(), d = 0; d < 3; d++) for (var f = 0; f < 3; f++) me.setValue(l, d, f, Ti.getValue(u, d, f));
    return me.setTranslation(l, s), t(o, l, { ncsId: c });
  };
  var r = In.identity(), n = In(), i = In(), a = w();
  e.lerpFromIdentity = function(o, u, s) {
    var c = u.inverse;
    if (u.isIdentity) return me.copy(o, c);
    var l = 1 - s;
    me.getRotation(n, c), In.slerp(n, r, n, l);
    var d = In.getAxisAngle(a, n);
    return me.fromRotation(o, d, a), me.setValue(o, 0, 3, l * me.getValue(c, 0, 3)), me.setValue(o, 1, 3, l * me.getValue(c, 1, 3)), me.setValue(o, 2, 3, l * me.getValue(c, 2, 3)), o;
  }, e.slerp = function(o, u, s, c) {
    if (Math.abs(c) <= 1e-5) return me.copy(o, u);
    if (Math.abs(c - 1) <= 1e-5) return me.copy(o, s);
    me.getRotation(n, u), me.getRotation(i, s), In.slerp(i, n, i, c);
    var l = In.getAxisAngle(a, i);
    return me.fromRotation(o, l, a), me.setValue(o, 0, 3, Si(me.getValue(u, 0, 3), me.getValue(s, 0, 3), c)), me.setValue(o, 1, 3, Si(me.getValue(u, 1, 3), me.getValue(s, 1, 3), c)), me.setValue(o, 2, 3, Si(me.getValue(u, 2, 3), me.getValue(s, 2, 3), c)), o;
  }, e.compose = function(o, u) {
    var s = me.mul(me(), u.matrix, o.matrix);
    return t(u.name, s, u);
  }, e.createMapping = function(o, u, s) {
    var c = e.createCoordinateMapper(e.Default, u), l = o.isIdentity ? c : e.createCoordinateMapper(o, u), d = function(f, m) {
      return f.isIdentity ? { x: Ly(m.x), y: Ly(m.y), z: Ly(m.z) } : { x: Jq(f, m), y: $q(f, m), z: eK(f, m) };
    }(o, u);
    return { operator: o, coordinates: u, invariantPosition: c, position: l, x: d.x, y: d.y, z: d.z, r: s || Qq };
  }, e.createCoordinateMapper = function(o, u) {
    return o.isIdentity ? function(s) {
      var c = s.x, l = s.y, d = s.z;
      return function(f, m) {
        return m[0] = c[f], m[1] = l[f], m[2] = d[f], m;
      };
    }(u) : function(s, c) {
      var l = s.matrix, d = c.x, f = c.y, m = c.z;
      return Ag(l) ? function(v, p) {
        var g = d[v], h = f[v], y = m[v];
        return p[0] = l[0] * g + l[4] * h + l[8] * y + l[12], p[1] = l[1] * g + l[5] * h + l[9] * y + l[13], p[2] = l[2] * g + l[6] * h + l[10] * y + l[14], p;
      } : function(v, p) {
        return p[0] = d[v], p[1] = f[v], p[2] = m[v], w.transformMat4(p, p, l), p;
      };
    }(o, u);
  };
})(hn || (hn = {}));
var ky = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [-1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0.5], [1, 0, 0, 0.5], [-1, 0, 0, 0.5], [0, 0, 1, 0.5], [0, -1, 0, 0.5], [0, 0, -1, 0.5], [1, 0, 0, 0.25], [0, -1, 0, 0.25], [0, 0, 1, 0.25], [-1, 0, 0, 0.25], [0, 1, 0, 0.25], [0, -1, 0, 0.75], [0, 0, 1, 0.75], [0, 1, 0, 0.75], [1, 0, 0, 0.75], [-1, 0, 0, 0.75], [0, 0, -1, 0.25], [0, 0, -1, 0.75], [1, -1, 0, 0], [-1, 1, 0, 0], [0, 0, 1, 1 / 3], [0, 0, 1, 2 / 3], [1, 0, 0, 2 / 3], [0, 1, 0, 1 / 3], [0, -1, 0, 2 / 3], [1, -1, 0, 1 / 3], [-1, 1, 0, 2 / 3], [-1, 0, 0, 1 / 3], [1, 0, 0, 1 / 3], [0, 1, 0, 2 / 3], [0, -1, 0, 1 / 3], [1, -1, 0, 2 / 3], [-1, 1, 0, 1 / 3], [-1, 0, 0, 2 / 3], [0, 0, -1, 1 / 3], [0, 0, -1, 2 / 3], [0, 0, 1, 5 / 6], [0, 0, 1, 1 / 6], [0, 0, -1, 5 / 6], [0, 0, -1, 1 / 6]], tK = [[0, 1, 2], [3, 4, 5], [3, 1, 5], [3, 6, 5], [7, 6, 2], [8, 6, 5], [0, 4, 2], [0, 4, 9], [7, 10, 2], [7, 10, 9], [0, 10, 2], [8, 10, 5], [3, 1, 11], [3, 6, 11], [0, 10, 9], [8, 6, 11], [3, 4, 2], [0, 4, 5], [3, 4, 9], [7, 10, 5], [8, 4, 9], [8, 10, 9], [8, 10, 2], [0, 6, 9], [3, 10, 9], [0, 10, 11], [7, 1, 9], [8, 1, 11], [7, 4, 11], [7, 6, 9], [7, 10, 11], [3, 10, 2], [8, 1, 5], [0, 4, 11], [3, 1, 2], [3, 1, 9], [7, 4, 2], [8, 1, 2], [8, 1, 9], [3, 6, 9], [7, 4, 9], [8, 6, 2], [8, 6, 9], [3, 6, 2], [12, 13, 14], [15, 16, 14], [12, 17, 18], [15, 19, 18], [20, 13, 18], [21, 16, 18], [20, 17, 14], [21, 19, 14], [0, 1, 5], [8, 10, 11], [7, 6, 11], [7, 6, 5], [8, 4, 2], [7, 4, 5], [7, 1, 5], [7, 1, 11], [0, 10, 5], [0, 1, 11], [0, 6, 11], [0, 6, 5], [3, 10, 11], [8, 4, 11], [15, 13, 22], [12, 16, 22], [15, 17, 23], [12, 19, 23], [21, 13, 23], [20, 16, 23], [21, 17, 22], [20, 19, 22], [4, 0, 2], [1, 3, 2], [4, 0, 14], [1, 3, 18], [4, 0, 9], [1, 3, 9], [4, 0, 18], [1, 3, 14], [10, 7, 9], [6, 8, 9], [4, 7, 14], [6, 3, 18], [10, 0, 18], [1, 8, 14], [1, 3, 5], [4, 0, 5], [6, 8, 11], [10, 7, 11], [1, 3, 11], [4, 0, 11], [10, 7, 2], [6, 8, 2], [3, 10, 22], [7, 1, 23], [8, 4, 23], [0, 6, 22], [1, 0, 5], [4, 3, 5], [1, 0, 23], [4, 3, 22], [10, 7, 14], [6, 8, 18], [8, 6, 22], [7, 10, 23], [4, 3, 11], [1, 0, 11], [1, 0, 22], [4, 3, 23], [10, 7, 18], [6, 8, 14], [8, 6, 23], [7, 10, 22], [6, 7, 11], [10, 8, 11], [8, 1, 23], [0, 10, 22], [3, 6, 22], [7, 4, 23], [4, 3, 2], [1, 0, 2], [10, 8, 2], [6, 7, 2], [4, 3, 9], [1, 0, 9], [10, 8, 9], [6, 7, 9], [4, 8, 14], [6, 0, 18], [10, 3, 18], [1, 7, 14], [4, 8, 18], [6, 0, 14], [10, 3, 14], [1, 7, 18], [6, 7, 5], [10, 8, 5], [6, 8, 5], [10, 7, 5], [8, 1, 22], [0, 10, 23], [3, 6, 23], [7, 4, 22], [4, 24, 2], [25, 3, 2], [4, 24, 26], [25, 3, 27], [4, 24, 27], [25, 3, 26], [28, 29, 26], [30, 31, 26], [32, 33, 26], [34, 35, 27], [36, 37, 27], [38, 39, 27], [2, 0, 1], [1, 2, 0], [1, 25, 5], [24, 0, 5], [39, 36, 40], [35, 38, 40], [37, 34, 40], [33, 30, 41], [29, 32, 41], [31, 28, 41], [5, 3, 4], [4, 5, 3], [25, 1, 5], [0, 24, 5], [24, 4, 5], [3, 25, 5], [4, 3, 41], [25, 1, 40], [24, 4, 41], [3, 25, 40], [4, 3, 40], [25, 1, 41], [24, 4, 40], [3, 25, 41], [35, 34, 40], [37, 36, 40], [39, 38, 40], [29, 28, 41], [31, 30, 41], [33, 32, 41], [3, 5, 4], [5, 4, 3], [25, 1, 2], [0, 24, 2], [24, 4, 2], [3, 25, 2], [25, 1, 9], [0, 24, 9], [24, 4, 9], [3, 25, 9], [30, 33, 26], [32, 29, 26], [28, 31, 26], [36, 39, 27], [38, 35, 27], [34, 37, 27], [0, 2, 1], [2, 1, 0], [30, 33, 42], [32, 29, 42], [28, 31, 42], [36, 39, 43], [38, 35, 43], [34, 37, 43], [7, 9, 6], [9, 6, 7], [25, 1, 11], [0, 24, 11], [24, 4, 11], [3, 25, 11], [35, 34, 44], [37, 36, 44], [39, 38, 44], [29, 28, 45], [31, 30, 45], [33, 32, 45], [8, 11, 10], [11, 10, 8], [1, 25, 2], [24, 0, 2], [1, 25, 42], [24, 0, 43], [1, 25, 43], [24, 0, 42], [1, 25, 27], [24, 0, 26], [1, 25, 26], [24, 0, 27], [1, 25, 9], [24, 0, 9], [4, 24, 5], [25, 3, 5], [4, 24, 11], [25, 3, 11], [1, 0, 40], [4, 3, 44], [0, 24, 45], [1, 0, 41], [4, 3, 45], [0, 24, 44], [0, 24, 40], [0, 24, 41], [2, 3, 4], [5, 3, 1], [5, 0, 4], [4, 2, 3], [1, 5, 3], [4, 5, 0], [2, 7, 6], [2, 8, 10], [5, 8, 6], [5, 7, 10], [1, 9, 7], [4, 9, 8], [1, 11, 8], [4, 11, 7], [9, 0, 6], [9, 3, 10], [11, 3, 6], [11, 0, 10], [6, 2, 7], [10, 2, 8], [6, 5, 8], [10, 5, 7], [9, 7, 1], [9, 8, 4], [11, 8, 1], [11, 7, 4], [6, 9, 0], [10, 9, 3], [6, 11, 3], [10, 11, 0], [9, 7, 6], [9, 8, 10], [11, 8, 6], [11, 7, 10], [6, 9, 7], [10, 9, 8], [6, 11, 8], [10, 11, 7], [2, 3, 10], [5, 8, 1], [11, 0, 4], [10, 2, 3], [1, 5, 8], [4, 11, 0], [5, 0, 1], [2, 0, 4], [2, 3, 1], [1, 5, 0], [4, 2, 0], [1, 2, 3], [11, 8, 10], [11, 7, 6], [9, 7, 10], [9, 8, 6], [10, 11, 8], [6, 11, 7], [10, 9, 7], [6, 9, 8], [5, 8, 10], [5, 7, 6], [2, 7, 10], [2, 8, 6], [4, 11, 8], [1, 11, 7], [4, 9, 7], [1, 9, 8], [11, 3, 10], [11, 0, 6], [9, 0, 10], [9, 3, 6], [10, 5, 8], [6, 5, 7], [10, 2, 7], [6, 2, 8], [11, 8, 4], [11, 7, 1], [9, 7, 4], [9, 8, 1], [10, 11, 3], [6, 11, 0], [10, 9, 0], [6, 9, 3], [22, 15, 13], [22, 12, 16], [14, 12, 13], [14, 15, 16], [13, 22, 15], [16, 22, 12], [13, 14, 12], [16, 14, 15], [22, 21, 17], [22, 20, 19], [14, 20, 17], [14, 21, 19], [13, 23, 21], [16, 23, 20], [13, 18, 20], [16, 18, 21], [23, 15, 17], [23, 12, 19], [18, 12, 17], [18, 15, 19], [17, 22, 21], [19, 22, 20], [17, 14, 20], [19, 14, 21], [23, 21, 13], [23, 20, 16], [18, 20, 13], [18, 21, 16], [17, 23, 15], [19, 23, 12], [17, 18, 12], [19, 18, 15], [5, 0, 6], [2, 7, 4], [9, 3, 1], [6, 5, 0], [4, 2, 7], [1, 9, 3], [0, 2, 4], [3, 2, 1], [0, 5, 1], [2, 1, 3], [2, 4, 0], [5, 1, 0], [7, 9, 10], [8, 9, 6], [7, 11, 6], [9, 6, 8], [9, 10, 7], [11, 6, 7], [1, 7, 11], [4, 8, 11], [1, 8, 9], [4, 7, 9], [0, 9, 10], [3, 9, 6], [3, 11, 10], [0, 11, 6], [2, 6, 8], [2, 10, 7], [5, 6, 7], [5, 10, 8], [6, 0, 11], [10, 3, 11], [6, 3, 9], [10, 0, 9], [7, 2, 10], [8, 2, 6], [8, 5, 10], [7, 5, 6], [9, 1, 8], [9, 4, 7], [11, 1, 7], [11, 4, 8], [7, 9, 4], [8, 9, 1], [8, 11, 4], [7, 11, 1], [9, 6, 3], [9, 10, 0], [11, 6, 0], [11, 10, 3], [19, 12, 23], [13, 15, 22], [16, 21, 18], [17, 20, 14], [20, 14, 17], [21, 18, 16], [15, 22, 13], [12, 23, 19], [18, 16, 21], [14, 17, 20], [23, 19, 12], [22, 13, 15], [19, 20, 22], [13, 21, 23], [16, 15, 14], [17, 12, 18], [20, 18, 13], [21, 14, 19], [15, 23, 17], [12, 22, 16], [18, 19, 15], [14, 13, 12], [23, 16, 20], [22, 17, 21], [16, 12, 22], [17, 15, 23], [19, 21, 14], [13, 20, 18], [12, 14, 13], [15, 18, 19], [21, 22, 17], [20, 23, 16], [14, 16, 15], [18, 17, 12], [22, 19, 20], [23, 13, 21], [16, 20, 23], [17, 21, 22], [19, 15, 18], [13, 12, 14], [12, 18, 17], [15, 14, 16], [21, 23, 13], [20, 22, 19], [14, 19, 21], [18, 13, 20], [22, 16, 12], [23, 17, 15], [19, 12, 22], [17, 21, 23], [16, 15, 18], [13, 20, 14], [20, 14, 13], [15, 18, 16], [21, 23, 17], [12, 22, 19], [18, 16, 15], [14, 13, 20], [22, 19, 12], [23, 17, 21], [3, 2, 4], [3, 5, 1], [0, 5, 4], [2, 4, 3], [5, 1, 3], [5, 4, 0], [1, 7, 9], [4, 8, 9], [1, 8, 11], [4, 7, 11], [0, 9, 6], [3, 9, 10], [3, 11, 6], [0, 11, 10], [2, 6, 7], [2, 10, 8], [5, 6, 8], [5, 10, 7], [6, 0, 9], [10, 3, 9], [6, 3, 11], [10, 0, 11], [7, 2, 6], [8, 2, 10], [8, 5, 6], [7, 5, 10], [9, 1, 7], [9, 4, 8], [11, 1, 8], [11, 4, 7], [7, 9, 1], [8, 9, 4], [8, 11, 1], [7, 11, 4], [9, 6, 0], [9, 10, 3], [11, 6, 3], [11, 10, 0], [8, 9, 10], [8, 11, 6], [7, 11, 10], [9, 10, 8], [11, 6, 8], [11, 10, 7], [6, 0, 2], [10, 3, 2], [6, 3, 5], [10, 0, 5], [7, 2, 1], [8, 2, 4], [8, 5, 1], [7, 5, 4], [9, 1, 0], [9, 4, 3], [11, 1, 3], [11, 4, 0], [1, 7, 2], [4, 8, 2], [1, 8, 5], [4, 7, 5], [0, 9, 1], [3, 9, 4], [3, 11, 1], [0, 11, 4], [2, 6, 0], [2, 10, 3], [5, 6, 3], [5, 10, 0], [0, 2, 6], [3, 2, 10], [3, 5, 6], [0, 5, 10], [2, 1, 7], [2, 4, 8], [5, 1, 8], [5, 4, 7], [16, 12, 14], [13, 21, 18], [19, 15, 23], [17, 20, 22], [12, 14, 16], [21, 18, 13], [15, 23, 19], [20, 22, 17], [14, 16, 12], [18, 13, 21], [23, 19, 15], [22, 17, 20], [19, 20, 18], [17, 15, 14], [16, 21, 22], [13, 12, 23], [20, 18, 19], [15, 14, 17], [21, 22, 16], [12, 23, 13], [18, 19, 20], [14, 17, 15], [22, 16, 21], [23, 13, 12], [6, 0, 5], [10, 3, 5], [6, 3, 2], [10, 0, 2], [7, 2, 4], [8, 2, 1], [8, 5, 4], [7, 5, 1], [9, 1, 3], [9, 4, 0], [11, 1, 0], [11, 4, 3], [1, 7, 5], [4, 8, 5], [1, 8, 2], [4, 7, 2], [0, 9, 4], [3, 9, 1], [3, 11, 4], [0, 11, 1], [2, 6, 3], [2, 10, 0], [5, 6, 0], [5, 10, 3], [0, 2, 10], [3, 2, 6], [3, 5, 10], [0, 5, 6], [2, 1, 8], [2, 4, 7], [5, 1, 7], [5, 4, 8], [21, 17, 23], [20, 16, 22], [12, 13, 18], [15, 19, 14], [23, 21, 17], [22, 20, 16], [18, 12, 13], [14, 15, 19], [17, 23, 21], [16, 22, 20], [13, 18, 12], [19, 14, 15], [21, 13, 22], [20, 19, 23], [12, 17, 14], [15, 16, 18], [23, 15, 13], [22, 12, 19], [18, 20, 17], [14, 21, 16], [17, 22, 15], [16, 23, 12], [13, 14, 20], [19, 18, 21], [15, 17, 22], [12, 16, 23], [20, 13, 14], [21, 19, 18], [22, 21, 13], [23, 20, 19], [14, 12, 17], [18, 15, 16], [13, 23, 15], [19, 22, 12], [17, 18, 20], [16, 14, 21], [15, 13, 23], [12, 19, 22], [20, 17, 18], [21, 16, 14], [22, 15, 17], [23, 12, 16], [14, 20, 13], [18, 21, 19], [13, 22, 21], [19, 23, 20], [17, 14, 12], [16, 18, 15], [6, 5, 3], [4, 9, 3], [9, 3, 4], [5, 7, 4], [4, 5, 7], [5, 3, 6]], rK = [[0], [0, 1], [0, 2], [0, 3], [0, 2, 4, 5], [0, 6], [0, 7], [0, 6, 4, 8], [0, 7, 4, 9], [0, 6, 2, 1], [0, 3, 1, 10], [0, 6, 2, 1, 4, 8, 5, 11], [0, 12, 1, 7], [0, 1, 13, 14], [0, 12, 1, 7, 4, 15, 11, 9], [0, 16, 2, 17], [0, 18, 12, 17], [0, 16, 5, 19], [0, 20, 13, 19], [0, 18, 12, 17, 4, 21, 15, 19], [0, 16, 2, 17, 4, 22, 5, 19], [0, 16, 2, 17, 23, 24, 13, 25, 26, 20, 27, 28, 4, 22, 5, 19], [0, 16, 17, 2, 29, 21, 30, 15], [0, 20, 13, 19, 29, 31, 32, 33], [0, 16, 6, 34], [0, 18, 7, 34], [0, 16, 7, 35], [0, 16, 36, 37], [0, 18, 36, 38], [0, 16, 14, 39], [0, 20, 40, 34], [0, 16, 8, 41], [0, 18, 8, 42], [0, 16, 9, 42], [0, 16, 6, 34, 4, 22, 8, 41], [0, 18, 7, 34, 4, 21, 9, 41], [0, 16, 7, 35, 4, 22, 9, 42], [0, 16, 6, 34, 23, 24, 14, 39], [0, 16, 10, 43, 23, 24, 7, 35], [0, 16, 36, 37, 23, 24, 9, 42], [0, 16, 8, 41, 23, 24, 40, 38], [0, 16, 6, 34, 23, 24, 14, 39, 26, 20, 40, 38, 4, 22, 8, 41], [0, 16, 44, 45, 23, 24, 46, 47, 26, 20, 48, 49, 4, 22, 50, 51], [0, 16, 6, 34, 29, 21, 9, 42], [0, 16, 8, 41, 29, 21, 7, 35], [0, 16, 36, 37, 29, 21, 14, 39], [0, 16, 2, 17, 1, 52, 6, 34], [0, 16, 2, 17, 53, 54, 9, 42], [0, 16, 12, 33, 1, 52, 7, 35], [0, 16, 2, 17, 11, 55, 8, 41], [0, 56, 2, 57, 1, 58, 6, 37], [0, 56, 15, 25, 1, 58, 9, 39], [0, 20, 27, 17, 1, 59, 40, 34], [0, 56, 12, 28, 1, 58, 7, 38], [0, 16, 5, 19, 1, 52, 8, 41], [0, 22, 13, 28, 1, 55, 14, 38], [0, 18, 13, 60, 1, 61, 14, 43], [0, 16, 15, 30, 1, 52, 9, 42], [0, 16, 5, 19, 11, 55, 6, 34], [0, 21, 12, 19, 1, 54, 7, 41], [0, 20, 13, 19, 1, 59, 14, 41], [0, 20, 3, 30, 1, 59, 10, 42], [0, 18, 12, 17, 1, 61, 7, 34, 4, 21, 15, 19, 11, 54, 9, 41], [0, 24, 13, 17, 1, 62, 14, 34, 4, 20, 27, 19, 11, 59, 40, 41], [0, 16, 2, 17, 1, 52, 6, 34, 4, 22, 5, 19, 11, 55, 8, 41], [0, 16, 12, 33, 1, 52, 7, 35, 4, 22, 15, 30, 11, 55, 9, 42], [0, 31, 3, 17, 1, 63, 10, 34, 4, 56, 32, 19, 11, 58, 36, 41], [0, 22, 2, 19, 64, 59, 14, 38, 4, 16, 5, 17, 65, 62, 40, 39], [0, 16, 2, 17, 1, 52, 6, 34, 23, 24, 13, 25, 64, 62, 14, 39, 26, 20, 27, 28, 65, 59, 40, 38, 4, 22, 5, 19, 11, 55, 8, 41], [0, 16, 2, 17, 66, 67, 44, 45, 23, 24, 13, 25, 68, 69, 46, 47, 26, 20, 27, 28, 70, 71, 48, 49, 4, 22, 5, 19, 72, 73, 50, 51], [0, 16, 2, 17, 1, 52, 6, 34, 29, 21, 15, 30, 53, 54, 9, 42], [0, 16, 5, 19, 1, 52, 8, 41, 29, 21, 12, 33, 53, 54, 7, 35], [0, 20, 13, 19, 1, 59, 14, 41, 29, 31, 32, 33, 53, 63, 36, 35], [0, 31, 3, 17, 1, 63, 10, 34, 29, 20, 27, 30, 53, 59, 40, 42], [0, 16, 74, 75], [0, 18, 76, 77], [0, 16, 78, 79], [0, 18, 80, 81], [0, 16, 74, 75, 29, 21, 82, 83], [0, 21, 84, 85, 29, 16, 86, 87], [0, 16, 88, 89], [0, 16, 88, 89, 29, 21, 90, 91], [0, 16, 74, 75, 1, 52, 88, 89], [0, 16, 78, 79, 1, 52, 92, 93], [0, 16, 94, 95, 11, 55, 88, 89], [0, 16, 82, 83, 53, 54, 88, 89], [0, 16, 74, 75, 1, 52, 88, 89, 29, 21, 82, 83, 53, 54, 90, 91], [0, 21, 84, 85, 96, 97, 88, 91, 29, 16, 86, 87, 98, 99, 90, 89], [0, 16, 74, 75, 2, 17, 100, 101], [0, 16, 94, 95, 5, 19, 100, 101], [0, 18, 76, 77, 2, 33, 102, 103], [0, 18, 104, 105, 106, 107, 100, 108], [0, 16, 78, 79, 2, 17, 109, 108], [0, 16, 82, 83, 15, 30, 100, 101], [0, 18, 80, 81, 2, 33, 110, 111], [0, 18, 112, 113, 114, 115, 100, 108], [0, 16, 74, 75, 2, 17, 100, 101, 29, 21, 82, 83, 15, 30, 116, 117], [0, 21, 84, 85, 118, 119, 116, 101, 29, 16, 86, 87, 120, 121, 100, 117], [0, 16, 74, 75, 6, 34, 122, 123], [0, 16, 74, 75, 8, 41, 124, 125], [0, 16, 78, 79, 7, 35, 122, 123], [0, 16, 82, 83, 9, 42, 122, 123], [0, 16, 74, 75, 7, 35, 126, 127], [0, 16, 74, 75, 9, 42, 128, 129], [0, 16, 78, 79, 6, 34, 126, 127], [0, 16, 78, 79, 8, 41, 128, 129], [0, 16, 74, 75, 6, 34, 122, 123, 29, 21, 82, 83, 9, 42, 128, 129], [0, 16, 74, 75, 7, 35, 126, 127, 29, 21, 82, 83, 8, 41, 124, 125], [0, 21, 84, 85, 6, 42, 130, 131, 29, 16, 86, 87, 9, 34, 132, 133], [0, 21, 84, 85, 7, 41, 134, 135, 29, 16, 86, 87, 8, 35, 136, 137], [0, 16, 89, 88, 2, 17, 122, 123], [0, 16, 89, 88, 12, 33, 126, 127], [0, 16, 89, 88, 5, 19, 124, 125], [0, 16, 89, 88, 15, 30, 128, 129], [0, 16, 88, 89, 6, 34, 100, 101], [0, 16, 89, 88, 7, 35, 109, 108], [0, 16, 89, 88, 8, 41, 138, 139], [0, 16, 89, 88, 9, 42, 116, 117], [0, 16, 89, 88, 6, 34, 100, 101, 29, 21, 91, 90, 9, 42, 116, 117], [0, 16, 89, 88, 7, 35, 109, 108, 29, 21, 91, 90, 8, 41, 138, 139], [0, 16, 89, 88, 2, 17, 122, 123, 29, 21, 91, 90, 15, 30, 128, 129], [0, 16, 89, 88, 118, 121, 132, 131, 29, 21, 91, 90, 120, 119, 130, 133], [0, 16, 74, 75, 2, 17, 100, 101, 1, 52, 88, 89, 6, 34, 122, 123], [0, 16, 74, 75, 12, 33, 109, 108, 1, 52, 88, 89, 7, 35, 126, 127], [0, 16, 74, 75, 2, 17, 100, 101, 11, 55, 140, 141, 8, 41, 124, 125], [0, 16, 74, 75, 2, 17, 100, 101, 53, 54, 90, 91, 9, 42, 128, 129], [0, 16, 74, 75, 5, 19, 138, 139, 1, 52, 88, 89, 8, 41, 124, 125], [0, 16, 74, 75, 15, 30, 116, 117, 1, 52, 88, 89, 9, 42, 128, 129], [0, 16, 94, 95, 5, 19, 100, 101, 11, 55, 88, 89, 6, 34, 124, 125], [0, 16, 94, 95, 15, 30, 109, 108, 11, 55, 88, 89, 7, 35, 128, 129], [0, 16, 78, 79, 2, 17, 109, 108, 1, 52, 92, 93, 6, 34, 126, 127], [0, 16, 78, 79, 12, 33, 100, 101, 1, 52, 92, 93, 7, 35, 122, 123], [0, 16, 82, 83, 12, 33, 138, 139, 53, 54, 88, 89, 8, 41, 126, 127], [0, 16, 82, 83, 2, 17, 116, 117, 53, 54, 88, 89, 9, 42, 122, 123], [0, 16, 78, 79, 5, 19, 116, 117, 1, 52, 92, 93, 8, 41, 128, 129], [0, 16, 82, 83, 15, 30, 100, 101, 1, 52, 90, 91, 9, 42, 122, 123], [0, 16, 82, 83, 15, 30, 100, 101, 53, 54, 88, 89, 6, 34, 128, 129], [0, 16, 82, 83, 5, 19, 109, 108, 53, 54, 88, 89, 7, 35, 124, 125], [0, 16, 74, 75, 2, 17, 100, 101, 1, 52, 88, 89, 6, 34, 122, 123, 29, 21, 82, 83, 15, 30, 116, 117, 53, 54, 90, 91, 9, 42, 128, 129], [0, 16, 74, 75, 12, 33, 109, 108, 1, 52, 88, 89, 7, 35, 126, 127, 29, 21, 82, 83, 5, 19, 138, 139, 53, 54, 90, 91, 8, 41, 124, 125], [0, 21, 84, 85, 118, 119, 116, 101, 96, 97, 88, 91, 9, 34, 132, 133, 29, 16, 86, 87, 120, 121, 100, 117, 98, 99, 90, 89, 6, 42, 130, 131], [0, 21, 84, 85, 142, 143, 138, 108, 96, 97, 88, 91, 8, 35, 136, 137, 29, 16, 86, 87, 144, 145, 109, 139, 98, 99, 90, 89, 7, 41, 134, 135], [0, 146, 147], [0, 148, 149], [0, 150, 151], [0, 146, 147, 152, 153, 154, 155, 156, 157], [0, 158, 159], [0, 146, 147, 1, 160, 161], [0, 146, 147, 1, 160, 161, 152, 153, 154, 162, 163, 164, 155, 156, 157, 165, 166, 167], [0, 158, 159, 1, 168, 169], [0, 146, 147, 101, 170, 171], [0, 146, 147, 100, 172, 173], [0, 148, 149, 174, 175, 171], [0, 148, 149, 100, 176, 177], [0, 150, 151, 178, 179, 171], [0, 150, 151, 100, 180, 181], [0, 146, 147, 100, 172, 173, 152, 153, 154, 182, 183, 184, 155, 156, 157, 185, 186, 187], [0, 158, 159, 101, 188, 189], [0, 146, 147, 122, 190, 191], [0, 146, 147, 123, 192, 193], [0, 146, 147, 126, 194, 195], [0, 146, 147, 127, 196, 197], [0, 146, 147, 122, 190, 191, 152, 153, 154, 198, 199, 200, 155, 156, 157, 201, 202, 203], [0, 158, 159, 123, 204, 205], [0, 146, 147, 126, 194, 195, 152, 153, 154, 206, 207, 208, 155, 156, 157, 209, 210, 211], [0, 158, 159, 129, 212, 213], [0, 146, 147, 101, 170, 171, 1, 160, 161, 123, 192, 193], [0, 146, 147, 108, 214, 215, 1, 160, 161, 127, 196, 197], [0, 146, 147, 100, 172, 173, 1, 160, 161, 122, 190, 191], [0, 146, 147, 109, 216, 217, 1, 160, 161, 126, 194, 195], [0, 146, 147, 100, 172, 173, 1, 160, 161, 122, 190, 191, 152, 153, 154, 182, 183, 184, 162, 163, 164, 198, 199, 200, 155, 156, 157, 185, 186, 187, 165, 166, 167, 201, 202, 203], [0, 158, 159, 101, 188, 189, 1, 168, 169, 123, 204, 205], [0, 146, 147, 109, 216, 217, 1, 160, 161, 126, 194, 195, 152, 153, 154, 218, 219, 220, 162, 163, 164, 206, 207, 208, 155, 156, 157, 221, 222, 223, 165, 166, 167, 209, 210, 211], [0, 158, 159, 117, 224, 225, 1, 168, 169, 129, 212, 213], [0, 146, 147, 16, 226, 227], [0, 148, 149, 18, 228, 229], [0, 150, 151, 18, 230, 231], [0, 150, 151, 16, 232, 233], [0, 148, 149, 16, 234, 235], [0, 146, 147, 18, 236, 237], [0, 146, 147, 52, 238, 239], [0, 146, 147, 16, 226, 227, 1, 160, 161, 52, 238, 239], [0, 146, 147, 18, 236, 237, 1, 160, 161, 61, 240, 241], [0, 146, 147, 16, 226, 227, 100, 172, 173, 101, 170, 171], [0, 148, 149, 18, 228, 229, 242, 172, 181, 243, 214, 244], [0, 150, 151, 18, 230, 231, 245, 172, 177, 246, 214, 247], [0, 150, 151, 16, 232, 233, 245, 172, 177, 174, 170, 248], [0, 148, 149, 16, 234, 235, 242, 172, 181, 178, 170, 249], [0, 146, 147, 18, 236, 237, 100, 172, 173, 108, 214, 215], [0, 146, 147, 16, 226, 227, 122, 190, 191, 123, 192, 193], [0, 146, 147, 16, 226, 227, 126, 194, 195, 127, 196, 197], [0, 146, 147, 18, 236, 237, 126, 194, 195, 123, 192, 193], [0, 146, 147, 18, 236, 237, 122, 190, 191, 127, 196, 197], [0, 146, 147, 52, 238, 239, 122, 190, 191, 101, 170, 171], [0, 146, 147, 61, 240, 241, 126, 194, 195, 101, 170, 171], [0, 146, 147, 52, 238, 239, 100, 172, 173, 123, 192, 193], [0, 146, 147, 61, 240, 241, 100, 172, 173, 127, 196, 197], [0, 146, 147, 16, 226, 227, 100, 172, 173, 101, 170, 171, 1, 160, 161, 52, 239, 238, 122, 190, 191, 123, 192, 193], [0, 146, 147, 16, 226, 227, 109, 216, 217, 108, 214, 215, 1, 160, 161, 52, 239, 238, 126, 194, 195, 127, 196, 197], [0, 146, 147, 18, 236, 237, 109, 216, 217, 101, 170, 171, 1, 160, 161, 61, 241, 240, 126, 194, 195, 123, 192, 193], [0, 146, 147, 18, 236, 237, 100, 172, 173, 108, 214, 215, 1, 160, 161, 61, 241, 240, 122, 190, 191, 127, 196, 197], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 64, 62, 14, 39, 308, 309, 310, 311, 312, 313, 314, 315, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 65, 59, 40, 38, 316, 317, 318, 319, 320, 321, 322, 323, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 11, 55, 8, 41, 324, 325, 326, 327, 328, 329, 330, 331], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 66, 67, 44, 45, 332, 333, 334, 335, 336, 337, 338, 339, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 68, 69, 46, 47, 340, 341, 342, 343, 344, 345, 346, 347, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 70, 71, 48, 49, 348, 349, 350, 351, 352, 353, 354, 355, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 72, 73, 50, 51, 356, 357, 358, 359, 360, 361, 362, 363], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 1, 59, 14, 41, 168, 325, 318, 311, 169, 313, 330, 323], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 1, 59, 14, 41, 168, 325, 318, 311, 169, 313, 330, 323, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293, 53, 63, 36, 35, 300, 364, 365, 366, 304, 367, 368, 369], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 138, 139, 95, 94, 406, 407, 408, 409, 410, 411, 412, 413], [0, 24, 5, 28, 158, 265, 258, 275, 159, 277, 270, 263, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 23, 16, 27, 19, 256, 273, 251, 267, 260, 269, 278, 255, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 26, 22, 13, 17, 264, 250, 274, 259, 268, 261, 254, 279, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 4, 20, 2, 25, 272, 257, 266, 252, 276, 253, 262, 271, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 450, 415, 440, 429, 454, 431, 420, 445, 458, 447, 436, 425], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293, 450, 415, 440, 429, 454, 431, 420, 445, 458, 447, 436, 425], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 123, 122, 88, 89, 204, 474, 475, 476, 205, 477, 478, 479], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 123, 122, 88, 89, 204, 474, 475, 476, 205, 477, 478, 479, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 125, 124, 140, 141, 504, 505, 506, 507, 508, 509, 510, 511], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 123, 122, 88, 89, 204, 474, 475, 476, 205, 477, 478, 479, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287, 129, 128, 90, 91, 212, 512, 513, 514, 213, 515, 516, 517], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 129, 128, 90, 91, 212, 512, 513, 514, 213, 515, 516, 517], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 129, 128, 90, 91, 212, 512, 513, 514, 213, 515, 516, 517, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 127, 126, 92, 93, 542, 543, 544, 545, 546, 547, 548, 549], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 122, 123, 89, 88, 475, 476, 204, 474, 479, 478, 477, 205], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307, 128, 129, 91, 90, 513, 514, 212, 512, 517, 516, 515, 213], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 128, 129, 91, 90, 513, 514, 212, 512, 517, 516, 515, 213], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307, 122, 123, 89, 88, 475, 476, 204, 474, 479, 478, 477, 205], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 122, 123, 89, 88, 475, 476, 204, 474, 479, 478, 477, 205, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 64, 62, 14, 39, 308, 309, 310, 311, 312, 313, 314, 315, 481, 480, 483, 482, 486, 487, 484, 485, 491, 490, 489, 488, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 65, 59, 40, 38, 316, 317, 318, 319, 320, 321, 322, 323, 493, 492, 495, 494, 498, 499, 496, 497, 503, 502, 501, 500, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 138, 139, 95, 94, 406, 407, 408, 409, 410, 411, 412, 413, 11, 55, 8, 41, 324, 325, 326, 327, 328, 329, 330, 331, 124, 125, 141, 140, 506, 507, 504, 505, 511, 510, 509, 508], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 128, 129, 91, 90, 513, 514, 212, 512, 517, 516, 515, 213, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 64, 62, 14, 39, 308, 309, 310, 311, 312, 313, 314, 315, 519, 518, 521, 520, 524, 525, 522, 523, 529, 528, 527, 526, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 65, 59, 40, 38, 316, 317, 318, 319, 320, 321, 322, 323, 531, 530, 533, 532, 536, 537, 534, 535, 541, 540, 539, 538, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 109, 108, 79, 78, 598, 599, 600, 601, 602, 603, 604, 605, 11, 55, 8, 41, 324, 325, 326, 327, 328, 329, 330, 331, 126, 127, 93, 92, 544, 545, 542, 543, 549, 548, 547, 546], [0, 24, 5, 28, 158, 265, 258, 275, 159, 277, 270, 263, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 66, 69, 50, 49, 332, 349, 342, 359, 336, 361, 354, 347, 493, 123, 483, 140, 498, 507, 204, 485, 503, 490, 509, 205, 23, 16, 27, 19, 256, 273, 251, 267, 260, 269, 278, 255, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 68, 67, 48, 51, 340, 357, 334, 351, 344, 353, 362, 339, 124, 480, 89, 494, 506, 499, 484, 474, 511, 478, 501, 488, 26, 22, 13, 17, 264, 250, 274, 259, 268, 261, 254, 279, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 70, 73, 46, 45, 348, 333, 358, 343, 352, 345, 338, 363, 122, 492, 141, 482, 475, 487, 496, 505, 479, 510, 489, 500, 4, 20, 2, 25, 272, 257, 266, 252, 276, 253, 262, 271, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 72, 71, 44, 47, 356, 341, 350, 335, 360, 337, 346, 355, 481, 125, 495, 88, 486, 476, 504, 497, 491, 502, 477, 508], [0, 24, 5, 28, 158, 265, 258, 275, 159, 277, 270, 263, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 531, 129, 521, 92, 536, 545, 212, 523, 541, 528, 547, 213, 23, 16, 27, 19, 256, 273, 251, 267, 260, 269, 278, 255, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 126, 518, 91, 532, 544, 537, 522, 512, 549, 516, 539, 526, 26, 22, 13, 17, 264, 250, 274, 259, 268, 261, 254, 279, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 128, 530, 93, 520, 513, 525, 534, 543, 517, 548, 527, 538, 4, 20, 2, 25, 272, 257, 266, 252, 276, 253, 262, 271, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 519, 127, 533, 90, 524, 514, 542, 535, 529, 540, 515, 546], [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 122, 123, 89, 88, 475, 476, 204, 474, 479, 478, 477, 205, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307, 128, 129, 91, 90, 513, 514, 212, 512, 517, 516, 515, 213], [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 1, 59, 14, 41, 168, 325, 318, 311, 169, 313, 330, 323, 551, 550, 553, 552, 556, 557, 554, 555, 561, 560, 559, 558, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293, 450, 415, 440, 429, 454, 431, 420, 445, 458, 447, 436, 425, 53, 63, 36, 35, 300, 364, 365, 366, 304, 367, 368, 369, 563, 562, 565, 564, 568, 569, 566, 567, 573, 572, 571, 570], [0, 16], [0, 18], [0, 16, 26, 20], [0, 2, 23, 13], [0, 3, 4, 32], [0, 2, 29, 15], [0, 3, 29, 27], [0, 52], [0, 63], [0, 52, 26, 59], [0, 63, 26, 54], [0, 52, 16, 1], [0, 18, 1, 61], [0, 52, 16, 1, 26, 59, 20, 65], [0, 31, 1, 63], [0, 1, 24, 62], [0, 15, 1, 9], [0, 5, 1, 8], [0, 31, 1, 63, 26, 21, 65, 54], [0, 2, 57, 56], [0, 60, 3, 16], [0, 22, 57, 3], [0, 2, 28, 20], [0, 17, 13, 24], [0, 20, 19, 13, 4, 24, 17, 27], [0, 22, 57, 3, 4, 16, 60, 32], [0, 22, 57, 3, 23, 20, 30, 12, 26, 24, 33, 15, 4, 16, 60, 32], [0, 22, 57, 3, 29, 18, 27, 25], [0, 22, 3, 57, 1, 55, 10, 37], [0, 22, 385, 396, 3, 57, 109, 117], [0, 22, 57, 3, 159, 279, 654, 655, 158, 274, 656, 657, 29, 18, 25, 27, 284, 658, 262, 269, 280, 659, 257, 267]], em = { "P 1": 0, "P -1": 1, "P 1 2 1": 2, "P 1 21 1": 3, "C 1 2 1": 4, "P 1 m 1": 5, "P 1 c 1": 6, "C 1 m 1": 7, "C 1 c 1": 8, "P 1 2/m 1": 9, "P 1 21/m 1": 10, "C 1 2/m 1": 11, "P 1 2/c 1": 12, "P 1 21/c 1": 13, "C 1 2/c 1": 14, "P 2 2 2": 15, "P 2 2 21": 16, "P 21 21 2": 17, "P 21 21 21": 18, "C 2 2 21": 19, "C 2 2 2": 20, "F 2 2 2": 21, "I 2 2 2": 22, "I 21 21 21": 23, "P m m 2": 24, "P m c 21": 25, "P c c 2": 26, "P m a 2": 27, "P c a 21": 28, "P n c 2": 29, "P m n 21": 30, "P b a 2": 31, "P n a 21": 32, "P n n 2": 33, "C m m 2": 34, "C m c 21": 35, "C c c 2": 36, "A m m 2": 37, "A b m 2": 38, "A m a 2": 39, "A b a 2": 40, "F m m 2": 41, "F d d 2": 42, "I m m 2": 43, "I b a 2": 44, "I m a 2": 45, "P 2/m 2/m 2/m": 46, "P m m m": 46, "P 2/n 2/n 2/n": 47, "P n n n": 47, "P 2/c 2/c 2/m": 48, "P c c m": 48, "P 2/b 2/a 2/n": 49, "P b a n": 49, "P 21/m 2/m 2/a": 50, "P m m a": 50, "P 2/n 21/n 2/a": 51, "P n n a": 51, "P 2/m 2/n 21/a": 52, "P m n a": 52, "P 21/c 2/c 2/a": 53, "P c c a": 53, "P 21/b 21/a 2/m": 54, "P b a m": 54, "P 21/c 21/c 2/n": 55, "P c c n": 55, "P 2/b 21/c 21/m": 56, "P b c m": 56, "P 21/n 21/n 2/m": 57, "P n n m": 57, "P 21/m 21/m 2/n": 58, "P m m n": 58, "P 21/b 2/c 21/n": 59, "P b c n": 59, "P 21/b 21/c 21/a": 60, "P b c a": 60, "P 21/n 21/m 21/a": 61, "P n m a": 61, "C 2/m 2/c 21/m": 62, "C m c m": 62, "C 2/m 2/c 21/a": 63, "C m c a": 63, "C 2/m 2/m 2/m": 64, "C m m m": 64, "C 2/c 2/c 2/m": 65, "C c c m": 65, "C 2/m 2/m 2/a": 66, "C m m a": 66, "C 2/c 2/c 2/a": 67, "C c c a": 67, "F 2/m 2/m 2/m": 68, "F m m m": 68, "F 2/d 2/d 2/d": 69, "F d d d": 69, "I 2/m 2/m 2/m": 70, "I m m m": 70, "I 2/b 2/a 2/m": 71, "I b a m": 71, "I 21/b 21/c 21/a": 72, "I b c a": 72, "I 21/m 21/m 21/a": 73, "I m m a": 73, "P 4": 74, "P 41": 75, "P 42": 76, "P 43": 77, "I 4": 78, "I 41": 79, "P -4": 80, "I -4": 81, "P 4/m": 82, "P 42/m": 83, "P 4/n": 84, "P 42/n": 85, "I 4/m": 86, "I 41/a": 87, "P 4 2 2": 88, "P 4 21 2": 89, "P 41 2 2": 90, "P 41 21 2": 91, "P 42 2 2": 92, "P 42 21 2": 93, "P 43 2 2": 94, "P 43 21 2": 95, "I 4 2 2": 96, "I 41 2 2": 97, "P 4 m m": 98, "P 4 b m": 99, "P 42 c m": 100, "P 42 n m": 101, "P 4 c c": 102, "P 4 n c": 103, "P 42 m c": 104, "P 42 b c": 105, "I 4 m m": 106, "I 4 c m": 107, "I 41 m d": 108, "I 41 c d": 109, "P -4 2 m": 110, "P -4 2 c": 111, "P -4 21 m": 112, "P -4 21 c": 113, "P -4 m 2": 114, "P -4 c 2": 115, "P -4 b 2": 116, "P -4 n 2": 117, "I -4 m 2": 118, "I -4 c 2": 119, "I -4 2 m": 120, "I -4 2 d": 121, "P 4/m 2/m 2/m": 122, "P4/m m m": 122, "P 4/m 2/c 2/c": 123, "P4/m c c": 123, "P 4/n 2/b 2/m": 124, "P4/n b m": 124, "P 4/n 2/n 2/c": 125, "P4/n n c": 125, "P 4/m 21/b 2/m": 126, "P4/m b m": 126, "P 4/m 21/n 2/c": 127, "P4/m n c": 127, "P 4/n 21/m 2/m": 128, "P4/n m m": 128, "P 4/n 2/c 2/c": 129, "P4/n c c": 129, "P 42/m 2/m 2/c": 130, "P42/m m c": 130, "P 42/m 2/c 2/m": 131, "P42/m c m": 131, "P 42/n 2/b 2/c": 132, "P42/n b c": 132, "P 42/n 2/n 2/m": 133, "P42/n n m": 133, "P 42/m 21/b 2/c": 134, "P42/m b c": 134, "P 42/m 21/n 2/m": 135, "P42/m n m": 135, "P 42/n 21/m 2/c": 136, "P42/n m c": 136, "P 42/n 21/c 2/m": 137, "P42/n c m": 137, "I 4/m 2/m 2/m": 138, "I4/m m m": 138, "I 4/m 2/c 2/m": 139, "I4/m c m": 139, "I 41/a 2/m 2/d": 140, "I41/a m d": 140, "I 41/a 2/c 2/d": 141, "I41/a c d": 141, "P 3": 142, "P 31": 143, "P 32": 144, "H 3": 145, "R 3": 146, "P -3": 147, "H -3": 148, "R -3": 149, "P 3 1 2": 150, "P 3 2 1": 151, "P 31 1 2": 152, "P 31 2 1": 153, "P 32 1 2": 154, "P 32 2 1": 155, "H 3 2": 156, "R 3 2": 157, "P 3 m 1": 158, "P 3 1 m": 159, "P 3 c 1": 160, "P 3 1 c": 161, "H 3 m": 162, "R 3 m": 163, "H 3 c": 164, "R 3 c": 165, "P -3 1 2/m": 166, "P -3 1 m": 166, "P -3 1 2/c": 167, "P -3 1 c": 167, "P -3 2/m 1": 168, "P -3 m 1": 168, "P -3 2/c 1": 169, "P -3 c 1": 169, "H -3 2/m": 170, "H -3 m": 170, "R -3 2/m": 171, "R -3 m": 171, "H -3 2/c": 172, "H -3 c": 172, "R -3 2/c": 173, "R -3 c": 173, "P 6": 174, "P 61": 175, "P 65": 176, "P 62": 177, "P 64": 178, "P 63": 179, "P -6": 180, "P 6/m": 181, "P 63/m": 182, "P 6 2 2": 183, "P 61 2 2": 184, "P 65 2 2": 185, "P 62 2 2": 186, "P 64 2 2": 187, "P 63 2 2": 188, "P 6 m m": 189, "P 6 c c": 190, "P 63 c m": 191, "P 63 m c": 192, "P -6 m 2": 193, "P -6 c 2": 194, "P -6 2 m": 195, "P -6 2 c": 196, "P 6/m 2/m 2/m": 197, "P 6/m m m": 197, "P 6/m 2/c 2/c": 198, "P 6/m c c": 198, "P 63/m 2/c 2/m": 199, "P 63/m c m": 199, "P 63/m 2/m 2/c": 200, "P 63/m m c": 200, "P 2 3": 201, "F 2 3": 202, "I 2 3": 203, "P 21 3": 204, "I 21 3": 205, "P 2/m -3": 206, "P m -3": 206, "P 2/n -3": 207, "P n -3": 207, "F 2/m -3": 208, "F m -3": 208, "F 2/d -3": 209, "F d -3": 209, "I 2/m -3": 210, "I m -3": 210, "P 21/a -3": 211, "P a -3": 211, "I 21/a -3": 212, "I a -3": 212, "P 4 3 2": 213, "P 42 3 2": 214, "F 4 3 2": 215, "F 41 3 2": 216, "I 4 3 2": 217, "P 43 3 2": 218, "P 41 3 2": 219, "I 41 3 2": 220, "P -4 3 m": 221, "F -4 3 m": 222, "I -4 3 m": 223, "P -4 3 n": 224, "F -4 3 c": 225, "I -4 3 d": 226, "P 4/m -3 2/m": 227, "P m -3 m": 227, "P 4/n -3 2/n": 228, "P n -3 n": 228, "P 42/m -3 2/n": 229, "P m -3 n": 229, "P 42/n -3 2/m": 230, "P n -3 m": 230, "F 4/m -3 2/m": 231, "F m -3 m": 231, "F 4/m -3 2/c": 232, "F m -3 c": 232, "F 41/d -3 2/m": 233, "F d -3 m": 233, "F 41/d -3 2/c": 234, "F d -3 c": 234, "I 4/m -3 2/m": 235, "I m -3 m": 235, "I 41/a -3 2/d": 236, "I a -3 d": 236, "P 1 1 2": 237, "P 1 1 21": 238, "B 1 1 2": 239, "B 2": 239, "A 1 2 1": 240, "C 1 21 1": 241, "I 1 2 1": 242, "I 2": 242, "I 1 21 1": 243, "P 1 1 m": 244, "P 1 1 b": 245, "B 1 1 m": 246, "B 1 1 b": 247, "P 1 1 2/m": 248, "P 1 1 21/m": 249, "B 1 1 2/m": 250, "P 1 1 2/b": 251, "P 1 1 21/b": 252, "P 1 21/n 1": 253, "P 1 21/a 1": 254, "B 1 1 2/b": 255, "P 21 2 2": 256, "P 2 21 2": 257, "P 21 21 2 (a)": 258, "P 21 2 21": 259, "P 2 21 21": 260, "C 2 2 21a)": 261, "C 2 2 2a": 262, "F 2 2 2a": 263, "I 2 2 2a": 264, "P 21/m 21/m 2/n a": 265, "P 42 21 2a": 266, "I 2 3a": 267 };
function nK(e) {
  if (e < 146) return e + 1;
  if (e === 146) return 1146;
  if (e < 149) return e + 1 - 1;
  if (e === 149) return 1148;
  if (e < 157) return e + 1 - 2;
  if (e === 157) return 1155;
  if (e < 163) return e + 1 - 3;
  if (e === 163) return 1160;
  if (e < 165) return e + 1 - 4;
  if (e === 165) return 1161;
  if (e < 171) return e + 1 - 5;
  if (e === 171) return 1166;
  if (e < 173) return e + 1 - 6;
  if (e === 173) return 1167;
  if (e < 237) return e + 1 - 7;
  if (e === 237) return 1003;
  if (e === 238) return 1004;
  if (e === 239) return 1005;
  if (e === 240) return 2005;
  if (e === 241) return 3005;
  if (e === 242) return 4005;
  if (e === 243) return 5005;
  if (e === 244) return 1006;
  if (e === 245) return 1007;
  if (e === 246) return 1008;
  if (e === 247) return 1009;
  if (e === 248) return 1010;
  if (e === 249) return 1011;
  if (e === 250) return 1012;
  if (e === 251) return 1013;
  if (e === 252) return 1014;
  if (e === 253) return 2014;
  if (e === 254) return 3014;
  if (e === 255) return 1015;
  if (e === 256) return 1017;
  if (e === 257) return 2017;
  if (e === 258) return 1018;
  if (e === 259) return 2018;
  if (e === 260) return 3018;
  if (e === 261) return 1020;
  if (e === 262) return 1021;
  if (e === 263) return 1022;
  if (e === 264) return 1023;
  if (e === 265) return 1059;
  if (e === 266) return 1094;
  if (e === 267) return 1197;
  throw new Error("unknown spacegroup index '".concat(e, "'"));
}
var Tu, ho, rd, yi, IM = function() {
  for (var e = /* @__PURE__ */ Object.create(null), t = 0, r = Object.keys(em); t < r.length; t++) {
    var n = r[t];
    e[em[n]] = n;
  }
  return e;
}(), iK = function() {
  for (var e = /* @__PURE__ */ Object.create(null), t = 0, r = Object.keys(em); t < r.length; t++) {
    var n = r[t], i = em[n];
    e[i] = nK(i);
  }
  return e;
}();
function W9(e) {
  var t = typeof e == "number" ? function(r) {
    switch (r) {
      case 1146:
        return 146;
      case 1148:
        return 149;
      case 1155:
        return 157;
      case 1160:
        return 163;
      case 1161:
        return 165;
      case 1166:
        return 171;
      case 1167:
        return 173;
      case 1003:
        return 237;
      case 1004:
        return 238;
      case 1005:
        return 239;
      case 2005:
        return 240;
      case 3005:
        return 241;
      case 4005:
        return 242;
      case 5005:
        return 243;
      case 1006:
        return 244;
      case 1007:
        return 245;
      case 1008:
        return 246;
      case 1009:
        return 247;
      case 1010:
        return 248;
      case 1011:
        return 249;
      case 1012:
        return 250;
      case 1013:
        return 251;
      case 1014:
        return 252;
      case 2014:
        return 253;
      case 3014:
        return 254;
      case 1015:
        return 255;
      case 1017:
        return 256;
      case 2017:
        return 257;
      case 1018:
        return 258;
      case 2018:
        return 259;
      case 3018:
        return 260;
      case 1020:
        return 261;
      case 1021:
        return 262;
      case 1022:
        return 263;
      case 1023:
        return 264;
      case 1059:
        return 265;
      case 1094:
        return 266;
      case 1197:
        return 267;
    }
    var n = 0;
    return r > 146 && ++n, r > 148 && ++n, r > 155 && ++n, r > 160 && ++n, r > 161 && ++n, r > 166 && ++n, r > 167 && ++n, r - 1 + n;
  }(e) : em[e];
  return t === void 0 || IM[t] === void 0 ? -1 : t;
}
function hc() {
  return hc.empty();
}
function zy(e, t, r, n) {
  n = e[t], e[t] = e[r], e[r] = n;
}
function aK(e, t) {
  return (e = Math.abs(e)) > (t = Math.abs(t)) ? (t /= e, e * Math.sqrt(1 + t * t)) : t > 0 ? (e /= t, t * Math.sqrt(1 + e * e)) : 0;
}
(function(e) {
  function t(r, n, i) {
    var a = W9(r);
    if (a < 0) return console.warn("Unknown spacegroup '".concat(r, "', returning a 'P 1' with cellsize [1, 1, 1]")), e.Zero;
    var o = n[0] * n[1] * n[2], u = i[0], s = i[1], c = i[2], l = n[0], d = n[1], f = n[2], m = Math.cos(s), v = (Math.cos(u) - Math.cos(s) * Math.cos(c)) / Math.sin(c), p = Math.sqrt(1 - m * m - v * v), g = [l, 0, 0], h = [Math.cos(c) * d, Math.sin(c) * d, 0], y = [m * f, v * f, p * f], x = me.ofRows([[g[0], h[0], y[0], 0], [0, h[1], y[1], 0], [0, 0, y[2], 0], [0, 0, 0, 1]]);
    return { index: a, size: n, volume: o, anglesInRadians: i, toFractional: me.invert(me.zero(), x), fromFractional: x };
  }
  e.Zero = t("P 1", w.create(1, 1, 1), w.create(Math.PI / 2, Math.PI / 2, Math.PI / 2)), e.isZero = function(r) {
    return !r || r.index === 0 && r.size[0] === 1 && r.size[1] === 1 && r.size[1] === 1;
  }, e.create = t, e.createMaterial = function(r, n, i, a, o, u) {
    var s = W9(r);
    return s < 0 ? (console.warn("Unknown spacegroup '".concat(r, "', returning a 'P 1' with cellsize [1, 1, 1]")), e.Zero) : { index: s, size: n, volume: a, anglesInRadians: i, toFractional: o, fromFractional: u };
  };
})(Tu || (Tu = {})), function(e) {
  function t(f) {
    var m = rK[f.index].map(function(v) {
      return g = ky[(p = tK[v])[0]], h = ky[p[1]], y = ky[p[2]], me.ofRows([g, h, y, [0, 0, 0, 1]]);
      var p, g, h, y;
    });
    return { name: IM[f.index], num: iK[f.index], cell: f, operators: m };
  }
  e.ZeroP1 = t(Tu.Zero), e.create = t;
  var r = w(), n = me();
  function i(f, m, v, p, g, h) {
    return w.set(r, v, p, g), me.fromTranslation(n, r), me.mul(h, me.mul(h, me.mul(h, f.cell.fromFractional, n), f.operators[m]), f.cell.toFractional);
  }
  e.setOperatorMatrix = i, e.getSymmetryOperator = function(f, m, v, p, g) {
    var h = i(f, m, v, p, g, me.zero());
    return hn.create("".concat(m + 1, "_").concat(5 + v).concat(5 + p).concat(5 + g), h, { hkl: w.create(v, p, g), spgrOp: m });
  };
  var a = w(), o = w(), u = w(), s = w();
  function c(f, m, v) {
    var p = [];
    if (f > 0 ? p.push("+X") : f < 0 && p.push("-X"), m > 0 ? p.push("+Y") : m < 0 && p.push("-Y"), v > 0 ? p.push("+Z") : v < 0 && p.push("-Z"), p.length === 1) return p[0].charAt(0) === "+" ? p[0].substr(1) : p[0];
    if (p.length === 2) {
      var g = p[0].charAt(0), h = p[1].charAt(0);
      if (g === "+") return "".concat(p[0].substr(1)).concat(p[1]);
      if (h === "+") return "".concat(p[1].substr(1)).concat(p[0]);
    }
    throw new Error("unknown rotation '".concat(p, "', ").concat(f, " ").concat(m, " ").concat(v));
  }
  function l(f) {
    switch (f) {
      case 0.5:
        return "1/2";
      case 1 / 4:
        return "1/4";
      case 3 / 4:
        return "3/4";
      case 1 / 3:
        return "1/3";
      case 2 / 3:
        return "2/3";
      case 1 / 6:
        return "1/6";
      case 5 / 6:
        return "5/6";
    }
    return "";
  }
  function d(f, m) {
    return m === "" ? f : f.length > 2 ? "".concat(f, "+").concat(m) : f.charAt(0) === "-" ? "".concat(m).concat(f) : "".concat(m, "+").concat(f);
  }
  e.getSymmetryOperatorRef = function(f, m, v, p, g, h) {
    var y = me.zero();
    w.set(r, v, p, g), w.floor(a, h), me.copy(y, f.operators[m]), w.floor(o, w.transformMat4(o, h, y)), me.getTranslation(s, y), w.sub(s, s, o), w.add(s, s, a), w.add(s, s, r), me.setTranslation(y, s), me.mul(y, f.cell.fromFractional, y), me.mul(y, y, f.cell.toFractional), w.sub(u, o, a);
    var x = v - u[0], A = p - u[1], b = g - u[2];
    return hn.create("".concat(m + 1, "_").concat(5 + x).concat(5 + A).concat(5 + b), y, { hkl: w.create(x, A, b), spgrOp: m });
  }, e.getOperatorXyz = function(f) {
    return [d(c(f[0], f[4], f[8]), l(f[12])), d(c(f[1], f[5], f[9]), l(f[13])), d(c(f[2], f[6], f[10]), l(f[14]))].join(",");
  };
}(ho || (ho = {})), function(e) {
  e.add = function(t, r, n) {
    t.squaredDistances[t.count] = n, t.indices[t.count++] = r;
  }, e.reset = function(t) {
    t.count = 0;
  }, e.create = function() {
    return { count: 0, indices: [], squaredDistances: [] };
  }, e.copy = function(t, r) {
    for (var n = 0; n < r.count; ++n) t.indices[n] = r.indices[n], t.squaredDistances[n] = r.squaredDistances[n];
    return t.count = r.count, t;
  };
}(rd || (rd = {})), function(e) {
  function t() {
    return { origin: w(), dirA: w(), dirB: w(), dirC: w() };
  }
  function r(o, u) {
    return w.copy(o.origin, u.origin), w.copy(o.dirA, u.dirA), w.copy(o.dirB, u.dirB), w.copy(o.dirC, u.dirC), o;
  }
  function n(o, u) {
    return w.set(o, 2 * w.magnitude(u.dirA), 2 * w.magnitude(u.dirB), 2 * w.magnitude(u.dirC));
  }
  e.create = function(o, u, s, c) {
    return { origin: o, dirA: u, dirB: s, dirC: c };
  }, e.empty = t, e.copy = r, e.clone = function(o) {
    return r(t(), o);
  }, e.size = n;
  var i = w();
  e.volume = function(o) {
    return n(i, o), i[0] * i[1] * i[2];
  }, e.normalize = function(o, u) {
    return w.copy(o.origin, u.origin), w.normalize(o.dirA, u.dirA), w.normalize(o.dirB, u.dirB), w.normalize(o.dirC, u.dirC), o;
  };
  var a = Ti();
  e.transform = function(o, u, s) {
    w.transformMat4(o.origin, u.origin, s);
    var c = Ti.directionTransform(a, s);
    return w.transformMat3(o.dirA, u.dirA, c), w.transformMat3(o.dirB, u.dirB, c), w.transformMat3(o.dirC, u.dirC, c), o;
  }, e.scale = function(o, u, s) {
    return w.scale(o.dirA, u.dirA, s), w.scale(o.dirB, u.dirB, s), w.scale(o.dirC, u.dirC, s), o;
  };
}(hc || (hc = {})), function(e) {
  e.create = function(t, r, n) {
    n === void 0 && (n = Float32Array);
    var i = t * r;
    return { data: new n(i), size: i, cols: t, rows: r };
  }, e.get = function(t, r, n) {
    return t.data[t.rows * n + r];
  }, e.set = function(t, r, n, i) {
    return t.data[t.rows * n + r] = i, t;
  }, e.add = function(t, r, n, i) {
    return t.data[t.rows * n + r] += i, t;
  }, e.makeZero = function(t) {
    return t.data.fill(0), t;
  }, e.clone = function(t) {
    return { data: t.data.slice(), size: t.size, cols: t.cols, rows: t.rows };
  }, e.fromArray = function(t, r, n) {
    return { data: t, size: r * n, cols: r, rows: n };
  }, e.transpose = function(t, r) {
    if (t.cols !== r.rows || t.rows !== r.cols) throw new Error("transpose: matrix dimensions incompatible");
    if (t.data === r.data) throw new Error("transpose: matrices share memory");
    for (var n = r.rows, i = r.cols, a = r.data, o = t.data, u = 0, s = 0, c = 0; u < n; c += 1, s += i, ++u) for (var l = c, d = 0; d < i; l += n, d++) o[l] = a[s + d];
    return t;
  }, e.multiplyABt = function(t, r, n) {
    for (var i = r.cols, a = r.rows, o = n.rows, u = r.data, s = n.data, c = t.data, l = 0, d = 0, f = 0; l < a; d += i, l++) for (var m = 0, v = 0; v < o; f++, v++) {
      for (var p = 0, g = d, h = 0; h < i; g++, m++, h++) p += u[g] * s[m];
      c[f] = p;
    }
    return t;
  }, e.meanRows = function(t) {
    for (var r = t.rows, n = t.cols, i = t.data, a = new Array(n), o = 0; o < n; ++o) a[o] = 0;
    for (var u = 0, s = 0; u < r; ++u) for (o = 0; o < n; ++o, ++s) a[o] += i[s];
    for (o = 0; o < n; ++o) a[o] /= r;
    return a;
  }, e.subRows = function(t, r) {
    for (var n = t.rows, i = t.cols, a = t.data, o = 0, u = 0; o < n; ++o) for (var s = 0; s < i; ++s, ++u) a[u] -= r[s];
    return t;
  };
}(yi || (yi = {}));
var Wl, oK = 1192092896e-16, uK = 1e-37;
function sK(e, t, r, n) {
  var i = 0, a = 0, o = e.rows, u = e.cols, s = o, c = u;
  s < c && (i = 1, a = s, s = c, c = a);
  var l = yi.create(s, s), d = yi.create(1, c), f = yi.create(c, c);
  if (i === 0) yi.transpose(l, e);
  else {
    for (a = 0; a < u * o; a++) l.data[a] = e.data[a];
    for (; a < c * s; a++) l.data[a] = 0;
  }
  if (function(m, v, p, g, h, y, x, A) {
    for (var b = 2 * oK, _ = uK, S = 0, D = 0, I = 0, M = 0, F = Math.max(y, 30), P = 0, E = 0, B = 0, N = 0, O = 0, z = 0, V = 0, U = 0, H = 0, K = 0, j = 0, X = 0, W = 0, Q = 0, te = 0, ee = 0, $ = 0, ie = 4660, ae = 0, se = 0, le = 0, pe = new Float64Array(x << 3); S < x; S++) {
      for (I = 0, j = 0; I < y; I++) j += (U = m[S * v + I]) * U;
      if (pe[S] = j, g) {
        for (I = 0; I < x; I++) g[S * h + I] = 0;
        g[S * h + S] = 1;
      }
    }
    for (; M < F; M++) {
      for (O = 0, S = 0; S < x - 1; S++) for (D = S + 1; D < x; D++) {
        for (P = S * v | 0, E = D * v | 0, te = pe[S], ee = 0, $ = pe[D], I = 2, ee += m[P] * m[E], ee += m[P + 1] * m[E + 1]; I < y; I++) ee += m[P + I] * m[E + I];
        if (!(Math.abs(ee) <= b * Math.sqrt(te * $))) {
          for (W = aK(ee *= 2, X = te - $), X < 0 ? (Q = 0.5 * (W - X), z = ee / (W * (V = Math.sqrt(Q / W)) * 2)) : V = ee / (W * (z = Math.sqrt((W + X) / (2 * W))) * 2), te = 0, $ = 0, I = 2, H = z * m[P] + V * m[E], K = -V * m[P] + z * m[E], m[P] = H, m[E] = K, te += H * H, $ += K * K, H = z * m[P + 1] + V * m[E + 1], K = -V * m[P + 1] + z * m[E + 1], m[P + 1] = H, m[E + 1] = K, te += H * H, $ += K * K; I < y; I++) H = z * m[P + I] + V * m[E + I], K = -V * m[P + I] + z * m[E + I], m[P + I] = H, m[E + I] = K, te += H * H, $ += K * K;
          if (pe[S] = te, pe[D] = $, O = 1, g) for (N = D * h | 0, I = 2, H = z * g[B = S * h | 0] + V * g[N], K = -V * g[B] + z * g[N], g[B] = H, g[N] = K, H = z * g[B + 1] + V * g[N + 1], K = -V * g[B + 1] + z * g[N + 1], g[B + 1] = H, g[N + 1] = K; I < x; I++) H = z * g[B + I] + V * g[N + I], K = -V * g[B + I] + z * g[N + I], g[B + I] = H, g[N + I] = K;
        }
      }
      if (O === 0) break;
    }
    for (S = 0; S < x; S++) {
      for (I = 0, j = 0; I < y; I++) j += (U = m[S * v + I]) * U;
      pe[S] = Math.sqrt(j);
    }
    for (S = 0; S < x - 1; S++) {
      for (D = S, I = S + 1; I < x; I++) pe[D] < pe[I] && (D = I);
      if (S !== D && (zy(pe, S, D, j), g)) {
        for (I = 0; I < y; I++) zy(m, S * v + I, D * v + I, U);
        for (I = 0; I < x; I++) zy(g, S * h + I, D * h + I, U);
      }
    }
    for (S = 0; S < x; S++) p[S] = pe[S];
    if (g) for (S = 0; S < A; S++) {
      for (j = S < x ? pe[S] : 0; j <= _; ) {
        for (se = 1 / y, I = 0; I < y; I++) ae = 256 & (ie = 214013 * ie + 2531011) >> 16 ? se : -se, m[S * v + I] = ae;
        for (M = 0; M < 2; M++) for (D = 0; D < S; D++) {
          for (j = 0, I = 0; I < y; I++) j += m[S * v + I] * m[D * v + I];
          for (le = 0, I = 0; I < y; I++) U = m[S * v + I] - j * m[D * v + I], m[S * v + I] = U, le += Math.abs(U);
          for (le = le ? 1 / le : 0, I = 0; I < y; I++) m[S * v + I] *= le;
        }
        for (j = 0, I = 0; I < y; I++) j += (U = m[S * v + I]) * U;
        j = Math.sqrt(j);
      }
      for (V = 1 / j, I = 0; I < y; I++) m[S * v + I] *= V;
    }
  }(l.data, s, d.data, f.data, c, s, c, s), t) {
    for (a = 0; a < c; a++) t.data[a] = d.data[a];
    for (; a < u; a++) t.data[a] = 0;
  }
  i === 0 ? (r && yi.transpose(r, l), n && yi.transpose(n, f)) : (r && yi.transpose(r, f), n && yi.transpose(n, l));
}
function Me() {
  return Me.zero();
}
function qr() {
  return qr.zero();
}
function lf(e, t, r) {
  return new cK(e, t, r);
}
(function(e) {
  function t(u) {
    if (u.length === 3) return hc.create(w.fromArray(w(), u, 0), w.create(1, 0, 0), w.create(0, 1, 0), w.create(0, 1, 0));
    var s = yi.fromArray(u, 3, u.length / 3), c = s.rows, l = c / 3, d = yi.create(3, 3), f = yi.create(1, 3), m = yi.create(3, 3), v = yi.create(3, 3), p = yi.meanRows(s), g = yi.subRows(yi.clone(s), p), h = yi.transpose(yi.create(c, 3), g);
    yi.multiplyABt(d, h, h), sK(d, f, m, v);
    var y = w.create(p[0], p[1], p[2]), x = w.create(m.data[0], m.data[3], m.data[6]), A = w.create(m.data[1], m.data[4], m.data[7]), b = w.create(m.data[2], m.data[5], m.data[8]);
    return w.scale(x, x, Math.sqrt(f.data[0] / l)), w.scale(A, A, Math.sqrt(f.data[1] / l)), w.scale(b, b, Math.sqrt(f.data[2] / l)), hc.create(y, x, A, b);
  }
  e.ofPositions = function(u) {
    var s = t(u);
    return { momentsAxes: s, boxAxes: o(u, s) };
  }, e.calculateMomentsAxes = t;
  var r = w(), n = w(), i = w(), a = w();
  function o(u, s) {
    if (u.length === 3) return hc.clone(s);
    for (var c = -1 / 0, l = -1 / 0, d = -1 / 0, f = -1 / 0, m = -1 / 0, v = -1 / 0, p = w(), g = w(), h = s.origin, y = w.normalize(n, s.dirA), x = w.normalize(i, s.dirB), A = w.normalize(a, s.dirC), b = 0, _ = u.length; b < _; b += 3) {
      w.projectPointOnVector(p, w.fromArray(p, u, b), y, h);
      var S = w.dot(y, w.normalize(g, w.sub(g, p, h))), D = w.distance(p, h);
      S > 0 ? D > c && (c = D) : D > l && (l = D), w.projectPointOnVector(p, w.fromArray(p, u, b), x, h);
      var I = w.dot(x, w.normalize(g, w.sub(g, p, h))), M = w.distance(p, h);
      I > 0 ? M > d && (d = M) : M > f && (f = M), w.projectPointOnVector(p, w.fromArray(p, u, b), A, h);
      var F = w.dot(A, w.normalize(g, w.sub(g, p, h))), P = w.distance(p, h);
      F > 0 ? P > m && (m = P) : P > v && (v = P);
    }
    var E = w.setMagnitude(w(), y, (c + l) / 2), B = w.setMagnitude(w(), x, (d + f) / 2), N = w.setMagnitude(w(), A, (m + v) / 2), O = w(), z = function(V, U, H) {
      w.copy(r, h), w.scaleAndAdd(r, r, y, V), w.scaleAndAdd(r, r, x, U), w.scaleAndAdd(r, r, A, H), w.add(O, O, r);
    };
    return z(c, d, m), z(c, d, -v), z(c, -f, -v), z(c, -f, m), z(-l, -f, -v), z(-l, -f, m), z(-l, d, m), z(-l, d, -v), w.scale(O, O, 1 / 8), hc.create(O, E, B, N);
  }
  e.calculateBoxAxes = o;
})(Wl || (Wl = {})), function(e) {
  function t(u) {
    return u.extrema !== void 0;
  }
  function r(u, s) {
    return { center: u, radius: s };
  }
  function n(u, s) {
    var c;
    return u.extrema !== void 0 ? (u.extrema.length = 0, (c = u.extrema).push.apply(c, s)) : u.extrema = s, u;
  }
  e.hasExtrema = t, e.create = r, e.zero = function() {
    return { center: w(), radius: 0 };
  }, e.clone = function(u) {
    var s = r(w.clone(u.center), u.radius);
    return t(u) && (s.extrema = u.extrema.map(function(c) {
      return w.clone(c);
    })), s;
  }, e.set = function(u, s, c) {
    return w.copy(u.center, s), u.radius = c, u;
  }, e.copy = function(u, s) {
    return w.copy(u.center, s.center), u.radius = s.radius, t(s) && n(u, s.extrema.map(function(c) {
      return w.clone(c);
    })), u;
  }, e.setExtrema = n, e.computeBounding = function(u) {
    for (var s = u.x, c = u.y, l = u.z, d = u.indices, f = 0, m = 0, v = 0, p = 0, g = Le.size(d), h = 0; h < g; h++)
      f += s[y = Le.getAt(d, h)], m += c[y], v += l[y];
    for (g > 0 && (f /= g, m /= g, v /= g), h = 0; h < g; h++) {
      var y, x = s[y = Le.getAt(d, h)] - f, A = c[y] - m, b = l[y] - v, _ = x * x + A * A + b * b;
      _ > p && (p = _);
    }
    return { center: w.create(f, m, v), radius: Math.sqrt(p) };
  }, e.transform = function(u, s, c) {
    return w.transformMat4(u.center, s.center, c), u.radius = s.radius * me.getMaxScaleOnAxis(c), t(s) && n(u, s.extrema.map(function(l) {
      return w.transformMat4(w(), l, c);
    })), u;
  }, e.translate = function(u, s, c) {
    return w.add(u.center, s.center, c), t(s) && n(u, s.extrema.map(function(l) {
      return w.add(w(), l, c);
    })), u;
  }, e.toArray = function(u, s, c) {
    w.toArray(u.center, s, c), s[c + 3] = u.radius;
  }, e.fromArray = function(u, s, c) {
    return w.fromArray(u.center, s, c), u.radius = s[c + 3], u;
  }, e.fromBox3D = function(u, s) {
    return w.scale(u.center, w.add(u.center, s.max, s.min), 0.5), u.radius = w.distance(u.center, s.max), e.setExtrema(u, [w.create(s.min[0], s.min[1], s.min[2]), w.create(s.max[0], s.max[1], s.max[2]), w.create(s.max[0], s.min[1], s.min[2]), w.create(s.min[0], s.max[1], s.max[2]), w.create(s.min[0], s.min[1], s.max[2]), w.create(s.max[0], s.min[1], s.max[2]), w.create(s.max[0], s.max[1], s.min[2]), w.create(s.min[0], s.max[1], s.min[2])]), u;
  }, e.fromAxes3D = function(u, s) {
    return w.copy(u.center, s.origin), u.radius = Math.max(w.magnitude(s.dirA), w.magnitude(s.dirB), w.magnitude(s.dirC)), u;
  };
  var i = w();
  e.fromDimensionsAndTransform = function(u, s, c) {
    var l = s[0], d = s[1], f = s[2], m = w.create(0, 0, 0);
    w.transformMat4(m, m, c);
    var v = w.create(l, d, f);
    w.transformMat4(v, v, c);
    var p = w.create(l, 0, 0);
    w.transformMat4(p, p, c);
    var g = w.create(0, d, f);
    w.transformMat4(g, g, c);
    var h = w.create(0, 0, f);
    w.transformMat4(h, h, c);
    var y = w.create(l, 0, f);
    w.transformMat4(y, y, c);
    var x = w.create(l, d, 0);
    w.transformMat4(x, x, c);
    var A = w.create(0, d, 0);
    w.transformMat4(A, A, c), w.add(i, m, v), w.scale(i, i, 0.5);
    var b = Math.max(w.distance(m, v), w.distance(p, g));
    return e.set(u, i, b / 2), e.setExtrema(u, [m, v, p, g, h, y, x, A]), u;
  };
  var a = w();
  e.addVec3 = function(u, s, c) {
    return w.distance(s.center, c) < s.radius ? e.copy(u, s) : (w.sub(a, s.center, c), w.sub(a, s.center, a), w.setMagnitude(a, a, s.radius), w.scale(u.center, w.add(a, a, c), 0.5), u.radius = w.distance(u.center, c), u);
  }, e.expandBySphere = function(u, s, c) {
    return w.copy(u.center, s.center), u.radius = Math.max(s.radius, w.distance(s.center, c.center) + c.radius), t(s) && t(c) && n(u, We(We([], s.extrema.map(function(l) {
      return w.clone(l);
    }), !0), c.extrema.map(function(l) {
      return w.clone(l);
    }), !0)), u;
  };
  var o = w();
  e.expand = function(u, s, c) {
    var l, d;
    if (w.copy(u.center, s.center), u.radius = s.radius + c, s.radius < 1e-12 || ((d = (l = s.extrema) === null || l === void 0 ? void 0 : l.length) !== null && d !== void 0 ? d : 0) <= 1) return u.extrema = void 0, u;
    if (t(s)) {
      for (var f = new Float32Array(3 * s.extrema.length), m = 0; m < s.extrema.length; m++) w.toArray(s.extrema[m], f, 3 * m);
      var v = Wl.calculateMomentsAxes(f);
      hc.scale(v, hc.normalize(v, v), c), n(u, s.extrema.map(function(p) {
        w.normalize(o, w.sub(o, p, s.center));
        var g = w.clone(p), h = w.dot(o, v.dirA) < 0 ? -1 : 1;
        w.scaleAndAdd(g, g, v.dirA, h);
        var y = w.dot(o, v.dirB) < 0 ? -1 : 1;
        w.scaleAndAdd(g, g, v.dirB, y);
        var x = w.dot(o, v.dirC) < 0 ? -1 : 1;
        return w.scaleAndAdd(g, g, v.dirC, x), w.distance(u.center, g) > u.radius && (s.extrema.length >= 14 && w.normalize(o, w.sub(o, g, s.center)), w.scaleAndAdd(g, u.center, o, u.radius)), g;
      }));
    }
    return u;
  }, e.exactEquals = function(u, s) {
    return u.radius === s.radius && w.exactEquals(u.center, s.center);
  }, e.equals = function(u, s) {
    var c = u.radius, l = s.radius;
    return Math.abs(c - l) <= pn * Math.max(1, Math.abs(c), Math.abs(l)) && w.equals(u.center, s.center);
  }, e.includes = function(u, s) {
    if (t(s)) {
      for (var c = 0, l = s.extrema; c < l.length; c++) {
        var d = l[c];
        if (w.distance(u.center, d) > u.radius) return !1;
      }
      return !0;
    }
    return w.distance(u.center, s.center) + s.radius <= u.radius;
  }, e.overlaps = function(u, s) {
    return w.distance(u.center, s.center) <= u.radius + s.radius;
  }, e.distance = function(u, s) {
    return w.distance(u.center, s.center) - u.radius + s.radius;
  };
}(Me || (Me = {})), function(e) {
  function t() {
    return { min: w(), max: w() };
  }
  function r(c, l) {
    return w.copy(c.min, l.min), w.copy(c.max, l.max), c;
  }
  function n(c, l) {
    e.setEmpty(c);
    for (var d = 0, f = l.length; d < f; d++) e.add(c, l[d]);
    return c;
  }
  function i(c, l) {
    return w.sub(c, l.max, l.min);
  }
  e.create = function(c, l) {
    return { min: c, max: l };
  }, e.zero = t, e.copy = r, e.clone = function(c) {
    return r(t(), c);
  }, e.fromSphere3D = function(c, l) {
    if (Me.hasExtrema(l) && l.extrema.length >= 14) return n(c, l.extrema);
    var d = w.create(l.radius, l.radius, l.radius);
    return w.sub(c.min, l.center, d), w.add(c.max, l.center, d), c;
  }, e.fromVec3Array = n, e.computeBounding = function(c) {
    for (var l = w.create(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), d = w.create(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), f = c.x, m = c.y, v = c.z, p = c.indices, g = 0, h = Le.size(p); g < h; g++) {
      var y = Le.getAt(p, g);
      l[0] = Math.min(f[y], l[0]), l[1] = Math.min(m[y], l[1]), l[2] = Math.min(v[y], l[2]), d[0] = Math.max(f[y], d[0]), d[1] = Math.max(m[y], d[1]), d[2] = Math.max(v[y], d[2]);
    }
    return { min: l, max: d };
  }, e.size = i;
  var a = w();
  function o(c) {
    return w.set(c.min, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), w.set(c.max, -Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), c;
  }
  function u(c, l) {
    return w.min(c.min, c.min, l), w.max(c.max, c.max, l), c;
  }
  e.volume = function(c) {
    return i(a, c), a[0] * a[1] * a[2];
  }, e.setEmpty = o, e.add = u, e.expand = function(c, l, d) {
    return w.sub(c.min, l.min, d), w.add(c.max, l.max, d), c;
  }, e.scale = function(c, l, d) {
    return w.scale(c.min, l.min, d), w.scale(c.max, l.max, d), c;
  };
  var s = w();
  e.transform = function(c, l, d) {
    var f = l.min, m = f[0], v = f[1], p = f[2], g = l.max, h = g[0], y = g[1], x = g[2];
    return o(c), u(c, w.transformMat4(s, w.set(s, m, v, p), d)), u(c, w.transformMat4(s, w.set(s, m, v, x), d)), u(c, w.transformMat4(s, w.set(s, m, y, p), d)), u(c, w.transformMat4(s, w.set(s, m, y, x), d)), u(c, w.transformMat4(s, w.set(s, h, v, p), d)), u(c, w.transformMat4(s, w.set(s, h, v, x), d)), u(c, w.transformMat4(s, w.set(s, h, y, p), d)), u(c, w.transformMat4(s, w.set(s, h, y, x), d)), c;
  }, e.containsVec3 = function(c, l) {
    return !(l[0] < c.min[0] || l[0] > c.max[0] || l[1] < c.min[1] || l[1] > c.max[1] || l[2] < c.min[2] || l[2] > c.max[2]);
  };
}(qr || (qr = {}));
var at, cK = function() {
  function e(t, r, n) {
    var i = function(a, o, u) {
      var s, c, l = qr.expand(qr(), o.box, w.create(0.5, 0.5, 0.5)), d = a.indices, f = qr.size(w.zero(), l), m = Le.size(d), v = typeof u == "number" ? u : 32, p = Array.isArray(u) && u;
      if (p) c = [Math.ceil(f[0] / p[0]), Math.ceil(f[1] / p[1]), Math.ceil(f[2] / p[2])], s = p;
      else if (m > 0) {
        var g = Math.ceil(m / v), h = Math.pow(g / (f[0] * f[1] * f[2]), 1 / 3);
        c = [Math.ceil(f[0] * h), Math.ceil(f[1] * h), Math.ceil(f[2] * h)], s = [f[0] / c[0], f[1] / c[1], f[2] / c[2]];
      } else s = f, c = [1, 1, 1];
      var y = { x: a.x, y: a.y, z: a.z, indices: d, radius: a.radius }, x = { size: c, data: y, expandedBox: l, boundingBox: o.box, boundingSphere: o.sphere, elementCount: m, delta: s };
      return function(A) {
        for (var b = A.expandedBox, _ = A.size, S = _[0], D = _[1], I = _[2], M = A.data, F = M.x, P = M.y, E = M.z, B = M.radius, N = M.indices, O = A.elementCount, z = A.delta, V = S * D * I, U = b.min, H = U[0], K = U[1], j = U[2], X = 0, W = 0, Q = new Uint32Array(V), te = new Int32Array(O), ee = 0; ee < O; ee++) {
          var $ = Le.getAt(N, ee), ie = (Math.floor((F[$] - H) / z[0]) * D + Math.floor((P[$] - K) / z[1])) * I + Math.floor((E[$] - j) / z[2]);
          (Q[ie] += 1) === 1 && (W += 1), te[ee] = ie;
        }
        if (B) for (ee = 0; ee < O; ee++)
          B[$ = Le.getAt(N, ee)] > X && (X = B[$]);
        for (var ae = new Int32Array(W), se = ($ = 0, 0); $ < V; $++) {
          var le = Q[$];
          le > 0 && (Q[$] = se + 1, ae[se] = le, se += 1);
        }
        var pe = new Uint32Array(W);
        for ($ = 1; $ < W; ++$) pe[$] += pe[$ - 1] + ae[$ - 1];
        var we = new Int32Array(W), Ge = new Int32Array(O);
        for ($ = 0; $ < O; $++) {
          var Ue = Q[te[$]];
          if (Ue > 0) {
            var Ke = Ue - 1;
            Ge[pe[Ke] + we[Ke]] = $, we[Ke] += 1;
          }
        }
        return { size: A.size, bucketArray: Ge, bucketCounts: ae, bucketOffset: pe, grid: Q, delta: z, min: A.expandedBox.min, data: A.data, maxRadius: X, expandedBox: A.expandedBox, boundingBox: A.boundingBox, boundingSphere: A.boundingSphere };
      }(x);
    }(t, r, n);
    this.ctx = { grid: i, x: 0.1, y: 0.1, z: 0.1, radius: 0.1, isCheck: !1 }, this.boundary = { box: i.boundingBox, sphere: i.boundingSphere }, this.buckets = { offset: i.bucketOffset, count: i.bucketCounts, array: i.bucketArray }, this.result = rd.create();
  }
  return e.prototype.find = function(t, r, n, i, a) {
    this.ctx.x = t, this.ctx.y = r, this.ctx.z = n, this.ctx.radius = i, this.ctx.isCheck = !1;
    var o = a ?? this.result;
    return Z9(this.ctx, o), o;
  }, e.prototype.check = function(t, r, n, i) {
    return this.ctx.x = t, this.ctx.y = r, this.ctx.z = n, this.ctx.radius = i, this.ctx.isCheck = !0, Z9(this.ctx, this.result);
  }, e;
}();
function Z9(e, t) {
  var r = e.grid, n = r.min, i = r.size, a = i[0], o = i[1], u = i[2], s = r.bucketOffset, c = r.bucketCounts, l = r.bucketArray, d = r.grid, f = r.data, m = f.x, v = f.y, p = f.z, g = f.indices, h = f.radius, y = r.delta, x = r.maxRadius, A = e.radius, b = e.isCheck, _ = e.x, S = e.y, D = e.z, I = A + x, M = I * I;
  rd.reset(t);
  var F = Math.max(0, Math.floor((_ - I - n[0]) / y[0])), P = Math.max(0, Math.floor((S - I - n[1]) / y[1])), E = Math.max(0, Math.floor((D - I - n[2]) / y[2])), B = Math.min(a - 1, Math.floor((_ + I - n[0]) / y[0])), N = Math.min(o - 1, Math.floor((S + I - n[1]) / y[1])), O = Math.min(u - 1, Math.floor((D + I - n[2]) / y[2]));
  if (F > B || P > N || E > O) return !1;
  for (var z = F; z <= B; z++) for (var V = P; V <= N; V++) for (var U = E; U <= O; U++) {
    var H = d[(z * o + V) * u + U];
    if (H !== 0) for (var K = H - 1, j = s[K], X = j + c[K], W = j; W < X; W++) {
      var Q = Le.getAt(g, l[W]), te = m[Q] - _, ee = v[Q] - S, $ = p[Q] - D, ie = te * te + ee * ee + $ * $;
      if (ie <= M) {
        if (x > 0 && Math.sqrt(ie) - h[Q] > A) continue;
        if (b) return !0;
        rd.add(t, l[W], ie);
      }
    }
  }
  return t.count > 0;
}
(function(e) {
  function t(i, a, o) {
    return { kind: "element-location", structure: i, unit: a, element: o || 0 };
  }
  e.create = t, e.clone = function(i) {
    return t(i.structure, i.unit, i.element);
  }, e.set = function(i, a, o, u) {
    return a && (i.structure = a), o && (i.unit = o), u !== void 0 && (i.element = u), i;
  }, e.copy = function(i, a) {
    return i.unit = a.unit, i.element = a.element, i;
  }, e.is = function(i) {
    return !!i && i.kind === "element-location";
  }, e.areEqual = function(i, a) {
    return i.unit === a.unit && i.element === a.element;
  };
  var r = w.zero(), n = w.zero();
  e.distance = function(i, a) {
    return i.unit.conformation.position(i.element, r), a.unit.conformation.position(a.element, n), w.distance(r, n);
  }, e.residueIndex = function(i) {
    return i.unit.model.atomicHierarchy.residueAtomSegments.index[i.element];
  }, e.chainIndex = function(i) {
    return i.unit.model.atomicHierarchy.chainAtomSegments.index[i.element];
  };
})(at || (at = {}));
var lK = function() {
  function e(t, r) {
    this.getHash = t, this.areEqual = r, this.size = 0, this.byHash = /* @__PURE__ */ new Map();
  }
  return e.prototype.add = function(t) {
    var r = this.getHash(t);
    if (this.byHash.has(r)) {
      for (var n = this.byHash.get(r), i = 0, a = n.length; i < a; i++) if (this.areEqual(t, n[i])) return !1;
      return n[n.length] = t, this.size++, !0;
    }
    return this.byHash.set(r, [t]), this.size++, !0;
  }, e.prototype.has = function(t) {
    var r = this.getHash(t);
    if (!this.byHash.has(r)) return !1;
    for (var n = this.byHash.get(r), i = 0, a = n.length; i < a; i++) if (this.areEqual(t, n[i])) return !0;
    return !1;
  }, e;
}();
function p_(e, t) {
  return new lK(e, t);
}
function Q9() {
  return new dK();
}
function J9(e) {
  return { previous: null, next: null, inList: !0, value: e };
}
var cn, xe, ra, xt, vr, dK = function() {
  function e() {
    this.count = 0, this.first = null, this.last = null;
  }
  return e.prototype.addFirst = function(t) {
    var r = J9(t);
    return r.inList = !0, this.first && (this.first.previous = r), r.next = this.first, this.first = r, this.count++, this.last || (this.last = r), r;
  }, e.prototype.addLast = function(t) {
    var r = J9(t);
    return this.last !== null && (this.last.next = r), r.previous = this.last, this.last = r, this.first === null && (this.first = r), r.inList = !0, this.count++, r;
  }, e.prototype.removeFirst = function() {
    var t = this.first;
    if (t) return this.remove(t), t.value;
  }, e.prototype.removeLast = function() {
    var t = this.last;
    if (t) return this.remove(t), t.value;
  }, e.prototype.remove = function(t) {
    t.inList && (t.inList = !1, t.previous !== null ? t.previous.next = t.next : t.previous === null && (this.first = t.next), t.next !== null ? t.next.previous = t.previous : t.next === null && (this.last = t.previous), t.next = null, t.previous = null, this.count--);
  }, e.prototype.find = function(t) {
    for (var r = this.first; r !== null; ) {
      if (r.value === t) return r;
      r = r.next;
    }
  }, e;
}();
function et(e, t) {
  var r = t || {}, n = r.description, i = n === void 0 ? void 0 : n, a = r.isOptional, o = a !== void 0 && a, u = r.isRest, s = u !== void 0 && u, c = r.defaultValue;
  return { type: e, isOptional: o, isRest: s, defaultValue: c === void 0 ? void 0 : c, description: i };
}
function Sp(e, t, r, n) {
  var i = function(a) {
    return ra.Apply(ra.Symbol(i.id), a);
  };
  return i.info = { namespace: "", name: e, description: n }, i.id = "", i.args = t, i.type = r, i;
}
function A2(e) {
  var t = e;
  return typeof t == "function" && !!t.info && !!t.args && typeof t.info.namespace == "string" && !!t.type;
}
function Et(e, t, r) {
  return Sp("", e, t, r);
}
function EM(e) {
  TM("", "", e);
}
function MM(e) {
  var t = [];
  return PM(e, t), t;
}
function $9(e) {
  var t = /([a-z])([A-Z])([a-z]|$)/g;
  return e.replace(t, function(r, n, i, a) {
    return "".concat(n, "-").concat(i.toLocaleLowerCase()).concat(a);
  }).replace(t, function(r, n, i, a) {
    return "".concat(n, "-").concat(i.toLocaleLowerCase()).concat(a);
  });
}
function TM(e, t, r) {
  if (A2(r)) return r.info.namespace = e, r.info.name = r.info.name || $9(t), void (r.id = "".concat(r.info.namespace, ".").concat(r.info.name));
  for (var n = "".concat(r["@namespace"] || $9(t)), i = e ? "".concat(e, ".").concat(n) : n, a = 0, o = Object.keys(r); a < o.length; a++) {
    var u = o[a];
    (typeof r[u] == "object" || A2(r[u])) && TM(i, u, r[u]);
  }
}
function PM(e, t) {
  if (A2(e)) t.push(e);
  else for (var r = 0, n = Object.keys(e); r < n.length; r++) {
    var i = n[r];
    (typeof e[i] == "object" || A2(e[i])) && PM(e[i], t);
  }
}
function Oi(e, t) {
  return Et(xt.Dictionary({ 0: et(e) }), e, t);
}
function sl(e, t) {
  return Et(xt.List(e, { nonEmpty: !0 }), e, t);
}
function fs(e, t, r) {
  return Et(xt.Dictionary({ 0: et(e), 1: et(e) }), t, r);
}
(function(e) {
  e.create = function() {
    return { keys: /* @__PURE__ */ new Set(), array: [] };
  }, e.add = function(t, r, n) {
    var i = t.keys, a = t.array;
    return !i.has(r) && (i.add(r), a[a.length] = n, !0);
  }, e.has = function(t, r) {
    return t.keys.has(r);
  };
})(cn || (cn = {})), function(e) {
  function t(n, i, a) {
    return { kind: "value", namespace: n, name: i, parent: a };
  }
  function r(n, i, a, o) {
    for (var u = /* @__PURE__ */ Object.create(null), s = 0, c = o; s < c.length; s++)
      u[c[s]] = !0;
    return { kind: "oneof", namespace: n, name: i, type: a, values: u };
  }
  e.Variable = function(n, i, a) {
    return { kind: "variable", name: n, type: i, isConstraint: a };
  }, e.Value = t, e.Container = function(n, i, a, o) {
    return { kind: "container", namespace: n, name: i, child: a, alias: o };
  }, e.Union = function(n) {
    return { kind: "union", types: n };
  }, e.OneOf = r, e.Any = { kind: "any" }, e.AnyValue = { kind: "any-value" }, e.Num = t("", "Number"), e.Str = t("", "String"), e.Bool = r("", "Bool", e.Str, ["true", "false"]), e.oneOfValues = function(n) {
    var i = n.values;
    return Object.keys(i).sort();
  };
}(xe || (xe = {})), function(e) {
  function t(n) {
    return !!n && !!n.head && typeof n == "object";
  }
  function r(n) {
    return !!n && typeof n.name == "string";
  }
  e.Symbol = function(n) {
    return { name: n };
  }, e.Apply = function(n, i) {
    return i ? { head: n, args: i } : { head: n };
  }, e.isArgumentsArray = function(n) {
    return !!n && Array.isArray(n);
  }, e.isArgumentsMap = function(n) {
    return !!n && !Array.isArray(n);
  }, e.isLiteral = function(n) {
    return !t(n) && !r(n);
  }, e.isApply = t, e.isSymbol = r;
}(ra || (ra = {})), function(e) {
  function t(r) {
    return { kind: "dictionary", map: r, "@type": 0 };
  }
  e.None = t({}), e.Dictionary = t, e.List = function(r, n) {
    var i = (n || {}).nonEmpty;
    return { kind: "list", type: r, nonEmpty: i !== void 0 && i, "@type": 0 };
  };
}(xt || (xt = {})), function(e) {
  e.AnyVar = xe.Variable("a", xe.Any), e.AnyValueVar = xe.Variable("a", xe.Any), e.ConstrainedVar = xe.Variable("a", xe.Any, !0), e.Regex = xe.Value("Core", "Regex"), e.Set = function(t) {
    return xe.Container("Core", "Set", t || e.AnyValueVar);
  }, e.List = function(t) {
    return xe.Container("Core", "List", t || e.AnyVar);
  }, e.Fn = function(t, r) {
    return xe.Container("Core", "Fn", t || e.AnyVar, r);
  }, e.Flags = function(t, r) {
    return xe.Container("Core", "Flags", t, r);
  }, e.BitFlags = e.Flags(xe.Num, "BitFlags");
}(vr || (vr = {})), xt.Dictionary({ 0: et(xe.Num), 1: et(xe.Num) }), et(xe.Str);
var m_ = { "@header": "Language Primitives", type: { "@header": "Types", bool: Et(xt.Dictionary({ 0: et(xe.AnyValue) }), xe.Bool, "Convert a value to boolean."), num: Et(xt.Dictionary({ 0: et(xe.AnyValue) }), xe.Num, "Convert a value to number."), str: Et(xt.Dictionary({ 0: et(xe.AnyValue) }), xe.Str, "Convert a value to string."), regex: Et(xt.Dictionary({ 0: et(xe.Str, { description: "Expression" }), 1: et(xe.Str, { isOptional: !0, description: "Flags, e.g. 'i' for ignore case" }) }), vr.Regex, "Creates a regular expression from a string using the ECMAscript syntax."), list: Et(xt.List(vr.AnyVar), vr.List()), set: Et(xt.List(vr.AnyValueVar), vr.Set()), bitflags: Et(xt.Dictionary({ 0: et(xe.Num) }), vr.BitFlags, "Interpret a number as bitflags."), compositeKey: Et(xt.List(xe.AnyValue), xe.AnyValue) }, logic: { "@header": "Logic", not: Oi(xe.Bool), and: sl(xe.Bool), or: sl(xe.Bool) }, ctrl: { "@header": "Control", eval: Et(xt.Dictionary({ 0: et(vr.Fn(vr.AnyVar)) }), vr.AnyVar, "Evaluate a function."), fn: Et(xt.Dictionary({ 0: et(vr.AnyVar) }), vr.Fn(vr.AnyVar), 'Wrap an expression to a "lazy" function.'), if: Et(xt.Dictionary({ 0: et(xe.Bool, { description: "Condition" }), 1: et(xe.Variable("a", xe.Any), { description: "If true" }), 2: et(xe.Variable("b", xe.Any), { description: "If false" }) }), xe.Union([xe.Variable("a", xe.Any), xe.Variable("b", xe.Any)])), assoc: Et(xt.Dictionary({ 0: et(xe.Str, { description: "Name" }), 1: et(xe.Variable("a", xe.Any), { description: "Value to assign" }) }), xe.Variable("a", xe.Any)) }, rel: { "@header": "Relational", eq: fs(xe.Variable("a", xe.AnyValue, !0), xe.Bool), neq: fs(xe.Variable("a", xe.AnyValue, !0), xe.Bool), lt: fs(xe.Num, xe.Bool), lte: fs(xe.Num, xe.Bool), gr: fs(xe.Num, xe.Bool), gre: fs(xe.Num, xe.Bool), inRange: Et(xt.Dictionary({ 0: et(xe.Num, { description: "Value to test" }), 1: et(xe.Num, { description: "Minimum value" }), 2: et(xe.Num, { description: "Maximum value" }) }), xe.Bool, "Check if the value of the 1st argument is >= 2nd and <= 3rd.") }, math: { "@header": "Math", add: sl(xe.Num), sub: sl(xe.Num), mult: sl(xe.Num), div: fs(xe.Num, xe.Num), pow: fs(xe.Num, xe.Num), mod: fs(xe.Num, xe.Num), min: sl(xe.Num), max: sl(xe.Num), floor: Oi(xe.Num), ceil: Oi(xe.Num), roundInt: Oi(xe.Num), abs: Oi(xe.Num), sqrt: Oi(xe.Num), cbrt: Oi(xe.Num), sin: Oi(xe.Num), cos: Oi(xe.Num), tan: Oi(xe.Num), asin: Oi(xe.Num), acos: Oi(xe.Num), atan: Oi(xe.Num), sinh: Oi(xe.Num), cosh: Oi(xe.Num), tanh: Oi(xe.Num), exp: Oi(xe.Num), log: Oi(xe.Num), log10: Oi(xe.Num), atan2: fs(xe.Num, xe.Num) }, str: { "@header": "Strings", concat: sl(xe.Str), match: Et(xt.Dictionary({ 0: et(vr.Regex), 1: et(xe.Str) }), xe.Bool) }, list: { "@header": "Lists", getAt: Et(xt.Dictionary({ 0: et(vr.List()), 1: et(xe.Num) }), vr.AnyVar), equal: Et(xt.Dictionary({ 0: et(vr.List()), 1: et(vr.List()) }), xe.Bool) }, set: { "@header": "Sets", has: Et(xt.Dictionary({ 0: et(vr.Set(vr.ConstrainedVar)), 1: et(vr.ConstrainedVar) }), xe.Bool, "Check if the the 1st argument includes the value of the 2nd."), isSubset: Et(xt.Dictionary({ 0: et(vr.Set(vr.ConstrainedVar)), 1: et(vr.Set(vr.ConstrainedVar)) }), xe.Bool, "Check if the the 1st argument is a subset of the 2nd.") }, flags: { "@header": "Flags", hasAny: Et(xt.Dictionary({ 0: et(vr.Flags(vr.ConstrainedVar)), 1: et(vr.Flags(vr.ConstrainedVar)) }), xe.Bool, "Check if the the 1st argument has at least one of the 2nd one's flags."), hasAll: Et(xt.Dictionary({ 0: et(vr.Flags(vr.ConstrainedVar)), 1: et(vr.Flags(vr.ConstrainedVar)) }), xe.Bool, "Check if the the 1st argument has all 2nd one's flags.") } };
EM(m_);
var pt, fK = MM(m_);
function pr(e, t) {
  return Et(xt.Dictionary({ 0: et(pt.ElementReference, { isOptional: !0, defaultValue: "slot.current-atom" }) }), e, t);
}
function j0(e, t) {
  return Et(xt.None, e, t);
}
(function() {
  for (var e = /* @__PURE__ */ Object.create(null), t = 0, r = fK; t < r.length; t++) {
    var n = r[t];
    e[n.id] = n;
  }
})(), function(e) {
  e.ElementSymbol = xe.Value("Structure", "ElementSymbol"), e.AtomName = xe.Value("Structure", "AtomName"), e.BondFlag = xe.OneOf("Structure", "BondFlag", xe.Str, ["covalent", "metallic", "ion", "hydrogen", "sulfide", "computed", "aromatic"]), e.BondFlags = vr.Flags(e.BondFlag, "BondFlags"), e.SecondaryStructureFlag = xe.OneOf("Structure", "SecondaryStructureFlag", xe.Str, ["alpha", "beta", "3-10", "pi", "sheet", "strand", "helix", "turn", "none"]), e.SecondaryStructureFlags = vr.Flags(e.SecondaryStructureFlag, "SecondaryStructureFlag"), e.RingFingerprint = xe.Value("Structure", "RingFingerprint"), e.EntityType = xe.OneOf("Structure", "EntityType", xe.Str, ["polymer", "non-polymer", "water", "branched"]), e.EntitySubtype = xe.OneOf("Structure", "EntitySubtype", xe.Str, ["other", "polypeptide(D)", "polypeptide(L)", "polydeoxyribonucleotide", "polyribonucleotide", "polydeoxyribonucleotide/polyribonucleotide hybrid", "cyclic-pseudo-peptide", "peptide nucleic acid", "oligosaccharide"]), e.ObjectPrimitive = xe.OneOf("Structure", "ObjectPrimitive", xe.Str, ["atomistic", "sphere", "gaussian", "other"]), e.ResidueId = xe.Value("Structure", "ResidueId"), e.ElementSet = xe.Value("Structure", "ElementSet"), e.ElementSelection = xe.Value("Structure", "ElementSelection"), e.ElementReference = xe.Value("Structure", "ElementReference"), e.ElementSelectionQuery = vr.Fn(e.ElementSelection, "ElementSelectionQuery");
}(pt || (pt = {}));
var fe = { core: m_, structureQuery: { "@header": "Structure Queries", type: { "@header": "Types", elementSymbol: Et(xt.Dictionary({ 0: et(xe.Str) }), pt.ElementSymbol, "Create element symbol representation from a string value."), atomName: Et(xt.Dictionary({ 0: et(xe.AnyValue) }), pt.AtomName, "Convert a value to an atom name."), entityType: Et(xt.Dictionary({ 0: et(pt.EntityType) }), pt.EntityType, "Create normalized representation of entity type: ".concat(xe.oneOfValues(pt.EntityType).join(", "), ".")), bondFlags: Et(xt.List(pt.BondFlag), pt.BondFlags, "Create bond flags representation from a list of strings. Allowed flags: ".concat(xe.oneOfValues(pt.BondFlag).join(", "), ".")), ringFingerprint: Et(xt.List(pt.ElementSymbol, { nonEmpty: !0 }), pt.RingFingerprint, "Create ring fingerprint from the supplied atom element list."), secondaryStructureFlags: Et(xt.List(pt.SecondaryStructureFlag), pt.SecondaryStructureFlags, "Create secondary structure flags representation from a list of strings. Allowed flags: ".concat(xe.oneOfValues(pt.SecondaryStructureFlag).join(", "), ".")), authResidueId: Et(xt.Dictionary({ 0: et(xe.Str, { description: "auth_asym_id" }), 1: et(xe.Num, { description: "auth_seq_id" }), 2: et(xe.Str, { description: "pdbx_PDB_ins_code", isOptional: !0 }) }), pt.ResidueId, 'Residue identifier based on "auth_" annotation.'), labelResidueId: Et(xt.Dictionary({ 0: et(xe.Str, { description: "label_entity_id" }), 1: et(xe.Str, { description: "label_asym_id" }), 2: et(xe.Num, { description: "label_seq_id" }), 3: et(xe.Str, { description: "pdbx_PDB_ins_code", isOptional: !0 }) }), pt.ResidueId, `Residue identifier based on mmCIF's "label_" annotation.`) }, slot: { "@header": "Iteration Slots", element: Et(xt.None, pt.ElementReference, "A reference to the current element."), elementSetReduce: Et(xt.None, xe.Variable("a", xe.AnyValue, !0), "Current value of the element set reducer.") }, generator: { "@header": "Generators", all: Et(xt.None, pt.ElementSelectionQuery, "The entire structure."), atomGroups: Et(xt.Dictionary({ "entity-test": et(xe.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom of every entity" }), "chain-test": et(xe.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom of every chain" }), "residue-test": et(xe.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom every residue" }), "atom-test": et(xe.Bool, { isOptional: !0, defaultValue: !0 }), "group-by": et(xe.Any, { isOptional: !0, defaultValue: "atom-key", description: "Group atoms to sets based on this property. Default: each atom has its own set" }) }), pt.ElementSelectionQuery, "Return all atoms for which the tests are satisfied, grouped into sets."), bondedAtomicPairs: Et(xt.Dictionary({ 0: et(xe.Bool, { isOptional: !0, defaultValue: "true for covalent bonds", description: "Test each bond with this predicate. Each bond is visited twice with swapped atom order." }) }), pt.ElementSelectionQuery, "Return all pairs of atoms for which the test is satisfied."), rings: Et(xt.Dictionary({ fingerprint: et(pt.RingFingerprint, { isOptional: !0 }), "only-aromatic": et(xe.Bool, { isOptional: !0, defaultValue: !1 }) }), pt.ElementSelectionQuery, "Return all rings or those with the specified fingerprint and/or only aromatic rings."), queryInSelection: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), query: et(pt.ElementSelectionQuery), "in-complement": et(xe.Bool, { isOptional: !0, defaultValue: !1 }) }), pt.ElementSelectionQuery, "Executes query only on atoms that are in the source selection."), empty: Et(xt.None, pt.ElementSelectionQuery, "Nada.") }, modifier: { "@header": "Selection Modifications", queryEach: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), query: et(pt.ElementSelectionQuery) }), pt.ElementSelectionQuery, "Query every atom set in the input selection separately."), intersectBy: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), by: et(pt.ElementSelectionQuery) }), pt.ElementSelectionQuery, "Intersect each atom set from the first sequence from atoms in the second one."), exceptBy: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), by: et(pt.ElementSelectionQuery) }), pt.ElementSelectionQuery, "Remove all atoms from 'selection' that occur in 'by'."), unionBy: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), by: et(pt.ElementSelectionQuery) }), pt.ElementSelectionQuery, "For each atom set A in the orginal sequence, combine all atoms sets in the target selection that intersect with A."), union: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery) }), pt.ElementSelectionQuery, "Collects all atom sets in the sequence into a single atom set."), cluster: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), "min-distance": et(xe.Num, { isOptional: !0, defaultValue: 0 }), "max-distance": et(xe.Num), "min-size": et(xe.Num, { description: "Minimal number of sets to merge, must be at least 2", isOptional: !0, defaultValue: 2 }), "max-size": et(xe.Num, { description: "Maximal number of sets to merge, if not set, no limit", isOptional: !0 }) }), pt.ElementSelectionQuery, "Combines atom sets that have mutual distance in the interval [min-radius, max-radius]. Minimum/maximum size determines how many atom sets can be combined."), includeSurroundings: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), radius: et(xe.Num), "atom-radius": et(xe.Num, { isOptional: !0, defaultValue: 0, description: "Value added to each atom before the distance check, for example VDW radius. Using this argument is computationally demanding." }), "as-whole-residues": et(xe.Bool, { isOptional: !0 }) }), pt.ElementSelectionQuery, "For each atom set in the selection, include all surrouding atoms/residues that are within the specified radius."), surroundingLigands: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), radius: et(xe.Num), "include-water": et(xe.Bool, { isOptional: !0, defaultValue: !0 }) }), pt.ElementSelectionQuery, "Find all ligands components around the source query."), includeConnected: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), "bond-test": et(xe.Bool, { isOptional: !0, defaultValue: "true for covalent bonds" }), "layer-count": et(xe.Num, { isOptional: !0, defaultValue: 1, description: "Number of bonded layers to include." }), "fixed-point": et(xe.Bool, { isOptional: !0, defaultValue: !1, description: "Continue adding layers as long as new connections exist." }), "as-whole-residues": et(xe.Bool, { isOptional: !0 }) }), pt.ElementSelectionQuery, "Pick all atom sets that are connected to the target."), wholeResidues: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery) }), pt.ElementSelectionQuery, "Expand the selection to whole residues."), expandProperty: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), property: et(xe.AnyValue) }), pt.ElementSelectionQuery, "To each atom set in the selection, add all atoms that have the same property value that was already present in the set.") }, filter: { "@header": "Selection Filters", pick: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), test: et(xe.Bool) }), pt.ElementSelectionQuery, "Pick all atom sets that satisfy the test."), first: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery) }), pt.ElementSelectionQuery, "Take the 1st atom set in the sequence."), withSameAtomProperties: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), source: et(pt.ElementSelectionQuery), property: et(xe.Any) }), pt.ElementSelectionQuery, "Pick all atom sets for which the set of given atom properties is a subset of the source properties."), intersectedBy: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), by: et(pt.ElementSelectionQuery) }), pt.ElementSelectionQuery, "Pick all atom sets that have non-zero intersection with the target."), within: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), target: et(pt.ElementSelectionQuery), "min-radius": et(xe.Num, { isOptional: !0, defaultValue: 0 }), "max-radius": et(xe.Num), "atom-radius": et(xe.Num, { isOptional: !0, defaultValue: 0, description: "Value added to each atom before the distance check, for example VDW radius. Using this argument is computationally demanding." }), invert: et(xe.Bool, { isOptional: !0, defaultValue: !1, description: "If true, pick only atom sets that are further than the specified radius." }) }), pt.ElementSelectionQuery, "Pick all atom sets from selection that have any atom within the radius of any atom from target."), isConnectedTo: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery), target: et(pt.ElementSelectionQuery), "bond-test": et(xe.Bool, { isOptional: !0, defaultValue: "true for covalent bonds" }), disjunct: et(xe.Bool, { isOptional: !0, defaultValue: !0, description: "If true, there must exist a bond to an atom that lies outside the given atom set to pass test." }), invert: et(xe.Bool, { isOptional: !0, defaultValue: !1, description: "If true, return atom sets that are not connected." }) }), pt.ElementSelectionQuery, "Pick all atom sets that are connected to the target.") }, combinator: { "@header": "Selection Combinators", intersect: Et(xt.List(pt.ElementSelectionQuery), pt.ElementSelectionQuery, "Return all unique atom sets that appear in all of the source selections."), merge: Et(xt.List(pt.ElementSelectionQuery), pt.ElementSelectionQuery, "Merges multiple selections into a single one. Only unique atom sets are kept."), distanceCluster: Et(xt.Dictionary({ matrix: et(vr.List(vr.List(xe.Num)), { description: "Distance matrix, represented as list of rows (num[][])). Lower triangle is min distance, upper triangle is max distance." }), selections: et(vr.List(pt.ElementSelectionQuery), { description: "A list of held selections." }) }), pt.ElementSelectionQuery, "Pick combinations of atom sets from the source sequences that are mutually within distances specified by a matrix.") }, atomSet: { "@header": "Atom Sets", atomCount: Et(xt.None, xe.Num), countQuery: Et(xt.Dictionary({ 0: et(pt.ElementSelectionQuery) }), xe.Num, "Counts the number of occurences of a specific query inside the current atom set."), reduce: Et(xt.Dictionary({ initial: et(xe.Variable("a", xe.AnyValue, !0), { description: "Initial value assigned to slot.atom-set-reduce. Current atom is set to the 1st atom of the current set for this." }), value: et(xe.Variable("a", xe.AnyValue, !0), { description: "Expression executed for each atom in the set" }) }), xe.Variable("a", xe.AnyValue, !0), "Execute the value expression for each atom in the current atom set and return the result. Works the same way as Array.reduce in JavaScript (``result = value(value(...value(initial)))``)"), propertySet: Et(xt.Dictionary({ 0: et(vr.ConstrainedVar) }), vr.Set(vr.ConstrainedVar), "Returns a set with all values of the given property in the current atom set.") }, atomProperty: { "@header": "Atom Properties", core: { "@header": "Core Properties", elementSymbol: pr(pt.ElementSymbol), vdw: pr(xe.Num, "Van der Waals radius"), mass: pr(xe.Num, "Atomic weight"), atomicNumber: pr(xe.Num, "Atomic number"), x: pr(xe.Num, "Cartesian X coordinate"), y: pr(xe.Num, "Cartesian Y coordinate"), z: pr(xe.Num, "Cartesian Z coordinate"), atomKey: pr(xe.AnyValue, "Unique value for each atom. Main use case is grouping of atoms."), bondCount: Et(xt.Dictionary({ 0: et(pt.ElementReference, { isOptional: !0, defaultValue: "slot.current-atom" }), flags: et(pt.BondFlags, { isOptional: !0, defaultValue: "covalent" }) }), xe.Num, "Number of bonds (by default only covalent bonds are counted)."), sourceIndex: pr(xe.Num, "Index of the atom/element in the input file."), operatorName: pr(xe.Str, "Name of the symmetry operator applied to this element."), modelIndex: pr(xe.Num, "Index of the model in the input file."), modelLabel: pr(xe.Str, "Label/header of the model in the input file.") }, topology: { connectedComponentKey: pr(xe.AnyValue, "Unique value for each connected component.") }, macromolecular: { "@header": "Macromolecular Properties (derived from the mmCIF format)", authResidueId: pr(pt.ResidueId, "type.auth-residue-id symbol executed on current atom's residue"), labelResidueId: pr(pt.ResidueId, "type.label-residue-id symbol executed on current atom's residue"), residueKey: pr(xe.AnyValue, "Unique value for each tuple ``(label_entity_id,auth_asym_id, auth_seq_id, pdbx_PDB_ins_code)``, main use case is grouping of atoms"), chainKey: pr(xe.AnyValue, "Unique value for each tuple ``(label_entity_id, auth_asym_id)``, main use case is grouping of atoms"), entityKey: pr(xe.AnyValue, "Unique value for each tuple ``label_entity_id``, main use case is grouping of atoms"), isHet: pr(xe.Bool, "Equivalent to atom_site.group_PDB !== ATOM"), id: pr(xe.Num, "_atom_site.id"), label_atom_id: pr(pt.AtomName), label_alt_id: pr(xe.Str), label_comp_id: pr(xe.Str), label_asym_id: pr(xe.Str), label_entity_id: pr(xe.Str), label_seq_id: pr(xe.Num), auth_atom_id: pr(pt.AtomName), auth_comp_id: pr(xe.Str), auth_asym_id: pr(xe.Str), auth_seq_id: pr(xe.Num), pdbx_PDB_ins_code: pr(xe.Str), pdbx_formal_charge: pr(xe.Num), occupancy: pr(xe.Num), B_iso_or_equiv: pr(xe.Num), entityType: pr(pt.EntityType, "Type of the entity as defined in mmCIF (polymer, non-polymer, branched, water)"), entitySubtype: pr(pt.EntitySubtype, "Subtype of the entity as defined in mmCIF _entity_poly.type and _pdbx_entity_branch.type (other, polypeptide(D), polypeptide(L), polydeoxyribonucleotide, polyribonucleotide, polydeoxyribonucleotide/polyribonucleotide hybrid, cyclic-pseudo-peptide, peptide nucleic acid, oligosaccharide)"), entityPrdId: pr(xe.Str, "The PRD ID of the entity."), entityDescription: pr(vr.List(xe.Str)), objectPrimitive: pr(pt.ObjectPrimitive, "Type of the primitive object used to model this segment as defined in mmCIF/IHM (atomistic, sphere, gaussian, other)"), secondaryStructureKey: pr(xe.AnyValue, "Unique value for each secondary structure element."), secondaryStructureFlags: pr(pt.SecondaryStructureFlags), isModified: pr(xe.Bool, "True if the atom belongs to modification of a standard residue."), modifiedParentName: pr(xe.Str, "'3-letter' code of the modifed parent residue."), isNonStandard: pr(xe.Bool, "True if this is a non-standard residue."), chemCompType: pr(xe.Str, "Type of the chemical component as defined in mmCIF.") } }, bondProperty: { "@header": "Bond Properties", flags: j0(pt.BondFlags), order: j0(xe.Num), length: j0(xe.Num), atomA: j0(pt.ElementReference), atomB: j0(pt.ElementReference) } }, internal: { "@header": "Internal Queries", generator: { "@header": "Generators", bundleElement: Et(xt.Dictionary({ groupedUnits: et(xe.Any), set: et(xe.Any), ranges: et(xe.Any) }), xe.Any), bundle: Et(xt.Dictionary({ elements: et(xe.Any) }), pt.ElementSelectionQuery, "A selection with single structure containing represented by the bundle."), current: Et(xt.None, pt.ElementSelectionQuery, "Current selection provided by the query context. Avoid using this in State Transforms.") } } };
EM(fe);
var Nt, pK = MM(fe);
(function() {
  for (var e = /* @__PURE__ */ Object.create(null), t = 0, r = pK; t < r.length; t++) {
    var n = r[t];
    e[n.id] = n;
  }
})(), function(e) {
  e.core = fe.core, e.struct = fe.structureQuery, e.internal = fe.internal, e.atomName = function(s) {
    return e.struct.type.atomName([s]);
  }, e.es = function(s) {
    return e.struct.type.elementSymbol([s]);
  }, e.list = function() {
    for (var s = [], c = 0; c < arguments.length; c++) s[c] = arguments[c];
    return e.core.type.list(s);
  }, e.set = function() {
    for (var s = [], c = 0; c < arguments.length; c++) s[c] = arguments[c];
    return e.core.type.set(s);
  }, e.re = function(s, c) {
    return e.core.type.regex([s, c]);
  }, e.fn = function(s) {
    return e.core.ctrl.fn([s]);
  }, e.evaluate = function(s) {
    return e.core.ctrl.eval([s]);
  };
  var t = e.struct.atomProperty.core, r = e.struct.atomProperty.macromolecular, n = e.struct.atomProperty.topology;
  function i(s) {
    return t[s]();
  }
  function a(s) {
    return n[s]();
  }
  function o(s) {
    return r[s]();
  }
  e.acp = i, e.atp = a, e.ammp = o;
  var u = e.struct.atomSet.propertySet;
  e.acpSet = function(s) {
    return u([i(s)]);
  }, e.atpSet = function(s) {
    return u([a(s)]);
  }, e.ammpSet = function(s) {
    return u([o(s)]);
  };
}(Nt || (Nt = {}));
var uu, su, mK = /* @__PURE__ */ new Set(["145", "147", "149", "289", "291", "293", "445", "475", "491", "510", "604", "045", "05L", "07E", "07Y", "08U", "09X", "0AT", "0BD", "0H0", "0HX", "0LP", "0MK", "0NZ", "0TS", "0UB", "0V4", "0WK", "0XY", "0YT", "10M", "12E", "14T", "15L", "16F", "16G", "16O", "17T", "18D", "18O", "18T", "1AR", "1BW", "1CF", "1FT", "1GL", "1GN", "1JB", "1LL", "1NA", "1S3", "1S4", "1SD", "1X4", "20S", "20X", "22O", "22S", "23V", "24S", "25E", "26M", "26O", "26Q", "26R", "26V", "26W", "26Y", "27C", "2DG", "2DR", "2F8", "2FG", "2FL", "2FP", "2GL", "2GS", "2H5", "2HA", "2M4", "2M5", "2M8", "2OS", "2WP", "2WS", "32O", "34V", "38J", "3BU", "3CM", "3DO", "3DY", "3FM", "3GR", "3HD", "3J3", "3J4", "3LJ", "3LR", "3MF", "3MG", "3MK", "3R3", "3S6", "3SA", "3YW", "40J", "42D", "44S", "46D", "46M", "46Z", "48Z", "49A", "49S", "49T", "49V", "4AM", "4CQ", "4GC", "4GL", "4GP", "4JA", "4N2", "4NN", "4QY", "4R1", "4RS", "4SG", "4U0", "4U1", "4U2", "4UZ", "4V5", "50A", "51N", "56N", "57S", "5DI", "5GF", "5GO", "5II", "5KQ", "5KS", "5KT", "5KV", "5L2", "5L3", "5LS", "5LT", "5MM", "5N6", "5QP", "5RP", "5SA", "5SP", "5TH", "5TJ", "5TK", "5TM", "61J", "62I", "64K", "66O", "6BG", "6C2", "6DM", "6GB", "6GP", "6GR", "6K3", "6KH", "6KL", "6KS", "6KU", "6KW", "6LA", "6LS", "6LW", "6MJ", "6MN", "6PG", "6PY", "6PZ", "6S2", "6SA", "6UD", "6Y6", "6YR", "6ZC", "73E", "79J", "7CV", "7D1", "7GP", "7JZ", "7K2", "7K3", "7NU", "7SA", "83Y", "89Y", "8B7", "8B9", "8EX", "8GA", "8GG", "8GP", "8LM", "8LR", "8OQ", "8PK", "8S0", "8YV", "95Z", "96O", "9AM", "9C1", "9CD", "9GP", "9KJ", "9MR", "9OK", "9PG", "9QG", "9QZ", "9S7", "9SG", "9SJ", "9SM", "9SP", "9T1", "9T7", "9VP", "9WJ", "9WN", "9WZ", "9YW", "A0K", "A1Q", "A2G", "A5C", "A6P", "AAL", "AAO", "ABC", "ABD", "ABE", "ABF", "ABL", "AC1", "ACG", "ACR", "ACX", "ADA", "ADG", "ADR", "AF1", "AFD", "AFL", "AFO", "AFP", "AFR", "AGC", "AGH", "AGL", "AGR", "AH2", "AH8", "AHG", "AHM", "AHR", "AIG", "ALL", "ALX", "AMG", "AMN", "AMU", "AMV", "ANA", "AOG", "AOS", "AQA", "ARA", "ARB", "ARE", "ARI", "ARW", "ASC", "ASG", "ASO", "AXP", "AXR", "AY9", "AZC", "B0D", "B16", "B1H", "B1N", "B2G", "B4G", "B6D", "B7G", "B8D", "B9D", "BBK", "BBV", "BCD", "BCW", "BDF", "BDG", "BDP", "BDR", "BDZ", "BEM", "BFN", "BFP", "BG6", "BG8", "BGC", "BGL", "BGN", "BGP", "BGS", "BHG", "BM3", "BM7", "BMA", "BMX", "BND", "BNG", "BNX", "BO1", "BOG", "BQY", "BRI", "BS7", "BTG", "BTU", "BWG", "BXF", "BXP", "BXX", "BXY", "BZD", "C3B", "C3G", "C3X", "C4B", "C4W", "C4X", "C5X", "CAP", "CBF", "CBI", "CBK", "CDR", "CE5", "CE6", "CE8", "CEG", "CEX", "CEY", "CEZ", "CGF", "CJB", "CKB", "CKP", "CNP", "CR1", "CR6", "CRA", "CT3", "CTO", "CTR", "CTT", "D0N", "D1M", "D5E", "D6G", "DAF", "DAG", "DAN", "DDA", "DDB", "DDL", "DEG", "DEL", "DFR", "DFX", "DG0", "DGC", "DGD", "DGM", "DGO", "DGS", "DGU", "DIG", "DJB", "DJE", "DK4", "DKX", "DKZ", "DL6", "DLD", "DLF", "DLG", "DMU", "DNO", "DO8", "DOM", "DP5", "DPC", "DQQ", "DQR", "DR2", "DR3", "DR4", "DR5", "DRI", "DSR", "DT6", "DVC", "DYM", "E3M", "E4P", "E5G", "EAG", "EBG", "EBQ", "EEN", "EEQ", "EGA", "EJT", "EMP", "EMZ", "EPG", "EQP", "EQV", "ERE", "ERI", "ETT", "EUS", "F1P", "F1X", "F55", "F58", "F6P", "F8X", "FBP", "FCA", "FCB", "FCT", "FDP", "FDQ", "FFC", "FFX", "FIF", "FIX", "FK9", "FKD", "FMF", "FMO", "FNG", "FNY", "FRU", "FSA", "FSI", "FSM", "FSR", "FSW", "FU4", "FUB", "FUC", "FUD", "FUF", "FUL", "FUY", "FVQ", "FX1", "FYJ", "G0S", "G16", "G1P", "G20", "G28", "G2F", "G3F", "G3I", "G4D", "G4S", "G6D", "G6P", "G6S", "G7P", "G8Z", "GAA", "GAC", "GAD", "GAF", "GAL", "GAT", "GBH", "GC1", "GC4", "GC9", "GCB", "GCD", "GCN", "GCO", "GCS", "GCT", "GCU", "GCV", "GCW", "GDA", "GDL", "GE1", "GE3", "GFP", "GIV", "GL0", "GL1", "GL2", "GL4", "GL5", "GL6", "GL7", "GL9", "GLA", "GLB", "GLC", "GLD", "GLF", "GLG", "GLO", "GLP", "GLS", "GLT", "GLW", "GM0", "GMB", "GMH", "GMT", "GMZ", "GN1", "GN4", "GNS", "GNX", "GP0", "GP1", "GP4", "GPH", "GPK", "GPM", "GPO", "GPQ", "GPU", "GPV", "GPW", "GQ1", "GRF", "GRX", "GS1", "GS4", "GS9", "GSA", "GSD", "GTE", "GTH", "GTK", "GTM", "GTR", "GU0", "GU1", "GU2", "GU3", "GU4", "GU5", "GU6", "GU8", "GU9", "GUF", "GUL", "GUP", "GUZ", "GXL", "GXV", "GYE", "GYG", "GYP", "GYU", "GYV", "GZL", "H1M", "H1S", "H2P", "H3S", "H53", "H6Q", "H6Z", "HBZ", "HD4", "HDL", "HMS", "HNV", "HNW", "HSG", "HSH", "HSJ", "HSQ", "HSR", "HSU", "HSX", "HSY", "HSZ", "HTG", "HTM", "I57", "IAB", "IDC", "IDF", "IDG", "IDR", "IDS", "IDT", "IDU", "IDX", "IDY", "IEM", "IN1", "IPT", "ISD", "ISL", "ISX", "IXD", "J5B", "JFZ", "JHM", "JLT", "JRV", "JS2", "JSV", "JV4", "JVA", "JVS", "JZR", "K5B", "K99", "KBA", "KBG", "KD5", "KDA", "KDB", "KDD", "KDE", "KDF", "KDM", "KDN", "KDO", "KDR", "KFN", "KG1", "KGM", "KHP", "KME", "KO1", "KO2", "KOT", "KTU", "L1L", "L6S", "L6T", "LAG", "LAH", "LAI", "LAK", "LAO", "LAT", "LB2", "LBS", "LBT", "LCN", "LDY", "LEC", "LER", "LFC", "LFR", "LGC", "LGU", "LKA", "LKS", "LM2", "LMO", "LMT", "LMU", "LNV", "LOG", "LOX", "LPK", "LRH", "LSM", "LTG", "LTM", "LVO", "LVZ", "LXB", "LXC", "LXZ", "LZ0", "M1F", "M1P", "M2F", "M3M", "M3N", "M55", "M6D", "M6P", "M7B", "M7P", "M8C", "MA1", "MA2", "MA3", "MA8", "MAB", "MAF", "MAG", "MAL", "MAN", "MAT", "MAV", "MAW", "MBE", "MBF", "MBG", "MCU", "MDA", "MDP", "MFA", "MFB", "MFU", "MG5", "MGA", "MGC", "MGL", "MGS", "MJJ", "MLB", "MLR", "MMA", "MMN", "MN0", "MNA", "MQG", "MQT", "MRH", "MRP", "MSX", "MTT", "MUB", "MUG", "MUR", "MVP", "MXY", "MXZ", "MYG", "N1L", "N9S", "NA1", "NAA", "NAG", "NBG", "NBX", "NBY", "NDG", "NED", "NFG", "NG1", "NG6", "NGA", "NGB", "NGC", "NGE", "NGF", "NGK", "NGL", "NGR", "NGS", "NGY", "NGZ", "NHF", "NLC", "NM6", "NM9", "NNG", "NPF", "NSQ", "NT1", "NTF", "NTO", "NTP", "NXD", "NYT", "O1G", "OAK", "OEL", "OI7", "OPM", "ORP", "OSU", "OTG", "OTN", "OTU", "OX2", "P53", "P6P", "P8E", "PA1", "PA5", "PAV", "PDX", "PH5", "PKM", "PNA", "PNG", "PNJ", "PNW", "PPC", "PRP", "PSG", "PSJ", "PSV", "PTQ", "PUF", "PZU", "QDK", "QIF", "QKH", "QPS", "QV4", "R1P", "R1X", "R2B", "R2G", "R5P", "RAA", "RAE", "RAF", "RAM", "RAO", "RAT", "RB5", "RBL", "RCD", "RDP", "REL", "RER", "RF5", "RG1", "RGG", "RHA", "RHC", "RI2", "RIB", "RIP", "RM4", "RNS", "RNT", "ROB", "ROR", "RP3", "RP5", "RP6", "RPA", "RR7", "RRJ", "RRY", "RST", "RTG", "RTV", "RUB", "RUG", "RUU", "RV7", "RVG", "RVM", "RWI", "RY7", "RZM", "S6P", "S7P", "S81", "SA0", "SCG", "SCR", "SDD", "SDY", "SEJ", "SF6", "SF9", "SFJ", "SFU", "SG4", "SG5", "SG6", "SG7", "SGA", "SGC", "SGD", "SGN", "SGS", "SHB", "SHD", "SHG", "SI3", "SIA", "SID", "SIO", "SIZ", "SLB", "SLM", "SLT", "SMD", "SN5", "SNG", "SOE", "SOG", "SOL", "SOR", "SR1", "SSG", "SSH", "STW", "STZ", "SUC", "SUP", "SUS", "SWE", "SZZ", "T68", "T6D", "T6P", "T6T", "TA6", "TAG", "TCB", "TCG", "TDG", "TEU", "TF0", "TFU", "TGA", "TGK", "TGR", "TGY", "TH1", "TM5", "TM6", "TM9", "TMR", "TMX", "TNX", "TOA", "TOC", "TQY", "TRE", "TRV", "TS8", "TT7", "TTV", "TTZ", "TU4", "TUG", "TUJ", "TUP", "TUR", "TVD", "TVG", "TVM", "TVS", "TVV", "TVY", "TW7", "TWA", "TWD", "TWG", "TWJ", "TWY", "TXB", "TYV", "U1Y", "U2A", "U2D", "U63", "U8V", "U97", "U9A", "U9D", "U9G", "U9J", "U9M", "UAP", "UCD", "UDC", "UEA", "V3M", "V3P", "V71", "VG1", "VJ1", "VJ4", "VKN", "VTB", "W9T", "WIA", "WOO", "WUN", "WZ1", "WZ2", "WZ4", "X0X", "X1P", "X1X", "X2F", "X2Y", "X34", "X4S", "X5S", "X6X", "X6Y", "XBP", "XDP", "XDX", "XGP", "XIL", "XKJ", "XLF", "XLS", "XMM", "XS2", "XUL", "XXM", "XXR", "XXX", "XYB", "XYF", "XYL", "XYP", "XYS", "XYT", "XYZ", "YDR", "YIO", "YJM", "YKR", "YO5", "YX0", "YX1", "YYB", "YYH", "YYJ", "YYK", "YYM", "YYQ", "YYR", "YZ0", "Z0F", "Z15", "Z16", "Z2D", "Z2T", "Z3K", "Z3L", "Z3Q", "Z3U", "Z4K", "Z4R", "Z4S", "Z4U", "Z4V", "Z4W", "Z4Y", "Z57", "Z5J", "Z5L", "Z61", "Z6H", "Z6J", "Z6W", "Z8H", "Z8T", "Z9D", "Z9E", "Z9H", "Z9K", "Z9L", "Z9M", "Z9N", "Z9W", "ZB0", "ZB1", "ZB2", "ZB3", "ZCD", "ZCZ", "ZD0", "ZDC", "ZDM", "ZDO", "ZEE", "ZEL", "ZGE", "ZMR", "UMQ", "SQD"]), yt = { Blue: 37052, Green: 42577, Yellow: 16765952, Orange: 16021792, Pink: 16162465, Purple: 10830745, LightBlue: 9424105, Brown: 10582605, Red: 15539236, Secondary: 15854817 };
(uu = {})[0] = "Hexose", uu[1] = "HexNAc", uu[2] = "Hexosamine", uu[3] = "Hexuronate", uu[4] = "Deoxyhexose", uu[5] = "DeoxyhexNAc", uu[6] = "Di-deoxyhexose", uu[7] = "Pentose", uu[8] = "Deoxynonulosonate", uu[9] = "Di-deoxynonulosonate", uu[10] = "Unknown", uu[11] = "Assigned", (su = {})[0] = 0, su[1] = 1, su[2] = 2, su[3] = 3, su[4] = 4, su[5] = 5, su[6] = 6, su[7] = 7, su[8] = 8, su[9] = 9, su[10] = 10, su[11] = 11;
var cl, BM = { abbr: "Unk", name: "Unknown", color: yt.Secondary, type: 10 }, S2 = [{ abbr: "Glc", name: "Glucose", color: yt.Blue, type: 0 }, { abbr: "Man", name: "Mannose", color: yt.Green, type: 0 }, { abbr: "Gal", name: "Galactose", color: yt.Yellow, type: 0 }, { abbr: "Gul", name: "Gulose", color: yt.Orange, type: 0 }, { abbr: "Alt", name: "Altrose", color: yt.Pink, type: 0 }, { abbr: "All", name: "Allose", color: yt.Purple, type: 0 }, { abbr: "Tal", name: "Talose", color: yt.LightBlue, type: 0 }, { abbr: "Ido", name: "Idose", color: yt.Brown, type: 0 }, { abbr: "GlcNAc", name: "N-Acetyl Glucosamine", color: yt.Blue, type: 1 }, { abbr: "ManNAc", name: "N-Acetyl Mannosamine", color: yt.Green, type: 1 }, { abbr: "GalNAc", name: "N-Acetyl Galactosamine", color: yt.Yellow, type: 1 }, { abbr: "GulNAc", name: "N-Acetyl Gulosamine", color: yt.Orange, type: 1 }, { abbr: "AltNAc", name: "N-Acetyl Altrosamine", color: yt.Pink, type: 1 }, { abbr: "AllNAc", name: "N-Acetyl Allosamine", color: yt.Purple, type: 1 }, { abbr: "TalNAc", name: "N-Acetyl Talosamine", color: yt.LightBlue, type: 1 }, { abbr: "IdoNAc", name: "N-Acetyl Idosamine", color: yt.Brown, type: 1 }, { abbr: "GlcN", name: "Glucosamine", color: yt.Blue, type: 2 }, { abbr: "ManN", name: "Mannosamine", color: yt.Green, type: 2 }, { abbr: "GalN", name: "Galactosamine", color: yt.Yellow, type: 2 }, { abbr: "GulN", name: "Gulosamine", color: yt.Orange, type: 2 }, { abbr: "AltN", name: "Altrosamine", color: yt.Pink, type: 2 }, { abbr: "AllN", name: "Allosamine", color: yt.Purple, type: 2 }, { abbr: "TalN", name: "Talosamine", color: yt.LightBlue, type: 2 }, { abbr: "IdoN", name: "Idosamine", color: yt.Brown, type: 2 }, { abbr: "GlcA", name: "Glucuronic Acid", color: yt.Blue, type: 3 }, { abbr: "ManA", name: "Mannuronic Acid", color: yt.Green, type: 3 }, { abbr: "GalA", name: "Galacturonic Acid", color: yt.Yellow, type: 3 }, { abbr: "GulA", name: "Guluronic Acid", color: yt.Orange, type: 3 }, { abbr: "AltA", name: "Altruronic Acid", color: yt.Pink, type: 3 }, { abbr: "AllA", name: "Alluronic Acid", color: yt.Purple, type: 3 }, { abbr: "TalA", name: "Taluronic Acid", color: yt.LightBlue, type: 3 }, { abbr: "IdoA", name: "Iduronic Acid", color: yt.Brown, type: 3 }, { abbr: "Qui", name: "Quinovose", color: yt.Blue, type: 4 }, { abbr: "Rha", name: "Rhamnose", color: yt.Green, type: 4 }, { abbr: "6dGul", name: "6-Deoxy Gulose", color: yt.Orange, type: 4 }, { abbr: "6dAlt", name: "6-Deoxy Altrose", color: yt.Pink, type: 4 }, { abbr: "6dTal", name: "6-Deoxy Talose", color: yt.LightBlue, type: 4 }, { abbr: "Fuc", name: "Fucose", color: yt.Red, type: 4 }, { abbr: "QuiNAc", name: "N-Acetyl Quinovosamine", color: yt.Blue, type: 5 }, { abbr: "RhaNAc", name: "N-Acetyl Rhamnosamine", color: yt.Green, type: 5 }, { abbr: "6dAltNAc", name: "N-Acetyl 6-Deoxy Altrosamine", color: yt.Pink, type: 5 }, { abbr: "6dTalNAc", name: "N-Acetyl 6-Deoxy Talosamine", color: yt.LightBlue, type: 5 }, { abbr: "FucNAc", name: "N-Acetyl Fucosamine", color: yt.Red, type: 5 }, { abbr: "Oli", name: "Olivose", color: yt.Blue, type: 6 }, { abbr: "Tyv", name: "Tyvelose", color: yt.Green, type: 6 }, { abbr: "Abe", name: "Abequose", color: yt.Orange, type: 6 }, { abbr: "Par", name: "Paratose", color: yt.Pink, type: 6 }, { abbr: "Dig", name: "Digitoxose", color: yt.Purple, type: 6 }, { abbr: "Col", name: "Colitose", color: yt.LightBlue, type: 6 }, { abbr: "Ara", name: "Arabinose", color: yt.Green, type: 7 }, { abbr: "Lyx", name: "Lyxose", color: yt.Yellow, type: 7 }, { abbr: "Xyl", name: "Xylose", color: yt.Orange, type: 7 }, { abbr: "Rib", name: "Ribose", color: yt.Pink, type: 7 }, { abbr: "Kdn", name: "Keto-Deoxy Nonulonic Acid", color: yt.Green, type: 8 }, { abbr: "Neu5Ac", name: "N-Acetyl Neuraminic Acid", color: yt.Purple, type: 8 }, { abbr: "Neu5Gc", name: "N-Glycolyl Neuraminic Acid", color: yt.LightBlue, type: 8 }, { abbr: "Neu", name: "Neuraminic Acid", color: yt.Brown, type: 8 }, { abbr: "Sia", name: "Sialic acid", color: yt.Red, type: 8 }, { abbr: "Pse", name: "Pseudaminic Acid", color: yt.Green, type: 9 }, { abbr: "Leg", name: "Legionaminic Acid", color: yt.Yellow, type: 9 }, { abbr: "Aci", name: "Acinetaminic Acid", color: yt.Pink, type: 9 }, { abbr: "4eLeg", name: "4-Epilegionaminic Acid", color: yt.LightBlue, type: 9 }, { abbr: "Bac", name: "Bacillosamine", color: yt.Blue, type: 10 }, { abbr: "LDmanHep", name: "L-Glycero-D-Manno Heptose", color: yt.Green, type: 10 }, { abbr: "Kdo", name: "Keto-Deoxy Octulonic Acid", color: yt.Yellow, type: 10 }, { abbr: "Dha", name: "3-Deoxy Lyxo-Heptulosaric Acid", color: yt.Orange, type: 10 }, { abbr: "DDmanHep", name: "D-Glycero-D-Manno-Heptose", color: yt.Pink, type: 10 }, { abbr: "MurNAc", name: "N-Acetyl Muramic Acid", color: yt.Purple, type: 10 }, { abbr: "MurNGc", name: "N-Glycolyl Muramic Acid", color: yt.LightBlue, type: 10 }, { abbr: "Mur", name: "Muramic Acid", color: yt.Brown, type: 10 }, { abbr: "Api", name: "Apicose", color: yt.Green, type: 11 }, { abbr: "Fru", name: "Fructose", color: yt.Green, type: 11 }, { abbr: "Tag", name: "Tagatose", color: yt.Yellow, type: 11 }, { abbr: "Sor", name: "Sorbose", color: yt.Orange, type: 11 }, { abbr: "Psi", name: "Psicose", color: yt.Pink, type: 11 }], hK = function() {
  for (var e = /* @__PURE__ */ new Map(), t = 0, r = S2.length; t < r; ++t) {
    var n = S2[t];
    e.set(n.abbr, n);
  }
  return e;
}(), vK = [["Glc-family", yt.Blue], ["Man-family", yt.Green], ["Gal-family", yt.Yellow], ["Gul-family", yt.Orange], ["Alt-family", yt.Pink], ["All-family", yt.Purple], ["Tal-family", yt.LightBlue], ["Ido-family", yt.Brown], ["Fuc-family", yt.Red], ["Generic/Unknown/Secondary", yt.Secondary]], gK = { Glc: ["GLC", "BGC", "Z8T", "TRE", "MLR"], Man: ["MAN", "BMA"], Gal: ["GLA", "GAL", "GZL", "GXL", "GIV"], Gul: ["4GL", "GL0", "GUP", "Z8H"], Alt: ["Z6H", "3MK", "SHD"], All: ["AFD", "ALL", "WOO", "Z2D"], Tal: ["ZEE", "A5C", "SDY"], Ido: ["ZCD", "Z0F", "4N2"], GlcNAc: ["NDG", "NAG", "NGZ"], ManNAc: ["BM3", "BM7"], GalNAc: ["A2G", "NGA", "YYQ"], GulNAc: ["LXB"], AltNAc: [], AllNAc: ["NAA"], TalNAc: [], IdoNAc: ["LXZ", "HSQ"], GlcN: ["PA1", "GCS"], ManN: ["95Z"], GalN: ["X6X", "1GN"], GulN: [], AltN: [], AllN: [], TalN: [], IdoN: [], GlcA: ["GCU", "BDP"], ManA: ["MAV", "BEM"], GalA: ["ADA", "GTR", "GTK"], GulA: ["LGU"], AltA: [], AllA: [], TalA: ["X1X", "X0X"], IdoA: ["IDR"], Qui: ["G6D", "YYK"], Rha: ["RAM", "RM4", "XXR"], "6dGul": ["66O"], "6dAlt": [], "6dTal": [], Fuc: ["FUC", "FUL", "FCA", "FCB", "GYE"], QuiNAc: ["Z9W"], RhaNAc: [], "6dAltNAc": [], "6dTalNAc": [], FucNAc: ["49T"], Oli: ["DDA", "RAE", "Z5J"], Tyv: ["TYV"], Abe: ["ABE"], Par: ["PZU"], Dig: ["Z3U"], Col: [], Ara: ["64K", "ARA", "ARB", "AHR", "FUB", "BXY", "BXX", "SEJ"], Lyx: ["LDY", "Z4W"], Xyl: ["XYS", "XYP", "XYZ", "HSY", "LXC"], Rib: ["YYM", "RIP", "RIB", "BDR", "0MK", "Z6J", "32O"], Kdn: ["KDM", "KDN"], Neu5Ac: ["SIA", "SLB"], Neu5Gc: ["NGC", "NGE"], Neu: [], Sia: [], Pse: [], Leg: [], Aci: [], "4eLeg": [], Bac: [], LDmanHep: ["GMH"], Kdo: ["KDO"], Dha: [], DDmanHep: ["289"], MurNAc: ["MUB", "AMU"], MurNGc: [], Mur: ["1S4", "MUR"], Api: ["XXM"], Fru: ["BDF", "Z9N", "FRU", "LFR"], Tag: ["T6T"], Sor: ["SOE", "UEA"], Psi: ["PSV", "SF6", "SF9", "TTV"] }, yK = { Glc: ["AGLC", "BGLC"], GlcNAc: ["AGLCNA", "BGLCNA", "BGLCN0"], GlcA: ["AGLCA", "BGLCA", "BGLCA0"], Man: ["AMAN", "BMAN"], Rha: ["ARHM", "BRHM"], Ara: ["AARB", "BARB"], Gal: ["AGAL", "BGAL"], GalNAc: ["AGALNA", "BGALNA"], Gul: ["AGUL", "BGUL"], Alt: ["AALT", "BALT"], All: ["AALL", "BALL"], Tal: ["ATAL", "BTAL"], Ido: ["AIDO", "BIDO"], IdoA: ["AIDOA", "BIDOA"], Fuc: ["AFUC", "BFUC"], Lyx: ["ALYF", "BLYF"], Xyl: ["AXYL", "BXYL", "AXYF", "BXYF"], Rib: ["ARIB", "BRIB"], Fru: ["AFRU", "BFRU"], Neu5Ac: ["ANE5AC", "BNE5AC"] }, Zl = function() {
  for (var e = /* @__PURE__ */ new Map(), t = 0, r = S2.length; t < r; ++t) {
    var n = S2[t], i = gK[n.abbr];
    if (i) for (var a = 0, o = i.length; a < o; ++a) e.set(i[a], n);
    var u = yK[n.abbr];
    if (u) for (a = 0, o = u.length; a < o; ++a) e.set(u[a], n);
  }
  return mK.forEach(function(s) {
    e.has(s) || e.set(s, BM);
  }), e;
}(), FM = /* @__PURE__ */ new Set(["DAPC", "DBPC", "DFPC", "DGPC", "DIPC", "DLPC", "DNPC", "DOPC", "DPPC", "DRPC", "DTPC", "DVPC", "DXPC", "DYPC", "LPPC", "PAPC", "PEPC", "PGPC", "PIPC", "POPC", "PRPC", "PUPC", "DAPE", "DBPE", "DFPE", "DGPE", "DIPE", "DLPE", "DNPE", "DOPE", "DPPE", "DRPE", "DTPE", "DUPE", "DVPE", "DXPE", "DYPE", "LPPE", "PAPE", "PGPE", "PIPE", "POPE", "PQPE", "PRPE", "PUPE", "DAPS", "DBPS", "DFPS", "DGPS", "DIPS", "DLPS", "DNPS", "DOPS", "DPPS", "DRPS", "DTPS", "DUPS", "DVPS", "DXPS", "DYPS", "LPPS", "PAPS", "PGPS", "PIPS", "POPS", "PQPS", "PRPS", "PUPS", "DAPG", "DBPG", "DFPG", "DGPG", "DIPG", "DLPG", "DNPG", "DOPG", "DPPG", "DRPG", "DTPG", "DVPG", "DXPG", "DYPG", "LPPG", "PAPG", "PGPG", "PIPG", "POPG", "PRPG", "DAPA", "DBPA", "DFPA", "DGPA", "DIPA", "DLPA", "DNPA", "DOPA", "DPPA", "DRPA", "DTPA", "DVPA", "DXPA", "DYPA", "LPPA", "PAPA", "PGPA", "PIPA", "POPA", "PRPA", "PUPA", "DPP", "DPPI", "PAPI", "PIPI", "POP", "POPI", "PUPI", "PVP", "PVPI", "PADG", "PIDG", "PODG", "PUDG", "PVDG", "APC", "CPC", "IPC", "LPC", "OPC", "PPC", "TPC", "UPC", "VPC", "BNSM", "DBSM", "DPSM", "DXSM", "PGSM", "PNSM", "POSM", "PVSM", "XNSM", "DPCE", "DXCE", "PNCE", "XNCE", "DMPC"]), Cm = /* @__PURE__ */ new Set(["118", "119", "543", "1AL", "1CU", "2FK", "2HP", "2OF", "3CO", "3MT", "3NI", "3OF", "3P8", "4MO", "4PU", "4TI", "6MO", "ACT", "AG", "AL", "ALF", "AM", "ATH", "AU", "AU3", "AUC", "AZI", "BA", "BCT", "BEF", "BF4", "BO4", "BR", "BS3", "BSY", "CA", "CAC", "CD", "CD1", "CD3", "CD5", "CE", "CF", "CHT", "CL", "CO", "CO3", "CO5", "CON", "CR", "CS", "CSB", "CU", "CU1", "CU3", "CUA", "CUZ", "CYN", "DME", "DMI", "DSC", "DTI", "DY", "E4N", "EDR", "EMC", "ER3", "EU", "EU3", "F", "FE", "FE2", "FPO", "GA", "GD3", "GEP", "HAI", "HG", "HGC", "IN", "IOD", "IR", "IR3", "IRI", "IUM", "K", "KO4", "LA", "LCO", "LCP", "LI", "LU", "MAC", "MG", "MH2", "MH3", "MLI", "MMC", "MN", "MN3", "MN5", "MN6", "MO1", "MO2", "MO3", "MO4", "MO5", "MO6", "MOO", "MOS", "MOW", "MW1", "MW2", "MW3", "NA", "NA2", "NA5", "NA6", "NAO", "NAW", "ND", "NET", "NH4", "NI", "NI1", "NI2", "NI3", "NO2", "NO3", "NRU", "O4M", "OAA", "OC1", "OC2", "OC3", "OC4", "OC5", "OC6", "OC7", "OC8", "OCL", "OCM", "OCN", "OCO", "OF1", "OF2", "OF3", "OH", "OS", "OS4", "OXL", "PB", "PBM", "PD", "PDV", "PER", "PI", "PO3", "PO4", "PR", "PT", "PT4", "PTN", "RB", "RH3", "RHD", "RU", "SB", "SCN", "SE4", "SEK", "SM", "SMO", "SO3", "SO4", "SR", "T1A", "TB", "TBA", "TCN", "TEA", "TH", "THE", "TL", "TMA", "TRA", "UNX", "V", "VN3", "VO4", "W", "WO5", "Y1", "YB", "YB2", "YH", "YT3", "ZCM", "ZN", "ZN2", "ZN3", "ZNO", "ZO3", "ZR", "NCO", "OHX"]), bK = function() {
  for (var e = /* @__PURE__ */ Object.create(null), t = [], r = 65; r <= 90; r++) t[t.length] = String.fromCharCode(r);
  for (r = 97; r <= 122; r++) t[t.length] = String.fromCharCode(r);
  for (r = 48; r <= 57; r++) t[t.length] = String.fromCharCode(r);
  for (var n = 0, i = t; n < i.length; n++) {
    var a = i[n];
    e[a] = a.toUpperCase();
    for (var o = 0, u = t; o < u.length; o++) {
      var s = u[o];
      e[a + s] = (a + s).toUpperCase();
      for (var c = 0, l = t; c < l.length; c++) {
        var d = l[c];
        e[a + s + d] = (a + s + d).toUpperCase();
      }
    }
  }
  return e;
}();
function q1(e) {
  return bK[e] || e.toUpperCase();
}
new Map([[1, "H"], [2, "He"], [3, "Li"], [4, "Be"], [5, "B"], [6, "C"], [7, "N"], [8, "O"], [9, "F"], [10, "Ne"], [11, "Na"], [12, "Mg"], [13, "Al"], [14, "Si"], [15, "P"], [16, "S"], [17, "Cl"], [18, "Ar"], [19, "K"], [20, "Ca"], [21, "Sc"], [22, "Ti"], [23, "V"], [24, "Cr"], [25, "Mn"], [26, "Fe"], [27, "Co"], [28, "Ni"], [29, "Cu"], [30, "Zn"], [31, "Ga"], [32, "Ge"], [33, "As"], [34, "Se"], [35, "Br"], [36, "Kr"], [37, "Rb"], [38, "Sr"], [39, "Y"], [40, "Zr"], [41, "Nb"], [42, "Mo"], [43, "Tc"], [44, "Ru"], [45, "Rh"], [46, "Pd"], [47, "Ag"], [48, "Cd"], [49, "In"], [50, "Sn"], [51, "Sb"], [52, "Te"], [53, "I"], [54, "Xe"], [55, "Cs"], [56, "Ba"], [57, "La"], [58, "Ce"], [59, "Pr"], [60, "Nd"], [61, "Pm"], [62, "Sm"], [63, "Eu"], [64, "Gd"], [65, "Tb"], [66, "Dy"], [67, "Ho"], [68, "Er"], [69, "Tm"], [70, "Yb"], [71, "Lu"], [72, "Hf"], [73, "Ta"], [74, "W"], [75, "Re"], [76, "Os"], [77, "Ir"], [78, "Pt"], [79, "Au"], [80, "Hg"], [81, "Tl"], [82, "Pb"], [83, "Bi"], [84, "Po"], [85, "At"], [86, "Rn"], [87, "Fr"], [88, "Ra"], [89, "Ac"], [90, "Th"], [91, "Pa"], [92, "U"], [93, "Np"], [94, "Pu"], [95, "Am"], [96, "Cm"], [97, "Bk"], [98, "Cf"], [99, "Es"], [100, "Fm"], [101, "Md"], [102, "No"], [103, "Lr"], [104, "Rf"], [105, "Db"], [106, "Sg"], [107, "Bh"], [108, "Hs"], [109, "Mt"], [110, "Ds"], [111, "Rg"], [112, "Cn"], [113, "Uut"], [114, "Fl"], [115, "Uup"], [116, "Lv"], [117, "Uus"], [118, "Uuo"]].map(function(e) {
  return [e[0], q1(e[1])];
}));
var yr, cr, _K = ((cl = {})[0] = { trace: /* @__PURE__ */ new Set(), directionFrom: /* @__PURE__ */ new Set(), directionTo: /* @__PURE__ */ new Set(), backboneStart: /* @__PURE__ */ new Set(), backboneEnd: /* @__PURE__ */ new Set(), coarseBackbone: /* @__PURE__ */ new Set() }, cl[1] = { trace: /* @__PURE__ */ new Set(["CA"]), directionFrom: /* @__PURE__ */ new Set(["C"]), directionTo: /* @__PURE__ */ new Set(["O", "OC1", "O1", "OX1", "OXT", "OT1"]), backboneStart: /* @__PURE__ */ new Set(["N"]), backboneEnd: /* @__PURE__ */ new Set(["C"]), coarseBackbone: /* @__PURE__ */ new Set(["CA", "BB", "CA1"]) }, cl[2] = { trace: /* @__PURE__ */ new Set(["CA"]), directionFrom: /* @__PURE__ */ new Set(["C"]), directionTo: /* @__PURE__ */ new Set(["O"]), backboneStart: /* @__PURE__ */ new Set(["N"]), backboneEnd: /* @__PURE__ */ new Set(["CD"]), coarseBackbone: /* @__PURE__ */ new Set(["CA"]) }, cl[3] = { trace: /* @__PURE__ */ new Set(["CA"]), directionFrom: /* @__PURE__ */ new Set(["C"]), directionTo: /* @__PURE__ */ new Set(["O"]), backboneStart: /* @__PURE__ */ new Set(["N"]), backboneEnd: /* @__PURE__ */ new Set(["CG"]), coarseBackbone: /* @__PURE__ */ new Set(["CA"]) }, cl[4] = { trace: /* @__PURE__ */ new Set(["O3'", "O3*"]), directionFrom: /* @__PURE__ */ new Set(["C4'", "C4*"]), directionTo: /* @__PURE__ */ new Set(["C3'", "C3*"]), backboneStart: /* @__PURE__ */ new Set(["P"]), backboneEnd: /* @__PURE__ */ new Set(["O3'", "O3*"]), coarseBackbone: /* @__PURE__ */ new Set(["P"]) }, cl[5] = { trace: /* @__PURE__ */ new Set(["O3'", "O3*"]), directionFrom: /* @__PURE__ */ new Set(["C3'", "C3*"]), directionTo: /* @__PURE__ */ new Set(["C1'", "C1*"]), backboneStart: /* @__PURE__ */ new Set(["P"]), backboneEnd: /* @__PURE__ */ new Set(["O3'", "O3*"]), coarseBackbone: /* @__PURE__ */ new Set(["P"]) }, cl[6] = { trace: /* @__PURE__ */ new Set(["N4'", "N4*"]), directionFrom: /* @__PURE__ */ new Set(["N4'", "N4*"]), directionTo: /* @__PURE__ */ new Set(["C7'", "C7*"]), backboneStart: /* @__PURE__ */ new Set(["N1'", "N1*"]), backboneEnd: /* @__PURE__ */ new Set(["C'", "C*"]), coarseBackbone: /* @__PURE__ */ new Set(["P"]) }, cl), h_ = /* @__PURE__ */ new Set(["CA", "C", "N", "O", "O1", "O2", "OC1", "OC2", "OT1", "OT2", "OX1", "OXT", "H", "H1", "H2", "H3", "HA", "HN", "HXT", "BB"]), xK = /* @__PURE__ */ new Set(["P", "OP1", "OP2", "HOP2", "HOP3", "O2'", "O3'", "O4'", "O5'", "C1'", "C2'", "C3'", "C4'", "C5'", "H1'", "H2'", "H2''", "HO2'", "H3'", "H4'", "H5'", "H5''", "HO3'", "HO5'", "O2*", "O3*", "O4*", "O5*", "C1*", "C2*", "C3*", "C4*", "C5*"]), NM = /* @__PURE__ */ new Set(["D-PEPTIDE LINKING", "D-PEPTIDE NH3 AMINO TERMINUS", "D-PEPTIDE COOH CARBOXY TERMINUS", "D-GAMMA-PEPTIDE, C-DELTA LINKING", "D-BETA-PEPTIDE, C-GAMMA LINKING"]), RM = /* @__PURE__ */ new Set(["L-PEPTIDE LINKING", "L-PEPTIDE NH3 AMINO TERMINUS", "L-PEPTIDE COOH CARBOXY TERMINUS", "L-GAMMA-PEPTIDE, C-DELTA LINKING", "L-BETA-PEPTIDE, C-GAMMA LINKING"]), AK = /* @__PURE__ */ new Set(["D-GAMMA-PEPTIDE, C-DELTA LINKING", "L-GAMMA-PEPTIDE, C-DELTA LINKING"]), SK = /* @__PURE__ */ new Set(["D-BETA-PEPTIDE, C-GAMMA LINKING", "L-BETA-PEPTIDE, C-GAMMA LINKING"]), CK = /* @__PURE__ */ new Set(["D-PEPTIDE NH3 AMINO TERMINUS", "D-PEPTIDE COOH CARBOXY TERMINUS", "L-PEPTIDE NH3 AMINO TERMINUS", "L-PEPTIDE COOH CARBOXY TERMINUS"]), OM = /* @__PURE__ */ new Set(["PEPTIDE LINKING", "PEPTIDE-LIKE"]), wK = to.unionMany(NM, RM, OM), LM = /* @__PURE__ */ new Set(["DNA LINKING", "L-DNA LINKING", "DNA OH 5 PRIME TERMINUS", "DNA OH 3 PRIME TERMINUS"]), kM = /* @__PURE__ */ new Set(["RNA LINKING", "L-RNA LINKING", "RNA OH 5 PRIME TERMINUS", "RNA OH 3 PRIME TERMINUS"]), zM = /* @__PURE__ */ new Set(["D-SACCHARIDE, BETA LINKING", "L-SACCHARIDE, BETA LINKING", "D-SACCHARIDE, ALPHA LINKING", "L-SACCHARIDE, ALPHA LINKING", "L-SACCHARIDE", "D-SACCHARIDE", "SACCHARIDE", "D-SACCHARIDE 1,4 AND 1,4 LINKING", "L-SACCHARIDE 1,4 AND 1,4 LINKING", "D-SACCHARIDE 1,4 AND 1,6 LINKING", "L-SACCHARIDE 1,4 AND 1,6 LINKING"]), DK = /* @__PURE__ */ new Set(["NON-POLYMER", "OTHER"]), IK = /* @__PURE__ */ new Set(["ION"]), EK = /* @__PURE__ */ new Set(["LIPID"]), g0 = /* @__PURE__ */ new Set(["SOL", "WAT", "HOH", "H2O", "W", "DOD", "D3O", "TIP", "TIP3", "TIP4", "SPC"]), GM = /* @__PURE__ */ new Set(["HIS", "ARG", "LYS", "ILE", "PHE", "LEU", "TRP", "ALA", "MET", "PRO", "CYS", "ASN", "VAL", "GLY", "SER", "GLN", "TYR", "ASP", "GLU", "THR", "SEC", "PYL", "UNK", "MSE", "SEP", "TPO", "PTR", "PCA", "HSD", "HSE", "HSP", "LSN", "ASPP", "GLUP", "HID", "HIE", "HIP", "LYN", "ASH", "GLH", "ACE", "NME"]), VM = /* @__PURE__ */ new Set(["DAL", "DAR", "DSG", "DAS", "DCY", "DGL", "DGN", "DHI", "DIL", "DLE", "DLY", "MED", "DPN", "DPR", "DSN", "DTH", "DTR", "DTY", "DVA", "DNE"]), wm = to.unionMany(GM, VM), Sg = /* @__PURE__ */ new Set(["A", "C", "T", "G", "I", "U", "N"]), Cg = /* @__PURE__ */ new Set(["DA", "DC", "DT", "DG", "DI", "DU", "DN"]), v_ = /* @__PURE__ */ new Set(["APN", "CPN", "TPN", "GPN"]), MK = /* @__PURE__ */ new Set(["A", "G", "I", "DA", "DG", "DI", "APN", "GPN"]), TK = /* @__PURE__ */ new Set(["C", "T", "U", "DC", "DT", "DU", "CPN", "TPN"]), g_ = to.unionMany(Sg, Cg, v_), UM = function(e) {
  return MK.has(e.toUpperCase());
}, HM = function(e) {
  return TK.has(e.toUpperCase());
}, y_ = to.unionMany(wm, g_);
function Dm(e, t) {
  return e = e.toUpperCase(), t = t.toUpperCase(), v_.has(t) ? 8 : wK.has(e) ? 5 : kM.has(e) ? 6 : LM.has(e) ? 7 : zM.has(e) ? 9 : g0.has(t) ? 2 : Cm.has(t) ? 3 : FM.has(t) ? 4 : DK.has(e) ? Zl.has(t) ? 9 : wm.has(t) ? 5 : Sg.has(t) ? 6 : Cg.has(t) ? 7 : 1 : 0;
}
function PK(e, t) {
  return e = e.toUpperCase(), t === 5 ? AK.has(e) ? 2 : SK.has(e) ? 3 : CK.has(e) ? 0 : 1 : t === 6 ? 4 : t === 7 ? 5 : t === 8 ? 6 : 0;
}
function qM(e) {
  return e = e.toUpperCase(), wm.has(e) ? "peptide linking" : Sg.has(e) ? "RNA linking" : Cg.has(e) ? "DNA linking" : Zl.has(e) ? "saccharide" : "other";
}
function BK(e) {
  return e = e.toUpperCase(), g0.has(e) ? "water" : y_.has(e) ? "polymer" : Zl.has(e) ? "branched" : "non-polymer";
}
function FK(e, t) {
  return e = e.toUpperCase(), t = t.toUpperCase(), RM.has(t) ? "polypeptide(L)" : NM.has(t) ? "polypeptide(D)" : kM.has(t) ? "polyribonucleotide" : LM.has(t) ? "polydeoxyribonucleotide" : zM.has(t) || Zl.has(e) ? "oligosaccharide" : v_.has(e) ? "peptide nucleic acid" : GM.has(e) ? "polypeptide(L)" : VM.has(e) ? "polypeptide(D)" : Sg.has(e) ? "polyribonucleotide" : Cg.has(e) ? "polydeoxyribonucleotide" : IK.has(t) || Cm.has(e) ? "ion" : EK.has(t) || FM.has(e) ? "lipid" : OM.has(t) ? "peptide-like" : "other";
}
function b_(e) {
  return y0(e) || KM(e);
}
function y0(e) {
  return e === 7 || e === 6 || e === 8;
}
function KM(e) {
  return e === 5;
}
(function(e) {
  e.is = ya.has, e.create = ya.create, e.SecondaryStructureMmcif = { HELX_LH_27_P: 1058, HELX_LH_3T_P: 2082, HELX_LH_AL_P: 4130, HELX_LH_A_N: 524321, HELX_LH_B_N: 1048609, HELX_LH_GA_P: 8226, HELX_LH_N: 33, HELX_LH_OM_P: 16418, HELX_LH_OT_N: 131105, HELX_LH_OT_P: 546, HELX_LH_P: 34, HELX_LH_PI_P: 32802, HELX_LH_PP_P: 65570, HELX_LH_Z_N: 262177, HELX_N: 1, HELX_OT_N: 1, HELX_OT_P: 2, HELX_P: 2, HELX_RH_27_P: 1090, HELX_RH_3T_P: 2114, HELX_RH_AL_P: 4162, HELX_RH_A_N: 524353, HELX_RH_B_N: 1048641, HELX_RH_GA_P: 8258, HELX_RH_N: 65, HELX_RH_OM_P: 16450, HELX_RH_OT_N: 131137, HELX_RH_OT_P: 578, HELX_RH_P: 66, HELX_RH_PI_P: 32834, HELX_RH_PP_P: 65602, HELX_RH_Z_N: 262209, STRN: 4194308, TURN_OT_P: 33554448, TURN_P: 16, TURN_TY1P_P: 67109136, TURN_TY1_P: 67109008, TURN_TY2P_P: 134218e3, TURN_TY2_P: 134217872, TURN_TY3P_P: 268435728, TURN_TY3_P: 268435600 }, e.SecondaryStructurePdb = { 1: 4162, 2: 16450, 3: 32834, 4: 8258, 5: 2114, 6: 4130, 7: 16418, 8: 8226, 9: 1026, 10: 65538 }, e.SecondaryStructureStride = { H: 4098, G: 2050, I: 32770, E: 8388612, B: 4194308, T: 16, C: 536870912 }, e.SecondaryStructureDssp = { H: 4098, B: 4194308, E: 8388612, G: 2050, I: 32770, T: 16, S: 8 };
})(yr || (yr = {})), function(e) {
  function t(r) {
    switch (r) {
      case "covalent":
        return 1;
      case "metal-coordination":
        return 2;
      case "hydrogen-bond":
        return 4;
      case "disulfide":
        return 8;
      case "aromatic":
        return 16;
      case "computed":
        return 32;
    }
  }
  e.is = ya.has, e.create = function(r) {
    return ya.create(r);
  }, e.isCovalent = function(r) {
    return !!(1 & r);
  }, e.isAll = function(r) {
    return r === Math.pow(2, 6) - 1;
  }, e.Names = { covalent: 1, "metal-coordination": 2, "hydrogen-bond": 4, disulfide: 8, aromatic: 16, computed: 32 }, e.isName = function(r) {
    return r in e.Names;
  }, e.fromName = t, e.fromNames = function(r) {
    for (var n = 0, i = 0, a = r.length; i < a; ++i) n |= t(r[i]);
    return n;
  };
}(cr || (cr = {}));
var Gy = { ALA: [0.17, 0.5, 0.33], ARG: [0.81, 1.81, 1], ASN: [0.42, 0.85, 0.43], ASP: [1.23, 3.64, 2.41], ASH: [-0.07, 0.43, 0.5], CYS: [-0.24, -0.02, 0.22], GLN: [0.58, 0.77, 0.19], GLU: [2.02, 3.63, 1.61], GLH: [-0.01, 0.11, 0.12], GLY: [0.01, 1.15, 1.14], HIS: [0.17, 0.11, -0.06], ILE: [-0.31, -1.12, -0.81], LEU: [-0.56, -1.25, -0.69], LYS: [0.99, 2.8, 1.81], MET: [-0.23, -0.67, -0.44], PHE: [-1.13, -1.71, -0.58], PRO: [0.45, 0.14, -0.31], SER: [0.13, 0.46, 0.33], THR: [0.14, 0.25, 0.11], TRP: [-1.85, -2.09, -0.24], TYR: [-0.94, -0.71, 0.23], VAL: [0.07, -0.46, -0.53], HSD: [0.17, 0.11, -0.06], HSE: [0.17, 0.11, -0.06], HSP: [0.96, 2.33, 1.37], HID: [0.17, 0.11, -0.06], HIE: [0.17, 0.11, -0.06], HIP: [0.96, 2.33, 1.37] }, K1 = function() {
  function e() {
    this.count = 0, this.center = w(), this.radiusSq = 0;
  }
  return e.prototype.reset = function() {
    w.set(this.center, 0, 0, 0), this.radiusSq = 0, this.count = 0;
  }, e.prototype.includeStep = function(t) {
    w.add(this.center, this.center, t), this.count++;
  }, e.prototype.finishedIncludeStep = function() {
    this.count !== 0 && w.scale(this.center, this.center, 1 / this.count);
  }, e.prototype.radiusStep = function(t) {
    var r = w.squaredDistance(t, this.center);
    r > this.radiusSq && (this.radiusSq = r);
  }, e.prototype.radiusSphereStep = function(t, r) {
    var n = w.distance(t, this.center) + r, i = n * n;
    i > this.radiusSq && (this.radiusSq = i);
  }, e.prototype.getSphere = function(t) {
    return t || (t = Me()), w.copy(t.center, this.center), t.radius = Math.sqrt(this.radiusSq), t;
  }, e.prototype.getCount = function() {
    return this.count;
  }, e;
}();
(function(e) {
  var t = new e(), r = w(), n = w();
  e.fromArrays = function(i, a) {
    var o = i.x, u = i.y, s = i.z;
    t.reset();
    for (var c = o.length, l = 0; l < c; l++) w.set(r, o[l], u[l], s[l]), t.includeStep(r);
    for (t.finishedIncludeStep(), l = 0; l < c; l++) w.set(r, o[l], u[l], s[l]), t.radiusStep(r);
    return w.copy(a.center, t.center), a.radius = Math.sqrt(t.radiusSq), a;
  }, e.fromProvider = function(i, a, o) {
    t.reset();
    for (var u = 0; u < i; u++) a(u, r), t.includeStep(r);
    for (t.finishedIncludeStep(), u = 0; u < i; u++) a(u, r), t.radiusStep(r);
    return w.copy(o.center, t.center), o.radius = Math.sqrt(t.radiusSq), o;
  }, e.fromPairProvider = function(i, a, o) {
    t.reset();
    for (var u = 0; u < i; u++) a(u, r, n), t.includeStep(r), t.includeStep(n);
    for (t.finishedIncludeStep(), u = 0; u < i; u++) a(u, r, n), t.radiusStep(r), t.radiusStep(n);
    return w.copy(o.center, t.center), o.radius = Math.sqrt(t.radiusSq), o;
  };
})(K1 || (K1 = {}));
var df = function() {
  function e(t) {
    this.map = t;
    var r = 0, n = [], i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
    this.map.forEach(function(o) {
      o.forEach(function(u) {
        r += u.edgeCount, u.connectedIndices.forEach(function(s) {
          u.getEdges(s).forEach(function(c) {
            var l = u.unitA, d = u.unitB, f = e.getEdgeKey(s, l, c.indexB, d);
            i.set(f, n.length);
            var m = e.getVertexKey(s, l), v = a.get(m);
            v === void 0 ? a.set(m, [n.length]) : v.push(n.length), n.push(R(R({}, c), { indexA: s, unitA: l, unitB: d }));
          });
        });
      });
    }), this.edgeCount = r, this.edges = n, this.edgeKeyIndex = i, this.vertexKeyIndex = a;
  }
  return e.prototype.getConnectedUnits = function(t) {
    return this.map.has(t) ? this.map.get(t) : XM;
  }, e.prototype.getEdgeIndex = function(t, r, n, i) {
    var a = e.getEdgeKey(t, r, n, i), o = this.edgeKeyIndex.get(a);
    return o !== void 0 ? o : -1;
  }, e.prototype.hasEdge = function(t, r, n, i) {
    return this.getEdgeIndex(t, r, n, i) !== -1;
  }, e.prototype.getEdge = function(t, r, n, i) {
    var a = this.getEdgeIndex(t, r, n, i);
    return a !== -1 ? this.edges[a] : void 0;
  }, e.prototype.getEdgeIndices = function(t, r) {
    return this.vertexKeyIndex.get(e.getVertexKey(t, r)) || [];
  }, e;
}();
(function(e) {
  var t = function() {
    function i(a, o, u, s, c) {
      this.unitA = a, this.unitB = o, this.edgeCount = u, this.connectedIndices = s, this.edgeMap = c;
    }
    return i.prototype.hasEdges = function(a) {
      return this.edgeMap.has(a);
    }, i.prototype.getEdges = function(a) {
      return this.edgeMap.has(a) ? this.edgeMap.get(a) : XM;
    }, Object.defineProperty(i.prototype, "areUnitsOrdered", { get: function() {
      return this.unitA < this.unitB;
    }, enumerable: !1, configurable: !0 }), i;
  }();
  function r(i, a, o) {
    i.has(a) ? i.get(a).push(o) : i.set(a, [o]);
  }
  e.UnitPairEdges = t, e.getEdgeKey = function(i, a, o, u) {
    return "".concat(i, "|").concat(a, "|").concat(o, "|").concat(u);
  }, e.getVertexKey = function(i, a) {
    return "".concat(i, "|").concat(a);
  };
  var n = function() {
    function i() {
      this.map = /* @__PURE__ */ new Map();
    }
    return i.prototype.startUnitPair = function(a, o) {
      this.uA = a, this.uB = o, this.mapAB = /* @__PURE__ */ new Map(), this.mapBA = /* @__PURE__ */ new Map(), this.linkedA = cn.create(), this.linkedB = cn.create(), this.linkCount = 0;
    }, i.prototype.finishUnitPair = function() {
      this.linkCount !== 0 && (r(this.map, this.uA, new t(this.uA, this.uB, this.linkCount, this.linkedA.array, this.mapAB)), r(this.map, this.uB, new t(this.uB, this.uA, this.linkCount, this.linkedB.array, this.mapBA)));
    }, i.prototype.add = function(a, o, u) {
      r(this.mapAB, a, { indexB: o, props: u }), r(this.mapBA, o, { indexB: a, props: u }), cn.add(this.linkedA, a, a), cn.add(this.linkedB, o, o), this.linkCount += 1;
    }, i.prototype.getMap = function() {
      return this.map;
    }, i;
  }();
  e.Builder = n;
})(df || (df = {}));
var pb, XM = [];
(function(e) {
  e.Empty = So.create([], [], [], 0, { flags: [], order: [] });
})(pb || (pb = {}));
var C2 = function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  return ga(t, e), t.prototype.getBondFromLocation = function(r) {
    return Be.isAtomic(r.aUnit) && Be.isAtomic(r.bUnit) ? this.getEdge(r.aIndex, r.aUnit.id, r.bIndex, r.bUnit.id) : void 0;
  }, t.prototype.getBondIndexFromLocation = function(r) {
    return Be.isAtomic(r.aUnit) && Be.isAtomic(r.bUnit) ? this.getEdgeIndex(r.aIndex, r.aUnit.id, r.bIndex, r.bUnit.id) : -1;
  }, t;
}(df);
(function(e) {
  var t = function(r) {
    function n() {
      return r !== null && r.apply(this, arguments) || this;
    }
    return ga(n, r), n;
  }(df.UnitPairEdges);
  e.UnitPairBonds = t;
})(C2 || (C2 = {}));
var jM = { forceCompute: !1, noCompute: !1, maxRadius: 4 }, tm = { H: 0, h: 0, D: 0, d: 0, T: 0, t: 0, He: 2, HE: 2, he: 2, Li: 3, LI: 3, li: 3, Be: 4, BE: 4, be: 4, B: 5, b: 5, C: 6, c: 6, N: 7, n: 7, O: 8, o: 8, F: 9, f: 9, Ne: 10, NE: 10, ne: 10, Na: 11, NA: 11, na: 11, Mg: 12, MG: 12, mg: 12, Al: 13, AL: 13, al: 13, Si: 14, SI: 14, si: 14, P: 15, p: 15, S: 16, s: 16, Cl: 17, CL: 17, cl: 17, Ar: 18, AR: 18, ar: 18, K: 19, k: 19, Ca: 20, CA: 20, ca: 20, Sc: 21, SC: 21, sc: 21, Ti: 22, TI: 22, ti: 22, V: 23, v: 23, Cr: 24, CR: 24, cr: 24, Mn: 25, MN: 25, mn: 25, Fe: 26, FE: 26, fe: 26, Co: 27, CO: 27, co: 27, Ni: 28, NI: 28, ni: 28, Cu: 29, CU: 29, cu: 29, Zn: 30, ZN: 30, zn: 30, Ga: 31, GA: 31, ga: 31, Ge: 32, GE: 32, ge: 32, As: 33, AS: 33, as: 33, Se: 34, SE: 34, se: 34, Br: 35, BR: 35, br: 35, Kr: 36, KR: 36, kr: 36, Rb: 37, RB: 37, rb: 37, Sr: 38, SR: 38, sr: 38, Y: 39, y: 39, Zr: 40, ZR: 40, zr: 40, Nb: 41, NB: 41, nb: 41, Mo: 42, MO: 42, mo: 42, Tc: 43, TC: 43, tc: 43, Ru: 44, RU: 44, ru: 44, Rh: 45, RH: 45, rh: 45, Pd: 46, PD: 46, pd: 46, Ag: 47, AG: 47, ag: 47, Cd: 48, CD: 48, cd: 48, In: 49, IN: 49, in: 49, Sn: 50, SN: 50, sn: 50, Sb: 51, SB: 51, sb: 51, Te: 52, TE: 52, te: 52, I: 53, i: 53, Xe: 54, XE: 54, xe: 54, Cs: 55, CS: 55, cs: 55, Ba: 56, BA: 56, ba: 56, La: 57, LA: 57, la: 57, Ce: 58, CE: 58, ce: 58, Pr: 59, PR: 59, pr: 59, Nd: 60, ND: 60, nd: 60, Pm: 61, PM: 61, pm: 61, Sm: 62, SM: 62, sm: 62, Eu: 63, EU: 63, eu: 63, Gd: 64, GD: 64, gd: 64, Tb: 65, TB: 65, tb: 65, Dy: 66, DY: 66, dy: 66, Ho: 67, HO: 67, ho: 67, Er: 68, ER: 68, er: 68, Tm: 69, TM: 69, tm: 69, Yb: 70, YB: 70, yb: 70, Lu: 71, LU: 71, lu: 71, Hf: 72, HF: 72, hf: 72, Ta: 73, TA: 73, ta: 73, W: 74, w: 74, Re: 75, RE: 75, re: 75, Os: 76, OS: 76, os: 76, Ir: 77, IR: 77, ir: 77, Pt: 78, PT: 78, pt: 78, Au: 79, AU: 79, au: 79, Hg: 80, HG: 80, hg: 80, Tl: 81, TL: 81, tl: 81, Pb: 82, PB: 82, pb: 82, Bi: 83, BI: 83, bi: 83, Po: 84, PO: 84, po: 84, At: 85, AT: 85, at: 85, Rn: 86, RN: 86, rn: 86, Fr: 87, FR: 87, fr: 87, Ra: 88, RA: 88, ra: 88, Ac: 89, AC: 89, ac: 89, Th: 90, TH: 90, th: 90, Pa: 91, PA: 91, pa: 91, U: 92, u: 92, Np: 93, NP: 93, np: 93, Pu: 94, PU: 94, pu: 94, Am: 95, AM: 95, am: 95, Cm: 96, CM: 96, cm: 96, Bk: 97, BK: 97, bk: 97, Cf: 98, CF: 98, cf: 98, Es: 99, ES: 99, es: 99, Fm: 100, FM: 100, fm: 100, Md: 101, MD: 101, md: 101, No: 102, NO: 102, no: 102, Lr: 103, LR: 103, lr: 103, Rf: 104, RF: 104, rf: 104, Db: 105, DB: 105, db: 105, Sg: 106, SG: 106, sg: 106, Bh: 107, BH: 107, bh: 107, Hs: 108, HS: 108, hs: 108, Mt: 109, MT: 109, mt: 109, NH: 113 }, NK = { 0: 1.42, 1: 1.42, 3: 2.7, 4: 2.7, 6: 1.75, 7: 1.6, 8: 1.52, 11: 2.7, 12: 2.7, 13: 2.7, 14: 1.9, 15: 2, 16: 1.9, 17: 1.8, 19: 2.7, 20: 2.7, 21: 2.7, 22: 2.7, 23: 2.7, 24: 2.7, 25: 2.7, 26: 2.7, 27: 2.7, 28: 2.7, 29: 2.7, 30: 2.7, 31: 2.7, 33: 2.68, 37: 2.7, 38: 2.7, 39: 2.7, 40: 2.7, 41: 2.7, 42: 2.7, 43: 2.7, 44: 2.7, 45: 2.7, 46: 2.7, 47: 2.7, 48: 2.7, 49: 2.7, 50: 2.7, 55: 2.7, 56: 2.7, 57: 2.7, 58: 2.7, 59: 2.7, 60: 2.7, 61: 2.7, 62: 2.7, 63: 2.7, 64: 2.7, 65: 2.7, 66: 2.7, 67: 2.7, 68: 2.7, 69: 2.7, 70: 2.7, 71: 2.7, 72: 2.7, 73: 2.7, 74: 2.7, 75: 2.7, 76: 2.7, 77: 2.7, 78: 2.7, 79: 2.7, 80: 2.7, 81: 2.7, 82: 2.7, 83: 2.7, 87: 2.7, 88: 2.7, 89: 2.7, 90: 2.7, 91: 2.7, 92: 2.7, 93: 2.7, 94: 2.7, 95: 2.7, 96: 2.7, 97: 2.7, 98: 2.7, 99: 2.7, 100: 2.7, 101: 2.7, 102: 2.7, 103: 2.7, 104: 2.7, 105: 2.7, 106: 2.7, 107: 2.7, 108: 2.7, 109: 2.88 }, YM = { 0: 0.8, 20: 1.31, 27: 1.2, 35: 1.15, 44: 1.25, 54: 1, 60: 1.84, 72: 1.88, 84: 1.75, 85: 1.56, 86: 1.76, 98: 1.6, 99: 1.68, 100: 1.63, 112: 1.6, 113: 1.59, 114: 1.36, 129: 1.45, 135: 1.47, 144: 1.6, 152: 1.45, 170: 1.4, 180: 1.55, 202: 2.4, 222: 2.24, 224: 1.91, 225: 1.98, 243: 2.02, 269: 2, 293: 1.9, 316: 1.8, 420: 2.37, 480: 2.3, 512: 2.3, 544: 2.3, 612: 2.1, 629: 1.54, 665: 1, 813: 2.6, 854: 2.27, 894: 1.93, 896: 2.1, 937: 2.05, 938: 2.06, 981: 1.62, 1258: 2.68, 1309: 2.33, 1484: 1, 1763: 2.14, 1823: 2.48, 1882: 2.1, 1944: 1.72, 2380: 2.34, 3367: 2.44, 3733: 2.11, 3819: 2.6, 3821: 2.36, 4736: 2.75, 5724: 2.73, 5959: 2.63, 6519: 2.84, 6750: 2.87, 8991: 2.81 }, WM = { 14: 1.71649, 20: 1.59646, 27: 1.2, 35: 1.2, 44: 1.2, 54: 1.1, 60: 1.85846, 62: 2.66213, 73: 2.10649, 74: 2.60087, 77: 2.79942, 84: 1.89002, 85: 1.93846, 86: 1.98749, 87: 2.34276, 90: 2.24293, 98: 1.79202, 99: 1.82746, 100: 1.88749, 104: 1.90646, 112: 1.8826, 113: 1.97249, 114: 1.76646, 119: 1.82002, 128: 1.81746, 129: 1.76002, 135: 1.45998, 144: 1.7, 145: 1.82646, 152: 1.42998, 170: 1.5, 182: 3.12942, 201: 2.95693, 202: 2.56293, 205: 2.55649, 206: 3.02481, 209: 3.21942, 221: 2.80398, 222: 2.41824, 223: 2.24646, 224: 2.23302, 225: 2.37646, 226: 2.43649, 227: 2.91814, 230: 2.69295, 243: 2.29093, 244: 2.1074, 245: 2.12002, 246: 1.93998, 247: 2.27646, 248: 2.36649, 252: 2.24291, 266: 2.00146, 267: 1.99002, 268: 1.97146, 269: 2.15002, 270: 2.19646, 275: 1.76642, 290: 1.93002, 291: 2.08646, 292: 2.28849, 293: 2.11002, 299: 1.73642, 315: 2.01002, 316: 1.8, 317: 2.20646, 324: 1.67642, 341: 1.95002, 342: 2.16646, 350: 1.70642, 366: 3.47942, 368: 2.14646, 370: 3.41942, 377: 1.68642, 393: 3.00293, 394: 3.57685, 397: 3.25142, 398: 3.00295, 405: 1.9278, 420: 2.6, 421: 2.69646, 422: 2.89293, 423: 3.39412, 425: 3.11142, 426: 2.83062, 427: 2.54291, 434: 1.44998, 450: 2.58002, 451: 2.66646, 452: 2.79293, 455: 2.70495, 456: 2.42029, 457: 2.08642, 464: 1.81649, 480: 2.48381, 481: 2.47602, 482: 2.48846, 486: 2.32291, 487: 2.35391, 488: 2.38329, 495: 2.13293, 512: 2.57646, 513: 2.38002, 518: 2.86293, 519: 2.84939, 520: 2.5152, 527: 1.55998, 544: 2.2, 545: 2.28746, 551: 2.87293, 552: 2.44293, 553: 2.56193, 554: 2.25191, 560: 1.59998, 578: 2.37002, 585: 2.45293, 586: 2.51652, 587: 2.48193, 588: 2.19691, 612: 2.14296, 614: 3.44942, 620: 2.41093, 621: 2.44693, 622: 2.36293, 629: 1.58998, 649: 3.79285, 650: 3.41295, 656: 2.36293, 657: 2.40493, 658: 2.30649, 659: 2.32649, 685: 3.65976, 686: 3.31295, 687: 2.96291, 693: 2.35293, 694: 2.28149, 695: 2.49295, 723: 3.23295, 724: 2.88391, 725: 2.51642, 731: 2.20249, 732: 2.47295, 733: 2.43293, 736: 2.60649, 737: 3.2433, 740: 3.43645, 762: 2.92291, 763: 2.74646, 764: 2.46642, 770: 2.46295, 771: 2.41693, 772: 1.96, 774: 2.42646, 775: 2.57649, 776: 3.11654, 779: 2.87295, 802: 3.02293, 803: 2.82293, 804: 2.42642, 810: 2.38293, 811: 2.18646, 812: 1.92998, 813: 2.38646, 814: 2.40646, 815: 2.50649, 819: 2.46649, 843: 3.15293, 844: 2.72491, 845: 2.39642, 851: 2.14646, 852: 2.09802, 854: 2.01998, 855: 2.33646, 860: 2.29004, 885: 2.80293, 886: 2.93293, 887: 2.42642, 893: 2.01002, 894: 2.24546, 895: 2.1, 896: 2.26002, 902: 1.90642, 928: 2.84593, 929: 2.83793, 930: 2.36642, 936: 2.15646, 937: 2.16102, 945: 1.83701, 972: 2.86293, 973: 2.65293, 974: 2.31998, 980: 2.08002, 981: 2.35646, 1017: 2.74593, 1018: 2.58649, 1019: 2.65649, 1023: 3.64942, 1025: 2.20646, 1027: 3.79645, 1034: 1.65998, 1063: 2.62649, 1064: 2.76095, 1065: 2.86293, 1068: 3.09293, 1069: 3.71593, 1071: 2.67549, 1072: 3.43945, 1073: 3.09295, 1080: 1.59998, 1110: 2.75295, 1111: 2.80293, 1112: 2.46998, 1114: 2.75646, 1115: 3.03293, 1116: 3.57715, 1118: 3.37645, 1119: 2.98095, 1120: 2.77649, 1127: 1.51998, 1158: 2.72293, 1159: 2.61946, 1160: 2.36998, 1161: 2.66002, 1162: 2.72646, 1163: 2.99293, 1166: 2.88195, 1167: 2.62549, 1168: 2.65004, 1175: 1.65642, 1207: 2.52646, 1208: 2.56702, 1209: 2.29998, 1210: 2.61002, 1211: 2.65646, 1215: 2.51049, 1216: 3.09651, 1217: 2.46046, 1224: 2.52295, 1257: 2.49002, 1258: 2.84649, 1259: 2.69646, 1260: 2.55002, 1265: 2.99651, 1266: 2.45329, 1267: 2.4735, 1274: 1.87642, 1308: 2.61646, 1309: 2.81649, 1310: 2.44293, 1316: 2.35646, 1317: 2.3475, 1325: 2.00642, 1360: 2.57002, 1361: 2.21998, 1368: 2.2998, 1369: 2.22446, 1370: 2.2626, 1377: 2.81998, 1411: 3.94942, 1413: 2.33296, 1415: 3.50645, 1421: 2.24219, 1422: 2.22646, 1423: 2.2626, 1424: 2.33649, 1430: 1.87998, 1464: 3.48295, 1465: 4.00186, 1468: 3.97645, 1469: 3.43295, 1475: 2.57646, 1476: 2.24946, 1477: 2.40451, 1518: 3.04291, 1519: 3.42295, 1520: 3.8513, 1522: 3.86664, 1523: 3.51295, 1524: 3.17649, 1530: 2.16646, 1531: 2.39849, 1532: 2.00642, 1573: 2.87642, 1574: 3.00291, 1575: 3.36995, 1578: 3.37295, 1579: 3.08649, 1580: 3.02004, 1586: 2.34649, 1587: 2.81139, 1588: 2.82295, 1592: 3.42496, 1595: 3.55942, 1629: 2.54642, 1630: 2.53642, 1631: 2.94291, 1635: 3.00649, 1636: 2.91004, 1637: 2.61642, 1643: 2.76939, 1644: 2.76695, 1645: 2.18642, 1648: 2.81649, 1649: 3.37676, 1652: 3.08295, 1686: 2.49642, 1687: 2.48642, 1688: 3.20293, 1693: 3.33651, 1694: 2.74, 1695: 2.54701, 1701: 2.67395, 1702: 2.46491, 1703: 2.7152, 1705: 2.65646, 1706: 2.70649, 1710: 2.77293, 1744: 2.51642, 1745: 2.44642, 1746: 2.87329, 1752: 2.76291, 1753: 2.80067, 1760: 2.35491, 1761: 2.82146, 1762: 2.56446, 1763: 2.25998, 1764: 2.55646, 1769: 2.34644, 1803: 2.50642, 1804: 2.47642, 1805: 2.97293, 1812: 2.80447, 1814: 2.33998, 1820: 2.63793, 1821: 2.45237, 1822: 2.16998, 1823: 2.16998, 1829: 2.62649, 1863: 2.43642, 1864: 2.43642, 1865: 3.05293, 1873: 2.56002, 1874: 2.6426, 1875: 2.43998, 1881: 2.35646, 1882: 2.3334, 1924: 2.28998, 1925: 2.39642, 1926: 2.8952, 1935: 2.70646, 1936: 2.19998, 1937: 2.46998, 1943: 2.22002, 1944: 2.47646, 1986: 2.71895, 1987: 2.18998, 1988: 2.33642, 1998: 2.62646, 1999: 2.69649, 2e3: 2.37642, 2006: 3.18295, 2007: 2.63451, 2008: 3.94942, 2015: 2.56649, 2049: 2.95293, 2050: 2.76295, 2051: 2.80649, 2062: 2.65649, 2063: 3.08839, 2064: 3.20295, 2068: 3.95459, 2070: 2.62649, 2071: 3.53642, 2072: 3.33295, 2079: 2.18898, 2112: 2.6, 2113: 2.38998, 2114: 2.93293, 2115: 2.89295, 2127: 3.05939, 2128: 3.16695, 2129: 2.68642, 2132: 3.24293, 2133: 3.88251, 2135: 3.49942, 2136: 3.14795, 2137: 3.05293, 2144: 2.13, 2178: 2.47998, 2179: 3.41295, 2180: 2.86293, 2193: 3.09295, 2194: 2.93291, 2195: 2.60642, 2197: 2.93646, 2198: 3.17293, 2201: 3.05095, 2202: 2.90983, 2203: 2.78549, 2210: 2.51649, 2245: 2.70002, 2246: 2.6426, 2260: 3.52939, 2261: 3.15293, 2262: 2.56998, 2263: 2.84002, 2264: 2.86646, 2268: 2.79293, 2269: 2.86393, 2270: 2.90649, 2277: 2.09, 2312: 2.98649, 2313: 2.34998, 2328: 3.13111, 2329: 3.05, 2330: 2.56998, 2331: 2.76002, 2336: 2.75452, 2337: 2.74449, 2338: 3.01293, 2345: 2.11898, 2380: 2.93649, 2381: 2.80646, 2397: 2.80646, 2398: 2.79002, 2399: 2.44998, 2405: 2.62945, 2406: 2.8587, 2414: 2.06, 2450: 2.78002, 2467: 2.73906, 2468: 2.40998, 2475: 2.73452, 2477: 3.02351, 2484: 2.45649, 2522: 4.04645, 2538: 3.33295, 2540: 3.64194, 2546: 2.55233, 2547: 2.88251, 2548: 2.95549, 2555: 2.42649, 2593: 4.13773, 2594: 3.62295, 2608: 4.23284, 2611: 4.24942, 2612: 3.48295, 2618: 2.60649, 2619: 2.94249, 2620: 2.42, 2627: 2.42649, 2665: 4.05498, 2666: 3.58295, 2667: 3.24649, 2680: 3.62295, 2681: 4.11717, 2683: 3.91042, 2684: 3.66195, 2685: 3.32293, 2691: 2.83549, 2692: 2.76651, 2693: 2.80649, 2700: 1.93642, 2739: 3.54295, 2740: 3.21649, 2741: 3.07004, 2753: 3.20291, 2754: 3.58295, 2757: 3.55295, 2758: 3.35593, 2759: 3.00644, 2765: 3.15651, 2766: 2.65549, 2767: 2.38, 2774: 1.91642, 2814: 3.15649, 2815: 3.03004, 2816: 2.69642, 2824: 3.14729, 2827: 2.95642, 2828: 3.15291, 2832: 3.33452, 2833: 3.36293, 2834: 3.28649, 2840: 2.54249, 2841: 2.65651, 2842: 2.41898, 2849: 1.80998, 2890: 2.98004, 2891: 2.66642, 2892: 2.62701, 2902: 2.72642, 2903: 3.08291, 2908: 3.25293, 2909: 3.20649, 2916: 2.52944, 2917: 2.67047, 2918: 2.36, 2925: 1.79998, 2967: 3.07646, 2968: 2.59701, 2975: 3.13629, 2978: 2.67642, 2979: 2.66642, 2985: 3.12749, 2986: 3.42712, 2993: 2.56159, 2994: 2.63651, 2995: 2.74649, 3045: 2.8535, 3047: 2.40998, 3055: 2.70642, 3056: 3.19293, 3063: 3.22493, 3065: 3.23649, 3071: 2.51049, 3072: 2.60649, 3073: 2.84851, 3080: 1.80998, 3125: 2.69451, 3126: 2.41998, 3133: 2.68642, 3134: 3.23293, 3142: 3.41233, 3143: 3.15649, 3144: 2.85898, 3150: 2.51649, 3151: 2.74551, 3152: 2.71649, 3159: 1.44998, 3204: 2.30998, 3205: 2.37998, 3206: 2.34998, 3212: 2.61642, 3213: 3.1552, 3222: 3.08749, 3223: 3.37949, 3224: 2.81, 3230: 2.50649, 3231: 2.57749, 3232: 2.24642, 3239: 1.41998, 3285: 2.7126, 3286: 2.26998, 3287: 2.45642, 3292: 2.47998, 3293: 2.52878, 3303: 3.32549, 3304: 3.13649, 3305: 3.19649, 3311: 2.48249, 3312: 2.37946, 3313: 2.16642, 3320: 1.86642, 3367: 2.80649, 3368: 3.2, 3369: 3.29295, 3373: 2.87649, 3374: 3.00649, 3385: 3.06349, 3386: 3.11649, 3387: 2.77, 3393: 3.18291, 3394: 2.74646, 3395: 2.10998, 3402: 2.35644, 3450: 2.37642, 3451: 3.26295, 3452: 2.66642, 3455: 3.16293, 3456: 3.01795, 3468: 3.04349, 3469: 2.823, 3470: 2.79898, 3476: 2.2539, 3477: 2.20102, 3478: 2.10998, 3485: 2.27644, 3534: 3.21295, 3535: 2.62642, 3536: 2.77642, 3538: 2.58998, 3539: 3.07293, 3552: 3.01945, 3553: 3.13547, 3554: 2.75, 3560: 2.03, 3561: 2.3426, 3569: 2.12642, 3619: 3.05329, 3620: 2.96646, 3621: 2.64998, 3622: 2.60998, 3623: 2.91646, 3637: 3.05159, 3638: 3.27651, 3639: 3.13649, 3645: 2.16002, 3646: 2.23, 3647: 2.10998, 3648: 2.36649, 3705: 3.2152, 3706: 3.05646, 3707: 3.10646, 3708: 2.54998, 3723: 2.99944, 3724: 3.05649, 3725: 3.13649, 3731: 2.07746, 3732: 2.27746, 3733: 2.41649, 3792: 2.96646, 3793: 2.57998, 3794: 3.03646, 3810: 2.98944, 3811: 3.03649, 3812: 3.11649, 3818: 2.15002, 3819: 2.40649, 3820: 2.3826, 3880: 2.90002, 3881: 2.58998, 3898: 2.98249, 3899: 3.03649, 3900: 2.63642, 3906: 2.54002, 3907: 2.34646, 3908: 2.17642, 3971: 4.15942, 3987: 2.96944, 3988: 2.64642, 3989: 2.62642, 3995: 2.34646, 3996: 2.86939, 3997: 2.59644, 4057: 4.28802, 4060: 4.21655, 4061: 3.69, 4077: 2.75646, 4078: 2.8439, 4079: 2.50998, 4085: 2.88293, 4086: 3.36945, 4087: 3.0967, 4147: 3.73295, 4148: 4.33462, 4150: 4.06942, 4151: 3.74295, 4152: 3.51293, 4168: 2.6739, 4169: 2.43998, 4170: 2.50998, 4176: 3.26942, 4177: 3.04096, 4178: 2.56329, 4185: 2.67649, 4238: 3.40649, 4239: 3.74295, 4242: 3.74295, 4243: 3.45293, 4244: 3.08644, 4260: 2.47, 4261: 2.61998, 4268: 2.92045, 4269: 2.6608, 4330: 3.17004, 4331: 3.37649, 4335: 3.43293, 4336: 3.04644, 4337: 3.35649, 4353: 3.44712, 4354: 2.56002, 4355: 2.50998, 4361: 2.55291, 4362: 2.64646, 4370: 2.27644, 4423: 2.85642, 4424: 3.19004, 4429: 3.40452, 4430: 3.32649, 4447: 2.54002, 4448: 2.42998, 4449: 2.23998, 4455: 2.83646, 4517: 2.79701, 4518: 3.1439, 4524: 3.27649, 4525: 3.42293, 4542: 2.56746, 4543: 2.76649, 4544: 2.18998, 4613: 2.74701, 4620: 3.37293, 4622: 3.30649, 4638: 2.75646, 4639: 2.8326, 4640: 2.57642, 4708: 2.58998, 4717: 3.18233, 4718: 3.27649, 4719: 2.93898, 4735: 2.88295, 4736: 3.42093, 4737: 3.01644, 4805: 2.59998, 4806: 2.52998, 4815: 3.26649, 4816: 2.89898, 4817: 3.18, 4833: 3.24939, 4834: 3.66442, 4835: 2.94644, 4842: 2.7326, 4843: 2.94649, 4903: 2.52998, 4904: 2.52998, 4914: 3.46549, 4915: 2.85, 4916: 3.26649, 4932: 3.72942, 4933: 3.40395, 4934: 2.78642, 4940: 2.58646, 4941: 2.77349, 5002: 2.66642, 5003: 2.96649, 5014: 3.19945, 5015: 3.23649, 5016: 3.14, 5032: 3.39295, 5033: 3.13291, 5040: 2.68945, 5041: 2.63383, 5042: 2.78649, 5102: 3.45295, 5103: 2.53642, 5115: 3.18649, 5116: 2.81, 5117: 2.87898, 5133: 3.04291, 5141: 2.54437, 5142: 2.94295, 5203: 2.84642, 5204: 3.46295, 5217: 3.16945, 5218: 2.84898, 5219: 3.18, 5243: 2.80293, 5244: 2.63646, 5305: 2.91642, 5306: 3.19291, 5320: 3.20159, 5321: 3.18649, 5322: 3.22649, 5346: 2.59233, 5347: 2.68329, 5408: 2.82998, 5409: 3.52293, 5424: 3.14945, 5425: 3.18649, 5426: 3.19649, 5450: 2.58233, 5451: 2.71649, 5512: 2.80998, 5513: 3.21646, 5529: 3.13945, 5530: 3.16649, 5531: 3.19649, 5555: 2.61945, 5556: 2.79291, 5618: 3.13702, 5635: 3.12945, 5636: 3.16649, 5637: 2.71642, 5655: 3.33649, 5661: 2.68291, 5662: 2.64329, 5724: 2.4, 5742: 3.11945, 5743: 2.67642, 5744: 2.70642, 5760: 3.08646, 5761: 3.24649, 5768: 2.54233, 5769: 2.63291, 5833: 4.4631, 5850: 2.62642, 5851: 2.66642, 5852: 2.58998, 5868: 3.15945, 5870: 2.94644, 5876: 2.53233, 5877: 2.70139, 5941: 4.40942, 5942: 3.94295, 5959: 2.60642, 5960: 2.55998, 5961: 2.61998, 5977: 3.01437, 5978: 3.25293, 6051: 3.99295, 6052: 3.65293, 6069: 2.49998, 6070: 2.54998, 6087: 3.24452, 6088: 3.2, 6162: 3.64293, 6163: 3.22644, 6180: 2.70002, 6182: 2.58998, 6198: 3.07233, 6199: 3.3, 6274: 3.62452, 6275: 3.50649, 6292: 2.72002, 6293: 2.55998, 6294: 2.30998, 6310: 3.05233, 6387: 3.49649, 6388: 3.60293, 6405: 2.49998, 6406: 2.23998, 6407: 2.26998, 6423: 3.08945, 6501: 3.59452, 6519: 2.94191, 6520: 2.22998, 6521: 2.65642, 6537: 3.18291, 6617: 3.46649, 6634: 2.77646, 6635: 2.82642, 6636: 3.09644, 6652: 3.02291, 6732: 3.44649, 6733: 3.08898, 6750: 3.09293, 6751: 3.00644, 6752: 3.02644, 6768: 3.01291, 6849: 3.69549, 6850: 3.24, 6867: 3.80942, 6868: 3.55295, 6869: 2.87642, 6967: 3.41945, 6968: 3.42649, 6985: 3.62451, 6986: 3.5, 7086: 3.40945, 7087: 3.22, 7104: 3.17993, 7206: 3.39945, 7207: 3.03898, 7327: 3.44159, 7328: 3.22, 7449: 3.38945, 7450: 3.37649, 7494: 3.08895, 7572: 3.37945, 7573: 3.36649, 7616: 2.99195, 7696: 3.37945, 7697: 3.35649, 7716: 3.40649, 7821: 3.36945, 7822: 2.87642, 7839: 3.22726, 7840: 3.36649, 7947: 2.83642, 7948: 2.85642, 7965: 3.31945, 7967: 3.02644, 8074: 2.81642, 8075: 2.75998, 8092: 3.18437, 8093: 3.00644, 8202: 2.70998, 8203: 2.74998, 8220: 3.39452, 8331: 2.65998, 8349: 3.21233, 8462: 2.75998, 8479: 3.19233, 8592: 2.70998, 8593: 2.49998, 8610: 3.22944, 8628: 3.48195, 8724: 2.41998, 8725: 2.45998, 8857: 3.21295, 8858: 2.76642, 8875: 3.15233, 8991: 3.33293, 8992: 3.23644, 9009: 3.14233, 9126: 3.94142, 9127: 3.14644, 9262: 3.69562, 9263: 3.02642, 9399: 3.38291, 10243: 3.54649, 10386: 3.56649, 10532: 3.16644, 10677: 3.62452, 10824: 3.44233, 10972: 3.43233, 12960: 3.1952 }, eA = 2.001, w2 = function() {
  for (var e = /* @__PURE__ */ new Set(), t = 0, r = ["LI", "NA", "K", "RB", "CS", "FR", "BE", "MG", "CA", "SR", "BA", "RA", "AL", "GA", "IN", "SN", "TL", "PB", "BI", "SC", "TI", "V", "CR", "MN", "FE", "CO", "NI", "CU", "ZN", "Y", "ZR", "NB", "MO", "TC", "RU", "RH", "PD", "AG", "CD", "LA", "HF", "TA", "W", "RE", "OS", "IR", "PT", "AU", "HG", "AC", "RF", "DB", "SG", "BH", "HS", "MT", "CE", "PR", "ND", "PM", "SM", "EU", "GD", "TB", "DY", "HO", "ER", "TM", "YB", "LU", "TH", "PA", "U", "NP", "PU", "AM", "CM", "BK", "CF", "ES", "FM", "MD", "NO", "LR"]; t < r.length; t++) {
    var n = r[t];
    e.add(tm[n]);
  }
  return e;
}();
function ZM(e, t) {
  return e < t ? (e + t) * (e + t + 1) / 2 + t : (e + t) * (e + t + 1) / 2 + e;
}
function zl(e) {
  var t = tm[e];
  return t === void 0 ? -1 : t;
}
function E1(e) {
  if (e < 0) return eA;
  var t = NK[e];
  return t === void 0 ? eA : t;
}
function mb(e, t, r, n, i) {
  var a = function(o, u, s) {
    if (o < 0 || u < 0) return -1;
    var c = (s ? WM : YM)[ZM(o, u)];
    return c === void 0 ? -1 : c;
  }(e, t, i);
  return a > 0 ? a : t < 0 ? r : (r + n) / 1.95;
}
var RK = tm.H;
function Gl(e) {
  return e === RK;
}
var OK = /* @__PURE__ */ new Map([["HIS|CD2|CG", 2], ["HIS|CE1|ND1", 2], ["ARG|CZ|NH2", 2], ["PHE|CE1|CZ", 2], ["PHE|CD2|CE2", 2], ["PHE|CD1|CG", 2], ["TRP|CD1|CG", 2], ["TRP|CD2|CE2", 2], ["TRP|CE3|CZ3", 2], ["TRP|CH2|CZ2", 2], ["ASN|CG|OD1", 2], ["GLN|CD|OE1", 2], ["TYR|CD1|CG", 2], ["TYR|CD2|CE2", 2], ["TYR|CE1|CZ", 2], ["ASP|CG|OD1", 2], ["GLU|CD|OE1", 2], ["G|C8|N7", 2], ["G|C4|C5", 2], ["G|C2|N3", 2], ["G|C6|O6", 2], ["C|C4|N3", 2], ["C|C5|C6", 2], ["C|C2|O2", 2], ["A|C2|N3", 2], ["A|C6|N1", 2], ["A|C4|C5", 2], ["A|C8|N7", 2], ["U|C5|C6", 2], ["U|C2|O2", 2], ["U|C4|O4", 2], ["DG|C8|N7", 2], ["DG|C4|C5", 2], ["DG|C2|N3", 2], ["DG|C6|O6", 2], ["DC|C4|N3", 2], ["DC|C5|C6", 2], ["DC|C2|O2", 2], ["DA|C2|N3", 2], ["DA|C6|N1", 2], ["DA|C4|C5", 2], ["DA|C8|N7", 2], ["DT|C5|C6", 2], ["DT|C2|O2", 2], ["DT|C4|O4", 2]]);
function LK(e, t, r) {
  var n;
  return t = (n = t < r ? [t, r] : [r, t])[0], r = n[1], wm.has(e) && t === "C" && r === "O" || g_.has(e) && t === "OP1" && r === "P" ? 2 : OK.get("".concat(e, "|").concat(t, "|").concat(r)) || 1;
}
var kK = /* @__PURE__ */ new Map([["LYS|NZ|RET|C15", 2]]);
function QM(e, t, r, n) {
  var i, a;
  return e > r && (e = (i = [r, e])[0], r = i[1], t = (a = [n, t])[0], n = a[1]), kK.get("".concat(e, "|").concat(t, "|").concat(r, "|").concat(n)) || 1;
}
var cd = oe.Schema, Y = cd.str, be = cd.int, qt = cd.float, Vy = cd.coord, ht = cd.Aliased, ll = cd.Matrix, Vh = cd.Vector, Cd = cd.List, tr = { atom_site: { auth_asym_id: Y, auth_atom_id: Y, auth_comp_id: Y, auth_seq_id: be, B_iso_or_equiv: qt, Cartn_x: Vy, Cartn_y: Vy, Cartn_z: Vy, group_PDB: ht(Y), id: be, label_alt_id: Y, label_asym_id: Y, label_atom_id: Y, label_comp_id: Y, label_entity_id: Y, label_seq_id: be, occupancy: qt, type_symbol: Y, pdbx_PDB_ins_code: Y, pdbx_PDB_model_num: be, pdbx_formal_charge: be, pdbx_label_index: be, pdbx_sifts_xref_db_name: Y, pdbx_sifts_xref_db_acc: Y, pdbx_sifts_xref_db_num: Y, pdbx_sifts_xref_db_res: Y, ihm_model_id: be, cdr: be, em_confidence: Y }, atom_site_anisotrop: { id: be, type_symbol: Y, U: ll(3, 3), U_esd: ll(3, 3), pdbx_auth_seq_id: Y, pdbx_auth_asym_id: Y, pdbx_auth_atom_id: Y, pdbx_auth_comp_id: Y, pdbx_label_seq_id: be, pdbx_label_alt_id: Y, pdbx_label_asym_id: Y, pdbx_label_atom_id: Y, pdbx_label_comp_id: Y, pdbx_PDB_ins_code: Y }, atom_sites: { entry_id: Y, fract_transf_matrix: ll(3, 3), fract_transf_vector: Vh(3) }, audit_author: { name: Y, pdbx_ordinal: be, identifier_ORCID: Y }, audit_conform: { dict_location: Y, dict_name: Y, dict_version: Y }, cell: { angle_alpha: qt, angle_beta: qt, angle_gamma: qt, entry_id: Y, length_a: qt, length_b: qt, length_c: qt, Z_PDB: be, pdbx_unique_axis: Y }, chem_comp: { formula: Y, formula_weight: qt, id: Y, mon_nstd_flag: ht(Y), name: Y, type: ht(Y), pdbx_synonyms: Cd(";", function(e) {
  return e;
}) }, chem_comp_bond: { atom_id_1: Y, atom_id_2: Y, comp_id: Y, value_order: ht(Y), pdbx_ordinal: be, pdbx_stereo_config: ht(Y), pdbx_aromatic_flag: ht(Y) }, citation: { book_publisher: Y, country: Y, id: Y, journal_abbrev: Y, journal_id_ASTM: Y, journal_id_CSD: Y, journal_id_ISSN: Y, journal_volume: Y, page_first: Y, page_last: Y, title: Y, year: be, pdbx_database_id_DOI: Y, pdbx_database_id_PubMed: be }, citation_author: { citation_id: Y, name: Y, ordinal: be }, database_2: { database_id: ht(Y), database_code: Y }, entity: { details: Y, formula_weight: qt, id: Y, src_method: ht(Y), type: ht(Y), pdbx_description: Cd(",", function(e) {
  return e;
}), pdbx_number_of_molecules: be, pdbx_mutation: Y, pdbx_fragment: Y, pdbx_ec: Cd(",", function(e) {
  return e;
}) }, entity_poly: { entity_id: Y, nstd_linkage: ht(Y), nstd_monomer: ht(Y), type: ht(Y), pdbx_strand_id: Cd(",", function(e) {
  return e;
}), pdbx_seq_one_letter_code: Y, pdbx_seq_one_letter_code_can: Y, pdbx_target_identifier: Y }, entity_poly_seq: { entity_id: Y, hetero: ht(Y), mon_id: Y, num: be }, entry: { id: Y }, exptl: { entry_id: Y, method: ht(Y) }, software: { classification: Y, date: Y, description: Y, name: Y, type: ht(Y), version: Y, pdbx_ordinal: be }, struct: { entry_id: Y, title: Y, pdbx_descriptor: Y }, struct_asym: { details: Y, entity_id: Y, id: Y, pdbx_modified: Y, pdbx_blank_PDB_chainid_flag: ht(Y) }, struct_conf: { beg_label_asym_id: Y, beg_label_comp_id: Y, beg_label_seq_id: be, beg_auth_asym_id: Y, beg_auth_comp_id: Y, beg_auth_seq_id: be, conf_type_id: ht(Y), details: Y, end_label_asym_id: Y, end_label_comp_id: Y, end_label_seq_id: be, end_auth_asym_id: Y, end_auth_comp_id: Y, end_auth_seq_id: be, id: Y, pdbx_beg_PDB_ins_code: Y, pdbx_end_PDB_ins_code: Y, pdbx_PDB_helix_class: Y, pdbx_PDB_helix_length: be, pdbx_PDB_helix_id: Y }, struct_conn: { conn_type_id: ht(Y), details: Y, id: Y, ptnr1_label_asym_id: Y, ptnr1_label_atom_id: Y, ptnr1_label_comp_id: Y, ptnr1_label_seq_id: be, ptnr1_auth_asym_id: Y, ptnr1_auth_comp_id: Y, ptnr1_auth_seq_id: be, ptnr1_symmetry: Y, ptnr2_label_asym_id: Y, ptnr2_label_atom_id: Y, ptnr2_label_comp_id: Y, ptnr2_label_seq_id: be, ptnr2_auth_asym_id: Y, ptnr2_auth_comp_id: Y, ptnr2_auth_seq_id: be, ptnr2_symmetry: Y, pdbx_ptnr1_PDB_ins_code: Y, pdbx_ptnr1_label_alt_id: Y, pdbx_ptnr1_standard_comp_id: Y, pdbx_ptnr2_PDB_ins_code: Y, pdbx_ptnr2_label_alt_id: Y, pdbx_ptnr3_PDB_ins_code: Y, pdbx_ptnr3_label_alt_id: Y, pdbx_ptnr3_label_asym_id: Y, pdbx_ptnr3_label_atom_id: Y, pdbx_ptnr3_label_comp_id: Y, pdbx_ptnr3_label_seq_id: be, pdbx_PDB_id: Y, pdbx_dist_value: qt, pdbx_value_order: ht(Y) }, struct_conn_type: { criteria: Y, id: ht(Y), reference: Y }, struct_keywords: { entry_id: Y, text: Cd(",", function(e) {
  return e;
}), pdbx_keywords: Y }, struct_ncs_oper: { code: ht(Y), details: Y, id: be, matrix: ll(3, 3), vector: Vh(3) }, struct_sheet_range: { beg_label_asym_id: Y, beg_label_comp_id: Y, beg_label_seq_id: be, end_label_asym_id: Y, end_label_comp_id: Y, end_label_seq_id: be, beg_auth_asym_id: Y, beg_auth_comp_id: Y, beg_auth_seq_id: be, end_auth_asym_id: Y, end_auth_comp_id: Y, end_auth_seq_id: be, id: Y, sheet_id: Y, pdbx_beg_PDB_ins_code: Y, pdbx_end_PDB_ins_code: Y }, struct_site: { details: Y, id: Y, pdbx_num_residues: be, pdbx_evidence_code: Y, pdbx_auth_asym_id: Y, pdbx_auth_comp_id: Y, pdbx_auth_seq_id: Y, pdbx_auth_ins_code: Y }, struct_site_gen: { details: Y, id: Y, label_alt_id: Y, label_asym_id: Y, label_atom_id: Y, label_comp_id: Y, label_seq_id: be, auth_asym_id: Y, auth_comp_id: Y, auth_seq_id: Y, site_id: Y, symmetry: Y, pdbx_auth_ins_code: Y, pdbx_num_res: be }, symmetry: { entry_id: Y, cell_setting: ht(Y), Int_Tables_number: be, space_group_name_Hall: Y, "space_group_name_H-M": Y }, pdbx_database_status: { status_code: ht(Y), status_code_sf: ht(Y), status_code_mr: ht(Y), entry_id: Y, recvd_initial_deposition_date: Y, SG_entry: ht(Y), deposit_site: ht(Y), process_site: ht(Y), status_code_cs: ht(Y), methods_development_category: ht(Y), pdb_format_compatible: ht(Y) }, pdbx_nonpoly_scheme: { asym_id: Y, entity_id: Y, mon_id: Y, pdb_strand_id: Y, ndb_seq_num: Y, pdb_seq_num: Y, auth_seq_num: Y, pdb_mon_id: Y, auth_mon_id: Y, pdb_ins_code: Y }, pdbx_database_related: { db_name: Y, details: Y, db_id: Y, content_type: ht(Y) }, pdbx_entity_nonpoly: { entity_id: Y, comp_id: Y, name: Y }, pdbx_chem_comp_synonyms: { name: Y, comp_id: Y, provenance: ht(Y) }, pdbx_chem_comp_identifier: { comp_id: Y, identifier: Y, type: ht(Y), program: Y, program_version: Y }, pdbx_unobs_or_zero_occ_residues: { id: be, polymer_flag: ht(Y), occupancy_flag: ht(be), PDB_model_num: be, auth_asym_id: Y, auth_comp_id: Y, auth_seq_id: Y, PDB_ins_code: Y, label_asym_id: Y, label_comp_id: Y, label_seq_id: be }, pdbx_struct_mod_residue: { id: be, auth_asym_id: Y, auth_comp_id: Y, auth_seq_id: be, PDB_ins_code: Y, label_asym_id: Y, label_comp_id: Y, label_seq_id: be, parent_comp_id: Y, details: Y }, pdbx_struct_oper_list: { id: Y, type: ht(Y), name: Y, symmetry_operation: Y, matrix: ll(3, 3), vector: Vh(3) }, pdbx_struct_assembly: { method_details: Y, oligomeric_details: Y, oligomeric_count: be, details: Y, id: Y }, pdbx_struct_assembly_gen: { asym_id_list: Cd(",", function(e) {
  return e;
}), assembly_id: Y, oper_expression: Y }, pdbx_reference_entity_list: { prd_id: Y, ref_entity_id: Y, type: ht(Y), details: Y, component_id: be }, pdbx_reference_entity_link: { link_id: be, prd_id: Y, details: Y, ref_entity_id_1: Y, ref_entity_id_2: Y, entity_seq_num_1: be, entity_seq_num_2: be, comp_id_1: Y, comp_id_2: Y, atom_id_1: Y, atom_id_2: Y, value_order: ht(Y), component_1: be, component_2: be, link_class: ht(Y) }, pdbx_reference_entity_poly_link: { link_id: be, prd_id: Y, ref_entity_id: Y, component_id: be, entity_seq_num_1: be, entity_seq_num_2: be, comp_id_1: Y, comp_id_2: Y, atom_id_1: Y, atom_id_2: Y, value_order: ht(Y) }, pdbx_molecule: { prd_id: Y, instance_id: be, asym_id: Y }, pdbx_molecule_features: { prd_id: Y, class: ht(Y), type: ht(Y), name: Y, details: Y }, entity_src_nat: { entity_id: Y, pdbx_organism_scientific: Y, pdbx_plasmid_name: Y, pdbx_src_id: be, pdbx_beg_seq_num: be, pdbx_end_seq_num: be }, entity_src_gen: { entity_id: Y, pdbx_gene_src_gene: Cd(",", function(e) {
  return e;
}), pdbx_gene_src_scientific_name: Y, plasmid_name: Y, pdbx_src_id: be, pdbx_beg_seq_num: be, pdbx_end_seq_num: be }, pdbx_entity_src_syn: { organism_scientific: Y, entity_id: Y, pdbx_src_id: be, pdbx_beg_seq_num: be, pdbx_end_seq_num: be }, pdbx_entity_branch_descriptor: { entity_id: Y, descriptor: Y, type: ht(Y), program: Y, program_version: Y, ordinal: be }, pdbx_entity_instance_feature: { details: Y, feature_type: ht(Y), auth_asym_id: Y, asym_id: Y, auth_seq_num: Y, seq_num: be, comp_id: Y, auth_comp_id: Y, ordinal: be }, pdbx_entity_branch_list: { entity_id: Y, hetero: ht(Y), comp_id: Y, num: be }, pdbx_entity_branch_link: { link_id: be, details: Y, entity_id: Y, entity_branch_list_num_1: be, entity_branch_list_num_2: be, comp_id_1: Y, comp_id_2: Y, atom_id_1: Y, leaving_atom_id_1: Y, atom_stereo_config_1: ht(Y), atom_id_2: Y, leaving_atom_id_2: Y, atom_stereo_config_2: ht(Y), value_order: ht(Y) }, pdbx_entity_branch: { entity_id: Y, type: ht(Y) }, pdbx_branch_scheme: { entity_id: Y, hetero: ht(Y), asym_id: Y, mon_id: Y, num: be, pdb_asym_id: Y, pdb_seq_num: Y, pdb_mon_id: Y, auth_asym_id: Y, auth_seq_num: Y, auth_mon_id: Y }, pdbx_chem_comp_related: { comp_id: Y, related_comp_id: Y, relationship_type: ht(Y), details: Y }, ihm_starting_model_details: { starting_model_id: Y, entity_id: Y, entity_description: Y, asym_id: Y, entity_poly_segment_id: be, starting_model_source: ht(Y), starting_model_auth_asym_id: Y, starting_model_sequence_offset: be, dataset_list_id: be }, ihm_starting_comparative_models: { id: be, starting_model_id: Y, starting_model_auth_asym_id: Y, starting_model_seq_id_begin: be, starting_model_seq_id_end: be, template_auth_asym_id: Y, template_seq_id_begin: be, template_seq_id_end: be, template_sequence_identity: qt, template_sequence_identity_denominator: ht(be), template_dataset_list_id: be, alignment_file_id: be }, ihm_starting_model_seq_dif: { id: be, entity_id: Y, asym_id: Y, seq_id: be, comp_id: Y, starting_model_id: Y, db_asym_id: Y, db_seq_id: be, db_comp_id: Y, details: Y }, ihm_model_representation: { id: be, name: Y, details: Y }, ihm_model_representation_details: { id: be, representation_id: be, entity_poly_segment_id: be, entity_id: Y, entity_description: Y, entity_asym_id: Y, model_object_primitive: ht(Y), starting_model_id: Y, model_mode: ht(Y), model_granularity: ht(Y), model_object_count: be }, ihm_struct_assembly_details: { id: be, assembly_id: be, parent_assembly_id: be, entity_description: Y, entity_id: Y, asym_id: Y, entity_poly_segment_id: be }, ihm_struct_assembly: { id: be, name: Y, description: Y }, ihm_modeling_protocol: { id: be, num_steps: be, protocol_name: Y }, ihm_modeling_protocol_details: { id: be, protocol_id: be, step_id: be, struct_assembly_id: be, dataset_group_id: be, struct_assembly_description: Y, step_name: Y, step_method: Y, num_models_begin: be, num_models_end: be, multi_scale_flag: ht(Y), multi_state_flag: ht(Y), ordered_flag: ht(Y), script_file_id: be, software_id: be }, ihm_multi_state_modeling: { state_id: be, state_group_id: be, population_fraction: qt, population_fraction_sd: qt, state_type: Y, state_name: Y, experiment_type: ht(Y), details: Y }, ihm_modeling_post_process: { id: be, protocol_id: be, analysis_id: be, step_id: be, type: ht(Y), feature: ht(Y), num_models_begin: be, num_models_end: be }, ihm_ensemble_info: { ensemble_id: be, ensemble_name: Y, post_process_id: be, model_group_id: be, ensemble_clustering_method: ht(Y), ensemble_clustering_feature: ht(Y), num_ensemble_models: be, num_ensemble_models_deposited: be, ensemble_precision_value: qt, ensemble_file_id: be }, ihm_model_list: { model_id: be, model_name: Y, assembly_id: be, protocol_id: be, representation_id: be }, ihm_model_group: { id: be, name: Y, details: Y }, ihm_model_group_link: { model_id: be, group_id: be }, ihm_model_representative: { id: be, model_group_id: be, model_id: be, selection_criteria: ht(Y) }, ihm_dataset_list: { id: be, data_type: ht(Y), database_hosted: ht(Y) }, ihm_dataset_group: { id: be, name: Y, application: ht(Y), details: Y }, ihm_dataset_group_link: { dataset_list_id: be, group_id: be }, ihm_related_datasets: { dataset_list_id_derived: be, dataset_list_id_primary: be }, ihm_dataset_related_db_reference: { id: be, dataset_list_id: be, db_name: ht(Y), accession_code: Y, version: Y, details: Y }, ihm_external_reference_info: { reference_id: be, reference_provider: Y, reference_type: ht(Y), reference: Y, refers_to: ht(Y), associated_url: Y }, ihm_external_files: { id: be, reference_id: be, file_path: Y, content_type: ht(Y), file_size_bytes: qt, details: Y }, ihm_dataset_external_reference: { id: be, dataset_list_id: be, file_id: be }, ihm_localization_density_files: { id: be, file_id: be, ensemble_id: be, entity_id: Y, entity_poly_segment_id: be, asym_id: Y }, ihm_predicted_contact_restraint: { id: be, group_id: be, entity_id_1: Y, entity_id_2: Y, asym_id_1: Y, asym_id_2: Y, comp_id_1: Y, comp_id_2: Y, seq_id_1: be, seq_id_2: be, rep_atom_1: ht(Y), rep_atom_2: ht(Y), distance_lower_limit: qt, distance_upper_limit: qt, probability: qt, restraint_type: ht(Y), model_granularity: ht(Y), dataset_list_id: be, software_id: be }, ihm_cross_link_list: { id: be, group_id: be, entity_description_1: Y, entity_description_2: Y, entity_id_1: Y, entity_id_2: Y, comp_id_1: Y, comp_id_2: Y, seq_id_1: be, seq_id_2: be, linker_type: ht(Y), dataset_list_id: be }, ihm_cross_link_restraint: { id: be, group_id: be, entity_id_1: Y, entity_id_2: Y, asym_id_1: Y, asym_id_2: Y, comp_id_1: Y, comp_id_2: Y, seq_id_1: be, seq_id_2: be, atom_id_1: Y, atom_id_2: Y, restraint_type: ht(Y), conditional_crosslink_flag: ht(Y), model_granularity: ht(Y), distance_threshold: qt, psi: qt, sigma_1: qt, sigma_2: qt }, ihm_cross_link_result_parameters: { id: be, restraint_id: be, model_id: be, psi: qt, sigma_1: qt, sigma_2: qt }, ihm_2dem_class_average_restraint: { id: be, dataset_list_id: be, number_raw_micrographs: be, pixel_size_width: qt, pixel_size_height: qt, image_resolution: qt, image_segment_flag: ht(Y), number_of_projections: be, struct_assembly_id: be, details: Y }, ihm_2dem_class_average_fitting: { id: be, restraint_id: be, model_id: be, cross_correlation_coefficient: qt, rot_matrix: ll(3, 3), tr_vector: Vh(3) }, ihm_3dem_restraint: { id: be, dataset_list_id: be, model_id: be, struct_assembly_id: be, fitting_method: Y, number_of_gaussians: be, cross_correlation_coefficient: qt }, ihm_sas_restraint: { id: be, dataset_list_id: be, model_id: be, struct_assembly_id: be, profile_segment_flag: ht(Y), fitting_atom_type: Y, fitting_method: Y, fitting_state: ht(Y), radius_of_gyration: qt, chi_value: qt, details: Y }, ihm_starting_model_coord: { ordinal_id: be, starting_model_id: Y, group_PDB: ht(Y), id: be, type_symbol: Y, entity_id: Y, atom_id: Y, comp_id: Y, seq_id: be, asym_id: Y, Cartn_x: qt, Cartn_y: qt, Cartn_z: qt, B_iso_or_equiv: qt }, ihm_sphere_obj_site: { id: be, entity_id: Y, seq_id_begin: be, seq_id_end: be, asym_id: Y, Cartn_x: qt, Cartn_y: qt, Cartn_z: qt, object_radius: qt, rmsf: qt, model_id: be }, ihm_gaussian_obj_site: { id: be, entity_id: Y, seq_id_begin: be, seq_id_end: be, asym_id: Y, mean_Cartn_x: qt, mean_Cartn_y: qt, mean_Cartn_z: qt, weight: qt, covariance_matrix: ll(3, 3), model_id: be }, ihm_gaussian_obj_ensemble: { id: be, entity_id: Y, seq_id_begin: be, seq_id_end: be, asym_id: Y, mean_Cartn_x: qt, mean_Cartn_y: qt, mean_Cartn_z: qt, weight: qt, covariance_matrix: ll(3, 3), ensemble_id: be }, ihm_feature_list: { feature_id: be, feature_type: ht(Y), entity_type: ht(Y) }, ihm_poly_residue_feature: { ordinal_id: be, feature_id: be, entity_id: Y, asym_id: Y, comp_id_begin: Y, comp_id_end: Y, seq_id_begin: be, seq_id_end: be }, ihm_derived_distance_restraint: { id: be, group_id: be, feature_id_1: be, feature_id_2: be, group_conditionality: ht(Y), random_exclusion_fraction: qt, distance_upper_limit: qt, restraint_type: ht(Y), dataset_list_id: be }, ma_model_list: { ordinal_id: be, model_id: be, model_group_id: be, model_name: Y, model_group_name: Y, model_type: ht(Y), data_id: be }, ma_target_entity: { entity_id: Y, data_id: be, origin: ht(Y) }, ma_target_entity_instance: { asym_id: Y, entity_id: Y, details: Y }, ma_target_ref_db_details: { target_entity_id: Y, db_name: ht(Y), db_code: Y, db_accession: Y, seq_db_isoform: Y, seq_db_align_begin: Y, seq_db_align_end: Y, ncbi_taxonomy_id: Y, organism_scientific: Y }, ma_data: { id: be, content_type: ht(Y), content_type_other_details: Y, name: Y }, ma_software_group: { ordinal_id: be, group_id: be, software_id: be }, ma_qa_metric: { id: be, name: Y, type: ht(Y), mode: ht(Y), software_group_id: be }, ma_qa_metric_global: { ordinal_id: be, model_id: be, metric_id: be, metric_value: qt }, ma_qa_metric_local: { ordinal_id: be, model_id: be, label_asym_id: Y, label_seq_id: be, label_comp_id: Y, metric_id: be, metric_value: qt } }, zK = new Uint16Array(new Uint8Array([18, 52]).buffer)[0] === 13330;
function D2(e) {
  for (var t = e.data, r = e.encoding.length - 1; r >= 0; r--) t = GK(t, e.encoding[r]);
  return t;
}
function GK(e, t) {
  switch (t.kind) {
    case "ByteArray":
      switch (t.type) {
        case 4:
          return e;
        case 1:
          return function(r) {
            return new Int8Array(r.buffer, r.byteOffset);
          }(e);
        case 2:
          return function(r) {
            return Zf(r, 2, Int16Array);
          }(e);
        case 5:
          return function(r) {
            return Zf(r, 2, Uint16Array);
          }(e);
        case 3:
          return function(r) {
            return Zf(r, 4, Int32Array);
          }(e);
        case 6:
          return function(r) {
            return Zf(r, 4, Uint32Array);
          }(e);
        case 32:
          return function(r) {
            return Zf(r, 4, Float32Array);
          }(e);
        case 33:
          return function(r) {
            return Zf(r, 8, Float64Array);
          }(e);
        default:
          Hi(t.type);
      }
    case "FixedPoint":
      return function(r, n) {
        for (var i = r.length, a = rA(n.srcType, i), o = 1 / n.factor, u = 0; u < i; u++) a[u] = o * r[u];
        return a;
      }(e, t);
    case "IntervalQuantization":
      return function(r, n) {
        for (var i = r.length, a = rA(n.srcType, i), o = (n.max - n.min) / (n.numSteps - 1), u = n.min, s = 0; s < i; s++) a[s] = u + o * r[s];
        return a;
      }(e, t);
    case "RunLength":
      return function(r, n) {
        for (var i = tA(n.srcType, n.srcSize), a = 0, o = 0, u = r.length; o < u; o += 2) for (var s = r[o], c = r[o + 1], l = 0; l < c; ++l) i[a++] = s;
        return i;
      }(e, t);
    case "Delta":
      return function(r, n) {
        var i = r.length, a = tA(n.srcType, i);
        if (!i) return r;
        a[0] = r[0] + (0 | n.origin);
        for (var o = 1; o < i; ++o) a[o] = r[o] + a[o - 1];
        return a;
      }(e, t);
    case "IntegerPacking":
      return function(r, n) {
        return r.length === n.srcSize ? r : n.isUnsigned ? function(i, a) {
          for (var o = a.byteCount === 1 ? 255 : 65535, u = i.length, s = new Int32Array(a.srcSize), c = 0, l = 0; c < u; ) {
            for (var d = 0, f = i[c]; f === o; ) d += f, f = i[++c];
            d += f, s[l] = d, c++, l++;
          }
          return s;
        }(r, n) : function(i, a) {
          for (var o = a.byteCount === 1 ? 127 : 32767, u = -o - 1, s = i.length, c = new Int32Array(a.srcSize), l = 0, d = 0; l < s; ) {
            for (var f = 0, m = i[l]; m === o || m === u; ) f += m, m = i[++l];
            f += m, c[d] = f, l++, d++;
          }
          return c;
        }(r, n);
      }(e, t);
    case "StringArray":
      return function(r, n) {
        var i = D2({ encoding: n.offsetEncoding, data: n.offsets }), a = D2({ encoding: n.dataEncoding, data: r }), o = n.stringData, u = new Array(i.length);
        u[0] = "";
        for (var s = 1, c = i.length; s < c; s++) u[s] = o.substring(i[s - 1], i[s]);
        var l = 0, d = new Array(a.length);
        for (s = 0, c = a.length; s < c; s++) d[l++] = u[a[s] + 1];
        return d;
      }(e, t);
  }
}
function tA(e, t) {
  switch (e) {
    case 1:
      return new Int8Array(t);
    case 2:
      return new Int16Array(t);
    case 3:
      return new Int32Array(t);
    case 4:
      return new Uint8Array(t);
    case 5:
      return new Uint16Array(t);
    case 6:
      return new Uint32Array(t);
    default:
      Hi();
  }
}
function rA(e, t) {
  switch (e) {
    case 32:
      return new Float32Array(t);
    case 33:
      return new Float64Array(t);
    default:
      Hi();
  }
}
function Zf(e, t, r) {
  return new r(zK ? e.buffer : function(n, i) {
    for (var a = new ArrayBuffer(n.length), o = new Uint8Array(a), u = 0, s = n.length; u < s; u += i) for (var c = 0; c < i; c++) o[u + i - c - 1] = n[u + c];
    return a;
  }(e, t));
}
var Il, Cp, hb;
function VK(e, t, r) {
  var n, i = 1;
  for (n = 0; n < t; n++) {
    var a = i * e;
    if (Math.abs(Math.round(a) - a) <= r) return n;
    i *= 10;
  }
  return -1;
}
function nA(e, t) {
  return parseFloat(e.toPrecision(t));
}
function vb(e) {
  return Cp.classify(e);
}
(function(e) {
  e.getDataType = function(t) {
    return t instanceof Int8Array ? 1 : t instanceof Int16Array ? 2 : t instanceof Int32Array ? 3 : t instanceof Uint8Array ? 4 : t instanceof Uint16Array ? 5 : t instanceof Uint32Array ? 6 : t instanceof Float32Array ? 32 : t instanceof Float64Array ? 33 : 3;
  }, e.isSignedIntegerDataType = function(t) {
    if (t instanceof Int8Array || t instanceof Int16Array || t instanceof Int32Array) return !0;
    for (var r = 0, n = t.length; r < n; r++) if (r < 0) return !1;
    return !0;
  };
})(Il || (Il = {})), function(e) {
  function t(l, d) {
    return l >= 0 ? Math.ceil((l + 1) / d) : Math.ceil((l + 1) / (-d - 1));
  }
  function r(l, d, f) {
    var m = l.limit8, v = l.limit16;
    d.pack8 += t(f, m), d.pack16 += t(f, v), d.count += 1;
  }
  function n(l, d) {
    l.pack8 += t(d, 127), l.pack16 += t(d, 32767), l.count += 1;
  }
  function i(l) {
    return 4 * l.count < 2 * l.pack16 ? { length: 4 * l.count, elem: 4 } : 2 * l.pack16 < l.pack8 ? { length: 2 * l.pack16, elem: 2 } : { length: l.pack8, elem: 1 };
  }
  function a(l, d) {
    for (var f = { pack8: 0, pack16: 0, count: 0 }, m = 0, v = l.length; m < v; m++) r(d, f, l[m]);
    return R(R({}, i(f)), { kind: "pack" });
  }
  function o(l, d) {
    for (var f = { pack8: 0, pack16: 0, count: 0 }, m = l[0], v = 1, p = l.length; v < p; v++) n(f, l[v] - m), m = l[v];
    return R(R({}, i(f)), { kind: "delta" });
  }
  function u(l, d) {
    for (var f = { pack8: 0, pack16: 0, count: 0 }, m = 1, v = 1, p = l.length; v < p; v++) l[v - 1] !== l[v] ? (r(d, f, l[v - 1]), r(d, f, m), m = 1) : m++;
    return r(d, f, l[l.length - 1]), r(d, f, m), R(R({}, i(f)), { kind: "rle" });
  }
  function s(l, d) {
    for (var f = { pack8: 0, pack16: 0, count: 0 }, m = 1, v = 0, p = 0, g = 1, h = l.length; g < h; g++) {
      var y = l[g] - v;
      p !== y ? (n(f, p), n(f, m), m = 1) : m++, p = y, v = l[g];
    }
    return n(f, p), n(f, m), R(R({}, i(f)), { kind: "delta-rle" });
  }
  function c(l) {
    var d = function(m) {
      for (var v = !1, p = 0, g = m.length; p < g; p++) if (m[p] < 0) {
        v = !0;
        break;
      }
      return v ? { signed: v, limit8: 127, limit16: 32767 } : { signed: v, limit8: 255, limit16: 65535 };
    }(l), f = [a(l, d), u(l, d), o(l), s(l)];
    return f.sort(function(m, v) {
      return m.length - v.length;
    }), f;
  }
  e.getSize = c, e.classify = function(l) {
    if (l.length < 2) return sr.by(sr.byteArray);
    switch (c(l)[0].kind) {
      case "pack":
        return sr.by(sr.integerPacking);
      case "rle":
        return sr.by(sr.runLength).and(sr.integerPacking);
      case "delta":
        return sr.by(sr.delta).and(sr.integerPacking);
      case "delta-rle":
        return sr.by(sr.delta).and(sr.runLength).and(sr.integerPacking);
      default:
        Hi();
    }
  };
}(Cp || (Cp = {})), function(e) {
  e.classify = function(t) {
    var r = function(d, f, m) {
      for (var v = 1, p = 0, g = 0, h = d.length; g < h; g++) {
        if (v >= 0) {
          var y = VK(d[g], f, m);
          y < 0 ? v = -1 : y > v && (v = y);
        }
        var x = Math.abs(d[g]);
        if (x > m) {
          var A = Math.floor(Math.log10(Math.abs(x))) + 1;
          A > p && (p = A);
        }
      }
      return { mantissaDigits: v, integerDigits: p };
    }(t, 4, 1e-6), n = r.mantissaDigits, i = r.integerDigits;
    if (n < 0 || n + i > 10) return sr.by(sr.byteArray);
    if (n === 0) return Cp.classify(t);
    for (var a = function(d) {
      for (var f = 1, m = 0; m < d; m++) f *= 10;
      return f;
    }(n), o = new Int32Array(t.length), u = 0, s = t.length; u < s; u++) o[u] = Math.round(a * t[u]);
    var c = Cp.getSize(o)[0], l = sr.by(sr.fixedPoint(a));
    switch (c.kind) {
      case "pack":
        return l.and(sr.integerPacking);
      case "rle":
        return l.and(sr.runLength).and(sr.integerPacking);
      case "delta":
        return l.and(sr.delta).and(sr.integerPacking);
      case "delta-rle":
        return l.and(sr.delta).and(sr.runLength).and(sr.integerPacking);
      default:
        Hi();
    }
  };
}(hb || (hb = {}));
var Vl, sr, gb, Uo, yb, iA = function() {
  function e(t) {
    this.providers = t;
  }
  return e.prototype.and = function(t) {
    return new e(this.providers.concat([t]));
  }, e.prototype.encode = function(t) {
    for (var r = [], n = 0, i = this.providers; n < i.length; n++) {
      var a = (0, i[n])(t);
      if (!a.encodings.length) throw new Error("Encodings must be non-empty.");
      t = a.data;
      for (var o = 0, u = a.encodings; o < u.length; o++) {
        var s = u[o];
        r.push(s);
      }
    }
    if (!(t instanceof Uint8Array)) throw new Error("The encoding must result in a Uint8Array. Fix your encoding chain.");
    return { encoding: r, data: t };
  }, e;
}();
function Uy(e) {
  return function(t, r) {
    return r[e].value(t);
  };
}
function UK(e) {
  return function(t, r) {
    return r[e].value(t).join(r[e].schema.separator);
  };
}
function Hy(e) {
  for (var t = [], r = 1; r < arguments.length; r++) t[r - 1] = arguments[r];
  return function(n, i) {
    var a;
    return (a = i[e].schema.space).get.apply(a, We([i[e].value(n)], t, !1));
  };
}
function wp(e) {
  return function(t, r) {
    return r[e].valueKind(t);
  };
}
function HK(e, t) {
  var r = [], n = wp(e);
  if (t.rank === 1) for (var i = t.dimensions[0], a = 0; a < i; a++) {
    var o = "".concat(e, "[").concat(a + 1, "]");
    r.push({ name: o, type: 2, value: Hy(e, a), valueKind: n });
  }
  else if (t.rank === 2) {
    i = t.dimensions[0];
    var u = t.dimensions[1];
    for (a = 0; a < i; a++) for (var s = 0; s < u; s++) {
      var c = "".concat(e, "[").concat(a + 1, "][").concat(s + 1, "]");
      r.push({ name: c, type: 2, value: Hy(e, a, s), valueKind: n });
    }
  } else {
    if (t.rank !== 3) throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.");
    var l = t.dimensions[0], d = t.dimensions[1], f = t.dimensions[2];
    for (a = 0; a < l; a++) for (s = 0; s < d; s++) for (var m = 0; m < f; m++) {
      var v = "".concat(e, "[").concat(a + 1, "][").concat(s + 1, "][").concat(m + 1, "]");
      r.push({ name: v, type: 2, value: Hy(e, a, s, m), valueKind: n });
    }
  }
  return r;
}
function aA(e) {
  for (var t = [], r = 0, n = Object.keys(e); r < n.length; r++) {
    var i = n[r], a = e[i];
    a.valueType === "int" ? t.push({ name: i, type: 1, value: Uy(i), valueKind: wp(i) }) : a.valueType === "float" ? t.push({ name: i, type: 2, value: Uy(i), valueKind: wp(i) }) : a.valueType === "str" ? t.push({ name: i, type: 0, value: Uy(i), valueKind: wp(i) }) : a.valueType === "list" ? t.push({ name: i, type: 0, value: UK(i), valueKind: wp(i) }) : a.valueType === "tensor" ? t.push.apply(t, HK(i, a.space)) : Hi(a.valueType);
  }
  return t;
}
function bb(e) {
  return e.fields.some(function(t) {
    return !!t.shouldInclude;
  }) ? e.fields.filter(function(t) {
    return !t.shouldInclude || e.source.some(function(r) {
      return t.shouldInclude(r.data);
    });
  }) : e.fields;
}
function JM(e, t) {
  var r = e.instance(t), n = r.source.filter(function(o) {
    return o.rowCount > 0;
  });
  if (!n.length) return { instance: r, rowCount: 0, source: [] };
  var i = n.reduce(function(o, u) {
    return o + u.rowCount;
  }, 0), a = n.map(function(o) {
    return { data: o.data, keys: function() {
      return o.keys ? o.keys() : g2.Range(0, o.rowCount - 1);
    }, rowCount: o.rowCount };
  });
  return { instance: r, rowCount: i, source: a };
}
(function(e) {
  function t(n) {
    return new iA([n]);
  }
  function r(n) {
    switch (n.kind) {
      case "ByteArray":
        return sr.byteArray;
      case "FixedPoint":
        return sr.fixedPoint(n.factor);
      case "IntervalQuantization":
        return sr.intervalQuantizaiton(n.min, n.max, n.numSteps);
      case "RunLength":
        return sr.runLength;
      case "Delta":
        return sr.delta;
      case "IntegerPacking":
        return sr.integerPacking;
      case "StringArray":
        return sr.stringArray;
    }
  }
  e.by = t, e.fromEncoding = function(n) {
    for (var i = t(r(n[0])), a = 1; a < n.length; a++) i = i.and(r(n[a]));
    return i;
  };
})(Vl || (Vl = {})), function(e) {
  var t, r;
  e.by = function(u) {
    return new iA([u]);
  };
  var n = ((t = {})[2] = function(u, s, c) {
    u.setInt16(2 * s, c, !0);
  }, t[5] = function(u, s, c) {
    u.setUint16(2 * s, c, !0);
  }, t[3] = function(u, s, c) {
    u.setInt32(4 * s, c, !0);
  }, t[6] = function(u, s, c) {
    u.setUint32(4 * s, c, !0);
  }, t[32] = function(u, s, c) {
    u.setFloat32(4 * s, c, !0);
  }, t[33] = function(u, s, c) {
    u.setFloat64(8 * s, c, !0);
  }, t), i = ((r = {})[2] = 2, r[5] = 2, r[3] = 4, r[6] = 4, r[32] = 4, r[33] = 8, r);
  function a(u) {
    var s = Il.getDataType(u);
    if (s === 1) return function(v) {
      return { encodings: [{ kind: "ByteArray", type: 1 }], data: new Uint8Array(v.buffer, v.byteOffset) };
    }(u);
    if (s === 4) return /* @__PURE__ */ function(v) {
      return { encodings: [{ kind: "ByteArray", type: 4 }], data: v };
    }(u);
    for (var c = new Uint8Array(u.length * i[s]), l = n[s], d = new DataView(c.buffer), f = 0, m = u.length; f < m; f++) l(d, f, u[f]);
    return { encodings: [{ kind: "ByteArray", type: s }], data: c };
  }
  function o(u, s) {
    for (var c = -s - 1, l = 0, d = 0, f = u.length; d < f; d++) {
      var m = u[d];
      m === 0 ? l += 1 : m > 0 ? (l += Math.ceil(m / s), m % s == 0 && (l += 1)) : (l += Math.ceil(m / c), m % c == 0 && (l += 1));
    }
    return l;
  }
  e.byteArray = a, e.fixedPoint = function(u) {
    return function(s) {
      return function(c, l) {
        for (var d = Il.getDataType(c), f = new Int32Array(c.length), m = 0, v = c.length; m < v; m++) f[m] = Math.round(c[m] * l);
        return { encodings: [{ kind: "FixedPoint", factor: l, srcType: d }], data: f };
      }(s, u);
    };
  }, e.intervalQuantizaiton = function(u, s, c, l) {
    return l === void 0 && (l = Int32Array), function(d) {
      return function(f, m, v, p, g) {
        var h = Il.getDataType(f);
        if (!f.length) return { encodings: [{ kind: "IntervalQuantization", min: m, max: v, numSteps: p, srcType: h }], data: new Int32Array(0) };
        if (v < m) {
          var y = m;
          m = v, v = y;
        }
        for (var x = (v - m) / (p - 1), A = new g(f.length), b = 0, _ = f.length; b < _; b++) {
          var S = f[b];
          A[b] = S <= m ? 0 : S >= v ? p - 1 : 0 | Math.round((S - m) / x);
        }
        return { encodings: [{ kind: "IntervalQuantization", min: m, max: v, numSteps: p, srcType: h }], data: A };
      }(d, u, s, c, l);
    };
  }, e.runLength = function(u) {
    var s = Il.getDataType(u);
    if (s === void 0 && (u = new Int32Array(u), s = 3), !u.length) return { encodings: [{ kind: "RunLength", srcType: s, srcSize: 0 }], data: new Int32Array(0) };
    for (var c = 2, l = 1, d = u.length; l < d; l++) u[l - 1] !== u[l] && (c += 2);
    var f = new Int32Array(c), m = 0, v = 1;
    for (l = 1, d = u.length; l < d; l++) u[l - 1] !== u[l] ? (f[m] = u[l - 1], f[m + 1] = v, v = 1, m += 2) : ++v;
    return f[m] = u[u.length - 1], f[m + 1] = v, { encodings: [{ kind: "RunLength", srcType: s, srcSize: u.length }], data: f };
  }, e.delta = function(u) {
    if (!Il.isSignedIntegerDataType(u)) throw new Error("Only signed integer types can be encoded using delta encoding.");
    var s = Il.getDataType(u);
    if (s === void 0 && (u = new Int32Array(u), s = 3), !u.length) return { encodings: [{ kind: "Delta", origin: 0, srcType: s }], data: new u.constructor(0) };
    var c = new u.constructor(u.length), l = u[0];
    c[0] = u[0];
    for (var d = 1, f = u.length; d < f; d++) c[d] = u[d] - u[d - 1];
    return c[0] = 0, { encodings: [{ kind: "Delta", origin: l, srcType: s }], data: c };
  }, e.integerPacking = function(u) {
    var s = function(c) {
      var l = function(m) {
        for (var v = 0, p = m.length; v < p; v++) if (m[v] < 0) return !0;
        return !1;
      }(c), d = o(c, l ? 127 : 255), f = o(c, l ? 32767 : 65535);
      return 4 * c.length < 2 * f ? { isSigned: l, size: c.length, bytesPerElement: 4 } : 2 * f < d ? { isSigned: l, size: f, bytesPerElement: 2 } : { isSigned: l, size: d, bytesPerElement: 1 };
    }(u);
    return s.bytesPerElement === 4 ? a(u) : function(c, l) {
      for (var d = l.isSigned ? l.bytesPerElement === 1 ? 127 : 32767 : l.bytesPerElement === 1 ? 255 : 65535, f = -d - 1, m = c.length, v = l.isSigned ? l.bytesPerElement === 1 ? new Int8Array(l.size) : new Int16Array(l.size) : l.bytesPerElement === 1 ? new Uint8Array(l.size) : new Uint16Array(l.size), p = 0, g = 0; g < m; g++) {
        var h = c[g];
        if (h >= 0) for (; h >= d; ) v[p] = d, ++p, h -= d;
        else for (; h <= f; ) v[p] = f, ++p, h -= f;
        v[p] = h, ++p;
      }
      var y = a(v);
      return { encodings: [{ kind: "IntegerPacking", byteCount: l.bytesPerElement, isUnsigned: !l.isSigned, srcSize: m }, y.encodings[0]], data: y.data };
    }(u, s);
  }, e.stringArray = function(u) {
    var s = /* @__PURE__ */ Object.create(null), c = [], l = new Int32Array(u.length), d = Oe.create(Int32Array, 1, Math.min(1024, u.length < 32 ? u.length + 1 : Math.round(u.length / 8) + 1));
    Oe.add(d, 0);
    for (var f = 0, m = 0, v = 0, p = u; v < p.length; v++) {
      var g = p[v];
      if (g != null) {
        var h = s[g];
        h === void 0 && (f += g.length, c[h = c.length] = g, s[g] = h, Oe.add(d, f)), l[m++] = h;
      } else l[m++] = -1;
    }
    var y = Oe.compact(d), x = vb(y).encode(y), A = vb(l).encode(l);
    return { encodings: [{ kind: "StringArray", dataEncoding: A.encoding, stringData: c.join(""), offsetEncoding: x.encoding, offsets: x.data }], data: A.data };
  };
}(sr || (sr = {})), function(e) {
  function t(n, i, a) {
    return { name: n, type: 1, value: i, valueKind: a && a.valueKind, defaultFormat: a ? { encoder: a.encoder, typedArray: a.typedArray } : void 0, shouldInclude: a && a.shouldInclude };
  }
  e.str = function(n, i, a) {
    return { name: n, type: 0, value: i, valueKind: a && a.valueKind, defaultFormat: a && a.encoder ? { encoder: a.encoder } : void 0, shouldInclude: a && a.shouldInclude };
  }, e.int = t, e.float = function(n, i, a) {
    return { name: n, type: 2, value: i, valueKind: a && a.valueKind, defaultFormat: a ? { encoder: a.encoder, typedArray: a.typedArray, digitCount: a.digitCount !== void 0 ? a.digitCount : void 0 } : void 0, shouldInclude: a && a.shouldInclude };
  }, e.index = function(n) {
    return t(n, function(i, a, o) {
      return o + 1;
    }, { typedArray: Int32Array, encoder: sr.by(sr.delta).and(sr.runLength).and(sr.integerPacking) });
  };
  var r = function() {
    function n() {
      this.fields = [];
    }
    return n.prototype.index = function(i) {
      return this.fields.push(e.index(i)), this;
    }, n.prototype.str = function(i, a, o) {
      return this.fields.push(e.str(i, a, o)), this;
    }, n.prototype.int = function(i, a, o) {
      return this.fields.push(e.int(i, a, o)), this;
    }, n.prototype.vec = function(i, a, o) {
      for (var u = 0; u < a.length; u++) this.fields.push(e.int("".concat(i, "[").concat(u + 1, "]"), a[u], o));
      return this;
    }, n.prototype.float = function(i, a, o) {
      return this.fields.push(e.float(i, a, o)), this;
    }, n.prototype.many = function(i) {
      for (var a = 0; a < i.length; a++) this.fields.push(i[a]);
      return this;
    }, n.prototype.add = function(i) {
      return this.fields.push(i), this;
    }, n.prototype.getFields = function() {
      return this.fields;
    }, n;
  }();
  e.Builder = r, e.build = function() {
    return new r();
  };
}(gb || (gb = {})), function(e) {
  e.Empty = { fields: [], source: [] }, e.filterOf = function(t) {
    for (var r = [], n = [], i = [], a = [], o = 0, u = t.split(/[\r\n]+/); o < u.length; o++) {
      var s = u[o];
      if ((s = s.trim()).length !== 0) {
        var c = /^!/.test(s);
        c && (s = s.substr(1));
        var l = s.split(/\./), d = l[1], f = c ? d ? a : n : d ? i : r;
        f[f.length] = s, d && !r.includes(l[0]) && (r[r.length] = l[0]);
      }
    }
    var m = i.map(function(v) {
      return v.split(".")[0];
    });
    return { includeCategory: function(v) {
      return !n.includes(v) && (r.length <= 0 || r.indexOf(v) !== -1);
    }, includeField: function(v, p) {
      var g = v + "." + p;
      return !a.includes(g) && (!m.includes(v) || i.includes(g));
    } };
  }, e.DefaultFilter = { includeCategory: function(t) {
    return !0;
  }, includeField: function(t, r) {
    return !0;
  } }, e.DefaultFormatter = { getFormat: function(t, r) {
  } }, e.ofTable = function(t, r) {
    return r ? { fields: aA(t._schema), source: [{ data: t, rowCount: r.length, keys: function() {
      return g2.Array(r);
    } }] } : { fields: aA(t._schema), source: [{ data: t, rowCount: t._rowCount }] };
  };
}(Uo || (Uo = {})), function(e) {
  function t(r, n, i) {
    r.startDataBlock(n);
    for (var a = function(s) {
      r.writeCategory({ name: s, instance: function() {
        return Uo.ofTable(i[s]);
      } });
    }, o = 0, u = i._tableNames; o < u.length; o++)
      a(u[o]);
  }
  e.writeDatabase = t, e.writeDatabaseCollection = function(r, n) {
    for (var i = 0, a = Object.keys(n); i < a.length; i++) {
      var o = a[i];
      t(r, o, n[o]);
    }
  };
}(yb || (yb = {}));
var qK = function() {
  function e() {
    this.builder = Cr.create(), this.encoded = !1, this.dataBlockCreated = !1, this.filter = Uo.DefaultFilter, this.formatter = Uo.DefaultFormatter, this.isBinary = !1, this.binaryEncodingProvider = void 0;
  }
  return e.prototype.setFilter = function(t) {
    this.filter = t || Uo.DefaultFilter;
  }, e.prototype.isCategoryIncluded = function(t) {
    return this.filter.includeCategory(t);
  }, e.prototype.setFormatter = function(t) {
    this.formatter = t || Uo.DefaultFormatter;
  }, e.prototype.startDataBlock = function(t) {
    this.dataBlockCreated = !0, Cr.write(this.builder, "data_".concat((t || "").replace(/[ \n\t]/g, "").toUpperCase(), `
#
`));
  }, e.prototype.writeCategory = function(t, r, n) {
    if (this.encoded) throw new Error("The writer contents have already been encoded, no more writing.");
    if (!this.dataBlockCreated) throw new Error("No data block created.");
    if (n != null && n.ignoreFilter || this.filter.includeCategory(t.name)) {
      var i = JM(t, r), a = i.instance, o = i.rowCount, u = i.source;
      o && (o === 1 ? function(s, c, l, d, f, m) {
        var v = bb(c), p = l[0], g = p.data, h = v.reduce(function(_, S) {
          return f.includeField(s.name, S.name) ? Math.max(_, S.name.length) : 0;
        }, 0);
        if (h !== 0) {
          h += s.name.length + 6;
          for (var y = p.keys().move(), x = uA(s.name, c.fields, m), A = 0; A < v.length; A++) {
            var b = v[A];
            f.includeField(s.name, b.name) && (Cr.writePadRight(d, "_".concat(s.name, ".").concat(b.name), h), oA(d, g, y, b, x[A], 0) || Cr.newline(d));
          }
          Cr.write(d, `#
`);
        }
      }(t, a, u, this.builder, this.filter, this.formatter) : function(s, c, l, d, f, m) {
        var v = bb(c), p = f === Uo.DefaultFilter ? v : v.filter(function(F) {
          return f.includeField(s.name, F.name);
        }), g = p.length;
        if (g !== 0) {
          var h = uA(s.name, p, m);
          sA(d, "loop_");
          for (var y = 0; y < g; y++) sA(d, "_".concat(s.name, ".").concat(p[y].name));
          for (var x = 0, A = 0; A < l.length; A++) {
            var b = l[A], _ = b.data;
            if (b.rowCount !== 0) for (var S = b.keys(); S.hasNext; ) {
              for (var D = S.move(), I = !1, M = 0; M < g; M++) I = oA(d, _, D, p[M], h[M], x);
              I || Cr.newline(d), x++;
            }
          }
          Cr.write(d, `#
`);
        }
      }(t, a, u, this.builder, this.filter, this.formatter));
    }
  }, e.prototype.encode = function() {
    this.encoded = !0;
  }, e.prototype.writeTo = function(t) {
    for (var r = Cr.getChunks(this.builder), n = 0, i = r.length; n < i; n++) t.writeString(r[n]);
  }, e.prototype.getSize = function() {
    return Cr.getSize(this.builder);
  }, e.prototype.getData = function() {
    return Cr.getString(this.builder);
  }, e;
}();
function oA(e, t, r, n, i, a) {
  var o, u = n.valueKind, s = u ? u(r, t) : 0;
  if (s !== 0) s === 1 ? function(d) {
    Cr.writeSafe(d, ". ");
  }(e) : function(d) {
    Cr.writeSafe(d, "? ");
  }(e);
  else {
    var c = n.value(r, t, a), l = n.type;
    if (l === 0) return typeof (o = c) == "string" && o.indexOf(`
`) >= 0 ? (Uh(e, c), !0) : function(d, f) {
      if (!f) return Cr.writeSafe(d, ". "), !1;
      for (var m = f.charCodeAt(0), v = !1, p = 0, g = !1, h = !1, y = 0, x = f.length - 1; y <= x; y++)
        switch (f.charCodeAt(y)) {
          case 9:
          case 32:
            v = !0;
            break;
          case 10:
            return Uh(d, f), !0;
          case 34:
            if (y && y === x) break;
            if (g) return Uh(d, f), !0;
            h = !0, v = !0, p = 0;
            break;
          case 39:
            if (y && y === x) break;
            if (h) return Uh(d, f), !0;
            g = !0, v = !0, p = 1;
        }
      return v || m !== 35 && m !== 36 && m !== 59 && m !== 91 && m !== 93 && m !== 95 || (v = !0), v ? (Cr.writeSafe(d, p ? '"' : "'"), Cr.writeSafe(d, f), Cr.writeSafe(d, p ? '" ' : "' ")) : (Cr.writeSafe(d, f), Cr.writeSafe(d, " ")), !1;
    }(e, c);
    l === 1 ? function(d, f) {
      Cr.writeInteger(d, f), Cr.whitespace1(d);
    }(e, c) : function(d, f, m) {
      Cr.writeFloat(d, f, m), Cr.whitespace1(d);
    }(e, c, i);
  }
  return !1;
}
function uA(e, t, r) {
  for (var n, i = [], a = 0, o = t; a < o.length; a++) {
    var u = o[a], s = r.getFormat(e, u.name);
    s && s.digitCount !== void 0 ? i[i.length] = u.type === 2 ? Math.pow(10, Math.max(0, Math.min(s.digitCount, 15))) : 0 : i[i.length] = u.type === 2 ? Math.pow(10, (n = u).defaultFormat && n.defaultFormat.digitCount !== void 0 ? Math.max(0, Math.min(n.defaultFormat.digitCount, 16)) : 6) : 0;
  }
  return i;
}
function sA(e, t) {
  Cr.write(e, t), Cr.newline(e);
}
function Uh(e, t) {
  Cr.writeSafe(e, `
;` + t), Cr.writeSafe(e, `
;
`);
}
function KK(e) {
  var t = new ArrayBuffer(Jv(e)), r = new DataView(t), n = new Uint8Array(t);
  return $v(e, r, n, 0), n;
}
function Jv(e) {
  var t = typeof e;
  if (t === "string") {
    var r = fM(e);
    if (r < 32) return 1 + r;
    if (r < 256) return 2 + r;
    if (r < 65536) return 3 + r;
    if (r < 4294967296) return 5 + r;
  }
  if (e instanceof Uint8Array) {
    var n = e.byteLength;
    if (n < 256) return 2 + n;
    if (n < 65536) return 3 + n;
    if (n < 4294967296) return 5 + n;
  }
  if (t === "number") {
    if (Math.floor(e) !== e) return 9;
    if (e >= 0) {
      if (e < 128) return 1;
      if (e < 256) return 2;
      if (e < 65536) return 3;
      if (e < 4294967296) return 5;
      throw new Error("Number too big 0x" + e.toString(16));
    }
    if (e >= -32) return 1;
    if (e >= -128) return 2;
    if (e >= -32768) return 3;
    if (e >= -2147483648) return 5;
    throw new Error("Number too small -0x" + e.toString(16).substr(1));
  }
  if (t === "boolean" || e == null) return 1;
  if (t === "object") {
    var i, a = 0;
    if (Array.isArray(e)) {
      i = e.length;
      for (var o = 0; o < i; o++) a += Jv(e[o]);
    } else {
      var u = Object.keys(e);
      for (i = u.length, o = 0; o < i; o++) {
        var s = u[o];
        a += Jv(s) + Jv(e[s]);
      }
    }
    if (i < 16) return 1 + a;
    if (i < 65536) return 3 + a;
    if (i < 4294967296) return 5 + a;
    throw new Error("Array or object too long 0x" + i.toString(16));
  }
  throw new Error("Unknown type " + t);
}
function $v(e, t, r, n) {
  var i = typeof e;
  if (i === "string") {
    var a = fM(e);
    if (a < 32) return t.setUint8(n, 160 | a), Oh(r, n + 1, e), 1 + a;
    if (a < 256) return t.setUint8(n, 217), t.setUint8(n + 1, a), Oh(r, n + 2, e), 2 + a;
    if (a < 65536) return t.setUint8(n, 218), t.setUint16(n + 1, a), Oh(r, n + 3, e), 3 + a;
    if (a < 4294967296) return t.setUint8(n, 219), t.setUint32(n + 1, a), Oh(r, n + 5, e), 5 + a;
  }
  if (e instanceof Uint8Array) {
    var o = e.byteLength, u = new Uint8Array(t.buffer);
    if (o < 256) return t.setUint8(n, 196), t.setUint8(n + 1, o), u.set(e, n + 2), 2 + o;
    if (o < 65536) return t.setUint8(n, 197), t.setUint16(n + 1, o), u.set(e, n + 3), 3 + o;
    if (o < 4294967296) return t.setUint8(n, 198), t.setUint32(n + 1, o), u.set(e, n + 5), 5 + o;
  }
  if (i === "number") {
    if (!isFinite(e)) throw new Error("Number not finite: " + e);
    if (Math.floor(e) !== e) return t.setUint8(n, 203), t.setFloat64(n + 1, e), 9;
    if (e >= 0) {
      if (e < 128) return t.setUint8(n, e), 1;
      if (e < 256) return t.setUint8(n, 204), t.setUint8(n + 1, e), 2;
      if (e < 65536) return t.setUint8(n, 205), t.setUint16(n + 1, e), 3;
      if (e < 4294967296) return t.setUint8(n, 206), t.setUint32(n + 1, e), 5;
      throw new Error("Number too big 0x" + e.toString(16));
    }
    if (e >= -32) return t.setInt8(n, e), 1;
    if (e >= -128) return t.setUint8(n, 208), t.setInt8(n + 1, e), 2;
    if (e >= -32768) return t.setUint8(n, 209), t.setInt16(n + 1, e), 3;
    if (e >= -2147483648) return t.setUint8(n, 210), t.setInt32(n + 1, e), 5;
    throw new Error("Number too small -0x" + (-e).toString(16).substr(1));
  }
  if (e == null) return t.setUint8(n, 192), 1;
  if (i === "boolean") return t.setUint8(n, e ? 195 : 194), 1;
  if (i === "object") {
    var s, c = 0, l = Array.isArray(e), d = void 0;
    if ((s = l ? e.length : (d = Object.keys(e)).length) < 16 ? (t.setUint8(n, s | (l ? 144 : 128)), c = 1) : s < 65536 ? (t.setUint8(n, l ? 220 : 222), t.setUint16(n + 1, s), c = 3) : s < 4294967296 && (t.setUint8(n, l ? 221 : 223), t.setUint32(n + 1, s), c = 5), l) for (var f = 0; f < s; f++) c += $v(e[f], t, r, n + c);
    else {
      f = 0;
      for (var m = d.length; f < m; f++) {
        var v = d[f];
        c += $v(v, t, r, n + c), c += $v(e[v], t, r, n + c);
      }
    }
    return c;
  }
  throw new Error("Unknown type " + i);
}
var ki, rm, Ms, XK = function() {
  function e(t, r, n) {
    this.autoClassify = n, this.dataBlocks = [], this.filter = Uo.DefaultFilter, this.formatter = Uo.DefaultFormatter, this.isBinary = !0, this.binaryEncodingProvider = void 0, this.binaryEncodingProvider = r, this.data = { encoder: t, version: "0.3.0", dataBlocks: this.dataBlocks };
  }
  return e.prototype.setFilter = function(t) {
    this.filter = t || Uo.DefaultFilter;
  }, e.prototype.isCategoryIncluded = function(t) {
    return this.filter.includeCategory(t);
  }, e.prototype.setFormatter = function(t) {
    this.formatter = t || Uo.DefaultFormatter;
  }, e.prototype.startDataBlock = function(t) {
    this.dataBlocks.push({ header: (t || "").replace(/[ \n\t]/g, "").toUpperCase(), categories: [] });
  }, e.prototype.writeCategory = function(t, r, n) {
    if (!this.data) throw new Error("The writer contents have already been encoded, no more writing.");
    if (!this.dataBlocks.length) throw new Error("No data block created.");
    if (n != null && n.ignoreFilter || this.filter.includeCategory(t.name)) {
      var i = JM(t, r), a = i.instance, o = i.rowCount, u = i.source;
      if (o) {
        for (var s = { name: "_" + t.name, columns: [], rowCount: o }, c = 0, l = bb(a); c < l.length; c++) {
          var d = l[c];
          if (this.filter.includeField(t.name, d.name)) {
            var f = this.formatter.getFormat(t.name, d.name);
            s.columns.push(YK(t.name, d, u, o, f, this.binaryEncodingProvider, this.autoClassify));
          }
        }
        s.columns.length && this.dataBlocks[this.dataBlocks.length - 1].categories.push(s);
      }
    }
  }, e.prototype.encode = function() {
    this.encodedData || (this.encodedData = KK(this.data), this.data = null, this.dataBlocks = null);
  }, e.prototype.writeTo = function(t) {
    t.writeBinary(this.encodedData);
  }, e.prototype.getData = function() {
    return this.encode(), this.encodedData;
  }, e.prototype.getSize = function() {
    return this.encodedData.length;
  }, e;
}();
function jK(e, t) {
  return e === 0 ? Vl.by(sr.stringArray) : e === 1 ? vb(t) : (r = t, hb.classify(r));
  var r;
}
function YK(e, t, r, n, i, a, o) {
  var u = function(p, g, h, y) {
    for (var x = p.type === 0, A = new g(h), b = new Uint8Array(h), _ = p.valueKind, S = p.value, D = !0, I = 0, M = 0; M < y.length; M++) for (var F = y[M].data, P = y[M].keys(); P.hasNext; ) {
      var E = P.move(), B = _ ? _(E, F) : 0;
      if (B !== 0) b[I] = B, x && (A[I] = ""), D = !1;
      else {
        var N = S(E, F, I);
        typeof N != "string" || N ? b[I] = 0 : (b[I] = 1, D = !1), A[I] = N;
      }
      I++;
    }
    return { array: A, allPresent: D, mask: b };
  }(t, function(p, g) {
    return g && g.typedArray ? g.typedArray : p.defaultFormat && p.defaultFormat.typedArray ? p.defaultFormat.typedArray : p.type === 0 ? Array : p.type === 1 ? Int32Array : Float64Array;
  }(t, i), n, r), s = u.array, c = u.allPresent, l = u.mask, d = function(p, g, h, y) {
    return h && h.encoder ? h.encoder : g.defaultFormat && g.defaultFormat.encoder ? g.defaultFormat.encoder : y ? y.get(p, g.name) : void 0;
  }(e, t, i, a);
  d || (d = o ? jK(t.type, s) : function(p) {
    return p === 0 ? Vl.by(sr.stringArray) : Vl.by(sr.byteArray);
  }(t.type));
  var f = d.encode(s), m = void 0;
  if (!c) {
    var v = Vl.by(sr.runLength).and(sr.byteArray).encode(l);
    m = v.data.length < l.length ? v : Vl.by(sr.byteArray).encode(l);
  }
  return { name: t.name, data: f, mask: m };
}
function Hh(e, t, r, n, i, a) {
  for (var o = new So.EdgeBuilder(i, e, t), u = new Uint16Array(o.slotCount), s = new Int8Array(o.slotCount), c = 0, l = o.edgeCount; c < l; c++) o.addNextEdge(), o.assignProperty(u, n[c]), o.assignProperty(s, r[c]);
  return o.createGraph({ flags: u, order: s }, { canRemap: a });
}
(function(e) {
  e.Encoder = yb, e.Category = Uo, e.Field = gb, e.Encoding = sr, e.createEncoder = function(n) {
    var i = n || {}, a = i.binary, o = a !== void 0 && a, u = i.encoderName;
    return o ? new XK(u === void 0 ? "mol*" : u, n ? n.binaryEncodingPovider : void 0, !!n && !!n.binaryAutoClassifyEncoding) : new qK();
  }, e.fields = function() {
    return e.Field.build();
  };
  var t = e.Encoding;
  function r(n) {
    var i = n.precision;
    if (i !== void 0) {
      var a = Math.pow(10, i), o = t.by(t.fixedPoint(a));
      switch (n.encoding) {
        case "pack":
          return o.and(t.integerPacking);
        case "rle":
          return o.and(t.runLength).and(t.integerPacking);
        case "delta":
          return o.and(t.delta).and(t.integerPacking);
        case "delta-rle":
          return o.and(t.delta).and(t.runLength).and(t.integerPacking);
      }
    } else switch (n.encoding) {
      case "pack":
        return t.by(t.integerPacking);
      case "rle":
        return t.by(t.runLength).and(t.integerPacking);
      case "delta":
        return t.by(t.delta).and(t.integerPacking);
      case "delta-rle":
        return t.by(t.delta).and(t.runLength).and(t.integerPacking);
    }
    throw new Error("cannot be reached");
  }
  e.Encodings = { deltaRLE: t.by(t.delta).and(t.runLength).and(t.integerPacking), fixedPoint2: t.by(t.fixedPoint(100)).and(t.delta).and(t.integerPacking), fixedPoint3: t.by(t.fixedPoint(1e3)).and(t.delta).and(t.integerPacking) }, e.categoryInstance = function(n, i) {
    return { fields: n, source: [i] };
  }, e.createEncodingProviderFromCifFrame = function(n) {
    return { get: function(i, a) {
      var o = n.categories[i];
      if (o) {
        var u = o.getField(a);
        return u && u.binaryEncoding ? Vl.fromEncoding(u.binaryEncoding) : void 0;
      }
    } };
  }, e.createEncodingProviderFromJsonConfig = function(n) {
    return { get: function(i, a) {
      for (var o = 0; o < n.length; o++) {
        var u = n[o];
        if (u.categoryName === i && u.columnName === a) return r(u);
      }
    } };
  };
})(ki || (ki = {})), function(e) {
  e.Descriptor = { name: "chem_comp_bond", cifExport: { prefix: "", categories: [{ name: "chem_comp_bond", instance: function(r) {
    var n = e.Provider.get(r.firstModel);
    if (!n) return ki.Category.Empty;
    var i = n.data;
    if (!i) return ki.Category.Empty;
    for (var a = r.structures[0].uniqueResidueNames, o = i.comp_id, u = i._rowCount, s = [], c = 0; c < u; c++) a.has(o.value(c)) && (s[s.length] = c);
    return ki.Category.ofTable(i, s);
  } }] } }, e.Provider = Es.create(e.Descriptor), e.chemCompBondFromTable = function(r, n) {
    return Or.pick(n, tr.chem_comp_bond, function(i) {
      return r.properties.chemicalComponentMap.has(n.comp_id.value(i));
    });
  }, e.getEntriesFromChemCompBond = function(r) {
    var n = /* @__PURE__ */ new Map();
    function i(A) {
      if (n.has(A)) return n.get(A);
      var b = new t(A);
      return n.set(A, b), b;
    }
    for (var a = r.comp_id, o = r.atom_id_1, u = r.atom_id_2, s = r.value_order, c = r.pdbx_aromatic_flag, l = r._rowCount, d = i(a.value(0)), f = 0; f < l; f++) {
      var m = a.value(f), v = o.value(f), p = u.value(f), g = s.value(f), h = c.value(f) === "Y";
      d.id !== m && (d = i(m));
      var y = 1, x = 1;
      switch (h && (y |= 16), g.toLowerCase()) {
        case "delo":
          y |= 16;
          break;
        case "doub":
          x = 2;
          break;
        case "trip":
          x = 3;
          break;
        case "quad":
          x = 4;
      }
      d.add(v, p, x, y);
    }
    return n;
  };
  var t = function() {
    function r(n) {
      this.id = n, this.map = /* @__PURE__ */ new Map();
    }
    return r.prototype.add = function(n, i, a, o, u) {
      u === void 0 && (u = !0);
      var s = this.map.get(n);
      if (s !== void 0)
        s.get(i) === void 0 && s.set(i, { order: a, flags: o });
      else {
        var c = /* @__PURE__ */ new Map();
        c.set(i, { order: a, flags: o }), this.map.set(n, c);
      }
      u && this.add(i, n, a, o, !1);
    }, r;
  }();
  e.Entry = t;
}(rm || (rm = {})), function(e) {
  function t(r, n) {
    for (var i = r.units, a = 0, o = i.length; a < o; a++) if (qe.indexOf(i[a].elements, n) >= 0) return !0;
    return !1;
  }
  e.Descriptor = { name: "struct_conn", cifExport: { prefix: "", categories: [{ name: "struct_conn", instance: function(r) {
    var n = e.Provider.get(r.firstModel);
    if (!n || n.entries.length === 0) return ki.Category.Empty;
    for (var i = r.structures[0], a = [], o = 0, u = n.entries; o < u.length; o++) {
      var s = u[o];
      t(i, s.partnerA.atomIndex) && t(i, s.partnerB.atomIndex) && (a[a.length] = s.rowIndex);
    }
    return ki.Category.ofTable(n.data, a);
  } }] } }, e.Provider = Es.create(e.Descriptor), e.isExhaustive = function(r) {
    var n = e.Provider.get(r);
    return !!n && n.data.id.rowCount / r.atomicConformation.atomId.rowCount > 0.95;
  }, e.getAtomIndexFromEntries = function(r) {
    for (var n = /* @__PURE__ */ new Map(), i = 0, a = r; i < a.length; i++) {
      var o = a[i], u = o.partnerA.atomIndex, s = o.partnerB.atomIndex;
      n.has(u) ? n.get(u).push(o) : n.set(u, [o]), n.has(s) ? n.get(s).push(o) : n.set(s, [o]);
    }
    return n;
  }, e.getEntriesFromStructConn = function(r, n) {
    for (var i = r.conn_type_id, a = r.pdbx_dist_value, o = r.pdbx_value_order, u = { label_asym_id: r.ptnr1_label_asym_id, label_seq_id: r.ptnr1_label_seq_id, auth_seq_id: r.ptnr1_auth_seq_id, label_atom_id: r.ptnr1_label_atom_id, label_alt_id: r.pdbx_ptnr1_label_alt_id, ins_code: r.pdbx_ptnr1_PDB_ins_code, symmetry: r.ptnr1_symmetry }, s = { label_asym_id: r.ptnr2_label_asym_id, label_seq_id: r.ptnr2_label_seq_id, auth_seq_id: r.ptnr2_auth_seq_id, label_atom_id: r.ptnr2_label_atom_id, label_alt_id: r.pdbx_ptnr2_label_alt_id, ins_code: r.pdbx_ptnr2_PDB_ins_code, symmetry: r.ptnr2_symmetry }, c = function(h, y) {
      if (y.label_asym_id.valueKind(h) === 0) {
        var x = y.label_asym_id.value(h), A = n.atomicHierarchy.index.findEntity(x);
        if (!(A < 0)) {
          var b = n.atomicHierarchy.index.findResidue(n.entities.data.id.value(A), x, y.auth_seq_id.value(h), y.ins_code.value(h));
          if (!(b < 0)) {
            var _ = y.label_atom_id.value(h);
            if (_) {
              var S = n.atomicHierarchy.index.findAtomOnResidue(b, _, y.label_alt_id.value(h));
              if (!(S < 0)) return { residueIndex: b, atomIndex: S, symmetry: y.symmetry.value(h) };
            }
          }
        }
      }
    }, l = [], d = 0; d < r._rowCount; d++) {
      var f = c(d, u), m = c(d, s);
      if (f !== void 0 && m !== void 0) {
        var v = i.value(d), p = 0, g = 1;
        switch ((o.value(d) || "").toLowerCase()) {
          case "sing":
            g = 1;
            break;
          case "doub":
            g = 2;
            break;
          case "trip":
            g = 3;
            break;
          case "quad":
            g = 4;
            break;
          default:
            g = QM(r.ptnr1_label_comp_id.value(d), r.ptnr1_label_atom_id.value(d), r.ptnr2_label_comp_id.value(d), r.ptnr2_label_atom_id.value(d));
        }
        switch (v) {
          case "covale":
            p = 1;
            break;
          case "disulf":
            p = 9;
            break;
          case "hydrog":
            p = 4;
            break;
          case "metalc":
            p = 2;
        }
        l.push({ rowIndex: d, flags: p, order: g, distance: a.value(d), partnerA: f, partnerB: m });
      }
    }
    return l;
  };
}(Ms || (Ms = {}));
var cA = w(), lA = w();
function WK(e, t, r) {
  return e.conformation.position(t, cA), e.conformation.position(r, lA), w.distance(cA, lA);
}
var ZK = /* @__PURE__ */ new Set();
function QK(e, t) {
  var r = R(R({}, jM), t);
  return r.noCompute || nn.isCoarseGrained(e.model) ? pb.Empty : nn.isMaterial(e.model) && (r.isMaterial = !0, Ei.Provider.get(e.model)) ? function(n) {
    var i = Ei.Provider.get(n.model);
    return i ? Hh(Array.from(i.bonds.a || []), Array.from(i.bonds.b || []), Array.from(i.bonds.edgeProps.order || []), Array.from(i.bonds.edgeProps.flag || []), i.bonds.vertexCount, !1) : Hh([], [], [], [], 0, !1);
  }(e) : !r.forceCompute && Ei.Provider.get(e.model) ? function(n) {
    for (var i = Ei.Provider.get(n.model), a = n.elements, o = n.model.atomicHierarchy.atoms.type_symbol, u = n.elements.length, s = i.bonds, c = s.offset, l = s.b, d = s.edgeProps, f = d.order, m = d.distance, v = d.flag, p = n.model.atomicHierarchy.atomSourceIndex, g = nn.getInvertedAtomSourceIndex(n.model).invertedIndex, h = [], y = [], x = [], A = [], b = 0; b < u; b++) for (var _ = a[b], S = zl(o.value(_)), D = Gl(S), I = p.value(_), M = c[I], F = c[I + 1]; M < F; ++M) {
      var P = g[l[M]];
      if (!(_ >= P)) {
        var E = qe.indexOf(n.elements, P);
        if (!(E < 0)) {
          var B = zl(o.value(P)), N = m[M], O = WK(n, _, P), z = !1;
          n.model.sourceData.kind === "mol" || n.model.sourceData.kind === "sdf" || n.model.sourceData.kind === "mol2" ? z = !0 : N >= 0 ? z = Ln(O, N, 0.3) : S === -1 || B === -1 ? z = !0 : D && Gl(B) && (z = !1), z && (h[h.length] = b, y[y.length] = E, A[A.length] = f[M], x[x.length] = v[M]);
        }
      }
    }
    return Hh(h, y, A, x, u, !1);
  }(e) : function(n, i) {
    for (var a = i.maxRadius, o = i.isMaterial, u = n.model.atomicConformation, s = u.x, c = u.y, l = u.z, d = n.elements.length, f = n.elements, m = n.residueIndex, v = n.chainIndex, p = n.model.atomicHierarchy.atoms, g = p.type_symbol, h = p.label_atom_id, y = p.label_alt_id, x = p.label_comp_id, A = n.model.atomicHierarchy.residues.label_seq_id, b = n.model.atomicHierarchy.index, _ = n.model.sequence.byEntityKey, S = n.lookup3d, D = Ms.Provider.get(n.model), I = rm.Provider.get(n.model), M = Ms.isExhaustive(n.model), F = [], P = [], E = [], B = [], N = -1, O = void 0, z = !0, V = !0, U = !0, H = ZK, K = 0; K < d; K++) {
      var j = f[K], X = g.value(j);
      z && X !== "H" && X !== "O" && (z = !1);
      var W = i.forceCompute ? void 0 : D && D.byAtomIndex.get(j), Q = !1;
      if (W) for (var te = 0, ee = W; te < ee.length; te++) {
        var $ = ee[te], ie = $.partnerA, ae = $.partnerB;
        if (ie.symmetry === ae.symmetry) {
          var se = ie.atomIndex === j ? ae : ie;
          (he = qe.indexOf(n.elements, se.atomIndex)) < 0 || f[he] < j || (F[F.length] = K, P[P.length] = he, E[E.length] = $.flags, B[B.length] = $.order, Q || H.clear(), Q = !0, H.add(he));
        }
      }
      if (!M) {
        var le = m[j], pe = A.value(le), we = x.value(j);
        if (!i.forceCompute && le !== N) if (I && I.entries.has(we)) {
          var Ge = _[b.getEntityFromChain(v[j])];
          O = Ge && Ge.sequence.microHet.has(pe) ? void 0 : I.entries.get(we).map;
        } else O = void 0;
        N = le;
        for (var Ue = zl(X), Ke = h.value(j), Ze = O ? O.get(Ke) : void 0, Fe = S.find(s[j], c[j], l[j], a), Je = Fe.indices, Ne = Fe.count, nt = Fe.squaredDistances, re = Gl(Ue), J = E1(Ue), ce = y.value(j), de = w2.has(Ue), ve = 0; ve < Ne; ve++) {
          var he = Je[ve];
          if (!Q || !H.has(he)) {
            var Se = f[he];
            if (!(Se <= j)) {
              var Re = y.value(Se);
              if (!ce || !Re || ce === Re) {
                var Ve = zl(g.value(Se)), ze = Gl(Ve);
                if (!re || !ze) {
                  var mt = (de || w2.has(Ve)) && !(re || ze), bt = m[Se];
                  if (le === bt && Ze) {
                    var Ct = Ze.get(h.value(Se));
                    if (Ct) {
                      F[F.length] = K, P[P.length] = he, B[B.length] = Ct.order;
                      var De = Ct.flags;
                      mt && (o ? De = 33 : (1 | De && (De ^= 1), De |= 2)), E[E.length] = De;
                    }
                  } else {
                    var ut = Math.sqrt(nt[ve]);
                    if (ut !== 0 && ut <= mb(Ue, Ve, J, E1(Ve), o)) {
                      F[F.length] = K, P[P.length] = he, B[B.length] = LK(we, Ke, h.value(Se)), E[E.length] = 32 | (mt && !o ? 2 : 1);
                      var It = A.value(bt);
                      pe === It && (V = !1), Math.abs(pe - It) > 1 && (U = !1);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    return Hh(F, P, B, E, d, z || V && U);
  }(e, r);
}
var dA = w(), fA = w();
function pA(e, t, r, n) {
  return e.conformation.position(t, dA), r.conformation.position(n, fA), w.distance(dA, fA);
}
var JK = me(), wd = w(), Dt, $K = R(R({}, jM), { ignoreWater: !0, ignoreIon: !0 });
function eX(e, t) {
  var r = new df.Builder(), n = e.models.some(function(i) {
    return Ei.Provider.get(i);
  });
  return t.noCompute || e.isCoarseGrained && !n || tt.eachUnitPair(e, function(i, a) {
    (function(o, u, s, c) {
      var l = s.maxRadius, d = o.elements, f = o.residueIndex, m = o.model.atomicConformation, v = m.x, p = m.y, g = m.z, h = u.elements, y = u.residueIndex, x = o.elements.length, A = o.model.atomicHierarchy.atoms, b = A.type_symbol, _ = A.label_alt_id, S = A.label_atom_id, D = A.label_comp_id, I = u.model.atomicHierarchy.atoms, M = I.type_symbol, F = I.label_alt_id, P = I.label_atom_id, E = I.label_comp_id, B = o.model.atomicHierarchy.residues.auth_seq_id, N = u.model.atomicHierarchy.residues.auth_seq_id, O = o.model.atomicConformation.occupancy, z = u.model.atomicConformation.occupancy, V = O.isDefined && z.isDefined, U = o.model === u.model && Ms.Provider.get(o.model), H = !s.forceCompute && o.model === u.model && Ei.Provider.get(o.model), K = o.model.atomicHierarchy.atomSourceIndex, j = (H ? nn.getInvertedAtomSourceIndex(u.model) : { invertedIndex: void 0 }).invertedIndex, X = o.model === u.model && Ms.isExhaustive(o.model), W = me.mul(JK, u.conformation.operator.inverse, o.conformation.operator.matrix), Q = !me.isIdentity(W), te = u.boundary.sphere, ee = te.center, $ = te.radius, ie = ($ + l) * ($ + l);
      c.startUnitPair(o.id, u.id);
      for (var ae = 0; ae < x; ae++) {
        var se = d[ae];
        if (w.set(wd, v[se], p[se], g[se]), Q && w.transformMat4(wd, wd, W), !(w.squaredDistance(wd, ee) > ie)) if (s.forceCompute || !H) {
          var le = s.forceCompute ? void 0 : U && U.byAtomIndex.get(se);
          if (le && le.length) {
            for (var pe = !1, we = 0, Ge = le; we < Ge.length; we++) {
              var Ue = Ge[we], Ke = Ue.partnerA, Ze = Ue.partnerB, Fe = Ke.atomIndex === se ? Ze : Ke;
              ($r = qe.indexOf(u.elements, Fe.atomIndex)) < 0 || pA(o, se, u, Fe.atomIndex) > l || (c.add(ae, $r, { order: Ue.order, flag: Ue.flags }), pe = !0);
            }
            if (pe) continue;
          }
          if (!X) {
            var Je = O.value(se), Ne = u.lookup3d.find(wd[0], wd[1], wd[2], l), nt = Ne.indices, re = Ne.count, J = Ne.squaredDistances;
            if (re !== 0) for (var ce = zl(b.value(se)), de = Gl(ce), ve = E1(ce), he = _.value(se), Se = w2.has(ce), Re = S.value(se), Ve = D.value(f[se]), ze = 0; ze < re; ze++) {
              en = h[$r = nt[ze]];
              var mt = F.value(en);
              if (!(he && mt && he !== mt || V && z.value(en) < 1 && Je < 1 && B.value(se) === N.value(en))) {
                var bt = Gl(pi = zl(M.value(en)));
                if (!de || !bt) {
                  var Ct = (Se || w2.has(pi)) && !(de || bt);
                  if (!Ct && (wn = Math.sqrt(J[ze])) !== 0 && wn <= mb(ce, pi, ve, E1(pi))) {
                    var De = P.value(en), ut = E.value(y[en]);
                    c.add(ae, $r, { order: QM(Ve, ut, Re, De), flag: 32 | (Ct ? 2 : 1) });
                  }
                }
              }
            }
          }
        } else for (var It = H.maxDistance, ur = H.bonds, nr = ur.offset, Er = ur.b, dr = ur.edgeProps, ln = dr.order, Gn = dr.distance, Rn = dr.flag, Cn = K.value(se), Jr = nr[Cn], ni = nr[Cn + 1]; Jr < ni; ++Jr) {
          var $r, en = j[Er[Jr]];
          if (!(($r = qe.indexOf(u.elements, en)) < 0)) {
            var fi = zl(b.value(se)), pi = zl(b.value(en)), za = Gn[Jr], wn = pA(o, se, u, en), dn = !1;
            za >= 0 ? dn = Ln(wn, za, 0.3) : It >= 0 ? dn = wn < It : (dn = wn < mb(fi, pi, E1(fi), E1(pi)), Gl(fi) && Gl(pi) && (dn = !1)), dn && c.add(ae, $r, { order: ln[Jr], flag: Rn[Jr] });
          }
        }
      }
      c.finishUnitPair();
    })(i, a, t, r);
  }, { maxRadius: t.maxRadius, validUnit: function(i) {
    return Be.isAtomic(i);
  }, validUnitPair: function(i, a) {
    return t.validUnitPair(e, i, a);
  } }), new C2(r.getMap());
}
function tX(e, t) {
  var r = R(R({}, $K), t);
  return eX(e, R(R({}, r), { validUnitPair: t && t.validUnitPair || function(n, i, a) {
    var o = i.model.atomicHierarchy.derived.residue.moleculeType, u = a.model.atomicHierarchy.derived.residue.moleculeType, s = !(Be.isAtomic(i) && o[i.residueIndex[i.elements[0]]] === 2 || Be.isAtomic(a) && u[a.residueIndex[a.elements[0]]] === 2), c = i.model === a.model, l = !Be.isAtomic(i) || o[i.residueIndex[i.elements[0]]] !== 3 || c && mA(i), d = !Be.isAtomic(a) || u[a.residueIndex[a.elements[0]]] !== 3 || c && mA(a), f = l && d;
    return tt.validUnitPair(n, i, a) && (s || !r.ignoreWater) && (f || !r.ignoreIon);
  } }));
}
function mA(e) {
  if (!Be.isAtomic(e)) return !1;
  var t = e.elements, r = Ms.Provider.get(e.model);
  if (r) {
    for (var n = 0, i = t.length; n < i; n++) if (r.byAtomIndex.get(t[n])) return !0;
  }
  return !1;
}
function rX(e) {
  for (var t = function(a) {
    for (var o = Zt.transientSegments(a.model.atomicHierarchy.residueAtomSegments, a.elements), u = 0; o.hasNext; ) {
      var s = o.move();
      u = Math.max(u, s.end - s.start);
    }
    return u;
  }(e), r = function(a, o) {
    return { startVertex: 0, endVertex: 0, count: 0, isRingAtom: new Int32Array(o), marked: new Int32Array(o), queue: new Int32Array(o), pred: new Int32Array(o), depth: new Int32Array(o), left: new Int32Array(5), right: new Int32Array(5), color: new Int32Array(o), currentColor: 0, currentAltLoc: "", hasAltLoc: !1, rings: [], currentRings: [], unit: a, bonds: a.bonds, altLoc: a.model.atomicHierarchy.atoms.label_alt_id };
  }(e, t), n = Zt.transientSegments(e.model.atomicHierarchy.residueAtomSegments, e.elements); n.hasNext; ) {
    var i = n.move();
    nX(r, i.start, i.end);
  }
  return r.rings;
}
function hA(e) {
  e.count = e.endVertex - e.startVertex;
  for (var t = e.isRingAtom, r = e.pred, n = e.color, i = e.depth, a = e.marked, o = 0; o < e.count; o++) t[o] = 0, r[o] = -1, a[o] = -1, n[o] = 0, i[o] = 0;
  e.currentColor = 0, e.currentAltLoc = "", e.hasAltLoc = !1;
}
function vA(e) {
  for (var t = e.depth, r = 0; r < e.count; r++) t[r] = e.count + 1;
}
function gA(e, t) {
  var r = e.bonds.offset, n = e.startVertex + t, i = r[n], a = r[n + 1] - i;
  return !(a <= 1 || e.isRingAtom[t] && a === 2);
}
function nX(e, t, r) {
  if (e.startVertex = t, e.endVertex = r, !(e.endVertex - e.startVertex < 3)) {
    e.currentRings = [];
    for (var n = e.unit.elements, i = [], a = e.startVertex; a < e.endVertex; a++)
      Su(i, s = e.altLoc.value(n[a]));
    Qv(i, "");
    var o = 1;
    if (i.length === 0)
      for (hA(e), a = 0; a < e.count; a++) gA(e, a) && (vA(e), o = yA(e, a, o));
    else for (var u = 0; u < i.length; u++)
      for (hA(e), e.hasAltLoc = !0, e.currentAltLoc = i[u], a = 0; a < e.count; a++) {
        var s;
        gA(e, a) && ((s = e.altLoc.value(n[e.startVertex + a])) && s !== e.currentAltLoc || (vA(e), o = yA(e, a, o)));
      }
    a = 0;
    for (var c = e.currentRings.length; a < c; a++) e.rings.push(e.currentRings[a]);
  }
}
function iX(e, t, r, n) {
  if (r < t) return !1;
  for (var i = e.pred, a = e.color, o = e.left, u = e.right, s = ++e.currentColor, c = t, l = 0; l < 5 && (a[c] = s, !((c = i[c]) < 0)); l++) ;
  var d = 0, f = 0, m = !1, v = 0;
  for (c = r, l = 0; l < 5; l++) {
    if (a[c] === s) {
      v = c, m = !0;
      break;
    }
    if (u[f++] = c, (c = i[c]) < 0) break;
  }
  if (!m) return !1;
  for (c = t, l = 0; l < 5 && (o[d++] = c, v !== c) && !((c = i[c]) < 0); l++) ;
  var p = d + f;
  if (p < 3) return !1;
  var g = new Int32Array(p), h = 0;
  for (l = 0; l < d; l++) g[h++] = e.startVertex + o[l], n[o[l]] = 1;
  for (l = f - 1; l >= 0; l--) g[h++] = e.startVertex + u[l], n[u[l]] = 1;
  es(g);
  for (var y = 0, x = e.currentRings.length; y < x; y++) {
    var A = e.currentRings[y];
    if (g.length === A.length) {
      if (qe.areEqual(g, A)) return !1;
    } else if (g.length > A.length && qe.isSubset(g, A)) return !1;
  }
  return e.currentRings.push(qe.ofSortedArray(g)), !0;
}
function yA(e, t, r) {
  var n = e.bonds, i = e.startVertex, a = e.endVertex, o = e.isRingAtom, u = e.marked, s = e.queue, c = e.pred, l = e.depth, d = e.unit.elements, f = n.b, m = n.edgeProps.flags, v = n.offset;
  u[t] = r, l[t] = 0, s[0] = t;
  for (var p = 0, g = 1; p < g; ) for (var h = s[p++], y = l[h], x = i + h, A = v[x], b = v[x + 1], _ = A; _ < b; _++) {
    var S = f[_];
    if (!(S < i || S >= a) && cr.isCovalent(m[_])) {
      if (e.hasAltLoc) {
        var D = e.altLoc.value(d[S]);
        if (D && e.currentAltLoc !== D) continue;
      }
      var I = S - i;
      if (u[I] !== r) {
        var M = Math.min(l[I], y + 1);
        M > 5 || (l[I] = M, u[I] = r, s[g++] = I, c[I] = h);
      } else if (c[I] !== h && c[h] !== I && iX(e, h, I, o)) return r + 1;
    }
  }
  return r + 1;
}
function bA(e) {
  for (var t = e.length, r = new Int32Array(2 * t), n = 0; n < r.length; n++) r[n] = -1;
  for (var i = "", a = "", o = 0, u = 1; u < r.length; u++) {
    for (n = r[u - o - 1]; n !== -1 && (i = e[u % t]) !== (a = e[(o + n + 1) % t]); ) i < a && (o = u - n - 1), n = r[n];
    n === -1 && (i = e[u % t]) !== (a = e[(o + n + 1) % t]) ? (i < a && (o = u), r[u - o] = -1) : r[u - o] = n + 1;
  }
  return o;
}
function _A(e, t) {
  var r, n = e.length, i = [];
  for (r = 0; r < n - 1; r++) i.push(e[(r + t) % n]), i.push("-");
  return i.push(e[(r + t) % n]), i.join("");
}
function $M(e, t) {
  switch (e.kind) {
    case 0:
      return e.model.atomicHierarchy.derived.residue.moleculeType[e.residueIndex[t]];
    case 1:
    case 2:
      var r = function(i, a) {
        var o = i.coarseElements.entityKey[a], u = i.model.sequence.byEntityKey[o].sequence, s = i.coarseElements.seq_id_begin.value(a);
        return u.compId.value(s - 1);
      }(e, t), n = e.model.properties.chemicalComponentMap.get(r);
      if (n) return Dm(n.type, r);
  }
  return 0;
}
(function(e) {
  function t(a, o, u, s, c, l) {
    return { kind: "bond-location", aStructure: a, aUnit: o, aIndex: u, bStructure: s, bUnit: c, bIndex: l };
  }
  function r(a, o) {
    return a.aStructure.label === o.aStructure.label && a.bStructure.label === o.bStructure.label && a.aIndex === o.aIndex && a.bIndex === o.bIndex && a.aUnit.id === o.aUnit.id && a.bUnit.id === o.bUnit.id;
  }
  function n(a, o) {
    return { kind: "bond-loci", structure: a, bonds: o };
  }
  e.Location = t, e.isLocation = function(a) {
    return !!a && a.kind === "bond-location";
  }, e.areLocationsEqual = r, e.Loci = n, e.isLoci = function(a) {
    return !!a && a.kind === "bond-loci";
  }, e.areLociEqual = function(a, o) {
    if (a.structure !== o.structure || a.bonds.length !== o.bonds.length) return !1;
    for (var u = 0, s = a.bonds.length; u < s; ++u) if (!r(a.bonds[u], o.bonds[u])) return !1;
    return !0;
  }, e.isLociEmpty = function(a) {
    return a.bonds.length === 0;
  }, e.remapLoci = function(a, o) {
    if (o === a.structure) return a;
    var u = [];
    return a.bonds.forEach(function(s) {
      var c = o.unitMap.get(s.aUnit.id);
      if (c) {
        var l = o.unitMap.get(s.bUnit.id);
        if (l) {
          var d = s.aUnit.elements[s.aIndex], f = qe.indexOf(c.elements, d);
          if (f !== -1) {
            var m = s.bUnit.elements[s.bIndex], v = qe.indexOf(l.elements, m);
            v !== -1 && u.push(t(a.structure, c, f, a.structure, l, v));
          }
        }
      }
    }), n(o, u);
  }, e.toStructureElementLoci = function(a) {
    for (var o = [], u = /* @__PURE__ */ new Map(), s = 0, c = a.bonds; s < c.length; s++) {
      var l = c[s], d = l.aIndex, f = l.aUnit, m = l.bIndex, v = l.bUnit;
      f === v ? u.has(f.id) ? u.get(f.id).push(d, m) : u.set(f.id, [d, m]) : (u.has(f.id) ? u.get(f.id).push(d) : u.set(f.id, [d]), u.has(v.id) ? u.get(v.id).push(m) : u.set(v.id, [m]));
    }
    return u.forEach(function(p, g) {
      o.push({ unit: a.structure.unitMap.get(g), indices: qe.deduplicate(qe.ofUnsortedArray(p)) });
    }), Xe(a.structure, o);
  }, e.toFirstStructureElementLoci = function(a) {
    var o = a.bonds[0], u = o.aUnit, s = o.aIndex;
    return Xe(a.structure, [{ unit: u, indices: Le.ofSingleton(s) }]);
  }, e.getType = function(a, o) {
    if (o.aUnit === o.bUnit) {
      var u = o.aUnit.bonds, s = u.getEdgeIndex(o.aIndex, o.bIndex);
      return s < 0 ? cr.create(0) : cr.create(u.edgeProps.flags[s]);
    }
    var c = a.interUnitBonds.getBondFromLocation(o);
    return c ? cr.create(c.props.flag) : cr.create(0);
  }, e.getOrder = function(a, o) {
    if (o.aUnit === o.bUnit) {
      var u = o.aUnit.bonds, s = u.getEdgeIndex(o.aIndex, o.bIndex);
      return s < 0 ? 0 : u.edgeProps.order[s];
    }
    var c = a.interUnitBonds.getBondFromLocation(o);
    return c ? c.props.order : 0;
  }, e.getIntraUnitBondCount = function(a) {
    for (var o = 0, u = 0, s = a.units.length; u < s; ++u) {
      var c = a.units[u];
      Be.isAtomic(c) && (o += c.bonds.edgeCount);
    }
    return o;
  };
  var i = function() {
    function a() {
      this.current = {}, this.hasNext = !1;
    }
    return a.prototype.move = function() {
      return this.advance(), this.current;
    }, a.prototype.setElement = function(o, u, s) {
      this.structure = o, this.unit = u, this.index = s, this.interBondIndices = o.interUnitBonds.getEdgeIndices(s, u.id), this.interBondCount = this.interBondIndices.length, this.interBondIndex = 0, this.intraBondEnd = u.bonds.offset[s + 1], this.intraBondIndex = u.bonds.offset[s], this.hasNext = this.interBondIndex < this.interBondCount || this.intraBondIndex < this.intraBondEnd;
    }, a.prototype.advance = function() {
      if (this.intraBondIndex < this.intraBondEnd) this.current.otherUnit = this.unit, this.current.otherIndex = this.unit.bonds.b[this.intraBondIndex], this.current.type = this.unit.bonds.edgeProps.flags[this.intraBondIndex], this.current.order = this.unit.bonds.edgeProps.order[this.intraBondIndex], this.intraBondIndex += 1;
      else {
        if (!(this.interBondIndex < this.interBondCount)) return void (this.hasNext = !1);
        var o = this.structure.interUnitBonds.edges[this.interBondIndex];
        this.current.otherUnit = this.structure.unitMap.get(o.unitA !== this.unit.id ? o.unitA : o.unitB), this.current.otherIndex = o.indexA !== this.index ? o.indexA : o.indexB, this.current.type = o.props.flag, this.current.order = o.props.order, this.interBondIndex += 1;
      }
      this.hasNext = this.interBondIndex < this.interBondCount || this.intraBondIndex < this.intraBondEnd;
    }, a;
  }();
  e.ElementBondIterator = i, e.getBoundingSphere = function(a, o) {
    return K1.fromPairProvider(a.bonds.length, function(u, s, c) {
      var l = a.bonds[u], d = l.aUnit, f = l.aIndex, m = l.bUnit, v = l.bIndex;
      d.conformation.position(d.elements[f], s), m.conformation.position(m.elements[v], c);
    }, o);
  };
})(Dt || (Dt = {}));
var aX = /* @__PURE__ */ new Set();
function Ul(e, t) {
  var r = _K[e];
  if (r !== void 0) {
    var n = r[t];
    if (n !== void 0) return n;
  }
  return aX;
}
var xA = w.zero();
function eT(e, t) {
  for (var r = e.conformation.position, n = new Float32Array(3 * t.length), i = e.elements, a = 0, o = t.length; a < o; ++a) r(i[t[a]], xA), w.toArray(xA, n, 3 * a);
  return n;
}
var Eu, jr, I2 = function() {
  function e(t, r) {
    this.unit = r, this.all = t;
  }
  return Object.defineProperty(e.prototype, "index", { get: function() {
    return this._index || (this._index = function(t, r) {
      for (var n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = 0, o = t.length; a < o; a++) for (var u = 0, s = (m = t[a]).length; u < s; u++) {
        var c = m[u];
        n.has(c) ? n.get(c).push(a) : n.set(c, [a]);
      }
      for (var l = 0, d = r.length; l < d; l++) for (u = 0, s = (m = t[a = r[l]]).length; u < s; u++) c = m[u], i.has(c) ? i.get(c).push(a) : i.set(c, [a]);
      var f = new So.UniqueEdgeBuilder(t.length);
      for (a = 0, o = t.length; a < o; a++) {
        var m;
        for (u = 0, s = (m = t[a]).length; u < s; u++) {
          c = m[u];
          var v = n.get(c);
          if (v.length !== 1) for (var p = 0, g = v.length; p < g; p++) {
            var h = v[p];
            a >= h || f.addEdge(a, h);
          }
        }
      }
      var y = So.connectedComponents(f.getGraph()), x = y.componentIndex, A = [];
      for (u = 0; u < y.componentCount; u++) A[u] = [];
      for (a = 0, o = t.length; a < o; a++) A[x[a]].push(a);
      return { elementRingIndices: n, elementAromaticRingIndices: i, ringComponentIndex: x, ringComponents: A };
    }(this.all, this.aromaticRings)), this._index;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "byFingerprint", { get: function() {
    return this._byFingerprint || (this._byFingerprint = function(t, r) {
      for (var n = /* @__PURE__ */ new Map(), i = 0, a = 0, o = r.length; a < o; a++) {
        var u = r[a], s = Eu.fingerprint(t, u);
        n.has(s) ? n.get(s).push(i) : n.set(s, [i]), i++;
      }
      return n;
    }(this.unit, this.all)), this._byFingerprint;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "elementRingIndices", { get: function() {
    return this.index.elementRingIndices;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "elementAromaticRingIndices", { get: function() {
    return this.index.elementAromaticRingIndices;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "ringComponentIndex", { get: function() {
    return this.index.ringComponentIndex;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "ringComponents", { get: function() {
    return this.index.ringComponents;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "aromaticRings", { get: function() {
    return this._aromaticRings || (this._aromaticRings = function(t, r) {
      for (var n = [], i = 0, a = r.length; i < a; ++i) Eu.isAromatic(t, r[i]) && n.push(i);
      return n;
    }(this.unit, this.all)), this._aromaticRings;
  }, enumerable: !1, configurable: !0 }), e;
}();
function oX(e, t) {
  for (var r = e.elements, n = e.model.atomicHierarchy.residueAtomSegments.index, i = n[r[t[0]]], a = 1, o = t.length; a < o; a++) if (i !== n[r[t[a]]]) return -1;
  return i;
}
function uX(e, t, r) {
  var n = e.byFingerprint.get(t);
  if (n) for (var i = 0, a = n.length; i < a; i++) {
    var o = n[i], u = oX(e.unit, e.all[o]);
    u >= 0 && (r.has(u) ? r.get(u).push(o) : r.set(u, [o]));
  }
}
function sX(e) {
  for (var t = [], r = e.elements, n = e.model.coarseHierarchy, i = n.spheres, a = n.gaussians, o = Be.isSpheres(e) ? i.polymerRanges : a.polymerRanges, u = jr.transientSegments(o, r); u.hasNext; ) for (var s = u.move(), c = s.start, l = s.end, d = c; d < l; ++d) t.push(r[d]);
  return qe.ofSortedArray(t);
}
function cX(e) {
  for (var t = [], r = e.elements, n = e.model.coarseHierarchy, i = n.spheres, a = n.gaussians, o = Be.isSpheres(e) ? i.gapRanges : a.gapRanges, u = jr.transientSegments(o, r); u.hasNext; ) {
    var s = u.move(), c = s.start, l = s.end;
    t.push(r[c], r[l - 1]);
  }
  return qe.ofSortedArray(t);
}
(function(e) {
  function t(n) {
    return function(i) {
      for (var a = i.length, o = new Array(a), u = 0; u < a; u++) o[u] = i[a - u - 1];
      var s = bA(i), c = bA(o), l = !1;
      for (u = 0; u < a; u++) {
        var d = i[(u + s) % a], f = o[(u + c) % a];
        if (d !== f) {
          l = d < f;
          break;
        }
      }
      return l ? _A(i, s) : _A(o, c);
    }(n);
  }
  e.fingerprint = function(n, i) {
    for (var a = n.elements, o = n.model.atomicHierarchy.atoms.type_symbol, u = [], s = 0, c = i.length; s < c; s++) u[u.length] = o.value(a[i[s]]);
    return t(u);
  }, e.elementFingerprint = t;
  var r = /* @__PURE__ */ new Set(["B", "C", "N", "O", "SI", "P", "S", "GE", "AS", "SN", "SB", "BI"]);
  e.isAromatic = function(n, i) {
    var a = n.elements, o = n.bonds, u = o.b, s = o.offset, c = o.edgeProps.flags, l = n.model.atomicHierarchy.atoms, d = l.type_symbol;
    if (l.label_comp_id.value(n.elements[i[0]]) === "PRO") return !1;
    for (var f = 0, m = !1, v = 0, p = i.length; v < p; ++v) {
      var g = i[v];
      !m && r.has(d.value(a[g])) && (m = !0);
      for (var h = s[g], y = s[g + 1]; h < y; ++h) cr.is(16, c[h]) && qe.has(i, u[h]) && (f += 1);
    }
    if (f === 2 * i.length) return !0;
    if (!m || i.length < 5) return !1;
    var x = Wl.calculateMomentsAxes(eT(n, i));
    return w.magnitude(x.dirC) < 0.05;
  }, e.getAltId = function(n, i) {
    for (var a = n.model.atomicHierarchy.atoms.label_alt_id, o = n.elements, u = 0, s = i.length; u < s; ++u) {
      var c = o[i[u]], l = a.value(c);
      if (l) return l;
    }
    return "";
  };
})(Eu || (Eu = {})), function(e) {
  e.create = function(t) {
    var r = rX(t);
    return new e(r, t);
  }, e.byFingerprintAndResidue = function(t, r) {
    for (var n = /* @__PURE__ */ new Map(), i = 0, a = r.length; i < a; i++)
      uX(t, r[i], n);
    return n;
  };
}(I2 || (I2 = {})), function(e) {
  function t(l) {
    return l[l.length - 1];
  }
  function r(l) {
    return l.length / 2;
  }
  function n(l, d) {
    return l[2 * d];
  }
  function i(l, d) {
    return l[2 * d + 1] + 1;
  }
  function a(l, d) {
    return l[2 * d];
  }
  function o(l, d) {
    return l[2 * d + 1];
  }
  function u(l, d) {
    return s(l, d, 0);
  }
  function s(l, d, f) {
    if (a(l, f) > Le.max(d) || t(l) < Le.min(d)) return -1;
    for (var m = f, v = r(l); m < v; ++m) {
      var p = Ae.ofRange(a(l, m), o(l, m));
      if (Le.areIntersecting(p, d)) return m;
    }
    return -1;
  }
  e.ofSortedRanges = function(l) {
    return qe.ofSortedArray(l);
  }, e.start = function(l) {
    return l[0];
  }, e.end = function(l) {
    return l[l.length - 1] + 1;
  }, e.min = function(l) {
    return l[0];
  }, e.max = t, e.size = function(l) {
    for (var d = 0, f = 0, m = l.length; f < m; f += 2) d += l[f + 1] - l[f] + 1;
    return d;
  }, e.count = r, e.startAt = n, e.endAt = i, e.minAt = a, e.maxAt = o, e.areEqual = function(l, d) {
    if (l.length !== d.length) return !1;
    for (var f = 0, m = l.length; f < m; ++f) if (l[f] !== d[f]) return !1;
    return !0;
  }, e.forEach = function(l, d) {
    for (var f = 0, m = 0, v = l.length; m < v; m += 2) for (var p = l[m], g = l[m + 1]; p <= g; ++p) d(p, f), ++f;
  }, e.has = function(l, d) {
    return u(l, d) !== -1;
  }, e.hasFrom = function(l, d, f) {
    return s(l, d, f) !== -1;
  }, e.firstIntersectionIndex = u, e.firstIntersectionIndexFrom = s, e.transientSegments = function(l, d) {
    return new c(l, d);
  };
  var c = function() {
    function l(d, f) {
      this.ranges = d, this.set = f, this.value = { index: 0, start: 0, end: 0 }, this.curIndex = 0, this.hasNext = !1, this.curIndex = u(d, f), this.hasNext = this.curIndex !== -1;
    }
    return l.prototype.updateValue = function() {
      this.value.index = this.curIndex, this.value.start = Le.findPredecessorIndex(this.set, n(this.ranges, this.curIndex)), this.value.end = Le.findPredecessorIndex(this.set, i(this.ranges, this.curIndex));
    }, l.prototype.move = function() {
      return this.hasNext && (this.updateValue(), this.curIndex = s(this.ranges, this.set, this.curIndex + 1), this.hasNext = this.curIndex !== -1), this.value;
    }, l;
  }();
  e.Iterator = c;
}(jr || (jr = {}));
var AA = w.zero();
function SA(e) {
  var t = function(r) {
    for (var n = r.conformation.invariantPosition, i = r.elements, a = new Float32Array(3 * i.length), o = 0, u = i.length; o < u; o++) n(i[o], AA), w.toArray(AA, a, 3 * o);
    return a;
  }(e);
  return Wl.ofPositions(t);
}
var Nu = function() {
  function e(t) {
    this.minDist = [], this.maxDist = [], this.extrema = [], this.centroidHelper = new K1(), this.dir = function(r) {
      var n;
      switch (r) {
        case "6":
          n = We([], qh, !0);
          break;
        case "14":
          n = We(We([], qh, !0), qy, !0);
          break;
        case "26":
          n = We(We(We([], qh, !0), qy, !0), CA, !0);
          break;
        case "98":
          n = We(We(We(We(We(We([], qh, !0), qy, !0), CA, !0), lX, !0), dX, !0), fX, !0);
      }
      return n.map(function(i) {
        var a = w.create(i[0], i[1], i[2]);
        return w.normalize(a, a);
      });
    }(t), this.reset();
  }
  return e.prototype.computeExtrema = function(t, r) {
    var n = w.dot(this.dir[t], r);
    n < this.minDist[t] && (this.minDist[t] = n, w.copy(this.extrema[2 * t], r)), n > this.maxDist[t] && (this.maxDist[t] = n, w.copy(this.extrema[2 * t + 1], r));
  }, e.prototype.computeSphereExtrema = function(t, r, n) {
    var i = w.dot(this.dir[t], r);
    i - n < this.minDist[t] && (this.minDist[t] = i - n, w.scaleAndSub(this.extrema[2 * t], r, this.dir[t], n)), i + n > this.maxDist[t] && (this.maxDist[t] = i + n, w.scaleAndAdd(this.extrema[2 * t + 1], r, this.dir[t], n));
  }, e.prototype.includeSphere = function(t) {
    if (Me.hasExtrema(t) && t.extrema.length > 1) for (var r = 0, n = t.extrema; r < n.length; r++) {
      var i = n[r];
      this.includePosition(i);
    }
    else this.includePositionRadius(t.center, t.radius);
  }, e.prototype.includePosition = function(t) {
    for (var r = 0, n = this.dir.length; r < n; ++r) this.computeExtrema(r, t);
  }, e.prototype.includePositionRadius = function(t, r) {
    for (var n = 0, i = this.dir.length; n < i; ++n) this.computeSphereExtrema(n, t, r);
  }, e.prototype.finishedIncludeStep = function() {
    for (var t = 0; t < this.extrema.length; t++) this.centroidHelper.includeStep(this.extrema[t]);
    this.centroidHelper.finishedIncludeStep();
  }, e.prototype.radiusSphere = function(t) {
    if (Me.hasExtrema(t) && t.extrema.length > 1) for (var r = 0, n = t.extrema; r < n.length; r++) {
      var i = n[r];
      this.radiusPosition(i);
    }
    else this.radiusPositionRadius(t.center, t.radius);
  }, e.prototype.radiusPosition = function(t) {
    this.centroidHelper.radiusStep(t);
  }, e.prototype.radiusPositionRadius = function(t, r) {
    this.centroidHelper.radiusSphereStep(t, r);
  }, e.prototype.getSphere = function(t) {
    return Me.setExtrema(this.centroidHelper.getSphere(t), We([], this.extrema, !0));
  }, e.prototype.getBox = function(t) {
    return qr.fromVec3Array(t || qr(), this.extrema);
  }, e.prototype.reset = function() {
    for (var t = 0, r = this.dir.length; t < r; ++t) this.minDist[t] = 1 / 0, this.maxDist[t] = -1 / 0, this.extrema[2 * t] = w(), this.extrema[2 * t + 1] = w();
    this.centroidHelper.reset();
  }, e;
}(), qh = [[1, 0, 0], [0, 1, 0], [0, 0, 1]], qy = [[1, 1, 1], [-1, 1, 1], [-1, -1, 1], [1, -1, 1]], CA = [[1, 1, 0], [1, -1, 0], [1, 0, 1], [1, 0, -1], [0, 1, 1], [0, 1, -1]], lX = [[0, 1, 2], [0, 2, 1], [1, 0, 2], [2, 0, 1], [1, 2, 0], [2, 1, 0], [0, 1, -2], [0, 2, -1], [1, 0, -2], [2, 0, -1], [1, -2, 0], [2, -1, 0]], dX = [[1, 1, 2], [2, 1, 1], [1, 2, 1], [1, -1, 2], [1, 1, -2], [1, -1, -2], [2, -1, 1], [2, 1, -1], [2, -1, -1], [1, -2, 1], [1, 2, -1], [1, -2, -1]], fX = [[2, 2, 1], [1, 2, 2], [2, 1, 2], [2, -2, 1], [2, 2, -1], [2, -2, -1], [1, -2, 2], [1, 2, -2], [1, -2, -2], [2, -1, 2], [2, 1, -2], [2, -1, -2]], wA = w.set, pX = new Nu("14"), mX = new Nu("98"), Kh = w();
function X1(e) {
  var t = e.x, r = e.y, n = e.z, i = e.radius, a = e.indices, o = Le.size(a);
  if (o > 25e4) {
    var u = qr.computeBounding(e);
    return { box: u, sphere: Me.fromBox3D(Me(), u) };
  }
  var s = function(m) {
    return m > 1e4 ? pX : mX;
  }(o);
  s.reset();
  for (var c = 0; c < o; c++) {
    var l = Le.getAt(a, c);
    wA(Kh, t[l], r[l], n[l]), s.includePositionRadius(Kh, i && i[l] || 0);
  }
  for (s.finishedIncludeStep(), c = 0; c < o; c++)
    l = Le.getAt(a, c), wA(Kh, t[l], r[l], n[l]), s.radiusPositionRadius(Kh, i && i[l] || 0);
  var d = s.getSphere();
  if (!i && Me.hasExtrema(d) && o <= d.extrema.length) {
    var f = [];
    for (c = 0; c < o; c++)
      l = Le.getAt(a, c), f.push(w.create(t[l], r[l], n[l]));
    Me.setExtrema(d, f);
  }
  return { box: s.getBox(), sphere: d };
}
var E2, ia, Be, M2, hX = function() {
  function e() {
    this.data = /* @__PURE__ */ new Map();
  }
  return e.prototype.get = function(t) {
    var r = qe.hashCode(t);
    if (this.data.has(r)) for (var n = 0, i = this.data.get(r); n < i.length; n++) {
      var a = i[n], o = a[0], u = a[1];
      if (qe.areEqual(t, o)) return u;
    }
  }, e.prototype.set = function(t, r) {
    var n = qe.hashCode(t);
    if (this.data.has(n)) {
      for (var i = this.data.get(n), a = 0, o = i; a < o.length; a++) {
        var u = o[a];
        if (qe.areEqual(t, u[0])) return void (u[1] = r);
      }
      i.push([t, r]);
    } else this.data.set(n, [[t, r]]);
  }, e.get = function(t) {
    return t._dynamicPropertyData.ElementSetIntraBondCache || (t._dynamicPropertyData.ElementSetIntraBondCache = new e()), t._dynamicPropertyData.ElementSetIntraBondCache;
  }, e;
}(), _b = function() {
  function e(t, r, n) {
    this.operatorsProvider = n, this.id = t, this.details = r;
  }
  return Object.defineProperty(e.prototype, "operatorGroups", { get: function() {
    return this._operators || (this._operators = this.operatorsProvider()), this._operators;
  }, enumerable: !1, configurable: !0 }), e;
}();
function vX(e, t, r) {
  if (!e._rowCount) return [];
  for (var n = function(o) {
    for (var u = o.id, s = o.matrix, c = o.vector, l = o._schema, d = /* @__PURE__ */ new Map(), f = 0, m = o._rowCount; f < m; f++) {
      var v = zn.toMat4(me(), l.matrix.space, s.value(f)), p = zn.toVec3(w(), l.vector.space, c.value(f));
      me.setTranslation(v, p), me.setValue(v, 3, 3, 1), d.set(u.value(f), v);
    }
    return d;
  }(r), i = [], a = 0; a < e._rowCount; a++) i[i.length] = gX(e, t, a, n);
  return i;
}
function gX(e, t, r, n) {
  for (var i = e.id.value(r), a = e.details.value(r), o = [], u = t.assembly_id, s = t.oper_expression, c = t.asym_id_list, l = 0, d = t._rowCount; l < d; l++) u.value(l) === i && (o[o.length] = { assemblyId: i, expression: s.value(l), asymIds: c.value(l) });
  return _b.create(i, a, /* @__PURE__ */ function(f, m) {
    return function() {
      for (var v = [], p = 0, g = 0; g < f.length; g++) {
        var h = f[g], y = yX(_X(h.expression)), x = bX(m, y, p, h.assemblyId), A = gn.generators.atoms({ chainTest: gn.pred.and(gn.pred.eq(function(b) {
          return Qe.unit.operator_name(b.element);
        }, hn.DefaultName), gn.pred.inSet(function(b) {
          return Qe.chain.label_asym_id(b.element);
        }, h.asymIds)) });
        v[v.length] = { selector: A, operators: x }, p += x.length;
      }
      return v;
    };
  }(o, n));
}
function yX(e) {
  for (var t = [], r = [], n = 0; n < e.length; n++) r[n] = "";
  return tT(e, t, e.length - 1, r), t;
}
function tT(e, t, r, n) {
  if (r < 0) t[t.length] = n.slice(0);
  else for (var i = e[r], a = i.length, o = 0; o < a; o++) n[r] = i[o], tT(e, t, r - 1, n);
}
function bX(e, t, r, n) {
  for (var i = [], a = r, o = 0, u = t; o < u.length; o++) {
    for (var s = u[o], c = me.identity(), l = 0; l < s.length; l++) me.mul(c, c, e.get(s[l]));
    a++, i[i.length] = hn.create("ASM_".concat(a), c, { assembly: { id: n, operId: a, operList: s } });
  }
  return i;
}
function _X(e) {
  for (var t, r = /\(?([^\(\)]+)\)?]*/g, n = [], i = []; t = r.exec(e); ) n[n.length] = t[1];
  return n.forEach(function(a) {
    var o = [];
    a.split(",").forEach(function(u) {
      var s = u.indexOf("-");
      if (s > 0) for (var c = parseInt(u.substring(0, s)), l = parseInt(u.substr(s + 1)), d = c; d <= l; d++) o[o.length] = d.toString();
      else o[o.length] = u.trim();
    }), i[i.length] = o;
  }), i;
}
function xX(e) {
  if (e._rowCount !== 0) {
    for (var t = e.id, r = e.matrix, n = e.vector, i = tr.struct_ncs_oper.matrix.space, a = tr.struct_ncs_oper.vector.space, o = [], u = 0; u < e._rowCount; u++) {
      var s = zn.toMat3(Ti(), i, r.value(u)), c = zn.toVec3(w(), a, n.value(u));
      if (hn.checkIfRotationAndTranslation(s, c) && (e.code.value(u) !== "given" || Ti.isIdentity(s) || w.isZero(c))) {
        var l = t.value(u);
        o[o.length] = hn.ofRotationAndOffset("ncs_".concat(l), s, c, l);
      }
    }
    return o;
  }
}
function AX(e) {
  var t = e.bonds, r = t.b, n = t.edgeProps, i = t.offset;
  n.order;
  for (var a = n.flags, o = e.rings.elementAromaticRingIndices, u = [], s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = function(y, x, A) {
    var b = u.length;
    u.push(qe.ofUnsortedArray([y, x, A])), s.set(f2(y, x), A), c.has(y) ? c.get(y).push(b) : c.set(y, [b]);
  }, d = 0; d < e.elements.length; d++)
    if (!o.has(d) && !(i[d + 1] - i[d] + 1 < 2)) {
      for (var f = [], m = i[d], v = i[d + 1]; m < v; m++) {
        var p = a[m];
        cr.is(p, 16) && f.push(r[m]);
      }
      if (f.length >= 2) {
        l(d, f[0], f[1]);
        for (var g = 1, h = f.length; g < h; g++) l(d, f[g], f[0]);
      }
    }
  return { getThirdElement: function(y, x) {
    return s.get(f2(y, x));
  }, getTripletIndices: function(y) {
    return c.get(y);
  }, triplets: u };
}
function rT() {
  return { result: M2.create(), closeUnitsResult: rd.create(), unitGroupResult: rd.create() };
}
(function(e) {
  e.create = function(t, r, n) {
    return new e(t, r, n);
  };
})(_b || (_b = {})), function(e) {
  e.Default = { assemblies: [], spacegroup: ho.ZeroP1, isNonStandardCrystalFrame: !1 }, e.findAssembly = function(t, r) {
    var n = r.toLocaleLowerCase(), i = ia.Provider.get(t);
    return i ? function(a, o) {
      for (var u = 0, s = a.length; u < s; u++) if (o(a[u])) return a[u];
    }(i.assemblies, function(a) {
      return a.id.toLowerCase() === n;
    }) : void 0;
  }, e.getUnitcellLabel = function(t) {
    var r = t.spacegroup, n = r.cell, i = r.name, a = r.num, o = n.size, u = n.anglesInRadians, s = o[0].toFixed(2), c = o[1].toFixed(2), l = o[2].toFixed(2), d = xa(u[0]).toFixed(2), f = xa(u[1]).toFixed(2), m = xa(u[2]).toFixed(2), v = [];
    return v.push("Unit Cell <b>".concat(i, "</b> #").concat(a)), v.push("".concat(s, "×").concat(c, "×").concat(l, " Å")), v.push("α=".concat(d, "° β=").concat(f, "° γ=").concat(m, "°")), v.join(" | ");
  };
}(E2 || (E2 = {})), function(e) {
  e.Descriptor = { name: "model_symmetry" }, e.Provider = Es.create(e.Descriptor), e.fromData = function(t) {
    var r = vX(t.pdbx_struct_assembly, t.pdbx_struct_assembly_gen, t.pdbx_struct_oper_list), n = function(i, a) {
      if (i._rowCount === 0 || a._rowCount === 0) return ho.ZeroP1;
      var o = a.length_a.value(0), u = a.length_b.value(0), s = a.length_c.value(0);
      if (o === 0 || u === 0 || s === 0) return ho.ZeroP1;
      var c = a.angle_alpha.value(0), l = a.angle_beta.value(0), d = a.angle_gamma.value(0);
      if (c === 0 || l === 0 || d === 0) return ho.ZeroP1;
      var f = function(v) {
        var p = v.Int_Tables_number.value(0), g = v["space_group_name_H-M"].value(0);
        return v.Int_Tables_number.isDefined ? v["space_group_name_H-M"].isDefined ? g : p : g;
      }(i), m = Tu.create(f, w.create(o, u, s), w.scale(w(), w.create(c, l, d), Math.PI / 180));
      return ho.create(m);
    }(t.symmetry, t.cell);
    return { assemblies: r, spacegroup: n, isNonStandardCrystalFrame: (t.atom_sites._rowCount, !1), ncsOperators: xX(t.struct_ncs_oper) };
  }, e.fromCell = function(t, r) {
    var n = Tu.create("P 1", t, r);
    return { assemblies: [], spacegroup: ho.create(n), isNonStandardCrystalFrame: !1 };
  };
}(ia || (ia = {})), function(e) {
  function t(h) {
    for (var y = [], x = 0, A = h.length; x < A; x++) y.push(h[x].id);
    return Ra(y);
  }
  function r(h) {
    var y = {};
    return { elements: h[0].elements, units: h, get unitIndexMap() {
      return y.unitIndexMap || (y.unitIndexMap = function(x) {
        for (var A = Ps.Mutable(), b = 0, _ = x.length; b < _; b++) A.set(x[b].id, b);
        return A;
      }(h)), y.unitIndexMap;
    }, hashCode: n(h[0]), transformHash: t(h) };
  }
  function n(h) {
    return h0(h.invariantId, qe.hashCode(h.elements));
  }
  var i;
  e.isAtomic = function(h) {
    return h.kind === 0;
  }, e.isCoarse = function(h) {
    return h.kind === 1 || h.kind === 2;
  }, e.isSpheres = function(h) {
    return h.kind === 1;
  }, e.isGaussians = function(h) {
    return h.kind === 2;
  }, e.create = function(h, y, x, A, b, _, S, D, I) {
    switch (b) {
      case 0:
        return new a(h, y, x, A, _, D, hn.createMapping(S, _.atomicConformation, void 0), I ?? o());
      case 1:
        return f(h, y, x, A, _, 1, D, hn.createMapping(S, _.coarseConformation.spheres, function(M) {
          var F = M.coarseConformation.spheres.radius;
          return function(P) {
            return F[P];
          };
        }(_)), I ?? c());
      case 2:
        return f(h, y, x, A, _, 2, D, hn.createMapping(S, _.coarseConformation.gaussians, function(M) {
          return 0;
        }), I ?? c());
    }
  }, e.SymmetryGroup = r, function(h) {
    h.areInvariantElementsEqual = function(y, x) {
      return y.hashCode === x.hashCode && qe.areEqual(y.elements, x.elements);
    }, h.getUnitSymmetryGroupsIndexMap = function(y) {
      for (var x = Ps.Mutable(), A = 0, b = y.length; A < b; ++A) for (var _ = y[A], S = 0, D = _.units.length; S < D; ++S) x.set(_.units[S].id, A);
      return x;
    };
  }(r = e.SymmetryGroup || (e.SymmetryGroup = {})), e.conformationId = function(h) {
    return e.isAtomic(h) ? h.model.atomicConformation.id : h.model.coarseConformation.id;
  }, e.hashUnit = n, (i = e.Traits || (e.Traits = {})).is = ya.has, i.create = ya.create;
  var a = function() {
    function h(y, x, A, b, _, S, D, I) {
      this.kind = 0, this.objectPrimitive = "atomistic", this.id = y, this.invariantId = x, this.chainGroupId = A, this.traits = b, this.model = _, this.elements = S, this.conformation = D, this.residueIndex = _.atomicHierarchy.residueAtomSegments.index, this.chainIndex = _.atomicHierarchy.chainAtomSegments.index, this.props = I;
    }
    return h.prototype.getChild = function(y) {
      return y.length === this.elements.length ? this : new h(this.id, this.invariantId, this.chainGroupId, this.traits, this.model, y, this.conformation, o());
    }, h.prototype.applyOperator = function(y, x, A) {
      A === void 0 && (A = !1);
      var b = A ? x : hn.compose(this.conformation.operator, x);
      return new h(y, this.invariantId, this.chainGroupId, this.traits, this.model, this.elements, hn.createMapping(b, this.model.atomicConformation, this.conformation.r), this.props);
    }, h.prototype.remapModel = function(y, x, A) {
      var b, _;
      A || (A = R(R({}, this.props), { bonds: x && !(!((_ = (b = this.props.bonds) === null || b === void 0 ? void 0 : b.props) === null || _ === void 0) && _.canRemap) ? void 0 : m(this, this.props.bonds, y, x) }), e.isSameConformation(this, y) || (A.boundary = void 0, A.lookup3d = void 0, A.principalAxes = void 0));
      var S = this.conformation.operator, D = ia.Provider.get(y);
      if (S.spgrOp !== -1 && D && D !== ia.Provider.get(this.model)) {
        var I = S.hkl, M = I[0], F = I[1], P = I[2], E = D.spacegroup.cell.toFractional, B = w.transformMat4(w(), nn.getCenter(y), E);
        S = ho.getSymmetryOperatorRef(D.spacegroup, S.spgrOp, M, F, P, B);
      }
      var N = this.model.atomicConformation !== y.atomicConformation || S !== this.conformation.operator ? hn.createMapping(S, y.atomicConformation) : this.conformation;
      return new h(this.id, this.invariantId, this.chainGroupId, this.traits, y, this.elements, N, A);
    }, Object.defineProperty(h.prototype, "boundary", { get: function() {
      if (this.props.boundary) return this.props.boundary;
      var y = this.model.atomicConformation, x = y.x, A = y.y, b = y.z;
      return this.props.boundary = X1({ x, y: A, z: b, indices: this.elements }), this.props.boundary;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "lookup3d", { get: function() {
      if (this.props.lookup3d) return this.props.lookup3d;
      var y = this.model.atomicConformation, x = y.x, A = y.y, b = y.z;
      return this.props.lookup3d = lf({ x, y: A, z: b, indices: this.elements }, this.boundary), this.props.lookup3d;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "principalAxes", { get: function() {
      return this.props.principalAxes || (this.props.principalAxes = SA(this)), this.props.principalAxes;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "bonds", { get: function() {
      if (this.props.bonds) return this.props.bonds;
      var y = hX.get(this.model), x = y.get(this.elements);
      return x || (x = QK(this), y.set(this.elements, x)), this.props.bonds = x, this.props.bonds;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "rings", { get: function() {
      return this.props.rings || (this.props.rings = I2.create(this)), this.props.rings;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "resonance", { get: function() {
      return this.props.resonance || (this.props.resonance = function(y) {
        return { delocalizedTriplets: AX(y) };
      }(this)), this.props.resonance;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "polymerElements", { get: function() {
      return this.props.polymerElements || (this.props.polymerElements = function(y) {
        for (var x = [], A = y.elements, b = y.model, _ = y.model.atomicHierarchy.residueAtomSegments, S = b.atomicHierarchy.derived.residue.traceElementIndex, D = jr.transientSegments(y.model.atomicRanges.polymerRanges, A), I = Zt.transientSegments(_, A); D.hasNext; ) {
          var M = D.move();
          for (I.setSegment(M); I.hasNext; ) {
            var F = I.move(), P = F.start, E = F.end, B = F.index;
            if (Le.areIntersecting(Ae.ofRange(A[P], A[E - 1]), A)) {
              var N = S[B];
              x.push(N === -1 ? _.offsets[B] : N);
            }
          }
        }
        return qe.ofSortedArray(x);
      }(this)), this.props.polymerElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "gapElements", { get: function() {
      return this.props.gapElements || (this.props.gapElements = function(y) {
        for (var x = [], A = y.elements, b = y.model, _ = y.residueIndex, S = y.model.atomicHierarchy.residueAtomSegments, D = b.atomicHierarchy.derived.residue.traceElementIndex, I = jr.transientSegments(y.model.atomicRanges.gapRanges, y.elements); I.hasNext; ) {
          var M = I.move(), F = _[A[M.start]], P = _[A[M.end - 1]], E = D[F], B = D[P];
          x.push(E === -1 ? S.offsets[F] : E), x.push(B === -1 ? S.offsets[P] : B);
        }
        return qe.ofSortedArray(x);
      }(this)), this.props.gapElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "nucleotideElements", { get: function() {
      return this.props.nucleotideElements || (this.props.nucleotideElements = function(y) {
        for (var x = [], A = y.elements, b = y.model, _ = b.atomicHierarchy, S = _.chainAtomSegments, D = _.residueAtomSegments, I = b.atomicHierarchy.derived.residue, M = I.moleculeType, F = I.traceElementIndex, P = Zt.transientSegments(S, A), E = Zt.transientSegments(D, A); P.hasNext; ) for (E.setSegment(P.move()); E.hasNext; ) {
          var B = E.move().index;
          if (y0(M[B])) {
            var N = F[B];
            x.push(N === -1 ? D.offsets[B] : N);
          }
        }
        return qe.ofSortedArray(x);
      }(this)), this.props.nucleotideElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "proteinElements", { get: function() {
      return this.props.proteinElements || (this.props.proteinElements = function(y) {
        for (var x = [], A = y.elements, b = y.model, _ = b.atomicHierarchy, S = _.chainAtomSegments, D = _.residueAtomSegments, I = b.atomicHierarchy.derived.residue, M = I.moleculeType, F = I.traceElementIndex, P = Zt.transientSegments(S, A), E = Zt.transientSegments(D, A); P.hasNext; ) for (E.setSegment(P.move()); E.hasNext; ) {
          var B = E.move().index;
          if (KM(M[B])) {
            var N = F[B];
            x.push(N === -1 ? D.offsets[B] : N);
          }
        }
        return qe.ofSortedArray(x);
      }(this)), this.props.proteinElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "residueCount", { get: function() {
      if (this.props.residueCount !== void 0) return this.props.residueCount;
      for (var y = 0, x = Zt.transientSegments(this.model.atomicHierarchy.residueAtomSegments, this.elements); x.hasNext; ) x.move(), y += 1;
      return this.props.residueCount = y, this.props.residueCount;
    }, enumerable: !1, configurable: !0 }), h.prototype.getResidueIndex = function(y) {
      return this.residueIndex[this.elements[y]];
    }, h;
  }();
  function o() {
    return {};
  }
  e.Atomic = a;
  var u = function() {
    function h(y, x, A, b, _, S, D, I, M) {
      this.kind = S, this.objectPrimitive = S === 1 ? "sphere" : "gaussian", this.id = y, this.invariantId = x, this.chainGroupId = A, this.traits = b, this.model = _, this.elements = D, this.conformation = I, this.coarseElements = S === 1 ? _.coarseHierarchy.spheres : _.coarseHierarchy.gaussians, this.coarseConformation = S === 1 ? _.coarseConformation.spheres : _.coarseConformation.gaussians, this.props = M;
    }
    return h.prototype.getChild = function(y) {
      return y.length === this.elements.length ? this : f(this.id, this.invariantId, this.chainGroupId, this.traits, this.model, this.kind, y, this.conformation, c());
    }, h.prototype.applyOperator = function(y, x, A) {
      A === void 0 && (A = !1);
      var b = A ? x : hn.compose(this.conformation.operator, x);
      return f(y, this.invariantId, this.chainGroupId, this.traits, this.model, this.kind, this.elements, hn.createMapping(b, this.getCoarseConformation(), this.conformation.r), this.props);
    }, h.prototype.remapModel = function(y, x, A) {
      var b = this.getCoarseConformation(), _ = s(this.kind, y);
      A || (A = R({}, this.props), e.isSameConformation(this, y) || (A.boundary = void 0, A.lookup3d = void 0, A.principalAxes = void 0));
      var S = b !== _ ? hn.createMapping(this.conformation.operator, _) : this.conformation;
      return new h(this.id, this.invariantId, this.chainGroupId, this.traits, y, this.kind, this.elements, S, A);
    }, Object.defineProperty(h.prototype, "boundary", { get: function() {
      if (this.props.boundary) return this.props.boundary;
      var y = this.getCoarseConformation(), x = y.x, A = y.y, b = y.z;
      return this.props.boundary = X1({ x, y: A, z: b, indices: this.elements }), this.props.boundary;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "lookup3d", { get: function() {
      if (this.props.lookup3d) return this.props.lookup3d;
      var y = this.getCoarseConformation(), x = y.x, A = y.y, b = y.z;
      return this.props.lookup3d = lf({ x, y: A, z: b, indices: this.elements }, this.boundary), this.props.lookup3d;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "principalAxes", { get: function() {
      return this.props.principalAxes || (this.props.principalAxes = SA(this)), this.props.principalAxes;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "polymerElements", { get: function() {
      return this.props.polymerElements || (this.props.polymerElements = sX(this)), this.props.polymerElements;
    }, enumerable: !1, configurable: !0 }), Object.defineProperty(h.prototype, "gapElements", { get: function() {
      return this.props.gapElements || (this.props.gapElements = cX(this)), this.props.gapElements;
    }, enumerable: !1, configurable: !0 }), h.prototype.getCoarseConformation = function() {
      return s(this.kind, this.model);
    }, h;
  }();
  function s(h, y) {
    return h === 1 ? y.coarseConformation.spheres : y.coarseConformation.gaussians;
  }
  function c() {
    return {};
  }
  var l = function(h) {
    function y() {
      return h !== null && h.apply(this, arguments) || this;
    }
    return ga(y, h), y;
  }(u);
  e.Spheres = l;
  var d = function(h) {
    function y() {
      return h !== null && h.apply(this, arguments) || this;
    }
    return ga(y, h), y;
  }(u);
  function f(h, y, x, A, b, _, S, D, I) {
    return new u(h, y, x, A, b, _, S, D, I);
  }
  function m(h, y, x, A) {
    var b;
    if (y) {
      if (h.model.atomicConformation.id === x.atomicConformation.id) return y;
      var _ = Ei.Provider.get(h.model);
      if (_) {
        var S = Ei.Provider.get(x);
        return S && _ !== S ? void 0 : y;
      }
      return !((b = y.props) === null || b === void 0) && b.canRemap || !A || v(h, x) ? y : void 0;
    }
  }
  function v(h, y) {
    var x = nn.CoordinatesHistory.get(nn.getRoot(y));
    if (x) return x.areEqual(h.elements, h.kind, y);
    for (var A = h.elements, b = h.conformation.coordinates, _ = b.x, S = b.y, D = b.z, I = p(h.kind, y), M = I.x, F = I.y, P = I.z, E = 0, B = A.length; E < B; E++) {
      var N = A[E];
      if (_[N] !== M[N] || S[N] !== F[N] || D[N] !== P[N]) return !1;
    }
    return !0;
  }
  function p(h, y) {
    return h === 0 ? y.atomicConformation : h === 1 ? y.coarseConformation.spheres : y.coarseConformation.gaussians;
  }
  function g(h, y) {
    return h === 0 ? y.atomicHierarchy : h === 1 ? y.coarseHierarchy.spheres : y.coarseHierarchy.gaussians;
  }
  e.Gaussians = d, e.areSameChainOperatorGroup = function(h, y) {
    return h.chainGroupId === y.chainGroupId && h.conformation.operator.name === y.conformation.operator.name;
  }, e.areOperatorsEqual = function(h, y) {
    return me.areEqual(h.conformation.operator.matrix, y.conformation.operator.matrix, 1e-6);
  }, e.areConformationsEqual = function(h, y) {
    return !!qe.areEqual(h.elements, y.elements) && v(h, y.model);
  }, e.isSameConformation = v, e.getModelConformationOfKind = p, e.getConformation = function(h) {
    return p(h.kind, h.model);
  }, e.getModelHierarchyOfKind = g, e.getHierarchy = function(h) {
    return g(h.kind, h.model);
  };
}(Be || (Be = {})), function(e) {
  e.add = function(t, r, n, i) {
    t.indices[t.count] = n, t.units[t.count] = r, t.squaredDistances[t.count] = i, t.count++;
  }, e.create = function() {
    return { count: 0, indices: [], units: [], squaredDistances: [] };
  }, e.copy = function(t, r) {
    for (var n = 0; n < r.count; ++n) t.indices[n] = r.indices[n], t.units[n] = r.units[n], t.squaredDistances[n] = r.squaredDistances[n];
    return t.count = r.count, t;
  };
}(M2 || (M2 = {}));
var vt, $a, SX = function() {
  function e(t) {
    this.structure = t, this.pivot = w(), this.findContext = rT();
    for (var r = t.units, n = t.boundary, i = r.length, a = new Float32Array(i), o = new Float32Array(i), u = new Float32Array(i), s = new Float32Array(i), c = w(), l = 0; l < i; l++) {
      var d = r[l], f = d.boundary.sphere;
      w.transformMat4(c, f.center, d.conformation.operator.matrix), a[l] = c[0], o[l] = c[1], u[l] = c[2], s[l] = f.radius;
    }
    var m = { x: a, y: o, z: u, radius: s, indices: Le.ofBounds(0, i) };
    this.unitLookup = lf(m, n);
  }
  return e.prototype.findUnitIndices = function(t, r, n, i) {
    return this.unitLookup.find(t, r, n, i);
  }, e.prototype.find = function(t, r, n, i, a) {
    return this._find(t, r, n, i, a ?? this.findContext);
  }, e.prototype._find = function(t, r, n, i, a) {
    rd.reset(a.result);
    var o = this.structure.units, u = this.unitLookup.find(t, r, n, i, a.closeUnitsResult);
    if (u.count === 0) return a.result;
    for (var s = 0, c = u.count; s < c; s++) {
      var l = o[u.indices[s]];
      w.set(this.pivot, t, r, n), l.conformation.operator.isIdentity || w.transformMat4(this.pivot, this.pivot, l.conformation.operator.inverse);
      for (var d = l.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], i, a.unitGroupResult), f = 0, m = d.count; f < m; f++) M2.add(a.result, l, d.indices[f], d.squaredDistances[f]);
    }
    return a.result;
  }, e.prototype.findIntoBuilder = function(t, r, n, i, a) {
    var o = this.structure.units, u = this.unitLookup.find(t, r, n, i);
    if (u.count !== 0) for (var s = 0, c = u.count; s < c; s++) {
      var l = o[u.indices[s]];
      w.set(this.pivot, t, r, n), l.conformation.operator.isIdentity || w.transformMat4(this.pivot, this.pivot, l.conformation.operator.inverse);
      var d = l.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], i);
      if (d.count !== 0) {
        var f = l.elements;
        a.beginUnit(l.id);
        for (var m = 0, v = d.count; m < v; m++) a.addElement(f[d.indices[m]]);
        a.commitUnit();
      }
    }
  }, e.prototype.findIntoBuilderIf = function(t, r, n, i, a, o) {
    var u = this.structure.units, s = this.unitLookup.find(t, r, n, i);
    if (s.count !== 0) for (var c = at.create(this.structure), l = 0, d = s.count; l < d; l++) {
      var f = u[s.indices[l]];
      w.set(this.pivot, t, r, n), f.conformation.operator.isIdentity || w.transformMat4(this.pivot, this.pivot, f.conformation.operator.inverse);
      var m = f.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], i);
      if (m.count !== 0) {
        var v = f.elements;
        c.unit = f, a.beginUnit(f.id);
        for (var p = 0, g = m.count; p < g; p++) c.element = v[m.indices[p]], o(c) && a.addElement(c.element);
        a.commitUnit();
      }
    }
  }, e.prototype.findIntoBuilderWithRadius = function(t, r, n, i, a, o, u, s) {
    var c = this.structure.units, l = this.unitLookup.find(t, r, n, o);
    if (l.count !== 0) for (var d = at.create(this.structure), f = i + a + o, m = 0, v = l.count; m < v; m++) {
      var p = c[l.indices[m]];
      w.set(this.pivot, t, r, n), p.conformation.operator.isIdentity || w.transformMat4(this.pivot, this.pivot, p.conformation.operator.inverse);
      var g = p.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], f);
      if (g.count !== 0) {
        var h = p.elements;
        d.unit = p, s.beginUnit(p.id);
        for (var y = 0, x = g.count; y < x; y++) {
          d.element = h[g.indices[y]];
          var A = u(d);
          Math.sqrt(g.squaredDistances[y]) - i - A > o || s.addElement(h[g.indices[y]]);
        }
        s.commitUnit();
      }
    }
  }, e.prototype.check = function(t, r, n, i) {
    var a = this.structure.units, o = this.unitLookup.find(t, r, n, i);
    if (o.count === 0) return !1;
    for (var u = 0, s = o.count; u < s; u++) {
      var c = a[o.indices[u]];
      if (w.set(this.pivot, t, r, n), c.conformation.operator.isIdentity || w.transformMat4(this.pivot, this.pivot, c.conformation.operator.inverse), c.lookup3d.check(this.pivot[0], this.pivot[1], this.pivot[2], i)) return !0;
    }
    return !1;
  }, Object.defineProperty(e.prototype, "boundary", { get: function() {
    return this.structure.boundary;
  }, enumerable: !1, configurable: !0 }), e;
}();
function T2(e, t) {
  if (t.length === 0) return tt.Empty;
  if (t.length === 1) return t[0];
  for (var r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), i = 0, a = t; i < a.length; i++) for (var o = a[i].units, u = 0, s = o.length; u < s; u++) {
    var c = o[u];
    if (r.has(c.id)) {
      if (n.has(c.id)) continue;
      var l = qe.union(r.get(c.id), c.elements);
      r.set(c.id, l), l.length === e.unitMap.get(c.id).elements.length && n.add(c.id);
    } else r.set(c.id, c.elements), c.elements.length === e.unitMap.get(c.id).elements.length && n.add(c.id);
  }
  var d = e.subsetBuilder(!0);
  return r.forEach(CX, d), d.getStructure();
}
function CX(e, t) {
  this.setUnit(t, e);
}
function __(e, t) {
  if (e === t) return !0;
  var r, n;
  e.units.length < t.units.length ? (r = e, n = t) : (r = t, n = e);
  for (var i = r.units, a = n.unitMap, o = 0, u = i.length; o < u; o++) {
    var s = i[o];
    if (a.has(s.id)) {
      var c = a.get(s.id);
      if (qe.areIntersecting(s.elements, c.elements)) return !0;
    }
  }
  return !1;
}
function nT(e, t) {
  if (e === t) return tt.Empty;
  if (!__(e, t)) return e;
  for (var r = e.units, n = t.unitMap, i = [], a = 0, o = r.length; a < o; a++) {
    var u = r[a];
    if (n.has(u.id)) {
      var s = n.get(u.id), c = qe.subtract(u.elements, s.elements);
      c.length > 0 && (i[i.length] = u.getChild(c));
    } else i[i.length] = u;
  }
  return tt.create(i, { parent: e.parent || t.parent });
}
function xb(e) {
  return cr.isCovalent(e.atomicBond.type);
}
function iT(e, t, r) {
  return { groupedUnits: e, ranges: t, set: r };
}
function aT(e) {
  return function(t) {
    var r = { hash: t.inputStructure.hashCode, elements: e };
    return vt.Sequence(t.inputStructure, [$a.toStructure(r, t.inputStructure)]);
  };
}
(function(e) {
  function t(l, d) {
    return { kind: "singletons", source: l, structure: d };
  }
  function r(l, d) {
    return { kind: "sequence", source: l, structures: d };
  }
  function n(l) {
    return t(l, tt.Empty);
  }
  function i(l) {
    return l.kind === "singletons";
  }
  function a(l) {
    return i(l) ? l.structure.units.length === 0 : l.structures.length === 0;
  }
  function o(l) {
    return a(l) ? tt.Empty : i(l) ? l.structure : T2(l.source, l.structures);
  }
  function u(l, d, f) {
    return d.length === 0 ? n(l) : f ? t(l, T2(l, d)) : r(l, d);
  }
  e.Singletons = t, e.Sequence = r, e.Empty = n, e.isSingleton = i, e.isEmpty = a, e.structureCount = function(l) {
    return i(l) ? l.structure.elementCount : l.structures.length;
  }, e.unionStructure = o, e.toLociWithCurrentUnits = function(l) {
    for (var d = [], f = l.source.unitMap, m = 0, v = o(l).units; m < v.length; m++) {
      var p = v[m];
      p === f.get(p.id) ? d[d.length] = { unit: p, indices: Le.ofBounds(0, p.elements.length) } : d[d.length] = { unit: p, indices: Le.ofSortedArray(qe.indicesOf(f.get(p.id).elements, p.elements)) };
    }
    return Xe(l.source, d);
  }, e.toLociWithSourceUnits = function(l) {
    for (var d = [], f = l.source.unitMap, m = 0, v = o(l).units; m < v.length; m++) {
      var p = v[m];
      if (f.has(p.id)) {
        var g = f.get(p.id);
        d[d.length] = g === p ? { unit: g, indices: Le.ofBounds(0, g.elements.length) } : { unit: g, indices: Le.ofSortedArray(qe.indicesOf(g.elements, p.elements)) };
      }
    }
    return Xe(l.source, d);
  };
  var s = function() {
    function l(d) {
      this.source = d, this.structures = [], this.allSingletons = !0;
    }
    return l.prototype.add = function(d) {
      var f = d.elementCount;
      f !== 0 && (this.structures[this.structures.length] = d, f !== 1 && (this.allSingletons = !1));
    }, l.prototype.getSelection = function() {
      return u(this.source, this.structures, this.allSingletons);
    }, l;
  }(), c = function() {
    function l(d) {
      this.structure = d, this.structures = [], this.allSingletons = !0, this.uniqueSets = p_(tt.hashCode, tt.areUnitIdsAndIndicesEqual);
    }
    return l.prototype.add = function(d) {
      var f = d.elementCount;
      f !== 0 && this.uniqueSets.add(d) && (this.structures[this.structures.length] = d, f !== 1 && (this.allSingletons = !1));
    }, l.prototype.getSelection = function() {
      return u(this.structure, this.structures, this.allSingletons);
    }, l;
  }();
  e.LinearBuilder = function(l) {
    return new s(l);
  }, e.UniqueBuilder = function(l) {
    return new c(l);
  }, e.forEach = function(l, d) {
    var f = 0;
    if (e.isSingleton(l)) for (var m = 0, v = l.structure.units; m < v.length; m++) for (var p = v[m], g = p.elements, h = 0, y = g.length; h < y; h++)
      d(tt.create([p.getChild(qe.ofSingleton(g[h]))], { parent: l.source }), f++);
    else for (var x = 0, A = l.structures; x < A.length; x++)
      d(A[x], f++);
  }, e.withInputStructure = function(l, d) {
    return i(l) ? t(d, l.structure) : r(d, l.structures);
  };
})(vt || (vt = {})), function(e) {
  function t(i) {
    for (var a = [], o = 0, u = i.elements; o < u.length; o++) {
      var s = (x = u[o]).unit, c = x.indices;
      if (Le.size(c) !== 0) {
        var l = [], d = [];
        if (Le.isInterval(c)) Le.size(c) === 1 ? d.push(Ae.min(c)) : l.push(Ae.min(c), Ae.max(c));
        else for (var f = 0, m = c.length; f < m; ) {
          var v = f;
          for (f++; f < m && c[f - 1] + 1 === c[f]; ) f++;
          var p = f;
          if (p - v > 2) l.push(c[v], c[p - 1]);
          else for (var g = v; g < p; g++) d[d.length] = c[g];
        }
        a.push({ unit: s, set: qe.ofSortedArray(d), ranges: jr.ofSortedRanges(l) });
      }
    }
    for (var h = /* @__PURE__ */ new Map(), y = (f = 0, a.length); f < y; ++f) {
      var x, A, b = h0(Ra((x = a[f]).ranges), Ra(x.set));
      h.has(b) ? (A = h.get(b).groupedUnits).has(x.unit.invariantId) ? A.get(x.unit.invariantId).push(x.unit.id) : A.set(x.unit.invariantId, [x.unit.id]) : ((A = /* @__PURE__ */ new Map()).set(x.unit.invariantId, [x.unit.id]), h.set(b, { groupedUnits: A, set: x.set, ranges: x.ranges }));
    }
    var _ = [];
    return h.forEach(function(S) {
      var D = [];
      S.groupedUnits.forEach(function(I) {
        return D.push(qe.ofUnsortedArray(I));
      }), D.sort(function(I, M) {
        return I[0] - M[0];
      }), _.push({ groupedUnits: D, set: S.set, ranges: S.ranges });
    }), { hash: i.structure.hashCode, elements: _ };
  }
  function r(i, a) {
    for (var o = [], u = 0, s = i.length; u < s; ++u) {
      var c = i[u];
      a.unitMap.has(c) && o.push(a.unitMap.get(c));
    }
    return o;
  }
  function n(i) {
    return Nt.internal.generator.bundleElement({ groupedUnits: Nt.core.type.list(i.groupedUnits.map(function(a) {
      return Nt.core.type.list(a);
    })), ranges: Nt.core.type.list(i.ranges), set: Nt.core.type.list(i.set) });
  }
  e.Empty = { hash: -1, elements: [] }, e.fromSubStructure = function(i, a) {
    return t(vt.toLociWithSourceUnits(vt.Singletons(i, a)));
  }, e.fromSelection = function(i) {
    return t(vt.toLociWithSourceUnits(i));
  }, e.fromLoci = t, e.toLoci = function(i, a) {
    i.hash !== -1 && (i.hash, a.hashCode);
    for (var o = [], u = 0, s = i.elements; u < s.length; u++) for (var c = s[u], l = function(m) {
      var v = r(m, a);
      if (v.length === 0) return "continue";
      var p = void 0;
      if (c.ranges.length === 0) p = c.set;
      else if (c.set.length === 0) if (c.ranges.length === 2) p = Ae.ofRange(c.ranges[0], c.ranges[1]);
      else {
        var g = new Int32Array(jr.size(c.ranges));
        jr.forEach(c.ranges, function(_, S) {
          return g[S] = _;
        }), p = qe.ofSortedArray(g);
      }
      else {
        var h = jr.size(c.ranges), y = new Int32Array(c.set.length + h);
        jr.forEach(c.ranges, function(_, S) {
          return y[S] = _;
        }), y.set(c.set, h), p = qe.ofUnsortedArray(y);
      }
      for (var x = 0, A = v; x < A.length; x++) {
        var b = A[x];
        o.push({ unit: b, indices: p });
      }
    }, d = 0, f = c.groupedUnits; d < f.length; d++)
      l(f[d]);
    return Xe(a, o);
  }, e.toStructure = function(i, a) {
    i.hash !== -1 && (i.hash, a.hashCode);
    for (var o = [], u = 0, s = i.elements; u < s.length; u++) for (var c = s[u], l = function(m) {
      var v = r(m, a);
      if (v.length === 0) return "continue";
      var p = v[0].elements, g = jr.size(c.ranges), h = c.set.length, y = new Int32Array(h + g), x = void 0;
      if (g === 0) {
        for (var A = 0, b = h; A < b; ++A) y[A] = p[c.set[A]];
        x = qe.ofSortedArray(y);
      } else if (h === 0) jr.forEach(c.ranges, function(I, M) {
        return y[M] = p[I];
      }), x = qe.ofSortedArray(y);
      else if (qe.min(c.set) > jr.max(c.ranges)) {
        for (jr.forEach(c.ranges, function(I, M) {
          return y[M] = p[I];
        }), A = 0, b = h; A < b; ++A) y[A + g] = p[c.set[A]];
        x = qe.ofSortedArray(y);
      } else if (jr.min(c.ranges) > qe.max(c.set)) {
        for (A = 0, b = h; A < b; ++A) y[A] = p[c.set[A]];
        jr.forEach(c.ranges, function(I, M) {
          return y[M + h] = p[I];
        }), x = qe.ofSortedArray(y);
      } else {
        for (jr.forEach(c.ranges, function(I, M) {
          return y[M] = p[I];
        }), A = 0, b = h; A < b; ++A) y[A + g] = p[c.set[A]];
        x = qe.ofUnsortedArray(y);
      }
      for (var _ = 0, S = v; _ < S.length; _++) {
        var D = S[_];
        o.push(D.getChild(x));
      }
    }, d = 0, f = c.groupedUnits; d < f.length; d++)
      l(f[d]);
    return tt.create(o, { parent: a });
  }, e.toExpression = function(i) {
    return Nt.internal.generator.bundle({ elements: Nt.core.type.list(i.elements.map(n)) });
  }, e.areEqual = function(i, a) {
    if (i.elements.length !== a.elements.length) return !1;
    for (var o = 0, u = i.elements.length; o < u; ++o) {
      var s = i.elements[o], c = a.elements[o];
      if (s.groupedUnits.length !== c.groupedUnits.length) return !1;
      for (var l = 0, d = c.groupedUnits.length; l < d; ++l) if (!qe.areEqual(s.groupedUnits[l], c.groupedUnits[l])) return !1;
      if (!qe.areEqual(s.set, c.set) || !jr.areEqual(s.ranges, c.ranges)) return !1;
    }
    return !0;
  };
}($a || ($a = {}));
var DA, wX = Object.freeze({ __proto__: null, atomicHet: function() {
  return function(e) {
    for (var t = e.inputStructure, r = at.create(t), n = [], i = 0, a = t.units; i < a.length; i++) {
      var o = a[i];
      if (o.kind === 0) {
        r.unit = o;
        var u = o.elements;
        if (r.element = u[0], Qe.entity.type(r) !== "water") {
          if (Qe.entity.type(r) === "polymer") {
            for (var s = Zt.transientSegments(o.model.atomicHierarchy.residueAtomSegments, u), c = 0; s.hasNext; ) c++, s.move();
            if (c >= 8) continue;
          }
          n.push(o);
        }
      }
    }
    return vt.Singletons(t, tt.create(n, { parent: t }));
  };
}, atomicSequence: function() {
  return function(e) {
    for (var t = e.inputStructure, r = at.create(t), n = [], i = 0, a = t.units; i < a.length; i++) {
      var o = a[i];
      if (o.kind === 0) {
        r.unit = o;
        var u = o.elements;
        if (r.element = u[0], Qe.entity.type(r) === "polymer") {
          for (var s = Zt.transientSegments(o.model.atomicHierarchy.residueAtomSegments, u), c = 0; s.hasNext; ) c++, s.move();
          c < 8 || n.push(o);
        }
      }
    }
    return vt.Singletons(t, tt.create(n, { parent: t }));
  };
}, bundleElementImpl: iT, bundleGenerator: aT, defaultBondTest: xb, spheres: function() {
  return function(e) {
    for (var t = e.inputStructure, r = [], n = 0, i = t.units; n < i.length; n++) {
      var a = i[n];
      a.kind === 1 && r.push(a);
    }
    return vt.Singletons(t, tt.create(r, { parent: t }));
  };
}, water: function() {
  return function(e) {
    for (var t = e.inputStructure, r = at.create(t), n = [], i = 0, a = t.units; i < a.length; i++) {
      var o = a[i];
      if (o.kind === 0) {
        r.unit = o;
        var u = o.elements;
        r.element = u[0], Qe.entity.type(r) === "water" && n.push(o);
      }
    }
    return vt.Singletons(t, tt.create(n, { parent: t }));
  };
} }), ff = function() {
  function e(t, r) {
    this.currentElementStack = [], this.currentAtomicBondStack = [], this.currentStructureStack = [], this.inputStructureStack = [], this.timeCreated = li(), this.element = at.create(void 0), this.currentStructure = void 0, this.atomicBond = new IA(), this.currentSelection = void 0, this.inputStructure = t, this.timeoutMs = r && r.timeoutMs || 0, this.currentSelection = r && r.currentSelection;
  }
  return e.prototype.pushCurrentElement = function() {
    return this.currentElementStack[this.currentElementStack.length] = this.element, this.element = at.create(void 0), this.element;
  }, e.prototype.popCurrentElement = function() {
    this.element = this.currentElementStack.pop();
  }, e.prototype.pushCurrentBond = function() {
    return this.atomicBond && this.currentAtomicBondStack.push(this.atomicBond), this.atomicBond = new IA(), this.atomicBond;
  }, e.prototype.popCurrentBond = function() {
    this.currentAtomicBondStack.length > 0 ? this.atomicBond = this.currentAtomicBondStack.pop() : this.atomicBond = void 0;
  }, e.prototype.pushCurrentStructure = function() {
    this.currentStructure && this.currentStructureStack.push(this.currentStructure);
  }, e.prototype.popCurrentStructure = function() {
    this.currentStructureStack.length ? this.currentStructure = this.currentStructureStack.pop() : this.currentStructure = void 0;
  }, e.prototype.pushInputStructure = function(t) {
    this.inputStructureStack.push(this.inputStructure), this.inputStructure = t;
  }, e.prototype.popInputStructure = function() {
    if (this.inputStructureStack.length === 0) throw new Error("Must push before pop.");
    this.inputStructure = this.inputStructureStack.pop();
  }, e.prototype.throwIfTimedOut = function() {
    if (this.timeoutMs !== 0 && li() - this.timeCreated > this.timeoutMs) throw new Error("The query took too long to execute (> ".concat(this.timeoutMs / 1e3, "s)."));
  }, e.prototype.tryGetCurrentSelection = function() {
    if (!this.currentSelection) throw new Error("The current selection is not assigned.");
    return this.currentSelection;
  }, e;
}(), IA = function() {
  function e() {
    this.a = at.create(void 0), this.aIndex = 0, this.b = at.create(void 0), this.bIndex = 0, this.type = 0, this.order = 0, this.testFn = xb;
  }
  return e.prototype.setStructure = function(t) {
    this.a.structure = t, this.b.structure = t;
  }, e.prototype.setTestFn = function(t) {
    this.testFn = t || xb;
  }, e.prototype.test = function(t, r) {
    return !!this.testFn(t) || !!r && (this.swap(), this.testFn(t));
  }, e.prototype.swap = function() {
    var t = this.aIndex;
    this.aIndex = this.bIndex, this.bIndex = t;
    var r = this.a.unit;
    this.a.unit = this.b.unit, this.b.unit = r;
    var n = this.a.element;
    this.a.element = this.b.element, this.b.element = n;
  }, Object.defineProperty(e.prototype, "length", { get: function() {
    return at.distance(this.a, this.b);
  }, enumerable: !1, configurable: !0 }), e;
}();
(function(e) {
  e.run = function(t, r, n) {
    return t(new ff(r, n));
  };
})(DA || (DA = {}));
var Ky = function() {
  function e(t) {
    this.source = t, this.set = p_(tt.hashCode, tt.areUnitIdsAndIndicesEqual), this.structures = [], this.allSingletons = !0;
  }
  return e.prototype.add = function(t) {
    t.elementCount && (t.elementCount !== 1 && (this.allSingletons = !1), this.set.add(t) && (this.structures[this.structures.length] = t));
  }, e.prototype.getSelection = function() {
    return this.allSingletons ? vt.Singletons(this.source, T2(this.source, this.structures)) : vt.Sequence(this.source, this.structures);
  }, e;
}(), DX = function() {
  function e(t) {
    this.source = t, this.builders = [], this.builderMap = /* @__PURE__ */ new Map();
  }
  return e.prototype.add = function(t, r, n) {
    var i = this.builderMap.get(t);
    i || (i = this.source.subsetBuilder(!0), this.builders[this.builders.length] = i, this.builderMap.set(t, i)), i.addToUnit(r, n);
  }, e.prototype.allSingletons = function() {
    for (var t = 0, r = this.builders.length; t < r; t++) if (this.builders[t].elementCount > 1) return !1;
    return !0;
  }, e.prototype.singletonSelection = function() {
    for (var t = this.source.subsetBuilder(!0), r = at.create(this.source), n = 0, i = this.builders.length; n < i; n++) this.builders[n].setSingletonLocation(r), t.addToUnit(r.unit.id, r.element);
    return vt.Singletons(this.source, t.getStructure());
  }, e.prototype.fullSelection = function() {
    for (var t = new Array(this.builders.length), r = 0, n = this.builders.length; r < n; r++) t[r] = this.builders[r].getStructure();
    return vt.Sequence(this.source, t);
  }, e.prototype.getSelection = function() {
    return this.builders.length === 0 ? vt.Empty(this.source) : this.allSingletons() ? this.singletonSelection() : this.fullSelection();
  }, e;
}(), Ab = function(e) {
  return vt.Sequence(e.inputStructure, []);
}, oT = function(e) {
  return vt.Singletons(e.inputStructure, e.inputStructure);
};
function dl(e) {
  return !0;
}
function IX(e) {
  return 0;
}
function Xy(e) {
  if (!(e && (e.atomTest || e.residueTest || e.chainTest || e.entityTest || e.unitTest || e.groupBy))) return oT;
  if (e.atomTest && !e.residueTest && !e.chainTest && !e.entityTest && !e.unitTest && !e.groupBy) return t = e.atomTest, function(n) {
    var i = n.inputStructure, a = i.units, o = n.pushCurrentElement(), u = i.subsetBuilder(!0);
    o.structure = i;
    for (var s = 0, c = a; s < c.length; s++) {
      var l = c[s];
      o.unit = l;
      var d = l.elements;
      u.beginUnit(l.id);
      for (var f = 0, m = d.length; f < m; f++) o.element = d[f], t(n) && u.addElement(o.element);
      u.commitUnit(), n.throwIfTimedOut();
    }
    return n.popCurrentElement(), vt.Singletons(i, u.getStructure());
  };
  var t, r = { unitTest: e.unitTest || dl, entityTest: e.entityTest || dl, chainTest: e.chainTest || dl, residueTest: e.residueTest || dl, atomTest: e.atomTest || dl, groupBy: e.groupBy || IX };
  return e.groupBy ? function(n) {
    var i = n.unitTest, a = n.entityTest, o = n.chainTest, u = n.residueTest, s = n.atomTest, c = n.groupBy;
    return function(l) {
      var d = l.inputStructure, f = d.units, m = l.pushCurrentElement(), v = new DX(d);
      m.structure = d;
      for (var p = 0, g = f; p < g.length; p++) {
        var h = g[p];
        if (m.unit = h, i(l)) {
          var y = h.elements, x = h.model;
          if (h.kind === 0) for (var A = Zt.transientSegments(x.atomicHierarchy.chainAtomSegments, y), b = Zt.transientSegments(x.atomicHierarchy.residueAtomSegments, y); A.hasNext; ) {
            var _ = A.move();
            if (m.element = y[_.start], a(l) && o(l)) for (b.setSegment(_); b.hasNext; ) {
              var S = b.move();
              if (m.element = y[S.start], u(l)) for (var D = S.start, I = S.end; D < I; D++) m.element = y[D], s(l) && v.add(c(l), h.id, m.element);
            }
          }
          else {
            var M = x.coarseHierarchy.spheres.chainElementSegments;
            for (A = Zt.transientSegments(M, y); A.hasNext; )
              if (_ = A.move(), m.element = y[_.start], a(l) && o(l)) for (D = _.start, I = _.end; D < I; D++) m.element = y[D], u(l) && v.add(c(l), h.id, m.element);
          }
          l.throwIfTimedOut();
        }
      }
      return l.popCurrentElement(), v.getSelection();
    };
  }(r) : function(n) {
    var i = n.unitTest, a = n.entityTest, o = n.chainTest, u = n.residueTest, s = n.atomTest;
    return function(c) {
      var l = c.inputStructure, d = l.units, f = c.pushCurrentElement(), m = l.subsetBuilder(!0), v = u === dl && s === dl, p = s === dl;
      f.structure = l;
      for (var g = 0, h = d; g < h.length; g++) {
        var y = h[g];
        if (f.unit = y, i(c)) {
          var x = y.elements, A = y.model;
          if (m.beginUnit(y.id), y.kind === 0) for (var b = Zt.transientSegments(y.model.atomicHierarchy.chainAtomSegments, x), _ = Zt.transientSegments(y.model.atomicHierarchy.residueAtomSegments, x); b.hasNext; ) {
            var S = b.move();
            if (f.element = x[S.start], a(c) && o(c)) if (v) m.addElementRange(x, S.start, S.end);
            else for (_.setSegment(S); _.hasNext; ) {
              var D = _.move();
              if (f.element = x[D.start], u(c)) if (p) m.addElementRange(x, D.start, D.end);
              else for (var I = D.start, M = D.end; I < M; I++) f.element = x[I], s(c) && m.addElement(f.element);
            }
          }
          else {
            var F = A.coarseHierarchy.spheres.chainElementSegments;
            for (b = Zt.transientSegments(F, x); b.hasNext; )
              if (S = b.move(), f.element = x[S.start], a(c) && o(c)) if (v) m.addElementRange(x, S.start, S.end);
              else for (I = S.start, M = S.end; I < M; I++) f.element = x[I], u(c) && m.addElement(f.element);
          }
          m.commitUnit(), c.throwIfTimedOut();
        }
      }
      return c.popCurrentElement(), vt.Singletons(l, m.getStructure());
    };
  }(r);
}
function jy(e, t, r) {
  for (var n = new Int32Array(t.length), i = 0, a = t.length; i < a; i++) n[i] = e.elements[t[i]];
  return tt.create([e.getChild(qe.ofSortedArray(n))], { parent: r });
}
var ct, Pi, EX = Object.freeze({ __proto__: null, all: oT, atoms: Xy, bondedAtomicPairs: function(e) {
  return function(t) {
    var r = t.inputStructure, n = r.interUnitBonds, i = vt.UniqueBuilder(t.inputStructure);
    t.pushCurrentBond();
    var a = t.atomicBond;
    a.setTestFn(e), a.setStructure(r);
    for (var o = 0, u = r.units; o < u.length; o++) {
      var s = u[o];
      if (s.kind === 0) {
        var c = s.bonds, l = c.offset, d = c.b, f = c.edgeProps, m = f.flags, v = f.order;
        a.a.unit = s, a.b.unit = s;
        for (var p = 0, g = s.elements.length; p < g; p++) {
          a.aIndex = p, a.a.element = s.elements[p];
          for (var h = l[p], y = l[p + 1]; h < y; h++)
            a.bIndex = d[h], a.b.element = s.elements[d[h]], a.type = m[h], a.order = v[h], a.test(t, !1) && ((b = r.subsetBuilder(!1)).beginUnit(s.id), b.addElement(a.a.element), b.addElement(a.b.element), b.commitUnit(), i.add(b.getStructure()));
        }
      }
    }
    for (var x = 0, A = n.edges; x < A.length; x++) {
      var b, _ = A[x];
      a.a.unit = r.unitMap.get(_.unitA), a.a.element = a.a.unit.elements[_.indexA], a.aIndex = _.indexA, a.b.unit = r.unitMap.get(_.unitA), a.b.element = a.b.unit.elements[_.indexB], a.bIndex = _.indexB, a.order = _.props.order, a.type = _.props.flag, a.test(t, !1) && ((b = r.subsetBuilder(!1)).addToUnit(a.a.unit.id, a.a.element), b.addToUnit(a.b.unit.id, a.b.element), i.add(b.getStructure()));
    }
    return t.popCurrentBond(), i.getSelection();
  };
}, chains: function(e) {
  return Xy(R(R({}, e), { groupBy: function(t) {
    return Qe.chain.key(t.element);
  } }));
}, none: Ab, querySelection: function(e, t, r) {
  return r === void 0 && (r = !1), function(n) {
    var i = e(n);
    if (vt.structureCount(i) === 0) return i;
    var a = r ? nT(n.inputStructure, vt.unionStructure(i)) : vt.unionStructure(i);
    if (a.elementCount === 0) return vt.Empty(n.inputStructure);
    n.throwIfTimedOut(), n.pushInputStructure(a);
    var o = t(n);
    return n.popInputStructure(), vt.withInputStructure(o, n.inputStructure);
  };
}, residues: function(e) {
  return Xy(R(R({}, e), { groupBy: function(t) {
    return Qe.residue.key(t.element);
  } }));
}, rings: function(e, t) {
  return function(r) {
    var n = r.inputStructure.units, i = vt.LinearBuilder(r.inputStructure);
    if (e && e.length !== 0) {
      for (var a = cn.create(), o = 0; o < e.length; o++) cn.add(a, e[o], e[o]);
      for (var u = 0, s = n; u < s.length; u++)
        if (h = s[u], Be.isAtomic(h)) for (var c = h.rings, l = 0, d = a.array; l < d.length; l++) {
          var f = d[l];
          if (c.byFingerprint.has(f)) for (var m = 0, v = c.byFingerprint.get(f); m < v.length; m++)
            A = v[m], t && !c.aromaticRings.includes(A) || i.add(jy(h, c.all[A], r.inputStructure));
        }
    } else for (var p = 0, g = n; p < g.length; p++) {
      var h = g[p];
      if (Be.isAtomic(h)) if (t) for (var y = 0, x = h.rings.aromaticRings; y < x.length; y++) {
        var A = x[y];
        i.add(jy(h, h.rings.all[A], r.inputStructure));
      }
      else for (var b = 0, _ = h.rings.all; b < _.length; b++) {
        var A = _[b];
        i.add(jy(h, A, r.inputStructure));
      }
    }
    return i.getSelection();
  };
} }), wg = function() {
  function e(t) {
    this.parent = t, this.ids = [], this.unitMap = Ps.Mutable(), this.parentId = -1, this.currentUnit = cn.create(), this.elementCount = 0;
  }
  return e.prototype.addToUnit = function(t, r) {
    var n = this.unitMap.get(t);
    if (n) cn.add(n, r, r) && this.elementCount++;
    else {
      var i = cn.create();
      cn.add(i, r, r), this.unitMap.set(t, i), this.ids[this.ids.length] = t, this.elementCount++;
    }
  }, e.prototype.has = function(t, r) {
    var n = this.unitMap.get(t);
    return !!n && cn.has(n, r);
  }, e.prototype.beginUnit = function(t) {
    this.parentId = t, this.unitMap.has(t) ? this.currentUnit = this.unitMap.get(t) : this.currentUnit = this.currentUnit.array.length > 0 ? cn.create() : this.currentUnit;
  }, e.prototype.addElement = function(t) {
    cn.add(this.currentUnit, t, t) && this.elementCount++;
  }, e.prototype.commitUnit = function() {
    this.currentUnit.array.length === 0 || this.unitMap.has(this.parentId) || (this.ids[this.ids.length] = this.parentId, this.unitMap.set(this.parentId, this.currentUnit), this.parentId = -1);
  }, e.prototype.getStructure = function() {
    if (this.isEmpty) return tt.Empty;
    var t = [];
    es(this.ids);
    for (var r = W1.UnitEquivalenceBuilder(), n = 0, i = this.ids.length; n < i; n++) {
      var a = this.ids[n], o = this.parent.unitMap.get(a), u = this.unitMap.get(a).array, s = u.length;
      if (u.length !== o.elements.length) {
        s > 1 && es(u);
        var c = o.getChild(qe.ofSortedArray(u)), l = r.add(c.id, c);
        c !== l && (c = l.applyOperator(c.id, c.conformation.operator, !0)), t[t.length] = c;
      } else t[t.length] = o, r.add(o.id, o);
    }
    return tt.create(t, { parent: this.parent });
  }, Object.defineProperty(e.prototype, "isEmpty", { get: function() {
    return this.elementCount === 0;
  }, enumerable: !1, configurable: !0 }), e;
}();
function ot(e) {
  return { data: e, position: 0, length: e.length, lineNumber: 1, tokenStart: 0, tokenEnd: 0 };
}
function EA(e) {
  for (; e.position < e.length; ) switch (e.data.charCodeAt(e.position)) {
    case 9:
    case 10:
    case 13:
    case 32:
      return void (e.tokenEnd = e.position);
    default:
      ++e.position;
  }
  e.tokenEnd = e.position;
}
function MA(e) {
  return !(e.length - e.position < 2) && e.data.charCodeAt(e.position + 1) === 39 && e.data.charCodeAt(e.position + 2) === 39;
}
function MX(e, t, r) {
  var n, i = r - t, a = e.tokenStart - t, o = e.tokenEnd - e.tokenStart;
  if (o < i) return !1;
  for (n = t; n < r; ++n) if (e.data.charCodeAt(n) !== e.data.charCodeAt(n + a)) return !1;
  return i === o || e.data.charCodeAt(n + a) === 46;
}
function uT(e) {
  var t;
  for (t = e.tokenStart; t < e.tokenEnd; ++t) if (e.data.charCodeAt(t) === 46) return t;
  return t;
}
function sT(e, t) {
  return e.data.substring(e.tokenStart, t);
}
function Sb(e) {
  return e.data.substring(e.tokenStart, e.tokenEnd);
}
function TA(e) {
  var t = function(n) {
    for (var i = 10; n.position < n.length; ) {
      var a = n.data.charCodeAt(n.position);
      switch (a) {
        case 9:
        case 32:
          i = a, ++n.position;
          break;
        case 10:
          i !== 13 && ++n.lineNumber, i = a, ++n.position;
          break;
        case 13:
          i = a, ++n.position, ++n.lineNumber;
          break;
        default:
          return i;
      }
    }
    return i;
  }(e);
  if (e.position >= e.length) e.tokenType = 6;
  else {
    e.tokenStart = e.position, e.tokenEnd = e.position, e.isEscaped = !1;
    var r = e.data.charCodeAt(e.position);
    switch (r) {
      case 35:
        (function(n) {
          for (; n.position < n.length; ) {
            var i = n.data.charCodeAt(n.position);
            if (i === 10 || i === 13) return;
            ++n.position;
          }
        })(e), e.tokenType = 5;
        break;
      case 39:
        if (MA(e)) {
          (function(n) {
            for (n.position += 3; n.position < n.length; ) {
              if (n.data.charCodeAt(n.position) === 39 && MA(n)) return n.tokenStart += 3, n.tokenEnd = n.position, n.isEscaped = !0, void (n.position += 3);
              ++n.position;
            }
            n.tokenEnd = n.position;
          })(e), e.tokenType = 3;
          break;
        }
      case 34:
        (function(n, i) {
          var a, o;
          for (++n.position; n.position < n.length; ) if ((o = n.data.charCodeAt(n.position)) === i) switch (a = n.data.charCodeAt(n.position + 1)) {
            case 9:
            case 10:
            case 13:
            case 32:
              return n.tokenStart++, n.tokenEnd = n.position, n.isEscaped = !0, void ++n.position;
            default:
              if (a === void 0) return n.tokenStart++, n.tokenEnd = n.position, n.isEscaped = !0, void ++n.position;
              ++n.position;
          }
          else {
            if (o === 10 || o === 13) return void (n.tokenEnd = n.position);
            ++n.position;
          }
          n.tokenEnd = n.position;
        })(e, r), e.tokenType = 3;
        break;
      case 59:
        t === 10 || t === 13 ? function(n) {
          for (var i, a = 59, o = n.position + 1; o < n.length; ) {
            if ((i = n.data.charCodeAt(o)) === 59 && (a === 10 || a === 13)) {
              for (n.position = o + 1, n.tokenStart++, o--, i = n.data.charCodeAt(o); i === 10 || i === 13; ) o--, i = n.data.charCodeAt(o);
              return n.tokenEnd = o + 1, void (n.isEscaped = !0);
            }
            (i === 13 || i === 10 && a !== 13) && n.lineNumber++, a = i, ++o;
          }
          n.position = o;
        }(e) : EA(e), e.tokenType = 3;
        break;
      default:
        e.isImportGet ? function(n) {
          for (; n.position < n.length; ) {
            if (n.data.charCodeAt(n.position) === 93) return ++n.position, n.tokenEnd = n.position, void (n.isImportGet = !1);
            ++n.position;
          }
        }(e) : EA(e), e.isEscaped ? e.tokenType = 3 : e.data.charCodeAt(e.tokenStart) === 95 ? (e.inSaveFrame && function(n) {
          return n.tokenEnd - n.tokenStart == 11 && n.data.charCodeAt(n.tokenStart + 1) === 105 && n.data.charCodeAt(n.tokenStart + 2) === 109 && n.data.charCodeAt(n.tokenStart + 3) === 112 && n.data.charCodeAt(n.tokenStart + 4) === 111 && n.data.charCodeAt(n.tokenStart + 5) === 114 && n.data.charCodeAt(n.tokenStart + 6) === 116 && n.data.charCodeAt(n.tokenStart + 7) === 46 && n.data.charCodeAt(n.tokenStart + 8) === 103 && n.data.charCodeAt(n.tokenStart + 9) === 101 && n.data.charCodeAt(n.tokenStart + 10) === 116;
        }(e) && (e.isImportGet = !0), e.tokenType = 4) : e.tokenEnd - e.tokenStart >= 5 && e.data.charCodeAt(e.tokenStart + 4) === 95 ? function(n) {
          var i = n.data.charCodeAt(n.tokenStart);
          return !(i !== 68 && i !== 100 || (i = n.data.charCodeAt(n.tokenStart + 1)) !== 65 && i !== 97 || (i = n.data.charCodeAt(n.tokenStart + 2)) !== 84 && i !== 116 || (i = n.data.charCodeAt(n.tokenStart + 3)) !== 65 && i !== 97);
        }(e) ? e.tokenType = 0 : function(n) {
          var i = n.data.charCodeAt(n.tokenStart);
          return !(i !== 83 && i !== 115 || (i = n.data.charCodeAt(n.tokenStart + 1)) !== 65 && i !== 97 || (i = n.data.charCodeAt(n.tokenStart + 2)) !== 86 && i !== 118 || (i = n.data.charCodeAt(n.tokenStart + 3)) !== 69 && i !== 101);
        }(e) ? e.tokenType = 1 : function(n) {
          if (n.tokenEnd - n.tokenStart != 5) return !1;
          var i = n.data.charCodeAt(n.tokenStart);
          return !(i !== 76 && i !== 108 || (i = n.data.charCodeAt(n.tokenStart + 1)) !== 79 && i !== 111 || (i = n.data.charCodeAt(n.tokenStart + 2)) !== 79 && i !== 111 || (i = n.data.charCodeAt(n.tokenStart + 3)) !== 80 && i !== 112);
        }(e) ? e.tokenType = 2 : e.tokenType = 3 : e.tokenType = 3;
    }
  }
}
function Pl(e) {
  for (TA(e); e.tokenType === 5; ) TA(e);
}
function Xh() {
  return { categoryNames: [], categoryData: /* @__PURE__ */ Object.create(null) };
}
function Cb(e, t) {
  for (var r = /* @__PURE__ */ Object.create(null), n = 0, i = e; n < i.length; n++) {
    var a = i[n], o = t[a];
    r[a] = va(o.name, o.rowCount, o.fieldNames, o.fields);
  }
  return r;
}
function PA(e, t, r) {
  return f_(e.categoryNames, Cb(e.categoryNames, e.categoryData), t, r);
}
function wb(e, t, r, n, i) {
  var a;
  if (t in e.categoryData) {
    var o = e.categoryData[t];
    (a = o.fieldNames).push.apply(a, n), Object.assign(o.fields, i);
  } else e.categoryData[t] = { name: t, rowCount: r, fieldNames: n, fields: i }, e.categoryNames.push(t);
}
function TX(e, t) {
  for (var r = t.tokenizer, n = t.tokens, i = t.fieldCount, a = t.tokenCount, o = 0; r.tokenType === 3 && o < e; ) ct.add(n[a++ % i], r.tokenStart, r.tokenEnd), Pl(r), o++;
  return t.tokenCount = a, o;
}
function PX(e, t) {
  return e.update({ message: "Parsing...", current: t.tokenizer.position, max: t.tokenizer.data.length });
}
function BX(e, t) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o, u, s, c, l, d, f;
    return ye(this, function(m) {
      switch (m.label) {
        case 0:
          for (r = e.lineNumber, Pl(e), n = sT(e, uT(e)), i = function(v) {
            var p;
            for (p = v.tokenStart; p < v.tokenEnd; ++p) if (v.data.charCodeAt(p) === 46) return !1;
            return !0;
          }(e), a = []; e.tokenType === 4; ) a[a.length] = i ? Sb(e) : Sb(e).substring(n.length + 1), Pl(e);
          for (o = n === "_atom_site" ? e.data.length / 100 | 0 : 32, u = [], s = a.length, f = 0; f < s; f++) u[f] = ct.create(e.data, o);
          return c = { fieldCount: s, tokenCount: 0, tokenizer: e, tokens: u }, [4, $p(e.runtimeCtx, 1e6, c, TX, PX)];
        case 1:
          if (m.sent(), c.tokenCount % s != 0) return [2, { hasError: !0, errorLine: e.lineNumber, errorMessage: "The number of values for loop starting at line ".concat(r, " is not a multiple of the number of columns.") }];
          if (l = c.tokenCount / s | 0, i) for (f = 0; f < s; f++) d = { "": st.ofTokens(u[f]) }, wb(t, a[f].substr(1), l, [""], d);
          else {
            for (d = /* @__PURE__ */ Object.create(null), f = 0; f < s; f++) d[a[f]] = st.ofTokens(u[f]);
            wb(t, n.substr(1), l, a, d);
          }
          return [2, { hasError: !1, errorLine: 0, errorMessage: "" }];
      }
    });
  });
}
function Qf(e, t) {
  return Pi.error(t, e);
}
function FX(e) {
  return Pi.success(e);
}
function NX(e, t) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o, u, s, c, l, d;
    return ye(this, function(f) {
      switch (f.label) {
        case 0:
          r = [], n = function(p, g) {
            return { data: p, length: p.length, position: 0, tokenStart: 0, tokenEnd: 0, tokenType: 6, lineNumber: 1, isEscaped: !1, isImportGet: !1, inSaveFrame: !1, runtimeCtx: g };
          }(e, t), i = "", a = Xh(), o = [], u = Xh(), m = u.categoryNames, v = Cb(u.categoryNames, u.categoryData), s = { categoryNames: m, header: "", categories: v }, c = "", t.update({ message: "Parsing...", current: 0, max: e.length }), Pl(n), f.label = 1;
        case 1:
          return n.tokenType === 6 ? [3, 7] : (l = n.tokenType) !== 0 ? [3, 2] : n.inSaveFrame ? [2, Qf(n.lineNumber, "Unexpected data block inside a save frame.")] : (a.categoryNames.length > 0 && r.push(PA(a, i, o)), i = e.substring(n.tokenStart + 5, n.tokenEnd), a = Xh(), o = [], Pl(n), [3, 6]);
        case 2:
          if (l !== 1) return [3, 3];
          if (n.tokenEnd - n.tokenStart == 5) u.categoryNames.length > 0 && (o[o.length] = function(p, g) {
            return f_(p.categoryNames, Cb(p.categoryNames, p.categoryData), g);
          }(u, c)), n.inSaveFrame = !1;
          else {
            if (n.inSaveFrame) return [2, Qf(n.lineNumber, "Save frames cannot be nested.")];
            n.inSaveFrame = !0, c = e.substring(n.tokenStart + 5, n.tokenEnd), u = Xh();
          }
          return Pl(n), [3, 6];
        case 3:
          return l !== 2 ? [3, 5] : [4, BX(n, n.inSaveFrame ? u : a)];
        case 4:
          return (d = f.sent()).hasError ? [2, Qf(d.errorLine, d.errorMessage)] : [3, 6];
        case 5:
          if (l !== 4) return console.log(n.tokenType, ot.getTokenString(n)), [2, Qf(n.lineNumber, "Unexpected token. Expected data_, loop_, or data name.")];
          if (d = function(p, g) {
            for (var h = p.tokenStart, y = uT(p), x = sT(p, y), A = /* @__PURE__ */ Object.create(null), b = [], _ = !0; _; ) {
              if (p.tokenType !== 4 || !MX(p, h, y)) {
                _ = !1;
                break;
              }
              var S = Sb(p).substring(x.length + 1);
              if (Pl(p), p.tokenType !== 3) return { hasError: !0, errorLine: p.lineNumber, errorMessage: "Expected value." };
              A[S] = st.ofTokens({ data: p.data, indices: [p.tokenStart, p.tokenEnd], count: 1 }), b[b.length] = S, Pl(p);
            }
            return wb(g, x.substr(1), 1, b, A), { hasError: !1, errorLine: 0, errorMessage: "" };
          }(n, n.inSaveFrame ? u : a), d.hasError) return [2, Qf(d.errorLine, d.errorMessage)];
          f.label = 6;
        case 6:
          return [3, 1];
        case 7:
          return n.inSaveFrame ? [2, Qf(n.lineNumber, "Unfinished save frame (".concat(s.header, ")."))] : ((a.categoryNames.length > 0 || o.length > 0) && r.push(PA(a, i, o)), [2, FX(wM(r))]);
      }
      var m, v;
    });
  });
}
function RX(e) {
  var t = this;
  return er.create("Parse CIF", function(r) {
    return _e(t, 0, void 0, function() {
      return ye(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, NX(e, r)];
          case 1:
            return [2, n.sent()];
        }
      });
    });
  });
}
function Yy(e, t) {
  for (var r = {}, n = 0; n < t; n++)
    r[P2(e)] = P2(e);
  return r;
}
function Wy(e, t) {
  for (var r = new Uint8Array(t), n = e.offset, i = 0; i < t; i++) r[i] = e.buffer[i + n];
  return e.offset += t, r;
}
function jh(e, t) {
  var r = dM(e.buffer, e.offset, t);
  return e.offset += t, r;
}
function Zy(e, t) {
  for (var r = new Array(t), n = 0; n < t; n++) r[n] = P2(e);
  return r;
}
function P2(e) {
  var t, r, n = e.buffer[e.offset];
  if (!(128 & n)) return e.offset++, n;
  if ((240 & n) == 128) return r = 15 & n, e.offset++, Yy(e, r);
  if ((240 & n) == 144) return r = 15 & n, e.offset++, Zy(e, r);
  if ((224 & n) == 160) return r = 31 & n, e.offset++, jh(e, r);
  if (!(224 & ~n)) return t = e.dataView.getInt8(e.offset), e.offset++, t;
  switch (n) {
    case 192:
      return e.offset++, null;
    case 194:
      return e.offset++, !1;
    case 195:
      return e.offset++, !0;
    case 196:
      return r = e.dataView.getUint8(e.offset + 1), e.offset += 2, Wy(e, r);
    case 197:
      return r = e.dataView.getUint16(e.offset + 1), e.offset += 3, Wy(e, r);
    case 198:
      return r = e.dataView.getUint32(e.offset + 1), e.offset += 5, Wy(e, r);
    case 202:
      return t = e.dataView.getFloat32(e.offset + 1), e.offset += 5, t;
    case 203:
      return t = e.dataView.getFloat64(e.offset + 1), e.offset += 9, t;
    case 204:
      return t = e.buffer[e.offset + 1], e.offset += 2, t;
    case 205:
      return t = e.dataView.getUint16(e.offset + 1), e.offset += 3, t;
    case 206:
      return t = e.dataView.getUint32(e.offset + 1), e.offset += 5, t;
    case 208:
      return t = e.dataView.getInt8(e.offset + 1), e.offset += 2, t;
    case 209:
      return t = e.dataView.getInt16(e.offset + 1), e.offset += 3, t;
    case 210:
      return t = e.dataView.getInt32(e.offset + 1), e.offset += 5, t;
    case 217:
      return r = e.dataView.getUint8(e.offset + 1), e.offset += 2, jh(e, r);
    case 218:
      return r = e.dataView.getUint16(e.offset + 1), e.offset += 3, jh(e, r);
    case 219:
      return r = e.dataView.getUint32(e.offset + 1), e.offset += 5, jh(e, r);
    case 220:
      return r = e.dataView.getUint16(e.offset + 1), e.offset += 3, Zy(e, r);
    case 221:
      return r = e.dataView.getUint32(e.offset + 1), e.offset += 5, Zy(e, r);
    case 222:
      return r = e.dataView.getUint16(e.offset + 1), e.offset += 3, Yy(e, r);
    case 223:
      return r = e.dataView.getUint32(e.offset + 1), e.offset += 5, Yy(e, r);
  }
  throw new Error("Unknown type 0x" + n.toString(16));
}
function OX(e) {
  for (var t = /* @__PURE__ */ Object.create(null), r = /* @__PURE__ */ Object.create(null), n = 0, i = e.columns; n < i.length; n++) {
    var a = i[n];
    t[a.name] = a;
  }
  return { rowCount: e.rowCount, name: e.name.substr(1), fieldNames: e.columns.map(function(o) {
    return o.name;
  }), getField: function(o) {
    var u = t[o];
    if (u) return r[o] || (r[o] = function(s) {
      var c = s.mask ? D2(s.mask) : void 0, l = D2(s.data), d = r_(l), f = d ? c ? function(h) {
        return c[h] === 0 ? "" + l[h] : "";
      } : function(h) {
        return "" + l[h];
      } : c ? function(h) {
        return c[h] === 0 ? l[h] : "";
      } : function(h) {
        return l[h];
      }, m = d ? function(h) {
        return l[h];
      } : function(h) {
        var y = l[h];
        return Yl(y, 0, y.length);
      }, v = d ? function(h) {
        return l[h];
      } : function(h) {
        var y = l[h];
        return ef(y, 0, y.length);
      }, p = c ? function(h) {
        return c[h];
      } : function(h) {
        return 0;
      }, g = l.length;
      return { __array: l, binaryEncoding: s.data.encoding, isDefined: !0, rowCount: g, str: f, int: m, float: v, valueKind: p, areValuesEqual: function(h, y) {
        return l[h] === l[y];
      }, toStringArray: function(h) {
        return $i(g, f, h);
      }, toIntArray: d ? function(h) {
        return m2(l, h);
      } : function(h) {
        return $i(g, m, h);
      }, toFloatArray: d ? function(h) {
        return m2(l, h);
      } : function(h) {
        return $i(g, v, h);
      } };
    }(u)), r[o];
  } };
}
function LX(e) {
  var t = this;
  return er.create("Parse BinaryCIF", function(r) {
    return _e(t, 0, void 0, function() {
      var n, i, a;
      return ye(this, function(o) {
        n = [0, 3];
        try {
          return i = P2({ buffer: u = e, offset: 0, dataView: new DataView(u.buffer) }), function(s, c) {
            for (var l = 0; l < 2; l++) if (s[l] > c[l]) return !1;
            return !0;
          }(n, i.version.match(/(\d)\.(\d)\.\d/).slice(1).map(function(s) {
            return +s;
          })) ? (a = wM(i.dataBlocks.map(function(s) {
            for (var c = /* @__PURE__ */ Object.create(null), l = 0, d = s.categories; l < d.length; l++) {
              var f = d[l];
              c[f.name.substr(1)] = OX(f);
            }
            return f_(s.categories.map(function(m) {
              return m.name.substr(1);
            }), c, s.header);
          })), [2, Pi.success(a)]) : [2, Pi.error("Unsupported format version. Current ".concat(i.version, ", required ").concat(n.join("."), "."))];
        } catch (s) {
          return [2, Pi.error("" + s)];
        }
        var u;
        return [2];
      });
    });
  });
}
(function(e) {
  function t(o) {
    return o.data.substring(o.tokenStart, o.tokenEnd);
  }
  function r(o) {
    for (var u = o.data; o.position < o.length; ) switch (u.charCodeAt(o.position)) {
      case 10:
        return o.tokenEnd = o.position, ++o.position, ++o.lineNumber, !0;
      case 13:
        return o.tokenEnd = o.position, ++o.position, ++o.lineNumber, u.charCodeAt(o.position) === 10 && ++o.position, !0;
      default:
        ++o.position;
    }
    return o.tokenEnd = o.position, o.tokenStart !== o.tokenEnd;
  }
  function n(o) {
    return o.tokenStart = o.position, r(o);
  }
  function i(o, u, s) {
    for (var c = 0, l = 0; l < u; l++) {
      if (!n(o)) return c;
      ct.addUnchecked(s, o.tokenStart, o.tokenEnd), c++;
    }
    return c;
  }
  function a(o, u, s) {
    for (var c = o.data, l = u, d = s - 1, f = c.charCodeAt(l); (f === 9 || f === 32) && l <= d; ) f = c.charCodeAt(++l);
    for (f = c.charCodeAt(d); (f === 9 || f === 32) && d >= l; ) f = c.charCodeAt(--d);
    return o.tokenStart = l, o.tokenEnd = d + 1, o.position = s, o;
  }
  e.getTokenString = t, e.reset = function(o) {
    o.position = 0, o.lineNumber = 1, o.tokenStart = 0, o.tokenEnd = 0;
  }, e.eatLine = r, e.markStart = function(o) {
    o.tokenStart = o.position;
  }, e.markLine = n, e.readLine = function(o) {
    return n(o), t(o);
  }, e.readLineTrim = function(o) {
    n(o);
    var u = o.position;
    return a(o, o.tokenStart, o.tokenEnd), o.position = u, t(o);
  }, e.markLines = function(o, u) {
    var s = ct.create(o.data, 2 * u);
    return i(o, u, s), s;
  }, e.readLines = function(o, u) {
    for (var s = [], c = 0; c < u; c++) s.push(e.readLine(o));
    return s;
  }, e.readLinesAsync = function(o, u, s, c) {
    return c === void 0 && (c = 1e5), _e(this, 0, void 0, function() {
      var l, d, f;
      return ye(this, function(m) {
        switch (m.label) {
          case 0:
            return l = o.length, d = ct.create(o.data, 2 * u), f = 0, [4, $p(s, c, o, function(v, p) {
              var g = Math.min(u - f, v);
              return i(p, g, d), f += g, g;
            }, function(v, p) {
              return v.update({ message: "Parsing...", current: p.position, max: l });
            })];
          case 1:
            return m.sent(), [2, d];
        }
      });
    });
  }, e.readAllLines = function(o) {
    for (var u = e(o), s = ct.create(u.data, Math.max(o.length / 80, 2)); n(u); ) ct.add(s, u.tokenStart, u.tokenEnd);
    return s;
  }, e.readAllLinesAsync = function(o, u, s) {
    return s === void 0 && (s = 1e5), _e(this, 0, void 0, function() {
      var c, l;
      return ye(this, function(d) {
        switch (d.label) {
          case 0:
            return c = e(o), l = ct.create(c.data, Math.max(o.length / 80, 2)), [4, $p(u, s, c, function(f, m) {
              return function(v, p, g) {
                for (var h = 0, y = 0; y < p; y++) {
                  if (!n(v)) return h;
                  ct.add(g, v.tokenStart, v.tokenEnd), h++;
                }
              }(m, f, l), m.position < m.length ? f : 0;
            }, function(f, m) {
              return f.update({ message: "Parsing...", current: m.position, max: length });
            })];
          case 1:
            return d.sent(), [2, l];
        }
      });
    });
  }, e.eatValue = function(o) {
    for (; o.position < o.length; ) switch (o.data.charCodeAt(o.position)) {
      case 9:
      case 10:
      case 13:
      case 32:
        return void (o.tokenEnd = o.position);
      default:
        ++o.position;
    }
    o.tokenEnd = o.position;
  }, e.skipWhitespace = function(o) {
    for (var u = -1; o.position < o.length; ) {
      var s = o.data.charCodeAt(o.position);
      switch (s) {
        case 9:
        case 32:
          u = s, ++o.position;
          break;
        case 10:
          u !== 13 && ++o.lineNumber, u = s, ++o.position;
          break;
        case 13:
          u = s, ++o.position, ++o.lineNumber;
          break;
        default:
          return u;
      }
    }
    return u;
  }, e.trim = a;
})(ot || (ot = {})), function(e) {
  function t(r, n, i) {
    var a = r;
    a.offset > a.indicesLenMinus2 && function(o) {
      var u = new Uint32Array(1.61 * o.indices.length | 0);
      u.set(o.indices), o.indices = u, o.indicesLenMinus2 = u.length - 2 | 0;
    }(a), a.indices[a.offset++] = n, a.indices[a.offset++] = i, r.count++;
  }
  e.add = t, e.addToken = function(r, n) {
    t(r, n.tokenStart, n.tokenEnd);
  }, e.addUnchecked = function(r, n, i) {
    r.indices[r.offset++] = n, r.indices[r.offset++] = i, r.count++;
  }, e.create = function(r, n) {
    return { data: r, indicesLenMinus2: (n = Math.max(10, n)) - 2 | 0, count: 0, offset: 0, indices: new Uint32Array(n) };
  };
}(ct || (ct = {})), function(e) {
  e.error = function(n, i) {
    return i === void 0 && (i = -1), new t(n, i);
  }, e.success = function(n, i) {
    return i === void 0 && (i = []), new r(n, i);
  };
  var t = function() {
    function n(i, a) {
      this.message = i, this.line = a, this.isError = !0;
    }
    return n.prototype.toString = function() {
      return this.line >= 0 ? "[Line ".concat(this.line, "] ").concat(this.message) : this.message;
    }, n;
  }();
  e.Error = t;
  var r = function(n, i) {
    this.result = n, this.warnings = i, this.isError = !1;
  };
  e.Success = r;
}(Pi || (Pi = {}));
var b0 = oe.Schema, xr = b0.str, kX = b0.float, BA = b0.List, No = b0.Aliased, Y0 = b0.int, Jf = b0.coord, zX = { chem_comp: { formula: xr, formula_weight: kX, id: xr, mon_nstd_parent_comp_id: BA(",", function(e) {
  return e;
}), name: xr, one_letter_code: xr, three_letter_code: xr, type: No(xr), pdbx_synonyms: BA(";", function(e) {
  return e;
}), pdbx_type: xr, pdbx_ambiguous_flag: xr, pdbx_replaced_by: xr, pdbx_replaces: xr, pdbx_formal_charge: Y0, pdbx_model_coordinates_details: xr, pdbx_model_coordinates_db_code: xr, pdbx_ideal_coordinates_details: xr, pdbx_ideal_coordinates_missing_flag: No(xr), pdbx_model_coordinates_missing_flag: No(xr), pdbx_initial_date: xr, pdbx_modified_date: xr, pdbx_release_status: No(xr), pdbx_processing_site: No(xr) }, chem_comp_atom: { alt_atom_id: xr, atom_id: xr, charge: Y0, model_Cartn_x: Jf, model_Cartn_y: Jf, model_Cartn_z: Jf, comp_id: xr, type_symbol: xr, pdbx_align: Y0, pdbx_ordinal: Y0, pdbx_model_Cartn_x_ideal: Jf, pdbx_model_Cartn_y_ideal: Jf, pdbx_model_Cartn_z_ideal: Jf, pdbx_stereo_config: No(xr), pdbx_aromatic_flag: No(xr), pdbx_leaving_atom_flag: No(xr) }, chem_comp_bond: { atom_id_1: xr, atom_id_2: xr, comp_id: xr, value_order: No(xr), pdbx_ordinal: Y0, pdbx_stereo_config: No(xr), pdbx_aromatic_flag: No(xr) }, pdbx_chem_comp_descriptor: { comp_id: xr, descriptor: xr, type: No(xr), program: xr, program_version: xr }, pdbx_chem_comp_identifier: { comp_id: xr, identifier: xr, type: No(xr), program: xr, program_version: xr } }, Dg = oe.Schema, Pt = Dg.str, GX = Dg.float, qa = Dg.Aliased, cu = Dg.int, VX = { pdbx_reference_molecule: { prd_id: Pt, formula_weight: GX, formula: Pt, type: qa(Pt), type_evidence_code: Pt, class: qa(Pt), class_evidence_code: Pt, name: Pt, represent_as: qa(Pt), chem_comp_id: Pt, compound_details: Pt, description: Pt, representative_PDB_id_code: Pt, release_status: qa(Pt), replaces: Pt, replaced_by: Pt }, pdbx_reference_entity_list: { prd_id: Pt, ref_entity_id: Pt, type: qa(Pt), details: Pt, component_id: cu }, pdbx_reference_entity_nonpoly: { prd_id: Pt, ref_entity_id: Pt, name: Pt, chem_comp_id: Pt }, pdbx_reference_entity_link: { link_id: cu, prd_id: Pt, details: Pt, ref_entity_id_1: Pt, ref_entity_id_2: Pt, entity_seq_num_1: cu, entity_seq_num_2: cu, comp_id_1: Pt, comp_id_2: Pt, atom_id_1: Pt, atom_id_2: Pt, value_order: qa(Pt), component_1: cu, component_2: cu, link_class: qa(Pt) }, pdbx_reference_entity_poly_link: { link_id: cu, prd_id: Pt, ref_entity_id: Pt, component_id: cu, entity_seq_num_1: cu, entity_seq_num_2: cu, comp_id_1: Pt, comp_id_2: Pt, atom_id_1: Pt, atom_id_2: Pt, value_order: qa(Pt) }, pdbx_reference_entity_poly: { prd_id: Pt, ref_entity_id: Pt, type: qa(Pt), db_code: Pt, db_name: Pt }, pdbx_reference_entity_poly_seq: { prd_id: Pt, ref_entity_id: Pt, mon_id: Pt, parent_mon_id: Pt, num: cu, observed: qa(Pt), hetero: qa(Pt) }, pdbx_reference_entity_sequence: { prd_id: Pt, ref_entity_id: Pt, type: qa(Pt), NRP_flag: qa(Pt), one_letter_codes: Pt }, pdbx_reference_entity_src_nat: { prd_id: Pt, ref_entity_id: Pt, ordinal: cu, organism_scientific: Pt, taxid: Pt, db_code: Pt, db_name: Pt }, pdbx_prd_audit: { prd_id: Pt, date: Pt, processing_site: qa(Pt), action_type: qa(Pt) } }, cT = oe.Schema, oi = cT.str, UX = { datablock: { id: oi, description: oi }, dictionary: { title: oi, datablock_id: oi, version: oi }, dictionary_history: { version: oi, update: oi, revision: oi }, sub_category: { id: oi, description: oi }, category_group_list: { id: oi, parent_id: oi, description: oi }, item_type_list: { code: oi, primitive_code: oi, construct: oi, detail: oi }, item_units_list: { code: oi, detail: oi }, item_units_conversion: { from_code: oi, to_code: oi, operator: oi, factor: cT.float } }, Im = oe.Schema, Dp = Im.str, Yh = Im.int, Js = Im.float, Wh = Im.Aliased, El = Im.Vector;
Wh(Dp), Wh(Dp), Wh(Dp), Wh(Dp), El(3), El(3);
var Db, pf, HX = { volume_data_3d_info: { name: Dp, axis_order: El(3, Yh), origin: El(3), dimensions: El(3), sample_rate: Yh, sample_count: El(3, Yh), spacegroup_number: Yh, spacegroup_cell_size: El(3), spacegroup_cell_angles: El(3), mean_source: Js, mean_sampled: Js, sigma_source: Js, sigma_sampled: Js, min_source: Js, min_sampled: Js, max_source: Js, max_sampled: Js }, volume_data_3d: { values: Js } }, Ig = oe.Schema, Un = Ig.float, Qy = Ig.int, rn = Ig.str, qX = { cell: { angle_alpha: Un, angle_beta: Un, angle_gamma: Un, formula_units_z: Qy, length_a: Un, length_b: Un, length_c: Un, volume: Un }, chemical: { melting_point: Un, name_common: rn, name_systematic: rn }, chemical_formula: { moiety: rn, sum: rn, weight: Un }, space_group: { crystal_system: rn, it_number: Qy, "name_h-m_full": rn }, space_group_symop: { operation_xyz: rn }, geom_bond: { atom_site_label_1: rn, atom_site_label_2: rn, distance: Un, publ_flag: rn, site_symmetry_1: rn, site_symmetry_2: rn, valence: Un }, audit: { block_doi: rn }, database_code: { cod: rn, csd: rn, depnum_ccdc_archive: rn, depnum_ccdc_fiz: rn, icsd: rn, mdf: rn, nbs: rn }, atom_site: { adp_type: rn, calc_flag: rn, disorder_assembly: rn, disorder_group: rn, fract_x: Un, fract_y: Un, fract_z: Un, label: rn, occupancy: Un, refinement_flags: rn, site_symmetry_multiplicity: Qy, type_symbol: rn, u_iso_or_equiv: Un }, atom_site_aniso: { label: rn, u_11: Un, u: (0, Ig.Matrix)(3, 3), u_12: Un, u_13: Un, u_22: Un, u_23: Un, u_33: Un }, atom_type: { description: rn, symbol: rn }, atom_type_scat: { dispersion_imag: Un, dispersion_real: Un, source: rn } }, KX = { "cell.formula_units_z": ["cell_formula_units_Z"], "space_group.it_number": ["space_group_IT_number", "symmetry_Int_Tables_number"], "space_group.name_h-m_full": ["symmetry_space_group_name_H-M"], "space_group_symop.operation_xyz": ["symmetry_equiv_pos_as_xyz"], "geom_bond.atom_site_label_1": ["geom_bond_atom_site_id_1"], "geom_bond.atom_site_label_2": ["geom_bond_atom_site_id_2"], "geom_bond.distance": ["geom_bond_dist"], "audit.block_doi": ["audit_block_DOI"], "database_code.cod": ["database_code_COD"], "database_code.csd": ["database_code_CSD"], "database_code.depnum_ccdc_archive": ["database_code_depnum_CCDC_archive"], "database_code.depnum_ccdc_fiz": ["database_code_depnum_CCDC_fiz"], "database_code.icsd": ["database_code_ICSD"], "database_code.mdf": ["database_code_MDF"], "database_code.nbs": ["database_code_NBS"], "atom_site.adp_type": ["atom_site_ADP_type", "atom_site_thermal_displace_type"], "atom_site.label": ["atom_site_id"], "atom_site.site_symmetry_multiplicity": ["atom_site_symmetry_multiplicity"], "atom_site.u_iso_or_equiv": ["atom_site_U_iso_or_equiv"], "atom_site_aniso.label": ["atom_site_anisotrop_id"], "atom_site_aniso.u_11": ["atom_site_aniso_U_11", "atom_site_anisotrop_U_11"], "atom_site_aniso.u_12": ["atom_site_aniso_U_12", "atom_site_anisotrop_U_12"], "atom_site_aniso.u_13": ["atom_site_aniso_U_13", "atom_site_anisotrop_U_13"], "atom_site_aniso.u_22": ["atom_site_aniso_U_22", "atom_site_anisotrop_U_22"], "atom_site_aniso.u_23": ["atom_site_aniso_U_23", "atom_site_anisotrop_U_23"], "atom_site_aniso.u_33": ["atom_site_aniso_U_33", "atom_site_anisotrop_U_33"] }, lT = function(e) {
  return typeof e == "string" ? RX(e) : LX(e);
}, dT = { mmCIF: function(e) {
  return Kd(tr, e);
}, CCD: function(e) {
  return Kd(zX, e);
}, BIRD: function(e) {
  return Kd(VX, e);
}, dic: function(e) {
  return Kd(UX, e);
}, cifCore: function(e) {
  return Kd(qX, e, KX);
}, densityServer: function(e) {
  return Kd(HX, e);
} }, XX = { type_symbol: oe.Schema.Aliased(tr.atom_site.type_symbol), label_atom_id: tr.atom_site.label_atom_id, auth_atom_id: tr.atom_site.auth_atom_id, label_alt_id: tr.atom_site.label_alt_id, label_comp_id: tr.atom_site.label_comp_id, auth_comp_id: tr.atom_site.auth_comp_id, pdbx_formal_charge: tr.atom_site.pdbx_formal_charge, cdr: tr.atom_site.cdr, B_iso_or_equiv: tr.atom_site.B_iso_or_equiv, em_confidence: tr.atom_site.em_confidence }, jX = { group_PDB: tr.atom_site.group_PDB, label_seq_id: tr.atom_site.label_seq_id, auth_seq_id: tr.atom_site.auth_seq_id, pdbx_PDB_ins_code: tr.atom_site.pdbx_PDB_ins_code }, YX = { label_asym_id: tr.atom_site.label_asym_id, auth_asym_id: tr.atom_site.auth_asym_id, label_entity_id: tr.atom_site.label_entity_id };
(function(e) {
  e.EmptyResidueKey = function() {
    return { label_entity_id: "", label_asym_id: "", auth_seq_id: 0, pdbx_PDB_ins_code: void 0 };
  };
})(Db || (Db = {})), function(e) {
  function t(n, i) {
    return n.residueAtomSegments.index[n.chainAtomSegments.offsets[i]];
  }
  function r(n, i) {
    return n.residueAtomSegments.index[n.chainAtomSegments.offsets[i + 1] - 1] + 1;
  }
  e.chainStartResidueIndex = t, e.chainEndResidueIndexExcl = r, e.chainResidueCount = function(n, i) {
    return r(n, i) - t(n, i);
  };
}(pf || (pf = {}));
var nm, j1 = { H: 1, D: 1, T: 1, HE: 2, LI: 3, BE: 4, B: 5, C: 6, N: 7, O: 8, F: 9, NE: 10, NA: 11, MG: 12, AL: 13, SI: 14, P: 15, S: 16, CL: 17, AR: 18, K: 19, CA: 20, SC: 21, TI: 22, V: 23, CR: 24, MN: 25, FE: 26, CO: 27, NI: 28, CU: 29, ZN: 30, GA: 31, GE: 32, AS: 33, SE: 34, BR: 35, KR: 36, RB: 37, SR: 38, Y: 39, ZR: 40, NB: 41, MO: 42, TC: 43, RU: 44, RH: 45, PD: 46, AG: 47, CD: 48, IN: 49, SN: 50, SB: 51, TE: 52, I: 53, XE: 54, CS: 55, BA: 56, LA: 57, CE: 58, PR: 59, ND: 60, PM: 61, SM: 62, EU: 63, GD: 64, TB: 65, DY: 66, HO: 67, ER: 68, TM: 69, YB: 70, LU: 71, HF: 72, TA: 73, W: 74, RE: 75, OS: 76, IR: 77, PT: 78, AU: 79, HG: 80, TL: 81, PB: 82, BI: 83, PO: 84, AT: 85, RN: 86, FR: 87, RA: 88, AC: 89, TH: 90, PA: 91, U: 92, NP: 93, PU: 94, AM: 95, CM: 96, BK: 97, CF: 98, ES: 99, FM: 100, MD: 101, NO: 102, LR: 103, RF: 104, DB: 105, SG: 106, BH: 107, HS: 108, MT: 109 }, WX = { 1: 1.1, 2: 1.4, 3: 1.81, 4: 1.53, 5: 1.92, 6: 1.7, 7: 1.55, 8: 1.52, 9: 1.47, 10: 1.54, 11: 2.27, 12: 1.73, 13: 1.84, 14: 2.1, 15: 1.8, 16: 1.8, 17: 1.75, 18: 1.88, 19: 2.75, 20: 2.31, 21: 2.3, 22: 2.15, 23: 2.05, 24: 2.05, 25: 2.05, 26: 2.05, 27: 2, 28: 2, 29: 2, 30: 2.1, 31: 1.87, 32: 2.11, 33: 1.85, 34: 1.9, 35: 1.83, 36: 2.02, 37: 3.03, 38: 2.49, 39: 2.4, 40: 2.3, 41: 2.15, 42: 2.1, 43: 2.05, 44: 2.05, 45: 2, 46: 2.05, 47: 2.1, 48: 2.2, 49: 2.2, 50: 1.93, 51: 2.17, 52: 2.06, 53: 1.98, 54: 2.16, 55: 3.43, 56: 2.68, 57: 2.5, 58: 2.48, 59: 2.47, 60: 2.45, 61: 2.43, 62: 2.42, 63: 2.4, 64: 2.38, 65: 2.37, 66: 2.35, 67: 2.33, 68: 2.32, 69: 2.3, 70: 2.28, 71: 2.27, 72: 2.25, 73: 2.2, 74: 2.1, 75: 2.05, 76: 2, 77: 2, 78: 2.05, 79: 2.1, 80: 2.05, 81: 1.96, 82: 2.02, 83: 2.07, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2, 90: 2.4, 91: 2, 92: 2.3, 93: 2, 94: 2, 95: 2, 96: 2, 97: 2, 98: 2, 99: 2, 100: 2, 101: 2, 102: 2, 103: 2, 104: 2, 105: 2, 106: 2, 107: 2, 108: 2, 109: 2 }, ZX = { 1: 1.008, 2: 4.0026, 3: 6.94, 4: 9.0122, 5: 10.81, 6: 10.81, 7: 14.007, 8: 15.999, 9: 18.998, 10: 20.18, 11: 22.99, 12: 24.305, 13: 26.982, 14: 28.085, 15: 30.974, 16: 32.06, 17: 35.45, 18: 39.948, 19: 39.098, 20: 40.078, 21: 44.956, 22: 47.867, 23: 50.942, 24: 51.996, 25: 54.938, 26: 55.845, 27: 58.933, 28: 58.693, 29: 63.546, 30: 65.38, 31: 69.723, 32: 72.63, 33: 74.922, 34: 78.971, 35: 79.904, 36: 83.798, 37: 85.468, 38: 87.62, 39: 88.906, 40: 91.224, 41: 92.906, 42: 95.95, 43: 96.906, 44: 101.07, 45: 102.91, 46: 106.42, 47: 107.87, 48: 112.41, 49: 114.82, 50: 118.71, 51: 121.76, 52: 127.6, 53: 127.6, 54: 131.29, 55: 132.91, 56: 137.33, 57: 138.91, 58: 140.12, 59: 140.91, 60: 144.24, 61: 144.912, 62: 150.36, 63: 151.96, 64: 157.25, 65: 158.93, 66: 162.5, 67: 164.93, 68: 167.26, 69: 168.93, 70: 173.05, 71: 174.97, 72: 178.49, 73: 180.95, 74: 183.84, 75: 186.21, 76: 190.23, 77: 192.22, 78: 195.08, 79: 196.97, 80: 200.59, 81: 204.38, 82: 207.2, 83: 208.98, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2, 90: 232.04, 91: 231.04, 92: 238.03, 93: 237.048, 94: 244.064, 95: 243.061, 96: 247.07, 97: 247.07, 98: 251.079, 99: 252.083, 100: 257.095, 101: 258.098, 102: 259.101, 103: 262.11, 104: 267.122, 105: 270.131, 106: 271.134, 107: 270.133, 108: 270.134, 109: 278.156 }, QX = 1.7, JX = 0;
function Eg(e) {
  var t = j1[e];
  return t === void 0 ? QX : WX[t];
}
function im(e) {
  var t = j1[e];
  return t === void 0 ? JX : t;
}
function fT(e, t, r, n) {
  return { type: e, key: t, elements: r, getIndex: n };
}
function $X(e, t, r, n, i, a) {
  for (var o = e.residues, u = o.auth_seq_id, s = o.label_seq_id, c = o.pdbx_PDB_ins_code, l = r.endSeqId, d = r.endInsCode, f = r.key, m = r.type, v = t === "label" ? s : u, p = n; p < i; ) {
    var g = v.value(p);
    if (a.type[p] = m, a.key[p] = f, g > l || g === l && c.value(p) === d) break;
    p++;
  }
}
(function(e) {
  e.Descriptor = { name: "model_secondary_structure" }, e.Provider = Es.create(e.Descriptor), e.fromStruct = function(t, r, n) {
    var i = /* @__PURE__ */ new Map(), a = [{ kind: "none" }], o = function(c, l) {
      if (c._rowCount > 0) {
        if (c.beg_label_seq_id.valueKind(0) !== 0 || c.end_label_seq_id.valueKind(0) !== 0) return "auth";
      } else if (l && (l.beg_label_seq_id.valueKind(0) !== 0 || l.end_label_seq_id.valueKind(0) !== 0)) return "auth";
      return "label";
    }(t, r);
    (function(c, l, d, f) {
      if (c._rowCount)
        for (var m = c.beg_label_asym_id, v = c.beg_label_seq_id, p = c.beg_auth_seq_id, g = c.pdbx_beg_PDB_ins_code, h = c.end_label_seq_id, y = c.end_auth_seq_id, x = c.pdbx_end_PDB_ins_code, A = c.pdbx_PDB_helix_class, b = c.conf_type_id, _ = c.details, S = l === "label" ? v : p, D = l === "label" ? h : y, I = 0, M = c._rowCount; I < M; I++) {
          var F = yr.create(A.valueKind(I) === 0 ? yr.SecondaryStructurePdb[A.value(I)] : b.valueKind(I) === 0 ? yr.SecondaryStructureMmcif[b.value(I)] : 536870912), P = { kind: "helix", flags: F, type_id: b.valueKind(I) === 0 ? b.value(I) : "HELIX_P", helix_class: A.value(I), details: _.valueKind(I) === 0 ? _.value(I) : void 0 }, E = { startSeqId: S.value(I), startInsCode: g.value(I), endSeqId: D.value(I), endInsCode: x.value(I), type: F, key: f.length };
          f[f.length] = P;
          var B = m.value(I);
          if (d.has(B)) {
            var N = d.get(B);
            N.has(E.startSeqId) ? N.get(E.startSeqId).push(E) : N.set(E.startSeqId, [E]);
          } else d.set(B, /* @__PURE__ */ new Map([[E.startSeqId, [E]]]));
        }
    })(t, o, i, a), function(c, l, d, f, m) {
      if (c._rowCount)
        for (var v = c.beg_label_asym_id, p = c.beg_label_seq_id, g = c.beg_auth_seq_id, h = c.pdbx_beg_PDB_ins_code, y = c.end_label_seq_id, x = c.end_auth_seq_id, A = c.pdbx_end_PDB_ins_code, b = c.sheet_id, _ = l === "label" ? p : g, S = l === "label" ? y : x, D = /* @__PURE__ */ new Map(), I = f + 1, M = 0, F = c._rowCount; M < F; M++) {
          var P = b.value(M), E = void 0;
          D.has(P) ? E = D.get(P) : (E = I++, D.set(P, E));
          var B = yr.create(8388612), N = { kind: "sheet", flags: B, sheet_id: P, symmetry: void 0 }, O = { startSeqId: _.value(M), startInsCode: h.value(M), endSeqId: S.value(M), endInsCode: A.value(M), type: B, key: m.length };
          m[m.length] = N;
          var z = v.value(M);
          if (d.has(z)) {
            var V = d.get(z);
            V.has(O.startSeqId) ? V.get(O.startSeqId).push(O) : V.set(O.startSeqId, [O]);
          } else d.set(z, /* @__PURE__ */ new Map([[O.startSeqId, [O]]]));
        }
    }(r, o, i, t._rowCount, a);
    var u = n.residues._rowCount, s = { type: new Int32Array(u), key: new Int32Array(u), elements: a };
    return i.size > 0 && function(c, l, d, f) {
      for (var m = c.chainAtomSegments.count, v = c.chains.label_asym_id, p = c.residues, g = p.auth_seq_id, h = p.label_seq_id, y = p.pdbx_PDB_ins_code, x = l === "label" ? h : g, A = 0; A < m; A++) {
        var b = pf.chainStartResidueIndex(c, A), _ = pf.chainEndResidueIndexExcl(c, A), S = v.value(A);
        if (d.has(S)) for (var D = d.get(S), I = b; I < _; I++) {
          var M = x.value(I);
          if (D.has(M)) for (var F = 0, P = D.get(M); F < P.length; F++) {
            var E = P[F], B = y.value(I);
            E.startInsCode === B && $X(c, l, E, I, _, f);
          }
        }
      }
    }(n, o, i, s), fT(s.type, s.key, s.elements, function(c) {
      return c;
    });
  };
})(nm || (nm = {}));
var Ql, Vp, ej = { U: tr.atom_site_anisotrop.U, U_esd: tr.atom_site_anisotrop.U_esd };
(function(e) {
  e.Schema = ej, e.Descriptor = { name: "atom_site_anisotrop", cifExport: { prefix: "", categories: [{ name: "atom_site_anisotrop", instance: function(t) {
    return e.Provider.get(t.firstModel) && mn.is(t.firstModel.sourceData) ? ki.Category.ofTable(t.firstModel.sourceData.data.db.atom_site_anisotrop) : ki.Category.Empty;
  } }] } }, e.Provider = Es.create(e.Descriptor), e.getElementToAnsiotrop = function(t, r) {
    var n = new Int32Array(t.rowCount);
    n.fill(-1);
    for (var i = 0, a = t.rowCount; i < a; i++) n[t.value(i)] = i;
    var o = new Int32Array(t.rowCount);
    for (o.fill(-1), i = 0, a = r.rowCount; i < a; ++i) {
      var u = n[r.value(i)];
      u !== -1 && (o[u] = i);
    }
    return o;
  }, e.getElementToAnsiotropFromLabel = function(t, r) {
    for (var n = {}, i = 0, a = t.rowCount; i < a; i++) n[t.value(i)] = i;
    var o = new Int32Array(t.rowCount);
    for (o.fill(-1), i = 0, a = r.rowCount; i < a; ++i) {
      var u = n[r.value(i)];
      u !== void 0 && (o[u] = i);
    }
    return o;
  };
})(Ql || (Ql = {})), function(e) {
  var t, r = "molstar_global_model_transform_info";
  function n(i) {
    return e.Provider.get(i);
  }
  e.Schema = ((t = {})[r] = { matrix: oe.Schema.Matrix(4, 4, oe.Schema.float) }, t), e.Descriptor = rs({ name: r, cifExport: { categories: [{ name: r, instance: function(i) {
    var a = n(i.firstModel);
    if (!a) return ki.Category.Empty;
    var o = Or.ofRows(e.Schema.molstar_global_model_transform_info, [{ matrix: a }]);
    return ki.Category.ofTable(o);
  } }], prefix: "molstar" } }), e.Provider = Es.create(e.Descriptor), e.attach = function(i, a) {
    i.customProperties.has(e.Descriptor) || i.customProperties.add(e.Descriptor), e.Provider.set(i, a);
  }, e.get = n, e.fromMmCif = function(i) {
    if (mn.is(i.sourceData)) {
      var a = i.sourceData.data.frame.categories[r];
      if (a) {
        var o, u = (o = e.Schema[r], new DM(a, o, !0));
        if (u._rowCount !== 0) return u.matrix.value(0);
      }
    }
  }, e.hasData = function(i) {
    if (!mn.is(i.sourceData)) return !1;
    var a = i.sourceData.data.frame.categories[r];
    return !!a && a.rowCount > 0;
  }, e.writeMmCif = function(i, a) {
    i.writeCategory({ name: r, instance: function() {
      var o = Or.ofRows(e.Schema.molstar_global_model_transform_info, [{ matrix: a }]);
      return ki.Category.ofTable(o);
    } });
  };
}(Vp || (Vp = {})), tr.atom_site.label_comp_id, tr.atom_site.label_seq_id, tr.atom_site.pdbx_PDB_ins_code, tr.atom_site.label_asym_id, tr.atom_site.label_entity_id, tr.atom_site.auth_atom_id, tr.atom_site.auth_seq_id, tr.atom_site.auth_asym_id, R(R({}, tr.chem_comp_bond), { molstar_protonation_variant: oe.Schema.Str() });
var tj = R(R({}, tr.chem_comp), { type: oe.Schema.Aliased(oe.Schema.str) });
function rj(e, t) {
  var r = t.ihm_model_group, n = t.ihm_model_group_link, i = Or.pickRow(n, function(o) {
    return n.model_id.value(o) === e;
  });
  if (i) {
    var a = Or.pickRow(r, function(o) {
      return r.id.value(o) === i.group_id;
    });
    if (a) return a.name;
  }
  return "";
}
function FA(e) {
  for (var t = 0, r = e.rowCount; t < r; t++) if (e.valueKind(t) === 0) return !0;
  return !1;
}
function Zh(e, t, r) {
  e[t].isDefined && FA(e[t]) || (e[t] = e[r]), e[r].isDefined && FA(e[r]) || (e[r] = e[t]);
}
var mn, _o = { entry: tr.entry, struct: tr.struct, struct_asym: tr.struct_asym, ihm_model_list: tr.ihm_model_list, ihm_model_group: tr.ihm_model_group, ihm_model_group_link: tr.ihm_model_group_link, entity: tr.entity, entity_poly: tr.entity_poly, entity_poly_seq: tr.entity_poly_seq, pdbx_entity_branch: tr.pdbx_entity_branch, chem_comp: tj, pdbx_chem_comp_identifier: tr.pdbx_chem_comp_identifier, atom_site: tr.atom_site, ihm_sphere_obj_site: tr.ihm_sphere_obj_site, ihm_gaussian_obj_site: tr.ihm_gaussian_obj_site, pdbx_unobs_or_zero_occ_residues: tr.pdbx_unobs_or_zero_occ_residues, pdbx_molecule: tr.pdbx_molecule };
function ld(e, t) {
  t === void 0 && (t = !1);
  for (var r = /* @__PURE__ */ Object.create(null), n = 0, i = Object.keys(_o); n < i.length; n++) {
    var a = i[n];
    r[a] = a in e ? e[a] : Or.ofUndefinedColumns(_o[a], 0);
  }
  return t && (r.atom_site = function(o) {
    var u = Or.ofColumns(o._schema, o);
    return Zh(u, "label_atom_id", "auth_atom_id"), Zh(u, "label_comp_id", "auth_comp_id"), Zh(u, "label_seq_id", "auth_seq_id"), Zh(u, "label_asym_id", "auth_asym_id"), u;
  }(r.atom_site)), r;
}
function pT(e) {
  var t = mn.fromFrame(e), r = ld(t.data.db, !0);
  return er.create("Create mmCIF Model", function(n) {
    return Oc(r, t, n);
  });
}
ia.Provider.formatRegistry.add("mmCIF", function(e) {
  if (mn.is(e.sourceData)) return ia.fromData(e.sourceData.data.db);
}), nm.Provider.formatRegistry.add("mmCIF", function(e) {
  if (mn.is(e.sourceData)) {
    var t = e.sourceData.data.db, r = t.struct_conf, n = t.struct_sheet_range;
    return nm.fromStruct(r, n, e.atomicHierarchy);
  }
}), Ql.Provider.formatRegistry.add("mmCIF", function(e) {
  if (mn.is(e.sourceData)) {
    var t = e.sourceData.data.db.atom_site_anisotrop;
    return { data: Or.ofColumns(Ql.Schema, t), elementToAnsiotrop: Ql.getElementToAnsiotrop(e.atomicConformation.atomId, t.id) };
  }
}, function(e) {
  return !!mn.is(e.sourceData) && e.sourceData.data.db.atom_site_anisotrop.U.isDefined;
}), rm.Provider.formatRegistry.add("mmCIF", function(e) {
  if (mn.is(e.sourceData)) {
    var t = e.sourceData.data.db.chem_comp_bond;
    if (t._rowCount !== 0) return { data: t, entries: rm.getEntriesFromChemCompBond(t) };
  }
}), Ms.Provider.formatRegistry.add("mmCIF", function(e) {
  if (mn.is(e.sourceData)) {
    var t = e.sourceData.data.db.struct_conn;
    if (t._rowCount !== 0) {
      var r = Ms.getEntriesFromStructConn(t, e);
      return { data: t, byAtomIndex: Ms.getAtomIndexFromEntries(r), entries: r };
    }
  }
}), Vp.Provider.formatRegistry.add("mmCIF", Vp.fromMmCif, Vp.hasData), function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "mmCIF";
  }, e.fromFrame = function(t, r, n) {
    return r || (r = dT.mmCIF(t)), { kind: "mmCIF", name: r._name, data: { db: r, frame: t, source: n } };
  };
}(mn || (mn = {}));
var Ht, nj = 9, Qh = -27.888, ij = -0.5, NA = -9.9;
function aj(e, t, r, n) {
  var i = w.distance(e, n), a = w.distance(t, n), o = w.distance(t, r), u = w.distance(e, r), s = Qh / i - Qh / a + (Qh / o - Qh / u);
  return s < NA ? NA : s;
}
function oj(e, t, r) {
  for (var n = t.residueIndices, i = t.cIndices, a = t.hIndices, o = t.nIndices, u = t.oIndices, s = e.model.atomicHierarchy.index, c = e.conformation.invariantPosition, l = e.model.atomicHierarchy.derived.residue.traceElementIndex, d = n.length, f = [], m = [], v = [], p = w(), g = w(), h = w(), y = w(), x = w(), A = w(), b = w(), _ = 0, S = n.length; _ < S; ++_) {
    var D = _, I = n[_], M = u[D], F = i[D], P = l[I];
    if (M !== -1 && F !== -1 && s.findAtomOnResidue(I, "OXT") === -1) {
      c(M, p), c(F, g), c(P, h);
      for (var E = r.find(h[0], h[1], h[2], nj), B = E.indices, N = E.count, O = 0; O < N; ++O) {
        var z = B[O];
        if (z !== D && z - 1 !== D && z + 1 !== D) {
          var V = o[z];
          if (V !== -1) {
            c(V, y);
            var U = a[z];
            if (U === -1) {
              if (z === 0) continue;
              var H = z - 1, K = u[H], j = i[H];
              if (K === -1 || j === -1) continue;
              c(K, b), c(j, A), w.sub(x, A, b);
              var X = w.distance(b, A);
              w.scaleAndAdd(x, y, x, 1 / X);
            } else c(U, x);
            var W = aj(p, g, y, x);
            W > ij || (f[f.length] = D, m[m.length] = z, v[v.length] = W);
          }
        }
      }
    }
  }
  return function(Q, te, ee, $) {
    for (var ie = new So.DirectedEdgeBuilder(Q, te, ee), ae = new Float32Array(ie.slotCount), se = 0, le = ie.edgeCount; se < le; se++) ie.addNextEdge(), ie.assignProperty(ae, $[se]);
    return ie.createGraph({ energies: $ });
  }(d, f, m, v);
}
(function(e) {
  e.is = ya.has, e.create = ya.create;
})(Ht || (Ht = {}));
var Jh = function(e, t, r) {
  this.partner1 = Math.min(e, t), this.partner2 = Math.max(e, t), this.type = r;
};
function uj(e, t) {
  if (t.type !== e.type || t.partner1 !== e.firstEnd + 1) return !1;
  if (t.type === 0) {
    if (t.partner2 === e.secondEnd + 1) return !0;
  } else if (t.partner2 === e.secondStart - 1) return !0;
  return !1;
}
function sj(e, t) {
  return e.type === t.type && t.firstStart - e.firstEnd < 6 && e.firstStart < t.firstStart && t.nextLadder === 0 && (e.type === 0 ? RA(e, t) : RA(t, e));
}
function RA(e, t) {
  return t.secondStart - e.secondEnd > 0 && (t.secondStart - e.secondEnd < 6 && t.firstStart - e.firstEnd < 3 || t.secondStart - e.secondEnd < 3);
}
function OA(e) {
  return Ht.is(e, 8) || Ht.is(e, 1) || Ht.is(e, 16);
}
var Y1, cj = { oldDefinition: G.Boolean(!0, { description: "Whether to use the old DSSP convention for the annotation of turns and helices, causes them to be two residues shorter" }), oldOrdering: G.Boolean(!0, { description: "Alpha-helices are preferred over 3-10 helices" }) };
function mT(e, t) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o, u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _;
    return ye(this, function(S) {
      for (r = function(D) {
        for (var I = D.model.atomicHierarchy.index, M = D.proteinElements, F = D.residueIndex, P = M.length, E = new Uint32Array(P), B = new Int32Array(P), N = new Int32Array(P), O = new Int32Array(P), z = new Int32Array(P), V = 0; V < P; ++V) {
          var U = F[M[V]];
          E[V] = U, B[V] = I.findAtomOnResidue(U, "C"), N[V] = I.findAtomOnResidue(U, "H"), O[V] = I.findAtomOnResidue(U, "O"), z[V] = I.findAtomOnResidue(U, "N");
        }
        return { residueIndices: qe.ofSortedArray(E), cIndices: B, hIndices: N, oIndices: O, nIndices: z };
      }(e), n = r.residueIndices, i = function(D, I) {
        for (var M = D.model.atomicConformation, F = M.x, P = M.y, E = M.z, B = D.model.atomicHierarchy.derived.residue.traceElementIndex, N = new Uint32Array(I.length), O = 0, z = I.length; O < z; ++O) N[O] = B[I[O]];
        var V = { x: F, y: P, z: E, indices: qe.ofSortedArray(N) };
        return lf(V, X1(V));
      }(e, n), a = oj(e, r, i), o = n.length, u = new Uint32Array(o), s = function(D, I) {
        var M = I.cIndices, F = I.nIndices, P = I.residueIndices, E = D.conformation.position, B = D.model.atomicHierarchy.index, N = D.model.atomicHierarchy.derived.residue.traceElementIndex, O = P.length, z = function(ae, se) {
          return ae === -1 ? w.setNaN(se) : E(ae, se);
        }, V = w(), U = w(), H = w(), K = w(), j = w(), X = w(), W = w(), Q = w(), te = w();
        if (O === 0) return { phi: new Float32Array(0), psi: new Float32Array(0) };
        var ee = new Float32Array(O - 1), $ = new Float32Array(O - 1);
        z(-1, V), z(-1, U), z(-1, H), z(M[0], K), z(N[P[0]], j), z(F[0], X), z(M[1], W), z(N[P[1]], Q), z(F[1], te);
        for (var ie = 0; ie < O - 1; ++ie) B.findAtomOnResidue(P[ie], "OXT") === -1 && (ee[ie] = xa(w.dihedralAngle(V, X, j, K)), $[ie] = xa(w.dihedralAngle(X, j, K, te)), V = K, U = j, H = X, K = W, j = Q, X = te, z(M[ie + 1], W), z(N[P[ie + 1]], Q), z(F[ie + 1], te));
        return { phi: ee, psi: $ };
      }(e, r), c = [], l = [], d = t.oldDefinition ? fj : mj, f = t.oldOrdering ? pj : hj, function(D) {
        for (var I = D.proteinInfo, M = D.hbonds, F = D.flags, P = [1024, 2048, 4096, 128, 256, 512], E = 0; E < 3; E++) for (var B = 0, N = I.residueIndices.length - 1; B < N; ++B) if (M.getDirectedEdgeIndex(B, B + E + 3) !== -1) if (F[B] |= P[E + 3] | P[E], D.params.oldDefinition) for (var O = 1; O < E + 3; ++O) F[B + O] |= 64 | P[E + 3];
        else for (O = 0; O <= E + 3; ++O) F[B + O] |= 64 | P[E + 3];
      }(m = { params: t, getResidueFlag: d, getFlagName: f, unit: e, proteinInfo: r, flags: u, hbonds: a, torsionAngles: s, ladders: c, bridges: l }), function(D) {
        for (var I = D.proteinInfo, M = D.flags, F = I.residueIndices.length, P = [1024, 2048, 4096, 128, 256, 512], E = [0, 0, 0, 8, 1, 16], B = D.params.oldOrdering ? [4, 3, 5] : [3, 4, 5], N = 0; N < B.length; N++) for (var O = B[N], z = 1, V = F - O; z < V; z++) {
          var U = Ht.create(M[z]), H = Ht.create(M[z - 1]), K = Ht.create(M[z + 1]);
          if (D.params.oldOrdering) {
            if (O === 3 && (Ht.is(U, 1) || Ht.is(K, 1)) || O === 5 && (Ht.is(U, 1) || Ht.is(U, 8) || Ht.is(K, 1) || Ht.is(K, 8))) continue;
          } else if (O === 4 && (Ht.is(U, 8) || Ht.is(K, 8)) || O === 5 && (Ht.is(U, 1) || Ht.is(U, 8) || Ht.is(K, 1) || Ht.is(K, 8))) continue;
          if (Ht.is(U, P[O]) && Ht.is(U, P[O - 3]) && Ht.is(H, P[O]) && Ht.is(H, P[O - 3])) if (D.params.oldDefinition) for (var j = 0; j < O; j++) M[z + j] |= E[O];
          else for (j = -1; j <= O; j++) M[z + j] |= E[O];
        }
      }(m), function(D) {
        var I = D.unit, M = D.flags, F = D.proteinInfo, P = I.conformation.position, E = I.model.atomicHierarchy.derived.residue.traceElementIndex, B = F.residueIndices, N = F.nIndices, O = B.length, z = function(Ge, Ue) {
          return Ge === -1 ? w.setNaN(Ue) : P(Ge, Ue);
        }, V = w(), U = w(), H = w(), K = w(), j = w(), X = w(), W = w();
        e: for (var Q = 2; Q < O - 2; Q++) {
          for (var te = 0; te < 4; te++) {
            var ee = Q + te - 2;
            if (z(E[ee], K), z(N[ee + 1], j), w.squaredDistance(K, j) > 6.25) continue e;
          }
          var $ = B[Q - 2], ie = B[Q], ae = B[Q + 2], se = E[$], le = E[ie], pe = E[ae];
          z(se, V), z(le, U), z(pe, H), w.sub(X, V, U), w.sub(W, U, H);
          var we = xa(w.angle(X, W));
          we && we > 70 && (M[Q] |= 32);
        }
      }(m), function(D) {
        for (var I, M, F = D.proteinInfo, P = D.hbonds, E = D.flags, B = D.bridges, N = P.offset, O = P.b, z = 0, V = F.residueIndices.length; z < V; ++z) for (var U = N[z], H = N[z + 1]; U < H; U++) {
          var K = O[U];
          z > K || ((I = z + 1) !== (M = K) && P.getDirectedEdgeIndex(M, I + 1) !== -1 && (E[I] |= 2, E[M] |= 2, B[B.length] = new Jh(I, M, 0)), (I = z) !== (M = K - 1) && P.getDirectedEdgeIndex(M - 1, I) !== -1 && (E[I] |= 2, E[M] |= 2, B[B.length] = new Jh(M, I, 0)), (I = z) !== (M = K) && P.getDirectedEdgeIndex(M, I) !== -1 && (E[I] |= 2, E[M] |= 2, B[B.length] = new Jh(M, I, 1)), (I = z + 1) !== (M = K - 1) && P.getDirectedEdgeIndex(M - 1, I + 1) !== -1 && (E[I] |= 2, E[M] |= 2, B[B.length] = new Jh(M, I, 1)));
        }
        B.sort(function(j, X) {
          return j.partner1 > X.partner1 ? 1 : j.partner1 < X.partner1 ? -1 : 0;
        });
      }(m), function(D) {
        for (var I = D.bridges, M = D.ladders, F = 0; F < I.length; F++) {
          for (var P = I[F], E = !1, B = 0; B < M.length; B++) {
            var N = M[B];
            uj(N, P) && (E = !0, N.firstEnd++, P.type === 0 ? N.secondEnd++ : N.secondStart--);
          }
          E || (M[M.length] = { previousLadder: 0, nextLadder: 0, firstStart: P.partner1, firstEnd: P.partner1, secondStart: P.partner2, secondEnd: P.partner2, type: P.type });
        }
        for (var O = 0; O < M.length; O++) for (var z = M[O], V = O; V < M.length; V++) {
          var U = M[V];
          sj(z, U) && (z.nextLadder = V, U.previousLadder = O);
        }
      }(m), function(D) {
        for (var I = D.ladders, M = D.flags, F = 0; F < I.length; F++) {
          for (var P = I[F], E = P.firstStart; E <= P.firstEnd; E++) {
            var B = P.firstStart - E, N = P.secondStart - B;
            P.firstStart !== P.firstEnd ? (M[E] |= 4, M[N] |= 4) : (!OA(M[E]) && Ht.is(M[E], 4) && (M[E] |= 2), !OA(M[N]) && Ht.is(M[N], 4) && (M[N] |= 2));
          }
          if (P.nextLadder !== 0) {
            var O = I[P.nextLadder];
            for (E = P.firstStart; E <= O.firstEnd; E++) M[E] |= 4;
            if (P.type === 0) for (E = P.secondStart; E <= O.secondEnd; E++) M[E] |= 4;
            else for (E = O.secondEnd; E <= P.secondStart; E++) M[E] |= 4;
          }
        }
      }(m), v = function(D, I) {
        for (var M = new Uint32Array(D.length), F = 0, P = D.length; F < P; ++F) {
          var E = Ht.create(D[F]);
          M[F] = I(E);
        }
        return M;
      }(u, d), p = new Uint32Array(o), g = [], h = [], y = function(D) {
        return qe.indexOf(n, D);
      }, x = 0, A = n.length; x < A; ++x) b = v[x], p[x] = b, _ = d(u[x]), h.length !== 0 && _ === h[h.length - 1].flags || (h[h.length] = lj(dj(b), u[x], d)), g[x] = h.length - 1;
      return [2, fT(p, g, h, y)];
    });
  });
}
function lj(e, t, r) {
  return e === "helix" ? { kind: "helix", flags: r(t) } : e === "sheet" ? { kind: "sheet", flags: r(t) } : e === "turn" || e === "bend" ? { kind: "turn", flags: r(t) } : { kind: "none" };
}
function dj(e) {
  return e === yr.SecondaryStructureDssp.H || e === yr.SecondaryStructureDssp.G || e === yr.SecondaryStructureDssp.I ? "helix" : e === yr.SecondaryStructureDssp.B || e === yr.SecondaryStructureDssp.E ? "sheet" : e === yr.SecondaryStructureDssp.T ? "turn" : e === yr.SecondaryStructureDssp.S ? "bend" : "none";
}
function fj(e) {
  return Ht.is(e, 1) ? yr.SecondaryStructureDssp.H : Ht.is(e, 4) ? yr.SecondaryStructureDssp.E : Ht.is(e, 2) ? yr.SecondaryStructureDssp.B : Ht.is(e, 8) ? yr.SecondaryStructureDssp.G : Ht.is(e, 16) ? yr.SecondaryStructureDssp.I : Ht.is(e, 64) ? yr.SecondaryStructureDssp.T : Ht.is(e, 32) ? yr.SecondaryStructureDssp.S : 0;
}
function pj(e) {
  return Ht.is(e, 1) ? "H" : Ht.is(e, 4) ? "E" : Ht.is(e, 2) ? "B" : Ht.is(e, 8) ? "G" : Ht.is(e, 16) ? "I" : Ht.is(e, 64) ? "T" : Ht.is(e, 32) ? "S" : "-";
}
function mj(e) {
  return Ht.is(e, 16) ? yr.SecondaryStructureDssp.I : Ht.is(e, 1) ? yr.SecondaryStructureDssp.H : Ht.is(e, 4) ? yr.SecondaryStructureDssp.E : Ht.is(e, 2) ? yr.SecondaryStructureDssp.B : Ht.is(e, 8) ? yr.SecondaryStructureDssp.G : Ht.is(e, 64) ? yr.SecondaryStructureDssp.T : Ht.is(e, 32) ? yr.SecondaryStructureDssp.S : 0;
}
function hj(e) {
  return Ht.is(e, 16) ? "I" : Ht.is(e, 1) ? "H" : Ht.is(e, 4) ? "E" : Ht.is(e, 2) ? "B" : Ht.is(e, 8) ? "G" : Ht.is(e, 64) ? "T" : Ht.is(e, 32) ? "S" : "-";
}
function hT(e) {
  var t = "model";
  if (e) {
    t = "model";
    for (var r = 0, n = e.models.length; r < n; ++r) {
      var i = e.models[r];
      if (!nn.isFromPdbArchive(i) && !nn.hasSecondaryStructure(i)) {
        t = "dssp";
        break;
      }
    }
  }
  return { type: G.MappedStatic(t, { model: G.EmptyGroup({ label: "Model" }), dssp: G.Group(cj, { label: "DSSP", isFlat: !0 }) }, { options: [["model", "Model"], ["dssp", "DSSP"]] }) };
}
(function(e) {
  function t(r) {
    var n = this, i = r.descriptor.name, a = r.type === "root" ? "inheritedPropertyData" : "currentPropertyData", o = function(s) {
      return i in s[a] || (s[a][i] = { props: R({}, G.getDefaultValues(r.getParams(s))), data: Ll.create(void 0) }), s[a][i];
    }, u = function(s, c, l) {
      var d = o(s);
      s[a][i] = { props: c, data: Ll.withValue(d.data, l) };
    };
    return { label: r.label, descriptor: r.descriptor, isHidden: r.isHidden, getParams: function(s) {
      var c = G.clone(r.getParams(s));
      return G.setDefaultValues(c, o(s).props), c;
    }, defaultParams: r.defaultParams, isApplicable: r.isApplicable, attach: function(s, c, l, d) {
      return l === void 0 && (l = {}), _e(n, 0, void 0, function() {
        var f, m, v, p, g, h;
        return ye(this, function(y) {
          switch (y.label) {
            case 0:
              return d && c.customPropertyDescriptors.reference(r.descriptor, !0), r.type === "root" && (c = c.root), f = o(c.root).props, m = o(c), v = G.merge(r.defaultParams, f, l), m.data.value && G.areEqual(r.defaultParams, m.props, v) ? [2] : [4, r.obtain(s, c, v)];
            case 1:
              return p = y.sent(), g = p.value, h = p.assets, c.customPropertyDescriptors.add(r.descriptor), c.customPropertyDescriptors.assets(r.descriptor, h), u(c, v, g), [2];
          }
        });
      });
    }, ref: function(s, c) {
      return s.customPropertyDescriptors.reference(r.descriptor, c);
    }, get: function(s) {
      return o(s).data;
    }, set: function(s, c, l) {
      c === void 0 && (c = {}), r.type === "root" && (s = s.root);
      var d = o(s), f = G.merge(r.defaultParams, d.props, c);
      G.areEqual(r.defaultParams, d.props, f) || (u(s, f, l), s.customPropertyDescriptors.assets(r.descriptor));
    }, props: function(s) {
      return o(s).props;
    } };
  }
  e.createProvider = t, e.createSimple = function(r, n, i) {
    var a = this, o = { value: G.Value(i, { isHidden: !0 }) };
    return t({ label: Is(r), descriptor: rs({ name: r }), isHidden: !0, type: n, defaultParams: o, getParams: function() {
      return { value: G.Value(i, { isHidden: !0 }) };
    }, isApplicable: function() {
      return !0;
    }, obtain: function(u, s, c) {
      return _e(a, 0, void 0, function() {
        return ye(this, function(l) {
          return [2, R(R({}, G.getDefaultValues(o)), c)];
        });
      });
    } });
  };
})(Y1 || (Y1 = {}));
var LA = hT(), Aa = Y1.createProvider({ label: "Secondary Structure", descriptor: rs({ name: "molstar_computed_secondary_structure" }), type: "root", defaultParams: LA, getParams: hT, isApplicable: function(e) {
  return !0;
}, obtain: function(e, t, r) {
  return _e(void 0, 0, void 0, function() {
    var n, i, a;
    return ye(this, function(o) {
      switch (o.label) {
        case 0:
          switch (n = R(R({}, G.getDefaultValues(LA)), r), n.type.name) {
            case "dssp":
              return [3, 1];
            case "model":
              return [3, 3];
          }
          return [3, 5];
        case 1:
          return i = {}, [4, vj(t, n.type.params)];
        case 2:
          return [2, (i.value = o.sent(), i)];
        case 3:
          return a = {}, [4, gj(t)];
        case 4:
          return [2, (a.value = o.sent(), a)];
        case 5:
          return [2];
      }
    });
  });
} });
function vj(e, t) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o;
    return ye(this, function(u) {
      switch (u.label) {
        case 0:
          r = /* @__PURE__ */ new Map(), n = 0, i = e.unitSymmetryGroups.length, u.label = 1;
        case 1:
          return n < i ? (a = e.unitSymmetryGroups[n].units[0], !Be.isAtomic(a) || nn.isCoarseGrained(a.model) ? [3, 3] : [4, mT(a, t)]) : [3, 4];
        case 2:
          o = u.sent(), r.set(a.invariantId, o), u.label = 3;
        case 3:
          return ++n, [3, 1];
        case 4:
          return [2, r];
      }
    });
  });
}
function gj(e) {
  return _e(this, 0, void 0, function() {
    var t, r, n, i, a;
    return ye(this, function(o) {
      switch (o.label) {
        case 0:
          t = /* @__PURE__ */ new Map(), r = 0, n = e.unitSymmetryGroups.length, o.label = 1;
        case 1:
          return r < n ? (i = e.unitSymmetryGroups[r].units[0], Be.isAtomic(i) ? nn.isFromPdbArchive(i.model) || nn.hasSecondaryStructure(i.model) ? [3, 3] : [4, mT(i, { oldDefinition: !0, oldOrdering: !0 })] : [3, 4]) : [3, 5];
        case 2:
          return a = o.sent(), t.set(i.invariantId, a), [3, 4];
        case 3:
          (a = nm.Provider.get(i.model)) && t.set(i.invariantId, a), o.label = 4;
        case 4:
          return ++r, [3, 1];
        case 5:
          return [2, t];
      }
    });
  });
}
function yn() {
  throw new Error("Property only available for atomic models.");
}
function $s(e) {
  throw e ? new Error("Property only available for coarse models (".concat(e, ").")) : new Error("Property only available for coarse models.");
}
var Ip = { key: function(e) {
  return e.element;
}, x: function(e) {
  return e.unit.conformation.x(e.element);
}, y: function(e) {
  return e.unit.conformation.y(e.element);
}, z: function(e) {
  return e.unit.conformation.z(e.element);
}, id: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicConformation.atomId.value(e.element) : yn();
}, occupancy: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicConformation.occupancy.value(e.element) : yn();
}, B_iso_or_equiv: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicConformation.B_iso_or_equiv.value(e.element) : yn();
}, sourceIndex: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atomSourceIndex.value(e.element) : e.element;
}, type_symbol: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.type_symbol.value(e.element) : yn();
}, label_atom_id: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.label_atom_id.value(e.element) : yn();
}, auth_atom_id: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.auth_atom_id.value(e.element) : yn();
}, label_alt_id: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.label_alt_id.value(e.element) : yn();
}, label_comp_id: x_, auth_comp_id: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.auth_comp_id.value(e.element) : yn();
}, pdbx_formal_charge: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.pdbx_formal_charge.value(e.element) : yn();
}, vdw_radius: function(e) {
  return Be.isAtomic(e.unit) ? Eg(e.unit.model.atomicHierarchy.atoms.type_symbol.value(e.element)) : yn();
}, cdr: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.cdr.value(e.element) : yn();
}, em_confidence: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.atoms.em_confidence.value(e.element) : yn();
} };
function x_(e) {
  return Be.isAtomic(e.unit) || yn(), e.unit.model.atomicHierarchy.atoms.label_comp_id.value(e.element);
}
function Ib(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.residues.label_seq_id.value(e.unit.residueIndex[e.element]) : yn();
}
function kA(e) {
  Be.isAtomic(e.unit) || yn();
  var t = e.unit.model.sequence.byEntityKey[ja(e)];
  return t && t.sequence.microHet.get(Ib(e)) || [x_(e)];
}
var yj = { key: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.residueIndex[e.element] : yn();
}, group_PDB: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.residues.group_PDB.value(e.unit.residueIndex[e.element]) : yn();
}, label_seq_id: Ib, auth_seq_id: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.residues.auth_seq_id.value(e.unit.residueIndex[e.element]) : yn();
}, pdbx_PDB_ins_code: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(e.unit.residueIndex[e.element]) : yn();
}, isNonStandard: function(e) {
  return Be.isAtomic(e.unit) ? kA(e).some(function(t) {
    return e.unit.model.properties.chemicalComponentMap.get(t).mon_nstd_flag[0] === "n";
  }) : yn();
}, hasMicroheterogeneity: function(e) {
  Be.isAtomic(e.unit) || yn();
  var t = e.unit.model.sequence.byEntityKey[ja(e)];
  return t && t.sequence.microHet.has(Ib(e));
}, microheterogeneityCompIds: kA, secondary_structure_type: function(e) {
  var t;
  Be.isAtomic(e.unit) || yn();
  var r = (t = Aa.get(e.structure).value) === null || t === void 0 ? void 0 : t.get(e.unit.invariantId);
  return r ? r.type[r.getIndex(e.unit.residueIndex[e.element])] : 536870912;
}, secondary_structure_key: function(e) {
  var t;
  Be.isAtomic(e.unit) || yn();
  var r = (t = Aa.get(e.structure).value) === null || t === void 0 ? void 0 : t.get(e.unit.invariantId);
  return r ? r.key[r.getIndex(e.unit.residueIndex[e.element])] : -1;
}, chem_comp_type: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.properties.chemicalComponentMap.get(x_(e)).type : yn();
} }, bj = { key: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.chainIndex[e.element] : yn();
}, label_asym_id: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.chains.label_asym_id.value(e.unit.chainIndex[e.element]) : yn();
}, auth_asym_id: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.chains.auth_asym_id.value(e.unit.chainIndex[e.element]) : yn();
}, label_entity_id: function(e) {
  return Be.isAtomic(e.unit) ? e.unit.model.atomicHierarchy.chains.label_entity_id.value(e.unit.chainIndex[e.element]) : yn();
} }, _j = { key: Ip.key, entityKey: function(e) {
  return Be.isCoarse(e.unit) ? e.unit.coarseElements.entityKey[e.element] : $s();
}, x: Ip.x, y: Ip.y, z: Ip.z, asym_id: function(e) {
  return Be.isCoarse(e.unit) ? e.unit.coarseElements.asym_id.value(e.element) : $s();
}, entity_id: function(e) {
  return Be.isCoarse(e.unit) ? e.unit.coarseElements.entity_id.value(e.element) : $s();
}, seq_id_begin: function(e) {
  return Be.isCoarse(e.unit) ? e.unit.coarseElements.seq_id_begin.value(e.element) : $s();
}, seq_id_end: function(e) {
  return Be.isCoarse(e.unit) ? e.unit.coarseElements.seq_id_end.value(e.element) : $s();
}, sphere_radius: function(e) {
  return Be.isSpheres(e.unit) ? e.unit.coarseConformation.radius[e.element] : $s("spheres");
}, sphere_rmsf: function(e) {
  return Be.isSpheres(e.unit) ? e.unit.coarseConformation.rmsf[e.element] : $s("spheres");
}, gaussian_weight: function(e) {
  return Be.isGaussians(e.unit) ? e.unit.coarseConformation.weight[e.element] : $s("gaussians");
}, gaussian_covariance_matrix: function(e) {
  return Be.isGaussians(e.unit) ? e.unit.coarseConformation.covariance_matrix[e.element] : $s("gaussians");
} };
function ja(e) {
  switch (e.unit.kind) {
    case 0:
      return e.unit.model.atomicHierarchy.index.getEntityFromChain(e.unit.chainIndex[e.element]);
    case 1:
      return e.unit.model.coarseHierarchy.spheres.entityKey[e.element];
    case 2:
      return e.unit.model.coarseHierarchy.gaussians.entityKey[e.element];
  }
}
var xj = { key: ja, id: function(e) {
  return e.unit.model.entities.data.id.value(ja(e));
}, type: function(e) {
  return e.unit.model.entities.data.type.value(ja(e));
}, src_method: function(e) {
  return e.unit.model.entities.data.src_method.value(ja(e));
}, pdbx_description: function(e) {
  return e.unit.model.entities.data.pdbx_description.value(ja(e));
}, formula_weight: function(e) {
  return e.unit.model.entities.data.formula_weight.value(ja(e));
}, pdbx_number_of_molecules: function(e) {
  return e.unit.model.entities.data.pdbx_number_of_molecules.value(ja(e));
}, details: function(e) {
  return e.unit.model.entities.data.details.value(ja(e));
}, pdbx_mutation: function(e) {
  return e.unit.model.entities.data.pdbx_mutation.value(ja(e));
}, pdbx_fragment: function(e) {
  return e.unit.model.entities.data.pdbx_fragment.value(ja(e));
}, pdbx_ec: function(e) {
  return e.unit.model.entities.data.pdbx_ec.value(ja(e));
}, subtype: function(e) {
  return e.unit.model.entities.subtype.value(ja(e));
}, prd_id: function(e) {
  var t, r;
  return (r = (t = e.unit.model.entities.prd_id) === null || t === void 0 ? void 0 : t.value(ja(e))) !== null && r !== void 0 ? r : "";
} }, Aj = [], Sj = { id: function(e) {
  return e.unit.id;
}, chainGroupId: function(e) {
  return e.unit.chainGroupId;
}, multiChain: function(e) {
  return Be.Traits.is(e.unit.traits, 1);
}, object_primitive: function(e) {
  return e.unit.objectPrimitive;
}, operator_name: function(e) {
  return e.unit.conformation.operator.name;
}, model_index: function(e) {
  return e.unit.model.modelNum;
}, model_label: function(e) {
  return e.unit.model.label;
}, model_entry_id: function(e) {
  return e.unit.model.entryId;
}, hkl: function(e) {
  return e.unit.conformation.operator.hkl;
}, spgrOp: function(e) {
  return e.unit.conformation.operator.spgrOp;
}, model_num: function(e) {
  return e.unit.model.modelNum;
}, pdbx_struct_assembly_id: function(e) {
  var t;
  return ((t = e.unit.conformation.operator.assembly) === null || t === void 0 ? void 0 : t.id) || hn.DefaultName;
}, pdbx_struct_oper_list_ids: function(e) {
  var t;
  return ((t = e.unit.conformation.operator.assembly) === null || t === void 0 ? void 0 : t.operList) || Aj;
}, struct_ncs_oper_id: function(e) {
  return e.unit.conformation.operator.ncsId;
} }, Qe = { constant: { true: function(e) {
  return !0;
}, false: function(e) {
  return !1;
}, zero: function(e) {
  return 0;
} }, atom: Ip, residue: yj, chain: bj, entity: xj, unit: Sj, coarse: _j }, Up = function() {
  function e(t) {
    var r;
    this.index = /* @__PURE__ */ new Map(), this.checkOperator = !1, this.checkOperator = (r = t == null ? void 0 : t.checkOperator) !== null && r !== void 0 && r;
  }
  return e.prototype.add = function(t) {
    var r = this.index.get(t.label_asym_id);
    r || (r = /* @__PURE__ */ new Map(), this.index.set(t.label_asym_id, r));
    var n = r.get(t.label_seq_id);
    return n || (n = [], r.set(t.label_seq_id, n)), !this._find(t, n) && (n.push(t), !0);
  }, e.prototype.hasLabelAsymId = function(t) {
    return this.index.has(t);
  }, e.prototype.has = function(t) {
    var r, n, i = zA(t);
    if (this.index.has(i)) {
      var a = this.index.get(i), o = GA(t);
      if (a.has(o)) for (var u = a.get(o), s = VA(t), c = UA(t), l = HA(t), d = (r = qA(t)) !== null && r !== void 0 ? r : "1_555", f = 0, m = u; f < m.length; f++) {
        var v = m[f];
        if (v.label_comp_id === s && v.label_alt_id === c && v.ins_code === l && (!this.checkOperator || ((n = v.operator_name) !== null && n !== void 0 ? n : "1_555") === d)) return v;
      }
    }
  }, e.getLabel = function(t, r) {
    var n;
    return r === void 0 && (r = !1), "".concat(t.label_asym_id, " ").concat(t.label_comp_id, " ").concat(t.label_seq_id, ":").concat(t.ins_code, ":").concat(t.label_alt_id).concat(r ? " " + ((n = t.operator_name) !== null && n !== void 0 ? n : "1_555") : "");
  }, e.getEntryFromLocation = function(t) {
    var r;
    return { label_asym_id: zA(t), label_comp_id: VA(t), label_seq_id: GA(t), label_alt_id: UA(t), ins_code: HA(t), operator_name: (r = qA(t)) !== null && r !== void 0 ? r : "1_555" };
  }, e.prototype._find = function(t, r) {
    for (var n, i, a = 0, o = r; a < o.length; a++) {
      var u = o[a];
      if (u.label_comp_id === t.label_comp_id && u.label_alt_id === t.label_alt_id && u.ins_code === t.ins_code && (!this.checkOperator || ((n = u.operator_name) !== null && n !== void 0 ? n : "1_555") === ((i = t.operator_name) !== null && i !== void 0 ? i : "1_555"))) return !0;
    }
    return !1;
  }, e;
}(), zA = Qe.chain.label_asym_id, GA = Qe.residue.label_seq_id, VA = Qe.atom.label_comp_id, UA = Qe.atom.label_alt_id, HA = Qe.residue.pdbx_PDB_ins_code, qA = Qe.unit.operator_name;
function O1(e, t, r) {
  for (var n = t.subsetBuilder(!0), i = 0, a = r.units; i < a.length; i++) {
    var o = a[i];
    if (o.kind === 0) {
      var u = o.model.atomicHierarchy.residueAtomSegments, s = t.unitMap.get(o.id).elements, c = o.elements;
      n.beginUnit(o.id);
      for (var l = Zt.transientSegments(u, c); l.hasNext; ) for (var d = l.move().index, f = u.offsets[d], m = u.offsets[d + 1]; f < m; f++) qe.has(s, f) && n.addElement(f);
      n.commitUnit(), e.throwIfTimedOut();
    } else n.setUnit(o.id, o.elements);
  }
  return n.getStructure();
}
function Jy(e, t, r, n) {
  for (var i = new wg(t), a = t.lookup3d, o = n.radius, u = 0, s = r.units; u < s.length; u++) {
    for (var c = s[u], l = c.conformation, d = l.x, f = l.y, m = l.z, v = c.elements, p = 0, g = v.length; p < g; p++) {
      var h = v[p];
      a.findIntoBuilder(d(h), f(h), m(h), o, i);
    }
    e.throwIfTimedOut();
  }
  return n.wholeResidues ? O1(e, t, i.getStructure()) : i.getStructure();
}
function KA(e, t, r, n) {
  var i = new wg(t), a = t.lookup3d, o = n.elementRadius, u = n.elementRadiusClosure, s = n.sourceMaxRadius, c = n.radius;
  e.pushCurrentElement(), e.element.structure = r;
  for (var l = 0, d = r.units; l < d.length; l++) {
    var f = d[l];
    e.element.unit = f;
    for (var m = f.conformation, v = m.x, p = m.y, g = m.z, h = f.elements, y = 0, x = h.length; y < x; y++) {
      var A = h[y];
      e.element.element = A;
      var b = o(e);
      a.findIntoBuilderWithRadius(v(A), p(A), g(A), b, s, c, u, i);
    }
    e.throwIfTimedOut();
  }
  return e.popCurrentElement(), n.wholeResidues ? O1(e, t, i.getStructure()) : i.getStructure();
}
function Cj(e, t) {
  return function(r) {
    return e.element.structure = r.structure, e.element.unit = r.unit, e.element.element = r.element, t(e);
  };
}
function wj(e, t) {
  var r = 0;
  e.element.structure = e.inputStructure;
  for (var n = 0, i = e.inputStructure.units; n < i.length; n++) {
    var a = i[n];
    e.element.unit = a;
    for (var o = a.elements, u = 0, s = o.length; u < s; u++) {
      var c = o[u];
      e.element.element = c;
      var l = t(e);
      l > r && (r = l);
    }
  }
  return e.throwIfTimedOut(), r;
}
function XA(e, t, r) {
  var n = function(i, a) {
    for (var o = i.inputStructure, u = o.interUnitBonds, s = new wg(o), c = i.atomicBond, l = 0, d = a.units; l < d.length; l++) {
      var f = d[l];
      if (f.kind === 0) {
        var m = o.unitMap.get(f.id), v = m.bonds, p = v.offset, g = v.b, h = v.edgeProps, y = h.flags, x = h.order;
        for (c.setStructure(o), c.a.unit = m, c.b.unit = m, H = 0, K = f.elements.length; H < K; H++) {
          s.addToUnit(f.id, f.elements[H]);
          for (var A = qe.indexOf(m.elements, f.elements[H]), b = p[A], _ = p[A + 1]; b < _; b++) {
            var S = g[b], D = m.elements[S];
            qe.has(f.elements, D) || s.has(f.id, D) || (c.aIndex = A, c.a.element = f.elements[H], c.bIndex = S, c.b.element = D, c.type = y[b], c.order = x[b], c.test(i, !0) && s.addToUnit(f.id, D));
          }
        }
        for (var I = 0, M = u.getConnectedUnits(m.id); I < M.length; I++) for (var F = M[I], P = a.unitMap.get(F.unitB), E = o.unitMap.get(F.unitB), B = 0, N = F.connectedIndices; B < N.length; B++) {
          var O = N[B];
          if (qe.has(f.elements, m.elements[O])) for (var z = 0, V = F.getEdges(O); z < V.length; z++) {
            var U = V[z];
            D = E.elements[U.indexB], P && qe.has(P.elements, D) || s.has(F.unitB, D) || (c.a.unit = m, c.aIndex = O, c.a.element = m.elements[O], c.b.unit = E, c.bIndex = U.indexB, c.b.element = D, c.type = U.props.flag, c.order = U.props.order, c.test(i, !0) && s.addToUnit(F.unitB, D));
          }
        }
      } else {
        s.beginUnit(f.id);
        for (var H = 0, K = f.elements.length; H < K; H++) s.addElement(f.elements[H]);
        s.commitUnit();
      }
    }
    return s.getStructure();
  }(e, r);
  return t ? O1(e, e.inputStructure, n) : n;
}
var Dj = Qe.entity.type;
function Ij(e) {
  return Dj(e) === "water";
}
var B2, F2, Ej = function() {
  function e() {
    this.vertices = /* @__PURE__ */ new Map(), this.edges = /* @__PURE__ */ new Map();
  }
  return e.prototype.addVertex = function(t, r) {
    this.vertices.has(r) || (this.vertices.set(r, t), this.edges.set(r, []));
  }, e.prototype.addEdge = function(t, r) {
    var n = Up.getLabel(t), i = Up.getLabel(r);
    this.addVertex(t, n), this.addVertex(r, i), Su(this.edges.get(n), i), Su(this.edges.get(i), n);
  }, e.prototype.addComponent = function(t, r) {
    var n = Up.getLabel(t);
    if (this.vertices.has(n)) {
      var i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), o = [n];
      for (a.add(n), r.add(t); o.length > 0; ) {
        var u = o.pop();
        i.add(u);
        for (var s = this.vertices.get(u), c = 0, l = this.edges.get(u); c < l.length; c++) {
          var d = l[c];
          if (!i.has(d) && (o.push(d), !a.has(d))) {
            a.add(d);
            var f = this.vertices.get(d);
            s.operator_name === f.operator_name ? r.add(R(R({}, f), { operator_name: t.operator_name })) : r.add(f);
          }
        }
      }
    } else r.add(t);
  }, e;
}(), Mj = Object.freeze({ __proto__: null, exceptBy: function(e, t) {
  return function(r) {
    var n = e(r);
    if (vt.structureCount(n) === 0) return n;
    var i = t(r);
    if (vt.structureCount(i) === 0) return n;
    var a = vt.unionStructure(i), o = vt.UniqueBuilder(r.inputStructure);
    return vt.forEach(n, function(u, s) {
      var c = nT(u, a);
      c.elementCount !== 0 && o.add(c), s % 50 == 0 && r.throwIfTimedOut();
    }), o.getSelection();
  };
}, expandProperty: function(e, t) {
  return function(r) {
    var n = e(r), i = /* @__PURE__ */ new Map(), a = [];
    r.pushCurrentElement(), vt.forEach(n, function(A, b) {
      r.element.structure = A;
      for (var _ = 0, S = A.units; _ < S.length; _++) {
        var D = S[_];
        r.element.unit = D;
        for (var I = D.elements, M = 0, F = I.length; M < F; M++) {
          r.element.element = I[M];
          var P = t(r), E = void 0;
          i.has(P) ? E = i.get(P) : (E = cn.create(), i.set(P, E)), cn.add(E, b, b);
        }
      }
      a[b] = r.inputStructure.subsetBuilder(!0), b % 10 == 0 && r.throwIfTimedOut();
    }), r.element.structure = r.inputStructure;
    for (var o = 0, u = r.inputStructure.units; o < u.length; o++) {
      var s = u[o];
      r.element.unit = s;
      for (var c = s.elements, l = 0, d = c.length; l < d; l++) {
        r.element.element = c[l];
        var f = t(r);
        if (i.has(f)) for (var m = i.get(f).array, v = 0, p = m.length; v < p; v++) a[m[v]].addToUnit(s.id, c[l]);
      }
    }
    r.popCurrentElement();
    for (var g = vt.UniqueBuilder(r.inputStructure), h = 0, y = a; h < y.length; h++) {
      var x = y[h];
      g.add(x.getStructure());
    }
    return g.getSelection();
  };
}, includeConnected: function(e) {
  var t = e.query, r = e.layerCount, n = e.wholeResidues, i = e.bondTest, a = e.fixedPoint, o = Math.max(r, 0);
  return function(u) {
    var s = vt.UniqueBuilder(u.inputStructure), c = t(u);
    return u.pushCurrentBond(), u.atomicBond.setTestFn(i), vt.forEach(c, function(l, d) {
      var f = l;
      if (a) for (; ; ) {
        var m = f.elementCount;
        if ((f = XA(u, n, f)).elementCount === m) break;
      }
      else for (var v = 0; v < o; v++) f = XA(u, n, f);
      s.add(f), d % 10 == 0 && u.throwIfTimedOut();
    }), u.popCurrentBond(), s.getSelection();
  };
}, includeSurroundings: function(e, t) {
  return function(r) {
    var n = e(r);
    if (t.elementRadius) {
      var i = R(R({}, t), { elementRadius: t.elementRadius, elementRadiusClosure: Cj(r, t.elementRadius), sourceMaxRadius: wj(r, t.elementRadius) });
      if (vt.isSingleton(n)) {
        var a = KA(r, r.inputStructure, n.structure, i);
        return vt.Singletons(r.inputStructure, a);
      }
      for (var o = new Ky(r.inputStructure), u = 0, s = n.structures; u < s.length; u++) {
        var c = s[u];
        o.add(KA(r, r.inputStructure, c, i));
      }
      return o.getSelection();
    }
    if (vt.isSingleton(n))
      return a = Jy(r, r.inputStructure, n.structure, t), vt.Singletons(r.inputStructure, a);
    o = new Ky(r.inputStructure);
    for (var l = 0, d = n.structures; l < d.length; l++)
      c = d[l], o.add(Jy(r, r.inputStructure, c, t));
    return o.getSelection();
  };
}, intersectBy: function(e, t) {
  return function(r) {
    var n = e(r);
    if (vt.structureCount(n) === 0) return n;
    var i = t(r);
    if (vt.structureCount(i) === 0) return vt.Empty(r.inputStructure);
    var a = vt.unionStructure(i), o = vt.UniqueBuilder(r.inputStructure);
    return vt.forEach(n, function(u, s) {
      var c = function(l, d) {
        if (l === d) return l;
        if (!__(l, d)) return tt.Empty;
        var f, m;
        l.units.length < d.units.length ? (f = l, m = d) : (f = d, m = l);
        for (var v = f.units, p = m.unitMap, g = [], h = 0, y = v.length; h < y; h++) {
          var x = v[h];
          if (p.has(x.id)) {
            var A = p.get(x.id);
            if (qe.areIntersecting(x.elements, A.elements)) {
              var b = qe.intersect(x.elements, A.elements);
              g[g.length] = x.getChild(b);
            }
          }
        }
        return tt.create(g, { parent: l.parent || d.parent });
      }(a, u);
      c.elementCount !== 0 && o.add(c), s % 50 == 0 && r.throwIfTimedOut();
    }), o.getSelection();
  };
}, querySelection: function(e, t) {
  return function(r) {
    var n = e(r);
    if (vt.structureCount(n) === 0) return n;
    var i = vt.UniqueBuilder(r.inputStructure), a = function(o) {
      return i.add(o);
    };
    return vt.forEach(n, function(o, u) {
      r.pushInputStructure(o), vt.forEach(t(r), a), r.popInputStructure(), u % 10 == 0 && r.throwIfTimedOut();
    }), i.getSelection();
  };
}, surroundingLigands: function(e) {
  var t = e.query, r = e.radius, n = e.includeWater;
  return function(i) {
    for (var a = vt.unionStructure(t(i)), o = O1(i, i.inputStructure, Jy(i, i.inputStructure, a, { radius: r })), u = function(j) {
      var X = j.models[0], W = /* @__PURE__ */ new Set();
      if (!mn.is(X.sourceData)) return W;
      for (var Q = X.sourceData.data.db.pdbx_molecule, te = Q._rowCount, ee = Q.asym_id, $ = 0; $ < te; $++) W.add(ee.value($));
      return W;
    }(i.inputStructure), s = function(j) {
      var X, W, Q = j.models[0], te = new Ej();
      if (!mn.is(Q.sourceData)) return te;
      for (var ee = Q.sourceData.data.db.struct_conn, $ = ee.conn_type_id, ie = ee.ptnr1_label_asym_id, ae = ee.ptnr1_label_comp_id, se = ee.ptnr1_label_seq_id, le = ee.ptnr1_symmetry, pe = ee.pdbx_ptnr1_label_alt_id, we = ee.pdbx_ptnr1_PDB_ins_code, Ge = ee.ptnr2_label_asym_id, Ue = ee.ptnr2_label_comp_id, Ke = ee.ptnr2_label_seq_id, Ze = ee.ptnr2_symmetry, Fe = ee.pdbx_ptnr2_label_alt_id, Je = ee.pdbx_ptnr2_PDB_ins_code, Ne = 0; Ne < ee._rowCount; Ne++) {
        var nt = $.value(Ne);
        if (nt === "covale" || nt === "metalc") {
          var re = { label_asym_id: ie.value(Ne), label_comp_id: ae.value(Ne), label_seq_id: se.value(Ne), label_alt_id: pe.value(Ne), ins_code: we.value(Ne), operator_name: (X = le.value(Ne)) !== null && X !== void 0 ? X : "1_555" }, J = { label_asym_id: Ge.value(Ne), label_comp_id: Ue.value(Ne), label_seq_id: Ke.value(Ne), label_alt_id: Fe.value(Ne), ins_code: Je.value(Ne), operator_name: (W = Ze.value(Ne)) !== null && W !== void 0 ? W : "1_555" };
          te.addEdge(re, J);
        }
      }
      return te;
    }(i.inputStructure), c = at.create(o), l = /* @__PURE__ */ new Map(), d = new Up({ checkOperator: !0 }), f = 0, m = o.units; f < m.length; f++)
      if ((B = m[f]).kind === 0) {
        c.unit = B;
        for (var v = B.elements, p = Zt.transientSegments(B.model.atomicHierarchy.chainAtomSegments, v), g = Zt.transientSegments(B.model.atomicHierarchy.residueAtomSegments, v); p.hasNext; ) {
          var h = p.move();
          c.element = v[h.start];
          var y = Qe.chain.label_asym_id(c), x = Qe.unit.operator_name(c);
          if (u.has(y)) l.has(y) ? Su(l.get(y), x) : l.set(y, [x]);
          else {
            var A = Qe.entity.type(c);
            if (A !== "water" && A !== "polymer") for (g.setSegment(h); g.hasNext; ) {
              var b = g.move();
              c.element = v[b.start], s.addComponent(Up.getEntryFromLocation(c), d);
            }
          }
        }
        i.throwIfTimedOut();
      }
    for (var _ = i.inputStructure.subsetBuilder(!0), S = 0, D = i.inputStructure.units; S < D.length; S++)
      if ((B = D[S]).kind === 0) {
        for (c.unit = B, v = B.elements, p = Zt.transientSegments(B.model.atomicHierarchy.chainAtomSegments, v), g = Zt.transientSegments(B.model.atomicHierarchy.residueAtomSegments, v), _.beginUnit(B.id); p.hasNext; )
          if (h = p.move(), c.element = v[h.start], y = Qe.chain.label_asym_id(c), x = Qe.unit.operator_name(c), l.has(y) && l.get(y).indexOf(x) >= 0) _.addElementRange(v, h.start, h.end);
          else if (d.hasLabelAsymId(y)) for (g.setSegment(h); g.hasNext; )
            b = g.move(), c.element = v[b.start], d.has(c) && _.addElementRange(v, b.start, b.end);
        _.commitUnit(), i.throwIfTimedOut();
      }
    var I = T2(i.inputStructure, [_.getStructure(), a]);
    if (n) {
      for (var M = new wg(i.inputStructure), F = i.inputStructure.lookup3d, P = 0, E = I.units; P < E.length; P++) {
        for (var B, N = (B = E[P]).conformation, O = N.x, z = N.y, V = N.z, U = 0, H = (v = B.elements).length; U < H; U++) {
          var K = v[U];
          F.findIntoBuilderIf(O(K), z(K), V(K), r, M, Ij), M.addToUnit(B.id, K);
        }
        i.throwIfTimedOut();
      }
      return vt.Sequence(i.inputStructure, [M.getStructure()]);
    }
    return vt.Sequence(i.inputStructure, [I]);
  };
}, union: function(e) {
  return function(t) {
    var r = vt.LinearBuilder(t.inputStructure);
    return r.add(vt.unionStructure(e(t))), r.getSelection();
  };
}, wholeResidues: function(e) {
  return function(t) {
    var r = e(t);
    if (vt.isSingleton(r)) return vt.Singletons(t.inputStructure, O1(t, t.inputStructure, r.structure));
    for (var n = new Ky(t.inputStructure), i = 0, a = r.structures; i < a.length; i++) {
      var o = a[i];
      n.add(O1(t, t.inputStructure, o));
    }
    return n.getSelection();
  };
} });
function $y(e, t, r) {
  var n = e.currentStructure.units, i = e.pushCurrentElement();
  i.structure = e.currentStructure;
  for (var a = 0, o = n; a < o.length; a++) {
    var u = o[a];
    i.unit = u;
    var s = u.elements, c = void 0;
    if (c = Be.isAtomic(u) ? t.atomic : t.coarse) {
      for (var l = 0, d = s.length; l < d; l++) i.element = s[l], r.add(c(e));
      e.throwIfTimedOut();
    }
  }
  return e.popCurrentElement(), r;
}
(function(e) {
  var t = w.zero();
  function r(a, o, u, s, c, l, d) {
    var f = o.elements, m = o.conformation.position, v = t;
    a.element.unit = o;
    for (var p = !1, g = 0, h = f.length; g < h; g++) {
      var y = f[g];
      a.element.element = y;
      var x = Math.max(0, w.distance(u, m(y, v)) - s - d(a));
      if (x < c) return 0;
      x < l && (p = !0);
    }
    return p ? 1 : 2;
  }
  function n(a, o, u, s, c, l, d) {
    for (var f = o.units, m = !1, v = 0, p = f.length; v < p; v++) {
      var g = r(a, f[v], u, s, c, l, d);
      if (g === 0) return 0;
      g === 1 && (m = !0);
    }
    return m ? 1 : 2;
  }
  e.toPoint = n;
  var i = w.zero();
  e.check = function(a, o, u, s, c, l) {
    if (o.elementCount === 0 || u.elementCount === 0) return 0;
    var d = o.units, f = !1;
    a.element.structure = o;
    for (var m = 0, v = d.length; m < v; m++) {
      var p = d[m], g = p.elements, h = p.conformation.position;
      a.element.unit = p;
      for (var y = 0, x = g.length; y < x; y++) {
        var A = g[y];
        a.element.element = A;
        var b = n(a, u, h(A, i), l(a), s, c, l);
        if (b === 0) return 0;
        b === 1 && (f = !0);
      }
    }
    return f;
  };
})(B2 || (B2 = {})), function(e) {
  var t = w.zero();
  function r(a, o, u, s, c, l) {
    var d = o.elements, f = o.conformation.position, m = t;
    a.element.unit = o;
    for (var v = 0, p = d.length; v < p; v++) {
      var g = d[v];
      if (a.element.element = g, Math.max(0, w.distance(u, f(g, m)) - s - l(a)) <= c) return !0;
    }
    return !1;
  }
  function n(a, o, u, s, c, l) {
    for (var d = o.units, f = 0, m = d.length; f < m; f++) if (r(a, d[f], u, s, c, l)) return !0;
    return !1;
  }
  e.toPoint = n;
  var i = w.zero();
  e.check = function(a, o, u, s, c) {
    if (o.elementCount === 0 || u.elementCount === 0) return 0;
    var l = o.units;
    a.element.structure = o;
    for (var d = 0, f = l.length; d < f; d++) {
      var m = l[d];
      a.element.unit = m;
      for (var v = m.elements, p = m.conformation.position, g = 0, h = v.length; g < h; g++) {
        var y = v[g];
        if (a.element.element = y, n(a, u, p(y, i), c(a), s, c)) return !0;
      }
    }
    return !1;
  };
}(F2 || (F2 = {}));
var Tj = Object.freeze({ __proto__: null, areIntersectedBy: function(e, t) {
  return function(r) {
    var n = vt.unionStructure(t(r)), i = vt.LinearBuilder(r.inputStructure);
    return vt.forEach(e(r), function(a, o) {
      __(n, a) && i.add(a), o % 10 && r.throwIfTimedOut();
    }), i.getSelection();
  };
}, first: function(e) {
  return function(t) {
    var r = e(t), n = vt.LinearBuilder(t.inputStructure);
    if (r.kind === "singletons") {
      if (r.structure.elementCount > 0) {
        var i = r.structure.units[0], a = tt.create([i.getChild(qe.ofSingleton(i.elements[0]))], { parent: t.inputStructure });
        n.add(a);
      }
    } else r.structures.length > 0 && n.add(r.structures[0]);
    return n.getSelection();
  };
}, getCurrentStructureProperties: $y, isConnectedTo: function(e) {
  var t = e.query, r = e.target, n = e.disjunct, i = e.invert, a = e.bondTest;
  return function(o) {
    var u = r(o);
    if (vt.isEmpty(u)) return u;
    var s = t(o);
    if (vt.isEmpty(s)) return s;
    var c = { queryCtx: o, input: o.inputStructure, disjunct: n, target: vt.unionStructure(u) }, l = vt.LinearBuilder(o.inputStructure);
    return o.pushCurrentBond(), o.atomicBond.setTestFn(a), vt.forEach(s, function(d, f) {
      (function(m, v) {
        var p = m.queryCtx, g = m.input, h = m.target, y = m.disjunct, x = p.atomicBond, A = g.interUnitBonds;
        x.setStructure(g);
        for (var b = 0, _ = v.units; b < _.length; b++) {
          var S = _[b];
          if (Be.isAtomic(S)) for (var D = g.unitMap.get(S.id), I = D.bonds, M = I.offset, F = I.b, P = I.edgeProps, E = P.flags, B = P.order, N = A.getConnectedUnits(S.id), O = N.length, z = S.elements, V = D.elements, U = 0, H = z.length; U < H; U++) {
            var K = qe.indexOf(V, z[U]);
            x.a.unit = D, x.b.unit = D;
            for (var j = M[K], X = M[K + 1]; j < X; j++) if (x.b.element = D.elements[F[j]], (!y || !qe.has(S.elements, x.b.element)) && h.hasElement(x.b) && (x.aIndex = K, x.a.element = z[U], x.bIndex = F[j], x.type = E[j], x.order = B[j], x.test(p, !0))) return !0;
            for (var W = 0; W < O; W++) for (var Q = N[W], te = g.unitMap.get(Q.unitB), ee = te.elements, $ = Q.getEdges(K), ie = 0, ae = $.length; ie < ae; ie++) {
              var se = $[ie];
              if (x.b.unit = te, x.b.element = ee[se.indexB], h.hasElement(x.b) && (!y || !v.hasElement(x.b)) && (x.a.unit = D, x.aIndex = K, x.a.element = z[U], x.bIndex = se.indexB, x.type = se.props.flag, x.order = se.props.order, x.test(p, !0))) return !0;
            }
          }
        }
        return !1;
      }(c, d) || i) && l.add(d), f % 5 == 0 && o.throwIfTimedOut();
    }), o.popCurrentBond(), l.getSelection();
  };
}, pick: function(e, t) {
  return function(r) {
    var n = e(r), i = vt.LinearBuilder(r.inputStructure);
    return r.pushCurrentElement(), vt.forEach(n, function(a, o) {
      r.currentStructure = a, t(r) && i.add(a), o % 100 && r.throwIfTimedOut();
    }), r.popCurrentStructure(), i.getSelection();
  };
}, withSameAtomProperties: function(e, t, r) {
  return function(n) {
    var i = e(n), a = function(u, s, c) {
      var l = /* @__PURE__ */ new Set(), d = s(u);
      return u.pushCurrentElement(), vt.forEach(d, function(f, m) {
        u.currentStructure = f, $y(u, c, l), m % 10 && u.throwIfTimedOut();
      }), u.popCurrentElement(), l;
    }(n, t, r), o = vt.LinearBuilder(n.inputStructure);
    return n.pushCurrentStructure(), vt.forEach(i, function(u, s) {
      n.currentStructure = u;
      var c = $y(n, r, /* @__PURE__ */ new Set());
      to.isSuperset(c, a) && o.add(u), s % 10 && n.throwIfTimedOut();
    }), n.popCurrentStructure(), o.getSelection();
  };
}, within: function(e) {
  return function(t) {
    var r = { queryCtx: t, selection: e.query(t), target: e.target(t), maxRadius: e.maxRadius, minRadius: e.minRadius ? Math.max(0, e.minRadius) : 0, elementRadius: e.elementRadius, invert: !!e.invert };
    return r.minRadius === 0 && e.minRadius === void 0 ? function(n) {
      var i = n.queryCtx, a = n.selection, o = n.target, u = n.maxRadius, s = n.invert, c = vt.unionStructure(o).lookup3d, l = vt.LinearBuilder(i.inputStructure), d = w.zero();
      return vt.forEach(a, function(f, m) {
        for (var v = f.units, p = !1, g = 0, h = v.length; g < h; g++) {
          for (var y = v[g], x = y.elements, A = y.conformation, b = A.position, _ = A.r, S = 0, D = x.length; S < D; S++) {
            var I = x[S];
            if (b(I, d), c.check(d[0], d[1], d[2], u + _(I))) {
              p = !0;
              break;
            }
          }
          if (p) break;
        }
        s && (p = !p), p && l.add(f), m % 10 == 0 && i.throwIfTimedOut();
      }), l.getSelection();
    }(r) : r.minRadius === 0 ? function(n) {
      var i = n.queryCtx, a = n.selection, o = n.target, u = n.maxRadius, s = n.invert, c = n.elementRadius, l = vt.unionStructure(o), d = vt.LinearBuilder(i.inputStructure);
      return i.pushCurrentElement(), vt.forEach(a, function(f, m) {
        var v = function(p, g, h, y, x) {
          return g.elementCount === 0 || h.elementCount === 0 || (g.elementCount <= h.elementCount ? F2.check(p, g, h, y, x) : F2.check(p, h, g, y, x));
        }(i, l, f, u, c);
        s && (v = !v), v && d.add(f), m % 10 == 0 && i.throwIfTimedOut();
      }), i.popCurrentElement(), d.getSelection();
    }(r) : function(n) {
      var i = n.queryCtx, a = n.selection, o = n.target, u = n.minRadius, s = n.maxRadius, c = n.invert, l = n.elementRadius, d = vt.unionStructure(o), f = vt.LinearBuilder(i.inputStructure);
      return i.pushCurrentElement(), vt.forEach(a, function(m, v) {
        var p = function(g, h, y, x, A, b) {
          return h.elementCount === 0 || y.elementCount === 0 || (h.elementCount <= y.elementCount ? B2.check(g, h, y, x, A, b) : B2.check(g, y, h, x, A, b));
        }(i, d, m, u, s, l);
        c && (p = !p), p && f.add(m), v % 10 == 0 && i.throwIfTimedOut();
      }), i.popCurrentElement(), f.getSelection();
    }(r);
  };
} }), Eb, Pj = Object.freeze({ __proto__: null, intersect: function(e) {
  return e.length === 0 ? Ab : e.length === 1 ? e[0] : function(t) {
    for (var r = [], n = 0; n < e.length; n++) r.push(e[n](t));
    var i = 0, a = vt.structureCount(r[0]);
    for (n = 1; n < r.length; n++) {
      var o = vt.structureCount(r[n]);
      o < a && (i = n, a = o);
    }
    t.throwIfTimedOut();
    var u = p_(function(l) {
      return l.hashCode;
    }, tt.areUnitIdsAndIndicesEqual);
    vt.forEach(r[i], function(l) {
      return u.add(l);
    });
    for (var s = vt.UniqueBuilder(t.inputStructure), c = 0; c < r.length; c++) c !== i && (vt.forEach(r[c], function(l) {
      u.has(l) && s.add(l);
    }), t.throwIfTimedOut());
    return s.getSelection();
  };
}, merge: function(e) {
  return e.length === 0 ? Ab : e.length === 1 ? e[0] : function(t) {
    for (var r = vt.UniqueBuilder(t.inputStructure), n = function(a) {
      vt.forEach(e[a](t), function(o, u) {
        r.add(o), a % 100 && t.throwIfTimedOut();
      });
    }, i = 0; i < e.length; i++) n(i);
    return r.getSelection();
  };
} });
(function(e) {
  function t(n) {
    return !0;
  }
  function r(n) {
    return !1;
  }
  e.eq = function(n, i) {
    return function(a) {
      return n(a) === i;
    };
  }, e.lt = function(n, i) {
    return function(a) {
      return n(a) < i;
    };
  }, e.lte = function(n, i) {
    return function(a) {
      return n(a) <= i;
    };
  }, e.gt = function(n, i) {
    return function(a) {
      return n(a) > i;
    };
  }, e.gte = function(n, i) {
    return function(a) {
      return n(a) >= i;
    };
  }, e.inSet = function(n, i) {
    if (function(u) {
      return !!u && !!u.has;
    }(i)) return function(u) {
      return i.has(n(u));
    };
    if (i.length === 0) return r;
    for (var a = /* @__PURE__ */ new Set(), o = 0; o < i.length; o++) a.add(i[o]);
    return function(u) {
      return a.has(n(u));
    };
  }, e.and = function() {
    for (var n = [], i = 0; i < arguments.length; i++) n[i] = arguments[i];
    switch (n.length) {
      case 0:
        return t;
      case 1:
        return n[0];
      case 2:
        var a = n[0], o = n[1];
        return function(M) {
          return a(M) && o(M);
        };
      case 3:
        var u = n[0], s = n[1], c = n[2];
        return function(M) {
          return u(M) && s(M) && c(M);
        };
      case 4:
        var l = n[0], d = n[1], f = n[2], m = n[3];
        return function(M) {
          return l(M) && d(M) && f(M) && m(M);
        };
      case 5:
        var v = n[0], p = n[1], g = n[2], h = n[3], y = n[4];
        return function(M) {
          return v(M) && p(M) && g(M) && h(M) && y(M);
        };
      case 6:
        var x = n[0], A = n[1], b = n[2], _ = n[3], S = n[4], D = n[5];
        return function(M) {
          return x(M) && A(M) && b(M) && _(M) && S(M) && D(M);
        };
      default:
        var I = n.length;
        return function(M) {
          for (var F = 0; F < I; F++) if (!n[F]) return !1;
          return !0;
        };
    }
  }, e.or = function() {
    for (var n = [], i = 0; i < arguments.length; i++) n[i] = arguments[i];
    switch (n.length) {
      case 0:
        return r;
      case 1:
        return n[0];
      case 2:
        var a = n[0], o = n[1];
        return function(M) {
          return a(M) || o(M);
        };
      case 3:
        var u = n[0], s = n[1], c = n[2];
        return function(M) {
          return u(M) || s(M) || c(M);
        };
      case 4:
        var l = n[0], d = n[1], f = n[2], m = n[3];
        return function(M) {
          return l(M) || d(M) || f(M) || m(M);
        };
      case 5:
        var v = n[0], p = n[1], g = n[2], h = n[3], y = n[4];
        return function(M) {
          return v(M) || p(M) || g(M) || h(M) || y(M);
        };
      case 6:
        var x = n[0], A = n[1], b = n[2], _ = n[3], S = n[4], D = n[5];
        return function(M) {
          return x(M) || A(M) || b(M) || _(M) || S(M) || D(M);
        };
      default:
        var I = n.length;
        return function(M) {
          for (var F = 0; F < I; F++) if (n[F]) return !0;
          return !1;
        };
    }
  };
})(Eb || (Eb = {}));
var W1, gn = { generators: EX, filters: Tj, modifiers: Mj, combinators: Pj, pred: Eb, internal: wX };
function vT(e, t, r, n, i, a) {
  var o = e.spacegroup, u = e.ncsOperators, s = [], c = o.cell.toFractional, l = w.transformMat4(w(), a, c), d = ho.getSymmetryOperatorRef(o, t, r, n, i, l);
  if (u && u.length) for (var f = 0, m = u.length; f < m; ++f) {
    var v = u[f], p = me.mul(me(), d.matrix, v.matrix), g = hn.create("".concat(d.name, " ").concat(v.name), p, { assembly: d.assembly, ncsId: v.ncsId, hkl: d.hkl, spgrOp: d.spgrOp });
    s.push(g);
  }
  else s.push(d);
  return s;
}
function jA(e, t, r, n) {
  var i = e.spacegroup, a = e.ncsOperators, o = a && a.length || 0, u = [];
  !o && t[0] <= 0 && r[0] >= 0 && t[1] <= 0 && r[1] >= 0 && t[2] <= 0 && r[2] >= 0 && (u[0] = ho.getSymmetryOperator(i, 0, 0, 0, 0));
  for (var s = 0; s < i.operators.length; s++) for (var c = t[0]; c <= r[0]; c++) for (var l = t[1]; l <= r[1]; l++) for (var d = t[2]; d <= r[2]; d++) (o || s !== 0 || c !== 0 || l !== 0 || d !== 0) && u.push.apply(u, vT(e, s, c, l, d, n));
  return u;
}
function YA(e, t) {
  for (var r = tt.Builder({ label: e.label, dynamicBonds: e.dynamicBonds }), n = e.units, i = 0, a = t; i < a.length; i++) for (var o = a[i], u = 0, s = n; u < s.length; u++) {
    var c = s[u];
    r.addWithOperator(c, o);
  }
  return r.getStructure();
}
(function(e) {
  function t(n, i) {
    return n.invariantId === i.invariantId && n.model.id === i.model.id && qe.areEqual(n.elements, i.elements);
  }
  function r() {
    return function(n, i) {
      return new _U(n, i);
    }(Be.hashUnit, t);
  }
  e.buildAssembly = function(n, i) {
    var a = this;
    return er.create("Build Assembly", function(o) {
      return _e(a, 0, void 0, function() {
        var u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _;
        return ye(this, function(S) {
          if ((u = n.models).length !== 1) throw new Error("Can only build assemblies from structures based on 1 model.");
          if (!(s = E2.findAssembly(u[0], i))) throw new Error("Assembly '".concat(i, "' is not defined."));
          for (c = hn.create(s.id, me.identity(), { assembly: { id: s.id, operId: 0, operList: [] } }), l = tt.Builder({ coordinateSystem: c, label: n.label, dynamicBonds: n.dynamicBonds }), d = new ff(n), f = 0, m = s.operatorGroups; f < m.length; f++) if (v = m[f], p = v.selector(d), vt.structureCount(p) !== 0) for (g = vt.unionStructure(p).units, h = 0, y = v.operators; h < y.length; h++) for (x = y[h], A = 0, b = g; A < b.length; A++) _ = b[A], l.addWithOperator(_, x);
          return [2, l.getStructure()];
        });
      });
    });
  }, e.buildSymmetryAssembly = function(n, i, a) {
    var o = this;
    return er.create("Build Symmetry Assembly", function(u) {
      return _e(o, 0, void 0, function() {
        var s, c, l, d, f, m, v, p, g, h, y, x, A, b, _, S, D, I, M, F, P, E, B, N, O;
        return ye(this, function(z) {
          if ((s = n.models).length !== 1) throw new Error("Can only build symmetry assemblies from structures based on 1 model.");
          for (c = w(), l = tt.Builder({ label: n.label, representativeModel: s[0], dynamicBonds: n.dynamicBonds }), d = new ff(n), f = 0, m = i; f < m.length; f++) if (v = m[f], V = v.asymIds, p = gn.generators.atoms({ chainTest: gn.pred.and(gn.pred.eq(function(U) {
            return Qe.unit.operator_name(U.element);
          }, hn.DefaultName), gn.pred.inSet(function(U) {
            return Qe.chain.label_asym_id(U.element);
          }, V)) }), g = p(d), vt.structureCount(g) !== 0) for (h = vt.unionStructure(g).units, y = 0, x = v.operators; y < x.length; y++) for (A = x[y], b = A.index, _ = A.shift, S = _[0], D = _[1], I = _[2], M = vT(a, b, S, D, I, c), F = 0, P = h; F < P.length; F++) for (E = P[F], B = 0, N = M; B < N.length; B++) O = N[B], l.addWithOperator(E, O);
          var V;
          return [2, l.getStructure()];
        });
      });
    });
  }, e.builderSymmetryMates = function(n, i) {
    return er.create("Find Symmetry Mates", function(a) {
      return function(o, u, s) {
        return _e(this, 0, void 0, function() {
          function c(N, O) {
            return "".concat(N.invariantId, "|").concat(O.name);
          }
          var l, d, f, m, v, p, g, h, y, x, A, b, _, S, D, I, M, F, P, E, B;
          return ye(this, function(N) {
            switch (N.label) {
              case 0:
                if ((l = u.models).length !== 1) throw new Error("Can only build symmetries from structures based on 1 model.");
                return (d = ia.Provider.get(l[0])) ? (f = d.spacegroup, Tu.isZero(f.cell) ? [2, u] : o.shouldUpdate ? [4, o.update("Initialing...")] : [3, 2]) : [2, u];
              case 1:
                N.sent(), N.label = 2;
              case 2:
                m = nn.getCenter(l[0]), v = function(O, z) {
                  return O._operators_333 && w.equals(z, O._operators_333.ref) || (O._operators_333 = { ref: w.clone(z), operators: jA(O, w.create(-3, -3, -3), w.create(3, 3, 3), z) }), O._operators_333.operators;
                }(d, m), p = u.lookup3d, g = /* @__PURE__ */ new Set(), h = tt.Builder({ label: u.label, dynamicBonds: u.dynamicBonds }), y = u.units, x = w.zero(), A = 0, b = v, N.label = 3;
              case 3:
                if (!(A < b.length)) return [3, 6];
                for (_ = b[A], S = 0, D = y; S < D.length; S++) for (I = D[S], M = I.lookup3d.boundary.sphere, w.transformMat4(x, M.center, _.matrix), F = p.findUnitIndices(x[0], x[1], x[2], M.radius + s), P = 0, E = F.count; P < E; P++) y[F.indices[P]].lookup3d.check(x[0], x[1], x[2], M.radius + s) && (B = c(I, _), g.has(B) || (h.addWithOperator(I, _), g.add(B)));
                return o.shouldUpdate ? [4, o.update("Building symmetry...")] : [3, 5];
              case 4:
                N.sent(), N.label = 5;
              case 5:
                return A++, [3, 3];
              case 6:
                return [2, h.getStructure()];
            }
          });
        });
      }(a, n, i);
    });
  }, e.buildSymmetryRange = function(n, i, a) {
    return er.create("Build Symmetry", function(o) {
      return function(u, s, c, l) {
        return _e(this, 0, void 0, function() {
          var d, f, m, v, p;
          return ye(this, function(g) {
            if ((d = s.models).length !== 1) throw new Error("Can only build symmetries from structures based on 1 model.");
            return (f = ia.Provider.get(d[0])) ? (m = f.spacegroup, Tu.isZero(m.cell) ? [2, s] : (v = nn.getCenter(d[0]), p = jA(f, c, l, v), [2, YA(s, p)])) : [2, s];
          });
        });
      }(0, n, i, a);
    });
  }, e.buildNcs = function(n) {
    return er.create("Build NCS", function(i) {
      return function(a, o) {
        return _e(this, 0, void 0, function() {
          var u, s, c;
          return ye(this, function(l) {
            if ((u = o.models).length !== 1) throw new Error("Can only build NCS from structures based on 1 model.");
            return (s = ia.Provider.get(u[0])) && (c = s.ncsOperators) && c.length ? [2, YA(o, c)] : [2, o];
          });
        });
      }(0, n);
    });
  }, e.areUnitsEquivalent = t, e.UnitEquivalenceBuilder = r, e.computeTransformGroups = function(n) {
    for (var i = r(), a = 0, o = n.units; a < o.length; a++) {
      var u = o[a];
      i.add(u.id, u);
    }
    for (var s = [], c = 0, l = i.groups; c < l.length; c++) {
      var d = l[c];
      s.push(Be.SymmetryGroup(d.map(function(f) {
        return n.unitMap.get(f);
      })));
    }
    return s;
  }, e.areTransformGroupsEquivalent = function(n, i) {
    if (n.length !== i.length) return !1;
    for (var a = 0, o = n.length; a < o; ++a) {
      var u = n[a].units, s = i[a].units;
      if (u.length !== s.length || n[a].hashCode !== i[a].hashCode) return !1;
      for (var c = 0, l = u.length; c < l; c++) if (u[c].conformation !== s[c].conformation) return !1;
    }
    return !0;
  };
})(W1 || (W1 = {}));
var Bj = function() {
  function e(t, r) {
    this.parent = t, this.isSorted = r, this.ids = [], this.unitMap = Ps.Mutable(), this.parentId = -1, this.currentUnit = [], this.elementCount = 0;
  }
  return e.prototype.addToUnit = function(t, r) {
    var n = this.unitMap.get(t);
    n ? n[n.length] = r : (this.unitMap.set(t, [r]), this.ids[this.ids.length] = t), this.elementCount++;
  }, e.prototype.beginUnit = function(t) {
    this.parentId = t, this.currentUnit = this.currentUnit.length > 0 ? [] : this.currentUnit;
  }, e.prototype.addElement = function(t) {
    this.currentUnit[this.currentUnit.length] = t, this.elementCount++;
  }, e.prototype.addElementRange = function(t, r, n) {
    for (var i = r; i < n; i++) this.currentUnit[this.currentUnit.length] = t[i], this.elementCount++;
  }, e.prototype.commitUnit = function() {
    this.currentUnit.length !== 0 && (this.ids[this.ids.length] = this.parentId, this.unitMap.set(this.parentId, this.currentUnit), this.parentId = -1);
  }, e.prototype.setUnit = function(t, r) {
    this.ids[this.ids.length] = t, this.unitMap.set(t, r), this.elementCount += r.length;
  }, e.prototype._getStructure = function(t) {
    if (this.isEmpty) return tt.Empty;
    var r = [];
    es(this.ids);
    for (var n = W1.UnitEquivalenceBuilder(), i = 0, a = this.ids.length; i < a; i++) {
      var o = this.ids[i], u = this.parent.unitMap.get(o), s = this.unitMap.get(o), c = !1;
      t && (this.isSorted || es(s), s = qe.deduplicate(qe.ofSortedArray(this.currentUnit)), c = !0);
      var l = s.length;
      if (s.length !== u.elements.length) {
        !this.isSorted && !c && l > 1 && es(s);
        var d = u.getChild(qe.ofSortedArray(s)), f = n.add(d.id, d);
        d !== f && (d = f.applyOperator(d.id, d.conformation.operator, !0)), r[r.length] = d;
      } else r[r.length] = u, n.add(u.id, u);
    }
    return tt.create(r, { parent: this.parent });
  }, e.prototype.getStructure = function() {
    return this._getStructure(!1);
  }, e.prototype.getStructureDeduplicate = function() {
    return this._getStructure(!0);
  }, e.prototype.setSingletonLocation = function(t) {
    var r = this.ids[0];
    t.unit = this.parent.unitMap.get(r), t.element = this.unitMap.get(r)[0];
  }, Object.defineProperty(e.prototype, "isEmpty", { get: function() {
    return this.elementCount === 0;
  }, enumerable: !1, configurable: !0 }), e;
}();
function WA(e, t) {
  for (var r = 1; t--; ) r *= e--;
  return r;
}
var Fj = function() {
  function e(t, r) {
    this.array = t, this.hasNext = !1, this.index = (1 << r) - 1, this.size = function(n, i) {
      return i > n ? 0 : WA(n, i) / WA(i, i);
    }(t.length, r), this.maxIndex = 1 << t.length, this.value = new Array(r), this.hasNext = r > 0 && r <= t.length;
  }
  return e.prototype.move = function() {
    if (this.hasNext) {
      for (var t = 0, r = 0, n = this.index; n; n >>>= 1, t++) 1 & n && (this.value[r++] = this.array[t]);
      this.index = function(i) {
        var a = i & -i, o = i + a;
        return o | ((o & -o) / a >> 1) - 1;
      }(this.index), this.hasNext = this.index < this.maxIndex;
    }
    return this.value;
  }, e;
}();
function gT(e, t) {
  for (var r = [], n = new Fj(e, t); n.hasNext; ) r.push(n.move().slice());
  return r;
}
var Dd = [], Nj = { links: Dd, terminalLinks: Dd, elements: Dd, partialElements: Dd, getElementIndices: function() {
  return Dd;
}, getLinkIndices: function() {
  return Dd;
}, getTerminalLinkIndices: function() {
  return Dd;
} }, Ai = q1("C"), Ep = q1("O"), Rj = [Eu.elementFingerprint([Ai, Ai, Ai, Ep]), Eu.elementFingerprint([Ai, Ai, Ai, Ai, Ep]), Eu.elementFingerprint([Ai, Ai, Ai, Ai, Ai, Ep]), Eu.elementFingerprint([Ai, Ai, Ai, Ai, Ai, Ai, Ep])];
function Oj(e, t) {
  for (var r = -1, n = -1, i = -1, a = -1, o = e.elements, u = e.model.atomicHierarchy.atoms, s = u.type_symbol, c = u.label_atom_id, l = e.bonds, d = l.b, f = l.offset, m = 0, v = t.length; m < v; ++m) {
    var p = o[t[m]];
    if (s.value(p) === Ai) {
      for (var g = 0, h = 0, y = f[t[m]], x = f[t[m] + 1]; y < x; ++y) {
        var A = o[d[y]], b = s.value(A);
        b === Ep ? ++g : b === Ai && ++h;
      }
      if (g === 2) {
        r = p;
        break;
      }
      g === 1 && h === 1 ? n = p : c.value(p).startsWith("C1") ? i = p : a = p;
    }
  }
  return r !== -1 ? r : n !== -1 ? n : i !== -1 ? i : a !== -1 ? a : o[t[0]];
}
function Lj(e, t, r, n) {
  var i = t.conformation.position;
  return w.normalize(e, w.sub(e, n, i(r, e))), e;
}
function ZA(e, t) {
  var r = e.elements;
  return e.model.atomicHierarchy.atoms.label_atom_id.value(r[t]);
}
function kj(e, t) {
  if (t && t.length) {
    for (var r = e.unit, n = e.all, i = /* @__PURE__ */ new Set(), a = gT(Fs(new Array(t.length)), 2), o = 0, u = a.length; o < u; ++o) {
      var s = a[o], c = n[t[s[0]]], l = n[t[s[1]]];
      qe.areIntersecting(c, l) && Eu.getAltId(r, c) === Eu.getAltId(r, l) && (i.add(t[s[0]]), i.add(t[s[1]]));
    }
    if (i.size) {
      var d = [];
      for (o = 0, u = t.length; o < u; ++o) i.has(t[o]) || d.push(t[o]);
      return d;
    }
    return t;
  }
}
function zj(e, t) {
  return t.properties.saccharideComponentMap.get(e);
}
function Gj(e) {
  if (e.models.reduce(function(le, pe) {
    return le + pe.properties.saccharideComponentMap.size;
  }, 0) === 0) return Nj;
  var t = [], r = [], n = [], i = [], a = /* @__PURE__ */ new Map();
  function o(le, pe, we) {
    return "".concat(le, "|").concat(pe, "|").concat(we);
  }
  function u(le, pe) {
    a.has(le) ? a.get(le).push(pe) : a.set(le, [pe]);
  }
  function s(le, pe) {
    w.sub(n[le].geometry.direction, n[pe].geometry.center, n[le].geometry.center), w.normalize(n[le].geometry.direction, n[le].geometry.direction);
  }
  var c = w.zero();
  function l(le, pe, we) {
    var Ge = we.conformation.position, Ue = n[le].geometry;
    w.sub(Ue.direction, Ge(we.elements[pe], c), Ue.center), w.normalize(Ue.direction, Ue.direction);
  }
  for (var d = 0, f = e.units.length; d < f; ++d) {
    var m = e.units[d];
    if (Be.isAtomic(m)) for (var v = m.model, p = m.rings, g = v.atomicHierarchy, h = g.chainAtomSegments, y = g.residueAtomSegments, x = g.atoms.label_comp_id, A = Zt.transientSegments(h, m.elements), b = Zt.transientSegments(y, m.elements), _ = void 0; A.hasNext; ) for (b.setSegment(A.move()); b.hasNext; ) {
      var S = b.move().index, D = zj(x.value(y.offsets[S]), v);
      if (D) {
        _ || (_ = I2.byFingerprintAndResidue(p, Rj));
        var I = kj(p, _.get(S));
        if (I && I.length) {
          for (var M = [], F = 0, P = I.length; F < P; ++F) {
            var E = p.all[I[F]], B = Oj(m, E), N = Wl.calculateMomentsAxes(eT(m, E)), O = w.copy(w.zero(), N.origin), z = w.copy(w.zero(), N.dirC), V = Lj(w.zero(), m, B, O);
            w.orthogonalize(V, z, V);
            var U = Eu.getAltId(m, E), H = n.length;
            M.push(H), u(o(S, m.id, U), H), U && u(o(S, m.id, ""), H), n.push({ geometry: { center: O, normal: z, direction: V }, component: D, ringIndex: I[F], altId: U, unit: m, residueIndex: S });
          }
          var K = gT(Fs(new Array(I.length)), 2);
          for (F = 0, P = K.length; F < P; ++F) {
            var j = K[F], X = p.all[I[j[0]]], W = p.all[I[j[1]]];
            if (So.areVertexSetsConnected(m.bonds, X, W, 3)) {
              var Q = M[j[0]], te = M[j[1]];
              n[Q].altId === n[te].altId && (s(Q, te), s(te, Q), t.push({ carbohydrateIndexA: Q, carbohydrateIndexB: te }), t.push({ carbohydrateIndexA: te, carbohydrateIndexB: Q }));
            }
          }
        } else i.push({ unit: m, residueIndex: S, component: D });
      }
    }
  }
  function ee(le, pe) {
    return a.get(o(le.getResidueIndex(pe), le.id, function(we, Ge) {
      var Ue = we.elements;
      return we.model.atomicHierarchy.atoms.label_alt_id.value(Ue[Ge]);
    }(le, pe))) || [];
  }
  for (d = 0, f = n.length; d < f; ++d) {
    var $ = n[d];
    for (m = $.unit, F = d + 1; F < f; ++F) {
      var ie = n[F];
      if (m === ie.unit && $.residueIndex !== ie.residueIndex) {
        var ae = m.rings.all[$.ringIndex], se = m.rings.all[ie.ringIndex];
        So.areVertexSetsConnected(m.bonds, ae, se, 3) && (s(d, F), s(F, d), t.push({ carbohydrateIndexA: d, carbohydrateIndexB: F }), t.push({ carbohydrateIndexA: F, carbohydrateIndexB: d }));
      }
    }
  }
  for (d = 0, f = e.units.length; d < f; ++d)
    m = e.units[d], Be.isAtomic(m) && e.interUnitBonds.getConnectedUnits(m.id).forEach(function(le) {
      le.connectedIndices.forEach(function(pe) {
        le.getEdges(pe).forEach(function(we) {
          var Ge = we.props, Ue = we.indexB;
          if (cr.isCovalent(Ge.flag)) {
            var Ke = e.unitMap.get(le.unitA), Ze = e.unitMap.get(le.unitB), Fe = ee(Ke, pe), Je = ee(Ze, Ue);
            if (Fe.length > 0 && Je.length > 0) for (var Ne = Fe.length, nt = Je.length, re = 0, J = Math.max(Ne, nt); re < J; ++re) {
              var ce = Fe[Math.min(re, Ne - 1)], de = Je[Math.min(re, nt - 1)];
              ((Se = ZA(Ke, pe)).startsWith("O1") || Se.startsWith("C1")) && s(ce, de), t.push({ carbohydrateIndexA: ce, carbohydrateIndexB: de });
            }
            else if (Je.length === 0) for (var ve = 0, he = Fe; ve < he.length; ve++) {
              var Se;
              ce = he[ve], ((Se = ZA(Ke, pe)).startsWith("O1") || Se.startsWith("C1")) && l(ce, Ue, Ze), r.push({ carbohydrateIndex: ce, elementIndex: Ue, elementUnit: Ze, fromCarbohydrate: !0 });
            }
            else if (Fe.length === 0) for (var Re = 0, Ve = Je; Re < Ve.length; Re++)
              de = Ve[Re], r.push({ carbohydrateIndex: de, elementIndex: pe, elementUnit: Ke, fromCarbohydrate: !1 });
          }
        });
      });
    });
  return R({ links: t, terminalLinks: r, elements: n, partialElements: i }, function(le, pe, we) {
    function Ge(nr, Er) {
      return Mu(nr.id, Er);
    }
    function Ue(nr, Er, dr) {
      var ln = [], Gn = nr.get(Ge(Er, dr));
      if (Gn !== void 0) for (var Rn = 0, Cn = Gn; Rn < Cn.length; Rn++)
        Su(ln, Cn[Rn]);
      return ln;
    }
    for (var Ke = /* @__PURE__ */ new Map(), Ze = 0, Fe = le.length; Ze < Fe; ++Ze) for (var Je = le[Ze], Ne = Je.unit, nt = Je.ringIndex, re = 0, J = (De = Ne.rings.all[nt]).length; re < J; ++re) {
      var ce = Ge(Ne, Ne.elements[De[re]]);
      (It = Ke.get(ce)) === void 0 ? Ke.set(ce, [Ze]) : It.push(Ze);
    }
    function de(nr, Er) {
      return Ue(Ke, nr, Er);
    }
    var ve = /* @__PURE__ */ new Map();
    for (Ze = 0, Fe = pe.length; Ze < Fe; ++Ze) {
      var he = le[pe[Ze].carbohydrateIndexA];
      for (Ne = he.unit, nt = he.ringIndex, re = 0, J = (De = Ne.rings.all[nt]).length; re < J; ++re)
        ce = Ge(Ne, Ne.elements[De[re]]), (It = ve.get(ce)) === void 0 ? ve.set(ce, [Ze]) : It.push(Ze);
    }
    function Se(nr, Er) {
      return Ue(ve, nr, Er);
    }
    var Re = /* @__PURE__ */ new Map();
    for (Ze = 0, Fe = we.length; Ze < Fe; ++Ze) {
      var Ve = we[Ze], ze = Ve.fromCarbohydrate, mt = Ve.carbohydrateIndex, bt = Ve.elementUnit, Ct = Ve.elementIndex;
      if (ze) {
        var De, ut = le[mt];
        for (Ne = ut.unit, nt = ut.ringIndex, re = 0, J = (De = Ne.rings.all[nt]).length; re < J; ++re)
          ce = Ge(Ne, Ne.elements[De[re]]), (It = Re.get(ce)) === void 0 ? Re.set(ce, [Ze]) : It.push(Ze);
      } else {
        var It;
        ce = Ge(bt, bt.elements[Ct]), (It = Re.get(ce)) === void 0 ? Re.set(ce, [Ze]) : It.push(Ze);
      }
    }
    function ur(nr, Er) {
      return Ue(Re, nr, Er);
    }
    return { getElementIndices: de, getLinkIndices: Se, getTerminalLinkIndices: ur };
  }(n, t, r));
}
var $h = Me(), Vj = new Nu("14"), Uj = new Nu("98");
function Hj(e) {
  var t = e.units, r = function(s) {
    return s > 500 ? Vj : Uj;
  }(t.length);
  r.reset();
  for (var n = 0, i = t.length; n < i; n++) {
    var a = (o = t[n]).boundary;
    (u = o.conformation.operator).isIdentity ? r.includeSphere(a.sphere) : (Me.transform($h, a.sphere, u.matrix), r.includeSphere($h));
  }
  for (r.finishedIncludeStep(), n = 0, i = t.length; n < i; n++) {
    var o, u;
    a = (o = t[n]).boundary, (u = o.conformation.operator).isIdentity ? r.radiusSphere(a.sphere) : (Me.transform($h, a.sphere, u.matrix), r.radiusSphere($h));
  }
  return { box: r.getBox(), sphere: r.getSphere() };
}
var tt = function() {
  function e(t, r, n, i, a) {
    this.units = t, this.unitMap = r, this.unitIndexMap = n, this.state = i, this._child = a == null ? void 0 : a.child, this._target = a == null ? void 0 : a.target, this._proxy = void 0;
  }
  return e.prototype.subsetBuilder = function(t) {
    return new Bj(this, t);
  }, Object.defineProperty(e.prototype, "elementCount", { get: function() {
    return this.state.elementCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "bondCount", { get: function() {
    return this.state.bondCount === -1 && (this.state.bondCount = this.interUnitBonds.edgeCount + Dt.getIntraUnitBondCount(this)), this.state.bondCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "hasCustomProperties", { get: function() {
    return !!this.state.customProps && this.state.customProps.all.length > 0;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "customPropertyDescriptors", { get: function() {
    return this.state.customProps || (this.state.customProps = new v0()), this.state.customProps;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "currentPropertyData", { get: function() {
    return this.state.propertyData || (this.state.propertyData = /* @__PURE__ */ Object.create(null)), this.state.propertyData;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "inheritedPropertyData", { get: function() {
    return this.parent ? this.parent.currentPropertyData : this.currentPropertyData;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "polymerResidueCount", { get: function() {
    return this.state.polymerResidueCount === -1 && (this.state.polymerResidueCount = function(t) {
      for (var r = t.units, n = 0, i = 0, a = r.length; i < a; i++) n += r[i].polymerElements.length;
      return n;
    }(this)), this.state.polymerResidueCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "polymerGapCount", { get: function() {
    return this.state.polymerGapCount === -1 && (this.state.polymerGapCount = function(t) {
      for (var r = t.units, n = 0, i = 0, a = r.length; i < a; i++) n += r[i].gapElements.length / 2;
      return n;
    }(this)), this.state.polymerGapCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "polymerUnitCount", { get: function() {
    return this.state.polymerUnitCount === -1 && (this.state.polymerUnitCount = function(t) {
      for (var r = t.units, n = 0, i = 0, a = r.length; i < a; i++) r[i].polymerElements.length > 0 && (n += 1);
      return n;
    }(this)), this.state.polymerUnitCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "uniqueElementCount", { get: function() {
    return this.state.uniqueElementCount === -1 && (this.state.uniqueElementCount = function(t) {
      for (var r = t.unitSymmetryGroups, n = 0, i = 0, a = r.length; i < a; i++) n += r[i].elements.length;
      return n;
    }(this)), this.state.uniqueElementCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "atomicResidueCount", { get: function() {
    return this.state.atomicResidueCount === -1 && (this.state.atomicResidueCount = function(t) {
      for (var r = t.units, n = 0, i = 0, a = r.length; i < a; i++) {
        var o = r[i];
        if (Be.isAtomic(o)) for (var u = o.elements, s = o.residueIndex, c = -1, l = -1, d = 0, f = u.length; d < f; ++d) (c = s[u[d]]) !== l && (n += 1, l = c);
      }
      return n;
    }(this)), this.state.atomicResidueCount;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isCoarseGrained", { get: function() {
    return this.models.some(function(t) {
      return nn.isCoarseGrained(t);
    });
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isEmpty", { get: function() {
    return this.units.length === 0;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "hashCode", { get: function() {
    return this.state.hashCode !== -1 ? this.state.hashCode : this.computeHash();
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "transformHash", { get: function() {
    return this.state.transformHash !== -1 || (this.state.transformHash = Ra(this.units.map(function(t) {
      return t.id;
    }))), this.state.transformHash;
  }, enumerable: !1, configurable: !0 }), e.prototype.computeHash = function() {
    for (var t = 23, r = 0, n = this.units.length; r < n; r++) {
      var i = this.units[r];
      t = 31 * (t = 31 * t + i.id | 0) + qe.hashCode(i.elements) | 0;
    }
    return (t = kE(t = 31 * t + this.elementCount | 0)) === -1 && (t = 0), this.state.hashCode = t, t;
  }, e.prototype.elementLocations = function() {
    return new e.ElementLocationIterator(this);
  }, Object.defineProperty(e.prototype, "root", { get: function() {
    var t;
    return (t = this.state.parent) !== null && t !== void 0 ? t : this;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "parent", { get: function() {
    return this.state.parent;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "coordinateSystem", { get: function() {
    return this.state.coordinateSystem;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "label", { get: function() {
    return this.state.label;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "boundary", { get: function() {
    return this.state.boundary || (this.state.boundary = Hj(this)), this.state.boundary;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "lookup3d", { get: function() {
    return this.state.lookup3d || (this.state.lookup3d = new SX(this)), this.state.lookup3d;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "interUnitBonds", { get: function() {
    return this.state.interUnitBonds || (this.parent && this.state.dynamicBonds === this.parent.state.dynamicBonds && this.parent.state.interUnitBonds && this.parent.state.interUnitBonds.edgeCount === 0 ? this.state.interUnitBonds = new C2(/* @__PURE__ */ new Map()) : this.state.interUnitBonds = tX(this, { ignoreWater: !this.dynamicBonds, ignoreIon: !this.dynamicBonds })), this.state.interUnitBonds;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "dynamicBonds", { get: function() {
    return this.state.dynamicBonds;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "unitSymmetryGroups", { get: function() {
    return this.state.unitSymmetryGroups || (this.state.unitSymmetryGroups = W1.computeTransformGroups(this)), this.state.unitSymmetryGroups;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "unitSymmetryGroupsIndexMap", { get: function() {
    return this.state.unitSymmetryGroupsIndexMap || (this.state.unitSymmetryGroupsIndexMap = Be.SymmetryGroup.getUnitSymmetryGroupsIndexMap(this.unitSymmetryGroups)), this.state.unitSymmetryGroupsIndexMap;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "carbohydrates", { get: function() {
    return this.state.carbohydrates || (this.state.carbohydrates = Gj(this)), this.state.carbohydrates;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "models", { get: function() {
    return this.state.models || (this.state.models = function(t) {
      for (var r = t.units, n = cn.create(), i = 0, a = r; i < a.length; i++) {
        var o = a[i];
        cn.add(n, o.model.id, o.model);
      }
      return n.array;
    }(this)), this.state.models;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "uniqueResidueNames", { get: function() {
    return this.state.uniqueResidueNames || (this.state.uniqueResidueNames = function(t) {
      for (var r = Qe.residue.microheterogeneityCompIds, n = /* @__PURE__ */ new Set(), i = at.create(t), a = 0, o = t.unitSymmetryGroups; a < o.length; a++) {
        var u = o[a].units[0];
        if (Be.isAtomic(u)) {
          var s = Zt.transientSegments(u.model.atomicHierarchy.residueAtomSegments, u.elements);
          for (i.unit = u; s.hasNext; ) {
            var c = s.move();
            i.element = u.elements[c.start];
            for (var l = 0, d = r(i); l < d.length; l++) {
              var f = d[l];
              n.add(f);
            }
          }
        }
      }
      return n;
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "uniqueElementSymbols", { get: function() {
    return this.state.uniqueElementSymbols || (this.state.uniqueElementSymbols = function(t) {
      for (var r = Qe.atom.type_symbol, n = /* @__PURE__ */ new Set(), i = at.create(t), a = 0, o = t.unitSymmetryGroups; a < o.length; a++) {
        var u = o[a].units[0];
        if (Be.isAtomic(u)) {
          i.unit = u;
          for (var s = 0, c = u.elements.length; s < c; ++s) i.element = u.elements[s], n.add(r(i));
        }
      }
      return n;
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "entityIndices", { get: function() {
    return this.state.entityIndices || (this.state.entityIndices = function(t) {
      for (var r = t.units, n = at.create(t), i = cn.create(), a = 0, o = r; a < o.length; a++) {
        var u = o[a], s = u.kind === 0 ? Qe.entity.key : Qe.coarse.entityKey;
        n.unit = u;
        for (var c = u.elements, l = Zt.transientSegments(u.model.atomicHierarchy.chainAtomSegments, c); l.hasNext; ) {
          var d = l.move();
          n.element = c[d.start];
          var f = s(n);
          cn.add(i, f, f);
        }
      }
      return es(i.array), i.array;
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "uniqueAtomicResidueIndices", { get: function() {
    return this.state.uniqueAtomicResidueIndices || (this.state.uniqueAtomicResidueIndices = function(t) {
      for (var r = /* @__PURE__ */ new Map(), n = [], i = t.unitSymmetryGroups, a = 0, o = i; a < o.length; a++) {
        var u = o[a].units[0];
        if (Be.isAtomic(u)) {
          var s = void 0;
          r.has(u.model.id) ? s = r.get(u.model.id) : (s = cn.create(), n.push(u.model.id), r.set(u.model.id, s));
          for (var c = Zt.transientSegments(u.model.atomicHierarchy.residueAtomSegments, u.elements); c.hasNext; ) {
            var l = c.move();
            cn.add(s, l.index, l.index);
          }
        }
      }
      for (var d = /* @__PURE__ */ new Map(), f = 0, m = n; f < m.length; f++) {
        var v = m[f], p = r.get(v).array;
        es(p), d.set(v, p);
      }
      return d;
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isAtomic", { get: function() {
    for (var t = 0, r = this.units; t < r.length; t++) {
      var n = r[t];
      if (!Be.isAtomic(n)) return !1;
    }
    return !0;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "hasAtomic", { get: function() {
    for (var t = 0, r = this.units; t < r.length; t++) {
      var n = r[t];
      if (Be.isAtomic(n)) return !0;
    }
    return !1;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isCoarse", { get: function() {
    for (var t = 0, r = this.units; t < r.length; t++) {
      var n = r[t];
      if (!Be.isCoarse(n)) return !1;
    }
    return !0;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "hasCoarse", { get: function() {
    for (var t = 0, r = this.units; t < r.length; t++) {
      var n = r[t];
      if (Be.isCoarse(n)) return !0;
    }
    return !1;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "serialMapping", { get: function() {
    return this.state.serialMapping || (this.state.serialMapping = function(t) {
      for (var r = t.units, n = t.elementCount, i = t.unitIndexMap, a = new Uint32Array(r.length), o = new Uint32Array(n), u = new Uint32Array(n), s = 0, c = 0, l = r.length; s < l; ++s) {
        a[s] = c;
        for (var d = r[s].elements, f = 0, m = d.length; f < m; ++f) {
          var v = c + f;
          o[v] = s, u[v] = d[f];
        }
        c += d.length;
      }
      return { cumulativeUnitElementCount: a, unitIndices: o, elementIndices: u, getSerialIndex: function(p, g) {
        return a[i.get(p.id)] + Le.indexOf(p.elements, g);
      } };
    }(this));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "model", { get: function() {
    if (this.state.model) return this.state.model;
    if (this.state.representativeModel) return this.state.representativeModel;
    if (this.state.masterModel) return this.state.masterModel;
    var t = this.models;
    if (t.length > 1) throw new Error("The structure is based on multiple models and has neither a master- nor a representative-model.");
    return this.state.model = t[0], this.state.model;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "masterModel", { get: function() {
    return this.state.masterModel;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "representativeModel", { get: function() {
    return this.state.representativeModel;
  }, enumerable: !1, configurable: !0 }), e.prototype.hasElement = function(t) {
    return !!this.unitMap.has(t.unit.id) && qe.has(this.unitMap.get(t.unit.id).elements, t.element);
  }, e.prototype.getModelIndex = function(t) {
    return this.models.indexOf(t);
  }, e.prototype.remapModel = function(t) {
    for (var r = this.state, n = r.dynamicBonds, i = r.interUnitBonds, a = r.parent, o = [], u = 0, s = this.unitSymmetryGroups; u < s.length; u++) {
      var c = s[u], l = c.units[0].remapModel(t, n);
      o.push(l);
      for (var d = 1, f = c.units.length; d < f; ++d) {
        var m = c.units[d];
        o.push(m.remapModel(t, n, l.props));
      }
    }
    return e.create(o, { parent: a == null ? void 0 : a.remapModel(t), label: this.label, interUnitBonds: n ? void 0 : i, dynamicBonds: n });
  }, e.prototype.asParent = function() {
    if (this._proxy) return this._proxy;
    if (this.parent) {
      var t = this.parent.coordinateSystem.isIdentity ? this.parent : e.transform(this.parent, this.parent.coordinateSystem.inverse), r = this.coordinateSystem.isIdentity ? t : e.transform(t, this.coordinateSystem.matrix);
      this._proxy = new e(r.units, r.unitMap, r.unitIndexMap, R(R({}, r.state), { dynamicBonds: this.dynamicBonds }), { child: this, target: this.parent });
    } else this._proxy = this;
    return this._proxy;
  }, Object.defineProperty(e.prototype, "child", { get: function() {
    return this._child;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "target", { get: function() {
    var t;
    return (t = this._target) !== null && t !== void 0 ? t : this;
  }, enumerable: !1, configurable: !0 }), e;
}();
function qj(e, t, r) {
  return e[t].id - e[r].id;
}
(function(e) {
  function t(h) {
    return { kind: "structure-loci", structure: h };
  }
  function r(h, y) {
    y === void 0 && (y = {});
    for (var x = Ps.Mutable(), A = Ps.Mutable(), b = 0, _ = !0, S = h.length > 0 ? h[0].id : 0, D = 0, I = h.length; D < I; D++) {
      var M = h[D];
      x.set(M.id, M), b += M.elements.length, M.id < S && (_ = !1), S = M.id;
    }
    for (_ || LE(h, 0, h.length, qj, Zd), D = 0, I = h.length; D < I; D++) A.set(h[D].id, D);
    var F = { hashCode: -1, transformHash: -1, elementCount: b, bondCount: -1, uniqueElementCount: -1, atomicResidueCount: -1, polymerResidueCount: -1, polymerGapCount: -1, polymerUnitCount: -1, dynamicBonds: !1, coordinateSystem: hn.Default, label: "" };
    return y.parent && (F.parent = y.parent.parent || y.parent), y.interUnitBonds && (F.interUnitBonds = y.interUnitBonds), y.dynamicBonds ? F.dynamicBonds = y.dynamicBonds : y.parent && (F.dynamicBonds = y.parent.dynamicBonds), y.coordinateSystem ? F.coordinateSystem = y.coordinateSystem : y.parent && (F.coordinateSystem = y.parent.coordinateSystem), y.label ? F.label = y.label : y.parent && (F.label = y.parent.label), y.masterModel ? F.masterModel = y.masterModel : y.parent && (F.masterModel = y.parent.masterModel), y.representativeModel ? F.representativeModel = y.representativeModel : y.parent && (F.representativeModel = y.parent.representativeModel), new e(h, x, A, F);
  }
  function n(h, y) {
    y === void 0 && (y = {});
    for (var x = h.atomicHierarchy.chainAtomSegments, A = h.atomicHierarchy.index, b = h.atomicHierarchy.chains.auth_asym_id, _ = h.atomicChainOperatorMappinng, S = new o(R({ label: h.label }, y)), D = 0; D < x.count; D++) {
      var I = _.get(D) || hn.Default, M = x.offsets[D];
      pf.chainResidueCount(h.atomicHierarchy, D), x.offsets[D + 1], x.offsets[D];
      var F = !1;
      if (i(h, D)) for (; D + 1 < x.count && i(h, D + 1) && _.get(D) === _.get(D + 1); )
        F = !0, D++;
      else for (; D + 1 < x.count && x.offsets[D + 1] - x.offsets[D] == 1 && x.offsets[D + 2] - x.offsets[D + 1] == 1 && !(A.getEntityFromChain(D) !== A.getEntityFromChain(D + 1) || b.value(D) !== b.value(D + 1) || _.get(D) !== _.get(D + 1)); )
        F = !0, D++;
      var P = qe.ofBounds(M, x.offsets[D + 1]);
      S.addUnit(0, h, I, P, F ? 1 : 0);
    }
    var E = h.coarseHierarchy;
    return E.isDefined && (E.spheres.count > 0 && a(S, h, h.coarseHierarchy.spheres, 1), E.gaussians.count > 0 && a(S, h, h.coarseHierarchy.gaussians, 2)), S.getStructure();
  }
  function i(h, y) {
    var x = h.atomicHierarchy.index.getEntityFromChain(y);
    return h.entities.data.type.value(x) === "water";
  }
  function a(h, y, x, A) {
    for (var b = x.chainElementSegments, _ = 0; _ < b.count; _++) {
      var S = qe.ofBounds(b.offsets[_], b.offsets[_ + 1]);
      h.addUnit(A, y, hn.Default, S, 0);
    }
  }
  e.Empty = r([]), e.Loci = t, e.toStructureElementLoci = function(h) {
    for (var y = [], x = 0, A = h.units; x < A.length; x++) {
      var b = A[x];
      y.push({ unit: b, indices: Ae.ofBounds(0, b.elements.length) });
    }
    return Xe(h, y);
  }, e.toSubStructureElementLoci = function(h, y) {
    return vt.toLociWithSourceUnits(vt.Singletons(h, y));
  }, e.isLoci = function(h) {
    return !!h && h.kind === "structure-loci";
  }, e.areLociEqual = function(h, y) {
    return h.structure === y.structure;
  }, e.isLociEmpty = function(h) {
    return h.structure.isEmpty;
  }, e.remapLoci = function(h, y) {
    return y === h.structure ? h : t(y);
  }, e.create = r, e.ofTrajectory = function(h, y) {
    return _e(this, 0, void 0, function() {
      var x, A, b, _, S, D, I, M, F, P, E, B, N;
      return ye(this, function(O) {
        switch (O.label) {
          case 0:
            if (h.frameCount === 0) return [2, e.Empty];
            x = [], A = void 0, b = 0, _ = 0, S = h.frameCount, O.label = 1;
          case 1:
            return _ < S ? [4, er.resolveInContext(h.getFrameAtIndex(_), y)] : [3, 4];
          case 2:
            for (D = O.sent(), A || (A = D), I = n(D), M = 0, F = I.units.length; M < F; ++M) P = I.units[M], E = P.invariantId + b, B = P.chainGroupId + b, N = Be.create(x.length, E, B, P.traits, P.kind, P.model, P.conformation.operator, P.elements), x.push(N);
            b = x.length, O.label = 3;
          case 3:
            return ++_, [3, 1];
          case 4:
            return [2, r(x, { representativeModel: A, label: A.label })];
        }
      });
    });
  }, e.ofModel = n, e.transform = function(h, y) {
    if (me.isIdentity(y)) return h;
    if (!me.isRotationAndTranslation(y, hn.RotationTranslationEpsilon)) throw new Error("Only rotation/translation combination can be applied.");
    for (var x = [], A = 0, b = h.units; A < b.length; A++) {
      var _ = b[A], S = _.conformation.operator, D = hn.create(S.name, y, S);
      x.push(_.applyOperator(_.id, D));
    }
    var I = h.coordinateSystem;
    return r(x, { parent: h, coordinateSystem: hn.compose(hn.create(I.name, y, I), I) });
  };
  var o = function() {
    function h(y) {
      y === void 0 && (y = {}), this.props = y, this.units = [], this.invariantId = La(), this.chainGroupId = -1, this.inChainGroup = !1, this.p = w(), this.singleElementUnits = /* @__PURE__ */ new Map();
    }
    return h.prototype.beginChainGroup = function() {
      this.chainGroupId++, this.inChainGroup = !0;
    }, h.prototype.endChainGroup = function() {
      this.inChainGroup = !1;
    }, h.prototype.addUnit = function(y, x, A, b, _, S) {
      S === void 0 && (S = this.invariantId());
      var D = this.inChainGroup ? this.chainGroupId : ++this.chainGroupId, I = Be.create(S, S, D, _, y, x, A, b);
      return this.add(I);
    }, h.prototype.add = function(y) {
      if (y.elements.length === 1) {
        y.conformation.position(y.elements[0], this.p);
        var x = [y.invariantId, this.p[0], this.p[1], this.p[2]].join("|");
        if (this.singleElementUnits.has(x)) return this.singleElementUnits.get(x);
        this.singleElementUnits.set(x, y);
      }
      return this.units.push(y), y;
    }, h.prototype.addWithOperator = function(y, x, A) {
      return A === void 0 && (A = !1), this.add(y.applyOperator(this.units.length, x, A));
    }, h.prototype.getStructure = function() {
      return r(this.units, this.props);
    }, Object.defineProperty(h.prototype, "isEmpty", { get: function() {
      return this.units.length === 0;
    }, enumerable: !1, configurable: !0 }), h;
  }();
  function u(h, y) {
    if (h === y) return !0;
    if (h.elementCount !== y.elementCount) return !1;
    var x = h.units.length;
    if (x !== y.units.length) return !1;
    for (var A = 0; A < x; A++) if (h.units[A].id !== y.units[A].id) return !1;
    return !0;
  }
  function s(h, y) {
    return h === y || h.hashCode === y.hashCode && W1.areTransformGroupsEquivalent(h.unitSymmetryGroups, y.unitSymmetryGroups);
  }
  e.StructureBuilder = o, e.Builder = function(h) {
    return h === void 0 && (h = {}), new o(h);
  }, e.hashCode = function(h) {
    return h.hashCode;
  }, e.conformationHash = function(h) {
    return J5(h.units.map(function(y) {
      return Be.conformationId(y);
    }).join("|"));
  }, e.areUnitIdsEqual = u, e.areUnitIdsAndIndicesEqual = function(h, y) {
    if (!u(h, y)) return !1;
    for (var x = 0, A = h.units.length; x < A; x++) if (!qe.areEqual(h.units[x].elements, y.units[x].elements)) return !1;
    return !0;
  }, e.areHierarchiesEqual = function(h, y) {
    if (h.hashCode !== y.hashCode) return !1;
    var x = h.models.length;
    if (x !== y.models.length) return !1;
    for (var A = 0; A < x; A++) if (!nn.areHierarchiesEqual(h.models[A], y.models[A])) return !1;
    return !0;
  }, e.areEquivalent = s, e.areRootsEquivalent = function(h, y) {
    return s(h.root, y.root);
  }, e.areRootsEqual = function(h, y) {
    return h.root === y.root;
  };
  var c = function() {
    function h(y) {
      this.structure = y, this.unitIndex = 0, this.maxIdx = 0, this.idx = -1, this.current = at.create(y), this.hasNext = y.elementCount > 0, this.hasNext && (this.elements = y.units[0].elements, this.maxIdx = this.elements.length - 1, this.current.unit = y.units[0]);
    }
    return h.prototype.move = function() {
      return this.advance(), this.current.element = this.elements[this.idx], this.current;
    }, h.prototype.advance = function() {
      if (this.idx < this.maxIdx) return this.idx++, void (this.idx === this.maxIdx && (this.hasNext = this.unitIndex + 1 < this.structure.units.length));
      this.idx = 0, this.unitIndex++, this.unitIndex >= this.structure.units.length ? this.hasNext = !1 : (this.current.unit = this.structure.units[this.unitIndex], this.elements = this.current.unit.elements, this.maxIdx = this.elements.length - 1, this.maxIdx === 0 && (this.hasNext = this.unitIndex + 1 < this.structure.units.length));
    }, h;
  }();
  e.ElementLocationIterator = c;
  var l = w();
  function d(h, y, x) {
    for (var A = h.elements, b = h.conformation, _ = b.position, S = b.r, D = l, I = Number.MAX_VALUE, M = 0, F = A.length; M < F; M++) {
      var P = A[M], E = w.distance(y, _(P, D)) - x - S(P);
      E < I && (I = E);
    }
    return I;
  }
  function f(h, y, x) {
    for (var A = h.units, b = Number.MAX_VALUE, _ = 0, S = A.length; _ < S; _++) {
      var D = d(A[_], y, x);
      D < b && (b = D);
    }
    return b;
  }
  e.minDistanceToPoint = f;
  var m, v = w();
  function p(h) {
    return h.unitSymmetryGroups.filter(function(y) {
      return y.units[0].polymerElements.length > 0;
    });
  }
  e.distance = function(h, y) {
    if (h.elementCount === 0 || y.elementCount === 0) return 0;
    for (var x = h.units, A = Number.MAX_VALUE, b = 0, _ = x.length; b < _; b++) for (var S = x[b], D = S.elements, I = S.conformation, M = I.position, F = I.r, P = 0, E = D.length; P < E; P++) {
      var B = D[P], N = f(y, M(B, v), F(B));
      N < A && (A = N);
    }
    return A;
  }, e.elementDescription = function(h) {
    return h.elementCount === 1 ? "1 element" : "".concat(h.elementCount, " elements");
  }, e.validUnitPair = function(h, y, x) {
    return !0;
  }, e.eachUnitPair = function(h, y, x) {
    var A = x.maxRadius, b = x.validUnit, _ = x.validUnitPair;
    if (h.units.some(function(O) {
      return b(O);
    })) for (var S = h.lookup3d, D = w(), I = 0, M = h.units; I < M.length; I++) {
      var F = M[I];
      if (b(F)) {
        var P = F.boundary.sphere;
        w.transformMat4(D, P.center, F.conformation.operator.matrix);
        for (var E = S.findUnitIndices(D[0], D[1], D[2], P.radius + A + 9999), B = 0; B < E.count; B++) {
          var N = h.units[E.indices[B]];
          !b(N) || F.id >= N.id || !_(F, N) || (N.elements.length >= F.elements.length ? y(F, N) : y(N, F));
        }
      }
    }
  }, e.eachAtomicHierarchyElement = function(h, y) {
    for (var x = y.chain, A = y.residue, b = y.atom, _ = at.create(h), S = 0, D = h.units; S < D.length; S++) {
      var I = D[S];
      if (I.kind === 0) {
        _.unit = I;
        for (var M = I.elements, F = Zt.transientSegments(I.model.atomicHierarchy.chainAtomSegments, M), P = Zt.transientSegments(I.model.atomicHierarchy.residueAtomSegments, M); F.hasNext; ) {
          var E = F.move();
          if (x && (_.element = M[E.start], x(_)), A || b) for (P.setSegment(E); P.hasNext; ) {
            var B = P.move();
            if (A && (_.element = M[B.start], A(_)), b) for (var N = B.start, O = B.end; N < O; N++) _.element = M[N], b(_);
          }
        }
      }
    }
  }, e.DefaultSizeThresholds = { smallResidueCount: 10, mediumResidueCount: 5e3, largeResidueCount: 3e4, highSymmetryUnitCount: 10, fiberResidueCount: 15 }, function(h) {
    h[h.Small = 0] = "Small", h[h.Medium = 1] = "Medium", h[h.Large = 2] = "Large", h[h.Huge = 3] = "Huge", h[h.Gigantic = 4] = "Gigantic";
  }(m = e.Size || (e.Size = {})), e.getSize = function(h, y, x) {
    y === void 0 && (y = {}), x === void 0 && (x = 1);
    var A = R(R({}, e.DefaultSizeThresholds), y);
    return h.polymerResidueCount >= A.largeResidueCount * x ? function(b, _) {
      var S = p(b);
      return S.length >= 1 && S[0].units.length > _.highSymmetryUnitCount;
    }(h, A) ? m.Huge : m.Gigantic : function(b, _) {
      var S = p(b);
      return S.length === 1 && S[0].units.length > 2 && S[0].units[0].polymerElements.length < _.fiberResidueCount;
    }(h, A) || h.polymerResidueCount < A.smallResidueCount * x ? m.Small : h.polymerResidueCount < A.mediumResidueCount * x ? m.Medium : m.Large;
  }, e.Index = Y1.createSimple("index", "root");
  var g = "__PrincipalAxes__";
  e.getPrincipalAxes = function(h) {
    if (h.currentPropertyData[g]) return h.currentPropertyData[g];
    var y = Xe.getPrincipalAxes(e.toStructureElementLoci(h));
    return h.currentPropertyData[g] = y, y;
  };
})(tt || (tt = {}));
var mf, Kj = di.diff;
function Xe(e, t) {
  return { kind: "element-loci", structure: e, elements: t };
}
function Xj(e) {
  return Be.isAtomic(e.unit) ? e.unit.residueIndex[e.element] : -1;
}
function jj(e) {
  return Be.isAtomic(e.unit) ? e.unit.chainIndex[e.element] : -1;
}
function Yj(e) {
  return Qe.entity.key(e);
}
(function(e) {
  function t(A) {
    for (var b = 0, _ = A.elements; b < _.length; b++) {
      var S = _[b];
      if (Le.size(S.indices) > 0) return !1;
    }
    return !0;
  }
  function r(A) {
    for (var b = 0, _ = 0, S = A.elements; _ < S.length; _++) {
      var D = S[_].indices;
      b += typeof D == "number" ? Kj(D) : D.length;
    }
    return b;
  }
  function n(A) {
    return t(A) ? A : e(A.structure, [{ unit: A.elements[0].unit, indices: Le.ofSingleton(Le.start(A.elements[0].indices)) }]);
  }
  function i(A) {
    return A.length > 3 && qe.isRange(A) ? Ae.ofRange(A[0], A[A.length - 1]) : qe.ofSortedArray(A);
  }
  function a(A, b) {
    for (var _ = [], S = /* @__PURE__ */ new Set(), D = 0, I = A.elements; D < I.length; D++) {
      var M = I[D];
      if (u(M)) _[_.length] = M;
      else if (M.unit.kind === 0) {
        for (var F = M.unit.elements, P = M.unit.model.atomicHierarchy, E = M.unit.model.atomicHierarchy.atoms.label_alt_id, B = P.residueAtomSegments, N = B.index, O = B.offsets, z = [], V = M.indices, U = Le.size(V), H = 0; H < U; ) {
          S.clear();
          var K = F[Le.getAt(V, H)], j = N[K];
          for (S.add(E.value(K)), H++; H < U; ) {
            var X = F[Le.getAt(V, H)];
            if (N[X] !== j) break;
            S.add(E.value(X)), H++;
          }
          for (var W = S.has(""), Q = O[j], te = O[j + 1]; Q < te; Q++) {
            var ee = Le.indexOf(F, Q);
            if (ee >= 0) {
              var $ = E.value(Q);
              b && !W && $ && !S.has($) || (z[z.length] = ee);
            }
          }
        }
        _[_.length] = { unit: M.unit, indices: i(z) };
      } else _[_.length] = M;
    }
    return e(A.structure, _);
  }
  function o(A) {
    switch (A.kind) {
      case 0:
        return A.model.atomicHierarchy.chainAtomSegments;
      case 1:
        return A.model.coarseHierarchy.spheres.chainElementSegments;
      case 2:
        return A.model.coarseHierarchy.gaussians.chainElementSegments;
    }
  }
  function u(A) {
    return A.unit.elements.length === Le.size(A.indices);
  }
  function s(A, b, _) {
    for (var S = o(A).index, D = A.elements, I = 0, M = 0, F = D.length; M < F; M++) {
      var P = S[D[M]];
      b.has(P) && I++;
    }
    if (I !== A.elements.length) {
      var E = new Int32Array(I);
      for (I = 0, M = 0, F = D.length; M < F; M++)
        P = S[D[M]], b.has(P) && (E[I++] = M);
      E.length > 0 && (_[_.length] = { unit: A, indices: i(E) });
    } else _[_.length] = { unit: A, indices: Ae.ofBounds(0, I) };
  }
  function c(A, b, _, S, D) {
    for (var I = o(A.elements[0].unit).index, M = /* @__PURE__ */ new Set(), F = b; F < _; F++) for (var P = A.elements[F], E = P.indices, B = P.unit.elements, N = 0, O = Le.size(E); N < O; N++) M.add(I[B[Le.getAt(E, N)]]);
    if (S) for (var z = A.elements[0].unit, V = 0, U = A.structure.units; V < U.length; V++) {
      var H = U[V];
      Be.areSameChainOperatorGroup(H, z) && s(H, M, D);
    }
    else for (F = b; F < _; F++) s(A.elements[F].unit, M, D);
  }
  function l(A) {
    for (var b = [], _ = 0, S = A.elements.length; _ < S; _++) {
      var D = A.elements[_];
      if (Be.Traits.is(D.unit.traits, 2)) {
        for (var I = _; _ < S && Be.areSameChainOperatorGroup(A.elements[_].unit, D.unit); ) _++;
        var M = _;
        _--, c(A, I, M, !0, b);
      } else u(D) ? b[b.length] = D : c(A, _, _ + 1, !1, b);
    }
    return e(A.structure, b);
  }
  function d(A) {
    return "".concat(A.unit.model.id, "|").concat(Qe.entity.id(A));
  }
  function f(A, b) {
    for (var _ = [], S = 0, D = Le.size(b); S < D; ++S) _.push(A[Le.getAt(b, S)]);
    return qe.ofSortedArray(_);
  }
  function m(A, b) {
    return qe.isRange(A) && qe.areEqual(A, b) ? Ae.ofLength(A.length) : i(qe.indicesOf(A, b));
  }
  e.is = function(A) {
    return !!A && A.kind === "element-loci";
  }, e.areEqual = function(A, b) {
    if (A.structure !== b.structure || A.elements.length !== b.elements.length) return !1;
    for (var _ = 0, S = A.elements.length; _ < S; ++_) {
      var D = A.elements[_], I = b.elements[_];
      if (D.unit.id !== I.unit.id || !Le.areEqual(D.indices, I.indices)) return !1;
    }
    return !0;
  }, e.isEmpty = t, e.isWholeStructure = function(A) {
    return r(A) === A.structure.elementCount;
  }, e.size = r, e.all = function(A) {
    return e(A, A.units.map(function(b) {
      return { unit: b, indices: Le.ofBounds(0, b.elements.length) };
    }));
  }, e.none = function(A) {
    return e(A, []);
  }, e.getFirstLocation = function(A, b) {
    if (!t(A)) {
      var _ = A.elements[0].unit, S = _.elements[Le.getAt(A.elements[0].indices, 0)];
      return b ? (b.structure = A.structure, b.unit = A.elements[0].unit, b.element = S, b) : at.create(A.structure, _, S);
    }
  }, e.firstElement = n, e.firstResidue = function(A) {
    return t(A) ? A : a(n(A));
  }, e.firstChain = function(A) {
    return t(A) ? A : l(n(A));
  }, e.toStructure = function(A) {
    for (var b = [], _ = function(I) {
      var M = I.unit, F = I.indices, P = new Int32Array(Le.size(F));
      Le.forEach(F, function(E, B) {
        return P[B] = M.elements[E];
      }), b.push(M.getChild(qe.ofSortedArray(P)));
    }, S = 0, D = A.elements; S < D.length; S++)
      _(D[S]);
    return tt.create(b, { parent: A.structure.parent });
  }, e.remap = function(A, b) {
    if (b === A.structure) return A;
    var _ = [];
    return A.elements.forEach(function(S) {
      if (b.unitMap.has(S.unit.id)) {
        var D = b.unitMap.get(S.unit.id), I = Le.indexedIntersect(S.indices, S.unit.elements, D.elements);
        Le.size(I) > 0 && _.push({ unit: D, indices: I });
      }
    }), e(b, _);
  }, e.union = function A(b, _) {
    if (b.elements.length > _.elements.length) return A(_, b);
    if (e.isEmpty(b)) return _;
    for (var S = /* @__PURE__ */ new Map(), D = 0, I = b.elements; D < I.length; D++) {
      var M = I[D];
      S.set(M.unit.id, M.indices);
    }
    for (var F = [], P = 0, E = _.elements; P < E.length; P++)
      M = E[P], S.has(M.unit.id) ? (F[F.length] = { unit: M.unit, indices: Le.union(S.get(M.unit.id), M.indices) }, S.delete(M.unit.id)) : F[F.length] = M;
    return S.forEach(function(B, N) {
      F[F.length] = { unit: b.structure.unitMap.get(N), indices: B };
    }), e(b.structure, F);
  }, e.subtract = function(A, b) {
    for (var _ = /* @__PURE__ */ new Map(), S = 0, D = b.elements; S < D.length; S++) {
      var I = D[S];
      _.set(I.unit.id, I.indices);
    }
    for (var M = [], F = 0, P = A.elements; F < P.length; F++)
      if (I = P[F], _.has(I.unit.id)) {
        var E = Le.subtract(I.indices, _.get(I.unit.id));
        if (Le.size(E) === 0) continue;
        M[M.length] = { unit: I.unit, indices: E };
      } else M[M.length] = I;
    return e(A.structure, M);
  }, e.intersect = function(A, b) {
    for (var _ = /* @__PURE__ */ new Map(), S = 0, D = A.elements; S < D.length; S++) {
      var I = D[S];
      _.set(I.unit.id, I.indices);
    }
    for (var M = [], F = 0, P = b.elements; F < P.length; F++)
      if (I = P[F], _.has(I.unit.id)) {
        var E = Le.intersect(_.get(I.unit.id), I.indices);
        Le.size(E) !== 0 && (M[M.length] = { unit: I.unit, indices: E });
      }
    return e(A.structure, M);
  }, e.areIntersecting = function A(b, _) {
    if (b.elements.length > _.elements.length) return A(_, b);
    if (e.isEmpty(b)) return e.isEmpty(_);
    for (var S = /* @__PURE__ */ new Map(), D = 0, I = b.elements; D < I.length; D++) {
      var M = I[D];
      S.set(M.unit.id, M.indices);
    }
    for (var F = 0, P = _.elements; F < P.length; F++)
      if (M = P[F], S.has(M.unit.id) && Le.areIntersecting(S.get(M.unit.id), M.indices)) return !0;
    return !1;
  }, e.isSubset = function(A, b) {
    if (e.isEmpty(A)) return e.isEmpty(b);
    for (var _ = /* @__PURE__ */ new Map(), S = 0, D = A.elements; S < D.length; S++) {
      var I = D[S];
      _.set(I.unit.id, I.indices);
    }
    for (var M = !1, F = 0, P = b.elements; F < P.length; F++)
      if (I = P[F], _.has(I.unit.id)) {
        if (!Le.isSubset(_.get(I.unit.id), I.indices)) return !1;
        M = !0;
      }
    return M;
  }, e.extendToWholeResidues = a, e.extendToWholeChains = l, e.extendToWholeEntities = function(A) {
    for (var b = [], _ = at.create(A.structure), S = /* @__PURE__ */ new Set(), D = A.structure.units, I = 0, M = A.elements.length; I < M; I++) {
      var F = A.elements[I];
      _.unit = F.unit, _.element = F.unit.elements[0], S.add(d(_));
    }
    I = 0;
    for (var P = D.length; I < P; ++I) {
      var E = D[I];
      if (_.unit = E, _.element = E.elements[0], S.has(d(_))) {
        var B = Le.ofBounds(0, E.elements.length);
        b[b.length] = { unit: E, indices: B };
      }
    }
    return e(A.structure, b);
  }, e.extendToWholeModels = function(A) {
    for (var b = [], _ = /* @__PURE__ */ new Set(), S = A.structure.units, D = 0, I = A.elements.length; D < I; D++) {
      var M = A.elements[D];
      _.add(M.unit.model.id);
    }
    D = 0;
    for (var F = S.length; D < F; ++D) {
      var P = S[D];
      if (_.has(P.model.id)) {
        var E = Le.ofBounds(0, P.elements.length);
        b[b.length] = { unit: P, indices: E };
      }
    }
    return e(A.structure, b);
  }, e.extendToAllInstances = function(A) {
    for (var b = [], _ = /* @__PURE__ */ new Map(), S = 0, D = A.elements.length; S < D; S++) {
      var I = A.elements[S], M = I.unit.model, F = f(I.unit.elements, I.indices);
      _.has(M) ? _.set(M, qe.union(F, _.get(M))) : _.set(M, F);
    }
    S = 0;
    for (var P = A.structure.units.length; S < P; ++S) {
      var E = A.structure.units[S];
      if (F = _.get(E.model)) {
        var B = m(E.elements, F);
        Le.size(B) && (b[b.length] = { unit: E, indices: B });
      }
    }
    return e(A.structure, b);
  }, e.extendToWholeOperators = function(A) {
    for (var b = [], _ = /* @__PURE__ */ new Set(), S = A.structure.units, D = 0, I = A.elements.length; D < I; D++) {
      var M = A.elements[D];
      _.add(M.unit.conformation.operator.name);
    }
    D = 0;
    for (var F = S.length; D < F; ++D) {
      var P = S[D];
      if (_.has(P.conformation.operator.name)) {
        var E = Le.ofBounds(0, P.elements.length);
        b[b.length] = { unit: P, indices: E };
      }
    }
    return e(A.structure, b);
  };
  var v = new Nu("98"), p = w();
  e.getBoundary = function(A, b) {
    v.reset();
    for (var _ = 0, S = A.elements; _ < S.length; _++) for (var D = (O = S[_]).indices, I = O.unit.conformation.position, M = O.unit.conformation.r, F = O.unit.elements, P = 0, E = Le.size(D); P < E; P++)
      I(z = F[Le.getAt(D, P)], p), b && w.transformMat4(p, p, b), v.includePositionRadius(p, M(z));
    v.finishedIncludeStep();
    for (var B = 0, N = A.elements; B < N.length; B++) {
      var O;
      for (D = (O = N[B]).indices, I = O.unit.conformation.position, M = O.unit.conformation.r, F = O.unit.elements, P = 0, E = Le.size(D); P < E; P++) {
        var z;
        I(z = F[Le.getAt(D, P)], p), b && w.transformMat4(p, p, b), v.radiusPositionRadius(p, M(z));
      }
    }
    return { box: v.getBox(), sphere: v.getSphere() };
  };
  var g = w();
  function h(A, b, _) {
    _ === void 0 && (_ = 0);
    for (var S = _, D = 0, I = A.elements; D < I.length; D++) {
      for (var M = I[D], F = M.indices, P = M.unit.conformation.position, E = M.unit.elements, B = Le.size(F), N = 0; N < B; N++)
        P(E[Le.getAt(F, N)], g), w.toArray(g, b, S + 3 * N);
      S += 3 * B;
    }
    return b;
  }
  function y(A, b) {
    return Be.isAtomic(A) ? A.model.atomicHierarchy.atomSourceIndex.value(b) : b;
  }
  function x(A, b, _, S, D) {
    es(b);
    for (var I = [], M = [], F = 0, P = b.length; F < P; ) {
      var E = F;
      for (F++; F < P && b[F - 1] + 1 === b[F]; ) F++;
      var B = F;
      if (B - E > 12) I[I.length] = b[E], I[I.length] = b[B - 1];
      else for (var N = E; N < B; N++) M[M.length] = b[N];
    }
    return _ ? { atom: { set: M, ranges: I }, chain: { opName: [A] }, entity: { modelLabel: S, modelIndex: D } } : { atom: { set: M, ranges: I }, chain: { opName: [A] } };
  }
  e.toPositionsArray = h, e.getPrincipalAxes = function(A) {
    var b = r(A), _ = h(A, new Float32Array(3 * b));
    return Wl.ofPositions(_);
  }, e.getPrincipalAxesMany = function(A) {
    var b = 0;
    A.forEach(function(D) {
      b += r(D);
    });
    var _ = new Float32Array(3 * b), S = 0;
    return A.forEach(function(D) {
      h(D, _, S), S += 3 * r(D);
    }), Wl.ofPositions(_);
  }, e.toExpression = function(A) {
    var b;
    if (e.isEmpty(A)) return Nt.struct.generator.empty();
    for (var _ = A.structure.models, S = /* @__PURE__ */ new Map(), D = 0, I = A.elements; D < I.length; D++) {
      var M = (H = I[D]).indices, F = H.unit.elements, P = H.unit.conformation.operator.name, E = void 0;
      S.has(P) ? E = S.get(P).xs : (E = cn.create(), S.set(P, { modelLabel: H.unit.model.label, modelIndex: H.unit.model.modelNum, xs: E }));
      for (var B = 0, N = Le.size(M); B < N; B++) {
        var O = y(H.unit, F[Le.getAt(M, B)]);
        cn.add(E, O, O);
      }
    }
    for (var z = [], V = S.keys(); ; ) {
      var U = V.next();
      if (U.done) break;
      var H = S.get(U.value);
      z.push(x(U.value, H.xs.array, _.length > 1, H.modelLabel, H.modelIndex));
    }
    for (var K = /* @__PURE__ */ new Map(), j = (B = 0, z.length); B < j; ++B) {
      var X = z[B], W = h0(Ra(X.atom.ranges), Ra(X.atom.set));
      P = "".concat(W, "|").concat(X.entity ? X.entity.modelLabel + X.entity.modelIndex : ""), K.has(P) ? (b = K.get(P).chain.opName).push.apply(b, X.chain.opName) : K.set(P, X);
    }
    var Q = [];
    return K.forEach(function(te) {
      var ee = te.atom, $ = ee.ranges, ie = ee.set, ae = te.chain.opName, se = Nt.struct.atomProperty.core.operatorName(), le = Nt.struct.atomProperty.core.sourceIndex(), pe = [];
      ie.length > 0 && (pe[pe.length] = Nt.core.set.has([Nt.core.type.set(ie), le]));
      for (var we = 0, Ge = $.length / 2; we < Ge; we++) pe[pe.length] = Nt.core.rel.inRange([le, $[2 * we], $[2 * we + 1]]);
      if (te.entity) {
        var Ue = te.entity, Ke = Ue.modelLabel, Ze = Ue.modelIndex;
        Q.push(Nt.struct.generator.atomGroups({ "atom-test": pe.length > 1 ? Nt.core.logic.or(pe) : pe[0], "chain-test": ae.length > 1 ? Nt.core.set.has([Nt.core.type.set(ae), se]) : Nt.core.rel.eq([se, ae[0]]), "entity-test": Nt.core.logic.and([Nt.core.rel.eq([Nt.struct.atomProperty.core.modelLabel(), Ke]), Nt.core.rel.eq([Nt.struct.atomProperty.core.modelIndex(), Ze])]) }));
      } else Q.push(Nt.struct.generator.atomGroups({ "atom-test": pe.length > 1 ? Nt.core.logic.or(pe) : pe[0], "chain-test": ae.length > 1 ? Nt.core.set.has([Nt.core.type.set(ae), se]) : Nt.core.rel.eq([se, ae[0]]) }));
    }), Nt.struct.modifier.union([Q.length === 1 ? Q[0] : Nt.struct.combinator.merge(Q.map(function(te) {
      return Nt.struct.modifier.union([te]);
    }))]);
  };
})(Xe || (Xe = {})), function(e) {
  function t() {
    return { elementCount: 0, conformationCount: 0, residueCount: 0, chainCount: 0, unitCount: 0, structureCount: 0, firstElementLoc: at.create(void 0), firstConformationLoc: at.create(void 0), firstResidueLoc: at.create(void 0), firstChainLoc: at.create(void 0), firstUnitLoc: at.create(void 0), firstStructureLoc: at.create(void 0) };
  }
  function r(o, u, s) {
    var c = o.get(u) || 0;
    o.set(u, c + s);
  }
  function n(o, u, s) {
    var c = s.indices, l = s.unit, d = l.elements, f = Le.size(c), m = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map();
    if (f > 0 && at.set(o.firstElementLoc, u, l, d[Le.start(c)]), f === d.length) o.unitCount += 1, o.unitCount === 1 && at.set(o.firstUnitLoc, u, l, d[Le.start(c)]);
    else if (f === 1) {
      if (Be.Traits.is(l.traits, 1)) return;
      o.elementCount += 1, o.elementCount === 1 && at.set(o.firstElementLoc, u, l, d[Le.start(c)]);
    } else if (Be.isAtomic(l)) for (var p = l.model.atomicHierarchy.residueAtomSegments, g = p.index, h = p.offsets, y = l.model.atomicHierarchy.atoms.label_alt_id, x = 0, A = function() {
      m.clear();
      var b = 0, _ = d[Le.getAt(c, x)], S = g[_];
      for (r(m, y.value(_), 1), ++x, ++b; x < f; ) {
        var D = d[Le.getAt(c, x)];
        if (g[D] !== S) break;
        r(m, y.value(D), 1), ++x, ++b;
      }
      if (h[S + 1] - h[S] === b) o.residueCount += 1, o.residueCount === 1 && at.set(o.firstResidueLoc, u, l, h[S]);
      else {
        v.clear();
        for (var I = h[S], M = h[S + 1]; I < M; ++I) r(v, y.value(I), 1);
        v.get("") === m.get("") && m.forEach(function(F, P) {
          if (v.get(P) === F) {
            if (P !== "" && (o.conformationCount += 1, o.conformationCount === 1)) {
              for (var E = h[S], B = h[S + 1]; E < B; ++E) if (P === y.value(E)) {
                at.set(o.firstConformationLoc, u, l, E);
                break;
              }
            }
            b -= F;
          }
        }), o.elementCount += b;
      }
    }; x < f; ) A();
    else o.elementCount += f, o.elementCount === 1 && at.set(o.firstElementLoc, u, l, d[Le.start(c)]);
  }
  function i(o, u, s) {
    var c = s.indices, l = s.unit, d = Le.size(c);
    if (d !== 0) {
      var f = l.elements;
      if (Be.Traits.is(l.traits, 1)) {
        var m = Be.isAtomic(l) ? l.model.atomicHierarchy.chainAtomSegments : Be.isSpheres(l) ? l.model.coarseHierarchy.spheres.chainElementSegments : Be.isGaussians(l) ? l.model.coarseHierarchy.gaussians.chainElementSegments : void 0;
        if (m) for (var v = m.index, p = m.offsets, g = 0; g < d; ) {
          var h = 0, y = f[Le.getAt(c, g)], x = v[y];
          for (++g, ++h; g < d && v[f[Le.getAt(c, g)]] === x; )
            ++g, ++h;
          p[x + 1] - p[x] === h ? (o.chainCount += 1, o.chainCount === 1 && at.set(o.firstChainLoc, u, l, p[x])) : d === 1 && (o.elementCount += 1, o.elementCount === 1 && at.set(o.firstElementLoc, u, l, y));
        }
        else console.warn("StructureElement loci stats: unknown unit type");
      } else d === f.length && (o.chainCount += 1, o.chainCount === 1 && at.set(o.firstChainLoc, u, l, f[Le.start(c)]));
    }
  }
  function a(o, u, s, c, l) {
    var d = s[c], f = Be.isAtomic(d.unit) ? d.unit.model.atomicHierarchy.chainAtomSegments : Be.isSpheres(d.unit) ? d.unit.model.coarseHierarchy.spheres.chainElementSegments : Be.isGaussians(d.unit) ? d.unit.model.coarseHierarchy.gaussians.chainElementSegments : void 0;
    if (f) {
      for (var m = f.index, v = f.offsets, p = /* @__PURE__ */ new Map(), g = c; g < l; g++) {
        var h = (d = s[g]).indices, y = d.unit;
        if ((D = Le.size(h)) !== 0) {
          var x = y.elements;
          if (Be.Traits.is(y.traits, 1)) for (var A = 0; A < D; ) {
            var b = 0, _ = m[I = x[Le.getAt(h, A)]];
            for (++A, ++b; A < D && m[x[Le.getAt(h, A)]] === _; )
              ++A, ++b;
            r(p, _, b);
          }
          else r(p, m[I = x[Le.start(h)]], x.length);
        }
      }
      var S = -1;
      if (p.forEach(function(M, F) {
        v[F + 1] - v[F] === M && (o.chainCount += 1, o.chainCount === 1 && (S = F));
      }), !(S < 0)) for (g = c; g < l; g++) {
        var D;
        if (h = (d = s[g]).indices, y = d.unit, (D = Le.size(h)) !== 0) for (x = y.elements, A = 0; A < D; ) {
          var I;
          if ((_ = m[I = x[Le.getAt(h, A)]]) === S) return void at.set(o.firstChainLoc, u, y, I);
        }
      }
    } else console.warn("StructureElement loci stats: unknown unit type");
  }
  e.create = t, e.ofLoci = function(o) {
    var u = t();
    if (Xe.isEmpty(o)) return u;
    var s = !1;
    if (Xe.isWholeStructure(o)) {
      if (u.structureCount += 1, u.structureCount === 1) {
        var c = o.elements[0], l = c.unit, d = c.indices;
        at.set(u.firstStructureLoc, o.structure, l, l.elements[Le.min(d)]);
      }
    } else for (var f = 0, m = o.elements; f < m.length; f++) {
      var v = m[f];
      n(u, o.structure, v), Be.Traits.is(v.unit.traits, 2) ? s = !0 : i(u, o.structure, v);
    }
    if (s) {
      for (var p = 0, g = o.elements.length; p < g; p++)
        if (v = o.elements[p], Be.Traits.is(v.unit.traits, 2)) {
          for (var h = p; p < g && Be.areSameChainOperatorGroup(o.elements[p].unit, v.unit); ) p++;
          var y = p;
          p--, y - h == 1 ? i(u, o.structure, v) : a(u, o.structure, o.elements, h, y);
        }
    }
    return u;
  }, e.add = function(o, u, s) {
    return u.elementCount === 1 && s.elementCount === 0 ? at.copy(o.firstElementLoc, u.firstElementLoc) : u.elementCount === 0 && s.elementCount === 1 && at.copy(o.firstElementLoc, s.firstElementLoc), u.conformationCount === 1 && s.conformationCount === 0 ? at.copy(o.firstConformationLoc, u.firstConformationLoc) : u.conformationCount === 0 && s.conformationCount === 1 && at.copy(o.firstConformationLoc, s.firstConformationLoc), u.residueCount === 1 && s.residueCount === 0 ? at.copy(o.firstResidueLoc, u.firstResidueLoc) : u.residueCount === 0 && s.residueCount === 1 && at.copy(o.firstResidueLoc, s.firstResidueLoc), u.chainCount === 1 && s.chainCount === 0 ? at.copy(o.firstChainLoc, u.firstChainLoc) : u.chainCount === 0 && s.chainCount === 1 && at.copy(o.firstChainLoc, s.firstChainLoc), u.unitCount === 1 && s.unitCount === 0 ? at.copy(o.firstUnitLoc, u.firstUnitLoc) : u.unitCount === 0 && s.unitCount === 1 && at.copy(o.firstUnitLoc, s.firstUnitLoc), u.structureCount === 1 && s.structureCount === 0 ? at.copy(o.firstStructureLoc, u.firstStructureLoc) : u.structureCount === 0 && s.structureCount === 1 && at.copy(o.firstStructureLoc, s.firstStructureLoc), o.elementCount = u.elementCount + s.elementCount, o.conformationCount = u.conformationCount + s.conformationCount, o.residueCount = u.residueCount + s.residueCount, o.chainCount = u.chainCount + s.chainCount, o.unitCount = u.unitCount + s.unitCount, o.structureCount = u.structureCount + s.structureCount, o;
  };
}(mf || (mf = {}));
var L1, QA;
(function(e) {
  function t(r) {
    var n = this, i = r.descriptor.name, a = r.type === "static" ? "_staticPropertyData" : "_dynamicPropertyData", o = function(s) {
      return i in s[a] || (s[a][i] = { props: R({}, G.getDefaultValues(r.getParams(s))), data: Ll.create(void 0) }), s[a][i];
    }, u = function(s, c, l) {
      var d = o(s);
      s[a][i] = { props: c, data: Ll.withValue(d.data, l) };
    };
    return { label: r.label, descriptor: r.descriptor, isHidden: r.isHidden, getParams: function(s) {
      var c = G.clone(r.getParams(s));
      return G.setDefaultValues(c, o(s).props), c;
    }, defaultParams: r.defaultParams, isApplicable: r.isApplicable, attach: function(s, c, l, d) {
      return l === void 0 && (l = {}), _e(n, 0, void 0, function() {
        var f, m, v, p, g;
        return ye(this, function(h) {
          switch (h.label) {
            case 0:
              return d && c.customProperties.reference(r.descriptor, !0), f = o(c), m = G.merge(r.defaultParams, f.props, l), f.data.value && G.areEqual(r.defaultParams, f.props, m) ? [2] : [4, r.obtain(s, c, m)];
            case 1:
              return v = h.sent(), p = v.value, g = v.assets, c.customProperties.add(r.descriptor), c.customProperties.assets(r.descriptor, g), u(c, m, p), [2];
          }
        });
      });
    }, ref: function(s, c) {
      return s.customProperties.reference(r.descriptor, c);
    }, get: function(s) {
      var c;
      return (c = o(s)) === null || c === void 0 ? void 0 : c.data;
    }, set: function(s, c) {
      c === void 0 && (c = {});
      var l = o(s), d = G.merge(r.defaultParams, l.props, c);
      G.areEqual(r.defaultParams, l.props, d) || (u(s, d, void 0), s.customProperties.assets(r.descriptor));
    }, props: function(s) {
      return o(s).props;
    } };
  }
  e.createProvider = t, e.createSimple = function(r, n, i) {
    var a = this, o = { value: G.Value(i, { isHidden: !0 }) };
    return t({ label: Is(r), descriptor: rs({ name: r }), isHidden: !0, type: n, defaultParams: o, getParams: function() {
      return { value: G.Value(i, { isHidden: !0 }) };
    }, isApplicable: function() {
      return !0;
    }, obtain: function(u, s, c) {
      return _e(a, 0, void 0, function() {
        var l;
        return ye(this, function(d) {
          return [2, { value: (l = c.value) !== null && l !== void 0 ? l : i }];
        });
      });
    } });
  };
})(L1 || (L1 = {})), function(e) {
  var t = this;
  function r(i) {
    if (!mn.is(i.sourceData)) return !1;
    var a = i.sourceData.data.db.atom_site, o = a.pdbx_sifts_xref_db_name, u = a.pdbx_sifts_xref_db_acc, s = a.pdbx_sifts_xref_db_num, c = a.pdbx_sifts_xref_db_res;
    return o.isDefined && u.isDefined && s.isDefined && c.isDefined;
  }
  function n(i) {
    if (mn.is(i.sourceData)) {
      var a = i.sourceData.data.db.atom_site, o = a.pdbx_sifts_xref_db_name, u = a.pdbx_sifts_xref_db_acc, s = a.pdbx_sifts_xref_db_num, c = a.pdbx_sifts_xref_db_res;
      if (o.isDefined && u.isDefined && s.isDefined && c.isDefined) {
        for (var l = i.atomicHierarchy.atomSourceIndex, d = i.atomicHierarchy.residueAtomSegments, f = d.count, m = d.offsets, v = new Array(f), p = new Array(f), g = new Array(f), h = new Array(f), y = 0; y < f; y++) {
          var x = l.value(m[y]);
          o.valueKind(x) === 0 ? (v[y] = o.value(x), p[y] = u.value(x), g[y] = s.value(x), h[y] = c.value(x)) : (v[y] = "", p[y] = "", g[y] = "", h[y] = "");
        }
        return { dbName: v, accession: p, num: g, residue: h };
      }
    }
  }
  e.Provider = L1.createProvider({ label: "SIFTS Mapping", descriptor: rs({ name: "sifts_sequence_mapping" }), type: "static", defaultParams: {}, getParams: function() {
    return {};
  }, isApplicable: function(i) {
    return r(i);
  }, obtain: function(i, a) {
    return _e(t, 0, void 0, function() {
      return ye(this, function(o) {
        return [2, { value: n(a) }];
      });
    });
  } }), e.isAvailable = r, e.getKey = function(i) {
    var a = i.unit.model, o = e.Provider.get(a).value;
    if (!o) return "";
    var u = i.unit.elements[i.element], s = a.atomicHierarchy.residueAtomSegments.index[u];
    return o.accession[s];
  }, e.getLabel = function(i) {
    var a = i.unit.model, o = e.Provider.get(a).value;
    if (o) {
      var u = i.unit.elements[i.element], s = a.atomicHierarchy.residueAtomSegments.index[u], c = o.dbName[s];
      if (c) return "".concat(c, " ").concat(o.accession[s], " ").concat(o.num[s], " ").concat(o.residue[s]);
    }
  };
}(QA || (QA = {})), ki.Field;
ki.Encodings;
ki.Field;
ki.Category;
ki.Category;
var JA;
ki.Category;
(function(e) {
  e.create = function(t) {
    var r = Array.isArray(t) ? t : [t];
    return { structures: r, firstModel: r[0].model, cache: /* @__PURE__ */ Object.create(null) };
  };
})(JA || (JA = {}));
var $A;
(function(e) {
  e.AtomSitePositionsFieldNames = /* @__PURE__ */ new Set(["id", "Cartn_x", "Cartn_y", "Cartn_z"]);
})($A || ($A = {}));
var Wj = { molstar_atom_site_operator_mapping: { label_asym_id: oe.Schema.Str(), auth_asym_id: oe.Schema.Str(), operator_name: oe.Schema.Str(), suffix: oe.Schema.Str(), assembly_id: oe.Schema.Str(), assembly_operator_id: oe.Schema.Int(), symmetry_operator_index: oe.Schema.Int(), symmetry_hkl: oe.Schema.Vector(3), ncs_id: oe.Schema.Int() } }, eS = function(e, t) {
  return t[e].operator.assembly === void 0 ? 1 : 0;
}, e4 = function(e, t) {
  return t[e].operator.spgrOp === -1 ? 1 : 0;
};
ki.fields().str("label_asym_id", function(e, t) {
  return t[e].label_asym_id;
}).str("auth_asym_id", function(e, t) {
  return t[e].auth_asym_id;
}).str("operator_name", function(e, t) {
  return t[e].operator.name;
}).str("suffix", function(e, t) {
  return t[e].operator.suffix;
}).str("assembly_id", function(e, t) {
  var r;
  return ((r = t[e].operator.assembly) === null || r === void 0 ? void 0 : r.id) || "";
}, { valueKind: eS }).int("assembly_operator_id", function(e, t) {
  var r;
  return ((r = t[e].operator.assembly) === null || r === void 0 ? void 0 : r.operId) || 0;
}, { valueKind: eS }).int("symmetry_operator_index", function(e, t) {
  return t[e].operator.spgrOp;
}, { valueKind: e4 }).vec("symmetry_hkl", [function(e, t) {
  return t[e].operator.hkl[0];
}, function(e, t) {
  return t[e].operator.hkl[1];
}, function(e, t) {
  return t[e].operator.hkl[2];
}], { valueKind: e4 }).int("ncs_id", function(e, t) {
  return t[e].operator.ncsId;
}, { valueKind: e4 }).getFields();
function Hp(e, t) {
  return t ? t.length === 1 ? Mu(t.charCodeAt(0), e) : t.length === 2 ? Mu(t.charCodeAt(0), Mu(t.charCodeAt(1), e)) : "".concat(e, " ").concat(t) : e;
}
function Zj(e, t, r, n) {
  if (e.has(t))
    (i = e.get(t)).has(r) || i.set(r, n);
  else {
    var i = /* @__PURE__ */ new Map();
    e.set(t, i), i.set(r, n);
  }
}
function Qj(e) {
  throw new Error("Missing entity entry for entity id '".concat(e, "'."));
}
var W0 = Db.EmptyResidueKey(), Jj = function() {
  function e(t) {
    this.map = t, this.entityIndex = t.entities.getEntityIndex, this.residueOffsets = this.map.segments.residueAtomSegments.offsets;
  }
  return e.prototype.getEntityFromChain = function(t) {
    return this.map.chain_index_entity_index[t];
  }, e.prototype.findEntity = function(t) {
    var r = this.map.label_asym_id.get(t);
    return r !== void 0 ? r : -1;
  }, e.prototype.findChainLabel = function(t) {
    var r = this.entityIndex(t.label_entity_id);
    if (r < 0 || !this.map.entity_index_label_asym_id.has(r)) return -1;
    var n = this.map.entity_index_label_asym_id.get(r);
    return n && n.has(t.label_asym_id) ? n.get(t.label_asym_id) : -1;
  }, e.prototype.findChainAuth = function(t) {
    if (!this.map.auth_asym_id_auth_seq_id.has(t.auth_asym_id)) return -1;
    var r = this.map.auth_asym_id_auth_seq_id.get(t.auth_asym_id);
    return r.has(t.auth_seq_id) ? r.get(t.auth_seq_id) : -1;
  }, e.prototype.findResidue = function(t, r, n, i) {
    var a;
    arguments.length === 1 ? a = t : (W0.label_entity_id = t, W0.label_asym_id = r, W0.auth_seq_id = n, W0.pdbx_PDB_ins_code = i, a = W0);
    var o = this.findChainLabel(a);
    if (o < 0) return -1;
    var u = this.map.chain_index_auth_seq_id.get(o), s = Hp(a.auth_seq_id, a.pdbx_PDB_ins_code || "");
    return u.has(s) ? u.get(s) : -1;
  }, e.prototype.findResidueAuth = function(t) {
    var r = this.findChainAuth(t);
    if (r < 0) return -1;
    var n = this.map.chain_index_auth_seq_id.get(r), i = Hp(t.auth_seq_id, t.pdbx_PDB_ins_code || "");
    return n.has(i) ? n.get(i) : -1;
  }, e.prototype.findResidueInsertion = function(t) {
    var r = this.findChainLabel(t);
    if (r < 0) return -1;
    var n = this.map.chain_index_label_seq_id.get(r), i = Hp(t.label_seq_id, t.pdbx_PDB_ins_code || "");
    if (n.has(i)) return n.get(i);
    var a = qe.findPredecessorIndex(this.map.label_seq_id, t.label_seq_id), o = pf.chainStartResidueIndex(this.map.segments, r);
    if (a < o) return o;
    var u = pf.chainEndResidueIndexExcl(this.map.segments, r) - 1;
    return a >= u ? u : a;
  }, e.prototype.findAtom = function(t) {
    var r = this.findResidue(t);
    return r < 0 ? -1 : t.label_alt_id === void 0 ? t4(this.residueOffsets[r], this.residueOffsets[r + 1], this.map.label_atom_id, t.label_atom_id) : r4(this.residueOffsets[r], this.residueOffsets[r + 1], this.map.label_atom_id, this.map.label_alt_id, t.label_atom_id, t.label_alt_id);
  }, e.prototype.findAtomAuth = function(t) {
    var r = this.findResidueAuth(t);
    return r < 0 ? -1 : t.label_alt_id === void 0 ? t4(this.residueOffsets[r], this.residueOffsets[r + 1], this.map.auth_atom_id, t.auth_atom_id) : r4(this.residueOffsets[r], this.residueOffsets[r + 1], this.map.auth_atom_id, this.map.label_alt_id, t.auth_atom_id, t.label_alt_id);
  }, e.prototype.findAtomOnResidue = function(t, r, n) {
    return n === void 0 ? t4(this.residueOffsets[t], this.residueOffsets[t + 1], this.map.label_atom_id, r) : r4(this.residueOffsets[t], this.residueOffsets[t + 1], this.map.label_atom_id, this.map.label_alt_id, r, n);
  }, e.prototype.findAtomsOnResidue = function(t, r) {
    return function(n, i, a, o) {
      for (var u = n; u < i; u++) if (o.has(a.value(u))) return u;
      return -1;
    }(this.residueOffsets[t], this.residueOffsets[t + 1], this.map.label_atom_id, r);
  }, e.prototype.findElementOnResidue = function(t, r) {
    return function(n, i, a, o) {
      for (var u = n; u < i; u++) if (a.value(u) === o) return u;
      return -1;
    }(this.residueOffsets[t], this.residueOffsets[t + 1], this.map.type_symbol, r);
  }, e;
}();
function t4(e, t, r, n) {
  for (var i = e; i < t; i++) if (r.value(i) === n) return i;
  return -1;
}
function r4(e, t, r, n, i, a) {
  for (var o = e; o < t; o++) if (r.value(o) === i && n.value(o) === a) return o;
  return -1;
}
function $j(e, t, r) {
  for (var n = function(M, F, P) {
    return { entities: M, segments: P, label_seq_id: qe.ofSortedArray(F.residues.label_seq_id.toArray({ array: Int32Array })), label_atom_id: F.atoms.label_atom_id, auth_atom_id: F.atoms.auth_atom_id, label_alt_id: F.atoms.label_alt_id, type_symbol: F.atoms.type_symbol, chain_index_entity_index: new Int32Array(F.chains._rowCount), entity_index_label_asym_id: /* @__PURE__ */ new Map(), chain_index_label_seq_id: /* @__PURE__ */ new Map(), auth_asym_id_auth_seq_id: /* @__PURE__ */ new Map(), chain_index_auth_seq_id: /* @__PURE__ */ new Map(), label_asym_id: /* @__PURE__ */ new Map() };
  }(t, e, r), i = e.residues, a = i.label_seq_id, o = i.auth_seq_id, u = i.pdbx_PDB_ins_code, s = e.chains, c = s.label_entity_id, l = s.label_asym_id, d = s.auth_asym_id, f = Ae.ofBounds(0, e.atoms._rowCount), m = Zt.transientSegments(r.chainAtomSegments, f); m.hasNext; ) {
    var v = m.move(), p = v.index, g = t.getEntityIndex(c.value(p));
    g < 0 && Qj(c.value(p)), n.chain_index_entity_index[p] = g;
    var h = d.value(p), y = n.auth_asym_id_auth_seq_id.get(h);
    y || (y = /* @__PURE__ */ new Map(), n.auth_asym_id_auth_seq_id.set(h, y));
    var x = l.value(p);
    n.label_asym_id.has(x) || n.label_asym_id.set(x, g), Zj(n.entity_index_label_asym_id, g, x, p);
    var A = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map();
    n.chain_index_label_seq_id.set(p, A), n.chain_index_auth_seq_id.set(p, b);
    for (var _ = Zt.transientSegments(r.residueAtomSegments, f, v); _.hasNext; ) {
      var S = _.move().index, D = o.value(S), I = u.value(S);
      A.set(Hp(a.value(S), I), S), b.set(Hp(D, I), S), y.set(D, p);
    }
  }
  return new Jj(n);
}
function eY(e, t, r, n, i, a) {
  var o = function(f) {
    if (f._rowCount === 0) return { residues: [], chains: [] };
    for (var m = f._rowCount, v = [0], p = [0], g = f.label_entity_id, h = f.label_asym_id, y = f.label_seq_id, x = f.auth_seq_id, A = f.pdbx_PDB_ins_code, b = 1; b < m; b++) {
      var _ = !g.areValuesEqual(b - 1, b) || !h.areValuesEqual(b - 1, b);
      (_ || !y.areValuesEqual(b - 1, b) || !x.areValuesEqual(b - 1, b) || !A.areValuesEqual(b - 1, b)) && (v[v.length] = b), _ && (p[p.length] = b);
    }
    return { residues: v, chains: p };
  }(e), u = function(f, m, v) {
    var p = Or.ofColumns(XX, { type_symbol: oe.ofArray({ array: oe.mapToArray(f.type_symbol, q1), schema: oe.Schema.Aliased(oe.Schema.str) }), label_atom_id: f.label_atom_id, auth_atom_id: f.auth_atom_id, label_alt_id: f.label_alt_id, label_comp_id: f.label_comp_id, auth_comp_id: f.auth_comp_id, pdbx_formal_charge: f.pdbx_formal_charge, cdr: f.cdr, B_iso_or_equiv: f.B_iso_or_equiv, em_confidence: f.em_confidence }), g = Or.view(f, jX, v.residues), h = Or.view(f, YX, v.chains);
    if (!g.label_seq_id.isDefined) {
      for (var y = new Int32Array(g.label_seq_id.rowCount), x = v.residues, A = v.chains, b = 0, _ = 0, S = 0, D = y.length; S < D; ++S) x[S] >= A[b + 1] && (b += 1, _ = 0), y[S] = ++_;
      g.label_seq_id = oe.ofIntArray(y);
    }
    return Or.columnToArray(g, "label_seq_id", Int32Array), Or.columnToArray(g, "auth_seq_id", Int32Array), { atoms: p, residues: g, chains: h, atomSourceIndex: m };
  }(e, t, o), s = function(f, m) {
    var v = /* @__PURE__ */ new Map();
    if (!mn.is(m)) return v;
    var p = Kd(Wj, m.data.frame).molstar_atom_site_operator_mapping;
    if (p._rowCount === 0) return v;
    for (var g = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), y = 0; y < p._rowCount; y++) {
      var x = p.assembly_operator_id.valueKind(y) === 0 ? { id: p.assembly_id.value(y), operList: [], operId: p.assembly_operator_id.value(y) } : void 0, A = hn.create(p.operator_name.value(y), me.identity(), { assembly: x, spgrOp: p.symmetry_operator_index.valueKind(y) === 0 ? p.symmetry_operator_index.value(y) : void 0, hkl: w.ofArray(p.symmetry_hkl.value(y)), ncsId: p.ncs_id.value(y) }), b = p.suffix.value(y), _ = p.label_asym_id.value(y);
      g.set("".concat(_).concat(b), { name: _, operator: A });
      var S = p.auth_asym_id.value(y);
      h.set("".concat(S).concat(b), S);
    }
    var D = f.chains, I = D.label_asym_id, M = D.auth_asym_id, F = new Array(I.rowCount), P = new Array(I.rowCount);
    for (y = 0; y < I.rowCount; y++) if (_ = I.value(y), S = M.value(y), g.has(_)) {
      var E = g.get(_), B = E.name;
      A = E.operator, v.set(y, A), F[y] = B, P[y] = h.get(S) || S;
    } else F[y] = _, P[y] = S;
    return f.chains.label_asym_id = oe.ofArray({ array: F, valueKind: f.chains.label_asym_id.valueKind, schema: f.chains.label_asym_id.schema }), f.chains.auth_asym_id = oe.ofArray({ array: P, valueKind: f.chains.auth_asym_id.valueKind, schema: f.chains.auth_asym_id.schema }), v;
  }(u, i);
  if (a && function(f, m) {
    return Or.areEqual(f.chains, m.chains) && Or.areEqual(f.residues, m.residues) && Or.areEqual(f.atoms, m.atoms);
  }(a.atomicHierarchy, u)) return { sameAsPrevious: !0, hierarchy: a.atomicHierarchy, chainOperatorMapping: s };
  var c = { residueAtomSegments: Zt.ofOffsets(o.residues, Ae.ofBounds(0, e._rowCount)), chainAtomSegments: Zt.ofOffsets(o.chains, Ae.ofBounds(0, e._rowCount)) }, l = $j(u, r, c), d = function(f, m, v, p) {
    for (var g = f.atoms, h = g.label_comp_id, y = g.type_symbol, x = g._rowCount, A = f.residues._rowCount, b = m.residueAtomSegments.offsets, _ = new Uint8Array(x), S = 0; S < x; ++S) _[S] = im(y.value(S));
    var D = new Int32Array(A), I = new Int32Array(A), M = new Int32Array(A), F = new Uint8Array(A), P = new Uint8Array(A), E = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map();
    for (S = 0; S < A; ++S) {
      var N = h.value(b[S]), O = p, z = void 0, V = void 0;
      if (E.has(N)) z = E.get(N), V = B.get(N);
      else {
        var U = void 0;
        O.has(N) ? U = O.get(N).type : (tM || console.info("chemComp not found", N), U = qM(N)), V = PK(U, z = Dm(U, N)), E.set(N, z), B.set(N, V);
      }
      F[S] = z, P[S] = V;
      var H = Ul(V, "trace"), K = v.findAtomsOnResidue(S, H);
      if (K === -1) {
        var j = Ul(V, "coarseBackbone");
        (K = v.findAtomsOnResidue(S, j)) === -1 && b_(z) && (K = v.findElementOnResidue(S, q1("C")));
      }
      D[S] = K;
      var X = Ul(V, "directionFrom");
      I[S] = v.findAtomsOnResidue(S, X);
      var W = Ul(V, "directionTo");
      M[S] = v.findAtomsOnResidue(S, W);
    }
    return { atom: { atomicNumber: _ }, residue: { traceElementIndex: D, directionFromElementIndex: I, directionToElementIndex: M, moleculeType: F, polymerType: P } };
  }(u, c, l, n);
  return { sameAsPrevious: !1, hierarchy: R(R(R({}, u), c), { index: l, derived: d }), chainOperatorMapping: s };
}
function yT(e, t, r, n, i, a) {
  var o = eY(e, t, r, n, i, a), u = o.sameAsPrevious, s = o.hierarchy, c = o.chainOperatorMapping, l = function(d) {
    return { id: Ii.create22(), atomId: d.id, occupancy: d.occupancy.isDefined ? d.occupancy : oe.ofConst(1, d._rowCount, oe.Schema.float), B_iso_or_equiv: d.B_iso_or_equiv, xyzDefined: d.Cartn_x.isDefined && d.Cartn_y.isDefined && d.Cartn_z.isDefined, x: d.Cartn_x.toArray({ array: Float32Array }), y: d.Cartn_y.toArray({ array: Float32Array }), z: d.Cartn_z.toArray({ array: Float32Array }) };
  }(e);
  return { sameAsPrevious: u, hierarchy: s, conformation: l, chainOperatorMapping: c };
}
var Mb, tS = { chainKey: [], entityKey: [], findSequenceKey: function() {
  return -1;
}, findChainKey: function() {
  return -1;
}, getEntityFromChain: function() {
  return -1;
}, count: 0, entity_id: oe.Undefined(0, oe.Schema.str), asym_id: oe.Undefined(0, oe.Schema.str), seq_id_begin: oe.Undefined(0, oe.Schema.int), seq_id_end: oe.Undefined(0, oe.Schema.int), chainElementSegments: Zt.create([]), polymerRanges: jr.ofSortedRanges([]), gapRanges: jr.ofSortedRanges([]) };
function tY(e, t, r) {
  if (e.has(t)) return e.get(t);
  var n = r.index++;
  return e.set(t, n), n;
}
function rY(e, t) {
  if (e.has(t)) return e.get(t);
  var r = /* @__PURE__ */ new Map();
  return e.set(t, r), r;
}
function nY(e) {
  throw new Error("Missing entity entry for entity id '".concat(e, "'."));
}
function rS(e, t) {
  for (var r = e.entity_id, n = e.asym_id, i = e.seq_id_begin, a = e.seq_id_end, o = e.count, u = e.chainElementSegments, s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = { index: 0 }, d = new Int32Array(o), f = new Int32Array(o), m = new Int32Array(u.count), v = 0; v < o; v++) f[v] = t.getEntityIndex(r.value(v)), f[v] < 0 && nY(r.value(v));
  for (var p = 0; p < u.count; p++) {
    var g = u.offsets[p], h = u.offsets[p + 1], y = f[g];
    m[p] = y;
    var x = tY(rY(c, y), n.value(g), l);
    for (v = g; v < h; v++) d[v] = x;
    var A = [], b = [];
    for (v = g; v < h; v++) {
      var _ = i.value(v), S = a.value(v);
      A.push(v), b.push(_, S);
    }
    var D = { elementIndices: A, seqRanges: jr.ofSortedRanges(b) };
    s.set(x, D);
  }
  var I = function(F, P, E) {
    var B = F.getEntityIndex;
    return { findChainKey: function(N, O) {
      var z = B(N);
      if (z < 0) return -1;
      var V = P.get(z);
      return V.has(O) ? V.get(O) : -1;
    }, findSequenceKey: function(N, O, z) {
      var V = B(N);
      if (V < 0) return -1;
      var U = P.get(V);
      if (U === void 0) return -1;
      var H = U.get(O);
      if (H === void 0) return -1;
      var K = E.get(H), j = K.elementIndices, X = K.seqRanges, W = jr.firstIntersectionIndex(X, Le.ofSingleton(z));
      return W !== -1 ? j[W] : -1;
    } };
  }(t, c, s), M = I.findChainKey;
  return { chainKey: d, entityKey: f, findSequenceKey: I.findSequenceKey, findChainKey: M, getEntityFromChain: function(F) {
    return m[F];
  } };
}
function nS(e, t) {
  for (var r = [], n = [], i = Zt.transientSegments(e.chainElementSegments, Ae.ofBounds(0, e.count)), a = e.seq_id_begin, o = e.seq_id_end; i.hasNext; ) for (var u = i.move(), s = u.start, c = u.end, l = -1, d = -1, f = s; f < c; ++f) {
    var m = o.value(f);
    f === s ? (l = f, d = o.value(f)) : a.value(f) - d > 1 && (r.push(l, f - 1), n.push(f - 1, f), l = f), f === c - 1 && r.push(l, f), d = m;
  }
  return { polymerRanges: jr.ofSortedRanges(r), gapRanges: jr.ofSortedRanges(n) };
}
(function(e) {
  e.Empty = { isDefined: !1, spheres: tS, gaussians: tS };
})(Mb || (Mb = {}));
var bT = { hierarchy: Mb.Empty, conformation: void 0 };
function iY(e, t) {
  var r = e.ihm_sphere_obj_site, n = e.ihm_gaussian_obj_site;
  if (r._rowCount === 0 && n._rowCount === 0) return bT;
  var i = iS(r), a = function(f) {
    return { x: f.Cartn_x.toArray({ array: Float32Array }), y: f.Cartn_y.toArray({ array: Float32Array }), z: f.Cartn_z.toArray({ array: Float32Array }), radius: f.object_radius.toArray({ array: Float32Array }), rmsf: f.rmsf.toArray({ array: Float32Array }) };
  }(r), o = rS(i, e.entities), u = nS(i), s = iS(n), c = function(f) {
    for (var m = _o.ihm_gaussian_obj_site.covariance_matrix.space, v = [], p = f.covariance_matrix, g = 0, h = p.rowCount; g < h; g++) v[g] = zn.toMat3(Ti(), m, p.value(g));
    return { x: f.mean_Cartn_x.toArray({ array: Float32Array }), y: f.mean_Cartn_y.toArray({ array: Float32Array }), z: f.mean_Cartn_z.toArray({ array: Float32Array }), weight: f.weight.toArray({ array: Float32Array }), covariance_matrix: v };
  }(n), l = rS(s, e.entities), d = nS(s);
  return { hierarchy: { isDefined: !0, spheres: R(R(R({}, i), o), u), gaussians: R(R(R({}, s), l), d) }, conformation: { id: Ii.create22(), spheres: a, gaussians: c } };
}
function iS(e) {
  var t = e.entity_id, r = e.seq_id_begin, n = e.seq_id_end, i = e.asym_id;
  return R({ count: t.rowCount, entity_id: t, asym_id: i, seq_id_begin: r, seq_id_end: n }, function(a, o, u) {
    for (var s = [0], c = 1, l = a.rowCount; c < l; c++) !a.areValuesEqual(c - 1, c) && (s[s.length] = c);
    return { chainElementSegments: Zt.ofOffsets(s, Ae.ofBounds(0, a.rowCount)) };
  }(i));
}
var Mp, Tb, aY = { HIS: "H", ARG: "R", LYS: "K", ILE: "I", PHE: "F", LEU: "L", TRP: "W", ALA: "A", MET: "M", PRO: "P", CYS: "C", ASN: "N", VAL: "V", GLY: "G", SER: "S", GLN: "Q", TYR: "Y", ASP: "D", GLU: "E", THR: "T", SEC: "U", PYL: "O", HSD: "H", HSE: "H", HSP: "H", LSN: "K", ASPP: "D", GLUP: "E", HID: "H", HIE: "H", HIP: "H", LYN: "K", ASH: "D", GLH: "E", ACE: "ACE", NME: "NME" }, oY = { DA: "A", DC: "C", DG: "G", DT: "T", DU: "U" }, uY = { A: "A", C: "C", G: "G", T: "T", U: "U" };
function aS(e) {
  return aY[e] || "X";
}
function oS(e) {
  return uY[e] || "X";
}
function uS(e) {
  return oY[e] || "X";
}
function _T(e, t, r, n) {
  if (!e.entity_poly_seq || !e.entity_poly_seq._rowCount) return Tb.fromHierarchy(t, r, n);
  for (var i = e.entity_poly_seq, a = i.entity_id, o = i.num, u = i.mon_id, s = {}, c = [], l = a.rowCount, d = 0; d < l; ) {
    for (var f = d; d < l - 1 && a.areValuesEqual(d, d + 1); ) d++;
    d++;
    var m = a.value(f), v = oe.window(u, f, d), p = oe.window(o, f, d), g = t.getEntityIndex(m);
    s[g] = { entityId: m, sequence: Mp.ofResidueNames(v, p) }, c.push(s[g]);
  }
  return { byEntityKey: s, sequences: c };
}
function xT(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    var i, a, o, u, s, c, l, d, f, m, v;
    return ye(this, function(p) {
      switch (p.label) {
        case 0:
          return i = $5(r, n - 1), a = t.label_entity_id, o = t.label_asym_id, u = t.label_seq_id, s = Dy(i, a.value), e.shouldUpdate ? [4, e.update()] : [3, 2];
        case 1:
          p.sent(), p.label = 2;
        case 2:
          c = 0, l = s.length - 1, p.label = 3;
        case 3:
          if (!(c < l)) return [3, 10];
          d = Dy(i, o.value, { start: s[c], end: s[c + 1] }), f = 0, m = d.length - 1, p.label = 4;
        case 4:
          return f < m ? (v = d[f], u.valueKind(v) !== 0 ? [3, 6] : (Dy(i, u.value, { sort: !0, start: v, end: d[f + 1] }), e.shouldUpdate ? [4, e.update()] : [3, 6])) : [3, 7];
        case 5:
          p.sent(), p.label = 6;
        case 6:
          return f++, [3, 4];
        case 7:
          return e.shouldUpdate ? [4, e.update()] : [3, 9];
        case 8:
          p.sent(), p.label = 9;
        case 9:
          return c++, [3, 3];
        case 10:
          return function(g) {
            for (var h = 0, y = g.length; h < y; h++) if (g[h] !== h) return !1;
            return !0;
          }(i) && i.length === t._rowCount ? [2, { atom_site: t, sourceIndex: oe.ofIntArray(i) }] : [2, { atom_site: Or.view(t, t._schema, i), sourceIndex: oe.ofIntArray(i) }];
      }
    });
  });
}
function sS(e, t, r, n, i) {
  var a = i.residue, o = a.polymerType, u = a.traceElementIndex, s = a.directionFromElementIndex, c = a.directionToElementIndex, l = o[e], d = o[t];
  if (l === 0 || d === 0 || u[e] === -1 || u[t] === -1) return !1;
  var f = n.findAtomsOnResidue(e, Ul(l, "backboneStart")), m = n.findAtomsOnResidue(t, Ul(d, "backboneEnd"));
  f !== -1 && m !== -1 || (f = n.findAtomsOnResidue(e, Ul(l, "coarseBackbone")), m = n.findAtomsOnResidue(t, Ul(d, "coarseBackbone")));
  var v = r.x, p = r.y, g = r.z, h = w.create(v[f], p[f], g[f]), y = w.create(v[m], p[m], g[m]), x = s[e] === -1 || c[e] === -1 || s[t] === -1 || c[t] === -1;
  return w.distance(h, y) < (x ? 10 : 3);
}
function AT(e, t, r, n) {
  for (var i, a, o, u, s = [], c = [], l = /* @__PURE__ */ new Map(), d = Zt.transientSegments(e.chainAtomSegments, Ae.ofBounds(0, e.atoms._rowCount)), f = Zt.transientSegments(e.residueAtomSegments, Ae.ofBounds(0, e.atoms._rowCount)), m = e.index, v = e.derived, p = e.residues.label_seq_id, g = e.chains.label_entity_id, h = v.residue, y = h.moleculeType, x = h.traceElementIndex; d.hasNext; ) {
    var A = d.move();
    f.setSegment(A), i = -1, a = -1, o = -1, u = -1;
    var b = t.getEntityIndex(g.value(A.index)), _ = n.byEntityKey[b], S = _ ? _.sequence.seqId.value(_.sequence.seqId.rowCount - 1) : -1, D = e.residueAtomSegments.index[A.start], I = e.residueAtomSegments.index[A.end - 1], M = p.value(D), F = p.value(I);
    for (M === 1 && F === S && r.xyzDefined && sS(D, I, r, m, v) && (l.set(D, I), l.set(I, D)); f.hasNext; ) {
      var P = f.move(), E = P.index, B = p.value(E);
      if (b_(y[E]) && x[E] !== -1) if (u !== -1) if (B !== i + 1) s.push(u, o - 1), c.push(a, P.end - 1), u = P.start;
      else if (f.hasNext) {
        var N = e.residueAtomSegments.index[P.start], O = e.residueAtomSegments.index[o - 1];
        r.xyzDefined && !sS(N, O, r, e.index, v) && (s.push(u, o - 1), c.push(a, P.end - 1), u = P.start);
      } else s.push(u, P.end - 1);
      else u = P.start;
      else u !== -1 && (s.push(u, o - 1), u = -1);
      a = P.start, o = P.end, i = B;
    }
  }
  return { polymerRanges: jr.ofSortedRanges(s), gapRanges: jr.ofSortedRanges(c), cyclicPolymerMap: l };
}
function ST(e) {
  var t = /* @__PURE__ */ new Map();
  return function(r) {
    if (t.has(r)) return t.get(r);
    var n = e(r);
    return t.set(r, n), n;
  };
}
function sY(e) {
  for (var t = /* @__PURE__ */ new Map(), r = function(u, s, c) {
    return "".concat(u, "|").concat(s, "|").concat(c);
  }, n = e.pdbx_unobs_or_zero_occ_residues, i = 0, a = n._rowCount; i < a; ++i) {
    var o = r(n.PDB_model_num.value(i), n.label_asym_id.value(i), n.label_seq_id.value(i));
    t.set(o, { polymer_flag: n.polymer_flag.value(i), occupancy_flag: n.occupancy_flag.value(i) });
  }
  return { has: function(u, s, c) {
    return t.has(r(u, s, c));
  }, get: function(u, s, c) {
    return t.get(r(u, s, c));
  }, size: t.size };
}
function cY(e) {
  var t = /* @__PURE__ */ new Map();
  if (e.chem_comp._rowCount > 0) for (var r = e.chem_comp.id, n = 0, i = r.rowCount; n < i; ++n) t.set(r.value(n), Or.getRow(e.chem_comp, n));
  else CT(e).forEach(function(a) {
    t.set(a, function(o) {
      return { formula: "", formula_weight: 0, id: o, name: o, mon_nstd_flag: y_.has(o) ? "y" : "n", pdbx_synonyms: [], type: qM(o) };
    }(a));
  });
  return t;
}
function lY(e) {
  var t = /* @__PURE__ */ new Map();
  if (e.pdbx_chem_comp_identifier._rowCount > 0) {
    for (var r = e.pdbx_chem_comp_identifier, n = r.comp_id, i = r.type, a = r.identifier, o = 0, u = n.rowCount; o < u; ++o) if (i.value(o) === "SNFG CARBOHYDRATE SYMBOL" || i.value(o) === "SNFG CARB SYMBOL") {
      var s = a.value(o), c = hK.get(s);
      c ? t.set(n.value(o), c) : console.warn("Unknown SNFG name '".concat(s, "'"));
    }
  }
  if (e.chem_comp._rowCount > 0) {
    var l = e.chem_comp, d = l.id;
    for (i = l.type, o = 0, u = d.rowCount; o < u; ++o) {
      var f = d.value(o);
      if (!t.has(f)) {
        var m = i.value(o);
        Zl.has(f) ? t.set(f, Zl.get(f)) : Dm(m, f) === 9 && t.set(f, BM);
      }
    }
  } else {
    var v = CT(e);
    Zl.forEach(function(p, g) {
      !t.has(g) && v.has(g) && t.set(g, p);
    });
  }
  return t;
}
(function(e) {
  e.getSequenceString = function(n) {
    var i = n.code.toArray();
    return (i instanceof Array ? i : Array.from(i)).join("");
  }, e.ofResidueNames = function(n, i) {
    if (i.rowCount === 0) throw new Error("cannot be empty");
    var a = function(o) {
      for (var u = 0, s = Math.min(o.rowCount, 10); u < s; u++) {
        var c = o.value(u) || "";
        if (aS(c) !== "X") return "protein";
        if (oS(c) !== "X") return "RNA";
        if (uS(c) !== "X") return "DNA";
      }
      return "generic";
    }(n);
    return new t(a, n, i);
  };
  var t = function() {
    function n(i, a, o) {
      this.kind = i, this.microHet = /* @__PURE__ */ new Map();
      for (var u = function(b, _) {
        var S;
        switch (b) {
          case "protein":
            S = aS;
            break;
          case "DNA":
            S = uS;
            break;
          case "RNA":
            S = oS;
            break;
          case "generic":
            S = function() {
              return "X";
            };
            break;
          default:
            Hi();
        }
        return S;
      }(i), s = [], c = [], l = [], d = /* @__PURE__ */ new Map(), f = 0, m = /* @__PURE__ */ new Map(), v = 0, p = o.rowCount; v < p; ++v) {
        var g = o.value(v);
        if (m.has(g)) d.has(g) ? d.get(g).push(a.value(v)) : d.set(g, [c[m.get(g)], a.value(v)]);
        else {
          m.set(g, f);
          var h = a.value(v);
          c[f] = h, l[f] = g, s[f] = u(h), f += 1;
        }
      }
      var y = [];
      for (v = 0, p = f; v < p; ++v) {
        var x = d.get(l[v]);
        if (x) {
          var A = x.map(function(b) {
            var _ = u(b);
            return _ === "X" ? b : _;
          });
          y[v] = "(".concat(A.join("|"), ")");
        } else y[v] = s[v] === "X" ? c[v] : s[v];
      }
      this.length = f, this.code = oe.ofStringArray(s), this.compId = oe.ofStringArray(c), this.seqId = oe.ofIntArray(l), this.label = oe.ofStringArray(y), this.microHet = d, this.indexMap = m;
    }
    return n.prototype.index = function(i) {
      return this.indexMap.get(i);
    }, n;
  }();
  e.ofSequenceRanges = function(n, i) {
    return new r("generic", n, i);
  };
  var r = function() {
    function n(i, a, o) {
      this.kind = i, this.seqIdStart = a, this.seqIdEnd = o, this.microHet = /* @__PURE__ */ new Map();
      for (var u = 0, s = Number.MAX_SAFE_INTEGER, c = 0, l = this.seqIdStart.rowCount; c < l; c++) {
        var d = this.seqIdStart.value(c), f = this.seqIdEnd.value(c);
        d < s && (s = d), u < f && (u = f);
      }
      var m = u - s + 1;
      this.code = oe.ofConst("X", m, oe.Schema.str), this.label = oe.ofConst("", m, oe.Schema.str), this.seqId = oe.ofLambda({ value: function(v) {
        return v + s + 1;
      }, rowCount: m, schema: oe.Schema.int }), this.compId = oe.ofConst("", m, oe.Schema.str), this.length = m, this.minSeqId = s;
    }
    return n.prototype.index = function(i) {
      return i - this.minSeqId;
    }, n;
  }();
})(Mp || (Mp = {})), function(e) {
  var t = { byEntityKey: {}, sequences: [] };
  function r() {
    for (var o = [], u = 0; u < arguments.length; u++) o[u] = arguments[u];
    for (var s = [], c = {}, l = 0, d = o.length; l < d; ++l) s.push.apply(s, o[l].sequences), Object.assign(c, o[l].byEntityKey);
    return { sequences: s, byEntityKey: c };
  }
  function n(o, u) {
    var s = u.atoms.label_comp_id, c = u.residues.label_seq_id, l = u.chainAtomSegments, d = u.residueAtomSegments, f = l.count, m = l.offsets, v = {}, p = [];
    if (f === 1 && m[0] === 0 && m[1] === 0) return { byEntityKey: v, sequences: p };
    for (var g = 0, h = u.chains._rowCount; g < h; g++) {
      var y = u.index.getEntityFromChain(g);
      if (v[y] === void 0 && o.data.type.value(y) === "polymer") {
        var x = g;
        for (g++; g < h && y === u.index.getEntityFromChain(g) && o.data.type.value(y) !== "polymer"; ) g++;
        g--;
        for (var A = d.index[m[x]], b = d.index[m[g + 1] - 1] + 1, _ = oe.window(c, A, b), S = [], D = A; D < b; ++D) S.push(s.value(d.offsets[D]));
        var I = oe.ofStringArray(S);
        v[y] = { entityId: o.data.id.value(y), sequence: Mp.ofResidueNames(I, _) }, p.push(v[y]);
      }
    }
    return { byEntityKey: v, sequences: p };
  }
  function i(o, u) {
    return r(a(o, u.spheres), a(o, u.gaussians));
  }
  function a(o, u) {
    var s = u.chainElementSegments, c = u.seq_id_begin, l = u.seq_id_end, d = s.count, f = s.offsets, m = {}, v = [];
    if (d === 1 && f[0] === 0 && f[1] === 0) return { byEntityKey: m, sequences: v };
    for (var p = 0, g = d; p < g; p++) {
      var h = u.getEntityFromChain(p);
      if (m[h] === void 0) {
        var y = p;
        for (p++; p < g && h === u.getEntityFromChain(p); ) p++;
        p--;
        var x = f[y], A = f[p + 1] - 1, b = oe.window(c, x, A), _ = oe.window(l, x, A);
        m[h] = { entityId: o.data.id.value(h), sequence: Mp.ofSequenceRanges(b, _) }, v.push(m[h]);
      }
    }
    return { byEntityKey: m, sequences: v };
  }
  e.fromHierarchy = function(o, u, s) {
    return r(n(o, u), s.isDefined ? i(o, s) : t);
  }, e.fromAtomicHierarchy = n, e.fromCoarseHierarchy = i, e.fromCoarseElements = a;
}(Tb || (Tb = {}));
var CT = ST(function(e) {
  for (var t = /* @__PURE__ */ new Set(), r = e.atom_site, n = r.label_comp_id, i = r.auth_comp_id, a = n.isDefined ? n : i, o = 0, u = a.rowCount; o < u; ++o) t.add(a.value(o));
  return t;
});
function wT(e, t) {
  for (var r = /* @__PURE__ */ new Map(), n = e.chains, i = n.auth_asym_id, a = n.label_asym_id, o = n.label_entity_id, u = 0, s = e.chains._rowCount; u < s; u++) {
    var c = a.value(u);
    r.set(c, { id: c, auth_id: i.value(u), entity_id: o.value(u) });
  }
  if (t != null && t.struct_asym._rowCount) for (var l = t.struct_asym, d = (c = l.id, l.entity_id), f = (u = 0, c.rowCount); u < f; ++u) {
    var m = c.value(u);
    r.has(m) || r.set(m, { id: m, auth_id: "", entity_id: d.value(u) });
  }
  return r;
}
var dY = oe.Schema.Aliased(oe.Schema.Str(""));
function DT(e) {
  var t;
  if (e.entity.id.isDefined) t = e.entity;
  else {
    for (var r = /* @__PURE__ */ new Set(), n = [], i = [], a = e.atom_site, o = a.label_entity_id, u = a.label_comp_id, s = 0, c = e.atom_site._rowCount; s < c; s++) {
      var l = o.value(s);
      r.has(l) || (n.push(l), i.push(BK(u.value(s))), r.add(l));
    }
    var d = e.ihm_sphere_obj_site.entity_id;
    for (s = 0, c = e.ihm_sphere_obj_site._rowCount; s < c; s++)
      l = d.value(s), r.has(l) || (n.push(l), i.push("polymer"), r.add(l));
    var f = e.ihm_gaussian_obj_site.entity_id;
    for (s = 0, c = e.ihm_gaussian_obj_site._rowCount; s < c; s++)
      l = f.value(s), r.has(l) || (n.push(l), i.push("polymer"), r.add(l));
    t = Or.ofPartialColumns(_o.entity, { id: oe.ofArray({ array: n, schema: _o.entity.id }), type: oe.ofArray({ array: i, schema: _o.entity.type }) }, n.length);
  }
  var m = oe.createIndexer(t.id), v = new Array(t._rowCount);
  v.fill("other");
  var p = /* @__PURE__ */ new Set(), g = !1;
  if (e.entity_poly && e.entity_poly.type.isDefined) {
    var h = e.entity_poly, y = h.entity_id, x = h.type, A = h._rowCount;
    for (s = 0; s < A; ++s)
      v[m(l = y.value(s))] = x.value(s), p.add(l);
  } else g = !0;
  if (e.pdbx_entity_branch && e.pdbx_entity_branch.entity_id.isDefined) {
    var b = e.pdbx_entity_branch;
    for (y = b.entity_id, x = b.type, A = b._rowCount, s = 0; s < A; ++s)
      v[m(l = y.value(s))] = x.value(s), p.add(l);
  } else g = !0;
  if (p.size < v.length && (g = !0), g) {
    var _ = /* @__PURE__ */ new Map();
    if (e.chem_comp) {
      var S = e.chem_comp, D = S.id;
      for (x = S.type, s = 0, c = e.chem_comp._rowCount; s < c; s++) _.set(D.value(s), x.value(s));
    }
    if (e.atom_site) {
      var I = e.atom_site;
      for (o = I.label_entity_id, u = I.label_comp_id, s = 0, c = e.atom_site._rowCount; s < c; s++)
        if (l = o.value(s), !p.has(l)) {
          var M = u.value(s), F = _.get(M) || "";
          v[m(l)] = FK(M, F), p.add(l);
        }
    }
  }
  return { data: t, subtype: oe.ofArray({ array: v, schema: dY }), getEntityIndex: m };
}
function IT(e, t, r) {
  var n;
  if (!e.pdbx_molecule || !e.pdbx_molecule.prd_id.isDefined) return t;
  var i = new Array(t.data._rowCount);
  i.fill("");
  for (var a = e.pdbx_molecule, o = a.asym_id, u = a.prd_id, s = a._rowCount, c = 0; c < s; ++c) {
    var l = o.value(c), d = (n = r.get(l)) === null || n === void 0 ? void 0 : n.entity_id;
    d !== void 0 && (i[t.getEntityIndex(d)] = u.value(c));
  }
  var f = oe.ofArray({ array: i, schema: oe.Schema.str });
  return R(R({}, t), { prd_id: f });
}
var nn, cS, am = function() {
  function e(t) {
    this.frames = t, this.frameCount = t.length, this.representative = t[0], this.duration = t.length;
  }
  return e.prototype.getFrameAtIndex = function(t) {
    return this.frames[t];
  }, e;
}();
function Oc(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o;
    return ye(this, function(u) {
      switch (u.label) {
        case 0:
          return n = function(s, c) {
            return { missingResidues: sY(s), chemicalComponentMap: cY(s), saccharideComponentMap: lY(s) };
          }(e), e.ihm_model_list._rowCount > 0 ? [4, pY(r, e, n, t)] : [3, 2];
        case 1:
          return a = u.sent(), [3, 4];
        case 2:
          return [4, fY(r, e, n, t)];
        case 3:
          a = u.sent(), u.label = 4;
        case 4:
          for (i = a, o = 0; o < i.length; o++) nn.TrajectoryInfo.set(i[o], { index: o, size: i.length });
          return [2, new am(i)];
      }
    });
  });
}
function ET(e, t) {
  var r = e.rowCount;
  if (!e.isDefined) return r;
  for (var n = t + 1; n < r && e.areValuesEqual(t, n); ) n++;
  return n;
}
function fY(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    var i, a, o, u, s, c, l, d, f;
    return ye(this, function(m) {
      switch (m.label) {
        case 0:
          if (i = [], !t.atom_site) return [3, 3];
          a = t.atom_site.id.rowCount, o = DT(t), u = 0, m.label = 1;
        case 1:
          return u < a ? (s = ET(t.atom_site.pdbx_PDB_model_num, u), [4, xT(e, t.atom_site, u, s)]) : [3, 3];
        case 2:
          return c = m.sent(), l = c.atom_site, d = c.sourceIndex, f = function(v, p, g, h, y, x, A) {
            var b = yT(p, g, h, y.chemicalComponentMap, x, A), _ = p.pdbx_PDB_model_num.value(0);
            if (A && b.sameAsPrevious) return R(R({}, A), { id: Ii.create22(), modelNum: _, atomicConformation: b.conformation, _dynamicPropertyData: /* @__PURE__ */ Object.create(null) });
            var S = bT, D = _T(v, h, b.hierarchy, S.hierarchy), I = AT(b.hierarchy, h, b.conformation, D), M = wT(b.hierarchy), F = v.entry.id.valueKind(0) === 0 ? v.entry.id.value(0) : x.name, P = [];
            return F && P.push(F), v.struct.title.valueKind(0) === 0 && P.push(v.struct.title.value(0)), { id: Ii.create22(), entryId: F, label: P.join(" | "), entry: F, sourceData: x, modelNum: _, parent: void 0, entities: IT(v, h, M), sequence: D, atomicHierarchy: b.hierarchy, atomicConformation: b.conformation, atomicRanges: I, atomicChainOperatorMappinng: b.chainOperatorMapping, coarseHierarchy: S.hierarchy, coarseConformation: S.conformation, properties: R(R({}, y), { structAsymMap: M }), customProperties: new v0(), _staticPropertyData: /* @__PURE__ */ Object.create(null), _dynamicPropertyData: /* @__PURE__ */ Object.create(null) };
          }(t, l, d, o, r, n, i.length > 0 ? i[i.length - 1] : void 0), i.push(f), u = s, [3, 1];
        case 3:
          return [2, i];
      }
    });
  });
}
function n4(e, t) {
  for (var r = /* @__PURE__ */ new Map(), n = e._rowCount, i = 0; i < n; ) {
    var a = ET(t, i), o = t.value(i);
    r.set(o, { table: Or.window(e, e._schema, i, a), start: i, end: a }), i = a;
  }
  return r;
}
function pY(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    var i, a, o, u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _;
    return ye(this, function(S) {
      switch (S.label) {
        case 0:
          if (i = DT(t), a = t.atom_site.ihm_model_id.isDefined ? t.atom_site.ihm_model_id : t.atom_site.pdbx_PDB_model_num, o = n4(t.atom_site, a), u = n4(t.ihm_sphere_obj_site, t.ihm_sphere_obj_site.model_id), s = n4(t.ihm_gaussian_obj_site, t.ihm_gaussian_obj_site.model_id), c = [], !t.ihm_model_list) return [3, 6];
          l = t.ihm_model_list, d = l.model_id, f = l.model_name, m = 0, S.label = 1;
        case 1:
          return m < t.ihm_model_list._rowCount ? (v = d.value(m), p = void 0, g = void 0, o.has(v) ? (h = o.get(v), [4, xT(e, t.atom_site, h.start, h.end)]) : [3, 3]) : [3, 6];
        case 2:
          return y = S.sent(), x = y.atom_site, A = y.sourceIndex, p = x, g = A, [3, 4];
        case 3:
          p = Or.window(t.atom_site, t.atom_site._schema, 0, 0), g = oe.ofIntArray([]), S.label = 4;
        case 4:
          b = { model_id: v, model_name: f.value(m), model_group_name: rj(v, t), entities: i, atom_site: p, atom_site_sourceIndex: g, ihm_sphere_obj_site: u.has(v) ? u.get(v).table : Or.window(t.ihm_sphere_obj_site, t.ihm_sphere_obj_site._schema, 0, 0), ihm_gaussian_obj_site: s.has(v) ? s.get(v).table : Or.window(t.ihm_gaussian_obj_site, t.ihm_gaussian_obj_site._schema, 0, 0) }, _ = function(D, I, M, F) {
            var P = yT(I.atom_site, I.atom_site_sourceIndex, I.entities, M.chemicalComponentMap, F), E = iY(I, M.chemicalComponentMap), B = _T(D, I.entities, P.hierarchy, E.hierarchy), N = AT(P.hierarchy, I.entities, P.conformation, B), O = D.entry.id.valueKind(0) === 0 ? D.entry.id.value(0) : F.name, z = [];
            O && z.push(O), D.struct.title.valueKind(0) === 0 && z.push(D.struct.title.value(0)), I.model_name && z.push(I.model_name), I.model_group_name && z.push(I.model_group_name);
            var V = wT(P.hierarchy, D);
            return { id: Ii.create22(), entryId: O, label: z.join(" | "), entry: O, sourceData: F, modelNum: I.model_id, parent: void 0, entities: IT(D, I.entities, V), sequence: B, atomicHierarchy: P.hierarchy, atomicConformation: P.conformation, atomicRanges: N, atomicChainOperatorMappinng: P.chainOperatorMapping, coarseHierarchy: E.hierarchy, coarseConformation: E.conformation, properties: R(R({}, M), { structAsymMap: V }), customProperties: new v0(), _staticPropertyData: /* @__PURE__ */ Object.create(null), _dynamicPropertyData: /* @__PURE__ */ Object.create(null) };
          }(t, b, r, n), c.push(_), S.label = 5;
        case 5:
          return m++, [3, 1];
        case 6:
          return [2, c];
      }
    });
  });
}
function i4(e) {
  for (var t = /* @__PURE__ */ new Map(), r = 0, n = e.length; r < n; r++) t.set(r, e[r]);
  return t;
}
(function(e) {
  function t(h, y) {
    for (var x = [], A = y.frames, b = h.atomicHierarchy.atomSourceIndex, _ = oe.isIdentity(b) ? void 0 : b.toArray({ array: Int32Array }), S = s(h), D = 0, I = A.length; D < I; ++D) {
      var M = A[D], F = R(R({}, h), { id: Ii.create22(), modelNum: D, atomicConformation: x2.getAtomicConformation(M, h.atomicConformation.atomId, _), customProperties: new v0(), _staticPropertyData: /* @__PURE__ */ Object.create(null), _dynamicPropertyData: /* @__PURE__ */ Object.create(null) });
      if (M.cell) {
        var P = ia.fromCell(M.cell.size, M.cell.anglesInRadians);
        ia.Provider.set(F, P);
      }
      e.TrajectoryInfo.set(F, { index: D, size: A.length }), e.CoarseGrained.set(F, S), x.push(F);
    }
    return { trajectory: x, srcIndexArray: _ };
  }
  e.trajectoryFromModelAndCoordinates = function(h, y) {
    return new am(t(h, y).trajectory);
  }, e.trajectoryFromTopologyAndCoordinates = function(h, y) {
    var x = this;
    return er.create("Create Trajectory", function(A) {
      return _e(x, 0, void 0, function() {
        var b, _, S, D, I, M, F, P, E, B;
        return ye(this, function(N) {
          switch (N.label) {
            case 0:
              return [4, Oc(h.basic, h.sourceData, A)];
            case 1:
              if ((b = N.sent()).frameCount === 0) throw new Error("found no model");
              for (_ = b.representative, S = t(_, y).trajectory, D = { pairs: h.bonds, count: _.atomicHierarchy.atoms._rowCount }, I = Ei.fromData(D), M = s(_), F = 0, P = 0, E = S; P < E.length; P++) B = E[P], Ei.Provider.set(B, I), e.TrajectoryInfo.set(B, { index: F++, size: S.length }), e.CoarseGrained.set(B, M);
              return [2, new am(S)];
          }
        });
      });
    });
  };
  var r = "__Center__";
  e.getCenter = function(h) {
    if (h._dynamicPropertyData[r]) return h._dynamicPropertyData[r];
    var y = function(x, A) {
      var b = [], _ = [], S = [];
      x.x.length && (b.push.apply(b, Oo(x.x)), _.push.apply(_, Oo(x.y)), S.push.apply(S, Oo(x.z))), A && (A.spheres.x.length && (b.push.apply(b, Oo(A.spheres.x)), _.push.apply(_, Oo(A.spheres.y)), S.push.apply(S, Oo(A.spheres.z))), A.gaussians.x.length && (b.push.apply(b, Oo(A.gaussians.x)), _.push.apply(_, Oo(A.gaussians.y)), S.push.apply(S, Oo(A.gaussians.z))));
      var D = Oo(b), I = D[0], M = D[1], F = Oo(_), P = F[0], E = F[1], B = Oo(S), N = B[0], O = I + (M - I) / 2, z = P + (E - P) / 2, V = N + (B[1] - N) / 2;
      return w.create(O, z, V);
    }(h.atomicConformation, h.coarseConformation);
    return h._dynamicPropertyData[r] = y, y;
  };
  var n = "__InvertedAtomSrcIndex__";
  e.getInvertedAtomSourceIndex = function(h) {
    if (h._staticPropertyData[n]) return h._staticPropertyData[n];
    var y = function(x) {
      for (var A = new Int32Array(x.rowCount), b = !1, _ = 0, S = x.rowCount; _ < S; _++) {
        var D = x.value(_);
        D !== _ && (b = !1), A[D] = _;
      }
      return { isIdentity: b, invertedIndex: A };
    }(h.atomicHierarchy.atomSourceIndex);
    return h._staticPropertyData[n] = y, y;
  };
  var i = "__TrajectoryInfo__";
  e.TrajectoryInfo = { get: function(h) {
    return h._dynamicPropertyData[i] || { index: 0, size: 1 };
  }, set: function(h, y) {
    return h._dynamicPropertyData[i] = y;
  } };
  var a = "__AsymIdCount__";
  e.AsymIdCount = { get: function(h) {
    if (h._dynamicPropertyData[a]) return h._dynamicPropertyData[a];
    var y = function(x) {
      var A = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Set();
      return x.properties.structAsymMap.forEach(function(_, S) {
        var D = _.auth_id;
        A.add(D), b.add(S);
      }), { auth: A.size, label: b.size };
    }(h);
    return h._dynamicPropertyData[a] = y, y;
  } }, e.AsymIdOffset = L1.createSimple("asym_id_offset", "static"), e.Index = L1.createSimple("index", "static"), e.getRoot = function(h) {
    return h.parent || h;
  }, e.areHierarchiesEqual = function(h, y) {
    return h.atomicHierarchy === y.atomicHierarchy && h.coarseHierarchy === y.coarseHierarchy;
  };
  var o = "__CoordinatesHistory__";
  e.CoordinatesHistory = { get: function(h) {
    return h._staticPropertyData[o];
  }, set: function(h, y) {
    return h._staticPropertyData[o] = y;
  } };
  var u = "__CoarseGrained__";
  function s(h) {
    var y = e.CoarseGrained.get(h);
    if (y === void 0) {
      for (var x = 0, A = h.atomicHierarchy.derived.residue.polymerType, b = 0; b < A.length; ++b) A[b] !== 0 && (x += 1);
      var _ = !1, S = !1, D = h.atomicHierarchy.atoms, I = D.label_atom_id, M = D._rowCount;
      for (b = 0; b < M; ++b) {
        var F = I.value(b);
        if (_ || F !== "BB" || (_ = !0), S || F !== "SC1" || (S = !0), _ && S) break;
      }
      y = _ && S || !(!x || !M) && M / x < 3, e.CoarseGrained.set(h, y);
    }
    return y;
  }
  function c(h) {
    return !!mn.is(h.sourceData) && (h.entryId.match(/^[1-9][a-z0-9]{3,3}$/i) !== null || h.entryId.match(/^pdb_[0-9]{4,4}[1-9][a-z0-9]{3,3}$/i) !== null);
  }
  e.CoarseGrained = { get: function(h) {
    return h._staticPropertyData[u];
  }, set: function(h, y) {
    return h._staticPropertyData[u] = y;
  } }, e.isCoarseGrained = s, e.isMaterial = function(h) {
    var y, x;
    return !!(!((x = (y = h.sourceData) === null || y === void 0 ? void 0 : y.data) === null || x === void 0) && x.isMaterial);
  }, e.isMaterialCrystal = function(h) {
    var y, x, A, b = (y = h.sourceData) === null || y === void 0 ? void 0 : y.data;
    return !(b != null && b.isMaterial) && !!(!((A = (x = b == null ? void 0 : b.molecules) === null || x === void 0 ? void 0 : x[0]) === null || A === void 0) && A.cell);
  }, e.hasCarbohydrate = function(h) {
    return h.properties.saccharideComponentMap.size > 0;
  }, e.hasProtein = function(h) {
    for (var y = h.entities.subtype, x = 0, A = y.rowCount; x < A; ++x) if (y.value(x).startsWith("polypeptide")) return !0;
    return !1;
  }, e.hasNucleic = function(h) {
    for (var y = h.entities.subtype, x = 0, A = y.rowCount; x < A; ++x) {
      var b = y.value(x);
      if (b.endsWith("ribonucleotide hybrid") || b.endsWith("ribonucleotide")) return !0;
    }
    return !1;
  }, e.isFromPdbArchive = function(h) {
    if (!mn.is(h.sourceData)) return !1;
    for (var y = h.sourceData.data.db, x = 0, A = y.database_2.database_id.rowCount; x < A; ++x) if (y.database_2.database_id.value(x) === "PDB") return !0;
    return !1;
  }, e.hasPdbId = c, e.hasSecondaryStructure = function(h) {
    if (!mn.is(h.sourceData)) return !1;
    var y = h.sourceData.data.db;
    return y.struct_conf.id.isDefined || y.struct_sheet_range.id.isDefined;
  };
  var l = w.create(1.5707963, 1.5707963, 1.5707963), d = w.create(1, 1, 1);
  function f(h) {
    if (!mn.is(h.sourceData)) return !1;
    for (var y = h.sourceData.data.db, x = 0; x < y.exptl.method.rowCount; x++)
      if (y.exptl.method.value(x).toUpperCase().indexOf("DIFFRACTION") >= 0) return !0;
    return !1;
  }
  function m(h) {
    if (!mn.is(h.sourceData)) return !1;
    for (var y = h.sourceData.data.db, x = 0; x < y.exptl.method.rowCount; x++)
      if (y.exptl.method.value(x).toUpperCase().indexOf("MICROSCOPY") >= 0) return !0;
    return !1;
  }
  function v(h) {
    if (!mn.is(h.sourceData) || !f(h)) return !1;
    var y = h.sourceData.data.db.pdbx_database_status.status_code_sf;
    return y.isDefined && y.value(0) === "REL";
  }
  function p(h) {
    if (!mn.is(h.sourceData)) return !1;
    for (var y = h.sourceData.data.db, x = y.pdbx_database_related, A = x.db_name, b = x.content_type, _ = 0, S = y.pdbx_database_related._rowCount; _ < S; ++_) if (A.value(_).toUpperCase() === "EMDB" && b.value(_) === "associated EM volume") return !0;
    return !1;
  }
  function g(h) {
    return !!mn.is(h.sourceData) && (v(h) || p(h));
  }
  e.hasCrystalSymmetry = function(h) {
    var y, x = (y = ia.Provider.get(h)) === null || y === void 0 ? void 0 : y.spacegroup;
    return !(!x || x.num === 1 && w.equals(x.cell.anglesInRadians, l) && w.equals(x.cell.size, d));
  }, e.isFromXray = f, e.isFromEm = m, e.isFromNmr = function(h) {
    if (!mn.is(h.sourceData)) return !1;
    for (var y = h.sourceData.data.db, x = 0; x < y.exptl.method.rowCount; x++)
      if (y.exptl.method.value(x).toUpperCase().indexOf("NMR") >= 0) return !0;
    return !1;
  }, e.hasXrayMap = v, e.hasEmMap = p, e.hasDensityMap = g, e.probablyHasDensityMap = function(h) {
    if (!mn.is(h.sourceData)) return !1;
    var y = h.sourceData.data.db;
    return g(h) || c(h) && (!y.exptl.method.isDefined || f(h) && (!y.pdbx_database_status.status_code_sf.isDefined || y.pdbx_database_status.status_code_sf.valueKind(0) === 2) || m(h) && !y.pdbx_database_related.db_name.isDefined);
  };
})(nn || (nn = {})), function(e) {
  e.getCifDataSource = function(n, i, a) {
    if (!i) return { rowCount: 0 };
    if (a && a[i.id]) return a[i.id];
    var o = i.getElements(n), u = { data: o, rowCount: o.elements.length };
    return a && (a[i.id] = u), u;
  }, e.fromAtomMap = function(n) {
    return new lS(n);
  }, e.fromAtomArray = function(n) {
    return new lS(i4(n));
  };
  var t = function(n) {
    return n.atomicHierarchy.residueAtomSegments;
  };
  e.fromResidueMap = function(n) {
    return new ev("residue", n, t, 0);
  }, e.fromResidueArray = function(n) {
    return new ev("residue", i4(n), t, 0);
  };
  var r = function(n) {
    return n.atomicHierarchy.chainAtomSegments;
  };
  e.fromChainMap = function(n) {
    return new ev("chain", n, r, 0);
  }, e.fromChainArray = function(n) {
    return new ev("chain", i4(n), r, 0);
  }, e.fromEntityMap = function(n) {
    return new mY(n);
  };
}(cS || (cS = {}));
var ev = function() {
  function e(t, r, n, i) {
    this.level = t, this.map = r, this.segmentGetter = n, this.id = Ii.create22(), this.kind = i;
  }
  return e.prototype.has = function(t) {
    return this.map.has(t);
  }, e.prototype.get = function(t) {
    return this.map.get(t);
  }, e.prototype.getStructureElements = function(t) {
    var r = t.models;
    if (r.length !== 1) throw new Error("Only works on structures with a single model.");
    for (var n = /* @__PURE__ */ new Set(), i = t.unitSymmetryGroups, a = [], o = this.segmentGetter(r[0]), u = 0, s = i; u < s.length; u++) {
      var c = s[u].units[0];
      if (c.kind === this.kind) for (var l = Zt.transientSegments(o, c.elements); l.hasNext; ) {
        var d = l.move();
        this.has(d.index) && !n.has(d.index) && (n.add(d.index), a[a.length] = at.create(t, c, c.elements[d.start]));
      }
    }
    return a.sort(function(f, m) {
      return f.element - m.element;
    }), a;
  }, e.prototype.getElements = function(t) {
    var r = this, n = this.segmentGetter(t.model).index, i = this.getStructureElements(t);
    return { elements: i, property: function(a) {
      return r.get(n[i[a].element]);
    } };
  }, e;
}(), lS = function() {
  function e(t) {
    this.map = t, this.id = Ii.create22(), this.level = "atom", this.kind = 0;
  }
  return e.prototype.has = function(t) {
    return this.map.has(t);
  }, e.prototype.get = function(t) {
    return this.map.get(t);
  }, e.prototype.getStructureElements = function(t) {
    if (t.models.length !== 1) throw new Error("Only works on structures with a single model.");
    for (var r = /* @__PURE__ */ new Set(), n = [], i = 0, a = t.unitSymmetryGroups; i < a.length; i++) {
      var o = a[i].units[0];
      if (o.kind === this.kind) for (var u = o.elements, s = 0, c = u.length; s < c; s++) {
        var l = u[s];
        this.has(l) && !r.has(l) && (r.add(u[s]), n[n.length] = at.create(t, o, l));
      }
    }
    return n.sort(function(d, f) {
      return d.element - f.element;
    }), n;
  }, e.prototype.getElements = function(t) {
    var r = this, n = this.getStructureElements(t);
    return { elements: n, property: function(i) {
      return r.get(n[i].element);
    } };
  }, e;
}(), mY = function() {
  function e(t) {
    this.map = t, this.id = Ii.create22(), this.level = "entity", this.kind = 0;
  }
  return e.prototype.has = function(t) {
    return this.map.has(t);
  }, e.prototype.get = function(t) {
    return this.map.get(t);
  }, e.prototype.getStructureElements = function(t) {
    var r = t.models;
    if (r.length !== 1) throw new Error("Only works on structures with a single model.");
    for (var n = r[0].atomicHierarchy.index, i = /* @__PURE__ */ new Set(), a = t.unitSymmetryGroups, o = [], u = r[0].atomicHierarchy.chainAtomSegments, s = 0, c = a; s < c.length; s++) {
      var l = c[s].units[0];
      if (l.kind === this.kind) for (var d = Zt.transientSegments(u, l.elements); d.hasNext; ) {
        var f = d.move(), m = n.getEntityFromChain(f.index);
        this.has(m) && !i.has(m) && (i.add(m), o[o.length] = at.create(t, l, l.elements[f.start]));
      }
    }
    return o.sort(function(v, p) {
      return v.element - p.element;
    }), o;
  }, e.prototype.getElements = function(t) {
    var r = this, n = this.getStructureElements(t), i = t.model.atomicHierarchy.chainAtomSegments.index, a = t.model.atomicHierarchy.index;
    return { elements: n, property: function(o) {
      return r.get(a.getEntityFromChain(i[n[o].element]));
    } };
  }, e;
}(), tv = He(13421772), dS = {}, hY = { name: "carbohydrate-symbol", label: "Carbohydrate Symbol", category: "Residue Property", factory: function e(t, r) {
  var n;
  if (t.structure) {
    var i = t.structure.carbohydrates, a = i.elements, o = i.getElementIndices, u = function(s, c) {
      if (!Be.isAtomic(s)) return tv;
      var l = o(s, c);
      return l.length > 0 ? a[l[0]].component.color : tv;
    };
    n = function(s, c) {
      return c ? yt.Secondary : at.is(s) ? u(s.unit, s.element) : Dt.isLocation(s) ? u(s.aUnit, s.aUnit.elements[s.aIndex]) : tv;
    };
  } else n = function() {
    return tv;
  };
  return { factory: e, granularity: "group", color: n, props: r, description: "Assigns colors according to the Symbol Nomenclature for Glycans (SNFG).", legend: is(vK) };
}, getParams: function(e) {
  return dS;
}, defaultValues: G.getDefaultValues(dS), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return nn.hasCarbohydrate(t);
  });
} }, MT = He(14539007), vY = "Gives everything the same, uniform color.", N2 = { value: G.Color(MT) };
function Em(e, t) {
  var r = Ci(t.value, MT);
  return { factory: Em, granularity: "uniform", color: function() {
    return r;
  }, props: t, description: vY, legend: is([["uniform", r]]) };
}
var gY = { name: "uniform", label: "Uniform", category: "Miscellaneous", factory: Em, getParams: function(e) {
  return N2;
}, defaultValues: G.getDefaultValues(N2), isApplicable: function(e) {
  return !0;
} }, fS = { value: G.Numeric(1, { min: 0, max: 20, step: 0.1 }) };
function A_(e, t) {
  var r = t.value;
  return { factory: A_, granularity: "uniform", size: function() {
    return r;
  }, props: t, description: "Gives everything the same, uniform size." };
}
var yY = { name: "uniform", label: "Uniform", category: "", factory: A_, getParams: function(e) {
  return fS;
}, defaultValues: G.getDefaultValues(fS), isApplicable: function(e) {
  return !0;
} }, pS = { scale: G.Numeric(1, { min: 0.1, max: 5, step: 0.1 }) };
function a4(e, t) {
  return Be.isAtomic(e) ? Eg(e.model.atomicHierarchy.atoms.type_symbol.value(t)) : Be.isSpheres(e) ? e.model.coarseConformation.spheres.radius[t] : 0;
}
var bY = { name: "physical", label: "Physical", category: "", factory: function e(t, r) {
  var n = r.scale === void 0 ? 1 : r.scale;
  return { factory: e, granularity: "group", size: function(i) {
    return at.is(i) ? n * a4(i.unit, i.element) : Dt.isLocation(i) ? n * Math.min(a4(i.aUnit, i.aUnit.elements[i.aIndex]), a4(i.bUnit, i.bUnit.elements[i.bIndex])) : 1 * n;
  }, props: r, description: "Assigns a physical size, i.e. vdW radius for atoms or given radius for coarse spheres." };
}, getParams: function(e) {
  return pS;
}, defaultValues: G.getDefaultValues(pS), isApplicable: function(e) {
  return !!e.structure;
} }, vo = w();
function Z1(e, t, r, n) {
  for (var i = 0, a = 3 * n; i < a; i += 3) w.fromArray(vo, t, r + i), w.transformMat4(vo, vo, e), w.toArray(vo, t, r + i);
}
var mS = w(), o4 = w(), hS = w(), lu = w(), vS = w();
function TT(e, t, r, n, i) {
  for (var a = 0, o = 3 * i; a < o; a += 3) {
    var u = 3 * t[a], s = 3 * t[a + 1], c = 3 * t[a + 2];
    w.fromArray(mS, e, u), w.fromArray(o4, e, s), w.fromArray(hS, e, c), w.sub(lu, hS, o4), w.sub(vS, mS, o4), w.cross(lu, lu, vS), r[u] += lu[0], r[u + 1] += lu[1], r[u + 2] += lu[2], r[s] += lu[0], r[s + 1] += lu[1], r[s + 2] += lu[2], r[c] += lu[0], r[c + 1] += lu[1], r[c + 2] += lu[2];
  }
  return function(l, d) {
    for (var f = 0, m = 3 * d; f < m; f += 3) {
      var v = l[f], p = l[f + 1], g = l[f + 2], h = 1 / Math.sqrt(v * v + p * p + g * g);
      l[f] = v * h, l[f + 1] = p * h, l[f + 2] = g * h;
    }
    return l;
  }(r, n);
}
function _0(e, t, r) {
  r === void 0 && (r = 1);
  for (var n = y2(e), i = new Int32Array(n + 2), a = new Int32Array(t), o = new Int32Array(t), u = 0, s = t * r; u < s; u += r) ++o[e[u]];
  var c = 0;
  for (u = 0; u < t; u++) i[u] = c, c += o[u];
  i[t] = c;
  var l = new Int32Array(c);
  for (u = 0, s = t * r; u < s; u += r) {
    var d = e[u];
    l[i[d] + a[d]] = u, ++a[d];
  }
  return { indices: l, offsets: i };
}
function Di(e, t, r, n) {
  var i = function(s, c) {
    s = Math.max(s, 2);
    var l = Math.sqrt(s), d = Math.ceil(l), f = (d += (c - d % c) % c) > 0 ? Math.ceil(s / d) : 0;
    return { width: d, height: f, length: d * f * c };
  }(e, t), a = i.length, o = i.width, u = i.height;
  return { array: n = n && n.length >= a ? n : new r(a), width: o, height: u };
}
var xu = w(), _Y = new Nu("14"), xY = new Nu("98");
function PT(e) {
  return e > 1e5 ? _Y : xY;
}
function nd(e, t, r) {
  var n = 3 * r, i = PT(t);
  i.reset();
  for (var a = 0, o = 3 * t; a < o; a += n) w.fromArray(xu, e, a), i.includePosition(xu);
  for (i.finishedIncludeStep(), a = 0, o = 3 * t; a < o; a += n) w.fromArray(xu, e, a), i.radiusPosition(xu);
  var u = i.getSphere();
  if (t <= 98) {
    var s = [];
    for (a = 0, o = 3 * t; a < o; a += n) s.push(w.fromArray(w(), e, a));
    Me.setExtrema(u, s);
  }
  return u;
}
var u4 = me();
function zi(e, t, r) {
  if (r === 1) {
    me.fromArray(u4, t, 0);
    var n = Me.clone(e);
    return me.isIdentity(u4) ? n : Me.transform(n, n, u4);
  }
  var i = PT(r);
  i.reset();
  var a = e.center, o = e.radius, u = e.extrema;
  if (u && r < 50) {
    for (var s = 0, c = r; s < c; ++s) for (var l = 0, d = u; l < d.length; l++) {
      var f = d[l];
      w.transformMat4Offset(xu, f, t, 0, 0, 16 * s), i.includePosition(xu);
    }
    for (i.finishedIncludeStep(), s = 0, c = r; s < c; ++s) for (var m = 0, v = u; m < v.length; m++)
      f = v[m], w.transformMat4Offset(xu, f, t, 0, 0, 16 * s), i.radiusPosition(xu);
  } else {
    for (s = 0, c = r; s < c; ++s) w.transformMat4Offset(xu, a, t, 0, 0, 16 * s), i.includePositionRadius(xu, o);
    for (i.finishedIncludeStep(), s = 0, c = r; s < c; ++s) w.transformMat4Offset(xu, a, t, 0, 0, 16 * s), i.radiusPositionRadius(xu, o);
  }
  return i.getSphere();
}
var fa = new Uint8Array(772);
function BT(e, t) {
  if (t === 0) return 0;
  var r = new Uint32Array(e.buffer, 0, e.buffer.byteLength >> 2), n = t - 4 >> 2, i = 4 * n, a = 0;
  if (n < 0) for (var o = 0; o < t; ++o) a += e[o] && 1;
  else {
    for (o = 0; o < n; ++o) {
      var u = r[o];
      a += fa[65535 & u] + fa[u >> 16];
    }
    for (o = i; o < t; ++o) a += e[o] && 1;
  }
  return a / t;
}
function Pu(e, t) {
  var r = Di(Math.max(1, e), 1, Uint8Array, t && t.tMarker.ref.value.array), n = BT(r.array, e), i = n === 0 ? 0 : -1;
  return t ? (k.updateIfChanged(t.uMarker, 0), k.update(t.tMarker, r), k.update(t.uMarkerTexDim, ke.create(r.width, r.height)), k.updateIfChanged(t.markerAverage, n), k.updateIfChanged(t.markerStatus, i), t) : { uMarker: k.create(0), tMarker: k.create(r), uMarkerTexDim: k.create(ke.create(r.width, r.height)), markerAverage: k.create(n), markerStatus: k.create(i) };
}
fa[1] = 1, fa[2] = 1, fa[3] = 1, fa[256] = 1, fa[512] = 1, fa[768] = 1, fa[257] = 2, fa[513] = 2, fa[769] = 2, fa[258] = 2, fa[514] = 2, fa[770] = 2, fa[259] = 2, fa[515] = 2, fa[771] = 2;
var Ns = { kind: "null-location" };
function ri(e, t, r, n, i, a) {
  if (i === void 0 && (i = !1), a === void 0 && (a = function() {
    return !1;
  }), e % r != 0) throw new Error("incompatible groupCount and stride");
  var o = { location: Ns, index: 0, groupIndex: 0, instanceIndex: 0, isSecondary: !1 }, u = o.groupIndex < e, s = !1, c = 0, l = 0, d = !1;
  return { get hasNext() {
    return u;
  }, get isNextNewInstance() {
    return s;
  }, groupCount: e, instanceCount: t, count: e * t, stride: r, nonInstanceable: i, move: function() {
    return u && (o.groupIndex = c, o.instanceIndex = l, o.index = l * e + c, o.location = n(c, d ? -1 : l), o.isSecondary = a(c, d ? -1 : l), (c += r) === e ? (++l, s = !0, l < t && (c = 0)) : s = !1, u = c < e), o;
  }, reset: function() {
    o.location = Ns, o.index = 0, o.groupIndex = 0, o.instanceIndex = 0, o.isSecondary = !1, u = o.groupIndex < e, s = !1, c = 0, l = 0, d = !1;
  }, skipInstance: function() {
    u && o.instanceIndex === l && (++l, c = 0, u = l < t);
  }, voidInstances: function() {
    d = !0;
  } };
}
function hf(e) {
  return { kind: "position-location", position: w() };
}
function Xo(e, t, r, n) {
  var i = function(a, o, u, s) {
    switch (oa.getGranularity(a, u.granularity)) {
      case "uniform":
        return function(c, l, d) {
          return function(f, m) {
            return m ? (k.update(m.uColor, He.toVec3Normalized(m.uColor.ref.value, f)), k.updateIfChanged(m.dColorType, "uniform"), m) : { uColor: k.create(He.toVec3Normalized(w(), f)), tColor: k.create({ array: new Uint8Array(3), width: 1, height: 1 }), tColorGrid: k.create(go()), tPalette: k.create({ array: new Uint8Array(3), width: 1, height: 1 }), uColorTexDim: k.create(ke.create(1, 1)), uColorGridDim: k.create(w.create(1, 1, 1)), uColorGridTransform: k.create(Vt.create(0, 0, 0, 1)), dColorType: k.create("uniform"), dUsePalette: k.create(!1) };
          }(l(Ns, !1), d);
        }(0, u.color, s);
      case "instance":
        return function(c, l, d) {
          var f = c.instanceCount, m = Di(Math.max(1, f), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(); c.hasNext; ) {
            var v = c.move(), p = v.location, g = v.isSecondary, h = v.instanceIndex;
            He.toArray(l(p, g), m.array, 3 * h), c.skipInstance();
          }
          return Z0(m, "instance", d);
        }(a, u.color, s);
      case "group":
        return function(c, l, d) {
          var f = c.groupCount, m = Di(Math.max(1, f), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(); c.hasNext && !c.isNextNewInstance; ) {
            var v = c.move(), p = v.location, g = v.isSecondary, h = v.groupIndex;
            He.toArray(l(p, g), m.array, 3 * h);
          }
          return Z0(m, "group", d);
        }(a, u.color, s);
      case "groupInstance":
        return function(c, l, d) {
          var f = c.groupCount, m = c.instanceCount, v = m * f, p = Di(Math.max(1, v), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(); c.hasNext; ) {
            var g = c.move(), h = g.location, y = g.isSecondary, x = g.index;
            He.toArray(l(h, y), p.array, 3 * x);
          }
          return Z0(p, "groupInstance", d);
        }(a, u.color, s);
      case "vertex":
        return function(c, l, d) {
          var f = c.groupCount, m = c.stride, v = Di(Math.max(1, f), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(), c.voidInstances(); c.hasNext && !c.isNextNewInstance; ) for (var p = c.move(), g = p.location, h = p.isSecondary, y = p.groupIndex, x = l(g, h), A = 0; A < m; ++A) He.toArray(x, v.array, 3 * (y + A));
          return Z0(v, "vertex", d);
        }(o, u.color, s);
      case "vertexInstance":
        return function(c, l, d) {
          var f = c.groupCount, m = c.instanceCount, v = c.stride, p = m * f, g = Di(Math.max(1, p), 3, Uint8Array, d && d.tColor.ref.value.array);
          for (c.reset(); c.hasNext; ) for (var h = c.move(), y = h.location, x = h.isSecondary, A = h.index, b = l(y, x), _ = 0; _ < v; ++_) He.toArray(b, g.array, 3 * (A + _));
          return Z0(g, "vertexInstance", d);
        }(o, u.color, s);
      case "volume":
        return gS(u.grid, "volume", s);
      case "volumeInstance":
        return gS(u.grid, "volumeInstance", s);
      case "direct":
        return function(c) {
          return c ? (k.updateIfChanged(c.dColorType, "direct"), c) : { uColor: k.create(w()), tColor: k.create({ array: new Uint8Array(3), width: 1, height: 1 }), tColorGrid: k.create(go()), tPalette: k.create({ array: new Uint8Array(3), width: 1, height: 1 }), uColorTexDim: k.create(ke.create(1, 1)), uColorGridDim: k.create(w.create(1, 1, 1)), uColorGridTransform: k.create(Vt.create(0, 0, 0, 1)), dColorType: k.create("direct"), dUsePalette: k.create(!1) };
        }(s);
    }
  }(e, t, r, n);
  return r.palette ? (k.updateIfChanged(i.dUsePalette, !0), function(a, o) {
    var u = !0, s = o.ref.value;
    if (a.colors.length !== s.width || s.filter !== a.filter) u = !1;
    else for (var c = s.array, l = 0, d = 0, f = a.colors; d < f.length; d++) {
      var m = f[d], v = He.toRgb(m), p = v[0], g = v[1], h = v[2];
      if (c[l++] !== p || c[l++] !== g || c[l++] !== h) {
        u = !1;
        break;
      }
    }
    if (!u) {
      for (var y = new Uint8Array(3 * a.colors.length), x = 0, A = 0, b = a.colors; A < b.length; A++) {
        m = b[A];
        var _ = He.toRgb(m);
        p = _[0], g = _[1], h = _[2], y[x++] = p, y[x++] = g, y[x++] = h;
      }
      k.update(o, { array: y, height: 1, width: a.colors.length, filter: a.filter });
    }
  }(r.palette, i.tPalette)) : k.updateIfChanged(i.dUsePalette, !1), i;
}
function Z0(e, t, r) {
  return r ? (k.update(r.tColor, e), k.update(r.uColorTexDim, ke.create(e.width, e.height)), k.updateIfChanged(r.dColorType, t), r) : { uColor: k.create(w()), tColor: k.create(e), tColorGrid: k.create(go()), tPalette: k.create({ array: new Uint8Array(3), width: 1, height: 1 }), uColorTexDim: k.create(ke.create(e.width, e.height)), uColorGridDim: k.create(w.create(1, 1, 1)), uColorGridTransform: k.create(Vt.create(0, 0, 0, 1)), dColorType: k.create(t), dUsePalette: k.create(!1) };
}
function gS(e, t, r) {
  var n = e.colors, i = e.dimension, a = e.transform, o = n.getWidth(), u = n.getHeight();
  return r ? (k.update(r.tColorGrid, n), k.update(r.uColorTexDim, ke.create(o, u)), k.update(r.uColorGridDim, w.clone(i)), k.update(r.uColorGridTransform, Vt.clone(a)), k.updateIfChanged(r.dColorType, t), r) : { uColor: k.create(w()), tColor: k.create({ array: new Uint8Array(3), width: 1, height: 1 }), tColorGrid: k.create(n), tPalette: k.create({ array: new Uint8Array(3), width: 1, height: 1 }), uColorTexDim: k.create(ke.create(o, u)), uColorGridDim: k.create(w.clone(i)), uColorGridTransform: k.create(Vt.clone(a)), dColorType: k.create(t), dUsePalette: k.create(!1) };
}
var yS = Ti(), AY = me();
function S_(e, t, r) {
  var n = function(s, c) {
    for (var l = 0; l < c; l++) if (Ti.fromMat4(yS, me.fromArray(AY, s, 16 * l)), Ti.determinant(yS) < 0) return !0;
    return !1;
  }(e, t);
  if (r) {
    k.update(r.matrix, r.matrix.ref.value);
    var i = r.transform.ref.value.length >= 16 * t ? r.transform.ref.value : new Float32Array(16 * t);
    i.set(e), k.update(r.transform, i), k.updateIfChanged(r.uInstanceCount, t), k.updateIfChanged(r.instanceCount, t);
    var a = r.aTransform.ref.value.length >= 16 * t ? r.aTransform.ref.value : new Float32Array(16 * t);
    k.update(r.aTransform, a);
    var o = r.extraTransform.ref.value.length >= 16 * t ? r.extraTransform.ref.value : new Float32Array(16 * t);
    k.update(r.extraTransform, Pb(o, t));
    var u = r.aInstance.ref.value.length >= t ? r.aInstance.ref.value : new Float32Array(t);
    k.update(r.aInstance, Fs(u, t)), k.update(r.hasReflection, n);
  } else r = { aTransform: k.create(new Float32Array(16 * t)), matrix: k.create(me.identity()), transform: k.create(new Float32Array(e)), extraTransform: k.create(Pb(new Float32Array(16 * t), t)), uInstanceCount: k.create(t), instanceCount: k.create(t), aInstance: k.create(Fs(new Float32Array(t))), hasReflection: k.create(n) };
  return FT(r), r;
}
var C_ = new Float32Array(16);
function w_(e) {
  return S_(new Float32Array(C_), 1, e);
}
function Pb(e, t) {
  for (var r = 0; r < t; r++) e.set(C_, 16 * r);
  return e;
}
function FT(e) {
  for (var t = e.aTransform.ref.value, r = e.instanceCount.ref.value, n = e.matrix.ref.value, i = e.transform.ref.value, a = e.extraTransform.ref.value, o = 0; o < r; o++) {
    var u = 16 * o;
    me.mulOffset(t, a, i, u, u, u), me.mulOffset(t, n, t, u, 0, u);
  }
  k.update(e.aTransform, t);
}
me.toArray(me.identity(), C_, 0);
var Kt = { aliceblue: 15792383, antiquewhite: 16444375, aqua: 65535, aquamarine: 8388564, azure: 15794175, beige: 16119260, bisque: 16770244, black: 0, blanchedalmond: 16772045, blue: 255, blueviolet: 9055202, brown: 10824234, burlywood: 14596231, cadetblue: 6266528, chartreuse: 8388352, chocolate: 13789470, coral: 16744272, cornflower: 6591981, cornflowerblue: 6591981, cornsilk: 16775388, crimson: 14423100, cyan: 65535, darkblue: 139, darkcyan: 35723, darkgoldenrod: 12092939, darkgray: 11119017, darkgreen: 25600, darkgrey: 11119017, darkkhaki: 12433259, darkmagenta: 9109643, darkolivegreen: 5597999, darkorange: 16747520, darkorchid: 10040012, darkred: 9109504, darksalmon: 15308410, darkseagreen: 9419919, darkslateblue: 4734347, darkslategray: 3100495, darkslategrey: 3100495, darkturquoise: 52945, darkviolet: 9699539, deeppink: 16716947, deepskyblue: 49151, dimgray: 6908265, dimgrey: 6908265, dodgerblue: 2003199, firebrick: 11674146, floralwhite: 16775920, forestgreen: 2263842, fuchsia: 16711935, gainsboro: 14474460, ghostwhite: 16316671, gold: 16766720, goldenrod: 14329120, gray: 8421504, green: 32768, greenyellow: 11403055, grey: 8421504, honeydew: 15794160, hotpink: 16738740, indianred: 13458524, indigo: 4915330, ivory: 16777200, khaki: 15787660, laserlemon: 16777044, lavender: 15132410, lavenderblush: 16773365, lawngreen: 8190976, lemonchiffon: 16775885, lightblue: 11393254, lightcoral: 15761536, lightcyan: 14745599, lightgoldenrod: 16448210, lightgoldenrodyellow: 16448210, lightgray: 13882323, lightgreen: 9498256, lightgrey: 13882323, lightpink: 16758465, lightsalmon: 16752762, lightseagreen: 2142890, lightskyblue: 8900346, lightslategray: 7833753, lightslategrey: 7833753, lightsteelblue: 11584734, lightyellow: 16777184, lime: 65280, limegreen: 3329330, linen: 16445670, magenta: 16711935, maroon: 8388608, maroon2: 8323072, maroon3: 11546720, mediumaquamarine: 6737322, mediumblue: 205, mediumorchid: 12211667, mediumpurple: 9662683, mediumseagreen: 3978097, mediumslateblue: 8087790, mediumspringgreen: 64154, mediumturquoise: 4772300, mediumvioletred: 13047173, midnightblue: 1644912, mintcream: 16121850, mistyrose: 16770273, moccasin: 16770229, navajowhite: 16768685, navy: 128, oldlace: 16643558, olive: 8421376, olivedrab: 7048739, orange: 16753920, orangered: 16729344, orchid: 14315734, palegoldenrod: 15657130, palegreen: 10025880, paleturquoise: 11529966, palevioletred: 14381203, papayawhip: 16773077, peachpuff: 16767673, peru: 13468991, pink: 16761035, plum: 14524637, powderblue: 11591910, purple: 8388736, purple2: 8323199, purple3: 10494192, rebeccapurple: 6697881, red: 16711680, rosybrown: 12357519, royalblue: 4286945, saddlebrown: 9127187, salmon: 16416882, sandybrown: 16032864, seagreen: 3050327, seashell: 16774638, sienna: 10506797, silver: 12632256, skyblue: 8900331, slateblue: 6970061, slategray: 7372944, slategrey: 7372944, snow: 16775930, springgreen: 65407, steelblue: 4620980, tan: 13808780, teal: 32896, thistle: 14204888, tomato: 16737095, turquoise: 4251856, violet: 15631086, wheat: 16113331, white: 16777215, whitesmoke: 16119285, yellow: 16776960, yellowgreen: 10145074 };
function Q1(e) {
  return R(R({}, Q1.Zero), e);
}
function qp() {
}
(function() {
  var e = /* @__PURE__ */ new Map();
  Object.keys(Kt).forEach(function(t) {
    e.set(Kt[t], t);
  });
})(), function(e) {
  e.Zero = { metalness: 0, roughness: 0, bumpiness: 0 }, e.toArray = function(t, r, n) {
    return r[n] = 255 * t.metalness, r[n + 1] = 255 * t.roughness, r[n + 2] = 255 * t.bumpiness, r;
  }, e.toString = function(t) {
    var r = t.metalness, n = t.roughness, i = t.bumpiness;
    return "M ".concat(r.toFixed(2), " | R ").concat(n.toFixed(2), " | B ").concat(i.toFixed(2));
  }, e.getParam = function(t) {
    return G.Group({ metalness: G.Numeric(0, { min: 0, max: 1, step: 0.01 }), roughness: G.Numeric(1, { min: 0, max: 1, step: 0.01 }), bumpiness: G.Numeric(0, { min: 0, max: 1, step: 0.01 }) }, R(R({}, t), { presets: [[{ metalness: 0, roughness: 1, bumpiness: 0 }, "Matte"], [{ metalness: 0, roughness: 0.2, bumpiness: 0 }, "Plastic"], [{ metalness: 0, roughness: 0.6, bumpiness: 0 }, "Glossy"], [{ metalness: 1, roughness: 0.6, bumpiness: 0 }, "Metallic"]] }));
  };
}(Q1 || (Q1 = {})), function(e) {
  e.Type = { none: 0, plane: 1, sphere: 2, cube: 3, cylinder: 4, infiniteCone: 5 }, e.Params = { variant: G.Select("pixel", G.arrayToOptions(["instance", "pixel"])), objects: G.ObjectList({ type: G.Select("plane", G.objectToOptions(e.Type, function(a) {
    return Is(a);
  })), invert: G.Boolean(!1), position: G.Vec3(w()), rotation: G.Group({ axis: G.Vec3(w.create(1, 0, 0)), angle: G.Numeric(0, { min: -180, max: 180, step: 1 }, { description: "Angle in Degrees" }) }, { isExpanded: !0 }), scale: G.Vec3(w.create(1, 1, 1)) }, function(a) {
    return Is(a.type);
  }) };
  var t = In(), r = In(), n = w(), i = w();
  e.getClip = function(a, o) {
    for (var u = (o == null ? void 0 : o.objects) || { count: 0, type: new Array(5).fill(1), invert: new Array(5).fill(!1), position: new Array(15).fill(0), rotation: new Array(20).fill(0), scale: new Array(15).fill(1) }, s = u.type, c = u.invert, l = u.position, d = u.rotation, f = u.scale, m = 0, v = a.objects.length; m < v; ++m) {
      var p = a.objects[m];
      s[m] = e.Type[p.type], c[m] = p.invert, w.toArray(p.position, l, 3 * m), In.toArray(In.setAxisAngle(t, p.rotation.axis, Bn(p.rotation.angle)), d, 4 * m), w.toArray(p.scale, f, 3 * m);
    }
    return { variant: a.variant, objects: { count: a.objects.length, type: s, invert: c, position: l, rotation: d, scale: f } };
  }, e.areEqual = function(a, o) {
    if (a.variant !== o.variant || a.objects.count !== o.objects.count) return !1;
    for (var u = a.objects, s = o.objects, c = 0, l = u.count; c < l; ++c)
      if (u.invert[c] !== s.invert[c] || u.type[c] !== s.type[c] || (w.fromArray(n, u.position, 3 * c), w.fromArray(i, s.position, 3 * c), !w.equals(n, i)) || (w.fromArray(n, u.scale, 3 * c), w.fromArray(i, s.scale, 3 * c), !w.equals(n, i)) || (In.fromArray(t, u.rotation, 4 * c), In.fromArray(r, s.rotation, 4 * c), !In.equals(t, r))) return !1;
    return !0;
  };
}(qp || (qp = {}));
var ft, SY = Object.keys({ custom: {}, auto: {}, highest: {}, higher: {}, high: {}, medium: {}, low: {}, lower: {}, lowest: {} }), CY = G.arrayToOptions(SY), wY = { smoothColors: G.MappedStatic("auto", { auto: G.Group({}), on: G.Group({ resolutionFactor: G.Numeric(2, { min: 0.5, max: 6, step: 0.1 }), sampleStride: G.Numeric(3, { min: 1, max: 12, step: 1 }) }), off: G.Group({}) }) };
function s4(e) {
  return !!e.smoothColors;
}
function Xd(e, t, r) {
  if ((e.name === "on" || e.name === "auto" && t) && r && r < 3) {
    var n = 3;
    return e.name === "on" ? (r *= e.params.resolutionFactor, n = e.params.sampleStride) : (r *= 2 - RE(0, 1.1, r), (r = Math.max(0.5, r)) > 1.2 && (n = 2)), { resolution: r, stride: n };
  }
}
function bS(e, t, r) {
  return e.fill(0, 4 * t, 4 * r), !0;
}
(function(e) {
  e.MaterialCategory = { category: "Material" }, e.ShadingCategory = { category: "Shading" }, e.CustomQualityParamInfo = { category: "Custom Quality", hideIf: function(t) {
    return t.quality !== void 0 && t.quality !== "custom";
  } }, e.Params = { alpha: G.Numeric(1, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }), quality: G.Select("auto", CY, { isEssential: !0, description: "Visual/rendering quality of the representation." }), material: Q1.getParam(), clip: G.Group(qp.Params) }, e.createSimple = function(t, r, n) {
    return t === void 0 && (t = Kt.grey), r === void 0 && (r = 1), n || (n = w_()), { transform: n, locationIterator: ri(1, n.instanceCount.ref.value, 1, function() {
      return Ns;
    }, !1, function() {
      return !1;
    }), theme: { color: Em(0, { value: t }), size: A_(0, { value: r }) } };
  }, e.createValues = function(t, r) {
    var n = qp.getClip(t.clip);
    return { alpha: k.create(t.alpha), uAlpha: k.create(t.alpha), uVertexCount: k.create(r.vertexCount), uGroupCount: k.create(r.groupCount), drawCount: k.create(r.drawCount), uMetalness: k.create(t.material.metalness), uRoughness: k.create(t.material.roughness), uBumpiness: k.create(t.material.bumpiness), dLightCount: k.create(1), dClipObjectCount: k.create(n.objects.count), dClipVariant: k.create(n.variant), uClipObjectType: k.create(n.objects.type), uClipObjectInvert: k.create(n.objects.invert), uClipObjectPosition: k.create(n.objects.position), uClipObjectRotation: k.create(n.objects.rotation), uClipObjectScale: k.create(n.objects.scale) };
  }, e.updateValues = function(t, r) {
    k.updateIfChanged(t.alpha, r.alpha), k.updateIfChanged(t.uMetalness, r.material.metalness), k.updateIfChanged(t.uRoughness, r.material.roughness), k.updateIfChanged(t.uBumpiness, r.material.bumpiness);
    var n = qp.getClip(r.clip);
    k.update(t.dClipObjectCount, n.objects.count), k.update(t.dClipVariant, n.variant), k.update(t.uClipObjectType, n.objects.type), k.update(t.uClipObjectInvert, n.objects.invert), k.update(t.uClipObjectPosition, n.objects.position), k.update(t.uClipObjectRotation, n.objects.rotation), k.update(t.uClipObjectScale, n.objects.scale);
  }, e.createRenderableState = function(t) {
    t === void 0 && (t = {});
    var r = t.alpha === void 0 || t.alpha === 1;
    return { disposed: !1, visible: !0, alphaFactor: 1, pickable: !0, colorOnly: !1, opaque: r, writeDepth: r };
  }, e.updateRenderableState = function(t, r) {
    t.opaque = r.alpha * t.alphaFactor >= 1, t.writeDepth = t.opaque;
  };
})(ft || (ft = {}));
var DY = { array: new Uint8Array(4), width: 1, height: 1 };
function Ac(e) {
  return { tOverpaint: k.create(DY), uOverpaintTexDim: k.create(ke.create(1, 1)), dOverpaint: k.create(!1), tOverpaintGrid: k.create(go()), uOverpaintGridDim: k.create(w.create(1, 1, 1)), uOverpaintGridTransform: k.create(Vt.create(0, 0, 0, 1)), dOverpaintType: k.create("groupInstance") };
}
function _S(e, t) {
  for (var r = 0, n = 0; n < t; ++n) r += e[n];
  return r / (255 * t);
}
var IY = { array: new Uint8Array(1), width: 1, height: 1 };
function Sc(e) {
  return { tTransparency: k.create(IY), uTransparencyTexDim: k.create(ke.create(1, 1)), dTransparency: k.create(!1), transparencyAverage: k.create(0), tTransparencyGrid: k.create(go()), uTransparencyGridDim: k.create(w.create(1, 1, 1)), uTransparencyGridTransform: k.create(Vt.create(0, 0, 0, 1)), dTransparencyType: k.create("groupInstance") };
}
var EY = { array: new Uint8Array(1), width: 1, height: 1 };
function Cc(e) {
  return { tClipping: k.create(EY), uClippingTexDim: k.create(ke.create(1, 1)), dClipping: k.create(!1) };
}
function xS(e, t, r) {
  return e.fill(0, 4 * t, 4 * r), !0;
}
var Gt, MY = { array: new Uint8Array(4), width: 1, height: 1 };
function wc(e) {
  return { tSubstance: k.create(MY), uSubstanceTexDim: k.create(ke.create(1, 1)), dSubstance: k.create(!1), tSubstanceGrid: k.create(go()), uSubstanceGridDim: k.create(w.create(1, 1, 1)), uSubstanceGridTransform: k.create(Vt.create(0, 0, 0, 1)), dSubstanceType: k.create("groupInstance") };
}
function c4(e, t, r) {
  return e = Qa(Math.round(e), 0, 16777215) + 1, t[r + 2] = e % 256, e = Math.floor(e / 256), t[r + 1] = e % 256, e = Math.floor(e / 256), t[r] = e % 256, t;
}
function D_(e, t, r) {
  return 256 * Math.floor(e) * 256 + 256 * Math.floor(t) + Math.floor(r) - 1;
}
(function(e) {
  function t(m, v, p, g, h, y, x) {
    return x ? function(A, b, _, S, D, I, M) {
      return M.vertexCount = D, M.triangleCount = I, k.update(M.vertexBuffer, A), k.update(M.indexBuffer, b), k.update(M.normalBuffer, _), k.update(M.groupBuffer, S), M;
    }(m, v, p, g, h, y, x) : function(A, b, _, S, D, I) {
      var M, F = Me(), P = -1, E = -1, B = { kind: "mesh", vertexCount: D, triangleCount: I, vertexBuffer: k.create(A), indexBuffer: k.create(b), normalBuffer: k.create(_), groupBuffer: k.create(S), get boundingSphere() {
        var N = n(B);
        if (N !== P) {
          var O = nd(B.vertexBuffer.ref.value, B.vertexCount, 1);
          Me.copy(F, O), P = N;
        }
        return F;
      }, get groupMapping() {
        return B.groupBuffer.ref.version !== E && (M = _0(B.groupBuffer.ref.value, B.vertexCount), E = B.groupBuffer.ref.version), M;
      }, setBoundingSphere: function(N) {
        Me.copy(F, N), P = n(B);
      }, meta: {} };
      return B;
    }(m, v, p, g, h, y);
  }
  function r(m) {
    return t(m ? m.vertexBuffer.ref.value : new Float32Array(0), m ? m.indexBuffer.ref.value : new Uint32Array(0), m ? m.normalBuffer.ref.value : new Float32Array(0), m ? m.groupBuffer.ref.value : new Float32Array(0), 0, 0, m);
  }
  function n(m) {
    return Ra([m.vertexCount, m.triangleCount, m.vertexBuffer.ref.version, m.indexBuffer.ref.version, m.normalBuffer.ref.version, m.groupBuffer.ref.version]);
  }
  e.create = t, e.createEmpty = r, e.computeNormals = function(m) {
    var v = m.vertexCount, p = m.triangleCount, g = m.vertexBuffer.ref.value, h = m.indexBuffer.ref.value, y = m.normalBuffer.ref.value.length >= 3 * v ? m.normalBuffer.ref.value : new Float32Array(3 * v);
    y === m.normalBuffer.ref.value && y.fill(0, 0, 3 * v), TT(g, h, y, v, p), k.update(m.normalBuffer, y);
  }, e.checkForDuplicateVertices = function(m, v) {
    v === void 0 && (v = 3);
    for (var p = m.vertexBuffer.ref.value, g = /* @__PURE__ */ new Map(), h = function(D, I) {
      return "".concat(D[0].toFixed(I), "|").concat(D[1].toFixed(I), "|").concat(D[2].toFixed(I));
    }, y = 0, x = w(), A = 0, b = m.vertexCount; A < b; ++A) {
      w.fromArray(x, p, 3 * A);
      var _ = h(x, v), S = g.get(_);
      S !== void 0 ? (y += 1, g.set(_, S + 1)) : g.set(_, 1);
    }
    return y;
  };
  var i = Ti();
  function a(m) {
    for (var v = m.vertexCount, p = m.triangleCount, g = m.indexBuffer.ref.value, h = [], y = 0; y < v; ++y) h[y] = [];
    for (y = 0; y < p; ++y) {
      var x = g[3 * y], A = g[3 * y + 1], b = g[3 * y + 2];
      Su(h[x], A), Su(h[x], b), Su(h[A], x), Su(h[A], b), Su(h[b], x), Su(h[b], A);
    }
    return h;
  }
  function o(m) {
    for (var v = m.triangleCount, p = m.indexBuffer.ref.value, g = /* @__PURE__ */ new Map(), h = function(_, S) {
      var D = f2(_, S), I = g.get(D) || 0;
      g.set(D, I + 1);
    }, y = 0; y < v; ++y) {
      var x = p[3 * y], A = p[3 * y + 1], b = p[3 * y + 2];
      h(x, A), h(x, b), h(A, b);
    }
    return g;
  }
  function u(m) {
    var v = /* @__PURE__ */ new Set(), p = [0, 0];
    return m.forEach(function(g, h) {
      g === 1 && (function(y, x) {
        var A = Math.floor((Math.sqrt(8 * x + 1) - 1) / 2), b = x - (A * A + A) / 2;
        y[0] = A - b, y[1] = b;
      }(p, h), v.add(p[0]), v.add(p[1]));
    }), v;
  }
  function s(m, v, p) {
    var g = /* @__PURE__ */ new Map(), h = function(y, x) {
      g.has(y) ? Su(g.get(y), x) : g.set(y, [x]);
    };
    return v.forEach(function(y) {
      for (var x = 0, A = m[y]; x < A.length; x++) {
        var b = A[x];
        v.has(b) && p.get(f2(y, b)) === 1 && h(y, b);
      }
    }), g;
  }
  function c(m, v, p, g) {
    for (var h, y = m.vertexBuffer, x = m.indexBuffer, A = m.normalBuffer, b = m.triangleCount, _ = y.ref.value, S = x.ref.value, D = A.ref.value, I = Oe.create(Uint32Array, 3, 1024, b), M = 0, F = 0; F < b; ++F) Oe.add3(I, S[3 * F], S[3 * F + 1], S[3 * F + 2]), M += 1;
    var P = w(), E = w(), B = w(), N = w(), O = w(), z = w(), V = w(), U = w(), H = w(), K = w(), j = Bn(120), X = /* @__PURE__ */ new Set(), W = Array.from(p.keys()).filter(function(Ue) {
      return p.get(Ue).length < 2;
    }).map(function(Ue) {
      var Ke = p.get(Ue);
      return w.fromArray(P, _, 3 * Ue), w.fromArray(E, _, 3 * Ke[0]), w.fromArray(B, _, 3 * Ke[1]), w.sub(O, E, P), w.sub(z, B, P), [Ue, w.angle(O, z)];
    });
    W.sort(function(Ue, Ke) {
      return Ue[1] - Ke[1];
    });
    for (var Q = 0, te = W; Q < te.length; Q++) {
      var ee = te[Q], $ = ee[0], ie = ee[1];
      if (!(X.has($) || ie > j)) {
        var ae = p.get($);
        if ((!v[ae[0]].includes(ae[1]) || !((h = p.get(ae[0])) === null || h === void 0) && h.includes(ae[1])) && (w.fromArray(P, _, 3 * $), w.fromArray(E, _, 3 * ae[0]), w.fromArray(B, _, 3 * ae[1]), w.sub(O, E, P), w.sub(z, B, P), w.add(U, O, z), !(w.squaredDistance(P, E) >= g))) {
          for (var se = !1, le = 0, pe = v[$]; le < pe.length; le++) {
            var we = pe[le];
            if (!ae.includes(we) && (w.fromArray(N, _, 3 * we), w.sub(V, N, P), w.dot(U, V) < 0)) {
              se = !0;
              break;
            }
          }
          se && (w.fromArray(H, D, 3 * $), w.triangleNormal(K, P, E, B), w.dot(K, H) > 0 ? Oe.add3(I, $, ae[0], ae[1]) : Oe.add3(I, ae[1], ae[0], $), X.add($), X.add(ae[0]), X.add(ae[1]), M += 1);
        }
      }
    }
    var Ge = Oe.compact(I);
    return m.triangleCount = M, k.update(x, Ge), m;
  }
  function l(m, v) {
    var p = m.vertexCount, g = v.instanceCount.ref.value, h = hf(), y = h.position, x = m.vertexBuffer.ref.value, A = v.aTransform.ref.value;
    return ri(p, g, 1, function(b, _) {
      return _ < 0 ? w.fromArray(y, x, 3 * b) : w.transformMat4Offset(y, x, A, 0, 3 * b, 16 * _), h;
    });
  }
  function d(m, v, p, g, h) {
    var y = p.instanceCount, x = p.groupCount, A = Xo(p, l(m, v), g.color), b = Pu(y * x), _ = Ac(), S = Sc(), D = wc(), I = Cc(), M = { drawCount: 3 * m.triangleCount, vertexCount: m.vertexCount, groupCount: x, instanceCount: y }, F = Me.clone(m.boundingSphere), P = zi(F, v.aTransform.ref.value, y);
    return R(R(R(R(R(R(R(R(R({ dGeometryType: k.create("mesh"), aPosition: m.vertexBuffer, aNormal: m.normalBuffer, aGroup: m.groupBuffer, elements: m.indexBuffer, boundingSphere: k.create(P), invariantBoundingSphere: k.create(F), uInvariantBoundingSphere: k.create(Vt.ofSphere(F)) }, A), b), _), S), D), I), v), ft.createValues(h, M)), { uDoubleSided: k.create(h.doubleSided), dFlatShaded: k.create(h.flatShaded), dFlipSided: k.create(h.flipSided), dIgnoreLight: k.create(h.ignoreLight), dXrayShaded: k.create(h.xrayShaded), uBumpFrequency: k.create(h.bumpFrequency), uBumpAmplitude: k.create(h.bumpAmplitude), meta: k.create(m.meta) });
  }
  function f(m, v) {
    ft.updateRenderableState(m, v), m.opaque = m.opaque && !v.xrayShaded, m.writeDepth = m.opaque;
  }
  e.transform = function(m, v) {
    var p = m.vertexBuffer.ref.value;
    Z1(v, p, 0, m.vertexCount), me.isTranslationAndUniformScaling(v) || function(g, h, y, x) {
      for (var A = 0, b = 3 * x; A < b; A += 3) w.fromArray(vo, h, y + A), w.transformMat3(vo, vo, g), w.toArray(vo, h, y + A);
    }(Ti.directionTransform(i, v), m.normalBuffer.ref.value, 0, m.vertexCount), k.update(m.vertexBuffer, p);
  }, e.getOriginalData = function(m) {
    return ("kind" in m ? m.meta : m.meta.ref.value).originalData;
  }, e.uniformTriangleGroup = function(m, v) {
    v === void 0 && (v = !0);
    var p = m.indexBuffer, g = m.vertexBuffer, h = m.groupBuffer, y = m.normalBuffer, x = m.triangleCount, A = m.vertexCount, b = p.ref.value, _ = g.ref.value, S = h.ref.value, D = y.ref.value, I = Oe.create(Uint32Array, 3, 1024, x), M = Oe.create(Float32Array, 3, 1024, _);
    M.currentIndex = 3 * A, M.elementCount = A;
    var F = Oe.create(Float32Array, 3, 1024, D);
    F.currentIndex = 3 * A, F.elementCount = A;
    var P = Oe.create(Float32Array, 1, 1024, S);
    P.currentIndex = A, P.elementCount = A;
    var E = w(), B = w(), N = w(), O = w(), z = w(), V = w();
    function U(Fe) {
      w.fromArray(E, _, 3 * Fe), w.fromArray(O, D, 3 * Fe), Oe.add3(M, E[0], E[1], E[2]), Oe.add3(F, O[0], O[1], O[2]);
    }
    function H(Fe, Je) {
      w.fromArray(E, _, 3 * Fe), w.fromArray(B, _, 3 * Je), w.scale(E, w.add(E, E, B), 0.5), w.fromArray(O, D, 3 * Fe), w.fromArray(z, D, 3 * Je), w.scale(O, w.add(O, O, z), 0.5), Oe.add3(M, E[0], E[1], E[2]), Oe.add3(F, O[0], O[1], O[2]);
    }
    function K(Fe, Je, Ne) {
      w.fromArray(E, _, 3 * Fe), w.fromArray(B, _, 3 * Je), w.fromArray(N, _, 3 * Ne), w.scale(E, w.add(E, w.add(E, E, B), N), 1 / 3), w.fromArray(O, D, 3 * Fe), w.fromArray(z, D, 3 * Je), w.fromArray(V, D, 3 * Ne), w.scale(O, w.add(O, w.add(O, O, z), V), 1 / 3), Oe.add3(M, E[0], E[1], E[2]), Oe.add3(F, O[0], O[1], O[2]);
    }
    function j(Fe, Je, Ne, nt, re) {
      ++W, U(Fe), H(Fe, Je), H(Fe, Ne), Oe.add3(I, X, X + 1, X + 2);
      for (var J = 0; J < 3; ++J) Oe.add(P, nt);
      for (X += 3, W += 2, U(Je), U(Ne), H(Fe, Je), H(Fe, Ne), Oe.add3(I, X, X + 1, X + 3), Oe.add3(I, X, X + 3, X + 2), J = 0; J < 4; ++J) Oe.add(P, re);
      X += 4;
    }
    var X = A, W = 0;
    if (v) for (var Q = 0, te = x; Q < te; ++Q) {
      var ee = b[3 * Q], $ = b[3 * Q + 1], ie = b[3 * Q + 2], ae = S[ee], se = S[$], le = S[ie];
      if (ae === se && ae === le) ++W, Oe.add3(I, ee, $, ie);
      else if (ae === se) j(ie, ee, $, le, ae);
      else if (ae === le) j($, ie, ee, se, le);
      else if (se === le) j(ee, $, ie, ae, se);
      else {
        W += 2, U(ee), H(ee, $), H(ee, ie), K(ee, $, ie), Oe.add3(I, X, X + 1, X + 3), Oe.add3(I, X, X + 3, X + 2);
        for (var pe = 0; pe < 4; ++pe) Oe.add(P, ae);
        for (X += 4, W += 2, U($), H($, ie), H($, ee), K(ee, $, ie), Oe.add3(I, X, X + 1, X + 3), Oe.add3(I, X, X + 3, X + 2), pe = 0; pe < 4; ++pe) Oe.add(P, se);
        for (X += 4, W += 2, U(ie), H(ie, $), H(ie, ee), K(ee, $, ie), Oe.add3(I, X + 3, X + 1, X), Oe.add3(I, X + 2, X + 3, X), pe = 0; pe < 4; ++pe) Oe.add(P, le);
        X += 4;
      }
    }
    else for (Q = 0, te = x; Q < te; ++Q)
      if (ee = b[3 * Q], $ = b[3 * Q + 1], ie = b[3 * Q + 2], ae = S[ee], se = S[$], le = S[ie], ae !== se || ae !== le) {
        ++W, U(ee), U($), U(ie), Oe.add3(I, X, X + 1, X + 2);
        var we = se === le ? se : ae;
        for (pe = 0; pe < 3; ++pe) Oe.add(P, we);
        X += 3;
      } else ++W, Oe.add3(I, ee, $, ie);
    var Ge = Oe.compact(I), Ue = Oe.compact(M), Ke = Oe.compact(F), Ze = Oe.compact(P);
    return m.vertexCount = X, m.triangleCount = W, k.update(g, Ue), k.update(h, Ze), k.update(p, Ge), k.update(y, Ke), m.meta.originalData = { indexBuffer: b, vertexCount: A, triangleCount: x }, m;
  }, e.smoothEdges = function(m, v) {
    (function(A, b) {
      for (var _ = A.indexBuffer, S = A.triangleCount, D = _.ref.value, I = Oe.create(Uint32Array, 3, 1024, S), M = 0, F = 0; F < S; ++F) {
        var P = D[3 * F], E = D[3 * F + 1], B = D[3 * F + 2];
        b[P].length !== 2 && b[E].length !== 2 && b[B].length !== 2 && (Oe.add3(I, P, E, B), M += 1);
      }
      var N = Oe.compact(I);
      A.triangleCount = M, k.update(_, N);
    })(m, a(m));
    for (var p = 0; p < 10; ++p) {
      var g = m.triangleCount, h = o(m), y = a(m);
      if (c(m, y, s(y, u(h), h), v.maxNewEdgeLength * v.maxNewEdgeLength), m.triangleCount === g) break;
    }
    var x = o(m);
    return function(A, b, _) {
      for (var S = _.iterations, D = _.lambda, I = w(), M = w(), F = w(), P = w(), E = -D, B = new Float32Array(A.vertexBuffer.ref.value.length), N = function(z) {
        var V = A.vertexBuffer.ref.value;
        B.set(V), b.forEach(function(H, K) {
          if (H.length === 2) {
            w.fromArray(I, V, 3 * K), w.fromArray(M, V, 3 * H[0]), w.fromArray(F, V, 3 * H[1]);
            var j = 1 / w.distance(I, M), X = 1 / w.distance(I, F);
            w.scale(M, M, j), w.scale(F, F, X), w.add(P, M, F), w.scale(P, P, 1 / (j + X)), w.sub(P, P, I), w.scale(P, P, z), w.add(P, I, P), w.toArray(P, B, 3 * K);
          }
        });
        var U = A.vertexBuffer.ref.value;
        k.update(A.vertexBuffer, B), B = U;
      }, O = 0; O < S; ++O) N(D), N(E);
    }(m, s(a(m), u(x), x), { iterations: v.iterations, lambda: 0.5 }), m;
  }, e.Params = R(R({}, ft.Params), { doubleSided: G.Boolean(!1, ft.CustomQualityParamInfo), flipSided: G.Boolean(!1, ft.ShadingCategory), flatShaded: G.Boolean(!1, ft.ShadingCategory), ignoreLight: G.Boolean(!1, ft.ShadingCategory), xrayShaded: G.Boolean(!1, ft.ShadingCategory), bumpFrequency: G.Numeric(0, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory), bumpAmplitude: G.Numeric(1, { min: 0, max: 5, step: 0.1 }, ft.ShadingCategory) }), e.Utils = { Params: e.Params, createEmpty: r, createValues: d, createValuesSimple: function(m, v, p, g, h) {
    var y = ft.createSimple(p, g, h), x = R(R({}, G.getDefaultValues(e.Params)), v);
    return d(m, y.transform, y.locationIterator, y.theme, x);
  }, updateValues: function(m, v) {
    ft.updateValues(m, v), k.updateIfChanged(m.uDoubleSided, v.doubleSided), k.updateIfChanged(m.dFlatShaded, v.flatShaded), k.updateIfChanged(m.dFlipSided, v.flipSided), k.updateIfChanged(m.dIgnoreLight, v.ignoreLight), k.updateIfChanged(m.dXrayShaded, v.xrayShaded), k.updateIfChanged(m.uBumpFrequency, v.bumpFrequency), k.updateIfChanged(m.uBumpAmplitude, v.bumpAmplitude);
  }, updateBoundingSphere: function(m, v) {
    var p = Me.clone(v.boundingSphere), g = zi(p, m.aTransform.ref.value, m.instanceCount.ref.value);
    Me.equals(g, m.boundingSphere.ref.value) || k.update(m.boundingSphere, g), Me.equals(p, m.invariantBoundingSphere.ref.value) || (k.update(m.invariantBoundingSphere, p), k.update(m.uInvariantBoundingSphere, Vt.fromSphere(m.uInvariantBoundingSphere.ref.value, p)));
  }, createRenderableState: function(m) {
    var v = ft.createRenderableState(m);
    return f(v, m), v;
  }, updateRenderableState: f, createPositionIterator: l };
})(Gt || (Gt = {}));
var l4 = 255 / 256, d4 = w.create(16777216, 65536, 256), TY = Vt.create(l4 / d4[0], l4 / d4[1], l4 / d4[2], 0.99609375), AS = Vt();
function Lc(e, t, r) {
  switch (oa.getGranularity(e, t.granularity)) {
    case "uniform":
      return function(n, i, a) {
        return function(o, u) {
          return u ? (k.update(u.uSize, o), k.updateIfChanged(u.dSizeType, "uniform"), u) : R(R({ uSize: k.create(o) }, { tSize: k.create(PY), uSizeTexDim: k.create(ke.create(1, 1)) }), { dSizeType: k.create("uniform") });
        }(i(Ns), a);
      }(0, t.size, r);
    case "group":
      return function(n, i, a) {
        var o = n.groupCount, u = Di(Math.max(1, o), 3, Uint8Array, a && a.tSize.ref.value.array);
        for (n.reset(); n.hasNext && !n.isNextNewInstance; ) {
          var s = n.move();
          c4(i(s.location) * e2, u.array, 3 * s.groupIndex);
        }
        return f4(u, "group", a);
      }(e, t.size, r);
    case "groupInstance":
      return function(n, i, a) {
        var o = n.groupCount, u = n.instanceCount, s = u * o, c = Di(Math.max(1, s), 3, Uint8Array, a && a.tSize.ref.value.array);
        for (n.reset(); n.hasNext; ) {
          var l = n.move();
          c4(i(l.location) * e2, c.array, 3 * l.index);
        }
        return f4(c, "groupInstance", a);
      }(e, t.size, r);
    case "instance":
      return function(n, i, a) {
        var o = n.instanceCount, u = Di(Math.max(1, o), 3, Uint8Array, a && a.tSize.ref.value.array);
        for (n.reset(); n.hasNext && !n.isNextNewInstance; ) {
          var s = n.move();
          c4(i(s.location) * e2, u.array, 3 * s.instanceIndex), n.skipInstance();
        }
        return f4(u, "instance", a);
      }(e, t.size, r);
  }
}
var e2 = 100;
function om(e) {
  switch (e.dSizeType.ref.value) {
    case "uniform":
      return e.uSize.ref.value;
    case "instance":
    case "group":
    case "groupInstance":
      for (var t = 0, r = e.tSize.ref.value.array, n = 0, i = r.length; n < i; n += 3) {
        var a = D_(r[n], r[n + 1], r[n + 2]);
        t < a && (t = a);
      }
      return t / e2;
  }
}
var vf, PY = { array: new Uint8Array(3), width: 1, height: 1 };
function f4(e, t, r) {
  return r ? (k.update(r.tSize, e), k.update(r.uSizeTexDim, ke.create(e.width, e.height)), k.updateIfChanged(r.dSizeType, t), r) : { uSize: k.create(0), tSize: k.create(e), uSizeTexDim: k.create(ke.create(e.width, e.height)), dSizeType: k.create(t) };
}
function SS(e, t, r, n, i, a, o) {
  for (var u = 0; u < t; u++) {
    for (var s = 0; s < r; s++) n[s] = e[s * t + u];
    for (CS(n, i, a, o, r), s = 0; s < r; s++) e[s * t + u] = i[s];
  }
  for (s = 0; s < r; s++) {
    for (u = 0; u < t; u++) n[u] = e[s * t + u];
    for (CS(n, i, a, o, t), u = 0; u < t; u++) e[s * t + u] = Math.sqrt(i[u]);
  }
}
function CS(e, t, r, n, i) {
  r[0] = 0, n[0] = Number.MIN_SAFE_INTEGER, n[1] = Number.MAX_SAFE_INTEGER;
  for (var a = 1, o = 0; a < i; a++) {
    for (var u = (e[a] + a * a - (e[r[o]] + r[o] * r[o])) / (2 * a - 2 * r[o]); u <= n[o]; ) o--, u = (e[a] + a * a - (e[r[o]] + r[o] * r[o])) / (2 * a - 2 * r[o]);
    r[++o] = a, n[o] = u, n[o + 1] = Number.MAX_SAFE_INTEGER;
  }
  for (a = 0, o = 0; a < i; a++) {
    for (; n[o + 1] < a; ) o++;
    t[a] = (a - r[o]) * (a - r[o]) + e[r[o]];
  }
}
(function(e) {
  function t(u, s, c, l) {
    return l ? function(d, f, m, v) {
      return v.pointCount = m, k.update(v.centerBuffer, d), k.update(v.groupBuffer, f), v;
    }(u, s, c, l) : function(d, f, m) {
      var v, p = Me(), g = -1, h = -1, y = { kind: "points", pointCount: m, centerBuffer: k.create(d), groupBuffer: k.create(f), get boundingSphere() {
        var x = n(y);
        if (x !== g) {
          var A = nd(y.centerBuffer.ref.value, y.pointCount, 1);
          Me.copy(p, A), g = x;
        }
        return p;
      }, get groupMapping() {
        return y.groupBuffer.ref.version !== h && (v = _0(y.groupBuffer.ref.value, y.pointCount), h = y.groupBuffer.ref.version), v;
      }, setBoundingSphere: function(x) {
        Me.copy(p, x), g = n(y);
      } };
      return y;
    }(u, s, c);
  }
  function r(u) {
    return t(u ? u.centerBuffer.ref.value : new Float32Array(0), u ? u.groupBuffer.ref.value : new Float32Array(0), 0, u);
  }
  function n(u) {
    return Ra([u.pointCount, u.centerBuffer.ref.version, u.groupBuffer.ref.version]);
  }
  function i(u, s) {
    var c = u.pointCount, l = s.instanceCount.ref.value, d = hf(), f = d.position, m = u.centerBuffer.ref.value, v = s.aTransform.ref.value;
    return ri(c, l, 1, function(p, g) {
      return g < 0 ? w.fromArray(f, m, 3 * p) : w.transformMat4Offset(f, m, v, 0, 3 * p, 16 * g), d;
    });
  }
  function a(u, s, c, l, d) {
    var f = c.instanceCount, m = c.groupCount, v = Xo(c, i(u, s), l.color), p = Lc(c, l.size), g = Pu(f * m), h = Ac(), y = Sc(), x = wc(), A = Cc(), b = { drawCount: u.pointCount, vertexCount: u.pointCount, groupCount: m, instanceCount: f }, _ = Me.clone(u.boundingSphere), S = zi(_, s.aTransform.ref.value, f);
    return R(R(R(R(R(R(R(R(R(R({ dGeometryType: k.create("points"), aPosition: u.centerBuffer, aGroup: u.groupBuffer, boundingSphere: k.create(S), invariantBoundingSphere: k.create(_), uInvariantBoundingSphere: k.create(Vt.ofSphere(_)) }, v), p), g), h), y), x), A), s), ft.createValues(d, b)), { uSizeFactor: k.create(d.sizeFactor), dPointSizeAttenuation: k.create(d.pointSizeAttenuation), dPointStyle: k.create(d.pointStyle) });
  }
  function o(u, s) {
    ft.updateRenderableState(u, s), u.opaque = u.opaque && s.pointStyle !== "fuzzy", u.writeDepth = u.opaque;
  }
  e.create = t, e.createEmpty = r, e.transform = function(u, s) {
    var c = u.centerBuffer.ref.value;
    Z1(s, c, 0, u.pointCount), k.update(u.centerBuffer, c);
  }, e.StyleTypes = { square: "Square", circle: "Circle", fuzzy: "Fuzzy" }, e.StyleTypeNames = Object.keys(e.StyleTypes), e.Params = R(R({}, ft.Params), { sizeFactor: G.Numeric(3, { min: 0, max: 10, step: 0.1 }), pointSizeAttenuation: G.Boolean(!1), pointStyle: G.Select("square", G.objectToOptions(e.StyleTypes)) }), e.Utils = { Params: e.Params, createEmpty: r, createValues: a, createValuesSimple: function(u, s, c, l, d) {
    var f = ft.createSimple(c, l, d), m = R(R({}, G.getDefaultValues(e.Params)), s);
    return a(u, f.transform, f.locationIterator, f.theme, m);
  }, updateValues: function(u, s) {
    ft.updateValues(u, s), k.updateIfChanged(u.uSizeFactor, s.sizeFactor), k.updateIfChanged(u.dPointSizeAttenuation, s.pointSizeAttenuation), k.updateIfChanged(u.dPointStyle, s.pointStyle);
  }, updateBoundingSphere: function(u, s) {
    var c = Me.clone(s.boundingSphere), l = zi(c, u.aTransform.ref.value, u.instanceCount.ref.value);
    Me.equals(l, u.boundingSphere.ref.value) || k.update(u.boundingSphere, l), Me.equals(c, u.invariantBoundingSphere.ref.value) || (k.update(u.invariantBoundingSphere, c), k.update(u.uInvariantBoundingSphere, Vt.fromSphere(u.uInvariantBoundingSphere.ref.value, c)));
  }, createRenderableState: function(u) {
    var s = ft.createRenderableState(u);
    return o(s, u), s;
  }, updateRenderableState: o, createPositionIterator: i };
})(vf || (vf = {}));
var p4 = {}, jo, NT = { fontFamily: G.Select("sans-serif", [["sans-serif", "Sans Serif"], ["monospace", "Monospace"], ["serif", "Serif"], ["cursive", "Cursive"]]), fontQuality: G.Select(3, [[0, "lower"], [1, "low"], [2, "medium"], [3, "high"], [4, "higher"]]), fontStyle: G.Select("normal", [["normal", "Normal"], ["italic", "Italic"], ["oblique", "Oblique"]]), fontVariant: G.Select("normal", [["normal", "Normal"], ["small-caps", "Small Caps"]]), fontWeight: G.Select("normal", [["normal", "Normal"], ["bold", "Bold"]]) }, BY = function() {
  function e(t) {
    t === void 0 && (t = {}), this.mapped = {}, this.scratchW = 0, this.scratchH = 0, this.currentX = 0, this.currentY = 0, this.cutoff = 0.5;
    var r = R(R({}, G.getDefaultValues(NT)), t);
    this.props = r;
    var n = 32 * (r.fontQuality + 1);
    this.buffer = n / 8, this.radius = n / 3, this.lineHeight = Math.round(n + 2 * this.buffer + this.radius), this.maxWidth = Math.round(0.75 * this.lineHeight), this.texture = Di(350 * this.lineHeight * this.maxWidth, 1, Uint8Array), this.scratchCanvas = document.createElement("canvas"), this.scratchCanvas.width = this.maxWidth, this.scratchCanvas.height = this.lineHeight, this.scratchContext = this.scratchCanvas.getContext("2d"), this.scratchContext.font = "".concat(r.fontStyle, " ").concat(r.fontVariant, " ").concat(r.fontWeight, " ").concat(n, "px ").concat(r.fontFamily), this.scratchContext.fillStyle = "black", this.scratchContext.textBaseline = "middle", this.scratchData = new Uint8Array(this.lineHeight * this.maxWidth), this.gridOuter = new Float64Array(this.lineHeight * this.maxWidth), this.gridInner = new Float64Array(this.lineHeight * this.maxWidth), this.f = new Float64Array(Math.max(this.lineHeight, this.maxWidth)), this.d = new Float64Array(Math.max(this.lineHeight, this.maxWidth)), this.z = new Float64Array(Math.max(this.lineHeight, this.maxWidth) + 1), this.v = new Int16Array(Math.max(this.lineHeight, this.maxWidth)), this.middle = Math.ceil(this.lineHeight / 2), this.placeholder = this.get("�");
  }
  return e.prototype.get = function(t) {
    if (this.mapped[t] === void 0) {
      this.draw(t);
      var r = this.texture, n = r.array, i = r.width, a = r.height, o = this.scratchData;
      if (this.currentX + this.scratchW > i && (this.currentX = 0, this.currentY += this.scratchH), this.currentY + this.scratchH > a) return console.warn("canvas to small"), this.placeholder;
      this.mapped[t] = { x: this.currentX, y: this.currentY, w: this.scratchW, h: this.scratchH, nw: this.scratchW / this.lineHeight, nh: this.scratchH / this.lineHeight };
      for (var u = 0; u < this.scratchH; ++u) for (var s = 0; s < this.scratchW; ++s) n[i * (this.currentY + u) + this.currentX + s] = o[u * this.scratchW + s];
      this.currentX += this.scratchW;
    }
    return this.mapped[t];
  }, e.prototype.draw = function(t) {
    var r = this.lineHeight, n = this.scratchContext, i = this.scratchData, a = n.measureText(t), o = Math.min(this.maxWidth, Math.ceil(a.width + 2 * this.buffer)), u = o * r;
    n.clearRect(0, 0, o, r), n.fillText(t, this.buffer, this.middle);
    for (var s = n.getImageData(0, 0, o, r), c = 0; c < u; c++) {
      var l = s.data[4 * c + 3] / 255;
      this.gridOuter[c] = l === 1 ? 0 : l === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - l), 2), this.gridInner[c] = l === 1 ? Number.MAX_SAFE_INTEGER : l === 0 ? 0 : Math.pow(Math.max(0, l - 0.5), 2);
    }
    for (SS(this.gridOuter, o, r, this.f, this.d, this.v, this.z), SS(this.gridInner, o, r, this.f, this.d, this.v, this.z), c = 0; c < u; c++) {
      var d = this.gridOuter[c] - this.gridInner[c];
      i[c] = Math.max(0, Math.min(255, Math.round(255 - 255 * (d / this.radius + this.cutoff))));
    }
    this.scratchW = o, this.scratchH = r;
  }, e;
}();
function wS(e, t, r, n) {
  for (var i = 0, a = 0, o = 0, u = 4 * r; o < u; ++o) {
    var s = 2 * o, c = Math.abs(e[s]);
    c > i && (i = c);
    var l = Math.abs(e[s + 1]);
    l > i && (i = l);
    var d = Math.abs(t[o]);
    d > a && (a = d);
  }
  return Math.max(a, n + n * i);
}
(function(e) {
  function t(u, s, c, l, d, f, m, v, p) {
    return p ? function(g, h, y, x, A, b, _, S, D) {
      return D.charCount = S, k.update(D.fontTexture, g), k.update(D.centerBuffer, h), k.update(D.mappingBuffer, y), k.update(D.depthBuffer, x), k.update(D.indexBuffer, A), k.update(D.groupBuffer, b), k.update(D.tcoordBuffer, _), D;
    }(u, s, c, l, d, f, m, v, p) : function(g, h, y, x, A, b, _, S) {
      var D, I = Me(), M = -1, F = -1, P = { kind: "text", charCount: S, fontTexture: k.create(g), centerBuffer: k.create(h), mappingBuffer: k.create(y), depthBuffer: k.create(x), indexBuffer: k.create(A), groupBuffer: k.create(b), tcoordBuffer: k.create(_), get boundingSphere() {
        var E = n(P);
        if (E !== M) {
          var B = nd(P.centerBuffer.ref.value, 4 * P.charCount, 4);
          Me.copy(I, B), M = E;
        }
        return I;
      }, get groupMapping() {
        return P.groupBuffer.ref.version !== F && (D = _0(P.groupBuffer.ref.value, P.charCount, 4), F = P.groupBuffer.ref.version), D;
      }, setBoundingSphere: function(E) {
        Me.copy(I, E), M = n(P);
      } };
      return P;
    }(u, s, c, l, d, f, m, v);
  }
  function r(u) {
    return t(u ? u.fontTexture.ref.value : Di(0, 1, Uint8Array), u ? u.centerBuffer.ref.value : new Float32Array(0), u ? u.mappingBuffer.ref.value : new Float32Array(0), u ? u.depthBuffer.ref.value : new Float32Array(0), u ? u.indexBuffer.ref.value : new Uint32Array(0), u ? u.groupBuffer.ref.value : new Float32Array(0), u ? u.tcoordBuffer.ref.value : new Float32Array(0), 0, u);
  }
  function n(u) {
    return Ra([u.charCount, u.fontTexture.ref.version, u.centerBuffer.ref.version, u.mappingBuffer.ref.version, u.depthBuffer.ref.version, u.indexBuffer.ref.version, u.groupBuffer.ref.version, u.tcoordBuffer.ref.version]);
  }
  function i(u, s) {
    var c = 4 * u.charCount, l = s.instanceCount.ref.value, d = hf(), f = d.position, m = u.centerBuffer.ref.value, v = s.aTransform.ref.value;
    return ri(c, l, 4, function(p, g) {
      return g < 0 ? w.fromArray(f, m, 3 * p) : w.transformMat4Offset(f, m, v, 0, 3 * p, 16 * g), d;
    });
  }
  function a(u, s, c, l, d) {
    var f = c.instanceCount, m = c.groupCount, v = Xo(c, i(u, s), l.color), p = Lc(c, l.size), g = Pu(f * m), h = Ac(), y = Sc(), x = wc(), A = Cc(), b = { drawCount: 2 * u.charCount * 3, vertexCount: 4 * u.charCount, groupCount: m, instanceCount: f }, _ = wS(u.mappingBuffer.ref.value, u.depthBuffer.ref.value, u.charCount, om(p)), S = Me.expand(Me(), u.boundingSphere, _), D = zi(S, s.aTransform.ref.value, f);
    return R(R(R(R(R(R(R(R(R(R(R({ dGeometryType: k.create("text"), aPosition: u.centerBuffer, aMapping: u.mappingBuffer, aDepth: u.depthBuffer, aGroup: u.groupBuffer, elements: u.indexBuffer, boundingSphere: k.create(D), invariantBoundingSphere: k.create(S), uInvariantBoundingSphere: k.create(Vt.ofSphere(S)) }, v), p), g), h), y), x), A), s), { aTexCoord: u.tcoordBuffer, tFont: u.fontTexture, padding: k.create(_) }), ft.createValues(d, b)), { uSizeFactor: k.create(d.sizeFactor), uBorderWidth: k.create(Qa(d.borderWidth, 0, 0.5)), uBorderColor: k.create(He.toArrayNormalized(d.borderColor, w.zero(), 0)), uOffsetX: k.create(d.offsetX), uOffsetY: k.create(d.offsetY), uOffsetZ: k.create(d.offsetZ), uBackgroundColor: k.create(He.toArrayNormalized(d.backgroundColor, w.zero(), 0)), uBackgroundOpacity: k.create(d.backgroundOpacity) });
  }
  function o(u, s) {
    ft.updateRenderableState(u, s), u.pickable = !1, u.opaque = !1, u.writeDepth = !0;
  }
  e.create = t, e.createEmpty = r, e.Params = R(R(R({}, ft.Params), NT), { sizeFactor: G.Numeric(1, { min: 0, max: 10, step: 0.1 }), borderWidth: G.Numeric(0, { min: 0, max: 0.5, step: 0.01 }), borderColor: G.Color(Kt.grey), offsetX: G.Numeric(0, { min: 0, max: 10, step: 0.1 }), offsetY: G.Numeric(0, { min: 0, max: 10, step: 0.1 }), offsetZ: G.Numeric(0, { min: 0, max: 10, step: 0.1 }), background: G.Boolean(!1), backgroundMargin: G.Numeric(0.2, { min: 0, max: 1, step: 0.01 }), backgroundColor: G.Color(Kt.grey), backgroundOpacity: G.Numeric(1, { min: 0, max: 1, step: 0.01 }), tether: G.Boolean(!1), tetherLength: G.Numeric(1, { min: 0, max: 5, step: 0.1 }), tetherBaseWidth: G.Numeric(0.3, { min: 0, max: 1, step: 0.01 }), attachment: G.Select("middle-center", [["bottom-left", "bottom-left"], ["bottom-center", "bottom-center"], ["bottom-right", "bottom-right"], ["middle-left", "middle-left"], ["middle-center", "middle-center"], ["middle-right", "middle-right"], ["top-left", "top-left"], ["top-center", "top-center"], ["top-right", "top-right"]]) }), e.Utils = { Params: e.Params, createEmpty: r, createValues: a, createValuesSimple: function(u, s, c, l, d) {
    var f = ft.createSimple(c, l, d), m = R(R({}, G.getDefaultValues(e.Params)), s);
    return a(u, f.transform, f.locationIterator, f.theme, m);
  }, updateValues: function(u, s) {
    ft.updateValues(u, s), k.updateIfChanged(u.uSizeFactor, s.sizeFactor), k.updateIfChanged(u.uBorderWidth, s.borderWidth), He.fromNormalizedArray(u.uBorderColor.ref.value, 0) !== s.borderColor && (He.toArrayNormalized(s.borderColor, u.uBorderColor.ref.value, 0), k.update(u.uBorderColor, u.uBorderColor.ref.value)), k.updateIfChanged(u.uOffsetX, s.offsetX), k.updateIfChanged(u.uOffsetY, s.offsetY), k.updateIfChanged(u.uOffsetZ, s.offsetZ), He.fromNormalizedArray(u.uBackgroundColor.ref.value, 0) !== s.backgroundColor && (He.toArrayNormalized(s.backgroundColor, u.uBackgroundColor.ref.value, 0), k.update(u.uBackgroundColor, u.uBackgroundColor.ref.value)), k.updateIfChanged(u.uBackgroundOpacity, s.backgroundOpacity);
  }, updateBoundingSphere: function(u, s) {
    var c = wS(u.aMapping.ref.value, u.aDepth.ref.value, s.charCount, om(u)), l = Me.expand(Me(), s.boundingSphere, c), d = zi(l, u.aTransform.ref.value, u.instanceCount.ref.value);
    Me.equals(d, u.boundingSphere.ref.value) || k.update(u.boundingSphere, d), Me.equals(l, u.invariantBoundingSphere.ref.value) || (k.update(u.invariantBoundingSphere, l), k.update(u.uInvariantBoundingSphere, Vt.fromSphere(u.uInvariantBoundingSphere.ref.value, l))), k.update(u.padding, c);
  }, createRenderableState: function(u) {
    var s = ft.createRenderableState(u);
    return o(s, u), s;
  }, updateRenderableState: o, createPositionIterator: i };
})(jo || (jo = {}));
var aa, Mr, ps = w(), ms = w(), Id = w(), DS = Oe.add, rv = Oe.add3;
(function(e) {
  e.create = function(t, r, n) {
    t === void 0 && (t = 2048), r === void 0 && (r = 1024);
    var i = Oe.create(Float32Array, 1, r, n ? n.groupBuffer.ref.value : t), a = Oe.create(Float32Array, 3, r, n ? n.startBuffer.ref.value : t), o = Oe.create(Float32Array, 3, r, n ? n.endBuffer.ref.value : t), u = function(c, l, d, f, m, v, p) {
      for (var g = 0; g < 4; ++g) rv(a, c, l, d), rv(o, f, m, v), DS(i, p);
    }, s = function(c, l, d, f) {
      var m = w.distance(c, l), v = Math.floor(d / 2), p = 1 / d;
      w.sub(Id, l, c);
      for (var g = 0; g < v; ++g) {
        var h = p * (2 * g + 1);
        w.setMagnitude(Id, Id, m * h), w.add(ps, c, Id), w.setMagnitude(Id, Id, m * p * (2 * (g + 1))), w.add(ms, c, Id), u(ps[0], ps[1], ps[2], ms[0], ms[1], ms[2], f);
      }
    };
    return { add: u, addVec: function(c, l, d) {
      for (var f = 0; f < 4; ++f) rv(a, c[0], c[1], c[2]), rv(o, l[0], l[1], l[2]), DS(i, d);
    }, addFixedCountDashes: s, addFixedLengthDashes: function(c, l, d, f) {
      var m = w.distance(c, l);
      s(c, l, m / d, f);
    }, addCage: function(c, l, d) {
      for (var f = l.vertices, m = l.edges, v = 0, p = m.length; v < p; v += 2) w.fromArray(ps, f, 3 * m[v]), w.fromArray(ms, f, 3 * m[v + 1]), w.transformMat4(ps, ps, c), w.transformMat4(ms, ms, c), u(ps[0], ps[1], ps[2], ms[0], ms[1], ms[2], d);
    }, getLines: function() {
      var c = i.elementCount / 4, l = Oe.compact(i, !0), d = Oe.compact(a, !0), f = Oe.compact(o, !0), m = n && c <= n.lineCount ? n.mappingBuffer.ref.value : new Float32Array(8 * c), v = n && c <= n.lineCount ? n.indexBuffer.ref.value : new Uint32Array(6 * c);
      return (!n || c > n.lineCount) && function(p, g, h) {
        for (var y = 0; y < p; ++y) {
          var x = 8 * y;
          g[x] = -1, g[x + 1] = -1, g[x + 2] = 1, g[x + 3] = -1, g[x + 4] = -1, g[x + 5] = 1, g[x + 6] = 1, g[x + 7] = 1;
        }
        for (y = 0; y < p; ++y) {
          var A = 4 * y, b = 6 * y;
          h[b] = A, h[b + 1] = A + 1, h[b + 2] = A + 2, h[b + 3] = A + 1, h[b + 4] = A + 3, h[b + 5] = A + 2;
        }
      }(c, m, v), Mr.create(m, v, l, d, f, c, n);
    } };
  };
})(aa || (aa = {})), function(e) {
  function t(o, u, s, c, l, d, f) {
    return f ? function(m, v, p, g, h, y, x) {
      return y > x.lineCount && (k.update(x.mappingBuffer, m), k.update(x.indexBuffer, v)), x.lineCount = y, k.update(x.groupBuffer, p), k.update(x.startBuffer, g), k.update(x.endBuffer, h), x;
    }(o, u, s, c, l, d, f) : function(m, v, p, g, h, y) {
      var x, A = Me(), b = -1, _ = -1, S = { kind: "lines", lineCount: y, mappingBuffer: k.create(m), indexBuffer: k.create(v), groupBuffer: k.create(p), startBuffer: k.create(g), endBuffer: k.create(h), get boundingSphere() {
        var D = n(S);
        if (D !== b) {
          var I = nd(S.startBuffer.ref.value, 4 * S.lineCount, 4), M = nd(S.endBuffer.ref.value, 4 * S.lineCount, 4);
          Me.expandBySphere(A, I, M), b = D;
        }
        return A;
      }, get groupMapping() {
        return S.groupBuffer.ref.version !== _ && (x = _0(S.groupBuffer.ref.value, S.lineCount, 4), _ = S.groupBuffer.ref.version), x;
      }, setBoundingSphere: function(D) {
        Me.copy(A, D), b = n(S);
      } };
      return S;
    }(o, u, s, c, l, d);
  }
  function r(o) {
    return t(o ? o.mappingBuffer.ref.value : new Float32Array(0), o ? o.indexBuffer.ref.value : new Uint32Array(0), o ? o.groupBuffer.ref.value : new Float32Array(0), o ? o.startBuffer.ref.value : new Float32Array(0), o ? o.endBuffer.ref.value : new Float32Array(0), 0, o);
  }
  function n(o) {
    return Ra([o.lineCount, o.mappingBuffer.ref.version, o.indexBuffer.ref.version, o.groupBuffer.ref.version, o.startBuffer.ref.version, o.endBuffer.ref.version]);
  }
  function i(o, u) {
    var s = 4 * o.lineCount, c = u.instanceCount.ref.value, l = hf(), d = l.position, f = o.startBuffer.ref.value, m = o.endBuffer.ref.value, v = u.aTransform.ref.value;
    return ri(s, c, 2, function(p, g) {
      var h = p % 4 == 0 ? f : m;
      return g < 0 ? w.fromArray(d, h, 3 * p) : w.transformMat4Offset(d, h, v, 0, 3 * p, 16 * g), l;
    });
  }
  function a(o, u, s, c, l) {
    var d = s.instanceCount, f = s.groupCount, m = Xo(s, i(o, u), c.color), v = Lc(s, c.size), p = Pu(d * f), g = Ac(), h = Sc(), y = wc(), x = Cc(), A = { drawCount: 2 * o.lineCount * 3, vertexCount: 4 * o.lineCount, groupCount: f, instanceCount: d }, b = Me.clone(o.boundingSphere), _ = zi(b, u.aTransform.ref.value, d);
    return R(R(R(R(R(R(R(R(R(R({ dGeometryType: k.create("lines"), aMapping: o.mappingBuffer, aGroup: o.groupBuffer, aStart: o.startBuffer, aEnd: o.endBuffer, elements: o.indexBuffer, boundingSphere: k.create(_), invariantBoundingSphere: k.create(b), uInvariantBoundingSphere: k.create(Vt.ofSphere(b)) }, m), v), p), g), h), y), x), u), ft.createValues(l, A)), { uSizeFactor: k.create(l.sizeFactor), dLineSizeAttenuation: k.create(l.lineSizeAttenuation), uDoubleSided: k.create(!0), dFlipSided: k.create(!1) });
  }
  e.create = t, e.createEmpty = r, e.fromMesh = function(o, u) {
    for (var s = o.vertexBuffer.ref.value, c = o.indexBuffer.ref.value, l = o.groupBuffer.ref.value, d = aa.create(3 * o.triangleCount, o.triangleCount / 10, u), f = 0, m = 3 * o.triangleCount; f < m; f += 3) {
      var v = c[f], p = c[f + 1], g = c[f + 2], h = s[3 * v], y = s[3 * v + 1], x = s[3 * v + 2], A = s[3 * p], b = s[3 * p + 1], _ = s[3 * p + 2], S = s[3 * g], D = s[3 * g + 1], I = s[3 * g + 2];
      d.add(h, y, x, A, b, _, l[v]), d.add(h, y, x, S, D, I, l[v]), d.add(A, b, _, S, D, I, l[p]);
    }
    return d.getLines();
  }, e.transform = function(o, u) {
    var s = o.startBuffer.ref.value;
    Z1(u, s, 0, 4 * o.lineCount), k.update(o.startBuffer, s);
    var c = o.endBuffer.ref.value;
    Z1(u, c, 0, 4 * o.lineCount), k.update(o.endBuffer, c);
  }, e.Params = R(R({}, ft.Params), { sizeFactor: G.Numeric(2, { min: 0, max: 10, step: 0.1 }), lineSizeAttenuation: G.Boolean(!1) }), e.Utils = { Params: e.Params, createEmpty: r, createValues: a, createValuesSimple: function(o, u, s, c, l) {
    var d = ft.createSimple(s, c, l), f = R(R({}, G.getDefaultValues(e.Params)), u);
    return a(o, d.transform, d.locationIterator, d.theme, f);
  }, updateValues: function(o, u) {
    ft.updateValues(o, u), k.updateIfChanged(o.uSizeFactor, u.sizeFactor), k.updateIfChanged(o.dLineSizeAttenuation, u.lineSizeAttenuation);
  }, updateBoundingSphere: function(o, u) {
    var s = Me.clone(u.boundingSphere), c = zi(s, o.aTransform.ref.value, o.instanceCount.ref.value);
    Me.equals(c, o.boundingSphere.ref.value) || k.update(o.boundingSphere, c), Me.equals(s, o.invariantBoundingSphere.ref.value) || (k.update(o.invariantBoundingSphere, s), k.update(o.uInvariantBoundingSphere, Vt.fromSphere(o.uInvariantBoundingSphere.ref.value, s)));
  }, createRenderableState: ft.createRenderableState, updateRenderableState: ft.updateRenderableState, createPositionIterator: i };
}(Mr || (Mr = {}));
var IS = w(), ES = w(), MS = w();
function RT(e, t) {
  for (var r = t.length, n = Mm(r / 3), i = 0; i < r; i += 3) w.fromArray(IS, e, 3 * t[i]), w.fromArray(ES, e, 3 * t[i + 1]), w.fromArray(MS, e, 3 * t[i + 2]), n.add(IS, ES, MS);
  return n.getPrimitive();
}
var nv = w();
function Mm(e, t) {
  t === void 0 && (t = 3 * e);
  var r = new Float32Array(3 * t), n = new Float32Array(3 * t), i = new Uint32Array(3 * e), a = 0, o = 0;
  return { add: function(u, s, c) {
    w.toArray(u, r, a), w.toArray(s, r, a + 3), w.toArray(c, r, a + 6), w.triangleNormal(nv, u, s, c);
    for (var l = 0; l < 3; ++l) w.toArray(nv, n, a + 3 * l), i[o + l] = a / 3 + l;
    a += 9, o += 3;
  }, addQuad: function(u, s, c, l) {
    w.toArray(u, r, a), w.toArray(s, r, a + 3), w.toArray(c, r, a + 6), w.toArray(l, r, a + 9), w.triangleNormal(nv, u, s, c);
    for (var d = 0; d < 4; ++d) w.toArray(nv, n, a + 3 * d);
    var f = a / 3;
    i[o] = f, i[o + 1] = f + 1, i[o + 2] = f + 2, i[o + 3] = f + 2, i[o + 4] = f + 3, i[o + 5] = f, a += 12, o += 6;
  }, getPrimitive: function() {
    return { vertices: r, normals: n, indices: i };
  } };
}
var $f = w(), FY = Ti();
function Mg(e, t) {
  for (var r = e.vertices, n = e.normals, i = Ti.directionTransform(FY, t), a = 0, o = r.length; a < o; a += 3) w.transformMat4($f, w.fromArray($f, r, a), t), w.toArray($f, r, a), w.transformMat3($f, w.fromArray($f, n, a), i), w.toArray($f, n, a);
  return e;
}
function Tg(e, t, r) {
  r === void 0 && (r = -1);
  for (var n = new Float32Array(3 * e), i = r === -1 ? e <= 4 ? Math.sqrt(2) / 2 : 0.6 : r, a = t ? 1 : 0, o = 0, u = e; o < u; ++o) {
    var s = (2 * o + a) / e * Math.PI;
    n[3 * o] = Math.cos(s) * i, n[3 * o + 1] = Math.sin(s) * i, n[3 * o + 2] = 0;
  }
  return n;
}
function Pg(e) {
  return { vertices: new Float32Array(e.vertices), edges: new Uint32Array(e.edges) };
}
var m4 = w.zero();
function Bg(e, t) {
  for (var r = e.vertices, n = 0, i = r.length; n < i; n += 3) w.transformMat4(m4, w.fromArray(m4, r, n), t), w.toArray(m4, r, n);
  return e;
}
var h4, v4, mo, g4, y4, ar, e1 = w(), t1 = w(), r1 = w(), n1 = w(), Hn = Tg(4, !0);
function OT() {
  return h4 || (h4 = function(e) {
    for (var t = Mm(12, 24), r = 0; r < 4; ++r) {
      var n = (r + 1) % 4;
      w.set(e1, Hn[3 * r], Hn[3 * r + 1], -0.5), w.set(t1, Hn[3 * n], Hn[3 * n + 1], -0.5), w.set(r1, Hn[3 * n], Hn[3 * n + 1], 0.5), w.set(n1, Hn[3 * r], Hn[3 * r + 1], 0.5), t.addQuad(e1, t1, r1, n1);
    }
    return w.set(e1, Hn[0], Hn[1], -0.5), w.set(t1, Hn[3], Hn[4], -0.5), w.set(r1, Hn[6], Hn[7], -0.5), w.set(n1, Hn[9], Hn[10], -0.5), t.addQuad(n1, r1, t1, e1), w.set(e1, Hn[0], Hn[1], 0.5), w.set(t1, Hn[3], Hn[4], 0.5), w.set(r1, Hn[6], Hn[7], 0.5), w.set(n1, Hn[9], Hn[10], 0.5), t.addQuad(e1, t1, r1, n1), t.getPrimitive();
  }()), h4;
}
function LT() {
  return v4 || (v4 = /* @__PURE__ */ function(e, t) {
    return { vertices: e, edges: t };
  }([0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5, -0.5, 0.5, 0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5], [0, 4, 1, 5, 2, 6, 3, 7, 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4])), v4;
}
function TS(e) {
  return e.map(function(t) {
    return { x: t[0], alpha: t[1] };
  });
}
function PS(e, t) {
  for (var r, n, i, a, o, u, s = We(We([{ x: 0, alpha: 0 }, { x: 0, alpha: 0 }], e, !0), [{ x: 1, alpha: 0 }, { x: 1, alpha: 0 }], !1), c = t ? t.ref.value.array : new Uint8Array(256), l = 0, d = e.length + 1, f = 0; f < d; ++f) {
    r = s[f + 1].x, n = s[f + 2].x, i = s[f].alpha, a = s[f + 1].alpha, o = s[f + 2].alpha, u = s[f + 3].alpha;
    for (var m = Math.round(256 * (n - r)), v = 0; v < m; ++v) {
      var p = v / m;
      c[l] = Math.max(0, 255 * Yv(i, a, o, u, p, 0.5)), ++l;
    }
  }
  var g = { array: c, width: 256, height: 1 };
  return t ? (k.update(t, g), t) : k.create(g);
}
function BS(e, t, r, n) {
  var i = (n - r) / t;
  i === 0 && (i = 1);
  for (var a = new Int32Array(t), o = 0, u = e.length; o < u; o++) {
    var s = Math.floor((e[o] - r) / i);
    s >= t ? s = t - 1 : s < 0 && (s = 0), a[s]++;
  }
  return { min: r, max: n, binWidth: i, counts: a };
}
(function(e) {
  e.One = { transform: { kind: "matrix", matrix: me.identity() }, cells: zn.create(zn.Space([1, 1, 1], [0, 1, 2]), zn.Data1([0])), stats: { min: 0, max: 0, mean: 0, sigma: 0 } };
  var t = me.zero(), r = me.zero();
  e.getGridToCartesianTransform = function(n) {
    if (n.transform.kind === "matrix") return me.copy(me(), n.transform.matrix);
    if (n.transform.kind === "spacegroup") {
      var i = n.cells.space, a = me.fromScaling(t, w.div(w.zero(), qr.size(w.zero(), n.transform.fractionalBox), w.ofArray(i.dimensions))), o = me.fromTranslation(r, n.transform.fractionalBox.min);
      return me.mul3(me.zero(), n.transform.cell.fromFractional, o, a);
    }
    return me.identity();
  }, e.areEquivalent = function(n, i) {
    return n === i;
  }, e.isEmpty = function(n) {
    return n.cells.data.length === 0;
  }, e.getBoundingSphere = function(n, i) {
    i || (i = Me());
    var a = n.cells.space.dimensions, o = e.getGridToCartesianTransform(n);
    return Me.fromDimensionsAndTransform(i, a, o);
  }, e.getHistogram = function(n, i) {
    var a = n._historams;
    return a || (a = n._historams = {}), a[i] || (a[i] = function(o, u, s) {
      if (s) return BS(o, u, s.min, s.max);
      var c = Oo(o);
      return BS(o, u, c[0], c[1]);
    }(n.cells.data, i, { min: n.stats.min, max: n.stats.max })), a[i];
  };
})(mo || (mo = {})), function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "cube";
  }, e.create = function(t) {
    return { kind: "cube", name: t.name, data: t };
  };
}(g4 || (g4 = {})), function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "dscif";
  }, e.create = function(t) {
    return { kind: "dscif", name: t._name, data: t };
  };
}(y4 || (y4 = {})), function(e) {
  var t;
  e.is = function(a) {
    var o, u, s, c;
    return ((c = (s = (u = (o = a == null ? void 0 : a.grid) === null || o === void 0 ? void 0 : o.cells) === null || u === void 0 ? void 0 : u.space) === null || s === void 0 ? void 0 : s.dimensions) === null || c === void 0 ? void 0 : c.length) && (a == null ? void 0 : a.sourceData) && (a == null ? void 0 : a.customProperties) && (a == null ? void 0 : a._propertyData);
  }, function(a) {
    function o(u, s) {
      return u.kind === "absolute" ? u : { kind: "absolute", absoluteValue: a.calcAbsolute(s, u.relativeValue) };
    }
    a.areSame = function(u, s, c) {
      return Ln(o(u, c).absoluteValue, o(s, c).absoluteValue, c.sigma / 100);
    }, a.absolute = function(u) {
      return { kind: "absolute", absoluteValue: u };
    }, a.relative = function(u) {
      return { kind: "relative", relativeValue: u };
    }, a.calcAbsolute = function(u, s) {
      return s * u.sigma + u.mean;
    }, a.calcRelative = function(u, s) {
      return u.sigma === 0 ? 0 : (s - u.mean) / u.sigma;
    }, a.toAbsolute = o, a.toRelative = function(u, s) {
      return u.kind === "relative" ? u : { kind: "relative", relativeValue: a.calcRelative(s, u.absoluteValue) };
    }, a.toString = function(u) {
      return u.kind === "relative" ? "".concat(u.relativeValue.toFixed(2), " σ") : "".concat(u.absoluteValue.toPrecision(4));
    };
  }(t = e.IsoValue || (e.IsoValue = {})), e.adjustedIsoValue = function(a, o, u) {
    if (u === "relative") return t.relative(o);
    var s = t.absolute(o);
    if (y4.is(a.sourceData)) {
      var c = { min: a.sourceData.data.volume_data_3d_info.min_source.value(0), max: a.sourceData.data.volume_data_3d_info.max_source.value(0), mean: a.sourceData.data.volume_data_3d_info.mean_source.value(0), sigma: a.sourceData.data.volume_data_3d_info.sigma_source.value(0) };
      return e.IsoValue.toRelative(s, c);
    }
    return s;
  };
  var r, n = { min: -1, max: 1, mean: 0, sigma: 0.1 };
  function i(a, o) {
    var u = o || n, s = u.min, c = u.max, l = u.mean, d = u.sigma, f = (s - l) / d, m = (c - l) / d, v = a;
    return a.kind === "absolute" ? a.absoluteValue < s ? v = e.IsoValue.absolute(s) : a.absoluteValue > c && (v = e.IsoValue.absolute(c)) : a.relativeValue < f ? v = e.IsoValue.relative(f) : a.relativeValue > m && (v = e.IsoValue.relative(m)), G.Conditioned(v, { absolute: G.Converted(function(p) {
      return e.IsoValue.toAbsolute(p, mo.One.stats).absoluteValue;
    }, function(p) {
      return e.IsoValue.absolute(p);
    }, G.Numeric(l, { min: s, max: c, step: nA(d / 100, 2) })), relative: G.Converted(function(p) {
      return e.IsoValue.toRelative(p, mo.One.stats).relativeValue;
    }, function(p) {
      return e.IsoValue.relative(p);
    }, G.Numeric(Math.min(1, m), { min: f, max: m, step: nA(Math.round((c - s) / d) / 100, 2) })) }, function(p) {
      return p.kind === "absolute" ? "absolute" : "relative";
    }, function(p, g) {
      return g === "absolute" ? e.IsoValue.toAbsolute(p, u) : e.IsoValue.toRelative(p, u);
    }, { isEssential: !0 });
  }
  e.createIsoValueParam = i, e.IsoValueParam = i(e.IsoValue.relative(2)), e.One = { label: "", grid: mo.One, sourceData: { kind: "", name: "", data: {} }, customProperties: new v0(), _propertyData: /* @__PURE__ */ Object.create(null) }, e.areEquivalent = function(a, o) {
    return mo.areEquivalent(a.grid, o.grid);
  }, e.isEmpty = function(a) {
    return mo.isEmpty(a.grid);
  }, e.isOrbitals = function(a) {
    return !!g4.is(a.sourceData) && a.sourceData.data.header.orbitals;
  }, e.Loci = function(a) {
    return { kind: "volume-loci", volume: a };
  }, e.isLoci = function(a) {
    return !!a && a.kind === "volume-loci";
  }, e.areLociEqual = function(a, o) {
    return a.volume === o.volume;
  }, e.isLociEmpty = function(a) {
    return mo.isEmpty(a.volume.grid);
  }, e.getBoundingSphere = function(a, o) {
    return mo.getBoundingSphere(a.grid, o);
  }, (r = e.Isosurface || (e.Isosurface = {})).Loci = function(a, o) {
    return { kind: "isosurface-loci", volume: a, isoValue: o };
  }, r.isLoci = function(a) {
    return !!a && a.kind === "isosurface-loci";
  }, r.areLociEqual = function(a, o) {
    return a.volume === o.volume && e.IsoValue.areSame(a.isoValue, o.isoValue, a.volume.grid.stats);
  }, r.isLociEmpty = function(a) {
    return a.volume.grid.cells.data.length === 0;
  }, r.getBoundingSphere = function(a, o, u) {
    return e.getBoundingSphere(a, u);
  }, function(a) {
    a.Loci = function(s, c) {
      return { kind: "cell-loci", volume: s, indices: c };
    }, a.isLoci = function(s) {
      return !!s && s.kind === "cell-loci";
    }, a.areLociEqual = function(s, c) {
      return s.volume === c.volume && Le.areEqual(s.indices, c.indices);
    }, a.isLociEmpty = function(s) {
      return Le.size(s.indices) === 0;
    };
    var o = new Nu("98"), u = w();
    a.getBoundingSphere = function(s, c, l) {
      o.reset();
      for (var d = mo.getGridToCartesianTransform(s.grid), f = s.grid.cells.space.getCoords, m = 0, v = Le.size(c); m < v; m++)
        f(Le.getAt(c, m), u), w.transformMat4(u, u, d), o.includePosition(u);
      for (o.finishedIncludeStep(), m = 0, v = Le.size(c); m < v; m++)
        f(Le.getAt(c, m), u), w.transformMat4(u, u, d), o.radiusPosition(u);
      var p = o.getSphere(l);
      return Me.expand(p, p, 10 * me.getMaxScaleOnAxis(d));
    };
  }(e.Cell || (e.Cell = {}));
}(ar || (ar = {}));
var R2, ns, id, b4 = OT();
function Vr(e, t, r) {
  return { type: "attribute", kind: e, itemSize: t, divisor: r };
}
function Ie(e, t) {
  return { type: "uniform", kind: e, variant: t };
}
function zt(e, t, r, n) {
  return { type: "texture", kind: e, format: t, dataType: r, filter: n };
}
function Sf(e) {
  return { type: "elements", kind: e };
}
function kt(e, t) {
  return { type: "define", kind: e, options: t };
}
function ci(e) {
  return { type: "value", kind: e };
}
(function(e) {
  function t(s, c, l, d, f, m, v, p, g, h) {
    return h ? function(y, x, A, b, _, S, D, I, M, F) {
      var P = S.getWidth(), E = S.getHeight(), B = S.getDepth();
      return k.update(F.gridDimension, x), k.update(F.gridTexture, S), k.update(F.gridTextureDim, w.set(F.gridTextureDim.ref.value, P, E, B)), k.update(F.gridStats, Vt.set(F.gridStats.ref.value, D.min, D.max, D.mean, D.sigma)), k.update(F.bboxMin, y.min), k.update(F.bboxMax, y.max), k.update(F.bboxSize, w.sub(F.bboxSize.ref.value, y.max, y.min)), k.update(F.transform, A), k.update(F.cellDim, _), k.update(F.unitToCartn, b), k.update(F.cartnToUnit, me.invert(me(), b)), k.updateIfChanged(F.packedGroup, I), k.updateIfChanged(F.axisOrder, w.fromArray(F.axisOrder.ref.value, M, 0)), F;
    }(s, c, l, d, f, m, v, p, g, h) : function(y, x, A, b, _, S, D, I, M) {
      var F = Me(), P = -1, E = S.getWidth(), B = S.getHeight(), N = S.getDepth(), O = { kind: "direct-volume", gridDimension: k.create(x), gridTexture: k.create(S), gridTextureDim: k.create(w.create(E, B, N)), gridStats: k.create(Vt.create(D.min, D.max, D.mean, D.sigma)), bboxMin: k.create(y.min), bboxMax: k.create(y.max), bboxSize: k.create(w.sub(w(), y.max, y.min)), transform: k.create(A), cellDim: k.create(_), unitToCartn: k.create(b), cartnToUnit: k.create(me.invert(me(), b)), get boundingSphere() {
        var z = r(O);
        if (z !== P) {
          var V = function(U, H) {
            return Me.fromDimensionsAndTransform(Me(), U, H);
          }(O.gridDimension.ref.value, O.transform.ref.value);
          Me.copy(F, V), P = z;
        }
        return F;
      }, packedGroup: k.create(I), axisOrder: k.create(M), setBoundingSphere: function(z) {
        Me.copy(F, z), P = r(O);
      } };
      return O;
    }(s, c, l, d, f, m, v, p, g);
  }
  function r(s) {
    return Ra([s.bboxSize.ref.version, s.gridDimension.ref.version, s.gridTexture.ref.version, s.transform.ref.version, s.gridStats.ref.version]);
  }
  function n(s) {
    return t(qr(), w(), me.identity(), me.identity(), w(), go(), mo.One.stats, !1, w.create(0, 1, 2), s);
  }
  function i(s, c) {
    return Math.ceil(w.magnitude(s) * c);
  }
  function a(s, c) {
    return Math.min.apply(Math, s) * (1 / c);
  }
  function o(s) {
    return 1 / s;
  }
  function u(s, c, l, d, f) {
    var m = s.gridTexture, v = s.gridTextureDim, p = s.gridStats, g = s.bboxSize, h = s.bboxMin, y = s.bboxMax, x = s.gridDimension, A = s.transform, b = l.instanceCount, _ = l.groupCount, S = Xo(l, e.Utils.createPositionIterator(s, c), d.color), D = Pu(b * _), I = Ac(), M = Sc(), F = wc(), P = Cc(), E = x.ref.value, B = E[0], N = E[1], O = E[2], z = { drawCount: b4.indices.length, vertexCount: B * N * O, groupCount: _, instanceCount: b }, V = Me.clone(s.boundingSphere), U = zi(V, c.aTransform.ref.value, b), H = PS(TS(f.controlPoints));
    return R(R(R(R(R(R(R(R(R({ dGeometryType: k.create("directVolume") }, S), D), I), M), F), P), c), ft.createValues(f, z)), { aPosition: k.create(b4.vertices), elements: k.create(b4.indices), boundingSphere: k.create(U), invariantBoundingSphere: k.create(V), uInvariantBoundingSphere: k.create(Vt.ofSphere(V)), uBboxMin: h, uBboxMax: y, uBboxSize: g, uMaxSteps: k.create(i(x.ref.value, f.stepsPerCell)), uStepScale: k.create(a(s.cellDim.ref.value, f.stepsPerCell)), uJumpLength: k.create(f.jumpLength), uTransform: A, uGridDim: x, tTransferTex: H, uTransferScale: k.create(o(f.stepsPerCell)), dGridTexType: k.create(m.ref.value.getDepth() > 0 ? "3d" : "2d"), uGridTexDim: v, tGridTex: m, uGridStats: p, uCellDim: s.cellDim, uCartnToUnit: s.cartnToUnit, uUnitToCartn: s.unitToCartn, dPackedGroup: s.packedGroup, dAxisOrder: k.create(s.axisOrder.ref.value.join("")), dIgnoreLight: k.create(f.ignoreLight), dXrayShaded: k.create(f.xrayShaded) });
  }
  e.create = t, e.createEmpty = n, e.Params = R(R({}, ft.Params), { ignoreLight: G.Boolean(!1, ft.ShadingCategory), xrayShaded: G.Boolean(!1, ft.ShadingCategory), controlPoints: G.LineGraph([ke.create(0.19, 0), ke.create(0.2, 0.05), ke.create(0.25, 0.05), ke.create(0.26, 0), ke.create(0.79, 0), ke.create(0.8, 0.05), ke.create(0.85, 0.05), ke.create(0.86, 0)], { isEssential: !0 }), stepsPerCell: G.Numeric(3, { min: 1, max: 10, step: 1 }), jumpLength: G.Numeric(0, { min: 0, max: 20, step: 0.1 }) }), e.Utils = { Params: e.Params, createEmpty: n, createValues: u, createValuesSimple: function(s, c, l, d, f) {
    var m = ft.createSimple(l, d, f), v = R(R({}, G.getDefaultValues(e.Params)), c);
    return u(s, m.transform, m.locationIterator, m.theme, v);
  }, updateValues: function(s, c) {
    ft.updateValues(s, c), k.updateIfChanged(s.dIgnoreLight, c.ignoreLight), k.updateIfChanged(s.dXrayShaded, c.xrayShaded), PS(TS(c.controlPoints), s.tTransferTex), k.updateIfChanged(s.uMaxSteps, i(s.uGridDim.ref.value, c.stepsPerCell)), k.updateIfChanged(s.uStepScale, a(s.uCellDim.ref.value, c.stepsPerCell)), k.updateIfChanged(s.uTransferScale, o(c.stepsPerCell)), k.updateIfChanged(s.uJumpLength, c.jumpLength);
  }, updateBoundingSphere: function(s, c) {
    var l = Me.clone(c.boundingSphere), d = zi(l, s.aTransform.ref.value, s.instanceCount.ref.value);
    Me.equals(d, s.boundingSphere.ref.value) || k.update(s.boundingSphere, d), Me.equals(l, s.invariantBoundingSphere.ref.value) || (k.update(s.invariantBoundingSphere, l), k.update(s.uInvariantBoundingSphere, Vt.fromSphere(s.uInvariantBoundingSphere.ref.value, l)));
  }, createRenderableState: function(s) {
    var c = ft.createRenderableState(s);
    return c.opaque = !1, c.writeDepth = !1, c;
  }, updateRenderableState: function(s, c) {
    ft.updateRenderableState(s, c), s.opaque = !1, s.writeDepth = !1;
  }, createPositionIterator: function(s, c) {
    var l = s.transform.ref.value, d = s.gridDimension.ref.value, f = d[0], m = d[1], v = d[2], p = f * m * v, g = c.instanceCount.ref.value, h = hf(), y = h.position, x = c.aTransform.ref.value;
    return ri(p, g, 1, function(A, b) {
      var _ = Math.floor(A / v);
      return y[0] = Math.floor(_ / m), y[1] = _ % m, y[2] = A % v, w.transformMat4(y, y, l), b >= 0 && w.transformMat4Offset(y, y, x, 0, 0, 16 * b), h;
    });
  } };
})(R2 || (R2 = {})), function(e) {
  function t(u, s, c, l, d, f) {
    return f ? function(m, v, p, g, h, y) {
      return h > y.sphereCount && (k.update(y.mappingBuffer, v), k.update(y.indexBuffer, p)), y.sphereCount = h, k.update(y.centerBuffer, m), k.update(y.groupBuffer, g), y;
    }(u, s, c, l, d, f) : function(m, v, p, g, h) {
      var y, x = Me(), A = -1, b = -1, _ = { kind: "spheres", sphereCount: h, centerBuffer: k.create(m), mappingBuffer: k.create(v), indexBuffer: k.create(p), groupBuffer: k.create(g), get boundingSphere() {
        var S = n(_);
        if (S !== A) {
          var D = nd(_.centerBuffer.ref.value, 4 * _.sphereCount, 4);
          Me.copy(x, D), A = S;
        }
        return x;
      }, get groupMapping() {
        return _.groupBuffer.ref.version !== b && (y = _0(_.groupBuffer.ref.value, _.sphereCount, 4), b = _.groupBuffer.ref.version), y;
      }, setBoundingSphere: function(S) {
        Me.copy(x, S), A = n(_);
      } };
      return _;
    }(u, s, c, l, d);
  }
  function r(u) {
    return t(u ? u.centerBuffer.ref.value : new Float32Array(0), u ? u.mappingBuffer.ref.value : new Float32Array(0), u ? u.indexBuffer.ref.value : new Uint32Array(0), u ? u.groupBuffer.ref.value : new Float32Array(0), 0, u);
  }
  function n(u) {
    return Ra([u.sphereCount, u.centerBuffer.ref.version, u.mappingBuffer.ref.version, u.indexBuffer.ref.version, u.groupBuffer.ref.version]);
  }
  function i(u, s) {
    var c = 4 * u.sphereCount, l = s.instanceCount.ref.value, d = hf(), f = d.position, m = u.centerBuffer.ref.value, v = s.aTransform.ref.value;
    return ri(c, l, 4, function(p, g) {
      return g < 0 ? w.fromArray(f, m, 3 * p) : w.transformMat4Offset(f, m, v, 0, 3 * p, 16 * g), d;
    });
  }
  function a(u, s, c, l, d) {
    var f = c.instanceCount, m = c.groupCount, v = Xo(c, i(u, s), l.color), p = Lc(c, l.size), g = Pu(f * m), h = Ac(), y = Sc(), x = wc(), A = Cc(), b = { drawCount: 2 * u.sphereCount * 3, vertexCount: 4 * u.sphereCount, groupCount: m, instanceCount: f }, _ = u.boundingSphere.radius ? om(p) * d.sizeFactor : 0, S = Me.expand(Me(), u.boundingSphere, _), D = zi(S, s.aTransform.ref.value, f);
    return R(R(R(R(R(R(R(R(R(R(R({ dGeometryType: k.create("spheres"), aPosition: u.centerBuffer, aMapping: u.mappingBuffer, aGroup: u.groupBuffer, elements: u.indexBuffer, boundingSphere: k.create(D), invariantBoundingSphere: k.create(S), uInvariantBoundingSphere: k.create(Vt.ofSphere(S)) }, v), p), g), h), y), x), A), s), { padding: k.create(_) }), ft.createValues(d, b)), { uSizeFactor: k.create(d.sizeFactor), uDoubleSided: k.create(d.doubleSided), dIgnoreLight: k.create(d.ignoreLight), dXrayShaded: k.create(d.xrayShaded), uBumpFrequency: k.create(d.bumpFrequency), uBumpAmplitude: k.create(d.bumpAmplitude) });
  }
  function o(u, s) {
    ft.updateRenderableState(u, s), u.opaque = u.opaque && !s.xrayShaded, u.writeDepth = u.opaque;
  }
  e.create = t, e.createEmpty = r, e.Params = R(R({}, ft.Params), { sizeFactor: G.Numeric(1, { min: 0, max: 10, step: 0.1 }), doubleSided: G.Boolean(!1, ft.CustomQualityParamInfo), ignoreLight: G.Boolean(!1, ft.ShadingCategory), xrayShaded: G.Boolean(!1, ft.ShadingCategory), bumpFrequency: G.Numeric(0, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory), bumpAmplitude: G.Numeric(1, { min: 0, max: 5, step: 0.1 }, ft.ShadingCategory) }), e.Utils = { Params: e.Params, createEmpty: r, createValues: a, createValuesSimple: function(u, s, c, l, d) {
    var f = ft.createSimple(c, l, d), m = R(R({}, G.getDefaultValues(e.Params)), s);
    return a(u, f.transform, f.locationIterator, f.theme, m);
  }, updateValues: function(u, s) {
    ft.updateValues(u, s), k.updateIfChanged(u.uSizeFactor, s.sizeFactor), k.updateIfChanged(u.uDoubleSided, s.doubleSided), k.updateIfChanged(u.dIgnoreLight, s.ignoreLight), k.updateIfChanged(u.dXrayShaded, s.xrayShaded), k.updateIfChanged(u.uBumpFrequency, s.bumpFrequency), k.updateIfChanged(u.uBumpAmplitude, s.bumpAmplitude);
  }, updateBoundingSphere: function(u, s) {
    var c = s.boundingSphere.radius ? om(u) * u.uSizeFactor.ref.value : 0, l = Me.expand(Me(), s.boundingSphere, c), d = zi(l, u.aTransform.ref.value, u.instanceCount.ref.value);
    Me.equals(d, u.boundingSphere.ref.value) || k.update(u.boundingSphere, d), Me.equals(l, u.invariantBoundingSphere.ref.value) || (k.update(u.invariantBoundingSphere, l), k.update(u.uInvariantBoundingSphere, Vt.fromSphere(u.uInvariantBoundingSphere.ref.value, l))), k.update(u.padding, c);
  }, createRenderableState: function(u) {
    var s = ft.createRenderableState(u);
    return o(s, u), s;
  }, updateRenderableState: o, createPositionIterator: i };
}(ns || (ns = {})), function(e) {
  var t = function() {
    function a() {
      this.index = 0, this.textures = [];
    }
    return a.prototype.get = function() {
      return this.textures[this.index];
    }, a.prototype.set = function(o, u, s) {
      this.textures[this.index] = Object.assign(this.textures[this.index] || {}, { vertex: o, group: u, normal: s }), this.index = (this.index + 1) % 2;
    }, a.prototype.destroy = function() {
      for (var o = 0, u = this.textures; o < u.length; o++) {
        var s = u[o];
        s.vertex.destroy(), s.group.destroy(), s.normal.destroy();
      }
    }, a;
  }();
  function r(a, o, u, s, c, l, d) {
    var f = u.getWidth(), m = u.getHeight();
    return d ? (d.vertexCount = a, d.groupCount = o, k.update(d.geoTextureDim, ke.set(d.geoTextureDim.ref.value, f, m)), k.update(d.vertexTexture, u), k.update(d.groupTexture, s), k.update(d.normalTexture, c), d.doubleBuffer.set(u, s, c), Me.copy(d.boundingSphere, l), d) : { kind: "texture-mesh", vertexCount: a, groupCount: o, geoTextureDim: k.create(ke.create(f, m)), vertexTexture: k.create(u), groupTexture: k.create(s), normalTexture: k.create(c), doubleBuffer: new t(), boundingSphere: Me.clone(l), meta: {} };
  }
  function n(a) {
    return r(0, 0, a ? a.vertexTexture.ref.value : go(), a ? a.groupTexture.ref.value : go(), a ? a.normalTexture.ref.value : go(), a ? a.boundingSphere : Me(), a);
  }
  function i(a, o, u, s, c) {
    var l = u.instanceCount, d = u.groupCount, f = Xo(u, e.Utils.createPositionIterator(a, o), s.color), m = Pu(l * d), v = Ac(), p = Sc(), g = wc(), h = Cc(), y = { drawCount: a.vertexCount, vertexCount: a.vertexCount, groupCount: d, instanceCount: l }, x = Me.clone(a.boundingSphere), A = zi(x, o.aTransform.ref.value, l);
    return R(R(R(R(R(R(R(R(R({ dGeometryType: k.create("textureMesh"), uGeoTexDim: a.geoTextureDim, tPosition: a.vertexTexture, tGroup: a.groupTexture, tNormal: a.normalTexture, boundingSphere: k.create(A), invariantBoundingSphere: k.create(x), uInvariantBoundingSphere: k.create(Vt.ofSphere(x)) }, f), m), v), p), g), h), o), ft.createValues(c, y)), { uDoubleSided: k.create(c.doubleSided), dFlatShaded: k.create(c.flatShaded), dFlipSided: k.create(c.flipSided), dIgnoreLight: k.create(c.ignoreLight), dXrayShaded: k.create(c.xrayShaded), uBumpFrequency: k.create(c.bumpFrequency), uBumpAmplitude: k.create(c.bumpAmplitude), meta: k.create(a.meta) });
  }
  e.DoubleBuffer = t, e.create = r, e.createEmpty = n, e.Params = R(R({}, ft.Params), { doubleSided: G.Boolean(!1, ft.CustomQualityParamInfo), flipSided: G.Boolean(!1, ft.ShadingCategory), flatShaded: G.Boolean(!1, ft.ShadingCategory), ignoreLight: G.Boolean(!1, ft.ShadingCategory), xrayShaded: G.Boolean(!1, ft.ShadingCategory), bumpFrequency: G.Numeric(0, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory), bumpAmplitude: G.Numeric(1, { min: 0, max: 5, step: 0.1 }, ft.ShadingCategory) }), e.Utils = { Params: e.Params, createEmpty: n, createValues: i, createValuesSimple: function(a, o, u, s, c) {
    var l = ft.createSimple(u, s, c), d = R(R({}, G.getDefaultValues(e.Params)), o);
    return i(a, l.transform, l.locationIterator, l.theme, d);
  }, updateValues: function(a, o) {
    ft.updateValues(a, o), k.updateIfChanged(a.uDoubleSided, o.doubleSided), k.updateIfChanged(a.dFlatShaded, o.flatShaded), k.updateIfChanged(a.dFlipSided, o.flipSided), k.updateIfChanged(a.dIgnoreLight, o.ignoreLight), k.updateIfChanged(a.dXrayShaded, o.xrayShaded), k.updateIfChanged(a.uBumpFrequency, o.bumpFrequency), k.updateIfChanged(a.uBumpAmplitude, o.bumpAmplitude);
  }, updateBoundingSphere: function(a, o) {
    var u = Me.clone(o.boundingSphere), s = zi(u, a.aTransform.ref.value, a.instanceCount.ref.value);
    Me.equals(s, a.boundingSphere.ref.value) || k.update(a.boundingSphere, s), Me.equals(u, a.invariantBoundingSphere.ref.value) || (k.update(a.invariantBoundingSphere, u), k.update(a.uInvariantBoundingSphere, Vt.fromSphere(a.uInvariantBoundingSphere.ref.value, u)));
  }, createRenderableState: ft.createRenderableState, updateRenderableState: ft.updateRenderableState, createPositionIterator: function() {
    return ri(1, 1, 1, function() {
      return Ns;
    });
  } };
}(id || (id = {}));
var ec = { uModel: Ie("m4"), uView: Ie("m4"), uInvView: Ie("m4"), uModelView: Ie("m4"), uInvModelView: Ie("m4"), uProjection: Ie("m4"), uInvProjection: Ie("m4"), uModelViewProjection: Ie("m4"), uInvModelViewProjection: Ie("m4"), uIsOrtho: Ie("f"), uPixelRatio: Ie("f"), uViewport: Ie("v4"), uViewOffset: Ie("v2"), uDrawingBufferSize: Ie("v2"), uCameraPosition: Ie("v3"), uCameraDir: Ie("v3"), uNear: Ie("f"), uFar: Ie("f"), uFogNear: Ie("f"), uFogFar: Ie("f"), uFogColor: Ie("v3"), uTransparentBackground: Ie("b"), uLightDirection: Ie("v3[]"), uLightColor: Ie("v3[]"), uAmbientColor: Ie("v3"), uPickingAlphaThreshold: Ie("f"), uInteriorDarkening: Ie("f"), uInteriorColorFlag: Ie("b"), uInteriorColor: Ie("v3"), uHighlightColor: Ie("v3"), uSelectColor: Ie("v3"), uHighlightStrength: Ie("f"), uSelectStrength: Ie("f"), uMarkerPriority: Ie("i"), uXrayEdgeFalloff: Ie("f"), uRenderWboit: Ie("b"), uMarkingDepthTest: Ie("b"), uMarkingType: Ie("i"), uPickType: Ie("i"), uInvalidColor: Ie("v3"), uInvalidStrength: Ie("f") }, tc = { tDepth: zt("texture", "depth", "ushort", "nearest") }, rc = { uObjectId: Ie("i") }, NY = { uColor: Ie("v3", "material"), uColorTexDim: Ie("v2"), uColorGridDim: Ie("v3"), uColorGridTransform: Ie("v4"), tColor: zt("image-uint8", "rgb", "ubyte", "nearest"), tPalette: zt("image-uint8", "rgb", "ubyte", "nearest"), tColorGrid: zt("texture", "rgb", "ubyte", "linear"), dColorType: kt("string", ["uniform", "attribute", "instance", "group", "groupInstance", "vertex", "vertexInstance", "volume", "volumeInstance", "direct"]), dUsePalette: kt("boolean") }, Tm = { uSize: Ie("f", "material"), uSizeTexDim: Ie("v2"), tSize: zt("image-uint8", "rgb", "ubyte", "nearest"), dSizeType: kt("string", ["uniform", "attribute", "instance", "group", "groupInstance"]), uSizeFactor: Ie("f") }, RY = { uMarker: Ie("f"), uMarkerTexDim: Ie("v2"), tMarker: zt("image-uint8", "alpha", "ubyte", "nearest"), markerAverage: ci("number"), markerStatus: ci("number") }, OY = { uOverpaintTexDim: Ie("v2"), tOverpaint: zt("image-uint8", "rgba", "ubyte", "nearest"), dOverpaint: kt("boolean"), uOverpaintGridDim: Ie("v3"), uOverpaintGridTransform: Ie("v4"), tOverpaintGrid: zt("texture", "rgba", "ubyte", "linear"), dOverpaintType: kt("string", ["groupInstance", "volumeInstance"]) }, LY = { uTransparencyTexDim: Ie("v2"), tTransparency: zt("image-uint8", "alpha", "ubyte", "nearest"), dTransparency: kt("boolean"), transparencyAverage: ci("number"), uTransparencyGridDim: Ie("v3"), uTransparencyGridTransform: Ie("v4"), tTransparencyGrid: zt("texture", "alpha", "ubyte", "linear"), dTransparencyType: kt("string", ["groupInstance", "volumeInstance"]) }, kY = { uSubstanceTexDim: Ie("v2"), tSubstance: zt("image-uint8", "rgba", "ubyte", "nearest"), dSubstance: kt("boolean"), uSubstanceGridDim: Ie("v3"), uSubstanceGridTransform: Ie("v4"), tSubstanceGrid: zt("texture", "rgba", "ubyte", "linear"), dSubstanceType: kt("string", ["groupInstance", "volumeInstance"]) }, zY = { uClippingTexDim: Ie("v2"), tClipping: zt("image-uint8", "alpha", "ubyte", "nearest"), dClipping: kt("boolean") }, kc = R(R(R(R(R(R(R({ dGeometryType: kt("string", ["cylinders", "directVolume", "image", "lines", "mesh", "points", "spheres", "text", "textureMesh"]) }, NY), RY), OY), LY), kY), zY), { dLightCount: kt("number"), dClipObjectCount: kt("number"), dClipVariant: kt("string", ["instance", "pixel"]), uClipObjectType: Ie("i[]"), uClipObjectInvert: Ie("b[]"), uClipObjectPosition: Ie("v3[]"), uClipObjectRotation: Ie("v4[]"), uClipObjectScale: Ie("v3[]"), aInstance: Vr("float32", 1, 1), aTransform: Vr("float32", 16, 1), uAlpha: Ie("f", "material"), uMetalness: Ie("f", "material"), uRoughness: Ie("f", "material"), uBumpiness: Ie("f", "material"), uVertexCount: Ie("i"), uInstanceCount: Ie("i"), uGroupCount: Ie("i"), uInvariantBoundingSphere: Ie("v4"), drawCount: ci("number"), instanceCount: ci("number"), alpha: ci("number"), matrix: ci("m4"), transform: ci("float32"), extraTransform: ci("float32"), hasReflection: ci("boolean"), boundingSphere: ci("sphere"), invariantBoundingSphere: ci("sphere") }), Fa = `
precision highp float;

attribute vec2 aPosition;
uniform vec2 uQuadScale;

void main(void) {
    vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale;
    gl_Position = vec4(position, 0.0, 1.0);
}
`, GY = La(), I_ = Object.keys({ colorBlended: "", colorWboit: "", pick: "", depth: "", marking: "" }), Fg = I_.filter(function(e) {
  return e !== "colorWboit";
}), VY = I_.filter(function(e) {
  return e !== "colorBlended";
}), UY = Object.keys({ compute: "" });
function FS(e, t, r, n, i) {
  return r = R(R({}, r), { dRenderVariant: k.create(t) }), i.dRenderVariant === void 0 && Object.defineProperty(i, "dRenderVariant", { value: kt("string") }), e.resources.program(r, n, i);
}
function nc(e, t, r, n, i, a, o) {
  return kT(e, t, r, n, i, a, o);
}
function Bi(e, t, r, n, i, a) {
  return a === void 0 && (a = -1), kT(e, t, r, n, i, a, UY);
}
function kT(e, t, r, n, i, a, o) {
  var u = GY(), s = e.stats, c = e.state, l = e.resources, d = e.extensions, f = d.instancedArrays, m = d.vertexArrayObject;
  if (i.uVertexCount) {
    var v = i.uVertexCount.ref.value;
    i.aVertex = k.create(Fs(new Float32Array(v))), n.aVertex = Vr("float32", 1, 0);
  }
  for (var p = function(ie, ae) {
    var se = {}, le = {}, pe = {}, we = {}, Ge = {}, Ue = {};
    return Object.keys(ie).forEach(function(Ke) {
      var Ze = ie[Ke];
      Ze.type === "attribute" && (se[Ke] = ae[Ke]), Ze.type === "define" && (le[Ke] = ae[Ke]), Ze.type === "texture" && ae[Ke] !== void 0 && (pe[Ke] = ae[Ke]), Ze.type === "uniform" && ae[Ke] !== void 0 && (Ze.variant === "material" ? Ge[Ke] = ae[Ke] : Ze.variant === "buffered" ? Ue[Ke] = ae[Ke] : we[Ke] = ae[Ke]);
    }), { attributeValues: se, defineValues: le, textureValues: pe, uniformValues: we, materialUniformValues: Ge, bufferedUniformValues: Ue };
  }(n, i), g = p.attributeValues, h = p.defineValues, y = p.textureValues, x = p.uniformValues, A = p.materialUniformValues, b = p.bufferedUniformValues, _ = Object.entries(x), S = Object.entries(A), D = Object.entries(b), I = Object.entries(function(ie) {
    var ae = {};
    return Object.keys(ie).forEach(function(se) {
      ae[se] = k.create(Tc(ie[se].ref.value));
    }), ae;
  }(b)), M = Object.entries(h), F = function(ie) {
    var ae = {};
    return Object.keys(ie).forEach(function(se) {
      ae[se] = ie[se].ref.version;
    }), ae;
  }(i), P = function(ie, ae) {
    var se = ie.gl;
    switch (ae) {
      case "points":
        return se.POINTS;
      case "lines":
        return se.LINES;
      case "line-strip":
        return se.LINE_STRIP;
      case "line-loop":
        return se.LINE_LOOP;
      case "triangles":
        return se.TRIANGLES;
      case "triangle-strip":
        return se.TRIANGLE_STRIP;
      case "triangle-fan":
        return se.TRIANGLE_FAN;
    }
  }(e, t), E = {}, B = 0, N = o; B < N.length; B++) {
    var O = N[B];
    E[O] = FS(e, O, h, r, n);
  }
  var z, V = function(ie, ae, se) {
    var le = ie.resources, pe = [];
    return Object.keys(ae).forEach(function(we) {
      var Ge = ae[we];
      if (Ge.type === "texture") {
        var Ue = se[we];
        if (Ue) if (Ge.kind === "texture") pe[pe.length] = [we, Ue.ref.value];
        else {
          var Ke = le.texture(Ge.kind, Ge.format, Ge.dataType, Ge.filter);
          Ke.load(Ue.ref.value), pe[pe.length] = [we, Ke];
        }
      }
    }), pe;
  }(e, n, y), U = function(ie, ae, se) {
    var le = [];
    return Object.keys(ae).forEach(function(pe) {
      var we = ae[pe];
      we.type === "attribute" && (le[le.length] = [pe, ie.resources.attribute(se[pe].ref.value, we.itemSize, we.divisor)]);
    }), le;
  }(e, n, g), H = i.elements;
  H && H.ref.value && (z = l.elements(H.ref.value));
  for (var K = {}, j = 0, X = o; j < X.length; j++)
    O = X[j], K[O] = m ? l.vertexArray(E[O], U, z) : null;
  var W = i.drawCount.ref.value, Q = i.instanceCount.ref.value;
  s.drawCount += W, s.instanceCount += Q, s.instancedDrawCount += Q * W;
  var te = { attributes: !1, defines: !1, elements: !1, textures: !1 }, ee = !1, $ = -1;
  return { id: u, materialId: a, getProgram: function(ie) {
    return E[ie];
  }, render: function(ie, ae) {
    if (W !== 0 && Q !== 0 && !e.isContextLost) {
      var se = E[ie];
      if (se.id === $ && c.currentRenderItemId === u) se.setUniforms(_), ae && ae.length > 0 ? (se.bindTextures(ae, 0), se.bindTextures(V, ae.length)) : se.bindTextures(V, 0);
      else {
        var le = K[ie];
        se.id === c.currentProgramId && se.id === $ && a !== -1 && a === c.currentMaterialId || (se.id !== c.currentProgramId && se.use(), se.setUniforms(S), c.currentMaterialId = a, $ = se.id), se.setUniforms(_), se.setUniforms(I), ae && ae.length > 0 ? (se.bindTextures(ae, 0), se.bindTextures(V, ae.length)) : se.bindTextures(V, 0), le ? (le.bind(), z && z.bind()) : (z && z.bind(), se.bindAttributes(U)), c.currentRenderItemId = u;
      }
      if (Ir) try {
        d_(e.gl);
      } catch (pe) {
        throw new Error("Framebuffer error rendering item id ".concat(u, ": '").concat(pe, "'"));
      }
      if (z ? f.drawElementsInstanced(P, W, z._dataType, 0, Q) : f.drawArraysInstanced(P, 0, W, Q), Ir) try {
        _M(e.gl);
      } catch (pe) {
        throw new Error("Draw error rendering item id ".concat(u, ": '").concat(pe, "'"));
      }
    }
  }, update: function() {
    if (function(Se) {
      Se.attributes = !1, Se.defines = !1, Se.elements = !1, Se.textures = !1;
    }(te), i.aVertex) {
      var ie = i.uVertexCount.ref.value;
      i.aVertex.ref.value.length < ie && k.update(i.aVertex, Fs(new Float32Array(ie)));
    }
    for (var ae = 0, se = M.length; ae < se; ++ae) {
      var le = M[ae], pe = le[0];
      (J = le[1]).ref.version !== F[pe] && (te.defines = !0, F[pe] = J.ref.version);
    }
    if (te.defines) for (var we = 0, Ge = o; we < Ge.length; we++)
      pe = Ge[we], E[pe].destroy(), E[pe] = FS(e, pe, h, r, n);
    for (i.drawCount.ref.version !== F.drawCount && (s.drawCount += i.drawCount.ref.value - W, s.instancedDrawCount += Q * i.drawCount.ref.value - Q * W, W = i.drawCount.ref.value, F.drawCount = i.drawCount.ref.version), i.instanceCount.ref.version !== F.instanceCount && (s.instanceCount += i.instanceCount.ref.value - Q, s.instancedDrawCount += i.instanceCount.ref.value * W - Q * W, Q = i.instanceCount.ref.value, F.instanceCount = i.instanceCount.ref.version), ae = 0, se = U.length; ae < se; ++ae) {
      var Ue = U[ae], Ke = (pe = Ue[0], Ue[1]);
      if ((J = g[pe]).ref.version !== F[pe]) {
        if (Ke.length >= J.ref.value.length) Ke.updateSubData(J.ref.value, 0, Ke.length);
        else {
          Ke.destroy();
          var Ze = n[pe], Fe = Ze.itemSize, Je = Ze.divisor;
          U[ae][1] = l.attribute(J.ref.value, Fe, Je), te.attributes = !0;
        }
        F[pe] = J.ref.version;
      }
    }
    if (z && i.elements.ref.version !== F.elements && (z.length >= i.elements.ref.value.length ? z.updateSubData(i.elements.ref.value, 0, z.length) : (z.destroy(), z = l.elements(i.elements.ref.value), te.elements = !0), F.elements = i.elements.ref.version), te.attributes || te.defines || te.elements) for (var Ne = 0, nt = o; Ne < nt.length; Ne++) {
      pe = nt[Ne];
      var re = K[pe];
      re && re.destroy(), K[pe] = m ? l.vertexArray(E[pe], U, z) : null;
    }
    for (ae = 0, se = V.length; ae < se; ++ae) {
      var J, ce = V[ae], de = (pe = ce[0], ce[1]);
      (J = y[pe]).ref.version !== F[pe] && (n[pe].kind !== "texture" ? (de.load(J.ref.value), te.textures = !0) : V[ae][1] = J.ref.value, F[pe] = J.ref.version);
    }
    for (ae = 0, se = D.length; ae < se; ++ae) {
      var ve = D[ae], he = (pe = ve[0], ve[1]);
      he.ref.version !== F[pe] && (k.update(I[ae][1], Tc(he.ref.value)), F[pe] = he.ref.version);
    }
    return te;
  }, destroy: function() {
    if (!ee) {
      for (var ie = 0, ae = o; ie < ae.length; ie++) {
        var se = ae[ie];
        E[se].destroy();
        var le = K[se];
        le && le.destroy();
      }
      V.forEach(function(pe) {
        var we = pe[0], Ge = pe[1];
        n[we].kind !== "texture" && Ge.destroy();
      }), U.forEach(function(pe) {
        return pe[0], pe[1].destroy();
      }), z && z.destroy(), s.drawCount -= W, s.instanceCount -= Q, s.instancedDrawCount -= Q * W, ee = !0;
    }
  } };
}
var zT = La();
function ic(e, t, r) {
  return { id: zT(), materialId: e.materialId, values: t, state: r, render: function(n, i) {
    t.uAlpha && t.alpha && k.updateIfChanged(t.uAlpha, Qa(t.alpha.ref.value * r.alphaFactor, 0, 1)), e.render(n, i);
  }, getProgram: function(n) {
    return e.getProgram(n);
  }, update: function() {
    return e.update();
  }, dispose: function() {
    return e.destroy();
  } };
}
function Fi(e, t) {
  return { id: zT(), values: t, render: function() {
    return e.render("compute");
  }, update: function() {
    return e.update();
  }, dispose: function() {
    return e.destroy();
  } };
}
var GT = new Float32Array([1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1, 1]), qi = { drawCount: ci("number"), instanceCount: ci("number"), aPosition: Vr("float32", 2, 0), uQuadScale: Ie("v2") }, Ui = { drawCount: k.create(6), instanceCount: k.create(1), aPosition: k.create(GT), uQuadScale: k.create(ke.create(1, 1)) }, HY = R(R({}, qi), { tColor: zt("texture", "rgba", "ubyte", "nearest"), uTexSize: Ie("v2") }), qY = Sn("copy", Fa, `
precision highp float;
precision highp sampler2D;

uniform sampler2D tColor;
uniform vec2 uTexSize;

void main() {
    vec2 coords = gl_FragCoord.xy / uTexSize;
    gl_FragColor = texture2D(tColor, coords);
}
`);
function Bb(e, t) {
  var r = R(R({}, Ui), { tColor: k.create(t), uTexSize: k.create(ke.create(t.getWidth(), t.getHeight())) }), n = R({}, HY);
  return Fi(Bi(e, "triangles", qY, n, r), r);
}
var _4, Na, oa, NS = new Uint32Array([0, 1, 2, 1, 3, 2]), KY = new Float32Array([0, 1, 0, 0, 1, 1, 1, 0]), VT = { nearest: "Nearest", catmulrom: "Catmulrom (Cubic)", mitchell: "Mitchell (Cubic)", bspline: "B-Spline (Cubic)" }, XY = Object.keys(VT);
(function(e) {
  function t(i, a, o, u) {
    return u ? function(s, c, l, d) {
      var f = s.width, m = s.height;
      return k.update(d.imageTexture, s), k.update(d.imageTextureDim, ke.set(d.imageTextureDim.ref.value, f, m)), k.update(d.cornerBuffer, c), k.update(d.groupTexture, l), d;
    }(i, a, o, u) : function(s, c, l) {
      var d = Me(), f = -1, m = s.width, v = s.height, p = { kind: "image", imageTexture: k.create(s), imageTextureDim: k.create(ke.create(m, v)), cornerBuffer: k.create(c), groupTexture: k.create(l), get boundingSphere() {
        var g = function(y) {
          return Ra([y.cornerBuffer.ref.version]);
        }(p);
        if (g !== f) {
          var h = function(y) {
            for (var x = w(), A = [], b = 0, _ = y.length; b < _; b += 3) {
              var S = w.fromArray(w(), y, b);
              A.push(S), w.add(x, x, S);
            }
            w.scale(x, x, 1 / (y.length / 3));
            for (var D = 0, I = 0, M = A; I < M.length; I++) {
              S = M[I];
              var F = w.distance(x, S);
              F > D && (D = F);
            }
            var P = Me.create(x, D);
            return Me.setExtrema(P, A), P;
          }(p.cornerBuffer.ref.value);
          Me.copy(d, h), f = g;
        }
        return d;
      } };
      return p;
    }(i, a, o);
  }
  function r(i) {
    return t(Di(0, 4, Uint8Array), i ? i.cornerBuffer.ref.value : new Float32Array(24), Di(0, 4, Uint8Array), i);
  }
  function n(i, a, o, u, s) {
    var c = o.instanceCount, l = o.groupCount, d = Xo(o, e.Utils.createPositionIterator(i, a), u.color), f = Pu(c * l), m = Ac(), v = Sc(), p = wc(), g = Cc(), h = { drawCount: NS.length, vertexCount: GT.length / 3, groupCount: l, instanceCount: c }, y = Me.clone(i.boundingSphere), x = zi(y, a.aTransform.ref.value, c);
    return R(R(R(R(R(R(R(R(R({ dGeometryType: k.create("image") }, d), f), m), v), p), g), a), ft.createValues(s, h)), { aPosition: i.cornerBuffer, aUv: k.create(KY), elements: k.create(NS), aGroup: k.create(Fs(new Float32Array(4))), boundingSphere: k.create(x), invariantBoundingSphere: k.create(y), uInvariantBoundingSphere: k.create(Vt.ofSphere(y)), dInterpolation: k.create(s.interpolation), uImageTexDim: i.imageTextureDim, tImageTex: i.imageTexture, tGroupTex: i.groupTexture });
  }
  e.create = t, e.createEmpty = r, e.Params = R(R({}, ft.Params), { interpolation: G.Select("bspline", G.objectToOptions(VT)) }), e.Utils = { Params: e.Params, createEmpty: r, createValues: n, createValuesSimple: function(i, a, o, u, s) {
    var c = ft.createSimple(o, u, s), l = R(R({}, G.getDefaultValues(e.Params)), a);
    return n(i, c.transform, c.locationIterator, c.theme, l);
  }, updateValues: function(i, a) {
    ft.updateValues(i, a), k.updateIfChanged(i.dInterpolation, a.interpolation);
  }, updateBoundingSphere: function(i, a) {
    var o = Me.clone(a.boundingSphere), u = zi(o, i.aTransform.ref.value, i.instanceCount.ref.value);
    Me.equals(u, i.boundingSphere.ref.value) || k.update(i.boundingSphere, u), Me.equals(o, i.invariantBoundingSphere.ref.value) || (k.update(i.invariantBoundingSphere, o), k.update(i.uInvariantBoundingSphere, Vt.fromSphere(i.uInvariantBoundingSphere.ref.value, o)));
  }, createRenderableState: function(i) {
    var a = ft.createRenderableState(i);
    return a.opaque = !1, a;
  }, updateRenderableState: function(i, a) {
    ft.updateRenderableState(i, a), i.opaque = !1;
  }, createPositionIterator: function() {
    return ri(1, 1, 1, function() {
      return Ns;
    });
  } };
})(_4 || (_4 = {})), function(e) {
  function t(u, s, c, l, d, f, m, v, p) {
    return p ? function(g, h, y, x, A, b, _, S, D) {
      return S > D.cylinderCount && (k.update(D.mappingBuffer, g), k.update(D.indexBuffer, h)), D.cylinderCount = S, k.update(D.groupBuffer, y), k.update(D.startBuffer, x), k.update(D.endBuffer, A), k.update(D.scaleBuffer, b), k.update(D.capBuffer, _), D;
    }(u, s, c, l, d, f, m, v, p) : function(g, h, y, x, A, b, _, S) {
      var D, I = Me(), M = -1, F = -1, P = { kind: "cylinders", cylinderCount: S, mappingBuffer: k.create(g), indexBuffer: k.create(h), groupBuffer: k.create(y), startBuffer: k.create(x), endBuffer: k.create(A), scaleBuffer: k.create(b), capBuffer: k.create(_), get boundingSphere() {
        var E = n(P);
        if (E !== M) {
          var B = nd(P.startBuffer.ref.value, 6 * P.cylinderCount, 6), N = nd(P.endBuffer.ref.value, 6 * P.cylinderCount, 6);
          Me.expandBySphere(I, B, N), M = E;
        }
        return I;
      }, get groupMapping() {
        return P.groupBuffer.ref.version !== F && (D = _0(P.groupBuffer.ref.value, P.cylinderCount, 6), F = P.groupBuffer.ref.version), D;
      }, setBoundingSphere: function(E) {
        Me.copy(I, E), M = n(P);
      } };
      return P;
    }(u, s, c, l, d, f, m, v);
  }
  function r(u) {
    return t(u ? u.mappingBuffer.ref.value : new Float32Array(0), u ? u.indexBuffer.ref.value : new Uint32Array(0), u ? u.groupBuffer.ref.value : new Float32Array(0), u ? u.startBuffer.ref.value : new Float32Array(0), u ? u.endBuffer.ref.value : new Float32Array(0), u ? u.scaleBuffer.ref.value : new Float32Array(0), u ? u.capBuffer.ref.value : new Float32Array(0), 0, u);
  }
  function n(u) {
    return Ra([u.cylinderCount, u.mappingBuffer.ref.version, u.indexBuffer.ref.version, u.groupBuffer.ref.version, u.startBuffer.ref.version, u.endBuffer.ref.version, u.scaleBuffer.ref.version, u.capBuffer.ref.version]);
  }
  function i(u, s) {
    var c = 6 * u.cylinderCount, l = s.instanceCount.ref.value, d = hf(), f = d.position, m = u.startBuffer.ref.value, v = u.endBuffer.ref.value, p = s.aTransform.ref.value;
    return ri(c, l, 2, function(g, h) {
      var y = g % 6 == 0 ? m : v;
      return h < 0 ? w.fromArray(f, y, 3 * g) : w.transformMat4Offset(f, y, p, 0, 3 * g, 16 * h), d;
    });
  }
  function a(u, s, c, l, d) {
    var f = c.instanceCount, m = c.groupCount, v = Xo(c, i(u, s), l.color), p = Lc(c, l.size), g = Pu(f * m), h = Ac(), y = Sc(), x = wc(), A = Cc(), b = { drawCount: 4 * u.cylinderCount * 3, vertexCount: 6 * u.cylinderCount, groupCount: m, instanceCount: f }, _ = om(p) * d.sizeFactor, S = Me.clone(u.boundingSphere), D = zi(S, s.aTransform.ref.value, f);
    return R(R(R(R(R(R(R(R(R(R(R({ dGeometryType: k.create("cylinders"), aMapping: u.mappingBuffer, aGroup: u.groupBuffer, aStart: u.startBuffer, aEnd: u.endBuffer, aScale: u.scaleBuffer, aCap: u.capBuffer, elements: u.indexBuffer, boundingSphere: k.create(D), invariantBoundingSphere: k.create(S), uInvariantBoundingSphere: k.create(Vt.ofSphere(S)) }, v), p), g), h), y), x), A), s), { padding: k.create(_) }), ft.createValues(d, b)), { uSizeFactor: k.create(d.sizeFactor * d.sizeAspectRatio), uDoubleSided: k.create(d.doubleSided), dIgnoreLight: k.create(d.ignoreLight), dXrayShaded: k.create(d.xrayShaded), uBumpFrequency: k.create(d.bumpFrequency), uBumpAmplitude: k.create(d.bumpAmplitude) });
  }
  function o(u, s) {
    ft.updateRenderableState(u, s), u.opaque = u.opaque && !s.xrayShaded, u.writeDepth = u.opaque;
  }
  e.create = t, e.createEmpty = r, e.transform = function(u, s) {
    var c = u.startBuffer.ref.value;
    Z1(s, c, 0, 6 * u.cylinderCount), k.update(u.startBuffer, c);
    var l = u.endBuffer.ref.value;
    Z1(s, l, 0, 6 * u.cylinderCount), k.update(u.endBuffer, l);
  }, e.Params = R(R({}, ft.Params), { sizeFactor: G.Numeric(1, { min: 0, max: 10, step: 0.1 }), sizeAspectRatio: G.Numeric(1, { min: 0, max: 3, step: 0.01 }), doubleSided: G.Boolean(!1, ft.CustomQualityParamInfo), ignoreLight: G.Boolean(!1, ft.ShadingCategory), xrayShaded: G.Boolean(!1, ft.ShadingCategory), bumpFrequency: G.Numeric(0, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory), bumpAmplitude: G.Numeric(1, { min: 0, max: 5, step: 0.1 }, ft.ShadingCategory) }), e.Utils = { Params: e.Params, createEmpty: r, createValues: a, createValuesSimple: function(u, s, c, l, d) {
    var f = ft.createSimple(c, l, d), m = R(R({}, G.getDefaultValues(e.Params)), s);
    return a(u, f.transform, f.locationIterator, f.theme, m);
  }, updateValues: function(u, s) {
    ft.updateValues(u, s), k.updateIfChanged(u.uSizeFactor, s.sizeFactor * s.sizeAspectRatio), k.updateIfChanged(u.uDoubleSided, s.doubleSided), k.updateIfChanged(u.dIgnoreLight, s.ignoreLight), k.updateIfChanged(u.dXrayShaded, s.xrayShaded), k.updateIfChanged(u.uBumpFrequency, s.bumpFrequency), k.updateIfChanged(u.uBumpAmplitude, s.bumpAmplitude);
  }, updateBoundingSphere: function(u, s) {
    var c = Me.clone(s.boundingSphere), l = zi(c, u.aTransform.ref.value, u.instanceCount.ref.value);
    Me.equals(l, u.boundingSphere.ref.value) || k.update(u.boundingSphere, l), Me.equals(c, u.invariantBoundingSphere.ref.value) || (k.update(u.invariantBoundingSphere, c), k.update(u.uInvariantBoundingSphere, Vt.fromSphere(u.uInvariantBoundingSphere.ref.value, c)));
  }, createRenderableState: function(u) {
    var s = ft.createRenderableState(u);
    return o(s, u), s;
  }, updateRenderableState: o, createPositionIterator: i };
}(Na || (Na = {})), function(e) {
  function t(r) {
    switch (r.kind) {
      case "mesh":
        return 3 * r.triangleCount;
      case "points":
        return r.pointCount;
      case "spheres":
        return 2 * r.sphereCount * 3;
      case "cylinders":
        return 4 * r.cylinderCount * 3;
      case "text":
        return 2 * r.charCount * 3;
      case "lines":
        return 2 * r.lineCount * 3;
      case "direct-volume":
        return 36;
      case "image":
        return 6;
      case "texture-mesh":
        return r.vertexCount;
    }
  }
  e.getDrawCount = t, e.getVertexCount = function(r) {
    switch (r.kind) {
      case "mesh":
      case "texture-mesh":
        return r.vertexCount;
      case "points":
        return r.pointCount;
      case "spheres":
        return 4 * r.sphereCount;
      case "cylinders":
        return 6 * r.cylinderCount;
      case "text":
        return 4 * r.charCount;
      case "lines":
        return 4 * r.lineCount;
      case "direct-volume":
        var n = r.gridDimension.ref.value;
        return n[0] * n[1] * n[2];
      case "image":
        return 4;
    }
  }, e.getGroupCount = function(r) {
    switch (r.kind) {
      case "mesh":
      case "points":
      case "spheres":
      case "cylinders":
      case "text":
      case "lines":
        return t(r) === 0 ? 0 : y2(r.groupBuffer.ref.value) + 1;
      case "direct-volume":
        return 1;
      case "image":
        return y2(r.groupTexture.ref.value.array) + 1;
      case "texture-mesh":
        return r.groupCount;
    }
  }, e.getUtils = function(r) {
    switch (r.kind) {
      case "mesh":
        return Gt.Utils;
      case "points":
        return vf.Utils;
      case "spheres":
        return ns.Utils;
      case "cylinders":
        return Na.Utils;
      case "text":
        return jo.Utils;
      case "lines":
        return Mr.Utils;
      case "direct-volume":
        return R2.Utils;
      case "image":
        return _4.Utils;
      case "texture-mesh":
        return id.Utils;
    }
  }, e.getGranularity = function(r, n) {
    return n === "instance" && r.nonInstanceable ? "group" : n;
  };
}(oa || (oa = {}));
var jY = He(13421772), RS = {};
function E_(e, t) {
  return { factory: E_, granularity: "groupInstance", color: function(r) {
    return Za.isLocation(r) ? r.shape.getColor(r.group, r.instance) : jY;
  }, props: t, description: "Assigns colors as defined by the shape object." };
}
var YY = { name: "shape-group", label: "Shape Group", category: "Miscellaneous", factory: E_, getParams: function(e) {
  return RS;
}, defaultValues: G.getDefaultValues(RS), isApplicable: function(e) {
  return !!e.shape;
} }, WY = R(R({}, kc), { aPosition: Vr("float32", 3, 0), elements: Sf("uint32"), uBboxMin: Ie("v3"), uBboxMax: Ie("v3"), uBboxSize: Ie("v3"), uMaxSteps: Ie("i"), uStepScale: Ie("f"), uJumpLength: Ie("f"), uTransform: Ie("m4"), uGridDim: Ie("v3"), tTransferTex: zt("image-uint8", "alpha", "ubyte", "linear"), uTransferScale: Ie("f"), dGridTexType: kt("string", ["2d", "3d"]), uGridTexDim: Ie("v3"), tGridTex: zt("texture", "rgba", "ubyte", "linear"), uGridStats: Ie("v4"), uCellDim: Ie("v3"), uCartnToUnit: Ie("m4"), uUnitToCartn: Ie("m4"), dPackedGroup: kt("boolean"), dAxisOrder: kt("string", ["012", "021", "102", "120", "201", "210"]), dIgnoreLight: kt("boolean"), dXrayShaded: kt("boolean") }), ZY = R(R({}, kc), { aGroup: Vr("float32", 1, 0), aPosition: Vr("float32", 3, 0), aNormal: Vr("float32", 3, 0), elements: Sf("uint32"), dFlatShaded: kt("boolean"), uDoubleSided: Ie("b"), dFlipSided: kt("boolean"), dIgnoreLight: kt("boolean"), dXrayShaded: kt("boolean"), uBumpFrequency: Ie("f"), uBumpAmplitude: Ie("f"), meta: ci("unknown") }), QY = R(R(R({}, kc), Tm), { aGroup: Vr("float32", 1, 0), aPosition: Vr("float32", 3, 0), dPointSizeAttenuation: kt("boolean"), dPointStyle: kt("string", ["square", "circle", "fuzzy"]) }), JY = R(R(R({}, kc), Tm), { aGroup: Vr("float32", 1, 0), aMapping: Vr("float32", 2, 0), aStart: Vr("float32", 3, 0), aEnd: Vr("float32", 3, 0), elements: Sf("uint32"), dLineSizeAttenuation: kt("boolean"), uDoubleSided: Ie("b"), dFlipSided: kt("boolean") }), $Y = R(R(R({}, kc), Tm), { aGroup: Vr("float32", 1, 0), aPosition: Vr("float32", 3, 0), aMapping: Vr("float32", 2, 0), elements: Sf("uint32"), padding: ci("number"), uDoubleSided: Ie("b"), dIgnoreLight: kt("boolean"), dXrayShaded: kt("boolean"), uBumpFrequency: Ie("f"), uBumpAmplitude: Ie("f") }), eW = R(R(R({}, kc), Tm), { aGroup: Vr("float32", 1, 0), aPosition: Vr("float32", 3, 0), aMapping: Vr("float32", 2, 0), aDepth: Vr("float32", 1, 0), elements: Sf("uint32"), aTexCoord: Vr("float32", 2, 0), tFont: zt("image-uint8", "alpha", "ubyte", "linear"), padding: ci("number"), uBorderWidth: Ie("f"), uBorderColor: Ie("v3"), uOffsetX: Ie("f"), uOffsetY: Ie("f"), uOffsetZ: Ie("f"), uBackgroundColor: Ie("v3"), uBackgroundOpacity: Ie("f") }), tW = R(R({}, kc), { uGeoTexDim: Ie("v2", "buffered"), tPosition: zt("texture", "rgb", "float", "nearest"), tGroup: zt("texture", "alpha", "float", "nearest"), tNormal: zt("texture", "rgb", "float", "nearest"), dFlatShaded: kt("boolean"), uDoubleSided: Ie("b"), dFlipSided: kt("boolean"), dIgnoreLight: kt("boolean"), dXrayShaded: kt("boolean"), uBumpFrequency: Ie("f"), uBumpAmplitude: Ie("f"), meta: ci("unknown") }), rW = R(R({}, kc), { aGroup: Vr("float32", 1, 0), aPosition: Vr("float32", 3, 0), aUv: Vr("float32", 2, 0), elements: Sf("uint32"), uImageTexDim: Ie("v2"), tImageTex: zt("image-uint8", "rgba", "ubyte", "nearest"), tGroupTex: zt("image-uint8", "rgba", "ubyte", "nearest"), dInterpolation: kt("string", XY) }), nW = R(R(R({}, kc), Tm), { aGroup: Vr("float32", 1, 0), aStart: Vr("float32", 3, 0), aEnd: Vr("float32", 3, 0), aMapping: Vr("float32", 3, 0), aScale: Vr("float32", 1, 0), aCap: Vr("float32", 1, 0), elements: Sf("uint32"), padding: ci("number"), uDoubleSided: Ie("b"), dIgnoreLight: kt("boolean"), dXrayShaded: kt("boolean"), uBumpFrequency: Ie("f"), uBumpAmplitude: Ie("f") }), $t, Za, iW = La(0, 2147483647), zc = La(0, 2147483647);
function x0(e, t, r, n) {
  return { id: iW(), type: e, values: t, state: r, materialId: n };
}
function aW(e, t, r) {
  switch (t.type) {
    case "mesh":
      return function(n, i, a, o, u, s) {
        var c = R(R(R(R({}, ec), tc), rc), ZY), l = { uObjectId: k.create(i) };
        return ic(nc(n, "triangles", D9, c, R(R({}, a), l), u, s), a, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
    case "points":
      return function(n, i, a, o, u, s) {
        var c = R(R(R(R({}, ec), tc), rc), QY), l = { uObjectId: k.create(i) };
        return ic(nc(n, "points", dq, c, R(R({}, a), l), u, s), a, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
    case "spheres":
      return function(n, i, a, o, u, s) {
        var c = R(R(R(R({}, ec), tc), rc), $Y), l = { uObjectId: k.create(i) };
        return ic(nc(n, "triangles", fq, c, R(R({}, a), l), u, s), a, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
    case "cylinders":
      return function(n, i, a, o, u, s) {
        var c = R(R(R(R({}, ec), tc), rc), nW), l = { uObjectId: k.create(i) };
        return ic(nc(n, "triangles", pq, c, R(R({}, a), l), u, s), a, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
    case "text":
      return function(n, i, a, o, u, s) {
        var c = R(R(R(R({}, ec), tc), rc), eW), l = { uObjectId: k.create(i) };
        return ic(nc(n, "triangles", mq, c, R(R({}, a), l), u, s), a, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
    case "lines":
      return function(n, i, a, o, u, s) {
        var c = R(R(R(R({}, ec), tc), rc), JY), l = { uObjectId: k.create(i) };
        return ic(nc(n, "triangles", hq, c, R(R({}, a), l), u, s), a, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
    case "direct-volume":
      return function(n, i, a, o, u, s) {
        var c = R(R(R(R({}, ec), tc), rc), WY);
        n.isWebGL2 || (c.uMaxSteps = kt("number"));
        var l = { uObjectId: k.create(i) };
        return ic(nc(n, "triangles", vq, c, R(R({}, a), l), u, s), a, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
    case "image":
      return function(n, i, a, o, u, s) {
        var c = R(R(R(R({}, ec), tc), rc), rW), l = { uObjectId: k.create(i) };
        return ic(nc(n, "triangles", gq, c, R(R({}, a), l), u, s), a, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
    case "texture-mesh":
      return function(n, i, a, o, u, s) {
        var c = R(R(R(R({}, ec), tc), rc), tW), l = { uObjectId: k.create(i) };
        return ic(nc(n, "triangles", D9, c, R(R({}, a), l), u, s), a, o);
      }(e, t.id, t.values, t.state, t.materialId, r);
  }
  throw new Error("unsupported type");
}
(function(e) {
  function t(r) {
    var n = r.transforms.length, i = Za.Location(r);
    return ri(r.groupCount, n, 1, function(a, o) {
      return i.group = a, i.instance = o, i;
    });
  }
  e.create = function(r, n, i, a, o, u, s) {
    return { id: Ii.create22(), name: r, sourceData: n, geometry: i, transforms: s || [me.identity()], get groupCount() {
      return oa.getGroupCount(i);
    }, getColor: a, getSize: o, getLabel: u };
  }, e.getTheme = function(r) {
    return { color: E_(0, {}), size: M_({ shape: r }, {}) };
  }, e.groupIterator = t, e.createTransform = function(r, n) {
    for (var i = n && n.aTransform.ref.value.length >= 16 * r.length ? n.aTransform.ref.value : new Float32Array(16 * r.length), a = 0, o = r.length; a < o; ++a) me.toArray(r[a], i, 16 * a);
    return S_(i, r.length, n);
  }, e.createRenderObject = function(r, n) {
    var i = e.getTheme(r), a = oa.getUtils(r.geometry), o = zc(), u = t(r), s = e.createTransform(r.transforms), c = a.createValues(r.geometry, s, u, i, n), l = a.createRenderableState(n);
    return x0(r.geometry.kind, c, l, o);
  }, e.Loci = function(r) {
    return { kind: "shape-loci", shape: r };
  }, e.isLoci = function(r) {
    return !!r && r.kind === "shape-loci";
  }, e.areLociEqual = function(r, n) {
    return r.shape === n.shape;
  }, e.isLociEmpty = function(r) {
    return r.shape.groupCount === 0;
  };
})($t || ($t = {})), function(e) {
  function t(o) {
    for (var u = 0, s = 0, c = o.groups; s < c.length; s++) {
      var l = c[s];
      u += Le.size(l.ids);
    }
    return u;
  }
  e.Location = function(o, u, s) {
    return u === void 0 && (u = 0), s === void 0 && (s = 0), { kind: "group-location", shape: o, group: u, instance: s };
  }, e.isLocation = function(o) {
    return !!o && o.kind === "group-location";
  }, e.Loci = function(o, u) {
    return { kind: "group-loci", shape: o, groups: u };
  }, e.isLoci = function(o) {
    return !!o && o.kind === "group-loci";
  }, e.areLociEqual = function(o, u) {
    if (o.shape !== u.shape || o.groups.length !== u.groups.length) return !1;
    for (var s = 0, c = o.groups.length; s < c; ++s) {
      var l = o.groups[s], d = l.ids, f = l.instance, m = u.groups[s], v = m.ids;
      if (f !== m.instance || !Le.areEqual(d, v)) return !1;
    }
    return !0;
  }, e.isLociEmpty = function(o) {
    return t(o) === 0;
  }, e.size = t;
  var r = new K1(), n = w.zero();
  function i(o, u, s, c) {
    for (var l = u.indices, d = u.offsets, f = function(g, h) {
      Le.forEach(g, function(y) {
        for (var x = d[y], A = d[y + 1]; x < A; ++x) w.fromArray(n, s, 3 * l[x]), w.transformMat4(n, n, c[h]), r.includeStep(n);
      });
    }, m = 0, v = o; m < v.length; m++) {
      var p = v[m];
      f(p.ids, p.instance);
    }
  }
  function a(o, u, s, c) {
    for (var l = u.indices, d = u.offsets, f = function(g, h) {
      Le.forEach(g, function(y) {
        for (var x = d[y], A = d[y + 1]; x < A; ++x) w.fromArray(n, s, 3 * l[x]), w.transformMat4(n, n, c[h]), r.radiusStep(n);
      });
    }, m = 0, v = o; m < v.length; m++) {
      var p = v[m];
      f(p.ids, p.instance);
    }
  }
  e.getBoundingSphere = function(o, u) {
    u || (u = Me()), r.reset();
    var s = 0, c = o.shape, l = c.geometry, d = c.transforms;
    if (l.kind === "mesh" || l.kind === "points") {
      var f = l.kind === "mesh" ? l.vertexBuffer.ref.value : l.centerBuffer.ref.value;
      i(o.groups, l.groupMapping, f, d), r.finishedIncludeStep(), a(o.groups, l.groupMapping, f, d);
    } else if (l.kind === "lines") {
      var m = l.startBuffer.ref.value, v = l.endBuffer.ref.value;
      i(o.groups, l.groupMapping, m, d), i(o.groups, l.groupMapping, v, d), r.finishedIncludeStep(), a(o.groups, l.groupMapping, m, d), a(o.groups, l.groupMapping, v, d);
    } else {
      if (l.kind !== "spheres" && l.kind !== "text") return Me.copy(u, l.boundingSphere);
      f = l.centerBuffer.ref.value, i(o.groups, l.groupMapping, f, d), r.finishedIncludeStep(), a(o.groups, l.groupMapping, f, d);
      for (var p = function(x, A) {
        Le.forEach(x, function(b) {
          var _ = o.shape.getSize(b, A);
          s < _ && (s = _);
        });
      }, g = 0, h = o.groups; g < h.length; g++) {
        var y = h[g];
        p(y.ids, y.instance);
      }
    }
    return w.copy(u.center, r.center), u.radius = Math.sqrt(r.radiusSq), Me.expand(u, u, s), u;
  };
}(Za || (Za = {}));
var oW = 1, uW = "Assigns sizes as defined by the shape object.", OS = {};
function M_(e, t) {
  return { factory: M_, granularity: "groupInstance", size: function(r) {
    return Za.isLocation(r) ? r.shape.getSize(r.group, r.instance) : oW;
  }, props: t, description: uW };
}
var sW = { name: "shape-group", label: "Shape Group", category: "", factory: M_, getParams: function(e) {
  return OS;
}, defaultValues: G.getDefaultValues(OS), isApplicable: function(e) {
  return !!e.shape;
} }, LS = { bfactorFactor: G.Numeric(0.1, { min: 0, max: 1, step: 0.01 }), rmsfFactor: G.Numeric(0.05, { min: 0, max: 1, step: 0.01 }), baseSize: G.Numeric(0.2, { min: 0, max: 2, step: 0.1 }) };
function kS(e, t, r) {
  return Be.isAtomic(e) ? e.model.atomicConformation.B_iso_or_equiv.value(t) * r.bfactorFactor : Be.isSpheres(e) ? e.model.coarseConformation.spheres.rmsf[t] * r.rmsfFactor : 0;
}
var cW = { name: "uncertainty", label: "Uncertainty/Disorder", category: "", factory: function e(t, r) {
  return { factory: e, granularity: "group", size: function(n) {
    var i = r.baseSize;
    return at.is(n) ? i += kS(n.unit, n.element, r) : Dt.isLocation(n) && (i += kS(n.aUnit, n.aUnit.elements[n.aIndex], r)), i;
  }, props: r, description: "Assigns a size reflecting the uncertainty or disorder of an element's position, e.g. B-factor or RMSF, depending on the data availability and experimental technique." };
}, getParams: function(e) {
  return LS;
}, defaultValues: G.getDefaultValues(LS), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return t.atomicConformation.B_iso_or_equiv.isDefined || t.coarseHierarchy.isDefined;
  });
} }, zS = { hydrogenSize: G.Numeric(0.2, { min: 0, max: 10, step: 0.1 }), oxygenSize: G.Numeric(0.2, { min: 0, max: 10, step: 0.1 }), baseSize: G.Numeric(0.2, { min: 0, max: 2, step: 0.1 }) }, eo, Bu, lW = { name: "aquasite", label: "Aquasite", category: "", factory: function e(t, r) {
  return { factory: e, granularity: "group", size: function(n) {
    var i = r.baseSize;
    return at.is(n) && (i += function(a, o, u) {
      if (Be.isAtomic(a)) {
        var s = a.model.atomicHierarchy.atoms.type_symbol.value(o).toUpperCase();
        return s === "H" ? u.hydrogenSize : s === "O" ? u.oxygenSize : 0;
      }
      return 0;
    }(n.unit, n.element, r)), i;
  }, props: r, description: "Aquasite" };
}, getParams: function(e) {
  return zS;
}, defaultValues: G.getDefaultValues(zS), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return t.atomicConformation.B_iso_or_equiv.isDefined || t.coarseHierarchy.isDefined;
  });
} };
function GS(e) {
  return e.map(function(t) {
    return [t.name, t.provider.label, t.provider.category];
  });
}
(function(e) {
  e.EmptyFactory = function() {
    return e.Empty;
  }, e.Empty = { factory: e.EmptyFactory, granularity: "uniform", size: function() {
    return 1;
  }, props: {} }, e.areEqual = function(t, r) {
    return t.factory === r.factory && td(t.props, r.props);
  }, e.EmptyProvider = { name: "", label: "", category: "", factory: e.EmptyFactory, getParams: function() {
    return {};
  }, defaultValues: {}, isApplicable: function() {
    return !0;
  } }, e.createRegistry = function() {
    return new UT(e.BuiltIn, e.EmptyProvider);
  }, e.BuiltIn = { physical: bY, "shape-group": sW, uncertainty: cW, uniform: yY, aquasite: lW };
})(eo || (eo = {})), function(e) {
  function t() {
    return { color: Bc.Empty, size: eo.Empty };
  }
  e.create = function(r, n, i, a) {
    a = a || t();
    var o = i.colorTheme, u = i.sizeTheme;
    return a.color = r.colorThemeRegistry.create(o.name, n, o.params), a.size = r.sizeThemeRegistry.create(u.name, n, u.params), a;
  }, e.createEmpty = t, e.ensureDependencies = function(r, n, i, a) {
    var o, u;
    return _e(this, 0, void 0, function() {
      return ye(this, function(s) {
        switch (s.label) {
          case 0:
            return [4, (o = n.colorThemeRegistry.get(a.colorTheme.name).ensureCustomProperties) === null || o === void 0 ? void 0 : o.attach(r, i)];
          case 1:
            return s.sent(), [4, (u = n.sizeThemeRegistry.get(a.sizeTheme.name).ensureCustomProperties) === null || u === void 0 ? void 0 : u.attach(r, i)];
          case 2:
            return s.sent(), [2];
        }
      });
    });
  }, e.releaseDependencies = function(r, n, i) {
    var a, o;
    (a = r.colorThemeRegistry.get(i.colorTheme.name).ensureCustomProperties) === null || a === void 0 || a.detach(n), (o = r.sizeThemeRegistry.get(i.sizeTheme.name).ensureCustomProperties) === null || o === void 0 || o.detach(n);
  };
}(Bu || (Bu = {}));
var UT = function() {
  function e(t, r) {
    var n = this;
    this.emptyProvider = r, this._list = [], this._map = /* @__PURE__ */ new Map(), this._name = /* @__PURE__ */ new Map(), eM(t, function(i, a) {
      if (i.name !== a) throw new Error("Fix build in themes to have matching names. ".concat(i.name, " ").concat(a));
      n.add(i);
    });
  }
  return Object.defineProperty(e.prototype, "default", { get: function() {
    return this._list[0];
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "list", { get: function() {
    return this._list;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "types", { get: function() {
    return GS(this._list);
  }, enumerable: !1, configurable: !0 }), e.prototype.sort = function() {
    this._list.sort(function(t, r) {
      return t.provider.category === r.provider.category ? t.provider.label < r.provider.label ? -1 : t.provider.label > r.provider.label ? 1 : 0 : t.provider.category < r.provider.category ? -1 : 1;
    });
  }, e.prototype.add = function(t) {
    if (this._map.has(t.name)) throw new Error("".concat(t.name, " already registered."));
    var r = t.name;
    this._list.push({ name: r, provider: t }), this._map.set(r, t), this._name.set(t, r), this.sort();
  }, e.prototype.remove = function(t) {
    this._list.splice(this._list.findIndex(function(n) {
      return n.name === t.name;
    }), 1);
    var r = this._map.get(t.name);
    r && (this._map.delete(t.name), this._name.delete(r));
  }, e.prototype.has = function(t) {
    return this._map.has(t.name);
  }, e.prototype.get = function(t) {
    return this._map.get(t) || this.emptyProvider;
  }, e.prototype.getName = function(t) {
    if (!this._name.has(t)) throw new Error("'".concat(t.label, "' is not a registered theme provider."));
    return this._name.get(t);
  }, e.prototype.create = function(t, r, n) {
    n === void 0 && (n = {});
    var i = this.get(t);
    return i.factory(r, R(R({}, G.getDefaultValues(i.getParams(r))), n));
  }, e.prototype.getApplicableList = function(t) {
    return this._list.filter(function(r) {
      return r.provider.isApplicable(t);
    });
  }, e.prototype.getApplicableTypes = function(t) {
    return GS(this.getApplicableList(t));
  }, e;
}(), HT = { hue: G.Interval([1, 360], { min: 0, max: 360, step: 1 }), chroma: G.Interval([40, 70], { min: 0, max: 100, step: 1 }), luminance: G.Interval([15, 85], { min: 0, max: 100, step: 1 }), clusteringStepCount: G.Numeric(50, { min: 10, max: 200, step: 1 }, { isHidden: !0 }), minSampleCount: G.Numeric(800, { min: 100, max: 5e3, step: 100 }, { isHidden: !0 }) };
function VS(e, t) {
  return Math.sqrt(Math.pow(Math.abs(e[0] - t[0]), 2) + Math.pow(Math.abs(e[1] - t[1]), 2) + Math.pow(Math.abs(e[2] - t[2]), 2));
}
var i1 = 2, Ed = [0, 0, 0], Md = [0, 0, 0];
function dW(e, t) {
  return Ji.toHcl(Ed, e), Ji.fromColor(Md, Ji.toColor(e)), Ed[0] >= t.hue[0] && Ed[0] <= t.hue[1] && Ed[1] >= t.chroma[0] && Ed[1] <= t.chroma[1] && Ed[2] >= t.luminance[0] && Ed[2] <= t.luminance[1] && Md[0] >= e[0] - i1 && Md[0] <= e[0] + i1 && Md[1] >= e[1] - i1 && Md[1] <= e[1] + i1 && Md[2] >= e[2] - i1 && Md[2] <= e[2] + i1;
}
function fW(e, t) {
  t === void 0 && (t = {});
  var r = R(R({}, G.getDefaultValues(HT)), t);
  if (e <= 0) return [];
  var n = function(M, F) {
    for (var P = /* @__PURE__ */ new Map(), E = 1.001 * Math.cbrt(M), B = (F.hue[1] - F.hue[0]) / E, N = (F.chroma[1] - F.chroma[0]) / E, O = (F.luminance[1] - F.luminance[0]) / E, z = F.hue[0]; z <= F.hue[1]; z += B) for (var V = F.chroma[0]; V <= F.chroma[1]; V += N) for (var U = F.luminance[0]; U <= F.luminance[1]; U += O) {
      var H = Ji.fromHcl(Ji(), _s.create(z, V, U));
      dW(H, F) && P.set(H.toString(), H);
    }
    return Array.from(P.values());
  }(Math.max(r.minSampleCount, 5 * e), r);
  if (n.length < e) throw new Error("Not enough samples to generate distinct colors, increase sample count.");
  for (var i = [], a = [], o = Math.floor(n.length / e), u = 0; u < n.length && (i.push(n[u]), a.push([]), !(i.length >= e)); u += o) ;
  for (var s = 1; s <= r.clusteringStepCount; ++s) {
    var c = Tc(a);
    for (u = 0; u < n.length; ++u) {
      for (var l = Number.MAX_SAFE_INTEGER, d = 0, f = 0; f < i.length; f++) {
        var m = VS(n[u], i[f]);
        m < l && (l = m, d = f);
      }
      c[d].push(n[u]);
    }
    var v = Tc(i);
    for (u = 0; u < c.length; ++u) {
      for (var p = c[u], g = p.length, h = [], y = [], x = [], A = 0, b = p; A < b.length; A++) {
        var _ = b[A];
        h.push(_[0]), y.push(_[1]), x.push(_[2]);
      }
      var S = Zv(h) / g, D = Zv(y) / g, I = Zv(x) / g;
      i[u] = [S, D, I];
    }
    if (td(v, i)) break;
  }
  return function(M) {
    for (var F = M.slice(0), P = [F.shift()]; F.length > 0; ) {
      for (var E = P[P.length - 1], B = 0, N = Number.MIN_SAFE_INTEGER, O = 0; O < F.length; ++O) {
        var z = VS(E, F[O]);
        z > N && (N = z, B = O);
      }
      P.push(F.splice(B, 1)[0]);
    }
    return P;
  }(i).map(function(M) {
    return Ji.toColor(M);
  });
}
var qT = { type: "generate", colorList: "red-yellow-blue" };
function Qo(e) {
  e === void 0 && (e = {});
  var t = R(R({}, qT), e);
  return { palette: G.MappedStatic(t.type, { colors: G.Group({ list: G.ColorList(t.colorList) }, { isFlat: !0 }), generate: G.Group(R(R({}, HT), { maxCount: G.Numeric(75, { min: 1, max: 250, step: 1 }) }), { isFlat: !0 }) }, { options: [["colors", "Color List"], ["generate", "Generate Distinct"]] }) };
}
G.getDefaultValues(Qo());
var US = { valueLabel: function(e) {
  return "".concat(e + 1);
}, minLabel: "Start", maxLabel: "End" };
function as(e, t, r) {
  var n, i, a;
  if (r === void 0 && (r = {}), t.palette.name === "colors" && t.palette.params.list.kind === "interpolate") {
    var o = t.palette.params.list, u = [0, e - 1], s = R(R({}, US), r), c = s.minLabel, l = s.maxLabel, d = o.colors;
    d.length === 0 && (d = Ec(qT.colorList).list);
    var f = Bs.create({ listOrName: d, domain: u, minLabel: c, maxLabel: l });
    a = f.legend, i = f.color;
  } else {
    var m;
    t.palette.name === "colors" ? (m = t.palette.params.list.colors.map(function(x) {
      return Array.isArray(x) ? x[0] : x;
    }), m.length === 0 && (m = Ec("dark-2").list.map(function(x) {
      return Array.isArray(x) ? x[0] : x;
    }))) : (e = Math.min(e, t.palette.params.maxCount), m = fW(e, t.palette.params));
    for (var v = (n = r.valueLabel) !== null && n !== void 0 ? n : US.valueLabel, p = m.length, g = [], h = 0; h < e; ++h) {
      var y = h % p;
      g[y] === void 0 ? g[y] = [v(h), m[y]] : g[y][0] += ", ".concat(v(h));
    }
    a = is(g), i = function(x) {
      return m[x % p];
    };
  }
  return { color: i, legend: a };
}
var HS = He(16448250), pW = "Gives every chain a color based on its `asym_id` value.", gf = R({ asymId: G.Select("auth", G.arrayToOptions(["auth", "label"])) }, Qo({ type: "colors", colorList: "many-distinct" }));
function qS(e, t) {
  var r = function(n, i) {
    switch (n.kind) {
      case 0:
        return i === "auth" ? Qe.chain.auth_asym_id : Qe.chain.label_asym_id;
      case 1:
      case 2:
        return Qe.coarse.asym_id;
    }
  }(e.unit, t)(e);
  return e.structure.root.models.length > 1 ? KT(e.unit.model, r) : r;
}
function KT(e, t) {
  return "".concat(t, "|").concat((nn.Index.get(e).value || 0) + 1);
}
function Ng(e, t) {
  var r, n;
  if (e.structure) {
    var i = at.create(e.structure.root), a = function(s, c) {
      for (var l = /* @__PURE__ */ new Map(), d = function(v) {
        var p = nn.AsymIdOffset.get(v).value, g = (c === "auth" ? p == null ? void 0 : p.auth : p == null ? void 0 : p.label) || 0, h = 0;
        v.properties.structAsymMap.forEach(function(y, x) {
          var A = y.auth_id, b = c === "auth" ? A : x, _ = s.models.length > 1 ? KT(v, b) : b;
          l.has(_) || (l.set(_, h + g), ++h);
        });
      }, f = 0, m = s.models; f < m.length; f++) d(m[f]);
      return l;
    }(e.structure.root, t.asymId), o = Array.from(a.keys()), u = as(a.size, t, { valueLabel: function(s) {
      return o[s];
    } });
    n = u.legend, r = function(s) {
      var c = void 0;
      if (at.is(s)) {
        var l = qS(s, t.asymId);
        c = a.get(l);
      } else Dt.isLocation(s) && (i.unit = s.aUnit, i.element = s.aUnit.elements[s.aIndex], l = qS(i, t.asymId), c = a.get(l));
      return c === void 0 ? HS : u.color(c);
    };
  } else r = function() {
    return HS;
  };
  return { factory: Ng, granularity: "group", color: r, props: t, description: pW, legend: n };
}
var mW = { name: "chain-id", label: "Chain Id", category: "Chain Property", factory: Ng, getParams: function(e) {
  var t, r = G.clone(gf);
  return !((t = e.structure) === null || t === void 0) && t.models.some(function(n) {
    return n.coarseHierarchy.isDefined;
  }) && (r.asymId.defaultValue = "label"), r;
}, defaultValues: G.getDefaultValues(gf), isApplicable: function(e) {
  return !!e.structure;
} }, KS = He(13421772), XS = R({}, Qo({ type: "colors", colorList: "red-yellow-blue" })), hW = { name: "element-index", label: "Element Index", category: "Atom Property", factory: function e(t, r) {
  var n, i;
  if (t.structure) {
    for (var a = t.structure.root.units, o = a.length, u = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = 0, l = 0; l < o; ++l) u.set(l, c), c += a[l].elements.length, s.set(a[l].id, l);
    var d = as(c, r);
    i = d.legend, n = function(f) {
      if (at.is(f)) {
        var m = s.get(f.unit.id), v = Le.findPredecessorIndex(a[m].elements, f.element);
        return d.color(u.get(m) + v);
      }
      return Dt.isLocation(f) ? (m = s.get(f.aUnit.id), v = Le.findPredecessorIndex(a[m].elements, f.aUnit.elements[f.aIndex]), d.color(u.get(m) + v)) : KS;
    };
  } else n = function() {
    return KS;
  };
  return { factory: e, granularity: "groupInstance", preferSmoothing: !0, color: n, props: r, description: "Gives every element (atom or coarse sphere/gaussian) a unique color based on the position (index) of the element in the list of elements in the structure.", legend: i };
}, getParams: function(e) {
  return XS;
}, defaultValues: G.getDefaultValues(XS), isApplicable: function(e) {
  return !!e.structure;
} };
function A0(e) {
  var t = {};
  return eM(e, function(r, n) {
    t[n] = G.Color(e[n]);
  }), t;
}
var jS = He(13421772), vW = "Assigns a color based on the operator name of a transformed chain.", J1 = R({}, Qo({ type: "colors", colorList: "many-distinct" }));
function T_(e, t) {
  var r, n;
  if (e.structure) {
    var i = function(u) {
      for (var s = /* @__PURE__ */ new Map(), c = 0, l = u.units.length; c < l; ++c) {
        var d = u.units[c].conformation.operator.name;
        s.has(d) || s.set(d, s.size);
      }
      return s;
    }(e.structure.root), a = Array.from(i.keys()), o = as(i.size, t, { valueLabel: function(u) {
      return a[u];
    } });
    n = o.legend, r = function(u) {
      var s = void 0;
      if (at.is(u)) {
        var c = u.unit.conformation.operator.name;
        s = i.get(c);
      } else if (Dt.isLocation(u)) {
        var l = u.aUnit.conformation.operator.name;
        s = i.get(l);
      }
      return s === void 0 ? jS : o.color(s);
    };
  } else r = function() {
    return jS;
  };
  return { factory: T_, granularity: "instance", color: r, props: t, description: vW, legend: n };
}
var gW = { name: "operator-name", label: "Operator Name", category: "Symmetry", factory: T_, getParams: function(e) {
  return G.clone(J1);
}, defaultValues: G.getDefaultValues(J1), isApplicable: function(e) {
  return !!e.structure;
} }, YS = He(16448250), yW = "Gives every chain a color based on its `label_entity_id` value.", $1 = R({}, Qo({ type: "colors", colorList: "many-distinct" }));
function Q0(e, t) {
  return "".concat(e, "|").concat(t);
}
function WS(e) {
  switch (e.unit.kind) {
    case 0:
      return Qe.chain.label_entity_id(e);
    case 1:
    case 2:
      return Qe.coarse.entity_id(e);
  }
}
function Rg(e, t) {
  var r, n;
  if (e.structure) {
    var i = at.create(e.structure.root), a = function(s) {
      for (var c = /* @__PURE__ */ new Map(), l = 0, d = s.models.length; l < d; ++l) {
        for (var f = s.models[l].atomicHierarchy.chains.label_entity_id, m = 0, v = f.rowCount; m < v; ++m) {
          var p = Q0(f.value(m), l);
          c.has(p) || c.set(p, c.size);
        }
        var g = s.models[l].coarseHierarchy;
        if (g.isDefined) {
          var h = g.spheres.entity_id;
          for (m = 0, v = h.rowCount; m < v; ++m) p = Q0(h.value(m), l), c.has(p) || c.set(p, c.size);
          var y = g.gaussians.entity_id;
          for (m = 0, v = y.rowCount; m < v; ++m) p = Q0(y.value(m), l), c.has(p) || c.set(p, c.size);
        }
      }
      return c;
    }(e.structure.root), o = Array.from(a.keys()), u = as(a.size, t, { valueLabel: function(s) {
      return o[s];
    } });
    n = u.legend, r = function(s) {
      var c = void 0;
      if (at.is(s)) {
        var l = Q0(WS(s), s.structure.models.indexOf(s.unit.model));
        c = a.get(l);
      } else Dt.isLocation(s) && (i.unit = s.aUnit, i.element = s.aUnit.elements[s.aIndex], l = Q0(WS(i), i.structure.models.indexOf(i.unit.model)), c = a.get(l));
      return c === void 0 ? YS : u.color(c);
    };
  } else r = function() {
    return YS;
  };
  return { factory: Rg, granularity: "group", color: r, props: t, description: yW, legend: n };
}
var bW = { name: "entity-id", label: "Entity Id", category: "Chain Property", factory: Rg, getParams: function(e) {
  return G.clone($1);
}, defaultValues: G.getDefaultValues($1), isApplicable: function(e) {
  return !!e.structure;
} }, Fb = "dark-2", iv = He(16448250), _W = "Gives ranges of a polymer chain a color based on the entity source it originates from (e.g. gene, plasmid, organism).", e0 = R({}, Qo({ type: "colors", colorList: Fb }));
function XT(e, t) {
  return "".concat(e, "|").concat(t);
}
function xW(e, t, r, n, i, a) {
  return "".concat(e, "|").concat(t, "|").concat(r, "|").concat(a || i || n);
}
function x4(e, t, r, n, i, a, o, u) {
  for (var s = i.entity_id, c = i.pdbx_src_id, l = i.pdbx_beg_seq_num, d = i.pdbx_end_seq_num, f = 0, m = i._rowCount; f < m; ++f) {
    var v = s.value(f), p = XT(r, v), g = void 0;
    if (e.has(p)) g = e.get(p);
    else {
      var h = n.entities.getEntityIndex(v), y = n.sequence.sequences[h].sequence;
      g = new Int16Array(y.length), e.set(p, g);
    }
    var x = o ? o.value(f) : "", A = u ? u.value(f)[0] : "", b = xW(r, v, a.value(f), c.value(f), x, A), _ = l.valueKind(f) === 0 ? l.value(f) : 1, S = d.valueKind(f) === 0 ? d.value(f) : g.length, D = void 0;
    t.has(b) ? D = t.get(b) : (D = t.size + 1, t.set(b, D));
    for (var I = _, M = S; I <= M; ++I) g[I - 1] = D;
  }
}
function jT(e) {
  for (var t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), n = 0, i = e.length; n < i; ++n) {
    var a = e[n];
    if (mn.is(a.sourceData)) {
      var o = a.sourceData.data.db, u = o.entity_src_gen, s = o.entity_src_nat, c = o.pdbx_entity_src_syn;
      x4(t, r, n, a, u, u.pdbx_gene_src_scientific_name, u.plasmid_name, u.pdbx_gene_src_gene), x4(t, r, n, a, s, s.pdbx_organism_scientific, s.pdbx_plasmid_name), x4(t, r, n, a, c, c.organism_scientific);
    }
  }
  return { seqToSrcByModelEntity: t, srcKeySerialMap: r };
}
function AW(e) {
  var t = 0;
  return Array.from(e.keys()).map(function(r) {
    var n = r.split("|"), i = n[2], a = function(o) {
      o = o.trim();
      var u = parseInt(o, 10);
      return !isNaN(u) && u.toString() === o;
    }(n[3]) ? "Unnamed ".concat(++t) : n[3];
    return "".concat(a).concat(i ? " (".concat(i, ")") : "");
  });
}
function Og(e, t) {
  var r, n;
  if (e.structure) {
    var i = at.create(e.structure), a = e.structure.root.models, o = jT(a), u = o.seqToSrcByModelEntity, s = o.srcKeySerialMap, c = AW(s), l = as(s.size, t, { valueLabel: function(f) {
      return c[f];
    } });
    n = l.legend;
    var d = function(f) {
      var m = XT(a.indexOf(f.unit.model), Qe.entity.id(f)), v = u.get(m);
      if (v) {
        var p = v[Qe.residue.label_seq_id(f) - 1] - 1;
        return p === -1 ? iv : l.color(p);
      }
      return iv;
    };
    r = function(f) {
      return at.is(f) ? d(f) : Dt.isLocation(f) ? (i.unit = f.aUnit, i.element = f.aUnit.elements[f.aIndex], d(i)) : iv;
    };
  } else r = function() {
    return iv;
  };
  return { factory: Og, granularity: "group", color: r, props: t, description: _W, legend: n };
}
var SW = { name: "entity-source", label: "Entity Source", category: "Chain Property", factory: Og, getParams: function(e) {
  var t = G.clone(e0);
  return e.structure && jT(e.structure.root.models).srcKeySerialMap.size > bo[Fb].list.length && (t.palette.defaultValue.name = "colors", t.palette.defaultValue.params = R(R({}, t.palette.defaultValue.params), { list: { kind: "interpolate", colors: Ec(Fb).list } })), t;
}, defaultValues: G.getDefaultValues(e0), isApplicable: function(e) {
  return !!e.structure;
} }, YT = { H: 13817304, D: 16777152, T: 16777120, HE: 14286847, LI: 13402367, BE: 12779264, B: 16758197, C: 9474192, N: 7370475, O: 15425118, F: 2543814, NE: 11789301, NA: 11230450, MG: 9109248, AL: 12560038, SI: 1578e4, P: 15654476, S: 15771392, CL: 1286709, AR: 8442339, K: 9388244, CA: 4062976, SC: 15132390, TI: 12567239, V: 10921643, CR: 9083335, MN: 10255047, FE: 14706227, CO: 15765664, NI: 5296208, CU: 13140019, ZN: 8224944, GA: 12750735, GE: 6721423, AS: 12419299, SE: 16752896, BR: 8860212, KR: 6076625, RB: 7351984, SR: 65280, Y: 9764863, ZR: 9756896, NB: 7586505, MO: 5551541, TC: 3907230, RU: 2396047, RH: 687500, PD: 27013, AG: 12632256, CD: 16767375, IN: 10909043, SN: 6717568, SB: 10380213, TE: 13924864, I: 9699476, XE: 9699476, CS: 5707663, BA: 51456, LA: 7394559, CE: 16777159, PR: 14286791, ND: 13107143, PM: 10747847, SM: 9437127, EU: 6422471, GD: 4587463, TB: 3211207, DY: 2097095, HO: 65436, ER: 58997, TM: 54354, YB: 48952, LU: 43812, HF: 5096191, TA: 5089023, W: 2200790, RE: 2522539, OS: 2516630, IR: 1528967, PT: 13684960, AU: 16765219, HG: 12105936, TL: 10900557, PB: 5724513, BI: 10375093, PO: 11230208, AT: 7688005, RN: 4358806, FR: 4325478, RA: 32e3, AC: 7384058, TH: 47871, PA: 41471, U: 36863, NP: 33023, PU: 27647, AM: 5528818, CM: 7888099, BK: 9064419, CF: 10565332, ES: 11739092, FM: 11739066, MD: 11734438, NO: 12389767, LR: 13041766, RF: 13369433, DB: 13697103, SG: 14221381, BH: 14680120, HS: 15073326, MT: 15400998, DS: 16777215, RG: 16777215, CN: 16777215, UUT: 16777215, FL: 16777215, UUP: 16777215, LV: 16777215, UUH: 16777215 }, WT = He(16777215), ZT = { carbonColor: G.MappedStatic("chain-id", { "chain-id": G.Group(gf), "entity-id": G.Group($1), "entity-source": G.Group(e0), "operator-name": G.Group(J1), "element-symbol": G.EmptyGroup(), uniform: G.Group(N2) }, { description: "Use chain-id coloring for carbon atoms." }), saturation: G.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: G.Numeric(0.2, { min: -6, max: 6, step: 0.1 }), colors: G.MappedStatic("default", { default: G.EmptyGroup(), custom: G.Group(A0(YT)) }) };
function CW(e) {
  return ZT;
}
function wW(e, t) {
  var r = e[t];
  return r === void 0 ? WT : r;
}
function QT(e, t) {
  var r = xf(t.colors.name === "default" ? YT : t.colors.params, t.saturation, t.lightness), n = t.carbonColor, i = n.name === "chain-id" ? Ng(e, n.params).color : n.name === "entity-id" ? Rg(e, n.params).color : n.name === "entity-source" ? Og(e, n.params).color : n.name === "operator-name" ? T_(e, n.params).color : n.name === "element-symbol" ? void 0 : n.name === "uniform" ? Em(0, n.params).color : Hi();
  function a(o, u) {
    return i && o === "C" ? i(u, !1) : wW(r, o);
  }
  return { factory: QT, granularity: t.carbonColor.name === "operator-name" ? "groupInstance" : "group", preferSmoothing: !0, color: function(o) {
    if (at.is(o)) {
      if (Be.isAtomic(o.unit)) return a(o.unit.model.atomicHierarchy.atoms.type_symbol.value(o.element), o);
    } else if (Dt.isLocation(o) && Be.isAtomic(o.aUnit))
      return a(o.aUnit.model.atomicHierarchy.atoms.type_symbol.value(o.aUnit.elements[o.aIndex]), o);
    return WT;
  }, props: t, description: "Assigns a color to every atom according to its chemical element.", legend: is(Object.keys(r).map(function(o) {
    return [o, r[o]];
  })) };
}
var DW = { name: "element-symbol", label: "Element Symbol", category: "Atom Property", factory: QT, getParams: CW, defaultValues: G.getDefaultValues(ZT), isApplicable: function(e) {
  return !!e.structure;
} }, JT = { water: 3697840, ion: 15729279, protein: 12496596, RNA: 16629894, DNA: 12540695, PNA: 4367514, saccharide: 8374655 }, Nb = He(16777113), IW = "Assigns a color based on the molecule type of a residue.", Rb = { saturation: G.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: G.Numeric(0, { min: -6, max: 6, step: 0.1 }), colors: G.MappedStatic("default", { default: G.EmptyGroup(), custom: G.Group(A0(JT)) }) };
function ZS(e, t, r) {
  switch ($M(t, r)) {
    case 2:
      return e.water;
    case 3:
      return e.ion;
    case 5:
      return e.protein;
    case 6:
      return e.RNA;
    case 7:
      return e.DNA;
    case 8:
      return e.PNA;
    case 9:
      return e.saccharide;
  }
  return Nb;
}
function P_(e, t) {
  var r = xf(t.colors.name === "default" ? JT : t.colors.params, t.saturation, t.lightness);
  return { factory: P_, granularity: "group", color: function(n) {
    return at.is(n) ? ZS(r, n.unit, n.element) : Dt.isLocation(n) ? ZS(r, n.aUnit, n.aUnit.elements[n.aIndex]) : Nb;
  }, props: t, description: IW, legend: is(Object.keys(r).map(function(n) {
    return [n, r[n]];
  }).concat([["Other/unknown", Nb]])) };
}
var EW = { name: "molecule-type", label: "Molecule Type", category: "Residue Property", factory: P_, getParams: function(e) {
  return Rb;
}, defaultValues: G.getDefaultValues(Rb), isApplicable: function(e) {
  return !!e.structure;
} }, Ob = "dark-2", QS = He(16448250), JS = R({}, Qo({ type: "colors", colorList: Ob }));
function $S(e) {
  switch (e.kind) {
    case 0:
      return Qe.chain.label_asym_id;
    case 1:
    case 2:
      return Qe.coarse.asym_id;
  }
}
function eC(e) {
  for (var t = /* @__PURE__ */ new Map(), r = 0, n = e.unitSymmetryGroups.length; r < n; ++r) {
    var i = e.unitSymmetryGroups[r].units[0], a = i.model;
    if (Be.isAtomic(i)) for (var o = a.atomicHierarchy, u = o.chainAtomSegments, s = o.chains, c = Zt.transientSegments(u, i.elements); c.hasNext; ) {
      var l = c.move().index, d = s.label_entity_id.value(l), f = a.entities.getEntityIndex(d);
      if (a.entities.data.type.value(f) === "polymer") {
        var m = s.label_asym_id.value(l);
        t.has(m) || t.set(m, t.size);
      }
    }
    else if (Be.isCoarse(i)) {
      var v = Be.isSpheres(i) ? a.coarseHierarchy.spheres : a.coarseHierarchy.gaussians, p = v.chainElementSegments, g = v.asym_id, h = v.entity_id;
      for (c = Zt.transientSegments(p, i.elements); c.hasNext; ) {
        l = c.move().index;
        var y = p.offsets[l];
        d = h.value(y), f = a.entities.getEntityIndex(d), a.entities.data.type.value(f) === "polymer" && (m = g.value(y), t.has(m) || t.set(m, t.size));
      }
    }
  }
  return t;
}
var MW = { name: "polymer-id", label: "Polymer Chain Id", category: "Chain Property", factory: function e(t, r) {
  var n, i;
  if (t.structure) {
    var a = at.create(t.structure), o = eC(t.structure.root), u = Array.from(o.keys()), s = as(o.size, r, { valueLabel: function(c) {
      return u[c];
    } });
    i = s.legend, n = function(c) {
      var l = void 0;
      if (at.is(c)) {
        var d = $S(c.unit);
        l = o.get(d(c));
      } else Dt.isLocation(c) && (d = $S(c.aUnit), a.unit = c.aUnit, a.element = c.aUnit.elements[c.aIndex], l = o.get(d(a)));
      return l === void 0 ? QS : s.color(l);
    };
  } else n = function() {
    return QS;
  };
  return { factory: e, granularity: "group", color: n, props: r, description: "Gives every polymer chain a color based on its `asym_id` value.", legend: i };
}, getParams: function(e) {
  var t = G.clone(JS);
  return e.structure && eC(e.structure.root).size > bo[Ob].list.length && (t.palette.defaultValue.name = "colors", t.palette.defaultValue.params = R(R({}, t.palette.defaultValue.params), { list: { kind: "interpolate", colors: Ec(Ob).list } })), t;
}, defaultValues: G.getDefaultValues(JS), isApplicable: function(e) {
  return !!e.structure;
} }, Lb = "dark-2", tC = He(13421772), rC = R({}, Qo({ type: "colors", colorList: Lb }));
function nC(e) {
  for (var t = 0, r = e.units, n = 0, i = r.length; n < i; ++n) r[n].polymerElements.length > 0 && ++t;
  return t;
}
var TW = { name: "polymer-index", label: "Polymer Chain Instance", category: "Chain Property", factory: function e(t, r) {
  var n, i;
  if (t.structure) {
    var a = as(nC(t.structure.root), r);
    i = a.legend;
    for (var o = t.structure.root.units, u = /* @__PURE__ */ new Map(), s = 0, c = 0, l = o.length; s < l; ++s) o[s].polymerElements.length > 0 && (u.set(o[s].id, a.color(c)), ++c);
    n = function(d) {
      var f;
      return at.is(d) ? f = u.get(d.unit.id) : Dt.isLocation(d) && (f = u.get(d.aUnit.id)), f !== void 0 ? f : tC;
    };
  } else n = function() {
    return tC;
  };
  return { factory: e, granularity: "instance", color: n, props: r, description: "Gives every polymer chain instance a unique color based on the position (index) of the polymer in the list of polymers in the structure.", legend: i };
}, getParams: function(e) {
  var t = G.clone(rC);
  return e.structure && nC(e.structure.root) > bo[Lb].list.length && (t.palette.defaultValue.name = "colors", t.palette.defaultValue.params = R(R({}, t.palette.defaultValue.params), { list: { kind: "interpolate", colors: Ec(Lb).list } })), t;
}, defaultValues: G.getDefaultValues(rC), isApplicable: function(e) {
  return !!e.structure;
} }, $T = { ALA: 9240460, ARG: 124, ASN: 16743536, ASP: 10485826, CYS: 16777072, GLN: 16731212, GLU: 6684672, GLY: 15658734, HIS: 7368959, ILE: 19456, LEU: 4546117, LYS: 4671416, MET: 12099650, PHE: 5459026, PRO: 5395026, SER: 16740418, THR: 12078080, TRP: 5195264, TYR: 9203788, VAL: 16747775, A: 14423100, G: 3329330, I: 10145074, C: 16766720, T: 4286945, U: 4251856, DA: 14423100, DG: 3329330, DI: 10145074, DC: 16766720, DT: 4286945, DU: 4251856, APN: 14423100, GPN: 3329330, CPN: 16766720, TPN: 4286945, MOL: 0 }, kb = He(16711935), iC = { saturation: G.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: G.Numeric(1, { min: -6, max: 6, step: 0.1 }), colors: G.MappedStatic("default", { default: G.EmptyGroup(), custom: G.Group(A0($T)) }) };
function aC(e, t) {
  return e.model.atomicHierarchy.atoms.label_comp_id.value(t);
}
function oC(e, t) {
  var r = e.coarseElements.seq_id_begin.value(t);
  if (r === e.coarseElements.seq_id_end.value(t)) {
    var n = e.coarseElements.entityKey[t];
    return e.model.sequence.byEntityKey[n].sequence.compId.value(r - 1);
  }
}
function av(e, t) {
  var r = e[t];
  return r === void 0 ? kb : r;
}
var PW = { name: "residue-name", label: "Residue Name", category: "Residue Property", factory: function e(t, r) {
  var n = xf(r.colors.name === "default" ? $T : r.colors.params, r.saturation, r.lightness);
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(i) {
    if (at.is(i)) {
      if (Be.isAtomic(i.unit)) {
        var a = aC(i.unit, i.element);
        return av(n, a);
      }
      if (a = oC(i.unit, i.element)) return av(n, a);
    } else if (Dt.isLocation(i)) {
      if (Be.isAtomic(i.aUnit))
        return a = aC(i.aUnit, i.aUnit.elements[i.aIndex]), av(n, a);
      if (a = oC(i.aUnit, i.aUnit.elements[i.aIndex])) return av(n, a);
    }
    return kb;
  }, props: r, description: "Assigns a color to every residue according to its name.", legend: is(Object.keys(n).map(function(i) {
    return [i, n[i]];
  }).concat([["Unknown", kb]])) };
}, getParams: function(e) {
  return iC;
}, defaultValues: G.getDefaultValues(iC), isApplicable: function(e) {
  return !!e.structure;
} }, eP = { alphaHelix: 16711808, threeTenHelix: 10485888, piHelix: 6291584, betaTurn: 6324479, betaStrand: 16762880, coil: 16777215, bend: 6740169, turn: 45670, dna: 11403518, rna: 16580962, carbohydrate: 10921722 }, zb = He(8421504), uC = { saturation: G.Numeric(-1, { min: -6, max: 6, step: 0.1 }), lightness: G.Numeric(0, { min: -6, max: 6, step: 0.1 }), colors: G.MappedStatic("default", { default: G.EmptyGroup(), custom: G.Group(A0(eP)) }) };
function sC(e, t, r, n) {
  var i = yr.create(0);
  if (n && Be.isAtomic(t)) {
    var a = n.get(t.invariantId);
    a && (i = a.type[a.getIndex(t.residueIndex[r])]);
  }
  if (yr.is(i, 2)) return yr.is(i, 2048) ? e.threeTenHelix : yr.is(i, 32768) ? e.piHelix : e.alphaHelix;
  if (yr.is(i, 4)) return e.betaStrand;
  if (yr.is(i, 8)) return e.bend;
  if (yr.is(i, 16)) return e.turn;
  var o = $M(t, r);
  return o === 7 ? e.dna : o === 6 ? e.rna : o === 9 ? e.carbohydrate : o === 5 ? e.coil : zb;
}
var BW = { name: "secondary-structure", label: "Secondary Structure", category: "Residue Property", factory: function e(t, r) {
  var n = t.structure && Aa.get(t.structure), i = n ? h0(n.id, n.version) : -1, a = xf(r.colors.name === "default" ? eP : r.colors.params, r.saturation, r.lightness);
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(o) {
    return at.is(o) ? sC(a, o.unit, o.element, n == null ? void 0 : n.value) : Dt.isLocation(o) ? sC(a, o.aUnit, o.aUnit.elements[o.aIndex], n == null ? void 0 : n.value) : zb;
  }, props: r, contextHash: i, description: "Assigns a color based on the type of secondary structure and basic molecule type.", legend: is(Object.keys(a).map(function(o) {
    return [o, a[o]];
  }).concat([["Other", zb]])) };
}, getParams: function(e) {
  return uC;
}, defaultValues: G.getDefaultValues(uC), isApplicable: function(e) {
  return !!e.structure;
}, ensureCustomProperties: { attach: function(e, t) {
  return t.structure ? Aa.attach(e, t.structure, void 0, !0) : Promise.resolve();
}, detach: function(e) {
  return e.structure && Aa.ref(e.structure, !1);
} } }, FW = He(13421772), cC = { list: G.ColorList("turbo", { presetKind: "scale" }) };
function lC(e, t) {
  var r = e.model;
  switch (e.kind) {
    case 0:
      var n = r.atomicHierarchy.residueAtomSegments.index[t];
      return r.atomicHierarchy.residues.label_seq_id.value(n);
    case 1:
      return Math.round((r.coarseHierarchy.spheres.seq_id_begin.value(t) + r.coarseHierarchy.spheres.seq_id_end.value(t)) / 2);
    case 2:
      return Math.round((r.coarseHierarchy.gaussians.seq_id_begin.value(t) + r.coarseHierarchy.gaussians.seq_id_end.value(t)) / 2);
  }
}
function dC(e, t) {
  var r = e.model, n = "";
  switch (e.kind) {
    case 0:
      var i = r.atomicHierarchy.chainAtomSegments.index[t];
      n = r.atomicHierarchy.chains.label_entity_id.value(i);
      break;
    case 1:
      n = r.coarseHierarchy.spheres.entity_id.value(t);
      break;
    case 2:
      n = r.coarseHierarchy.gaussians.entity_id.value(t);
  }
  if (n === "") return 0;
  var a = r.entities.getEntityIndex(n);
  if (a === -1) return 0;
  var o = r.sequence.byEntityKey[a];
  return o === void 0 ? 0 : o.sequence.length;
}
var NW = { name: "sequence-id", label: "Sequence Id", category: "Residue Property", factory: function e(t, r) {
  var n = Bs.create({ listOrName: r.list.colors, minLabel: "Start", maxLabel: "End" });
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(i) {
    if (at.is(i)) {
      var a = i.unit, o = i.element;
      if ((u = lC(a, o)) > 0 && (s = dC(a, o))) return n.setDomain(0, s - 1), n.color(u);
    } else if (Dt.isLocation(i)) {
      var u, s, c = i.aUnit, l = i.aIndex;
      if ((u = lC(c, c.elements[l])) > 0 && (s = dC(c, c.elements[l]))) return n.setDomain(0, s - 1), n.color(u);
    }
    return FW;
  }, props: r, description: "Gives every polymer residue a color based on its `seq_id` value.", legend: n ? n.legend : void 0 };
}, getParams: function(e) {
  return cC;
}, defaultValues: G.getDefaultValues(cC), isApplicable: function(e) {
  return !!e.structure;
} }, Gb = "dark-2", fC = He(13421772), pC = R({}, Qo({ type: "colors", colorList: Gb })), RW = { name: "unit-index", label: "Chain Instance", category: "Chain Property", factory: function e(t, r) {
  var n, i;
  if (t.structure) {
    var a = t.structure.root.units, o = as(a.length, r);
    i = o.legend;
    for (var u = /* @__PURE__ */ new Map(), s = 0, c = a.length; s < c; ++s) u.set(a[s].id, o.color(s));
    n = function(l) {
      return at.is(l) ? u.get(l.unit.id) : Dt.isLocation(l) ? u.get(l.aUnit.id) : fC;
    };
  } else n = function() {
    return fC;
  };
  return { factory: e, granularity: "instance", color: n, props: r, description: "Gives every chain instance (single chain or collection of single elements) a unique color based on the position (index) of the chain in the list of chains in the structure.", legend: i };
}, getParams: function(e) {
  var t = G.clone(pC);
  return e.structure && e.structure.root.units.length > bo[Gb].list.length && (t.palette.defaultValue.name = "colors", t.palette.defaultValue.params = R(R({}, t.palette.defaultValue.params), { list: { kind: "interpolate", colors: Ec(Gb).list } })), t;
}, defaultValues: G.getDefaultValues(pC), isApplicable: function(e) {
  return !!e.structure;
} }, OW = He(16777113), mC = { domain: G.Interval([0, 100]), list: G.ColorList("red-white-blue", { presetKind: "scale" }) };
function hC(e, t) {
  return Be.isAtomic(e) ? e.model.atomicConformation.B_iso_or_equiv.value(t) : Be.isSpheres(e) ? e.model.coarseConformation.spheres.rmsf[t] : 0;
}
var LW = { name: "uncertainty", label: "Uncertainty/Disorder", category: "Atom Property", factory: function e(t, r) {
  var n = Bs.create({ reverse: !0, domain: r.domain, listOrName: r.list.colors });
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(i) {
    return at.is(i) ? n.color(hC(i.unit, i.element)) : Dt.isLocation(i) ? n.color(hC(i.aUnit, i.aUnit.elements[i.aIndex])) : OW;
  }, props: r, description: "Assigns a color based on the uncertainty or disorder of an element's position, e.g. B-factor or RMSF, depending on the data availability and experimental technique.", legend: n ? n.legend : void 0 };
}, getParams: function(e) {
  return mC;
}, defaultValues: G.getDefaultValues(mC), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return t.atomicConformation.B_iso_or_equiv.isDefined || t.coarseHierarchy.isDefined;
  });
} }, kW = He(15658734), vC = { style: G.MappedStatic("entity-id", { uniform: G.Group(N2), "chain-id": G.Group(gf), "entity-id": G.Group($1), "entity-source": G.Group(e0), "molecule-type": G.Group(Rb) }), carbonLightness: G.Numeric(0.8, { min: -6, max: 6, step: 0.1 }) }, zW = { name: "illustrative", label: "Illustrative", category: "Miscellaneous", factory: function e(t, r) {
  var n = r.style.name === "uniform" ? Em(0, r.style.params) : r.style.name === "chain-id" ? Ng(t, r.style.params) : r.style.name === "entity-id" ? Rg(t, r.style.params) : r.style.name === "entity-source" ? Og(t, r.style.params) : r.style.name === "molecule-type" ? P_(0, r.style.params) : Hi(r.style), i = n.color, a = n.legend;
  function o(u, s) {
    var c = i(u, !1);
    return s === "C" ? He.lighten(c, r.carbonLightness) : c;
  }
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(u) {
    if (at.is(u) && Be.isAtomic(u.unit)) {
      var s = u.unit.model.atomicHierarchy.atoms.type_symbol.value(u.element);
      return o(u, s);
    }
    if (Dt.isLocation(u) && Be.isAtomic(u.aUnit)) {
      var c = u.aUnit.elements[u.aIndex];
      return s = u.aUnit.model.atomicHierarchy.atoms.type_symbol.value(c), o(u, s);
    }
    return kW;
  }, props: r, description: "Assigns an illustrative color that gives every chain a color based on the choosen style but with lighter carbons (inspired by David Goodsell's Molecule of the Month style).", legend: a };
}, getParams: function(e) {
  return G.clone(vC);
}, defaultValues: G.getDefaultValues(vC), isApplicable: function(e) {
  return !!e.structure;
} }, gC = { list: G.ColorList("red-yellow-green", { presetKind: "scale" }), scale: G.Select("DGwif", [["DGwif", "DG water-membrane"], ["DGwoct", "DG water-octanol"], ["Oct-IF", "DG difference"]]) }, GW = { DGwif: 0, DGwoct: 1, "Oct-IF": 2 };
function yC(e, t) {
  return e.model.atomicHierarchy.atoms.label_comp_id.value(t);
}
function bC(e, t) {
  var r = e.coarseElements.seq_id_begin.value(t);
  if (r === e.coarseElements.seq_id_end.value(t)) {
    var n = e.coarseElements.entityKey[t];
    return e.model.sequence.byEntityKey[n].sequence.compId.value(r - 1);
  }
}
var VW = { name: "hydrophobicity", label: "Hydrophobicity", category: "Residue Property", factory: function e(t, r) {
  var n = GW[r.scale], i = 1 / 0, a = -1 / 0;
  for (var o in Gy) {
    var u = Gy[o][n];
    i = Math.min(i, u), a = Math.max(a, u);
  }
  var s = Bs.create({ listOrName: r.list.colors, domain: [a, i], minLabel: "Hydrophilic", maxLabel: "Hydrophobic" });
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(c) {
    var l;
    return at.is(c) ? l = Be.isAtomic(c.unit) ? yC(c.unit, c.element) : bC(c.unit, c.element) : Dt.isLocation(c) && (l = Be.isAtomic(c.aUnit) ? yC(c.aUnit, c.aUnit.elements[c.aIndex]) : bC(c.aUnit, c.aUnit.elements[c.aIndex])), s.color(l ? function(d, f) {
      var m = Gy[d];
      return m === void 0 ? 0 : m[f];
    }(l, n) : 0);
  }, props: r, description: 'Assigns a color to every amino acid according to the "Experimentally determined hydrophobicity scale for proteins at membrane interfaces" by Wimely and White (doi:10.1038/nsb1096-842).', legend: s ? s.legend : void 0 };
}, getParams: function(e) {
  return gC;
}, defaultValues: G.getDefaultValues(gC), isApplicable: function(e) {
  return !!e.structure;
} }, _C = He(13421772), xC = R({}, Qo({ type: "colors", colorList: "purples" })), UW = { name: "model-index", label: "Model Index", category: "Chain Property", factory: function e(t, r) {
  var n, i, a, o;
  if (t.structure) {
    for (var u = t.structure.root.models, s = 0, c = 0, l = u; c < l.length; c++) {
      var d = l[c];
      s = Math.max(s, ((n = nn.TrajectoryInfo.get(d)) === null || n === void 0 ? void 0 : n.size) || 0);
    }
    var f = as(s, r);
    o = f.legend;
    for (var m = /* @__PURE__ */ new Map(), v = 0, p = u.length; v < p; ++v) {
      var g = ((i = nn.TrajectoryInfo.get(u[v])) === null || i === void 0 ? void 0 : i.index) || 0;
      m.set(g, f.color(g));
    }
    a = function(h) {
      return at.is(h) ? m.get(nn.TrajectoryInfo.get(h.unit.model).index) : Dt.isLocation(h) ? m.get(nn.TrajectoryInfo.get(h.aUnit.model).index) : _C;
    };
  } else a = function() {
    return _C;
  };
  return { factory: e, granularity: "instance", color: a, props: r, description: "Gives every model a unique color based on the position (index) of the model in the list of models in the structure.", legend: o };
}, getParams: function(e) {
  return xC;
}, defaultValues: G.getDefaultValues(xC), isApplicable: function(e) {
  return !!e.structure && e.structure.elementCount > 0 && nn.TrajectoryInfo.get(e.structure.models[0]).size > 1;
} }, HW = He(13421772), AC = { domain: G.Interval([0, 1]), list: G.ColorList("purples", { presetKind: "scale" }) };
function SC(e, t) {
  return Be.isAtomic(e) ? e.model.atomicConformation.occupancy.value(t) : 0;
}
var qW = { name: "occupancy", label: "Occupancy", category: "Atom Property", factory: function e(t, r) {
  var n = Bs.create({ reverse: !1, domain: r.domain, listOrName: r.list.colors });
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(i) {
    return at.is(i) ? n.color(SC(i.unit, i.element)) : Dt.isLocation(i) ? n.color(SC(i.aUnit, i.aUnit.elements[i.aIndex])) : HW;
  }, props: r, description: "Assigns a color based on the occupancy of an atom.", legend: n ? n.legend : void 0 };
}, getParams: function(e) {
  return AC;
}, defaultValues: G.getDefaultValues(AC), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return t.atomicConformation.occupancy.isDefined;
  });
} }, Vb = "dark-2", CC = He(13421772), wC = R({}, Qo({ type: "colors", colorList: Vb })), Tp = 1e4;
function Ub(e) {
  return e.map(function(t) {
    return "".concat(t + Tp).padStart(5, "0");
  }).join("");
}
function Hb(e) {
  var t = function(a, o) {
    return Math.abs(a) < o ? 0 : Math.floor(Math.log10(Math.abs(a))) + 1;
  }(Tp, 0), r = parseInt(e.substr(0, t)), n = parseInt(e.substr(t, t)), i = parseInt(e.substr(t + t, t));
  return [r - Tp, n - Tp, i - Tp];
}
function A4(e) {
  return e.map(function(t) {
    return t + 5;
  }).join("");
}
function DC(e) {
  for (var t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), n = 0, i = e.units.length; n < i; ++n) {
    var a = Ub(e.units[n].conformation.operator.hkl);
    r.add(a);
  }
  var o = Array.from(r.values()).sort();
  return o.forEach(function(u) {
    return t.set(u, t.size);
  }), { min: Hb(o[0]), max: Hb(o[o.length - 1]), map: t };
}
var Pc, KW = { name: "operator-hkl", label: "Operator HKL", category: "Symmetry", factory: function e(t, r) {
  var n, i;
  if (t.structure) {
    var a = DC(t.structure.root), o = a.min, u = a.max, s = a.map, c = [];
    s.forEach(function(f, m) {
      var v = f % s.size, p = A4(Hb(m));
      c[v] === void 0 ? c[v] = p : c[v] += ", ".concat(p);
    });
    var l = { minLabel: A4(o), maxLabel: A4(u), valueLabel: function(f) {
      return c[f];
    } }, d = as(s.size, r, l);
    i = d.legend, n = function(f) {
      var m = void 0;
      if (at.is(f)) {
        var v = Ub(f.unit.conformation.operator.hkl);
        m = s.get(v);
      } else Dt.isLocation(f) && (v = Ub(f.aUnit.conformation.operator.hkl), m = s.get(v));
      return m === void 0 ? CC : d.color(m);
    };
  } else n = function() {
    return CC;
  };
  return { factory: e, granularity: "instance", color: n, props: r, description: "Assigns a color based on the operator HKL value of a transformed chain.", legend: i };
}, getParams: function(e) {
  var t = G.clone(wC);
  return e.structure && DC(e.structure.root).map.size > bo[Vb].list.length && (t.palette.defaultValue.name = "colors", t.palette.defaultValue.params = R(R({}, t.palette.defaultValue.params), { list: { kind: "interpolate", colors: Ec(Vb).list } })), t;
}, defaultValues: G.getDefaultValues(wC), isApplicable: function(e) {
  return !!e.structure;
} };
(function(e) {
  e.Descriptor = { name: "atom_partial_charge" }, e.Provider = Es.create(e.Descriptor);
})(Pc || (Pc = {}));
var S4 = He(16777113), IC = { domain: G.Interval([-1, 1]), list: G.ColorList("red-white-blue", { presetKind: "scale" }) };
function EC(e, t) {
  var r;
  return (r = Pc.Provider.get(e.model)) === null || r === void 0 ? void 0 : r.data.value(t);
}
var XW = { name: "partial-charge", label: "Partial Charge", category: "Atom Property", factory: function e(t, r) {
  var n = Bs.create({ domain: r.domain, listOrName: r.list.colors });
  return { factory: e, granularity: "group", preferSmoothing: !0, color: function(i) {
    var a;
    return at.is(i) ? (a = EC(i.unit, i.element)) === void 0 || Number.isNaN(a) ? S4 : n.color(a) : Dt.isLocation(i) ? (a = EC(i.aUnit, i.aUnit.elements[i.aIndex])) === void 0 || Number.isNaN(a) ? S4 : n.color(a) : S4;
  }, props: r, description: "Assigns a color based on the partial charge of an atom.", legend: n ? n.legend : void 0 };
}, getParams: function(e) {
  return IC;
}, defaultValues: G.getDefaultValues(IC), isApplicable: function(e) {
  return !!e.structure && e.structure.models.some(function(t) {
    return Pc.Provider.get(t) !== void 0;
  });
} }, MC = He(16448250), TC = R({}, Qo({ type: "colors", colorList: "many-distinct" })), jW = { name: "atom-id", label: "Atom Id", category: "Atom Property", factory: function e(t, r) {
  var n, i;
  if (t.structure) {
    var a = at.create(t.structure.root), o = function(c) {
      for (var l = /* @__PURE__ */ new Map(), d = 0, f = c.models; d < f.length; d++) for (var m = f[d].atomicHierarchy.atoms.label_atom_id, v = 0, p = m.rowCount; v < p; ++v) {
        var g = m.value(v);
        l.has(g) || l.set(g, l.size);
      }
      return l;
    }(t.structure.root), u = Array.from(o.keys()), s = as(o.size, r, { valueLabel: function(c) {
      return u[c];
    } });
    i = s.legend, n = function(c) {
      var l = void 0;
      if (at.is(c)) {
        var d = Qe.atom.label_atom_id(c);
        l = o.get(d);
      } else Dt.isLocation(c) && (a.unit = c.aUnit, a.element = c.aUnit.elements[c.aIndex], d = Qe.atom.label_atom_id(a), l = o.get(d));
      return l === void 0 ? MC : s.color(l);
    };
  } else n = function() {
    return MC;
  };
  return { factory: e, granularity: "group", preferSmoothing: !0, color: n, props: r, description: "Gives every atom a color based on its `label_atom_id` value.", legend: i };
}, getParams: function(e) {
  return G.clone(TC);
}, defaultValues: G.getDefaultValues(TC), isApplicable: function(e) {
  return !!e.structure;
} }, YW = He(13421772), PC = { colorList: G.ColorList({ kind: "interpolate", colors: [[Kt.white, 0], [Kt.red, 0.25], [Kt.white, 0.5], [Kt.blue, 0.75], [Kt.white, 1]] }, { offsets: !0, isEssential: !0 }) }, WW = { name: "volume-value", label: "Volume Value", category: "Miscellaneous", factory: function e(t, r) {
  for (var n = Bs.create({ domain: [0, 1], listOrName: r.colorList.colors }), i = [], a = 0; a < 256; ++a) i[a] = n.color(a / 255);
  var o = { colors: i, filter: "linear" };
  return { factory: e, granularity: "direct", color: function() {
    return YW;
  }, props: r, description: "Assign color based on the given value of a volume cell.", legend: n.legend, palette: o };
}, getParams: function(e) {
  return PC;
}, defaultValues: G.getDefaultValues(PC), isApplicable: function(e) {
  return !!e.volume;
} }, ZW = He(13421772), BC = { list: G.ColorList("turbo", { presetKind: "scale" }) }, QW = { name: "uni-fold", label: "Uni-Fold", category: "Residue Property", factory: function e(t, r) {
  var n = Bs.create({ listOrName: r.list.colors, minLabel: "Start", maxLabel: "End" });
  return { factory: e, granularity: "group", color: function(i) {
    if (at.is(i)) {
      if (Be.isAtomic(i.unit)) {
        if ((a = i.unit.model.atomicHierarchy.atoms.B_iso_or_equiv.value(i.element)) >= 90) return He.fromRgb(148, 164, 239);
        if (a < 90 && a >= 70) return He.fromRgb(148, 225, 239);
        if (a < 70 && a >= 50) return He.fromRgb(240, 193, 145);
        if (a < 50) return He.fromRgb(239, 156, 156);
      }
    } else if (Dt.isLocation(i) && Be.isAtomic(i.aUnit)) {
      var a;
      if ((a = i.aUnit.model.atomicHierarchy.atoms.B_iso_or_equiv.value(i.aUnit.elements[i.aIndex])) >= 90) return He.fromRgb(148, 164, 239);
      if (a < 90 && a >= 70) return He.fromRgb(148, 225, 239);
      if (a < 70 && a >= 50) return He.fromRgb(240, 193, 145);
      if (a < 50) return He.fromRgb(239, 156, 156);
    }
    return ZW;
  }, props: r, description: "Fold", legend: n ? n.legend : void 0 };
}, getParams: function(e) {
  return BC;
}, defaultValues: G.getDefaultValues(BC), isApplicable: function(e) {
  return !!e.structure;
} }, tP = { H: 16777215, D: 16777152, T: 16777120, HE: 14286847, LI: 13402367, BE: 12779264, B: 16758197, C: 9474192, N: 3166456, O: 16715021, F: 9494608, NE: 11789301, NA: 11230450, MG: 9109248, AL: 12560038, SI: 1578e4, P: 16744448, S: 16777008, CL: 2093087, AR: 8442339, K: 9388244, CA: 4062976, SC: 15132390, TI: 12567239, V: 10921643, CR: 9083335, MN: 10255047, FE: 14706227, CO: 15765664, NI: 5296208, CU: 13140019, ZN: 8224944, GA: 12750735, GE: 6721423, AS: 12419299, SE: 16752896, BR: 10889513, KR: 6076625, RB: 7351984, SR: 65280, Y: 9764863, ZR: 9756896, NB: 7586505, MO: 5551541, TC: 3907230, RU: 2396047, RH: 687500, PD: 27013, AG: 12632256, CD: 16767375, IN: 10909043, SN: 6717568, SB: 10380213, TE: 13924864, I: 9699476, XE: 9699476, CS: 5707663, BA: 51456, LA: 7394559, CE: 16777159, PR: 14286791, ND: 13107143, PM: 10747847, SM: 9437127, EU: 6422471, GD: 4587463, TB: 3211207, DY: 2097095, HO: 65436, ER: 58997, TM: 54354, YB: 48952, LU: 43812, HF: 5096191, TA: 5089023, W: 2200790, RE: 2522539, OS: 2516630, IR: 1528967, PT: 13684960, AU: 16765219, HG: 12105936, TL: 10900557, PB: 5724513, BI: 10375093, PO: 11230208, AT: 7688005, RN: 4358806, FR: 4325478, RA: 32e3, AC: 7384058, TH: 47871, PA: 41471, U: 36863, NP: 33023, PU: 27647, AM: 5528818, CM: 7888099, BK: 9064419, CF: 10565332, ES: 11739092, FM: 11739066, MD: 11734438, NO: 12389767, LR: 13041766, RF: 13369433, DB: 13697103, SG: 14221381, BH: 14680120, HS: 15073326, MT: 15400998, DS: 16777215, RG: 16777215, CN: 16777215, UUT: 16777215, FL: 16777215, UUP: 16777215, LV: 16777215, UUH: 16777215 }, JW = He(16777215), FC = { carbonColor: G.MappedStatic("chain-id", { "chain-id": G.Group(gf), "entity-id": G.Group($1), "entity-source": G.Group(e0), "operator-name": G.Group(J1), "element-symbol": G.EmptyGroup() }, { description: "Use chain-id coloring for carbon atoms." }), saturation: G.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: G.Numeric(0.2, { min: -6, max: 6, step: 0.1 }), colors: G.MappedStatic("default", { default: G.EmptyGroup(), custom: G.Group(A0(tP)) }) }, $W = { name: "cdr", label: "CDR", category: "Atom Property", factory: function e(t, r) {
  var n = xf(r.colors.name === "default" ? tP : r.colors.params, r.saturation, r.lightness);
  return { factory: e, granularity: r.carbonColor.name === "operator-name" ? "groupInstance" : "group", preferSmoothing: !0, color: function(i) {
    if (at.is(i)) {
      if (Be.isAtomic(i.unit)) {
        var a = i.unit.model.atomicHierarchy.atoms.cdr, o = i.unit.model.atomicHierarchy.chains.auth_asym_id, u = a.value(i.element), s = o.value(i.unit.chainIndex[i.element]);
        return u !== 0 ? u === 3 && s.toLocaleUpperCase() === "H" ? He.fromRgb(252, 180, 91) : He.fromRgb(153, 154, 235) : s.toLocaleUpperCase() === "L" ? He.fromRgb(145, 225, 192) : s.toLocaleUpperCase() === "H" ? He.fromRgb(148, 223, 247) : He(16777215);
      }
    } else if (Dt.isLocation(i) && Be.isAtomic(i.aUnit))
      return a = i.aUnit.model.atomicHierarchy.atoms.cdr, o = i.aUnit.model.atomicHierarchy.chains.auth_asym_id, u = a.value(i.aUnit.elements[i.aIndex]), s = o.value(i.aUnit.chainIndex[i.aIndex]), u !== 0 ? u === 3 && s.toLocaleUpperCase() === "H" ? He.fromRgb(252, 180, 91) : He.fromRgb(153, 154, 235) : s.toLocaleUpperCase() === "L" ? He.fromRgb(145, 225, 192) : s.toLocaleUpperCase() === "H" ? He.fromRgb(148, 223, 247) : He(16777215);
    return JW;
  }, props: r, description: "CDR", legend: is(Object.keys(n).map(function(i) {
    return [i, n[i]];
  })) };
}, getParams: function(e) {
  return FC;
}, defaultValues: G.getDefaultValues(FC), isApplicable: function(e) {
  return !!e.structure;
} }, NC = He(16448250), RC = R({ themes: G.Value([]) }, Qo({ type: "colors", colorList: "many-distinct" })), eZ = { name: "multi-theme", label: "Multi Theme", category: "Atom Property", factory: function e(t, r) {
  var n, i = r.themes;
  return n = t.structure ? function(a, o) {
    if (at.is(a)) for (var u = 0; u < i.length; u++) {
      var s = i[u];
      if ((c = $a.toStructure(s.bundle, t.structure)).hasElement(a)) return s.colorTheme.color(a, o);
    }
    else if (Dt.isLocation(a) && Be.isAtomic(a.aUnit)) for (u = 0; u < i.length; u++) {
      s = i[u];
      var c = $a.toStructure(s.bundle, t.structure), l = at.create(a.aStructure, a.aUnit, a.aUnit.elements[a.aIndex]);
      if (c.hasElement(l)) return s.colorTheme.color(a, o);
    }
    return NC;
  } : function() {
    return NC;
  }, { factory: e, granularity: "group", preferSmoothing: !0, color: n, props: r, description: "Structure allows multi theme based on location" };
}, getParams: function(e) {
  return G.clone(RC);
}, defaultValues: G.getDefaultValues(RC), isApplicable: function(e) {
  return !!e.structure;
} }, rP = { H: 16777215, D: 16777152, T: 16777120, HE: 14286847, LI: 13402367, BE: 12779264, B: 16758197, C: 9474192, N: 3166456, O: 16715021, F: 9494608, NE: 11789301, NA: 11230450, MG: 9109248, AL: 12560038, SI: 1578e4, P: 16744448, S: 16777008, CL: 2093087, AR: 8442339, K: 9388244, CA: 4062976, SC: 15132390, TI: 12567239, V: 10921643, CR: 9083335, MN: 10255047, FE: 14706227, CO: 15765664, NI: 5296208, CU: 13140019, ZN: 8224944, GA: 12750735, GE: 6721423, AS: 12419299, SE: 16752896, BR: 10889513, KR: 6076625, RB: 7351984, SR: 65280, Y: 9764863, ZR: 9756896, NB: 7586505, MO: 5551541, TC: 3907230, RU: 2396047, RH: 687500, PD: 27013, AG: 12632256, CD: 16767375, IN: 10909043, SN: 6717568, SB: 10380213, TE: 13924864, I: 9699476, XE: 9699476, CS: 5707663, BA: 51456, LA: 7394559, CE: 16777159, PR: 14286791, ND: 13107143, PM: 10747847, SM: 9437127, EU: 6422471, GD: 4587463, TB: 3211207, DY: 2097095, HO: 65436, ER: 58997, TM: 54354, YB: 48952, LU: 43812, HF: 5096191, TA: 5089023, W: 2200790, RE: 2522539, OS: 2516630, IR: 1528967, PT: 13684960, AU: 16765219, HG: 12105936, TL: 10900557, PB: 5724513, BI: 10375093, PO: 11230208, AT: 7688005, RN: 4358806, FR: 4325478, RA: 32e3, AC: 7384058, TH: 47871, PA: 41471, U: 36863, NP: 33023, PU: 27647, AM: 5528818, CM: 7888099, BK: 9064419, CF: 10565332, ES: 11739092, FM: 11739066, MD: 11734438, NO: 12389767, LR: 13041766, RF: 13369433, DB: 13697103, SG: 14221381, BH: 14680120, HS: 15073326, MT: 15400998, DS: 16777215, RG: 16777215, CN: 16777215, UUT: 16777215, FL: 16777215, UUP: 16777215, LV: 16777215, UUH: 16777215 }, tZ = He(16777215), OC = { carbonColor: G.MappedStatic("chain-id", { "chain-id": G.Group(gf), "entity-id": G.Group($1), "entity-source": G.Group(e0), "operator-name": G.Group(J1), "element-symbol": G.EmptyGroup() }, { description: "Use chain-id coloring for carbon atoms." }), saturation: G.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: G.Numeric(0.2, { min: -6, max: 6, step: 0.1 }), colors: G.MappedStatic("default", { default: G.EmptyGroup(), custom: G.Group(A0(rP)) }) }, rZ = { name: "em-confidence", label: "EM Confidence", category: "Residue Property", factory: function e(t, r) {
  var n = xf(r.colors.name === "default" ? rP : r.colors.params, r.saturation, r.lightness);
  return { factory: e, granularity: r.carbonColor.name === "operator-name" ? "groupInstance" : "group", preferSmoothing: !0, color: function(i) {
    if (at.is(i)) {
      if (Be.isAtomic(i.unit)) {
        var a = i.unit.model.atomicHierarchy.atoms.em_confidence;
        switch (!0) {
          case (o = parseFloat(a.value(i.element))) < -1:
            return He.fromRgb(239, 139, 139);
          case (o >= -1 && o < -0.8):
            return He.fromRgb(239, 151, 139);
          case (o >= -0.8 && o < -0.6):
            return He.fromRgb(239, 167, 138);
          case (o >= -0.6 && o < -0.4):
            return He.fromRgb(239, 190, 136);
          case (o >= -0.4 && o < -0.2):
            return He.fromRgb(239, 214, 136);
          case (o >= -0.2 && o < 0):
            return He.fromRgb(239, 236, 135);
          case (o >= 0 && o < 0.2):
            return He.fromRgb(134, 239, 134);
          case (o >= 0.2 && o < 0.4):
            return He.fromRgb(134, 239, 227);
          case (o >= 0.4 && o < 0.6):
            return He.fromRgb(134, 224, 239);
          case (o >= 0.6 && o < 0.8):
            return He.fromRgb(134, 200, 239);
          case (o >= 0.8 && o <= 1):
            return He.fromRgb(133, 175, 239);
          case o > 1:
            return He.fromRgb(134, 153, 239);
          default:
            return He(16777215);
        }
      }
    } else if (Dt.isLocation(i) && Be.isAtomic(i.aUnit)) {
      var o;
      switch (a = i.aUnit.model.atomicHierarchy.atoms.em_confidence, !0) {
        case (o = parseFloat(a.value(i.aUnit.elements[i.aIndex]))) < -1:
          return He.fromRgb(239, 139, 139);
        case (o >= -1 && o < -0.8):
          return He.fromRgb(239, 151, 139);
        case (o >= -0.8 && o < -0.6):
          return He.fromRgb(239, 167, 138);
        case (o >= -0.6 && o < -0.4):
          return He.fromRgb(239, 190, 136);
        case (o >= -0.4 && o < -0.2):
          return He.fromRgb(239, 214, 136);
        case (o >= -0.2 && o < 0):
          return He.fromRgb(239, 236, 135);
        case (o >= 0 && o < 0.2):
          return He.fromRgb(134, 239, 134);
        case (o >= 0.2 && o < 0.4):
          return He.fromRgb(134, 239, 227);
        case (o >= 0.4 && o < 0.6):
          return He.fromRgb(134, 224, 239);
        case (o >= 0.6 && o < 0.8):
          return He.fromRgb(134, 200, 239);
        case (o >= 0.8 && o <= 1):
          return He.fromRgb(133, 175, 239);
        case o > 1:
          return He.fromRgb(134, 153, 239);
        default:
          return He(16777215);
      }
    }
    return tZ;
  }, props: r, description: "EM", legend: is(Object.keys(n).map(function(i) {
    return [i, n[i]];
  })) };
}, getParams: function(e) {
  return OC;
}, defaultValues: G.getDefaultValues(OC), isApplicable: function(e) {
  return !!e.structure;
} }, O2 = { AC: 7384058, AG: 12632256, AL: 8499926, AM: 5528818, AR: 13631172, AS: 7655511, AT: 7688005, AU: 16765219, B: 2073103, BA: 51456, BE: 6215547, BH: 14680120, BI: 10375093, BK: 9064419, BR: 8270082, C: 5000268, CA: 5936829, CD: 16767375, CE: 16777159, CF: 10565332, CL: 3275778, CM: 7888099, CO: 175, CR: 158, CS: 5707663, CU: 2246620, DB: 13697103, DY: 2097095, ER: 58997, ES: 11739092, EU: 6422471, F: 11581926, FE: 11890944, FM: 11739066, FR: 4325478, GA: 10412915, GD: 4587463, GE: 8285862, H: 16764108, HE: 16574670, HF: 5096191, HG: 12105936, HO: 65436, HS: 15073326, I: 9699476, IN: 10909043, IR: 1528967, K: 10559990, KR: 16433651, LA: 5948489, LI: 8839027, LR: 13041766, LU: 43812, MD: 11734438, MG: 16481045, MN: 10946717, MO: 5551541, MT: 15400998, N: 11581926, NA: 16374844, NB: 7586505, ND: 13107143, NE: 16660405, NI: 12041149, NO: 12389767, NP: 33023, O: 16646912, OS: 2516630, P: 12623042, PA: 41471, PB: 5724513, PD: 27013, PM: 10747847, PO: 11230208, PR: 14286791, PT: 13684960, PU: 27647, RA: 32e3, RB: 7351984, RE: 2522539, RF: 13369433, RH: 687500, RN: 4358806, RU: 2396047, S: 16775680, SB: 10380213, SC: 11887531, SE: 10153743, SG: 14221381, SI: 1784826, SM: 9437127, SN: 10129081, SR: 65280, TA: 5089023, TB: 3211207, TC: 3907230, TE: 13924864, TH: 47871, TI: 7916287, TL: 10900557, TM: 54354, U: 36863, V: 15014144, W: 2200790, XE: 4366e3, Y: 9764863, YB: 48952, ZN: 9408385, ZR: 65280 }, L2 = window.materialColors, LC = function() {
  Object.keys(L2.settings).forEach(function(e) {
    O2[e] = L2.getColorNumber(e);
  });
};
L2 && (LC(), L2.setColorsSubject.subscribe(function() {
  LC();
}));
var C4 = O2, kC = He(16777215), nP = { carbonColor: G.MappedStatic("chain-id", { "chain-id": G.Group(R({}, gf)), "operator-name": G.Group(R({}, J1)), "element-symbol": G.Group({}) }, { description: "Use chain-id coloring for carbon atoms." }), saturation: G.Numeric(0, { min: -6, max: 6, step: 0.1 }), lightness: G.Numeric(0.2, { min: -6, max: 6, step: 0.1 }) };
function nZ(e) {
  return nP;
}
function iP(e, t) {
  var r = xf(C4, t.saturation, t.lightness);
  function n(i, a) {
    return function(o, u) {
      var s = o[u];
      return s === void 0 ? kC : s;
    }(r, i);
  }
  return { factory: iP, granularity: t.carbonColor.name === "operator-name" ? "groupInstance" : "group", preferSmoothing: !0, color: function(i) {
    if (at.is(i)) {
      if (Be.isAtomic(i.unit)) return n(i.unit.model.atomicHierarchy.atoms.type_symbol.value(i.element));
    } else if (Dt.isLocation(i) && Be.isAtomic(i.aUnit))
      return n(i.aUnit.model.atomicHierarchy.atoms.type_symbol.value(i.aUnit.elements[i.aIndex]));
    return kC;
  }, props: t, description: "Assigns a color to every atom according to its chemical element.", legend: is(Object.keys(C4).map(function(i) {
    return [i, C4[i]];
  })) };
}
var Bc, _t, Pr, iZ = { name: "material-element-symbol", label: "Material Element Symbol", category: "Atom Property", factory: iP, getParams: nZ, defaultValues: G.getDefaultValues(nP), isApplicable: function(e) {
  return !!e.structure;
} };
function w4(e, t, r) {
  switch (r) {
    case _t.Highlight:
      e[t] |= 1;
      break;
    case _t.RemoveHighlight:
      e[t] &= -2;
      break;
    case _t.Select:
      e[t] |= 2;
      break;
    case _t.Deselect:
      e[t] &= -3;
      break;
    case _t.Toggle:
      e[t] ^= 2;
      break;
    case _t.Clear:
      e[t] = 0;
  }
}
function qb(e, t, r) {
  if (r === _t.None) return !1;
  if (Ae.is(t)) {
    var n = Ae.start(t), i = Ae.end(t), a = n + 3 >> 2, o = a + (i - 4 * a >> 2);
    if (o <= a) {
      for (var u = n; u < i; ++u) w4(e, u, r);
      return !0;
    }
    var s = new Uint32Array(e.buffer, 0, e.buffer.byteLength >> 2), c = n, l = Math.min(4 * a, i), d = Math.max(n, 4 * o), f = i;
    switch (r) {
      case _t.Highlight:
        for (u = a; u < o; ++u) s[u] |= 16843009;
        break;
      case _t.RemoveHighlight:
        for (u = a; u < o; ++u) s[u] &= -16843010;
        break;
      case _t.Select:
        for (u = a; u < o; ++u) s[u] |= 33686018;
        break;
      case _t.Deselect:
        for (u = a; u < o; ++u) s[u] &= -33686019;
        break;
      case _t.Toggle:
        for (u = a; u < o; ++u) s[u] ^= 33686018;
        break;
      case _t.Clear:
        for (u = a; u < o; ++u) s[u] = 0;
        break;
      default:
        Hi();
    }
    for (u = c; u < l; ++u) w4(e, u, r);
    for (u = d; u < f; ++u) w4(e, u, r);
  } else switch (r) {
    case _t.Highlight:
      u = 0;
      for (var m = t.length; u < m; ++u) e[t[u]] |= 1;
      break;
    case _t.RemoveHighlight:
      for (u = 0, m = t.length; u < m; ++u) e[t[u]] &= -2;
      break;
    case _t.Select:
      for (u = 0, m = t.length; u < m; ++u) e[t[u]] |= 2;
      break;
    case _t.Deselect:
      for (u = 0, m = t.length; u < m; ++u) e[t[u]] &= -3;
      break;
    case _t.Toggle:
      for (u = 0, m = t.length; u < m; ++u) e[t[u]] ^= 2;
      break;
    case _t.Clear:
      for (u = 0, m = t.length; u < m; ++u) e[t[u]] = 0;
      break;
    default:
      Hi();
  }
  return !0;
}
(function(e) {
  e.PaletteScale = 16777215, e.EmptyFactory = function() {
    return e.Empty;
  };
  var t = He(13421772);
  e.Empty = { factory: e.EmptyFactory, granularity: "uniform", color: function() {
    return t;
  }, props: {} }, e.areEqual = function(r, n) {
    return r.contextHash === n.contextHash && r.factory === n.factory && td(r.props, n.props);
  }, e.EmptyProvider = { name: "", label: "", category: "", factory: e.EmptyFactory, getParams: function() {
    return {};
  }, defaultValues: {}, isApplicable: function() {
    return !0;
  } }, e.createRegistry = function() {
    return new UT(e.BuiltIn, e.EmptyProvider);
  }, e.BuiltIn = { "atom-id": jW, "carbohydrate-symbol": hY, "chain-id": mW, "element-index": hW, "element-symbol": DW, "material-element-symbol": iZ, "entity-id": bW, "entity-source": SW, hydrophobicity: VW, illustrative: zW, "model-index": UW, "molecule-type": EW, occupancy: qW, "operator-hkl": KW, "operator-name": gW, "partial-charge": XW, "polymer-id": MW, "polymer-index": TW, "residue-name": PW, "secondary-structure": BW, "sequence-id": NW, "shape-group": YY, uncertainty: LW, "unit-index": RW, uniform: gY, "volume-value": WW, "uni-fold": QW, cdr: $W, "em-confidence": rZ, "multi-theme": eZ };
})(Bc || (Bc = {})), function(e) {
  e[e.None = 0] = "None", e[e.Highlight = 1] = "Highlight", e[e.RemoveHighlight = 2] = "RemoveHighlight", e[e.Select = 4] = "Select", e[e.Deselect = 8] = "Deselect", e[e.Toggle = 16] = "Toggle", e[e.Clear = 32] = "Clear";
}(_t || (_t = {})), function(e) {
  e.is = ya.has, e.All = _t.Highlight | _t.RemoveHighlight | _t.Select | _t.Deselect | _t.Toggle | _t.Clear, e.Highlighting = _t.Highlight | _t.RemoveHighlight | _t.Clear, e.Selecting = _t.Select | _t.Deselect | _t.Toggle | _t.Clear, e.isReverse = function(t, r) {
    return t === _t.Highlight && r === _t.RemoveHighlight || t === _t.RemoveHighlight && r === _t.Highlight || t === _t.Select && r === _t.Deselect || t === _t.Deselect && r === _t.Select || t === _t.Toggle && r === _t.Toggle;
  };
}(Pr || (Pr = {}));
var B_ = { kind: "every-loci" };
function xo(e) {
  return !!e && e.kind === "every-loci";
}
var Hr, vn = { kind: "empty-loci" };
function Jl(e) {
  return !!e && e.kind === "empty-loci";
}
function Kp(e) {
  return !!e && e.kind === "data-loci";
}
function aZ(e, t) {
  if (!ib(e.data, t.data) || e.tag !== t.tag || e.elements.length !== t.elements.length) return !1;
  for (var r = 0, n = e.elements.length; r < n; ++r) if (!ib(e.elements[r], t.elements[r])) return !1;
  return !0;
}
function oZ(e) {
  return e.elements.length === 0;
}
function F_(e, t, r, n, i) {
  return { kind: "data-loci", tag: e, data: t, elements: r, getBoundingSphere: n, getLabel: i };
}
function uZ(e) {
  return Object.keys(e).filter(function(t) {
    return !isNaN(t);
  }).map(function(t) {
    return +t;
  }).sort(function(t, r) {
    return t - r;
  }).map(function(t) {
    return e[t];
  });
}
function D4(e, t, r) {
  return e && e[t] !== void 0 ? e[t] : r;
}
function Ye(e) {
  for (var t = [], r = 1; r < arguments.length; r++) t[r - 1] = arguments[r];
  return { kind: "alias", aliases: t, symbol: e };
}
function ov(e, t) {
  for (var r = [], n = 2; n < arguments.length; n++) r[n - 2] = arguments[n];
  return e.info.namespace = "molscript-macro", e.id = "molscript-macro.".concat(e.info.name), { kind: "macro", symbol: e, translate: t, aliases: We([e.info.name], r, !0) };
}
function sZ(e) {
  return e.kind === "alias" || e.kind === "macro";
}
(function(e) {
  var t = new Nu("98");
  function r(o, u) {
    var s;
    if (o.kind !== "every-loci" && o.kind !== "empty-loci") return u || (u = Me()), o.kind === "structure-loci" ? Me.copy(u, o.structure.boundary.sphere) : o.kind === "element-loci" ? Me.copy(u, Xe.getBoundary(o).sphere) : o.kind === "bond-loci" ? Dt.getBoundingSphere(o, u) : o.kind === "shape-loci" ? Me.copy(u, o.shape.geometry.boundingSphere) : o.kind === "group-loci" ? Za.getBoundingSphere(o, u) : o.kind === "data-loci" ? (s = o.getBoundingSphere) === null || s === void 0 ? void 0 : s.call(o, u) : o.kind === "volume-loci" ? ar.getBoundingSphere(o.volume, u) : o.kind === "isosurface-loci" ? ar.Isosurface.getBoundingSphere(o.volume, o.isoValue, u) : o.kind === "cell-loci" ? ar.Cell.getBoundingSphere(o.volume, o.indices, u) : void 0;
  }
  e.getBundleBoundingSphere = function(o) {
    var u = o.loci.map(function(m) {
      return r(m);
    }).filter(function(m) {
      return !!m;
    });
    t.reset();
    for (var s = 0, c = u; s < c.length; s++) {
      var l = c[s];
      t.includePositionRadius(l.center, l.radius);
    }
    t.finishedIncludeStep();
    for (var d = 0, f = u; d < f.length; d++)
      l = f[d], t.radiusPositionRadius(l.center, l.radius);
    return t.getSphere();
  }, e.areEqual = function(o, u) {
    return !(!xo(o) || !xo(u)) || !(!Jl(o) || !Jl(u)) || (Kp(o) && Kp(u) ? aZ(o, u) : tt.isLoci(o) && tt.isLoci(u) ? tt.areLociEqual(o, u) : Xe.is(o) && Xe.is(u) ? Xe.areEqual(o, u) : Dt.isLoci(o) && Dt.isLoci(u) ? Dt.areLociEqual(o, u) : $t.isLoci(o) && $t.isLoci(u) ? $t.areLociEqual(o, u) : Za.isLoci(o) && Za.isLoci(u) ? Za.areLociEqual(o, u) : ar.isLoci(o) && ar.isLoci(u) ? ar.areLociEqual(o, u) : ar.Isosurface.isLoci(o) && ar.Isosurface.isLoci(u) ? ar.Isosurface.areLociEqual(o, u) : !(!ar.Cell.isLoci(o) || !ar.Cell.isLoci(u)) && ar.Cell.areLociEqual(o, u));
  }, e.isEvery = function(o) {
    return !!o && o.kind === "every-loci";
  }, e.isEmpty = function(o) {
    return !xo(o) && (!!Jl(o) || (Kp(o) ? oZ(o) : tt.isLoci(o) ? tt.isLociEmpty(o) : Xe.is(o) ? Xe.isEmpty(o) : Dt.isLoci(o) ? Dt.isLociEmpty(o) : $t.isLoci(o) ? $t.isLociEmpty(o) : Za.isLoci(o) ? Za.isLociEmpty(o) : ar.isLoci(o) ? ar.isLociEmpty(o) : ar.Isosurface.isLoci(o) ? ar.Isosurface.isLociEmpty(o) : !!ar.Cell.isLoci(o) && ar.Cell.isLociEmpty(o)));
  }, e.remap = function(o, u) {
    return u instanceof tt && (Xe.is(o) ? o = Xe.remap(o, u) : tt.isLoci(o) ? o = tt.remapLoci(o, u) : Dt.isLoci(o) && (o = Dt.remapLoci(o, u))), o;
  }, e.getBoundingSphere = r;
  var n = Me.zero();
  e.getCenter = function(o, u) {
    var s = r(o, n);
    return s ? w.copy(u || w(), s.center) : void 0;
  }, e.getPrincipalAxes = function(o) {
    if (o.kind !== "every-loci" && o.kind !== "empty-loci") return o.kind === "structure-loci" ? Xe.getPrincipalAxes(tt.toStructureElementLoci(o.structure)) : o.kind === "element-loci" ? Xe.getPrincipalAxes(o) : void (o.kind !== "bond-loci" && o.kind !== "shape-loci" && o.kind !== "group-loci" && o.kind !== "data-loci" && o.kind !== "volume-loci" && o.kind !== "isosurface-loci" && o.kind);
  };
  var i = { element: function(o) {
    return o;
  }, residue: function(o) {
    return Xe.is(o) ? Xe.extendToWholeResidues(o, !0) : o;
  }, chain: function(o) {
    return Xe.is(o) ? Xe.extendToWholeChains(o) : o;
  }, entity: function(o) {
    return Xe.is(o) ? Xe.extendToWholeEntities(o) : o;
  }, model: function(o) {
    return Xe.is(o) ? Xe.extendToWholeModels(o) : o;
  }, operator: function(o) {
    return Xe.is(o) ? Xe.extendToWholeOperators(o) : o;
  }, structure: function(o) {
    return Xe.is(o) ? tt.toStructureElementLoci(o.structure) : Za.isLoci(o) ? $t.Loci(o.shape) : o;
  }, elementInstances: function(o) {
    return Xe.is(o) ? Xe.extendToAllInstances(o) : o;
  }, residueInstances: function(o) {
    return Xe.is(o) ? Xe.extendToAllInstances(Xe.extendToWholeResidues(o, !0)) : o;
  }, chainInstances: function(o) {
    return Xe.is(o) ? Xe.extendToAllInstances(Xe.extendToWholeChains(o)) : o;
  } };
  function a(o, u) {
    return i[u](o);
  }
  e.GranularityOptions = G.objectToOptions(i, function(o) {
    switch (o) {
      case "element":
        return "Atom/Coarse Element";
      case "elementInstances":
        return ["Atom/Coarse Element Instances", "With Symmetry"];
      case "structure":
        return "Structure/Shape";
      default:
        return o.indexOf("Instances") ? [Is(o), "With Symmetry"] : Is(o);
    }
  }), e.simpleGranularity = function(o) {
    return o.replace("Instances", "");
  }, e.applyGranularity = a, e.normalize = function(o, u, s) {
    return s === void 0 && (s = !1), (u !== "element" || s) && Dt.isLoci(o) && (o = Dt.toStructureElementLoci(o)), tt.isLoci(o) && (o = tt.toStructureElementLoci(o.structure)), Xe.is(o) && (o = Xe.remap(o, o.structure.root)), u && (o = a(o, u)), o;
  };
})(Hr || (Hr = {}));
var cZ = [["Core symbols", Ye(fe.core.type.bool, "bool"), Ye(fe.core.type.num, "num"), Ye(fe.core.type.str, "str"), Ye(fe.core.type.regex, "regex"), Ye(fe.core.type.list, "list"), Ye(fe.core.type.set, "set"), Ye(fe.core.type.compositeKey, "composite-key"), Ye(fe.core.logic.not, "not"), Ye(fe.core.logic.and, "and"), Ye(fe.core.logic.or, "or"), Ye(fe.core.ctrl.if, "if"), Ye(fe.core.ctrl.fn, "fn"), Ye(fe.core.ctrl.eval, "eval"), Ye(fe.core.math.add, "add", "+"), Ye(fe.core.math.sub, "sub", "-"), Ye(fe.core.math.mult, "mult", "*"), Ye(fe.core.math.div, "div", "/"), Ye(fe.core.math.pow, "pow", "**"), Ye(fe.core.math.mod, "mod"), Ye(fe.core.math.min, "min"), Ye(fe.core.math.max, "max"), Ye(fe.core.math.floor, "floor"), Ye(fe.core.math.ceil, "ceil"), Ye(fe.core.math.roundInt, "round"), Ye(fe.core.math.abs, "abs"), Ye(fe.core.math.sqrt, "sqrt"), Ye(fe.core.math.cbrt, "cbrt"), Ye(fe.core.math.sin, "sin"), Ye(fe.core.math.cos, "cos"), Ye(fe.core.math.tan, "tan"), Ye(fe.core.math.asin, "asin"), Ye(fe.core.math.acos, "acos"), Ye(fe.core.math.atan, "atan"), Ye(fe.core.math.sinh, "sinh"), Ye(fe.core.math.cosh, "cosh"), Ye(fe.core.math.tanh, "tanh"), Ye(fe.core.math.exp, "exp"), Ye(fe.core.math.log, "log"), Ye(fe.core.math.log10, "log10"), Ye(fe.core.math.atan2, "atan2"), Ye(fe.core.rel.eq, "eq", "="), Ye(fe.core.rel.neq, "neq", "!="), Ye(fe.core.rel.lt, "lt", "<"), Ye(fe.core.rel.lte, "lte", "<="), Ye(fe.core.rel.gr, "gr", ">"), Ye(fe.core.rel.gre, "gre", ">="), Ye(fe.core.rel.inRange, "in-range"), Ye(fe.core.str.concat, "concat"), Ye(fe.core.str.match, "regex.match"), Ye(fe.core.list.getAt, "list.get"), Ye(fe.core.set.has, "set.has"), Ye(fe.core.set.isSubset, "set.subset")], ["Structure", ["Types", Ye(fe.structureQuery.type.entityType, "ent-type"), Ye(fe.structureQuery.type.authResidueId, "auth-resid"), Ye(fe.structureQuery.type.labelResidueId, "label-resid"), Ye(fe.structureQuery.type.ringFingerprint, "ringfp"), Ye(fe.structureQuery.type.bondFlags, "bond-flags")], ["Slots", Ye(fe.structureQuery.slot.elementSetReduce, "atom.set.reduce.value")], ["Generators", Ye(fe.structureQuery.generator.atomGroups, "sel.atom.atom-groups"), Ye(fe.structureQuery.generator.queryInSelection, "sel.atom.query-in-selection"), Ye(fe.structureQuery.generator.rings, "sel.atom.rings"), Ye(fe.structureQuery.generator.empty, "sel.atom.empty"), Ye(fe.structureQuery.generator.all, "sel.atom.all"), Ye(fe.structureQuery.generator.bondedAtomicPairs, "sel.atom.bonded-pairs"), ov(Sp("sel.atom.atoms", xt.Dictionary({ 0: et(xe.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to each atom." }) }), pt.ElementSelection, "A selection of singleton atom sets."), function(e) {
  return Nt.struct.generator.atomGroups({ "atom-test": D4(e, 0, !0) });
}), ov(Sp("sel.atom.res", xt.Dictionary({ 0: et(xe.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to the 1st atom of each residue." }) }), pt.ElementSelection, "A selection of atom sets grouped by residue."), function(e) {
  return Nt.struct.generator.atomGroups({ "residue-test": D4(e, 0, !0), "group-by": Nt.ammp("residueKey") });
}), ov(Sp("sel.atom.chains", xt.Dictionary({ 0: et(xe.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to the 1st atom of each chain." }) }), pt.ElementSelection, "A selection of atom sets grouped by chain."), function(e) {
  return Nt.struct.generator.atomGroups({ "chain-test": D4(e, 0, !0), "group-by": Nt.ammp("chainKey") });
})], ["Modifiers", Ye(fe.structureQuery.modifier.queryEach, "sel.atom.query-each"), Ye(fe.structureQuery.modifier.intersectBy, "sel.atom.intersect-by"), Ye(fe.structureQuery.modifier.exceptBy, "sel.atom.except-by"), Ye(fe.structureQuery.modifier.unionBy, "sel.atom.union-by"), Ye(fe.structureQuery.modifier.union, "sel.atom.union"), Ye(fe.structureQuery.modifier.cluster, "sel.atom.cluster"), Ye(fe.structureQuery.modifier.includeSurroundings, "sel.atom.include-surroundings"), Ye(fe.structureQuery.modifier.surroundingLigands, "sel.atom.surrounding-ligands"), Ye(fe.structureQuery.modifier.includeConnected, "sel.atom.include-connected"), Ye(fe.structureQuery.modifier.expandProperty, "sel.atom.expand-property")], ["Filters", Ye(fe.structureQuery.filter.pick, "sel.atom.pick"), Ye(fe.structureQuery.filter.first, "sel.atom.first"), Ye(fe.structureQuery.filter.withSameAtomProperties, "sel.atom.with-same-atom-properties"), Ye(fe.structureQuery.filter.intersectedBy, "sel.atom.intersected-by"), Ye(fe.structureQuery.filter.within, "sel.atom.within"), Ye(fe.structureQuery.filter.isConnectedTo, "sel.atom.is-connected-to")], ["Combinators", Ye(fe.structureQuery.combinator.intersect, "sel.atom.intersect"), Ye(fe.structureQuery.combinator.merge, "sel.atom.merge"), Ye(fe.structureQuery.combinator.distanceCluster, "sel.atom.dist-cluster")], ["Atom Set Properties", Ye(fe.structureQuery.atomSet.atomCount, "atom.set.atom-count"), Ye(fe.structureQuery.atomSet.countQuery, "atom.set.count-query"), Ye(fe.structureQuery.atomSet.reduce, "atom.set.reduce"), Ye(fe.structureQuery.atomSet.propertySet, "atom.set.property")], ["Atom Properties", Ye(fe.structureQuery.atomProperty.core.elementSymbol, "atom.el"), Ye(fe.structureQuery.atomProperty.core.vdw, "atom.vdw"), Ye(fe.structureQuery.atomProperty.core.mass, "atom.mass"), Ye(fe.structureQuery.atomProperty.core.atomicNumber, "atom.atomic-number"), Ye(fe.structureQuery.atomProperty.core.x, "atom.x"), Ye(fe.structureQuery.atomProperty.core.y, "atom.y"), Ye(fe.structureQuery.atomProperty.core.z, "atom.z"), Ye(fe.structureQuery.atomProperty.core.sourceIndex, "atom.src-index"), Ye(fe.structureQuery.atomProperty.core.operatorName, "atom.op-name"), Ye(fe.structureQuery.atomProperty.core.modelIndex, "atom.model-index"), Ye(fe.structureQuery.atomProperty.core.modelLabel, "atom.model-label"), Ye(fe.structureQuery.atomProperty.core.atomKey, "atom.key"), Ye(fe.structureQuery.atomProperty.core.bondCount, "atom.bond-count"), Ye(fe.structureQuery.atomProperty.topology.connectedComponentKey, "atom.key.molecule"), Ye(fe.structureQuery.atomProperty.macromolecular.authResidueId, "atom.auth-resid"), Ye(fe.structureQuery.atomProperty.macromolecular.labelResidueId, "atom.label-resid"), Ye(fe.structureQuery.atomProperty.macromolecular.residueKey, "atom.key.res"), Ye(fe.structureQuery.atomProperty.macromolecular.chainKey, "atom.key.chain"), Ye(fe.structureQuery.atomProperty.macromolecular.entityKey, "atom.key.entity"), Ye(fe.structureQuery.atomProperty.macromolecular.isHet, "atom.is-het"), Ye(fe.structureQuery.atomProperty.macromolecular.id, "atom.id"), Ye(fe.structureQuery.atomProperty.macromolecular.label_atom_id, "atom.label_atom_id"), Ye(fe.structureQuery.atomProperty.macromolecular.label_alt_id, "atom.label_alt_id", "atom.altloc"), Ye(fe.structureQuery.atomProperty.macromolecular.label_comp_id, "atom.label_comp_id"), Ye(fe.structureQuery.atomProperty.macromolecular.label_asym_id, "atom.label_asym_id"), Ye(fe.structureQuery.atomProperty.macromolecular.label_entity_id, "atom.label_entity_id"), Ye(fe.structureQuery.atomProperty.macromolecular.label_seq_id, "atom.label_seq_id"), Ye(fe.structureQuery.atomProperty.macromolecular.auth_atom_id, "atom.auth_atom_id", "atom.name"), Ye(fe.structureQuery.atomProperty.macromolecular.auth_comp_id, "atom.auth_comp_id", "atom.resname"), Ye(fe.structureQuery.atomProperty.macromolecular.auth_asym_id, "atom.auth_asym_id", "atom.chain"), Ye(fe.structureQuery.atomProperty.macromolecular.auth_seq_id, "atom.auth_seq_id", "atom.resno"), Ye(fe.structureQuery.atomProperty.macromolecular.pdbx_PDB_ins_code, "atom.pdbx_PDB_ins_code", "atom.inscode"), Ye(fe.structureQuery.atomProperty.macromolecular.pdbx_formal_charge, "atom.pdbx_formal_charge"), Ye(fe.structureQuery.atomProperty.macromolecular.occupancy, "atom.occupancy"), Ye(fe.structureQuery.atomProperty.macromolecular.B_iso_or_equiv, "atom.B_iso_or_equiv", "atom.bfactor"), Ye(fe.structureQuery.atomProperty.macromolecular.entityType, "atom.entity-type"), Ye(fe.structureQuery.atomProperty.macromolecular.entitySubtype, "atom.entity-subtype"), Ye(fe.structureQuery.atomProperty.macromolecular.entityPrdId, "atom.entity-prd-id"), Ye(fe.structureQuery.atomProperty.macromolecular.entityDescription, "atom.entity-description"), Ye(fe.structureQuery.atomProperty.macromolecular.objectPrimitive, "atom.object-primitive"), Ye(fe.structureQuery.atomProperty.macromolecular.chemCompType, "atom.chem-comp-type"), Ye(fe.structureQuery.atomProperty.macromolecular.secondaryStructureKey, "atom.key.sec-struct"), Ye(fe.structureQuery.atomProperty.macromolecular.isModified, "atom.is-modified"), Ye(fe.structureQuery.atomProperty.macromolecular.modifiedParentName, "atom.modified-parent")], ["Bond Properties", Ye(fe.structureQuery.bondProperty.order, "bond.order"), Ye(fe.structureQuery.bondProperty.length, "bond.length"), Ye(fe.structureQuery.bondProperty.atomA, "bond.atom-a"), Ye(fe.structureQuery.bondProperty.atomB, "bond.atom-b"), ov(Sp("bond.is", xt.List(pt.BondFlag), xe.Bool, "Test if the current bond has at least one (or all if partial = false) of the specified flags: ".concat(xe.oneOfValues(pt.BondFlag).join(", "))), function(e) {
  return Nt.core.flags.hasAny([Nt.struct.bondProperty.flags(), Nt.struct.type.bondFlags(uZ(e))]);
})]]], aP = [];
(function e(t) {
  for (var r = 0, n = t; r < n.length; r++) {
    var i = n[r];
    sZ(i) ? aP.push(i) : i instanceof Array && e(i);
  }
})(cZ);
var lZ = function() {
  for (var e = [], t = /* @__PURE__ */ Object.create(null), r = cn.create(), n = cn.create(), i = 0, a = aP; i < a.length; i++) {
    for (var o = a[i], u = 0, s = o.aliases; u < s.length; u++) {
      var c = s[u];
      if (e.push([c, o]), t[c]) throw new Error("Alias '".concat(c, "' already in use."));
      t[c] = o;
    }
    var l = o.symbol.args;
    if (l.kind === "dictionary") for (var d = 0, f = Object.keys(l.map); d < f.length; d++) {
      c = f[d], isNaN(c) && cn.add(r, c, c);
      var m = l.map[c];
      m.type.kind === "oneof" && xe.oneOfValues(m.type).forEach(function(v) {
        return cn.add(n, v, v);
      });
    }
    else l.type.kind === "oneof" && xe.oneOfValues(l.type).forEach(function(v) {
      return cn.add(n, v, v);
    });
  }
  return { symbolList: e, symbolMap: t, namedArgs: r.array, constants: n.array };
}(), a1 = lZ.symbolMap;
function Pp(e) {
  if (ra.isLiteral(e)) return e;
  if (ra.isSymbol(e)) {
    if (!a1[e.name]) return e;
    var t = a1[e.name];
    if (t.kind === "alias") return ra.Symbol(a1[e.name].symbol.id);
    throw t.translate([]);
  }
  var r = ra.isSymbol(e.head) && !!a1[e.head.name] && a1[e.head.name].kind === "macro", n = r ? e.head : Pp(e.head), i = n !== e.head;
  if (!e.args) return r ? Pp(e.head) : i ? ra.Apply(n) : e;
  var a, o = !1;
  if (ra.isArgumentsArray(e.args)) {
    a = [];
    for (var u = 0, s = e.args.length; u < s; u++)
      (d = e.args[u]) !== (f = Pp(d)) && (o = !0), a[a.length] = f;
    if (o || (a = e.args), !r && !i && !o) return e;
  } else {
    a = {};
    for (var c = 0, l = Object.keys(e.args); c < l.length; c++) {
      var d, f, m = l[c];
      (d = e.args[m]) !== (f = Pp(d)) && (o = !0), a[m] = f;
    }
    if (!r && !i && !o) return e;
    o || (a = e.args);
  }
  if (r) {
    var v = a1[e.head.name];
    return v.kind !== "macro" ? ra.Apply(n, a) : v.translate(a);
  }
  return ra.Apply(n, a);
}
function dZ(e) {
  return Pp(e);
}
var Kb, qu = function() {
  function e(t) {
    this._ = t;
  }
  return e.prototype.parse = function(t) {
    var r = this.skip(e.eof)._(t, 0);
    return r.status ? { success: !0, value: r.value } : { success: !1, index: oP(t, r.furthest), expected: r.expected };
  }, e.prototype.tryParse = function(t) {
    var r = this.parse(t);
    if (r.success) return r.value;
    var n = function(i, a) {
      return "expected ".concat(function(o) {
        return o.length === 1 ? o[0] : "one of " + o.join(", ");
      }(a.expected)).concat(function(o, u) {
        var s = u.index, c = s.offset;
        if (c === o.length) return ", got the end of the input";
        var l = c > 0 ? "'..." : "'", d = o.length - c > 12 ? "...'" : "'";
        return " at line ".concat(s.line, " column ").concat(s.column, ", got ").concat(l).concat(o.slice(c, c + 12)).concat(d);
      }(i, a));
    }(t, r);
    throw new Error(n);
  }, e.prototype.or = function(t) {
    return e.alt(this, t);
  }, e.prototype.trim = function(t) {
    return this.wrap(t, t);
  }, e.prototype.wrap = function(t, r) {
    return I4(1, typeof t == "string" ? e.string(t) : t, this, typeof r == "string" ? e.string(r) : r);
  }, e.prototype.thru = function(t) {
    return t(this);
  }, e.prototype.then = function(t) {
    return I4(1, this, t);
  }, e.prototype.many = function() {
    var t = this;
    return new e(function(r, n) {
      for (var i = [], a = void 0; ; ) {
        if (!(a = Cu(t._(r, n), a)).status) return Cu(Ia(n, i), a);
        if (n === a.index) throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");
        n = a.index, i.push(a.value);
      }
    });
  }, e.prototype.times = function(t, r) {
    var n = this, i = r === void 0 ? t : r;
    return new e(function(a, o) {
      var u, s = [], c = void 0, l = void 0;
      for (u = 0; u < t; u++) {
        if (l = Cu(c = n._(a, o), l), !c.status) return l;
        o = c.index, s.push(c.value);
      }
      for (; u < i && (l = Cu(c = n._(a, o), l), c.status); u += 1) o = c.index, s.push(c.value);
      return Cu(Ia(o, s), l);
    });
  }, e.prototype.result = function(t) {
    return this.map(function() {
      return t;
    });
  }, e.prototype.atMost = function(t) {
    return this.times(0, t);
  }, e.prototype.atLeast = function(t) {
    return e.seq(this.times(t), this.many()).map(function(r) {
      return We(We([], r[0], !0), r[1], !0);
    });
  }, e.prototype.map = function(t) {
    var r = this;
    return new e(function(n, i) {
      var a = r._(n, i);
      return a.status ? Cu(Ia(a.index, t(a.value)), a) : a;
    });
  }, e.prototype.skip = function(t) {
    return I4(0, this, t);
  }, e.prototype.mark = function() {
    return e.seq(e.index, this, e.index).map(function(t) {
      return { start: t[0], value: t[1], end: t[2] };
    });
  }, e.prototype.node = function(t) {
    return e.seq(e.index, this, e.index).map(function(r) {
      return { name: t, start: r[0], value: r[1], end: r[2] };
    });
  }, e.prototype.sepBy = function(t) {
    return e.sepBy(this, t);
  }, e.prototype.sepBy1 = function(t) {
    return e.sepBy1(this, t);
  }, e.prototype.lookahead = function(t) {
    return this.skip(e.lookahead(t));
  }, e.prototype.notFollowedBy = function(t) {
    return this.skip(e.notFollowedBy(t));
  }, e.prototype.desc = function(t) {
    var r = this;
    return new e(function(n, i) {
      var a = r._(n, i);
      return a.status || (a.expected = [t]), a;
    });
  }, e.prototype.fallback = function(t) {
    return this.or(e.succeed(t));
  }, e.prototype.ap = function(t) {
    return e.seq(t, this).map(function(r) {
      return (0, r[0])(r[1]);
    });
  }, e.prototype.chain = function(t) {
    var r = this;
    return new e(function(n, i) {
      var a = r._(n, i);
      return a.status ? Cu(t(a.value)._(n, a.index), a) : a;
    });
  }, e;
}();
function I4(e) {
  for (var t = [], r = 1; r < arguments.length; r++) t[r - 1] = arguments[r];
  var n = t.length;
  return new qu(function(i, a) {
    for (var o, u, s = a, c = 0; c < n; c++) {
      if (!(o = Cu(t[c]._(i, s), o)).status) return o;
      e === c && (u = o.value), s = o.index;
    }
    return Cu(Ia(s, u), o);
  });
}
function Ia(e, t) {
  return { status: !0, index: e, value: t };
}
function ac(e, t) {
  return { status: !1, furthest: e, expected: [t] };
}
function Cu(e, t) {
  if (!t || e.status || t.status || e.furthest > t.furthest) return e;
  var r = e.furthest === t.furthest ? function(n, i) {
    var a = n.length, o = i.length;
    if (a === 0) return i;
    if (o === 0) return n;
    for (var u = /* @__PURE__ */ new Set(), s = [], c = 0; c < a; c++) u.has(n[c]) || (s[s.length] = n[c], u.add(n[c]));
    for (c = 0; c < o; c++) u.has(i[c]) || (s[s.length] = i[c], u.add(i[c]));
    return s.sort(), s;
  }(e.expected, t.expected) : t.expected;
  return { status: e.status, furthest: t.furthest, expected: r };
}
function oP(e, t) {
  var r = e.slice(0, t).split(`
`);
  return { offset: t, line: r.length, column: r[r.length - 1].length + 1 };
}
function fZ(e) {
  return e instanceof qu;
}
(function(e) {
  function t() {
    for (var c = [], l = 0; l < arguments.length; l++) c[l] = arguments[l];
    var d = c.length;
    return new e(function(f, m) {
      for (var v, p = new Array(d), g = m, h = 0; h < d; h++) {
        if (!(v = Cu(c[h]._(f, g), v)).status) return v;
        p[h] = v.value, g = v.index;
      }
      return Cu(Ia(g, p), v);
    });
  }
  function r() {
    for (var c = [], l = 0; l < arguments.length; l++) c[l] = arguments[l];
    return c.length === 0 ? u("zero alternates") : new e(function(d, f) {
      for (var m, v = 0; v < c.length; v++) if ((m = Cu(c[v]._(d, f), m)).status) return m;
      return m;
    });
  }
  function n(c, l) {
    return t(c, l.then(c).many()).map(function(d) {
      return We([d[0]], d[1], !0);
    });
  }
  function i(c) {
    var l = "'".concat(c, "'");
    if (c.length === 1) {
      var d = c.charCodeAt(0);
      return new e(function(f, m) {
        return f.charCodeAt(m) === d ? Ia(m + 1, c) : ac(m, l);
      });
    }
    return new e(function(f, m) {
      var v = m + c.length;
      return f.slice(m, v) === c ? Ia(v, c) : ac(m, l);
    });
  }
  function a(c, l) {
    l === void 0 && (l = 0);
    var d = function(m) {
      return RegExp("^(?:" + m.source + ")", function(v) {
        var p = "" + v;
        return p.slice(p.lastIndexOf("/") + 1);
      }(m));
    }(c), f = "" + c;
    return new e(function(m, v) {
      var p = d.exec(m.slice(v));
      if (p) {
        if (0 <= l && l <= p.length) {
          var g = p[0], h = p[l];
          return Ia(v + g.length, h);
        }
        return ac(v, "invalid match group (0 to ".concat(p.length, ") in ").concat(f));
      }
      return ac(v, f);
    });
  }
  function o(c) {
    return new e(function(l, d) {
      return Ia(d, c);
    });
  }
  function u(c) {
    return new e(function(l, d) {
      return ac(d, c);
    });
  }
  function s(c) {
    return new e(function(l, d) {
      var f = l.charAt(d);
      return d < l.length && c(f) ? Ia(d + 1, f) : ac(d, "a character " + c);
    });
  }
  e.seq = t, e.alt = r, e.sepBy = function(c, l) {
    return n(c, l).or(o([]));
  }, e.sepBy1 = n, e.string = i, e.regexp = a, e.succeed = o, e.fail = u, e.lookahead = function c(l) {
    if (fZ(l)) return new e(function(d, f) {
      var m = l._(d, f);
      return m.status && (m.index = f, m.value = null), m;
    });
    if (typeof l == "string") return c(i(l));
    if (l instanceof RegExp) return c(a(l));
    throw new Error("not a string, regexp, or parser: " + l);
  }, e.notFollowedBy = function(c) {
    return new e(function(l, d) {
      var f = c._(l, d);
      return f.status ? ac(d, 'not "' + l.slice(d, f.index) + '"') : Ia(d, null);
    });
  }, e.test = s, e.oneOf = function(c) {
    return s(function(l) {
      return c.indexOf(l) >= 0;
    });
  }, e.noneOf = function(c) {
    return s(function(l) {
      return c.indexOf(l) < 0;
    });
  }, e.range = function(c, l) {
    return s(function(d) {
      return c <= d && d <= l;
    }).desc(c + "-" + l);
  }, e.takeWhile = function(c) {
    return new e(function(l, d) {
      for (var f = d; f < l.length && c(l.charAt(f)); ) f++;
      return Ia(f, l.slice(d, f));
    });
  }, e.lazy = function(c) {
    var l = new e(function(d, f) {
      var m = c()._;
      return l._ = m, m(d, f);
    });
    return l;
  }, e.empty = function() {
    return u("empty");
  }, e.index = new e(function(c, l) {
    return Ia(l, oP(c, l));
  }), e.anyChar = new e(function(c, l) {
    return l >= c.length ? ac(l, "any character") : Ia(l + 1, c.charAt(l));
  }), e.all = new e(function(c, l) {
    return Ia(c.length, c.slice(l));
  }), e.eof = new e(function(c, l) {
    return l < c.length ? ac(l, "EOF") : Ia(l, null);
  }), e.digit = a(/[0-9]/).desc("a digit"), e.digits = a(/[0-9]*/).desc("optional digits"), e.letter = a(/[a-z]/i).desc("a letter"), e.letters = a(/[a-z]*/i).desc("optional letters"), e.optWhitespace = a(/\s*/).desc("optional whitespace"), e.whitespace = a(/\s+/).desc("whitespace"), e.cr = i("\r"), e.lf = i(`
`), e.crlf = i(`\r
`), e.newline = r(e.crlf, e.lf, e.cr).desc("newline"), e.end = r(e.newline, e.eof);
})(qu || (qu = {})), function(e) {
  var t;
  (function(p) {
    p.str = function(g) {
      return { kind: "string", value: g };
    }, p.symb = function(g) {
      return { kind: "symbol", value: g };
    }, p.list = function(g, h) {
      return { kind: "list", bracket: g, nodes: h };
    }, p.comment = function(g) {
      return { kind: "comment", value: g };
    };
  })(t || (t = {}));
  var r = qu.regexp(/[\n\r\s]*/), n = qu.lazy(function() {
    return qu.alt(i, d, a, o).trim(r);
  }), i = qu.takeWhile(function(p) {
    return p !== "`";
  }).trim("`").map(t.str), a = qu.regexp(/[^()\[\]{};`,\n\r\s]+/).map(t.symb), o = qu.regexp(/\s*;+([^\n\r]*)\n/, 1).map(t.comment), u = n.many(), s = u.wrap("(", ")").map(function(p) {
    return t.list("(", p);
  }), c = u.wrap("[", "]").map(function(p) {
    return t.list("[", p);
  }), l = u.wrap("{", "}").map(function(p) {
    return t.list("{", p);
  }), d = qu.alt(s, c, l), f = n.many();
  function m(p) {
    switch (p.kind) {
      case "string":
        return p.value;
      case "symbol":
        var g = p.value;
        if (g.length > 1) switch (g.charAt(0)) {
          case ".":
            return Nt.atomName(g.substr(1));
          case "_":
            return Nt.struct.type.elementSymbol([g.substr(1)]);
        }
        return g === "true" || g !== "false" && (function(y) {
          return /-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/.test(y) && !isNaN(+y);
        }(g) ? +g : ra.Symbol(g));
      case "list":
        switch (p.bracket) {
          case "[":
            return Nt.core.type.list(v(p.nodes).map(m));
          case "{":
            return Nt.core.type.set(v(p.nodes).map(m));
          case "(":
            if (p.nodes[0].kind === "comment") throw new Error("Invalid expression");
            var h = m(p.nodes[0]);
            return ra.Apply(h, function(y) {
              if (!(y.length <= 1)) {
                if (!function(B) {
                  for (var N = 1, O = B.length; N < O; N++) {
                    var z = B[N];
                    if (z.kind === "symbol" && z.value.length > 1 && z.value.charAt(0) === ":") return !0;
                  }
                  return !1;
                }(y)) {
                  for (var x = [], A = 1, b = y.length; A < b; A++)
                    (I = y[A]).kind !== "comment" && (x[x.length] = m(I));
                  return x;
                }
                var _ = {}, S = !0, D = 0;
                for (A = 1, b = y.length; A < b; A++) {
                  var I;
                  if ((I = y[A]).kind !== "comment") if (I.kind === "symbol" && I.value.length > 1 && I.value.charAt(0) === ":") {
                    var M = I.value.substr(1);
                    for (++A; A < b && y[A].kind === "comment"; ) A++;
                    if (A >= b) throw new Error("There must be a value foolowed a named arg ':".concat(M, "'."));
                    if (y[A].kind === "comment") throw new Error("Invalid expression");
                    _[M] = m(y[A]), isNaN(+M) && (S = !1);
                  } else _[D++] = m(I);
                }
                if (S) {
                  var F = Object.keys(_).map(function(B) {
                    return +B;
                  }).sort(function(B, N) {
                    return B - N;
                  }), P = !0;
                  for (A = 0, b = F.length; A < b; A++) if (F[A] !== A) {
                    P = !1;
                    break;
                  }
                  if (P) {
                    var E = [];
                    for (A = 0, b = F.length; A < b; A++) E[A] = _[A];
                    return E;
                  }
                }
                return _;
              }
            }(p.nodes));
          default:
            Hi(p.bracket);
        }
      default:
        Hi();
    }
  }
  function v(p) {
    for (var g = !1, h = 0, y = p.length; h < y; h++) if (p[h].kind === "comment") {
      g = !0;
      break;
    }
    return g ? p.filter(function(x) {
      return x.kind !== "comment";
    }) : p;
  }
  e.parse = function(p) {
    for (var g = function(b) {
      return f.tryParse(b);
    }(p), h = [], y = 0, x = g; y < x.length; y++) {
      var A = x[y];
      A.kind !== "comment" && (h[h.length] = m(A));
    }
    return h;
  };
}(Kb || (Kb = {}));
var zC, t0, Xp, k2, pZ = function() {
  function e() {
    this.map = /* @__PURE__ */ new Map();
  }
  return e.prototype.removeSymbol = function(t) {
    this.map.delete(t.symbol.id);
  }, e.prototype.addSymbol = function(t) {
    this.map.has(t.symbol.id) && console.warn("Symbol '".concat(t.symbol.id, "' already added. Call removeSymbol/removeCustomProps re-adding the symbol.")), this.map.set(t.symbol.id, t);
  }, e.prototype.addCustomProp = function(t) {
    if (t.symbols) for (var r = 0, n = Object.keys(t.symbols); r < n.length; r++) {
      var i = n[r];
      this.addSymbol(t.symbols[i]);
    }
  }, e.prototype.removeCustomProp = function(t) {
    if (t.symbols) for (var r = 0, n = Object.keys(t.symbols); r < n.length; r++) {
      var i = n[r];
      this.removeSymbol(t.symbols[i]);
    }
  }, e.prototype.getRuntime = function(t) {
    return this.map.get(t);
  }, e;
}(), uP = new pZ(), mZ = function(e) {
  this.table = e, this.constQueryContext = new ff(tt.Empty);
};
(function(e) {
  e.Const = function(t) {
    return { kind: "const", value: t };
  }, e.Dynamic = function(t) {
    return { kind: "dynamic", runtime: t };
  };
})(zC || (zC = {})), function(e) {
  e.Const = function(t) {
    return { isConst: !0, fn: function(r) {
      return t;
    } };
  }, e.Dynamic = function(t) {
    return { isConst: !1, fn: t };
  };
}(t0 || (t0 = {})), function(e) {
  e.forEachEval = function(t, r, n, i) {
    if (typeof t.length == "number") for (var a = 0, o = t.length; a < o; a++) n(t[a](r), a, i);
    else {
      a = 0;
      for (var u = 0, s = Object.keys(t); u < s.length; u++)
        n(t[s[u]](r), a++, i);
    }
    return i;
  };
}(Xp || (Xp = {})), function(e) {
  e.Const = function(t, r) {
    return new GC(t, r, !0);
  }, e.Dynamic = function(t, r) {
    return new GC(t, r, !1);
  };
}(k2 || (k2 = {}));
var Rs, GC = function() {
  function e(t, r, n) {
    this.symbol = t, this.fn = r, this.isConst = n;
  }
  return e.prototype.compile = function(t, r) {
    var n, i = !1;
    if (r) if (ra.isArgumentsArray(r)) {
      n = [], i = !0;
      for (var a = 0, o = r; a < o.length; a++) {
        var u = Xb(t, o[a]);
        i = i && u.isConst, n.push(u.fn);
      }
    } else {
      n = /* @__PURE__ */ Object.create(null), i = !0;
      for (var s = 0, c = Object.keys(r); s < c.length; s++) {
        var l = c[s];
        u = Xb(t, r[l]), i = i && u.isConst, n[l] = u.fn;
      }
    }
    else n = void 0, i = !0;
    return this.isConst && this.isConst && i ? t0.Const(this.fn(t.constQueryContext, n)) : t0.Dynamic(hZ(this.fn, n));
  }, e;
}();
function hZ(e, t) {
  return function(r) {
    return e(r, t);
  };
}
function Xb(e, t) {
  if (ra.isLiteral(t)) return t0.Const(t);
  if (ra.isSymbol(t)) {
    var r = e.table.getRuntime(t.name);
    return r ? r.compile(e) : t0.Const(t.name);
  }
  if (!ra.isSymbol(t.head)) throw new Error("Can only apply symbols.");
  var n = e.table.getRuntime(t.head.name);
  if (!n) throw new Error("Symbol '".concat(t.head.name, "' is not implemented."));
  return n.compile(e, t.args);
}
function z2(e) {
  return Xb(new mZ(uP), e).fn;
}
function Hl(e, t) {
  return { expression: e, language: t };
}
function um(e) {
  return { layers: e };
}
function sm(e, t) {
  return { kind: e, layers: t };
}
(function(e) {
  function t(n) {
    if (n.language === "mol-script") {
      var i = (a = n.expression, Kb.parse(a));
      if (i.length === 0) throw new Error("No query");
      return dZ(i[0]);
    }
    var a;
    throw new Error("unsupported script language");
  }
  function r(n) {
    return z2(t(n));
  }
  e.is = function(n) {
    return !!n && typeof n.expression == "string" && !!n.language;
  }, e.areEqual = function(n, i) {
    return n.language === i.language && n.expression === i.expression;
  }, e.toExpression = t, e.toQuery = r, e.toLoci = function(n, i) {
    var a = r(n)(new ff(i));
    return vt.toLociWithSourceUnits(a);
  }, e.getStructureSelection = function(n, i, a) {
    return z2(typeof n == "function" ? n(Nt) : n)(new ff(i, a));
  };
})(Hl || (Hl = {})), function(e) {
  function t(r) {
    return r.layers.length === 0;
  }
  e.Empty = { layers: [] }, e.areEqual = function(r, n) {
    if (r.layers.length === 0 && n.layers.length === 0) return !0;
    if (r.layers.length !== n.layers.length) return !1;
    for (var i = 0, a = r.layers.length; i < a; ++i)
      if (r.layers[i].clear !== n.layers[i].clear || r.layers[i].color !== n.layers[i].color || !Hr.areEqual(r.layers[i].loci, n.layers[i].loci)) return !1;
    return !0;
  }, e.isEmpty = t, e.remap = function(r, n) {
    for (var i = [], a = 0, o = r.layers; a < o.length; a++) {
      var u = o[a], s = u.loci, c = u.color, l = u.clear;
      s = Xe.remap(s, n), Xe.isEmpty(s) || i.push({ loci: s, color: c, clear: l });
    }
    return { layers: i };
  }, e.merge = function(r) {
    if (t(r)) return r;
    for (var n = r.layers[0].loci.structure, i = /* @__PURE__ */ new Map(), a = Xe.none(n), o = 0, u = r.layers.length; o < u; ++o) {
      var s = r.layers[u - o - 1], c = s.loci, l = s.color, d = s.clear;
      if (c = Xe.subtract(c, a), a = Xe.union(c, a), !Xe.isEmpty(c)) {
        var f = d ? -1 : l;
        i.has(f) && (c = Xe.union(c, i.get(f))), i.set(f, c);
      }
    }
    var m = [];
    return i.forEach(function(v, p) {
      var g = p === -1, h = g ? He(0) : p;
      m.push({ loci: v, color: h, clear: g });
    }), { layers: m };
  }, e.filter = function(r, n) {
    if (t(r)) return r;
    for (var i = r.layers[0].loci.structure, a = [], o = 0, u = r.layers; o < u.length; o++) {
      var s = u[o], c = s.loci, l = s.color, d = s.clear, f = Xe.remap(c, n);
      c = Xe.remap(f, i), Xe.isEmpty(c) || a.push({ loci: c, color: l, clear: d });
    }
    return { layers: a };
  }, e.ofScript = function(r, n) {
    for (var i = [], a = 0, o = r.length; a < o; ++a) {
      var u = r[a], s = u.script, c = u.color, l = u.clear, d = Hl.toLoci(s, n);
      Xe.isEmpty(d) || i.push({ loci: d, color: c, clear: l });
    }
    return { layers: i };
  }, e.ofBundle = function(r, n) {
    for (var i = [], a = 0, o = r.length; a < o; ++a) {
      var u = r[a], s = u.bundle, c = u.color, l = u.clear, d = $a.toLoci(s, n.root);
      i.push({ loci: d, color: c, clear: l });
    }
    return { layers: i };
  }, e.toBundle = function(r) {
    for (var n = [], i = 0, a = r.layers.length; i < a; ++i) {
      var o = r.layers[i], u = o.loci, s = o.color, c = o.clear, l = $a.fromLoci(u);
      n.push({ bundle: l, color: s, clear: c });
    }
    return { layers: n };
  };
}(um || (um = {})), function(e) {
  function t(r) {
    return r.layers.length === 0;
  }
  e.Empty = { kind: "empty-loci", layers: [] }, e.areEqual = function(r, n) {
    if (r.layers.length === 0 && n.layers.length === 0) return !0;
    if (r.layers.length !== n.layers.length) return !1;
    for (var i = 0, a = r.layers.length; i < a; ++i)
      if (r.layers[i].value !== n.layers[i].value || !Hr.areEqual(r.layers[i].loci, n.layers[i].loci)) return !1;
    return !0;
  }, e.isEmpty = t, e.remap = function(r, n) {
    if (r.kind === "element-loci") {
      for (var i = [], a = 0, o = r.layers; a < o.length; a++) {
        var u = o[a], s = Xe.remap(u.loci, n);
        Xe.isEmpty(s) || i.push({ loci: s, value: u.value });
      }
      return { kind: "element-loci", layers: i };
    }
    return r;
  }, e.merge = function(r) {
    if (t(r)) return r;
    if (r.kind === "element-loci") {
      for (var n = r.layers[0].loci.structure, i = /* @__PURE__ */ new Map(), a = Xe.none(n), o = 0, u = r.layers.length; o < u; ++o) {
        var s = r.layers[u - o - 1], c = s.loci, l = s.value;
        c = Xe.subtract(c, a), a = Xe.union(c, a), Xe.isEmpty(c) || (i.has(l) && (c = Xe.union(c, i.get(l))), i.set(l, c));
      }
      var d = [];
      return i.forEach(function(f, m) {
        d.push({ loci: f, value: m });
      }), { kind: "element-loci", layers: d };
    }
    return r;
  }, e.filter = function(r, n) {
    if (t(r)) return r;
    if (r.kind === "element-loci") {
      for (var i = r.layers[0].loci.structure, a = [], o = 0, u = r.layers; o < u.length; o++) {
        var s = u[o], c = s.loci, l = s.value, d = Xe.remap(c, n);
        c = Xe.remap(d, i), Xe.isEmpty(c) || a.push({ loci: c, value: l });
      }
      return { kind: "element-loci", layers: a };
    }
    return r;
  }, e.ofScript = function(r, n) {
    for (var i = [], a = 0, o = r.length; a < o; ++a) {
      var u = r[a], s = u.script, c = u.value, l = Hl.toLoci(s, n);
      Xe.isEmpty(l) || i.push({ loci: l, value: c });
    }
    return { kind: "element-loci", layers: i };
  }, e.ofBundle = function(r, n) {
    for (var i = [], a = 0, o = r.length; a < o; ++a) {
      var u = r[a], s = u.bundle, c = u.value, l = $a.toLoci(s, n.root);
      i.push({ loci: l, value: c });
    }
    return { kind: "element-loci", layers: i };
  }, e.toBundle = function(r) {
    for (var n = [], i = 0, a = r.layers.length; i < a; ++i) {
      var o = r.layers[i], u = o.loci, s = o.value, c = $a.fromLoci(u);
      n.push({ bundle: c, value: s });
    }
    return { kind: "element-loci", layers: n };
  };
}(sm || (sm = {})), function(e) {
  e.create = function() {
    return { updateTransform: !1, updateMatrix: !1, updateColor: !1, updateSize: !1, createGeometry: !1, createNew: !1, info: {} };
  }, e.reset = function(t) {
    t.updateTransform = !1, t.updateMatrix = !1, t.updateColor = !1, t.updateSize = !1, t.createGeometry = !1, t.createNew = !1;
  };
}(Rs || (Rs = {}));
var vZ = { lowestElementCount: 1e6, lowerElementCount: 5e5, lowElementCount: 1e5, mediumElementCount: 2e4, highElementCount: 2e3, coarseGrainedFactor: 10, elementCountFactor: 1 };
function jb(e, t) {
  var r = Ci(e.quality, "auto"), n = Ci(e.detail, 1), i = Ci(e.radialSegments, 12), a = Ci(e.linearSegments, 8), o = Ci(e.resolution, 2), u = Ci(e.probePositions, 12), s = Ci(e.doubleSided, !0), c = 0;
  if (r === "auto") {
    if (t instanceof tt) r = function(d, f) {
      f === void 0 && (f = {});
      var m = R(R({}, vZ), f), v = d.elementCount * m.elementCountFactor;
      return d.isCoarseGrained && (v *= m.coarseGrainedFactor), v > m.lowestElementCount ? "lowest" : v > m.lowerElementCount ? "lower" : v > m.lowElementCount ? "low" : v > m.mediumElementCount ? "medium" : v > m.highElementCount ? "high" : "higher";
    }(t.root), c = function(d) {
      if (d.root.models.length === 1) {
        var f = ia.Provider.get(d.root.model);
        if (f && f.spacegroup.name === "P 1" && !Tu.isZero(f.spacegroup.cell)) return f.spacegroup.cell.volume;
      }
      return qr.volume(d.root.boundary.box);
    }(t);
    else if (ar.is(t)) {
      var l = t.grid.cells.space.dimensions;
      r = (c = l[0] * l[1] * l[2]) < 1e7 ? "medium" : "low";
    }
  }
  switch (r) {
    case "highest":
      n = 3, i = 36, a = 18, o = 0.1, u = 72, s = !0;
      break;
    case "higher":
      n = 3, i = 28, a = 14, o = 0.3, u = 48, s = !0;
      break;
    case "high":
      n = 2, i = 20, a = 10, o = 0.5, u = 36, s = !0;
      break;
    case "medium":
      n = 1, i = 12, a = 8, o = 0.8, u = 24, s = !0;
      break;
    case "low":
      n = 0, i = 8, a = 3, o = 1.3, u = 24, s = !1;
      break;
    case "lower":
      n = 0, i = 4, a = 2, o = 3, u = 12, s = !1;
      break;
    case "lowest":
      n = 0, i = 2, a = 1, o = 8, u = 12, s = !1;
  }
  return o = Math.max(o, c / 5e8), o = Math.min(o, 20), (e.alpha !== void 0 && e.alpha < 1 || e.xrayShaded) && (s = !1), { detail: n, radialSegments: i, linearSegments: a, resolution: o, probePositions: u, doubleSided: s };
}
function G2(e, t) {
  t === void 0 && (t = 0);
  var r = e[0] * e[1] * e[2], n = Math.sqrt(r), i = Math.pow(2, Math.ceil(Math.log(n) / Math.log(2))), a = e[0] + t, o = e[1] + t, u = 1, s = a;
  return i < a * e[2] ? (a *= s = Math.floor(i / a), o *= u = Math.ceil(e[2] / s)) : a *= e[2], { width: a, height: o, columns: s, rows: u, powerOfTwoSize: o < i ? i : 2 * i };
}
function t2(e, t, r, n, i) {
  var a = e.colorType, o = e.vertexCount, u = e.groupCount, s = e.positionBuffer, c = e.transformBuffer, l = e.groupBuffer, d = e.itemSize, f = a.endsWith("Instance"), m = qr.fromSphere3D(qr(), f ? e.boundingSphere : e.invariantBoundingSphere), v = 1 + t, p = qr.expand(qr(), m, w.create(v, v, v)), g = 1 / t, h = qr.scale(qr(), p, g), y = qr.size(w(), h);
  w.ceil(y, y), w.add(y, y, w.create(2, 2, 2));
  var x = p.min, A = y[0], b = y[1], _ = G2(y), S = _.width, D = _.height, I = new Float32Array(S * D * d), M = new Float32Array(S * D), F = new Uint8Array(S * D * d), P = { array: F, width: S, height: D, filter: "linear" }, E = f ? e.instanceCount : 1, B = e.colorData.array;
  function N(mt, bt, Ct) {
    var De = Math.floor(Ct * A % S / A), ut = Math.floor(Ct * A / S);
    return d * (ut * b * S + bt * S + (De * A + mt));
  }
  for (var O = y[0], z = y[1], V = y[2], U = w(), H = 0; H < E; ++H) for (var K = 0; K < o; K += r) {
    w.fromArray(U, s, 3 * K), f && w.transformMat4Offset(U, U, c, 0, 0, 16 * H), w.sub(U, U, x), w.scale(U, U, g);
    for (var j = U[0], X = U[1], W = U[2], Q = Math.floor(j), te = Math.floor(X), ee = Math.floor(W), $ = (H * u + l[K]) * d, ie = Math.max(0, Q - 2), ae = Math.max(0, te - 2), se = Math.max(0, ee - 2), le = Math.min(O, Q + 2 + 2), pe = Math.min(z, te + 2 + 2), we = Math.min(V, ee + 2 + 2), Ge = ie; Ge < le; ++Ge) for (var Ue = Ge - j, Ke = ae; Ke < pe; ++Ke) for (var Ze = Ke - X, Fe = se; Fe < we; ++Fe) {
      var Je = Fe - W, Ne = Math.sqrt(Ue * Ue + Ze * Ze + Je * Je);
      if (!(Ne > 2)) {
        for (var nt = 2 - Ne, re = N(Ge, Ke, Fe), J = 0; J < d; ++J) I[re + J] += B[$ + J] * nt;
        M[re / d] += nt;
      }
    }
  }
  H = 0;
  for (var ce = M.length; H < ce; ++H) {
    var de = H * d, ve = M[H];
    for (J = 0; J < d; ++J) F[de + J] = Math.round(I[de + J] / ve);
  }
  var he = ke.create(S, D), Se = Vt.create(x[0], x[1], x[2], g), Re = f ? "volumeInstance" : "volume";
  if (n) {
    if (!i) {
      var Ve = d === 4 ? "rgba" : d === 3 ? "rgb" : "alpha";
      i = n.resources.texture("image-uint8", Ve, "ubyte", "linear");
    }
    return i.load(P), { kind: "volume", texture: i, gridTexDim: he, gridDim: y, gridTransform: Se, type: Re };
  }
  var ze = function(mt) {
    var bt = mt.vertexCount, Ct = mt.positionBuffer, De = mt.transformBuffer, ut = mt.grid, It = mt.gridDim, ur = mt.gridTexDim, nr = mt.gridTransform, Er = mt.vertexStride, dr = mt.colorStride, ln = mt.itemOffset || 0, Gn = mt.outputStride;
    if (Gn + ln > dr) throw new Error("outputStride + itemOffset must NOT be larger than colorStride");
    var Rn = mt.colorType.endsWith("Instance"), Cn = Rn ? mt.instanceCount : 1, Jr = Di(Math.max(1, Cn * bt), Gn, Uint8Array), ni = Jr.array, $r = It[0], en = It[1], fi = ur[0], pi = w.fromArray(w(), nr, 0), za = nr[3];
    function wn(v3, Wm, Rf) {
      var P0 = Math.floor(Rf * $r % fi / $r), Zc = Math.floor(Rf * $r / fi);
      return dr * (Zc * en * fi + Wm * fi + (P0 * $r + v3));
    }
    for (var dn = w(), wo = w(), Do = w(), io = w(), os = 0; os < Cn; ++os) for (var Ga = 0; Ga < bt; ++Ga) {
      w.fromArray(dn, Ct, Ga * Er), Rn && w.transformMat4Offset(dn, dn, De, 0, 0, 16 * os), w.sub(dn, dn, pi), w.scale(dn, dn, za), w.floor(wo, dn), w.ceil(Do, dn), w.sub(io, dn, wo), w.sub(dn, Do, wo), w.div(io, io, dn);
      for (var mi = wo[0], Gs = wo[1], Hc = wo[2], qc = Do[0], Kc = Do[1], Xc = Do[2], jc = io[0], Bf = io[1], Yc = io[2], Vs = wn(mi, Gs, Hc) + ln, Fr = wn(qc, Gs, Hc) + ln, Ki = wn(mi, Gs, Xc) + ln, E0 = wn(qc, Gs, Xc) + ln, Wc = wn(mi, Kc, Hc) + ln, us = wn(qc, Kc, Hc) + ln, Ff = wn(mi, Kc, Xc) + ln, Vm = wn(qc, Kc, Xc) + ln, d3 = (os * bt + Ga) * Gn, Io = 0; Io < Gn; ++Io) {
        var f3 = ut[Vs + Io], p3 = ut[Fr + Io], Um = ut[Ki + Io], Hm = ut[E0 + Io], qm = ut[Wc + Io], M0 = ut[us + Io], m3 = ut[Ff + Io], Km = ut[Vm + Io], Nf = Si(f3, p3, jc), Xm = Si(Um, Hm, jc), h3 = Si(qm, M0, jc), jm = Si(m3, Km, jc), Ym = Si(Nf, h3, Bf), T0 = Si(Xm, jm, Bf);
        ni[d3 + Io] = Si(Ym, T0, Yc);
      }
    }
    return Jr;
  }({ vertexCount: o, instanceCount: E, transformBuffer: c, positionBuffer: s, colorType: Re, grid: F, gridDim: y, gridTexDim: he, gridTransform: Se, vertexStride: 3, colorStride: d, outputStride: d });
  return { kind: "vertex", texture: ze, texDim: ke.create(ze.width, ze.height), type: f ? "vertexInstance" : "vertex" };
}
w.set, w.normalize, w.sub, w.addScalar, w.scale, w.toArray;
var gZ = `
precision highp float;
precision highp sampler2D;

uniform sampler2D tColor;
uniform sampler2D tCount;
uniform vec2 uTexSize;

void main(void) {
    vec2 coords = gl_FragCoord.xy / uTexSize;
    vec4 color = texture2D(tColor, coords);
    float count = texture2D(tCount, coords).r;

    gl_FragColor = color / count;
}
`, yZ = `
precision highp float;

varying vec3 vPosition;
varying vec4 vColor;

uniform float uCurrentSlice;
uniform float uCurrentX;
uniform float uCurrentY;
uniform float uResolution;

const float p = 2.0;

void main() {
    vec2 v = gl_FragCoord.xy - vec2(uCurrentX, uCurrentY) - 0.5;
    vec3 fragPos = vec3(v.x, v.y, uCurrentSlice);
    float dist = distance(fragPos, vPosition);
    if (dist > p) discard;

    float f = p - dist;
    gl_FragColor = vColor * f;
    gl_FragData[1] = vec4(f);
}
`, bZ = `
precision highp float;

#include common
#include read_from_texture

uniform int uTotalCount;
uniform int uGroupCount;

attribute float aSample;
#define SampleID int(aSample)

attribute mat4 aTransform;
attribute float aInstance;

uniform vec2 uGeoTexDim;
uniform sampler2D tPosition;
uniform sampler2D tGroup;

uniform vec2 uColorTexDim;
uniform sampler2D tColor;

varying vec3 vPosition;
varying vec4 vColor;

uniform vec3 uBboxSize;
uniform vec3 uBboxMin;
uniform float uResolution;

void main() {
    vec3 position = readFromTexture(tPosition, SampleID, uGeoTexDim).xyz;
    float group = unpackRGBToInt(readFromTexture(tGroup, SampleID, uGeoTexDim).rgb);

    position = (aTransform * vec4(position, 1.0)).xyz;
    gl_PointSize = 7.0;
    vPosition = (position - uBboxMin) / uResolution;
    gl_Position = vec4(((position - uBboxMin) / uBboxSize) * 2.0 - 1.0, 1.0);

    #if defined(dColorType_group)
        vColor = readFromTexture(tColor, group, uColorTexDim);
    #elif defined(dColorType_groupInstance)
        vColor = readFromTexture(tColor, aInstance * float(uGroupCount) + group, uColorTexDim);
    #endif
}
`, _Z = { drawCount: ci("number"), instanceCount: ci("number"), stride: ci("number"), uTotalCount: Ie("i"), uInstanceCount: Ie("i"), uGroupCount: Ie("i"), aTransform: Vr("float32", 16, 1), aInstance: Vr("float32", 1, 1), aSample: Vr("float32", 1, 0), uGeoTexDim: Ie("v2", "buffered"), tPosition: zt("texture", "rgba", "float", "nearest"), tGroup: zt("texture", "rgba", "float", "nearest"), uColorTexDim: Ie("v2"), tColor: zt("texture", "rgba", "ubyte", "nearest"), dColorType: kt("string", ["group", "groupInstance", "vertex", "vertexInstance"]), uCurrentSlice: Ie("f"), uCurrentX: Ie("f"), uCurrentY: Ie("f"), uBboxMin: Ie("v3", "material"), uBboxSize: Ie("v3", "material"), uResolution: Ie("f", "material") }, zo = "color-accumulate", J0 = "color-count";
function VC(e, t) {
  for (var r = new Float32Array(e), n = 0; n < e; ++n) r[n] = n * t;
  return r;
}
function xZ(e, t, r, n, i) {
  if (e.namedComputeRenderables[zo]) {
    var a = w.sub(w(), r.max, r.min), o = e.namedComputeRenderables[zo].values, u = Math.round(t.vertexCount / i);
    (u > o.drawCount.ref.value || i !== o.stride.ref.value) && k.update(o.aSample, VC(u, i)), k.updateIfChanged(o.drawCount, u), k.updateIfChanged(o.instanceCount, t.instanceCount), k.updateIfChanged(o.stride, i), k.updateIfChanged(o.uTotalCount, t.vertexCount), k.updateIfChanged(o.uInstanceCount, t.instanceCount), k.updateIfChanged(o.uGroupCount, t.groupCount), k.update(o.aTransform, t.transformBuffer), k.update(o.aInstance, t.instanceBuffer), k.update(o.uGeoTexDim, ke.set(o.uGeoTexDim.ref.value, t.positionTexture.getWidth(), t.positionTexture.getHeight())), k.update(o.tPosition, t.positionTexture), k.update(o.tGroup, t.groupTexture), k.update(o.uColorTexDim, ke.set(o.uColorTexDim.ref.value, t.colorData.getWidth(), t.colorData.getHeight())), k.update(o.tColor, t.colorData), k.updateIfChanged(o.dColorType, t.colorType), k.updateIfChanged(o.uCurrentSlice, 0), k.updateIfChanged(o.uCurrentX, 0), k.updateIfChanged(o.uCurrentY, 0), k.update(o.uBboxMin, r.min), k.update(o.uBboxSize, a), k.updateIfChanged(o.uResolution, n), e.namedComputeRenderables[zo].update();
  } else e.namedComputeRenderables[zo] = function(s, c, l, d, f) {
    var m = w.sub(w(), l.max, l.min), v = Math.round(c.vertexCount / f), p = { drawCount: k.create(v), instanceCount: k.create(c.instanceCount), stride: k.create(f), uTotalCount: k.create(c.vertexCount), uInstanceCount: k.create(c.instanceCount), uGroupCount: k.create(c.groupCount), aTransform: k.create(c.transformBuffer), aInstance: k.create(c.instanceBuffer), aSample: k.create(VC(v, f)), uGeoTexDim: k.create(ke.create(c.positionTexture.getWidth(), c.positionTexture.getHeight())), tPosition: k.create(c.positionTexture), tGroup: k.create(c.groupTexture), uColorTexDim: k.create(ke.create(c.colorData.getWidth(), c.colorData.getHeight())), tColor: k.create(c.colorData), dColorType: k.create(c.colorType), uCurrentSlice: k.create(0), uCurrentX: k.create(0), uCurrentY: k.create(0), uBboxMin: k.create(l.min), uBboxSize: k.create(m), uResolution: k.create(d) }, g = R({}, _Z), h = Sn("accumulate", bZ, yZ, { drawBuffers: "required" }), y = Bi(s, "points", h, g, p);
    return Fi(y, p);
  }(e, t, r, n, i);
  return e.namedComputeRenderables[zo];
}
var AZ = R(R({}, qi), { tColor: zt("texture", "rgba", "float", "nearest"), tCount: zt("texture", "alpha", "float", "nearest"), uTexSize: Ie("v2") }), $0 = "color-normalize";
function SZ(e, t, r) {
  if (e.namedComputeRenderables[$0]) {
    var n = e.namedComputeRenderables[$0].values;
    k.update(n.tColor, t), k.update(n.tCount, r), k.update(n.uTexSize, ke.set(n.uTexSize.ref.value, t.getWidth(), t.getHeight())), e.namedComputeRenderables[$0].update();
  } else e.namedComputeRenderables[$0] = function(i, a, o) {
    var u = R(R({}, Ui), { tColor: k.create(a), tCount: k.create(o), uTexSize: k.create(ke.create(a.getWidth(), a.getHeight())) }), s = R({}, AZ), c = Sn("normalize", Fa, gZ), l = Bi(i, "triangles", c, s, u);
    return Fi(l, u);
  }(e, t, r);
  return e.namedComputeRenderables[$0];
}
function E4(e, t, r, n, i) {
  var a = n.extensions.drawBuffers;
  if (!a) throw new Error("need WebGL draw buffers");
  var o = n.gl, u = n.resources, s = n.state, c = n.extensions, l = c.colorBufferHalfFloat, d = c.textureHalfFloat, f = e.colorType.endsWith("Instance"), m = qr.fromSphere3D(qr(), f ? e.boundingSphere : e.invariantBoundingSphere), v = 1 + t, p = qr.expand(qr(), m, w.create(v, v, v)), g = 1 / t, h = qr.scale(qr(), p, g), y = qr.size(w(), h);
  w.ceil(y, y), w.add(y, y, w.create(2, 2, 2));
  var x = p.min, A = y[0], b = y[1], _ = y[2], S = function(te) {
    var ee = te[0] * te[1] * te[2], $ = Math.sqrt(ee), ie = Math.pow(2, Math.ceil(Math.log($) / Math.log(2))), ae = 0, se = te[1], le = 1, pe = te[2];
    return ie < te[0] * te[2] ? (pe = Math.floor(ie / te[0]), le = Math.ceil(te[2] / pe), ae = pe * te[0], se *= le) : ae = te[0] * te[2], { texDimX: ae, texDimY: se, texRows: le, texCols: pe, powerOfTwoSize: se < ie ? ie : 2 * ie };
  }(y), D = S.texDimX, I = S.texDimY, M = S.texCols;
  n.namedFramebuffers[zo] || (n.namedFramebuffers[zo] = n.resources.framebuffer());
  var F = n.namedFramebuffers[zo];
  ir(o) ? (n.namedTextures[zo] || (n.namedTextures[zo] = l && d ? u.texture("image-float16", "rgba", "fp16", "nearest") : u.texture("image-float32", "rgba", "float", "nearest")), n.namedTextures[J0] || (n.namedTextures[J0] = u.texture("image-float32", "alpha", "float", "nearest"))) : (n.namedTextures[zo] || (n.namedTextures[zo] = u.texture("image-float32", "rgba", "float", "nearest")), n.namedTextures[J0] || (n.namedTextures[J0] = u.texture("image-float32", "rgba", "float", "nearest")));
  var P = n.namedTextures[zo], E = n.namedTextures[J0];
  P.define(D, I), E.define(D, I), P.attachFramebuffer(F, 0), E.attachFramebuffer(F, 1);
  var B = xZ(n, e, p, t, r);
  s.currentRenderItemId = -1, F.bind(), a.drawBuffers([a.COLOR_ATTACHMENT0, a.COLOR_ATTACHMENT1]);
  var N = B.values, O = N.uCurrentSlice, z = N.uCurrentX, V = N.uCurrentY;
  (function(te) {
    var ee = te.gl, $ = te.state;
    $.disable(ee.CULL_FACE), $.enable(ee.BLEND), $.disable(ee.DEPTH_TEST), $.enable(ee.SCISSOR_TEST), $.depthMask(!1), $.clearColor(0, 0, 0, 0), $.blendFunc(ee.ONE, ee.ONE), $.blendEquation(ee.FUNC_ADD);
  })(n), o.viewport(0, 0, D, I), o.scissor(0, 0, D, I), o.clear(o.COLOR_BUFFER_BIT), k.update(V, 0);
  for (var U = 0, H = 0, K = 0, j = 0; j < _; ++j) U >= M && (U -= M, H += b, K = 0, k.update(V, H)), k.update(z, K), k.update(O, j), o.viewport(K, H, A, b), o.scissor(K, H, A, b), B.render(), ++U, K += A;
  P.detachFramebuffer(F, 0), E.detachFramebuffer(F, 1), a.drawBuffers([o.COLOR_ATTACHMENT0, o.NONE]), i || (i = u.texture("image-uint8", "rgba", "ubyte", "linear")), i.define(D, I);
  var X = SZ(n, P, E);
  s.currentRenderItemId = -1, function(te) {
    var ee = te.gl, $ = te.state;
    $.disable(ee.CULL_FACE), $.enable(ee.BLEND), $.disable(ee.DEPTH_TEST), $.enable(ee.SCISSOR_TEST), $.depthMask(!1), $.clearColor(0, 0, 0, 0), $.blendFunc(ee.ONE, ee.ONE), $.blendEquation(ee.FUNC_ADD);
  }(n), i.attachFramebuffer(F, 0), o.viewport(0, 0, D, I), o.scissor(0, 0, D, I), o.clear(o.COLOR_BUFFER_BIT), X.render();
  var W = Vt.create(x[0], x[1], x[2], g), Q = f ? "volumeInstance" : "volume";
  return { texture: i, gridDim: y, gridTexDim: ke.create(D, I), gridTransform: W, type: Q };
}
var rr, UC, o1 = "color-smoothing-rgba", M4 = "color-smoothing-alpha";
function cm(e) {
  return { layers: e };
}
function lm(e) {
  return { layers: e };
}
(function(e) {
  e.setVisibility = function(t, r) {
    t && (t.state.visible = r);
  }, e.setAlphaFactor = function(t, r) {
    t && (t.state.alphaFactor = r);
  }, e.setPickable = function(t, r) {
    t && (t.state.pickable = r);
  }, e.setColorOnly = function(t, r) {
    t && (t.state.colorOnly = r);
  }, e.mark = function(t, r, n, i, a) {
    if (!t || Jl(r)) return !1;
    var o = t.values, u = o.tMarker, s = o.uMarker, c = o.markerAverage, l = o.markerStatus, d = o.uGroupCount, f = o.instanceCount, m = d.ref.value * f.ref.value, v = u.ref.value.array, p = l.ref.value;
    if (!xo(r)) {
      var g = 0;
      if (i(r, function(b) {
        return g += Ae.size(b), !0;
      }, !0), g === 0) return !1;
      g === m && (r = B_);
    }
    var h = !1, y = -1, x = -1;
    if (xo(r)) {
      var A = function(b, _) {
        var S = -1, D = -1;
        switch (b) {
          case _t.Highlight:
            _ === 0 || _ === 1 ? (S = 1, D = 1) : _ === 2 || _ === 3 ? (S = 1, D = 3) : S = 1;
            break;
          case _t.RemoveHighlight:
            _ === 0 || _ === 1 ? (S = 0, D = 0) : _ !== 2 && _ !== 3 || (S = 1, D = 2);
            break;
          case _t.Select:
            _ === 1 || _ === 3 ? (S = 1, D = 3) : _ === 0 || _ === 2 ? (S = 1, D = 2) : S = 1;
            break;
          case _t.Deselect:
            _ === 1 || _ === 3 ? (S = 1, D = 1) : _ !== 0 && _ !== 2 || (S = 0, D = 0);
            break;
          case _t.Toggle:
            _ === 1 ? (S = 1, D = 3) : _ === 2 ? (S = 0, D = 0) : _ === 3 ? (S = 1, D = 1) : _ === 0 && (S = 1, D = 2);
            break;
          case _t.Clear:
            S = 0, D = 0;
        }
        return { average: S, status: D };
      }(n, p);
      A.status !== -1 ? (h = p !== A.status) && function(b, _, S) {
        b.fill(_, 0, S);
      }(v, A.status, m) : h = qb(v, Ae.ofLength(m), n), y = A.average, x = A.status;
    } else (h = i(r, function(b) {
      return qb(v, b, n);
    }, !0)) && (y = function(b, _) {
      switch (b) {
        case _t.Highlight:
          return 0.5;
        case _t.RemoveHighlight:
          return _ === 0 ? 0 : _ === 2 || _ === 3 ? 0.5 : -1;
        case _t.Select:
          return 0.5;
        case _t.Deselect:
          return _ === 1 || _ === 3 ? 0.5 : _ === 0 ? 0 : -1;
        case _t.Toggle:
          return _ === -1 ? -1 : 0.5;
        case _t.Clear:
          return _ === -1 ? -1 : _ === 0 ? 0 : 0.5;
        case _t.None:
          return -1;
        default:
          Hi();
      }
    }(n, p), a && a.status !== -1 && y === -1 && Pr.isReverse(a.action, n) && Hr.areEqual(r, a.loci) && (y = (x = a.status) === 0 ? 0 : 0.5));
    return h && (y === -1 && (y = BT(v, m)) === 0 && (x = 0), a && (a.action = n, a.loci = r, a.status = p), k.updateIfChanged(s, x), x === -1 && k.update(u, u.ref.value), k.updateIfChanged(c, y), k.updateIfChanged(l, x)), h;
  }, e.setOverpaint = function(t, r, n, i, a) {
    if (t) {
      var o = t.values, u = o.tOverpaint, s = o.dOverpaintType, c = o.dOverpaint, l = o.uGroupCount, d = o.instanceCount, f = l.ref.value * d.ref.value;
      (function(I, M) {
        var F = Di(Math.max(1, I), 4, Uint8Array, M && M.tOverpaint.ref.value.array);
        M ? (k.update(M.tOverpaint, F), k.update(M.uOverpaintTexDim, ke.create(F.width, F.height)), k.updateIfChanged(M.dOverpaint, I > 0)) : (k.create(F), k.create(ke.create(F.width, F.height)), k.create(I > 0), k.create(go()), k.create(w.create(1, 1, 1)), k.create(Vt.create(0, 0, 0, 1)), k.create("groupInstance"));
      })(r.layers.length ? f : 0, t.values);
      var m = u.ref.value.array;
      i && bS(m, 0, f);
      for (var v = function(I, M) {
        var F = r.layers[I], P = F.loci, E = F.color, B = F.clear;
        n(P, function(N) {
          var O = Ae.start(N), z = Ae.end(N);
          return B ? bS(m, O, z) : function(V, U, H, K) {
            for (var j = U; j < H; ++j) He.toArray(K, V, 4 * j), V[4 * j + 3] = 255;
            return !0;
          }(m, O, z, E);
        }, !1);
      }, p = 0, g = r.layers.length; p < g; ++p) v(p);
      if (k.update(u, u.ref.value), k.updateIfChanged(s, "groupInstance"), k.updateIfChanged(c, r.layers.length > 0), r.layers.length !== 0 && a && s4(a.props)) {
        var h = a.geometry, y = a.props, x = a.webgl;
        if (h.kind === "mesh") {
          var A = h.meta, b = A.resolution, _ = A.overpaintTexture;
          (S = Xd(y.smoothColors, !0, b)) && (function(I, M, F, P, E) {
            if (/* @__PURE__ */ function(N) {
              return N === "groupInstance";
            }(I.dOverpaintType.ref.value)) {
              var B = t2({ vertexCount: I.uVertexCount.ref.value, instanceCount: I.uInstanceCount.ref.value, groupCount: I.uGroupCount.ref.value, transformBuffer: I.aTransform.ref.value, instanceBuffer: I.aInstance.ref.value, positionBuffer: I.aPosition.ref.value, groupBuffer: I.aGroup.ref.value, colorData: I.tOverpaint.ref.value, colorType: I.dOverpaintType.ref.value, boundingSphere: I.boundingSphere.ref.value, invariantBoundingSphere: I.invariantBoundingSphere.ref.value, itemSize: 4 }, M, F, P, E);
              B.kind === "volume" ? (k.updateIfChanged(I.dOverpaintType, B.type), k.update(I.tOverpaintGrid, B.texture), k.update(I.uOverpaintTexDim, B.gridTexDim), k.update(I.uOverpaintGridDim, B.gridDim), k.update(I.uOverpaintGridTransform, B.gridTransform)) : B.kind === "vertex" && (k.updateIfChanged(I.dOverpaintType, B.type), k.update(I.tOverpaint, B.texture), k.update(I.uOverpaintTexDim, B.texDim));
            }
          }(t.values, S.resolution, S.stride, x, _), h.meta.overpaintTexture = t.values.tOverpaintGrid.ref.value);
        } else if (x && h.kind === "texture-mesh") {
          var S, D = h.meta;
          b = D.resolution, _ = D.overpaintTexture, (S = Xd(y.smoothColors, !0, b)) && (function(I, M, F, P, E) {
            if (/* @__PURE__ */ function(O) {
              return O === "groupInstance";
            }(I.dOverpaintType.ref.value)) {
              F *= 3, P.namedTextures[o1] || (P.namedTextures[o1] = P.resources.texture("image-uint8", "rgba", "ubyte", "nearest"));
              var B = P.namedTextures[o1];
              B.load(I.tOverpaint.ref.value);
              var N = E4({ vertexCount: I.uVertexCount.ref.value, instanceCount: I.uInstanceCount.ref.value, groupCount: I.uGroupCount.ref.value, transformBuffer: I.aTransform.ref.value, instanceBuffer: I.aInstance.ref.value, positionTexture: I.tPosition.ref.value, groupTexture: I.tGroup.ref.value, colorData: B, colorType: I.dOverpaintType.ref.value, boundingSphere: I.boundingSphere.ref.value, invariantBoundingSphere: I.invariantBoundingSphere.ref.value }, M, F, P, E);
              k.updateIfChanged(I.dOverpaintType, N.type), k.update(I.tOverpaintGrid, N.texture), k.update(I.uOverpaintTexDim, N.gridTexDim), k.update(I.uOverpaintGridDim, N.gridDim), k.update(I.uOverpaintGridTransform, N.gridTransform);
            }
          }(t.values, S.resolution, S.stride, x, _), h.meta.overpaintTexture = t.values.tOverpaintGrid.ref.value);
        }
      }
    }
  }, e.setTransparency = function(t, r, n, i, a) {
    if (t) {
      var o = t.values, u = o.tTransparency, s = o.dTransparencyType, c = o.transparencyAverage, l = o.dTransparency, d = o.uGroupCount, f = o.instanceCount, m = d.ref.value * f.ref.value;
      (function(M, F) {
        var P = Di(Math.max(1, M), 1, Uint8Array, F && F.tTransparency.ref.value.array);
        F ? (k.update(F.tTransparency, P), k.update(F.uTransparencyTexDim, ke.create(P.width, P.height)), k.updateIfChanged(F.dTransparency, M > 0), k.updateIfChanged(F.transparencyAverage, _S(P.array, M))) : (k.create(P), k.create(ke.create(P.width, P.height)), k.create(M > 0), k.create(0), k.create(go()), k.create(w.create(1, 1, 1)), k.create(Vt.create(0, 0, 0, 1)), k.create("groupInstance"));
      })(r.layers.length ? m : 0, t.values);
      var v = u.ref.value.array;
      i && function(M, F, P) {
        M.fill(0, F, P);
      }(v, 0, m);
      for (var p = function(M, F) {
        var P = r.layers[M], E = P.loci, B = P.value;
        n(E, function(N) {
          var O = Ae.start(N), z = Ae.end(N);
          return function(V, U, H, K) {
            for (var j = U; j < H; ++j) V[j] = 255 * K;
            return !0;
          }(v, O, z, B);
        }, !1);
      }, g = 0, h = r.layers.length; g < h; ++g) p(g);
      if (k.update(u, u.ref.value), k.updateIfChanged(c, _S(v, m)), k.updateIfChanged(s, "groupInstance"), k.updateIfChanged(l, r.layers.length > 0), r.layers.length !== 0 && a && s4(a.props)) {
        var y = a.geometry, x = a.props, A = a.webgl;
        if (y.kind === "mesh") {
          var b = y.meta, _ = b.resolution, S = b.transparencyTexture;
          (D = Xd(x.smoothColors, !0, _)) && (function(M, F, P, E, B) {
            if (/* @__PURE__ */ function(O) {
              return O === "groupInstance";
            }(M.dTransparencyType.ref.value)) {
              var N = t2({ vertexCount: M.uVertexCount.ref.value, instanceCount: M.uInstanceCount.ref.value, groupCount: M.uGroupCount.ref.value, transformBuffer: M.aTransform.ref.value, instanceBuffer: M.aInstance.ref.value, positionBuffer: M.aPosition.ref.value, groupBuffer: M.aGroup.ref.value, colorData: M.tTransparency.ref.value, colorType: M.dTransparencyType.ref.value, boundingSphere: M.boundingSphere.ref.value, invariantBoundingSphere: M.invariantBoundingSphere.ref.value, itemSize: 1 }, F, P, E, B);
              N.kind === "volume" ? (k.updateIfChanged(M.dTransparencyType, N.type), k.update(M.tTransparencyGrid, N.texture), k.update(M.uTransparencyTexDim, N.gridTexDim), k.update(M.uTransparencyGridDim, N.gridDim), k.update(M.uTransparencyGridTransform, N.gridTransform)) : N.kind === "vertex" && (k.updateIfChanged(M.dTransparencyType, N.type), k.update(M.tTransparency, N.texture), k.update(M.uTransparencyTexDim, N.texDim));
            }
          }(t.values, D.resolution, D.stride, A, S), y.meta.transparencyTexture = t.values.tTransparencyGrid.ref.value);
        } else if (A && y.kind === "texture-mesh") {
          var D, I = y.meta;
          _ = I.resolution, S = I.transparencyTexture, (D = Xd(x.smoothColors, !0, _)) && (function(M, F, P, E, B) {
            if (/* @__PURE__ */ function(z) {
              return z === "groupInstance";
            }(M.dTransparencyType.ref.value)) {
              P *= 3, E.namedTextures[M4] || (E.namedTextures[M4] = E.resources.texture("image-uint8", "alpha", "ubyte", "nearest"));
              var N = E.namedTextures[M4];
              N.load(M.tTransparency.ref.value);
              var O = E4({ vertexCount: M.uVertexCount.ref.value, instanceCount: M.uInstanceCount.ref.value, groupCount: M.uGroupCount.ref.value, transformBuffer: M.aTransform.ref.value, instanceBuffer: M.aInstance.ref.value, positionTexture: M.tPosition.ref.value, groupTexture: M.tGroup.ref.value, colorData: N, colorType: M.dTransparencyType.ref.value, boundingSphere: M.boundingSphere.ref.value, invariantBoundingSphere: M.invariantBoundingSphere.ref.value }, F, P, E, B);
              k.updateIfChanged(M.dTransparencyType, O.type), k.update(M.tTransparencyGrid, O.texture), k.update(M.uTransparencyTexDim, O.gridTexDim), k.update(M.uTransparencyGridDim, O.gridDim), k.update(M.uTransparencyGridTransform, O.gridTransform);
            }
          }(t.values, D.resolution, D.stride, A, S), y.meta.transparencyTexture = t.values.tTransparencyGrid.ref.value);
        }
      }
    }
  }, e.setSubstance = function(t, r, n, i, a) {
    if (t) {
      var o = t.values, u = o.tSubstance, s = o.dSubstanceType, c = o.dSubstance, l = o.uGroupCount, d = o.instanceCount, f = l.ref.value * d.ref.value;
      (function(I, M) {
        var F = Di(Math.max(1, I), 4, Uint8Array, M && M.tSubstance.ref.value.array);
        M ? (k.update(M.tSubstance, F), k.update(M.uSubstanceTexDim, ke.create(F.width, F.height)), k.updateIfChanged(M.dSubstance, I > 0)) : (k.create(F), k.create(ke.create(F.width, F.height)), k.create(I > 0), k.create(go()), k.create(w.create(1, 1, 1)), k.create(Vt.create(0, 0, 0, 1)), k.create("groupInstance"));
      })(r.layers.length ? f : 0, t.values);
      var m = u.ref.value.array;
      i && xS(m, 0, f);
      for (var v = function(I, M) {
        var F = r.layers[I], P = F.loci, E = F.material, B = F.clear;
        n(P, function(N) {
          var O = Ae.start(N), z = Ae.end(N);
          return B ? xS(m, O, z) : function(V, U, H, K) {
            for (var j = U; j < H; ++j) Q1.toArray(K, V, 4 * j), V[4 * j + 3] = 255;
            return !0;
          }(m, O, z, E);
        }, !1);
      }, p = 0, g = r.layers.length; p < g; ++p) v(p);
      if (k.update(u, u.ref.value), k.updateIfChanged(s, "groupInstance"), k.updateIfChanged(c, r.layers.length > 0), r.layers.length !== 0 && a && s4(a.props)) {
        var h = a.geometry, y = a.props, x = a.webgl;
        if (h.kind === "mesh") {
          var A = h.meta, b = A.resolution, _ = A.substanceTexture;
          (S = Xd(y.smoothColors, !0, b)) && (function(I, M, F, P, E) {
            if (/* @__PURE__ */ function(N) {
              return N === "groupInstance";
            }(I.dSubstanceType.ref.value)) {
              var B = t2({ vertexCount: I.uVertexCount.ref.value, instanceCount: I.uInstanceCount.ref.value, groupCount: I.uGroupCount.ref.value, transformBuffer: I.aTransform.ref.value, instanceBuffer: I.aInstance.ref.value, positionBuffer: I.aPosition.ref.value, groupBuffer: I.aGroup.ref.value, colorData: I.tSubstance.ref.value, colorType: I.dSubstanceType.ref.value, boundingSphere: I.boundingSphere.ref.value, invariantBoundingSphere: I.invariantBoundingSphere.ref.value, itemSize: 4 }, M, F, P, E);
              B.kind === "volume" ? (k.updateIfChanged(I.dSubstanceType, B.type), k.update(I.tSubstanceGrid, B.texture), k.update(I.uSubstanceTexDim, B.gridTexDim), k.update(I.uSubstanceGridDim, B.gridDim), k.update(I.uSubstanceGridTransform, B.gridTransform)) : B.kind === "vertex" && (k.updateIfChanged(I.dSubstanceType, B.type), k.update(I.tSubstance, B.texture), k.update(I.uSubstanceTexDim, B.texDim));
            }
          }(t.values, S.resolution, S.stride, x, _), h.meta.substanceTexture = t.values.tSubstanceGrid.ref.value);
        } else if (x && h.kind === "texture-mesh") {
          var S, D = h.meta;
          b = D.resolution, _ = D.substanceTexture, (S = Xd(y.smoothColors, !0, b)) && (function(I, M, F, P, E) {
            if (/* @__PURE__ */ function(O) {
              return O === "groupInstance";
            }(I.dSubstanceType.ref.value)) {
              F *= 3, P.namedTextures[o1] || (P.namedTextures[o1] = P.resources.texture("image-uint8", "rgba", "ubyte", "nearest"));
              var B = P.namedTextures[o1];
              B.load(I.tSubstance.ref.value);
              var N = E4({ vertexCount: I.uVertexCount.ref.value, instanceCount: I.uInstanceCount.ref.value, groupCount: I.uGroupCount.ref.value, transformBuffer: I.aTransform.ref.value, instanceBuffer: I.aInstance.ref.value, positionTexture: I.tPosition.ref.value, groupTexture: I.tGroup.ref.value, colorData: B, colorType: I.dSubstanceType.ref.value, boundingSphere: I.boundingSphere.ref.value, invariantBoundingSphere: I.invariantBoundingSphere.ref.value }, M, F, P, E);
              k.updateIfChanged(I.dSubstanceType, N.type), k.update(I.tSubstanceGrid, N.texture), k.update(I.uSubstanceTexDim, N.gridTexDim), k.update(I.uSubstanceGridDim, N.gridDim), k.update(I.uSubstanceGridTransform, N.gridTransform);
            }
          }(t.values, S.resolution, S.stride, x, _), h.meta.substanceTexture = t.values.tSubstanceGrid.ref.value);
        }
      }
    }
  }, e.setClipping = function(t, r, n, i) {
    if (t) {
      var a = t.values, o = a.tClipping, u = a.dClipping, s = a.uGroupCount, c = a.instanceCount, l = s.ref.value * c.ref.value;
      (function(p, g) {
        var h = Di(Math.max(1, p), 1, Uint8Array, g && g.tClipping.ref.value.array);
        g ? (k.update(g.tClipping, h), k.update(g.uClippingTexDim, ke.create(h.width, h.height)), k.updateIfChanged(g.dClipping, p > 0)) : (k.create(h), k.create(ke.create(h.width, h.height)), k.create(p > 0));
      })(r.layers.length ? l : 0, t.values);
      var d = o.ref.value.array;
      i && function(p, g, h) {
        p.fill(0, g, h);
      }(d, 0, l);
      for (var f = function(p, g) {
        var h = r.layers[p], y = h.loci, x = h.groups;
        n(y, function(A) {
          var b = Ae.start(A), _ = Ae.end(A);
          return function(S, D, I, M) {
            return S.fill(M, D, I), !0;
          }(d, b, _, x);
        }, !1);
      }, m = 0, v = r.layers.length; m < v; ++m) f(m);
      k.update(o, o.ref.value), k.updateIfChanged(u, r.layers.length > 0);
    }
  }, e.setTransform = function(t, r, n) {
    if (t && (r || n)) {
      var i = t.values;
      r && (me.copy(i.matrix.ref.value, r), k.update(i.matrix, i.matrix.ref.value)), n ? (i.extraTransform.ref.value.set(n), k.update(i.extraTransform, i.extraTransform.ref.value)) : n === null && (Pb(i.extraTransform.ref.value, i.instanceCount.ref.value), k.update(i.extraTransform, i.extraTransform.ref.value)), FT(i);
      var a = zi(i.invariantBoundingSphere.ref.value, i.aTransform.ref.value, i.instanceCount.ref.value);
      k.update(i.boundingSphere, a);
    }
  };
})(rr || (rr = {})), function(e) {
  function t(r) {
    return r.layers.length === 0;
  }
  e.Empty = { layers: [] }, function(r) {
    function n(i) {
      switch (i) {
        case "one":
          return 1;
        case "two":
          return 2;
        case "three":
          return 4;
        case "four":
          return 8;
        case "five":
          return 16;
        case "six":
          return 32;
      }
    }
    r.is = ya.has, r.create = function(i) {
      return ya.create(i);
    }, r.Names = { one: 1, two: 2, three: 4, four: 8, five: 16, six: 32 }, r.isName = function(i) {
      return i in r.Names;
    }, r.fromName = n, r.fromNames = function(i) {
      for (var a = 0, o = 0, u = i.length; o < u; ++o) a |= n(i[o]);
      return a;
    }, r.toNames = function(i) {
      var a = [];
      return r.is(i, 1) && a.push("one"), r.is(i, 2) && a.push("two"), r.is(i, 4) && a.push("three"), r.is(i, 8) && a.push("four"), r.is(i, 16) && a.push("five"), r.is(i, 32) && a.push("six"), a;
    };
  }(e.Groups || (e.Groups = {})), e.areEqual = function(r, n) {
    if (r.layers.length !== n.layers.length) return !1;
    for (var i = 0, a = r.layers.length; i < a; ++i)
      if (r.layers[i].groups !== n.layers[i].groups || !Hr.areEqual(r.layers[i].loci, n.layers[i].loci)) return !1;
    return !0;
  }, e.isEmpty = t, e.remap = function(r, n) {
    for (var i = [], a = 0, o = r.layers; a < o.length; a++) {
      var u = o[a], s = u.loci, c = u.groups;
      s = Xe.remap(s, n), Xe.isEmpty(s) || i.push({ loci: s, groups: c });
    }
    return { layers: i };
  }, e.merge = function(r) {
    if (t(r)) return r;
    for (var n = r.layers[0].loci.structure, i = /* @__PURE__ */ new Map(), a = Xe.none(n), o = 0, u = r.layers.length; o < u; ++o) {
      var s = r.layers[u - o - 1], c = s.loci, l = s.groups;
      c = Xe.subtract(c, a), a = Xe.union(c, a), Xe.isEmpty(c) || (i.has(l) && (c = Xe.union(c, i.get(l))), i.set(l, c));
    }
    var d = [];
    return i.forEach(function(f, m) {
      d.push({ loci: f, groups: m });
    }), { layers: d };
  }, e.filter = function(r, n) {
    if (t(r)) return r;
    for (var i = r.layers[0].loci.structure, a = [], o = 0, u = r.layers; o < u.length; o++) {
      var s = u[o], c = s.loci, l = s.groups, d = Xe.remap(c, n);
      c = Xe.remap(d, i), Xe.isEmpty(c) || a.push({ loci: c, groups: l });
    }
    return { layers: a };
  }, e.ofScript = function(r, n) {
    for (var i = [], a = 0, o = r.length; a < o; ++a) {
      var u = r[a], s = u.script, c = u.groups, l = Hl.toLoci(s, n);
      Xe.isEmpty(l) || i.push({ loci: l, groups: c });
    }
    return { layers: i };
  }, e.ofBundle = function(r, n) {
    for (var i = [], a = 0, o = r.length; a < o; ++a) {
      var u = r[a], s = u.bundle, c = u.groups, l = $a.toLoci(s, n.root);
      i.push({ loci: l, groups: c });
    }
    return { layers: i };
  }, e.toBundle = function(r) {
    for (var n = [], i = 0, a = r.layers.length; i < a; ++i) {
      var o = r.layers[i], u = o.loci, s = o.groups, c = $a.fromLoci(u);
      n.push({ bundle: c, groups: s });
    }
    return { layers: n };
  };
}(cm || (cm = {})), function(e) {
  function t(r) {
    return r.layers.length === 0;
  }
  e.Empty = { layers: [] }, e.areEqual = function(r, n) {
    if (r.layers.length === 0 && n.layers.length === 0) return !0;
    if (r.layers.length !== n.layers.length) return !1;
    for (var i = 0, a = r.layers.length; i < a; ++i)
      if (r.layers[i].clear !== n.layers[i].clear || !RH(r.layers[i].material, n.layers[i].material) || !Hr.areEqual(r.layers[i].loci, n.layers[i].loci)) return !1;
    return !0;
  }, e.isEmpty = t, e.remap = function(r, n) {
    for (var i = [], a = 0, o = r.layers; a < o.length; a++) {
      var u = o[a], s = u.loci, c = u.material, l = u.clear;
      s = Xe.remap(s, n), Xe.isEmpty(s) || i.push({ loci: s, material: c, clear: l });
    }
    return { layers: i };
  }, e.merge = function(r) {
    if (t(r)) return r;
    for (var n = r.layers[0].loci.structure, i = void 0, a = /* @__PURE__ */ new Map(), o = Xe.none(n), u = 0, s = r.layers.length; u < s; ++u) {
      var c = r.layers[s - u - 1], l = c.loci, d = c.material, f = c.clear;
      l = Xe.subtract(l, o), o = Xe.union(l, o), Xe.isEmpty(l) || (f ? i = i ? Xe.union(l, i) : l : (a.has(d) && (l = Xe.union(l, a.get(d))), a.set(d, l)));
    }
    var m = [];
    return i && m.push({ loci: i, material: Q1(), clear: !0 }), a.forEach(function(v, p) {
      m.push({ loci: v, material: p, clear: !1 });
    }), { layers: m };
  }, e.filter = function(r, n) {
    if (t(r)) return r;
    for (var i = r.layers[0].loci.structure, a = [], o = 0, u = r.layers; o < u.length; o++) {
      var s = u[o], c = s.loci, l = s.material, d = s.clear, f = Xe.remap(c, n);
      c = Xe.remap(f, i), Xe.isEmpty(c) || a.push({ loci: c, material: l, clear: d });
    }
    return { layers: a };
  }, e.ofScript = function(r, n) {
    for (var i = [], a = 0, o = r.length; a < o; ++a) {
      var u = r[a], s = u.script, c = u.material, l = u.clear, d = Hl.toLoci(s, n);
      Xe.isEmpty(d) || i.push({ loci: d, material: c, clear: l });
    }
    return { layers: i };
  }, e.ofBundle = function(r, n) {
    for (var i = [], a = 0, o = r.length; a < o; ++a) {
      var u = r[a], s = u.bundle, c = u.material, l = u.clear, d = $a.toLoci(s, n.root);
      i.push({ loci: d, material: c, clear: l });
    }
    return { layers: i };
  }, e.toBundle = function(r) {
    for (var n = [], i = 0, a = r.layers.length; i < a; ++i) {
      var o = r.layers[i], u = o.loci, s = o.material, c = o.clear, l = $a.fromLoci(u);
      n.push({ bundle: l, material: s, clear: c });
    }
    return { layers: n };
  };
}(lm || (lm = {})), function(e) {
  e.getDetaultParams = function(t, r, n) {
    return G.getDefaultValues(t.getParams(r, n));
  };
}(UC || (UC = {}));
var or, V2, CZ = { name: "", label: "", description: "", factory: function() {
  return or.Empty;
}, getParams: function() {
  return {};
}, defaultValues: {}, defaultColorTheme: Bc.EmptyProvider, defaultSizeTheme: eo.EmptyProvider, isApplicable: function() {
  return !0;
} };
function HC(e) {
  return e.map(function(t) {
    return [t.name, t.provider.label];
  });
}
(function() {
  function e() {
    this._list = [], this._map = /* @__PURE__ */ new Map(), this._name = /* @__PURE__ */ new Map();
  }
  Object.defineProperty(e.prototype, "default", { get: function() {
    return this._list[0];
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "types", { get: function() {
    return HC(this._list);
  }, enumerable: !1, configurable: !0 }), e.prototype.add = function(t) {
    if (this._map.has(t.name)) throw new Error("".concat(t.name, " already registered."));
    this._list.push({ name: t.name, provider: t }), this._map.set(t.name, t), this._name.set(t, t.name);
  }, e.prototype.getName = function(t) {
    if (!this._name.has(t)) throw new Error("'".concat(t.label, "' is not a registered represenatation provider."));
    return this._name.get(t);
  }, e.prototype.remove = function(t) {
    var r = t.name;
    this._list.splice(this._list.findIndex(function(i) {
      return i.name === r;
    }), 1);
    var n = this._map.get(r);
    n && (this._map.delete(r), this._name.delete(n));
  }, e.prototype.get = function(t) {
    return this._map.get(t) || CZ;
  }, Object.defineProperty(e.prototype, "list", { get: function() {
    return this._list;
  }, enumerable: !1, configurable: !0 }), e.prototype.getApplicableList = function(t) {
    return this._list.filter(function(r) {
      return r.provider.isApplicable(t);
    });
  }, e.prototype.getApplicableTypes = function(t) {
    return HC(this.getApplicableList(t));
  };
})(), function(e) {
  function t() {
    return { visible: !0, alphaFactor: 1, pickable: !0, colorOnly: !1, syncManually: !1, transform: me.identity(), overpaint: um.Empty, transparency: sm.Empty, substance: lm.Empty, clipping: cm.Empty, markerActions: Pr.All };
  }
  function r(i, a) {
    a.visible !== void 0 && (i.visible = a.visible), a.alphaFactor !== void 0 && (i.alphaFactor = a.alphaFactor), a.pickable !== void 0 && (i.pickable = a.pickable), a.colorOnly !== void 0 && (i.colorOnly = a.colorOnly), a.overpaint !== void 0 && (i.overpaint = a.overpaint), a.transparency !== void 0 && (i.transparency = a.transparency), a.substance !== void 0 && (i.substance = a.substance), a.clipping !== void 0 && (i.clipping = a.clipping), a.syncManually !== void 0 && (i.syncManually = a.syncManually), a.transform !== void 0 && me.copy(i.transform, a.transform), a.markerActions !== void 0 && (i.markerActions = a.markerActions);
  }
  (function(i) {
    i.areEqual = function(a, o) {
      return a.repr === o.repr && Hr.areEqual(a.loci, o.loci);
    }, i.isEmpty = function(a) {
      return Hr.isEmpty(a.loci);
    }, i.Empty = { loci: vn };
  })(e.Loci || (e.Loci = {})), e.createState = t, e.updateState = r, e.StateBuilder = { create: t, update: r }, e.Empty = { label: "", groupCount: 0, renderObjects: [], geometryVersion: -1, props: {}, params: {}, updated: new ui(), state: t(), theme: Bu.createEmpty(), createOrUpdate: function() {
    return er.constant("", void 0);
  }, setState: function() {
  }, setTheme: function() {
  }, getLoci: function() {
    return vn;
  }, mark: function() {
    return !1;
  }, destroy: function() {
  } };
  var n = function() {
    function i() {
      this.curr = /* @__PURE__ */ new Set(), this.next = /* @__PURE__ */ new Set(), this._version = -1;
    }
    return Object.defineProperty(i.prototype, "version", { get: function() {
      return this._version;
    }, enumerable: !1, configurable: !0 }), i.prototype.add = function(a, o) {
      this.next.add(Mu(a, o));
    }, i.prototype.snapshot = function() {
      var a;
      to.areEqual(this.curr, this.next) || (this._version += 1), a = [this.next, this.curr], this.curr = a[0], this.next = a[1], this.next.clear();
    }, i;
  }();
  e.GeometryState = n, e.createMulti = function(i, a, o, u, s) {
    var c, l, d, f = this, m = 0, v = new ui(), p = new n(), g = u.create(), h = Bu.createEmpty(), y = {}, x = Object.keys(s).map(function(A, b) {
      y[b] = A;
      var _ = s[A](a, o);
      return _.setState(g), _;
    });
    return { label: i, updated: v, get groupCount() {
      var A = 0;
      if (l) for (var b = l.visuals, _ = 0, S = x.length; _ < S; ++_) b && !b.includes(y[_]) || (A += x[_].groupCount);
      return A;
    }, get renderObjects() {
      var A = [];
      if (l) for (var b = l.visuals, _ = 0, S = x.length; _ < S; ++_) b && !b.includes(y[_]) || A.push.apply(A, x[_].renderObjects);
      return A;
    }, get geometryVersion() {
      return p.version;
    }, get props() {
      return l;
    }, get params() {
      return c;
    }, createOrUpdate: function(A, b) {
      A === void 0 && (A = {}), b && b !== d && (c = o(a, b), d = b, l || (l = G.getDefaultValues(c))), l || (l = {});
      var _ = jb(Object.assign({}, l || {}, A || {}), d);
      Object.assign(l, A || {}, _ || {});
      var S = l.visuals;
      return er.create("Creating or updating '".concat(i, "' representation"), function(D) {
        return _e(f, 0, void 0, function() {
          var I, M;
          return ye(this, function(F) {
            switch (F.label) {
              case 0:
                I = 0, M = x.length, F.label = 1;
              case 1:
                return I < M ? S && !S.includes(y[I]) ? [3, 3] : [4, x[I].createOrUpdate(l, d).runInContext(D)] : [3, 5];
              case 2:
                F.sent(), F.label = 3;
              case 3:
                p.add(I, x[I].geometryVersion), F.label = 4;
              case 4:
                return ++I, [3, 1];
              case 5:
                return p.snapshot(), v.next(m++), [2];
            }
          });
        });
      });
    }, get state() {
      return g;
    }, get theme() {
      return h;
    }, getLoci: function(A) {
      for (var b = l.visuals, _ = 0, S = x.length; _ < S; ++_) if (!b || b.includes(y[_])) {
        var D = x[_].getLoci(A);
        if (!Jl(D)) return D;
      }
      return vn;
    }, mark: function(A, b) {
      for (var _ = !1, S = 0, D = x.length; S < D; ++S) _ = x[S].mark(A, b) || _;
      return _;
    }, setState: function(A) {
      u.update(g, A);
      for (var b = 0, _ = x.length; b < _; ++b) x[b].setState(A);
      v.next(m++);
    }, setTheme: function(A) {
      h = A;
      for (var b = 0, _ = x.length; b < _; ++b) x[b].setTheme(A);
    }, destroy: function() {
      for (var A = 0, b = x.length; A < b; ++A) x[A].destroy();
    } };
  }, e.fromRenderObject = function(i, a) {
    var o = this, u = 0, s = new ui(), c = new n(), l = e.createState(), d = Bu.createEmpty(), f = G.clone(ft.Params), m = G.getDefaultValues(ft.Params);
    return { label: i, updated: s, get groupCount() {
      return a.values.uGroupCount.ref.value;
    }, get renderObjects() {
      return [a];
    }, get geometryVersion() {
      return c.version;
    }, get props() {
      return m;
    }, get params() {
      return f;
    }, createOrUpdate: function(v) {
      v === void 0 && (v = {});
      var p = jb(Object.assign({}, m, v));
      return Object.assign(m, v, p), er.create("Updating '".concat(i, "' representation"), function(g) {
        return _e(o, 0, void 0, function() {
          return ye(this, function(h) {
            return c.add(0, a.id), c.snapshot(), s.next(u++), [2];
          });
        });
      });
    }, get state() {
      return l;
    }, get theme() {
      return d;
    }, getLoci: function() {
      return vn;
    }, mark: function(v, p) {
      return !1;
    }, setState: function(v) {
      v.visible !== void 0 && rr.setVisibility(a, v.visible), v.alphaFactor !== void 0 && rr.setAlphaFactor(a, v.alphaFactor), v.pickable !== void 0 && rr.setPickable(a, v.pickable), v.colorOnly !== void 0 && rr.setColorOnly(a, v.colorOnly), v.overpaint, v.transparency, v.substance, v.transform !== void 0 && rr.setTransform(a, v.transform), e.updateState(l, v);
    }, setTheme: function() {
    }, destroy: function() {
    } };
  };
}(or || (or = {})), function(e) {
  e.create = function() {
    return { view: me.identity(), position: w.create(0, 0, 0), direction: w.create(0, 0, -1), up: w.create(0, 1, 0) };
  };
  var t = w.zero();
  e.update = function(r) {
    w.add(t, r.position, r.direction), me.lookAt(r.view, r.position, t, r.up);
  };
}(V2 || (V2 = {}));
var r0, wZ = function() {
  function e() {
    this.removeList = Q9(), this.removeMap = /* @__PURE__ */ new Map(), this.addList = Q9(), this.addMap = /* @__PURE__ */ new Map();
  }
  return Object.defineProperty(e.prototype, "isEmpty", { get: function() {
    return this.removeList.count === 0 && this.addList.count === 0;
  }, enumerable: !1, configurable: !0 }), e.prototype.add = function(t) {
    if (this.removeMap.has(t)) {
      var r = this.removeMap.get(t);
      this.removeMap.delete(t), this.removeList.remove(r);
    }
    if (!this.addMap.has(t)) {
      var n = this.addList.addLast(t);
      this.addMap.set(t, n);
    }
  }, e.prototype.remove = function(t) {
    if (this.addMap.has(t)) {
      var r = this.addMap.get(t);
      this.addMap.delete(t), this.addList.remove(r);
    }
    if (!this.removeMap.has(t)) {
      var n = this.removeList.addLast(t);
      this.removeMap.set(t, n);
    }
  }, e.prototype.tryGetRemove = function() {
    var t = this.removeList.removeFirst();
    return t && this.removeMap.delete(t), t;
  }, e.prototype.tryGetAdd = function() {
    var t = this.addList.removeFirst();
    return t && this.addMap.delete(t), t;
  }, e;
}(), ep = new Nu("98");
function qC(e, t, r) {
  ep.reset();
  for (var n = 0, i = e.length; n < i; ++n) if (!r || e[n].state.visible) {
    var a = e[n].values.boundingSphere.ref.value;
    a.radius && ep.includeSphere(a);
  }
  for (ep.finishedIncludeStep(), n = 0, i = e.length; n < i; ++n) if (!r || e[n].state.visible) {
    var o = e[n].values.boundingSphere.ref.value;
    o.radius && ep.radiusSphere(o);
  }
  return ep.getSphere(t);
}
function DZ(e, t) {
  var r = (e.getProgram("colorBlended") || e.getProgram("colorWboit")).id, n = (t.getProgram("colorBlended") || e.getProgram("colorWboit")).id, i = e.materialId, a = t.materialId;
  return r !== n ? r - n : i !== a ? i - a : e.id - t.id;
}
(function(e) {
  e.create = function(t, r) {
    r === void 0 && (r = I_);
    var n = /* @__PURE__ */ new Map(), i = [], a = Me(), o = Me(), u = [], s = [], c = !0, l = !0, d = V2.create(), f = d.view, m = d.position, v = d.direction, p = d.up;
    function g(_) {
      if (n.has(_)) return console.warn("RenderObject with id '".concat(_.id, "' already present")), n.get(_);
      var S = aW(t, _, r);
      return i.push(S), _.type === "direct-volume" ? s.push(S) : u.push(S), n.set(_, S), c = !0, l = !0, S;
    }
    function h(_) {
      var S = n.get(_);
      S && (S.dispose(), Qv(i, S), Qv(u, S), Qv(s, S), n.delete(_), c = !0, l = !0);
    }
    var y = new wZ(), x = -1;
    function A() {
      for (var _ = 23, S = 0, D = i.length; S < D; ++S) i[S].state.visible && (_ = 31 * _ + i[S].id | 0);
      return (_ = kE(_)) === -1 && (_ = 0), _;
    }
    function b() {
      return A() !== x && (l = !0, !0);
    }
    return { view: f, position: m, direction: v, up: p, renderables: i, primitives: { view: f, position: m, direction: v, up: p, renderables: u }, volumes: { view: f, position: m, direction: v, up: p, renderables: s }, syncVisibility: b, update: function(_, S) {
      var D;
      if (V2.update(d), _) for (var I = 0, M = _.length; I < M; ++I) (D = n.get(_[I])) === null || D === void 0 || D.update();
      else for (I = 0, M = i.length; I < M; ++I) i[I].update();
      S ? b() : (c = !0, l = !0);
    }, add: function(_) {
      return y.add(_);
    }, remove: function(_) {
      return y.remove(_);
    }, commit: function(_) {
      return _ === void 0 && (_ = Number.MAX_VALUE), function(S) {
        for (var D = li(), I = 0; M = y.tryGetRemove(); ) if (h(M), ++I % 100 == 0 && li() - D > S) return !1;
        for (; ; ) {
          var M;
          if (!(M = y.tryGetAdd())) break;
          if (g(M), ++I % 100 == 0 && li() - D > S) return !1;
        }
        return i.sort(DZ), !0;
      }(_);
    }, get needsCommit() {
      return !y.isEmpty;
    }, has: function(_) {
      return n.has(_);
    }, clear: function() {
      for (var _ = 0, S = i.length; _ < S; ++_) i[_].dispose();
      i.length = 0, n.clear(), c = !0, l = !0;
    }, forEach: function(_) {
      n.forEach(_);
    }, get count() {
      return i.length;
    }, get boundingSphere() {
      return c && (qC(i, a, !1), c = !1), a;
    }, get boundingSphereVisible() {
      return l && (qC(i, o, !0), l = !1, x = A()), o;
    }, getMarkerAverage: function() {
      if (u.length === 0 && s.length === 0) return 0;
      for (var _ = 0, S = 0, D = u.length; S < D; ++S) _ += u[S].values.markerAverage.ref.value;
      for (S = 0, D = s.length; S < D; ++S) _ += s[S].values.markerAverage.ref.value;
      return _ / (u.length + s.length);
    } };
  };
})(r0 || (r0 = {}));
var Yb = function() {
  function e(t) {
    this.camera = t, this.t = 0, this.func = e.defaultTransition, this.start = 0, this.inTransition = !1, this.durationMs = 0, this._source = Jn.createDefaultSnapshot(), this._target = Jn.createDefaultSnapshot(), this._current = Jn.createDefaultSnapshot();
  }
  return Object.defineProperty(e.prototype, "source", { get: function() {
    return this._source;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "target", { get: function() {
    return this._target;
  }, enumerable: !1, configurable: !0 }), e.prototype.apply = function(t, r, n) {
    r === void 0 && (r = 0), (!this.inTransition || r > 0) && Jn.copySnapshot(this._source, this.camera.state), this.inTransition || Jn.copySnapshot(this._target, this.camera.state), Jn.copySnapshot(this._target, t), this._target.radius > this._target.radiusMax && (this._target.radius = this._target.radiusMax), this._target.radius < 0.01 && (this._target.radius = 0.01), this._target.radiusMax < 0.01 && (this._target.radiusMax = 0.01), !this.inTransition && r <= 0 || t.mode !== void 0 && t.mode !== this.camera.state.mode ? this.finish(this._target) : (this.inTransition = !0, this.func = n || e.defaultTransition, (!this.inTransition || r > 0) && (this.start = this.t, this.durationMs = r));
  }, e.prototype.tick = function(t) {
    this.t = t, this.update();
  }, e.prototype.finish = function(t) {
    Jn.copySnapshot(this.camera.state, t), this.inTransition = !1;
  }, e.prototype.update = function() {
    if (this.inTransition) {
      var t = Math.min((this.t - this.start) / this.durationMs, 1);
      t !== 1 ? (this.func(this._current, t, this._source, this._target), Jn.copySnapshot(this.camera.state, this._current)) : this.finish(this._target);
    }
  }, e;
}();
(function(e) {
  var t = In.identity();
  e.defaultTransition = function(r, n, i, a) {
    Jn.copySnapshot(r, a), In.slerp(t, In.Identity, In.rotationTo(t, i.up, a.up), n), w.transformQuat(r.up, i.up, t), w.lerp(r.target, i.target, a.target, n), w.lerp(r.position, i.position, a.position, n), r.radius = Si(i.radius, a.radius, n), r.radiusMax = Si(i.radiusMax, a.radiusMax, n), r.fov = Si(i.fov, a.fov, n), r.fog = Si(i.fog, a.fog, n);
  };
})(Yb || (Yb = {}));
var KC = w(), XC = w(), uv = Vt(), Jn = function() {
  function e(t, r, n) {
    r === void 0 && (r = Vi.create(0, 0, 128, 128)), n === void 0 && (n = {}), this.view = me.identity(), this.projection = me.identity(), this.projectionView = me.identity(), this.inverseProjectionView = me.identity(), this.state = e.createDefaultSnapshot(), this.viewOffset = e.ViewOffset(), this.near = 1, this.far = 1e4, this.fogNear = 5e3, this.fogFar = 1e4, this.zoom = 1, this.transition = new Yb(this), this.stateChanged = new Ol(this.state), this.prevProjection = me.identity(), this.prevView = me.identity(), this.deltaDirection = w(), this.newPosition = w(), this.viewport = r, this.pixelScale = n.pixelScale || 1, e.copySnapshot(this.state, t);
  }
  return Object.defineProperty(e.prototype, "pixelRatio", { get: function() {
    return (typeof window < "u" ? window.devicePixelRatio : 1) * this.pixelScale;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "position", { get: function() {
    return this.state.position;
  }, set: function(t) {
    w.copy(this.state.position, t);
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "up", { get: function() {
    return this.state.up;
  }, set: function(t) {
    w.copy(this.state.up, t);
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "target", { get: function() {
    return this.state.target;
  }, set: function(t) {
    w.copy(this.state.target, t);
  }, enumerable: !1, configurable: !0 }), e.prototype.update = function() {
    var t = this.state;
    if (t.radiusMax === 0) return !1;
    var r = 2 * Math.tan(t.fov / 2) * w.distance(t.position, t.target);
    switch (this.zoom = this.viewport.height / r, function(i) {
      var a = i.state, o = a.radius, u = a.radiusMax, s = (a.mode, a.fog), c = a.clipFar;
      o < 0.01 && (o = 0.01);
      var l = c ? o : u, d = w.distance(i.position, i.target), f = d - o, m = d + l, v = d - l * (-(50 - s) / 50), p = m;
      f = Math.max(Math.min(u, 5), f), m = Math.max(5, m), f === m && (m = f + 0.01), i.near = f, i.far = 2 * m, i.fogNear = v, i.fogFar = p;
    }(this), this.state.mode) {
      case "orthographic":
        (function(i) {
          var a = i.viewport, o = i.zoom, u = i.near, s = i.far, c = i.viewOffset, l = -a.width / 2, d = a.width / 2, f = a.height / 2, m = -a.height / 2, v = (d - l) / (2 * o), p = (f - m) / (2 * o), g = (d + l) / 2, h = (f + m) / 2, y = g - v, x = g + v, A = h + p, b = h - p;
          if (c.enabled) {
            var _ = o / (c.width / c.fullWidth), S = o / (c.height / c.fullHeight), D = (d - l) / c.width, I = (f - m) / c.height;
            x = (y += D * (c.offsetX / _)) + D * (c.width / _), b = (A -= I * (c.offsetY / S)) - I * (c.height / S);
          }
          me.ortho(i.projection, y, x, A, b, u, s), me.lookAt(i.view, i.position, i.target, i.up);
        })(this);
        break;
      case "perspective":
        (function(i) {
          var a = i.viewport.width / i.viewport.height, o = i.near, u = i.far, s = i.viewOffset, c = o * Math.tan(0.5 * i.state.fov), l = 2 * c, d = a * l, f = -0.5 * d;
          s.enabled && (f += s.offsetX * d / s.fullWidth, c -= s.offsetY * l / s.fullHeight, d *= s.width / s.fullWidth, l *= s.height / s.fullHeight), me.perspective(i.projection, f, f + d, c, c - l, o, u), me.lookAt(i.view, i.position, i.target, i.up);
        })(this);
        break;
      default:
        Hi(this.state.mode);
    }
    var n = !me.areEqual(this.projection, this.prevProjection, pn) || !me.areEqual(this.view, this.prevView, pn);
    if (n) {
      if (me.mul(this.projectionView, this.projection, this.view), !me.tryInvert(this.inverseProjectionView, this.projectionView)) return me.copy(this.view, this.prevView), me.copy(this.projection, this.prevProjection), me.mul(this.projectionView, this.projection, this.view), !1;
      me.copy(this.prevView, this.view), me.copy(this.prevProjection, this.projection);
    }
    return n;
  }, e.prototype.setState = function(t, r) {
    !Number.isNaN(t.radius) && t.radius <= 0.01 || (this.transition.apply(t, r), this.stateChanged.next(t));
  }, e.prototype.getSnapshot = function() {
    return e.copySnapshot(e.createDefaultSnapshot(), this.state);
  }, e.prototype.getTargetDistance = function(t) {
    return e.targetDistance(t, this.state.fov, this.viewport.width, this.viewport.height);
  }, e.prototype.getFocus = function(t, r, n, i) {
    var a = Math.max(r, 0.01), o = this.getTargetDistance(a);
    w.sub(this.deltaDirection, this.target, this.position), i && w.matchDirection(this.deltaDirection, i, this.deltaDirection), w.setMagnitude(this.deltaDirection, this.deltaDirection, o), w.sub(this.newPosition, t, this.deltaDirection);
    var u = e.copySnapshot(e.createDefaultSnapshot(), this.state);
    return u.target = w.clone(t), u.radius = a, u.position = w.clone(this.newPosition), n && w.matchDirection(u.up, n, u.up), u;
  }, e.prototype.getInvariantFocus = function(t, r, n, i) {
    var a = Math.max(r, 0.01), o = this.getTargetDistance(a);
    w.copy(this.deltaDirection, i), w.setMagnitude(this.deltaDirection, this.deltaDirection, o), w.sub(this.newPosition, t, this.deltaDirection);
    var u = e.copySnapshot(e.createDefaultSnapshot(), this.state);
    return u.target = w.clone(t), u.radius = a, u.position = w.clone(this.newPosition), w.copy(u.up, n), u;
  }, e.prototype.focus = function(t, r, n, i, a) {
    r > 0 && this.setState(this.getFocus(t, r, i, a), n);
  }, e.prototype.project = function(t, r) {
    return function(n, i, a, o) {
      var u = a.x, s = a.y, c = a.width, l = a.height;
      Vt.set(ds, i[0], i[1], i[2], 1), Vt.transformMat4(ds, ds, o);
      var d = ds[3];
      return d !== 0 && (ds[0] /= d, ds[1] /= d, ds[2] /= d), n[0] = (ds[0] + 1) * c * 0.5 + u, n[1] = (1 - ds[1]) * l * 0.5 + s, n[2] = 0.5 * (ds[2] + 1), n[3] = d === 0 ? 0 : 1 / d, n;
    }(t, r, this.viewport, this.projectionView);
  }, e.prototype.unproject = function(t, r) {
    return Ap(t, r, this.viewport, this.inverseProjectionView);
  }, e.prototype.getPixelSize = function(t) {
    return this.project(uv, t), this.unproject(KC, uv), uv[0] += 1, this.unproject(XC, uv), w.distance(KC, XC);
  }, e;
}();
(function(e) {
  e.ViewOffset = function() {
    return { enabled: !1, fullWidth: 1, fullHeight: 1, offsetX: 0, offsetY: 0, width: 1, height: 1 };
  }, e.setViewOffset = function(t, r, n, i, a, o, u) {
    t.fullWidth = r, t.fullHeight = n, t.offsetX = i, t.offsetY = a, t.width = o, t.height = u;
  }, e.copyViewOffset = function(t, r) {
    t.enabled = r.enabled, t.fullWidth = r.fullWidth, t.fullHeight = r.fullHeight, t.offsetX = r.offsetX, t.offsetY = r.offsetY, t.width = r.width, t.height = r.height;
  }, e.targetDistance = function(t, r, n, i) {
    var a = Math.max(t, 0.01), o = i < n ? 1 : n / i;
    return Math.abs(a / o / Math.sin(r / 2));
  }, e.createDefaultSnapshot = function() {
    return { mode: "orthographic", fov: Math.PI / 4, position: w.create(0, 0, 100), up: w.create(0, 1, 0), target: w.create(0, 0, 0), radius: 0, radiusMax: 10, fog: 50, clipFar: !0 };
  }, e.copySnapshot = function(t, r) {
    return r && (r.mode !== void 0 && (t.mode = r.mode), r.fov !== void 0 && (t.fov = r.fov), r.position !== void 0 && w.copy(t.position, r.position), r.up !== void 0 && w.copy(t.up, r.up), r.target !== void 0 && w.copy(t.target, r.target), r.radius !== void 0 && (t.radius = r.radius), r.radiusMax !== void 0 && (t.radiusMax = r.radiusMax), r.fog !== void 0 && (t.fog = r.fog), r.clipFar !== void 0 && (t.clipFar = r.clipFar)), t;
  }, e.areSnapshotsEqual = function(t, r) {
    return t.mode === r.mode && t.fov === r.fov && t.radius === r.radius && t.radiusMax === r.radiusMax && t.fog === r.fog && t.clipFar === r.clipFar && w.exactEquals(t.position, r.position) && w.exactEquals(t.up, r.up) && w.exactEquals(t.target, r.target);
  };
})(Jn || (Jn = {}));
var IZ = { radius: 1, detail: 0 };
function EZ(e, t, r) {
  var n = R(R({}, IZ), r), i = n.radius, a = n.detail, o = /* @__PURE__ */ function() {
    var d = [], f = [], m = /* @__PURE__ */ new Map();
    function v(p) {
      var g = "".concat(p[0].toFixed(5), "|").concat(p[1].toFixed(5), "|").concat(p[2].toFixed(5)), h = m.get(g);
      return h === void 0 && (h = d.length / 3, m.set(g, h), d.push.apply(d, p)), h;
    }
    return { vertices: d, indices: f, add: function(p, g, h) {
      f.push(v(p), v(g), v(h));
    } };
  }(), u = o.vertices, s = o.indices;
  (function(d) {
    for (var f = w(), m = w(), v = w(), p = 0; p < t.length; p += 3) w.fromArray(f, e, 3 * t[p + 0]), w.fromArray(m, e, 3 * t[p + 1]), w.fromArray(v, e, 3 * t[p + 2]), l(f, m, v, d);
  })(a), function(d, f) {
    for (var m = 0, v = d.length; m < v; m += 3) w.fromArray(vo, d, m), w.normalize(vo, vo), w.scale(vo, vo, f), w.toArray(vo, d, m);
  }(u, i);
  var c = new Float32Array(u.length);
  return TT(u, s, c, u.length / 3, s.length / 3), { vertices: new Float32Array(u), normals: new Float32Array(c), indices: new Uint32Array(s) };
  function l(d, f, m, v) {
    for (var p = Math.pow(2, v), g = [], h = 0; h <= p; ++h) {
      g[h] = [];
      var y = w();
      w.lerp(y, d, m, h / p);
      var x = w();
      w.lerp(x, f, m, h / p);
      for (var A = p - h, b = 0; b <= A; ++b) if (b === 0 && h === p) g[h][b] = y;
      else {
        var _ = w();
        w.lerp(_, y, x, b / A), g[h][b] = _;
      }
    }
    for (h = 0; h < p; ++h) for (b = 0; b < 2 * (p - h) - 1; ++b) {
      var S = Math.floor(b / 2);
      b % 2 == 0 ? o.add(g[h][S + 1], g[h + 1][S], g[h][S]) : o.add(g[h][S + 1], g[h + 1][S + 1], g[h + 1][S]);
    }
  }
}
var T4, du = (1 + Math.sqrt(5)) / 2, sP = (T4 || (T4 = RT([-1, du, 0, 1, du, 0, -1, -du, 0, 1, -du, 0, 0, -1, du, 0, 1, du, 0, -1, -du, 0, 1, -du, du, 0, -1, du, 0, 1, -du, 0, -1, -du, 0, 1], [0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 0, 10, 11, 1, 5, 9, 5, 11, 4, 11, 10, 2, 10, 7, 6, 7, 1, 8, 3, 9, 4, 3, 4, 2, 3, 2, 6, 3, 6, 8, 3, 8, 9, 4, 9, 5, 2, 4, 11, 6, 2, 10, 8, 6, 7, 9, 8, 1])), T4), MZ = sP.vertices, TZ = sP.indices;
function cP(e) {
  return 10 * Math.pow(Math.pow(2, e), 2) + 2;
}
var jC = /* @__PURE__ */ new Map(), PZ = me.identity();
function BZ(e) {
  var t = jC.get(e);
  return t === void 0 && (t = function(r) {
    return EZ(MZ, TZ, { detail: r, radius: 1 });
  }(e), jC.set(e, t)), t;
}
function Mi(e, t, r, n) {
  wt.addPrimitive(e, function(i, a, o) {
    return me.scaleUniformly(i, me.fromTranslation(i, a), o);
  }(PZ, t, r), BZ(n));
}
var hs = { radiusTop: 1, radiusBottom: 1, height: 1, radialSegments: 8, heightSegments: 1, topCap: !1, bottomCap: !1, thetaStart: 0, thetaLength: 2 * Math.PI }, YC = w(), WC = w(), co = w(), lo = w(), vs = w(), u1 = w(), FZ = { height: 1, topCap: !0, bottomCap: !0 }, ZC = /* @__PURE__ */ new Map(), QC = w.create(0, 1, 0), Cs = w(), sv = w(), JC = w(), ql = me(), $C = me(), ew = w(), M1 = w(), P4 = w();
function U2(e, t, r, n, i) {
  return w.setMagnitude(sv, r, n / 2), w.add(JC, t, sv), i ? w.matchDirection(P4, QC, sv) : w.copy(P4, QC), w.set(ew, 1, n, 1), w.makeRotation($C, P4, sv), me.scale(e, $C, ew), me.setTranslation(e, JC);
}
var gs = new Int32Array(9);
function N_(e) {
  var t = function(i) {
    var a, o, u, s, c, l, d, f, m;
    return gs[0] = Math.round(1e3 * ((a = i.radiusTop) !== null && a !== void 0 ? a : hs.radiusTop)), gs[1] = Math.round(1e3 * ((o = i.radiusBottom) !== null && o !== void 0 ? o : hs.radiusBottom)), gs[2] = Math.round(1e3 * ((u = i.height) !== null && u !== void 0 ? u : hs.height)), gs[3] = (s = i.radialSegments) !== null && s !== void 0 ? s : hs.radialSegments, gs[4] = (c = i.heightSegments) !== null && c !== void 0 ? c : hs.heightSegments, gs[5] = ((l = i.topCap) !== null && l !== void 0 ? l : hs.topCap) ? 1 : 0, gs[6] = ((d = i.bottomCap) !== null && d !== void 0 ? d : hs.bottomCap) ? 1 : 0, gs[7] = Math.round(1e3 * ((f = i.thetaStart) !== null && f !== void 0 ? f : hs.thetaStart)), gs[8] = Math.round(1e3 * ((m = i.thetaLength) !== null && m !== void 0 ? m : hs.thetaLength)), Ra(gs);
  }(e), r = ZC.get(t);
  if (r === void 0) {
    if (e.radialSegments && e.radialSegments <= 4) {
      var n = function(i, a) {
        var o = i.length / 3;
        if (o < 3) throw new Error("need at least 3 points to build a prism");
        var u = R(R({}, FZ), a), s = u.height, c = u.topCap, l = u.bottomCap, d = 2 * o, f = 4 * o, m = (c ? 1 : 0) + (l ? 1 : 0);
        o === 3 ? (d += m, f += 3 * m) : o === 4 ? (d += 2 * m, f += 4 * m) : (d += m * o, f += m * o * 3);
        var v = Mm(d, f), p = 0.5 * s;
        w.set(YC, 0, 0, -p), w.set(WC, 0, 0, p);
        for (var g = 0; g < o; ++g) {
          var h = (g + 1) % o;
          w.set(co, i[3 * g], i[3 * g + 1], -p), w.set(lo, i[3 * h], i[3 * h + 1], -p), w.set(vs, i[3 * h], i[3 * h + 1], p), w.set(u1, i[3 * g], i[3 * g + 1], p), v.addQuad(co, lo, vs, u1);
        }
        if (o === 3) c && (w.set(co, i[0], i[1], -p), w.set(lo, i[3], i[4], -p), w.set(vs, i[6], i[7], -p), v.add(vs, lo, co)), l && (w.set(co, i[0], i[1], p), w.set(lo, i[3], i[4], p), w.set(vs, i[6], i[7], p), v.add(co, lo, vs));
        else if (o === 4) c && (w.set(co, i[0], i[1], -p), w.set(lo, i[3], i[4], -p), w.set(vs, i[6], i[7], -p), w.set(u1, i[9], i[10], -p), v.addQuad(u1, vs, lo, co)), l && (w.set(co, i[0], i[1], p), w.set(lo, i[3], i[4], p), w.set(vs, i[6], i[7], p), w.set(u1, i[9], i[10], p), v.addQuad(co, lo, vs, u1));
        else for (g = 0; g < o; ++g) h = (g + 1) % o, c && (w.set(co, i[3 * g], i[3 * g + 1], -p), w.set(lo, i[3 * h], i[3 * h + 1], -p), v.add(YC, lo, co)), l && (w.set(co, i[3 * g], i[3 * g + 1], p), w.set(lo, i[3 * h], i[3 * h + 1], p), v.add(co, lo, WC));
        return v.getPrimitive();
      }(Tg(Math.max(3, e.radialSegments), !0, e.radiusTop), e);
      r = Mg(n, me.rotX90);
    } else r = function(i) {
      var a = R(R({}, hs), i), o = a.radiusTop, u = a.radiusBottom, s = a.height, c = a.radialSegments, l = a.heightSegments, d = a.topCap, f = a.bottomCap, m = a.thetaStart, v = a.thetaLength, p = [], g = [], h = [], y = 0, x = [], A = s / 2;
      return function() {
        for (var _ = w.zero(), S = (u - o) / s, D = 0; D <= l; ++D) {
          for (var I = [], M = D / l, F = M * (u - o) + o, P = 0; P <= c; ++P) {
            var E = P / c * v + m, B = Math.sin(E), N = Math.cos(E);
            g.push(F * B, -M * s + A, F * N), w.normalize(_, w.set(_, B, S, N)), h.push.apply(h, _), I.push(y++);
          }
          x.push(I);
        }
        for (P = 0; P < c; ++P) for (D = 0; D < l; ++D) {
          var O = x[D][P], z = x[D + 1][P], V = x[D + 1][P + 1], U = x[D][P + 1];
          p.push(O, z, U), p.push(z, V, U);
        }
      }(), d && o > 0 && b(!0), f && u > 0 && b(!1), { vertices: new Float32Array(g), normals: new Float32Array(h), indices: new Uint32Array(p) };
      function b(_) {
        for (var S = _ === !0 ? o : u, D = _ === !0 ? 1 : -1, I = y, M = 1; M <= c; ++M) g.push(0, A * D, 0), h.push(0, D, 0), ++y;
        var F = y;
        for (M = 0; M <= c; ++M) {
          var P = M / c * v + m, E = Math.cos(P), B = Math.sin(P);
          g.push(S * B, A * D, S * E), h.push(0, D, 0), ++y;
        }
        for (M = 0; M < c; ++M) {
          var N = I + M, O = F + M;
          _ === !0 ? p.push(O, O + 1, N) : p.push(O + 1, O, N);
        }
      }
    }(e);
    ZC.set(t, r);
  }
  return r;
}
function wi(e, t, r, n, i) {
  var a = w.distance(t, r) * n;
  w.sub(Cs, r, t), U2(ql, t, Cs, a, !0), wt.addPrimitive(e, ql, N_(i));
}
function NZ(e, t, r, n, i, a) {
  var o = w.distance(t, r) * n, u = N_(a);
  w.sub(Cs, r, t), w.add(M1, t, i), U2(ql, M1, Cs, o, !0), wt.addPrimitive(e, ql, u), w.sub(M1, t, i), U2(ql, M1, Cs, o, !0), wt.addPrimitive(e, ql, u);
}
function jp(e, t, r, n, i, a) {
  var o = Math.floor(i / 2), u = 1 / i;
  if (n < 1) {
    var s = n / 2 / i;
    n += i % 2 == 1 ? s : -s;
  }
  var c = w.distance(t, r) * n, l = N_(a);
  w.sub(Cs, r, t);
  for (var d = 0; d < o; ++d) {
    var f = u * (2 * d + 1);
    w.setMagnitude(Cs, Cs, c * f), w.add(M1, t, Cs), U2(ql, M1, Cs, c * u, !1), wt.addPrimitive(e, ql, l);
  }
}
var wt, qn = w(), tw = Ti(), oc = w(), ys = w(), Td = w(), cv = w(), Ro = w.fromArray, RZ = w.triangleNormal, rw = w.copy, lv = w.transformMat4, nw = w.transformMat3, iw = Ti.directionTransform, Gu = Oe.add3, B4 = Oe.add;
(function(e) {
  function t(n, i, a, o) {
    var u = n.vertices, s = n.normals, c = n.indices, l = n.groups, d = n.currentGroup, f = u.elementCount;
    Gu(u, i[0], i[1], i[2]), Gu(u, a[0], a[1], a[2]), Gu(u, o[0], o[1], o[2]), RZ(qn, i, a, o);
    for (var m = 0; m < 3; ++m) Gu(s, qn[0], qn[1], qn[2]), B4(l, d);
    Gu(c, f, f + 1, f + 2);
  }
  function r(n, i, a) {
    for (var o = a.vertices, u = a.normals, s = a.indices, c = n.vertices, l = n.normals, d = n.indices, f = n.groups, m = n.currentGroup, v = c.elementCount, p = iw(tw, i), g = 0, h = o.length; g < h; g += 3) lv(qn, Ro(qn, o, g), i), Gu(c, qn[0], qn[1], qn[2]), nw(qn, Ro(qn, u, g), p), Gu(l, qn[0], qn[1], qn[2]), B4(f, m);
    for (g = 0, h = s.length; g < h; g += 3) Gu(d, s[g] + v, s[g + 1] + v, s[g + 2] + v);
  }
  e.createState = function(n, i, a) {
    return n === void 0 && (n = 2048), i === void 0 && (i = 1024), { currentGroup: -1, vertices: Oe.create(Float32Array, 3, i, a ? a.vertexBuffer.ref.value : n), normals: Oe.create(Float32Array, 3, i, a ? a.normalBuffer.ref.value : n), indices: Oe.create(Uint32Array, 3, 3 * i, a ? a.indexBuffer.ref.value : 3 * n), groups: Oe.create(Float32Array, 1, i, a ? a.groupBuffer.ref.value : n), mesh: a };
  }, e.addTriangle = t, e.addTriangleStrip = function(n, i, a) {
    Ro(Td, i, 3 * a[0]), Ro(cv, i, 3 * a[1]);
    for (var o = 2, u = a.length; o < u; o += 2) rw(oc, Td), rw(ys, cv), Ro(Td, i, 3 * a[o]), Ro(cv, i, 3 * a[o + 1]), t(n, oc, ys, Td), t(n, ys, cv, Td);
  }, e.addTriangleFan = function(n, i, a) {
    Ro(oc, i, 3 * a[0]);
    for (var o = 2, u = a.length; o < u; ++o) Ro(ys, i, 3 * a[o - 1]), Ro(Td, i, 3 * a[o]), t(n, oc, Td, ys);
  }, e.addPrimitive = r, e.addPrimitiveFlipped = function(n, i, a) {
    for (var o = a.vertices, u = a.normals, s = a.indices, c = n.vertices, l = n.normals, d = n.indices, f = n.groups, m = n.currentGroup, v = c.elementCount, p = iw(tw, i), g = 0, h = o.length; g < h; g += 3) lv(qn, Ro(qn, o, g), i), Gu(c, qn[0], qn[1], qn[2]), nw(qn, Ro(qn, u, g), p), Gu(l, -qn[0], -qn[1], -qn[2]), B4(f, m);
    for (g = 0, h = s.length; g < h; g += 3) Gu(d, s[g + 2] + v, s[g + 1] + v, s[g] + v);
  }, e.addCage = function(n, i, a, o, u, s) {
    for (var c = a.vertices, l = a.edges, d = { radiusTop: o, radiusBottom: o, radialSegments: s }, f = 0, m = l.length; f < m; f += 2) Ro(oc, c, 3 * l[f]), Ro(ys, c, 3 * l[f + 1]), lv(oc, oc, i), lv(ys, ys, i), Mi(n, oc, o, u), Mi(n, ys, o, u), wi(n, oc, ys, 1, d);
  }, e.addMesh = function(n, i, a) {
    r(n, i, { vertices: a.vertexBuffer.ref.value.subarray(0, 3 * a.vertexCount), normals: a.normalBuffer.ref.value.subarray(0, 3 * a.vertexCount), indices: a.indexBuffer.ref.value.subarray(0, 3 * a.triangleCount) });
  }, e.getMesh = function(n) {
    var i = n.vertices, a = n.normals, o = n.indices, u = n.groups, s = n.mesh, c = Oe.compact(i, !0), l = Oe.compact(o, !0), d = Oe.compact(a, !0), f = Oe.compact(u, !0);
    return Gt.create(c, l, d, f, n.vertices.elementCount, n.indices.elementCount, s);
  };
})(wt || (wt = {}));
var R_ = { sceneBoundingSpheres: G.Boolean(!1, { description: "Show full scene bounding spheres." }), visibleSceneBoundingSpheres: G.Boolean(!1, { description: "Show visible scene bounding spheres." }), objectBoundingSpheres: G.Boolean(!1, { description: "Show bounding spheres of visible render objects." }), instanceBoundingSpheres: G.Boolean(!1, { description: "Show bounding spheres of visible instances." }) }, OZ = function() {
  function e(t, r, n) {
    this.objectsData = /* @__PURE__ */ new Map(), this.instancesData = /* @__PURE__ */ new Map(), this.scene = r0.create(t, Fg), this.parent = r, this._props = R(R({}, G.getDefaultValues(R_)), n);
  }
  return e.prototype.update = function() {
    var t = this, r = dv(this.scene, this.parent.boundingSphere, this.sceneData, Kt.lightgrey, LZ);
    r && (this.sceneData = r);
    var n = dv(this.scene, this.parent.boundingSphereVisible, this.visibleSceneData, Kt.black, kZ);
    n && (this.visibleSceneData = n), this.parent.forEach(function(i, a) {
      var o = t.objectsData.get(a), u = dv(t.scene, i.values.boundingSphere.ref.value, o, Kt.tomato, zZ);
      u && t.objectsData.set(a, u);
      var s = t.instancesData.get(a), c = dv(t.scene, i.values.invariantBoundingSphere.ref.value, s, Kt.skyblue, GZ, { aTransform: a.values.aTransform, matrix: a.values.matrix, transform: a.values.transform, extraTransform: a.values.extraTransform, uInstanceCount: a.values.uInstanceCount, instanceCount: a.values.instanceCount, aInstance: a.values.aInstance, hasReflection: a.values.hasReflection });
      c && t.instancesData.set(a, c);
    }), this.objectsData.forEach(function(i, a) {
      t.parent.has(a) || (t.scene.remove(i.renderObject), t.objectsData.delete(a));
    }), this.instancesData.forEach(function(i, a) {
      t.parent.has(a) || (t.scene.remove(i.renderObject), t.instancesData.delete(a));
    }), this.scene.update(void 0, !1), this.scene.commit();
  }, e.prototype.syncVisibility = function() {
    var t = this;
    this.sceneData && (this.sceneData.renderObject.state.visible = this._props.sceneBoundingSpheres), this.visibleSceneData && (this.visibleSceneData.renderObject.state.visible = this._props.visibleSceneBoundingSpheres), this.parent.forEach(function(r, n) {
      var i = t.objectsData.get(n);
      i && (i.renderObject.state.visible = n.state.visible && t._props.objectBoundingSpheres);
      var a = t.instancesData.get(n);
      a && (a.renderObject.state.visible = n.state.visible && t._props.instanceBoundingSpheres);
    });
  }, e.prototype.clear = function() {
    this.sceneData = void 0, this.objectsData.clear(), this.scene.clear();
  }, Object.defineProperty(e.prototype, "isEnabled", { get: function() {
    return this._props.sceneBoundingSpheres || this._props.visibleSceneBoundingSpheres || this._props.objectBoundingSpheres || this._props.instanceBoundingSpheres;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "props", { get: function() {
    return this._props;
  }, enumerable: !1, configurable: !0 }), e.prototype.setProps = function(t) {
    Object.assign(this._props, t), this.isEnabled && this.update();
  }, e;
}();
function dv(e, t, r, n, i, a) {
  if (!r || !Me.equals(r.boundingSphere, t)) {
    var o = function(s, c) {
      var l = 2, d = cP(l), f = wt.createState(d, d / 2, c);
      if (s.radius && (Mi(f, s.center, s.radius, l), Me.hasExtrema(s))) for (var m = 0, v = s.extrema; m < v.length; m++)
        Mi(f, v[m], 1, 0);
      return wt.getMesh(f);
    }(t, r && r.mesh), u = r ? r.renderObject : function(s, c, l, d) {
      var f = Gt.Utils.createValuesSimple(s, { alpha: 0.1, doubleSided: !1 }, c, 1, d);
      return x0("mesh", f, { disposed: !1, visible: !0, alphaFactor: 1, pickable: !1, colorOnly: !1, opaque: !1, writeDepth: !1 }, l);
    }(o, n, i, a);
    return r ? k.updateIfChanged(u.values.drawCount, oa.getDrawCount(o)) : e.add(u), { boundingSphere: Me.clone(t), renderObject: u, mesh: o };
  }
}
var LZ = zc(), kZ = zc(), zZ = zc(), GZ = zc(), F4 = w(), N4 = w(), aw = w(), lP = { maxFps: G.Numeric(30, { min: 10, max: 60, step: 10 }), preferAtomPixelPadding: G.Numeric(3, { min: 0, max: 20, step: 1 }, { description: "Number of extra pixels at which to prefer atoms over bonds." }) }, VZ = function() {
  function e(t, r, n, i, a) {
    var o = this;
    a === void 0 && (a = {}), this.canvasIdentify = t, this.lociGetter = r, this.input = n, this.camera = i, this.ev = ro.create(), this.events = { hover: this.ev(), drag: this.ev(), click: this.ev() }, this.startX = -1, this.startY = -1, this.endX = -1, this.endY = -1, this.id = void 0, this.position = void 0, this.currentIdentifyT = 0, this.isInteracting = !1, this.prevLoci = or.Loci.Empty, this.prevT = 0, this.inside = !1, this.buttons = cf.create(0), this.button = cf.create(0), this.modifiers = H1.None, this.props = R(R({}, G.getDefaultValues(lP)), a), n.drag.subscribe(function(u) {
      var s = u.x, c = u.y, l = u.buttons, d = u.button, f = u.modifiers;
      o.isInteracting = !0, o.drag(s, c, l, d, f);
    }), n.move.subscribe(function(u) {
      var s = u.x, c = u.y, l = u.inside, d = u.buttons, f = u.button, m = u.modifiers;
      l && !o.isInteracting && o.move(s, c, d, f, m);
    }), n.leave.subscribe(function() {
      o.leave();
    }), n.click.subscribe(function(u) {
      var s = u.x, c = u.y, l = u.buttons, d = u.button, f = u.modifiers;
      o.outsideViewport(s, c) || o.click(s, c, l, d, f);
    }), n.interactionEnd.subscribe(function() {
      o.isInteracting = !1;
    }), n.modifiers.subscribe(function(u) {
      o.modify(u);
    });
  }
  return e.prototype.setProps = function(t) {
    Object.assign(this.props, t);
  }, e.prototype.identify = function(t, r) {
    var n = this.startX !== this.endX || this.startY !== this.endY;
    if (t !== 2) {
      if (n) {
        var i = this.canvasIdentify(this.endX, this.endY);
        this.id = i == null ? void 0 : i.id, this.position = i == null ? void 0 : i.position, this.startX = this.endX, this.startY = this.endY;
      }
      if (t === 1) {
        var a = this.getLoci(this.id, this.position);
        return this.events.click.next({ current: a, buttons: this.buttons, button: this.button, modifiers: this.modifiers, page: ke.create(this.endX, this.endY), position: this.position }), void (this.prevLoci = a);
      }
      if (this.inside && this.currentIdentifyT === r && n && !this.outsideViewport(this.endX, this.endY)) {
        var o = this.getLoci(this.id, this.position);
        this.events.hover.next({ current: o, buttons: this.buttons, button: this.button, modifiers: this.modifiers, page: ke.create(this.endX, this.endY), position: this.position }), this.prevLoci = o;
      }
    } else n && !this.outsideViewport(this.startX, this.startY) && (this.events.drag.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers, pageStart: ke.create(this.startX, this.startY), pageEnd: ke.create(this.endX, this.endY) }), this.startX = this.endX, this.startY = this.endY);
  }, e.prototype.tick = function(t) {
    this.inside && t - this.prevT > 1e3 / this.props.maxFps && (this.prevT = t, this.currentIdentifyT = t, this.identify(this.isInteracting ? 2 : 0, t));
  }, e.prototype.leave = function() {
    this.inside = !1, or.Loci.isEmpty(this.prevLoci) || (this.prevLoci = or.Loci.Empty, this.events.hover.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers }));
  }, e.prototype.move = function(t, r, n, i, a) {
    this.inside = !0, this.buttons = n, this.button = i, this.modifiers = a, this.endX = t, this.endY = r;
  }, e.prototype.click = function(t, r, n, i, a) {
    this.endX = t, this.endY = r, this.buttons = n, this.button = i, this.modifiers = a, this.identify(1, 0);
  }, e.prototype.drag = function(t, r, n, i, a) {
    this.endX = t, this.endY = r, this.buttons = n, this.button = i, this.modifiers = a, this.identify(2, 0);
  }, e.prototype.modify = function(t) {
    H1.areEqual(t, this.modifiers) || (this.modifiers = t, this.events.hover.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers, page: ke.create(this.endX, this.endY), position: this.position }));
  }, e.prototype.outsideViewport = function(t, r) {
    var n = this.input, i = this.camera.viewport;
    return t *= n.pixelRatio, r *= n.pixelRatio, t > i.x + i.width || n.height - r > i.y + i.height || t < i.x || n.height - r < i.y;
  }, e.prototype.getLoci = function(t, r) {
    var n, i = this.lociGetter(t), a = i.repr, o = i.loci;
    if (r && a && Dt.isLoci(o) && o.bonds.length === 2) {
      var u = o.bonds[0], s = u.aUnit, c = u.aIndex;
      s.conformation.position(s.elements[c], F4), w.sub(aw, this.camera.state.position, this.camera.state.target), w.projectPointOnPlane(N4, r, aw, F4);
      var l = this.camera.getPixelSize(N4), d = a.theme.size.size(o.bonds[0]) * ((n = a.props.sizeFactor) !== null && n !== void 0 ? n : 1);
      if (a.props.lineSizeAttenuation === !1 && (d *= l / 2), d += this.props.preferAtomPixelPadding * l, w.distance(N4, F4) < d) return { repr: a, loci: Dt.toFirstStructureElementLoci(o) };
    }
    return { repr: a, loci: o };
  }, e.prototype.dispose = function() {
    this.ev.dispose();
  }, e;
}(), UZ = { edgeThresholdMin: G.Numeric(0.0312, { min: 0.0312, max: 0.0833, step: 1e-4 }, { description: "Trims the algorithm from processing darks." }), edgeThresholdMax: G.Numeric(0.063, { min: 0.063, max: 0.333, step: 1e-3 }, { description: "The minimum amount of local contrast required to apply algorithm." }), iterations: G.Numeric(12, { min: 0, max: 16, step: 1 }, { description: "Number of edge exploration steps." }), subpixelQuality: G.Numeric(0.3, { min: 0, max: 1, step: 0.01 }, { description: "Choose the amount of sub-pixel aliasing removal." }) }, HZ = function() {
  function e(t, r) {
    var n, i, a, o, u, s;
    this.webgl = t, this.renderable = (n = t, a = (i = r).getWidth(), o = i.getHeight(), u = R(R({}, Ui), { tColor: k.create(i), uTexSizeInv: k.create(ke.create(1 / a, 1 / o)), dEdgeThresholdMin: k.create(0.0312), dEdgeThresholdMax: k.create(0.125), dIterations: k.create(12), dSubpixelQuality: k.create(0.3) }), s = R({}, qZ), Fi(Bi(n, "triangles", KZ, s, u), u));
  }
  return e.prototype.updateState = function(t) {
    var r = this.webgl, n = r.gl, i = r.state;
    i.enable(n.SCISSOR_TEST), i.disable(n.BLEND), i.disable(n.DEPTH_TEST), i.depthMask(!1);
    var a = t.x, o = t.y, u = t.width, s = t.height;
    n.viewport(a, o, u, s), n.scissor(a, o, u, s), i.clearColor(0, 0, 0, 1), n.clear(n.COLOR_BUFFER_BIT);
  }, e.prototype.setSize = function(t, r) {
    k.update(this.renderable.values.uTexSizeInv, ke.set(this.renderable.values.uTexSizeInv.ref.value, 1 / t, 1 / r));
  }, e.prototype.update = function(t, r) {
    var n = this.renderable.values, i = r.edgeThresholdMin, a = r.edgeThresholdMax, o = r.iterations, u = r.subpixelQuality, s = !1;
    n.tColor.ref.value !== t && (k.update(this.renderable.values.tColor, t), s = !0), n.dEdgeThresholdMin.ref.value !== i && (s = !0), k.updateIfChanged(n.dEdgeThresholdMin, i), n.dEdgeThresholdMax.ref.value !== a && (s = !0), k.updateIfChanged(n.dEdgeThresholdMax, a), n.dIterations.ref.value !== o && (s = !0), k.updateIfChanged(n.dIterations, o), n.dSubpixelQuality.ref.value !== u && (s = !0), k.updateIfChanged(n.dSubpixelQuality, u), s && this.renderable.update();
  }, e.prototype.render = function(t, r) {
    r ? r.bind() : this.webgl.unbindFramebuffer(), this.updateState(t), this.renderable.render();
  }, e;
}(), qZ = R(R({}, qi), { tColor: zt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: Ie("v2"), dEdgeThresholdMin: kt("number"), dEdgeThresholdMax: kt("number"), dIterations: kt("number"), dSubpixelQuality: kt("number") }), KZ = Sn("fxaa", Fa, `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tColor;
uniform vec2 uTexSizeInv;

// adapted from https://github.com/kosua20/Rendu
// MIT License Copyright (c) 2017 Simon Rodriguez

#define QUALITY(q) ((q) < 5 ? 1.0 : ((q) > 5 ? ((q) < 10 ? 2.0 : ((q) < 11 ? 4.0 : 8.0)) : 1.5))

float rgb2luma(vec3 rgb){
    return sqrt(dot(rgb, vec3(0.299, 0.587, 0.114)));
}

float sampleLuma(vec2 uv) {
    return rgb2luma(texture2D(tColor, uv).rgb);
}

float sampleLuma(vec2 uv, float uOffset, float vOffset) {
    uv += uTexSizeInv * vec2(uOffset, vOffset);
    return sampleLuma(uv);
}

void main(void) {
    vec2 coords = gl_FragCoord.xy * uTexSizeInv;
    vec2 inverseScreenSize = uTexSizeInv;

    vec4 colorCenter = texture2D(tColor, coords);

    // Luma at the current fragment
    float lumaCenter = rgb2luma(colorCenter.rgb);

    // Luma at the four direct neighbours of the current fragment.
    float lumaDown = sampleLuma(coords, 0.0, -1.0);
    float lumaUp = sampleLuma(coords, 0.0, 1.0);
    float lumaLeft = sampleLuma(coords, -1.0, 0.0);
    float lumaRight = sampleLuma(coords, 1.0, 0.0);

    // Find the maximum and minimum luma around the current fragment.
    float lumaMin = min(lumaCenter, min(min(lumaDown, lumaUp), min(lumaLeft, lumaRight)));
    float lumaMax = max(lumaCenter, max(max(lumaDown, lumaUp), max(lumaLeft, lumaRight)));

    // Compute the delta.
    float lumaRange = lumaMax - lumaMin;

    // If the luma variation is lower that a threshold (or if we are in a really dark area),
    // we are not on an edge, don't perform any AA.
    if (lumaRange < max(dEdgeThresholdMin, lumaMax * dEdgeThresholdMax)) {
        gl_FragColor = colorCenter;
        return;
    }

    // Query the 4 remaining corners lumas.
    float lumaDownLeft = sampleLuma(coords, -1.0, -1.0);
    float lumaUpRight = sampleLuma(coords, 1.0, 1.0);
    float lumaUpLeft = sampleLuma(coords, -1.0, 1.0);
    float lumaDownRight = sampleLuma(coords, 1.0, -1.0);

    // Combine the four edges lumas (using intermediary variables for future computations
    // with the same values).
    float lumaDownUp = lumaDown + lumaUp;
    float lumaLeftRight = lumaLeft + lumaRight;

    // Same for corners
    float lumaLeftCorners = lumaDownLeft + lumaUpLeft;
    float lumaDownCorners = lumaDownLeft + lumaDownRight;
    float lumaRightCorners = lumaDownRight + lumaUpRight;
    float lumaUpCorners = lumaUpRight + lumaUpLeft;

    // Compute an estimation of the gradient along the horizontal and vertical axis.
    float edgeHorizontal = abs(-2.0 * lumaLeft + lumaLeftCorners) + abs(-2.0 * lumaCenter + lumaDownUp) * 2.0 + abs(-2.0 * lumaRight + lumaRightCorners);
    float edgeVertical = abs(-2.0 * lumaUp + lumaUpCorners) + abs(-2.0 * lumaCenter + lumaLeftRight) * 2.0 + abs(-2.0 * lumaDown + lumaDownCorners);

    // Is the local edge horizontal or vertical ?
    bool isHorizontal = (edgeHorizontal >= edgeVertical);

    // Choose the step size (one pixel) accordingly.
    float stepLength = isHorizontal ? inverseScreenSize.y : inverseScreenSize.x;

    // Select the two neighboring texels lumas in the opposite direction to the local edge.
    float luma1 = isHorizontal ? lumaDown : lumaLeft;
    float luma2 = isHorizontal ? lumaUp : lumaRight;
    // Compute gradients in this direction.
    float gradient1 = luma1 - lumaCenter;
    float gradient2 = luma2 - lumaCenter;

    // Which direction is the steepest ?
    bool is1Steepest = abs(gradient1) >= abs(gradient2);

    // Gradient in the corresponding direction, normalized.
    float gradientScaled = 0.25 * max(abs(gradient1), abs(gradient2));

    // Average luma in the correct direction.
    float lumaLocalAverage = 0.0;
    if(is1Steepest){
        // Switch the direction
        stepLength = -stepLength;
        lumaLocalAverage = 0.5 * (luma1 + lumaCenter);
    } else {
        lumaLocalAverage = 0.5 * (luma2 + lumaCenter);
    }

    // Shift UV in the correct direction by half a pixel.
    vec2 currentUv = coords;
    if(isHorizontal){
        currentUv.y += stepLength * 0.5;
    } else {
        currentUv.x += stepLength * 0.5;
    }

    // Compute offset (for each iteration step) in the right direction.
    vec2 offset = isHorizontal ? vec2(inverseScreenSize.x, 0.0) : vec2(0.0, inverseScreenSize.y);
    // Compute UVs to explore on each side of the edge, orthogonally.
    // The QUALITY allows us to step faster.
    vec2 uv1 = currentUv - offset * QUALITY(0);
    vec2 uv2 = currentUv + offset * QUALITY(0);

    // Read the lumas at both current extremities of the exploration segment,
    // and compute the delta wrt to the local average luma.
    float lumaEnd1 = sampleLuma(uv1);
    float lumaEnd2 = sampleLuma(uv2);
    lumaEnd1 -= lumaLocalAverage;
    lumaEnd2 -= lumaLocalAverage;

    // If the luma deltas at the current extremities is larger than the local gradient,
    // we have reached the side of the edge.
    bool reached1 = abs(lumaEnd1) >= gradientScaled;
    bool reached2 = abs(lumaEnd2) >= gradientScaled;
    bool reachedBoth = reached1 && reached2;

    // If the side is not reached, we continue to explore in this direction.
    if(!reached1){
        uv1 -= offset * QUALITY(1);
    }
    if(!reached2){
        uv2 += offset * QUALITY(1);
    }

    // If both sides have not been reached, continue to explore.
    if(!reachedBoth){
        for(int i = 2; i < dIterations; i++){
            // If needed, read luma in 1st direction, compute delta.
            if(!reached1){
                lumaEnd1 = sampleLuma(uv1);
                lumaEnd1 = lumaEnd1 - lumaLocalAverage;
            }
            // If needed, read luma in opposite direction, compute delta.
            if(!reached2){
                lumaEnd2 = sampleLuma(uv2);
                lumaEnd2 = lumaEnd2 - lumaLocalAverage;
            }
            // If the luma deltas at the current extremities is larger than the local gradient,
            // we have reached the side of the edge.
            reached1 = abs(lumaEnd1) >= gradientScaled;
            reached2 = abs(lumaEnd2) >= gradientScaled;
            reachedBoth = reached1 && reached2;

            // If the side is not reached, we continue to explore in this direction,
            // with a variable quality.
            if(!reached1){
                uv1 -= offset * QUALITY(i);
            }
            if(!reached2){
                uv2 += offset * QUALITY(i);
            }

            // If both sides have been reached, stop the exploration.
            if(reachedBoth){
                break;
            }
        }
    }

    // Compute the distances to each side edge of the edge (!).
    float distance1 = isHorizontal ? (coords.x - uv1.x) : (coords.y - uv1.y);
    float distance2 = isHorizontal ? (uv2.x - coords.x) : (uv2.y - coords.y);

    // In which direction is the side of the edge closer ?
    bool isDirection1 = distance1 < distance2;
    float distanceFinal = min(distance1, distance2);

    // Thickness of the edge.
    float edgeThickness = (distance1 + distance2);

    // Is the luma at center smaller than the local average ?
    bool isLumaCenterSmaller = lumaCenter < lumaLocalAverage;

    // If the luma at center is smaller than at its neighbour,
    // the delta luma at each end should be positive (same variation).
    bool correctVariation1 = (lumaEnd1 < 0.0) != isLumaCenterSmaller;
    bool correctVariation2 = (lumaEnd2 < 0.0) != isLumaCenterSmaller;

    // Only keep the result in the direction of the closer side of the edge.
    bool correctVariation = isDirection1 ? correctVariation1 : correctVariation2;

    // UV offset: read in the direction of the closest side of the edge.
    float pixelOffset = - distanceFinal / edgeThickness + 0.5;

    // If the luma variation is incorrect, do not offset.
    float finalOffset = correctVariation ? pixelOffset : 0.0;

    // Sub-pixel shifting
    // Full weighted average of the luma over the 3x3 neighborhood.
    float lumaAverage = (1.0 / 12.0) * (2.0 * (lumaDownUp + lumaLeftRight) + lumaLeftCorners + lumaRightCorners);
    // Ratio of the delta between the global average and the center luma,
    // over the luma range in the 3x3 neighborhood.
    float subPixelOffset1 = clamp(abs(lumaAverage - lumaCenter) / lumaRange, 0.0, 1.0);
    float subPixelOffset2 = (-2.0 * subPixelOffset1 + 3.0) * subPixelOffset1 * subPixelOffset1;
    // Compute a sub-pixel offset based on this delta.
    float subPixelOffsetFinal = subPixelOffset2 * subPixelOffset2 * float(dSubpixelQuality);

    // Pick the biggest of the two offsets.
    finalOffset = max(finalOffset, subPixelOffsetFinal);

    // Compute the final UV coordinates.
    vec2 finalUv = coords;
    if(isHorizontal){
        finalUv.y += finalOffset * stepLength;
    } else {
        finalUv.x += finalOffset * stepLength;
    }

    // Read the color at the new UV coordinates, and use it.
    gl_FragColor = texture2D(tColor, finalUv);
}
`), XZ = { edgeThreshold: G.Numeric(0.1, { min: 0.05, max: 0.15, step: 0.01 }), maxSearchSteps: G.Numeric(16, { min: 0, max: 32, step: 1 }) }, jZ = function() {
  function e(t, r) {
    if (this.webgl = t, this._supported = !1, typeof HTMLImageElement < "u") {
      var n = r.getWidth(), i = r.getHeight();
      this.edgesTarget = t.createRenderTarget(n, i, !1, "uint8", "linear"), this.weightsTarget = t.createRenderTarget(n, i, !1, "uint8", "linear"), this.edgesRenderable = function(a, o) {
        var u = o.getWidth(), s = o.getHeight(), c = R(R({}, Ui), { tColor: k.create(o), uTexSizeInv: k.create(ke.create(1 / u, 1 / s)), uViewport: k.create(Vt()), dEdgeThreshold: k.create(0.1) }), l = R({}, YZ);
        return Fi(Bi(a, "triangles", WZ, l, c), c);
      }(t, r), this.weightsRenderable = function(a, o) {
        var u = o.getWidth(), s = o.getHeight(), c = fb(a.gl, a.extensions, "image-uint8", "rgb", "ubyte", "linear"), l = fb(a.gl, a.extensions, "image-uint8", "rgba", "ubyte", "nearest"), d = R(R({}, Ui), { tEdges: k.create(o), tArea: k.create(c), tSearch: k.create(l), uTexSizeInv: k.create(ke.create(1 / u, 1 / s)), uViewport: k.create(Vt()), dMaxSearchSteps: k.create(16) });
        V9("data:image/png;base64, ", d.tArea, c), V9("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII=", d.tSearch, l);
        var f = R({}, ZZ);
        return Fi(Bi(a, "triangles", QZ, f, d), d);
      }(t, this.edgesTarget.texture), this.blendRenderable = function(a, o, u) {
        var s = o.getWidth(), c = o.getHeight(), l = R(R({}, Ui), { tColor: k.create(o), tWeights: k.create(u), uTexSizeInv: k.create(ke.create(1 / s, 1 / c)), uViewport: k.create(Vt()) }), d = R({}, JZ);
        return Fi(Bi(a, "triangles", $Z, d, l), l);
      }(t, r, this.weightsTarget.texture), this._supported = !0;
    } else Ir && console.log('Missing "HTMLImageElement" required for "SMAA"');
  }
  return Object.defineProperty(e.prototype, "supported", { get: function() {
    return this._supported;
  }, enumerable: !1, configurable: !0 }), e.prototype.updateState = function(t) {
    var r = this.webgl, n = r.gl, i = r.state;
    i.enable(n.SCISSOR_TEST), i.disable(n.BLEND), i.disable(n.DEPTH_TEST), i.depthMask(!1);
    var a = t.x, o = t.y, u = t.width, s = t.height;
    n.viewport(a, o, u, s), n.scissor(a, o, u, s), i.clearColor(0, 0, 0, 1), n.clear(n.COLOR_BUFFER_BIT), k.update(this.edgesRenderable.values.uViewport, Vi.toVec4(this.edgesRenderable.values.uViewport.ref.value, t)), k.update(this.weightsRenderable.values.uViewport, Vi.toVec4(this.weightsRenderable.values.uViewport.ref.value, t)), k.update(this.blendRenderable.values.uViewport, Vi.toVec4(this.blendRenderable.values.uViewport.ref.value, t));
  }, e.prototype.setSize = function(t, r) {
    var n = this.edgesTarget.getWidth(), i = this.edgesTarget.getHeight();
    t === n && r === i || (this.edgesTarget.setSize(t, r), this.weightsTarget.setSize(t, r), k.update(this.edgesRenderable.values.uTexSizeInv, ke.set(this.edgesRenderable.values.uTexSizeInv.ref.value, 1 / t, 1 / r)), k.update(this.weightsRenderable.values.uTexSizeInv, ke.set(this.weightsRenderable.values.uTexSizeInv.ref.value, 1 / t, 1 / r)), k.update(this.blendRenderable.values.uTexSizeInv, ke.set(this.blendRenderable.values.uTexSizeInv.ref.value, 1 / t, 1 / r)));
  }, e.prototype.update = function(t, r) {
    var n = !1;
    this.edgesRenderable.values.tColor.ref.value !== t && (k.update(this.edgesRenderable.values.tColor, t), n = !0), this.edgesRenderable.values.dEdgeThreshold.ref.value !== r.edgeThreshold && (k.update(this.edgesRenderable.values.dEdgeThreshold, r.edgeThreshold), n = !0), n && this.edgesRenderable.update(), this.weightsRenderable.values.dMaxSearchSteps.ref.value !== r.maxSearchSteps && (k.update(this.weightsRenderable.values.dMaxSearchSteps, r.maxSearchSteps), this.weightsRenderable.update()), this.blendRenderable.values.tColor.ref.value !== t && (k.update(this.blendRenderable.values.tColor, t), this.blendRenderable.update());
  }, e.prototype.render = function(t, r) {
    this.edgesTarget.bind(), this.updateState(t), this.edgesRenderable.render(), this.weightsTarget.bind(), this.updateState(t), this.weightsRenderable.render(), r ? r.bind() : this.webgl.unbindFramebuffer(), this.updateState(t), this.blendRenderable.render();
  }, e;
}(), YZ = R(R({}, qi), { tColor: zt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: Ie("v2"), uViewport: Ie("v4"), dEdgeThreshold: kt("number") }), WZ = Sn("smaa-edges", `
precision highp float;

attribute vec2 aPosition;
uniform vec2 uQuadScale;

uniform vec2 uTexSizeInv;
uniform vec4 uViewport;

varying vec2 vUv;
varying vec4 vOffset[3];

void SMAAEdgeDetectionVS(vec2 texCoord) {
    vOffset[0] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-1.0, 0.0, 0.0, 1.0); // WebGL port note: Changed sign in W component
    vOffset[1] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(1.0, 0.0, 0.0, -1.0); // WebGL port note: Changed sign in W component
    vOffset[2] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-2.0, 0.0, 0.0, 2.0); // WebGL port note: Changed sign in W component
}

void main() {
    vec2 scale = uViewport.zw * uTexSizeInv;
    vec2 shift = uViewport.xy * uTexSizeInv;
    vUv = (aPosition + 1.0) * 0.5 * scale + shift;
    SMAAEdgeDetectionVS(vUv);
    vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale;
    gl_Position = vec4(position, 0.0, 1.0);
}
`, `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tColor;
uniform vec2 uTexSizeInv;

varying vec2 vUv;
varying vec4 vOffset[3];

vec4 SMAAColorEdgeDetectionPS(vec2 texcoord, vec4 offset[3], sampler2D colorTex) {
    vec2 threshold = vec2(dEdgeThreshold, dEdgeThreshold);

    // Calculate color deltas:
    vec4 delta;
    vec3 C = texture2D(colorTex, texcoord).rgb;

    vec3 Cleft = texture2D(colorTex, offset[0].xy).rgb;
    vec3 t = abs(C - Cleft);
    delta.x = max(max(t.r, t.g), t.b);

    vec3 Ctop = texture2D(colorTex, offset[0].zw).rgb;
    t = abs(C - Ctop);
    delta.y = max(max(t.r, t.g), t.b);

    // We do the usual threshold:
    vec2 edges = step(threshold, delta.xy);

    // Then discard if there is no edge:
    if (dot(edges, vec2(1.0, 1.0 )) == 0.0)
        discard;

    // Calculate right and bottom deltas:
    vec3 Cright = texture2D(colorTex, offset[1].xy).rgb;
    t = abs( C - Cright );
    delta.z = max(max(t.r, t.g), t.b);

    vec3 Cbottom  = texture2D(colorTex, offset[1].zw).rgb;
    t = abs(C - Cbottom);
    delta.w = max(max(t.r, t.g), t.b);

    // Calculate the maximum delta in the direct neighborhood:
    float maxDelta = max(max(max(delta.x, delta.y), delta.z), delta.w );

    // Calculate left-left and top-top deltas:
    vec3 Cleftleft  = texture2D(colorTex, offset[2].xy).rgb;
    t = abs( C - Cleftleft );
    delta.z = max(max(t.r, t.g), t.b);

    vec3 Ctoptop = texture2D(colorTex, offset[2].zw).rgb;
    t = abs(C - Ctoptop);
    delta.w = max(max(t.r, t.g), t.b);

    // Calculate the final maximum delta:
    maxDelta = max(max(maxDelta, delta.z), delta.w);

    // Local contrast adaptation in action:
    edges.xy *= step(0.5 * maxDelta, delta.xy);

    return vec4(edges, 0.0, 0.0);
}

void main() {
    gl_FragColor = SMAAColorEdgeDetectionPS(vUv, vOffset, tColor);
}
`), ZZ = R(R({}, qi), { tEdges: zt("texture", "rgba", "ubyte", "linear"), tArea: zt("texture", "rgb", "ubyte", "linear"), tSearch: zt("texture", "rgba", "ubyte", "nearest"), uTexSizeInv: Ie("v2"), uViewport: Ie("v4"), dMaxSearchSteps: kt("number") }), QZ = Sn("smaa-weights", `
precision highp float;

attribute vec2 aPosition;
uniform vec2 uQuadScale;

uniform vec2 uTexSizeInv;
uniform vec4 uViewport;

varying vec2 vUv;
varying vec4 vOffset[3];
varying vec2 vPixCoord;

void SMAABlendingWeightCalculationVS(vec2 texCoord) {
    vPixCoord = texCoord / uTexSizeInv;

    // We will use these offsets for the searches later on (see @PSEUDO_GATHER4):
    vOffset[0] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-0.25, 0.125, 1.25, 0.125); // WebGL port note: Changed sign in Y and W components
    vOffset[1] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-0.125, 0.25, -0.125, -1.25); // WebGL port note: Changed sign in Y and W components

    // And these for the searches, they indicate the ends of the loops:
    vOffset[2] = vec4(vOffset[0].xz, vOffset[1].yw) + vec4(-2.0, 2.0, -2.0, 2.0) * uTexSizeInv.xxyy * float(dMaxSearchSteps);
}

void main() {
    vec2 scale = uViewport.zw * uTexSizeInv;
    vec2 shift = uViewport.xy * uTexSizeInv;
    vUv = (aPosition + 1.0) * 0.5 * scale + shift;
    SMAABlendingWeightCalculationVS(vUv);
    vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale;
    gl_Position = vec4(position, 0.0, 1.0);
}
`, `
precision highp float;
precision highp int;
precision highp sampler2D;

#define SMAASampleLevelZeroOffset(tex, coord, offset) texture2D(tex, coord + float(offset) * uTexSizeInv, 0.0)

#define SMAA_AREATEX_MAX_DISTANCE 16
#define SMAA_AREATEX_PIXEL_SIZE (1.0 / vec2(160.0, 560.0))
#define SMAA_AREATEX_SUBTEX_SIZE (1.0 / 7.0)

uniform sampler2D tEdges;
uniform sampler2D tArea;
uniform sampler2D tSearch;
uniform vec2 uTexSizeInv;

varying vec2 vUv;
varying vec4 vOffset[3];
varying vec2 vPixCoord;

#if __VERSION__ == 100
    vec2 round(vec2 x) {
        return sign(x) * floor(abs(x) + 0.5);
    }
#endif

float SMAASearchLength(sampler2D searchTex, vec2 e, float bias, float scale) {
    // Not required if searchTex accesses are set to point:
    // float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0);
    // e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE +
    //     e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE;
    e.r = bias + e.r * scale;
    return 255.0 * texture2D(searchTex, e, 0.0).r;
}

float SMAASearchXLeft(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) {
    /**
     * @PSEUDO_GATHER4
     * This texCoord has been offset by (-0.25, -0.125) in the vertex shader to
     * sample between edge, thus fetching four edges in a row.
     * Sampling with different offsets in each direction allows to disambiguate
     * which edges are active from the four fetched ones.
     */
    vec2 e = vec2(0.0, 1.0);

    for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for
        e = texture2D( edgesTex, texCoord, 0.0).rg;
        texCoord -= vec2(2.0, 0.0) * uTexSizeInv;
        if (!(texCoord.x > end && e.g > 0.8281 && e.r == 0.0)) break;
    }

    // We correct the previous (-0.25, -0.125) offset we applied:
    texCoord.x += 0.25 * uTexSizeInv.x;

    // The searches are bias by 1, so adjust the coords accordingly:
    texCoord.x += uTexSizeInv.x;

    // Disambiguate the length added by the last step:
    texCoord.x += 2.0 * uTexSizeInv.x; // Undo last step
    texCoord.x -= uTexSizeInv.x * SMAASearchLength(searchTex, e, 0.0, 0.5);

    return texCoord.x;
}

float SMAASearchXRight(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) {
    vec2 e = vec2( 0.0, 1.0 );

    for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for
        e = texture2D(edgesTex, texCoord, 0.0).rg;
        texCoord += vec2(2.0, 0.0) * uTexSizeInv;
        if (!(texCoord.x < end && e.g > 0.8281 && e.r == 0.0)) break;
    }

    texCoord.x -= 0.25 * uTexSizeInv.x;
    texCoord.x -= uTexSizeInv.x;
    texCoord.x -= 2.0 * uTexSizeInv.x;
    texCoord.x += uTexSizeInv.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );

    return texCoord.x;
}

float SMAASearchYUp(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) {
    vec2 e = vec2( 1.0, 0.0 );

    for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for
        e = texture2D(edgesTex, texCoord, 0.0).rg;
        texCoord += vec2(0.0, 2.0) * uTexSizeInv; // WebGL port note: Changed sign
        if (!(texCoord.y > end && e.r > 0.8281 && e.g == 0.0)) break;
    }

    texCoord.y -= 0.25 * uTexSizeInv.y; // WebGL port note: Changed sign
    texCoord.y -= uTexSizeInv.y; // WebGL port note: Changed sign
    texCoord.y -= 2.0 * uTexSizeInv.y; // WebGL port note: Changed sign
    texCoord.y += uTexSizeInv.y * SMAASearchLength(searchTex, e.gr, 0.0, 0.5); // WebGL port note: Changed sign

    return texCoord.y;
}

float SMAASearchYDown(sampler2D edgesTex, sampler2D searchTex, vec2 texCoord, float end) {
    vec2 e = vec2( 1.0, 0.0 );

    for (int i = 0; i < dMaxSearchSteps; i++) { // WebGL port note: Changed while to for
        e = texture2D(edgesTex, texCoord, 0.0).rg;
        texCoord -= vec2( 0.0, 2.0 ) * uTexSizeInv; // WebGL port note: Changed sign
        if (!(texCoord.y < end && e.r > 0.8281 && e.g == 0.0)) break;
    }

    texCoord.y += 0.25 * uTexSizeInv.y; // WebGL port note: Changed sign
    texCoord.y += uTexSizeInv.y; // WebGL port note: Changed sign
    texCoord.y += 2.0 * uTexSizeInv.y; // WebGL port note: Changed sign
    texCoord.y -= uTexSizeInv.y * SMAASearchLength(searchTex, e.gr, 0.5, 0.5); // WebGL port note: Changed sign

    return texCoord.y;
}

vec2 SMAAArea(sampler2D areaTex, vec2 dist, float e1, float e2, float offset) {
    // Rounding prevents precision errors of bilinear filtering:
    vec2 texCoord = float(SMAA_AREATEX_MAX_DISTANCE) * round(4.0 * vec2(e1, e2)) + dist;

    // We do a scale and bias for mapping to texel space:
    texCoord = SMAA_AREATEX_PIXEL_SIZE * texCoord + (0.5 * SMAA_AREATEX_PIXEL_SIZE);

    // Move to proper place, according to the subpixel offset:
    texCoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;

    return texture2D(areaTex, texCoord, 0.0).rg;
}

vec4 SMAABlendingWeightCalculationPS(vec2 texCoord, vec2 pixCoord, vec4 offset[3], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices) {
    vec4 weights = vec4(0.0, 0.0, 0.0, 0.0);

    vec2 e = texture2D(edgesTex, texCoord).rg;

    if (e.g > 0.0) { // Edge at north
        vec2 d;

        // Find the distance to the left:
        vec2 coords;
        coords.x = SMAASearchXLeft(edgesTex, searchTex, offset[0].xy, offset[2].x );
        coords.y = offset[1].y; // offset[1].y = texCoord.y - 0.25 * uTexSizeInv.y (@CROSSING_OFFSET)
        d.x = coords.x;

        // Now fetch the left crossing edges, two at a time using bilinear
        // filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to
        // discern what value each edge has:
        float e1 = texture2D(edgesTex, coords, 0.0).r;

        // Find the distance to the right:
        coords.x = SMAASearchXRight(edgesTex, searchTex, offset[0].zw, offset[2].y);
        d.y = coords.x;

        // We want the distances to be in pixel units (doing this here allow to
        // better interleave arithmetic and memory accesses):
        d = d / uTexSizeInv.x - pixCoord.x;

        // SMAAArea below needs a sqrt, as the areas texture is compressed
        // quadratically:
        vec2 sqrt_d = sqrt(abs(d));

        // Fetch the right crossing edges:
        coords.y -= 1.0 * uTexSizeInv.y; // WebGL port note: Added
        float e2 = SMAASampleLevelZeroOffset(edgesTex, coords, ivec2(1, 0)).r;

        // Ok, we know how this pattern looks like, now it is time for getting
        // the actual area:
        weights.rg = SMAAArea(areaTex, sqrt_d, e1, e2, float(subsampleIndices.y));
    }

    if (e.r > 0.0) { // Edge at west
        vec2 d;

        // Find the distance to the top:
        vec2 coords;

        coords.y = SMAASearchYUp(edgesTex, searchTex, offset[1].xy, offset[2].z );
        coords.x = offset[0].x; // offset[1].x = texCoord.x - 0.25 * uTexSizeInv.x;
        d.x = coords.y;

        // Fetch the top crossing edges:
        float e1 = texture2D(edgesTex, coords, 0.0).g;

        // Find the distance to the bottom:
        coords.y = SMAASearchYDown(edgesTex, searchTex, offset[1].zw, offset[2].w);
        d.y = coords.y;

        // We want the distances to be in pixel units:
        d = d / uTexSizeInv.y - pixCoord.y;

        // SMAAArea below needs a sqrt, as the areas texture is compressed
        // quadratically:
        vec2 sqrt_d = sqrt(abs(d));

        // Fetch the bottom crossing edges:
        coords.y -= 1.0 * uTexSizeInv.y; // WebGL port note: Added
        float e2 = SMAASampleLevelZeroOffset(edgesTex, coords, ivec2(0, 1)).g;

        // Get the area for this direction:
        weights.ba = SMAAArea(areaTex, sqrt_d, e1, e2, float(subsampleIndices.x));
    }

    return weights;
}

void main() {
    gl_FragColor = SMAABlendingWeightCalculationPS(vUv, vPixCoord, vOffset, tEdges, tArea, tSearch, ivec4(0.0));
}
`), JZ = R(R({}, qi), { tColor: zt("texture", "rgba", "ubyte", "linear"), tWeights: zt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: Ie("v2"), uViewport: Ie("v4") }), $Z = Sn("smaa-blend", `
precision highp float;

attribute vec2 aPosition;
uniform vec2 uQuadScale;

uniform vec2 uTexSizeInv;
uniform vec4 uViewport;

varying vec2 vUv;
varying vec4 vOffset[2];

void SMAANeighborhoodBlendingVS(vec2 texCoord) {
    vOffset[0] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(-1.0, 0.0, 0.0, 1.0); // WebGL port note: Changed sign in W component
    vOffset[1] = texCoord.xyxy + uTexSizeInv.xyxy * vec4(1.0, 0.0, 0.0, -1.0); // WebGL port note: Changed sign in W component
}

void main() {
    vec2 scale = uViewport.zw * uTexSizeInv;
    vec2 shift = uViewport.xy * uTexSizeInv;
    vUv = (aPosition + 1.0) * 0.5 * scale + shift;
    SMAANeighborhoodBlendingVS(vUv);
    vec2 position = aPosition * uQuadScale - vec2(1.0, 1.0) + uQuadScale;
    gl_Position = vec4(position, 0.0, 1.0);
}
`, `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tWeights;
uniform sampler2D tColor;
uniform vec2 uTexSizeInv;

varying vec2 vUv;
varying vec4 vOffset[2];

vec4 SMAANeighborhoodBlendingPS(vec2 texCoord, vec4 offset[2], sampler2D colorTex, sampler2D blendTex) {
    // Fetch the blending weights for current pixel:
    vec4 a;
    a.xz = texture2D(blendTex, texCoord).xz;
    a.y = texture2D(blendTex, offset[1].zw).g;
    a.w = texture2D(blendTex, offset[1].xy).a;

    // Is there any blending weight with a value greater than 0.0?
    if (dot(a, vec4(1.0, 1.0, 1.0, 1.0)) < 1e-5) {
        return texture2D(colorTex, texCoord, 0.0);
    } else {
        // Up to 4 lines can be crossing a pixel (one through each edge). We
        // favor blending by choosing the line with the maximum weight for each
        // direction:
        vec2 offset;
        offset.x = a.a > a.b ? a.a : -a.b; // left vs. right
        offset.y = a.g > a.r ? -a.g : a.r; // top vs. bottom // WebGL port note: Changed signs

        // Then we go in the direction that has the maximum weight:
        if (abs(offset.x) > abs(offset.y)) { // horizontal vs. vertical
            offset.y = 0.0;
        } else {
            offset.x = 0.0;
        }

        // Fetch the opposite color and lerp by hand:
        vec4 C = texture2D(colorTex, texCoord, 0.0);
        texCoord += sign(offset) * uTexSizeInv;
        vec4 Cop = texture2D(colorTex, texCoord, 0.0);
        float s = abs(offset.x) > abs(offset.y) ? abs(offset.x) : abs(offset.y);

        // WebGL port note: Added gamma correction
        C.xyz = pow(C.xyz, vec3(2.2));
        Cop.xyz = pow(Cop.xyz, vec3(2.2));
        vec4 mixed = mix(C, Cop, s);
        mixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2));

        return mixed;
    }
}

void main() {
    gl_FragColor = SMAANeighborhoodBlendingPS(vUv, vOffset, tColor, tWeights);
}
`), eQ = R(R({}, qi), { tDepth: zt("texture", "rgba", "ubyte", "nearest"), uTexSize: Ie("v2"), dOrthographic: kt("number"), uNear: Ie("f"), uFar: Ie("f"), uMaxPossibleViewZDiff: Ie("f") }), tQ = R(R({}, qi), { tDepth: zt("texture", "rgba", "ubyte", "nearest"), uSamples: Ie("v3[]"), dNSamples: kt("number"), uProjection: Ie("m4"), uInvProjection: Ie("m4"), uBounds: Ie("v4"), uTexSize: Ie("v2"), uRadius: Ie("f"), uBias: Ie("f") }), rQ = R(R({}, qi), { tSsaoDepth: zt("texture", "rgba", "ubyte", "nearest"), uTexSize: Ie("v2"), uKernel: Ie("f[]"), dOcclusionKernelSize: kt("number"), uBlurDirectionX: Ie("f"), uBlurDirectionY: Ie("f"), uMaxPossibleViewZDiff: Ie("f"), uNear: Ie("f"), uFar: Ie("f"), uBounds: Ie("v4"), dOrthographic: kt("number") });
function ow(e, t, r) {
  var n = R(R({}, Ui), { tSsaoDepth: k.create(t), uTexSize: k.create(ke.create(t.getWidth(), t.getHeight())), uKernel: k.create([0]), dOcclusionKernelSize: k.create(15), uBlurDirectionX: k.create(r === "horizontal" ? 1 : 0), uBlurDirectionY: k.create(r === "vertical" ? 1 : 0), uMaxPossibleViewZDiff: k.create(0.5), uNear: k.create(0), uFar: k.create(1e4), uBounds: k.create(Vt()), dOrthographic: k.create(0) }), i = R({}, rQ);
  return Fi(Bi(e, "triangles", Sn("ssao_blur", Fa, `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tSsaoDepth;
uniform vec2 uTexSize;
uniform vec4 uBounds;

uniform float uKernel[dOcclusionKernelSize];

uniform float uBlurDirectionX;
uniform float uBlurDirectionY;

uniform float uMaxPossibleViewZDiff;

uniform float uNear;
uniform float uFar;

#include common

float getViewZ(const in float depth) {
    #if dOrthographic == 1
        return orthographicDepthToViewZ(depth, uNear, uFar);
    #else
        return perspectiveDepthToViewZ(depth, uNear, uFar);
    #endif
}

bool isBackground(const in float depth) {
    return depth == 1.0;
}

bool outsideBounds(const in vec2 p) {
    return p.x < uBounds.x || p.y < uBounds.y || p.x > uBounds.z || p.y > uBounds.w;
}

void main(void) {
    vec2 coords = gl_FragCoord.xy / uTexSize;

    vec2 packedDepth = texture2D(tSsaoDepth, coords).zw;

    if (outsideBounds(coords)) {
        gl_FragColor = vec4(packUnitIntervalToRG(1.0), packedDepth);
        return;
    }

    float selfDepth = unpackRGToUnitInterval(packedDepth);
    // if background and if second pass
    if (isBackground(selfDepth) && uBlurDirectionY != 0.0) {
        gl_FragColor = vec4(packUnitIntervalToRG(1.0), packedDepth);
        return;
    }

    float selfViewZ = getViewZ(selfDepth);

    vec2 offset = vec2(uBlurDirectionX, uBlurDirectionY) / uTexSize;

    float sum = 0.0;
    float kernelSum = 0.0;
    // only if kernelSize is odd
    for (int i = -dOcclusionKernelSize / 2; i <= dOcclusionKernelSize / 2; i++) {
        vec2 sampleCoords = coords + float(i) * offset;
        if (outsideBounds(sampleCoords)) {
            continue;
        }

        vec4 sampleSsaoDepth = texture2D(tSsaoDepth, sampleCoords);

        float sampleDepth = unpackRGToUnitInterval(sampleSsaoDepth.zw);
        if (isBackground(sampleDepth)) {
            continue;
        }

        if (abs(float(i)) > 1.0) { // abs is not defined for int in webgl1
            float sampleViewZ = getViewZ(sampleDepth);
            if (abs(selfViewZ - sampleViewZ) > uMaxPossibleViewZDiff) {
                continue;
            }
        }

        float kernel = uKernel[int(abs(float(i)))]; // abs is not defined for int in webgl1
        float sampleValue = unpackRGToUnitInterval(sampleSsaoDepth.xy);

        sum += kernel * sampleValue;
        kernelSum += kernel;
    }

    gl_FragColor = vec4(packUnitIntervalToRG(sum / kernelSum), packedDepth);
}
`), i, n), n);
}
var nQ = R(R({}, qi), { tSsaoDepth: zt("texture", "rgba", "ubyte", "nearest"), tColor: zt("texture", "rgba", "ubyte", "nearest"), tDepth: zt("texture", "rgba", "ubyte", "nearest"), tOutlines: zt("texture", "rgba", "ubyte", "nearest"), uTexSize: Ie("v2"), dOrthographic: kt("number"), uNear: Ie("f"), uFar: Ie("f"), uFogNear: Ie("f"), uFogFar: Ie("f"), uFogColor: Ie("v3"), uOutlineColor: Ie("v3"), uTransparentBackground: Ie("b"), uMaxPossibleViewZDiff: Ie("f"), dOcclusionEnable: kt("boolean"), uOcclusionOffset: Ie("v2"), dOutlineEnable: kt("boolean"), dOutlineScale: kt("number"), uOutlineThreshold: Ie("f") }), dP = { occlusion: G.MappedStatic("on", { on: G.Group({ samples: G.Numeric(32, { min: 1, max: 256, step: 1 }), radius: G.Numeric(5, { min: 0, max: 10, step: 0.1 }, { description: "Final occlusion radius is 2^x" }), bias: G.Numeric(0.8, { min: 0, max: 3, step: 0.1 }), blurKernelSize: G.Numeric(15, { min: 1, max: 25, step: 2 }), resolutionScale: G.Numeric(1, { min: 0.1, max: 1, step: 0.05 }, { description: "Adjust resolution of occlusion calculation" }) }), off: G.Group({}) }, { cycle: !0, description: "Darken occluded crevices with the ambient occlusion effect" }), outline: G.MappedStatic("off", { on: G.Group({ scale: G.Numeric(1, { min: 1, max: 5, step: 1 }), threshold: G.Numeric(0.33, { min: 0.01, max: 1, step: 0.01 }), color: G.Color(He(0)) }), off: G.Group({}) }, { cycle: !0, description: "Draw outline around 3D objects" }), antialiasing: G.MappedStatic("smaa", { fxaa: G.Group(UZ), smaa: G.Group(XZ), off: G.Group({}) }, { options: [["fxaa", "FXAA"], ["smaa", "SMAA"], ["off", "Off"]], description: "Smooth pixel edges" }) }, mc = function() {
  function e(t, r) {
    this.webgl = t, this.drawPass = r, this.occlusionOffset = [0, 0];
    var n = r.colorTarget, i = r.depthTexture, a = n.getWidth(), o = n.getHeight();
    this.nSamples = 1, this.blurKernelSize = 1, this.downsampleFactor = 1, this.ssaoScale = this.calcSsaoScale(), this.target = t.createRenderTarget(a, o, !1, "uint8", "linear"), this.outlinesTarget = t.createRenderTarget(a, o, !1), this.outlinesRenderable = function(d, f) {
      var m = R(R({}, Ui), { tDepth: k.create(f), uTexSize: k.create(ke.create(f.getWidth(), f.getHeight())), dOrthographic: k.create(0), uNear: k.create(1), uFar: k.create(1e4), uMaxPossibleViewZDiff: k.create(0.5) }), v = R({}, eQ);
      return Fi(Bi(d, "triangles", Sn("outlines", Fa, `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tDepth;
uniform vec2 uTexSize;

uniform float uNear;
uniform float uFar;

uniform float uMaxPossibleViewZDiff;

#include common

float getViewZ(const in float depth) {
    #if dOrthographic == 1
        return orthographicDepthToViewZ(depth, uNear, uFar);
    #else
        return perspectiveDepthToViewZ(depth, uNear, uFar);
    #endif
}

float getDepth(const in vec2 coords) {
    return unpackRGBAToDepth(texture2D(tDepth, coords));
}

bool isBackground(const in float depth) {
    return depth == 1.0;
}

void main(void) {
    float backgroundViewZ = uFar + 3.0 * uMaxPossibleViewZDiff;

    vec2 coords = gl_FragCoord.xy / uTexSize;
    vec2 invTexSize = 1.0 / uTexSize;

    float selfDepth = getDepth(coords);
    float selfViewZ = isBackground(selfDepth) ? backgroundViewZ : getViewZ(getDepth(coords));

    float outline = 1.0;
    float bestDepth = 1.0;

    for (int y = -1; y <= 1; y++) {
        for (int x = -1; x <= 1; x++) {
            vec2 sampleCoords = coords + vec2(float(x), float(y)) * invTexSize;
            float sampleDepth = getDepth(sampleCoords);
            float sampleViewZ = isBackground(sampleDepth) ? backgroundViewZ : getViewZ(sampleDepth);

            if (abs(selfViewZ - sampleViewZ) > uMaxPossibleViewZDiff && selfDepth > sampleDepth && sampleDepth <= bestDepth) {
                outline = 0.0;
                bestDepth = sampleDepth;
            }
        }
    }

    gl_FragColor = vec4(outline, packUnitIntervalToRG(bestDepth), 0.0);
}
`), v, m), m);
    }(t, i), this.randomHemisphereVector = [];
    for (var u = 0; u < 256; u++) {
      var s = w();
      s[0] = 2 * Math.random() - 1, s[1] = 2 * Math.random() - 1, s[2] = Math.random(), w.normalize(s, s), w.scale(s, s, Math.random()), this.randomHemisphereVector.push(s);
    }
    this.ssaoFramebuffer = t.resources.framebuffer(), this.ssaoBlurFirstPassFramebuffer = t.resources.framebuffer(), this.ssaoBlurSecondPassFramebuffer = t.resources.framebuffer();
    var c = Math.floor(a * this.ssaoScale), l = Math.floor(o * this.ssaoScale);
    this.downsampledDepthTarget = t.createRenderTarget(c, l, !1, "uint8", "linear"), this.downsampleDepthRenderable = Bb(t, i), this.ssaoDepthTexture = t.resources.texture("image-uint8", "rgba", "ubyte", "linear"), this.ssaoDepthTexture.define(c, l), this.ssaoDepthTexture.attachFramebuffer(this.ssaoFramebuffer, "color0"), this.ssaoDepthBlurProxyTexture = t.resources.texture("image-uint8", "rgba", "ubyte", "linear"), this.ssaoDepthBlurProxyTexture.define(c, l), this.ssaoDepthBlurProxyTexture.attachFramebuffer(this.ssaoBlurFirstPassFramebuffer, "color0"), this.ssaoDepthTexture.attachFramebuffer(this.ssaoBlurSecondPassFramebuffer, "color0"), this.ssaoRenderable = function(d, f) {
      var m = R(R({}, Ui), { tDepth: k.create(f), uSamples: k.create([0, 0, 1]), dNSamples: k.create(32), uProjection: k.create(me.identity()), uInvProjection: k.create(me.identity()), uBounds: k.create(Vt()), uTexSize: k.create(ke.create(d.gl.drawingBufferWidth, d.gl.drawingBufferHeight)), uRadius: k.create(8), uBias: k.create(0.025) }), v = R({}, tQ);
      return Fi(Bi(d, "triangles", Sn("ssao", Fa, `
precision highp float;
precision highp int;
precision highp sampler2D;

#include common

uniform sampler2D tDepth;
uniform vec2 uTexSize;
uniform vec4 uBounds;

uniform vec3 uSamples[dNSamples];

uniform mat4 uProjection;
uniform mat4 uInvProjection;

uniform float uRadius;
uniform float uBias;

float smootherstep(float edge0, float edge1, float x) {
    x = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
    return x * x * x * (x * (x * 6.0 - 15.0) + 10.0);
}

float noise(const in vec2 coords) {
    float a = 12.9898;
    float b = 78.233;
    float c = 43758.5453;
    float dt = dot(coords, vec2(a,b));
    float sn = mod(dt, PI);
    return abs(fract(sin(sn) * c)); // is abs necessary?
}

vec2 getNoiseVec2(const in vec2 coords) {
    return vec2(noise(coords), noise(coords + vec2(PI, 2.71828)));
}

bool isBackground(const in float depth) {
    return depth == 1.0;
}

bool outsideBounds(const in vec2 p) {
    return p.x < uBounds.x || p.y < uBounds.y || p.x > uBounds.z || p.y > uBounds.w;
}

float getDepth(const in vec2 coords) {
    return outsideBounds(coords) ? 1.0 : unpackRGBAToDepth(texture2D(tDepth, coords));
}

vec3 normalFromDepth(const in float depth, const in float depth1, const in float depth2, vec2 offset1, vec2 offset2) {
    vec3 p1 = vec3(offset1, depth1 - depth);
    vec3 p2 = vec3(offset2, depth2 - depth);

    vec3 normal = cross(p1, p2);
    normal.z = -normal.z;

    return normalize(normal);
}

// StarCraft II Ambient Occlusion by [Filion and McNaughton 2008]
void main(void) {
    vec2 invTexSize = 1.0 / uTexSize;
    vec2 selfCoords = gl_FragCoord.xy * invTexSize;

    float selfDepth = getDepth(selfCoords);
    vec2 selfPackedDepth = packUnitIntervalToRG(selfDepth);

    if (isBackground(selfDepth)) {
        gl_FragColor = vec4(packUnitIntervalToRG(0.0), selfPackedDepth);
        return;
    }

    vec2 offset1 = vec2(0.0, invTexSize.y);
    vec2 offset2 = vec2(invTexSize.x, 0.0);

    float selfDepth1 = getDepth(selfCoords + offset1);
    float selfDepth2 = getDepth(selfCoords + offset2);

    vec3 selfViewNormal = normalFromDepth(selfDepth, selfDepth1, selfDepth2, offset1, offset2);
    vec3 selfViewPos = screenSpaceToViewSpace(vec3(selfCoords, selfDepth), uInvProjection);

    vec3 randomVec = normalize(vec3(getNoiseVec2(selfCoords) * 2.0 - 1.0, 0.0));

    vec3 tangent = normalize(randomVec - selfViewNormal * dot(randomVec, selfViewNormal));
    vec3 bitangent = cross(selfViewNormal, tangent);
    mat3 TBN = mat3(tangent, bitangent, selfViewNormal);

    float occlusion = 0.0;
    for(int i = 0; i < dNSamples; i++){
        vec3 sampleViewPos = TBN * uSamples[i];
        sampleViewPos = selfViewPos + sampleViewPos * uRadius;

        vec4 offset = vec4(sampleViewPos, 1.0);
        offset = uProjection * offset;
        offset.xyz = (offset.xyz / offset.w) * 0.5 + 0.5;

        float sampleViewZ = screenSpaceToViewSpace(vec3(offset.xy, getDepth(offset.xy)), uInvProjection).z;

        occlusion += step(sampleViewPos.z + 0.025, sampleViewZ) * smootherstep(0.0, 1.0, uRadius / abs(selfViewPos.z - sampleViewZ));
    }
    occlusion = 1.0 - (uBias * occlusion / float(dNSamples));

    vec2 packedOcclusion = packUnitIntervalToRG(occlusion);

    gl_FragColor = vec4(packedOcclusion, selfPackedDepth);
}
`), v, m), m);
    }(t, this.downsampleFactor === 1 ? i : this.downsampledDepthTarget.texture), this.ssaoBlurFirstPassRenderable = ow(t, this.ssaoDepthTexture, "horizontal"), this.ssaoBlurSecondPassRenderable = ow(t, this.ssaoDepthBlurProxyTexture, "vertical"), this.renderable = function(d, f, m, v, p) {
      var g = R(R({}, Ui), { tSsaoDepth: k.create(p), tColor: k.create(f), tDepth: k.create(m), tOutlines: k.create(v), uTexSize: k.create(ke.create(f.getWidth(), f.getHeight())), dOrthographic: k.create(0), uNear: k.create(1), uFar: k.create(1e4), uFogNear: k.create(1e4), uFogFar: k.create(1e4), uFogColor: k.create(w.create(1, 1, 1)), uOutlineColor: k.create(w.create(0, 0, 0)), uTransparentBackground: k.create(!1), uMaxPossibleViewZDiff: k.create(0.5), dOcclusionEnable: k.create(!0), uOcclusionOffset: k.create(ke.create(0, 0)), dOutlineEnable: k.create(!1), dOutlineScale: k.create(1), uOutlineThreshold: k.create(0.33) }), h = R({}, nQ);
      return Fi(Bi(d, "triangles", Sn("postprocessing", Fa, `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tSsaoDepth;
uniform sampler2D tColor;
uniform sampler2D tDepth;
uniform sampler2D tOutlines;
uniform vec2 uTexSize;

uniform float uNear;
uniform float uFar;
uniform float uFogNear;
uniform float uFogFar;
uniform vec3 uFogColor;
uniform vec3 uOutlineColor;
uniform bool uTransparentBackground;

uniform vec2 uOcclusionOffset;

uniform float uMaxPossibleViewZDiff;

const vec3 occlusionColor = vec3(0.0);

#include common

float getViewZ(const in float depth) {
    #if dOrthographic == 1
        return orthographicDepthToViewZ(depth, uNear, uFar);
    #else
        return perspectiveDepthToViewZ(depth, uNear, uFar);
    #endif
}

float getDepth(const in vec2 coords) {
    return unpackRGBAToDepth(texture2D(tDepth, coords));
}

bool isBackground(const in float depth) {
    return depth == 1.0;
}

float getOutline(const in vec2 coords, out float closestTexel) {
    float backgroundViewZ = uFar + 3.0 * uMaxPossibleViewZDiff;
    vec2 invTexSize = 1.0 / uTexSize;

    float selfDepth = getDepth(coords);
    float selfViewZ = isBackground(selfDepth) ? backgroundViewZ : getViewZ(selfDepth);

    float outline = 1.0;
    closestTexel = 1.0;
    for (int y = -dOutlineScale; y <= dOutlineScale; y++) {
        for (int x = -dOutlineScale; x <= dOutlineScale; x++) {
            if (x * x + y * y > dOutlineScale * dOutlineScale) {
                continue;
            }

            vec2 sampleCoords = coords + vec2(float(x), float(y)) * invTexSize;

            vec4 sampleOutlineCombined = texture2D(tOutlines, sampleCoords);
            float sampleOutline = sampleOutlineCombined.r;
            float sampleOutlineDepth = unpackRGToUnitInterval(sampleOutlineCombined.gb);

            if (sampleOutline == 0.0 && sampleOutlineDepth < closestTexel && abs(selfViewZ - sampleOutlineDepth) > uMaxPossibleViewZDiff) {
                outline = 0.0;
                closestTexel = sampleOutlineDepth;
            }
        }
    }
    return outline;
}

float getSsao(vec2 coords) {
    float rawSsao = unpackRGToUnitInterval(texture2D(tSsaoDepth, coords).xy);
    if (rawSsao > 0.999) {
        return 1.0;
    } else if (rawSsao > 0.001) {
        return rawSsao;
    }
    // treat values close to 0.0 as errors and return no occlusion
    return 1.0;
}

void main(void) {
    vec2 coords = gl_FragCoord.xy / uTexSize;
    vec4 color = texture2D(tColor, coords);

    float viewDist;
    float fogFactor;

    #ifdef dOcclusionEnable
        float depth = getDepth(coords);
        if (!isBackground(depth)) {
            viewDist = abs(getViewZ(depth));
            fogFactor = smoothstep(uFogNear, uFogFar, viewDist);
            float occlusionFactor = getSsao(coords + uOcclusionOffset);
            if (!uTransparentBackground) {
                color.rgb = mix(mix(occlusionColor, uFogColor, fogFactor), color.rgb, occlusionFactor);
            } else {
                color.rgb = mix(occlusionColor * (1.0 - fogFactor), color.rgb, occlusionFactor);
            }
        }
    #endif

    // outline needs to be handled after occlusion to keep them clean
    #ifdef dOutlineEnable
        float closestTexel;
        float outline = getOutline(coords, closestTexel);

        if (outline == 0.0) {
            color.rgb = mix(uOutlineColor, color.rgb, outline);
            viewDist = abs(getViewZ(closestTexel));
            fogFactor = smoothstep(uFogNear, uFogFar, viewDist);
            if (!uTransparentBackground) {
                color.rgb = mix(color.rgb, uFogColor, fogFactor);
            } else {
                color.a = 1.0 - fogFactor;
            }
        }
    #endif

    gl_FragColor = color;
}
`), h, g), g);
    }(t, n.texture, i, this.outlinesTarget.texture, this.ssaoDepthTexture);
  }
  return e.isEnabled = function(t) {
    return t.occlusion.name === "on" || t.outline.name === "on";
  }, e.prototype.calcSsaoScale = function() {
    return Math.min(1, 1 / this.webgl.pixelRatio) * this.downsampleFactor;
  }, e.prototype.setSize = function(t, r) {
    var n = this.renderable.values.uTexSize.ref.value, i = n[0], a = n[1], o = this.calcSsaoScale();
    if (t !== i || r !== a || this.ssaoScale !== o) {
      this.ssaoScale = o;
      var u = Math.floor(t * this.ssaoScale), s = Math.floor(r * this.ssaoScale);
      this.target.setSize(t, r), this.outlinesTarget.setSize(t, r), this.downsampledDepthTarget.setSize(u, s), this.ssaoDepthTexture.define(u, s), this.ssaoDepthBlurProxyTexture.define(u, s), k.update(this.renderable.values.uTexSize, ke.set(this.renderable.values.uTexSize.ref.value, t, r)), k.update(this.outlinesRenderable.values.uTexSize, ke.set(this.outlinesRenderable.values.uTexSize.ref.value, t, r)), k.update(this.downsampleDepthRenderable.values.uTexSize, ke.set(this.downsampleDepthRenderable.values.uTexSize.ref.value, u, s)), k.update(this.ssaoRenderable.values.uTexSize, ke.set(this.ssaoRenderable.values.uTexSize.ref.value, u, s)), k.update(this.ssaoBlurFirstPassRenderable.values.uTexSize, ke.set(this.ssaoBlurFirstPassRenderable.values.uTexSize.ref.value, u, s)), k.update(this.ssaoBlurSecondPassRenderable.values.uTexSize, ke.set(this.ssaoBlurSecondPassRenderable.values.uTexSize.ref.value, u, s));
    }
  }, e.prototype.updateState = function(t, r, n, i) {
    var a = !1, o = !1, u = !1, s = t.state.mode === "orthographic" ? 1 : 0, c = i.outline.name === "on", l = i.occlusion.name === "on", d = me.identity();
    if (me.invert(d, t.projection), i.occlusion.name === "on") {
      k.update(this.ssaoRenderable.values.uProjection, t.projection), k.update(this.ssaoRenderable.values.uInvProjection, d);
      var f = this.renderable.values.uTexSize.ref.value, m = f[0], v = f[1], p = this.ssaoRenderable.values.uBounds, g = t.viewport, h = this.ssaoScale;
      if (Vt.set(p.ref.value, Math.floor(g.x * h) / (m * h), Math.floor(g.y * h) / (v * h), Math.ceil((g.x + g.width) * h) / (m * h), Math.ceil((g.y + g.height) * h) / (v * h)), k.update(p, p.ref.value), k.update(this.ssaoBlurFirstPassRenderable.values.uBounds, p.ref.value), k.update(this.ssaoBlurSecondPassRenderable.values.uBounds, p.ref.value), k.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.uNear, t.near), k.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.uNear, t.near), k.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.uFar, t.far), k.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.uFar, t.far), this.ssaoBlurFirstPassRenderable.values.dOrthographic.ref.value !== s && (u = !0), k.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.dOrthographic, s), k.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.dOrthographic, s), this.nSamples !== i.occlusion.params.samples && (o = !0, this.nSamples = i.occlusion.params.samples, k.update(this.ssaoRenderable.values.uSamples, function(O, z) {
        for (var V = [], U = 0; U < z; U++) {
          var H = (U * U + 2 * U + 1) / (z * z);
          H = 0.1 + 0.9 * H, V.push(O[U][0] * H), V.push(O[U][1] * H), V.push(O[U][2] * H);
        }
        return V;
      }(this.randomHemisphereVector, this.nSamples)), k.updateIfChanged(this.ssaoRenderable.values.dNSamples, this.nSamples)), k.updateIfChanged(this.ssaoRenderable.values.uRadius, Math.pow(2, i.occlusion.params.radius)), k.updateIfChanged(this.ssaoRenderable.values.uBias, i.occlusion.params.bias), this.blurKernelSize !== i.occlusion.params.blurKernelSize) {
        u = !0, this.blurKernelSize = i.occlusion.params.blurKernelSize;
        var y = function(O) {
          for (var z = O / 3, V = Math.floor((O + 1) / 2), U = [], H = 0; H < V; H++) U.push(1 / (Math.sqrt(2 * Math.PI) * z) * Math.exp(-H * H / (2 * z * z)));
          return U;
        }(this.blurKernelSize);
        k.update(this.ssaoBlurFirstPassRenderable.values.uKernel, y), k.update(this.ssaoBlurSecondPassRenderable.values.uKernel, y), k.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.dOcclusionKernelSize, this.blurKernelSize), k.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.dOcclusionKernelSize, this.blurKernelSize);
      }
      if (this.downsampleFactor !== i.occlusion.params.resolutionScale) {
        o = !0, this.downsampleFactor = i.occlusion.params.resolutionScale, this.ssaoScale = this.calcSsaoScale();
        var x = Math.floor(m * this.ssaoScale), A = Math.floor(v * this.ssaoScale);
        this.downsampledDepthTarget.setSize(x, A), this.ssaoDepthTexture.define(x, A), this.ssaoDepthBlurProxyTexture.define(x, A), this.ssaoScale === 1 ? k.update(this.ssaoRenderable.values.tDepth, this.drawPass.depthTexture) : k.update(this.ssaoRenderable.values.tDepth, this.downsampledDepthTarget.texture), k.update(this.downsampleDepthRenderable.values.uTexSize, ke.set(this.downsampleDepthRenderable.values.uTexSize.ref.value, x, A)), k.update(this.ssaoRenderable.values.uTexSize, ke.set(this.ssaoRenderable.values.uTexSize.ref.value, x, A)), k.update(this.ssaoBlurFirstPassRenderable.values.uTexSize, ke.set(this.ssaoBlurFirstPassRenderable.values.uTexSize.ref.value, x, A)), k.update(this.ssaoBlurSecondPassRenderable.values.uTexSize, ke.set(this.ssaoBlurSecondPassRenderable.values.uTexSize.ref.value, x, A));
      }
    }
    if (i.outline.name === "on") {
      var b = i.outline.params.threshold;
      t.state.mode === "orthographic" && (b /= 5);
      var _ = Math.pow(1e3, b) / 1e3 * t.state.radiusMax, S = i.outline.params.scale - 1;
      k.updateIfChanged(this.outlinesRenderable.values.uNear, t.near), k.updateIfChanged(this.outlinesRenderable.values.uFar, t.far), k.updateIfChanged(this.outlinesRenderable.values.uMaxPossibleViewZDiff, _), k.update(this.renderable.values.uOutlineColor, He.toVec3Normalized(this.renderable.values.uOutlineColor.ref.value, i.outline.params.color)), k.updateIfChanged(this.renderable.values.uMaxPossibleViewZDiff, _), this.renderable.values.dOutlineScale.ref.value !== S && (a = !0), k.updateIfChanged(this.renderable.values.dOutlineScale, S);
    }
    k.updateIfChanged(this.renderable.values.uFar, t.far), k.updateIfChanged(this.renderable.values.uNear, t.near), k.updateIfChanged(this.renderable.values.uFogFar, t.fogFar), k.updateIfChanged(this.renderable.values.uFogNear, t.fogNear), k.update(this.renderable.values.uFogColor, He.toVec3Normalized(this.renderable.values.uFogColor.ref.value, n)), k.updateIfChanged(this.renderable.values.uTransparentBackground, r), this.renderable.values.dOrthographic.ref.value !== s && (a = !0), k.updateIfChanged(this.renderable.values.dOrthographic, s), this.renderable.values.dOutlineEnable.ref.value !== c && (a = !0), k.updateIfChanged(this.renderable.values.dOutlineEnable, c), this.renderable.values.dOcclusionEnable.ref.value !== l && (a = !0), k.updateIfChanged(this.renderable.values.dOcclusionEnable, l), o && this.ssaoRenderable.update(), u && (this.ssaoBlurFirstPassRenderable.update(), this.ssaoBlurSecondPassRenderable.update()), a && this.renderable.update();
    var D = this.webgl, I = D.gl, M = D.state;
    M.enable(I.SCISSOR_TEST), M.disable(I.BLEND), M.disable(I.DEPTH_TEST), M.depthMask(!1);
    var F = t.viewport, P = F.x, E = F.y, B = F.width, N = F.height;
    I.viewport(P, E, B, N), I.scissor(P, E, B, N);
  }, e.prototype.setOcclusionOffset = function(t, r) {
    this.occlusionOffset[0] = t, this.occlusionOffset[1] = r, k.update(this.renderable.values.uOcclusionOffset, ke.set(this.renderable.values.uOcclusionOffset.ref.value, t, r));
  }, e.prototype.render = function(t, r, n, i, a) {
    this.updateState(t, n, i, a), a.outline.name === "on" && (this.outlinesTarget.bind(), this.outlinesRenderable.render()), a.occlusion.name === "on" && this.occlusionOffset[0] === 0 && this.occlusionOffset[1] === 0 && (this.ssaoScale < 1 && (this.downsampledDepthTarget.bind(), this.downsampleDepthRenderable.render()), this.ssaoFramebuffer.bind(), this.ssaoRenderable.render(), this.ssaoBlurFirstPassFramebuffer.bind(), this.ssaoBlurFirstPassRenderable.render(), this.ssaoBlurSecondPassFramebuffer.bind(), this.ssaoBlurSecondPassRenderable.render()), r ? this.webgl.unbindFramebuffer() : this.target.bind();
    var o = this.webgl, u = o.gl;
    o.state.clearColor(0, 0, 0, 1), u.clear(u.COLOR_BUFFER_BIT), this.renderable.render();
  }, e;
}(), R4 = function() {
  function e(t, r) {
    this.drawPass = r;
    var n = r.colorTarget, i = n.getWidth(), a = n.getHeight();
    this.target = t.createRenderTarget(i, a, !1), this.fxaa = new HZ(t, this.target.texture), this.smaa = new jZ(t, this.target.texture);
  }
  return e.isEnabled = function(t) {
    return t.antialiasing.name !== "off";
  }, e.prototype.setSize = function(t, r) {
    var n = this.target.texture.getWidth(), i = this.target.texture.getHeight();
    t === n && r === i || (this.target.setSize(t, r), this.fxaa.setSize(t, r), this.smaa.supported && this.smaa.setSize(t, r));
  }, e.prototype._renderFxaa = function(t, r, n) {
    if (n.antialiasing.name === "fxaa") {
      var i = mc.isEnabled(n) ? this.drawPass.postprocessing.target.texture : this.drawPass.colorTarget.texture;
      this.fxaa.update(i, n.antialiasing.params), this.fxaa.render(t.viewport, r ? void 0 : this.target);
    }
  }, e.prototype._renderSmaa = function(t, r, n) {
    if (n.antialiasing.name === "smaa") {
      var i = mc.isEnabled(n) ? this.drawPass.postprocessing.target.texture : this.drawPass.colorTarget.texture;
      this.smaa.update(i, n.antialiasing.params), this.smaa.render(t.viewport, r ? void 0 : this.target);
    }
  }, e.prototype.render = function(t, r, n) {
    if (n.antialiasing.name !== "off") {
      if (n.antialiasing.name === "fxaa") this._renderFxaa(t, r, n);
      else if (n.antialiasing.name === "smaa") {
        if (!this.smaa.supported) throw new Error('SMAA not supported, missing "HTMLImageElement"');
        this._renderSmaa(t, r, n);
      }
    }
  }, e;
}(), iQ = R(R({}, qi), { tColor: zt("texture", "rgba", "ubyte", "nearest"), uTexSize: Ie("v2"), uWeight: Ie("f") }), aQ = Sn("compose", Fa, `
precision highp float;
precision highp sampler2D;

uniform sampler2D tColor;
uniform vec2 uTexSize;
uniform float uWeight;

void main() {
    vec2 coords = gl_FragCoord.xy / uTexSize;
    gl_FragColor = texture2D(tColor, coords) * uWeight;
}
`), fP = { mode: G.Select("temporal", [["off", "Off"], ["on", "On"], ["temporal", "Temporal"]]), sampleLevel: G.Numeric(2, { min: 0, max: 5, step: 1 }, { description: "Take level^2 samples." }) }, H2 = function() {
  function e(t, r) {
    this.webgl = t, this.drawPass = r;
    var n = t.extensions, i = n.colorBufferFloat, a = n.textureFloat, o = n.colorBufferHalfFloat, u = n.textureHalfFloat, s = r.colorTarget.getWidth(), c = r.colorTarget.getHeight();
    this.colorTarget = t.createRenderTarget(s, c, !1);
    var l, d, f, m, v = o && u ? "fp16" : i && a ? "float32" : "uint8";
    this.composeTarget = t.createRenderTarget(s, c, !1, v), this.holdTarget = t.createRenderTarget(s, c, !1), this.compose = (l = t, d = r.colorTarget.texture, f = R(R({}, Ui), { tColor: k.create(d), uTexSize: k.create(ke.create(d.getWidth(), d.getHeight())), uWeight: k.create(1) }), m = R({}, iQ), Fi(Bi(l, "triangles", aQ, m, f), f));
  }
  return e.isEnabled = function(t) {
    return t.mode !== "off";
  }, e.prototype.syncSize = function() {
    var t = this.drawPass.colorTarget.getWidth(), r = this.drawPass.colorTarget.getHeight(), n = this.compose.values.uTexSize.ref.value, i = n[0], a = n[1];
    t === i && r === a || (this.colorTarget.setSize(t, r), this.composeTarget.setSize(t, r), this.holdTarget.setSize(t, r), k.update(this.compose.values.uTexSize, ke.set(this.compose.values.uTexSize.ref.value, t, r)));
  }, e.prototype.render = function(t, r, n, i, a) {
    return n.multiSample.mode !== "temporal" || a ? (this.renderMultiSample(r, i, n), -2) : this.renderTemporalMultiSample(t, r, n, i);
  }, e.prototype.bindOutputTarget = function(t) {
    t ? this.webgl.unbindFramebuffer() : this.colorTarget.bind();
  }, e.prototype.renderMultiSample = function(t, r, n) {
    var i = t.camera, a = this, o = a.compose, u = a.composeTarget, s = a.drawPass, c = a.webgl, l = c.gl, d = c.state, f = Wb[Math.max(0, Math.min(n.multiSample.sampleLevel, 5))], m = i.viewport, v = m.x, p = m.y, g = m.width, h = m.height, y = 1 / f.length;
    i.viewOffset.enabled = !0, k.update(o.values.tColor, s.getColorTarget(n.postprocessing).texture), o.update();
    for (var x = 0; x < f.length; ++x) {
      var A = f[x];
      Jn.setViewOffset(i.viewOffset, g, h, A[0], A[1], g, h), i.update();
      var b = y + 0.03125 * ((x + 0.5) / f.length - 0.5);
      k.update(o.values.uWeight, b), x === 0 ? s.postprocessing.setOcclusionOffset(0, 0) : s.postprocessing.setOcclusionOffset(A[0] / g, A[1] / h), s.render(t, n, !1), u.bind(), d.enable(l.BLEND), d.blendEquationSeparate(l.FUNC_ADD, l.FUNC_ADD), d.blendFuncSeparate(l.ONE, l.ONE, l.ONE, l.ONE), d.disable(l.DEPTH_TEST), d.depthMask(!1), l.viewport(v, p, g, h), l.scissor(v, p, g, h), x === 0 && (d.clearColor(0, 0, 0, 0), l.clear(l.COLOR_BUFFER_BIT)), o.render();
    }
    s.postprocessing.setOcclusionOffset(0, 0), k.update(o.values.uWeight, 1), k.update(o.values.tColor, u.texture), o.update(), this.bindOutputTarget(r), l.viewport(v, p, g, h), l.scissor(v, p, g, h), d.disable(l.BLEND), o.render(), i.viewOffset.enabled = !1, i.update();
  }, e.prototype.renderTemporalMultiSample = function(t, r, n, i) {
    var a = r.camera, o = this, u = o.compose, s = o.composeTarget, c = o.holdTarget, l = o.drawPass, d = o.webgl, f = d.gl, m = d.state, v = Wb[Math.max(0, Math.min(n.multiSample.sampleLevel, 5))];
    if (t === -2 || t >= v.length) return -2;
    var p = a.viewport, g = p.x, h = p.y, y = p.width, x = p.height, A = 1 / v.length;
    if (t === -1) l.render(r, n, !1), k.update(u.values.uWeight, 1), k.update(u.values.tColor, l.getColorTarget(n.postprocessing).texture), u.update(), c.bind(), m.disable(f.BLEND), m.disable(f.DEPTH_TEST), m.depthMask(!1), f.viewport(g, h, y, x), f.scissor(g, h, y, x), u.render(), t += 1;
    else {
      a.viewOffset.enabled = !0, k.update(u.values.tColor, l.getColorTarget(n.postprocessing).texture), k.update(u.values.uWeight, A), u.update();
      for (var b = Math.pow(2, Math.max(0, n.multiSample.sampleLevel - 2)), _ = 0; _ < b; ++_) {
        var S = v[t];
        if (Jn.setViewOffset(a.viewOffset, y, x, S[0], S[1], y, x), a.update(), t === 0 ? l.postprocessing.setOcclusionOffset(0, 0) : l.postprocessing.setOcclusionOffset(S[0] / y, S[1] / x), l.render(r, n, !1), s.bind(), m.enable(f.BLEND), m.blendEquationSeparate(f.FUNC_ADD, f.FUNC_ADD), m.blendFuncSeparate(f.ONE, f.ONE, f.ONE, f.ONE), m.disable(f.DEPTH_TEST), m.depthMask(!1), f.viewport(g, h, y, x), f.scissor(g, h, y, x), t === 0 && (m.clearColor(0, 0, 0, 0), f.clear(f.COLOR_BUFFER_BIT)), u.render(), (t += 1) >= v.length) break;
      }
    }
    l.postprocessing.setOcclusionOffset(0, 0), this.bindOutputTarget(i), f.viewport(g, h, y, x), f.scissor(g, h, y, x);
    var D = t * A;
    return D > 0 && (k.update(u.values.uWeight, 1), k.update(u.values.tColor, s.texture), u.update(), m.disable(f.BLEND), u.render()), D < 1 && (k.update(u.values.uWeight, 1 - D), k.update(u.values.tColor, c.texture), u.update(), D === 0 ? m.disable(f.BLEND) : m.enable(f.BLEND), u.render()), a.viewOffset.enabled = !1, a.update(), t >= v.length ? -2 : t;
  }, e;
}(), Wb = [[[0, 0]], [[0, 0], [-4, -4]], [[0, 0], [6, -2], [-6, 2], [2, 6]], [[0, 0], [-1, 3], [5, 1], [-3, -5], [-5, 5], [-7, -1], [3, 7], [7, -7]], [[0, 0], [-1, -3], [-3, 2], [4, -1], [-5, -2], [2, 5], [5, 3], [3, -5], [-2, 6], [0, -7], [-4, -6], [-6, 4], [-8, 0], [7, -4], [6, 7], [-7, -8]], [[0, 0], [-7, -5], [-3, -5], [-5, -4], [-1, -4], [-2, -2], [-6, -1], [-4, 0], [-7, 1], [-1, 2], [-6, 3], [-3, 3], [-7, 6], [-3, 6], [-5, 7], [-1, 7], [5, -7], [1, -6], [6, -5], [4, -4], [2, -3], [7, -2], [1, -1], [4, -1], [2, 1], [6, 2], [0, 4], [4, 4], [2, 5], [7, 5], [5, 6], [3, 7]]];
Wb.forEach(function(e) {
  e.forEach(function(t) {
    t[0] *= 0.0625, t[1] *= 0.0625;
  });
});
var pP = function() {
  function e(t) {
    this.multiSamplePass = t, this.sampleIndex = -2;
  }
  return e.prototype.update = function(t, r) {
    return t && (this.sampleIndex = -1), r.mode === "temporal" && this.sampleIndex !== -2;
  }, e.prototype.render = function(t, r, n, i) {
    return this.sampleIndex = this.multiSamplePass.render(this.sampleIndex, t, r, n, !!i), this.sampleIndex < 0;
  }, e;
}(), mP = { eyeSeparation: G.Numeric(0.064, { min: 0.01, max: 0.5, step: 1e-3 }), focus: G.Numeric(10, { min: 1, max: 100, step: 0.01 }) }, oQ = G.getDefaultValues(mP), n0 = function() {
  function e(t, r) {
    r === void 0 && (r = {}), this.parent = t, this.left = new uw(), this.right = new uw(), this.props = R(R({}, oQ), r);
  }
  return Object.defineProperty(e.prototype, "viewport", { get: function() {
    return this.parent.viewport;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "viewOffset", { get: function() {
    return this.parent.viewOffset;
  }, enumerable: !1, configurable: !0 }), e.prototype.setProps = function(t) {
    Object.assign(this.props, t);
  }, e.prototype.update = function() {
    this.parent.update(), function(t, r, n, i) {
      Vi.copy(n.viewport, t.viewport), me.copy(n.view, t.view), me.copy(n.projection, t.projection), Jn.copySnapshot(n.state, t.state), Jn.copyViewOffset(n.viewOffset, t.viewOffset), n.far = t.far, n.near = t.near, n.fogFar = t.fogFar, n.fogNear = t.fogNear, Vi.copy(i.viewport, t.viewport), me.copy(i.view, t.view), me.copy(i.projection, t.projection), Jn.copySnapshot(i.state, t.state), Jn.copyViewOffset(i.viewOffset, t.viewOffset), i.far = t.far, i.near = t.near, i.fogFar = t.fogFar, i.fogNear = t.fogNear;
      var a = Math.floor(t.viewport.width / 2), o = a / t.viewport.height;
      n.viewport.width = a, i.viewport.x += a, i.viewport.width -= a;
      var u, s, c = r.eyeSeparation / 2, l = c * t.near / r.focus, d = t.near * Math.tan(0.5 * t.state.fov);
      sw[12] = -c, cw[12] = c, u = -d * o + l, s = d * o + l, n.projection[0] = 2 * t.near / (s - u), n.projection[8] = (s + u) / (s - u), me.mul(n.view, n.view, sw), me.mul(n.projectionView, n.projection, n.view), me.invert(n.inverseProjectionView, n.projectionView), u = -d * o - l, s = d * o - l, i.projection[0] = 2 * t.near / (s - u), i.projection[8] = (s + u) / (s - u), me.mul(i.view, i.view, cw), me.mul(i.projectionView, i.projection, i.view), me.invert(i.inverseProjectionView, i.projectionView);
    }(this.parent, this.props, this.left, this.right);
  }, e;
}();
(function(e) {
  e.is = function(t) {
    return "left" in t && "right" in t;
  };
})(n0 || (n0 = {}));
var uw = function() {
  this.viewport = Vi.create(0, 0, 0, 0), this.view = me(), this.projection = me(), this.projectionView = me(), this.inverseProjectionView = me(), this.state = Jn.createDefaultSnapshot(), this.viewOffset = Jn.ViewOffset(), this.far = 0, this.near = 0, this.fogFar = 0, this.fogNear = 0;
}, sw = me.identity(), cw = me.identity(), O4 = Math.pow(2, 24) - 2, uQ = function() {
  function e(t, r, n) {
    this.webgl = t, this.drawPass = r, this.pickBaseScale = n;
    var i = n / t.pixelRatio;
    this.pickWidth = Math.ceil(r.colorTarget.getWidth() * i), this.pickHeight = Math.ceil(r.colorTarget.getHeight() * i), this.objectPickTarget = t.createRenderTarget(this.pickWidth, this.pickHeight), this.instancePickTarget = t.createRenderTarget(this.pickWidth, this.pickHeight), this.groupPickTarget = t.createRenderTarget(this.pickWidth, this.pickHeight), this.depthPickTarget = t.createRenderTarget(this.pickWidth, this.pickHeight);
  }
  return Object.defineProperty(e.prototype, "drawingBufferHeight", { get: function() {
    return this.drawPass.colorTarget.getHeight();
  }, enumerable: !1, configurable: !0 }), e.prototype.syncSize = function() {
    var t = this.pickBaseScale / this.webgl.pixelRatio, r = Math.ceil(this.drawPass.colorTarget.getWidth() * t), n = Math.ceil(this.drawPass.colorTarget.getHeight() * t);
    r === this.pickWidth && n === this.pickHeight || (this.pickWidth = r, this.pickHeight = n, this.objectPickTarget.setSize(this.pickWidth, this.pickHeight), this.instancePickTarget.setSize(this.pickWidth, this.pickHeight), this.groupPickTarget.setSize(this.pickWidth, this.pickHeight), this.depthPickTarget.setSize(this.pickWidth, this.pickHeight));
  }, e.prototype.renderVariant = function(t, r, n, i, a, o) {
    var u = this.drawPass.depthTexturePrimitives;
    t.clear(!1), t.update(r), t.renderPick(n.primitives, r, a, null, o), t.renderPick(n.volumes, r, a, u, o), t.renderPick(i.handle.scene, r, a, null, o), i.camera.isEnabled && (i.camera.update(r), t.update(i.camera.camera), t.renderPick(i.camera.scene, i.camera.camera, a, null, o));
  }, e.prototype.render = function(t, r, n, i) {
    this.objectPickTarget.bind(), this.renderVariant(t, r, n, i, "pick", 1), this.instancePickTarget.bind(), this.renderVariant(t, r, n, i, "pick", 2), this.groupPickTarget.bind(), this.renderVariant(t, r, n, i, "pick", 3), this.depthPickTarget.bind(), this.renderVariant(t, r, n, i, "depth", 0);
  }, e;
}(), sQ = function() {
  function e(t, r, n, i, a, o, u) {
    u === void 0 && (u = 1), this.webgl = t, this.renderer = r, this.scene = n, this.helper = i, this.pickPass = a, this.pickPadding = u, this.dirty = !0, this.viewport = Vi(), this.setViewport(o.x, o.y, o.width, o.height);
  }
  return e.prototype.setupBuffers = function() {
    var t = this.pickWidth * this.pickHeight * 4;
    this.objectBuffer && this.objectBuffer.length === t || (this.objectBuffer = new Uint8Array(t), this.instanceBuffer = new Uint8Array(t), this.groupBuffer = new Uint8Array(t), this.depthBuffer = new Uint8Array(t));
  }, e.prototype.setViewport = function(t, r, n, i) {
    Vi.set(this.viewport, t, r, n, i), this.pickScale = this.pickPass.pickBaseScale / this.webgl.pixelRatio, this.pickX = Math.ceil(t * this.pickScale), this.pickY = Math.ceil(r * this.pickScale);
    var a = Math.floor(n * this.pickScale), o = Math.floor(i * this.pickScale);
    a === this.pickWidth && o === this.pickHeight || (this.pickWidth = a, this.pickHeight = o, this.halfPickWidth = Math.floor(this.pickWidth / 2), this.setupBuffers()), this.spiral = function(u) {
      for (var s, c = 0, l = 0, d = [0, -1], f = 2 * u + 1, m = f / 2, v = [], p = Math.pow(f, 2); p > 0; --p) -m < c && c <= m && -m < l && l <= m && v.push([c, l]), (c === l || c < 0 && c === -l || c > 0 && c === 1 - l) && (s = [-d[1], d[0]], d[0] = s[0], d[1] = s[1]), c += d[0], l += d[1];
      return v;
    }(Math.round(this.pickScale * this.pickPadding));
  }, e.prototype.syncBuffers = function() {
    var t = this, r = t.pickX, n = t.pickY, i = t.pickWidth, a = t.pickHeight;
    this.pickPass.objectPickTarget.bind(), this.webgl.readPixels(r, n, i, a, this.objectBuffer), this.pickPass.instancePickTarget.bind(), this.webgl.readPixels(r, n, i, a, this.instanceBuffer), this.pickPass.groupPickTarget.bind(), this.webgl.readPixels(r, n, i, a, this.groupBuffer), this.pickPass.depthPickTarget.bind(), this.webgl.readPixels(r, n, i, a, this.depthBuffer);
  }, e.prototype.getBufferIdx = function(t, r) {
    return 4 * (r * this.pickWidth + t);
  }, e.prototype.getDepth = function(t, r) {
    var n = this.getBufferIdx(t, r), i = this.depthBuffer;
    return function(a, o, u, s) {
      return Vt.set(AS, a / 255, o / 255, u / 255, s / 255), Vt.dot(AS, TY);
    }(i[n], i[n + 1], i[n + 2], i[n + 3]);
  }, e.prototype.getId = function(t, r, n) {
    var i = this.getBufferIdx(t, r);
    return D_(n[i], n[i + 1], n[i + 2]);
  }, e.prototype.render = function(t) {
    var r = this, n = r.pickX, i = r.pickY, a = r.pickWidth, o = r.pickHeight, u = r.halfPickWidth, s = this, c = s.renderer, l = s.scene, d = s.helper;
    c.setTransparentBackground(!1), c.setDrawingBufferSize(this.pickPass.objectPickTarget.getWidth(), this.pickPass.objectPickTarget.getHeight()), c.setPixelRatio(this.pickScale), n0.is(t) ? (c.setViewport(n, i, u, o), this.pickPass.render(c, t.left, l, d), c.setViewport(n + u, i, a - u, o), this.pickPass.render(c, t.right, l, d)) : (c.setViewport(n, i, a, o), this.pickPass.render(c, t, l, d)), this.dirty = !1;
  }, e.prototype.identifyInternal = function(t, r, n) {
    var i = this.webgl, a = this.pickScale;
    if (!i.isContextLost) {
      t *= i.pixelRatio, r *= i.pixelRatio, r = this.pickPass.drawingBufferHeight - r;
      var o = this.viewport;
      if (!(t < o.x || r < o.y || t > o.x + o.width || r > o.y + o.height)) {
        this.dirty && (this.render(n), this.syncBuffers());
        var u = t - o.x, s = r - o.y, c = Math.floor(u * a), l = Math.floor(s * a), d = this.getId(c, l, this.objectBuffer);
        if (d !== -1 && d !== O4) {
          var f = this.getId(c, l, this.instanceBuffer);
          if (f !== -1 && f !== O4) {
            var m = this.getId(c, l, this.groupBuffer);
            if (m !== -1 && m !== O4) {
              var v = this.getDepth(c, l), p = w.create(t, o.height - r, v);
              if (n0.is(n)) {
                var g = Math.floor(o.width / 2);
                t > o.x + g ? (p[0] = o.x + 2 * (u - g), Ap(p, p, o, n.right.inverseProjectionView)) : (p[0] = o.x + 2 * u, Ap(p, p, o, n.left.inverseProjectionView));
              } else Ap(p, p, o, n.inverseProjectionView);
              return { id: { objectId: d, instanceId: f, groupId: m }, position: p };
            }
          }
        }
      }
    }
  }, e.prototype.identify = function(t, r, n) {
    for (var i = 0, a = this.spiral; i < a.length; i++) {
      var o = a[i], u = this.identifyInternal(t + o[0], r + o[1], n);
      if (u) return u;
    }
  }, e.prototype.getPosition = function(t, r, n) {
    var i = this.webgl;
    if (!i.isContextLost) {
      t *= i.pixelRatio, r *= i.pixelRatio, r = this.pickPass.drawingBufferHeight - r;
      var a = this.viewport;
      if (!(t < a.x || r < a.y || t > a.x + a.width || r > a.y + a.height)) {
        this.dirty && (this.render(n), this.syncBuffers());
        var o = 255 / 256, u = w.create(16777216, 65536, 256), s = Vt.create(o / u[0], o / u[1], o / u[2], 0.99609375), c = Vt();
        Vt.set(c, 128 / 255, 128 / 255, 30 / 255, 60 / 255);
        var l = Vt.dot(c, s) / (n.zoom / 40);
        l > 0.2 && (l = 0.1);
        var d = w.create(t, a.height - r, l);
        return Ap(d, d, a, n.inverseProjectionView), { position: d };
      }
    }
  }, e;
}(), cQ = R(R({}, qi), { tWboitA: zt("texture", "rgba", "float", "nearest"), tWboitB: zt("texture", "rgba", "float", "nearest"), uTexSize: Ie("v2") }), lQ = Sn("evaluate-wboit", Fa, `
precision highp float;

uniform sampler2D tWboitA;
uniform sampler2D tWboitB;
uniform vec2 uTexSize;

void main() {
    vec2 coords = gl_FragCoord.xy / uTexSize;

    vec4 accum = texture2D(tWboitA, coords);
    float r = 1.0 - accum.a;

    accum.a = texture2D(tWboitB, coords).r;
    // divisor needs to allow very small values for nice fading
    gl_FragColor = vec4(accum.rgb / clamp(accum.a, 0.00000001, 50000.0), r);
}
`), dQ = function() {
  function e(t, r, n) {
    if (this.webgl = t, this._supported = !1, e.isSupported(t)) {
      var i, a, o, u, s, c = t.resources;
      this.textureA = c.texture("image-float32", "rgba", "float", "nearest"), this.textureA.define(r, n), this.textureB = c.texture("image-float32", "rgba", "float", "nearest"), this.textureB.define(r, n), this.renderable = (i = t, a = this.textureA, o = this.textureB, u = R(R({}, Ui), { tWboitA: k.create(a), tWboitB: k.create(o), uTexSize: k.create(ke.create(a.getWidth(), a.getHeight())) }), s = R({}, cQ), Fi(Bi(i, "triangles", lQ, s, u), u)), this.framebuffer = c.framebuffer(), this._supported = !0, this._init();
    }
  }
  return Object.defineProperty(e.prototype, "supported", { get: function() {
    return this._supported;
  }, enumerable: !1, configurable: !0 }), e.prototype.bind = function() {
    var t = this.webgl, r = t.state, n = t.gl;
    this.framebuffer.bind(), r.clearColor(0, 0, 0, 1), n.clear(n.COLOR_BUFFER_BIT), r.disable(n.DEPTH_TEST), r.blendFuncSeparate(n.ONE, n.ONE, n.ZERO, n.ONE_MINUS_SRC_ALPHA), r.enable(n.BLEND);
  }, e.prototype.render = function() {
    var t = this.webgl, r = t.state, n = t.gl;
    r.blendFuncSeparate(n.SRC_ALPHA, n.ONE_MINUS_SRC_ALPHA, n.ONE, n.ONE_MINUS_SRC_ALPHA), r.enable(n.BLEND), this.renderable.update(), this.renderable.render();
  }, e.prototype.setSize = function(t, r) {
    var n = this.renderable.values.uTexSize.ref.value, i = n[0], a = n[1];
    t === i && r === a || (this.textureA.define(t, r), this.textureB.define(t, r), k.update(this.renderable.values.uTexSize, ke.set(this.renderable.values.uTexSize.ref.value, t, r)));
  }, e.prototype.reset = function() {
    this._supported && this._init();
  }, e.prototype._init = function() {
    var t = this.webgl.extensions.drawBuffers;
    this.framebuffer.bind(), t.drawBuffers([t.COLOR_ATTACHMENT0, t.COLOR_ATTACHMENT1]), this.textureA.attachFramebuffer(this.framebuffer, "color0"), this.textureB.attachFramebuffer(this.framebuffer, "color1");
  }, e.isSupported = function(t) {
    var r = t.extensions, n = r.drawBuffers, i = r.textureFloat, a = r.colorBufferFloat, o = r.depthTexture;
    if (i && a && o && n) return !0;
    if (Ir) {
      var u = [];
      i || u.push("textureFloat"), a || u.push("colorBufferFloat"), o || u.push("depthTexture"), n || u.push("drawBuffers"), console.log('Missing "'.concat(u.join('", "'), '" extensions required for "wboit"'));
    }
    return !1;
  }, e;
}(), hP = { enabled: G.Boolean(!0), highlightEdgeColor: G.Color(He.darken(He.fromNormalizedRgb(1, 0.4, 0.6), 1)), selectEdgeColor: G.Color(He.darken(He.fromNormalizedRgb(0.2, 1, 0.1), 1)), edgeScale: G.Numeric(1, { min: 1, max: 3, step: 1 }, { description: "Thickness of the edge." }), ghostEdgeStrength: G.Numeric(1, { min: 0, max: 1, step: 0.1 }, { description: "Opacity of the hidden edges that are covered by other geometry. When set to 1, one less geometry render pass is done." }), innerEdgeFactor: G.Numeric(1.5, { min: 0, max: 3, step: 0.1 }, { description: "Factor to multiply the inner edge color with - for added contrast." }) }, lw = function() {
  function e(t, r, n) {
    this.webgl = t, this.depthTarget = t.createRenderTarget(r, n), this.maskTarget = t.createRenderTarget(r, n), this.edgesTarget = t.createRenderTarget(r, n), this.edge = function(i, a) {
      var o = a.getWidth(), u = a.getHeight(), s = R(R({}, Ui), { tMaskTexture: k.create(a), uTexSizeInv: k.create(ke.create(1 / o, 1 / u)), dEdgeScale: k.create(1) }), c = R({}, fQ);
      return Fi(Bi(i, "triangles", pQ, c, s), s);
    }(t, this.maskTarget.texture), this.overlay = function(i, a) {
      var o = a.getWidth(), u = a.getHeight(), s = R(R({}, Ui), { tEdgeTexture: k.create(a), uTexSizeInv: k.create(ke.create(1 / o, 1 / u)), uHighlightEdgeColor: k.create(w()), uSelectEdgeColor: k.create(w()), uGhostEdgeStrength: k.create(0), uInnerEdgeFactor: k.create(0) }), c = R({}, mQ);
      return Fi(Bi(i, "triangles", hQ, c, s), s);
    }(t, this.edgesTarget.texture);
  }
  return e.isEnabled = function(t) {
    return t.enabled;
  }, e.prototype.setEdgeState = function(t) {
    var r = this.webgl, n = r.gl, i = r.state;
    i.enable(n.SCISSOR_TEST), i.enable(n.BLEND), i.blendFunc(n.ONE, n.ONE), i.blendEquation(n.FUNC_ADD), i.disable(n.DEPTH_TEST), i.depthMask(!1);
    var a = t.x, o = t.y, u = t.width, s = t.height;
    n.viewport(a, o, u, s), n.scissor(a, o, u, s), i.clearColor(0, 0, 0, 0), n.clear(n.COLOR_BUFFER_BIT);
  }, e.prototype.setOverlayState = function(t) {
    var r = this.webgl, n = r.gl, i = r.state;
    i.enable(n.SCISSOR_TEST), i.enable(n.BLEND), i.blendFunc(n.SRC_ALPHA, n.ONE_MINUS_SRC_ALPHA), i.blendEquation(n.FUNC_ADD), i.disable(n.DEPTH_TEST), i.depthMask(!1);
    var a = t.x, o = t.y, u = t.width, s = t.height;
    n.viewport(a, o, u, s), n.scissor(a, o, u, s);
  }, e.prototype.setSize = function(t, r) {
    var n = this.depthTarget.getWidth(), i = this.depthTarget.getHeight();
    t === n && r === i || (this.depthTarget.setSize(t, r), this.maskTarget.setSize(t, r), this.edgesTarget.setSize(t, r), k.update(this.edge.values.uTexSizeInv, ke.set(this.edge.values.uTexSizeInv.ref.value, 1 / t, 1 / r)), k.update(this.overlay.values.uTexSizeInv, ke.set(this.overlay.values.uTexSizeInv.ref.value, 1 / t, 1 / r)));
  }, e.prototype.update = function(t) {
    var r = t.highlightEdgeColor, n = t.selectEdgeColor, i = t.edgeScale, a = t.innerEdgeFactor, o = t.ghostEdgeStrength, u = this.edge.values, s = Math.round(i * this.webgl.pixelRatio);
    u.dEdgeScale.ref.value !== s && (k.update(u.dEdgeScale, s), this.edge.update());
    var c = this.overlay.values;
    k.update(c.uHighlightEdgeColor, He.toVec3Normalized(c.uHighlightEdgeColor.ref.value, r)), k.update(c.uSelectEdgeColor, He.toVec3Normalized(c.uSelectEdgeColor.ref.value, n)), k.update(c.uInnerEdgeFactor, a), k.update(c.uGhostEdgeStrength, o);
  }, e.prototype.render = function(t, r) {
    this.edgesTarget.bind(), this.setEdgeState(t), this.edge.render(), r ? r.bind() : this.webgl.unbindFramebuffer(), this.setOverlayState(t), this.overlay.render();
  }, e;
}(), fQ = R(R({}, qi), { tMaskTexture: zt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: Ie("v2"), dEdgeScale: kt("number") }), pQ = Sn("edge", Fa, `
precision highp float;
precision highp sampler2D;

uniform sampler2D tMaskTexture;
uniform vec2 uTexSizeInv;

void main() {
    vec2 coords = gl_FragCoord.xy * uTexSizeInv;
    vec4 offset = vec4(float(dEdgeScale), 0.0, 0.0, float(dEdgeScale)) * vec4(uTexSizeInv, uTexSizeInv);
    vec4 c0 = texture2D(tMaskTexture, coords);
    vec4 c1 = texture2D(tMaskTexture, coords + offset.xy);
    vec4 c2 = texture2D(tMaskTexture, coords - offset.xy);
    vec4 c3 = texture2D(tMaskTexture, coords + offset.yw);
    vec4 c4 = texture2D(tMaskTexture, coords - offset.yw);
    float diff1 = (c1.r - c2.r) * 0.5;
    float diff2 = (c3.r - c4.r) * 0.5;
    float d = length(vec2(diff1, diff2));
    if (d <= 0.0)
        discard;
    float a1 = min(c1.g, c2.g);
    float a2 = min(c3.g, c4.g);
    float visibility = min(a1, a2) > 0.001 ? 1.0 : 0.0;
    float mask = c0.r;
    float marker = min(c1.b, min(c2.b, min(c3.b, c4.b)));
    float fogAlpha = min(c1.a, min(c2.a, min(c3.a, c4.a)));
    gl_FragColor = vec4(visibility, mask, marker, fogAlpha);
}
`), mQ = R(R({}, qi), { tEdgeTexture: zt("texture", "rgba", "ubyte", "linear"), uTexSizeInv: Ie("v2"), uHighlightEdgeColor: Ie("v3"), uSelectEdgeColor: Ie("v3"), uGhostEdgeStrength: Ie("f"), uInnerEdgeFactor: Ie("f") }), hQ = Sn("overlay", Fa, `
precision highp float;
precision highp sampler2D;

uniform vec2 uTexSizeInv;
uniform sampler2D tEdgeTexture;
uniform vec3 uHighlightEdgeColor;
uniform vec3 uSelectEdgeColor;
uniform float uGhostEdgeStrength;
uniform float uInnerEdgeFactor;

void main() {
    vec2 coords = gl_FragCoord.xy * uTexSizeInv;
    vec4 edgeValue = texture2D(tEdgeTexture, coords);
    if (edgeValue.a > 0.0) {
        vec3 edgeColor = edgeValue.b == 1.0 ? uHighlightEdgeColor : uSelectEdgeColor;
        gl_FragColor.rgb = edgeValue.g > 0.0 ? edgeColor : edgeColor * uInnerEdgeFactor;
        gl_FragColor.a = (edgeValue.r == 1.0 ? uGhostEdgeStrength : 1.0) * edgeValue.a;
    } else {
        gl_FragColor = vec4(0.0);
    }
}
`), vQ = R(R({}, qi), { tDepthPrimitives: zt("texture", "depth", "ushort", "nearest"), tDepthVolumes: zt("texture", "depth", "ushort", "nearest"), uTexSize: Ie("v2"), dPackedDepth: kt("boolean") }), gQ = Sn("depth-merge", Fa, `
precision highp float;
precision highp sampler2D;

uniform sampler2D tDepthPrimitives;
uniform sampler2D tDepthVolumes;
uniform vec2 uTexSize;

#include common

float getDepth(const in vec2 coords, sampler2D tDepth) {
    #ifdef dPackedDepth
        return unpackRGBAToDepth(texture2D(tDepth, coords));
    #else
        return texture2D(tDepth, coords).r;
    #endif
}

void main() {
    vec2 coords = gl_FragCoord.xy / uTexSize;
    float depth = min(getDepth(coords, tDepthPrimitives), getDepth(coords, tDepthVolumes));
    gl_FragColor = packDepthToRGBA(depth);
}
`), vP = function() {
  function e(t, r, n, i) {
    this.webgl = t;
    var a, o, u, s, c, l, d, f = t.extensions, m = t.resources, v = t.isWebGL2;
    this.drawTarget = (a = t.gl, { id: yM(), texture: go(a), framebuffer: { id: vM(), bind: function() {
    }, reset: function() {
    }, destroy: function() {
    } }, getWidth: function() {
      return 0;
    }, getHeight: function() {
      return 0;
    }, bind: function() {
      a.bindFramebuffer(a.FRAMEBUFFER, null);
    }, setSize: function() {
    }, reset: function() {
    }, destroy: function() {
    } }), this.colorTarget = t.createRenderTarget(r, n, !0, "uint8", "linear"), this.packedDepth = !f.depthTexture, this.depthTarget = t.createRenderTarget(r, n), this.depthTexture = this.depthTarget.texture, this.depthTargetPrimitives = this.packedDepth ? t.createRenderTarget(r, n) : null, this.depthTargetVolumes = this.packedDepth ? t.createRenderTarget(r, n) : null, this.depthTexturePrimitives = this.depthTargetPrimitives ? this.depthTargetPrimitives.texture : m.texture("image-depth", "depth", v ? "float" : "ushort", "nearest"), this.depthTextureVolumes = this.depthTargetVolumes ? this.depthTargetVolumes.texture : m.texture("image-depth", "depth", v ? "float" : "ushort", "nearest"), this.packedDepth || (this.depthTexturePrimitives.define(r, n), this.depthTextureVolumes.define(r, n)), this.depthMerge = (o = t, u = this.depthTexturePrimitives, s = this.depthTextureVolumes, c = this.packedDepth, l = R(R({}, Ui), { tDepthPrimitives: k.create(u), tDepthVolumes: k.create(s), uTexSize: k.create(ke.create(u.getWidth(), u.getHeight())), dPackedDepth: k.create(c) }), d = R({}, vQ), Fi(Bi(o, "triangles", gQ, d, l), l)), this.wboit = i ? new dQ(t, r, n) : void 0, this.marking = new lw(t, r, n), this.postprocessing = new mc(t, this), this.antialiasing = new R4(t, this), this.copyFboTarget = Bb(t, this.colorTarget.texture), this.copyFboPostprocessing = Bb(t, this.postprocessing.target.texture);
  }
  return Object.defineProperty(e.prototype, "wboitEnabled", { get: function() {
    var t;
    return !!(!((t = this.wboit) === null || t === void 0) && t.supported);
  }, enumerable: !1, configurable: !0 }), e.prototype.reset = function() {
    var t;
    (t = this.wboit) === null || t === void 0 || t.reset();
  }, e.prototype.setSize = function(t, r) {
    var n, i = this.colorTarget.getWidth(), a = this.colorTarget.getHeight();
    t === i && r === a || (this.colorTarget.setSize(t, r), this.depthTarget.setSize(t, r), this.depthTargetPrimitives ? this.depthTargetPrimitives.setSize(t, r) : this.depthTexturePrimitives.define(t, r), this.depthTargetVolumes ? this.depthTargetVolumes.setSize(t, r) : this.depthTextureVolumes.define(t, r), k.update(this.depthMerge.values.uTexSize, ke.set(this.depthMerge.values.uTexSize.ref.value, t, r)), k.update(this.copyFboTarget.values.uTexSize, ke.set(this.copyFboTarget.values.uTexSize.ref.value, t, r)), k.update(this.copyFboPostprocessing.values.uTexSize, ke.set(this.copyFboPostprocessing.values.uTexSize.ref.value, t, r)), !((n = this.wboit) === null || n === void 0) && n.supported && this.wboit.setSize(t, r), this.marking.setSize(t, r), this.postprocessing.setSize(t, r), this.antialiasing.setSize(t, r));
  }, e.prototype._depthMerge = function() {
    var t = this.webgl, r = t.state, n = t.gl;
    this.depthMerge.update(), this.depthTarget.bind(), r.disable(n.BLEND), r.disable(n.DEPTH_TEST), r.disable(n.CULL_FACE), r.depthMask(!1), r.clearColor(1, 1, 1, 1), n.clear(n.COLOR_BUFFER_BIT), this.depthMerge.render();
  }, e.prototype._renderWboit = function(t, r, n, i, a) {
    var o;
    if (!(!((o = this.wboit) === null || o === void 0) && o.supported)) throw new Error("expected wboit to be supported");
    this.colorTarget.bind(), t.clear(!0), this.depthTexturePrimitives.attachFramebuffer(this.colorTarget.framebuffer, "depth"), this.colorTarget.bind(), t.clearDepth(), t.renderWboitOpaque(n.primitives, r, null), this.depthTextureVolumes.attachFramebuffer(this.colorTarget.framebuffer, "depth"), this.colorTarget.bind(), t.clearDepth(), t.renderWboitOpaque(n.volumes, r, this.depthTexturePrimitives), this._depthMerge(), mc.isEnabled(a) && this.postprocessing.render(r, !1, i, t.props.backgroundColor, a), this.wboit.bind(), t.renderWboitTransparent(n.primitives, r, this.depthTexture), t.renderWboitTransparent(n.volumes, r, this.depthTexture), mc.isEnabled(a) ? (this.depthTexturePrimitives.attachFramebuffer(this.postprocessing.target.framebuffer, "depth"), this.postprocessing.target.bind()) : (this.depthTexturePrimitives.attachFramebuffer(this.colorTarget.framebuffer, "depth"), this.colorTarget.bind()), this.wboit.render();
  }, e.prototype._renderBlended = function(t, r, n, i, a, o) {
    if (i ? this.drawTarget.bind() : (this.colorTarget.bind(), this.packedDepth || this.depthTexturePrimitives.attachFramebuffer(this.colorTarget.framebuffer, "depth")), t.clear(!0), t.renderBlendedOpaque(n.primitives, r, null), !i) {
      this.depthTargetPrimitives && (this.depthTargetPrimitives.bind(), t.clear(!1), t.renderDepth(n.primitives, r, null), this.colorTarget.bind()), this.packedDepth || (this.depthTextureVolumes.attachFramebuffer(this.colorTarget.framebuffer, "depth"), t.clearDepth()), t.renderBlendedVolumeOpaque(n.volumes, r, this.depthTexturePrimitives), this.depthTargetVolumes && (this.depthTargetVolumes.bind(), t.clear(!1), t.renderDepth(n.volumes, r, this.depthTexturePrimitives), this.colorTarget.bind()), this._depthMerge(), this.colorTarget.bind(), mc.isEnabled(o) && this.postprocessing.render(r, !1, a, t.props.backgroundColor, o), t.renderBlendedVolumeTransparent(n.volumes, r, this.depthTexturePrimitives);
      var u = mc.isEnabled(o) ? this.postprocessing.target : this.colorTarget;
      this.packedDepth || this.depthTexturePrimitives.attachFramebuffer(u.framebuffer, "depth"), u.bind();
    }
    t.renderBlendedTransparent(n.primitives, r, null);
  }, e.prototype._render = function(t, r, n, i, a, o) {
    var u = n.volumes.renderables.length > 0, s = mc.isEnabled(o.postprocessing), c = R4.isEnabled(o.postprocessing), l = lw.isEnabled(o.marking), d = r.viewport, f = d.x, m = d.y, v = d.width, p = d.height;
    if (t.setViewport(f, m, v, p), t.update(r), o.transparentBackground && !c && a && (this.drawTarget.bind(), t.clear(!1)), this.wboitEnabled ? this._renderWboit(t, r, n, o.transparentBackground, o.postprocessing) : this._renderBlended(t, r, n, !u && !s && !c && a, o.transparentBackground, o.postprocessing), s ? this.postprocessing.target.bind() : !a || u || this.wboitEnabled ? this.colorTarget.bind() : this.drawTarget.bind(), l) {
      var g = n.getMarkerAverage();
      if (g > 0) {
        var h = o.marking.ghostEdgeStrength < 1;
        h && g !== 1 && (this.marking.depthTarget.bind(), t.clear(!1, !0), t.renderMarkingDepth(n.primitives, r, null)), this.marking.maskTarget.bind(), t.clear(!1, !0), t.renderMarkingMask(n.primitives, r, h ? this.marking.depthTarget.texture : null), this.marking.update(o.marking), this.marking.render(r.viewport, s ? this.postprocessing.target : this.colorTarget);
      }
    }
    i.debug.isEnabled && (i.debug.syncVisibility(), t.renderBlended(i.debug.scene, r, null)), i.handle.isEnabled && t.renderBlended(i.handle.scene, r, null), i.camera.isEnabled && (i.camera.update(r), t.update(i.camera.camera), t.renderBlended(i.camera.scene, i.camera.camera, null)), c ? this.antialiasing.render(r, a, o.postprocessing) : a && (this.drawTarget.bind(), this.webgl.state.disable(this.webgl.gl.DEPTH_TEST), s ? this.copyFboPostprocessing.render() : (u || this.wboitEnabled) && this.copyFboTarget.render()), this.webgl.gl.flush();
  }, e.prototype.render = function(t, r, n) {
    var i = t.renderer, a = t.camera, o = t.scene, u = t.helper;
    i.setTransparentBackground(r.transparentBackground), i.setDrawingBufferSize(this.colorTarget.getWidth(), this.colorTarget.getHeight()), i.setPixelRatio(this.webgl.pixelRatio), n0.is(a) ? (this._render(i, a.left, o, u, n, r), this._render(i, a.right, o, u, n, r)) : this._render(i, a, o, u, n, r);
  }, e.prototype.getColorTarget = function(t) {
    return R4.isEnabled(t) ? this.antialiasing.target : mc.isEnabled(t) ? this.postprocessing.target : this.colorTarget;
  }, e;
}();
function Zu(e) {
  for (var t = arguments.length, r = Array(t > 1 ? t - 1 : 0), n = 1; n < t; n++) r[n - 1] = arguments[n];
  throw Error("[Immer] minified error nr: " + e + (r.length ? " " + r.map(function(i) {
    return "'" + i + "'";
  }).join(",") : "") + ". Find the full error at: https://bit.ly/3cXEKWf");
}
function i0(e) {
  return !!e && !!e[Yo];
}
function yf(e) {
  return !!e && (function(t) {
    if (!t || typeof t != "object") return !1;
    var r = Object.getPrototypeOf(t);
    if (r === null) return !0;
    var n = Object.hasOwnProperty.call(r, "constructor") && r.constructor;
    return n === Object || typeof n == "function" && Function.toString.call(n) === SQ;
  }(e) || Array.isArray(e) || !!e[yw] || !!e.constructor[yw] || O_(e) || L_(e));
}
function dm(e, t, r) {
  r === void 0 && (r = !1), a0(e) === 0 ? (r ? Object.keys : U_)(e).forEach(function(n) {
    r && typeof n == "symbol" || t(n, e[n], e);
  }) : e.forEach(function(n, i) {
    return t(i, n, e);
  });
}
function a0(e) {
  var t = e[Yo];
  return t ? t.i > 3 ? t.i - 4 : t.i : Array.isArray(e) ? 1 : O_(e) ? 2 : L_(e) ? 3 : 0;
}
function Zb(e, t) {
  return a0(e) === 2 ? e.has(t) : Object.prototype.hasOwnProperty.call(e, t);
}
function gP(e, t, r) {
  var n = a0(e);
  n === 2 ? e.set(t, r) : n === 3 ? (e.delete(t), e.add(r)) : e[t] = r;
}
function O_(e) {
  return xQ && e instanceof Map;
}
function L_(e) {
  return AQ && e instanceof Set;
}
function jd(e) {
  return e.o || e.t;
}
function k_(e) {
  if (Array.isArray(e)) return Array.prototype.slice.call(e);
  var t = CQ(e);
  delete t[Yo];
  for (var r = U_(t), n = 0; n < r.length; n++) {
    var i = r[n], a = t[i];
    a.writable === !1 && (a.writable = !0, a.configurable = !0), (a.get || a.set) && (t[i] = { configurable: !0, writable: !0, enumerable: a.enumerable, value: e[i] });
  }
  return Object.create(Object.getPrototypeOf(e), t);
}
function z_(e, t) {
  return t === void 0 && (t = !1), G_(e) || i0(e) || !yf(e) || (a0(e) > 1 && (e.set = e.add = e.clear = e.delete = yQ), Object.freeze(e), t && dm(e, function(r, n) {
    return z_(n, !0);
  }, !0)), e;
}
function yQ() {
  Zu(2);
}
function G_(e) {
  return e == null || typeof e != "object" || Object.isFrozen(e);
}
function Ts(e) {
  var t = wQ[e];
  return t || Zu(18, e), t;
}
function dw() {
  return fm;
}
function L4(e, t) {
  t && (Ts("Patches"), e.u = [], e.s = [], e.v = t);
}
function q2(e) {
  Qb(e), e.p.forEach(bQ), e.p = null;
}
function Qb(e) {
  e === fm && (fm = e.l);
}
function fw(e) {
  return fm = { p: [], l: fm, h: e, m: !0, _: 0 };
}
function bQ(e) {
  var t = e[Yo];
  t.i === 0 || t.i === 1 ? t.j() : t.O = !0;
}
function k4(e, t) {
  t._ = t.p.length;
  var r = t.p[0], n = e !== void 0 && e !== r;
  return t.h.g || Ts("ES5").S(t, e, n), n ? (r[Yo].P && (q2(t), Zu(4)), yf(e) && (e = K2(t, e), t.l || X2(t, e)), t.u && Ts("Patches").M(r[Yo].t, e, t.u, t.s)) : e = K2(t, r, []), q2(t), t.u && t.v(t.u, t.s), e !== yP ? e : void 0;
}
function K2(e, t, r) {
  if (G_(t)) return t;
  var n = t[Yo];
  if (!n) return dm(t, function(a, o) {
    return pw(e, n, t, a, o, r);
  }, !0), t;
  if (n.A !== e) return t;
  if (!n.P) return X2(e, n.t, !0), n.t;
  if (!n.I) {
    n.I = !0, n.A._--;
    var i = n.i === 4 || n.i === 5 ? n.o = k_(n.k) : n.o;
    dm(n.i === 3 ? new Set(i) : i, function(a, o) {
      return pw(e, n, i, a, o, r);
    }), X2(e, i, !1), r && e.u && Ts("Patches").R(n, r, e.u, e.s);
  }
  return n.o;
}
function pw(e, t, r, n, i, a) {
  if (i0(i)) {
    var o = K2(e, i, a && t && t.i !== 3 && !Zb(t.D, n) ? a.concat(n) : void 0);
    if (gP(r, n, o), !i0(o)) return;
    e.m = !1;
  }
  if (yf(i) && !G_(i)) {
    if (!e.h.F && e._ < 1) return;
    K2(e, i), t && t.A.l || X2(e, i);
  }
}
function X2(e, t, r) {
  r === void 0 && (r = !1), e.h.F && e.m && z_(t, r);
}
function z4(e, t) {
  var r = e[Yo];
  return (r ? jd(r) : e)[t];
}
function mw(e, t) {
  if (t in e) for (var r = Object.getPrototypeOf(e); r; ) {
    var n = Object.getOwnPropertyDescriptor(r, t);
    if (n) return n;
    r = Object.getPrototypeOf(r);
  }
}
function Jb(e) {
  e.P || (e.P = !0, e.l && Jb(e.l));
}
function G4(e) {
  e.o || (e.o = k_(e.t));
}
function $b(e, t, r) {
  var n = O_(t) ? Ts("MapSet").N(t, r) : L_(t) ? Ts("MapSet").T(t, r) : e.g ? function(i, a) {
    var o = Array.isArray(i), u = { i: o ? 1 : 0, A: a ? a.A : dw(), P: !1, I: !1, D: {}, l: a, t: i, k: null, o: null, j: null, C: !1 }, s = u, c = e6;
    o && (s = [u], c = Bp);
    var l = Proxy.revocable(s, c), d = l.revoke, f = l.proxy;
    return u.k = f, u.j = d, f;
  }(t, r) : Ts("ES5").J(t, r);
  return (r ? r.A : dw()).p.push(n), n;
}
function _Q(e) {
  return i0(e) || Zu(22, e), function t(r) {
    if (!yf(r)) return r;
    var n, i = r[Yo], a = a0(r);
    if (i) {
      if (!i.P && (i.i < 4 || !Ts("ES5").K(i))) return i.t;
      i.I = !0, n = hw(r, a), i.I = !1;
    } else n = hw(r, a);
    return dm(n, function(o, u) {
      i && function(s, c) {
        return a0(s) === 2 ? s.get(c) : s[c];
      }(i.t, o) === u || gP(n, o, t(u));
    }), a === 3 ? new Set(n) : n;
  }(e);
}
function hw(e, t) {
  switch (t) {
    case 2:
      return new Map(e);
    case 3:
      return Array.from(e);
  }
  return k_(e);
}
var vw, fm, V_ = typeof Symbol < "u" && typeof Symbol("x") == "symbol", xQ = typeof Map < "u", AQ = typeof Set < "u", gw = typeof Proxy < "u" && Proxy.revocable !== void 0 && typeof Reflect < "u", yP = V_ ? Symbol.for("immer-nothing") : ((vw = {})["immer-nothing"] = !0, vw), yw = V_ ? Symbol.for("immer-draftable") : "__$immer_draftable", Yo = V_ ? Symbol.for("immer-state") : "__$immer_state", SQ = "" + Object.prototype.constructor, U_ = typeof Reflect < "u" && Reflect.ownKeys ? Reflect.ownKeys : Object.getOwnPropertySymbols !== void 0 ? function(e) {
  return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e));
} : Object.getOwnPropertyNames, CQ = Object.getOwnPropertyDescriptors || function(e) {
  var t = {};
  return U_(e).forEach(function(r) {
    t[r] = Object.getOwnPropertyDescriptor(e, r);
  }), t;
}, wQ = {}, e6 = { get: function(e, t) {
  if (t === Yo) return e;
  var r = jd(e);
  if (!Zb(r, t)) return function(i, a, o) {
    var u, s = mw(a, o);
    return s ? "value" in s ? s.value : (u = s.get) === null || u === void 0 ? void 0 : u.call(i.k) : void 0;
  }(e, r, t);
  var n = r[t];
  return e.I || !yf(n) ? n : n === z4(e.t, t) ? (G4(e), e.o[t] = $b(e.A.h, n, e)) : n;
}, has: function(e, t) {
  return t in jd(e);
}, ownKeys: function(e) {
  return Reflect.ownKeys(jd(e));
}, set: function(e, t, r) {
  var n = mw(jd(e), t);
  if (n != null && n.set) return n.set.call(e.k, r), !0;
  if (!e.P) {
    var i = z4(jd(e), t), a = i == null ? void 0 : i[Yo];
    if (a && a.t === r) return e.o[t] = r, e.D[t] = !1, !0;
    if (function(o, u) {
      return o === u ? o !== 0 || 1 / o == 1 / u : o != o && u != u;
    }(r, i) && (r !== void 0 || Zb(e.t, t))) return !0;
    G4(e), Jb(e);
  }
  return e.o[t] === r && typeof r != "number" && (r !== void 0 || t in e.o) || (e.o[t] = r, e.D[t] = !0, !0);
}, deleteProperty: function(e, t) {
  return z4(e.t, t) !== void 0 || t in e.t ? (e.D[t] = !1, G4(e), Jb(e)) : delete e.D[t], e.o && delete e.o[t], !0;
}, getOwnPropertyDescriptor: function(e, t) {
  var r = jd(e), n = Reflect.getOwnPropertyDescriptor(r, t);
  return n && { writable: !0, configurable: e.i !== 1 || t !== "length", enumerable: n.enumerable, value: r[t] };
}, defineProperty: function() {
  Zu(11);
}, getPrototypeOf: function(e) {
  return Object.getPrototypeOf(e.t);
}, setPrototypeOf: function() {
  Zu(12);
} }, Bp = {};
dm(e6, function(e, t) {
  Bp[e] = function() {
    return arguments[0] = arguments[0][0], t.apply(this, arguments);
  };
}), Bp.deleteProperty = function(e, t) {
  return Bp.set.call(this, e, t, void 0);
}, Bp.set = function(e, t, r) {
  return e6.set.call(this, e[0], t, r, e[0]);
};
var DQ = function() {
  function e(r) {
    var n = this;
    this.g = gw, this.F = !0, this.produce = function(i, a, o) {
      if (typeof i == "function" && typeof a != "function") {
        var u = a;
        a = i;
        var s = n;
        return function(p) {
          var g = this;
          p === void 0 && (p = u);
          for (var h = arguments.length, y = Array(h > 1 ? h - 1 : 0), x = 1; x < h; x++) y[x - 1] = arguments[x];
          return s.produce(p, function(A) {
            var b;
            return (b = a).call.apply(b, [g, A].concat(y));
          });
        };
      }
      var c;
      if (typeof a != "function" && Zu(6), o !== void 0 && typeof o != "function" && Zu(7), yf(i)) {
        var l = fw(n), d = $b(n, i, void 0), f = !0;
        try {
          c = a(d), f = !1;
        } finally {
          f ? q2(l) : Qb(l);
        }
        return typeof Promise < "u" && c instanceof Promise ? c.then(function(p) {
          return L4(l, o), k4(p, l);
        }, function(p) {
          throw q2(l), p;
        }) : (L4(l, o), k4(c, l));
      }
      if (!i || typeof i != "object") {
        if ((c = a(i)) === void 0 && (c = i), c === yP && (c = void 0), n.F && z_(c, !0), o) {
          var m = [], v = [];
          Ts("Patches").M(i, c, m, v), o(m, v);
        }
        return c;
      }
      Zu(21, i);
    }, this.produceWithPatches = function(i, a) {
      if (typeof i == "function") return function(c) {
        for (var l = arguments.length, d = Array(l > 1 ? l - 1 : 0), f = 1; f < l; f++) d[f - 1] = arguments[f];
        return n.produceWithPatches(c, function(m) {
          return i.apply(void 0, [m].concat(d));
        });
      };
      var o, u, s = n.produce(i, a, function(c, l) {
        o = c, u = l;
      });
      return typeof Promise < "u" && s instanceof Promise ? s.then(function(c) {
        return [c, o, u];
      }) : [s, o, u];
    }, typeof (r == null ? void 0 : r.useProxies) == "boolean" && this.setUseProxies(r.useProxies), typeof (r == null ? void 0 : r.autoFreeze) == "boolean" && this.setAutoFreeze(r.autoFreeze);
  }
  var t = e.prototype;
  return t.createDraft = function(r) {
    yf(r) || Zu(8), i0(r) && (r = _Q(r));
    var n = fw(this), i = $b(this, r, void 0);
    return i[Yo].C = !0, Qb(n), i;
  }, t.finishDraft = function(r, n) {
    var i = (r && r[Yo]).A;
    return L4(i, n), k4(void 0, i);
  }, t.setAutoFreeze = function(r) {
    this.F = r;
  }, t.setUseProxies = function(r) {
    r && !gw && Zu(20), this.g = r;
  }, t.applyPatches = function(r, n) {
    var i;
    for (i = n.length - 1; i >= 0; i--) {
      var a = n[i];
      if (a.path.length === 0 && a.op === "replace") {
        r = a.value;
        break;
      }
    }
    i > -1 && (n = n.slice(i + 1));
    var o = Ts("Patches").$;
    return i0(r) ? o(r, n) : this.produce(r, function(u) {
      return o(u, n);
    });
  }, e;
}(), Lo = new DQ(), H_ = Lo.produce;
Lo.produceWithPatches.bind(Lo), Lo.setAutoFreeze.bind(Lo), Lo.setUseProxies.bind(Lo), Lo.applyPatches.bind(Lo), Lo.createDraft.bind(Lo), Lo.finishDraft.bind(Lo);
var ad, fu = new Uint16Array([0, 1, 2, 1, 3, 2]), Pd = Oe.add3, ji = Oe.add2, bw = Oe.add;
(function(e) {
  e.create = function(t, r, n, i) {
    t === void 0 && (t = {}), r === void 0 && (r = 2048), n === void 0 && (n = 1024), r *= 2, n *= 2;
    var a = Oe.create(Float32Array, 3, n, i ? i.centerBuffer.ref.value : r), o = Oe.create(Float32Array, 2, n, i ? i.mappingBuffer.ref.value : r), u = Oe.create(Float32Array, 1, n, i ? i.depthBuffer.ref.value : r), s = Oe.create(Uint32Array, 3, n, i ? i.indexBuffer.ref.value : r), c = Oe.create(Float32Array, 1, n, i ? i.groupBuffer.ref.value : r), l = Oe.create(Float32Array, 2, n, i ? i.tcoordBuffer.ref.value : r), d = R(R({}, G.getDefaultValues(jo.Params)), t), f = d.attachment, m = d.background, v = d.backgroundMargin, p = d.tether, g = d.tetherLength, h = d.tetherBaseWidth, y = function(_) {
      var S = JSON.stringify(_);
      return p4[S] === void 0 && (p4[S] = new BY(_)), p4[S];
    }(d), x = 0.4 * v, A = y.buffer / y.lineHeight, b = function(_, S, D, I, M) {
      Pd(a, _, S, D), bw(u, I), bw(c, M);
    };
    return { add: function(_, S, D, I, M, F, P) {
      for (var E = 0, B = _.length, N = 0; N < B; ++N)
        E += (Ge = y.get(_[N])).nw - 2 * A;
      var O, z;
      if (O = f.startsWith("top") ? 0.8 : f.startsWith("middle") ? 0.4 : 0, z = f.endsWith("right") ? E : f.endsWith("center") ? E / 2 : 0, p) switch (f) {
        case "bottom-left":
          z -= g / 2 + x + 0.1, O -= g / 2 + x;
          break;
        case "bottom-center":
          O -= g + x;
          break;
        case "bottom-right":
          z += g / 2 + x + 0.1, O -= g / 2 + x;
          break;
        case "middle-left":
          z -= g + x + 0.1;
          break;
        case "middle-center":
          break;
        case "middle-right":
          z += g + x + 0.1;
          break;
        case "top-left":
          z -= g / 2 + x + 0.1, O += g / 2 + x;
          break;
        case "top-center":
          O += g + x;
          break;
        case "top-right":
          z += g / 2 + x + 0.1, O += g / 2 + x;
      }
      var V = (-z - x - 0.1) * F, U = (E - z + x + 0.1) * F, H = (0.8 - O + x) * F, K = (-O - x) * F;
      if (m) {
        ji(o, V, H), ji(o, V, K), ji(o, U, H), ji(o, U, K);
        for (var j = a.elementCount, X = 0; X < 4; ++X) ji(l, 10, 10), b(S, D, I, M, P);
        Pd(s, j + fu[0], j + fu[1], j + fu[2]), Pd(s, j + fu[3], j + fu[4], j + fu[5]);
      }
      if (p) {
        var W = void 0, Q = void 0, te = void 0, ee = void 0, $ = void 0, ie = void 0, ae = void 0, se = void 0, le = g * F, pe = h * F;
        switch (f) {
          case "bottom-left":
            W = V - le / 2, te = V + pe / 2, $ = V, ae = V, Q = K - le / 2, ee = K, ie = K + pe / 2, se = K;
            break;
          case "bottom-center":
            W = 0, te = pe / 2, $ = -pe / 2, ae = 0, Q = K - le, ee = K, ie = K, se = K;
            break;
          case "bottom-right":
            W = U + le / 2, te = U, $ = U - pe / 2, ae = U, Q = K - le / 2, ee = K + pe / 2, ie = K, se = K;
            break;
          case "middle-left":
            W = V - le, te = V, $ = V, ae = V, Q = 0, ee = -pe / 2, ie = pe / 2, se = 0;
            break;
          case "middle-center":
            W = 0, te = 0, $ = 0, ae = 0, Q = 0, ee = 0, ie = 0, se = 0;
            break;
          case "middle-right":
            W = U + le, te = U, $ = U, ae = U, Q = 0, ee = pe / 2, ie = -pe / 2, se = 0;
            break;
          case "top-left":
            W = V - le / 2, te = V + pe / 2, $ = V, ae = V, Q = H + le / 2, ee = H, ie = H - pe / 2, se = H;
            break;
          case "top-center":
            W = 0, te = pe / 2, $ = -pe / 2, ae = 0, Q = H + le, ee = H, ie = H, se = H;
            break;
          case "top-right":
            W = U + le / 2, te = U, $ = U - pe / 2, ae = U, Q = H + le / 2, ee = H - pe / 2, ie = H, se = H;
            break;
          default:
            Hi();
        }
        for (ji(o, W, Q), ji(o, te, ee), ji(o, $, ie), ji(o, ae, se), j = a.elementCount, X = 0; X < 4; ++X) ji(l, 10, 10), b(S, D, I, M, P);
        Pd(s, j, j + 1, j + 3), Pd(s, j, j + 3, j + 2);
      }
      z += A, O += A;
      var we = 0;
      for (N = 0; N < B; ++N) {
        var Ge, Ue = (we - z) * F, Ke = (we + (Ge = y.get(_[N])).nw - z) * F, Ze = (Ge.nh - O) * F, Fe = -O * F;
        ji(o, Ue, Ze), ji(o, Ue, Fe), ji(o, Ke, Ze), ji(o, Ke, Fe);
        var Je = y.texture.width, Ne = y.texture.height;
        for (ji(l, Ge.x / Je, Ge.y / Ne), ji(l, Ge.x / Je, (Ge.y + Ge.h) / Ne), ji(l, (Ge.x + Ge.w) / Je, Ge.y / Ne), ji(l, (Ge.x + Ge.w) / Je, (Ge.y + Ge.h) / Ne), we += Ge.nw - 2 * A, j = a.elementCount, X = 0; X < 4; ++X) b(S, D, I, M, P);
        Pd(s, j + fu[0], j + fu[1], j + fu[2]), Pd(s, j + fu[3], j + fu[4], j + fu[5]);
      }
    }, getText: function() {
      var _ = y.texture, S = Oe.compact(a, !0), D = Oe.compact(o, !0), I = Oe.compact(u, !0), M = Oe.compact(s, !0), F = Oe.compact(c, !0), P = Oe.compact(l, !0);
      return jo.create(_, S, D, I, M, F, P, s.elementCount / 2, i);
    } };
  };
})(ad || (ad = {}));
var on, bP = { alpha: G.Numeric(0.51, { min: 0, max: 1, step: 0.01 }, { isEssential: !0, label: "Opacity" }), hideX: G.Boolean(!1), hideY: G.Boolean(!1), hideZ: G.Boolean(!1), colorX: G.Color(Kt.red, { isEssential: !0 }), colorY: G.Color(Kt.green, { isEssential: !0 }), colorZ: G.Color(Kt.blue, { isEssential: !0 }), scale: G.Numeric(0.33, { min: 0.1, max: 2, step: 0.1 }, { isEssential: !0 }), vecA: G.Vec3(w.unitX), vecB: G.Vec3(w.unitY), vecC: G.Vec3(w.unitZ), location: G.Select("bottom-left", G.arrayToOptions(["bottom-left", "bottom-right", "top-left", "top-right"])), locationOffsetX: G.Numeric(0), locationOffsetY: G.Numeric(0), originColor: G.Color(Kt.grey), radiusScale: G.Numeric(0.075, { min: 0.01, max: 0.3, step: 1e-3 }), showPlanes: G.Boolean(!1), planeColorXY: G.Color(Kt.grey, { label: "Plane Color XY" }), planeColorXZ: G.Color(Kt.grey, { label: "Plane Color XZ" }), planeColorYZ: G.Color(Kt.grey, { label: "Plane Color YZ" }), showLabels: G.Boolean(!0), labelX: G.Text("X"), labelY: G.Text("Y"), labelZ: G.Text("Z"), labelColorX: G.Color(Kt.grey), labelColorY: G.Color(Kt.grey), labelColorZ: G.Color(Kt.grey), labelOpacity: G.Numeric(1, { min: 0, max: 1, step: 0.01 }), labelScale: G.Numeric(0.15, { min: 0.1, max: 1, step: 0.01 }) }, Lg = { axes: G.MappedStatic("on", { on: G.Group(bP), off: G.Group({}) }, { cycle: !0, description: "Show camera orientation axes" }) }, _P = function() {
  function e(t, r) {
    var n = this;
    r === void 0 && (r = {}), this.webgl = t, this.props = { axes: { name: "off", params: {} } }, this.pixelRatio = 1, this.eachGroup = function(i, a) {
      if (!_w(i)) return !1;
      var o = !1;
      if (n.meshRenderObject) for (var u = n.meshRenderObject.values.uGroupCount.ref.value, s = 0, c = i.elements; s < c.length; s++) {
        var l = c[s], d = l.groupId, f = l.instanceId * u + d;
        a(Ae.ofSingleton(f)) && (o = !0);
      }
      if (n.textRenderObject) {
        u = n.textRenderObject.values.uGroupCount.ref.value;
        for (var m = 0, v = i.elements; m < v.length; m++) {
          var p = v[m];
          d = p.groupId, f = p.instanceId * u + d, a(Ae.ofSingleton(f)) && (o = !0);
        }
      }
      return o;
    }, this.scene = r0.create(t, Fg), this.camera = new Jn(), w.set(this.camera.up, 0, 1, 0), w.set(this.camera.target, 0, 0, 0), this.setProps(r);
  }
  return e.prototype.setProps = function(t) {
    var r = this;
    this.props = H_(this.props, function(n) {
      if (t.axes !== void 0 && (n.axes.name = t.axes.name, t.axes.name === "on")) {
        r.scene.clear();
        var i = R(R({}, G.getDefaultValues(bP)), t.axes.params);
        r.pixelRatio = r.webgl.pixelRatio;
        var a = R(R({}, i), { scale: i.scale * r.pixelRatio, labelScale: i.labelScale * r.pixelRatio });
        r.meshRenderObject = function(o) {
          var u = function(s, c) {
            var l = 100 * s.scale, d = function(m, v) {
              var p = m.vecA, g = m.vecB, h = m.vecC, y = wt.createState(512, 256, v), x = 100 * m.scale, A = m.radiusScale * x, b = m.showLabels ? 100 * m.labelScale / 3 : 0, _ = w.sub(w(), w.scale(w(), p, x - b), w.scale(w(), w.create(0, 0, 1), 0.5 * x)), S = w.sub(w(), w.scale(w(), g, x - b), w.scale(w(), w.create(0, 0, 1), 0.5 * x)), D = w.sub(w(), w.scale(w(), h, x - b), w.scale(w(), w.create(0, 0, 1), 0.5 * x)), I = w.sub(w(), w.origin, w.scale(w(), w.create(0, 0, 1), 0.5 * x)), M = { radiusTop: A, radiusBottom: A, radialSegments: 32 };
              if (y.currentGroup = on.Origin, Mi(y, I, A, 2), m.hideX || (y.currentGroup = on.X, Mi(y, _, A, 2), wi(y, I, _, 1, M)), m.hideY || (y.currentGroup = on.Y, Mi(y, S, A, 2), wi(y, I, S, 1, M)), m.hideZ || (y.currentGroup = on.Z, Mi(y, D, A, 2), wi(y, I, D, 1, M)), m.showPlanes) {
                if (w.scale(_, _, 0.5), w.scale(S, S, 0.5), w.scale(D, D, 0.5), !m.hideX && !m.hideY) {
                  y.currentGroup = on.XY, wt.addTriangle(y, I, _, S), wt.addTriangle(y, I, S, _);
                  var F = w.add(w(), _, S);
                  wt.addTriangle(y, F, _, S), wt.addTriangle(y, F, S, _);
                }
                if (!m.hideX && !m.hideZ) {
                  y.currentGroup = on.XZ, wt.addTriangle(y, I, _, D), wt.addTriangle(y, I, D, _);
                  var P = w.add(w(), _, D);
                  wt.addTriangle(y, P, _, D), wt.addTriangle(y, P, D, _);
                }
                if (!m.hideY && !m.hideZ) {
                  y.currentGroup = on.YZ, wt.addTriangle(y, I, S, D), wt.addTriangle(y, I, D, S);
                  var E = w.add(w(), S, D);
                  wt.addTriangle(y, E, S, D), wt.addTriangle(y, E, D, S);
                }
              }
              return wt.getMesh(y);
            }(s, void 0);
            d.setBoundingSphere(Me.create(w.create(l / 2, l / 2, l / 2), l + l / 4));
            var f = function(m) {
              switch (m) {
                case on.X:
                  return s.colorX;
                case on.Y:
                  return s.colorY;
                case on.Z:
                  return s.colorZ;
                case on.XY:
                  return s.planeColorXY;
                case on.XZ:
                  return s.planeColorXZ;
                case on.YZ:
                  return s.planeColorYZ;
                case on.Origin:
                  return s.originColor;
                default:
                  return Kt.grey;
              }
            };
            return $t.create("axes-mesh", {}, d, f, function() {
              return 1;
            }, function() {
              return "";
            });
          }(o);
          return $t.createRenderObject(u, R(R(R({}, G.getDefaultValues(Gt.Params)), o), { ignoreLight: !0 }));
        }(a), r.scene.add(r.meshRenderObject), a.showLabels ? (r.textRenderObject = function(o) {
          var u = function(s, c) {
            var l = 100 * s.scale, d = function(m, v) {
              var p = m.vecA, g = m.vecB, h = m.vecC, y = ad.create(m, 8, 8, v), x = 100 * m.scale, A = w.add(w(), w.scale(w(), p, x), w.scale(w(), w.create(0, 0, 1), 1.5 * x)), b = w.add(w(), w.scale(w(), g, x), w.scale(w(), w.create(0, 0, 1), 1.5 * x)), _ = w.add(w(), w.scale(w(), h, x), w.scale(w(), w.create(0, 0, 1), 1.5 * x)), S = 100 * m.labelScale;
              return m.hideX || y.add(m.labelX, A[0], A[1], A[2], 0, S, on.X), m.hideY || y.add(m.labelY, b[0], b[1], b[2], 0, S, on.Y), m.hideZ || y.add(m.labelZ, _[0], _[1], _[2], 0, S, on.Z), y.getText();
            }(s, void 0);
            d.setBoundingSphere(Me.create(w.create(l / 2, l / 2, l / 2), l));
            var f = function(m) {
              switch (m) {
                case on.X:
                  return s.labelColorX;
                case on.Y:
                  return s.labelColorY;
                case on.Z:
                  return s.labelColorZ;
                default:
                  return Kt.grey;
              }
            };
            return $t.create("axes-text", {}, d, f, function() {
              return 1;
            }, function() {
              return "";
            });
          }(o);
          return $t.createRenderObject(u, R(R(R({}, G.getDefaultValues(jo.Params)), o), { alpha: o.labelOpacity }));
        }(a), r.scene.add(r.textRenderObject)) : r.textRenderObject = void 0, r.scene.commit(), w.set(r.camera.position, 0, 0, 200 * a.scale), me.lookAt(r.camera.view, r.camera.position, r.camera.target, r.camera.up), n.axes.params = R({}, i);
      }
    });
  }, Object.defineProperty(e.prototype, "isEnabled", { get: function() {
    return this.props.axes.name === "on";
  }, enumerable: !1, configurable: !0 }), e.prototype.getLoci = function(t) {
    var r = t.objectId, n = t.groupId, i = t.instanceId;
    return (this.meshRenderObject && r === this.meshRenderObject.id || this.textRenderObject && r === this.textRenderObject.id) && n !== on.None ? function(a, o, u) {
      return F_("camera-axes", a, [{ groupId: o, instanceId: u }], void 0, function() {
        return function(s, c) {
          var l = c.props.axes, d = l.name === "on" ? l.params.labelX : "X", f = l.name === "on" ? l.params.labelY : "Y", m = l.name === "on" ? l.params.labelZ : "Z";
          switch (s) {
            case on.X:
              return "".concat(d, " Axis");
            case on.Y:
              return "".concat(f, " Axis");
            case on.Z:
              return "".concat(m, " Axis");
            case on.XY:
              return "".concat(d).concat(f, " Plane");
            case on.XZ:
              return "".concat(d).concat(m, " Plane");
            case on.YZ:
              return "".concat(f).concat(m, " Plane");
            case on.Origin:
              return "Origin";
            default:
              return "Axes";
          }
        }(o, a);
      });
    }(this, n, i) : vn;
  }, e.prototype.mark = function(t, r) {
    return !Pr.is(Pr.Highlighting, r) || !xo(t) && (!_w(t) || t.data !== this) ? !1 : rr.mark(this.meshRenderObject, t, r, this.eachGroup) || rr.mark(this.textRenderObject, t, r, this.eachGroup);
  }, e.prototype.update = function(t) {
    if (this.meshRenderObject && this.props.axes.name !== "off") {
      this.pixelRatio !== this.webgl.pixelRatio && this.setProps(this.props), function(o, u, s) {
        var c = o.near, l = o.far, d = -u.width / 2, f = u.width / 2, m = u.height / 2, v = -u.height / 2, p = (f - d) / 2, g = (m - v) / 2, h = (f + d) / 2, y = (m + v) / 2, x = h - p, A = h + p, b = y + g, _ = y - g;
        if (s.enabled) {
          var S = (f - d) / s.width, D = (m - v) / s.height;
          A = (x += S * s.offsetX) + S * s.width, _ = (b -= D * s.offsetY) - D * s.height;
        }
        me.ortho(o.projection, x, A, b, _, c, l);
      }(this.camera, t.viewport, t.viewOffset), me.extractRotation(this.scene.view, t.view);
      var r = this.textRenderObject ? this.textRenderObject.values.boundingSphere.ref.value.radius : this.meshRenderObject.values.boundingSphere.ref.value.radius, n = this.props.axes.params.location, i = this.props.axes.params.locationOffsetX * this.pixelRatio, a = this.props.axes.params.locationOffsetY * this.pixelRatio;
      n === "bottom-left" ? me.setTranslation(this.scene.view, w.create(-t.viewport.width / 2 + r + i, -t.viewport.height / 2 + r + a, 0)) : n === "bottom-right" ? me.setTranslation(this.scene.view, w.create(t.viewport.width / 2 - r - i, -t.viewport.height / 2 + r + a, 0)) : n === "top-left" ? me.setTranslation(this.scene.view, w.create(-t.viewport.width / 2 + r + i, t.viewport.height / 2 - r - a, 0)) : n === "top-right" ? me.setTranslation(this.scene.view, w.create(t.viewport.width / 2 - r - i, t.viewport.height / 2 - r - a, 0)) : Hi();
    }
  }, e;
}();
function _w(e) {
  return e.kind === "data-loci" && e.tag === "camera-axes";
}
(function(e) {
  e[e.None = 0] = "None", e[e.X = 1] = "X", e[e.Y = 2] = "Y", e[e.Z = 3] = "Z", e[e.XY = 4] = "XY", e[e.XZ = 5] = "XZ", e[e.YZ = 6] = "YZ", e[e.Origin = 7] = "Origin";
})(on || (on = {}));
var IQ = { transparentBackground: G.Boolean(!1), multiSample: G.Group(fP), postprocessing: G.Group(dP), marking: G.Group(hP), cameraHelper: G.Group(Lg) }, EQ = function() {
  function e(t, r, n, i, a, o, u) {
    this.webgl = t, this.renderer = r, this.scene = n, this.camera = i, this._width = 0, this._height = 0, this._camera = new Jn(), this.props = R(R({}, G.getDefaultValues(IQ)), u), this.drawPass = new vP(t, 128, 128, o), this.multiSamplePass = new H2(t, this.drawPass), this.multiSampleHelper = new pP(this.multiSamplePass), this.helper = { camera: new _P(t, this.props.cameraHelper), debug: a.debug, handle: a.handle }, this.setSize(1024, 768);
  }
  return Object.defineProperty(e.prototype, "colorTarget", { get: function() {
    return this._colorTarget;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "width", { get: function() {
    return this._width;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "height", { get: function() {
    return this._height;
  }, enumerable: !1, configurable: !0 }), e.prototype.setSize = function(t, r) {
    t === this._width && r === this._height || (this._width = t, this._height = r, this.drawPass.setSize(t, r), this.multiSamplePass.syncSize());
  }, e.prototype.setProps = function(t) {
    t === void 0 && (t = {}), Object.assign(this.props, t), t.cameraHelper && this.helper.camera.setProps(t.cameraHelper);
  }, e.prototype.render = function() {
    Jn.copySnapshot(this._camera.state, this.camera.state), Vi.set(this._camera.viewport, 0, 0, this._width, this._height), this._camera.update();
    var t = { renderer: this.renderer, camera: this._camera, scene: this.scene, helper: this.helper };
    H2.isEnabled(this.props.multiSample) ? (this.multiSampleHelper.render(t, this.props, !1), this._colorTarget = this.multiSamplePass.colorTarget) : (this.drawPass.render(t, this.props, !1), this._colorTarget = this.drawPass.getColorTarget(this.props.postprocessing));
  }, e.prototype.getImageData = function(t, r, n) {
    var i, a;
    this.setSize(t, r), this.render(), this.colorTarget.bind();
    var o = (i = n == null ? void 0 : n.width) !== null && i !== void 0 ? i : t, u = (a = n == null ? void 0 : n.height) !== null && a !== void 0 ? a : r, s = new Uint8Array(o * u * 4);
    n ? this.webgl.readPixels(n.x, r - n.y - n.height, o, u, s) : this.webgl.readPixels(0, 0, o, u, s);
    var c = nf.create(s, o, u);
    return nf.flipY(c), nf.divideByAlpha(c), new ImageData(new Uint8ClampedArray(s), o, u);
  }, e;
}(), MQ = R(R({}, Gt.Params), { alpha: R(R({}, Gt.Params.alpha), { defaultValue: 1 }), ignoreLight: R(R({}, Gt.Params.ignoreLight), { defaultValue: !0 }), colorX: G.Color(Kt.red, { isEssential: !0 }), colorY: G.Color(Kt.green, { isEssential: !0 }), colorZ: G.Color(Kt.blue, { isEssential: !0 }), scale: G.Numeric(0.33, { min: 0.1, max: 2, step: 0.1 }, { isEssential: !0 }) }), xP = { handle: G.MappedStatic("off", { on: G.Group(MQ), off: G.Group({}) }, { cycle: !0, description: "Show handle tool" }) }, TQ = function() {
  function e(t, r) {
    var n = this;
    r === void 0 && (r = {}), this.webgl = t, this.props = { handle: { name: "off", params: {} } }, this.pixelRatio = 1, this._transform = me(), this.eachGroup = function(i, a) {
      if (!n.renderObject || !xw(i)) return !1;
      for (var o = !1, u = n.renderObject.values.uGroupCount.ref.value, s = 0, c = i.elements; s < c.length; s++) {
        var l = c[s], d = l.groupId, f = l.instanceId * u + d;
        a(Ae.ofSingleton(f)) && (o = !0);
      }
      return o;
    }, this.scene = r0.create(t, Fg), this.setProps(r);
  }
  return e.prototype.getBoundingSphere = function(t, r) {
    return this.renderObject && (Me.copy(t, this.renderObject.values.invariantBoundingSphere.ref.value), me.fromArray(this._transform, this.renderObject.values.aTransform.ref.value, 16 * r), Me.transform(t, t, this._transform)), t;
  }, e.prototype.setProps = function(t) {
    var r = this;
    this.props = H_(this.props, function(n) {
      if (t.handle !== void 0 && (n.handle.name = t.handle.name, t.handle.name === "on")) {
        r.scene.clear(), r.pixelRatio = r.webgl.pixelRatio;
        var i = R(R({}, t.handle.params), { scale: t.handle.params.scale * r.webgl.pixelRatio });
        r.renderObject = function(a) {
          var o = function(u, s) {
            var c = 10 * u.scale, l = function(f, m) {
              var v = wt.createState(512, 256, m), p = 0.05 * f, g = w.scale(w(), w.unitX, f), h = w.scale(w(), w.unitY, f), y = w.scale(w(), w.unitZ, f), x = { radiusTop: p, radiusBottom: p, radialSegments: 32 };
              return v.currentGroup = Bd.TranslateScreenXY, Mi(v, w.origin, 3 * p, 2), v.currentGroup = Bd.TranslateObjectX, Mi(v, g, p, 2), wi(v, w.origin, g, 1, x), v.currentGroup = Bd.TranslateObjectY, Mi(v, h, p, 2), wi(v, w.origin, h, 1, x), v.currentGroup = Bd.TranslateObjectZ, Mi(v, y, p, 2), wi(v, w.origin, y, 1, x), wt.getMesh(v);
            }(c, void 0);
            l.setBoundingSphere(Me.create(w.create(c / 2, c / 2, c / 2), c + c / 4));
            var d = function(f) {
              switch (f) {
                case Bd.TranslateObjectX:
                  return u.colorX;
                case Bd.TranslateObjectY:
                  return u.colorY;
                case Bd.TranslateObjectZ:
                  return u.colorZ;
                default:
                  return Kt.grey;
              }
            };
            return $t.create("handle", {}, l, d, function() {
              return 1;
            }, function() {
              return "";
            });
          }(a);
          return $t.createRenderObject(o, a);
        }(i), r.scene.add(r.renderObject), r.scene.commit(), n.handle.params = R({}, t.handle.params);
      }
    });
  }, Object.defineProperty(e.prototype, "isEnabled", { get: function() {
    return this.props.handle.name === "on";
  }, enumerable: !1, configurable: !0 }), e.prototype.update = function(t, r, n) {
    this.renderObject && (this.pixelRatio !== this.webgl.pixelRatio && this.setProps(this.props), me.setTranslation(this.renderObject.values.aTransform.ref.value, r), me.fromMat3(this.renderObject.values.aTransform.ref.value, n), k.update(this.renderObject.values.aTransform, this.renderObject.values.aTransform.ref.value), this.scene.update([this.renderObject], !0));
  }, e.prototype.getLoci = function(t) {
    var r = t.objectId, n = t.groupId, i = t.instanceId;
    return this.renderObject && r === this.renderObject.id ? function(a, o, u) {
      return F_("handle", a, [{ groupId: o, instanceId: u }], function(s) {
        return a.getBoundingSphere(s, u);
      }, function() {
        return "Handle Helper | Group Id ".concat(o, " | Instance Id ").concat(u);
      });
    }(this, n, i) : vn;
  }, e.prototype.mark = function(t, r) {
    return !Pr.is(Pr.Highlighting, r) || !xo(t) && (!xw(t) || t.data !== this) ? !1 : rr.mark(this.renderObject, t, r, this.eachGroup);
  }, e;
}(), Bd = { None: 0, TranslateScreenXY: 1, TranslateObjectX: 3, TranslateObjectY: 4, TranslateObjectZ: 5 };
function xw(e) {
  return e.kind === "data-loci" && e.tag === "handle";
}
var t6, PQ = { debug: G.Group(R_), camera: G.Group({ helper: G.Group(Lg) }), handle: G.Group(xP) }, BQ = G.getDefaultValues(PQ), FQ = function(e, t, r) {
  r === void 0 && (r = {});
  var n = R(R({}, BQ), r);
  this.debug = new OZ(e, t, n.debug), this.camera = new _P(e, n.camera.helper), this.handle = new TQ(e, n.handle);
}, NQ = function() {
  function e(t, r) {
    r === void 0 && (r = {}), this.webgl = t;
    var n = t.gl;
    this.draw = new vP(t, n.drawingBufferWidth, n.drawingBufferHeight, r.enableWboit || !1), this.pick = new uQ(t, this.draw, r.pickScale || 0.25), this.multiSample = new H2(t, this.draw);
  }
  return e.prototype.updateSize = function() {
    var t = this.webgl.gl;
    this.draw.setSize(t.drawingBufferWidth, t.drawingBufferHeight), this.pick.syncSize(), this.multiSample.syncSize();
  }, e;
}(), j2 = { camera: G.Group({ mode: G.Select("orthographic", G.arrayToOptions(["perspective", "orthographic"]), { label: "Camera" }), helper: G.Group(Lg, { isFlat: !0 }), stereo: G.MappedStatic("off", { on: G.Group(mP), off: G.Group({}) }, { cycle: !0, hideIf: function(e) {
  return (e == null ? void 0 : e.mode) !== "perspective";
} }), manualReset: G.Boolean(!1, { isHidden: !0 }) }, { pivot: "mode" }), cameraFog: G.MappedStatic("on", { on: G.Group({ intensity: G.Numeric(50, { min: 1, max: 100, step: 1 }) }), off: G.Group({}) }, { cycle: !0, description: "Show fog in the distance" }), cameraClipping: G.Group({ radius: G.Numeric(100, { min: 0, max: 99, step: 1 }, { label: "Clipping", description: "How much of the scene to show." }), far: G.Boolean(!0, { description: "Hide scene in the distance" }) }, { pivot: "radius" }), viewport: G.MappedStatic("canvas", { canvas: G.Group({}), "static-frame": G.Group({ x: G.Numeric(0), y: G.Numeric(0), width: G.Numeric(128), height: G.Numeric(128) }), "relative-frame": G.Group({ x: G.Numeric(0.33, { min: 0, max: 1, step: 0.01 }), y: G.Numeric(0.33, { min: 0, max: 1, step: 0.01 }), width: G.Numeric(0.5, { min: 0.01, max: 1, step: 0.01 }), height: G.Numeric(0.5, { min: 0.01, max: 1, step: 0.01 }) }) }), cameraResetDurationMs: G.Numeric(250, { min: 0, max: 1e3, step: 1 }, { description: "The time it takes to reset the camera." }), transparentBackground: G.Boolean(!1), multiSample: G.Group(fP), postprocessing: G.Group(dP), marking: G.Group(hP), renderer: G.Group(cb), trackball: G.Group(mM), interaction: G.Group(lP), debug: G.Group(R_), handle: G.Group(xP) }, RQ = G.getDefaultValues(j2);
(function(e) {
  e.DefaultAttribs = { antialias: !0, preserveDrawingBuffer: !0, pixelScale: 1, pickScale: 0.25, pickPadding: 1, enableWboit: !0, preferWebGl1: !1 }, e.fromCanvas = function(t, r) {
    r === void 0 && (r = {});
    var n = R(R({}, e.DefaultAttribs), r), i = n.antialias, a = n.preserveDrawingBuffer, o = n.pixelScale, u = n.preferWebGl1, s = function(g, h) {
      function y(A) {
        try {
          return g.getContext(A, h);
        } catch {
          return null;
        }
      }
      var x = (h != null && h.preferWebGl1 ? null : y("webgl2")) || y("webgl") || y("experimental-webgl");
      return Ir && console.log("isWebgl2: ".concat(ir(x))), x;
    }(t, { antialias: i, preserveDrawingBuffer: a, alpha: !0, depth: !0, premultipliedAlpha: !0, preferWebGl1: u });
    if (s === null) throw new Error("Could not create a WebGL rendering context");
    var c = ab.fromElement(t, { pixelScale: o, preventGestures: !0 }), l = qq(s, { pixelScale: o }), d = new NQ(l, r);
    if (Ir) {
      var f = s.getExtension("WEBGL_lose_context");
      f && t.addEventListener("mousedown", function(g) {
        l.isContextLost || g.shiftKey && g.ctrlKey && g.altKey && (Ir && console.log("lose context"), f.loseContext(), setTimeout(function() {
          l.isContextLost && (Ir && console.log("restore context"), f.restoreContext());
        }, 1e3));
      }, !1);
    }
    var m = new Ol(0), v = function(g) {
      l.setContextLost(), g && g.preventDefault(), Ir && console.log("context lost"), m.next(li());
    }, p = function() {
      l.isContextLost && (l.handleContextRestored(function() {
        d.draw.reset();
      }), Ir && console.log("context restored"));
    };
    return t.addEventListener("webglcontextlost", v, !1), t.addEventListener("webglcontextrestored", p, !1), { canvas: t, webgl: l, input: c, passes: d, attribs: n, contextLost: m, contextRestored: l.contextRestored, dispose: function(g) {
      c.dispose(), t.removeEventListener("webglcontextlost", v, !1), t.removeEventListener("webglcontextrestored", p, !1), l.destroy(g);
    }, handleWebglContextLost: v, handlewWebglContextRestored: p };
  };
})(t6 || (t6 = {}));
var r6, OQ = typeof window < "u" ? window.requestAnimationFrame : function(e) {
  return setImmediate(function() {
    return e(Date.now());
  });
}, LQ = typeof window < "u" ? window.cancelAnimationFrame : function(e) {
  return clearImmediate(e);
};
function Aw(e, t, r) {
  r === void 0 && (r = 1);
  var n = window.innerWidth, i = window.innerHeight;
  t !== document.body && (n = t.offsetWidth, i = t.offsetHeight), function(a, o, u, s) {
    s === void 0 && (s = 1), a.width = Math.round(window.devicePixelRatio * s * o), a.height = Math.round(window.devicePixelRatio * s * u), Object.assign(a.style, { width: "".concat(o, "px"), height: "".concat(u, "px") });
  }(e, n, i, r);
}
function Sw(e, t, r) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(n) {
      return [2, new Promise(function(i, a) {
        var o = function(u) {
          u ? i(u) : a("no blob returned");
        };
        HTMLCanvasElement.prototype.toBlob ? e.toBlob(o, t, r) : function(u, s, c, l) {
          for (var d = atob(u.toDataURL(c, l).split(",")[1]), f = d.length, m = f >> 2, v = new Uint8Array(f), p = new Uint32Array(v.buffer, 0, m), g = 0, h = 0; h < m; ++h) p[h] = d.charCodeAt(g++) | d.charCodeAt(g++) << 8 | d.charCodeAt(g++) << 16 | d.charCodeAt(g++) << 24;
          for (var y = 3 & f; y--; ) v[g] = d.charCodeAt(g++);
          s(new Blob([v], { type: c }));
        }(e, o, t, r);
      })];
    });
  });
}
function Br(e, t) {
  return e.model.atomicHierarchy.atoms.type_symbol.value(e.elements[t]);
}
function q_(e, t) {
  return e.model.atomicHierarchy.atoms.pdbx_formal_charge.value(e.elements[t]);
}
function AP(e, t) {
  return e.model.atomicHierarchy.atoms.label_atom_id.value(e.elements[t]);
}
function Y2(e, t) {
  return e.model.atomicHierarchy.atoms.label_alt_id.value(e.elements[t]);
}
function kQ(e, t) {
  return e.model.atomicHierarchy.atoms.label_comp_id.value(e.elements[t]);
}
function pm(e, t, r) {
  return function(n, i, a) {
    for (var o = 0, u = n.interUnitBonds.getEdgeIndices(a, i.id), s = 0, c = u.length; s < c; ++s) {
      var l = n.interUnitBonds.edges[u[s]];
      cr.isCovalent(l.props.flag) && (o += 1);
    }
    return o;
  }(e, t, r) + function(n, i) {
    for (var a = 0, o = n.bonds, u = o.offset, s = o.edgeProps.flags, c = u[i], l = u[i + 1]; c < l; ++c) cr.isCovalent(s[c]) && (a += 1);
    return a;
  }(t, r);
}
function Cw(e, t, r, n) {
  var i = 0;
  return $l(e, t, r, function(a, o) {
    Br(a, o) === n && (i += 1);
  }), i;
}
function zQ(e, t, r, n, i) {
  return t === n ? function(a, o, u) {
    var s = a.bonds, c = s.offset, l = s.b, d = s.edgeProps.flags;
    cr.is;
    for (var f = c[o], m = c[o + 1]; f < m; ++f) if (l[f] === u && cr.isCovalent(d[f])) return !0;
    return !1;
  }(t, r, i) : function(a, o, u, s, c) {
    var l = a.interUnitBonds.getEdge(u, o.id, c, s.id);
    return l && cr.isCovalent(l.props.flag);
  }(e, t, r, n, i);
}
function Ds(e, t, r) {
  for (var n = e.bonds, i = n.offset, a = n.b, o = n.edgeProps.flags, u = i[t], s = i[t + 1]; u < s; ++u) cr.isCovalent(o[u]) && r(e, a[u]);
}
function $l(e, t, r, n) {
  (function(i, a, o, u) {
    for (var s = i.interUnitBonds.getEdgeIndices(o, a.id), c = 0, l = s.length; c < l; ++c) {
      var d = i.interUnitBonds.edges[s[c]], f = i.unitMap.get(d.unitB);
      cr.isCovalent(d.props.flag) && u(f, d.indexB);
    }
  })(e, t, r, n), Ds(t, r, n);
}
function fv(e) {
  switch (e) {
    case 0:
      return 0;
    case 1:
      return 1;
    case 2:
      return 2;
    case 3:
      return 3;
    case 4:
      return 4;
    default:
      return 8;
  }
}
(function(e) {
  e.create = function(t, r) {
    var n = t.webgl, i = t.input, a = t.passes, o = t.attribs;
    r === void 0 && (r = {});
    var u = R(R({}, RQ), r), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = new Ol(0), d = li(), f = new Ol(0), m = new Ol(0), v = n.gl, p = n.contextRestored, g = 0, h = 0, y = 128, x = 128;
    nt();
    var A = r0.create(n, a.draw.wboitEnabled ? VY : Fg), b = new Jn({ position: w.create(0, 0, 100), mode: u.camera.mode, fog: u.cameraFog.name === "on" ? u.cameraFog.params.intensity : 0, clipFar: u.cameraClipping.far }, { x: g, y: h, width: y, height: x }, { pixelScale: o.pixelScale }), _ = new n0(b, u.camera.stereo.params), S = lb.create(i, b, u.trackball), D = sb.create(n, u.renderer), I = new FQ(n, A, u), M = new sQ(n, D, A, I, a.pick, { x: g, y: h, width: y, height: x }, o.pickPadding), F = new VZ(se, V, i, b, u.interaction), P = new pP(a.multiSample), E = !1, B = void 0, N = void 0, O = !1, z = !0;
    function V(J) {
      var ce = vn, de = or.Empty;
      if (J) {
        var ve = I.camera.getLoci(J);
        if (ve !== vn) return { loci: ve, repr: de };
        ce = I.handle.getLoci(J), s.forEach(function(he, Se) {
          var Re = Se.getLoci(J);
          Jl(Re) || (Jl(ce) || console.warn("found another loci, this should not happen"), ce = Re, de = Se);
        });
      }
      return { loci: ce, repr: de };
    }
    var U = [];
    function H(J, ce) {
      var de = J.repr, ve = J.loci, he = !1;
      return de ? he = de.mark(ve, ce) : (he = I.handle.mark(ve, ce), he = I.camera.mark(ve, ce) || he, s.forEach(function(Se, Re) {
        he = Re.mark(ve, ce) || he;
      })), he;
    }
    function K(J) {
      if (n.isContextLost) return !1;
      var ce = !1;
      if (O && (Ne(!1), O = !1, ce = !0), g > v.drawingBufferWidth || g + y < 0 || h > v.drawingBufferHeight || h + x < 0) return !1;
      var de = function() {
        for (var bt = !1, Ct = 0, De = U; Ct < De.length; Ct++) {
          var ut = De[Ct];
          bt = H(ut[0], ut[1]) || bt;
        }
        return U = [], bt && (A.update(void 0, !0), I.handle.scene.update(void 0, !0), I.camera.scene.update(void 0, !0)), bt;
      }(), ve = !1;
      S.update(W);
      var he = b.update(), Se = J || he || ce || j;
      j = !1;
      var Re = P.update(de || Se, u.multiSample);
      if (Se || Re || de) {
        var Ve = b;
        u.camera.stereo.name === "on" && (_.update(), Ve = _);
        var ze = { renderer: D, camera: Ve, scene: A, helper: I };
        if (H2.isEnabled(u.multiSample)) {
          var mt = !he && de && !S.isAnimating;
          P.render(ze, u, !0, mt);
        } else a.draw.render(ze, u, !0);
        M.dirty = M.dirty || Se, ve = !0;
      }
      return ve;
    }
    var j = !1, X = !1, W = 0, Q = !1;
    function te(J) {
      Q || K(!!(J != null && J.force)) && z && f.next(li() - d);
    }
    function ee() {
      j = !0;
    }
    var $ = 0;
    function ie(J, ce) {
      W = J, le(ce == null ? void 0 : ce.isSynchronous), b.transition.tick(W), ce != null && ce.manualDraw || (te(), b.transition.inTransition || n.isContextLost || F.tick(W));
    }
    function ae() {
      ie(li()), $ = OQ(ae);
    }
    function se(J, ce) {
      var de = u.camera.stereo.name === "on" ? _ : b;
      return n.isContextLost ? void 0 : M.identify(J, ce, de);
    }
    function le(J) {
      J === void 0 && (J = !1);
      var ce = function(de) {
        return A.needsCommit ? (Me.copy(pe, A.boundingSphereVisible), A.commit(de ? void 0 : Ge) ? (I.debug.isEnabled && I.debug.update(), u.camera.manualReset || l.value !== 0 && !function() {
          if (b.state.radiusMax === 0) return !0;
          if (b.transition.inTransition || N) return !1;
          var ve = !0, he = !0;
          Me.set(we, b.state.target, b.state.radius);
          for (var Se = 0, Re = A.renderables; Se < Re.length; Se++) {
            var Ve = Re[Se];
            if (Ve.state.visible) {
              var ze = Ve.values.boundingSphere.ref.value;
              if (ze.radius) {
                he = !1;
                var mt = w.distance(we.center, ze.center);
                if ((mt > we.radius || mt > ze.radius || ze.radius > b.state.radiusMax) && !Me.includes(pe, ze)) return !0;
                Me.overlaps(we, ze) && (ve = !1);
              }
            }
          }
          return ve || !he && we.radius <= 0.1;
        }() || (E = !0), pe.radius === 0 && (B = 0), b.setState({ radiusMax: A.boundingSphere.radius }, 0), l.next(s.size), Ir && Ue(), !0) : !1) : !0;
      }(J);
      ce && (S.isLockCamera ? (B = void 0, N = void 0, E = !1) : function() {
        if (!(!E || S.isLockCamera)) {
          var de = A.boundingSphereVisible, ve = de.center, he = de.radius, Se = S.props.autoAdjustMinMaxDistance;
          if (Se.name === "on") {
            var Re = Se.params.minDistanceFactor * he + Se.params.minDistancePadding, Ve = Math.max(Se.params.maxDistanceFactor * he, Se.params.maxDistanceMin);
            S.setProps({ minDistance: Re, maxDistance: Ve });
          }
          if (he > 0) {
            var ze = B === void 0 ? u.cameraResetDurationMs : B, mt = b.getFocus(ve, he), bt = typeof N == "function" ? N(A, b) : N, Ct = bt ? R(R({}, mt), bt) : mt;
            b.setState(R(R({}, Ct), { radiusMax: A.boundingSphere.radius }), ze);
          }
          B = void 0, N = void 0, E = !1;
        }
      }(), X && (I.debug.isEnabled && I.debug.update(), te({ force: !0 }), X = !1), m.next(li()));
    }
    var pe = Me(), we = Me(), Ge = 250;
    function Ue() {
      console.table(A.renderables.map(function(he) {
        return { drawCount: he.values.drawCount.ref.value, instanceCount: he.values.instanceCount.ref.value, materialId: he.materialId, renderItemId: he.id };
      })), console.log(n.stats);
      var J = n.resources.getByteCounts(), ce = J.texture, de = J.attribute, ve = J.elements;
      console.log({ texture: "".concat((ce / 1024 / 1024).toFixed(3), " MiB"), attribute: "".concat((de / 1024 / 1024).toFixed(3), " MiB"), elements: "".concat((ve / 1024 / 1024).toFixed(3), " MiB") });
    }
    function Ke(J) {
      (function(ve) {
        c.has(ve) || c.set(ve, ve.updated.subscribe(function(he) {
          ve.state.syncManually || Ke(ve);
        }));
      })(J);
      var ce = s.get(J), de = /* @__PURE__ */ new Set();
      J.renderObjects.forEach(function(ve) {
        return de.add(ve);
      }), ce ? to.areEqual(de, ce) || (de.forEach(function(ve) {
        ce.has(ve) || A.add(ve);
      }), ce.forEach(function(ve) {
        de.has(ve) || A.remove(ve);
      })) : J.renderObjects.forEach(function(ve) {
        return A.add(ve);
      }), s.set(J, de), A.update(J.renderObjects, !1), X = !0, Ir && Ue();
    }
    function Ze() {
      var J = A.boundingSphere.radius > 0 ? 100 - Math.round(b.transition.target.radius / A.boundingSphere.radius * 100) : 0;
      return { camera: { mode: b.state.mode, helper: R({}, I.camera.props), stereo: R({}, u.camera.stereo), manualReset: !!u.camera.manualReset }, cameraFog: b.state.fog > 0 ? { name: "on", params: { intensity: b.state.fog } } : { name: "off", params: {} }, cameraClipping: { far: b.state.clipFar, radius: J }, cameraResetDurationMs: u.cameraResetDurationMs, transparentBackground: u.transparentBackground, viewport: u.viewport, postprocessing: R({}, u.postprocessing), marking: R({}, u.marking), multiSample: R({}, u.multiSample), renderer: R({}, D.props), trackball: R({}, S.props), interaction: R({}, F.props), debug: R({}, I.debug.props), handle: R({}, I.handle.props) };
    }
    var Fe = p.subscribe(function() {
      M.dirty = !0, te({ force: !0 }), te({ force: !0 });
    }), Je = new Ol(0);
    function Ne(J) {
      J === void 0 && (J = !0), a.updateSize(), nt(), re(), J && ee(), Je.next(+/* @__PURE__ */ new Date());
    }
    return { webgl: n, scene: A, helper: I, add: Ke, remove: function(J) {
      (function(de) {
        var ve = c.get(de);
        ve && (ve.unsubscribe(), c.delete(de));
      })(J);
      var ce = s.get(J);
      ce && (ce.forEach(function(de) {
        return A.remove(de);
      }), s.delete(J), X = !0, Ir && Ue());
    }, commit: le, controls: S, update: function(J, ce) {
      if (J) {
        if (!s.has(J)) return;
        A.update(J.renderObjects, !!ce);
      } else A.update(void 0, !!ce);
      X = !0;
    }, clear: function() {
      c.forEach(function(J) {
        return J.unsubscribe();
      }), c.clear(), s.clear(), A.clear(), I.debug.clear(), ee(), l.next(s.size);
    }, syncVisibility: function() {
      b.state.radiusMax === 0 && (E = !0, B = 0), A.syncVisibility() && I.debug.isEnabled && I.debug.update(), ee();
    }, requestDraw: ee, tick: ie, animate: function() {
      Q = !1, S.start(li()), $ === 0 && ae();
    }, resetTime: function(J) {
      d = J, S.start(J);
    }, pause: function(J) {
      J === void 0 && (J = !1), Q = J, LQ($), $ = 0;
    }, resume: function() {
      Q = !1;
    }, identify: se, getPosition: function(J, ce) {
      var de = b;
      return n.isContextLost ? void 0 : M.getPosition(J, ce, de);
    }, mark: function(J, ce) {
      U.push([J, ce]);
    }, getLoci: V, handleResize: Ne, requestResize: function() {
      O = !0;
    }, requestCameraReset: function(J) {
      B = J == null ? void 0 : J.durationMs, N = J == null ? void 0 : J.snapshot, E = !0;
    }, camera: b, boundingSphere: A.boundingSphere, boundingSphereVisible: A.boundingSphereVisible, get notifyDidDraw() {
      return z;
    }, set notifyDidDraw(J) {
      z = J;
    }, didDraw: f, commited: m, reprCount: l, resized: Je, setProps: function(J, ce) {
      var de, ve, he;
      ce === void 0 && (ce = !1);
      var Se = typeof J == "function" ? H_(Ze(), J) : J, Re = /* @__PURE__ */ Object.create(null);
      if (Se.camera && Se.camera.mode !== void 0 && Se.camera.mode !== b.state.mode && (Re.mode = Se.camera.mode), Se.cameraFog !== void 0 && Se.cameraFog.params) {
        var Ve = Se.cameraFog.name === "on" ? Se.cameraFog.params.intensity : 0;
        Ve !== b.state.fog && (Re.fog = Ve);
      }
      if (Se.cameraClipping !== void 0 && (Se.cameraClipping.far !== void 0 && Se.cameraClipping.far !== b.state.clipFar && (Re.clipFar = Se.cameraClipping.far), Se.cameraClipping.radius !== void 0)) {
        var ze = A.boundingSphere.radius / 100 * (100 - Se.cameraClipping.radius);
        ze > 0 && ze !== Re.radius && (Re.radius = Math.max(ze, 0.01));
      }
      Object.keys(Re).length > 0 && b.setState(Re), !((de = Se.camera) === null || de === void 0) && de.helper && I.camera.setProps(Se.camera.helper), ((ve = Se.camera) === null || ve === void 0 ? void 0 : ve.manualReset) !== void 0 && (u.camera.manualReset = Se.camera.manualReset), ((he = Se.camera) === null || he === void 0 ? void 0 : he.stereo) !== void 0 && Object.assign(u.camera.stereo, Se.camera.stereo), Se.cameraResetDurationMs !== void 0 && (u.cameraResetDurationMs = Se.cameraResetDurationMs), Se.transparentBackground !== void 0 && (u.transparentBackground = Se.transparentBackground), Se.viewport !== void 0 && (u.viewport === Se.viewport || u.viewport.name === Se.viewport.name && ib(u.viewport.params, Se.viewport.params) || (u.viewport = Se.viewport, nt(), re())), Se.postprocessing && Object.assign(u.postprocessing, Se.postprocessing), Se.marking && Object.assign(u.marking, Se.marking), Se.multiSample && Object.assign(u.multiSample, Se.multiSample), Se.renderer && D.setProps(Se.renderer), Se.trackball && S.setProps(Se.trackball), Se.interaction && F.setProps(Se.interaction), Se.debug && I.debug.setProps(Se.debug), Se.handle && I.handle.setProps(Se.handle), Re.mode === "orthographic" && (u.camera.stereo.name = "off"), ce || ee();
    }, getImagePass: function(J) {
      return J === void 0 && (J = {}), new EQ(n, D, A, b, I, a.draw.wboitEnabled, J);
    }, getRenderObjects: function() {
      var J = [];
      return A.forEach(function(ce, de) {
        return J.push(de);
      }), J;
    }, get props() {
      return Ze();
    }, get input() {
      return i;
    }, get stats() {
      return D.stats;
    }, get interaction() {
      return F.events;
    }, dispose: function() {
      Fe.unsubscribe(), U = [], A.clear(), I.debug.clear(), S.dispose(), D.dispose(), F.dispose();
    } };
    function nt() {
      var J = g, ce = h, de = y, ve = x;
      u.viewport.name === "canvas" ? (g = 0, h = 0, y = v.drawingBufferWidth, x = v.drawingBufferHeight) : u.viewport.name === "static-frame" ? (g = u.viewport.params.x * n.pixelRatio, x = u.viewport.params.height * n.pixelRatio, h = v.drawingBufferHeight - x - u.viewport.params.y * n.pixelRatio, y = u.viewport.params.width * n.pixelRatio) : u.viewport.name === "relative-frame" && (g = Math.round(u.viewport.params.x * v.drawingBufferWidth), x = Math.round(u.viewport.params.height * v.drawingBufferHeight), h = Math.round(v.drawingBufferHeight - x - u.viewport.params.y * v.drawingBufferHeight), y = Math.round(u.viewport.params.width * v.drawingBufferWidth)), J === g && ce === h && de === y && ve === x || (j = !0);
    }
    function re() {
      M.setViewport(g, h, y, x), D.setViewport(g, h, y, x), Vi.set(b.viewport, g, h, y, x), Vi.set(S.viewport, g, h, y, x);
    }
  };
})(r6 || (r6 = {}));
var ww = w(), Dw = w(), V4 = w(), Iw = w(), Ew = w();
function n6(e, t, r, n, i) {
  var a = [];
  return t.conformation.position(t.elements[r], V4), n.conformation.position(n.elements[i], Iw), w.sub(ww, Iw, V4), $l(e, t, r, function(o, u) {
    Br(o, u) !== "H" && (o.conformation.position(o.elements[u], Ew), w.sub(Dw, Ew, V4), a.push(w.angle(ww, Dw)));
  }), a;
}
var GQ = /* @__PURE__ */ new Set(["LI", "NA", "K", "RB", "CS", "FR"]), VQ = /* @__PURE__ */ new Set(["BE", "MG", "CA", "SR", "BA", "RA"]), UQ = /* @__PURE__ */ new Set(["ZN", "GA", "CD", "IN", "SN", "HG", "TI", "PB", "BI", "PO", "CN"]), HQ = /* @__PURE__ */ new Set(["F", "CL", "BR", "I", "AT"]);
function qQ(e) {
  return HQ.has(e);
}
function SP(e) {
  var t = im(e);
  return t >= 21 && t <= 29 || t >= 39 && t <= 47 || t >= 72 && t <= 79 || t >= 104 && t <= 108;
}
function KQ(e) {
  return function(t) {
    return GQ.has(t);
  }(e) || function(t) {
    return VQ.has(t);
  }(e) || function(t) {
    var r = im(t);
    return r >= 57 && r <= 71;
  }(e) || function(t) {
    var r = im(t);
    return r >= 89 && r <= 103;
  }(e) || SP(e) || function(t) {
    return UQ.has(t);
  }(e);
}
var U4 = new Dt.ElementBondIterator(), H4 = new Dt.ElementBondIterator(), s1 = new Dt.ElementBondIterator(), q4 = new Dt.ElementBondIterator();
function XQ(e, t, r, n) {
  var i = Cw(e, t, r, "H"), a = Br(t, r), o = q_(t, r), u = n.assignCharge === "always" || n.assignCharge === "auto" && o === 0, s = !["sdf", "mol"].includes(t.model.sourceData.kind) && (n.assignH === "always" || n.assignH === "auto" && i === 0), c = pm(e, t, r), l = function(x, A, b) {
    for (var _ = 0, S = A.bonds, D = S.offset, I = S.edgeProps, M = I.flags, F = I.order, P = D[b], E = D[b + 1]; P < E; ++P) cr.isCovalent(M[P]) && (_ += F[P]);
    return x.interUnitBonds.getEdgeIndices(b, A.id).forEach(function(B) {
      var N = x.interUnitBonds.edges[B];
      cr.isCovalent(N.props.flag) && (_ += N.props.order);
    }), _;
  }(e, t, r), d = function(x, A, b) {
    var _ = Br(A, b), S = _ === "O" || _ === "N";
    if (S && pm(x, A, b) === 4) return !1;
    for (U4.setElement(x, A, b); U4.hasNext; ) {
      var D = U4.move();
      if (D.order > 1) return !0;
      if (S) {
        var I = Br(D.otherUnit, D.otherIndex);
        for (H4.setElement(x, D.otherUnit, D.otherIndex); H4.hasNext; ) {
          var M = H4.move();
          if (M.order > 1) {
            if ((I === "P" || I === "S") && Br(M.otherUnit, M.otherIndex) === "O") continue;
            return !0;
          }
        }
      }
    }
    return !1;
  }(e, t, r), f = l - c > 0, m = 0, v = 8;
  switch (a) {
    case "H":
      u && (c === 0 ? (o = 1, v = 0) : c === 1 && (o = 0, v = 1));
      break;
    case "C":
      u && (o = 0), s && (m = Math.max(0, 4 - l - Math.abs(o))), v = fv(c + m + Math.max(0, -o));
      break;
    case "N":
      if (u) if (s) if (d && l < 4) o = c - i == 1 && l - i == 2 ? 1 : 0;
      else for (s1.setElement(e, t, r); s1.hasNext; ) {
        var p = s1.move(), g = Br(p.otherUnit, p.otherIndex);
        if (g === "S" || KQ(g) || cr.is(p.type, 32)) {
          o = 0;
          break;
        }
        o = 1;
      }
      else o = l - 3;
      s && (m = Math.max(0, 3 - l + o)), v = fv(d && !f ? c + m - o : c + m + 1 - o);
      break;
    case "O":
      if (u && (s || (o = l - 2), l === 1)) {
        s1.setElement(e, t, r);
        e: for (; s1.hasNext; ) {
          var h = s1.move();
          for (q4.setElement(e, h.otherUnit, h.otherIndex); q4.hasNext; ) {
            var y = q4.move();
            if ((y.otherUnit !== t || y.otherIndex !== r) && Br(y.otherUnit, y.otherIndex) === "O" && y.order === 2) {
              o = -1;
              break e;
            }
          }
        }
      }
      s && (m = Math.max(0, 2 - l + o)), v = fv(d && !f ? c + m - o + 1 : c + m - o + 2);
      break;
    case "S":
      u && (s || (o = l <= 3 && Cw(e, t, r, "O") === 0 ? l - 2 : 0)), s && l < 2 && (m = Math.max(0, 2 - l + o)), l <= 3 && (v = fv(c + m - o + 2));
      break;
    case "F":
    case "CL":
    case "BR":
    case "I":
    case "AT":
      u && (o = l - 1);
      break;
    case "LI":
    case "NA":
    case "K":
    case "RB":
    case "CS":
    case "FR":
      u && (o = 1 - l);
      break;
    case "BE":
    case "MG":
    case "CA":
    case "SR":
    case "BA":
    case "RA":
      u && (o = 2 - l);
      break;
    default:
      Ir && console.warn("Requested charge, protonation for an unhandled element", a);
  }
  return [o, m, m + i, v];
}
function jQ(e, t, r) {
  for (var n = t.elements.length, i = new Int8Array(n), a = new Int8Array(n), o = new Int8Array(n), u = new Int8Array(n), s = 0; s < n; ++s) {
    var c = XQ(e, t, s, r), l = c[0], d = c[1], f = c[2], m = c[3];
    i[s] = l, a[s] = d, o[s] = f, u[s] = m;
  }
  return { charge: i, implicitH: a, totalH: o, idealGeometry: u };
}
var CP = { assignCharge: G.Select("auto", [["always", "always"], ["auto", "auto"], ["never", "never"]]), assignH: G.Select("auto", [["always", "always"], ["auto", "auto"], ["never", "never"]]) };
function YQ(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o, u, s;
    return ye(this, function(c) {
      for (n = R(R({}, G.getDefaultValues(CP)), r), i = /* @__PURE__ */ new Map(), a = 0, o = t.units.length; a < o; ++a) u = t.units[a], Be.isAtomic(u) && (s = jQ(t, u, n), i.set(u.id, s));
      return [2, i];
    });
  });
}
var Ur, i6, a6, K4 = R({}, CP), Pm = Y1.createProvider({ label: "Valence Model", descriptor: rs({ name: "molstar_computed_valence_model" }), type: "local", defaultParams: K4, getParams: function(e) {
  return K4;
}, isApplicable: function(e) {
  return !0;
}, obtain: function(e, t, r) {
  return _e(void 0, 0, void 0, function() {
    var n, i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return n = R(R({}, G.getDefaultValues(K4)), r), i = {}, [4, YQ(e.runtime, t, n)];
        case 1:
          return [2, (i.value = a.sent(), i)];
      }
    });
  });
} });
(function(e) {
  function t(a, o) {
    for (var u = new Int32Array(o + 1), s = new Int32Array(o), c = new Int32Array(o), l = a.members, d = a.count, f = a.offsets, m = 0, v = f[d]; m < v; ++m) ++c[l[m]];
    var p = 0;
    for (m = 0; m < o; m++) u[m] = p, p += c[m];
    u[o] = p;
    var g = new Int32Array(p);
    for (m = 0; m < d; ++m) for (var h = f[m], y = f[m + 1]; h < y; ++h) {
      var x = l[h];
      g[u[x] + s[x]] = m, ++s[x];
    }
    return { indices: g, offsets: u };
  }
  function r(a, o) {
    for (var u, s = a.count, c = a.types, l = [], d = 0; d < s; ++d) o.has(c[d]) && l.push(d);
    var f = qe.ofSortedArray(l);
    return { indices: f, get lookup3d() {
      if (!u) {
        var m = { x: a.x, y: a.y, z: a.z, indices: f };
        u = lf(m, X1(m));
      }
      return u;
    } };
  }
  e.setPosition = function(a, o, u, s) {
    return w.set(a, s.x[u], s.y[u], s.z[u]), w.transformMat4(a, a, o.conformation.operator.matrix), a;
  }, e.createElementsIndex = t, e.create = function(a, o) {
    var u, s;
    return R(R({}, o), { get lookup3d() {
      if (!u) {
        var c = { x: o.x, y: o.y, z: o.z, indices: Le.ofBounds(0, o.count) };
        u = lf(c, X1(c));
      }
      return u;
    }, get elementsIndex() {
      return s || (s = t(o, a));
    }, subset: function(c) {
      return r(o, c);
    } });
  }, e.createSubset = r, e.Info = function(a, o, u) {
    var s = Pm.get(a).value;
    if (!s || !s.has(o.id)) throw new Error("valence model required");
    return { unit: o, types: u.types, feature: -1, x: u.x, y: u.y, z: u.z, members: u.members, offsets: u.offsets, idealGeometry: s.get(o.id).idealGeometry };
  }, e.position = function(a, o) {
    return w.set(a, o.x[o.feature], o.y[o.feature], o.z[o.feature]), w.transformMat4(a, a, o.unit.conformation.operator.matrix), a;
  };
  var n = w(), i = w();
  e.distance = function(a, o) {
    var u = a.members[a.offsets[a.feature]], s = o.members[o.offsets[o.feature]];
    return a.unit.conformation.position(a.unit.elements[u], n), o.unit.conformation.position(o.unit.elements[s], i), w.distance(n, i);
  }, e.Provider = function(a, o) {
    return { types: new Set(a), add: o };
  };
})(Ur || (Ur = {})), function(e) {
  e.create = function(t, r, n) {
    t === void 0 && (t = 2048), r === void 0 && (r = 1024);
    var i = Oe.create(Float32Array, 1, r, n ? n.x : t), a = Oe.create(Float32Array, 1, r, n ? n.y : t), o = Oe.create(Float32Array, 1, r, n ? n.z : t), u = Oe.create(Uint8Array, 1, r, n ? n.types : t), s = Oe.create(Uint8Array, 1, r, n ? n.groups : t), c = Oe.create(Uint32Array, 1, r, n ? n.offsets : t), l = Oe.create(Uint32Array, 1, r, n ? n.members : t), d = { x: 0, y: 0, z: 0, offset: 0, count: 0 };
    return { startState: function() {
      d.x = 0, d.y = 0, d.z = 0, d.offset = l.elementCount, d.count = 0;
    }, pushMember: function(f, m, v, p) {
      Oe.add(l, p), d.x += f, d.y += m, d.z += v, d.count += 1;
    }, finishState: function(f, m) {
      var v = d.count;
      v !== 0 && (Oe.add(u, f), Oe.add(s, m), Oe.add(i, d.x / v), Oe.add(a, d.y / v), Oe.add(o, d.z / v), Oe.add(c, d.offset));
    }, add: function(f, m, v, p, g, h) {
      Oe.add(u, f), Oe.add(s, m), Oe.add(i, v), Oe.add(a, p), Oe.add(o, g), Oe.add(c, l.elementCount), Oe.add(l, h);
    }, getFeatures: function(f) {
      Oe.add(c, l.elementCount);
      var m = Oe.compact(i, !0), v = Oe.compact(a, !0), p = Oe.compact(o, !0), g = i.elementCount;
      return Ur.create(f, { x: m, y: v, z: p, count: g, types: Oe.compact(u, !0), groups: Oe.compact(s, !0), offsets: Oe.compact(c, !0), members: Oe.compact(l, !0) });
    } };
  };
}(i6 || (i6 = {})), function(e) {
  e.createElementsIndex = function(t, r, n) {
    for (var i = new Int32Array(n + 1), a = new Int32Array(n), o = new Int32Array(n), u = r.members, s = r.offsets, c = 0, l = 2 * t.edgeCount; c < l; ++c)
      if (!((p = t.a[c]) > (g = t.b[c]))) {
        for (var d = s[p], f = s[p + 1]; d < f; ++d) ++o[u[d]];
        for (d = s[g], f = s[g + 1]; d < f; ++d) ++o[u[d]];
      }
    var m = 0;
    for (c = 0; c < n; c++) i[c] = m, m += o[c];
    i[n] = m;
    var v = new Int32Array(m);
    for (c = 0, l = 2 * t.edgeCount; c < l; ++c) {
      var p, g;
      if (!((p = t.a[c]) > (g = t.b[c]))) {
        for (d = s[p], f = s[p + 1]; d < f; ++d)
          v[i[h = u[d]] + a[h]] = c, ++a[h];
        for (d = s[g], f = s[g + 1]; d < f; ++d) {
          var h;
          v[i[h = u[d]] + a[h]] = c, ++a[h];
        }
      }
    }
    return { indices: v, offsets: i };
  };
}(a6 || (a6 = {}));
var no, gr, WQ = function(e) {
  function t(r, n) {
    var i = e.call(this, r) || this;
    i.elementKeyIndex = /* @__PURE__ */ new Map();
    for (var a = 0, o = i.edges.length; a < o; ++a) for (var u = i.edges[a], s = u.unitA, c = u.indexA, l = n.get(s), d = l.offsets, f = l.members, m = d[c], v = d[c + 1]; m < v; ++m) {
      var p = i.getElementKey(f[m], s), g = i.elementKeyIndex.get(p);
      g === void 0 ? i.elementKeyIndex.set(p, [a]) : g.push(a);
    }
    return i;
  }
  return ga(t, e), t.prototype.getContactIndicesForElement = function(r, n) {
    return this.elementKeyIndex.get(this.getElementKey(r, n.id)) || [];
  }, t.prototype.getElementKey = function(r, n) {
    return "".concat(r, "|").concat(n);
  }, t;
}(df);
function o6(e) {
  switch (e) {
    case gr.HydrogenBond:
      return "Hydrogen Bond";
    case gr.Hydrophobic:
      return "Hydrophobic Contact";
    case gr.HalogenBond:
      return "Halogen Bond";
    case gr.Ionic:
      return "Salt Bridge";
    case gr.MetalCoordination:
      return "Metal Bond";
    case gr.CationPi:
      return "Cation-Pi Interaction";
    case gr.PiStacking:
      return "Pi Stacking";
    case gr.WeakHydrogenBond:
      return "Weak Hydrogen Bond";
    case gr.Unknown:
      return "Unknown Interaction";
  }
}
(function(e) {
  e[e.None = 0] = "None", e[e.Filtered = 1] = "Filtered";
})(no || (no = {})), function(e) {
  e[e.Unknown = 0] = "Unknown", e[e.Ionic = 1] = "Ionic", e[e.CationPi = 2] = "CationPi", e[e.PiStacking = 3] = "PiStacking", e[e.HydrogenBond = 4] = "HydrogenBond", e[e.HalogenBond = 5] = "HalogenBond", e[e.Hydrophobic = 6] = "Hydrophobic", e[e.MetalCoordination = 7] = "MetalCoordination", e[e.WeakHydrogenBond = 8] = "WeakHydrogenBond";
}(gr || (gr = {}));
var wP = { distanceMax: G.Numeric(2.8, { min: 1, max: 5, step: 0.1 }), backbone: G.Boolean(!0, { description: "Include backbone-to-backbone hydrogen bonds" }), accAngleDevMax: G.Numeric(90, { min: 0, max: 180, step: 1 }, { description: "Max deviation from ideal acceptor angle" }), donAngleDevMax: G.Numeric(120, { min: 0, max: 180, step: 1 }, { description: "Max deviation from ideal donor angle" }), accOutOfPlaneAngleMax: G.Numeric(90, { min: 0, max: 180, step: 1 }), donOutOfPlaneAngleMax: G.Numeric(45, { min: 0, max: 180, step: 1 }) }, DP = R(R({}, wP), { water: G.Boolean(!1, { description: "Include water-to-water hydrogen bonds" }), sulfurDistanceMax: G.Numeric(3.4, { min: 1, max: 5, step: 0.1 }) }), ZQ = G.getDefaultValues(DP), IP = R({}, wP), QQ = G.getDefaultValues(IP);
function Mw(e, t) {
  return e.model.atomicHierarchy.derived.residue.moleculeType[e.residueIndex[e.elements[t]]] === 2;
}
function Tw(e, t) {
  return h_.has(AP(e, t));
}
function EP(e) {
  return { includeBackbone: e.backbone, maxAccAngleDev: Bn(e.accAngleDevMax), maxDonAngleDev: Bn(e.donAngleDevMax), maxAccOutOfPlaneAngle: Bn(e.accOutOfPlaneAngleMax), maxDonOutOfPlaneAngle: Bn(e.donOutOfPlaneAngleMax) };
}
function MP(e, t, r, n) {
  var i = t.members[t.offsets[t.feature]], a = r.members[r.offsets[r.feature]];
  if (n.includeBackbone || (o = t.unit, u = i, s = r.unit, c = a, !Tw(o, u) || !Tw(s, c))) {
    var o, u, s, c, l = n6(e, t.unit, i, r.unit, a);
    if (xa(l[0]) >= 120 && xa(l[0]) <= 180) return !0;
  }
}
function JQ(e, t, r, n, i) {
  var a = t.types[t.feature], o = r.types[r.feature];
  if (s = o, (u = a) === 5 && s === 4 || u === 4 && s === 5) {
    var u, s, c, l, d, f, m = o === 5 ? [t, r] : [r, t], v = m[0], p = m[1], g = v.members[v.offsets[v.feature]], h = p.members[p.offsets[p.feature]];
    if (!(n > (Br(v.unit, g) === "S" || Br(p.unit, h) === "S" ? i.maxSulfurDistSq : i.maxDistSq)) && (i.includeWater || (c = v.unit, l = g, d = p.unit, f = h, !Mw(c, l) || !Mw(d, f))) && MP(e, v, p, i)) return gr.HydrogenBond;
  }
}
var $Q = Ur.Provider([4], function(e, t, r) {
  for (var n = t.elements, i = t.model.atomicConformation, a = i.x, o = i.y, u = i.z, s = function(d, f) {
    var m = Br(t, d), v = !1;
    m === "H" && (Ds(t, d, function(p, g) {
      var h = Br(p, g);
      h !== "N" && h !== "O" && h !== "S" || (v = !0);
    }), v && r.add(4, 0, a[n[d]], o[n[d]], u[n[d]], d));
  }, c = 0, l = n.length; c < l; ++c) s(c);
}), eJ = Ur.Provider([9], function(e, t, r) {
  for (var n = t.elements, i = t.model.atomicConformation, a = i.x, o = i.y, u = i.z, s = function(d, f) {
    var m = Br(t, d), v = !1;
    if (m === "H") {
      var p = [];
      if (Ds(t, d, function(h, y) {
        Br(h, y) === "C" && (function(x, A) {
          var b = x.rings.elementAromaticRingIndices, _ = b.get(A);
          return _ !== void 0;
        }(h, y) ? v = !0 : p.push(y));
      }), !v && p.length === 1) {
        var g = 0;
        Ds(t, p[0], function(h, y) {
          Br(h, y) === "F" && g++;
        }), g === 2 && (v = !0);
      }
      v && r.add(9, 0, a[n[d]], o[n[d]], u[n[d]], d);
    }
  }, c = 0, l = n.length; c < l; ++c) s(c);
}), tJ = Ur.Provider([5], function(e, t, r) {
  for (var n = function(y, x) {
    var A = Pm.get(y).value;
    if (!A) throw Error("expected valence model to be available");
    var b = A.get(x.id);
    if (!b) throw Error("expected valence model for unit to be available");
    return b;
  }(e, t), i = n.charge, a = n.implicitH, o = n.idealGeometry, u = t.elements, s = t.model.atomicConformation, c = s.x, l = s.y, d = s.z, f = function(y) {
    r.add(5, 0, c[u[y]], l[u[y]], d[u[y]], y);
  }, m = 0, v = u.length; m < v; ++m) {
    var p = Br(t, m);
    if (p === "O") f(m);
    else if (p === "N") {
      if (i[m] < 1) {
        var g = pm(e, t, m) + a[m], h = o[m];
        (h === 4 && g < 4 || h === 3 && g < 3 || h === 2 && g < 2) && f(m);
      }
    } else p === "S" ? q_(t, m) === -1 && f(m) : p === "F" && f(m);
  }
}), rJ = { name: "hydrogen-bonds", params: DP, createTester: function(e) {
  var t = Math.max(e.distanceMax, e.sulfurDistanceMax), r = function(n) {
    return R(R({}, EP(n)), { includeWater: n.water, maxSulfurDistSq: n.sulfurDistanceMax * n.sulfurDistanceMax, maxDistSq: n.distanceMax * n.distanceMax });
  }(e);
  return { maxDistance: t, requiredFeatures: /* @__PURE__ */ new Set([4, 5]), getType: function(n, i, a, o) {
    return JQ(n, i, a, o, r);
  } };
} }, nJ = { name: "weak-hydrogen-bonds", params: IP, createTester: function(e) {
  var t = EP(e);
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([9, 5]), getType: function(r, n, i, a) {
    return function(o, u, s, c, l) {
      var d = u.types[u.feature], f = s.types[s.feature];
      if (v = f, (m = d) === 9 && v === 5 || m === 5 && v === 9) {
        var m, v, p = f === 5 ? [u, s] : [s, u];
        if (MP(o, p[0], p[1], l)) return gr.WeakHydrogenBond;
      }
    }(r, n, i, 0, t);
  } };
} }, TP = { distanceMax: G.Numeric(3.5, { min: 1, max: 5, step: 0.1 }), angleMax: G.Numeric(60, { min: 0, max: 60, step: 1 }) }, iJ = G.getDefaultValues(TP), aJ = ["CL", "BR", "I", "AT"], oJ = Bn(180), uJ = Bn(120), sJ = Ur.Provider([6], function(e, t, r) {
  for (var n = t.elements, i = t.model.atomicConformation, a = i.x, o = i.y, u = i.z, s = 0, c = n.length; s < c; ++s) {
    var l = Br(t, s);
    aJ.includes(l) && r.add(6, 0, a[n[s]], o[n[s]], u[n[s]], s);
  }
}), cJ = Ur.Provider([7], function(e, t, r) {
  for (var n = function(S, D) {
    var I = Pm.get(S).value;
    if (!I) throw Error("expected valence model to be available");
    var M = I.get(D.id);
    if (!M) throw Error("expected valence model for unit to be available");
    return M;
  }(e, t), i = n.charge, a = n.implicitH, o = n.idealGeometry, u = t.elements, s = t.model.atomicConformation, c = s.x, l = s.y, d = s.z, f = function(S) {
    r.add(7, 0, c[u[S]], l[u[S]], d[u[S]], S);
  }, m = 0, v = u.length; m < v; ++m) {
    var p = Br(t, m);
    if (p === "O") f(m);
    else if (p === "N") {
      if (i[m] < 1) {
        var g = pm(e, t, m) + a[m], h = o[m];
        (h === 4 && g < 4 || h === 3 && g < 3 || h === 2 && g < 2) && f(m);
      }
    } else p === "S" ? q_(t, m) === -1 && f(m) : p === "F" && f(m);
  }
  for (var y = 0, x = t.rings.aromaticRings; y < x.length; y++) {
    var A = x[y], b = t.rings.all[A];
    for (r.startState(), m = 0, v = b.length; m < v; ++m) {
      var _ = b[m];
      r.pushMember(c[u[_]], l[u[_]], d[u[_]], _);
    }
    r.finishState(7, 0);
  }
}), lJ = { name: "halogen-bonds", params: TP, createTester: function(e) {
  var t = function(r) {
    return { angleMax: Bn(r.angleMax) };
  }(e);
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([6, 7]), getType: function(r, n, i) {
    return function(a, o, u, s) {
      var c = o.types[o.feature], l = u.types[u.feature];
      if (f = l, (d = c) === 7 && f === 6 || d === 6 && f === 7) {
        var d, f, m = c === 6 ? [o, u] : [u, o], v = m[0], p = m[1], g = v.members[v.offsets[v.feature]], h = p.members[p.offsets[p.feature]], y = n6(a, v.unit, g, p.unit, h);
        if (y.length === 1 && !(oJ - y[0] > s.angleMax)) {
          var x = n6(a, p.unit, h, v.unit, g);
          if (x.length !== 0 && !x.some(function(A) {
            return uJ - A > s.angleMax;
          })) return gr.HalogenBond;
        }
      }
    }(r, n, i, t);
  } };
} }, PP = { distanceMax: G.Numeric(5, { min: 0, max: 8, step: 0.1 }) }, dJ = G.getDefaultValues(PP), BP = { distanceMax: G.Numeric(5.5, { min: 1, max: 8, step: 0.1 }), offsetMax: G.Numeric(2, { min: 0, max: 4, step: 0.1 }), angleDevMax: G.Numeric(30, { min: 0, max: 180, step: 1 }) }, fJ = G.getDefaultValues(BP), FP = { distanceMax: G.Numeric(6.6, { min: 1, max: 8, step: 0.1 }), offsetMax: G.Numeric(2, { min: 0, max: 4, step: 0.1 }) }, pJ = G.getDefaultValues(FP);
function NP(e, t) {
  var r = Pm.get(e).value;
  if (!r) throw Error("expected valence model to be available");
  var n = r.get(t.id);
  if (!n) throw Error("expected valence model for unit to be available");
  return n;
}
var Pw = w(), Bw = w(), o0 = w(), Kl = w(), af = w(), pv = w();
function u6(e, t) {
  var r = t.unit, n = t.feature, i = t.offsets, a = t.members, o = r.elements, u = i[n];
  return t.unit.conformation.position(o[a[u]], o0), t.unit.conformation.position(o[a[u + 1]], Kl), t.unit.conformation.position(o[a[u + 2]], af), w.triangleNormal(e, o0, Kl, af);
}
var X4 = Bn(180), mv = Bn(90), Yp = w(), j4 = w();
function mJ(e, t, r, n, i) {
  var a, o, u = t.types[t.feature], s = r.types[r.feature];
  if (o = s, ((a = u) === 2 && o === 1 || a === 1 && o === 2) && function(c, l, d) {
    for (var f = c.feature, m = c.offsets, v = c.members, p = l.feature, g = l.offsets, h = l.members, y = m[f], x = m[f + 1]; y < x; ++y) {
      var A = v[y];
      c.unit.conformation.position(c.unit.elements[A], Pw);
      for (var b = g[p], _ = g[p + 1]; b < _; ++b) {
        var S = h[b];
        if (l.unit.conformation.position(l.unit.elements[S], Bw), w.squaredDistance(Pw, Bw) < d) return !0;
      }
    }
    return !1;
  }(t, r, i.distanceMaxSq)) return gr.Ionic;
}
function hJ(e, t, r, n, i) {
  var a, o, u = t.types[t.feature], s = r.types[r.feature];
  if (o = s, (a = u) === 3 && o === 1 || a === 1 && o === 3) {
    var c = u === 3 ? [t, r] : [r, t], l = c[0], d = c[1];
    u6(Yp, l);
    var f = function(m, v, p) {
      return Ur.position(o0, m), Ur.position(Kl, v), w.sub(af, o0, Kl), w.projectOnPlane(pv, af, p), w.add(pv, pv, Kl), w.distance(pv, Kl);
    }(d, l, Yp);
    if (f <= i.offsetMax) return gr.CationPi;
  }
}
var vJ = Ur.Provider([2], function(e, t, r) {
  for (var n = NP(e, t).charge, i = t.elements, a = t.model.atomicConformation, o = a.x, u = a.y, s = a.z, c = Zt.transientSegments(t.model.atomicHierarchy.residueAtomSegments, i); c.hasNext; ) for (var l = c.move(), d = l.start, f = l.end, m = function(p) {
    if (n[p] < 0) r.add(2, 0, o[i[p]], u[i[p]], s[i[p]], p);
    else if (Br(t, p) === "O") {
      var g = -1, h = 0;
      if (Ds(t, p, function(M, F) {
        Br(t, F) === "C" && (g = F, h++);
      }), h === 1 && g !== -1) {
        var y = /* @__PURE__ */ new Set(), x = 0;
        if (Ds(t, g, function(M, F) {
          Br(t, F) === "O" && y.add(F);
        }), y.size === 2) {
          for (var A = t.bonds, b = !0, _ = 0, S = A.a.length; _ < S; _++) {
            var D = A.a[_], I = A.b[_];
            y.has(I) && D !== g && Br(t, D) !== "H" && (x = -100), A.edgeProps.order[_] === 2 && I === p && (b = !1), D === g && y.has(I) && A.edgeProps.order[_] === 2 && x++;
          }
          x === 1 && b && r.add(2, 0, o[i[p]], u[i[p]], s[i[p]], p);
        }
      }
    }
  }, v = d; v < f; ++v) m(v);
}), gJ = Ur.Provider([1], function(e, t, r) {
  for (var n = NP(e, t).charge, i = t.elements, a = t.model.atomicConformation, o = a.x, u = a.y, s = a.z, c = Zt.transientSegments(t.model.atomicHierarchy.residueAtomSegments, i); c.hasNext; ) for (var l = c.move(), d = l.start, f = l.end, m = function(p) {
    if (n[p] > 0) r.add(1, 0, o[i[p]], u[i[p]], s[i[p]], p);
    else if (Br(t, p) === "N") {
      var g = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Map();
      if (Ds(t, p, function(x, A) {
        Br(t, A) === "C" && g.add(A);
      }), !g.size) return "continue";
      g.forEach(function(x) {
        var A = /* @__PURE__ */ new Set();
        Ds(t, x, function(b, _) {
          Br(t, _) === "N" ? A.add(_) : g.delete(x);
        }), A.size !== 3 ? g.delete(x) : h.set(x, A);
      });
      var y = !1;
      if (!g.size) return "continue";
      g.forEach(function(x) {
        var A = t.bonds, b = h.get(x), _ = 0;
        if (b) {
          for (var S = function(M, F) {
            var P = A.a[M], E = A.b[M];
            if (P === x && b.has(E) && A.edgeProps.order[M] === 2) {
              E === p && (y = !0);
              var B = !0;
              Ds(t, E, function(N, O) {
                O !== x && Br(t, O) !== "H" && (B = !1);
              }), B && b.delete(E), _++;
            }
          }, D = 0, I = A.a.length; D < I; D++) S(D);
          _ !== 1 ? g.delete(x) : b.forEach(function(M) {
            var F = !0;
            Ds(t, M, function(P, E) {
              E !== x && Br(t, E) !== "H" && (F = !1);
            }), F && b.delete(M);
          }), b.size > 1 && g.delete(x);
        }
      }), g.size && y && r.add(1, 0, o[i[p]], u[i[p]], s[i[p]], p);
    }
  }, v = d; v < f; ++v) m(v);
}), yJ = Ur.Provider([3], function(e, t, r) {
  for (var n = t.elements, i = t.model.atomicConformation, a = i.x, o = i.y, u = i.z, s = 0, c = t.rings.aromaticRings; s < c.length; s++) {
    var l = c[s], d = t.rings.all[l];
    r.startState();
    for (var f = 0, m = d.length; f < m; ++f) {
      var v = d[f];
      r.pushMember(a[n[v]], o[n[v]], u[n[v]], v);
    }
    r.finishState(3, 0);
  }
}), bJ = { name: "ionic", params: PP, createTester: function(e) {
  var t = function(r) {
    return { distanceMaxSq: r.distanceMax * r.distanceMax };
  }(e);
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([2, 1]), getType: function(r, n, i, a) {
    return mJ(0, n, i, 0, t);
  } };
} }, _J = { name: "pi-stacking", params: BP, createTester: function(e) {
  var t = function(r) {
    return { offsetMax: r.offsetMax, angleDevMax: Bn(r.angleDevMax) };
  }(e);
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([3]), getType: function(r, n, i, a) {
    return function(o, u, s, c, l) {
      var d, f = u.types[u.feature], m = s.types[s.feature];
      if (d = m, f === 3 && d === 3) {
        u6(Yp, u), u6(j4, s);
        var v = w.angle(Yp, j4);
        Ur.position(o0, u), Ur.position(Kl, s), w.sub(af, o0, Kl);
        var p = w.angle(Yp, af), g = w.angle(j4, af), h = xa(p > mv ? X4 - p : p), y = xa(g > mv ? X4 - g : g), x = v <= l.angleDevMax || v >= X4 - l.angleDevMax ? "parallel" : v <= l.angleDevMax + mv && v >= mv - l.angleDevMax ? "t-shaped" : void 0, A = x === "parallel" ? [0, 33] : [0, 30];
        if (x && (h >= A[0] && h <= A[1] || y >= A[0] && y <= A[1])) return gr.PiStacking;
      }
    }(0, n, i, 0, t);
  } };
} }, xJ = { name: "cation-pi", params: FP, createTester: function(e) {
  var t = function(r) {
    return { offsetMax: r.offsetMax };
  }(e);
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([3, 1]), getType: function(r, n, i, a) {
    return hJ(0, n, i, 0, t);
  } };
} }, RP = { distanceMax: G.Numeric(3, { min: 1, max: 5, step: 0.1 }) }, AJ = G.getDefaultValues(RP), hv = { 7: 0.71, 8: 0.63, 16: 1.03, 17: 0.99, 35: 1.14, 53: 1.33, 12: 1.39, 23: 1.34, 24: 1.22, 25: 1.19, 26: 1.16, 27: 1.11, 28: 1.1, 29: 1.12, 30: 1.18, 44: 1.25, 45: 1.25, 75: 1.31, 76: 1.29, 78: 1.23, 79: 1.24 }, SJ = ["LI", "NA", "K", "RB", "CS", "MG", "CA", "SR", "BA", "AL", "GA", "IN", "TL", "SC", "SN", "PB", "BI", "SB", "HG"];
function Fw(e) {
  return !h_.has(e);
}
function CJ(e) {
  return h_.has(e);
}
function wJ(e) {
  return xK.has(e);
}
function Nw(e, t) {
  return e === 12 ? t === 11 || t === 12 : e === 13 ? t === 10 : void 0;
}
var vv, tp, c1, mr, Ea, Te, At, DJ = Ur.Provider([13, 12], function(e, t, r) {
  for (var n = t.elements, i = t.model.atomicConformation, a = i.x, o = i.y, u = i.z, s = 0, c = n.length; s < c; ++s) {
    var l = Br(t, s), d = 0;
    SJ.includes(l) ? d = 13 : (SP(l) || l === "ZN" || l === "CD") && (d = 12), d && r.add(d, 0, a[n[s]], o[n[s]], u[n[s]], s);
  }
}), IJ = Ur.Provider([10, 11], function(e, t, r) {
  for (var n = t.elements, i = t.model.atomicConformation, a = i.x, o = i.y, u = i.z, s = 0, c = n.length; s < c; ++s) {
    var l = Br(t, s), d = kQ(t, s), f = AP(t, s), m = !1, v = !1, p = wm.has(d), g = g_.has(d);
    p || g ? p ? l === "O" ? (["ASP", "GLU", "SER", "THR", "TYR", "ASN", "GLN"].includes(d) && Fw(f) || CJ(f)) && (m = !0, v = !0) : l !== "S" || d !== "CYS" && d !== "MET" ? l === "N" && d === "HIS" && Fw(f) && (m = !0) : (m = !0, v = !0) : g && (l === "O" && wJ(f) ? (m = !0, v = !0) : ["N3", "N4", "N7"].includes(f) ? m = !0 : ["O2", "O4", "O6"].includes(f) && (m = !0, v = !0)) : qQ(l) || l === "O" || l === "S" ? (m = !0, v = !0) : l === "N" && (m = !0), m && r.add(11, 0, a[n[s]], o[n[s]], u[n[s]], s), v && r.add(10, 0, a[n[s]], o[n[s]], u[n[s]], s);
  }
}), EJ = { name: "metal-coordination", params: RP, createTester: function(e) {
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([13, 12, 10, 11]), getType: function(t, r, n, i) {
    return function(a, o, u, s) {
      var c = o.types[o.feature], l = u.types[u.feature];
      if (Nw(c, l) || Nw(l, c)) {
        var d = j1[Br(o.unit, o.members[o.offsets[o.feature]])], f = j1[Br(u.unit, u.members[u.offsets[u.feature]])];
        if (d && f && hv[d] && hv[f]) {
          var m = hv[d] + hv[f] + 0.5, v = w.create(0, 0, 0), p = w.create(0, 0, 0);
          if (Ur.position(v, o), Ur.position(p, u), w.distance(v, p) > m) return;
        }
        return gr.MetalCoordination;
      }
    }(0, r, n);
  } };
} };
(function(e) {
  e.Pdb = "pdb", e.Sdf = "sdf", e.Mol = "mol", e.Mol2 = "mol2", e.MMCif = "mmcif", e.Gro = "gro", e.Xtc = "xtc", e.Dump = "dump", e.Xyz = "xyz", e.Cif = "cif", e.MCif = "mcif", e.POSCAR = "poscar", e.Material = "material", e.Pymatgen = "pymatgen";
})(mr || (mr = {})), function(e) {
  e.Molecular = "Molecular", e.Protein = "Protein", e.Chain = "Chain", e.Residue = "Residue", e.Ligand = "Ligand", e.Solvent = "Solvent", e.Water = "Water", e.Other = "Other", e.Metal = "Metal", e.Ions = "Ions", e.Atom = "Atom";
}(Ea || (Ea = {})), function(e) {
  e.Ribbon = "Ribbon", e.BallAndStick = "BallAndStick", e.Line = "Line", e.Stick = "Stick", e.CPK = "CPK", e.Label = "Label", e.Distance = "Distance", e.Angle = "Angle", e.Dihedral = "Dihedral", e.IntraInteractions = "IntraInteractions", e.BetweenInteractions = "BetweenInteractions", e.Pharmacophore = "Pharmacophore", e.Pocket = "Pocket", e.Surface = "Surface", e.IsoSurface = "IsoSurface", e.RotateArrow = "RotateArrow", e.MappingLine = "MappingLine", e.UnitCell = "UnitCell", e.CustomLines = "CustomLines", e.CustomPlanes = "CustomPlanes", e.Trajectory = "Trajectory";
}(Te || (Te = {})), function(e) {
  e.RIBBON = "Ribbon", e.ATOM = "Atom", e.SURFACE = "Surface";
}(At || (At = {}));
var Bl, xn = ((vv = {})[At.RIBBON] = [Te.Ribbon], vv[At.ATOM] = [Te.CPK, Te.Line, Te.Stick, Te.BallAndStick], vv[At.SURFACE] = [Te.Surface], vv);
(function(e) {
  e[e.Not = 0] = "Not", e[e.Include = 1] = "Include", e[e.BeIncluded = 2] = "BeIncluded", e[e.Cross = 3] = "Cross";
})(Bl || (Bl = {}));
var kr;
Te.Ribbon, Te.CPK, Te.Line, Te.Stick, Te.BallAndStick, Te.Surface;
var D1 = /* @__PURE__ */ new Set([Te.BallAndStick, Te.Line, Te.Stick, Te.CPK]), MJ = /* @__PURE__ */ new Set([Te.BallAndStick, Te.Line, Te.Stick]), u0 = /* @__PURE__ */ new Set([Te.Label, Te.Distance, Te.Angle, Te.Dihedral]), TJ = /* @__PURE__ */ new Set([Te.Surface, Te.Pharmacophore, Te.Pocket]);
(function(e) {
  e.Atom = "Atom", e.Residue = "Residue", e.Chain = "Chain", e.Molecular = "Molecular";
})(kr || (kr = {}));
var xs, PJ = ((tp = {})[kr.Atom] = "element", tp[kr.Residue] = "residue", tp[kr.Chain] = "chain", tp[kr.Molecular] = "entity", tp), BJ = { element: kr.Atom, residue: kr.Residue, chain: kr.Chain, entity: kr.Molecular };
(function(e) {
  e.HydrogenBonds = "hydrogen-bonds", e.WeakHydrogenBonds = "weak-hydrogen-bonds", e.HalogenBonds = "halogen-bonds", e.SaltBridge = "ionic", e.PiPiStacking = "pi-stacking", e.PiCations = "cation-pi", e.MetalBonds = "metal-coordination", e.Hydrophobic = "hydrophobic";
})(xs || (xs = {}));
var Wd, s6 = function(e) {
  var t, r = ((t = {})[xs.HydrogenBonds] = { name: "on", params: ZQ }, t[xs.WeakHydrogenBonds] = { name: "off", params: QQ }, t[xs.HalogenBonds] = { name: "on", params: iJ }, t[xs.SaltBridge] = { name: "on", params: dJ }, t[xs.PiPiStacking] = { name: "on", params: fJ }, t[xs.PiCations] = { name: "on", params: pJ }, t[xs.MetalBonds] = { name: "on", params: AJ }, t[xs.Hydrophobic] = { name: "off", params: {} }, t);
  return e && Object.keys(r).forEach(function(n) {
    r[n].name = e.includes(n) ? "on" : "off";
  }), r;
};
(function(e) {
  e[e.All = 0] = "All", e[e.Residues = 1] = "Residues", e[e.Water = 2] = "Water", e[e.SolventWithoutWater = 3] = "SolventWithoutWater", e[e.Solvent = 4] = "Solvent";
})(Wd || (Wd = {}));
var Wp, bi, Jd, FJ = ((c1 = {})[Wd.All] = [Ea.Protein, Ea.Water, Ea.Ligand, Ea.Solvent], c1[Wd.Residues] = [Ea.Protein], c1[Wd.Water] = [Ea.Water], c1[Wd.SolventWithoutWater] = [Ea.Solvent], c1[Wd.Solvent] = [Ea.Water, Ea.Solvent], c1);
(function(e) {
  e.Structure = "Structure", e.Measurement = "Measurement", e.Interaction = "Interaction", e.Bond = "Bond";
})(Wp || (Wp = {})), function(e) {
  e[e.NotHydrogen = -1] = "NotHydrogen", e[e.NonPolar = 0] = "NonPolar", e[e.Polar = 1] = "Polar", e[e.ConnectPolar = 2] = "ConnectPolar", e[e.ConnectNonPolar = 3] = "ConnectNonPolar";
}(bi || (bi = {})), function(e) {
  e.Drug = "drug", e.Material = "material";
}(Jd || (Jd = {}));
var ha = function(e) {
  if (e.kind === "element-loci") return e;
  if (e.kind === "structure-loci") return tt.toStructureElementLoci(e.structure);
  if (e.kind === "shape-loci") {
    var t, r = e.shape.sourceData, n = [];
    return r.infos ? n.push.apply(n, We([], r.infos, !0).map(function(i) {
      return i.loci;
    })) : r.pairs ? n.push.apply(n, r.pairs[0].loci) : r.triples ? n.push.apply(n, r.triples[0].loci) : r.quads && n.push.apply(n, r.quads[0].loci), n.forEach(function(i) {
      t = t ? Xe.union(t, ha(i)) : ha(i);
    }), t;
  }
}, ei = function(e, t) {
  var r = [], n = new Set(t), i = /* @__PURE__ */ new Set();
  return e.units.forEach(function(a) {
    if (!i.has(a.invariantId)) {
      i.add(a.invariantId);
      var o = [];
      a.elements.forEach(function(u, s) {
        t && !n.has(u) || o.push(s);
      }), o.length > 0 && r.push({ unit: a, indices: o });
    }
  }), Xe(e, r);
}, Gi = function(e) {
  var t = [];
  return e.elements.forEach(function(r) {
    t.push.apply(t, Le.toArray(r.indices).map(function(n) {
      return r.unit.elements[n];
    }).filter(function(n) {
      return n !== void 0;
    }));
  }), t;
}, NJ = function(e, t) {
  var r, n = mf.ofLoci(e);
  r = n.elementCount > 0 ? n.firstElementLoc : n.residueCount > 0 ? n.firstResidueLoc : n.chainCount > 0 ? n.firstChainLoc : n.unitCount > 0 ? n.firstUnitLoc : n.conformationCount > 0 ? n.firstConformationLoc : n.firstStructureLoc;
  var i = Qe.atom.em_confidence(r), a = Qe.atom.B_iso_or_equiv(r);
  switch (t) {
    case kr.Atom:
      return n.elementCount === 1 ? { x: Qe.atom.x(r), y: Qe.atom.y(r), z: Qe.atom.z(r), granularity: kr.Atom, atomName: Qe.atom.label_atom_id(r), atomId: Qe.atom.id(r), altId: Qe.atom.label_alt_id(r), residueName: Qe.atom.label_comp_id(r), residueId: Qe.residue.auth_seq_id(r), insertCode: Qe.residue.pdbx_PDB_ins_code(r), chainId: Qe.chain.label_asym_id(r), emConfidence: i, bfactor: a } : { granularity: kr.Residue, altId: Qe.atom.label_alt_id(r), residueName: Qe.atom.label_comp_id(r), residueId: Qe.residue.auth_seq_id(r), chainId: Qe.chain.label_asym_id(r), insertCode: Qe.residue.pdbx_PDB_ins_code(r), emConfidence: i, bfactor: a };
    case kr.Residue:
      return { granularity: kr.Residue, altId: Qe.atom.label_alt_id(r), residueName: Qe.atom.label_comp_id(r), residueId: Qe.residue.auth_seq_id(r), chainId: Qe.chain.label_asym_id(r), insertCode: Qe.residue.pdbx_PDB_ins_code(r), bfactor: a };
    case kr.Chain:
      return { granularity: kr.Chain, chainId: Qe.chain.label_asym_id(r) };
    case kr.Molecular:
      return { granularity: kr.Molecular };
    default:
      return {};
  }
}, RJ = function(e) {
  var t = e.elements[0], r = t.unitA, n = t.indexA, i = t.unitB, a = t.indexB, o = e.data.interactions, u = o.contacts, s = o.unitsContacts, c = o.unitsFeatures, l = c.get(r.id), d = l.members, f = l.offsets, m = c.get(i.id), v = m.members, p = m.offsets, g = -1;
  if (r === i) {
    var h = s.get(r.id), y = h.getDirectedEdgeIndex(n, a);
    g = h.edgeProps.type[y];
  } else
    y = u.getEdgeIndex(n, r.id, a, i.id), g = u.edges[y].props.type;
  var x = Dt.Location(e.data.structure, r, d[f[n]], e.data.structure, i, v[p[a]]), A = Xe(x.aStructure, [{ unit: x.aUnit, indices: Le.ofSingleton(x.aIndex) }]), b = Xe(x.bStructure, [{ unit: x.bUnit, indices: Le.ofSingleton(x.bIndex) }]), _ = mf.ofLoci(A), S = mf.ofLoci(b), D = _.firstElementLoc, I = S.firstElementLoc;
  return { infoA: { chainId: Qe.chain.label_asym_id(D), residueName: Qe.atom.label_comp_id(D), residueId: Qe.residue.auth_seq_id(D), atomName: Qe.atom.label_atom_id(D) }, infoB: { chainId: Qe.chain.label_asym_id(I), residueName: Qe.atom.label_comp_id(I), residueId: Qe.residue.auth_seq_id(I), atomName: Qe.atom.label_atom_id(I) }, interactionType: o6(g) };
}, OJ = function(e) {
  return fetch(e).then(function(t) {
    return t.text();
  });
}, LJ = function(e) {
  return fetch(e).then(function(t) {
    return t.blob();
  });
}, kJ = function(e) {
  return new Promise(function(t) {
    var r = new FileReader();
    r.onload = function(n) {
      return _e(this, 0, void 0, function() {
        return ye(this, function(i) {
          return t(r.result), [2];
        });
      });
    }, r.readAsText(e);
  });
}, of = function(e) {
  return _e(void 0, 0, void 0, function() {
    var t, r;
    return ye(this, function(n) {
      switch (n.label) {
        case 0:
          return typeof e != "string" ? [3, 4] : e.startsWith("http") || e.startsWith("https") ? [4, OJ(e)] : [3, 2];
        case 1:
          return r = n.sent(), [3, 3];
        case 2:
          r = e, n.label = 3;
        case 3:
          return t = r, [3, 6];
        case 4:
          return [4, kJ(e)];
        case 5:
          t = n.sent(), n.label = 6;
        case 6:
          return [2, t];
      }
    });
  });
}, zJ = function(e) {
  return _e(void 0, 0, void 0, function() {
    var t, r;
    return ye(this, function(n) {
      switch (n.label) {
        case 0:
          return typeof e != "string" ? [3, 2] : [4, LJ(e)];
        case 1:
          return t = n.sent(), [3, 4];
        case 2:
          return r = Blob.bind, [4, e.arrayBuffer()];
        case 3:
          t = new (r.apply(Blob, [void 0, [n.sent()]]))(), n.label = 4;
        case 4:
          return [2, t];
      }
    });
  });
};
function GJ(e, t, r) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(n) {
      return [2, new Promise(function(i, a) {
        var o = function(p) {
          p ? i(p) : a("no blob returned");
        };
        if (HTMLCanvasElement.prototype.toBlob) e.toBlob(o, t, r);
        else {
          for (var u = atob(e.toDataURL(t, r).split(",")[1]), s = u.length, c = s >> 2, l = new Uint8Array(s), d = new Uint32Array(l.buffer, 0, c), f = 0, m = 0; m < c; ++m) d[m] = u.charCodeAt(f++) | u.charCodeAt(f++) << 8 | u.charCodeAt(f++) << 16 | u.charCodeAt(f++) << 24;
          for (var v = 3 & s; v--; ) l[f] = u.charCodeAt(f++);
          o(new Blob([l], { type: t }));
        }
      })];
    });
  });
}
var VJ = 1 / 0;
function OP(e, t, r, n, i) {
  var a = -1, o = e.length;
  for (r || (r = Array.isArray), i || (i = []); ++a < o; ) {
    var u = e[a];
    r(u) ? OP(u, t - 1, r, n, i) : i[i.length] = u;
  }
  return i;
}
function LP(e) {
  return e != null && e.length ? OP(e, VJ) : [];
}
var Y4 = function(e, t) {
  for (var r = [], n = 0, i = t.length; n < i; n++) {
    var a = t[n], o = a.start, u = a.end;
    a.regular.test(e.slice(o, u)) || r.push({ start: o, end: u });
  }
  return r;
}, mm = function(e) {
  return e.length > 2 || e.length === 0 ? e : "".concat(e[0].toLocaleUpperCase()).concat(e.length === 2 ? e[1].toLocaleLowerCase() : "");
}, W4 = { HSE: "SER", HSD: "HIS", HSP: "HIS", "2AS": "ASP", "3AH": "HIS", "5HP": "GLU", ACL: "ARG", AGM: "ARG", AIB: "ALA", ALM: "ALA", ALO: "THR", ALY: "LYS", ARM: "ARG", ASA: "ASP", ASB: "ASP", ASK: "ASP", ASL: "ASP", ASQ: "ASP", AYA: "ALA", BCS: "CYS", BHD: "ASP", BMT: "THR", BNN: "ALA", BUC: "CYS", BUG: "LEU", C5C: "CYS", C6C: "CYS", CAS: "CYS", CCS: "CYS", CEA: "CYS", CGU: "GLU", CHG: "GLY", CLE: "LEU", CME: "CYS", CSD: "CYS", CSO: "CYS", CSP: "CYS", CSS: "CYS", CSW: "CYS", CSX: "CYS", CXM: "MET", CY1: "CYS", CY3: "CYS", CYG: "CYS", CYM: "CYS", CYQ: "CYS", DAH: "PHE", DAL: "ALA", DAR: "ARG", DAS: "ASP", DCY: "CYS", DGL: "GLU", DGN: "GLN", DHA: "ALA", DHI: "HIS", DIL: "ILE", DIV: "VAL", DLE: "LEU", DLY: "LYS", DNP: "ALA", DPN: "PHE", DPR: "PRO", DSN: "SER", DSP: "ASP", DTH: "THR", DTR: "TRP", DTY: "TYR", DVA: "VAL", EFC: "CYS", FLA: "ALA", FME: "MET", GGL: "GLU", GL3: "GLY", GLZ: "GLY", GMA: "GLU", GSC: "GLY", HAC: "ALA", HAR: "ARG", HIC: "HIS", HIP: "HIS", HMR: "ARG", HPQ: "PHE", HTR: "TRP", HYP: "PRO", IAS: "ASP", IIL: "ILE", IYR: "TYR", KCX: "LYS", LLP: "LYS", LLY: "LYS", LTR: "TRP", LYM: "LYS", LYZ: "LYS", MAA: "ALA", MEN: "ASN", MHS: "HIS", MIS: "SER", MLE: "LEU", MPQ: "GLY", MSA: "GLY", MSE: "MET", MVA: "VAL", NEM: "HIS", NEP: "HIS", NLE: "LEU", NLN: "LEU", NLP: "LEU", NMC: "GLY", OAS: "SER", OCS: "CYS", OMT: "MET", PAQ: "TYR", PCA: "GLU", PEC: "CYS", PHI: "PHE", PHL: "PHE", PR3: "CYS", PRR: "ALA", PTR: "TYR", PYX: "CYS", SAC: "SER", SAR: "GLY", SCH: "CYS", SCS: "CYS", SCY: "CYS", SEL: "SER", SEP: "SER", SET: "SER", SHC: "CYS", SHR: "LYS", SMC: "CYS", SOC: "CYS", STY: "TYR", SVA: "SER", TIH: "ALA", TPL: "TRP", TPO: "THR", TPQ: "ALA", TRG: "LYS", TRO: "TRP", TYB: "TYR", TYI: "TYR", TYQ: "TYR", TYS: "TYR", TYY: "TYR", ALA: "ALA", ASN: "ASN", CYS: "CYS", GLU: "GLU", HIS: "HIS", LEU: "LEU", MET: "MET", PRO: "PRO", THR: "THR", TYR: "TYR", ARG: "ARG", ASP: "ASP", GLN: "GLN", GLY: "GLY", ILE: "ILE", LYS: "LYS", PHE: "PHE", SER: "SER", TRP: "TRP", VAL: "VAL", "0CS": "ALA", "1AB": "PRO", "1LU": "LEU", "1PA": "PHE", "1TQ": "TRP", "1TY": "TYR", "23F": "PHE", "23S": "TRP", "2BU": "ALA", "2ML": "LEU", "2MR": "ARG", "2MT": "PRO", "2OP": "ALA", "2TY": "TYR", "32S": "TRP", "32T": "TRP", "3MD": "ASP", "3TY": "TYR", "4DP": "TRP", "4F3": "ALA", "4FB": "PRO", "4FW": "TRP", "4HT": "TRP", "4IN": "TRP", "4PH": "PHE", "5CS": "CYS", "6CL": "LYS", "6CW": "TRP", A0A: "ASP", AA4: "ALA", AAR: "ARG", AB7: "GLU", ABA: "ALA", ACB: "ASP", ACY: "GLY", AEI: "THR", AFA: "ASN", AGT: "CYS", AHB: "ASN", AHO: "ALA", AHP: "ALA", AKL: "ASP", ALC: "ALA", ALG: "ARG", ALN: "ALA", ALS: "ALA", ALT: "ALA", AME: "MET", AP7: "ALA", APH: "ALA", API: "LYS", APK: "LYS", AR2: "ARG", AR4: "GLU", ARO: "ARG", ASI: "ASP", AYG: "ALA", AZK: "LYS", B2A: "ALA", B2F: "PHE", B2I: "ILE", B2V: "VAL", B3A: "ALA", B3D: "ASP", B3E: "GLU", B3K: "LYS", B3S: "SER", B3X: "ASN", B3Y: "TYR", BAL: "ALA", BBC: "CYS", BCX: "CYS", BFD: "ASP", BG1: "SER", BIF: "PHE", BLE: "LEU", BLY: "LYS", BOR: "ARG", BPE: "CYS", BTR: "TRP", C12: "ALA", C1X: "LYS", C3Y: "CYS", C99: "ALA", CAB: "ALA", CAF: "CYS", CH6: "ALA", CH7: "ALA", CHP: "GLY", CHS: "PHE", CIR: "ARG", CLB: "ALA", CLD: "ALA", CLG: "LYS", CLH: "LYS", CLV: "ALA", CML: "CYS", CMT: "CYS", CQR: "ALA", CR2: "ALA", CR5: "ALA", CR7: "ALA", CR8: "ALA", CRK: "ALA", CRO: "THR", CRQ: "TYR", CRW: "ALA", CRX: "ALA", CS1: "CYS", CS3: "CYS", CS4: "CYS", CSA: "CYS", CSB: "CYS", CSE: "CYS", CSI: "ALA", CSR: "CYS", CSU: "CYS", CSY: "ALA", CSZ: "CYS", CTH: "THR", CWR: "ALA", CY0: "CYS", CY4: "CYS", CY7: "CYS", CYD: "CYS", CYF: "CYS", CYJ: "LYS", CYR: "CYS", CYX: "CYS", CZ2: "CYS", CZZ: "CYS", DA2: "ARG", DAB: "ALA", DAM: "ALA", DBU: "ALA", DBY: "TYR", DBZ: "ALA", DCL: "LEU", DDE: "HIS", DHL: "SER", DLS: "LYS", DMH: "ASN", DMK: "ASP", DNE: "LEU", DNG: "LEU", DNL: "LYS", DNM: "LEU", DPH: "PHE", DPL: "PRO", DPP: "ALA", DPQ: "TYR", DSE: "SER", DSG: "ASN", DYG: "ALA", DYS: "CYS", ESB: "TYR", ESC: "MET", FCL: "PHE", FGL: "ALA", FGP: "SER", FHL: "LYS", FLE: "LEU", FLT: "TYR", FOE: "CYS", FOG: "PHE", FOR: "MET", FRF: "PHE", FTR: "TRP", FTY: "TYR", GHG: "GLN", GHP: "GLY", GLH: "GLN", GMU: "ALA", GPL: "LYS", GT9: "CYS", GVL: "SER", GYC: "CYS", GYS: "GLY", H5M: "PRO", HHK: "ALA", HIA: "HIS", HID: "HIS", HIE: "HIS", HIQ: "HIS", HLU: "LEU", HMF: "ALA", HPE: "PHE", HPH: "PHE", HRG: "ARG", HSL: "SER", HSO: "HIS", HTI: "CYS", HY3: "PRO", IAM: "ALA", IGL: "ALA", ILG: "GLU" }, UJ = { ALA: "A", CYS: "C", ASP: "D", GLU: "E", PHE: "F", GLY: "G", HIS: "H", ILE: "I", LYS: "K", LEU: "L", MET: "M", ASN: "N", PRO: "P", GLN: "Q", ARG: "R", SER: "S", THR: "T", VAL: "V", TRP: "W", TYR: "Y", HID: "H", HIE: "H", HIP: "H", ASH: "B", GLH: "E", LYN: "K", CYM: "CM" }, HJ = [{ start: 0, end: 10, regular: /\s*[\d.-]+/ }, { start: 10, end: 20, regular: /\s*[\d.-]+/ }, { start: 20, end: 30, regular: /\s*[\d.-]+/ }, { start: 31, end: 33, regular: /[\sA-Za-z]+/ }], qJ = [{ start: 0, end: 3, regular: /\s*[\d]+/ }, { start: 3, end: 6, regular: /\s*[\d]+/ }, { start: 6, end: 9, regular: /\s*[\d]+/ }], KJ = [{ start: 0, end: 3, regular: /\s*[\d]+/ }, { start: 3, end: 6, regular: /\s*[\d]+/ }], kP = { Dihedral: Te.Dihedral, Distance: Te.Distance, Angle: Te.Angle, Label: Te.Label, "Molecular Surface": Te.Surface, "Ball & Stick": Te.BallAndStick, Line: Te.Line, Stick: Te.Stick, Spacefill: Te.CPK, Cartoon: Te.Ribbon }, zP = function(e, t, r) {
  var n, i = t[0], a = i.residueName, o = i.residueId, u = i.isEutectic, s = t.map(function(m) {
    return m.elementId;
  }), c = ei(e, s), l = mf.ofLoci(c);
  n = l.elementCount > 0 ? l.firstElementLoc : l.residueCount > 0 ? l.firstResidueLoc : l.chainCount > 0 ? l.firstChainLoc : l.unitCount > 0 ? l.firstUnitLoc : l.conformationCount > 0 ? l.firstConformationLoc : l.firstStructureLoc;
  var d, f = (d = Qe.residue.secondary_structure_type(n), yr.is(d, 2) ? "helix" : yr.is(d, 4) ? "sheet" : yr.is(d, 16) ? "turn" : yr.is(d, 8) ? "bend" : "none");
  return { residueNum: o, residueName: a.toUpperCase(), standardResidueName: W4[a.toUpperCase()], oneLetter: u ? "X" : UJ[W4[a.toUpperCase()]] || W4[a.toUpperCase()] || "X", elementIds: t.map(function(m) {
    return m.elementId;
  }), secondaryStructureType: f, secondaryStructureTypeInfo: Qe.residue.secondary_structure_type(n), secondaryStructureTypeKey: Qe.residue.secondary_structure_key(n), insCode: Qe.residue.pdbx_PDB_ins_code(n), index: r };
}, K_ = /* @__PURE__ */ new Set(["LI", "NA", "K", "RB", "CS", "FR", "BE", "MG", "CA", "SR", "BA", "RA", "AL", "GA", "IN", "SN", "TL", "PB", "BI", "SC", "TI", "V", "CR", "MN", "FE", "CO", "NI", "CU", "ZN", "Y", "ZR", "NB", "MO", "TC", "RU", "RH", "PD", "AG", "CD", "LA", "HF", "TA", "W", "RE", "OS", "IR", "PT", "AU", "HG", "AC", "RF", "DB", "SG", "BH", "HS", "MT", "CE", "PR", "ND", "PM", "SM", "EU", "GD", "TB", "DY", "HO", "ER", "TM", "YB", "LU", "TH", "PA", "U", "NP", "PU", "AM", "CM", "BK", "CF", "ES", "FM", "MD", "NO", "LR"]), X_ = /* @__PURE__ */ new Set(["EOH", "GOL", "DMS", "PEG", "POL", "IOH", "DIO", "ACN", "SBT", "1BO", "CCN", "DMS", "GBL", "P2K", "MPD", "PGQ", "SEO"]), Wa = function(e, t, r) {
  r === void 0 && (r = !1);
  var n = r ? "".concat(t.residueId, "_").concat(t.insertCode) : t.residueId;
  e[t.chainId] ? e[t.chainId][n] = (e[t.chainId][n] ? e[t.chainId][n] : []).concat(t) : (e[t.chainId] = {}, e[t.chainId][n] = [t]);
}, GP = function(e) {
  var t = {}, r = {}, n = {}, i = {}, a = {}, o = {}, u = {}, s = {}, c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map();
  e.units.forEach(function(g) {
    var h;
    g.elements.forEach(function(_) {
      var S = Os(g, _);
      if (g0.has(S.residueName.toUpperCase())) Wa(r, S);
      else if (K_.has(S.typeSymbol.toUpperCase())) Wa(i, S);
      else if (X_.has(S.residueName.toUpperCase())) Wa(n, S);
      else if (Cm.has(S.residueName.toUpperCase())) Wa(a, S);
      else {
        if (S.groupPDB === "ATOM" && !["UNK", "MOL"].includes(S.residueName)) return Wa(t, S, !0), void c.add(S.elementId);
        if (S.groupPDB === "HETATM" || ["UNK", "MOL"].includes(S.residueName)) {
          var D = "".concat(S.chainId, "_").concat(S.residueId);
          l.set(D, l.has(D) ? We(We([], l.get(D), !0), [S], !1) : [S]);
        } else Wa(u, S);
      }
    });
    for (var y = 0, x = g.bonds.a.length; y < x; y++) {
      var A = g.elements[g.bonds.a[y]], b = g.elements[g.bonds.b[y]];
      d.has(A) ? (h = d.get(A)) === null || h === void 0 || h.add(b) : d.set(A, /* @__PURE__ */ new Set([b]));
    }
  }), l.forEach(function(g) {
    var h = !1;
    new Set(g.map(function(y) {
      return y.elementId;
    })).forEach(function(y) {
      if (d.has(y)) {
        var x = d.get(y);
        x == null || x.forEach(function(A) {
          c.has(A) && (h = !0);
        });
      }
    }), g.forEach(function(y) {
      h ? (Object.assign(y, { isEutectic: !0 }), Wa(o, y)) : Wa(u, y);
    });
  });
  var f = {};
  Object.keys(u).forEach(function(g) {
    var h = u[g];
    Object.keys(h).forEach(function(y) {
      var x = h[y], A = x.filter(function(b) {
        return b.typeSymbol !== "H";
      });
      A.length > 10 && A.length < 150 ? (s[g] || (s[g] = {}), s[g][y] = x) : (f[g] || (f[g] = {}), f[g][y] = x);
    });
  });
  var m = {};
  Object.keys(t).forEach(function(g) {
    var h;
    m[g] || (m[g] = []), (h = m[g]).push.apply(h, Object.values(t[g]));
  }), Object.keys(o).forEach(function(g) {
    var h = o[g];
    Object.keys(h).forEach(function(y) {
      var x = h[y];
      f[g] || (f[g] = {}), m[g] || (m[g] = []), m[g].push(x), f[g][y] = x;
    });
  });
  var v = 0, p = {};
  return Object.keys(m).forEach(function(g) {
    p[g] = {}, m[g].sort(function(h, y) {
      return h[0].residueId !== y[0].residueId ? h[0].residueId - y[0].residueId : h[0].insertCode.localeCompare(y[0].insertCode);
    }).forEach(function(h) {
      p[h[0].chainId]["".concat(h[0].residueId, "_").concat(h[0].insertCode)] = zP(e, h, v++);
    });
  }), { data: { polymer: t, water: r, otherSolvent: n, metal: i, ion: a, ligand: s, other: f }, extraData: { sequenceData: p } };
}, XJ = function(e) {
  var t = {}, r = {}, n = {}, i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
  e.units.forEach(function(d) {
    var f;
    d.elements.forEach(function(h) {
      var y = Os(d, h);
      if (!(g0.has(y.residueName.toUpperCase()) || K_.has(y.typeSymbol.toUpperCase()) || X_.has(y.residueName.toUpperCase()) || Cm.has(y.residueName.toUpperCase()))) {
        if (y.groupPDB === "ATOM" && !["UNK", "MOL"].includes(y.residueName)) return Wa(t, y, !0), void i.add(y.elementId);
        if (y.groupPDB === "HETATM" || ["UNK", "MOL"].includes(y.residueName)) {
          var x = "".concat(y.chainId, "_").concat(y.residueId);
          a.set(x, a.has(x) ? We(We([], a.get(x), !0), [y], !1) : [y]);
        } else Wa(n, y);
      }
    });
    for (var m = 0, v = d.bonds.a.length; m < v; m++) {
      var p = d.elements[d.bonds.a[m]], g = d.elements[d.bonds.b[m]];
      o.has(p) ? (f = o.get(p)) === null || f === void 0 || f.add(g) : o.set(p, /* @__PURE__ */ new Set([g]));
    }
  }), a.forEach(function(d) {
    var f = !1;
    new Set(d.map(function(m) {
      return m.elementId;
    })).forEach(function(m) {
      if (o.has(m)) {
        var v = o.get(m);
        v == null || v.forEach(function(p) {
          i.has(p) && (f = !0);
        });
      }
    }), d.forEach(function(m) {
      f ? (Object.assign(m, { isEutectic: !0 }), Wa(r, m)) : Wa(n, m);
    });
  });
  var u = {};
  Object.keys(n).forEach(function(d) {
    var f = n[d];
    Object.keys(f).forEach(function(m) {
      var v = f[m], p = v.filter(function(g) {
        return g.typeSymbol !== "H";
      });
      p.length <= 10 && p.length < 150 && (u[d] || (u[d] = {}), u[d][m] = v);
    });
  });
  var s = {};
  Object.keys(t).forEach(function(d) {
    var f;
    s[d] || (s[d] = []), (f = s[d]).push.apply(f, Object.values(t[d]));
  }), Object.keys(r).forEach(function(d) {
    var f = r[d];
    Object.keys(f).forEach(function(m) {
      var v = f[m];
      u[d] || (u[d] = {}), s[d] || (s[d] = []), s[d].push(v), u[d][m] = v;
    });
  });
  var c = 0, l = {};
  return Object.keys(s).forEach(function(d) {
    l[d] = {}, s[d].sort(function(f, m) {
      return f[0].residueId !== m[0].residueId ? f[0].residueId - m[0].residueId : f[0].insertCode.localeCompare(m[0].insertCode);
    }).forEach(function(f) {
      l[f[0].chainId]["".concat(f[0].residueId, "_").concat(f[0].insertCode)] = zP(e, f, c++);
    });
  }), l;
}, W2 = function(e, t) {
  switch (t) {
    case kr.Atom:
      return "".concat(e.elementId);
    case kr.Residue:
      return "".concat(e.chainId, "_").concat(e.residueName, "_").concat(e.residueId);
    case kr.Chain:
      return "".concat(e.chainId);
    case kr.Molecular:
      return "".concat(e.unitId);
  }
  return "";
}, jJ = function(e, t) {
  switch (t) {
    case kr.Atom:
      return e;
    case kr.Residue:
      return { unitId: e.unitId, chainId: e.chainId, groupPDB: e.groupPDB, residueId: e.residueId, residueName: e.residueName };
    case kr.Chain:
      return { unitId: e.unitId, chainId: e.chainId };
    case kr.Molecular:
      return { unitId: e.unitId };
  }
  return {};
};
function VP(e, t, r) {
  var n = this;
  return r === void 0 && (r = !1), er.create("Parse PDB", function(i) {
    return _e(n, 0, void 0, function() {
      var a, o, u;
      return ye(this, function(s) {
        switch (s.label) {
          case 0:
            return o = (a = Pi).success, u = {}, [4, ot.readAllLinesAsync(e, i)];
          case 1:
            return [2, o.apply(a, [(u.lines = s.sent(), u.id = t, u.isPdbqt = r, u)])];
        }
      });
    });
  });
}
function YJ(e, t) {
  var r = function(a, o) {
    return (t.substr(a, o) || "").trim();
  }, n = { entry_id: st.ofString(e), length_a: st.ofString(r(6, 9)), length_b: st.ofString(r(15, 9)), length_c: st.ofString(r(24, 9)), angle_alpha: st.ofString(r(33, 7)), angle_beta: st.ofString(r(40, 7)), angle_gamma: st.ofString(r(47, 7)), Z_PDB: st.ofString(r(66, 4)), pdbx_unique_axis: st.ofString("?") }, i = { entry_id: st.ofString(e), "space_group_name_H-M": st.ofString(r(55, 11)), Int_Tables_number: st.ofString("?"), cell_setting: st.ofString("?"), space_group_name_Hall: st.ofString("?") };
  return [va.ofFields("cell", n), va.ofFields("symmetry", i)];
}
function Rw(e, t) {
  return { id: e, details: t, groups: [] };
}
function WJ(e, t, r) {
  for (var n, i, a, o = [], u = 1, s = 1, c = function(X) {
    return e.data.substring(e.indices[2 * X], e.indices[2 * X + 1]);
  }, l = t; l < r; l++) {
    var d = c(l);
    if (d.substr(11, 12) === "BIOMOLECULE:") {
      var f = d.substr(23).trim(), m = "Biomolecule ".concat(f);
      (d = c(l + 1)).substr(11, 30) !== "APPLY THE FOLLOWING TO CHAINS:" && (l++, m = d.substr(11).trim()), n = Rw(f, m), o.push(n);
    } else if (d.substr(13, 5) === "BIOMT") {
      var v = d.split(/\s+/);
      (H = parseInt(d[18]) - 1) === 0 && (a = me.identity(), i.operators.push({ id: u++, matrix: a })), me.setValue(a, H, 0, parseFloat(v[4])), me.setValue(a, H, 1, parseFloat(v[5])), me.setValue(a, H, 2, parseFloat(v[6])), me.setValue(a, H, 3, parseFloat(v[7]));
    } else if (d.substr(11, 30) === "APPLY THE FOLLOWING TO CHAINS:" || d.substr(11, 30) === "                   AND CHAINS:") {
      d.substr(11, 5) === "APPLY" && (i = { chains: [], operators: [] }, n.groups.push(i));
      for (var p = 0, g = (h = d.substr(41, 30).split(",")).length; p < g; ++p)
        (y = h[p].trim()) && i.chains.push(y);
    } else if (d.substr(11, 33) === "APPLYING THE FOLLOWING TO CHAINS:") {
      n = Rw("".concat(s), "Biomolecule ".concat(s)), o.push(n), s += 1, i = { chains: [], operators: [] }, n.groups.push(i);
      var h;
      for (p = 0, g = (h = (d = c(++l)).substr(11, 69).split(",")).length; p < g; ++p) {
        var y;
        (y = h[p].trim()) && i.chains.push(y);
      }
    }
  }
  if (o.length === 0) return [];
  for (var x = { id: st.ofStrings(o.map(function(X) {
    return X.id;
  })), details: st.ofStrings(o.map(function(X) {
    return X.details;
  })) }, A = [], b = 0, _ = o; b < _.length; b++) for (var S = 0, D = (B = _[b]).groups; S < D.length; S++) {
    var I = D[S];
    A.push({ assembly_id: B.id, oper_expression: I.operators.map(function(X) {
      return X.id;
    }).join(","), asym_id_list: I.chains.join(",") });
  }
  for (var M = { assembly_id: st.ofStrings(A.map(function(X) {
    return X.assembly_id;
  })), oper_expression: st.ofStrings(A.map(function(X) {
    return X.oper_expression;
  })), asym_id_list: st.ofStrings(A.map(function(X) {
    return X.asym_id_list;
  })) }, F = [], P = 0, E = o; P < E.length; P++) for (var B, N = 0, O = (B = E[P]).groups; N < O.length; N++) for (var z = 0, V = O[N].operators; z < V.length; z++) {
    var U = V[z], H = { id: "" + U.id, type: "?", name: "?", symmetry_operation: "?" };
    for (l = 0; l < 3; l++) {
      for (p = 0; p < 3; p++) H["matrix[".concat(l + 1, "][").concat(p + 1, "]")] = "" + me.getValue(U.matrix, l, p);
      H["vector[".concat(l + 1, "]")] = "" + me.getValue(U.matrix, l, 3);
    }
    F.push(H);
  }
  var K = { id: st.ofStrings(F.map(function(X) {
    return X.id;
  })), type: st.ofStrings(F.map(function(X) {
    return X.type;
  })), name: st.ofStrings(F.map(function(X) {
    return X.name;
  })), symmetry_operation: st.ofStrings(F.map(function(X) {
    return X.symmetry_operation;
  })) }, j = function(X) {
    for (var W = function(ee) {
      var $ = "matrix[".concat(X + 1, "][").concat(ee + 1, "]");
      K[$] = st.ofStrings(F.map(function(ie) {
        return ie[$];
      }));
    }, Q = 0; Q < 3; Q++) W(Q);
    var te = "vector[".concat(X + 1, "]");
    K[te] = st.ofStrings(F.map(function(ee) {
      return ee[te];
    }));
  };
  for (l = 0; l < 3; l++) j(l);
  return [va.ofFields("pdbx_struct_assembly", x), va.ofFields("pdbx_struct_assembly_gen", M), va.ofFields("pdbx_struct_oper_list", K)];
}
function ZJ(e, t, r) {
  for (var n, i = [], a = function(y) {
    return e.data.substring(e.indices[2 * y], e.indices[2 * y + 1]);
  }, o = t; o < r; o++) {
    var u = a(o), s = u.split(/\s+/);
    (v = parseInt(u[5]) - 1) === 0 && (n = me.identity(), i.push(n)), me.setValue(n, v, 0, parseFloat(s[2])), me.setValue(n, v, 1, parseFloat(s[3])), me.setValue(n, v, 2, parseFloat(s[4])), me.setValue(n, v, 3, parseFloat(s[5]));
  }
  if (i.length === 0) return [];
  for (var c = [], l = 1, d = 0, f = i; d < f.length; d++) {
    var m = f[d], v = { id: "ncsop" + l++, code: ".", details: "." };
    for (o = 0; o < 3; o++) {
      for (var p = 0; p < 3; p++) v["matrix[".concat(o + 1, "][").concat(p + 1, "]")] = "" + me.getValue(m, o, p);
      v["vector[".concat(o + 1, "]")] = "" + me.getValue(m, o, 3);
    }
    c.push(v);
  }
  var g = { id: st.ofStrings(c.map(function(y) {
    return y.id;
  })), code: st.ofStrings(c.map(function(y) {
    return y.code;
  })), details: st.ofStrings(c.map(function(y) {
    return y.details;
  })) }, h = function(y) {
    for (var x = function(_) {
      var S = "matrix[".concat(y + 1, "][").concat(_ + 1, "]");
      g[S] = st.ofStrings(c.map(function(D) {
        return D[S];
      }));
    }, A = 0; A < 3; A++) x(A);
    var b = "vector[".concat(y + 1, "]");
    g[b] = st.ofStrings(c.map(function(_) {
      return _[b];
    }));
  };
  for (o = 0; o < 3; o++) h(o);
  return [va.ofFields("struct_ncs_oper", g)];
}
var QJ = { 1: "HELX_RH_AL_P", 2: "HELX_RH_OM_P", 3: "HELX_RH_PI_P", 4: "HELX_RH_GA_P", 5: "HELX_RH_3T_P", 6: "HELX_LH_AL_P", 7: "HELX_LH_OM_P", 8: "HELX_LH_GA_P", 9: "HELX_RH_27_P", 10: "HELX_RH_PP_P" };
function JJ(e, t, r) {
  for (var n = [], i = function(f) {
    return e.data.substring(e.indices[2 * f], e.indices[2 * f + 1]);
  }, a = t; a < r; a++) {
    var o = i(a);
    n.push({ serNum: o.substr(7, 3).trim(), helixID: o.substr(11, 3).trim(), initResName: o.substr(15, 3).trim(), initChainID: o.substr(19, 1).trim(), initSeqNum: o.substr(21, 4).trim(), initICode: o.substr(25, 1).trim(), endResName: o.substr(27, 3).trim(), endChainID: o.substr(31, 3).trim(), endSeqNum: o.substr(33, 4).trim(), endICode: o.substr(37, 1).trim(), helixClass: o.substr(38, 2).trim(), comment: o.substr(40, 30).trim(), length: o.substr(71, 5).trim() });
  }
  var u = st.ofStrings(n.map(function(f) {
    return f.initChainID;
  })), s = st.ofStrings(n.map(function(f) {
    return f.initResName;
  })), c = st.ofStrings(n.map(function(f) {
    return f.endChainID;
  })), l = st.ofStrings(n.map(function(f) {
    return f.endResName;
  })), d = { beg_label_asym_id: u, beg_label_comp_id: s, beg_label_seq_id: st.ofUndefined(n.length, oe.Schema.int), beg_auth_asym_id: u, beg_auth_comp_id: s, beg_auth_seq_id: st.ofStrings(n.map(function(f) {
    return f.initSeqNum;
  })), conf_type_id: st.ofStrings(n.map(function(f) {
    return function(m) {
      return QJ[m] || "HELX_P";
    }(f.helixClass);
  })), details: st.ofStrings(n.map(function(f) {
    return f.comment;
  })), end_label_asym_id: c, end_label_comp_id: l, end_label_seq_id: st.ofUndefined(n.length, oe.Schema.int), end_auth_asym_id: c, end_auth_comp_id: l, end_auth_seq_id: st.ofStrings(n.map(function(f) {
    return f.endSeqNum;
  })), id: st.ofStrings(n.map(function(f) {
    return f.serNum;
  })), pdbx_beg_PDB_ins_code: st.ofStrings(n.map(function(f) {
    return f.initICode;
  })), pdbx_end_PDB_ins_code: st.ofStrings(n.map(function(f) {
    return f.endICode;
  })), pdbx_PDB_helix_class: st.ofStrings(n.map(function(f) {
    return f.helixClass;
  })), pdbx_PDB_helix_length: st.ofStrings(n.map(function(f) {
    return f.length;
  })), pdbx_PDB_helix_id: st.ofStrings(n.map(function(f) {
    return f.helixID;
  })) };
  return va.ofFields("struct_conf", d);
}
function $J(e, t, r) {
  for (var n = [], i = function(v) {
    return e.data.substring(e.indices[2 * v], e.indices[2 * v + 1]);
  }, a = t; a < r; a++) {
    var o = i(a);
    n.push({ strand: o.substr(7, 3).trim(), sheetID: o.substr(11, 3).trim(), numStrands: o.substr(14, 2).trim(), initResName: o.substr(17, 3).trim(), initChainID: o.substr(21, 1).trim(), initSeqNum: o.substr(22, 4).trim(), initICode: o.substr(26, 1).trim(), endResName: o.substr(28, 3).trim(), endChainID: o.substr(32, 1).trim(), endSeqNum: o.substr(33, 4).trim(), endICode: o.substr(37, 1).trim(), sense: o.substr(38, 2).trim(), curAtom: o.substr(41, 4).trim(), curResName: o.substr(45, 3).trim(), curChainId: o.substr(49, 1).trim(), curResSeq: o.substr(50, 4).trim(), curICode: o.substr(54, 1).trim(), prevAtom: o.substr(56, 4).trim(), prevResName: o.substr(60, 3).trim(), prevChainId: o.substr(64, 1).trim(), prevResSeq: o.substr(65, 4).trim(), prevICode: o.substr(69, 1).trim() });
  }
  var u = st.ofStrings(n.map(function(v) {
    return v.initChainID;
  })), s = st.ofStrings(n.map(function(v) {
    return v.initResName;
  })), c = st.ofStrings(n.map(function(v) {
    return v.initSeqNum;
  })), l = st.ofStrings(n.map(function(v) {
    return v.endChainID;
  })), d = st.ofStrings(n.map(function(v) {
    return v.endResName;
  })), f = st.ofStrings(n.map(function(v) {
    return v.endSeqNum;
  })), m = { beg_label_asym_id: u, beg_label_comp_id: s, beg_label_seq_id: c, beg_auth_asym_id: u, beg_auth_comp_id: s, beg_auth_seq_id: c, end_label_asym_id: l, end_label_comp_id: l, end_label_seq_id: f, end_auth_asym_id: l, end_auth_comp_id: d, end_auth_seq_id: f, id: st.ofStrings(n.map(function(v) {
    return v.strand;
  })), sheet_id: st.ofStrings(n.map(function(v) {
    return v.sheetID;
  })), pdbx_beg_PDB_ins_code: st.ofStrings(n.map(function(v) {
    return v.initICode;
  })), pdbx_end_PDB_ins_code: st.ofStrings(n.map(function(v) {
    return v.endICode;
  })) };
  return va.ofFields("struct_sheet_range", m);
}
var e$ = { MOL_ID: "", MOLECULE: "", CHAIN: "", FRAGMENT: "", SYNONYM: "", EC: "", ENGINEERED: "", MUTATION: "", OTHER_DETAILS: "" };
function t$(e, t, r) {
  for (var n, i = function(x) {
    return e.data.substring(e.indices[2 * x], e.indices[2 * x + 1]);
  }, a = { chains: [], description: "" }, o = [], u = t; u < r; u++) {
    var s = i(u).substr(10, 70).trim(), c = s.indexOf(":"), l = s.substring(0, c), d = void 0;
    l in e$ ? (n = l, d = s.substring(c + 2)) : d = s, d = d.replace(/;$/, ""), n === "MOL_ID" ? (a = { chains: [], description: "" }, o.push(a)) : n === "MOLECULE" ? (a.description && (a.description += " "), a.description += d) : n === "CHAIN" && Array.prototype.push.apply(a.chains, d.split(/\s*,\s*/));
  }
  for (var f = [], m = 0, v = o; m < v.length; m++) for (var p = v[m], g = 0, h = p.chains; g < h.length; g++) {
    var y = h[g];
    f.push({ description: p.description, chains: [y] });
  }
  return f;
}
function r$(e, t, r) {
  for (var n = function(c) {
    return e.data.substring(e.indices[2 * c], e.indices[2 * c + 1]);
  }, i = /* @__PURE__ */ new Map(), a = t; a < r; a++) {
    var o = n(a), u = o.substr(11, 3).trim(), s = o.substr(15).trim();
    i.has(u) ? i.set(u, "".concat(i.get(u), " ").concat(s)) : i.set(u, s);
  }
  return i;
}
var n$ = [/* @__PURE__ */ new Set(["CA"]), /* @__PURE__ */ new Set(["C"]), /* @__PURE__ */ new Set(["N"])], i$ = [/* @__PURE__ */ new Set(["P", "O3'", "O3*"]), /* @__PURE__ */ new Set(["C4'", "C4*"]), /* @__PURE__ */ new Set(["O2'", "O2*", "F2'", "F2*"])], a$ = [/* @__PURE__ */ new Set(["P", "O3'", "O3*"]), /* @__PURE__ */ new Set(["C3'", "C3*"]), /* @__PURE__ */ new Set(["O2'", "O2*", "F2'", "F2*"])], o$ = /* @__PURE__ */ new Set(["FMN", "NCN", "FNS", "FMA", "ATP", "ADP", "AMP", "GTP", "GDP", "GMP"]), Ow = function() {
  var e = /* @__PURE__ */ new Map();
  return [{ id: "HIS", name: "HISTIDINE", type: "L-peptide linking" }, { id: "ARG", name: "ARGININE", type: "L-peptide linking" }, { id: "LYS", name: "LYSINE", type: "L-peptide linking" }, { id: "ILE", name: "ISOLEUCINE", type: "L-peptide linking" }, { id: "PHE", name: "PHENYLALANINE", type: "L-peptide linking" }, { id: "LEU", name: "LEUCINE", type: "L-peptide linking" }, { id: "TRP", name: "TRYPTOPHAN", type: "L-peptide linking" }, { id: "ALA", name: "ALANINE", type: "L-peptide linking" }, { id: "MET", name: "METHIONINE", type: "L-peptide linking" }, { id: "CYS", name: "CYSTEINE", type: "L-peptide linking" }, { id: "ASN", name: "ASPARAGINE", type: "L-peptide linking" }, { id: "VAL", name: "VALINE", type: "L-peptide linking" }, { id: "GLY", name: "GLYCINE", type: "peptide linking" }, { id: "SER", name: "SERINE", type: "L-peptide linking" }, { id: "GLN", name: "GLUTAMINE", type: "L-peptide linking" }, { id: "TYR", name: "TYROSINE", type: "L-peptide linking" }, { id: "ASP", name: "ASPARTIC ACID", type: "L-peptide linking" }, { id: "GLU", name: "GLUTAMIC ACID", type: "L-peptide linking" }, { id: "THR", name: "THREONINE", type: "L-peptide linking" }, { id: "PRO", name: "PROLINE", type: "L-peptide linking" }, { id: "SEC", name: "SELENOCYSTEINE", type: "L-peptide linking" }, { id: "PYL", name: "PYRROLYSINE", type: "L-peptide linking" }, { id: "MSE", name: "SELENOMETHIONINE", type: "L-peptide linking" }, { id: "SEP", name: "PHOSPHOSERINE", type: "L-peptide linking" }, { id: "TPO", name: "PHOSPHOTHREONINE", type: "L-peptide linking" }, { id: "PTR", name: "O-PHOSPHOTYROSINE", type: "L-peptide linking" }, { id: "PCA", name: "PYROGLUTAMIC ACID", type: "L-peptide linking" }, { id: "A", name: "ADENOSINE-5'-MONOPHOSPHATE", type: "RNA linking" }, { id: "C", name: "CYTIDINE-5'-MONOPHOSPHATE", type: "RNA linking" }, { id: "T", name: "THYMIDINE-5'-MONOPHOSPHATE", type: "RNA linking" }, { id: "G", name: "GUANOSINE-5'-MONOPHOSPHATE", type: "RNA linking" }, { id: "I", name: "INOSINIC ACID", type: "RNA linking" }, { id: "U", name: "URIDINE-5'-MONOPHOSPHATE", type: "RNA linking" }, { id: "DA", name: "2'-DEOXYADENOSINE-5'-MONOPHOSPHATE", type: "DNA linking" }, { id: "DC", name: "2'-DEOXYCYTIDINE-5'-MONOPHOSPHATE", type: "DNA linking" }, { id: "DT", name: "THYMIDINE-5'-MONOPHOSPHATE", type: "DNA linking" }, { id: "DG", name: "2'-DEOXYGUANOSINE-5'-MONOPHOSPHATE", type: "DNA linking" }, { id: "DI", name: "2'-DEOXYINOSINE-5'-MONOPHOSPHATE", type: "DNA linking" }, { id: "DU", name: "2'-DEOXYURIDINE-5'-MONOPHOSPHATE", type: "DNA linking" }, { id: "ACE", name: "Acetylgroup", type: "peptide linking" }, { id: "NME", name: "Methylamine", type: "peptide linking" }].forEach(function(t) {
    return e.set(t.id, t);
  }), e;
}(), Lw = function() {
  var e = /* @__PURE__ */ new Map();
  return [{ id: "ZN2", name: "ZINC ION", type: "Ion" }, { id: "SOD", name: "SODIUM ION", type: "Ion" }, { id: "CES", name: "CESIUM ION", type: "Ion" }, { id: "CLA", name: "CHLORIDE ION", type: "Ion" }, { id: "CAL", name: "CALCIUM ION", type: "Ion" }, { id: "POT", name: "POTASSIUM ION", type: "Ion" }].forEach(function(t) {
    return e.set(t.id, t);
  }), e;
}(), Cf = function() {
  function e(t, r) {
    this.seqId = t, this.atomId = r, this.namesMap = /* @__PURE__ */ new Map(), this.comps = /* @__PURE__ */ new Map(), this.ids = [], this.names = [], this.types = [], this.mon_nstd_flags = [];
  }
  return e.prototype.set = function(t) {
    this.comps.set(t.id, t), this.ids.push(t.id), this.names.push(t.name), this.types.push(t.type), this.mon_nstd_flags.push(y_.has(t.id) ? "y" : "n");
  }, e.prototype.getAtomIds = function(t) {
    for (var r = /* @__PURE__ */ new Set(), n = this.seqId.value(t); t < this.seqId.rowCount && this.seqId.value(t) === n; )
      r.add(this.atomId.value(t)), t += 1;
    return r;
  }, e.prototype.hasAtomIds = function(t, r) {
    for (var n = 0, i = r.length; n < i; ++n) if (!to.areIntersecting(t, r[n])) return !1;
    return !0;
  }, e.prototype.getType = function(t) {
    return this.hasAtomIds(t, n$) ? "peptide linking" : this.hasAtomIds(t, i$) ? "RNA linking" : this.hasAtomIds(t, a$) ? "DNA linking" : "other";
  }, e.prototype.has = function(t) {
    return this.comps.has(t);
  }, e.prototype.get = function(t) {
    return this.comps.get(t);
  }, e.prototype.add = function(t, r) {
    if (!this.has(t)) if (Ow.has(t)) this.set(Ow.get(t));
    else if (g0.has(t)) this.set({ id: t, name: "WATER", type: "non-polymer" });
    else if (o$.has(t.toUpperCase())) this.set({ id: t, name: this.namesMap.get(t) || t, type: "non-polymer" });
    else if (Zl.has(t.toUpperCase())) this.set({ id: t, name: this.namesMap.get(t) || t, type: "saccharide" });
    else {
      var n = this.getAtomIds(r);
      if (n.size === 1 && Lw.has(t)) this.set(Lw.get(t));
      else {
        var i = this.getType(n);
        this.set({ id: t, name: this.namesMap.get(t) || t, type: i });
      }
    }
    return this.get(t);
  }, e.prototype.getChemCompTable = function() {
    return Or.ofPartialColumns(_o.chem_comp, { id: oe.ofStringArray(this.ids), name: oe.ofStringArray(this.names), type: oe.ofStringAliasArray(this.types), mon_nstd_flag: oe.ofStringAliasArray(this.mon_nstd_flags) }, this.ids.length);
  }, e.prototype.setNames = function(t) {
    var r = this;
    t.forEach(function(n) {
      return r.namesMap.set(n[0], n[1]);
    });
  }, e;
}(), wf = function() {
  function e() {
    this.count = 0, this.ids = [], this.types = [], this.descriptions = [], this.compoundsMap = /* @__PURE__ */ new Map(), this.namesMap = /* @__PURE__ */ new Map(), this.heteroMap = /* @__PURE__ */ new Map(), this.chainMap = /* @__PURE__ */ new Map();
  }
  return e.prototype.set = function(t, r) {
    this.count += 1, this.ids.push("".concat(this.count)), this.types.push(t), this.descriptions.push([r]);
  }, e.prototype.getEntityId = function(t, r, n, i) {
    return r === 2 ? (this.waterId === void 0 && (this.set("water", (i == null ? void 0 : i.customName) || "Water"), this.waterId = "".concat(this.count)), this.waterId) : b_(r) ? this.compoundsMap.has(n) ? this.compoundsMap.get(n) : (this.chainMap.has(n) || (this.set("polymer", (i == null ? void 0 : i.customName) || "Polymer ".concat(this.chainMap.size + 1)), this.chainMap.set(n, "".concat(this.count))), this.chainMap.get(n)) : (this.heteroMap.has(t) || (this.set("non-polymer", (i == null ? void 0 : i.customName) || this.namesMap.get(t) || t), this.heteroMap.set(t, "".concat(this.count))), this.heteroMap.get(t));
  }, e.prototype.getEntityTable = function() {
    return Or.ofPartialColumns(_o.entity, { id: oe.ofStringArray(this.ids), type: oe.ofStringAliasArray(this.types), pdbx_description: oe.ofStringListArray(this.descriptions) }, this.count);
  }, e.prototype.setCompounds = function(t) {
    for (var r = 0, n = t.length; r < n; ++r) {
      var i = t[r], a = i.chains, o = i.description;
      this.set("polymer", o);
      for (var u = 0, s = a.length; u < s; ++u) this.compoundsMap.set(a[u], "".concat(this.count));
    }
  }, e.prototype.setNames = function(t) {
    var r = this;
    t.forEach(function(n) {
      return r.namesMap.set(n[0], n[1]);
    });
  }, e;
}();
function Z2(e, t, r, n) {
  for (var i = r, a = n - 1, o = t.charCodeAt(i); (o === 32 || o >= 48 && o <= 57) && i <= a; ) o = t.charCodeAt(++i);
  for (o = t.charCodeAt(a); (o === 32 || o >= 48 && o <= 57) && a >= i; ) o = t.charCodeAt(--a);
  if (i === ++a || i + 1 === a) return ct.add(e, i, a);
  if (o = t.charCodeAt(i), i + 2 === a) {
    var u = t.charCodeAt(i + 1);
    if (!((o !== 78 && o !== 110 || u !== 65 && u !== 97) && (o !== 67 && o !== 99 || u !== 76 && u !== 108) && (o !== 70 && o !== 102 || u !== 69 && u !== 101) && (o !== 83 && o !== 115 || u !== 73 && u !== 105) && (o !== 66 && o !== 98 || u !== 82 && u !== 114) && (o !== 65 && o !== 97 || u !== 83 && u !== 115))) return ct.add(e, i, i + 2);
  }
  if (o === 67 || o === 99 || o === 72 || o === 104 || o === 78 || o === 110 || o === 79 || o === 111 || o === 80 || o === 112 || o === 83 || o === 115) return ct.add(e, i, i + 1);
  ct.add(e, i, i);
}
var c6, u$ = /* @__PURE__ */ new Set(["NA", "CL", "FE", "SI", "BR", "AS", "LI"]), s$ = /* @__PURE__ */ new Set(["C", "H", "N", "O", "P", "S", "F", "B"]), c$ = /^[\s\d]+|[\s\d]+$/g;
function j_(e, t) {
  var r = (e = e.replace(c$, "").toUpperCase()).length;
  if (r === 0 || r === 1 || u$.has(e)) return e;
  if (r === 3 && t === e) {
    if (e === "SOD") return "NA";
    if (e === "POT") return "K";
    if (e === "CES") return "CS";
    if (e === "CAL") return "CA";
    if (e === "CLA") return "CL";
  }
  return s$.has(e[0]) ? e[0] : e;
}
function kw(e, t, r, n, i, a) {
  var o = r.data, u = i - n;
  ct.addToken(e.group_PDB, ot.trim(r, n, n + 6)), ot.trim(r, n + 6, n + 11), e.id[e.index] = r.data.substring(r.tokenStart, r.tokenEnd), ct.addToken(e.auth_atom_id, ot.trim(r, n + 12, n + 16)), o.charCodeAt(n + 16) === 32 ? ct.add(e.label_alt_id, 0, 0) : ct.add(e.label_alt_id, n + 16, n + 17), ct.addToken(e.auth_comp_id, ot.trim(r, n + 17, n + 20)), ct.add(e.auth_asym_id, n + 21, n + 22), ct.addToken(e.auth_seq_id, ot.trim(r, n + 22, n + 26)), o.charCodeAt(n + 26) === 32 ? ct.add(e.pdbx_PDB_ins_code, 0, 0) : ct.add(e.pdbx_PDB_ins_code, n + 26, n + 27), ct.addToken(e.Cartn_x, ot.trim(r, n + 30, n + 38)), ct.addToken(e.Cartn_y, ot.trim(r, n + 38, n + 46)), ct.addToken(e.Cartn_z, ot.trim(r, n + 46, n + 54)), ct.addToken(e.occupancy, ot.trim(r, n + 54, n + 60)), u >= 66 ? ct.addToken(e.B_iso_or_equiv, ot.trim(r, n + 60, n + 66)) : ct.add(e.B_iso_or_equiv, 0, 0), a && ct.addToken(e.partial_charge, ot.trim(r, n + 70, n + 76)), u >= 78 && !a ? (ot.trim(r, n + 76, n + 78), r.tokenStart < r.tokenEnd ? ct.addToken(e.type_symbol, r) : Z2(e.type_symbol, o, n + 12, n + 16)) : Z2(e.type_symbol, o, n + 12, n + 16), u >= 82 && ct.addToken(e.pdbx_formal_charge, ot.trim(r, n + 78, n + 82)), u >= 84 && ct.addToken(e.cdr, ot.trim(r, n + 82, n + 84)), u >= 90 && ct.addToken(e.em_confidence, ot.trim(r, n + 84, n + 90)), e.pdbx_PDB_model_num[e.index] = t, e.index++;
}
function l$(e) {
  var t = st.ofTokens(e.pdbx_auth_seq_id), r = st.ofTokens(e.pdbx_auth_comp_id), n = st.ofTokens(e.pdbx_auth_asym_id), i = st.ofTokens(e.pdbx_auth_atom_id), a = { id: st.ofStrings(e.id), type_symbol: st.ofTokens(e.type_symbol), pdbx_label_atom_id: i, pdbx_label_alt_id: st.ofTokens(e.pdbx_label_alt_id), pdbx_label_comp_id: r, pdbx_label_asym_id: n, pdbx_label_seq_id: t, pdbx_PDB_ins_code: st.ofTokens(e.pdbx_PDB_ins_code), pdbx_auth_seq_id: t, pdbx_auth_comp_id: r, pdbx_auth_asym_id: n, pdbx_auth_atom_id: i };
  return a["U[1][1]"] = st.ofNumbers(e["U[1][1]"]), a["U[2][2]"] = st.ofNumbers(e["U[2][2]"]), a["U[3][3]"] = st.ofNumbers(e["U[3][3]"]), a["U[1][2]"] = st.ofNumbers(e["U[1][2]"]), a["U[1][3]"] = st.ofNumbers(e["U[1][3]"]), a["U[2][3]"] = st.ofNumbers(e["U[2][3]"]), a;
}
function d$(e, t, r, n, i) {
  var a = r.data, o = i - n;
  ot.trim(r, n + 6, n + 11), e.id[e.index] = a.substring(r.tokenStart, r.tokenEnd), ct.addToken(e.pdbx_auth_atom_id, ot.trim(r, n + 12, n + 16)), a.charCodeAt(n + 16) === 32 ? ct.add(e.pdbx_label_alt_id, 0, 0) : ct.add(e.pdbx_label_alt_id, n + 16, n + 17), ct.addToken(e.pdbx_auth_comp_id, ot.trim(r, n + 17, n + 20)), ct.add(e.pdbx_auth_asym_id, n + 21, n + 22), ct.addToken(e.pdbx_auth_seq_id, ot.trim(r, n + 22, n + 26)), a.charCodeAt(n + 26) === 32 ? ct.add(e.pdbx_PDB_ins_code, 0, 0) : ct.add(e.pdbx_PDB_ins_code, n + 26, n + 27), e["U[1][1]"][e.index] = qd(a, n + 28, n + 35) / 1e4, e["U[2][2]"][e.index] = qd(a, n + 35, n + 42) / 1e4, e["U[3][3]"][e.index] = qd(a, n + 42, n + 49) / 1e4, e["U[1][2]"][e.index] = qd(a, n + 49, n + 56) / 1e4, e["U[1][3]"][e.index] = qd(a, n + 56, n + 63) / 1e4, e["U[2][3]"][e.index] = qd(a, n + 63, n + 70) / 1e4, o >= 78 ? (ot.trim(r, n + 76, n + 78), r.tokenStart < r.tokenEnd ? ct.addToken(e.type_symbol, r) : Z2(e.type_symbol, a, n + 12, n + 16)) : Z2(e.type_symbol, a, n + 12, n + 16), e.index++;
}
function f$(e) {
  return _e(this, 0, void 0, function() {
    var t, r, n, i, a, o, u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _, S, D, I, M, F, P, E, B, N, O, z;
    return ye(this, function(V) {
      for (t = e.lines, r = t.data, n = t.indices, i = ot(r), a = !!e.isPdbqt, o = 0, u = 0, I = 0, g = t.count; I < g; I++) switch (h = n[2 * I], y = n[2 * I + 1], r[h]) {
        case "A":
          ai(r, h, y, "ATOM  ") ? o++ : ai(r, h, y, "ANISOU") && u++;
          break;
        case "H":
          ai(r, h, y, "HETATM") && o++;
      }
      for (s = function(X, W) {
        var Q = function() {
          return ct.create(X, 2 * W);
        };
        return { index: 0, group_PDB: Q(), id: [], auth_atom_id: Q(), label_alt_id: Q(), auth_comp_id: Q(), auth_asym_id: Q(), auth_seq_id: Q(), pdbx_PDB_ins_code: Q(), Cartn_x: Q(), Cartn_y: Q(), Cartn_z: Q(), occupancy: Q(), B_iso_or_equiv: Q(), type_symbol: Q(), pdbx_PDB_model_num: [], label_entity_id: [], partial_charge: Q(), pdbx_formal_charge: Q(), cdr: Q(), em_confidence: Q() };
      }(r, o), c = function(X, W) {
        var Q = function() {
          return new Float32Array(W);
        }, te = function() {
          return ct.create(X, 2 * W);
        };
        return { index: 0, count: W, id: [], type_symbol: te(), pdbx_label_atom_id: te(), pdbx_label_alt_id: te(), pdbx_label_comp_id: te(), pdbx_label_asym_id: te(), pdbx_label_seq_id: te(), pdbx_PDB_ins_code: te(), "U[1][1]": Q(), "U[2][2]": Q(), "U[3][3]": Q(), "U[1][2]": Q(), "U[1][3]": Q(), "U[2][3]": Q(), pdbx_auth_seq_id: te(), pdbx_auth_comp_id: te(), pdbx_auth_asym_id: te(), pdbx_auth_atom_id: te() };
      }(r, u), l = new wf(), d = [], f = [], m = 0, v = "", p = void 0, I = 0, g = t.count; I < g; I++) switch (h = n[2 * I], y = n[2 * I + 1], r[h]) {
        case "A":
          ai(r, h, y, "ATOM  ") ? (m || (m++, v = "" + m), kw(s, v, i, h, y, a)) : ai(r, h, y, "ANISOU") && d$(c, 0, i, h, y);
          break;
        case "C":
          if (ai(r, h, y, "CRYST1")) d.push.apply(d, YJ(e.id || "?", r.substring(h, y)));
          else if (ai(r, h, y, "CONECT")) {
            for (x = I + 1; h = n[2 * x], y = n[2 * x + 1], ai(r, h, y, "CONECT"); ) x++;
            p ? Ir && console.log("only single CONECT block allowed, ignoring others") : p = [I, x], I = x - 1;
          } else if (ai(r, h, y, "COMPND")) {
            for (x = I + 1; h = n[2 * x], y = n[2 * x + 1], ai(r, h, y, "COMPND"); ) x++;
            l.setCompounds(t$(t, I, x)), I = x - 1;
          }
          break;
        case "H":
          if (ai(r, h, y, "HETATM")) m || (m++, v = "" + m), kw(s, v, i, h, y, a);
          else if (ai(r, h, y, "HELIX")) {
            for (x = I + 1; h = n[2 * x], y = n[2 * x + 1], ai(r, h, y, "HELIX"); ) x++;
            d.push(JJ(t, I, x)), I = x - 1;
          } else if (ai(r, h, y, "HETNAM")) {
            for (x = I + 1; h = n[2 * x], y = n[2 * x + 1], ai(r, h, y, "HETNAM"); ) x++;
            f.push.apply(f, Array.from(r$(t, I, x).entries())), I = x - 1;
          }
          break;
        case "M":
          if (ai(r, h, y, "MODEL ") && (m++, v = "" + m), ai(r, h, y, "MTRIX")) {
            for (x = I + 1; h = n[2 * x], y = n[2 * x + 1], ai(r, h, y, "MTRIX"); ) x++;
            d.push.apply(d, ZJ(t, I, x)), I = x - 1;
          }
          break;
        case "O":
          break;
        case "R":
          if (ai(r, h, y, "REMARK 350")) {
            for (x = I + 1; h = n[2 * x], y = n[2 * x + 1], ai(r, h, y, "REMARK 350"); ) x++;
            d.push.apply(d, WJ(t, I, x)), I = x - 1;
          }
          break;
        case "S":
          if (ai(r, h, y, "SHEET")) {
            for (x = I + 1; h = n[2 * x], y = n[2 * x + 1], ai(r, h, y, "SHEET"); ) x++;
            d.push($J(t, I, x)), I = x - 1;
          }
      }
      for (A = oe.ofIntTokens(s.auth_seq_id), b = oe.ofStringTokens(s.auth_atom_id), _ = oe.ofStringTokens(s.auth_comp_id), S = oe.ofStringTokens(s.auth_asym_id), (D = new Cf(A, b)).setNames(f), l.setNames(f), I = 0, M = _.rowCount; I < M; ++I) F = _.value(I), P = Dm(D.add(F, I).type, F), s.label_entity_id[I] = l.getEntityId(F, P, S.value(I));
      var U, H, K, j;
      for (U = s, H = st.ofTokens(U.auth_asym_id), K = st.ofTokens(U.auth_atom_id), j = st.ofTokens(U.auth_comp_id), E = { auth_asym_id: H, auth_atom_id: K, auth_comp_id: j, auth_seq_id: st.ofTokens(U.auth_seq_id), B_iso_or_equiv: st.ofTokens(U.B_iso_or_equiv), Cartn_x: st.ofTokens(U.Cartn_x), Cartn_y: st.ofTokens(U.Cartn_y), Cartn_z: st.ofTokens(U.Cartn_z), group_PDB: st.ofTokens(U.group_PDB), id: st.ofStrings(U.id), label_alt_id: st.ofTokens(U.label_alt_id), label_asym_id: H, label_atom_id: K, label_comp_id: j, label_seq_id: st.ofUndefined(U.index, oe.Schema.int), label_entity_id: st.ofStrings(U.label_entity_id), occupancy: jq(U.occupancy) ? st.ofUndefined(U.index, oe.Schema.float) : st.ofTokens(U.occupancy), type_symbol: st.ofTokens(U.type_symbol), pdbx_PDB_ins_code: st.ofTokens(U.pdbx_PDB_ins_code), pdbx_PDB_model_num: st.ofStrings(U.pdbx_PDB_model_num), partial_charge: st.ofTokens(U.partial_charge), pdbx_formal_charge: st.ofTokens(U.pdbx_formal_charge), cdr: st.ofTokens(U.cdr), em_confidence: st.ofTokens(U.em_confidence) }, p && d.push(function(X, W, Q, te) {
        for (var ee = {}, $ = 0, ie = te.id.rowCount; $ < ie; ++$) ee[te.id.str($)] = $;
        var ae = function(Re) {
          return X.data.substring(X.indices[2 * Re], X.indices[2 * Re + 1]);
        }, se = [], le = [], pe = [], we = [], Ge = [], Ue = [], Ke = [], Ze = [], Fe = [], Je = [], Ne = [11, 16, 21, 26], nt = 1;
        for ($ = W; $ < Q; $++) {
          var re = ae($), J = ee[parseInt(re.substr(6, 5))], ce = {};
          if (J !== void 0) for (var de = 0; de < 4; ++de) {
            var ve = parseInt(re.substr(Ne[de], 5));
            if (!Number.isNaN(ve)) {
              var he = ee[ve];
              he !== void 0 && (J > he || ce[he] === void 0 && (se.push("covale".concat(nt)), le.push("covale"), pe.push(te.label_asym_id.str(J)), Ge.push(te.auth_seq_id.int(J)), we.push(te.label_seq_id.int(J)), Ue.push(te.label_atom_id.str(J)), Ke.push(te.label_asym_id.str(he)), Fe.push(te.auth_seq_id.int(he)), Ze.push(te.label_seq_id.int(he)), Je.push(te.label_atom_id.str(he)), nt += 1));
            }
          }
        }
        var Se = { id: st.ofStrings(se), conn_type_id: st.ofStrings(le), ptnr1_label_asym_id: st.ofStrings(pe), ptnr1_auth_seq_id: st.ofNumbers(Ge), ptnr1_label_seq_id: st.ofNumbers(we), ptnr1_label_atom_id: st.ofStrings(Ue), ptnr2_label_asym_id: st.ofStrings(Ke), ptnr2_label_seq_id: st.ofNumbers(Ze), ptnr2_auth_seq_id: st.ofNumbers(Fe), ptnr2_label_atom_id: st.ofStrings(Je) };
        return va.ofFields("struct_conn", Se);
      }(t, p[0], p[1], E)), B = { entity: va.ofTable("entity", l.getEntityTable()), chem_comp: va.ofTable("chem_comp", D.getChemCompTable()), atom_site: va.ofFields("atom_site", E), atom_site_anisotrop: va.ofFields("atom_site_anisotrop", l$(c)) }, N = 0, O = d; N < O.length; N++) z = O[N], B[z.name] = z;
      return [2, { header: e.id || "PDB", categoryNames: Object.keys(B), categories: B }];
    });
  });
}
function UP(e) {
  var t = this;
  return er.create("Parse PDB", function(r) {
    return _e(t, 0, void 0, function() {
      var n, i, a, o, u, s, c, l, d, f, m;
      return ye(this, function(v) {
        switch (v.label) {
          case 0:
            return [4, r.update("Converting to mmCIF")];
          case 1:
            return v.sent(), [4, f$(e)];
          case 2:
            return n = v.sent(), i = mn.fromFrame(n, void 0, c6.create(e)), [4, Oc(ld(i.data.db, !0), i, r)];
          case 3:
            return a = v.sent(), (o = (m = n.categories.atom_site) === null || m === void 0 ? void 0 : m.getField("partial_charge")) && a.frameCount === 1 && (u = a.representative, s = u.atomicHierarchy.atomSourceIndex, c = oe.isIdentity(s), l = c ? void 0 : s.toArray({ array: Int32Array }), d = o.toFloatArray(), f = l ? oe.ofFloatArray(oe.mapToArray(s, function(p) {
              return d[p];
            }, Float32Array)) : oe.ofFloatArray(d), Pc.Provider.set(u, { data: f, type: "GASTEIGER" })), [2, a];
        }
      });
    });
  });
}
(function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "pdb";
  }, e.create = function(t) {
    return { kind: "pdb", name: t.id || "", data: t };
  };
})(c6 || (c6 = {}));
var l6, p$ = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    var t;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return e.trim() ? [4, VP(e).run()] : [2, [zs()]];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, UP(t.result).run()];
        case 2:
          return [2, r.sent().frames.map(function(n) {
            return tt.ofModel(n, { dynamicBonds: !0 });
          })];
      }
    });
  });
} };
function m$(e) {
  switch (e) {
    case 7:
      return -3;
    case 6:
      return -2;
    case 5:
      return -1;
    case 0:
    case 4:
      return 0;
    case 3:
      return 1;
    case 2:
      return 2;
    case 1:
      return 3;
    default:
      return console.error("Value ".concat(e, " is outside the 0-7 range, defaulting to 0.")), 0;
  }
}
function Y_(e, t) {
  for (var r = ct.create(e.data, 2 * t), n = ct.create(e.data, 2 * t), i = ct.create(e.data, 2 * t), a = ct.create(e.data, 2 * t), o = ct.create(e.data, 2 * t), u = 0; u < t; ++u) {
    ot.markLine(e);
    var s = e.tokenStart, c = e.position;
    ot.trim(e, s, s + 10), ct.addUnchecked(r, e.tokenStart, e.tokenEnd), ot.trim(e, s + 10, s + 20), ct.addUnchecked(n, e.tokenStart, e.tokenEnd), ot.trim(e, s + 20, s + 30), ct.addUnchecked(i, e.tokenStart, e.tokenEnd), ot.trim(e, s + 31, s + 34), ct.addUnchecked(a, e.tokenStart, e.tokenEnd), ot.trim(e, s + 36, s + 39), ct.addUnchecked(o, e.tokenStart, e.tokenEnd), e.position = c;
  }
  return { count: t, x: Gr(r)(oe.Schema.float), y: Gr(n)(oe.Schema.float), z: Gr(i)(oe.Schema.float), type_symbol: Gr(a)(oe.Schema.str), formal_charge: Gr(o)(oe.Schema.int) };
}
function W_(e, t) {
  for (var r = ct.create(e.data, 2 * t), n = ct.create(e.data, 2 * t), i = ct.create(e.data, 2 * t), a = 0; a < t; ++a) {
    ot.markLine(e);
    var o = e.tokenStart, u = e.position;
    ot.trim(e, o, o + 3), ct.addUnchecked(r, e.tokenStart, e.tokenEnd), ot.trim(e, o + 3, o + 6), ct.addUnchecked(n, e.tokenStart, e.tokenEnd), ot.trim(e, o + 6, o + 9), ct.addUnchecked(i, e.tokenStart, e.tokenEnd), e.position = u;
  }
  return { count: t, atomIdxA: Gr(r)(oe.Schema.int), atomIdxB: Gr(n)(oe.Schema.int), order: Gr(i)(oe.Schema.int) };
}
function h$(e, t, r) {
  ot.trim(e, t + 6, t + 9);
  for (var n = parseInt(ot.getTokenString(e)), i = 0; i < n; ++i) {
    var a = 9 + 8 * i;
    ot.trim(e, t + a, t + a + 4);
    var o = ot.getTokenString(e);
    r.atomIdx.push(+o), ot.trim(e, t + a + 4, t + a + 8);
    var u = ot.getTokenString(e);
    r.charge.push(+u);
  }
  ot.eatLine(e);
}
function Z_(e) {
  for (var t = { atomIdx: [], charge: [] }; e.position < e.length; ) {
    var r = e.position;
    ot.trim(e, r + 3, r + 6);
    var n = ot.getTokenString(e);
    if (n === "END") break;
    ot.eatLine(e), n === "CHG" && h$(e, r, t);
  }
  return { atomIdx: oe.ofIntArray(t.atomIdx), charge: oe.ofIntArray(t.charge) };
}
function v$(e) {
  var t = ot(e), r = ot.readLine(t).trim(), n = ot.readLine(t).trim(), i = ot.readLine(t).trim(), a = ot.readLine(t), o = +a.substr(0, 3), u = +a.substr(3, 3), s = { title: r, program: n, comment: i, atoms: Y_(t, o), bonds: W_(t, u), formalCharges: Z_(t) };
  return Pi.success(s);
}
function g$(e) {
  var t = this;
  return er.create("Parse Mol", function() {
    return _e(t, 0, void 0, function() {
      return ye(this, function(r) {
        return [2, v$(e)];
      });
    });
  });
}
function HP(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o, u, s, c, l, d, f, m, v, p, g, h, y, x;
    return ye(this, function(A) {
      switch (A.label) {
        case 0:
          if (n = e.atoms, i = e.bonds, a = e.formalCharges, o = oe.ofConst("MOL", e.atoms.count, oe.Schema.str), u = oe.ofConst("A", e.atoms.count, oe.Schema.str), s = oe.asArrayColumn(n.type_symbol), c = oe.ofConst(1, n.count, oe.Schema.int), l = new Int32Array(e.atoms.count), a.atomIdx.rowCount > 0) for (d = 0; d < a.atomIdx.rowCount; d++) l[a.atomIdx.value(d) - 1] = a.charge.value(d);
          else for (d = 0; d < e.atoms.count; d++) l[d] = m$(n.formal_charge.value(d));
          return f = Or.ofPartialColumns(_o.atom_site, { auth_asym_id: u, auth_atom_id: s, auth_comp_id: o, auth_seq_id: c, Cartn_x: oe.asArrayColumn(n.x, Float32Array), Cartn_y: oe.asArrayColumn(n.y, Float32Array), Cartn_z: oe.asArrayColumn(n.z, Float32Array), id: oe.range(0, n.count - 1), label_asym_id: u, label_atom_id: s, label_comp_id: o, label_seq_id: c, label_entity_id: oe.ofConst("1", n.count, oe.Schema.str), occupancy: oe.ofConst(1, n.count, oe.Schema.float), type_symbol: s, pdbx_PDB_model_num: oe.ofConst(1, n.count, oe.Schema.int), pdbx_formal_charge: oe.ofIntArray(l) }, n.count), (m = new wf()).setNames([["MOL", "Ligand"]]), m.getEntityId("MOL", 0, "A"), (v = new Cf(c, s)).setNames([["MOL", "Unknown Molecule"]]), v.add("MOL", 0), [4, Oc(ld({ entity: m.getEntityTable(), chem_comp: v.getChemCompTable(), atom_site: f }), t ?? l6.create(e), r)];
        case 1:
          return (p = A.sent()).frameCount > 0 && (g = oe.ofIntArray(oe.mapToArray(i.atomIdxA, function(b) {
            return b - 1;
          }, Int32Array)), h = oe.ofIntArray(oe.mapToArray(i.atomIdxB, function(b) {
            return b - 1;
          }, Int32Array)), y = oe.asArrayColumn(i.order, Int32Array), x = Ei.fromData({ pairs: { indexA: g, indexB: h, order: y }, count: n.count }), Ei.Provider.set(p.representative, x)), [2, p];
      }
    });
  });
}
(function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "mol";
  }, e.create = function(t) {
    return { kind: "mol", name: t.title, data: t };
  };
})(l6 || (l6 = {}));
var y$ = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    var t, r;
    return ye(this, function(n) {
      switch (n.label) {
        case 0:
          return e.trim() ? [4, g$(e).run()] : [2, [zs()]];
        case 1:
          if ((t = n.sent()).isError) throw t;
          return [4, (i = t.result, er.create("Parse MOL", function(a) {
            return HP(i, void 0, a);
          })).run()];
        case 2:
          return r = n.sent(), [2, [tt.ofModel(r.representative)]];
      }
      var i;
    });
  });
} };
function uc(e) {
  ot.skipWhitespace(e), ot.eatValue(e);
}
function sc(e, t) {
  var r = e.position;
  ot.skipWhitespace(e), ot.eatValue(e), ot.trim(e, r, e.position), ct.addUnchecked(t, e.tokenStart, e.tokenEnd);
}
var d6, Z4 = "$$$$";
function b$(e) {
  var t = ot.readLine(e).trim(), r = ot.readLine(e).trim(), n = ot.readLine(e).trim(), i = ot.readLine(e), a = i.trim().endsWith("V3000"), o = a ? function(v) {
    var p = ct.create(v.data, 1), g = ct.create(v.data, 1);
    return ot.eatLine(v), uc(v), uc(v), uc(v), sc(v, p), sc(v, g), ot.eatLine(v), { atomCount: Gr(p)(oe.Schema.int).value(0), bondCount: Gr(g)(oe.Schema.int).value(0) };
  }(e) : function(v) {
    return { atomCount: +v.substr(0, 3), bondCount: +v.substr(3, 3) };
  }(i), u = o.atomCount, s = o.bondCount;
  if (!Number.isNaN(u) && !Number.isNaN(s)) {
    var c = { atomIdx: oe.ofConst(0, u, oe.Schema.int), charge: oe.ofConst(0, u, oe.Schema.int) }, l = a ? function(v, p) {
      for (var g = ct.create(v.data, 2 * p), h = ct.create(v.data, 2 * p), y = ct.create(v.data, 2 * p), x = ct.create(v.data, 2 * p), A = 0; A < p; ++A) {
        ot.markLine(v), uc(v), uc(v), uc(v);
        var b = v.position;
        sc(v, x), sc(v, g), sc(v, h), sc(v, y), v.position = b;
      }
      return ot.eatLine(v), ot.eatLine(v), { count: p, x: Gr(g)(oe.Schema.float), y: Gr(h)(oe.Schema.float), z: Gr(y)(oe.Schema.float), type_symbol: Gr(x)(oe.Schema.str), formal_charge: oe.ofConst(0, p, oe.Schema.int) };
    }(e, u) : Y_(e, u), d = a ? function(v, p) {
      for (var g = ct.create(v.data, 2 * p), h = ct.create(v.data, 2 * p), y = ct.create(v.data, 2 * p), x = 0; x < p; ++x) {
        ot.markLine(v), uc(v), uc(v), uc(v);
        var A = v.position;
        sc(v, y), sc(v, g), sc(v, h), v.position = A;
      }
      return ot.eatLine(v), ot.eatLine(v), { count: p, atomIdxA: Gr(g)(oe.Schema.float), atomIdxB: Gr(h)(oe.Schema.float), order: Gr(y)(oe.Schema.float) };
    }(e, s) : W_(e, s), f = a ? c : Z_(e), m = function(v) {
      for (var p = ct.create(v.data, 32), g = ct.create(v.data, 32); v.position < v.length; ) {
        var h = ot.readLine(v);
        if (h.startsWith(Z4)) break;
        if (h && h.startsWith("> ")) {
          ct.add(p, v.tokenStart + 2, v.tokenEnd), ot.markLine(v);
          for (var y = v.tokenStart, x = v.tokenEnd, A = !1; v.position < v.length; ) {
            var b = ot.readLine(v);
            if (!b || b.startsWith(Z4) || b.startsWith("> ")) {
              ct.add(g, y, x), A = !0;
              break;
            }
            x = v.tokenEnd;
          }
          A || ct.add(g, y, x);
        }
      }
      return { dataHeader: Gr(p)(oe.Schema.str), data: Gr(g)(oe.Schema.str) };
    }(e);
    return { molFile: { title: t, program: r, comment: n, atoms: l, bonds: d, formalCharges: f }, dataItems: m };
  }
  for (; e.position < e.length && !ot.readLine(e).startsWith(Z4); )
    ;
}
function _$(e) {
  for (var t = ot(e), r = []; t.position < t.length; ) {
    var n = b$(t);
    n && r.push(n);
  }
  return Pi.success({ compounds: r });
}
function x$(e) {
  var t = this;
  return er.create("Parse Sdf", function() {
    return _e(t, 0, void 0, function() {
      return ye(this, function(r) {
        return [2, _$(e)];
      });
    });
  });
}
(function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "sdf";
  }, e.create = function(t) {
    return { kind: "sdf", name: t.molFile.title, data: t };
  };
})(d6 || (d6 = {}));
var Q4, Zp, uf = {};
Q4 = uf, function() {
  var e = { not_string: /[^s]/, not_bool: /[^t]/, not_type: /[^T]/, not_primitive: /[^v]/, number: /[diefg]/, numeric_arg: /[bcdiefguxX]/, json: /[j]/, not_json: /[^j]/, text: /^[^\x25]+/, modulo: /^\x25{2}/, placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/, key: /^([a-z_][a-z_\d]*)/i, key_access: /^\.([a-z_][a-z_\d]*)/i, index_access: /^\[(\d+)\]/, sign: /^[+-]/ };
  function t(i) {
    return function(a, o) {
      var u, s, c, l, d, f, m, v, p, g = 1, h = a.length, y = "";
      for (s = 0; s < h; s++) if (typeof a[s] == "string") y += a[s];
      else if (typeof a[s] == "object") {
        if ((l = a[s]).keys) for (u = o[g], c = 0; c < l.keys.length; c++) {
          if (u == null) throw new Error(t('[sprintf] Cannot access property "%s" of undefined value "%s"', l.keys[c], l.keys[c - 1]));
          u = u[l.keys[c]];
        }
        else u = l.param_no ? o[l.param_no] : o[g++];
        if (e.not_type.test(l.type) && e.not_primitive.test(l.type) && u instanceof Function && (u = u()), e.numeric_arg.test(l.type) && typeof u != "number" && isNaN(u)) throw new TypeError(t("[sprintf] expecting number but found %T", u));
        switch (e.number.test(l.type) && (v = u >= 0), l.type) {
          case "b":
            u = parseInt(u, 10).toString(2);
            break;
          case "c":
            u = String.fromCharCode(parseInt(u, 10));
            break;
          case "d":
          case "i":
            u = parseInt(u, 10);
            break;
          case "j":
            u = JSON.stringify(u, null, l.width ? parseInt(l.width) : 0);
            break;
          case "e":
            u = l.precision ? parseFloat(u).toExponential(l.precision) : parseFloat(u).toExponential();
            break;
          case "f":
            u = l.precision ? parseFloat(u).toFixed(l.precision) : parseFloat(u);
            break;
          case "g":
            u = l.precision ? String(Number(u.toPrecision(l.precision))) : parseFloat(u);
            break;
          case "o":
            u = (parseInt(u, 10) >>> 0).toString(8);
            break;
          case "s":
            u = String(u), u = l.precision ? u.substring(0, l.precision) : u;
            break;
          case "t":
            u = String(!!u), u = l.precision ? u.substring(0, l.precision) : u;
            break;
          case "T":
            u = Object.prototype.toString.call(u).slice(8, -1).toLowerCase(), u = l.precision ? u.substring(0, l.precision) : u;
            break;
          case "u":
            u = parseInt(u, 10) >>> 0;
            break;
          case "v":
            u = u.valueOf(), u = l.precision ? u.substring(0, l.precision) : u;
            break;
          case "x":
            u = (parseInt(u, 10) >>> 0).toString(16);
            break;
          case "X":
            u = (parseInt(u, 10) >>> 0).toString(16).toUpperCase();
        }
        e.json.test(l.type) ? y += u : (!e.number.test(l.type) || v && !l.sign ? p = "" : (p = v ? "+" : "-", u = u.toString().replace(e.sign, "")), f = l.pad_char ? l.pad_char === "0" ? "0" : l.pad_char.charAt(1) : " ", m = l.width - (p + u).length, d = l.width && m > 0 ? f.repeat(m) : "", y += l.align ? p + u + d : f === "0" ? p + d + u : d + p + u);
      }
      return y;
    }(function(a) {
      if (n[a]) return n[a];
      for (var o, u = a, s = [], c = 0; u; ) {
        if ((o = e.text.exec(u)) !== null) s.push(o[0]);
        else if ((o = e.modulo.exec(u)) !== null) s.push("%");
        else {
          if ((o = e.placeholder.exec(u)) === null) throw new SyntaxError("[sprintf] unexpected placeholder");
          if (o[2]) {
            c |= 1;
            var l = [], d = o[2], f = [];
            if ((f = e.key.exec(d)) === null) throw new SyntaxError("[sprintf] failed to parse named argument key");
            for (l.push(f[1]); (d = d.substring(f[0].length)) !== ""; ) if ((f = e.key_access.exec(d)) !== null) l.push(f[1]);
            else {
              if ((f = e.index_access.exec(d)) === null) throw new SyntaxError("[sprintf] failed to parse named argument key");
              l.push(f[1]);
            }
            o[2] = l;
          } else c |= 2;
          if (c === 3) throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");
          s.push({ placeholder: o[0], param_no: o[1], keys: o[2], sign: o[3], pad_char: o[4], align: o[5], width: o[6], precision: o[7], type: o[8] });
        }
        u = u.substring(o[0].length);
      }
      return n[a] = s;
    }(i), arguments);
  }
  function r(i, a) {
    return t.apply(null, [i].concat(a || []));
  }
  var n = /* @__PURE__ */ Object.create(null);
  Q4.sprintf = t, Q4.vsprintf = r, typeof window < "u" && (window.sprintf = t, window.vsprintf = r);
}(), function(e) {
  e.PDB = "chemical/pdb", e.SDF = "chemical/x-mdl-sdf", e.MOL = "chemical/x-mdl-molfile", e.MOL2 = "chemical/x-mol2";
}(Zp || (Zp = {}));
var A$ = ["HEADER", "SOURCE", "AUTHOR", "OBSLTE", "KEYWDS", "REVDAT", "TITLE", "EXPDTA", "SPRSDE", "SPLT", "NUMMDL", "JRNL", "CAVEAT", "MDLTYP", "REMARKS", "COMPND"], S$ = ["DBREF", "DBREF1", "DBREF2", "SEQADV", "SEQRES", "MODRES"], C$ = ["HET   ", "HETNAM", "HETSYN", "FORMUL"], Q_ = function(e, t) {
  var r = Ko(e);
  return (r == null ? void 0 : r.sourceData.kind) === "mmCIF" ? r.sourceData.data.source.data.lines.data.split(`
`).filter(function(n) {
    for (var i = 0, a = t.length; i < a; i++) if (n.startsWith(t[i])) return !0;
    return !1;
  }) : [];
};
function J_(e, t, r, n) {
  var i, a = [];
  if (((i = e.models[0]) === null || i === void 0 ? void 0 : i.sourceData.kind) === "mmCIF") {
    var o = We(We(We([], A$, !0), S$, !0), C$, !0);
    a.push.apply(a, Q_(e, o));
  }
  var u = [];
  t ? u.push.apply(u, We([], t, !0).sort(function(p, g) {
    return p - g;
  })) : e.units.forEach(function(p) {
    return u.push.apply(u, We([], p.elements, !0));
  });
  var s = e.units[0], c = [], l = !1, d = !1;
  if (u.forEach(function(p) {
    var g = { elementId: p, group_PDB: s.model.atomicHierarchy.residues.group_PDB.value(s.residueIndex[p]), atom_id: s.model.atomicConformation.atomId.value(p), auth_atom_id: s.model.atomicHierarchy.atoms.auth_atom_id.value(p), label_alt_id: s.model.atomicHierarchy.atoms.label_alt_id.value(p), auth_comp_id: s.model.atomicHierarchy.atoms.label_comp_id.value(p), auth_asym_id: s.model.atomicHierarchy.chains.auth_asym_id.value(s.chainIndex[p]), auth_seq_id: s.model.atomicHierarchy.residues.auth_seq_id.value(s.residueIndex[p]), pdbx_PDB_ins_code: s.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(s.residueIndex[p]), x: s.model.atomicConformation.x[p], y: s.model.atomicConformation.y[p], z: s.model.atomicConformation.z[p], occupancy: s.model.atomicConformation.occupancy.value(p), B_iso_or_equiv: s.model.atomicConformation.B_iso_or_equiv.value(p), type_symbol: mm(s.model.atomicHierarchy.atoms.type_symbol.value(p)), charge: s.model.atomicHierarchy.atoms.pdbx_formal_charge.value(p), em_confidence: s.model.atomicHierarchy.atoms.em_confidence.value(p) };
    c.push(g), g.em_confidence && (l = !0), g.charge && (d = !0);
  }), n) {
    var f = n(c, []), m = f.editedAtomList, v = f.editedBondList;
    return a.push(f6(m, v, r && d, r && l)), a.join(`
`);
  }
  return a.push(f6(c, [], r && d, r && l)), a.join(`
`);
}
function f6(e, t, r, n) {
  var i = "ATOM  %5d %-4s%1s%3s %1s%4d%1s   %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s".concat(r ? "%4.1f" : "%2s  ").concat(n ? "   %5.2f" : ""), a = "HETATM%5d %-4s%1s%3s %1s%4d%1s   %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s".concat(r ? "%4.1f" : "%2s  ").concat(n ? "   %5.2f" : ""), o = "CONECT%5s%5s%5s%5s%5s", u = [], s = [];
  return e.forEach(function(c) {
    var l = c.elementId, d = c.atom_id, f = c.auth_atom_id, m = c.label_alt_id, v = c.auth_comp_id, p = c.auth_asym_id, g = c.auth_seq_id, h = c.pdbx_PDB_ins_code, y = h === void 0 ? " " : h, x = c.x, A = c.y, b = c.z, _ = c.occupancy, S = c.B_iso_or_equiv, D = c.type_symbol, I = c.group_PDB, M = c.charge, F = c.em_confidence, P = I === "HETATM" ? a : i;
    u.push(uf.sprintf(P, d, f, m, v, p, g, y, x, A, b, _, S, " ", D, r ? M : "  ", n ? F : ""));
    var E = [];
    if (t && (t.forEach(function(O) {
      if (O.a !== l || E.includes(O.atom_idB)) {
        if (O.b === l && !E.includes(O.atom_idA)) for (z = 0, V = O.order; z < V; z++) E.push(O.atom_idA);
      } else for (var z = 0, V = O.order; z < V; z++) E.push(O.atom_idB);
    }), E.length > 0)) {
      for (var B = []; E.length > 0; ) {
        var N = E.shift();
        N && B.push(N), B.length === 4 && (s.push(uf.sprintf(o, d, B[0], B[1], B[2], B[3])), B = []);
      }
      B.length > 0 && (s.push(uf.sprintf(o, d, B[0] || "", B[1] || "", B[2] || "", B[3] || "")), B = []);
    }
  }), We(We([], u, !0), s, !0).join(`
`);
}
function p6(e, t, r, n, i) {
  var a, o, u, s, c, l;
  i === void 0 && (i = !1);
  var d = [];
  if (e.units.forEach(function(O) {
    return d.push.apply(d, We([], O.elements, !0));
  }), d.length > 999) return "";
  if (d.length <= 0) {
    if (n) {
      var f = n([], []), m = f.editedAtomList, v = f.editedBondList, p = (a = e == null ? void 0 : e.state.model) !== null && a !== void 0 ? a : e == null ? void 0 : e.state.models[0], g = (o = p == null ? void 0 : p.sourceData) === null || o === void 0 ? void 0 : o.kind, h = r2(m, v);
      return g === "sdf" || g === "mol" ? We(We([p.entryId], h.split(`
`).slice(1), !0), ["$$$$"], !1).join(`
`) : "".concat(h, `
$$$$`);
    }
    return "";
  }
  var y = e.units[0], x = [], A = /* @__PURE__ */ new Map();
  d.forEach(function(O) {
    var z;
    x.push({ elementId: O, group_PDB: y.model.atomicHierarchy.residues.group_PDB.value(y.residueIndex[O]), atom_id: y.model.atomicConformation.atomId.value(O), auth_atom_id: y.model.atomicHierarchy.atoms.label_atom_id.value(O), label_alt_id: y.model.atomicHierarchy.atoms.label_alt_id.value(O), auth_comp_id: y.model.atomicHierarchy.atoms.label_comp_id.value(O), auth_asym_id: y.model.atomicHierarchy.chains.auth_asym_id.value(y.chainIndex[O]), auth_seq_id: y.model.atomicHierarchy.residues.auth_seq_id.value(y.residueIndex[O]), pdbx_PDB_ins_code: y.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(y.residueIndex[O]), x: y.model.atomicConformation.x[O], y: y.model.atomicConformation.y[O], z: y.model.atomicConformation.z[O], occupancy: y.model.atomicConformation.occupancy.value(O), B_iso_or_equiv: y.model.atomicConformation.B_iso_or_equiv.value(O), type_symbol: mm(y.model.atomicHierarchy.atoms.type_symbol.value(O)), charge: y.model.atomicHierarchy.atoms.pdbx_formal_charge.value(O) || ((z = Pc.Provider.get(y.model)) === null || z === void 0 ? void 0 : z.data.value(O)) || 0 });
  });
  var b = new Set(t), _ = /* @__PURE__ */ new Map();
  if (i && ((u = e.model) === null || u === void 0 ? void 0 : u.sourceData.kind) === "mmCIF") for (var S = function(O, z) {
    for (var V = e.units[O], U = function(j, X) {
      var W = V.rings.all[V.rings.aromaticRings[j]].map(function(Q) {
        return V.elements[Q];
      });
      W.forEach(function(Q, te) {
        b.has(Q) && _.set(Q, new Set(We(We([], W.slice(0, te), !0), W.slice(te + 1), !0)));
      });
    }, H = 0, K = V.rings.aromaticRings.length; H < K; H++) U(H);
  }, D = 0, I = e.units.length; D < I; D++) S(D);
  e.units.forEach(function(O) {
    for (var z, V = 0, U = O.bonds.a.length; V < U; V++) {
      var H = O.elements[O.bonds.a[V]], K = O.elements[O.bonds.b[V]];
      if (d.includes(H) && d.includes(K) && !A.has("".concat(H, "_").concat(K)) && !A.has("".concat(K, "_").concat(H))) {
        var j = i && _.has(H) && (!((z = _.get(H)) === null || z === void 0) && z.has(K)) ? 4 : O.bonds.edgeProps.order[V];
        A.set("".concat(H, "_").concat(K), { a: d.indexOf(H) + 1, b: d.indexOf(K) + 1, order: j });
      }
    }
  });
  var M = [];
  if (((s = e.model) === null || s === void 0 ? void 0 : s.sourceData.kind) === "sdf" && (!((c = e.state.models) === null || c === void 0) && c.length)) for (var F = (l = e.state.models[0]) === null || l === void 0 ? void 0 : l.sourceData.data.dataItems, P = (D = 0, F.data.rowCount); D < P; D++) M.push("> ".concat(F.dataHeader.value(D), `
`).concat(F.data.value(D)));
  if (n) {
    var E = n(x, Array.from(A).map(function(O) {
      return O[1];
    })), B = (m = E.editedAtomList, v = E.editedBondList, r2(m, v));
    return "".concat(B, `
`).concat(M.join(`

`)).concat(M.length ? `

` : "", "$$$$");
  }
  var N = r2(x, Array.from(A).map(function(O) {
    return O[1];
  }));
  return "".concat(N, `
`).concat(M.join(`

`)).concat(M.length ? `

` : "", "$$$$");
}
var r2 = function(e, t, r) {
  var n = [];
  return n.push("".concat("", `

`)), n.push(uf.sprintf("%3d%3d  0  0  0  0  0  0  0  0999 V2000", e.length, t.length)), e.forEach(function(i) {
    var a = i.x, o = i.y, u = i.z, s = i.type_symbol, c = i.charge;
    n.push(uf.sprintf("%10.4f%10.4f%10.4f %-2s  0%3d  0  0  0  0  0  0  0  0  0  0", a, o, u, s, function(l) {
      switch (l) {
        case 0:
          return 0;
        case 3:
          return 1;
        case 2:
          return 2;
        case 1:
          return 3;
        case -1:
          return 5;
        case -2:
          return 6;
        case -3:
          return 7;
        default:
          return 0;
      }
    }(c)));
  }), t.forEach(function(i) {
    var a = i.a, o = i.b, u = i.order;
    n.push(uf.sprintf("%3s%3s%3s  0  0  0  0", a, o, u));
  }), n.push("M  END"), n.join(`
`);
}, rp = function(e, t, r, n) {
  return { elementId: -1, group_PDB: "HETATM", atom_id: e, auth_atom_id: t, label_alt_id: "", auth_comp_id: "UNK", auth_asym_id: " ", auth_seq_id: "1", x: parseFloat(r[0].toFixed(3)), y: parseFloat(r[1].toFixed(3)), z: parseFloat(r[2].toFixed(3)), occupancy: "1", B_iso_or_equiv: "0.00", type_symbol: t, charge: n ?? 0 };
}, w$ = function(e, t) {
  var r = [], n = [], i = 1, a = "sdf", o = [], u = [], s = !1, c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Map(), d = e.sort(function(g) {
    var h;
    return ((h = Ko(g)) === null || h === void 0 ? void 0 : h.sourceData.kind) === "mmCIF" ? -1 : 1;
  });
  d.forEach(function(g, h) {
    var y;
    g && ((y = Ko(g)) === null || y === void 0 ? void 0 : y.sourceData.kind) === "mmCIF" && Array.from(Ko(g).properties.structAsymMap.keys()).forEach(function(x) {
      l.set("".concat(h, `
`).concat(x), x), c.has(x) && (s = !0), c.add(x);
    });
  });
  var f = "", m = 1;
  if (l.size > 35) return { format: "pdb", type: Zp.PDB, content: "" };
  if (s) c.clear(), Array.from(l.keys()).forEach(function(g, h) {
    var y = 65 + h > 90 ? String.fromCharCode(65 + h) : "".concat(h);
    l.set(g, y), h === l.size - 1 && (f = 65 + h + 1 > 90 ? String.fromCharCode(65 + h + 1) : "".concat(h));
  });
  else {
    for (var v = 65; v < 91 && f === ""; v++) {
      var p = String.fromCharCode(v);
      c.has(p) || (f = p);
    }
    for (v = 48; v < 58 && f === ""; v++)
      p = String.fromCharCode(v), c.has(p) || (f = p);
  }
  return d.forEach(function(g, h) {
    var y;
    if (g) if (((y = Ko(g)) === null || y === void 0 ? void 0 : y.sourceData.kind) === "mmCIF") {
      var x = [], A = Q_(g, ["HEADER"]);
      x.push.apply(x, A);
      var b = qo(g), _ = g.units[0], S = [];
      b.forEach(function(E) {
        var B, N = _.model.atomicHierarchy.chains.auth_asym_id.value(_.chainIndex[E]), O = { elementId: i, atom_id: "".concat(i), group_PDB: _.model.atomicHierarchy.residues.group_PDB.value(_.residueIndex[E]), auth_atom_id: _.model.atomicHierarchy.atoms.auth_atom_id.value(E), label_alt_id: _.model.atomicHierarchy.atoms.label_alt_id.value(E), auth_comp_id: _.model.atomicHierarchy.atoms.label_comp_id.value(E), auth_asym_id: (B = l.get("".concat(h, `
`).concat(N))) !== null && B !== void 0 ? B : N, auth_seq_id: _.model.atomicHierarchy.residues.auth_seq_id.value(_.residueIndex[E]), pdbx_PDB_ins_code: _.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(_.residueIndex[E]), x: _.model.atomicConformation.x[E], y: _.model.atomicConformation.y[E], z: _.model.atomicConformation.z[E], occupancy: _.model.atomicConformation.occupancy.value(E), B_iso_or_equiv: _.model.atomicConformation.B_iso_or_equiv.value(E), type_symbol: mm(_.model.atomicHierarchy.atoms.type_symbol.value(E)), charge: _.model.atomicHierarchy.atoms.pdbx_formal_charge.value(E) };
        S.push(O), i++;
      });
      var D = /* @__PURE__ */ new Map();
      g.units.forEach(function(E) {
        for (var B = 0, N = E.bonds.a.length; B < N; B++) {
          var O = E.elements[E.bonds.a[B]], z = E.elements[E.bonds.b[B]];
          if (b.includes(O) && b.includes(z) && !D.has("".concat(O, "_").concat(z)) && !D.has("".concat(z, "_").concat(O))) {
            var V = E.bonds.edgeProps.order[B];
            D.set("".concat(O, "_").concat(z), { a: S[b.indexOf(O)].elementId, b: S[b.indexOf(z)].elementId, order: V, atom_idA: S[b.indexOf(O)].atom_id, atom_idB: S[b.indexOf(O)].atom_id });
          }
        }
      }), r.push.apply(r, S), n.push.apply(n, Array.from(D).map(function(E) {
        return E[1];
      })), a = "pdb";
    } else {
      var I = qo(g), M = g.units[0], F = [], P = /* @__PURE__ */ new Map();
      I.forEach(function(E) {
        var B;
        F.push({ elementId: i, group_PDB: "HETATM", atom_id: "".concat(i), auth_atom_id: M.model.atomicHierarchy.atoms.label_atom_id.value(E), label_alt_id: M.model.atomicHierarchy.atoms.label_alt_id.value(E), auth_comp_id: M.model.atomicHierarchy.atoms.label_comp_id.value(E), auth_asym_id: f, auth_seq_id: "".concat(m), pdbx_PDB_ins_code: M.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(M.residueIndex[E]), x: M.model.atomicConformation.x[E], y: M.model.atomicConformation.y[E], z: M.model.atomicConformation.z[E], occupancy: M.model.atomicConformation.occupancy.value(E), B_iso_or_equiv: M.model.atomicConformation.B_iso_or_equiv.value(E), type_symbol: mm(M.model.atomicHierarchy.atoms.type_symbol.value(E)), charge: M.model.atomicHierarchy.atoms.pdbx_formal_charge.value(E) || ((B = Pc.Provider.get(M.model)) === null || B === void 0 ? void 0 : B.data.value(E)) || 0 }), i++;
      }), g.units.forEach(function(E) {
        for (var B = 0, N = E.bonds.a.length; B < N; B++) {
          var O = E.elements[E.bonds.a[B]], z = E.elements[E.bonds.b[B]];
          if (I.includes(O) && I.includes(z) && !P.has("".concat(O, "_").concat(z)) && !P.has("".concat(z, "_").concat(O))) {
            var V = E.bonds.edgeProps.order[B];
            P.set("".concat(O, "_").concat(z), { a: F[I.indexOf(O)].elementId, b: F[I.indexOf(z)].elementId, order: V, atom_idA: F[I.indexOf(O)].atom_id, atom_idB: F[I.indexOf(O)].atom_id });
          }
        }
      }), m++, u.push.apply(u, F), n.push.apply(n, Array.from(P).map(function(E) {
        return E[1];
      }));
    }
  }), o.length === 2 && n.push({ a: o[0], b: o[1], order: 1, atom_idA: "".concat(o[0]), atom_idB: "".concat(o[1]) }), r.push.apply(r, u), a === "pdb" ? { format: "pdb", type: Zp.PDB, content: r.length > 99999 ? "" : f6(r, n, !1, !1) } : { format: "sdf", type: Zp.SDF, content: r.length > 999 || n.length > 999 ? "" : "".concat(r2(r, n), `
$$$$`) };
}, D$ = function(e, t) {
  switch (t) {
    case mr.Pdb:
      return I$(e);
    case mr.Sdf:
    case mr.Mol:
      return qP(e);
    default:
      return [e];
  }
}, I$ = function(e) {
  var t = e.split(`
`), r = [], n = [[]], i = 0;
  t.forEach(function(u) {
    switch (u[0]) {
      case "A":
        if (u.startsWith("ATOM")) return void n[i].push(u);
        if (u.startsWith("AUTHER")) return;
        r.push(u);
        break;
      case "C":
        if (u.startsWith("CONECT")) return void n[i].push(u);
        r.push(u);
        break;
      case "E":
        if (u.startsWith("ENDMDL")) return void (n[i].length > 0 && (i++, n.push([])));
        if (u.startsWith("END")) return;
        r.push(u);
        break;
      case "H":
        if (u.startsWith("HETATM")) return void n[i].push(u);
        r.push(u);
        break;
      case "M":
        if (u.startsWith("MODEL")) return void (n[i].length > 0 && (i++, n.push([])));
        if (u.startsWith("MASTER")) return;
        r.push(u);
        break;
      case "R":
        if (u.startsWith("REVDAT")) return;
        r.push(u);
        break;
      case "S":
        if (u.startsWith("SOURCE")) return;
        r.push(u);
        break;
      case "T":
        if (u.startsWith("TER")) return void n[i].push(u);
        r.push(u);
        break;
      default:
        r.push(u);
    }
  });
  var a = r.join(`
`), o = [];
  return n.forEach(function(u) {
    u.length > 0 && o.push("".concat(a).concat(a ? `
` : "").concat(u.join(`
`)));
  }), o;
}, qP = function(e) {
  return e.split(/\$\$\$\$\r?\n?/).filter(function(t) {
    return t.trim() !== "";
  });
}, E$ = function(e) {
  for (var t = e.split(`
`), r = !0, n = !1, i = [], a = [], o = 0, u = t.length; o < u; o++) {
    var s = t[o];
    if (r) {
      if (i.length < 4)
        i.push(s), i.length === 4 && (c = Y4(s, KJ)).length > 0 && a.push({ index: o, info: c });
      else if (s.startsWith("M  END")) n = !0, r = !1, i = [];
      else if (!s.startsWith("M") && !s.startsWith("V")) {
        if (s.startsWith("G") || s.startsWith("A")) o++;
        else if (s.slice(4, 5) !== "T" && s.slice(4, 5) !== "F") {
          var c;
          s.length < 34 ? (c = Y4(s, qJ)).length > 0 && a.push({ index: o, info: c }) : (c = Y4(s, HJ)).length > 0 && a.push({ index: o, info: c });
        }
      }
    } else s.startsWith("$$$$") && (r = !0, i = []);
  }
  return n || a.push({ index: 0, info: [{ start: 0, end: 0 }] }), a;
}, M$ = function(e, t) {
  switch (t) {
    case mr.Sdf:
    case mr.Mol:
      return E$(e);
    default:
      return [];
  }
}, T$ = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    var t, r, n, i, a, o, u, s, c, l;
    return ye(this, function(d) {
      switch (d.label) {
        case 0:
          if (!e.trim()) return [2, [zs()]];
          t = [], r = qP(e), n = 0, i = r, d.label = 1;
        case 1:
          return n < i.length ? [4, x$(i[n]).run()] : [3, 7];
        case 2:
          if ((a = d.sent()).isError) throw a;
          o = 0, u = a.result.compounds, d.label = 3;
        case 3:
          return o < u.length ? (s = u[o], [4, (f = s, er.create("Parse SDF", function(m) {
            return HP(f.molFile, d6.create(f), m);
          })).run()]) : [3, 6];
        case 4:
          c = d.sent(), l = tt.ofModel(c.representative), t.push(l), d.label = 5;
        case 5:
          return o++, [3, 3];
        case 6:
          return n++, [3, 1];
        case 7:
          return [2, t];
      }
      var f;
    });
  });
} };
function P$(e) {
  return function(t, r, n) {
    return function(i, a, o, u) {
      var s = i.data, c = i.indices, l = i.count, d = u.valueType, f = d === "str" ? function(m) {
        var v = c[2 * m] + a, p = c[2 * m + 1];
        if (v >= p) return "";
        var g = v + o;
        return g > p && (g = p), function(h, y, x) {
          for (var A = y, b = x - 1, _ = h.charCodeAt(A); (_ === 9 || _ === 32) && A <= b; ) _ = h.charCodeAt(++A);
          for (_ = h.charCodeAt(b); (_ === 9 || _ === 32) && b >= A; ) _ = h.charCodeAt(--b);
          return h.substring(A, b + 1);
        }(s, v, g);
      } : d === "int" ? function(m) {
        var v = c[2 * m] + a;
        return v > c[2 * m + 1] ? 0 : qd(s, v, v + o);
      } : function(m) {
        var v = c[2 * m] + a;
        return v > c[2 * m + 1] ? 0 : function(p, g, h) {
          for (; g < h && p.charCodeAt(g) === 32; ) g++;
          return ef(p, g, h);
        }(s, v, v + o);
      };
      return { schema: u, __array: void 0, isDefined: !0, rowCount: l, value: f, valueKind: function(m) {
        return 0;
      }, toArray: function(m) {
        return $i(l, f, m);
      }, areValuesEqual: function(m, v) {
        return f(m) === f(v);
      } };
    }(e, t, r, n);
  };
}
function B$(e) {
  return _e(this, 0, void 0, function() {
    var t, r, n, i, a, o, u, s, c, l, d;
    return ye(this, function(f) {
      switch (f.label) {
        case 0:
          return t = e.tokenizer, r = e.numberOfAtoms, [4, ot.readLinesAsync(t, r, e.runtimeCtx, 1e5)];
        case 1:
          return n = f.sent(), i = t.data.substring(n.indices[0], n.indices[1]).substring(20), a = i.match(/\.\d+/g), o = a.length === 6, e.header.hasVelocities = o, e.header.precision.position = a[0].length - 1, e.header.precision.velocity = o ? a[3].length - 1 : 0, u = e.header.precision.position + 5, s = 20 + 3 * u, c = e.header.precision.velocity + 4, l = P$(n), d = oe.Undefined(e.numberOfAtoms, oe.Schema.float), [2, { count: e.numberOfAtoms, residueNumber: l(0, 5, oe.Schema.int), residueName: l(5, 5, oe.Schema.str), atomName: l(10, 5, oe.Schema.str), atomNumber: l(15, 5, oe.Schema.int), x: l(20, u, oe.Schema.float), y: l(20 + u, u, oe.Schema.float), z: l(20 + 2 * u, u, oe.Schema.float), vx: o ? l(s, c, oe.Schema.float) : d, vy: o ? l(s + c, c, oe.Schema.float) : d, vz: o ? l(s + 2 * c, c, oe.Schema.float) : d }];
      }
    });
  });
}
function F$(e, t) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o;
    return ye(this, function(u) {
      switch (u.label) {
        case 0:
          return r = ot(e), [4, t.update({ message: "Parsing...", current: 0, max: e.length })];
        case 1:
          u.sent(), n = [], u.label = 2;
        case 2:
          return r.position < e.length ? (i = /* @__PURE__ */ function(s, c) {
            return { tokenizer: s, header: { title: "", timeInPs: 0, hasVelocities: !1, precision: { position: 0, velocity: 0 }, box: [0, 0, 0] }, numberOfAtoms: 0, runtimeCtx: c };
          }(r, t), function(s) {
            var c = s.tokenizer, l = s.header, d = ot.readLine(c);
            d.trim().length === 0 && (d = ot.readLine(c));
            var f = d.lastIndexOf("t=");
            f >= 0 ? (l.timeInPs = parseFloat(d.substring(f + 2)), l.title = d.substring(0, f).trim(), l.title && l.title[l.title.length - 1] === "," && (l.title = l.title.substring(0, l.title.length - 1))) : l.title = d;
          }(i), function(s) {
            var c = s.tokenizer;
            ot.markLine(c);
            var l = ot.getTokenString(c);
            s.numberOfAtoms = parseInt(l);
          }(i), [4, B$(i)]) : [3, 4];
        case 3:
          return a = u.sent(), function(s) {
            var c = s.tokenizer, l = ot.readLine(c).trim().split(/\s+/g);
            s.header.box = [+l[0], +l[1], +l[2]];
          }(i), n.push({ header: i.header, atoms: a }), [3, 2];
        case 4:
          return o = { structures: n }, [2, Pi.success(o)];
      }
    });
  });
}
function KP(e) {
  var t = this;
  return er.create("Parse GRO", function(r) {
    return _e(t, 0, void 0, function() {
      return ye(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, F$(e, r)];
          case 1:
            return [2, n.sent()];
        }
      });
    });
  });
}
var zw = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", m6, N$ = ST(function(e) {
  for (var t = e, r = 0, n = zw[t % 26]; t >= 26; ) t = Math.floor(t / 26), n += zw[t % 26], r += 1;
  return r >= 5 && console.warn("getChainId overflow"), n;
});
function XP(e) {
  var t = this;
  return er.create("Parse GRO", function(r) {
    return _e(t, 0, void 0, function() {
      var n, i, a, o, u, s;
      return ye(this, function(c) {
        switch (c.label) {
          case 0:
            n = m6.fromGro(e), i = [], a = 0, o = e.structures.length, c.label = 1;
          case 1:
            return a < o ? (u = function(l, d) {
              for (var f = l.atomName, m = l.residueName, v = new Array(l.count), p = new Array(l.count), g = new Uint32Array(l.count), h = new Uint32Array(l.count), y = new Array(l.count), x = new wf(), A = new Cf(l.residueNumber, l.atomName), b = "", _ = 0, S = "", D = 0, I = 0, M = -1, F = 0, P = l.count; F < P; ++F) {
                var E = l.residueNumber.value(F);
                if (E !== M) {
                  var B = l.residueName.value(F), N = Dm(A.add(B, F).type, B);
                  N === I && (E === M + 1 || M === 99999 && E === 0) || (S = N$(_), _ += 1, D = 0), b = x.getEntityId(B, N, S), D += 1, M = E, I = N;
                }
                v[F] = b, p[F] = S, g[F] = D, h[F] = F, y[F] = j_(l.atomName.value(F), l.residueName.value(F));
              }
              var O = oe.ofStringArray(p), z = Or.ofPartialColumns(_o.atom_site, { auth_asym_id: O, auth_atom_id: f, auth_comp_id: m, auth_seq_id: l.residueNumber, Cartn_x: oe.ofFloatArray(oe.mapToArray(l.x, function(V) {
                return 10 * V;
              }, Float32Array)), Cartn_y: oe.ofFloatArray(oe.mapToArray(l.y, function(V) {
                return 10 * V;
              }, Float32Array)), Cartn_z: oe.ofFloatArray(oe.mapToArray(l.z, function(V) {
                return 10 * V;
              }, Float32Array)), id: oe.ofIntArray(h), label_asym_id: O, label_atom_id: f, label_comp_id: m, label_seq_id: oe.ofIntArray(g), label_entity_id: oe.ofStringArray(v), occupancy: oe.ofConst(1, l.count, oe.Schema.float), type_symbol: oe.ofStringArray(y), pdbx_PDB_model_num: oe.ofConst(d, l.count, oe.Schema.int) }, l.count);
              return ld({ entity: x.getEntityTable(), chem_comp: A.getChemCompTable(), atom_site: z });
            }(e.structures[a].atoms, a + 1), [4, Oc(u, n, r)]) : [3, 4];
          case 2:
            (s = c.sent()).frameCount === 1 && i.push(s.representative), c.label = 3;
          case 3:
            return ++a, [3, 1];
          case 4:
            return [2, new am(i)];
        }
      });
    });
  });
}
(function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "gro";
  }, e.fromGro = function(t) {
    return { kind: "gro", name: t.structures[0].header.title, data: t };
  };
})(m6 || (m6 = {}));
var po, R$ = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    var t;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, KP(e).run()];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, XP(t.result).run()];
        case 2:
          return [2, r.sent().representative];
      }
    });
  });
} }, l1 = new Uint32Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64, 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812, 1024, 1290, 1625, 2048, 2580, 3250, 4096, 5060, 6501, 8192, 10321, 13003, 16384, 20642, 26007, 32768, 41285, 52015, 65536, 82570, 104031, 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561, 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021, 4194304, 5284491, 6658042, 8388607, 10568983, 13316085, 16777216]), J4 = 9;
function O$() {
  throw new Error("(xdrfile error) Undefined error.");
}
function L$(e, t) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o, u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _, S, D, I, M, F, P, E, B, N, O, z, V;
    return ye(this, function(U) {
      switch (U.label) {
        case 0:
          r = new DataView(t.buffer, t.byteOffset), i = (n = { frames: [], boxes: [], times: [], timeOffset: 0, deltaTime: 0 }).frames, a = n.boxes, o = n.times, u = [0, 0, 0, 0, 0, 0], s = [0, 0, 0], c = [0, 0, 0], l = [0, 0, 0], d = [0.1, 0.1, 0.1], f = [0.1, 0.1, 0.1], m = 0, v = po.buf, U.label = 1;
        case 1:
          for (p = void 0, g = r.getInt32(m + 4), m += 12, o.push(r.getFloat32(m)), m += 4, h = new Float32Array(9), E = 0; E < 9; ++E) h[E] = 10 * r.getFloat32(m), m += 4;
          if (a.push(h), g <= 9) for (p = { count: g / 3, x: new Float32Array(g / 3), y: new Float32Array(g / 3), z: new Float32Array(g / 3) }, E = 0; E < g / 3; ++E) p.x[E] = r.getFloat32(m), p.y[E] = r.getFloat32(m), p.z[E] = r.getFloat32(m), m += 4;
          else {
            for (v[0] = v[1] = v[2] = 0, s[0] = s[1] = s[2] = 0, l[0] = l[1] = l[2] = 0, c[0] = c[1] = c[2] = 0, d[0] = d[1] = d[2] = 0, f[0] = f[1] = f[2] = 0, p = { count: g, x: new Float32Array(g), y: new Float32Array(g), z: new Float32Array(g) }, y = 0, x = r.getInt32(m), m += 4, A = r.getFloat32(m), m += 4, u[0] = r.getInt32(m), u[1] = r.getInt32(m + 4), u[2] = r.getInt32(m + 8), u[3] = r.getInt32(m + 12), u[4] = r.getInt32(m + 16), u[5] = r.getInt32(m + 20), s[0] = u[3] - u[0] + 1, s[1] = u[4] - u[1] + 1, s[2] = u[5] - u[2] + 1, m += 24, b = void 0, (s[0] | s[1] | s[2]) > 16777215 ? (c[0] = po.sizeOfInt(s[0]), c[1] = po.sizeOfInt(s[1]), c[2] = po.sizeOfInt(s[2]), b = 0) : b = po.sizeOfInts(3, s), _ = r.getInt32(m), m += 4, D = l1[S = J4 > (S = _ - 1) ? J4 : S] / 2 | 0, I = l1[_] / 2 | 0, l[0] = l[1] = l[2] = l1[_], M = 4 * Math.ceil(r.getInt32(m) / 4), m += 4, F = 1 / A, P = 0, E = 0, d[0] = d[1] = d[2] = 0; E < x; ) {
              if (b === 0 ? (d[0] = po.decodeBits(t, m, c[0]), d[1] = po.decodeBits(t, m, c[1]), d[2] = po.decodeBits(t, m, c[2])) : po.decodeInts(t, m, b, s, d), E++, d[0] += u[0], d[1] += u[1], d[2] += u[2], f[0] = d[0], f[1] = d[1], f[2] = d[2], B = po.decodeBits(t, m, 1), N = 0, B === 1 && (P = po.decodeBits(t, m, 5), P -= N = P % 3, N--), P > 0) for (d[0] = d[1] = d[2] = 0, O = 0; O < P; O += 3) po.decodeInts(t, m, _, l, d), E++, d[0] += f[0] - I, d[1] += f[1] - I, d[2] += f[2] - I, O === 0 ? (z = d[0], d[0] = f[0], f[0] = z, z = d[1], d[1] = f[1], f[1] = z, z = d[2], d[2] = f[2], f[2] = z, p.x[y] = f[0] * F, p.y[y] = f[1] * F, p.z[y] = f[2] * F, y++) : (f[0] = d[0], f[1] = d[1], f[2] = d[2]), p.x[y] = d[0] * F, p.y[y] = d[1] * F, p.z[y] = d[2] * F, y++;
              else p.x[y] = d[0] * F, p.y[y] = d[1] * F, p.z[y] = d[2] * F, y++;
              _ += N, N < 0 ? (I = D, D = _ > J4 ? l1[_ - 1] / 2 | 0 : 0) : N > 0 && (D = I, I = l1[_] / 2 | 0), l[0] = l[1] = l[2] = l1[_], l[0] !== 0 && l[1] !== 0 && l[2] !== 0 || O$();
            }
            m += M;
          }
          for (V = 0; V < g; V++) p.x[V] *= 10, p.y[V] *= 10, p.z[V] *= 10;
          return i.push(p), e.shouldUpdate ? [4, e.update({ current: m, max: t.length })] : [3, 3];
        case 2:
          U.sent(), U.label = 3;
        case 3:
          return m >= t.length ? [3, 4] : [3, 1];
        case 4:
          return o.length >= 1 && (n.timeOffset = o[0]), o.length >= 2 && (n.deltaTime = o[1] - o[0]), [2, n];
      }
    });
  });
}
function k$(e) {
  var t = this;
  return er.create("Parse XTC", function(r) {
    return _e(t, 0, void 0, function() {
      var n, i;
      return ye(this, function(a) {
        switch (a.label) {
          case 0:
            return a.trys.push([0, 2, , 3]), r.update({ canAbort: !0, message: "Parsing trajectory..." }), [4, L$(r, e)];
          case 1:
            return n = a.sent(), [2, Pi.success(n)];
          case 2:
            return i = a.sent(), [2, Pi.error("" + i)];
          case 3:
            return [2];
        }
      });
    });
  });
}
function Q2() {
  return Q2.empty();
}
function z$(e) {
  var t = this;
  return er.create("Parse XTC", function(r) {
    return _e(t, 0, void 0, function() {
      var n, i, a, o, u, s, c, l, d;
      return ye(this, function(f) {
        switch (f.label) {
          case 0:
            return [4, r.update("Converting to coordinates")];
          case 1:
            for (f.sent(), n = Ny(e.deltaTime, "step"), i = Ny(e.timeOffset, n.unit), a = [], o = 0, u = e.frames.length; o < u; ++o) s = e.boxes[o], c = w.fromArray(w(), s, 0), l = w.fromArray(w(), s, 3), d = w.fromArray(w(), s, 6), a.push({ elementCount: e.frames[o].count, cell: Q2.fromBasis(c, l, d), x: e.frames[o].x, y: e.frames[o].y, z: e.frames[o].z, xyzOrdering: { isIdentity: !0 }, time: Ny(i.value + n.value * o, n.unit) });
            return [2, x2.create(a, n, i)];
        }
      });
    });
  });
}
(function(e) {
  e.sizeOfInt = function(u) {
    for (var s = 1, c = 0; u >= s && c < 32; ) c++, s <<= 1;
    return c;
  };
  var t = new Uint8Array(32);
  e.sizeOfInts = function(u, s) {
    var c = 1, l = 0;
    t[0] = 1;
    for (var d = 0; d < u; d++) {
      var f = void 0, m = 0;
      for (f = 0; f < c; f++) m += t[f] * s[d], t[f] = 255 & m, m >>= 8;
      for (; m !== 0; ) t[f++] = 255 & m, m >>= 8;
      c = f;
    }
    var v = 1;
    for (c--; t[c] >= v; ) l++, v *= 2;
    return l + 8 * c;
  };
  var r = new ArrayBuffer(24);
  e.buf = new Int32Array(r);
  var n = new Uint32Array(r);
  function i(u, s, c) {
    for (var l = c, d = (1 << l) - 1, f = n[1], m = n[2], v = e.buf[0], p = 0; l >= 8; ) p |= (m = m << 8 | u[s + v++]) >> f << l - 8, l -= 8;
    return l > 0 && (f < l && (f += 8, m = m << 8 | u[s + v++]), p |= m >> (f -= l) & (1 << l) - 1), p &= d, e.buf[0] = v, e.buf[1] = f, e.buf[2] = m, p;
  }
  function a(u, s) {
    var c = n[2], l = e.buf[0];
    return c = c << 8 | u[s + l], e.buf[0] = l + 1, e.buf[2] = c, c >> n[1] & 255;
  }
  e.decodeBits = i;
  var o = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  e.decodeInts = function(u, s, c, l, d) {
    var f = c, m = 0;
    for (o[0] = 0, o[1] = 0, o[2] = 0, o[3] = 0; f > 8; ) o[m++] = a(u, s), f -= 8;
    f > 0 && (o[m++] = i(u, s, f));
    for (var v = 2; v > 0; v--) {
      for (var p = 0, g = l[v], h = m - 1; h >= 0; h--) {
        var y = (p = p << 8 | o[h]) / g | 0;
        o[h] = y, p -= y * g;
      }
      d[v] = p;
    }
    d[0] = o[0] | o[1] << 8 | o[2] << 16 | o[3] << 24;
  };
})(po || (po = {})), function(e) {
  function t(n, i) {
    return { size: n, anglesInRadians: i };
  }
  function r() {
    return t(w(), w());
  }
  e.create = t, e.empty = r, e.fromBasis = function(n, i, a) {
    var o = w.magnitude(n), u = w.magnitude(i), s = w.magnitude(a), c = Math.acos(w.dot(i, a) / (u * s)), l = Math.acos(w.dot(n, a) / (o * s)), d = Math.acos(w.dot(n, i) / (o * u));
    return o <= 0 || u <= 0 || s <= 0 || c >= Math.PI || l >= Math.PI || d >= Math.PI ? r() : t(w.create(o, u, s), w.create(c, l, d));
  };
}(Q2 || (Q2 = {}));
var G$ = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(t) {
      return [2, new Promise(function(r) {
        var n = new FileReader();
        n.onload = function(i) {
          return _e(this, 0, void 0, function() {
            var a, o;
            return ye(this, function(u) {
              switch (u.label) {
                case 0:
                  return [4, k$(new Uint8Array(n.result)).run()];
                case 1:
                  if ((a = u.sent()).isError) throw new Error(a.message);
                  return [4, z$(a.result).run()];
                case 2:
                  return o = u.sent(), r(o), [2];
              }
            });
          });
        }, n.readAsArrayBuffer(e);
      })];
    });
  });
} };
function jP(e, t, r, n, i, a) {
  var o = e, u = t, s = r, c = Math.cos(n * Math.PI / 180), l = Math.cos(i * Math.PI / 180), d = Math.cos(a * Math.PI / 180), f = Math.sin(n * Math.PI / 180), m = Math.sin(i * Math.PI / 180), v = function() {
    var b = (c * l - d) / (f * m);
    return Math.max(Math.min(b, 1), -1);
  }(), p = Math.acos(v), g = me.ofRows([[o * m, -u * f * Math.cos(p), 0, 0], [0, u * f * Math.sin(p), 0, 0], [o * l, u * c, s, 0], [0, 0, 0, 1]]), h = me.invert(me.zero(), g), y = w.create(g[0], g[4], g[8]), x = w.create(g[1], g[5], g[9]), A = w.create(g[2], g[6], g[10]);
  return { a: e, b: t, c: r, volume: Math.abs(w.dot(y, y)) * r, alpha: n, beta: i, gamma: a, vecA: y, vecB: x, vecC: A, matrix: g, invertMatrix: h };
}
function YP(e, t, r) {
  var n = w.create.apply(null, e), i = w.create.apply(null, t), a = w.create.apply(null, r), o = n[0], u = n[1], s = n[2], c = i[0], l = i[1], d = i[2], f = a[0], m = a[1], v = a[2], p = me.ofRows([[o, c, f, 0], [u, l, m, 0], [s, d, v, 0], [0, 0, 0, 1]]), g = me.invert(me.zero(), p), h = Math.sqrt(Math.abs(w.dot(n, n))), y = Math.sqrt(Math.abs(w.dot(i, i))), x = Math.sqrt(Math.abs(w.dot(a, a))), A = w.angle(i, a) * (180 / Math.PI), b = w.angle(n, a) * (180 / Math.PI), _ = w.angle(n, i) * (180 / Math.PI);
  return { a: h, b: y, c: x, volume: Math.abs(w.dot(n, n)) * x, alpha: A, beta: b, gamma: _, vecA: n, vecB: i, vecC: a, matrix: p, invertMatrix: g };
}
var J2, WP = [];
function V$(e) {
  ot.readLine(e);
  var t = +ot.readLine(e);
  ot.readLine(e);
  var r = +ot.readLine(e);
  isNaN(r) && (r = 0);
  var n = ot.readLine(e), i = new Float64Array(3), a = new Float64Array(3), o = new Float64Array(3);
  n.includes("xy xz yz") && function(b, _) {
    var S = _[0], D = _[1], I = _[2], M = _.map(function() {
      return ot.readLine(b).trim().split(/\s+/g).map(function(ae) {
        return Number(ae);
      });
    }), F = M[0], P = F[0], E = F[1], B = F[2], N = M[1], O = N[0], z = N[1], V = N[2], U = M[2], H = U[0], K = U[1], j = U[2], X = [[P, E], [O, z], [H, K]], W = [B, V, j], Q = [0, W[0], W[1], W[0] + W[1]], te = [0, W[2]], ee = [[Math.min.apply(null, Q), Math.max.apply(null, Q)], [Math.min.apply(null, te), Math.max.apply(null, te)], [0, 0]];
    X.forEach(function(ae, se) {
      ae.forEach(function(le, pe) {
        X[se][pe] = le - ee[se][pe];
      });
    });
    var $ = X.map(function(ae) {
      return ae[1] - ae[0];
    }), ie = [[$[0], 0, 0], [W[0], $[1], 0], [W[1], W[2], $[2]]];
    S[0] = ie[0][0], S[1] = ie[0][1], S[2] = ie[0][2], D[0] = ie[1][0], D[1] = ie[1][1], D[2] = ie[1][2], I[0] = ie[2][0], I[1] = ie[2][1], I[2] = ie[2][2];
  }(e, [i, a, o]);
  var u = function(b, _, S) {
    var D = new Float64Array(_), I = new Float64Array(_), M = new Float64Array(_), F = new Float64Array(_), P = new Float64Array(_), E = [["id", D], ["type", I], ["x", M], ["y", F], ["z", P]];
    E.sort(function(z, V) {
      return S.indexOf(z[0]) - S.indexOf(V[0]);
    });
    for (var B = E.map(function(z) {
      return z[1];
    }), N = function(z) {
      ot.readLine(b).trim().split(/\s+/g).forEach(function(V, U) {
        B[U][z] = Number(V);
      });
    }, O = 0; O < _; O++) N(O);
    return [D, I, M, F, P];
  }(e, r, ot.readLine(e).replace("ITEM: ATOMS", "").split(/\s+/g)), s = u[0], c = u[1], l = u[2], d = u[3], f = u[4], m = [], v = [];
  c.forEach(function(b) {
    m[b] || (m[b] = WP[b].symbol), v.push(m[b]);
  });
  for (var p = YP(i, a, o), g = new Float64Array(r), h = new Float64Array(r), y = new Float64Array(r), x = 0; x < r; x++) {
    var A = w.create(l[x], d[x], f[x]);
    w.transformMat4(A, A, p.invertMatrix), g[x] = A[0], h[x] = A[1], y[x] = A[2];
  }
  return { count: r, comment: "", x: oe.ofFloatArray(l), y: oe.ofFloatArray(d), z: oe.ofFloatArray(f), type_symbol: oe.ofStringArray(v), cell: p, timestep: t, fractX: oe.ofFloatArray(g), fractY: oe.ofFloatArray(h), fractZ: oe.ofFloatArray(y), id: oe.ofFloatArray(s) };
}
function U$(e) {
  for (var t = ot(e), r = []; ; ) {
    var n = V$(t);
    if (n.count === 0) break;
    r.push(n);
  }
  var i = { molecules: r, isMaterial: !0 };
  return Pi.success(i);
}
function $_(e) {
  var t = this;
  return er.create("Parse Mol", function() {
    return _e(t, 0, void 0, function() {
      var r;
      return ye(this, function(n) {
        return r = function(i) {
          var a = i.split(/\r?\n/).reduce(function(o, u) {
            return u.includes("ITEM: TIMESTEP") && o.push([]), o[o.length - 1].push(u), o;
          }, []).map(function(o) {
            var u = o.findIndex(function(z) {
              return z.includes("ITEM: BOX BOUNDS");
            });
            o.splice(u, 1, "ITEM: BOX BOUNDS xy xz yz pp pp pp");
            var s = o.findIndex(function(z) {
              return z.includes("ITEM: ATOMS");
            }), c = o[s].includes("xs") || o[s].includes("xsu"), l = o[u + 1], d = o[u + 2], f = o[u + 3], m = l.split(" ").map(function(z) {
              return +z;
            }), v = m[0], p = m[1], g = m[2], h = g === void 0 ? 0 : g, y = d.split(" ").map(function(z) {
              return +z;
            }), x = y[0], A = y[1], b = y[2], _ = b === void 0 ? 0 : b, S = f.split(" ").map(function(z) {
              return +z;
            }), D = S[0], I = S[1], M = S[2], F = M === void 0 ? 0 : M;
            if (c) {
              var P = [[p - v - Math.abs(h) - Math.abs(_), 0, 0], [h, A - x - Math.abs(F), 0], [_, F, I - D]], E = o.slice(s + 1).map(function(z) {
                return z.split(" ");
              }).map(function(z) {
                var V = z[0], U = z[1], H = function(K, j) {
                  for (var X = [], W = 0; W < K.length; W++) {
                    X[W] = [];
                    for (var Q = 0; Q < j[0].length; Q++) {
                      for (var te = 0, ee = 0; ee < K[0].length; ee++) te += +K[W][ee] * +j[ee][Q];
                      X[W][Q] = te;
                    }
                  }
                  return X;
                }([[z[2], z[3], z[4]]], P)[0];
                return [V, U, H[0], H[1], H[2]];
              }), B = E.map(function(z) {
                return z.join(" ");
              }).join(`
`);
              return [o.slice(0, u + 4).join(`
`), O = "ITEM: ATOMS id type x y z", B].join(`
`);
            }
            var N = [[v, p, h], [x, A, _], [D, I, F]].map(function(z) {
              return z.join(" ");
            });
            o.splice.apply(o, We([u + 1, 3], N, !1)), B = (E = o.slice(s + 1).map(function(z) {
              return z.split(" ");
            }).map(function(z) {
              return [z[0], z[1], z[2], z[3], z[4]];
            })).map(function(z) {
              return z.join(" ");
            }).join(`
`);
            var O = "ITEM: ATOMS id type x y z";
            return [o.slice(0, u + 4).join(`
`), O, B].join(`
`);
          });
          return a.join(`
`);
        }(e), [2, U$(r)];
      });
    });
  });
}
function H$(e, t) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o, u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _, S, D, I, M, F, P, E, B, N, O;
    return ye(this, function(z) {
      switch (z.label) {
        case 0:
          for (r = J2.formatMol(e), n = r.molecules, i = 0, a = 0, o = n; a < o.length; a++) p = o[a], i += p.count;
          for (u = new Array(i), s = new Int32Array(i), c = new Float32Array(i), l = new Float32Array(i), d = new Float32Array(i), f = new Int32Array(i), m = function(V) {
            if (V.length) {
              var U = V[0], H = U.cell, K = U.spaceGroup;
              if (H) {
                var j = H.a, X = H.b, W = H.c, Q = H.alpha, te = H.beta, ee = H.gamma, $ = H.matrix, ie = H.invertMatrix, ae = function(le) {
                  if (!le) return "P 1";
                  var pe = le.it_number.value(0), we = le["name_h-m_full"].value(0).replace("-", " ");
                  return le.it_number.isDefined ? (le["name_h-m_full"].isDefined, pe) : we;
                }(K), se = Tu.createMaterial(ae, w.create(j, X, W), w.scale(w(), w.create(Q, te, ee), Math.PI / 180), j * X * W, ie, $);
                return { spacegroup: ho.create(se), assemblies: [], isNonStandardCrystalFrame: !1, ncsOperators: [] };
              }
            }
          }(n), v = 0, O = 0; O < n.length; O++) for (p = n[O], g = 0; g < p.count; g++) u[v] = p.type_symbol.value(g), c[v] = p.x.value(g), l[v] = p.y.value(g), d[v] = p.z.value(g), s[v] = g, f[v] = O, v++;
          return h = oe.ofConst("MOL", i, oe.Schema.str), y = oe.ofConst("A", i, oe.Schema.str), x = oe.ofConst(1, i, oe.Schema.int), A = oe.ofStringArray(u), b = Or.ofPartialColumns(_o.atom_site, { auth_asym_id: y, auth_atom_id: A, auth_comp_id: h, auth_seq_id: x, Cartn_x: oe.ofFloatArray(c), Cartn_y: oe.ofFloatArray(l), Cartn_z: oe.ofFloatArray(d), id: oe.ofIntArray(s), label_asym_id: y, label_atom_id: A, label_comp_id: h, label_seq_id: x, label_entity_id: oe.ofConst("1", i, oe.Schema.str), occupancy: oe.ofConst(1, i, oe.Schema.float), type_symbol: A, pdbx_PDB_model_num: oe.ofIntArray(f) }, i), (_ = new wf()).setNames([["MOL", "Ligand"]]), _.getEntityId("MOL", 0, "A"), (S = new Cf(x, A)).setNames([["MOL", "Unknown Molecule"]]), S.add("MOL", 0), [4, Oc(ld({ entity: _.getEntityTable(), chem_comp: S.getChemCompTable(), atom_site: b }), J2.create(r), t)];
        case 1:
          if ((D = z.sent()).frameCount > 0 && (I = D.representative, ia.Provider.set(I, m)), M = n[0], F = M.bonds) for (P = oe.ofIntArray(F.atomA), E = oe.ofIntArray(F.atomB), B = oe.ofIntArray(new Array(F.count).fill(1)), N = Ei.fromData({ pairs: { indexA: P, indexB: E, order: B }, count: M.count }), O = 0; O < D.frameCount; O++) Ei.Provider.set(D.getFrameAtIndex(O), N);
          return [2, D];
      }
    });
  });
}
function dd(e) {
  return er.create("Parse Material", function(t) {
    return H$(e, t);
  });
}
Object.entries({ Ac: { "Atomic mass": 227, "Atomic no": 89, "Atomic orbitals": { "1s": -3443.110367, "2p": -572.7627, "2s": -592.622878, "3d": -119.541743, "3p": -137.654394, "3s": -147.320716, "4d": -23.57061, "4f": -12.278225, "4p": -31.761846, "4s": -36.15826, "5d": -3.222752, "5p": -6.06511, "5s": -7.713078, "6d": -0.137786, "6p": -0.744524, "6s": -1.19698, "7s": -0.126551 }, "Atomic radius": 1.95, "Atomic radius calculated": "no data", "Boiling point": "3573 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "10070 kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].6d<sup>1</sup>.7s<sup>2</sup>", "Ionic radii": { 3: 1.26 }, "Liquid range": "2250 K", "Melting point": "1323 K", "Mendeleev no": 48, "Mineral hardness": "no data", "Molar volume": "22.55 cm<sup>3</sup>", Name: "Actinium", "Oxidation states": [3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.26, ionic_radius: 1.12 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "12 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.47, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.1, "Youngs modulus": "no data GPa", "Metallic radius": 1.878, iupac_ordering: 32, "IUPAC ordering": 32, "Ground level": "2D3/2", "Ionization energies": [5.380226, 11.75, 17.431, 44.8, 55, 67, 79, 98.9, 113.9, 143.9, 161.1, 233, 255, 279, 305, 330, 355, 390, 416, 444, 470, 610, 640, 670, 710, 780, 820, 920, 950, 1030, 1100, 1170, 1240, 1310, 1380, 1460, 1530, 1610, 1680, 1750, 1820, 1900, 1970, 2298, 2362, 2430, 2503, 2572, 2639, 2762, 2833, 2908, 2980, 3264, 3334, 3409, 3479, 3811, 3893, 4093, 4175, 6767, 6923, 7088, 7265, 7430, 7600, 7950, 8120, 8310, 8480, 8970, 9120, 9290, 9440, 10480, 10660, 11030, 11200, 23480, 23890, 24340, 24760, 28610, 29160, 29850, 30293.1, 119938.6, 122062.9], "Electron affinity": 0.35 }, Ag: { "Atomic mass": 107.8682, "Atomic no": 47, "Atomic orbitals": { "1s": -900.324578, "2p": -120.913351, "2s": -129.859807, "3d": -13.367803, "3p": -20.06763, "3s": -23.678437, "4d": -0.298706, "4p": -2.086602, "4s": -3.22309, "5s": -0.157407 }, "Atomic radius": 1.6, "Atomic radius calculated": 1.65, "Boiling point": "2435 K", "Brinell hardness": "24.5 MN m<sup>-2</sup>", "Bulk modulus": "100 GPa", "Coefficient of linear thermal expansion": "18.9 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1], "Critical temperature": "no data K", "Density of solid": "10490 kg m<sup>-3</sup>", "Electrical resistivity": "1.63 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>.5s<sup>1</sup>", "ICSD oxidation states": [1, 2, 3], "Ionic radii": { 1: 1.29, 2: 1.08, 3: 0.89 }, "Liquid range": "1200.07 K", "Melting point": "1234.93 K", "Mendeleev no": 71, "Mineral hardness": "2.5", "Molar volume": "10.27 cm<sup>3</sup>", Name: "Silver", "Oxidation states": [1, 2, 3], "Poissons ratio": "0.37", Reflectivity: "97 %", "Refractive index": "no data", "Rigidity modulus": "30 GPa", "Shannon radii": { 1: { II: { "": { crystal_radius: 0.81, ionic_radius: 0.67 } }, IV: { "": { crystal_radius: 1.14, ionic_radius: 1 } }, IVSQ: { "": { crystal_radius: 1.16, ionic_radius: 1.02 } }, V: { "": { crystal_radius: 1.23, ionic_radius: 1.09 } }, VI: { "": { crystal_radius: 1.29, ionic_radius: 1.15 } }, VII: { "": { crystal_radius: 1.36, ionic_radius: 1.22 } }, VIII: { "": { crystal_radius: 1.42, ionic_radius: 1.28 } } }, 2: { IVSQ: { "": { crystal_radius: 0.93, ionic_radius: 0.79 } }, VI: { "": { crystal_radius: 1.08, ionic_radius: 0.94 } } }, 3: { IVSQ: { "": { crystal_radius: 0.81, ionic_radius: 0.67 } }, VI: { "": { crystal_radius: 0.89, ionic_radius: 0.75 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "430 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.11, "Velocity of sound": "2600 m s<sup>-1</sup>", "Vickers hardness": "251 MN m<sup>-2</sup>", X: 1.93, "Youngs modulus": "83 GPa", "Metallic radius": 1.445, iupac_ordering: 72, "IUPAC ordering": 72, "Ground level": "2S1/2", "Ionization energies": [7.576234, 21.4844, 34.8, 49, 65, 82, 106, 125, 145.1, 167, 188, 271.46, 294, 321, 347, 381, 408.43, 469, 500.87, 885, 946, 1013, 1082, 1149, 1231, 1308, 1382, 1460, 1535, 1747, 1810.5, 1888, 1979, 2077, 2131, 2302, 2371.99, 5558, 5753, 5966, 6170, 6551, 6785, 7082, 7271.298, 30097.318, 30965.698], "Electron affinity": 1.304473 }, Al: { "Atomic mass": 26.9815386, "Atomic no": 13, "Atomic orbitals": { "1s": -55.156044, "2p": -2.564018, "2s": -3.934827, "3p": -0.102545, "3s": -0.286883 }, "Atomic radius": 1.25, "Atomic radius calculated": 1.18, "Boiling point": "2792 K", "Brinell hardness": "245 MN m<sup>-2</sup>", "Bulk modulus": "76 GPa", "Coefficient of linear thermal expansion": "23.1 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "2700 kg m<sup>-3</sup>", "Electrical resistivity": "2.7 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ne].3s<sup>2</sup>.3p<sup>1</sup>", "ICSD oxidation states": [3], "Ionic radii": { 3: 0.675 }, "Liquid range": "1858.53 K", "Melting point": "933.47 K", "Mendeleev no": 80, "Mineral hardness": "2.75", "Molar volume": "10.00 cm<sup>3</sup>", Name: "Aluminum", "Oxidation states": [1, 3], "Poissons ratio": "0.35", Reflectivity: "71 %", "Refractive index": "no data", "Rigidity modulus": "26 GPa", "Shannon radii": { 3: { IV: { "": { crystal_radius: 0.53, ionic_radius: 0.39 } }, V: { "": { crystal_radius: 0.62, ionic_radius: 0.48 } }, VI: { "": { crystal_radius: 0.675, ionic_radius: 0.535 } } } }, "Superconduction temperature": "1.175 K", "Thermal conductivity": "235 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.84, "Velocity of sound": "5100 m s<sup>-1</sup>", "Vickers hardness": "167 MN m<sup>-2</sup>", X: 1.61, "Youngs modulus": "70 GPa", "NMR Quadrupole Moment": { "Al-27": 146.6 }, "Metallic radius": 1.43, iupac_ordering: 80, "IUPAC ordering": 80, "Ground level": "2P°1/2", "Ionization energies": [5.985769, 18.82855, 28.447642, 119.9924, 153.8252, 190.49, 241.76, 284.64, 330.21, 398.65, 442.005, 2085.97702, 2304.14007], "Electron affinity": 0.432835 }, Am: { "Atomic mass": 243, "Atomic no": 95, "Atomic orbitals": "no data", "Atomic radius": 1.75, "Atomic radius calculated": "no data", "Boiling point": "2880 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>7</sup>.7s<sup>2</sup>", "Ionic radii": { 2: 1.4, 3: 1.115, 4: 0.99 }, "Liquid range": "1431 K", "Melting point": "1449 K", "Mendeleev no": 42, "Mineral hardness": "no data", "Molar volume": "17.63 cm<sup>3</sup>", Name: "Americium", "Oxidation states": [2, 3, 4, 5, 6], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 2: { VII: { "": { crystal_radius: 1.35, ionic_radius: 1.21 } }, VIII: { "": { crystal_radius: 1.4, ionic_radius: 1.26 } }, IX: { "": { crystal_radius: 1.45, ionic_radius: 1.31 } } }, 3: { VI: { "": { crystal_radius: 1.115, ionic_radius: 0.975 } }, VIII: { "": { crystal_radius: 1.23, ionic_radius: 1.09 } } }, 4: { VI: { "": { crystal_radius: 0.99, ionic_radius: 0.85 } }, VIII: { "": { crystal_radius: 1.09, ionic_radius: 0.95 } } } }, "Superconduction temperature": "0.6 K", "Thermal conductivity": "10 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.44, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": 1.73, iupac_ordering: 26, "IUPAC ordering": 26, "Ground level": "8S°7/2", "Ionization energies": [5.97381, 11.7, 21.7, 36.8, 50, 67.9, 95, 110, 125, 141, 163, 184, 206, 225, 242, 284, 305, 424, 451, 481, 511, 541, 571, 616, 646, 680, 711, 870, 900, 940, 980, 1090, 1130, 1240, 1280, 1410, 1490, 1570, 1650, 1730, 1820, 1900, 1980, 2070, 2160, 2240, 2320, 2410, 2480, 2874, 2946, 3021, 3101, 3178, 3251, 3402, 3479, 3563, 3641, 3956, 4033, 4115, 4191, 4642, 4733, 4960, 5050, 8040, 8210, 8390, 8590, 8770, 8950, 9380, 9560, 9770, 9960, 10490, 10650, 10830, 11e3, 12400, 12600, 13e3, 13190, 27110, 27550, 28040, 28500, 33700, 34300, 35100, 35549.4, 139769.5, 142161], "Electron affinity": 0.1 }, Ar: { "Atomic mass": 39.948, "Atomic no": 18, "Atomic orbitals": { "1s": -113.800134, "2p": -8.443439, "2s": -10.794172, "3p": -0.38233, "3s": -0.883384 }, "Atomic radius": 0.71, "Atomic radius calculated": 0.71, "Boiling point": "87.3 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Critical temperature": "150.8 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ne].3s<sup>2</sup>.3p<sup>6</sup>", "Liquid range": "3.5 K", "Max oxidation state": 0, "Melting point": "83.8 K", "Mendeleev no": 3, "Min oxidation state": 0, "Mineral hardness": "no data", "Molar volume": "22.56 cm<sup>3</sup>", Name: "Argon", "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000281", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "0.01772 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.88, "Velocity of sound": "319 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 3, "IUPAC ordering": 3, "Ground level": "1S0", "Ionization energies": [15.7596119, 27.62967, 40.735, 59.58, 74.84, 91.29, 124.41, 143.4567, 422.6, 479.76, 540.4, 619, 685.5, 755.13, 855.5, 918.375, 4120.6657, 4426.2229], "Electron affinity": -1.02 }, As: { "Atomic mass": 74.9216, "Atomic no": 33, "Atomic orbitals": { "1s": -423.336658, "2p": -47.527869, "2s": -53.093086, "3d": -1.542767, "3p": -4.851725, "3s": -6.730755, "4p": -0.197497, "4s": -0.52367 }, "Atomic radius": 1.15, "Atomic radius calculated": 1.14, "Boiling point": "887 K", "Brinell hardness": "1440 MN m<sup>-2</sup>", "Bulk modulus": "22 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-3, 3, 5], "Critical temperature": "1700 K", "Density of solid": "5727 kg m<sup>-3</sup>", "Electrical resistivity": "33 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>10</sup>.4s<sup>2</sup>.4p<sup>3</sup>", "ICSD oxidation states": [2, 3, 5, -2, -3, -1], "Ionic radii": { 3: 0.72, 5: 0.6 }, "Liquid range": "203 K", "Melting point": "1090 K", "Mendeleev no": 89, "Mineral hardness": "3.5", "Molar volume": "12.95 cm<sup>3</sup>", Name: "Arsenic", "Oxidation states": [-3, 2, 3, 5], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.001552", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.72, ionic_radius: 0.58 } } }, 5: { IV: { "": { crystal_radius: 0.475, ionic_radius: 0.335 } }, VI: { "": { crystal_radius: 0.6, ionic_radius: 0.46 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "50 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.85, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.18, "Youngs modulus": "8 GPa", "Metallic radius": "no data", iupac_ordering: 89, "IUPAC ordering": 89, "Ground level": "4S°3/2", "Ionization energies": [9.78855, 18.5892, 28.349, 50.15, 62.77, 121.19, 147, 180, 213, 247, 296, 333, 375, 418, 460, 587.6, 628.8, 672.9, 728.9, 774, 814, 911.7, 956.79, 2356.9, 2486, 2626, 2766, 2938, 3088.1, 3287, 3411.643, 14447.678, 15028.907], "Electron affinity": 0.80482 }, At: { "Atomic mass": 210, "Atomic no": 85, "Atomic orbitals": { "1s": -3127.390276, "2p": -513.044243, "2s": -531.81835, "3d": -103.060375, "3p": -119.995013, "3s": -129.035542, "4d": -18.295162, "4f": -8.063483, "4p": -25.778264, "4s": -29.809515, "5d": -1.643758, "5p": -4.027061, "5s": -5.453383, "6p": -0.255453, "6s": -0.560189 }, "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-1, 1], "Critical temperature": "no data K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>10</sup>.6s<sup>2</sup>.6p<sup>5</sup>", "Ionic radii": { 7: 0.76 }, "Liquid range": "no data K", "Melting point": "575 K", "Mendeleev no": 96, "Mineral hardness": "no data", "Molar volume": "no data cm<sup>3</sup>", Name: "Astatine", "Oxidation states": [-1, 1, 3, 5], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 7: { VI: { "": { crystal_radius: 0.76, ionic_radius: 0.62 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "2 (estimate)W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.02, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.2, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 98, "IUPAC ordering": 98, "Ground level": "2P°3/2", "Ionization energies": [9.31751, 17.88, 26.58, 39.65, 50.39, 72, 85.1, 130.1, 149, 169, 192.1, 212, 236, 263, 287, 311, 335, 452, 481, 510, 540, 600, 630, 720, 750, 790, 860, 920, 990, 1050, 1120, 1180, 1250, 1320, 1380, 1450, 1510, 1590, 1650, 1948, 2007, 2071, 2139, 2203, 2266, 2373, 2439, 2510, 2576, 2841, 2905, 2977, 3042, 3312, 3388, 3573, 3649, 5976, 6122, 6279, 6445, 6604, 6759, 7068, 7230, 7410, 7570, 8030, 8180, 8330, 8480, 9330, 9500, 9830, 9990, 21210, 21600, 22030, 22420, 25580, 26090, 26730, 27139, 107923.4, 109886], "Electron affinity": 2.415787 }, Au: { "Atomic mass": 196.966569, "Atomic no": 79, "Atomic orbitals": { "1s": -2683.508245, "2p": -430.725701, "2s": -447.888973, "3d": -81.511751, "3p": -96.707, "3s": -104.824516, "4d": -12.131815, "4f": -3.486824, "4p": -18.578652, "4s": -22.078357, "5d": -0.304738, "5p": -2.002495, "5s": -3.113936, "6s": -0.162334 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.74, "Boiling point": "3129 K", "Brinell hardness": "2450 MN m<sup>-2</sup>", "Bulk modulus": "220 GPa", "Coefficient of linear thermal expansion": "14.2 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "19300 kg m<sup>-3</sup>", "Electrical resistivity": "2.2 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>10</sup>.6s<sup>1</sup>", "Ionic radii": { 1: 1.51, 3: 0.99, 5: 0.71 }, "Liquid range": "1791.67 K", "Melting point": "1337.33 K", "Mendeleev no": 70, "Mineral hardness": "2.5", "Molar volume": "10.21 cm<sup>3</sup>", Name: "Gold", "Oxidation states": [-1, 1, 2, 3, 5], "Poissons ratio": "0.44", Reflectivity: "95 %", "Refractive index": "no data", "Rigidity modulus": "27 GPa", "Shannon radii": { 1: { VI: { "": { crystal_radius: 1.51, ionic_radius: 1.37 } } }, 3: { IVSQ: { "": { crystal_radius: 0.82, ionic_radius: 0.68 } }, VI: { "": { crystal_radius: 0.99, ionic_radius: 0.85 } } }, 5: { VI: { "": { crystal_radius: 0.71, ionic_radius: 0.57 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "320 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.14, "Velocity of sound": "1740 m s<sup>-1</sup>", "Vickers hardness": "216 MN m<sup>-2</sup>", X: 2.54, "Youngs modulus": "78 GPa", "Metallic radius": 1.442, iupac_ordering: 71, "IUPAC ordering": 71, "Ground level": "2S1/2", "Ionization energies": [9.225554, 20.203, 30, 45, 60, 74, 94, 112, 130.1, 149, 168.2, 248, 275, 299, 324, 365, 392, 433, 487, 520, 550, 600, 650, 710, 760, 820, 870, 930, 990, 1040, 1100, 1150, 1210, 1475, 1527, 1584, 1644, 1702, 1758, 1845, 1904, 1967, 2026, 2261, 2320, 2383, 2443, 2640, 2708, 2870, 2941, 4888, 5013, 5156, 5307, 5452, 5594, 5846, 5994, 6156, 6305, 6724, 6854, 6997, 7130, 7760, 7910, 8210, 8360, 18040, 18400, 18790, 19150, 21470, 21920, 22500, 22868.1, 91515.82, 93254.3], "Electron affinity": 2.30861025 }, B: { "Atomic mass": 10.811, "Atomic no": 5, "Atomic orbitals": { "1s": -6.564347, "2p": -0.136603, "2s": -0.344701 }, "Atomic radius": 0.85, "Atomic radius calculated": 0.87, "Boiling point": "4200 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "320 GPa", "Coefficient of linear thermal expansion": "6 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "2460 kg m<sup>-3</sup>", "Electrical resistivity": "&gt; 10<sup>12</sup>10<sup>-8</sup> &Omega; m", "Electronic structure": "[He].2s<sup>2</sup>.2p<sup>1</sup>", "ICSD oxidation states": [3, -3], "Ionic radii": { 3: 0.41 }, "Liquid range": "1851 K", "Melting point": "2349 K", "Mendeleev no": 86, "Mineral hardness": "9.3", "Molar volume": "4.39 cm<sup>3</sup>", Name: "Boron", "Oxidation states": [1, 2, 3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { III: { "": { crystal_radius: 0.15, ionic_radius: 0.01 } }, IV: { "": { crystal_radius: 0.25, ionic_radius: 0.11 } }, VI: { "": { crystal_radius: 0.41, ionic_radius: 0.27 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "27 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.92, "Velocity of sound": "16200 m s<sup>-1</sup>", "Vickers hardness": "49000 MN m<sup>-2</sup>", X: 2.04, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "B-10": 84.59, "B-11": 40.59 }, "Metallic radius": "no data", iupac_ordering: 81, "IUPAC ordering": 81, "Ground level": "2P°1/2", "Ionization energies": [8.298019, 25.15483, 37.93059, 259.3715, 340.2260229], "Electron affinity": 0.27972325 }, Ba: { "Atomic mass": 137.327, "Atomic no": 56, "Atomic orbitals": { "1s": -1305.743258, "2p": -189.598483, "2s": -200.844444, "3d": -28.528933, "3p": -37.536931, "3s": -42.359434, "4d": -3.432441, "4p": -6.497622, "4s": -8.257061, "5p": -0.698605, "5s": -1.157159, "6s": -0.118967 }, "Atomic radius": 2.15, "Atomic radius calculated": 2.53, "Boiling point": "2143 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "9.6 GPa", "Coefficient of linear thermal expansion": "20.6 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "3510 kg m<sup>-3</sup>", "Electrical resistivity": "34 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].6s<sup>2</sup>", "ICSD oxidation states": [2], "Ionic radii": { 2: 1.49 }, "Liquid range": "1143 K", "Melting point": "1000 K", "Mendeleev no": 14, "Mineral hardness": "1.25", "Molar volume": "38.16 cm<sup>3</sup>", Name: "Barium", "Oxidation states": [2], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "4.9 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.49, ionic_radius: 1.35 } }, VII: { "": { crystal_radius: 1.52, ionic_radius: 1.38 } }, VIII: { "": { crystal_radius: 1.56, ionic_radius: 1.42 } }, IX: { "": { crystal_radius: 1.61, ionic_radius: 1.47 } }, X: { "": { crystal_radius: 1.66, ionic_radius: 1.52 } }, XI: { "": { crystal_radius: 1.71, ionic_radius: 1.57 } }, XII: { "": { crystal_radius: 1.75, ionic_radius: 1.61 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "18 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.68, "Velocity of sound": "1620 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.89, "Youngs modulus": "13 GPa", "Metallic radius": 2.236, iupac_ordering: 13, "IUPAC ordering": 13, "Ground level": "1S0", "Ionization energies": [5.2116646, 10.003826, 35.8438, 47, 58, 71, 86, 101, 130.5, 146.52, 241, 267.1, 296, 325, 354, 390, 422, 455, 488, 520, 646, 679, 717, 752, 809, 846, 935, 976.62, 1695, 1776, 1864, 1958, 2047, 2142, 2256, 2349, 2452, 2547, 2814, 2901, 2994, 3081, 3266, 3363, 3546, 3640, 8326, 8565, 8831, 9077, 9739, 10023, 10376, 10616.42, 43485.366, 44561.47], "Electron affinity": 0.144626 }, Be: { "Atomic mass": 9.012182, "Atomic no": 4, "Atomic orbitals": { "1s": -3.856411, "2s": -0.205744 }, "Atomic radius": 1.05, "Atomic radius calculated": 1.12, "Boiling point": "2742 K", "Brinell hardness": "600 MN m<sup>-2</sup>", "Bulk modulus": "130 GPa", "Coefficient of linear thermal expansion": "11.3 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "1848 kg m<sup>-3</sup>", "Electrical resistivity": "3.8 10<sup>-8</sup> &Omega; m", "Electronic structure": "[He].2s<sup>2</sup>", "ICSD oxidation states": [2], "Ionic radii": { 2: 0.59 }, "Liquid range": "1182 K", "Melting point": "1560 K", "Mendeleev no": 77, "Mineral hardness": "5.5", "Molar volume": "4.85 cm<sup>3</sup>", Name: "Beryllium", "Oxidation states": [2], "Poissons ratio": "0.032", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "132 GPa", "Shannon radii": { 2: { III: { "": { crystal_radius: 0.3, ionic_radius: 0.16 } }, IV: { "": { crystal_radius: 0.41, ionic_radius: 0.27 } }, VI: { "": { crystal_radius: 0.59, ionic_radius: 0.45 } } } }, "Superconduction temperature": "0.026 K", "Thermal conductivity": "190 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.53, "Velocity of sound": "13000 m s<sup>-1</sup>", "Vickers hardness": "1670 MN m<sup>-2</sup>", X: 1.57, "Youngs modulus": "287 GPa", "NMR Quadrupole Moment": { "Be-9": 52.88 }, "Metallic radius": 1.12, iupac_ordering: 17, "IUPAC ordering": 17, "Ground level": "1S0", "Ionization energies": [9.322699, 18.21115, 153.896205, 217.7185861], "Electron affinity": -0.52 }, Bi: { "Atomic mass": 208.9804, "Atomic no": 83, "Atomic orbitals": { "1s": -2975.550959, "2p": -484.716359, "2s": -502.950758, "3d": -95.532476, "3p": -111.883393, "3s": -120.613998, "4d": -16.084817, "4f": -6.382744, "4p": -23.218641, "4s": -27.07034, "5d": -1.139408, "5p": -3.293637, "5s": -4.611934, "6p": -0.180198, "6s": -0.426129 }, "Atomic radius": 1.6, "Atomic radius calculated": 1.43, "Boiling point": "1837 K", "Brinell hardness": "94.2 MN m<sup>-2</sup>", "Bulk modulus": "31 GPa", "Coefficient of linear thermal expansion": "13.4 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "9780 kg m<sup>-3</sup>", "Electrical resistivity": "130 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>10</sup>.6s<sup>2</sup>.6p<sup>3</sup>", "ICSD oxidation states": [1, 2, 3, 5], "Ionic radii": { 3: 1.17, 5: 0.9 }, "Liquid range": "1292.6 K", "Melting point": "544.4 K", "Mendeleev no": 87, "Mineral hardness": "2.25", "Molar volume": "21.31 cm<sup>3</sup>", Name: "Bismuth", "Oxidation states": [-3, 3, 5], "Poissons ratio": "0.33", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "12 GPa", "Shannon radii": { 3: { V: { "": { crystal_radius: 1.1, ionic_radius: 0.96 } }, VI: { "": { crystal_radius: 1.17, ionic_radius: 1.03 } }, VIII: { "": { crystal_radius: 1.31, ionic_radius: 1.17 } } }, 5: { VI: { "": { crystal_radius: 0.9, ionic_radius: 0.76 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "8 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.07, "Velocity of sound": "1790 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.02, "Youngs modulus": "32 GPa", "Metallic radius": 1.82, iupac_ordering: 87, "IUPAC ordering": 87, "Ground level": "4S°3/2", "Ionization energies": [7.285516, 16.703, 25.57075, 45.37, 54.856, 88.4, 103, 122, 143, 161.1, 183, 208, 229, 252, 272.6, 370.2, 409, 436, 464, 520, 550, 620, 660, 690, 750, 810, 870, 930, 990, 1060, 1120, 1180, 1250, 1310, 1380, 1440, 1500, 1784, 1840, 1902, 1967, 2029, 2090, 2190, 2253, 2321, 2385, 2641, 2703, 2771, 2835, 3078, 3151, 3329, 3401.8, 5599, 5740, 5892, 6054, 6208, 6358, 6648, 6804, 6977, 7137, 7580, 7720, 7870, 8010, 8780, 8950, 9270, 9430, 20130, 20500, 20920, 21300, 24150, 24640, 25260, 25656.9, 102251.76, 104132.8], "Electron affinity": 0.94236213 }, Bk: { "Atomic mass": 247, "Atomic no": 97, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "14780 kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>9</sup>.7s<sup>2</sup>", "Ionic radii": { 3: 1.1, 4: 0.97 }, "Liquid range": "no data K", "Melting point": "1259 K", "Mendeleev no": 40, "Mineral hardness": "no data", "Molar volume": "16.84 cm<sup>3</sup>", Name: "Berkelium", "Oxidation states": [3, 4], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.1, ionic_radius: 0.96 } } }, 4: { VI: { "": { crystal_radius: 0.97, ionic_radius: 0.83 } }, VIII: { "": { crystal_radius: 1.07, ionic_radius: 0.93 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "10 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.44, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": 1.703, iupac_ordering: 24, "IUPAC ordering": 24, "Ground level": "6H°15/2", "Ionization energies": [6.19785, 11.9, 21.6, 36, 56, 70.1, 90, 114, 130, 147, 171, 195, 218, 240, 259, 279, 303, 339, 361, 497, 526, 557, 590, 621, 652, 700, 733, 768, 800, 960, 1e3, 1040, 1080, 1200, 1240, 1360, 1410, 1550, 1630, 1720, 1800, 1890, 1970, 2050, 2140, 2240, 2320, 2410, 2490, 2580, 2670, 3080, 3154, 3232, 3315, 3393, 3469, 3630, 3709, 3797, 3877, 4202, 4281, 4365, 4445, 4940, 5040, 5270, 5360, 8500, 8670, 8850, 9050, 9240, 9420, 9880, 10070, 10280, 10480, 11020, 11190, 11380, 11550, 13090, 13300, 13720, 13910, 28380, 28800, 29300, 29800, 35500, 36200, 37e3, 37457.6, 146904.7, 149398], "Electron affinity": -1.72 }, Br: { "Atomic mass": 79.904, "Atomic no": 35, "Atomic orbitals": { "1s": -480.182643, "2p": -55.67796, "2s": -61.710022, "3d": -2.52211, "3p": -6.298805, "3s": -8.409057, "4p": -0.295334, "4s": -0.720066 }, "Atomic radius": 1.15, "Atomic radius calculated": 0.94, "Boiling point": "332 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "1.9 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-1, 1, 3, 5, 7], "Critical temperature": "586 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "&gt; 10<sup>18</sup>10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>10</sup>.4s<sup>2</sup>.4p<sup>5</sup>", "ICSD oxidation states": [5, -1], "Ionic radii": { "-1": 1.82, 3: 0.73, 5: 0.45, 7: 0.53 }, "Liquid range": "66.2 K", "Melting point": "265.8 K", "Mendeleev no": 98, "Mineral hardness": "no data", "Molar volume": "19.78 cm<sup>3</sup>", Name: "Bromine", "Oxidation states": [-1, 1, 3, 4, 5, 7], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.001132", "Rigidity modulus": "no data GPa", "Shannon radii": { "-1": { VI: { "": { crystal_radius: 1.82, ionic_radius: 1.96 } } }, 3: { IVSQ: { "": { crystal_radius: 0.73, ionic_radius: 0.59 } } }, 5: { IIIPY: { "": { crystal_radius: 0.45, ionic_radius: 0.31 } } }, 7: { IV: { "": { crystal_radius: 0.39, ionic_radius: 0.25 } }, VI: { "": { crystal_radius: 0.53, ionic_radius: 0.39 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.12 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.85, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.96, "Youngs modulus": "no data GPa", "Metallic radius": 1.14, iupac_ordering: 100, "IUPAC ordering": 100, "Ground level": "2P°3/2", "Ionization energies": [11.81381, 21.591, 34.871, 47.782, 59.595, 87.39, 103.03, 192.61, 224, 261, 301, 338, 393, 436, 481, 530, 577, 716.3, 761, 809.8, 870, 920.8, 963, 1070.6, 1119.17, 2731.4, 2869, 3021, 3169, 3361, 3523.1, 3735, 3868.986, 16317.011, 16937.127], "Electron affinity": 3.3635883 }, C: { "Atomic mass": 12.0107, "Atomic no": 6, "Atomic orbitals": { "1s": -9.947718, "2p": -0.199186, "2s": -0.500866 }, "Atomic radius": 0.7, "Atomic radius calculated": 0.67, "Boiling point": "4300 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "33 GPa", "Coefficient of linear thermal expansion": "7.1 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-4, 4], "Critical temperature": "no data K", "Density of solid": "2267 kg m<sup>-3</sup>", "Electrical resistivity": "about 1000 - direction dependent10<sup>-8</sup> &Omega; m", "Electronic structure": "[He].2s<sup>2</sup>.2p<sup>2</sup>", "ICSD oxidation states": [2, 3, 4, -4, -3, -2], "Ionic radii": { 4: 0.3 }, "Liquid range": "500 K", "Melting point": "3800 K", "Mendeleev no": 95, "Mineral hardness": "0.5 (graphite; diamond is 10.0)(no units)", "Molar volume": "5.29 cm<sup>3</sup>", Name: "Carbon", "Oxidation states": [-4, -3, -2, -1, 1, 2, 3, 4], "Poissons ratio": "no data", Reflectivity: "27 %", "Refractive index": "2.417 (diamond)(no units)", "Rigidity modulus": "no data GPa", "Shannon radii": { 4: { III: { "": { crystal_radius: 0.06, ionic_radius: -0.08 } }, IV: { "": { crystal_radius: 0.29, ionic_radius: 0.15 } }, VI: { "": { crystal_radius: 0.3, ionic_radius: 0.16 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "140 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.7, "Velocity of sound": "18350 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.55, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "C-11": 33.27 }, "Metallic radius": "no data", iupac_ordering: 86, "IUPAC ordering": 86, "Ground level": "3P0", "Ionization energies": [11.260288, 24.383154, 47.88778, 64.49352, 392.090518, 489.993198], "Electron affinity": 1.262113612 }, Ca: { "Atomic mass": 40.078, "Atomic no": 20, "Atomic orbitals": { "1s": -143.935181, "2p": -12.285376, "2s": -15.046905, "3p": -1.030572, "3s": -1.706331, "4s": -0.141411 }, "Atomic radius": 1.8, "Atomic radius calculated": 1.94, "Boiling point": "1757 K", "Brinell hardness": "167 MN m<sup>-2</sup>", "Bulk modulus": "17 GPa", "Coefficient of linear thermal expansion": "22.3 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "1550 kg m<sup>-3</sup>", "Electrical resistivity": "3.4 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].4s<sup>2</sup>", "ICSD oxidation states": [2], "Ionic radii": { 2: 1.14 }, "Liquid range": "642 K", "Melting point": "1115 K", "Mendeleev no": 16, "Mineral hardness": "1.75", "Molar volume": "26.20 cm<sup>3</sup>", Name: "Calcium", "Oxidation states": [2], "Poissons ratio": "0.31", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "7.4 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.14, ionic_radius: 1 } }, VII: { "": { crystal_radius: 1.2, ionic_radius: 1.06 } }, VIII: { "": { crystal_radius: 1.26, ionic_radius: 1.12 } }, IX: { "": { crystal_radius: 1.32, ionic_radius: 1.18 } }, X: { "": { crystal_radius: 1.37, ionic_radius: 1.23 } }, XII: { "": { crystal_radius: 1.48, ionic_radius: 1.34 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "200 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.31, "Velocity of sound": "3810 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1, "Youngs modulus": "20 GPa", "NMR Quadrupole Moment": { "Ca-41": -66.5, "Ca-43": -40.8 }, "Metallic radius": 1.976, iupac_ordering: 15, "IUPAC ordering": 15, "Ground level": "1S0", "Ionization energies": [6.11315547, 11.871719, 50.91316, 67.2732, 84.34, 108.78, 127.21, 147.24, 188.54, 211.275, 591.6, 658.2, 728.6, 817.2, 894, 973.7, 1086.8, 1157.726, 5128.8578, 5469.8616], "Electron affinity": 0.024551 }, Cd: { "Atomic mass": 112.411, "Atomic no": 48, "Atomic orbitals": { "1s": -941.476646, "2p": -127.63512, "2s": -136.83249, "3d": -14.685252, "3p": -21.637522, "3s": -25.379908, "4d": -0.47053, "4p": -2.39526, "4s": -3.596069, "5s": -0.204228 }, "Atomic radius": 1.55, "Atomic radius calculated": 1.61, "Boiling point": "1040 K", "Brinell hardness": "203 MN m<sup>-2</sup>", "Bulk modulus": "42 GPa", "Coefficient of linear thermal expansion": "30.8 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "8650 kg m<sup>-3</sup>", "Electrical resistivity": "7 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>.5s<sup>2</sup>", "ICSD oxidation states": [2], "Ionic radii": { 2: 1.09 }, "Liquid range": "445.78 K", "Melting point": "594.22 K", "Mendeleev no": 75, "Mineral hardness": "2.0", "Molar volume": "13.00 cm<sup>3</sup>", Name: "Cadmium", "Oxidation states": [1, 2], "Poissons ratio": "0.30", Reflectivity: "67 %", "Refractive index": "no data", "Rigidity modulus": "19 GPa", "Shannon radii": { 2: { IV: { "": { crystal_radius: 0.92, ionic_radius: 0.78 } }, V: { "": { crystal_radius: 1.01, ionic_radius: 0.87 } }, VI: { "": { crystal_radius: 1.09, ionic_radius: 0.95 } }, VII: { "": { crystal_radius: 1.17, ionic_radius: 1.03 } }, VIII: { "": { crystal_radius: 1.24, ionic_radius: 1.1 } }, XII: { "": { crystal_radius: 1.45, ionic_radius: 1.31 } } } }, "Superconduction temperature": "0.517 K", "Thermal conductivity": "97 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.18, "Velocity of sound": "2310 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.69, "Youngs modulus": "50 GPa", "Metallic radius": 1.51, iupac_ordering: 75, "IUPAC ordering": 75, "Ground level": "1S0", "Ionization energies": [8.99382, 16.908313, 37.468, 51, 67.9, 87, 105, 130.1, 150, 173, 195, 218, 305, 329, 358, 385, 421, 452.6, 513, 546.19, 963, 1026, 1095, 1167, 1237, 1320, 1401, 1477, 1558, 1635, 1852, 1917.9, 1998, 2091, 2195, 2250, 2427, 2498.62, 5839, 6039, 6257, 6460, 6869, 7109, 7414, 7607.95, 31451.062, 32341.49], "Electron affinity": -0.72 }, Ce: { "Atomic mass": 140.116, "Atomic no": 58, "Atomic orbitals": { "1s": -1406.148284, "2p": -206.925148, "2s": -218.684842, "3d": -32.412569, "3p": -41.938282, "3s": -47.035283, "4d": -4.192548, "4f": -0.337442, "4p": -7.532106, "4s": -9.432744, "5d": -0.14055, "5p": -0.85011, "5s": -1.369728, "6s": -0.133974 }, "Atomic radius": 1.85, "Atomic radius calculated": "no data", "Boiling point": "3633 K", "Brinell hardness": "412 MN m<sup>-2</sup>", "Bulk modulus": "22 GPa", "Coefficient of linear thermal expansion": "6.3 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3, 4], "Critical temperature": "no data K", "Density of solid": "6689 kg m<sup>-3</sup>", "Electrical resistivity": "74 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>1</sup>.5d<sup>1</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3, 4], "Ionic radii": { 3: 1.15, 4: 1.01 }, "Liquid range": "2565 K", "Melting point": "1068 K", "Mendeleev no": 32, "Mineral hardness": "2.5", "Molar volume": "20.69 cm<sup>3</sup>", Name: "Cerium", "Oxidation states": [2, 3, 4], "Poissons ratio": "0.24", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "14 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.15, ionic_radius: 1.01 } }, VII: { "": { crystal_radius: 1.21, ionic_radius: 1.07 } }, VIII: { "": { crystal_radius: 1.283, ionic_radius: 1.143 } }, IX: { "": { crystal_radius: 1.336, ionic_radius: 1.196 } }, X: { "": { crystal_radius: 1.39, ionic_radius: 1.25 } }, XII: { "": { crystal_radius: 1.48, ionic_radius: 1.34 } } }, 4: { VI: { "": { crystal_radius: 1.01, ionic_radius: 0.87 } }, VIII: { "": { crystal_radius: 1.11, ionic_radius: 0.97 } }, X: { "": { crystal_radius: 1.21, ionic_radius: 1.07 } }, XII: { "": { crystal_radius: 1.28, ionic_radius: 1.14 } } } }, "Superconduction temperature": "0.022  (under pressure)K", "Thermal conductivity": "11 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.42, "Velocity of sound": "2100 m s<sup>-1</sup>", "Vickers hardness": "270 MN m<sup>-2</sup>", X: 1.12, "Youngs modulus": "34 GPa", "Metallic radius": 1.707, iupac_ordering: 46, "IUPAC ordering": 46, "Ground level": "1G°4", "Ionization energies": [5.5386, 10.956, 20.1974, 36.906, 65.55, 77.6, 91, 106, 125, 140, 172, 192.24, 312, 340, 371, 403, 435, 472, 509, 543, 579, 613, 749, 785, 824, 862, 924, 965, 1060, 1103.5, 1908, 1994, 2087, 2185, 2280, 2378, 2500, 2600, 2706, 2806, 3087, 3176, 3274, 3366, 3570, 3672, 3865, 3963, 9020, 9269, 9545, 9803, 10542, 10840, 11210, 11459.85, 46840.306, 47965.72], "Electron affinity": 0.572 }, Cf: { "Atomic mass": 251, "Atomic no": 98, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "15100 kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>10</sup>.7s<sup>2</sup>", "Ionic radii": { 3: 1.09, 4: 0.961 }, "Liquid range": "no data K", "Melting point": "1173 K", "Mendeleev no": 39, "Mineral hardness": "no data", "Molar volume": "16.50 cm<sup>3</sup>", Name: "Californium", "Oxidation states": [2, 3, 4], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.09, ionic_radius: 0.95 } } }, 4: { VI: { "": { crystal_radius: 0.961, ionic_radius: 0.821 } }, VIII: { "": { crystal_radius: 1.06, ionic_radius: 0.92 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.45, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": 1.86, iupac_ordering: 23, "IUPAC ordering": 23, "Ground level": "5I8", "Ionization energies": [6.28166, 12, 22.4, 37.7, 51.9, 75, 91, 112.9, 133, 152, 178, 201, 225, 247, 265, 286, 310, 334, 368, 390, 536, 566, 597, 630, 662, 695, 744, 778, 814, 847, 1010, 1050, 1090, 1120, 1250, 1300, 1420, 1470, 1620, 1700, 1790, 1880, 1960, 2050, 2130, 2220, 2320, 2410, 2490, 2580, 2670, 2750, 3186, 3261, 3340, 3424, 3503, 3581, 3747, 3828, 3915, 3998, 4329, 4407, 4494, 4570, 5100, 5190, 5430, 5520, 8730, 8900, 9090, 9290, 9480, 9660, 10140, 10330, 10550, 10740, 11300, 11470, 11650, 11820, 13450, 13660, 14080, 14280, 29e3, 29500, 3e4, 30500, 36500, 37100, 37900, 38443.5, 150579.3, 153124], "Electron affinity": -1.01 }, Cl: { "Atomic mass": 35.453, "Atomic no": 17, "Atomic orbitals": { "1s": -100.369229, "2p": -7.039982, "2s": -9.187993, "3p": -0.32038, "3s": -0.754458 }, "Atomic radius": 1, "Atomic radius calculated": 0.79, "Boiling point": "239.11 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "1.1 (liquid)GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-1, 1, 3, 5, 7], "Critical temperature": "417 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "&gt; 10<sup>10</sup>10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ne].3s<sup>2</sup>.3p<sup>5</sup>", "ICSD oxidation states": [-1], "Ionic radii": { "-1": 1.67, 5: 0.26, 7: 0.41 }, "Liquid range": "67.51 K", "Melting point": "171.6 K", "Mendeleev no": 99, "Mineral hardness": "no data", "Molar volume": "17.39 cm<sup>3</sup>", Name: "Chlorine", "Oxidation states": [-1, 1, 2, 3, 4, 5, 6, 7], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000773", "Rigidity modulus": "no data GPa", "Shannon radii": { "-1": { VI: { "": { crystal_radius: 1.67, ionic_radius: 1.81 } } }, 5: { IIIPY: { "": { crystal_radius: 0.26, ionic_radius: 0.12 } } }, 7: { IV: { "": { crystal_radius: 0.22, ionic_radius: 0.08 } }, VI: { "": { crystal_radius: 0.41, ionic_radius: 0.27 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.0089 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.75, "Velocity of sound": "206 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 3.16, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "Cl-35": -81.65, "Cl-37": -64.35 }, "Metallic radius": "no data", iupac_ordering: 101, "IUPAC ordering": 101, "Ground level": "2P°3/2", "Ionization energies": [12.967633, 23.81364, 39.8, 53.24, 67.68, 96.94, 114.2013, 348.306, 400.851, 456.7, 530, 591.58, 656.3, 750.23, 809.198, 3658.3438, 3946.2909], "Electron affinity": 3.61272528 }, Cm: { "Atomic mass": 247, "Atomic no": 96, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "3383 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "13510 kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>7</sup>.6d<sup>1</sup>.7s<sup>2</sup>", "Ionic radii": { 3: 1.11, 4: 0.99 }, "Liquid range": "1770 K", "Melting point": "1613 K", "Mendeleev no": 41, "Mineral hardness": "no data", "Molar volume": "18.05 cm<sup>3</sup>", Name: "Curium", "Oxidation states": [3, 4], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.11, ionic_radius: 0.97 } } }, 4: { VI: { "": { crystal_radius: 0.99, ionic_radius: 0.85 } }, VIII: { "": { crystal_radius: 1.09, ionic_radius: 0.95 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "8.8 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.45, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": 1.743, iupac_ordering: 25, "IUPAC ordering": 25, "Ground level": "9D°2", "Ionization energies": [5.99141, 12.4, 20.1, 37.7, 51, 69.1, 97, 112, 128, 144, 167, 190, 213, 235, 253, 272, 311, 332, 460, 489, 518, 550, 580, 611, 657, 689, 723, 755, 910, 950, 990, 1030, 1140, 1180, 1300, 1340, 1480, 1560, 1650, 1730, 1810, 1890, 1980, 2060, 2160, 2240, 2320, 2410, 2490, 2580, 2976, 3050, 3125, 3207, 3284, 3360, 3515, 3593, 3679, 3758, 4078, 4156, 4239, 4317, 4791, 4880, 5110, 5200, 8270, 8440, 8620, 8820, 9e3, 9180, 9630, 9820, 10020, 10220, 10760, 10920, 11100, 11270, 12740, 12950, 13350, 13550, 27740, 28180, 28700, 29100, 34600, 35200, 36e3, 36493, 143299.6, 145743], "Electron affinity": 0.28 }, Co: { "Atomic mass": 58.933195, "Atomic no": 27, "Atomic orbitals": { "1s": -275.616639, "2p": -28.152095, "2s": -32.379758, "3d": -0.322368, "3p": -2.388285, "3s": -3.651812, "4s": -0.204497 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.52, "Boiling point": "3200 K", "Brinell hardness": "700 MN m<sup>-2</sup>", "Bulk modulus": "180 GPa", "Coefficient of linear thermal expansion": "13.0 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2, 3], "Critical temperature": "no data K", "Density of solid": "8900 kg m<sup>-3</sup>", "Electrical resistivity": "6 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>7</sup>.4s<sup>2</sup>", "ICSD oxidation states": [1, 2, 3, 4], "Ionic radii": { 2: 0.885, 3: 0.75, 4: 0.67 }, "Ionic radii hs": { 2: 0.885, 3: 0.75, 4: 0.67 }, "Ionic radii ls": { 2: 0.79, 3: 0.685 }, "Liquid range": "1432 K", "Melting point": "1768 K", "Mendeleev no": 64, "Mineral hardness": "5.0", "Molar volume": "6.67 cm<sup>3</sup>", Name: "Cobalt", "Oxidation states": [-1, 1, 2, 3, 4, 5], "Poissons ratio": "0.31", Reflectivity: "67 %", "Refractive index": "no data", "Rigidity modulus": "75 GPa", "Shannon radii": { 2: { IV: { "High Spin": { crystal_radius: 0.72, ionic_radius: 0.58 } }, V: { "": { crystal_radius: 0.81, ionic_radius: 0.67 } }, VI: { "Low Spin": { crystal_radius: 0.79, ionic_radius: 0.65 }, "High Spin": { crystal_radius: 0.885, ionic_radius: 0.745 } }, VIII: { "": { crystal_radius: 1.04, ionic_radius: 0.9 } } }, 3: { VI: { "High Spin": { crystal_radius: 0.75, ionic_radius: 0.61 }, "Low Spin": { crystal_radius: 0.685, ionic_radius: 0.545 } } }, 4: { IV: { "": { crystal_radius: 0.54, ionic_radius: 0.4 } }, VI: { "High Spin": { crystal_radius: 0.67, ionic_radius: 0.53 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "100 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2, "Velocity of sound": "4720 m s<sup>-1</sup>", "Vickers hardness": "1043 MN m<sup>-2</sup>", X: 1.88, "Youngs modulus": "209 GPa", "NMR Quadrupole Moment": { "Co-59": 420.3 }, "Metallic radius": 1.25, iupac_ordering: 67, "IUPAC ordering": 67, "Ground level": "4F9/2", "Ionization energies": [7.88101, 17.0844, 33.5, 51.27, 79.5, 102, 128.9, 157.8, 186.14, 275.4, 305.32, 336.1, 378.5, 410, 441.1, 511.96, 546.588, 1397.2, 1504.5, 1606, 1724, 1844, 1960.8, 2119.4, 2218.876, 9544.1833, 10012.122], "Electron affinity": 0.662265 }, Cr: { "Atomic mass": 51.9961, "Atomic no": 24, "Atomic orbitals": { "1s": -213.881191, "2p": -20.526273, "2s": -24.113457, "3d": -0.118123, "3p": -1.65423, "3s": -2.649085, "4s": -0.150445 }, "Atomic radius": 1.4, "Atomic radius calculated": 1.66, "Boiling point": "2944 K", "Brinell hardness": "1120 MN m<sup>-2</sup>", "Bulk modulus": "160 GPa", "Coefficient of linear thermal expansion": "4.9 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3, 6], "Critical temperature": "no data K", "Density of solid": "7140 kg m<sup>-3</sup>", "Electrical resistivity": "12.7 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>5</sup>.4s<sup>1</sup>", "ICSD oxidation states": [2, 3, 4, 5, 6], "Ionic radii": { 2: 0.94 }, "Ionic radii hs": { 2: 0.94 }, "Ionic radii ls": { 2: 0.87, 3: 0.755, 4: 0.69, 5: 0.63, 6: 0.58 }, "Liquid range": "764 K", "Melting point": "2180 K", "Mendeleev no": 57, "Mineral hardness": "8.5", "Molar volume": "7.23 cm<sup>3</sup>", Name: "Chromium", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.21", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "115 GPa", "Shannon radii": { 2: { VI: { "Low Spin": { crystal_radius: 0.87, ionic_radius: 0.73 }, "High Spin": { crystal_radius: 0.94, ionic_radius: 0.8 } } }, 3: { VI: { "": { crystal_radius: 0.755, ionic_radius: 0.615 } } }, 4: { IV: { "": { crystal_radius: 0.55, ionic_radius: 0.41 } }, VI: { "": { crystal_radius: 0.69, ionic_radius: 0.55 } } }, 5: { IV: { "": { crystal_radius: 0.485, ionic_radius: 0.345 } }, VI: { "": { crystal_radius: 0.63, ionic_radius: 0.49 } }, VIII: { "": { crystal_radius: 0.71, ionic_radius: 0.57 } } }, 6: { IV: { "": { crystal_radius: 0.4, ionic_radius: 0.26 } }, VI: { "": { crystal_radius: 0.58, ionic_radius: 0.44 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "94 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.06, "Velocity of sound": "5940 m s<sup>-1</sup>", "Vickers hardness": "1060 MN m<sup>-2</sup>", X: 1.66, "Youngs modulus": "279 GPa", "NMR Quadrupole Moment": { "Cr-53": -150.5 }, "Metallic radius": 1.285, iupac_ordering: 58, "IUPAC ordering": 58, "Ground level": "7S3", "Ionization energies": [6.76651, 16.486305, 30.959, 49.16, 69.46, 90.6349, 160.29, 184.76, 209.5, 244.5, 270.8, 296.7, 354.7, 384.163, 1011.6, 1097.2, 1188, 1294.8, 1394.5, 1495.1, 1634.1, 1721.183, 7481.8628, 7894.7992], "Electron affinity": 0.6758412 }, Cs: { "Atomic mass": 132.9054519, "Atomic no": 55, "Atomic orbitals": { "1s": -1256.738791, "2p": -180.995344, "2s": -191.981873, "3d": -26.418398, "3p": -35.166423, "3s": -39.851584, "4d": -2.848386, "4p": -5.769326, "4s": -7.455966, "5p": -0.504903, "5s": -0.915819, "6s": -0.078699 }, "Atomic radius": 2.6, "Atomic radius calculated": 2.98, "Boiling point": "944 K", "Brinell hardness": "0.14 MN m<sup>-2</sup>", "Bulk modulus": "1.6 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1], "Critical temperature": "1938 K", "Density of solid": "1879 kg m<sup>-3</sup>", "Electrical resistivity": "21 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].6s<sup>1</sup>", "ICSD oxidation states": [1], "Ionic radii": { 1: 1.81 }, "Liquid range": "642.41 K", "Melting point": "301.59 K", "Mendeleev no": 8, "Mineral hardness": "0.2", "Molar volume": "70.94 cm<sup>3</sup>", Name: "Cesium", "Oxidation states": [1], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 1: { VI: { "": { crystal_radius: 1.81, ionic_radius: 1.67 } }, VIII: { "": { crystal_radius: 1.88, ionic_radius: 1.74 } }, IX: { "": { crystal_radius: 1.92, ionic_radius: 1.78 } }, X: { "": { crystal_radius: 1.95, ionic_radius: 1.81 } }, XI: { "": { crystal_radius: 1.99, ionic_radius: 1.85 } }, XII: { "": { crystal_radius: 2.02, ionic_radius: 1.88 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "36 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 3.43, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.79, "Youngs modulus": "1.7 GPa", "Metallic radius": 2.719, iupac_ordering: 7, "IUPAC ordering": 7, "Ground level": "2S1/2", "Ionization energies": [3.89390572743, 23.15745, 33.195, 43, 56, 69.1, 82.9, 110.1, 125.61, 213.3, 233, 261, 289, 316, 352, 382, 413, 445, 476, 597, 629, 666, 700, 753, 791, 875, 916.1, 1592, 1672, 1757, 1848, 1936, 2029, 2137, 2230, 2329, 2422, 2683, 2767, 2859, 2945, 3118, 3214, 3392, 3485, 7989, 8224, 8484, 8726, 9350, 9629, 9974, 10208.78, 41861.075, 42912.99], "Electron affinity": 0.47163025 }, Cu: { "Atomic mass": 63.546, "Atomic no": 29, "Atomic orbitals": { "1s": -320.78852, "2p": -33.481247, "2s": -38.14131, "3d": -0.202272, "3p": -2.609244, "3s": -4.057453, "4s": -0.172056 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.45, "Boiling point": "3200 K", "Brinell hardness": "874 MN m<sup>-2</sup>", "Bulk modulus": "140 GPa", "Coefficient of linear thermal expansion": "16.5 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "8920 kg m<sup>-3</sup>", "Electrical resistivity": "1.72 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>10</sup>.4s<sup>1</sup>", "ICSD oxidation states": [1, 2, 3], "Ionic radii": { 1: 0.91, 2: 0.87, 3: 0.68 }, "Liquid range": "1842.23 K", "Melting point": "1357.77 K", "Mendeleev no": 72, "Mineral hardness": "3.0", "Molar volume": "7.11 cm<sup>3</sup>", Name: "Copper", "Oxidation states": [1, 2, 3, 4], "Poissons ratio": "0.34", Reflectivity: "90 %", "Refractive index": "no data", "Rigidity modulus": "48 GPa", "Shannon radii": { 1: { II: { "": { crystal_radius: 0.6, ionic_radius: 0.46 } }, IV: { "": { crystal_radius: 0.74, ionic_radius: 0.6 } }, VI: { "": { crystal_radius: 0.91, ionic_radius: 0.77 } } }, 2: { IV: { "": { crystal_radius: 0.71, ionic_radius: 0.57 } }, IVSQ: { "": { crystal_radius: 0.71, ionic_radius: 0.57 } }, V: { "": { crystal_radius: 0.79, ionic_radius: 0.65 } }, VI: { "": { crystal_radius: 0.87, ionic_radius: 0.73 } } }, 3: { VI: { "Low Spin": { crystal_radius: 0.68, ionic_radius: 0.54 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "400 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.96, "Velocity of sound": "3570 m s<sup>-1</sup>", "Vickers hardness": "369 MN m<sup>-2</sup>", X: 1.9, "Youngs modulus": "130 GPa", "NMR Quadrupole Moment": { "Cu-63": -220.15, "Cu-65": -204.14 }, "Metallic radius": 1.278, iupac_ordering: 73, "IUPAC ordering": 73, "Ground level": "2S1/2", "Ionization energies": [7.72638, 20.29239, 36.841, 57.38, 79.8, 103, 139, 166, 198, 232.2, 265.33, 367, 401, 436, 483.1, 518.7, 552.8, 632.5, 670.608, 1690.5, 1800, 1918, 2044, 2179.4, 2307.3, 2479.1, 2586.954, 11062.4313, 11567.613], "Electron affinity": 1.235784 }, Dy: { "Atomic mass": 162.5, "Atomic no": 66, "Atomic orbitals": { "1s": -1843.229585, "2p": -281.558531, "2s": -295.342856, "3d": -47.4867, "3p": -59.091931, "3s": -65.299442, "4d": -5.686352, "4f": -0.265302, "4p": -10.094091, "4s": -12.551251, "5p": -0.90349, "5s": -1.547977, "6s": -0.132769 }, "Atomic radius": 1.75, "Atomic radius calculated": 2.28, "Boiling point": "2840 K", "Brinell hardness": "500 MN m<sup>-2</sup>", "Bulk modulus": "41 GPa", "Coefficient of linear thermal expansion": "9.9 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "8551 kg m<sup>-3</sup>", "Electrical resistivity": "92.6 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>10</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3], "Ionic radii": { 2: 1.21, 3: 1.052 }, "Liquid range": "1160 K", "Melting point": "1680 K", "Mendeleev no": 24, "Mineral hardness": "no data", "Molar volume": "19.01 cm<sup>3</sup>", Name: "Dysprosium", "Oxidation states": [2, 3], "Poissons ratio": "0.25", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "25 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.21, ionic_radius: 1.07 } }, VII: { "": { crystal_radius: 1.27, ionic_radius: 1.13 } }, VIII: { "": { crystal_radius: 1.33, ionic_radius: 1.19 } } }, 3: { VI: { "": { crystal_radius: 1.052, ionic_radius: 0.912 } }, VII: { "": { crystal_radius: 1.11, ionic_radius: 0.97 } }, VIII: { "": { crystal_radius: 1.167, ionic_radius: 1.027 } }, IX: { "": { crystal_radius: 1.223, ionic_radius: 1.083 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "11 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.31, "Velocity of sound": "2710 m s<sup>-1</sup>", "Vickers hardness": "540 MN m<sup>-2</sup>", X: 1.22, "Youngs modulus": "61 GPa", "Metallic radius": 1.773, iupac_ordering: 38, "IUPAC ordering": 38, "Ground level": "5I8", "Ionization energies": [5.93905, 11.647, 22.89, 41.23, 62.1, 93, 110, 127, 152, 170, 192, 224, 259, 279, 300, 332, 366, 399, 431, 464.9, 664, 702, 743, 786, 827, 872, 924, 969, 1014, 1059, 1232, 1275, 1325, 1371, 1468, 1520, 1638, 1691.7, 2882, 2987, 3098, 3217, 3331, 3445, 3607, 3725, 3852, 3970, 4303, 4407, 4523, 4629, 4945, 5066, 5296, 5412, 12081, 12370, 12690, 12986, 14144, 14495, 14936, 15228.06, 61736.56, 63073.5], "Electron affinity": 0.352 }, Er: { "Atomic mass": 167.259, "Atomic no": 68, "Atomic orbitals": { "1s": -1961.799176, "2p": -302.01827, "2s": -316.310631, "3d": -51.682149, "3p": -63.818655, "3s": -70.310142, "4d": -6.127443, "4f": -0.278577, "4p": -10.819574, "4s": -13.423547, "5p": -0.935202, "5s": -1.616073, "6s": -0.134905 }, "Atomic radius": 1.75, "Atomic radius calculated": 2.26, "Boiling point": "3141 K", "Brinell hardness": "814 MN m<sup>-2</sup>", "Bulk modulus": "44 GPa", "Coefficient of linear thermal expansion": "12.2 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "9066 kg m<sup>-3</sup>", "Electrical resistivity": "86.0 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>12</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3], "Ionic radii": { 3: 1.03 }, "Liquid range": "1371 K", "Melting point": "1802 K", "Mendeleev no": 22, "Mineral hardness": "no data", "Molar volume": "18.46 cm<sup>3</sup>", Name: "Erbium", "Oxidation states": [3], "Poissons ratio": "0.24", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "28 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.03, ionic_radius: 0.89 } }, VII: { "": { crystal_radius: 1.085, ionic_radius: 0.945 } }, VIII: { "": { crystal_radius: 1.144, ionic_radius: 1.004 } }, IX: { "": { crystal_radius: 1.202, ionic_radius: 1.062 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "15 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.29, "Velocity of sound": "2830 m s<sup>-1</sup>", "Vickers hardness": "589 MN m<sup>-2</sup>", X: 1.24, "Youngs modulus": "70 GPa", "Metallic radius": 1.756, iupac_ordering: 36, "IUPAC ordering": 36, "Ground level": "3H6", "Ionization energies": [6.1077, 11.916, 22.7, 42.42, 65.1, 96, 114, 131, 158, 177, 201, 235, 268, 290, 311, 345, 381, 415, 450, 486, 520, 555, 770, 810, 853, 899, 943, 989, 1046, 1092, 1142, 1188, 1370, 1416, 1468, 1516, 1625, 1678, 1803, 1858.5, 3157, 3265, 3381, 3505, 3624, 3742, 3916, 4038, 4170, 4294, 4639, 4748, 4866, 4978, 5329, 5455, 5695, 5815, 12918, 13217, 13548, 13855, 15146, 15511, 15971, 16274.56, 65848.24, 67241.9], "Electron affinity": 0.312 }, Es: { "Atomic mass": 252, "Atomic no": 99, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>11</sup>.7s<sup>2</sup>", "Liquid range": "no data K", "Melting point": "1133 K", "Mendeleev no": 38, "Mineral hardness": "no data", "Molar volume": "28.52 cm<sup>3</sup>", Name: "Einsteinium", "Oxidation states": [2, 3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.45, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": 1.86, iupac_ordering: 22, "IUPAC ordering": 22, "Ground level": "4I°15/2", "Ionization energies": [6.36758, 12.2, 22.7, 38.8, 54.1, 71, 97, 112.9, 137, 157, 180, 206, 231, 252, 270, 294, 317, 342, 367, 398, 421, 576, 606, 638, 672, 705, 738, 790, 824, 861, 895, 1060, 1100, 1140, 1180, 1310, 1360, 1480, 1530, 1690, 1780, 1870, 1950, 2040, 2130, 2220, 2300, 2410, 2490, 2580, 2680, 2760, 2850, 3294, 3370, 3449, 3535, 3616, 3694, 3866, 3947, 4038, 4120, 4456, 4537, 4620, 4700, 5260, 5350, 5600, 5690, 8960, 9140, 9330, 9530, 9720, 9910, 10400, 10590, 10810, 11010, 11570, 11740, 11930, 12110, 13810, 14030, 14460, 14700, 29700, 30100, 30700, 31100, 37400, 38100, 38900, 39451.4, 154328.1, 156926], "Electron affinity": -0.3 }, Eu: { "Atomic mass": 151.964, "Atomic no": 63, "Atomic orbitals": { "1s": -1672.309322, "2p": -252.176697, "2s": -265.199534, "3d": -41.465518, "3p": -52.281987, "3s": -58.068128, "4d": -5.03242, "4f": -0.232773, "4p": -9.025455, "4s": -11.267747, "5p": -0.853575, "5s": -1.444087, "6s": -0.129426 }, "Atomic radius": 1.85, "Atomic radius calculated": 2.31, "Boiling point": "1800 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "8.3 GPa", "Coefficient of linear thermal expansion": "35 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2, 3], "Critical temperature": "no data K", "Density of solid": "5244 kg m<sup>-3</sup>", "Electrical resistivity": "90 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>7</sup>.6s<sup>2</sup>", "ICSD oxidation states": [2, 3], "Ionic radii": { 2: 1.31, 3: 1.087 }, "Liquid range": "701 K", "Melting point": "1099 K", "Mendeleev no": 18, "Mineral hardness": "no data", "Molar volume": "28.97 cm<sup>3</sup>", Name: "Europium", "Oxidation states": [2, 3], "Poissons ratio": "0.15", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "7.9 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.31, ionic_radius: 1.17 } }, VII: { "": { crystal_radius: 1.34, ionic_radius: 1.2 } }, VIII: { "": { crystal_radius: 1.39, ionic_radius: 1.25 } }, IX: { "": { crystal_radius: 1.44, ionic_radius: 1.3 } }, X: { "": { crystal_radius: 1.49, ionic_radius: 1.35 } } }, 3: { VI: { "": { crystal_radius: 1.087, ionic_radius: 0.947 } }, VII: { "": { crystal_radius: 1.15, ionic_radius: 1.01 } }, VIII: { "": { crystal_radius: 1.206, ionic_radius: 1.066 } }, IX: { "": { crystal_radius: 1.26, ionic_radius: 1.12 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "14 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.35, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "167 MN m<sup>-2</sup>", X: 1.2, "Youngs modulus": "18 GPa", "Metallic radius": 2.041, iupac_ordering: 41, "IUPAC ordering": 41, "Ground level": "8S°7/2", "Ionization energies": [5.670385, 11.24, 24.84, 42.94, 63.2, 89, 105, 120, 144, 161, 183, 213, 243, 263, 281, 311, 344.4, 518, 553, 590, 630, 667, 709, 755, 795, 838, 879, 1037, 1078, 1124, 1167, 1249, 1296, 1406, 1456.06, 2495, 2591, 2697, 2807, 2914, 3022, 3168, 3279, 3398, 3510, 3823, 3921, 4031, 4131, 4400, 4513, 4729, 4838, 10880, 11153, 11457, 11739, 12718, 13050, 13462, 13738.58, 55865.92, 57120.64], "Electron affinity": 0.11613 }, F: { "Atomic mass": 18.9984032, "Atomic no": 9, "Atomic orbitals": { "1s": -24.189391, "2p": -0.415606, "2s": -1.086859 }, "Atomic radius": 0.5, "Atomic radius calculated": 0.42, "Boiling point": "85.03 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-1], "Critical temperature": "144 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[He].2s<sup>2</sup>.2p<sup>5</sup>", "ICSD oxidation states": [-1], "Ionic radii": { "-1": 1.19, 7: 0.22 }, "Liquid range": "31.5 K", "Melting point": "53.53 K", "Mendeleev no": 102, "Mineral hardness": "no data", "Molar volume": "11.20 cm<sup>3</sup>", Name: "Fluorine", "Oxidation states": [-1], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000195", "Rigidity modulus": "no data GPa", "Shannon radii": { "-1": { II: { "": { crystal_radius: 1.145, ionic_radius: 1.285 } }, III: { "": { crystal_radius: 1.16, ionic_radius: 1.3 } }, IV: { "": { crystal_radius: 1.17, ionic_radius: 1.31 } }, VI: { "": { crystal_radius: 1.19, ionic_radius: 1.33 } } }, 7: { VI: { "": { crystal_radius: 0.22, ionic_radius: 0.08 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.0277 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.47, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 3.98, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "F-19": -94.2 }, "Metallic radius": "no data", iupac_ordering: 102, "IUPAC ordering": 102, "Ground level": "2P°3/2", "Ionization energies": [17.42282, 34.97081, 62.70798, 87.175, 114.249, 157.16311, 185.1868, 953.89805, 1103.11748], "Electron affinity": 3.401189824 }, Fe: { "Atomic mass": 55.845, "Atomic no": 26, "Atomic orbitals": { "1s": -254.225505, "2p": -25.551766, "2s": -29.56486, "3d": -0.295049, "3p": -2.187523, "3s": -3.360621, "4s": -0.197978 }, "Atomic radius": 1.4, "Atomic radius calculated": 1.56, "Boiling point": "3134 K", "Brinell hardness": "490 MN m<sup>-2</sup>", "Bulk modulus": "170 GPa", "Coefficient of linear thermal expansion": "11.8 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2, 3], "Critical temperature": "no data K", "Density of solid": "7874 kg m<sup>-3</sup>", "Electrical resistivity": "10 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>6</sup>.4s<sup>2</sup>", "ICSD oxidation states": [2, 3], "Ionic radii": { 2: 0.92, 3: 0.785 }, "Ionic radii hs": { 2: 0.92, 3: 0.785 }, "Ionic radii ls": { 2: 0.75, 3: 0.69, 4: 0.725, 6: 0.39 }, "Liquid range": "1323 K", "Melting point": "1811 K", "Mendeleev no": 61, "Mineral hardness": "4.0", "Molar volume": "7.09 cm<sup>3</sup>", Name: "Iron", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.29", Reflectivity: "65 %", "Refractive index": "no data", "Rigidity modulus": "82 GPa", "Shannon radii": { 2: { IV: { "High Spin": { crystal_radius: 0.77, ionic_radius: 0.63 } }, IVSQ: { "High Spin": { crystal_radius: 0.78, ionic_radius: 0.64 } }, VI: { "Low Spin": { crystal_radius: 0.75, ionic_radius: 0.61 }, "High Spin": { crystal_radius: 0.92, ionic_radius: 0.78 } }, VIII: { "High Spin": { crystal_radius: 1.06, ionic_radius: 0.92 } } }, 3: { IV: { "High Spin": { crystal_radius: 0.63, ionic_radius: 0.49 } }, V: { "": { crystal_radius: 0.72, ionic_radius: 0.58 } }, VI: { "Low Spin": { crystal_radius: 0.69, ionic_radius: 0.55 }, "High Spin": { crystal_radius: 0.785, ionic_radius: 0.645 } }, VIII: { "High Spin": { crystal_radius: 0.92, ionic_radius: 0.78 } } }, 4: { VI: { "": { crystal_radius: 0.725, ionic_radius: 0.585 } } }, 6: { IV: { "": { crystal_radius: 0.39, ionic_radius: 0.25 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "80 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.04, "Velocity of sound": "4910 m s<sup>-1</sup>", "Vickers hardness": "608 MN m<sup>-2</sup>", X: 1.83, "Youngs modulus": "211 GPa", "NMR Quadrupole Moment": { "Fe-57": 160 }, "Metallic radius": 1.277, iupac_ordering: 64, "IUPAC ordering": 64, "Ground level": "5D4", "Ionization energies": [7.9024681, 16.19921, 30.651, 54.91, 75, 98.985, 124.976, 151.06, 233.6, 262.1, 290.9, 330.8, 361, 392.2, 456.2, 489.312, 1262.7, 1357.8, 1460, 1575.6, 1687, 1798.4, 1950.4, 2045.759, 8828.1879, 9277.6818], "Electron affinity": 0.15323634 }, Fm: { "Atomic mass": 257, "Atomic no": 100, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>12</sup>.7s<sup>2</sup>", "Liquid range": "no data K", "Melting point": "about 1800 K", "Mendeleev no": 37, "Mineral hardness": "no data", "Molar volume": "no data cm<sup>3</sup>", Name: "Fermium", "Oxidation states": [2, 3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.45, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 21, "IUPAC ordering": 21, "Ground level": "3H6", "Ionization energies": [6.5, 12.4, 23.2, 39.3, 55, 74, 93, 120, 136, 162, 185, 209, 237, 257, 276, 300, 326, 351, 377, 402, 430, 453, 616, 647, 680, 716, 749, 782, 837, 871, 909, 944, 1110, 1150, 1190, 1230, 1370, 1420, 1550, 1600, 1770, 1850, 1940, 2030, 2120, 2210, 2300, 2390, 2490, 2590, 2680, 2760, 2850, 2950, 3403, 3480, 3561, 3647, 3730, 3810, 3986, 4070, 4160, 4245, 4586, 4670, 4760, 4840, 5420, 5510, 5760, 5860, 9200, 9370, 9570, 9770, 9970, 10160, 10660, 10860, 11080, 11280, 11850, 12020, 12220, 12390, 14180, 14400, 14800, 15e3, 30300, 30800, 31300, 31800, 38400, 39100, 4e4, 40482.2, 158152.5, 160804], "Electron affinity": 0.35 }, Fr: { "Atomic mass": 223, "Atomic no": 87, "Atomic orbitals": { "1s": -3283.263399, "2p": -542.41424, "2s": -561.73045, "3d": -111.085223, "3p": -128.607136, "3s": -137.959632, "4d": -20.812462, "4f": -10.050648, "4p": -28.648131, "4s": -32.861013, "5d": -2.360991, "5p": -4.97328, "5s": -6.509516, "6p": -0.466197, "6s": -0.841848, "7s": -0.076176 }, "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1], "Critical temperature": "no data K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].7s<sup>1</sup>", "Ionic radii": { 1: 1.94 }, "Liquid range": "no data K", "Melting point": "maybe about 300 K", "Mendeleev no": 7, "Mineral hardness": "no data", "Molar volume": "no data cm<sup>3</sup>", Name: "Francium", "Oxidation states": [1], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 1: { VI: { "": { crystal_radius: 1.94, ionic_radius: 1.8 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 3.48, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.7, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 6, "IUPAC ordering": 6, "Ground level": "2S1/2", "Ionization energies": [4.0727411, 22.4, 33.5, 39.1, 50, 67, 80, 106, 120, 179, 200, 222.1, 245, 269, 293, 324, 349, 375, 400, 530, 560, 590, 620, 690, 720, 810, 850, 910, 980, 1040, 1110, 1180, 1250, 1320, 1380, 1460, 1530, 1600, 1670, 1740, 1810, 2119, 2182, 2247, 2317, 2384, 2450, 2564, 2631, 2706, 2774, 3049, 3115, 3190, 3257, 3556, 3635, 3828, 3907, 6365, 6516, 6678, 6849, 7013, 7172, 7500, 7670, 7850, 8020, 8500, 8640, 8800, 8950, 9890, 10070, 10420, 10590, 22330, 22730, 23170, 23570, 27060, 27590, 28260, 28683.4, 113817.2, 115859], "Electron affinity": 0.486 }, Ga: { "Atomic mass": 69.723, "Atomic no": 31, "Atomic orbitals": { "1s": -370.170639, "2p": -40.093339, "2s": -45.200869, "3d": -0.736204, "3p": -3.584666, "3s": -5.241645, "4p": -0.101634, "4s": -0.328019 }, "Atomic radius": 1.3, "Atomic radius calculated": 1.36, "Boiling point": "2477 K", "Brinell hardness": "60 MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "120 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "5904 kg m<sup>-3</sup>", "Electrical resistivity": "about  14 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>10</sup>.4s<sup>2</sup>.4p<sup>1</sup>", "ICSD oxidation states": [2, 3], "Ionic radii": { 3: 0.76 }, "Liquid range": "2174.09 K", "Melting point": "302.91 K", "Mendeleev no": 81, "Mineral hardness": "1.5", "Molar volume": "11.80 cm<sup>3</sup>", Name: "Gallium", "Oxidation states": [1, 2, 3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { IV: { "": { crystal_radius: 0.61, ionic_radius: 0.47 } }, V: { "": { crystal_radius: 0.69, ionic_radius: 0.55 } }, VI: { "": { crystal_radius: 0.76, ionic_radius: 0.62 } } } }, "Superconduction temperature": "1.083 K", "Thermal conductivity": "29 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.87, "Velocity of sound": "2740 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.81, "Youngs modulus": "no data GPa", "Metallic radius": 1.35, iupac_ordering: 79, "IUPAC ordering": 79, "Ground level": "2P°1/2", "Ionization energies": [5.999302, 20.51514, 30.72576, 63.241, 86.01, 112.7, 140.8, 169.9, 211, 244, 280, 319, 356, 471.2, 508.8, 548.3, 599.8, 640, 677, 765.7, 807.308, 2010, 2129, 2258, 2391, 2543.9, 2683, 2868, 2984.426, 12696.5575, 13239.489], "Electron affinity": 0.3012011 }, Gd: { "Atomic mass": 157.25, "Atomic no": 64, "Atomic orbitals": { "1s": -1728.625195, "2p": -262.081616, "2s": -275.36313, "3d": -43.754556, "3p": -54.836922, "3s": -60.764408, "4d": -5.531835, "4f": -0.489012, "4p": -9.669866, "4s": -11.986486, "5d": -0.12722, "5p": -0.978749, "5s": -1.608477, "6s": -0.143627 }, "Atomic radius": 1.8, "Atomic radius calculated": 2.33, "Boiling point": "3523 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "38 GPa", "Coefficient of linear thermal expansion": "9.4 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "7901 kg m<sup>-3</sup>", "Electrical resistivity": "131 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>7</sup>.5d<sup>1</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3], "Ionic radii": { 3: 1.075 }, "Liquid range": "1938 K", "Melting point": "1585 K", "Mendeleev no": 27, "Mineral hardness": "no data", "Molar volume": "19.90 cm<sup>3</sup>", Name: "Gadolinium", "Oxidation states": [1, 2, 3], "Poissons ratio": "0.26", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "22 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.078, ionic_radius: 0.938 } }, VII: { "": { crystal_radius: 1.14, ionic_radius: 1 } }, VIII: { "": { crystal_radius: 1.193, ionic_radius: 1.053 } }, IX: { "": { crystal_radius: 1.247, ionic_radius: 1.107 } } } }, "Superconduction temperature": "1.083 K", "Thermal conductivity": "11 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.34, "Velocity of sound": "2680 m s<sup>-1</sup>", "Vickers hardness": "570 MN m<sup>-2</sup>", X: 1.2, "Youngs modulus": "55 GPa", "Metallic radius": 1.802, iupac_ordering: 40, "IUPAC ordering": 40, "Ground level": "9D°2", "Ionization energies": [6.1498, 12.076, 20.54, 44.44, 64.8, 89, 106, 123, 144, 165, 183, 213, 246, 268, 288, 319, 352, 384.4, 565, 601, 639, 680, 719, 761, 810, 851, 895, 937, 1100, 1142, 1189, 1233, 1321, 1368, 1481, 1532.3, 2621, 2720, 2827, 2941, 3050, 3160, 3312, 3424, 3546, 3660, 3980, 4080, 4191, 4294, 4578, 4693, 4914, 5025, 11273, 11552, 11861, 12147, 13183, 13521, 13943, 14224.57, 57783.9, 59065.53], "Electron affinity": 0.137 }, Ge: { "Atomic mass": 72.64, "Atomic no": 32, "Atomic orbitals": { "1s": -396.292991, "2p": -43.720129, "2s": -49.055282, "3d": -1.117316, "3p": -4.194822, "3s": -5.961472, "4p": -0.149882, "4s": -0.426523 }, "Atomic radius": 1.25, "Atomic radius calculated": 1.25, "Boiling point": "3093 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "6 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-4, 2, 4], "Critical temperature": "no data K", "Density of solid": "5323 kg m<sup>-3</sup>", "Electrical resistivity": "about 50000 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>10</sup>.4s<sup>2</sup>.4p<sup>2</sup>", "ICSD oxidation states": [2, 3, 4], "Ionic radii": { 2: 0.87, 4: 0.67 }, "Liquid range": "1881.6 K", "Melting point": "1211.4 K", "Mendeleev no": 84, "Mineral hardness": "6.0", "Molar volume": "13.63 cm<sup>3</sup>", Name: "Germanium", "Oxidation states": [-4, 1, 2, 3, 4], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 0.87, ionic_radius: 0.73 } } }, 4: { IV: { "": { crystal_radius: 0.53, ionic_radius: 0.39 } }, VI: { "": { crystal_radius: 0.67, ionic_radius: 0.53 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "60 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.11, "Velocity of sound": "5400 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.01, "Youngs modulus": "no data GPa", "Metallic radius": 1.39, iupac_ordering: 84, "IUPAC ordering": 84, "Ground level": "3P0", "Ionization energies": [7.899435, 15.93461, 34.0576, 45.7155, 90.5, 115.9, 144.9, 176.4, 212.5, 252.1, 286, 326, 367, 407, 527.9, 567.3, 609.1, 662.8, 706.7, 744, 837.1, 880.44, 2180.1, 2304, 2439, 2575, 2737.1, 2881.9, 3074, 3194.293, 13557.4208, 14119.43], "Electron affinity": 1.232676413 }, H: { "Atomic mass": 1.00794, "Atomic no": 1, "Atomic orbitals": { "1s": -0.233471 }, "Atomic radius": 0.25, "Atomic radius calculated": 0.53, "Boiling point": "20.28 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-1, 1], "Critical temperature": "33 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "1s<sup>1</sup>", "ICSD oxidation states": [1, -1], "Liquid range": "6.27 K", "Melting point": "14.01 K", "Mendeleev no": 103, "Mineral hardness": "no data", "Molar volume": "11.42 cm<sup>3</sup>", Name: "Hydrogen", "Oxidation states": [-1, 1], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000132 (gas; liquid 1.12)(no units)", "Rigidity modulus": "no data GPa", "Shannon radii": { 1: { I: { "": { crystal_radius: -0.24, ionic_radius: -0.38 } }, II: { "": { crystal_radius: -0.04, ionic_radius: -0.18 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.1805 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.1, "Velocity of sound": "1270 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.2, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "H-2": 2.86 }, "Metallic radius": "no data", iupac_ordering: 92, "IUPAC ordering": 92, "Ground level": "2S1/2", "Ionization energies": [13.598434599702], "Electron affinity": 0.754598 }, He: { "Atomic mass": 4.002602, "Atomic no": 2, "Atomic orbitals": { "1s": -0.570425 }, "Atomic radius": "no data", "Atomic radius calculated": 0.31, "Boiling point": "4.22 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Critical temperature": "5.19 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "1s<sup>2</sup>", "Liquid range": "3.27 K", "Max oxidation state": 0, "Melting point": "0.95 K", "Mendeleev no": 1, "Min oxidation state": 0, "Mineral hardness": "no data", "Molar volume": "21.0 cm<sup>3</sup>", Name: "Helium", "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000035 (gas; liquid 1.028)(no units)", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "0.1513 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.4, "Velocity of sound": "970 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 5, "IUPAC ordering": 5, "Ground level": "1S0", "Ionization energies": [24.587389011, 54.417765486], "Electron affinity": -0.52 }, Hf: { "Atomic mass": 178.49, "Atomic no": 72, "Atomic orbitals": { "1s": -2210.65199, "2p": -345.687023, "2s": -361.006527, "3d": -61.231443, "3p": -74.452656, "3s": -81.522812, "4d": -7.676638, "4f": -0.871574, "4p": -12.971211, "4s": -15.883625, "5d": -0.143805, "5p": -1.246441, "5s": -2.049828, "6s": -0.166465 }, "Atomic radius": 1.55, "Atomic radius calculated": 2.08, "Boiling point": "4876 K", "Brinell hardness": "1700 MN m<sup>-2</sup>", "Bulk modulus": "110 GPa", "Coefficient of linear thermal expansion": "5.9 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "13310 kg m<sup>-3</sup>", "Electrical resistivity": "34 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>2</sup>.6s<sup>2</sup>", "ICSD oxidation states": [4], "Ionic radii": { 4: 0.85 }, "Liquid range": "2370 K", "Melting point": "2506 K", "Mendeleev no": 50, "Mineral hardness": "5.5", "Molar volume": "13.44 cm<sup>3</sup>", Name: "Hafnium", "Oxidation states": [2, 3, 4], "Poissons ratio": "0.37", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "30 GPa", "Shannon radii": { 4: { IV: { "": { crystal_radius: 0.72, ionic_radius: 0.58 } }, VI: { "": { crystal_radius: 0.85, ionic_radius: 0.71 } }, VII: { "": { crystal_radius: 0.9, ionic_radius: 0.76 } }, VIII: { "": { crystal_radius: 0.97, ionic_radius: 0.83 } } } }, "Superconduction temperature": "0.128 K", "Thermal conductivity": "23 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.23, "Velocity of sound": "3010 m s<sup>-1</sup>", "Vickers hardness": "1760 MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "78 GPa", "Metallic radius": 1.58, iupac_ordering: 50, "IUPAC ordering": 50, "Ground level": "3F2", "Ionization energies": [6.82507, 14.61, 22.55, 33.37, 68.37, 98, 118, 137, 157, 187, 209, 230, 270, 310, 334, 359, 399, 440, 481, 520, 570, 610, 650, 690, 730, 772, 1002, 1047, 1094, 1146, 1195, 1245, 1311, 1362, 1417, 1467, 1669, 1719, 1776, 1827, 1963, 2022, 2159, 2218.9, 3741, 3858, 3984, 4118, 4246, 4372, 4573, 4703, 4846, 4980, 5350, 5468, 5595, 5713, 6149, 6284, 6545, 6674, 14678, 14999, 15351, 15680, 17280, 17680, 18180, 18502.32, 74565.93, 76077.8], "Electron affinity": 0.17807 }, Hg: { "Atomic mass": 200.59, "Atomic no": 80, "Atomic orbitals": { "1s": -2755.022637, "2p": -443.848676, "2s": -461.27864, "3d": -84.845492, "3p": -100.328031, "3s": -108.597921, "4d": -13.019221, "4f": -4.110291, "4p": -19.636187, "4s": -23.222921, "5d": -0.452552, "5p": -2.261975, "5s": -3.423486, "6s": -0.205137 }, "Atomic radius": 1.5, "Atomic radius calculated": 1.71, "Boiling point": "629.88 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "25 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1, 2], "Critical temperature": "1750 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "96 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>10</sup>.6s<sup>2</sup>", "ICSD oxidation states": [1, 2], "Ionic radii": { 1: 1.33, 2: 1.16 }, "Liquid range": "395.56 K", "Melting point": "234.32 K", "Mendeleev no": 74, "Mineral hardness": "1.5", "Molar volume": "14.09 cm<sup>3</sup>", Name: "Mercury", "Oxidation states": [1, 2, 4], "Poissons ratio": "no data", Reflectivity: "73 %", "Refractive index": "1.000933", "Rigidity modulus": "no data GPa", "Shannon radii": { 1: { III: { "": { crystal_radius: 1.11, ionic_radius: 0.97 } }, VI: { "": { crystal_radius: 1.33, ionic_radius: 1.19 } } }, 2: { II: { "": { crystal_radius: 0.83, ionic_radius: 0.69 } }, IV: { "": { crystal_radius: 1.1, ionic_radius: 0.96 } }, VI: { "": { crystal_radius: 1.16, ionic_radius: 1.02 } }, VIII: { "": { crystal_radius: 1.28, ionic_radius: 1.14 } } } }, "Superconduction temperature": "3.95 K", "Thermal conductivity": "8.3 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.23, "Velocity of sound": "1407 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "Hg-201": 387.6 }, "Metallic radius": 1.51, iupac_ordering: 74, "IUPAC ordering": 74, "Ground level": "1S0", "Ionization energies": [10.437504, 18.75688, 34.49, 48.55, 61.2, 76.6, 93, 113.9, 134, 153, 173, 192.7, 276.9, 307, 332, 357, 402, 429, 477, 530, 560, 590, 650, 710, 760, 820, 880, 930, 990, 1050, 1110, 1160, 1220, 1280, 1549, 1603, 1661, 1723, 1780, 1839, 1928, 1989, 2052, 2113, 2354, 2412, 2478, 2539, 2745, 2815, 2981, 3049.9, 5055, 5191, 5335, 5490, 5636, 5780, 6041, 6192, 6356, 6508, 6933, 7066, 7211, 7350, 8010, 8160, 8470, 8620, 18550, 18910, 19310, 19680, 22120, 22580, 23170, 23544.1, 94124.7, 95897.7], "Electron affinity": -0.52 }, Ho: { "Atomic mass": 164.93032, "Atomic no": 67, "Atomic orbitals": { "1s": -1902.051908, "2p": -291.700994, "2s": -305.739294, "3d": -49.565996, "3p": -61.436304, "3s": -67.785492, "4d": -5.906195, "4f": -0.272677, "4p": -10.455303, "4s": -12.985498, "5p": -0.919463, "5s": -1.582088, "6s": -0.133845 }, "Atomic radius": 1.75, "Atomic radius calculated": "no data", "Boiling point": "2993 K", "Brinell hardness": "746 MN m<sup>-2</sup>", "Bulk modulus": "40 GPa", "Coefficient of linear thermal expansion": "11.2 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "8795 kg m<sup>-3</sup>", "Electrical resistivity": "81.4 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>11</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3], "Ionic radii": { 3: 1.041 }, "Liquid range": "1259 K", "Melting point": "1734 K", "Mendeleev no": 23, "Mineral hardness": "no data", "Molar volume": "18.74 cm<sup>3</sup>", Name: "Holmium", "Oxidation states": [3], "Poissons ratio": "0.23", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "26 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.041, ionic_radius: 0.901 } }, VIII: { "": { crystal_radius: 1.155, ionic_radius: 1.015 } }, IX: { "": { crystal_radius: 1.212, ionic_radius: 1.072 } }, X: { "": { crystal_radius: 1.26, ionic_radius: 1.12 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "16 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.3, "Velocity of sound": "2760 m s<sup>-1</sup>", "Vickers hardness": "481 MN m<sup>-2</sup>", X: 1.23, "Youngs modulus": "65 GPa", "Metallic radius": 1.765, iupac_ordering: 37, "IUPAC ordering": 37, "Ground level": "4I°15/2", "Ionization energies": [6.0215, 11.781, 22.79, 42.52, 63.9, 95, 112, 129, 155, 173, 197, 229, 263, 284, 305, 340, 373, 408, 441, 475, 510, 715, 755, 797, 842, 885, 929, 985, 1029, 1077, 1122, 1300, 1346, 1395, 1443, 1545, 1598, 1719, 1773.6, 3018, 3125, 3238, 3359, 3476, 3592, 3760, 3880, 4009, 4131, 4469, 4576, 4693, 4802, 5135, 5258, 5494, 5611, 12495, 12790, 13116, 13417, 14639, 14998, 15448, 15745.77, 63772.43, 65136.8], "Electron affinity": 0.338 }, I: { "Atomic mass": 126.90447, "Atomic no": 53, "Atomic orbitals": { "1s": -1161.787047, "2p": -164.603788, "2s": -175.073804, "3d": -22.600693, "3p": -30.831092, "3s": -35.243351, "4d": -1.938179, "4p": -4.572522, "4s": -6.115811, "5p": -0.267904, "5s": -0.596339 }, "Atomic radius": 1.4, "Atomic radius calculated": 1.15, "Boiling point": "457.4 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "7.7 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-1, 1, 3, 5, 7], "Critical temperature": "819 K", "Density of solid": "4940 kg m<sup>-3</sup>", "Electrical resistivity": "&gt; 10<sup>15</sup>10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>.5s<sup>2</sup>.5p<sup>5</sup>", "ICSD oxidation states": [5, -1], "Ionic radii": { "-1": 2.06, 5: 1.09, 7: 0.67 }, "Liquid range": "70.55 K", "Melting point": "386.85 K", "Mendeleev no": 97, "Mineral hardness": "no data", "Molar volume": "25.72 cm<sup>3</sup>", Name: "Iodine", "Oxidation states": [-1, 1, 3, 5, 7], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { "-1": { VI: { "": { crystal_radius: 2.06, ionic_radius: 2.2 } } }, 5: { IIIPY: { "": { crystal_radius: 0.58, ionic_radius: 0.44 } }, VI: { "": { crystal_radius: 1.09, ionic_radius: 0.95 } } }, 7: { IV: { "": { crystal_radius: 0.56, ionic_radius: 0.42 } }, VI: { "": { crystal_radius: 0.67, ionic_radius: 0.53 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.449 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.98, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.66, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "I-127": -696.12, "I-129": -604.1 }, "Metallic radius": "no data", iupac_ordering: 99, "IUPAC ordering": 99, "Ground level": "2P°3/2", "Ionization energies": [10.45126, 19.13126, 29.57, 40.357, 51.52, 74.4, 87.61, 150.81, 171, 197, 220.9, 247, 279, 307, 335, 365, 393, 505, 535, 569, 601, 649, 683, 762, 800.8, 1397, 1472, 1553, 1639, 1720, 1812, 1911, 1999, 2093, 2181, 2431, 2510, 2598, 2680, 2836, 2926, 3096, 3185.5, 7337, 7563, 7811, 8044, 8601, 8867, 9196, 9421.1, 38716.996, 39721.41], "Electron affinity": 3.05905238 }, In: { "Atomic mass": 114.818, "Atomic no": 49, "Atomic orbitals": { "1s": -983.647445, "2p": -134.628845, "2s": -144.078357, "3d": -16.139823, "3p": -23.345778, "3s": -27.2206, "4d": -0.730481, "4p": -2.795832, "4s": -4.062639, "5p": -0.101782, "5s": -0.290497 }, "Atomic radius": 1.55, "Atomic radius calculated": 1.56, "Boiling point": "2345 K", "Brinell hardness": "8.83 MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "32.1 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "7310 kg m<sup>-3</sup>", "Electrical resistivity": "8 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>.5s<sup>2</sup>.5p<sup>1</sup>", "ICSD oxidation states": [1, 2, 3], "Ionic radii": { 3: 0.94 }, "Liquid range": "1915.25 K", "Melting point": "429.75 K", "Mendeleev no": 79, "Mineral hardness": "1.2", "Molar volume": "15.76 cm<sup>3</sup>", Name: "Indium", "Oxidation states": [1, 2, 3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { IV: { "": { crystal_radius: 0.76, ionic_radius: 0.62 } }, VI: { "": { crystal_radius: 0.94, ionic_radius: 0.8 } }, VIII: { "": { crystal_radius: 1.06, ionic_radius: 0.92 } } } }, "Superconduction temperature": "3.41 K", "Thermal conductivity": "82 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.93, "Velocity of sound": "1215 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.78, "Youngs modulus": "11 GPa", "NMR Quadrupole Moment": { "In-113": 759.8, "In-115": 770.8 }, "Metallic radius": 1.67, iupac_ordering: 78, "IUPAC ordering": 78, "Ground level": "2P°1/2", "Ionization energies": [5.7863557, 18.87041, 28.04415, 55.45, 69.3, 90, 109, 130.1, 156, 178, 201, 226, 249, 341, 368, 396, 425, 462, 497.1, 560, 593.38, 1043, 1109, 1181, 1255, 1328, 1413, 1496, 1575, 1659, 1738, 1961, 2028.5, 2111, 2207, 2317, 2373, 2555, 2628.77, 6126, 6331, 6554, 6770, 7196, 7442, 7754, 7953.14, 32837.592, 33750.31], "Electron affinity": 0.383926 }, Ir: { "Atomic mass": 192.217, "Atomic no": 77, "Atomic orbitals": { "1s": -2543.761342, "2p": -405.526834, "2s": -422.159424, "3d": -75.485027, "3p": -90.108427, "3s": -97.923081, "4d": -10.856593, "4f": -2.738339, "4p": -16.966578, "4s": -20.29429, "5d": -0.335189, "5p": -1.883349, "5s": -2.909174, "6s": -0.195511 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.8, "Boiling point": "4701 K", "Brinell hardness": "1670 MN m<sup>-2</sup>", "Bulk modulus": "320 GPa", "Coefficient of linear thermal expansion": "6.4 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3, 4], "Critical temperature": "no data K", "Density of solid": "22650 kg m<sup>-3</sup>", "Electrical resistivity": "4.7 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>7</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3, 4, 5], "Ionic radii": { 3: 0.82, 4: 0.765, 5: 0.71 }, "Liquid range": "1962 K", "Melting point": "2739 K", "Mendeleev no": 66, "Mineral hardness": "6.5", "Molar volume": "8.52 cm<sup>3</sup>", Name: "Iridium", "Oxidation states": [-3, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.26", Reflectivity: "78 %", "Refractive index": "no data", "Rigidity modulus": "210 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.82, ionic_radius: 0.68 } } }, 4: { VI: { "": { crystal_radius: 0.765, ionic_radius: 0.625 } } }, 5: { VI: { "": { crystal_radius: 0.71, ionic_radius: 0.57 } } } }, "Superconduction temperature": "0.11 K", "Thermal conductivity": "150 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.13, "Velocity of sound": "4825 m s<sup>-1</sup>", "Vickers hardness": "1760 MN m<sup>-2</sup>", X: 2.2, "Youngs modulus": "528 GPa", "Metallic radius": 1.357, iupac_ordering: 65, "IUPAC ordering": 65, "Ground level": "4F9/2", "Ionization energies": [8.96702, 17, 28, 40, 57, 72, 89, 105, 122.7, 194.8, 217, 240, 264, 303, 329, 356, 407, 445, 472, 510, 560, 610, 670, 720, 770, 820, 870, 920, 980, 1030, 1080, 1331, 1381, 1436, 1493, 1548, 1603, 1684, 1739, 1801, 1857, 2083, 2139, 2201, 2258, 2435, 2500, 2656, 2720.4, 4540, 4668, 4806, 4952, 5092, 5229, 5466, 5609, 5765, 5910, 6315, 6441, 6580, 6708, 7274, 7421, 7710, 7850, 17040, 17390, 17770, 18120, 20210, 20650, 21200, 21556.6, 86438.9, 88113.3], "Electron affinity": 1.5643615 }, K: { "Atomic mass": 39.0983, "Atomic no": 19, "Atomic orbitals": { "1s": -128.414957, "2p": -10.283851, "2s": -12.839001, "3p": -0.693776, "3s": -1.281897, "4s": -0.088815 }, "Atomic radius": 2.2, "Atomic radius calculated": 2.43, "Boiling point": "1032 K", "Brinell hardness": "0.363 MN m<sup>-2</sup>", "Bulk modulus": "3.1 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1], "Critical temperature": "2223 K", "Density of solid": "856 kg m<sup>-3</sup>", "Electrical resistivity": "7.5 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].4s<sup>1</sup>", "ICSD oxidation states": [1], "Ionic radii": { 1: 1.52 }, "Liquid range": "695.47 K", "Melting point": "336.53 K", "Mendeleev no": 10, "Mineral hardness": "0.4", "Molar volume": "45.94 cm<sup>3</sup>", Name: "Potassium", "Oxidation states": [-1, 1], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "1.3 GPa", "Shannon radii": { 1: { IV: { "": { crystal_radius: 1.51, ionic_radius: 1.37 } }, VI: { "": { crystal_radius: 1.52, ionic_radius: 1.38 } }, VII: { "": { crystal_radius: 1.6, ionic_radius: 1.46 } }, VIII: { "": { crystal_radius: 1.65, ionic_radius: 1.51 } }, IX: { "": { crystal_radius: 1.69, ionic_radius: 1.55 } }, X: { "": { crystal_radius: 1.73, ionic_radius: 1.59 } }, XII: { "": { crystal_radius: 1.78, ionic_radius: 1.64 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "100 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.75, "Velocity of sound": "2000 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.82, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "K-39": 58.5, "K-40": -73, "K-41": 71.1 }, "Metallic radius": 2.381, iupac_ordering: 9, "IUPAC ordering": 9, "Ground level": "2S1/2", "Ionization energies": [4.34066373, 31.625, 45.8031, 60.917, 82.66, 99.44, 117.56, 154.87, 175.8174, 503.67, 565.6, 631.1, 714.7, 786.3, 860.92, 967.7, 1034.542, 4610.87018, 4934.0484], "Electron affinity": 0.50145913 }, Kr: { "Atomic mass": 83.798, "Atomic no": 36, "Atomic orbitals": { "1s": -509.982989, "2p": -60.017328, "2s": -66.285953, "3d": -3.074109, "3p": -7.086634, "3s": -9.315192, "4p": -0.34634, "4s": -0.820574 }, "Atomic radius": "no data", "Atomic radius calculated": 0.88, "Boiling point": "119.93 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Critical temperature": "209.4 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>10</sup>.4s<sup>2</sup>.4p<sup>6</sup>", "Liquid range": "4.14 K", "Max oxidation state": 0, "Melting point": "115.79 K", "Mendeleev no": 4, "Min oxidation state": 0, "Mineral hardness": "no data", "Molar volume": "27.99 cm<sup>3</sup>", Name: "Krypton", "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000427", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "0.00943 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.02, "Velocity of sound": "1120 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 3, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 2, "IUPAC ordering": 2, "Ground level": "1S0", "Ionization energies": [13.9996055, 24.35984, 35.838, 50.85, 64.69, 78.49, 109.13, 125.802, 233, 268, 308, 350, 391, 446, 492, 540, 591, 640, 785, 831.6, 882.8, 945, 999, 1042, 1155, 1205.23, 2928.9, 3072, 3228, 3380, 3584, 3752, 3971, 4109.083, 17296.421, 17936.209], "Electron affinity": -1.02 }, La: { "Atomic mass": 138.90547, "Atomic no": 57, "Atomic orbitals": { "1s": -1355.622446, "2p": -198.325243, "2s": -209.831151, "3d": -30.626696, "3p": -39.895838, "3s": -44.856283, "4d": -3.95801, "4p": -7.167724, "4s": -9.000543, "5d": -0.141085, "5p": -0.824498, "5s": -1.324936, "6s": -0.132233 }, "Atomic radius": 1.95, "Atomic radius calculated": "no data", "Boiling point": "3743 K", "Brinell hardness": "363 MN m<sup>-2</sup>", "Bulk modulus": "28 GPa", "Coefficient of linear thermal expansion": "12.1 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "6146 kg m<sup>-3</sup>", "Electrical resistivity": "61.5 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].5d<sup>1</sup>.6s<sup>2</sup>", "ICSD oxidation states": [2, 3], "Ionic radii": { 3: 1.172 }, "Liquid range": "2550 K", "Melting point": "1193 K", "Mendeleev no": 33, "Mineral hardness": "2.5", "Molar volume": "22.39 cm<sup>3</sup>", Name: "Lanthanum", "Oxidation states": [2, 3], "Poissons ratio": "0.28", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "14 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.172, ionic_radius: 1.032 } }, VII: { "": { crystal_radius: 1.24, ionic_radius: 1.1 } }, VIII: { "": { crystal_radius: 1.3, ionic_radius: 1.16 } }, IX: { "": { crystal_radius: 1.356, ionic_radius: 1.216 } }, X: { "": { crystal_radius: 1.41, ionic_radius: 1.27 } }, XII: { "": { crystal_radius: 1.5, ionic_radius: 1.36 } } } }, "Superconduction temperature": "6.00 K", "Thermal conductivity": "13 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.43, "Velocity of sound": "2475 m s<sup>-1</sup>", "Vickers hardness": "491 MN m<sup>-2</sup>", X: 1.1, "Youngs modulus": "37 GPa", "NMR Quadrupole Moment": { "La-139": 200.6 }, "Metallic radius": 1.877, iupac_ordering: 47, "IUPAC ordering": 47, "Ground level": "2D3/2", "Ionization energies": [5.5769, 11.18496, 19.1773, 49.95, 61.6, 74, 88, 105, 119, 151.4, 168.77, 275, 303, 332, 364, 393, 431, 464, 498, 533, 566, 696, 731, 770, 806, 865, 906, 995, 1039.09, 1800, 1884, 1974, 2069, 2162, 2259, 2377, 2473, 2577, 2674, 2950, 3036, 3133, 3222, 3416, 3515, 3704, 3800, 8669, 8914, 9184, 9437, 10136, 10426, 10789, 11033.4, 45144.996, 46245.6], "Electron affinity": 0.5575462 }, Li: { "Atomic mass": 6.941, "Atomic no": 3, "Atomic orbitals": { "1s": -1.878564, "2s": -0.10554 }, "Atomic radius": 1.45, "Atomic radius calculated": 1.67, "Boiling point": "1615 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "11 GPa", "Coefficient of linear thermal expansion": "46 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1], "Critical temperature": "3223 K", "Density of solid": "535 kg m<sup>-3</sup>", "Electrical resistivity": "9.5 10<sup>-8</sup> &Omega; m", "Electronic structure": "[He].2s<sup>1</sup>", "ICSD oxidation states": [1], "Ionic radii": { 1: 0.9 }, "Liquid range": "1161.31 K", "Melting point": "453.69 K", "Mendeleev no": 12, "Mineral hardness": "0.6", "Molar volume": "13.02 cm<sup>3</sup>", Name: "Lithium", "Oxidation states": [1], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "4.2 GPa", "Shannon radii": { 1: { IV: { "": { crystal_radius: 0.73, ionic_radius: 0.59 } }, VI: { "": { crystal_radius: 0.9, ionic_radius: 0.76 } }, VIII: { "": { crystal_radius: 1.06, ionic_radius: 0.92 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "85 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.82, "Velocity of sound": "6000 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.98, "Youngs modulus": "4.9 GPa", "NMR Quadrupole Moment": { "Li-6": -0.808, "Li-7": -40.1 }, "Metallic radius": 1.52, iupac_ordering: 11, "IUPAC ordering": 11, "Ground level": "2S1/2", "Ionization energies": [5.391714996, 75.640097, 122.45435914], "Electron affinity": 0.61804922 }, Lr: { "Atomic mass": 262, "Atomic no": 103, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>14</sup>.7s<sup>2</sup>.7p<sup>1</sup> (tentative)", "Liquid range": "no data K", "Melting point": "about 1900 K", "Mendeleev no": 34, "Mineral hardness": "no data", "Molar volume": "no data cm<sup>3</sup>", Name: "Lawrencium", "Oxidation states": [3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": "no data", "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 18, "IUPAC ordering": 18, "Ground level": "2P°1/2", "Ionization energies": [4.96, 14.54, 21.8, 43.6, 56, 80, 96, 121, 143, 165, 197, 216, 244, 269, 290, 322, 344, 374, 403, 431, 459, 487, 510, 540, 560, 745, 779, 814, 852, 888, 922, 985, 1020, 1061, 1098, 1280, 1320, 1360, 1410, 1570, 1620, 1760, 1810, 2010, 2100, 2190, 2290, 2380, 2470, 2570, 2670, 2780, 2860, 2960, 3060, 3150, 3250, 3741, 3821, 3906, 3996, 4082, 4165, 4360, 4448, 4540, 4630, 4990, 5070, 5160, 5250, 5920, 6030, 6290, 6390, 9920, 10110, 10310, 10520, 10720, 10920, 11470, 11680, 11910, 12120, 12710, 12890, 13090, 13300, 15300, 15600, 16e3, 16200, 32400, 32900, 33400, 33900, 41600, 42300, 43200, 43759, null, 172930], "Electron affinity": -0.31 }, Lu: { "Atomic mass": 174.967, "Atomic no": 71, "Atomic orbitals": { "1s": -2146.885351, "2p": -334.330902, "2s": -349.390492, "3d": -58.592982, "3p": -71.538779, "3s": -78.462398, "4d": -7.113364, "4f": -0.568096, "4p": -12.250904, "4s": -15.08337, "5d": -0.103686, "5p": -1.111991, "5s": -1.872086, "6s": -0.155112 }, "Atomic radius": 1.75, "Atomic radius calculated": 2.17, "Boiling point": "3675 K", "Brinell hardness": "893 MN m<sup>-2</sup>", "Bulk modulus": "48 GPa", "Coefficient of linear thermal expansion": "9.9 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "9841 kg m<sup>-3</sup>", "Electrical resistivity": "58 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>1</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3], "Ionic radii": { 3: 1.001 }, "Liquid range": "1750 K", "Melting point": "1925 K", "Mendeleev no": 20, "Mineral hardness": "no data", "Molar volume": "17.78 cm<sup>3</sup>", Name: "Lutetium", "Oxidation states": [3], "Poissons ratio": "0.26", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "27 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.001, ionic_radius: 0.861 } }, VIII: { "": { crystal_radius: 1.117, ionic_radius: 0.977 } }, IX: { "": { crystal_radius: 1.172, ionic_radius: 1.032 } } } }, "Superconduction temperature": "0.022 K", "Thermal conductivity": "16 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.24, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "1160 MN m<sup>-2</sup>", X: 1.27, "Youngs modulus": "69 GPa", "Metallic radius": 1.735, iupac_ordering: 33, "IUPAC ordering": 33, "Ground level": "2D3/2", "Ionization energies": [5.425871, 14.13, 20.9594, 45.249, 66.8, 98, 117, 136, 159, 185, 205, 238, 276, 305, 328, 361, 399, 438, 476, 520, 560, 600, 630, 670, 713, 941, 985, 1032, 1081, 1130, 1178, 1242, 1292, 1345, 1395, 1591, 1641, 1696, 1747, 1875, 1933, 2067, 2125.5, 3590, 3706, 3828, 3960, 4086, 4211, 4403, 4532, 4673, 4803, 5168, 5282, 5408, 5525, 5937, 6070, 6326, 6452, 14228, 14542, 14890, 15211, 16730, 17120, 17610, 17928.05, 72322.91, 73804.8], "Electron affinity": 0.23887 }, Md: { "Atomic mass": 258, "Atomic no": 101, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>13</sup>.7s<sup>2</sup>", "Liquid range": "no data K", "Melting point": "about 1100 K", "Mendeleev no": 36, "Mineral hardness": "no data", "Molar volume": "no data cm<sup>3</sup>", Name: "Mendelevium", "Oxidation states": [2, 3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.46, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 20, "IUPAC ordering": 20, "Ground level": "2F°7/2", "Ionization energies": [6.58, 12.4, 24.3, 40, 54.1, 76, 96, 115.1, 143.9, 162, 187, 215, 240, 260, 282, 307, 334, 360, 386, 412, 438, 462, 486, 659, 690, 723, 760, 794, 828, 885, 920, 958, 994, 1160, 1210, 1250, 1290, 1430, 1480, 1620, 1660, 1840, 1930, 2020, 2110, 2200, 2290, 2390, 2480, 2580, 2680, 2760, 2860, 2950, 3050, 3513, 3592, 3675, 3762, 3845, 3926, 4109, 4194, 4286, 4371, 4720, 4800, 4890, 4970, 5580, 5680, 5930, 6030, 9430, 9620, 9810, 10020, 10220, 10410, 10930, 11130, 11350, 11560, 12130, 12310, 12500, 12680, 14560, 14800, 15200, 15400, 31e3, 31500, 32e3, 32500, 39500, 40100, 41e3, 41548, null, 164764], "Electron affinity": 0.98 }, Mg: { "Atomic mass": 24.305, "Atomic no": 12, "Atomic orbitals": { "1s": -45.973167, "2p": -1.71897, "2s": -2.903746, "3s": -0.175427 }, "Atomic radius": 1.5, "Atomic radius calculated": 1.45, "Boiling point": "1363 K", "Brinell hardness": "260 MN m<sup>-2</sup>", "Bulk modulus": "45 GPa", "Coefficient of linear thermal expansion": "8.2 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "1738 kg m<sup>-3</sup>", "Electrical resistivity": "4.4 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ne].3s<sup>2</sup>", "ICSD oxidation states": [2], "Ionic radii": { 2: 0.86 }, "Liquid range": "440 K", "Melting point": "923 K", "Mendeleev no": 73, "Mineral hardness": "2.5", "Molar volume": "14.00 cm<sup>3</sup>", Name: "Magnesium", "Oxidation states": [1, 2], "Poissons ratio": "0.29", Reflectivity: "74 %", "Refractive index": "no data", "Rigidity modulus": "17 GPa", "Shannon radii": { 2: { IV: { "": { crystal_radius: 0.71, ionic_radius: 0.57 } }, V: { "": { crystal_radius: 0.8, ionic_radius: 0.66 } }, VI: { "": { crystal_radius: 0.86, ionic_radius: 0.72 } }, VIII: { "": { crystal_radius: 1.03, ionic_radius: 0.89 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "160 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.73, "Velocity of sound": "4602 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.31, "Youngs modulus": "45 GPa", "NMR Quadrupole Moment": { "Mg-25": 199.4 }, "Metallic radius": 1.6, iupac_ordering: 16, "IUPAC ordering": 16, "Ground level": "1S0", "Ionization energies": [7.646236, 15.035271, 80.1436, 109.2654, 141.33, 186.76, 225.02, 265.924, 327.99, 367.489, 1761.80488, 1962.66366], "Electron affinity": -0.42 }, Mn: { "Atomic mass": 54.938045, "Atomic no": 25, "Atomic orbitals": { "1s": -233.696912, "2p": -23.066297, "2s": -26.866646, "3d": -0.26654, "3p": -1.99145, "3s": -3.076637, "4s": -0.191136 }, "Atomic radius": 1.4, "Atomic radius calculated": 1.61, "Boiling point": "2334 K", "Brinell hardness": "196 MN m<sup>-2</sup>", "Bulk modulus": "120 GPa", "Coefficient of linear thermal expansion": "21.7 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2, 4, 7], "Critical temperature": "no data K", "Density of solid": "7470 kg m<sup>-3</sup>", "Electrical resistivity": "144 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>5</sup>.4s<sup>2</sup>", "ICSD oxidation states": [2, 3, 4, 7], "Ionic radii": { 2: 0.97, 3: 0.785, 4: 0.67, 5: 0.47, 6: 0.395, 7: 0.6 }, "Ionic radii hs": { 2: 0.97, 3: 0.785 }, "Ionic radii ls": { 2: 0.81, 3: 0.72, 4: 0.67, 5: 0.47, 6: 0.395, 7: 0.6 }, "Liquid range": "815 K", "Melting point": "1519 K", "Mendeleev no": 60, "Mineral hardness": "6.0", "Molar volume": "7.35 cm<sup>3</sup>", Name: "Manganese", "Oxidation states": [-3, -2, -1, 1, 2, 3, 4, 5, 6, 7], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 2: { IV: { "High Spin": { crystal_radius: 0.8, ionic_radius: 0.66 } }, V: { "High Spin": { crystal_radius: 0.89, ionic_radius: 0.75 } }, VI: { "Low Spin": { crystal_radius: 0.81, ionic_radius: 0.67 }, "High Spin": { crystal_radius: 0.97, ionic_radius: 0.83 } }, VII: { "High Spin": { crystal_radius: 1.04, ionic_radius: 0.9 } }, VIII: { "": { crystal_radius: 1.1, ionic_radius: 0.96 } } }, 3: { V: { "": { crystal_radius: 0.72, ionic_radius: 0.58 } }, VI: { "Low Spin": { crystal_radius: 0.72, ionic_radius: 0.58 }, "High Spin": { crystal_radius: 0.785, ionic_radius: 0.645 } } }, 4: { IV: { "": { crystal_radius: 0.53, ionic_radius: 0.39 } }, VI: { "": { crystal_radius: 0.67, ionic_radius: 0.53 } } }, 5: { IV: { "": { crystal_radius: 0.47, ionic_radius: 0.33 } } }, 6: { IV: { "": { crystal_radius: 0.395, ionic_radius: 0.255 } } }, 7: { IV: { "": { crystal_radius: 0.39, ionic_radius: 0.25 } }, VI: { "": { crystal_radius: 0.6, ionic_radius: 0.46 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "7.8 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.05, "Velocity of sound": "5150 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.55, "Youngs modulus": "198 GPa", "NMR Quadrupole Moment": { "Mn-55": 330.1 }, "Metallic radius": 1.292, iupac_ordering: 61, "IUPAC ordering": 61, "Ground level": "6S5/2", "Ionization energies": [7.434038, 15.63999, 33.668, 51.21, 72.41, 95.604, 119.203, 195.5, 221.89, 248.6, 286.1, 314.4, 343.6, 402.95, 435.172, 1133.7, 1224.1, 1320.3, 1430.9, 1537.2, 1643.2, 1788.7, 1879.873, 8140.7872, 8571.9488], "Electron affinity": -0.52 }, Mo: { "Atomic mass": 95.94, "Atomic no": 42, "Atomic orbitals": { "1s": -709.232119, "2p": -90.791541, "2s": -98.503638, "3d": -8.257721, "3p": -13.71481, "3s": -16.681545, "4d": -0.153347, "4p": -1.39005, "4s": -2.234824, "5s": -0.14788 }, "Atomic radius": 1.45, "Atomic radius calculated": 1.9, "Boiling point": "4912 K", "Brinell hardness": "1500 MN m<sup>-2</sup>", "Bulk modulus": "230 GPa", "Coefficient of linear thermal expansion": "4.8 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4, 6], "Critical temperature": "no data K", "Density of solid": "10280 kg m<sup>-3</sup>", "Electrical resistivity": "5.5 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>5</sup>.5s<sup>1</sup>", "ICSD oxidation states": [2, 3, 4, 5, 6], "Ionic radii": { 3: 0.83, 4: 0.79, 5: 0.75, 6: 0.73 }, "Liquid range": "2016 K", "Melting point": "2896 K", "Mendeleev no": 56, "Mineral hardness": "5.5", "Molar volume": "9.38 cm<sup>3</sup>", Name: "Molybdenum", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.31", Reflectivity: "58 %", "Refractive index": "no data", "Rigidity modulus": "20 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.83, ionic_radius: 0.69 } } }, 4: { VI: { "": { crystal_radius: 0.79, ionic_radius: 0.65 } } }, 5: { IV: { "": { crystal_radius: 0.6, ionic_radius: 0.46 } }, VI: { "": { crystal_radius: 0.75, ionic_radius: 0.61 } } }, 6: { IV: { "": { crystal_radius: 0.55, ionic_radius: 0.41 } }, V: { "": { crystal_radius: 0.64, ionic_radius: 0.5 } }, VI: { "": { crystal_radius: 0.73, ionic_radius: 0.59 } }, VII: { "": { crystal_radius: 0.87, ionic_radius: 0.73 } } } }, "Superconduction temperature": "0.915 K", "Thermal conductivity": "139 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.17, "Velocity of sound": "6190 m s<sup>-1</sup>", "Vickers hardness": "1530 MN m<sup>-2</sup>", X: 2.16, "Youngs modulus": "329 GPa", "Metallic radius": 1.402, iupac_ordering: 57, "IUPAC ordering": 57, "Ground level": "7S3", "Ionization energies": [7.09243, 16.16, 27.13, 40.33, 54.417, 68.82704, 125.638, 143.6, 164.12, 186.3, 209.3, 230.28, 279.1, 302.6, 544, 591, 646, 702, 758, 829, 890, 953, 1019, 1082, 1263, 1319.6, 1385.1, 1462, 1537, 1587, 1730.1, 1790.93, 4259, 4430, 4618, 4800, 5084, 5287, 5548, 5713.194, 23810.654, 24572.156], "Electron affinity": 0.74733 }, N: { "Atomic mass": 14.0067, "Atomic no": 7, "Atomic orbitals": { "1s": -14.011501, "2p": -0.266297, "2s": -0.676151 }, "Atomic radius": 0.65, "Atomic radius calculated": 0.56, "Boiling point": "77.36 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-3, 3, 5], "Critical temperature": "126.2 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[He].2s<sup>2</sup>.2p<sup>3</sup>", "ICSD oxidation states": [1, 3, 5, -1, -3, -2], "Ionic radii": { "-3": 1.32, 3: 0.3, 5: 0.27 }, "Liquid range": "14.31 K", "Melting point": "63.05 K", "Mendeleev no": 100, "Mineral hardness": "no data", "Molar volume": "13.54 cm<sup>3</sup>", Name: "Nitrogen", "Oxidation states": [-3, -2, -1, 1, 2, 3, 4, 5], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000298 (gas; liquid 1.197)(no units)", "Rigidity modulus": "no data GPa", "Shannon radii": { "-3": { IV: { "": { crystal_radius: 1.32, ionic_radius: 1.46 } } }, 3: { VI: { "": { crystal_radius: 0.3, ionic_radius: 0.16 } } }, 5: { III: { "": { crystal_radius: 0.044, ionic_radius: -0.104 } }, VI: { "": { crystal_radius: 0.27, ionic_radius: 0.13 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.02583 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.55, "Velocity of sound": "333.6 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 3.04, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "N-14": 20.44 }, "Metallic radius": "no data", iupac_ordering: 91, "IUPAC ordering": 91, "Ground level": "4S°3/2", "Ionization energies": [14.53413, 29.60125, 47.4453, 77.4735, 97.8901, 552.06733, 667.046121], "Electron affinity": -0.07 }, Na: { "Atomic mass": 22.98976928, "Atomic no": 11, "Atomic orbitals": { "1s": -37.719975, "2p": -1.060636, "2s": -2.063401, "3s": -0.103415 }, "Atomic radius": 1.8, "Atomic radius calculated": 1.9, "Boiling point": "1156 K", "Brinell hardness": "0.69 MN m<sup>-2</sup>", "Bulk modulus": "6.3 GPa", "Coefficient of linear thermal expansion": "71 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1], "Critical temperature": "2573 K", "Density of solid": "968 kg m<sup>-3</sup>", "Electrical resistivity": "4.9 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ne].3s<sup>1</sup>", "ICSD oxidation states": [1], "Ionic radii": { 1: 1.16 }, "Liquid range": "785.13 K", "Melting point": "370.87 K", "Mendeleev no": 11, "Mineral hardness": "0.5", "Molar volume": "23.78 cm<sup>3</sup>", Name: "Sodium", "Oxidation states": [-1, 1], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "3.3 GPa", "Shannon radii": { 1: { IV: { "": { crystal_radius: 1.13, ionic_radius: 0.99 } }, V: { "": { crystal_radius: 1.14, ionic_radius: 1 } }, VI: { "": { crystal_radius: 1.16, ionic_radius: 1.02 } }, VII: { "": { crystal_radius: 1.26, ionic_radius: 1.12 } }, VIII: { "": { crystal_radius: 1.32, ionic_radius: 1.18 } }, IX: { "": { crystal_radius: 1.38, ionic_radius: 1.24 } }, XII: { "": { crystal_radius: 1.53, ionic_radius: 1.39 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "140 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.27, "Velocity of sound": "3200 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.93, "Youngs modulus": "10 GPa", "NMR Quadrupole Moment": { "Na-23": 104.1 }, "Metallic radius": 1.86, iupac_ordering: 10, "IUPAC ordering": 10, "Ground level": "2S1/2", "Ionization energies": [5.13907696, 47.28636, 71.62, 98.936, 138.404, 172.23, 208.504, 264.192, 299.856, 1465.134502, 1648.7022], "Electron affinity": 0.54792625 }, Nb: { "Atomic mass": 92.90638, "Atomic no": 41, "Atomic orbitals": { "1s": -673.76253, "2p": -85.272175, "2s": -92.74086, "3d": -7.339839, "3p": -12.552855, "3s": -15.393727, "4d": -0.125252, "4p": -1.250049, "4s": -2.036693, "5s": -0.144272 }, "Atomic radius": 1.45, "Atomic radius calculated": 1.98, "Boiling point": "5017 K", "Brinell hardness": "736 MN m<sup>-2</sup>", "Bulk modulus": "170 GPa", "Coefficient of linear thermal expansion": "7.3 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [5], "Critical temperature": "no data K", "Density of solid": "8570 kg m<sup>-3</sup>", "Electrical resistivity": "15.2 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>4</sup>.5s<sup>1</sup>", "ICSD oxidation states": [2, 3, 4, 5], "Ionic radii": { 3: 0.86, 4: 0.82, 5: 0.78 }, "Liquid range": "2267 K", "Melting point": "2750 K", "Mendeleev no": 53, "Mineral hardness": "6.0", "Molar volume": "10.83 cm<sup>3</sup>", Name: "Niobium", "Oxidation states": [-1, 2, 3, 4, 5], "Poissons ratio": "0.40", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "38 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.86, ionic_radius: 0.72 } } }, 4: { VI: { "": { crystal_radius: 0.82, ionic_radius: 0.68 } }, VIII: { "": { crystal_radius: 0.93, ionic_radius: 0.79 } } }, 5: { IV: { "": { crystal_radius: 0.62, ionic_radius: 0.48 } }, VI: { "": { crystal_radius: 0.78, ionic_radius: 0.64 } }, VII: { "": { crystal_radius: 0.83, ionic_radius: 0.69 } }, VIII: { "": { crystal_radius: 0.88, ionic_radius: 0.74 } } } }, "Superconduction temperature": "9.25 K", "Thermal conductivity": "54 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.18, "Velocity of sound": "3480 m s<sup>-1</sup>", "Vickers hardness": "1320 MN m<sup>-2</sup>", X: 1.6, "Youngs modulus": "105 GPa", "Metallic radius": 1.473, iupac_ordering: 54, "IUPAC ordering": 54, "Ground level": "6D1/2", "Ionization energies": [6.75885, 14.32, 25.04, 37.611, 50.5728, 102.069, 119.1, 136, 159.2, 180, 200.28, 246.1, 268.59, 482.5, 530, 581, 636, 688, 758, 816, 877, 940, 1e3, 1176, 1230.6, 1293.7, 1368, 1439, 1488, 1625.9, 1684.97, 4020.1, 4187, 4369, 4540, 4815, 5011, 5265, 5426.066, 22648.046, 23388.801], "Electron affinity": 0.917407 }, Nd: { "Atomic mass": 144.242, "Atomic no": 60, "Atomic orbitals": { "1s": -1509.698955, "2p": -224.351816, "2s": -236.613572, "3d": -35.754515, "3p": -45.791219, "3s": -51.161263, "4d": -4.377027, "4f": -0.179508, "4p": -7.96782, "4s": -10.000891, "5p": -0.798503, "5s": -1.334934, "6s": -0.125796 }, "Atomic radius": 1.85, "Atomic radius calculated": 2.06, "Boiling point": "3373 K", "Brinell hardness": "265 MN m<sup>-2</sup>", "Bulk modulus": "32 GPa", "Coefficient of linear thermal expansion": "9.6 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "6800 kg m<sup>-3</sup>", "Electrical resistivity": "64.3 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>4</sup>.6s<sup>2</sup>", "ICSD oxidation states": [2, 3], "Ionic radii": { 2: 1.43, 3: 1.123 }, "Liquid range": "2076 K", "Melting point": "1297 K", "Mendeleev no": 30, "Mineral hardness": "no data", "Molar volume": "20.59 cm<sup>3</sup>", Name: "Neodymium", "Oxidation states": [2, 3], "Poissons ratio": "0.28", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "16 GPa", "Shannon radii": { 2: { VIII: { "": { crystal_radius: 1.43, ionic_radius: 1.29 } }, IX: { "": { crystal_radius: 1.49, ionic_radius: 1.35 } } }, 3: { VI: { "": { crystal_radius: 1.123, ionic_radius: 0.983 } }, VIII: { "": { crystal_radius: 1.249, ionic_radius: 1.109 } }, IX: { "": { crystal_radius: 1.303, ionic_radius: 1.163 } }, XII: { "": { crystal_radius: 1.41, ionic_radius: 1.27 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "17 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.39, "Velocity of sound": "2330 m s<sup>-1</sup>", "Vickers hardness": "343 MN m<sup>-2</sup>", X: 1.14, "Youngs modulus": "41 GPa", "Metallic radius": 1.821, iupac_ordering: 44, "IUPAC ordering": 44, "Ground level": "5I4", "Ionization energies": [5.525, 10.783, 22.09, 40.6, 60, 84, 99, 114, 136, 152, 168, 195, 221, 243, 389, 420, 453, 489, 522, 562, 602, 638, 678, 714, 859, 896, 939, 978, 1049, 1092, 1191, 1238.42, 2134, 2224, 2321, 2425, 2525, 2627, 2758, 2861, 2974, 3078, 3371, 3465, 3567, 3662, 3891, 3997, 4198, 4302, 9742, 10002, 10288, 10555, 11384, 11694, 12082, 12341.66, 50339.59, 51515.58], "Electron affinity": 0.0974933 }, Ne: { "Atomic mass": 20.1797, "Atomic no": 10, "Atomic orbitals": { "1s": -30.305855, "2p": -0.498034, "2s": -1.322809 }, "Atomic radius": "no data", "Atomic radius calculated": 0.38, "Boiling point": "27.07 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Critical temperature": "44.4 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[He].2s<sup>2</sup>.2p<sup>6</sup>", "Liquid range": "2.51 K", "Max oxidation state": 0, "Melting point": "24.56 K", "Mendeleev no": 2, "Min oxidation state": 0, "Mineral hardness": "no data", "Molar volume": "13.23 cm<sup>3</sup>", Name: "Neon", "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000067", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "0.0491 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.54, "Velocity of sound": "936 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "Ne-21": 101.55 }, "Metallic radius": "no data", iupac_ordering: 4, "IUPAC ordering": 4, "Ground level": "1S0", "Ionization energies": [21.564541, 40.96297, 63.4233, 97.19, 126.247, 157.934, 207.271, 239.097, 1195.80784, 1362.19916], "Electron affinity": -1.22 }, Ni: { "Atomic mass": 58.6934, "Atomic no": 28, "Atomic orbitals": { "1s": -297.870824, "2p": -30.868027, "2s": -35.312112, "3d": -0.348699, "3p": -2.594158, "3s": -3.950717, "4s": -0.210764 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.49, "Boiling point": "3186 K", "Brinell hardness": "700 MN m<sup>-2</sup>", "Bulk modulus": "180 GPa", "Coefficient of linear thermal expansion": "13.4 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "8908 kg m<sup>-3</sup>", "Electrical resistivity": "7.2 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>8</sup>.4s<sup>2</sup>", "ICSD oxidation states": [1, 2, 3, 4], "Ionic radii": { 3: 0.74 }, "Ionic radii hs": { 3: 0.74 }, "Ionic radii ls": { 2: 0.83, 3: 0.7, 4: 0.62 }, "Liquid range": "1458 K", "Melting point": "1728 K", "Mendeleev no": 67, "Mineral hardness": "4.0", "Molar volume": "6.59 cm<sup>3</sup>", Name: "Nickel", "Oxidation states": [-1, 1, 2, 3, 4], "Poissons ratio": "0.31", Reflectivity: "72 %", "Refractive index": "no data", "Rigidity modulus": "76 GPa", "Shannon radii": { 2: { IV: { "": { crystal_radius: 0.69, ionic_radius: 0.55 } }, IVSQ: { "": { crystal_radius: 0.63, ionic_radius: 0.49 } }, V: { "": { crystal_radius: 0.77, ionic_radius: 0.63 } }, VI: { "": { crystal_radius: 0.83, ionic_radius: 0.69 } } }, 3: { VI: { "Low Spin": { crystal_radius: 0.7, ionic_radius: 0.56 }, "High Spin": { crystal_radius: 0.74, ionic_radius: 0.6 } } }, 4: { VI: { "Low Spin": { crystal_radius: 0.62, ionic_radius: 0.48 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "91 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.97, "Velocity of sound": "4970 m s<sup>-1</sup>", "Vickers hardness": "638 MN m<sup>-2</sup>", X: 1.91, "Youngs modulus": "200 GPa", "NMR Quadrupole Moment": { "Ni-61": 162.15 }, "Metallic radius": 1.246, iupac_ordering: 70, "IUPAC ordering": 70, "Ground level": "3F4", "Ionization energies": [7.639878, 18.168838, 35.187, 54.92, 76.06, 108, 132, 162, 193.2, 224.7, 319.5, 351.6, 384.5, 429.3, 462.8, 495.4, 571.07, 607.02, 1541, 1646, 1758, 1880, 2008.1, 2130.5, 2295.6, 2399.259, 10288.8862, 10775.386], "Electron affinity": 1.1571612 }, No: { "Atomic mass": 259, "Atomic no": 102, "Atomic orbitals": "no data", "Atomic radius": "no data", "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>14</sup>.7s<sup>2</sup>", "Liquid range": "no data K", "Melting point": "about 1100 K", "Mendeleev no": 35, "Mineral hardness": "no data", "Molar volume": "no data cm<sup>3</sup>", Name: "Nobelium", "Oxidation states": [2, 3], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.24, ionic_radius: 1.1 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "no data W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.46, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 19, "IUPAC ordering": 19, "Ground level": "1S0", "Ionization energies": [6.62621, 12.93, 25.8, 41.5, 60, 74, 97, 119, 140, 170, 187, 216, 246, 267, 285, 312, 341, 367, 394, 422, 448, 475, 496, 520, 701, 734, 768, 805, 840, 875, 934, 969, 1010, 1045, 1220, 1260, 1300, 1350, 1500, 1550, 1680, 1730, 1920, 2010, 2110, 2200, 2290, 2380, 2470, 2570, 2680, 2760, 2860, 2950, 3050, 3140, 3627, 3705, 3790, 3878, 3962, 4045, 4234, 4320, 4413, 4500, 4850, 4930, 5030, 5110, 5750, 5850, 6110, 6210, 9680, 9860, 10060, 10270, 10470, 10660, 11200, 11410, 11630, 11840, 12420, 12600, 12800, 12980, 15e3, 15200, 15600, 15800, 31700, 32200, 32700, 33200, 40500, 41200, 42100, 42632, null, 168806], "Electron affinity": -2.33 }, Np: { "Atomic mass": 237, "Atomic no": 93, "Atomic orbitals": "no data", "Atomic radius": 1.75, "Atomic radius calculated": "no data", "Boiling point": "4273 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [5], "Critical temperature": "no data K", "Density of solid": "20450 kg m<sup>-3</sup>", "Electrical resistivity": "120 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>4</sup>.6d<sup>1</sup>.7s<sup>2</sup>", "Ionic radii": { 2: 1.24, 3: 1.15, 4: 1.01, 5: 0.89, 6: 0.86, 7: 0.85 }, "Liquid range": "3363 K", "Melting point": "910 K", "Mendeleev no": 44, "Mineral hardness": "no data", "Molar volume": "11.59 cm<sup>3</sup>", Name: "Neptunium", "Oxidation states": [3, 4, 5, 6, 7], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.24, ionic_radius: 1.1 } } }, 3: { VI: { "": { crystal_radius: 1.15, ionic_radius: 1.01 } } }, 4: { VI: { "": { crystal_radius: 1.01, ionic_radius: 0.87 } }, VIII: { "": { crystal_radius: 1.12, ionic_radius: 0.98 } } }, 5: { VI: { "": { crystal_radius: 0.89, ionic_radius: 0.75 } } }, 6: { VI: { "": { crystal_radius: 0.86, ionic_radius: 0.72 } } }, 7: { VI: { "": { crystal_radius: 0.85, ionic_radius: 0.71 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "6 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.39, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.36, "Youngs modulus": "no data GPa", "Metallic radius": 1.503, iupac_ordering: 28, "IUPAC ordering": 28, "Ground level": "6L11/2", "Ionization energies": [6.26554, 11.5, 19.7, 33.8, 48, 65, 92, 107, 121, 136, 151, 179, 196, 233, 252, 355, 382, 408, 438, 466, 495, 535, 565, 596, 626, 770, 810, 850, 880, 980, 1020, 1130, 1170, 1280, 1360, 1430, 1510, 1590, 1670, 1740, 1820, 1910, 1990, 2070, 2140, 2230, 2310, 2675, 2745, 2817, 2894, 2969, 3041, 3181, 3255, 3338, 3413, 3718, 3792, 3872, 3947, 4353, 4441, 4658, 4744, 7610, 7770, 7950, 8130, 8310, 8480, 8890, 9070, 9270, 9450, 9970, 10130, 10300, 10470, 11730, 11930, 12320, 12500, 25870, 26300, 26770, 27210, 31910, 32500, 33300, 33722.2, 132901.8, 135202], "Electron affinity": 0.48 }, O: { "Atomic mass": 15.9994, "Atomic no": 8, "Atomic orbitals": { "1s": -18.758245, "2p": -0.338381, "2s": -0.871362 }, "Atomic radius": 0.6, "Atomic radius calculated": 0.48, "Boiling point": "90.2 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-2], "Critical temperature": "154.6 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[He].2s<sup>2</sup>.2p<sup>4</sup>", "ICSD oxidation states": [-2], "Ionic radii": { "-2": 1.26 }, "Liquid range": "35.4 K", "Melting point": "54.8 K", "Mendeleev no": 101, "Mineral hardness": "no data", "Molar volume": "17.36 cm<sup>3</sup>", Name: "Oxygen", "Oxidation states": [-2, -1, 1, 2], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000271 (gas; liquid 1.221)(no units)", "Rigidity modulus": "no data GPa", "Shannon radii": { "-2": { II: { "": { crystal_radius: 1.21, ionic_radius: 1.35 } }, III: { "": { crystal_radius: 1.22, ionic_radius: 1.36 } }, IV: { "": { crystal_radius: 1.24, ionic_radius: 1.38 } }, VI: { "": { crystal_radius: 1.26, ionic_radius: 1.4 } }, VIII: { "": { crystal_radius: 1.28, ionic_radius: 1.42 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.02658 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.52, "Velocity of sound": "317.5 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 3.44, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "O-17": -25.58 }, "Metallic radius": "no data", iupac_ordering: 97, "IUPAC ordering": 97, "Ground level": "3P2", "Ionization energies": [13.618055, 35.12112, 54.93554, 77.4135, 113.899, 138.1189, 739.32683, 871.409883], "Electron affinity": 1.4611053 }, Os: { "Atomic mass": 190.23, "Atomic no": 76, "Atomic orbitals": { "1s": -2475.238617, "2p": -393.15408, "2s": -409.522396, "3d": -72.497183, "3p": -86.837047, "3s": -94.501324, "4d": -10.176082, "4f": -2.321175, "4p": -16.119671, "4s": -19.362527, "5d": -0.296791, "5p": -1.757404, "5s": -2.738293, "6s": -0.191489 }, "Atomic radius": 1.3, "Atomic radius calculated": 1.85, "Boiling point": "5285 K", "Brinell hardness": "3920 MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "5.1 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "22610 kg m<sup>-3</sup>", "Electrical resistivity": "8.1 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>6</sup>.6s<sup>2</sup>", "Ionic radii": { 4: 0.77, 5: 0.715, 6: 0.685, 7: 0.665, 8: 0.53 }, "Liquid range": "1979 K", "Melting point": "3306 K", "Mendeleev no": 63, "Mineral hardness": "7.0", "Molar volume": "8.42 cm<sup>3</sup>", Name: "Osmium", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6, 7, 8], "Poissons ratio": "0.25", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "222 GPa", "Shannon radii": { 4: { VI: { "": { crystal_radius: 0.77, ionic_radius: 0.63 } } }, 5: { VI: { "": { crystal_radius: 0.715, ionic_radius: 0.575 } } }, 6: { V: { "": { crystal_radius: 0.63, ionic_radius: 0.49 } }, VI: { "": { crystal_radius: 0.685, ionic_radius: 0.545 } } }, 7: { VI: { "": { crystal_radius: 0.665, ionic_radius: 0.525 } } }, 8: { IV: { "": { crystal_radius: 0.53, ionic_radius: 0.39 } } } }, "Superconduction temperature": "0.66 K", "Thermal conductivity": "88 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.16, "Velocity of sound": "4940 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.2, "Youngs modulus": "no data GPa", "Metallic radius": 1.352, iupac_ordering: 62, "IUPAC ordering": 62, "Ground level": "5D4", "Ionization energies": [8.43823, 17, 25, 41, 55, 70.1, 85.1, 102.02, 168.7, 190, 213, 235, 269, 298, 322, 367, 410, 436, 470, 520, 570, 620, 670, 720, 770, 820, 870, 920, 970, 1015, 1262, 1311, 1364, 1420, 1474, 1528, 1606, 1660, 1720, 1776, 1996, 2052, 2112, 2168, 2336, 2400, 2552, 2615.5, 4374, 4501, 4635, 4779, 4917, 5052, 5280, 5421, 5575, 5717, 6115, 6240, 6376, 6503, 7039, 7185, 7468, 7610, 16560, 16900, 17270, 17620, 19600, 20030, 20570, 20920.6, 83976.21, 85614.4], "Electron affinity": 1.0778013 }, P: { "Atomic mass": 30.973762, "Atomic no": 15, "Atomic orbitals": { "1s": -76.061897, "2p": -4.576617, "2s": -6.329346, "3p": -0.20608, "3s": -0.512364 }, "Atomic radius": 1, "Atomic radius calculated": 0.98, "Boiling point": "550 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "11 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-3, 3, 5], "Critical temperature": "994 K", "Density of solid": "1823 kg m<sup>-3</sup>", "Electrical resistivity": "about 10 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ne].3s<sup>2</sup>.3p<sup>3</sup>", "ICSD oxidation states": [3, 4, 5, -2, -3, -1], "Ionic radii": { 3: 0.58, 5: 0.52 }, "Liquid range": "232.7 K", "Melting point": "(white P) 317.3 K", "Mendeleev no": 90, "Mineral hardness": "no data", "Molar volume": "17.02 cm<sup>3</sup>", Name: "Phosphorus", "Oxidation states": [-3, -2, -1, 1, 2, 3, 4, 5], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.001212", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.58, ionic_radius: 0.44 } } }, 5: { IV: { "": { crystal_radius: 0.31, ionic_radius: 0.17 } }, V: { "": { crystal_radius: 0.43, ionic_radius: 0.29 } }, VI: { "": { crystal_radius: 0.52, ionic_radius: 0.38 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.236 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.8, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.19, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 90, "IUPAC ordering": 90, "Ground level": "4S°3/2", "Ionization energies": [10.486686, 19.76949, 30.20264, 51.44387, 65.02511, 220.43, 263.57, 309.6, 372.31, 424.4, 479.44, 560.62, 611.741, 2816.90879, 3069.8416], "Electron affinity": 0.7466071 }, Pa: { "Atomic mass": 231.03588, "Atomic no": 91, "Atomic orbitals": { "1s": -3606.333629, "2p": -603.470278, "2s": -623.870431, "3d": -127.781168, "3p": -146.485678, "3s": -156.466742, "4d": -25.933121, "4f": -14.105747, "4p": -34.48293, "4s": -39.064507, "5d": -3.659928, "5f": -0.316813, "5p": -6.709821, "5s": -8.463463, "6d": -0.142481, "6p": -0.799756, "6s": -1.287232, "7s": -0.129653 }, "Atomic radius": 1.8, "Atomic radius calculated": "no data", "Boiling point": "no data K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [5], "Critical temperature": "no data K", "Density of solid": "15370 kg m<sup>-3</sup>", "Electrical resistivity": "18 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>2</sup>.6d<sup>1</sup>.7s<sup>2</sup>", "Ionic radii": { 3: 1.16, 4: 1.04, 5: 0.92 }, "Liquid range": "no data K", "Melting point": "1841 K", "Mendeleev no": 46, "Mineral hardness": "no data", "Molar volume": "15.18 cm<sup>3</sup>", Name: "Protactinium", "Oxidation states": [3, 4, 5], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.18, ionic_radius: 1.04 } } }, 4: { VI: { "": { crystal_radius: 1.04, ionic_radius: 0.9 } }, VIII: { "": { crystal_radius: 1.15, ionic_radius: 1.01 } } }, 5: { VI: { "": { crystal_radius: 0.92, ionic_radius: 0.78 } }, VIII: { "": { crystal_radius: 1.05, ionic_radius: 0.91 } }, IX: { "": { crystal_radius: 1.09, ionic_radius: 0.95 } } } }, "Superconduction temperature": "1.4 K", "Thermal conductivity": "47 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.1, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.5, "Youngs modulus": "no data GPa", "Metallic radius": 1.642, iupac_ordering: 30, "IUPAC ordering": 30, "Ground level": "4K11/2", "Ionization energies": [5.89, 11.9, 18.6, 30.9, 44.3, 72, 85.1, 98.9, 111, 137, 153, 187, 203, 292, 316, 342, 369, 395, 423, 460, 488, 518, 546, 690, 720, 760, 790, 880, 920, 1020, 1060, 1150, 1220, 1300, 1370, 1450, 1520, 1600, 1670, 1760, 1830, 1910, 1980, 2060, 2130, 2483, 2550, 2620, 2696, 2766, 2837, 2968, 3040, 3119, 3193, 3488, 3558, 3637, 3709, 4077, 4161, 4370, 4454, 7181, 7341, 7510, 7690, 7870, 8040, 8410, 8590, 8780, 8960, 9460, 9620, 9790, 9950, 11100, 11290, 11660, 11840, 24660, 25080, 25540, 25970, 30230, 30800, 31520, 31971.6, 126296.6, 128507.1], "Electron affinity": 0.55 }, Pb: { "Atomic mass": 207.2, "Atomic no": 82, "Atomic orbitals": { "1s": -2901.078061, "2p": -470.877785, "2s": -488.843335, "3d": -91.889924, "3p": -107.950391, "3s": -116.526852, "4d": -15.030026, "4f": -5.592532, "4p": -21.990564, "4s": -25.75333, "5d": -0.902393, "5p": -2.941657, "5s": -4.206797, "6p": -0.141831, "6s": -0.357187 }, "Atomic radius": 1.8, "Atomic radius calculated": 1.54, "Boiling point": "2022 K", "Brinell hardness": "38.3 MN m<sup>-2</sup>", "Bulk modulus": "46 GPa", "Coefficient of linear thermal expansion": "28.9 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2, 4], "Critical temperature": "no data K", "Density of solid": "11340 kg m<sup>-3</sup>", "Electrical resistivity": "21 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>10</sup>.6s<sup>2</sup>.6p<sup>2</sup>", "ICSD oxidation states": [2, 4], "Ionic radii": { 2: 1.33, 4: 0.915 }, "Liquid range": "1421.39 K", "Melting point": "600.61 K", "Mendeleev no": 82, "Mineral hardness": "1.5", "Molar volume": "18.26 cm<sup>3</sup>", Name: "Lead", "Oxidation states": [-4, 2, 4], "Poissons ratio": "0.44", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "5.6 GPa", "Shannon radii": { 2: { IVPY: { "": { crystal_radius: 1.12, ionic_radius: 0.98 } }, VI: { "": { crystal_radius: 1.33, ionic_radius: 1.19 } }, VII: { "": { crystal_radius: 1.37, ionic_radius: 1.23 } }, VIII: { "": { crystal_radius: 1.43, ionic_radius: 1.29 } }, IX: { "": { crystal_radius: 1.49, ionic_radius: 1.35 } }, X: { "": { crystal_radius: 1.54, ionic_radius: 1.4 } }, XI: { "": { crystal_radius: 1.59, ionic_radius: 1.45 } }, XII: { "": { crystal_radius: 1.63, ionic_radius: 1.49 } } }, 4: { IV: { "": { crystal_radius: 0.79, ionic_radius: 0.65 } }, V: { "": { crystal_radius: 0.87, ionic_radius: 0.73 } }, VI: { "": { crystal_radius: 0.915, ionic_radius: 0.775 } }, VIII: { "": { crystal_radius: 1.08, ionic_radius: 0.94 } } } }, "Superconduction temperature": "7.2 K", "Thermal conductivity": "35 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.02, "Velocity of sound": "1260 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.33, "Youngs modulus": "16 GPa", "Metallic radius": 1.75, iupac_ordering: 82, "IUPAC ordering": 82, "Ground level": "1/2,1/2)0", "Ionization energies": [7.4166799, 15.032499, 31.9373, 42.33256, 68.8, 82.9, 100.1, 120, 138, 158, 182, 203, 224, 245.1, 338.1, 374, 401, 427, 478, 507, 570, 610, 650, 690, 750, 810, 870, 930, 990, 1050, 1120, 1180, 1240, 1300, 1360, 1430, 1704, 1760, 1819, 1884, 1945, 2004, 2101, 2163, 2230, 2292, 2543, 2605, 2671, 2735, 2965, 3036, 3211, 3282.1, 5414, 5555, 5703, 5862, 6015, 6162, 6442, 6597, 6767, 6924, 7362, 7500, 7650, 7790, 8520, 8680, 9e3, 9150, 19590, 19970, 20380, 20750, 23460, 23940, 24550, 24938.2, 99491.85, 101336.4], "Electron affinity": 0.3567212 }, Pd: { "Atomic mass": 106.42, "Atomic no": 46, "Atomic orbitals": { "1s": -860.134909, "2p": -114.408286, "2s": -123.105078, "3d": -12.132197, "3p": -18.580798, "3s": -22.060898, "4d": -0.160771, "4p": -1.815215, "4s": -2.889173 }, "Atomic radius": 1.4, "Atomic radius calculated": 1.69, "Boiling point": "3236 K", "Brinell hardness": "37.3 MN m<sup>-2</sup>", "Bulk modulus": "180 GPa", "Coefficient of linear thermal expansion": "11.8 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2, 4], "Critical temperature": "no data K", "Density of solid": "12023 kg m<sup>-3</sup>", "Electrical resistivity": "10.8 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>", "ICSD oxidation states": [2, 4], "Ionic radii": { 1: 0.73, 2: 1, 3: 0.9, 4: 0.755 }, "Liquid range": "1407.95 K", "Melting point": "1828.05 K", "Mendeleev no": 69, "Mineral hardness": "4.75", "Molar volume": "8.56 cm<sup>3</sup>", Name: "Palladium", "Oxidation states": [2, 4], "Poissons ratio": "0.39", Reflectivity: "72 %", "Refractive index": "no data", "Rigidity modulus": "44 GPa", "Shannon radii": { 1: { II: { "": { crystal_radius: 0.73, ionic_radius: 0.59 } } }, 2: { IVSQ: { "": { crystal_radius: 0.78, ionic_radius: 0.64 } }, VI: { "": { crystal_radius: 1, ionic_radius: 0.86 } } }, 3: { VI: { "": { crystal_radius: 0.9, ionic_radius: 0.76 } } }, 4: { VI: { "": { crystal_radius: 0.755, ionic_radius: 0.615 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "72 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.1, "Velocity of sound": "3070 m s<sup>-1</sup>", "Vickers hardness": "461 MN m<sup>-2</sup>", X: 2.2, "Youngs modulus": "121 GPa", "Metallic radius": 1.376, iupac_ordering: 69, "IUPAC ordering": 69, "Ground level": "1S0", "Ionization energies": [8.336839, 19.43, 32.93, 46, 61, 84.1, 101, 120, 141, 159.9, 238.57, 260, 286, 311, 342, 369.1, 427, 457.5, 810, 869, 933, 1e3, 1065, 1145, 1218, 1290, 1366, 1438, 1644, 1706.2, 1781.3, 1869, 1962, 2016, 2181, 2248.87, 5284, 5475, 5683, 5880, 6242, 6469, 6759, 6943.097, 28776.034, 29622.6], "Electron affinity": 0.5621412 }, Pm: { "Atomic mass": 145, "Atomic no": 61, "Atomic orbitals": { "1s": -1562.980284, "2p": -233.455114, "2s": -245.970548, "3d": -37.625433, "3p": -47.921132, "3s": -53.429311, "4d": -4.596822, "4f": -0.200159, "4p": -8.320495, "4s": -10.422756, "5p": -0.817702, "5s": -1.372265, "6s": -0.127053 }, "Atomic radius": 1.85, "Atomic radius calculated": 2.05, "Boiling point": "3273 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "33 GPa", "Coefficient of linear thermal expansion": "11 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "7264 kg m<sup>-3</sup>", "Electrical resistivity": "about 75 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>5</sup>.6s<sup>2</sup>", "Ionic radii": { 3: 1.11 }, "Liquid range": "1900 K", "Melting point": "1373 K", "Mendeleev no": 29, "Mineral hardness": "no data", "Molar volume": "20.23 cm<sup>3</sup>", Name: "Promethium", "Oxidation states": [3], "Poissons ratio": "0.28", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "18 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.11, ionic_radius: 0.97 } }, VIII: { "": { crystal_radius: 1.233, ionic_radius: 1.093 } }, IX: { "": { crystal_radius: 1.284, ionic_radius: 1.144 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "15 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.38, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.13, "Youngs modulus": "46 GPa", "Metallic radius": 1.811, iupac_ordering: 43, "IUPAC ordering": 43, "Ground level": "6H°5/2", "Ionization energies": [5.58187, 10.938, 22.44, 41.17, 61.7, 85, 101, 116, 138, 155, 174, 202, 229, 248, 269, 430, 462, 497, 534, 569, 609, 651, 689, 730, 767, 916, 956, 998, 1040, 1113, 1158, 1261, 1308.7, 2251, 2344, 2443, 2549, 2652, 2755, 2892, 2997, 3112, 3219, 3519, 3613, 3718, 3816, 4056, 4166, 4371, 4476, 10115, 10378, 10671, 10942, 11819, 12136, 12532, 12797.26, 52144.29, 53346.1], "Electron affinity": 0.129 }, Po: { "Atomic mass": 210, "Atomic no": 84, "Atomic orbitals": { "1s": -3050.988417, "2p": -498.77192, "2s": -517.275843, "3d": -99.256068, "3p": -115.898384, "3s": -124.783683, "4d": -17.173307, "4f": -7.206499, "4p": -24.481337, "4s": -28.42254, "5d": -1.386458, "5p": -3.655382, "5s": -5.027447, "6p": -0.217889, "6s": -0.493528 }, "Atomic radius": 1.9, "Atomic radius calculated": 1.35, "Boiling point": "1235 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-2, 2, 4], "Critical temperature": "no data K", "Density of solid": "9196 kg m<sup>-3</sup>", "Electrical resistivity": "40 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>10</sup>.6s<sup>2</sup>.6p<sup>4</sup>", "Ionic radii": { 4: 1.08, 6: 0.81 }, "Liquid range": "708 K", "Melting point": "527 K", "Mendeleev no": 91, "Mineral hardness": "no data", "Molar volume": "22.97 cm<sup>3</sup>", Name: "Polonium", "Oxidation states": [-2, 2, 4, 6], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 4: { VI: { "": { crystal_radius: 1.08, ionic_radius: 0.94 } }, VIII: { "": { crystal_radius: 1.22, ionic_radius: 1.08 } } }, 6: { VI: { "": { crystal_radius: 0.81, ionic_radius: 0.67 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "20 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.97, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2, "Youngs modulus": "no data GPa", "Metallic radius": 1.53, iupac_ordering: 93, "IUPAC ordering": 93, "Ground level": "3P2", "Ionization energies": [8.41807, 19.3, 27.3, 36, 57, 69.1, 108, 125, 146.1, 166, 186, 209, 235, 257, 281, 304, 416, 444, 473, 502, 560, 590, 670, 700, 740, 800, 870, 930, 990, 1060, 1120, 1180, 1250, 1320, 1380, 1440, 1510, 1570, 1865, 1923, 1986, 2052, 2115, 2177, 2281, 2345, 2414, 2480, 2740, 2803, 2873, 2938, 3194, 3268, 3450, 3524.2, 5785, 5930, 6084, 6248, 6405, 6557, 6856, 7015, 7191, 7350, 7810, 7950, 8100, 8240, 9050, 9220, 9550, 9710, 20670, 21050, 21470, 21860, 24860, 25360, 25990, 26390.4, 105064.3, 106982.7], "Electron affinity": 1.407 }, Pr: { "Atomic mass": 140.90765, "Atomic no": 59, "Atomic orbitals": { "1s": -1457.338067, "2p": -215.418313, "2s": -227.426363, "3d": -33.913996, "3p": -43.692548, "3s": -48.924994, "4d": -4.154228, "4f": -0.155138, "4p": -7.613108, "4s": -9.577447, "5p": -0.778046, "5s": -1.296106, "6s": -0.124465 }, "Atomic radius": 1.85, "Atomic radius calculated": 2.47, "Boiling point": "3563 K", "Brinell hardness": "481 MN m<sup>-2</sup>", "Bulk modulus": "29 GPa", "Coefficient of linear thermal expansion": "6.7 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "6640 kg m<sup>-3</sup>", "Electrical resistivity": "70 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>3</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3, 4], "Ionic radii": { 3: 1.13, 4: 0.99 }, "Liquid range": "2355 K", "Melting point": "1208 K", "Mendeleev no": 31, "Mineral hardness": "no data", "Molar volume": "20.80 cm<sup>3</sup>", Name: "Praseodymium", "Oxidation states": [2, 3, 4], "Poissons ratio": "0.28", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "15 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.13, ionic_radius: 0.99 } }, VIII: { "": { crystal_radius: 1.266, ionic_radius: 1.126 } }, IX: { "": { crystal_radius: 1.319, ionic_radius: 1.179 } } }, 4: { VI: { "": { crystal_radius: 0.99, ionic_radius: 0.85 } }, VIII: { "": { crystal_radius: 1.1, ionic_radius: 0.96 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "13 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.4, "Velocity of sound": "2280 m s<sup>-1</sup>", "Vickers hardness": "400 MN m<sup>-2</sup>", X: 1.13, "Youngs modulus": "37 GPa", "Metallic radius": 1.828, iupac_ordering: 45, "IUPAC ordering": 45, "Ground level": "4I°9/2", "Ionization energies": [5.4702, 10.631, 21.6237, 38.981, 57.53, 82, 97, 112, 131, 148, 162, 196, 217.02, 350, 378, 412, 445, 478, 516, 554, 590, 627, 663, 803, 840, 880, 920, 985, 1028, 1124, 1169.9, 2019, 2108, 2202, 2304, 2400, 2501, 2628, 2729, 2838, 2941, 3227, 3319, 3419, 3512, 3729, 3832, 4030, 4130, 9378, 9632, 9913, 10175, 10959, 11262, 11641, 11895.89, 48571.71, 49722.25], "Electron affinity": 0.1092346 }, Pt: { "Atomic mass": 195.084, "Atomic no": 78, "Atomic orbitals": { "1s": -2613.096532, "2p": -417.96053, "2s": -434.858003, "3d": -78.400271, "3p": -93.309108, "3s": -101.274869, "4d": -11.419476, "4f": -3.038049, "4p": -17.697297, "4s": -21.110651, "5d": -0.273634, "5p": -1.884256, "5s": -2.950526, "6s": -0.161308 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.77, "Boiling point": "4098 K", "Brinell hardness": "392 MN m<sup>-2</sup>", "Bulk modulus": "230 GPa", "Coefficient of linear thermal expansion": "8.8 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2, 4], "Critical temperature": "no data K", "Density of solid": "21090 kg m<sup>-3</sup>", "Electrical resistivity": "10.6 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>9</sup>.6s<sup>1</sup>", "Ionic radii": { 2: 0.94, 4: 0.765, 5: 0.71 }, "Liquid range": "2056.6 K", "Melting point": "2041.4 K", "Mendeleev no": 68, "Mineral hardness": "3.5", "Molar volume": "9.09 cm<sup>3</sup>", Name: "Platinum", "Oxidation states": [-2, 2, 4, 5, 6], "Poissons ratio": "0.38", Reflectivity: "73 %", "Refractive index": "no data", "Rigidity modulus": "61 GPa", "Shannon radii": { 2: { IVSQ: { "": { crystal_radius: 0.74, ionic_radius: 0.6 } }, VI: { "": { crystal_radius: 0.94, ionic_radius: 0.8 } } }, 4: { VI: { "": { crystal_radius: 0.765, ionic_radius: 0.625 } } }, 5: { VI: { "": { crystal_radius: 0.71, ionic_radius: 0.57 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "72 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.13, "Velocity of sound": "2680 m s<sup>-1</sup>", "Vickers hardness": "549 MN m<sup>-2</sup>", X: 2.28, "Youngs modulus": "168 GPa", "Metallic radius": 1.387, iupac_ordering: 68, "IUPAC ordering": 68, "Ground level": "3D3", "Ionization energies": [8.95883, 18.56, 29, 43, 56, 75, 91, 109, 126, 144.9, 220.4, 245, 269, 293, 332, 358, 392, 445, 479, 507, 550, 610, 660, 710, 760, 820, 870, 930, 980, 1040, 1090, 1140, 1402, 1454, 1509, 1567, 1624, 1680, 1763, 1821, 1883, 1941, 2171, 2228, 2291, 2350, 2536, 2603, 2762, 2827.8, 4715, 4839, 4980, 5128, 5270, 5410, 5654, 5800, 5959, 6106, 6517, 6646, 6787, 6918, 7512, 7660, 7960, 8100, 17540, 17890, 18280, 18630, 20840, 21280, 21840, 22205.7, 88955.18, 90659.7], "Electron affinity": 2.125105 }, Pu: { "Atomic mass": 244, "Atomic no": 94, "Atomic orbitals": "no data", "Atomic radius": 1.75, "Atomic radius calculated": "no data", "Boiling point": "3503 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "19816 kg m<sup>-3</sup>", "Electrical resistivity": "150 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>6</sup>.7s<sup>2</sup>", "Ionic radii": { 3: 1.14, 4: 1, 5: 0.88, 6: 0.85 }, "Liquid range": "2590.5 K", "Melting point": "912.5 K", "Mendeleev no": 43, "Mineral hardness": "no data", "Molar volume": "12.29 cm<sup>3</sup>", Name: "Plutonium", "Oxidation states": [3, 4, 5, 6, 7], "Poissons ratio": "0.21", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "43 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.14, ionic_radius: 1 } } }, 4: { VI: { "": { crystal_radius: 1, ionic_radius: 0.86 } }, VIII: { "": { crystal_radius: 1.1, ionic_radius: 0.96 } } }, 5: { VI: { "": { crystal_radius: 0.88, ionic_radius: 0.74 } } }, 6: { VI: { "": { crystal_radius: 0.85, ionic_radius: 0.71 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "6 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.43, "Velocity of sound": "2260 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.28, "Youngs modulus": "96 GPa", "Metallic radius": 1.523, iupac_ordering: 27, "IUPAC ordering": 27, "Ground level": "7F0", "Ionization energies": [6.02576, 11.5, 21.1, 35, 49, 80, 95, 109, 124, 139, 159, 179, 200, 219, 258, 278, 389, 416, 444, 474, 503, 532, 575, 605, 637, 668, 820, 850, 890, 930, 1030, 1070, 1180, 1220, 1340, 1420, 1500, 1580, 1660, 1740, 1820, 1890, 1990, 2070, 2150, 2230, 2310, 2390, 2774, 2844, 2918, 2997, 3072, 3146, 3290, 3366, 3449, 3527, 3836, 3911, 3993, 4068, 4496, 4585, 4807, 4890, 7830, 7990, 8170, 8360, 8540, 8710, 9130, 9310, 9520, 9700, 10230, 10390, 10570, 10730, 12060, 12260, 12660, 12840, 26480, 26920, 27400, 27840, 32800, 33400, 34100, 34625.8, 136299.2, 138646], "Electron affinity": -0.5 }, Ra: { "Atomic mass": 226, "Atomic no": 88, "Atomic orbitals": { "1s": -3362.736563, "2p": -557.513214, "2s": -577.101208, "3d": -115.306476, "3p": -133.12325, "3s": -142.632426, "4d": -22.208125, "4f": -11.181066, "4p": -30.221208, "4s": -34.525628, "5d": -2.819853, "5p": -5.547203, "5s": -7.139137, "6p": -0.634674, "6s": -1.05135, "7s": -0.113732 }, "Atomic radius": 2.15, "Atomic radius calculated": "no data", "Boiling point": "2010 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "5000 kg m<sup>-3</sup>", "Electrical resistivity": "100 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].7s<sup>2</sup>", "Ionic radii": { 2: 1.62 }, "Liquid range": "1037 K", "Melting point": "973 K", "Mendeleev no": 13, "Mineral hardness": "no data", "Molar volume": "41.09 cm<sup>3</sup>", Name: "Radium", "Oxidation states": [2], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 2: { VIII: { "": { crystal_radius: 1.62, ionic_radius: 1.48 } }, XII: { "": { crystal_radius: 1.84, ionic_radius: 1.7 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "19 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.83, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.9, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "Ra-223": 1210.3 }, "Metallic radius": 2.293, iupac_ordering: 12, "IUPAC ordering": 12, "Ground level": "1S0", "Ionization energies": [5.2784239, 10.14718, 31, 41, 52.9, 64, 82, 97, 124, 140, 204.9, 227, 250, 274, 299, 324, 356, 382, 409, 435, 570, 600, 630, 660, 740, 770, 860, 900, 970, 1040, 1110, 1180, 1250, 1320, 1390, 1460, 1530, 1610, 1680, 1750, 1820, 1880, 2208, 2271, 2338, 2409, 2477, 2544, 2662, 2731, 2806, 2876, 3155, 3224, 3298, 3368, 3682, 3762, 3959, 4040, 6565, 6718, 6881, 7056, 7222, 7380, 7720, 7890, 8080, 8250, 8730, 8880, 9040, 9200, 10190, 10360, 10720, 10890, 22900, 23300, 23750, 24160, 27830, 28370, 29050, 29479.8, 116848.7, 118931.3], "Electron affinity": 0.1 }, Rb: { "Atomic mass": 85.4678, "Atomic no": 37, "Atomic orbitals": { "1s": -540.957115, "2p": -64.784678, "2s": -71.291202, "3d": -3.915508, "3p": -8.165416, "3s": -10.513861, "4p": -0.59217, "4s": -1.135051, "5s": -0.085375 }, "Atomic radius": 2.35, "Atomic radius calculated": 2.65, "Boiling point": "961 K", "Brinell hardness": "0.216 MN m<sup>-2</sup>", "Bulk modulus": "2.5 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1], "Critical temperature": "2093 K", "Density of solid": "1532 kg m<sup>-3</sup>", "Electrical resistivity": "13.3 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].5s<sup>1</sup>", "ICSD oxidation states": [1], "Ionic radii": { 1: 1.66 }, "Liquid range": "648.54 K", "Melting point": "312.46 K", "Mendeleev no": 9, "Mineral hardness": "0.3", "Molar volume": "55.76 cm<sup>3</sup>", Name: "Rubidium", "Oxidation states": [1], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 1: { VI: { "": { crystal_radius: 1.66, ionic_radius: 1.52 } }, VII: { "": { crystal_radius: 1.7, ionic_radius: 1.56 } }, VIII: { "": { crystal_radius: 1.75, ionic_radius: 1.61 } }, IX: { "": { crystal_radius: 1.77, ionic_radius: 1.63 } }, X: { "": { crystal_radius: 1.8, ionic_radius: 1.66 } }, XI: { "": { crystal_radius: 1.83, ionic_radius: 1.69 } }, XII: { "": { crystal_radius: 1.86, ionic_radius: 1.72 } }, XIV: { "": { crystal_radius: 1.97, ionic_radius: 1.83 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "58 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 3.03, "Velocity of sound": "1300 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.82, "Youngs modulus": "2.4 GPa", "Metallic radius": 2.537, iupac_ordering: 8, "IUPAC ordering": 8, "Ground level": "2S1/2", "Ionization energies": [4.1771281, 27.28954, 39.247, 52.2, 68.44, 82.9, 98.67, 132.79, 150.628, 277.12, 313.1, 356, 400, 443, 502, 550, 601, 654, 706, 857, 905.3, 958.9, 1024, 1080, 1125, 1242.5, 1294.57, 3133.3, 3281, 3443, 3600, 3815, 3988, 4214, 4356.865, 18305.884, 18965.516], "Electron affinity": 0.48591621 }, Re: { "Atomic mass": 186.207, "Atomic no": 75, "Atomic orbitals": { "1s": -2407.665572, "2p": -380.982869, "2s": -397.087707, "3d": -69.57676, "3p": -83.634578, "3s": -91.149193, "4d": -9.516816, "4f": -1.92508, "4p": -15.295495, "4s": -18.454325, "5d": -0.258639, "5p": -1.631227, "5s": -2.567348, "6s": -0.186859 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.88, "Boiling point": "5869 K", "Brinell hardness": "1320 MN m<sup>-2</sup>", "Bulk modulus": "370 GPa", "Coefficient of linear thermal expansion": "6.2 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "21020 kg m<sup>-3</sup>", "Electrical resistivity": "18 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>5</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3, 4, 5, 6, 7], "Ionic radii": { 4: 0.77, 5: 0.72, 6: 0.69, 7: 0.67 }, "Liquid range": "2410 K", "Melting point": "3459 K", "Mendeleev no": 58, "Mineral hardness": "7.0", "Molar volume": "8.86 cm<sup>3</sup>", Name: "Rhenium", "Oxidation states": [-3, -1, 1, 2, 3, 4, 5, 6, 7], "Poissons ratio": "0.30", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "178 GPa", "Shannon radii": { 4: { VI: { "": { crystal_radius: 0.77, ionic_radius: 0.63 } } }, 5: { VI: { "": { crystal_radius: 0.72, ionic_radius: 0.58 } } }, 6: { VI: { "": { crystal_radius: 0.69, ionic_radius: 0.55 } } }, 7: { IV: { "": { crystal_radius: 0.52, ionic_radius: 0.38 } }, VI: { "": { crystal_radius: 0.67, ionic_radius: 0.53 } } } }, "Superconduction temperature": "1.70 K", "Thermal conductivity": "48 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.16, "Velocity of sound": "4700 m s<sup>-1</sup>", "Vickers hardness": "2450 MN m<sup>-2</sup>", X: 1.9, "Youngs modulus": "463 GPa", "Metallic radius": 1.375, iupac_ordering: 59, "IUPAC ordering": 59, "Ground level": "6S5/2", "Ionization energies": [7.83352, 16.6, 27, 39.1, 51.9, 67, 82.71, 144.4, 165, 187, 208, 236, 268, 291, 330, 377, 403, 429, 476, 520, 570, 620, 670, 720, 760, 810, 860, 910, 953, 1194, 1242, 1294, 1349, 1402, 1454, 1530, 1583, 1641, 1696, 1912, 1966, 2025, 2080, 2240, 2302, 2450, 2514.5, 4214, 4335, 4468, 4609, 4745, 4877, 5099, 5236, 5388, 5528, 5919, 6042, 6176, 6300, 6810, 6952, 7230, 7366, 16080, 16410, 16780, 17120, 19e3, 19420, 19950, 20297.4, 81556.9, 83162.3], "Electron affinity": 0.06039663 }, Rh: { "Atomic mass": 102.9055, "Atomic no": 45, "Atomic orbitals": { "1s": -821.136773, "2p": -108.357665, "2s": -116.80695, "3d": -11.21725, "3p": -17.415299, "3s": -20.765603, "4d": -0.239422, "4p": -1.806456, "4s": -2.825505, "5s": -0.154624 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.73, "Boiling point": "3968 K", "Brinell hardness": "1100 MN m<sup>-2</sup>", "Bulk modulus": "380 GPa", "Coefficient of linear thermal expansion": "8.2 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "12450 kg m<sup>-3</sup>", "Electrical resistivity": "4.3 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>8</sup>.5s<sup>1</sup>", "ICSD oxidation states": [3, 4], "Ionic radii": { 3: 0.805, 4: 0.74, 5: 0.69 }, "Liquid range": "1731 K", "Melting point": "2237 K", "Mendeleev no": 65, "Mineral hardness": "6.0", "Molar volume": "8.28 cm<sup>3</sup>", Name: "Rhodium", "Oxidation states": [-1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.26", Reflectivity: "84 %", "Refractive index": "no data", "Rigidity modulus": "150 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.805, ionic_radius: 0.665 } } }, 4: { VI: { "": { crystal_radius: 0.74, ionic_radius: 0.6 } } }, 5: { VI: { "": { crystal_radius: 0.69, ionic_radius: 0.55 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "150 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.1, "Velocity of sound": "4700 m s<sup>-1</sup>", "Vickers hardness": "1246 MN m<sup>-2</sup>", X: 2.28, "Youngs modulus": "275 GPa", "Metallic radius": 1.345, iupac_ordering: 66, "IUPAC ordering": 66, "Ground level": "4F9/2", "Ionization energies": [7.4589, 18.08, 31.06, 42, 63, 80, 97, 115.1, 135, 207.51, 228, 252.1, 277, 306, 331.58, 389.3, 415.97, 739, 794, 857, 921, 984, 1061, 1131, 1202, 1274, 1344, 1544, 1604.9, 1677.6, 1763, 1851, 1903, 2063, 2129.22, 5018, 5203, 5406, 5600, 5940, 6161, 6444, 6623.262, 27486.983, 28311.965], "Electron affinity": 1.142892 }, Rn: { "Atomic mass": 220, "Atomic no": 86, "Atomic orbitals": { "1s": -3204.756288, "2p": -527.533025, "2s": -546.57796, "3d": -106.945006, "3p": -124.172862, "3s": -133.369144, "4d": -19.449994, "4f": -8.953318, "4p": -27.108985, "4s": -31.230804, "5d": -1.911329, "5p": -4.408702, "5s": -5.889683, "6p": -0.29318, "6s": -0.62657 }, "Atomic radius": "no data", "Atomic radius calculated": 1.2, "Boiling point": "211.3 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Critical temperature": "377 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>10</sup>.6s<sup>2</sup>.6p<sup>6</sup>", "Liquid range": "9.3 K", "Max oxidation state": 0, "Melting point": "202 K", "Mendeleev no": 6, "Min oxidation state": 0, "Mineral hardness": "no data", "Molar volume": "50.50 cm<sup>3</sup>", Name: "Radon", "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Superconduction temperature": "no data K", "Thermal conductivity": "0.00361 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.2, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.2, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 0, "IUPAC ordering": 0, "Ground level": "1S0", "Ionization energies": [10.7485, 21.4, 29.4, 36.9, 52.9, 64, 88, 102, 154, 173.9, 195, 218, 240, 264, 293, 317, 342, 367, 488, 520, 550, 580, 640, 680, 760, 800, 850, 920, 980, 1050, 1110, 1180, 1250, 1310, 1390, 1460, 1520, 1590, 1660, 1720, 2033, 2094, 2158, 2227, 2293, 2357, 2467, 2535, 2606, 2674, 2944, 3010, 3082, 3149, 3433, 3510, 3699, 3777, 6169, 6318, 6476, 6646, 6807, 6964, 7283, 7450, 7630, 7800, 8260, 8410, 8570, 8710, 9610, 9780, 10120, 10290, 21770, 22160, 22600, 22990, 26310, 26830, 27490, 27903.1, 110842, 112843.7], "Electron affinity": -0.72 }, Ru: { "Atomic mass": 101.07, "Atomic no": 44, "Atomic orbitals": { "1s": -782.918621, "2p": -102.333649, "2s": -110.536054, "3d": -10.195668, "3p": -16.145217, "3s": -19.366692, "4d": -0.210375, "4p": -1.667549, "4s": -2.628363, "5s": -0.152834 }, "Atomic radius": 1.3, "Atomic radius calculated": 1.78, "Boiling point": "4423 K", "Brinell hardness": "2160 MN m<sup>-2</sup>", "Bulk modulus": "220 GPa", "Coefficient of linear thermal expansion": "6.4 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3, 4], "Critical temperature": "no data K", "Density of solid": "12370 kg m<sup>-3</sup>", "Electrical resistivity": "7.1 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>7</sup>.5s<sup>1</sup>", "ICSD oxidation states": [2, 3, 4, 5, 6], "Ionic radii": { 3: 0.82, 4: 0.76, 5: 0.705, 7: 0.52, 8: 0.5 }, "Liquid range": "1816 K", "Melting point": "2607 K", "Mendeleev no": 62, "Mineral hardness": "6.5", "Molar volume": "8.17 cm<sup>3</sup>", Name: "Ruthenium", "Oxidation states": [-2, 1, 2, 3, 4, 5, 6, 7, 8], "Poissons ratio": "0.30", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "173 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.82, ionic_radius: 0.68 } } }, 4: { VI: { "": { crystal_radius: 0.76, ionic_radius: 0.62 } } }, 5: { VI: { "": { crystal_radius: 0.705, ionic_radius: 0.565 } } }, 7: { IV: { "": { crystal_radius: 0.52, ionic_radius: 0.38 } } }, 8: { IV: { "": { crystal_radius: 0.5, ionic_radius: 0.36 } } } }, "Superconduction temperature": "0.49 K", "Thermal conductivity": "120 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.13, "Velocity of sound": "5970 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.2, "Youngs modulus": "447 GPa", "Metallic radius": 1.339, iupac_ordering: 63, "IUPAC ordering": 63, "Ground level": "5F5", "Ionization energies": [7.3605, 16.76, 28.47, 45, 59, 76, 93, 110, 178.41, 198, 219.9, 245, 271, 295.9, 348, 376.25, 670, 723, 784, 845, 905, 981, 1048, 1115, 1187, 1253, 1447, 1506.7, 1577, 1659, 1743, 1794, 1949, 2013.04, 4758, 4939, 5136, 5330, 5647, 5861, 6137, 6311.721, 26229.895, 27033.502], "Electron affinity": 1.0463825 }, S: { "Atomic mass": 32.065, "Atomic no": 16, "Atomic orbitals": { "1s": -87.789937, "2p": -5.751257, "2s": -7.69994, "3p": -0.261676, "3s": -0.630912 }, "Atomic radius": 1, "Atomic radius calculated": 0.88, "Boiling point": "717.87 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "7.7 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-2, 2, 4, 6], "Critical temperature": "1314 K", "Density of solid": "1960 kg m<sup>-3</sup>", "Electrical resistivity": "&gt; 10<sup>23</sup>10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ne].3s<sup>2</sup>.3p<sup>4</sup>", "ICSD oxidation states": [-1, 2, 4, -2, 6], "Ionic radii": { "-2": 1.7, 4: 0.51, 6: 0.43 }, "Liquid range": "329.51 K", "Melting point": "388.36 K", "Mendeleev no": 94, "Mineral hardness": "2.0", "Molar volume": "15.53 cm<sup>3</sup>", Name: "Sulfur", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.001111", "Rigidity modulus": "no data GPa", "Shannon radii": { "-2": { VI: { "": { crystal_radius: 1.7, ionic_radius: 1.84 } } }, 4: { VI: { "": { crystal_radius: 0.51, ionic_radius: 0.37 } } }, 6: { IV: { "": { crystal_radius: 0.26, ionic_radius: 0.12 } }, VI: { "": { crystal_radius: 0.43, ionic_radius: 0.29 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.205 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.8, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.58, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "S-33": -67.8, "S-35": 47.1 }, "Metallic radius": "no data", iupac_ordering: 96, "IUPAC ordering": 96, "Ground level": "3P2", "Ionization energies": [10.36001, 23.33788, 34.86, 47.222, 72.5945, 88.0529, 280.954, 328.794, 379.84, 447.7, 504.55, 564.41, 651.96, 706.994, 3223.7807, 3494.1879], "Electron affinity": 2.077104512 }, Sb: { "Atomic mass": 121.76, "Atomic no": 51, "Atomic orbitals": { "1s": -1070.823495, "2p": -149.214271, "2s": -159.171745, "3d": -19.239895, "3p": -26.956184, "3s": -31.098242, "4d": -1.297338, "4p": -3.646579, "4s": -5.04964, "5p": -0.185623, "5s": -0.445605 }, "Atomic radius": 1.45, "Atomic radius calculated": 1.33, "Boiling point": "1860 K", "Brinell hardness": "294 MN m<sup>-2</sup>", "Bulk modulus": "42 GPa", "Coefficient of linear thermal expansion": "11 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-3, 3, 5], "Critical temperature": "no data K", "Density of solid": "6697 kg m<sup>-3</sup>", "Electrical resistivity": "40 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>.5s<sup>2</sup>.5p<sup>3</sup>", "ICSD oxidation states": [-2, 3, 5, -1, -3], "Ionic radii": { 3: 0.9, 5: 0.76 }, "Liquid range": "956.22 K", "Melting point": "903.78 K", "Mendeleev no": 88, "Mineral hardness": "3.0", "Molar volume": "18.19 cm<sup>3</sup>", Name: "Antimony", "Oxidation states": [-3, 3, 5], "Poissons ratio": "no data", Reflectivity: "55 %", "Refractive index": "no data", "Rigidity modulus": "20 GPa", "Shannon radii": { 3: { IVPY: { "": { crystal_radius: 0.9, ionic_radius: 0.76 } }, V: { "": { crystal_radius: 0.94, ionic_radius: 0.8 } }, VI: { "": { crystal_radius: 0.9, ionic_radius: 0.76 } } }, 5: { VI: { "": { crystal_radius: 0.74, ionic_radius: 0.6 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "24 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.06, "Velocity of sound": "3420 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.05, "Youngs modulus": "55 GPa", "NMR Quadrupole Moment": { "Sb-121": -543.11, "Sb-123": -692.14 }, "Metallic radius": 1.61, iupac_ordering: 88, "IUPAC ordering": 88, "Ground level": "4S°3/2", "Ionization energies": [8.608389, 16.626, 25.3235, 43.804, 55, 99.51, 117, 139, 162, 185, 214, 238, 265, 292, 317, 420, 447, 479, 510, 552, 584, 657, 693.26, 1214, 1285, 1360, 1441, 1518, 1606, 1698, 1781, 1869, 1954, 2190, 2266, 2349, 2428, 2567, 2654, 2815, 2900, 6714, 6929, 7167, 7390, 7887, 8140, 8455, 8669.48, 35710.028, 36668.05], "Electron affinity": 1.04740119 }, Sc: { "Atomic mass": 44.955912, "Atomic no": 21, "Atomic orbitals": { "1s": -160.184109, "2p": -14.240006, "2s": -17.206464, "3d": -0.13108, "3p": -1.233165, "3s": -1.988378, "4s": -0.156478 }, "Atomic radius": 1.6, "Atomic radius calculated": 1.84, "Boiling point": "3103 K", "Brinell hardness": "750 MN m<sup>-2</sup>", "Bulk modulus": "57 GPa", "Coefficient of linear thermal expansion": "10.2 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "2985 kg m<sup>-3</sup>", "Electrical resistivity": "about 55 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>1</sup>.4s<sup>2</sup>", "ICSD oxidation states": [2, 3], "Ionic radii": { 3: 0.885 }, "Liquid range": "1289 K", "Melting point": "1814 K", "Mendeleev no": 19, "Mineral hardness": "no data", "Molar volume": "15.00 cm<sup>3</sup>", Name: "Scandium", "Oxidation states": [1, 2, 3], "Poissons ratio": "0.28", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "29 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.885, ionic_radius: 0.745 } }, VIII: { "": { crystal_radius: 1.01, ionic_radius: 0.87 } } } }, "Superconduction temperature": "0.05  (under pressure)K", "Thermal conductivity": "16 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.15, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.36, "Youngs modulus": "74 GPa", "NMR Quadrupole Moment": { "Sc-45": -220.2 }, "Metallic radius": 1.641, iupac_ordering: 49, "IUPAC ordering": 49, "Ground level": "2D3/2", "Ionization energies": [6.56149, 12.79977, 24.756839, 73.4894, 91.95, 110.68, 137.99, 158.08, 180.03, 225.18, 249.798, 687.36, 757.7, 833.2, 926.5, 1008.6, 1093.5, 1213.1, 1287.957, 5674.9037, 6033.7542], "Electron affinity": 0.1882 }, Se: { "Atomic mass": 78.96, "Atomic no": 34, "Atomic orbitals": { "1s": -451.300258, "2p": -51.514388, "2s": -57.311948, "3d": -2.011392, "3p": -5.553517, "3s": -7.547186, "4p": -0.245806, "4s": -0.621248 }, "Atomic radius": 1.15, "Atomic radius calculated": 1.03, "Boiling point": "958 K", "Brinell hardness": "736 MN m<sup>-2</sup>", "Bulk modulus": "8.3 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-2, 2, 4, 6], "Critical temperature": "1766 K", "Density of solid": "4819 kg m<sup>-3</sup>", "Electrical resistivity": "high 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>10</sup>.4s<sup>2</sup>.4p<sup>4</sup>", "ICSD oxidation states": [-1, 4, -2, 6], "Ionic radii": { "-2": 1.84, 4: 0.64, 6: 0.56 }, "Liquid range": "464 K", "Melting point": "494 K", "Mendeleev no": 93, "Mineral hardness": "2.0", "Molar volume": "16.42 cm<sup>3</sup>", Name: "Selenium", "Oxidation states": [-2, 2, 4, 6], "Poissons ratio": "0.33", Reflectivity: "no data %", "Refractive index": "1.000895", "Rigidity modulus": "3.7 GPa", "Shannon radii": { "-2": { VI: { "": { crystal_radius: 1.84, ionic_radius: 1.98 } } }, 4: { VI: { "": { crystal_radius: 0.64, ionic_radius: 0.5 } } }, 6: { IV: { "": { crystal_radius: 0.42, ionic_radius: 0.28 } }, VI: { "": { crystal_radius: 0.56, ionic_radius: 0.42 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.52 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.9, "Velocity of sound": "3350 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.55, "Youngs modulus": "10 GPa", "Metallic radius": "no data", iupac_ordering: 95, "IUPAC ordering": 95, "Ground level": "3P2", "Ionization energies": [9.752392, 21.196, 31.697, 42.947, 68.3, 81.83, 155.327, 184, 219, 255, 291, 342.9, 383, 426, 473, 517, 650.5, 693.4, 739.8, 798, 845.8, 887, 989.6, 1036.36, 2540.7, 2674, 2820, 2964, 3146, 3301.8, 3507, 3636.526, 15367.491, 15968.084], "Electron affinity": 2.020604712 }, Si: { "Atomic mass": 28.0855, "Atomic no": 14, "Atomic orbitals": { "1s": -65.184426, "2p": -3.514938, "2s": -5.075056, "3p": -0.153293, "3s": -0.398139 }, "Atomic radius": 1.1, "Atomic radius calculated": 1.11, "Boiling point": "3173 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "100 GPa", "Coefficient of linear thermal expansion": "2.6 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-4, 4], "Critical temperature": "no data K", "Density of solid": "2330 kg m<sup>-3</sup>", "Electrical resistivity": "about 100000 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ne].3s<sup>2</sup>.3p<sup>2</sup>", "ICSD oxidation states": [-4, 4], "Ionic radii": { 4: 0.54 }, "Liquid range": "1486 K", "Melting point": "1687 K", "Mendeleev no": 85, "Mineral hardness": "6.5", "Molar volume": "12.06 cm<sup>3</sup>", Name: "Silicon", "Oxidation states": [-4, -3, -2, -1, 1, 2, 3, 4], "Poissons ratio": "no data", Reflectivity: "28 %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 4: { IV: { "": { crystal_radius: 0.4, ionic_radius: 0.26 } }, VI: { "": { crystal_radius: 0.54, ionic_radius: 0.4 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "150 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.1, "Velocity of sound": "2200 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.9, "Youngs modulus": "47 GPa", "Metallic radius": "no data", iupac_ordering: 85, "IUPAC ordering": 85, "Ground level": "3P0", "Ionization energies": [8.15168, 16.34585, 33.493, 45.14179, 166.767, 205.279, 246.57, 303.59, 351.28, 401.38, 476.273, 523.415, 2437.65815, 2673.17755], "Electron affinity": 1.38952128 }, Sm: { "Atomic mass": 150.36, "Atomic no": 62, "Atomic orbitals": { "1s": -1617.183426, "2p": -242.729726, "2s": -255.498846, "3d": -39.528656, "3p": -50.08426, "3s": -55.731133, "4d": -4.814978, "4f": -0.21776, "4p": -8.672685, "4s": -10.844667, "5p": -0.835987, "5s": -1.408552, "6s": -0.128259 }, "Atomic radius": 1.85, "Atomic radius calculated": 2.38, "Boiling point": "2076 K", "Brinell hardness": "441 MN m<sup>-2</sup>", "Bulk modulus": "38 GPa", "Coefficient of linear thermal expansion": "12.7 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "7353 kg m<sup>-3</sup>", "Electrical resistivity": "94 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>6</sup>.6s<sup>2</sup>", "ICSD oxidation states": [2, 3], "Ionic radii": { 2: 1.36, 3: 1.0979999999999999 }, "Liquid range": "731 K", "Melting point": "1345 K", "Mendeleev no": 28, "Mineral hardness": "no data", "Molar volume": "19.98 cm<sup>3</sup>", Name: "Samarium", "Oxidation states": [2, 3], "Poissons ratio": "0.27", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "20 GPa", "Shannon radii": { 2: { VII: { "": { crystal_radius: 1.36, ionic_radius: 1.22 } }, VIII: { "": { crystal_radius: 1.41, ionic_radius: 1.27 } }, IX: { "": { crystal_radius: 1.46, ionic_radius: 1.32 } } }, 3: { VI: { "": { crystal_radius: 1.098, ionic_radius: 0.958 } }, VII: { "": { crystal_radius: 1.16, ionic_radius: 1.02 } }, VIII: { "": { crystal_radius: 1.219, ionic_radius: 1.079 } }, IX: { "": { crystal_radius: 1.272, ionic_radius: 1.132 } }, XII: { "": { crystal_radius: 1.38, ionic_radius: 1.24 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "13 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.36, "Velocity of sound": "2130 m s<sup>-1</sup>", "Vickers hardness": "412 MN m<sup>-2</sup>", X: 1.17, "Youngs modulus": "50 GPa", "Metallic radius": 1.804, iupac_ordering: 42, "IUPAC ordering": 42, "Ground level": "7F0", "Ionization energies": [5.64371, 11.078, 23.55, 41.64, 62.7, 87, 103, 118, 141, 158, 179, 208, 237, 257, 276, 306.5, 474, 506, 543, 581, 617, 658, 702, 742, 782, 822, 976, 1016, 1060, 1103, 1180, 1226, 1332, 1381.56, 2371, 2466, 2569, 2676, 2782, 2887, 3028, 3137, 3253, 3363, 3669, 3766, 3873, 3971, 4227, 4337, 4548, 4655, 10494, 10762, 11060, 11337, 12264, 12588, 12992, 13262.85, 53986.12, 55214.23], "Electron affinity": 0.162 }, Sn: { "Atomic mass": 118.71, "Atomic no": 50, "Atomic orbitals": { "1s": -1026.762169, "2p": -141.821093, "2s": -151.523991, "3d": -17.657276, "3p": -25.117913, "3s": -29.125969, "4d": -1.004952, "4p": -3.211998, "4s": -4.546335, "5p": -0.14445, "5s": -0.369349 }, "Atomic radius": 1.45, "Atomic radius calculated": 1.45, "Boiling point": "2875 K", "Brinell hardness": "51 MN m<sup>-2</sup>", "Bulk modulus": "58 GPa", "Coefficient of linear thermal expansion": "22 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-4, 2, 4], "Critical temperature": "no data K", "Density of solid": "7310 kg m<sup>-3</sup>", "Electrical resistivity": "11.5 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>.5s<sup>2</sup>.5p<sup>2</sup>", "ICSD oxidation states": [2, 3, 4], "Ionic radii": { 4: 0.83 }, "Liquid range": "2369.92 K", "Melting point": "505.08 K", "Mendeleev no": 83, "Mineral hardness": "1.5", "Molar volume": "16.29 cm<sup>3</sup>", Name: "Tin", "Oxidation states": [-4, 2, 4], "Poissons ratio": "0.36", Reflectivity: "54 %", "Refractive index": "no data", "Rigidity modulus": "18 GPa", "Shannon radii": { 4: { IV: { "": { crystal_radius: 0.69, ionic_radius: 0.55 } }, V: { "": { crystal_radius: 0.76, ionic_radius: 0.62 } }, VI: { "": { crystal_radius: 0.83, ionic_radius: 0.69 } }, VII: { "": { crystal_radius: 0.89, ionic_radius: 0.75 } }, VIII: { "": { crystal_radius: 0.95, ionic_radius: 0.81 } } } }, "Superconduction temperature": "3.72 K", "Thermal conductivity": "67 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.17, "Velocity of sound": "2500 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.96, "Youngs modulus": "50 GPa", "NMR Quadrupole Moment": { "Sn-119": -132.1 }, "Metallic radius": 1.58, iupac_ordering: 83, "IUPAC ordering": 83, "Ground level": "3P0", "Ionization energies": [7.343918, 14.63307, 30.506, 40.74, 77.03, 94, 112.9, 135, 156, 184, 208, 232, 258, 282, 379, 407, 437, 466, 506, 537, 608, 642.35, 1127, 1195, 1269, 1347, 1421, 1508, 1596, 1676, 1763, 1844, 2074, 2142.1, 2227, 2326, 2443, 2499, 2687, 2762.49, 6421, 6631, 6859, 7080, 7531, 7790, 8103, 8306.95, 34257.143, 35192.39], "Electron affinity": 1.1120702 }, Sr: { "Atomic mass": 87.62, "Atomic no": 38, "Atomic orbitals": { "1s": -572.870169, "2p": -69.745941, "2s": -76.491823, "3d": -4.813498, "3p": -9.301863, "3s": -11.771585, "4p": -0.844489, "4s": -1.455317, "5s": -0.131793 }, "Atomic radius": 2, "Atomic radius calculated": 2.19, "Boiling point": "1655 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "22.5 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "2630 kg m<sup>-3</sup>", "Electrical resistivity": "13.5 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].5s<sup>2</sup>", "ICSD oxidation states": [2], "Ionic radii": { 2: 1.32 }, "Liquid range": "605 K", "Melting point": "1050 K", "Mendeleev no": 15, "Mineral hardness": "1.5", "Molar volume": "33.94 cm<sup>3</sup>", Name: "Strontium", "Oxidation states": [2], "Poissons ratio": "0.28", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "6.1 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.32, ionic_radius: 1.18 } }, VII: { "": { crystal_radius: 1.35, ionic_radius: 1.21 } }, VIII: { "": { crystal_radius: 1.4, ionic_radius: 1.26 } }, IX: { "": { crystal_radius: 1.45, ionic_radius: 1.31 } }, X: { "": { crystal_radius: 1.5, ionic_radius: 1.36 } }, XII: { "": { crystal_radius: 1.58, ionic_radius: 1.44 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "35 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.49, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 0.95, "Youngs modulus": "no data GPa", "NMR Quadrupole Moment": { "Sr-87": 305.2 }, "Metallic radius": 2.151, iupac_ordering: 14, "IUPAC ordering": 14, "Ground level": "1S0", "Ionization energies": [5.69486745, 11.0302765, 42.88353, 56.28, 70.7, 88, 104, 121.21, 158.33, 177.3, 324.07, 362, 408, 454, 499, 562, 612, 665, 722, 774, 932, 982.1, 1038, 1105, 1165, 1211, 1333.4, 1387.19, 3344.7, 3497, 3664, 3830, 4053, 4232, 4465, 4612.397, 19345.588, 20025.233], "Electron affinity": 0.052066 }, Ta: { "Atomic mass": 180.94788, "Atomic no": 73, "Atomic orbitals": { "1s": -2275.371387, "2p": -357.248334, "2s": -372.828724, "3d": -63.942521, "3p": -77.440942, "3s": -84.658467, "4d": -8.265848, "4f": -1.199347, "4p": -13.71981, "4s": -16.713337, "5d": -0.182464, "5p": -1.37653, "5s": -2.223807, "6s": -0.174814 }, "Atomic radius": 1.45, "Atomic radius calculated": 2, "Boiling point": "5731 K", "Brinell hardness": "800 MN m<sup>-2</sup>", "Bulk modulus": "200 GPa", "Coefficient of linear thermal expansion": "6.3 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [5], "Critical temperature": "no data K", "Density of solid": "16650 kg m<sup>-3</sup>", "Electrical resistivity": "13.5 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>3</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3, 4, 5], "Ionic radii": { 3: 0.86, 4: 0.82, 5: 0.78 }, "Liquid range": "2441 K", "Melting point": "3290 K", "Mendeleev no": 52, "Mineral hardness": "6.5", "Molar volume": "10.85 cm<sup>3</sup>", Name: "Tantalum", "Oxidation states": [-1, 2, 3, 4, 5], "Poissons ratio": "0.34", Reflectivity: "78 %", "Refractive index": "no data", "Rigidity modulus": "69 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 0.86, ionic_radius: 0.72 } } }, 4: { VI: { "": { crystal_radius: 0.82, ionic_radius: 0.68 } } }, 5: { VI: { "": { crystal_radius: 0.78, ionic_radius: 0.64 } }, VII: { "": { crystal_radius: 0.83, ionic_radius: 0.69 } }, VIII: { "": { crystal_radius: 0.88, ionic_radius: 0.74 } } } }, "Superconduction temperature": "4.47 K", "Thermal conductivity": "57 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.22, "Velocity of sound": "3400 m s<sup>-1</sup>", "Vickers hardness": "873 MN m<sup>-2</sup>", X: 1.5, "Youngs modulus": "186 GPa", "Metallic radius": 1.47, iupac_ordering: 53, "IUPAC ordering": 53, "Ground level": "4F3/2", "Ionization energies": [7.549571, 16.2, 23.1, 35, 48.272, 94.01, 119, 139, 159, 180, 213, 235, 262, 304, 338, 363, 396, 439, 482, 530, 570, 610, 660, 700, 750, 790, 832, 1064, 1110, 1160, 1211, 1262, 1313, 1382, 1434, 1490, 1542, 1748, 1799, 1857, 1910, 2053, 2113, 2254, 2314.7, 3898.7, 4014, 4143, 4278, 4410, 4537, 4745, 4877, 5024, 5159, 5537, 5655, 5785, 5907, 6364, 6502, 6769, 6900, 15137, 15461, 15820, 16150, 17840, 18250, 18760, 19088.51, 76852.03, 78394.7], "Electron affinity": 0.32312 }, Tb: { "Atomic mass": 158.92535, "Atomic no": 65, "Atomic orbitals": { "1s": -1785.331942, "2p": -271.590585, "2s": -285.121013, "3d": -45.443863, "3p": -56.785113, "3s": -62.851563, "4d": -5.467662, "4f": -0.256311, "4p": -9.735637, "4s": -12.120486, "5p": -0.88723, "5s": -1.513669, "6s": -0.131677 }, "Atomic radius": 1.75, "Atomic radius calculated": 2.25, "Boiling point": "3503 K", "Brinell hardness": "677 MN m<sup>-2</sup>", "Bulk modulus": "38.7 GPa", "Coefficient of linear thermal expansion": "10.3 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "8219 kg m<sup>-3</sup>", "Electrical resistivity": "115 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>9</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3, 4], "Ionic radii": { 3: 1.063, 4: 0.9 }, "Liquid range": "1874 K", "Melting point": "1629 K", "Mendeleev no": 26, "Mineral hardness": "no data", "Molar volume": "19.30 cm<sup>3</sup>", Name: "Terbium", "Oxidation states": [1, 3, 4], "Poissons ratio": "0.26", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "22 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.063, ionic_radius: 0.923 } }, VII: { "": { crystal_radius: 1.12, ionic_radius: 0.98 } }, VIII: { "": { crystal_radius: 1.18, ionic_radius: 1.04 } }, IX: { "": { crystal_radius: 1.235, ionic_radius: 1.095 } } }, 4: { VI: { "": { crystal_radius: 0.9, ionic_radius: 0.76 } }, VIII: { "": { crystal_radius: 1.02, ionic_radius: 0.88 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "11 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.33, "Velocity of sound": "2620 m s<sup>-1</sup>", "Vickers hardness": "863 MN m<sup>-2</sup>", X: 1.1, "Youngs modulus": "56 GPa", "Metallic radius": 1.781, iupac_ordering: 39, "IUPAC ordering": 39, "Ground level": "6H°15/2", "Ionization energies": [5.8638, 11.513, 21.82, 39.33, 66.5, 90, 108, 125, 143, 168, 186, 216, 250, 273, 294, 325, 358, 393, 426.6, 613, 651, 690, 732, 772, 816, 866, 909, 954, 997, 1165, 1208, 1256, 1301, 1393, 1443, 1559, 1610.4, 2750, 2852, 2961, 3078, 3189, 3300, 3458, 3573, 3698, 3814, 4139, 4242, 4355, 4460, 4760, 4877, 5103, 5217, 11673, 11957, 12272, 12563, 13658, 14003, 14434, 14721.02, 59739.3, 61049.65], "Electron affinity": 0.131318 }, Tc: { "Atomic mass": 98, "Atomic no": 43, "Atomic orbitals": { "1s": -745.742024, "2p": -96.61021, "2s": -104.567508, "3d": -9.33986, "3p": -15.041738, "3s": -18.135303, "4d": -0.270262, "4p": -1.64323, "4s": -2.550712, "5s": -0.183636 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.83, "Boiling point": "4538 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4, 7], "Critical temperature": "no data K", "Density of solid": "11500 kg m<sup>-3</sup>", "Electrical resistivity": "about 22 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>5</sup>.5s<sup>2</sup>", "Ionic radii": { 4: 0.785, 5: 0.74, 7: 0.7 }, "Liquid range": "2108 K", "Melting point": "2430 K", "Mendeleev no": 59, "Mineral hardness": "no data", "Molar volume": "8.63 cm<sup>3</sup>", Name: "Technetium", "Oxidation states": [-3, -1, 1, 2, 3, 4, 5, 6, 7], "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "no data GPa", "Shannon radii": { 4: { VI: { "": { crystal_radius: 0.785, ionic_radius: 0.645 } } }, 5: { VI: { "": { crystal_radius: 0.74, ionic_radius: 0.6 } } }, 7: { IV: { "": { crystal_radius: 0.51, ionic_radius: 0.37 } }, VI: { "": { crystal_radius: 0.7, ionic_radius: 0.56 } } } }, "Superconduction temperature": "7.8 K", "Thermal conductivity": "51 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.16, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.9, "Youngs modulus": "no data GPa", "Metallic radius": 1.363, iupac_ordering: 60, "IUPAC ordering": 60, "Ground level": "6S5/2", "Ionization energies": [7.11938, 15.26, 29.55, 41, 57, 72, 88, 150, 169, 189.9, 214, 239, 262.08, 311, 338.55, 604, 655, 713, 773, 829, 904, 968, 1032, 1102, 1166, 1354, 1411.6, 1479.5, 1559, 1638, 1689, 1838, 1900.28, 4505, 4681, 4874, 5060, 5361, 5570, 5838, 6008.391, 25004.533, 25786.99], "Electron affinity": 0.552 }, Te: { "Atomic mass": 127.6, "Atomic no": 52, "Atomic orbitals": { "1s": -1115.831819, "2p": -156.808583, "2s": -167.021776, "3d": -20.887801, "3p": -28.860685, "3s": -33.137485, "4d": -1.608381, "4p": -4.100084, "4s": -5.572846, "5p": -0.226594, "5s": -0.520997 }, "Atomic radius": 1.4, "Atomic radius calculated": 1.23, "Boiling point": "1261 K", "Brinell hardness": "180 MN m<sup>-2</sup>", "Bulk modulus": "65 GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [-2, 2, 4, 6], "Critical temperature": "no data K", "Density of solid": "6240 kg m<sup>-3</sup>", "Electrical resistivity": "about 10000 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>.5s<sup>2</sup>.5p<sup>4</sup>", "ICSD oxidation states": [-2, 4, -1, 6], "Ionic radii": { "-2": 2.07, 4: 1.11, 6: 0.7 }, "Liquid range": "538.34 K", "Melting point": "722.66 K", "Mendeleev no": 92, "Mineral hardness": "2.25", "Molar volume": "20.46 cm<sup>3</sup>", Name: "Tellurium", "Oxidation states": [-2, 2, 4, 5, 6], "Poissons ratio": "no data", Reflectivity: "50 %", "Refractive index": "1.000991", "Rigidity modulus": "16 GPa", "Shannon radii": { "-2": { VI: { "": { crystal_radius: 2.07, ionic_radius: 2.21 } } }, 4: { III: { "": { crystal_radius: 0.66, ionic_radius: 0.52 } }, IV: { "": { crystal_radius: 0.8, ionic_radius: 0.66 } }, VI: { "": { crystal_radius: 1.11, ionic_radius: 0.97 } } }, 6: { IV: { "": { crystal_radius: 0.57, ionic_radius: 0.43 } }, VI: { "": { crystal_radius: 0.7, ionic_radius: 0.56 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "3 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.06, "Velocity of sound": "2610 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.1, "Youngs modulus": "43 GPa", "Metallic radius": "no data", iupac_ordering: 94, "IUPAC ordering": 94, "Ground level": "3P2", "Ionization energies": [9.009808, 18.6, 27.84, 37.4155, 59.3, 69.1, 124.2, 143, 167, 191.1, 215, 245, 272, 299, 328, 354, 461, 491, 522, 555, 599, 633, 709, 746.12, 1304, 1377, 1455, 1538, 1618, 1707, 1803, 1889, 1979, 2066, 2309, 2386, 2472, 2552, 2700, 2788, 2954, 3041, 7022, 7243, 7485, 7714, 8240, 8499, 8821, 9040.83, 37196.522, 38177.56], "Electron affinity": 1.9708757 }, Th: { "Atomic mass": 232.03806, "Atomic no": 90, "Atomic orbitals": { "1s": -3524.439052, "2p": -588.218112, "2s": -608.350958, "3d": -123.846396, "3p": -142.25581, "3s": -152.079741, "4d": -24.955184, "4f": -13.397389, "4p": -33.325252, "4s": -37.814094, "5d": -3.625729, "5p": -6.58281, "5s": -8.287057, "6d": -0.172896, "6p": -0.846921, "6s": -1.333769, "7s": -0.135872 }, "Atomic radius": 1.8, "Atomic radius calculated": "no data", "Boiling point": "5093 K", "Brinell hardness": "400 MN m<sup>-2</sup>", "Bulk modulus": "54 GPa", "Coefficient of linear thermal expansion": "11.0 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "11724 kg m<sup>-3</sup>", "Electrical resistivity": "15 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].6d<sup>2</sup>.7s<sup>2</sup>", "ICSD oxidation states": [4], "Ionic radii": { 4: 1.08 }, "Liquid range": "2978 K", "Melting point": "2115 K", "Mendeleev no": 47, "Mineral hardness": "3.0", "Molar volume": "19.80 cm<sup>3</sup>", Name: "Thorium", "Oxidation states": [2, 3, 4], "Poissons ratio": "0.27", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "31 GPa", "Shannon radii": { 4: { VI: { "": { crystal_radius: 1.08, ionic_radius: 0.94 } }, VIII: { "": { crystal_radius: 1.19, ionic_radius: 1.05 } }, IX: { "": { crystal_radius: 1.23, ionic_radius: 1.09 } }, X: { "": { crystal_radius: 1.27, ionic_radius: 1.13 } }, XI: { "": { crystal_radius: 1.32, ionic_radius: 1.18 } }, XII: { "": { crystal_radius: 1.35, ionic_radius: 1.21 } } } }, "Superconduction temperature": "1.38 K", "Thermal conductivity": "54 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.45, "Velocity of sound": "2490 m s<sup>-1</sup>", "Vickers hardness": "350 MN m<sup>-2</sup>", X: 1.3, "Youngs modulus": "79 GPa", "Metallic radius": 1.798, iupac_ordering: 31, "IUPAC ordering": 31, "Ground level": "3F2", "Ionization energies": [6.3067, 12.1, 18.32, 28.648, 58, 69.1, 82, 95, 118, 133, 165, 181, 262, 285, 310, 336, 362, 389, 424, 451, 480, 508, 650, 680, 720, 750, 830, 870, 970, 1010, 1090, 1160, 1240, 1310, 1380, 1460, 1530, 1600, 1680, 1760, 1830, 1910, 1980, 2060, 2390, 2455, 2524, 2598, 2669, 2737, 2864, 2935, 3013, 3086, 3375, 3445, 3522, 3593, 3943, 4025, 4230, 4313, 6972, 7130, 7299, 7480, 7650, 7810, 8180, 8350, 8550, 8720, 9220, 9370, 9540, 9690, 10790, 10970, 11340, 11510, 24060, 24480, 24940, 25360, 29410, 29970, 30680, 31122.8, 123086.4, 125253.4], "Electron affinity": 1.17 }, Ti: { "Atomic mass": 47.867, "Atomic no": 22, "Atomic orbitals": { "1s": -177.276643, "2p": -16.285339, "2s": -19.457901, "3d": -0.17001, "3p": -1.422947, "3s": -2.258007, "4s": -0.167106 }, "Atomic radius": 1.4, "Atomic radius calculated": 1.76, "Boiling point": "3560 K", "Brinell hardness": "716 MN m<sup>-2</sup>", "Bulk modulus": "110 GPa", "Coefficient of linear thermal expansion": "8.6 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "4507 kg m<sup>-3</sup>", "Electrical resistivity": "about 40 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>2</sup>.4s<sup>2</sup>", "ICSD oxidation states": [2, 3, 4], "Ionic radii": { 2: 1, 3: 0.81, 4: 0.745 }, "Liquid range": "1619 K", "Melting point": "1941 K", "Mendeleev no": 51, "Mineral hardness": "6.0", "Molar volume": "10.64 cm<sup>3</sup>", Name: "Titanium", "Oxidation states": [-1, 2, 3, 4], "Poissons ratio": "0.32", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "44 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1, ionic_radius: 0.86 } } }, 3: { VI: { "": { crystal_radius: 0.81, ionic_radius: 0.67 } } }, 4: { IV: { "": { crystal_radius: 0.56, ionic_radius: 0.42 } }, V: { "": { crystal_radius: 0.65, ionic_radius: 0.51 } }, VI: { "": { crystal_radius: 0.745, ionic_radius: 0.605 } }, VIII: { "": { crystal_radius: 0.88, ionic_radius: 0.74 } } } }, "Superconduction temperature": "0.40 K", "Thermal conductivity": "22 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.11, "Velocity of sound": "4140 m s<sup>-1</sup>", "Vickers hardness": "970 MN m<sup>-2</sup>", X: 1.54, "Youngs modulus": "116 GPa", "NMR Quadrupole Moment": { "Ti-47": 302.1, "Ti-49": 247.11 }, "Metallic radius": 1.462, iupac_ordering: 52, "IUPAC ordering": 52, "Ground level": "3F2", "Ionization energies": [6.82812, 13.5755, 27.49171, 43.26717, 99.299, 119.533, 140.68, 170.5, 192.1, 215.92, 265.07, 291.5, 787.67, 864, 944.5, 1042.5, 1130.2, 1220.3, 1346.3, 1425.257, 6249.0226, 6625.8073], "Electron affinity": 0.075545 }, Tl: { "Atomic mass": 204.3833, "Atomic no": 81, "Atomic orbitals": { "1s": -2827.569408, "2p": -457.255971, "2s": -474.953368, "3d": -88.328299, "3p": -104.099296, "3s": -112.52218, "4d": -14.008848, "4f": -4.835747, "4p": -20.797078, "4s": -24.471512, "5d": -0.674544, "5p": -2.59873, "5s": -3.811512, "6p": -0.101507, "6s": -0.28502 }, "Atomic radius": 1.9, "Atomic radius calculated": 1.56, "Boiling point": "1746 K", "Brinell hardness": "26.4 MN m<sup>-2</sup>", "Bulk modulus": "43 GPa", "Coefficient of linear thermal expansion": "29.9 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [1, 3], "Critical temperature": "no data K", "Density of solid": "11850 kg m<sup>-3</sup>", "Electrical resistivity": "15 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>10</sup>.6s<sup>2</sup>.6p<sup>1</sup>", "ICSD oxidation states": [1, 3], "Ionic radii": { 1: 1.64, 3: 1.025 }, "Liquid range": "1169 K", "Melting point": "577 K", "Mendeleev no": 78, "Mineral hardness": "1.2", "Molar volume": "17.22 cm<sup>3</sup>", Name: "Thallium", "Oxidation states": [1, 3], "Poissons ratio": "0.45", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "2.8 GPa", "Shannon radii": { 1: { VI: { "": { crystal_radius: 1.64, ionic_radius: 1.5 } }, VIII: { "": { crystal_radius: 1.73, ionic_radius: 1.59 } }, XII: { "": { crystal_radius: 1.84, ionic_radius: 1.7 } } }, 3: { IV: { "": { crystal_radius: 0.89, ionic_radius: 0.75 } }, VI: { "": { crystal_radius: 1.025, ionic_radius: 0.885 } }, VIII: { "": { crystal_radius: 1.12, ionic_radius: 0.98 } } } }, "Superconduction temperature": "2.38 K", "Thermal conductivity": "46 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 1.96, "Velocity of sound": "818 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.62, "Youngs modulus": "8 GPa", "Metallic radius": 1.7, iupac_ordering: 77, "IUPAC ordering": 77, "Ground level": "2P°1/2", "Ionization energies": [6.1082873, 20.4283, 29.852, 51.14, 62.6, 80, 97.9, 116, 135, 158, 177, 198, 218.3, 306.9, 340, 366, 392, 439, 467, 520, 570, 600, 640, 700, 760, 820, 880, 930, 990, 1060, 1110, 1170, 1230, 1290, 1350, 1625, 1681, 1740, 1802, 1862, 1920, 2014, 2075, 2140, 2202, 2447, 2508, 2574, 2635, 2854, 2925, 3094, 3164.7, 5234, 5371, 5518, 5674, 5824, 5969, 6241, 6392, 6560, 6714, 7146, 7281, 7430, 7570, 8260, 8420, 8730, 8880, 19070, 19440, 19840, 20210, 22780, 23250, 23850, 24234.1, 96783.21, 98591.6], "Electron affinity": 0.32005319 }, Tm: { "Atomic mass": 168.93421, "Atomic no": 69, "Atomic orbitals": { "1s": -2022.471608, "2p": -312.510608, "2s": -327.05712, "3d": -53.835494, "3p": -66.239338, "3s": -72.873753, "4d": -6.350307, "4f": -0.28312, "4p": -11.187151, "4s": -13.865665, "5p": -0.950748, "5s": -1.64999, "6s": -0.135953 }, "Atomic radius": 1.75, "Atomic radius calculated": 2.22, "Boiling point": "2223 K", "Brinell hardness": "471 MN m<sup>-2</sup>", "Bulk modulus": "45 GPa", "Coefficient of linear thermal expansion": "13.3 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "9321 kg m<sup>-3</sup>", "Electrical resistivity": "67.6 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>13</sup>.6s<sup>2</sup>", "ICSD oxidation states": [3], "Ionic radii": { 2: 1.17, 3: 1.02 }, "Liquid range": "405 K", "Melting point": "1818 K", "Mendeleev no": 21, "Mineral hardness": "no data", "Molar volume": "19.1 cm<sup>3</sup>", Name: "Thulium", "Oxidation states": [2, 3], "Poissons ratio": "0.21", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "31 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.17, ionic_radius: 1.03 } }, VII: { "": { crystal_radius: 1.23, ionic_radius: 1.09 } } }, 3: { VI: { "": { crystal_radius: 1.02, ionic_radius: 0.88 } }, VIII: { "": { crystal_radius: 1.134, ionic_radius: 0.994 } }, IX: { "": { crystal_radius: 1.192, ionic_radius: 1.052 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "17 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.27, "Velocity of sound": "no data m s<sup>-1</sup>", "Vickers hardness": "520 MN m<sup>-2</sup>", X: 1.25, "Youngs modulus": "74 GPa", "Metallic radius": 1.747, iupac_ordering: 35, "IUPAC ordering": 35, "Ground level": "2F°7/2", "Ionization energies": [6.18431, 12.065, 23.66, 42.41, 65.4, 98, 116, 133, 160, 180, 205, 239, 274, 295, 317, 352, 387, 424, 460, 496, 530, 570, 603, 825, 866, 911, 958, 1004, 1050, 1110, 1157, 1207, 1255, 1442, 1490, 1542, 1591, 1706, 1761, 1889, 1945.2, 3298, 3409, 3528, 3653, 3775, 3895, 4075, 4199, 4335, 4461, 4812, 4922, 5044, 5157, 5527, 5656, 5901, 6023, 13347, 13651, 13988, 14300, 15663, 16036, 16510, 16814.34, 67965.26, 69387.3], "Electron affinity": 1.02922 }, U: { "Atomic mass": 238.02891, "Atomic no": 92, "Atomic orbitals": { "1s": -3689.355141, "2p": -619.10855, "2s": -639.778728, "3d": -131.977358, "3p": -150.97898, "3s": -161.118073, "4d": -27.123212, "4f": -15.02746, "4p": -35.853321, "4s": -40.528084, "5d": -3.866175, "5f": -0.366543, "5p": -7.018092, "5s": -8.824089, "6d": -0.14319, "6p": -0.822538, "6s": -1.325976, "7s": -0.130948 }, "Atomic radius": 1.75, "Atomic radius calculated": "no data", "Boiling point": "4200 K", "Brinell hardness": "2400 MN m<sup>-2</sup>", "Bulk modulus": "100 GPa", "Coefficient of linear thermal expansion": "13.9 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [6], "Critical temperature": "no data K", "Density of solid": "19050 kg m<sup>-3</sup>", "Electrical resistivity": "28 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Rn].5f<sup>3</sup>.6d<sup>1</sup>.7s<sup>2</sup>", "ICSD oxidation states": [3, 4, 5, 6], "Ionic radii": { 3: 1.165, 4: 1.03, 5: 0.9, 6: 0.87 }, "Liquid range": "2794.7 K", "Melting point": "1405.3 K", "Mendeleev no": 45, "Mineral hardness": "6.0", "Molar volume": "12.49 cm<sup>3</sup>", Name: "Uranium", "Oxidation states": [3, 4, 5, 6], "Poissons ratio": "0.23", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "111 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.165, ionic_radius: 1.025 } } }, 4: { VI: { "": { crystal_radius: 1.03, ionic_radius: 0.89 } }, VII: { "": { crystal_radius: 1.09, ionic_radius: 0.95 } }, VIII: { "": { crystal_radius: 1.14, ionic_radius: 1 } }, IX: { "": { crystal_radius: 1.19, ionic_radius: 1.05 } }, XII: { "": { crystal_radius: 1.31, ionic_radius: 1.17 } } }, 5: { VI: { "": { crystal_radius: 0.9, ionic_radius: 0.76 } }, VII: { "": { crystal_radius: 0.98, ionic_radius: 0.84 } } }, 6: { II: { "": { crystal_radius: 0.59, ionic_radius: 0.45 } }, IV: { "": { crystal_radius: 0.66, ionic_radius: 0.52 } }, VI: { "": { crystal_radius: 0.87, ionic_radius: 0.73 } }, VII: { "": { crystal_radius: 0.95, ionic_radius: 0.81 } }, VIII: { "": { crystal_radius: 1, ionic_radius: 0.86 } } } }, "Superconduction temperature": "0.2 K", "Thermal conductivity": "27 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.41, "Velocity of sound": "3155 m s<sup>-1</sup>", "Vickers hardness": "1960 MN m<sup>-2</sup>", X: 1.38, "Youngs modulus": "208 GPa", "Metallic radius": 1.542, iupac_ordering: 29, "IUPAC ordering": 29, "Ground level": "5L°6", "Ionization energies": [6.19405, 11.6, 19.8, 36.7, 46, 62, 89, 101, 116, 128.9, 158, 173, 210, 227, 323, 348, 375, 402, 431, 458, 497, 525, 557, 585, 730, 770, 800, 840, 930, 970, 1070, 1110, 1210, 1290, 1370, 1440, 1520, 1590, 1670, 1750, 1830, 1910, 1990, 2070, 2140, 2220, 2578, 2646, 2718, 2794, 2867, 2938, 3073, 3147, 3228, 3301, 3602, 3675, 3753, 3827, 4214, 4299, 4513, 4598, 7393, 7550, 7730, 7910, 8090, 8260, 8650, 8830, 9030, 9210, 9720, 9870, 10040, 10200, 11410, 11600, 11990, 12160, 25260, 25680, 26150, 26590, 31060, 31640, 32400, 32836.5, 129570.3, 131821], "Electron affinity": 0.53 }, V: { "Atomic mass": 50.9415, "Atomic no": 23, "Atomic orbitals": { "1s": -195.224014, "2p": -18.435189, "2s": -21.815346, "3d": -0.204634, "3p": -1.610516, "3s": -2.526904, "4s": -0.175968 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.71, "Boiling point": "3680 K", "Brinell hardness": "628 MN m<sup>-2</sup>", "Bulk modulus": "160 GPa", "Coefficient of linear thermal expansion": "8.4 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [5], "Critical temperature": "no data K", "Density of solid": "6110 kg m<sup>-3</sup>", "Electrical resistivity": "20 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>3</sup>.4s<sup>2</sup>", "ICSD oxidation states": [2, 3, 4, 5], "Ionic radii": { 2: 0.93, 3: 0.78, 4: 0.72, 5: 0.68 }, "Liquid range": "1497 K", "Melting point": "2183 K", "Mendeleev no": 54, "Mineral hardness": "7.0", "Molar volume": "8.32 cm<sup>3</sup>", Name: "Vanadium", "Oxidation states": [-1, 1, 2, 3, 4, 5], "Poissons ratio": "0.37", Reflectivity: "61 %", "Refractive index": "no data", "Rigidity modulus": "47 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 0.93, ionic_radius: 0.79 } } }, 3: { VI: { "": { crystal_radius: 0.78, ionic_radius: 0.64 } } }, 4: { V: { "": { crystal_radius: 0.67, ionic_radius: 0.53 } }, VI: { "": { crystal_radius: 0.72, ionic_radius: 0.58 } }, VIII: { "": { crystal_radius: 0.86, ionic_radius: 0.72 } } }, 5: { IV: { "": { crystal_radius: 0.495, ionic_radius: 0.355 } }, V: { "": { crystal_radius: 0.6, ionic_radius: 0.46 } }, VI: { "": { crystal_radius: 0.68, ionic_radius: 0.54 } } } }, "Superconduction temperature": "5.40 K", "Thermal conductivity": "31 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.07, "Velocity of sound": "4560 m s<sup>-1</sup>", "Vickers hardness": "628 MN m<sup>-2</sup>", X: 1.63, "Youngs modulus": "128 GPa", "NMR Quadrupole Moment": { "V-50": 210.4, "V-51": -52.1 }, "Metallic radius": 1.347, iupac_ordering: 55, "IUPAC ordering": 55, "Ground level": "4F3/2", "Ionization energies": [6.746187, 14.634, 29.3111, 46.709, 65.28165, 128.125, 150.72, 173.55, 206, 230.5, 254.8, 308.5, 336.274, 896, 977.2, 1062.9, 1165.2, 1258.9, 1354.2, 1486.7, 1569.656, 6851.3109, 7246.1226], "Electron affinity": 0.527662 }, W: { "Atomic mass": 183.84, "Atomic no": 74, "Atomic orbitals": { "1s": -2341.042887, "2p": -369.013973, "2s": -384.856157, "3d": -66.724787, "3p": -80.502102, "3s": -87.867792, "4d": -8.879693, "4f": -1.550835, "4p": -14.495102, "4s": -17.570797, "5d": -0.220603, "5p": -1.504457, "5s": -2.396018, "6s": -0.181413 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.93, "Boiling point": "5828 K", "Brinell hardness": "2570 MN m<sup>-2</sup>", "Bulk modulus": "310 GPa", "Coefficient of linear thermal expansion": "4.5 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4, 6], "Critical temperature": "no data K", "Density of solid": "19250 kg m<sup>-3</sup>", "Electrical resistivity": "5.4 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.5d<sup>4</sup>.6s<sup>2</sup>", "ICSD oxidation states": [2, 3, 4, 5, 6], "Ionic radii": { 4: 0.8, 5: 0.76, 6: 0.74 }, "Liquid range": "2133 K", "Melting point": "3695 K", "Mendeleev no": 55, "Mineral hardness": "7.5", "Molar volume": "9.47 cm<sup>3</sup>", Name: "Tungsten", "Oxidation states": [-2, -1, 1, 2, 3, 4, 5, 6], "Poissons ratio": "0.28", Reflectivity: "62 %", "Refractive index": "no data", "Rigidity modulus": "161 GPa", "Shannon radii": { 4: { VI: { "": { crystal_radius: 0.8, ionic_radius: 0.66 } } }, 5: { VI: { "": { crystal_radius: 0.76, ionic_radius: 0.62 } } }, 6: { IV: { "": { crystal_radius: 0.56, ionic_radius: 0.42 } }, V: { "": { crystal_radius: 0.65, ionic_radius: 0.51 } }, VI: { "": { crystal_radius: 0.74, ionic_radius: 0.6 } } } }, "Superconduction temperature": "0.015 K", "Thermal conductivity": "170 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.18, "Velocity of sound": "5174 m s<sup>-1</sup>", "Vickers hardness": "3430 MN m<sup>-2</sup>", X: 2.36, "Youngs modulus": "411 GPa", "Metallic radius": 1.41, iupac_ordering: 56, "IUPAC ordering": 56, "Ground level": "5D0", "Ionization energies": [7.86403, 16.37, 26, 38.2, 51.6, 64.77, 122.01, 141.2, 160.2, 179, 208.9, 231.6, 258.3, 290.7, 325.3, 361.9, 387.9, 420.7, 462.1, 502.6, 543.4, 594.5, 640.6, 685.6, 734.1, 784.4, 833.4, 881.4, 1132.2, 1180, 1230.4, 1283.4, 1335.1, 1386.8, 1459.9, 1512.4, 1569.1, 1621.7, 1829.8, 1882.9, 1940.6, 1994.8, 2149.1, 2210, 2354.5, 2414.1, 4057, 4180, 4309, 4446, 4578, 4709, 4927, 5063, 5209, 5348, 5719, 5840, 5970, 6093, 6596, 6735, 7e3, 7130, 15566, 15896, 16252, 16588, 18476, 18872, 19362, 19686.74, 79181.94, 80755.6], "Electron affinity": 0.816268 }, Xe: { "Atomic mass": 131.293, "Atomic no": 54, "Atomic orbitals": { "1s": -1208.688993, "2p": -172.599583, "2s": -183.327495, "3d": -24.37823, "3p": -32.867042, "3s": -37.415454, "4d": -2.286666, "4p": -5.063802, "4s": -6.67834, "5p": -0.309835, "5s": -0.672086 }, "Atomic radius": "no data", "Atomic radius calculated": 1.08, "Boiling point": "165.1 K", "Brinell hardness": "no data MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "no data x10<sup>-6</sup>K<sup>-1</sup>", "Critical temperature": "289.7 K", "Density of solid": "no data kg m<sup>-3</sup>", "Electrical resistivity": "no data 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>10</sup>.5s<sup>2</sup>.5p<sup>6</sup>", "Ionic radii": { 8: 0.62 }, "Liquid range": "3.7 K", "Max oxidation state": 8, "Melting point": "161.4 K", "Mendeleev no": 5, "Min oxidation state": 2, "Mineral hardness": "no data", "Molar volume": "35.92 cm<sup>3</sup>", Name: "Xenon", "Poissons ratio": "no data", Reflectivity: "no data %", "Refractive index": "1.000702", "Rigidity modulus": "no data GPa", "Shannon radii": { 8: { IV: { "": { crystal_radius: 0.54, ionic_radius: 0.4 } }, VI: { "": { crystal_radius: 0.62, ionic_radius: 0.48 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "0.00565 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.16, "Velocity of sound": "1090 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 2.6, "Youngs modulus": "no data GPa", "Metallic radius": "no data", iupac_ordering: 1, "IUPAC ordering": 1, "Ground level": "1S0", "Ionization energies": [12.1298437, 20.975, 31.05, 42.2, 54.1, 66.703, 91.6, 105.9778, 179.84, 202, 229.02, 255, 281, 314, 343, 374, 404, 434, 549, 582, 616, 650, 700, 736, 818, 857, 1493, 1571, 1653, 1742, 1826, 1919, 2023, 2113, 2209, 2300, 2556, 2637, 2726, 2811, 2975, 3068, 3243, 3333.8, 7660, 7889, 8144, 8382, 8971, 9243, 9581, 9810.37, 40271.724, 41299.71], "Electron affinity": -0.82 }, Y: { "Atomic mass": 88.90585, "Atomic no": 39, "Atomic orbitals": { "1s": -605.631981, "2p": -74.803201, "2s": -81.789102, "3d": -5.671499, "3p": -10.399926, "3s": -12.992217, "4d": -0.108691, "4p": -1.02449, "4s": -1.697124, "5s": -0.150727 }, "Atomic radius": 1.8, "Atomic radius calculated": 2.12, "Boiling point": "3609 K", "Brinell hardness": "589 MN m<sup>-2</sup>", "Bulk modulus": "41 GPa", "Coefficient of linear thermal expansion": "10.6 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "4472 kg m<sup>-3</sup>", "Electrical resistivity": "about 60 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>1</sup>.5s<sup>2</sup>", "ICSD oxidation states": [3], "Ionic radii": { 3: 1.04 }, "Liquid range": "1810 K", "Melting point": "1799 K", "Mendeleev no": 25, "Mineral hardness": "no data", "Molar volume": "19.88 cm<sup>3</sup>", Name: "Yttrium", "Oxidation states": [1, 2, 3], "Poissons ratio": "0.24", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "26 GPa", "Shannon radii": { 3: { VI: { "": { crystal_radius: 1.04, ionic_radius: 0.9 } }, VII: { "": { crystal_radius: 1.1, ionic_radius: 0.96 } }, VIII: { "": { crystal_radius: 1.159, ionic_radius: 1.019 } }, IX: { "": { crystal_radius: 1.215, ionic_radius: 1.075 } } } }, "Superconduction temperature": "1.3  (under pressure)K", "Thermal conductivity": "17 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.32, "Velocity of sound": "3300 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.22, "Youngs modulus": "64 GPa", "Metallic radius": 1.8, iupac_ordering: 48, "IUPAC ordering": 48, "Ground level": "2D3/2", "Ionization energies": [6.21726, 12.2236, 20.52441, 60.6072, 75.35, 91.39, 110.02, 128.12, 145.64, 185.7, 205.814, 374.04, 414, 463, 512, 559, 624, 677, 733, 790, 847, 1010, 1061.9, 1120.2, 1190, 1253, 1300, 1427.6, 1483.12, 3562.9, 3720, 3892, 4060, 4299, 4484, 4724, 4875.731, 20415.717, 21115.55], "Electron affinity": 0.30712 }, Yb: { "Atomic mass": 173.04, "Atomic no": 70, "Atomic orbitals": { "1s": -2084.069389, "2p": -323.178219, "2s": -337.978976, "3d": -56.026315, "3p": -68.698655, "3s": -75.47663, "4d": -6.574963, "4f": -0.286408, "4p": -11.558246, "4s": -14.312076, "5p": -0.966137, "5s": -1.683886, "6s": -0.136989 }, "Atomic radius": 1.75, "Atomic radius calculated": 2.22, "Boiling point": "1469 K", "Brinell hardness": "343 MN m<sup>-2</sup>", "Bulk modulus": "31 GPa", "Coefficient of linear thermal expansion": "26.3 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [3], "Critical temperature": "no data K", "Density of solid": "6570 kg m<sup>-3</sup>", "Electrical resistivity": "25.0 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Xe].4f<sup>14</sup>.6s<sup>2</sup>", "ICSD oxidation states": [2, 3], "Ionic radii": { 2: 1.16, 3: 1.008 }, "Liquid range": "372 K", "Melting point": "1097 K", "Mendeleev no": 17, "Mineral hardness": "no data", "Molar volume": "24.84 cm<sup>3</sup>", Name: "Ytterbium", "Oxidation states": [2, 3], "Poissons ratio": "0.21", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "9.9 GPa", "Shannon radii": { 2: { VI: { "": { crystal_radius: 1.16, ionic_radius: 1.02 } }, VII: { "": { crystal_radius: 1.22, ionic_radius: 1.08 } }, VIII: { "": { crystal_radius: 1.28, ionic_radius: 1.14 } } }, 3: { VI: { "": { crystal_radius: 1.008, ionic_radius: 0.868 } }, VII: { "": { crystal_radius: 1.065, ionic_radius: 0.925 } }, VIII: { "": { crystal_radius: 1.125, ionic_radius: 0.985 } }, IX: { "": { crystal_radius: 1.182, ionic_radius: 1.042 } } } }, "Superconduction temperature": "no data K", "Thermal conductivity": "39 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.26, "Velocity of sound": "1590 m s<sup>-1</sup>", "Vickers hardness": "206 MN m<sup>-2</sup>", X: 1.1, "Youngs modulus": "24 GPa", "Metallic radius": 1.94, iupac_ordering: 34, "IUPAC ordering": 34, "Ground level": "1S0", "Ionization energies": [6.25416, 12.179185, 25.053, 43.61, 65.6, 99, 117, 135, 163, 182, 209, 244, 279, 301, 324, 360, 396, 431, 469, 505, 540, 580, 610, 651, 882, 924, 971, 1019, 1065, 1114, 1175, 1224, 1275, 1324, 1516, 1564, 1618, 1668, 1789, 1845, 1978, 2036.4, 3443, 3555, 3677, 3805, 3929, 4051, 4238, 4364, 4502, 4630, 4988, 5101, 5224, 5339, 5731, 5860, 6111, 6236, 13784, 14093, 14435, 14752, 16191, 16570, 17050, 17365.44, 70123.04, 71574.8], "Electron affinity": -0.02 }, Zn: { "Atomic mass": 65.409, "Atomic no": 30, "Atomic orbitals": { "1s": -344.969756, "2p": -36.648765, "2s": -41.531323, "3d": -0.398944, "3p": -3.022363, "3s": -4.573041, "4s": -0.222725 }, "Atomic radius": 1.35, "Atomic radius calculated": 1.42, "Boiling point": "1180 K", "Brinell hardness": "412 MN m<sup>-2</sup>", "Bulk modulus": "70 GPa", "Coefficient of linear thermal expansion": "30.2 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [2], "Critical temperature": "no data K", "Density of solid": "7140 kg m<sup>-3</sup>", "Electrical resistivity": "6.0 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Ar].3d<sup>10</sup>.4s<sup>2</sup>", "ICSD oxidation states": [2], "Ionic radii": { 2: 0.88 }, "Liquid range": "487.32 K", "Melting point": "692.68 K", "Mendeleev no": 76, "Mineral hardness": "2.5", "Molar volume": "9.16 cm<sup>3</sup>", Name: "Zinc", "Oxidation states": [1, 2], "Poissons ratio": "0.25", Reflectivity: "80 %", "Refractive index": "1.002050", "Rigidity modulus": "43 GPa", "Shannon radii": { 2: { IV: { "": { crystal_radius: 0.74, ionic_radius: 0.6 } }, V: { "": { crystal_radius: 0.82, ionic_radius: 0.68 } }, VI: { "": { crystal_radius: 0.88, ionic_radius: 0.74 } }, VIII: { "": { crystal_radius: 1.04, ionic_radius: 0.9 } } } }, "Superconduction temperature": "0.85 K", "Thermal conductivity": "120 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.01, "Velocity of sound": "3700 m s<sup>-1</sup>", "Vickers hardness": "no data MN m<sup>-2</sup>", X: 1.65, "Youngs modulus": "108 GPa", "NMR Quadrupole Moment": { "Zn-67": 150.15 }, "Metallic radius": 1.34, iupac_ordering: 76, "IUPAC ordering": 76, "Ground level": "1S0", "Ionization energies": [9.394197, 17.96439, 39.7233, 59.573, 82.6, 108, 133.9, 173.9, 203, 238, 274.4, 310.8, 417.6, 453.4, 490.6, 540, 577.8, 613.3, 697.5, 737.366, 1846.8, 1961, 2085, 2214, 2358, 2491.5, 2669.9, 2781.996, 11864.9399, 12388.929], "Electron affinity": -0.62 }, Zr: { "Atomic mass": 91.224, "Atomic no": 40, "Atomic orbitals": { "1s": -639.292236, "2p": -80.010043, "2s": -87.237062, "3d": -6.544643, "3p": -11.514415, "3s": -14.230432, "4d": -0.150673, "4p": -1.186597, "4s": -1.918971, "5s": -0.162391 }, "Atomic radius": 1.55, "Atomic radius calculated": 2.06, "Boiling point": "4682 K", "Brinell hardness": "650 MN m<sup>-2</sup>", "Bulk modulus": "no data GPa", "Coefficient of linear thermal expansion": "5.7 x10<sup>-6</sup>K<sup>-1</sup>", "Common oxidation states": [4], "Critical temperature": "no data K", "Density of solid": "6511 kg m<sup>-3</sup>", "Electrical resistivity": "43.3 10<sup>-8</sup> &Omega; m", "Electronic structure": "[Kr].4d<sup>2</sup>.5s<sup>2</sup>", "ICSD oxidation states": [2, 3, 4], "Ionic radii": { 4: 0.86 }, "Liquid range": "2554 K", "Melting point": "2128 K", "Mendeleev no": 49, "Mineral hardness": "5.0", "Molar volume": "14.02 cm<sup>3</sup>", Name: "Zirconium", "Oxidation states": [1, 2, 3, 4], "Poissons ratio": "0.34", Reflectivity: "no data %", "Refractive index": "no data", "Rigidity modulus": "33 GPa", "Shannon radii": { 4: { IV: { "": { crystal_radius: 0.73, ionic_radius: 0.59 } }, V: { "": { crystal_radius: 0.8, ionic_radius: 0.66 } }, VI: { "": { crystal_radius: 0.86, ionic_radius: 0.72 } }, VII: { "": { crystal_radius: 0.92, ionic_radius: 0.78 } }, VIII: { "": { crystal_radius: 0.98, ionic_radius: 0.84 } }, IX: { "": { crystal_radius: 1.03, ionic_radius: 0.89 } } } }, "Superconduction temperature": "0.61 K", "Thermal conductivity": "23 W m<sup>-1</sup> K<sup>-1</sup>", "Van der waals radius": 2.23, "Velocity of sound": "3800 m s<sup>-1</sup>", "Vickers hardness": "903 MN m<sup>-2</sup>", X: 1.33, "Youngs modulus": "68 GPa", "Metallic radius": 1.602, iupac_ordering: 51, "IUPAC ordering": 51, "Ground level": "3F2", "Ionization energies": [6.634126, 13.13, 23.17, 34.41836, 80.348, 96.38, 112, 133.7, 153, 172.02, 214.9, 236.252, 426, 470, 520, 573, 622, 690, 745, 803, 863, 922, 1092, 1144.7, 1205.4, 1277, 1344, 1392, 1525.1, 1582.37, 3788, 3950, 4127, 4300, 4553, 4744, 4991, 5146.935, 21516.469, 22236.678], "Electron affinity": 0.433289 }, Rf: { "Atomic mass": 267, "Atomic no": 104, Name: "Rutherfordium", "Ground level": "3F2", "Ionization energies": [6.02, 14.35, 23.84, 31.87, 64, 77, 102, 119, 146.1, 169, 193, 225, 244, 275, null, 791, 825, 860, 899, 936, 972, 1036, 1073, 1114, 1151, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 3857, 3938, 4025, 4116, 4203, 4287, 4489, 4580, 4670, 4760, 5130, 5210, 5300, 5390, 6100, 6200, 6470, 6570, 10170, 10360, 10560, 10780, 10980, 11180, 11750, 11960, 12200, 12410, 13010, 13190, 13400, 13600, 15800, 16e3, 16400, 16700, 33100, 33600, 34100, 34600, 42700, 43400, 44300, null, null, 177148], "Electron affinity": null, "Van der waals radius": "no data" }, Db: { "Atomic mass": 268, "Atomic no": 105, Name: "Dubnium", "Ground level": "4F3/2", "Ionization energies": [6.8, 14, 23.1, 33, 43, 86, 98.9, 126, 145.1, 172, 196, 220.9, 254, 274, 307, null, 838, 872, 908, 948, 985, 1022, 1089, 1126, 1168, 1207, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 3975, 4057, 4145, 4237, 4326, 4411, 4620, 4710, 4810, 4900, 5260, 5350, 5450, 5530, 6280, 6380, 6650, 6760, 10420, 10610, 10820, 11040, 11240, 11440, 12040, 12250, 12480, 12700, 13300, 13500, 13700, 13900, 16200, 16400, 16900, 17100, 33800, 34300, 34800, 35300, 43800, 44500, 45400, null, null, 181444], "Electron affinity": null, "Van der waals radius": "no data" }, Sg: { "Atomic mass": 269, "Atomic no": 106, Name: "Seaborgium", "Ground level": "0", "Ionization energies": [7.8, 17.1, 25.8, 35.5, 47.2, 59.3, 109, 122, 152, 170, 200, 224, 251, 285, 306, 339, null, 885, 921, 958, 998, 1036, 1073, 1143, 1181, 1223, 1263, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 4095, 4178, 4267, 4360, 4450, 4540, 4750, 4840, 4940, 5030, 5410, 5490, 5590, 5680, 6460, 6570, 6840, 6950, 10680, 10870, 11080, 11300, 11510, 11710, 12320, 12540, 12780, 12990, 13600, 13800, 14e3, 14200, 16600, 16800, 17300, 17500, 34500, 35e3, 35600, 36100, 44900, 45700, 46600, null, null, 185839], "Electron affinity": null, "Van der waals radius": "no data" }, Bh: { "Atomic mass": 270, "Atomic no": 107, Name: "Bohrium", "Ground level": "5/2", "Ionization energies": [7.7, 17.5, 26.7, 37.3, 49, 62.1, 74.9, 134, 148, 178, 198, 228, 255, 281, 318, 337, 374, null, 934, 969, 1008, 1049, 1088, 1126, 1197, 1237, 1280, 1320, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 4216, 4301, 4390, 4486, 4580, 4660, 4890, 4980, 5080, 5170, 5550, 5640, 5740, 5830, 6650, 6760, 7040, 7140, 10930, 11130, 11340, 11560, 11780, 11980, 12610, 12830, 13070, 13300, 13900, 14100, 14300, 14500, 17e3, 17300, 17700, 18e3, 35200, 35700, 36300, 36800, 46100, 46900, 47800, null, null, 190331], "Electron affinity": null, "Van der waals radius": "no data" }, Hs: { "Atomic mass": 270, "Atomic no": 108, Name: "Hassium", "Ground level": "4", "Ionization energies": [7.6, 18.2, 29.3, 37.7, 51.2, 64, 78.1, 91.7, 159.9, 173.9, 206.1, 227, 258, 285, 314, 351, 371, 409, null, 984, 1020, 1060, 1101, 1140, 1180, 1253, 1294, 1338, 1379, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 4339, 4425, 4516, 4610, 4700, 4790, 5020, 5110, 5220, 5310, 5700, 5780, 5880, 5980, 6840, 6950, 7230, 7340, 11200, 11390, 11610, 11830, 12040, 12250, 12910, 13130, 13400, 13600, 14200, 14400, 14600, 14800, 17500, 17700, 18200, 18400, 35900, 36400, 37e3, 37500, 47300, 48100, 49e3, null, null, 194917], "Electron affinity": null, "Van der waals radius": "no data" }, Mt: { "Atomic mass": 278, "Atomic no": 109, Name: "Meitnerium", "Ground level": null, "Ionization energies": [50, null, null, 94, 109, 187, 202, 235.9, 257, 289, 318, 346, 386, 406, 445, null, 1035, 1072, 1112, 1154, 1195, 1234, 1311, 1352, 1397, 1439, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 4464, 4551, 4640, 4740, 4830, 4920, 5160, 5250, 5360, 5450, 5840, 5930, 6030, 6130, 7030, 7150, 7430, 7550, 11460, 11660, 11870, 12100, 12320, 12530, 13200, 13400, 13700, 13900, 14500, 14700, 14900, 15100, 17900, 18200, 18700, 18900, 36700, 37200, 37800, 38300, 48500, 49400, 50300, null, null, 199606], "Electron affinity": null, "Van der waals radius": "no data" }, Ds: { "Atomic mass": 281, "Atomic no": 110, Name: "Darmstadtium", "Ground level": null, "Ionization energies": [65, null, null, 112.9, 128, 216, 231, 266, 288, 322, 352, 380, 422, 442, 483, null, 1087, 1125, 1165, 1208, 1250, 1290, 1369, 1412, 1457, 1500, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 4590, 4680, 4770, 4870, 4960, 5060, 5300, 5400, 5500, 5600, 5990, 6080, 6190, 6280, 7230, 7350, 7640, 7750, 11730, 11930, 12140, 12380, 12600, 12810, 13500, 13700, 14e3, 14200, 14800, 15e3, 15300, 15500, 18400, 18600, 19100, 19400, 37400, 37900, 38500, 39100, 49800, 50700, 51600, null, null, 204400], "Electron affinity": null, "Van der waals radius": "no data" }, Rg: { "Atomic mass": 282, "Atomic no": 111, Name: "Roentgenium", "Ground level": null, "Ionization energies": [], "Electron affinity": 1.565, "Van der waals radius": "no data" }, Cn: { "Atomic mass": 285, "Atomic no": 112, Name: "Copernicium", "Ground level": null, "Ionization energies": [], "Electron affinity": null, "Van der waals radius": "no data" }, Nh: { "Atomic mass": 286, "Atomic no": 113, Name: "Nihonium", "Ground level": null, "Ionization energies": [], "Electron affinity": 0.69, "Van der waals radius": "no data" }, Fl: { "Atomic mass": 289, "Atomic no": 114, Name: "Flerovium", "Ground level": null, "Ionization energies": [], "Electron affinity": null, "Van der waals radius": "no data" }, Mc: { "Atomic mass": 290, "Atomic no": 115, Name: "Moscovium", "Ground level": null, "Ionization energies": [], "Electron affinity": 0.366, "Van der waals radius": "no data" }, Lv: { "Atomic mass": 293, "Atomic no": 116, Name: "Livermorium", "Ground level": null, "Ionization energies": [], "Electron affinity": 0.776, "Van der waals radius": "no data" }, Ts: { "Atomic mass": 294, "Atomic no": 117, Name: "Tennessine", "Ground level": null, "Ionization energies": [], "Electron affinity": 1.719, "Van der waals radius": "no data" }, Og: { "Atomic mass": 2949, "Atomic no": 118, Name: "Oganesson", "Ground level": null, "Ionization energies": [], "Electron affinity": 0.0561, "Van der waals radius": "no data" } }).forEach(function(e) {
  var t = e[0], r = e[1];
  WP[r["Atomic no"]] = R(R({}, r), { symbol: t });
}), function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "material";
  }, e.create = function(t) {
    return { kind: "material", name: "material", data: t };
  }, e.formatMol = function(t) {
    var r = t.isMaterial, n = t.molecules;
    if (!r || n.length > 1 || !n[0].cell) return t;
    for (var i = n[0], a = i.cell, o = i.x, u = i.y, s = i.z, c = o.rowCount, l = new Float32Array(c), d = new Float32Array(c), f = new Float32Array(c), m = 0; m < c; m++) {
      var v = w.create(o.value(m), u.value(m), s.value(m)), p = w.transformMat4(w.zero(), v, a.invertMatrix);
      l[m] = p[0], d[m] = p[1], f[m] = p[2];
    }
    return { isMaterial: !0, molecules: [R(R({}, n[0]), { fractX: oe.ofFloatArray(l), fractY: oe.ofFloatArray(d), fractZ: oe.ofFloatArray(f) })] };
  };
}(J2 || (J2 = {}));
var h6, q$ = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    var t;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, $_(e).run()];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, dd(t.result).run()];
        case 2:
          return [2, r.sent().frames.map(function(n) {
            return tt.ofModel(n, { dynamicBonds: !0 });
          })];
      }
    });
  });
} };
function K$(e) {
  var t = e.position >= e.data.length - 1 ? 0 : +ot.readLine(e);
  isNaN(t) && (t = 0);
  for (var r = ot.readLine(e), n = new Float64Array(t), i = new Float64Array(t), a = new Float64Array(t), o = new Array(t), u = 0; u < t; ++u) {
    var s = ot.readLineTrim(e).split(/\s+/g);
    o[u] = s[0], n[u] = +s[1], i[u] = +s[2], a[u] = +s[3];
  }
  return { count: t, comment: r, x: oe.ofFloatArray(n), y: oe.ofFloatArray(i), z: oe.ofFloatArray(a), type_symbol: oe.ofStringArray(o) };
}
function X$(e) {
  for (var t = ot(e), r = []; ; ) {
    var n = K$(t);
    if (n.count === 0) break;
    r.push(n);
  }
  var i = { molecules: r, isMaterial: !1 };
  return Pi.success(i);
}
function ZP(e) {
  var t = this;
  return er.create("Parse Mol", function() {
    return _e(t, 0, void 0, function() {
      return ye(this, function(r) {
        return [2, X$(e)];
      });
    });
  });
}
function QP(e) {
  return er.create("Parse XYZ", function(t) {
    return function(r, n) {
      for (var i = r.molecules, a = 0, o = 0, u = i; o < u.length; o++) a += (g = u[o]).count;
      for (var s = new Array(a), c = new Int32Array(a), l = new Float32Array(a), d = new Float32Array(a), f = new Float32Array(a), m = new Int32Array(a), v = 0, p = 0; p < i.length; p++) for (var g = i[p], h = 0; h < g.count; h++) s[v] = g.type_symbol.value(h), l[v] = g.x.value(h), d[v] = g.y.value(h), f[v] = g.z.value(h), c[v] = h, m[v] = p, v++;
      var y = oe.ofConst("MOL", a, oe.Schema.str), x = oe.ofConst("A", a, oe.Schema.str), A = oe.ofConst(1, a, oe.Schema.int), b = oe.ofStringArray(s), _ = Or.ofPartialColumns(_o.atom_site, { auth_asym_id: x, auth_atom_id: b, auth_comp_id: y, auth_seq_id: A, Cartn_x: oe.ofFloatArray(l), Cartn_y: oe.ofFloatArray(d), Cartn_z: oe.ofFloatArray(f), id: oe.ofIntArray(c), label_asym_id: x, label_atom_id: b, label_comp_id: y, label_seq_id: A, label_entity_id: oe.ofConst("1", a, oe.Schema.str), occupancy: oe.ofConst(1, a, oe.Schema.float), type_symbol: b, pdbx_PDB_model_num: oe.ofIntArray(m) }, a), S = new wf();
      S.setNames([["MOL", "Unknown Entity"]]), S.getEntityId("MOL", 0, "A");
      var D = new Cf(A, b);
      return D.setNames([["MOL", "Unknown Molecule"]]), D.add("MOL", 0), Oc(ld({ entity: S.getEntityTable(), chem_comp: D.getChemCompTable(), atom_site: _ }), h6.create(r), n);
    }(e, t);
  });
}
(function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "xyz";
  }, e.create = function(t) {
    return { kind: "xyz", name: "xyz", data: t };
  };
})(h6 || (h6 = {}));
var Fp, j$ = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    var t, r;
    return ye(this, function(n) {
      switch (n.label) {
        case 0:
          return e.trim() ? [4, ZP(e).run()] : [2, [zs()]];
        case 1:
          if ((t = n.sent()).isError) throw t;
          return [4, QP(t.result).run()];
        case 2:
          return r = n.sent(), [2, [tt.ofModel(r.representative, { dynamicBonds: !0 })]];
      }
    });
  });
} };
function Y$(e, t, r) {
  var n;
  return _e(this, 0, void 0, function() {
    var i, a, o, u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _, S, D, I, M, F, P, E, B, N, O, z, V, U, H, K, j, X, W, Q, te, ee, $, ie, ae, se, le, pe, we, Ge, Ue, Ke, Ze;
    return ye(this, function(Fe) {
      switch (Fe.label) {
        case 0:
          for (i = e.atom_site._rowCount, a = oe.ofConst("MOL", i, oe.Schema.str), o = oe.ofConst("A", i, oe.Schema.str), u = oe.ofConst(1, i, oe.Schema.int), s = function(Je) {
            var Ne = Je.cell, nt = (J = Je.space_group, ce = J.it_number.value(0), de = J["name_h-m_full"].value(0).replace("-", " "), J.it_number.isDefined ? (J["name_h-m_full"].isDefined, ce) : de), re = Tu.create(nt, w.create(Ne.length_a.value(0), Ne.length_b.value(0), Ne.length_c.value(0)), w.scale(w(), w.create(Ne.angle_alpha.value(0), Ne.angle_beta.value(0), Ne.angle_gamma.value(0)), Math.PI / 180)), J, ce, de;
            return { spacegroup: ho.create(re), assemblies: [], isNonStandardCrystalFrame: !1, ncsOperators: [] };
          }(e), c = s.spacegroup.cell.fromFractional, l = e.atom_site, d = l.fract_x, f = l.fract_y, m = l.fract_z, v = new Float32Array(i), p = new Float32Array(i), g = new Float32Array(i), h = w(), we = 0; we < i; ++we) w.set(h, d.value(we), f.value(we), m.value(we)), w.transformMat4(h, h, c), v[we] = h[0], p[we] = h[1], g[we] = h[2];
          if (y = e.atom_site, x = y.type_symbol, A = y.label, x.isDefined) {
            for (M = new Array(i), S = new Int8Array(i), we = 0; we < i; ++we) D = x.value(we), I = D.length, D[I - 1] === "+" ? S[we] = parseInt(D[I - 2]) : D[I - 2] === "+" ? S[we] = parseInt(D[I - 1]) : D[I - 1] === "-" ? S[we] = -parseInt(D[I - 2]) : D[I - 2] === "-" ? S[we] = -parseInt(D[I - 1]) : (M[we] = D, S[we] = 0), D = (D = (D = D.replace(/\-/g, "")).replace(/\+/g, "")).replace(/[0-9]/g, ""), M[we] = D;
            b = oe.ofStringArray(M), _ = oe.ofIntArray(S);
          } else {
            for (M = new Array(i), we = 0; we < i; ++we) M[we] = j_(A.value(we), "");
            b = oe.ofStringArray(M), _ = oe.Undefined(i, oe.Schema.int);
          }
          return F = Or.ofPartialColumns(_o.atom_site, { auth_asym_id: o, auth_atom_id: A, auth_comp_id: a, auth_seq_id: u, Cartn_x: oe.ofFloatArray(v), Cartn_y: oe.ofFloatArray(p), Cartn_z: oe.ofFloatArray(g), id: oe.range(0, i - 1), label_asym_id: o, label_atom_id: A, label_comp_id: a, label_seq_id: u, label_entity_id: oe.ofConst("1", i, oe.Schema.str), occupancy: e.atom_site.occupancy.isDefined ? e.atom_site.occupancy : oe.ofConst(1, i, oe.Schema.float), type_symbol: b, pdbx_formal_charge: _, pdbx_PDB_model_num: oe.ofConst(1, i, oe.Schema.int), B_iso_or_equiv: e.atom_site.u_iso_or_equiv }, i), P = e.chemical.name_common.value(0) || e.chemical.name_systematic.value(0) || e.chemical_formula.sum.value(0), (E = new wf()).setNames([["MOL", P || "Ligand"]]), E.getEntityId("MOL", 0, "A"), (B = new Cf(u, e.atom_site.type_symbol)).setNames([["MOL", P || "Unknown Molecule"]]), B.add("MOL", 0), [4, Oc(ld({ entity: E.getEntityTable(), chem_comp: B.getChemCompTable(), atom_site: F }), t, r)];
        case 1:
          if ((N = Fe.sent()).frameCount > 0 && (O = N.representative, ia.Provider.set(O, s), (z = e.geom_bond._rowCount) > 0)) {
            for (V = {}, U = e.atom_site.label, we = 0, H = U.rowCount; we < H; ++we) V[U.value(we)] = we;
            for (K = (n = t.data.frame.categories.ccdc_geom_bond_type) === null || n === void 0 ? void 0 : n.getField(""), j = [], X = [], W = [], Q = [], te = [], ee = /* @__PURE__ */ new Set(), $ = 0, ie = e.geom_bond, ae = ie.atom_site_label_1, se = ie.atom_site_label_2, le = ie.valence, pe = ie.distance, we = 0; we < z; ++we) Ge = V[ae.value(we)], Ue = V[se.value(we)], Ke = Ge < Ue ? Mu(Ge, Ue) : Mu(Ue, Ge), ee.has(Ke) || (ee.add(Ke), j[$] = Ge, X[$] = Ue, Q[$] = pe.value(we) || -1, K ? (Ze = K.str(we)) === "D" ? (W[$] = 2, te[$] = 1) : Ze === "A" ? (W[$] = 1, te[$] = 17) : (W[$] = 1, te[$] = 1) : (te[$] = 1, W[$] = le.isDefined ? le.value(we) : 1), $ += 1);
            Ei.Provider.set(O, Ei.fromData({ pairs: { indexA: oe.ofIntArray(j), indexB: oe.ofIntArray(X), order: oe.ofIntArray(W), distance: oe.ofFloatArray(Q), flag: oe.ofIntArray(te) }, count: i }));
          }
          return [2, N];
      }
    });
  });
}
function W$(e) {
  var t = Fp.fromFrame(e);
  return er.create("Parse CIF Core", function(r) {
    return Y$(t.data.db, t, r);
  });
}
Ql.Provider.formatRegistry.add("cifCore", function(e) {
  if (Fp.is(e.sourceData)) {
    var t = e.sourceData.data.db, r = t.atom_site, n = t.atom_site_aniso;
    return { data: Or.ofPartialColumns(Ql.Schema, { U: n.u }, n._rowCount), elementToAnsiotrop: Ql.getElementToAnsiotropFromLabel(r.label, n.label) };
  }
}, function(e) {
  return !!Fp.is(e.sourceData) && e.sourceData.data.db.atom_site_aniso.u.isDefined;
}), function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "cifCore";
  }, e.fromFrame = function(t, r) {
    return r || (r = dT.cifCore(t)), { kind: "cifCore", name: r.database_code.depnum_ccdc_archive.value(0) || r.database_code.depnum_ccdc_fiz.value(0) || r.database_code.icsd.value(0) || r.database_code.mdf.value(0) || r.database_code.nbs.value(0) || r.database_code.csd.value(0) || r.database_code.cod.value(0) || r._name, data: { db: r, frame: t } };
  };
}(Fp || (Fp = {}));
var Z$ = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    var t, r, n, i, a, o, u;
    return ye(this, function(s) {
      switch (s.label) {
        case 0:
          return e.trim() ? [4, lT(e).run()] : [2, [zs()]];
        case 1:
          if ((t = s.sent()).isError) throw t;
          r = function(c) {
            return c.startsWith(`data_SERVER
#
_density_server_result`) ? "dscif" : c.startsWith(`data_SERVER
#
data_SEGMENTATION_DATA`) ? "segcif" : c.includes("atom_site_fract_x") || c.includes("atom_site.fract_x") ? "coreCif" : -1;
          }(e) === -1 ? pT : W$, n = [], i = 0, a = t.result.blocks.length, s.label = 2;
        case 2:
          return i < a ? (o = t.result.blocks[i], [4, r(o).run()]) : [3, 5];
        case 3:
          u = s.sent(), n.push(tt.ofModel(u.frames[0], { dynamicBonds: !0 })), s.label = 4;
        case 4:
          return i++, [3, 2];
        case 5:
          return [2, n];
      }
    });
  });
} }, Gw = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    var t, r, n, i, a;
    return ye(this, function(o) {
      switch (o.label) {
        case 0:
          return e.trim() ? [4, lT(e).run()] : [2, [zs()]];
        case 1:
          if ((t = o.sent()).isError) throw t;
          r = [], n = 0, i = t.result.blocks.length, o.label = 2;
        case 2:
          return n < i ? [4, pT(t.result.blocks[n]).run()] : [3, 5];
        case 3:
          a = o.sent(), r.push(tt.ofModel(a.frames[0], { dynamicBonds: !0 })), o.label = 4;
        case 4:
          return n++, [3, 2];
        case 5:
          return [2, r];
      }
    });
  });
} };
function Q$(e) {
  var t = [], r = function(i) {
    var a = ot.readLine(i), o = +ot.readLine(i), u = new Float64Array(3), s = new Float64Array(3), c = new Float64Array(3);
    [u, s, c].forEach(function(N) {
      var O = ot.readLineTrim(i).trim().split(/\s+/g);
      N[0] = +O[0], N[1] = +O[1], N[2] = +O[2];
    });
    for (var l = YP(u, s, c), d = ot.readLineTrim(i).trim().split(/\s+/g), f = ot.readLineTrim(i).trim().split(/\s+/g), m = ot.readLineTrim(i), v = ["cartesian", "direct"].includes(m.toLowerCase()) ? "cartesian" : m, p = f.reduce(function(N, O) {
      return +N + +O;
    }, 0), g = new Float64Array(p), h = new Float64Array(p), y = new Float64Array(p), x = new Float64Array(p), A = new Float64Array(p), b = new Float64Array(p), _ = new Float64Array(p), S = new Float64Array(p), D = new Float64Array(p), I = new Array(p), M = function(N) {
      for (var O = N === 0 ? 0 : f.slice(0, N).reduce(function(H, K) {
        return +H + +K;
      }, 0), z = 0; z < Number(f[N]); z++) {
        var V = O + z, U = ot.readLineTrim(i).trim().split(/\s+/g);
        I[V] = d[N], _[V] = +U[0], S[V] = +U[1], D[V] = +U[2];
      }
    }, F = 0; F < f.length; F++) M(F);
    if (v === "cartesian") for (F = 0; F < p; F++) {
      g[F] = _[F], h[F] = S[F], y[F] = D[F];
      var P = w.create(g[F], h[F], y[F]), E = w.transformMat4(w.zero(), P, l.invertMatrix);
      x[F] = E[0], A[F] = E[1], b[F] = E[2];
    }
    else for (F = 0; F < p; F++) {
      x[F] = _[F], A[F] = S[F], b[F] = D[F];
      var B = w.create(g[F], h[F], y[F]);
      E = w.transformMat4(w.zero(), B, l.matrix), g[F] = E[0], h[F] = E[1], y[F] = E[2];
    }
    return { count: p, comment: a, scalingFactor: o, dynamics: v, type_symbol: oe.ofStringArray(I), x: oe.ofFloatArray(g), y: oe.ofFloatArray(h), z: oe.ofFloatArray(y), fractX: oe.ofFloatArray(g), fractY: oe.ofFloatArray(h), fractZ: oe.ofFloatArray(y), cell: l };
  }(ot(e));
  t.push(r);
  var n = { isMaterial: !0, molecules: t };
  return Pi.success(n);
}
function J$(e) {
  var t = this;
  return er.create("Parse Mol", function() {
    return _e(t, 0, void 0, function() {
      return ye(this, function(r) {
        return [2, Q$(e)];
      });
    });
  });
}
var $$ = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    var t;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return e.trim() ? [4, J$(e).run()] : [2, [zs()]];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, dd(t.result).run()];
        case 2:
          return [2, r.sent().frames.map(function(n) {
            return tt.ofModel(n, { dynamicBonds: !0 });
          })];
      }
    });
  });
} };
function eee(e) {
  var t = [], r = function(n, i, a) {
    for (var o = function() {
      if (a) return jP(a.a, a.b, a.c, a.alpha, a.beta, a.gamma);
    }(), u = n.length, s = new Float64Array(u), c = new Float64Array(u), l = new Float64Array(u), d = new Array(u), f = 0; f < u; f++) d[f] = n[f], s[f] = i[f][0], c[f] = i[f][1], l[f] = i[f][2];
    return { count: u, comment: "", type_symbol: oe.ofStringArray(d), x: oe.ofFloatArray(s), y: oe.ofFloatArray(c), z: oe.ofFloatArray(l), cell: o };
  }(e.elements, e.xyzs, e.lattice);
  return t.push(r), { isMaterial: !0, molecules: t };
}
function JP(e) {
  return eee(e);
}
var tee = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(t) {
      switch (t.label) {
        case 0:
          return [4, dd(JP(e)).run()];
        case 1:
          return [2, t.sent().frames.map(function(r) {
            return tt.ofModel(r, { dynamicBonds: !0 });
          })];
      }
    });
  });
} }, Np = function(e, t, r, n) {
  this.name = e, this.visible = t, this.origin = r, this.contents = n;
};
(function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  ga(t, e);
})(Np), function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  ga(t, e);
}(Np), function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  ga(t, e);
}(Np), function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  ga(t, e);
}(Np);
var ree = function(e) {
  function t() {
    return e !== null && e.apply(this, arguments) || this;
  }
  return ga(t, e), t.create = function(r) {
    var n = r.name, i = r.visible, a = r.origin, o = r.contents, u = {};
    return o.forEach(function(s) {
      Reflect.defineProperty(u, s.name, { value: s });
    }), new t(n, i, a, u);
  }, t;
}(Np);
function nee(e) {
  var t = e.scene, r = e.structure, n = ree.create(t).contents, i = n.atoms, a = n.bonds, o = i.contents.length, u = new Float64Array(o), s = new Float64Array(o), c = new Float64Array(o), l = new Array(o), d = function() {
    if (r.lattice) {
      var h = r.lattice;
      return jP(h.a, h.b, h.c, h.alpha, h.beta, h.gamma);
    }
  }(), f = {};
  a.contents.forEach(function(h) {
    h.positionPairs.forEach(function(y) {
      var x = y[1].join(",");
      f[x] = f[x] || [], f[x].push(y[0]);
    });
  });
  var m = {};
  i.contents.forEach(function(h, y) {
    var x, A = h.positions, b = h.tooltip, _ = A[0];
    for (var S in u[y] = _[0], s[y] = _[1], c[y] = _[2], l[y] = ((x = b.split(/\s/)[0].match(/[A-Za-z]/g)) === null || x === void 0 ? void 0 : x.join("")) || "", f) {
      var D = f[S];
      m[S] = m[S] || [], D[0].every(function(I, M) {
        return I === _[M];
      }) && (m[S][0] = y), D[1].every(function(I, M) {
        return I === _[M];
      }) && (m[S][1] = y);
    }
  });
  var v = [], p = [];
  Object.values(m).forEach(function(h) {
    v.push(h[0]), p.push(h[1]);
  });
  var g = { count: 2 * v.length, atomA: We(We([], v, !0), p, !0), atomB: We(We([], p, !0), v, !0) };
  return { comment: "", count: o, x: oe.ofFloatArray(u), y: oe.ofFloatArray(s), z: oe.ofFloatArray(c), type_symbol: oe.ofStringArray(l), cell: d, bonds: g };
}
function iee(e) {
  var t = { molecules: e.map(nee), isMaterial: !0 };
  return Pi.success(t);
}
function $P(e) {
  var t = this;
  return er.create("Parse Mol", function() {
    return _e(t, 0, void 0, function() {
      return ye(this, function(r) {
        return [2, iee(e)];
      });
    });
  });
}
var aee = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    var t;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, $P(e).run()];
        case 1:
          if ((t = r.sent()).isError) throw new Error(t.message);
          return [4, dd(t.result).run()];
        case 2:
          return [2, r.sent().frames.map(function(n) {
            return tt.ofModel(n, { dynamicBonds: !0 });
          })];
      }
    });
  });
} }, e8 = ot.skipWhitespace, eB = ot.eatValue, gu = ot.markLine, yu = ot.getTokenString, tB = ot.readLine, v6, Vw = /\s+/g;
function oee(e) {
  return _e(this, 0, void 0, function() {
    var t, r, n, i, a, o, u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _;
    return ye(this, function(S) {
      switch (S.label) {
        case 0:
          for (t = e.tokenizer, r = e.molecule; yu(t) !== "@<TRIPOS>ATOM" && t.position < t.data.length; ) gu(t);
          return n = t.position, i = t.lineNumber, a = tB(t), o = a.trim().split(/\s+/g), u = o.length, s = ct.create(t.data, 2 * r.num_atoms), c = ct.create(t.data, 2 * r.num_atoms), l = ct.create(t.data, 2 * r.num_atoms), d = ct.create(t.data, 2 * r.num_atoms), f = ct.create(t.data, 2 * r.num_atoms), m = ct.create(t.data, 2 * r.num_atoms), v = ct.create(t.data, 2 * r.num_atoms), p = ct.create(t.data, 2 * r.num_atoms), g = ct.create(t.data, 2 * r.num_atoms), h = ct.create(t.data, 2 * r.num_atoms), y = oe.Undefined(r.num_atoms, oe.Schema.float), x = oe.Undefined(r.num_atoms, oe.Schema.int), A = oe.Undefined(r.num_atoms, oe.Schema.str), t.position = n, t.lineNumber = i, b = t.length, _ = 0, [4, $p(e.runtimeCtx, 1e5, void 0, function(D) {
            for (var I = Math.min(r.num_atoms - _, D), M = 0; M < I; M++) for (var F = 0; F < u; F++) switch (e8(t), t.tokenStart = t.position, eB(t), F) {
              case 0:
                ct.addUnchecked(s, t.tokenStart, t.tokenEnd);
                break;
              case 1:
                ct.addUnchecked(c, t.tokenStart, t.tokenEnd);
                break;
              case 2:
                ct.addUnchecked(l, t.tokenStart, t.tokenEnd);
                break;
              case 3:
                ct.addUnchecked(d, t.tokenStart, t.tokenEnd);
                break;
              case 4:
                ct.addUnchecked(f, t.tokenStart, t.tokenEnd);
                break;
              case 5:
                ct.addUnchecked(m, t.tokenStart, t.tokenEnd);
                break;
              case 6:
                ct.addUnchecked(v, t.tokenStart, t.tokenEnd);
                break;
              case 7:
                ct.addUnchecked(p, t.tokenStart, t.tokenEnd);
                break;
              case 8:
                ct.addUnchecked(g, t.tokenStart, t.tokenEnd);
                break;
              case 9:
                ct.addUnchecked(h, t.tokenStart, t.tokenEnd);
            }
            return _ += I, I;
          }, function(D) {
            return D.update({ message: "Parsing...", current: t.position, max: b });
          })];
        case 1:
          return S.sent(), [2, { count: r.num_atoms, atom_id: Gr(s)(oe.Schema.int), atom_name: Gr(c)(oe.Schema.str), x: Gr(l)(oe.Schema.float), y: Gr(d)(oe.Schema.float), z: Gr(f)(oe.Schema.float), atom_type: u > 5 ? Gr(m)(oe.Schema.str) : A, subst_id: u > 6 ? Gr(v)(oe.Schema.int) : x, subst_name: u > 7 ? Gr(p)(oe.Schema.str) : A, charge: u > 8 ? Gr(g)(oe.Schema.float) : y, status_bit: u > 9 ? Gr(h)(oe.Schema.str) : A }];
      }
    });
  });
}
function uee(e) {
  return _e(this, 0, void 0, function() {
    var t, r, n, i, a, o, u, s, c, l, d, f, m, v;
    return ye(this, function(p) {
      switch (p.label) {
        case 0:
          for (t = e.tokenizer, r = e.molecule; yu(t) !== "@<TRIPOS>BOND" && t.position < t.data.length; ) gu(t);
          return n = t.position, i = t.lineNumber, a = tB(t), o = a.trim().split(/\s+/g), u = o.length, s = ct.create(t.data, 2 * r.num_bonds), c = ct.create(t.data, 2 * r.num_bonds), l = ct.create(t.data, 2 * r.num_bonds), d = ct.create(t.data, 2 * r.num_bonds), f = ct.create(t.data, 2 * r.num_bonds), t.position = n, t.lineNumber = i, m = t.length, v = 0, [4, $p(e.runtimeCtx, 1e5, void 0, function(g) {
            for (var h = Math.min(r.num_bonds - v, g), y = 0; y < h; y++) for (var x = 0; x < u; x++) switch (e8(t), t.tokenStart = t.position, eB(t), x) {
              case 0:
                ct.addUnchecked(s, t.tokenStart, t.tokenEnd);
                break;
              case 1:
                ct.addUnchecked(c, t.tokenStart, t.tokenEnd);
                break;
              case 2:
                ct.addUnchecked(l, t.tokenStart, t.tokenEnd);
                break;
              case 3:
                ct.addUnchecked(d, t.tokenStart, t.tokenEnd);
                break;
              default:
                ct.addUnchecked(f, t.tokenStart, t.tokenEnd);
            }
            return v += h, h;
          }, function(g) {
            return g.update({ message: "Parsing...", current: t.position, max: m });
          })];
        case 1:
          return p.sent(), [2, { count: r.num_bonds, bond_id: Gr(s)(oe.Schema.int), origin_atom_id: Gr(c)(oe.Schema.int), target_atom_id: Gr(l)(oe.Schema.int), bond_type: Gr(d)(oe.Schema.str), status_bits: u > 4 ? Gr(f)(oe.Schema.str) : oe.Undefined(r.num_bonds, oe.Schema.str) }];
      }
    });
  });
}
function see(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o, u, s, c;
    return ye(this, function(l) {
      switch (l.label) {
        case 0:
          n = ot(t), e.update({ message: "Parsing...", current: 0, max: t.length }), i = [], l.label = 1;
        case 1:
          return n.position < t.length ? (a = /* @__PURE__ */ function(d, f) {
            return { tokenizer: d, molecule: { mol_name: "", num_atoms: 0, num_bonds: 0, num_subst: 0, num_feat: 0, num_sets: 0, mol_type: "", charge_type: "", status_bits: "", mol_comment: "" }, runtimeCtx: f };
          }(n, e), function(d) {
            for (var f = d.tokenizer, m = d.molecule; yu(f) !== "@<TRIPOS>MOLECULE" && f.position < f.data.length; ) gu(f);
            gu(f), m.mol_name = yu(f), gu(f);
            var v = yu(f).trim().split(Vw);
            m.num_atoms = parseInt(v[0]), m.num_bonds = parseInt(v[1]), m.num_subst = parseInt(v[2]), m.num_feat = parseInt(v[3]), m.num_sets = parseInt(v[4]), gu(f);
            var p = yu(f);
            if (!p.startsWith("@<TRIPOS>")) {
              m.mol_type = p, gu(f);
              var g = yu(f);
              if (!g.startsWith("@<TRIPOS>")) {
                m.charge_type = g, gu(f);
                var h = yu(f);
                if (!h.startsWith("@<TRIPOS>")) {
                  m.status_bits = h, gu(f);
                  var y = yu(f);
                  y.startsWith("@<TRIPOS>") || (m.mol_comment = y);
                }
              }
            }
          }(a), [4, oee(a)]) : [3, 4];
        case 2:
          return o = l.sent(), [4, uee(a)];
        case 3:
          for (u = l.sent(), s = function(d) {
            for (var f = d.tokenizer; f.position < f.data.length; ) {
              var m = yu(f);
              if (m === "@<TRIPOS>MOLECULE") return;
              if (m === "@<TRIPOS>CRYSIN") break;
              gu(f);
            }
            if (!(f.position >= f.data.length)) {
              gu(f);
              var v = yu(f).trim().split(Vw);
              return { a: parseFloat(v[0]), b: parseFloat(v[1]), c: parseFloat(v[2]), alpha: parseFloat(v[3]), beta: parseFloat(v[4]), gamma: parseFloat(v[5]), spaceGroup: parseInt(v[6], 10), setting: parseInt(v[7], 10) };
            }
          }(a), i.push({ molecule: a.molecule, atoms: o, bonds: u, crysin: s }), e8(n); yu(n) !== "@<TRIPOS>MOLECULE" && n.position < n.data.length; ) gu(n);
          return [3, 1];
        case 4:
          return c = { name: r, structures: i }, [2, Pi.success(c)];
      }
    });
  });
}
function cee(e, t) {
  var r = this;
  return er.create("Parse MOL2", function(n) {
    return _e(r, 0, void 0, function() {
      return ye(this, function(i) {
        switch (i.label) {
          case 0:
            return [4, see(n, e, t)];
          case 1:
            return [2, i.sent()];
        }
      });
    });
  });
}
function lee(e, t) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o, u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _, S, D, I, M, F, P;
    return ye(this, function(E) {
      switch (E.label) {
        case 0:
          r = [], n = 0, i = e.structures.length, E.label = 1;
        case 1:
          if (!(n < i)) return [3, 4];
          for (a = e.structures[n], o = a.molecule, u = a.atoms, s = a.bonds, c = a.crysin, l = oe.ofConst("A", u.count, oe.Schema.str), d = new Array(u.count), f = !1, m = 0; m < u.count; ++m) if (u.atom_type.value(m).includes(".")) {
            f = !0;
            break;
          }
          for (v = 0; v < u.count; ++v) d[v] = f ? u.atom_type.value(v).split(".")[0].toUpperCase() : j_(u.atom_name.value(v), u.subst_name.value(v));
          for (p = Or.ofPartialColumns(_o.atom_site, { auth_asym_id: l, auth_atom_id: oe.asArrayColumn(u.atom_name), auth_comp_id: u.subst_name, auth_seq_id: u.subst_id, Cartn_x: oe.asArrayColumn(u.x, Float32Array), Cartn_y: oe.asArrayColumn(u.y, Float32Array), Cartn_z: oe.asArrayColumn(u.z, Float32Array), id: oe.asArrayColumn(u.atom_id), label_asym_id: l, label_atom_id: oe.asArrayColumn(u.atom_name), label_comp_id: u.subst_name, label_seq_id: u.subst_id, label_entity_id: oe.ofConst("1", u.count, oe.Schema.str), occupancy: oe.ofConst(1, u.count, oe.Schema.float), type_symbol: oe.ofStringArray(d), pdbx_PDB_model_num: oe.ofConst(n, u.count, oe.Schema.int) }, u.count), (g = new wf()).setNames([["MOL", o.mol_name || "Ligand"]]), g.getEntityId("MOL", 0, "A"), h = new Cf(u.subst_id, u.atom_name), y = 0, x = u.subst_name.rowCount; y < x; ++y) h.add(u.subst_name.value(y), y);
          return [4, Oc(ld({ entity: g.getEntityTable(), chem_comp: h.getChemCompTable(), atom_site: p }), v6.create(e), t)];
        case 2:
          (A = E.sent()).frameCount > 0 && (b = oe.ofIntArray(oe.mapToArray(s.origin_atom_id, function(B) {
            return B - 1;
          }, Int32Array)), _ = oe.ofIntArray(oe.mapToArray(s.target_atom_id, function(B) {
            return B - 1;
          }, Int32Array)), S = s.bond_id, D = oe.ofIntArray(oe.mapToArray(s.bond_type, function(B) {
            switch (B) {
              case "ar":
              case "am":
              case "un":
                return 1;
              case "du":
              case "nc":
                return 0;
              default:
                return parseInt(B);
            }
          }, Int8Array)), I = oe.ofIntArray(oe.mapToArray(s.bond_type, function(B) {
            switch (B) {
              case "ar":
              case "am":
                return 17;
              case "du":
              case "nc":
                return 0;
              default:
                return 1;
            }
          }, Int8Array)), M = Ei.fromData({ pairs: { key: S, indexA: b, indexB: _, order: D, flag: I }, count: u.count }), F = A.representative, Ei.Provider.set(F, M), Pc.Provider.set(F, { data: u.charge, type: o.charge_type }), c && (P = function(B) {
            if (B.setting === 1) {
              var N = Tu.create(B.spaceGroup, w.create(B.a, B.b, B.c), w.scale(w(), w.create(B.alpha, B.beta, B.gamma), Math.PI / 180));
              return { spacegroup: ho.create(N), assemblies: [], isNonStandardCrystalFrame: !1, ncsOperators: [] };
            }
          }(c), P && ia.Provider.set(F, P)), r.push(F)), E.label = 3;
        case 3:
          return ++n, [3, 1];
        case 4:
          return [2, new am(r)];
      }
    });
  });
}
(function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "mol2";
  }, e.create = function(t) {
    return { kind: "mol2", name: t.name, data: t };
  };
})(v6 || (v6 = {}));
var Ka, dee = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    var t, r;
    return ye(this, function(n) {
      switch (n.label) {
        case 0:
          return e.trim() ? [4, cee(e, "").run()] : [2, [zs()]];
        case 1:
          if ((t = n.sent()).isError) throw t;
          return [4, (i = t.result, er.create("Parse MOL2", function(a) {
            return lee(i, a);
          })).run()];
        case 2:
          return r = n.sent(), [2, [tt.ofModel(r.representative, { dynamicBonds: !0 })]];
      }
      var i;
    });
  });
} }, Fc = ((Ka = {})[mr.Pdb] = p$, Ka[mr.Mol] = y$, Ka[mr.Sdf] = T$, Ka[mr.Gro] = R$, Ka[mr.Xtc] = G$, Ka[mr.Dump] = q$, Ka[mr.Xyz] = j$, Ka[mr.Cif] = Z$, Ka[mr.MMCif] = Gw, Ka[mr.MCif] = Gw, Ka[mr.POSCAR] = $$, Ka[mr.Material] = tee, Ka[mr.Pymatgen] = aee, Ka[mr.Mol2] = dee, Ka), Ot = k2.Const, Mt = k2.Dynamic, fee = [Ot(fe.core.type.bool, function(e, t) {
  return !!t[0](e);
}), Ot(fe.core.type.num, function(e, t) {
  return +t[0](e);
}), Ot(fe.core.type.str, function(e, t) {
  return "" + t[0](e);
}), Ot(fe.core.type.list, function(e, t) {
  return Xp.forEachEval(t, e, function(r, n, i) {
    return i[n] = r;
  }, []);
}), Ot(fe.core.type.set, function(e, t) {
  return Xp.forEachEval(t, e, function(r, n, i) {
    return i.add(r);
  }, /* @__PURE__ */ new Set());
}), Ot(fe.core.type.regex, function(e, t) {
  return new RegExp(t[0](e), t[1] && t[1](e) || "");
}), Ot(fe.core.type.bitflags, function(e, t) {
  return +t[0](e);
}), Ot(fe.core.type.compositeKey, function(e, t) {
  return Xp.forEachEval(t, e, function(r, n, i) {
    return i[n] = "" + r;
  }, []).join("-");
}), Ot(fe.core.logic.not, function(e, t) {
  return !t[0](e);
}), Ot(fe.core.logic.and, function(e, t) {
  if (typeof t.length == "number") {
    for (var r = 0, n = t.length; r < n; r++) if (!t[r](e)) return !1;
  } else for (var i = 0, a = Object.keys(t); i < a.length; i++)
    if (!t[a[i]](e)) return !1;
  return !0;
}), Ot(fe.core.logic.or, function(e, t) {
  if (typeof t.length == "number") {
    for (var r = 0, n = t.length; r < n; r++) if (t[r](e)) return !0;
  } else for (var i = 0, a = Object.keys(t); i < a.length; i++)
    if (t[a[i]](e)) return !0;
  return !1;
}), Ot(fe.core.rel.eq, function(e, t) {
  return t[0](e) === t[1](e);
}), Ot(fe.core.rel.neq, function(e, t) {
  return t[0](e) !== t[1](e);
}), Ot(fe.core.rel.lt, function(e, t) {
  return t[0](e) < t[1](e);
}), Ot(fe.core.rel.lte, function(e, t) {
  return t[0](e) <= t[1](e);
}), Ot(fe.core.rel.gr, function(e, t) {
  return t[0](e) > t[1](e);
}), Ot(fe.core.rel.gre, function(e, t) {
  return t[0](e) >= t[1](e);
}), Ot(fe.core.rel.inRange, function(e, t) {
  var r = t[0](e);
  return r >= t[1](e) && r <= t[2](e);
}), Ot(fe.core.math.add, function(e, t) {
  var r = 0;
  if (typeof t.length == "number") for (var n = 0, i = t.length; n < i; n++) r += t[n](e);
  else for (var a = 0, o = Object.keys(t); a < o.length; a++)
    r += t[o[a]](e);
  return r;
}), Ot(fe.core.math.sub, function(e, t) {
  var r = 0;
  if (typeof t.length == "number") {
    if (t.length === 1) return -t[0](e);
    r = t[0](e) || 0;
    for (var n = 1, i = t.length; n < i; n++) r -= t[n](e);
  } else {
    var a = Object.keys(t);
    if (a.length === 1) return -t[a[0]](e);
    for (r = t[a[0]](e) || 0, n = 1, i = a.length; n < i; n++) r -= t[a[n]](e);
  }
  return r;
}), Ot(fe.core.math.mult, function(e, t) {
  var r = 1;
  if (typeof t.length == "number") for (var n = 0, i = t.length; n < i; n++) r *= t[n](e);
  else for (var a = 0, o = Object.keys(t); a < o.length; a++)
    r *= t[o[a]](e);
  return r;
}), Ot(fe.core.math.div, function(e, t) {
  return t[0](e) / t[1](e);
}), Ot(fe.core.math.pow, function(e, t) {
  return Math.pow(t[0](e), t[1](e));
}), Ot(fe.core.math.mod, function(e, t) {
  return t[0](e) % t[1](e);
}), Ot(fe.core.math.min, function(e, t) {
  var r = Number.POSITIVE_INFINITY;
  if (typeof t.length == "number") for (var n = 0, i = t.length; n < i; n++) r = Math.min(t[n](e), r);
  else for (var a = 0, o = Object.keys(t); a < o.length; a++) {
    var u = o[a];
    r = Math.min(t[u](e), r);
  }
  return r;
}), Ot(fe.core.math.max, function(e, t) {
  var r = Number.NEGATIVE_INFINITY;
  if (typeof t.length == "number") for (var n = 0, i = t.length; n < i; n++) r = Math.max(t[n](e), r);
  else for (var a = 0, o = Object.keys(t); a < o.length; a++) {
    var u = o[a];
    r = Math.max(t[u](e), r);
  }
  return r;
}), Ot(fe.core.math.floor, function(e, t) {
  return Math.floor(t[0](e));
}), Ot(fe.core.math.ceil, function(e, t) {
  return Math.ceil(t[0](e));
}), Ot(fe.core.math.roundInt, function(e, t) {
  return Math.round(t[0](e));
}), Ot(fe.core.math.abs, function(e, t) {
  return Math.abs(t[0](e));
}), Ot(fe.core.math.sqrt, function(e, t) {
  return Math.sqrt(t[0](e));
}), Ot(fe.core.math.cbrt, function(e, t) {
  return Math.cbrt(t[0](e));
}), Ot(fe.core.math.sin, function(e, t) {
  return Math.sin(t[0](e));
}), Ot(fe.core.math.cos, function(e, t) {
  return Math.cos(t[0](e));
}), Ot(fe.core.math.tan, function(e, t) {
  return Math.tan(t[0](e));
}), Ot(fe.core.math.asin, function(e, t) {
  return Math.asin(t[0](e));
}), Ot(fe.core.math.acos, function(e, t) {
  return Math.acos(t[0](e));
}), Ot(fe.core.math.atan, function(e, t) {
  return Math.atan(t[0](e));
}), Ot(fe.core.math.sinh, function(e, t) {
  return Math.sinh(t[0](e));
}), Ot(fe.core.math.cosh, function(e, t) {
  return Math.cosh(t[0](e));
}), Ot(fe.core.math.tanh, function(e, t) {
  return Math.tanh(t[0](e));
}), Ot(fe.core.math.exp, function(e, t) {
  return Math.exp(t[0](e));
}), Ot(fe.core.math.log, function(e, t) {
  return Math.log(t[0](e));
}), Ot(fe.core.math.log10, function(e, t) {
  return Math.log10(t[0](e));
}), Ot(fe.core.math.atan2, function(e, t) {
  return Math.atan2(t[0](e), t[1](e));
}), Ot(fe.core.str.match, function(e, t) {
  return t[0](e).test(t[1](e));
}), Ot(fe.core.str.concat, function(e, t) {
  var r = [];
  if (typeof t.length == "number") for (var n = 0, i = t.length; n < i; n++) r.push(t[n](e).toString());
  else for (var a = 0, o = Object.keys(t); a < o.length; a++) {
    var u = o[a];
    r.push(t[u](e).toString());
  }
  return r.join("");
}), Ot(fe.core.list.getAt, function(e, t) {
  return t[0](e)[t[1](e)];
}), Ot(fe.core.list.equal, function(e, t) {
  return function(r, n) {
    if (!r || r.length === 0) return !n || n.length === 0;
    if (!n) return !1;
    var i = r.length;
    if (i !== n.length) return !1;
    for (var a = 0; a < i; a++) if (r[a] !== n[a]) return !1;
    return !0;
  }(t[0](e), t[1](e));
}), Ot(fe.core.set.has, function(e, t) {
  return t[0](e).has(t[1](e));
}), Ot(fe.core.set.isSubset, function(e, t) {
  return to.isSuperset(t[1](e), t[0](e));
}), Ot(fe.core.flags.hasAny, function(e, t) {
  var r = t[1](e), n = t[0](e);
  return r ? !!(n & r) : !!n;
}), Ot(fe.core.flags.hasAll, function(e, t) {
  var r = t[1](e), n = t[0](e);
  return r ? (n & r) === r : !n;
}), Ot(fe.structureQuery.type.elementSymbol, function(e, t) {
  return q1(t[0](e));
}), Ot(fe.structureQuery.type.atomName, function(e, t) {
  return (r = t[0](e)) ? typeof r == "string" ? r.toUpperCase() : "".concat(r).toUpperCase() : "";
  var r;
}), Ot(fe.structureQuery.type.bondFlags, function(e, t) {
  var r = 0;
  if (typeof t.length == "number") for (var n = 0, i = t.length; n < i; n++) r = Uw(r, t[n](e));
  else for (var a = 0, o = Object.keys(t); a < o.length; a++)
    r = Uw(r, t[o[a]](e));
  return r;
}), Ot(fe.structureQuery.type.ringFingerprint, function(e, t) {
  return Eu.elementFingerprint(function(r, n) {
    var i = [];
    if (!n) return i;
    if (typeof n.length == "number") for (var a = 0, o = n.length; a < o; a++) i.push(n[a](r));
    else {
      var u = Object.keys(n);
      for (a = 1, o = u.length; a < o; a++) i.push(n[u[a]](r));
    }
    return i;
  }(e, t));
}), Ot(fe.structureQuery.type.secondaryStructureFlags, function(e, t) {
  var r = 0;
  if (typeof t.length == "number") for (var n = 0, i = t.length; n < i; n++) r = Hw(r, t[n](e));
  else for (var a = 0, o = Object.keys(t); a < o.length; a++)
    r = Hw(r, t[o[a]](e));
  return r;
}), Mt(fe.structureQuery.filter.pick, function(e, t) {
  return gn.filters.pick(t[0], t.test)(e);
}), Mt(fe.structureQuery.filter.first, function(e, t) {
  return gn.filters.first(t[0])(e);
}), Mt(fe.structureQuery.filter.withSameAtomProperties, function(e, t) {
  return gn.filters.withSameAtomProperties(t[0], t.source, t.property)(e);
}), Mt(fe.structureQuery.filter.intersectedBy, function(e, t) {
  return gn.filters.areIntersectedBy(t[0], t.by)(e);
}), Mt(fe.structureQuery.filter.within, function(e, t) {
  return gn.filters.within({ query: t[0], target: t.target, minRadius: t["min-radius"], maxRadius: t["max-radius"], elementRadius: t["atom-radius"], invert: t.invert })(e);
}), Mt(fe.structureQuery.filter.isConnectedTo, function(e, t) {
  return gn.filters.isConnectedTo({ query: t[0], target: t.target, disjunct: t.disjunct, invert: t.invert, bondTest: t["bond-test"] })(e);
}), Mt(fe.structureQuery.generator.atomGroups, function(e, t) {
  return gn.generators.atoms({ entityTest: t["entity-test"], chainTest: t["chain-test"], residueTest: t["residue-test"], atomTest: t["atom-test"], groupBy: t["group-by"] })(e);
}), Mt(fe.structureQuery.generator.all, function(e) {
  return gn.generators.all(e);
}), Mt(fe.structureQuery.generator.empty, function(e) {
  return gn.generators.none(e);
}), Mt(fe.structureQuery.generator.bondedAtomicPairs, function(e, t) {
  return gn.generators.bondedAtomicPairs(t && t[0])(e);
}), Mt(fe.structureQuery.generator.rings, function(e, t) {
  var r, n;
  return gn.generators.rings((r = t == null ? void 0 : t.fingerprint) === null || r === void 0 ? void 0 : r.call(t, e), (n = t == null ? void 0 : t["only-aromatic"]) === null || n === void 0 ? void 0 : n.call(t, e))(e);
}), Mt(fe.structureQuery.modifier.includeSurroundings, function(e, t) {
  return gn.modifiers.includeSurroundings(t[0], { radius: t.radius(e), wholeResidues: !(!t["as-whole-residues"] || !t["as-whole-residues"](e)), elementRadius: t["atom-radius"] })(e);
}), Mt(fe.structureQuery.modifier.surroundingLigands, function(e, t) {
  return gn.modifiers.surroundingLigands({ query: t[0], radius: t.radius(e), includeWater: !(!t["include-water"] || !t["include-water"](e)) })(e);
}), Mt(fe.structureQuery.modifier.wholeResidues, function(e, t) {
  return gn.modifiers.wholeResidues(t[0])(e);
}), Mt(fe.structureQuery.modifier.union, function(e, t) {
  return gn.modifiers.union(t[0])(e);
}), Mt(fe.structureQuery.modifier.expandProperty, function(e, t) {
  return gn.modifiers.expandProperty(t[0], t.property)(e);
}), Mt(fe.structureQuery.modifier.exceptBy, function(e, t) {
  return gn.modifiers.exceptBy(t[0], t.by)(e);
}), Mt(fe.structureQuery.modifier.intersectBy, function(e, t) {
  return gn.modifiers.intersectBy(t[0], t.by)(e);
}), Mt(fe.structureQuery.modifier.includeConnected, function(e, t) {
  var r, n;
  return gn.modifiers.includeConnected({ query: t[0], bondTest: t["bond-test"], wholeResidues: !(!t["as-whole-residues"] || !t["as-whole-residues"](e)), layerCount: t["layer-count"] && t["layer-count"](e) || 1, fixedPoint: (n = (r = t["fixed-point"]) === null || r === void 0 ? void 0 : r.call(t, e)) !== null && n !== void 0 && n })(e);
}), Mt(fe.structureQuery.combinator.merge, function(e, t) {
  return gn.combinators.merge(t)(e);
}), Mt(fe.structureQuery.atomProperty.core.elementSymbol, Xr(Qe.atom.type_symbol)), Mt(fe.structureQuery.atomProperty.core.vdw, function(e, t) {
  return Eg(Qe.atom.type_symbol(t && t[0] && t[0](e) || e.element));
}), Mt(fe.structureQuery.atomProperty.core.mass, function(e, t) {
  return function(r) {
    var n = j1[r];
    return n === void 0 ? 10.81 : ZX[n];
  }(Qe.atom.type_symbol(t && t[0] && t[0](e) || e.element));
}), Mt(fe.structureQuery.atomProperty.core.atomicNumber, function(e, t) {
  return im(Qe.atom.type_symbol(t && t[0] && t[0](e) || e.element));
}), Mt(fe.structureQuery.atomProperty.core.x, Xr(Qe.atom.x)), Mt(fe.structureQuery.atomProperty.core.y, Xr(Qe.atom.y)), Mt(fe.structureQuery.atomProperty.core.z, Xr(Qe.atom.z)), Mt(fe.structureQuery.atomProperty.core.sourceIndex, Xr(Qe.atom.sourceIndex)), Mt(fe.structureQuery.atomProperty.core.operatorName, Xr(Qe.unit.operator_name)), Mt(fe.structureQuery.atomProperty.core.modelIndex, Xr(Qe.unit.model_index)), Mt(fe.structureQuery.atomProperty.core.modelLabel, Xr(Qe.unit.model_label)), Mt(fe.structureQuery.atomProperty.core.atomKey, function(e, t) {
  var r = t && t[0] && t[0](e) || e.element;
  return Mu(r.unit.id, r.element);
}), Mt(fe.structureQuery.atomProperty.macromolecular.residueKey, function(e, t) {
  return Xj(t && t[0] && t[0](e) || e.element);
}), Mt(fe.structureQuery.atomProperty.macromolecular.chainKey, function(e, t) {
  return jj(t && t[0] && t[0](e) || e.element);
}), Mt(fe.structureQuery.atomProperty.macromolecular.entityKey, function(e, t) {
  return Yj(t && t[0] && t[0](e) || e.element);
}), Mt(fe.structureQuery.atomProperty.macromolecular.id, Xr(Qe.atom.id)), Mt(fe.structureQuery.atomProperty.macromolecular.isHet, function(e, t) {
  return Qe.residue.group_PDB(t && t[0] && t[0](e) || e.element) !== "ATOM";
}), Mt(fe.structureQuery.atomProperty.macromolecular.label_atom_id, Xr(Qe.atom.label_atom_id)), Mt(fe.structureQuery.atomProperty.macromolecular.label_alt_id, Xr(Qe.atom.label_alt_id)), Mt(fe.structureQuery.atomProperty.macromolecular.label_comp_id, Xr(Qe.atom.label_comp_id)), Mt(fe.structureQuery.atomProperty.macromolecular.label_seq_id, Xr(Qe.residue.label_seq_id)), Mt(fe.structureQuery.atomProperty.macromolecular.label_asym_id, Xr(Qe.chain.label_asym_id)), Mt(fe.structureQuery.atomProperty.macromolecular.label_entity_id, Xr(Qe.entity.id)), Mt(fe.structureQuery.atomProperty.macromolecular.auth_atom_id, Xr(Qe.atom.auth_atom_id)), Mt(fe.structureQuery.atomProperty.macromolecular.auth_comp_id, Xr(Qe.atom.auth_comp_id)), Mt(fe.structureQuery.atomProperty.macromolecular.auth_seq_id, Xr(Qe.residue.auth_seq_id)), Mt(fe.structureQuery.atomProperty.macromolecular.auth_asym_id, Xr(Qe.chain.auth_asym_id)), Mt(fe.structureQuery.atomProperty.macromolecular.pdbx_PDB_ins_code, Xr(Qe.residue.pdbx_PDB_ins_code)), Mt(fe.structureQuery.atomProperty.macromolecular.pdbx_formal_charge, Xr(Qe.atom.pdbx_formal_charge)), Mt(fe.structureQuery.atomProperty.macromolecular.occupancy, Xr(Qe.atom.occupancy)), Mt(fe.structureQuery.atomProperty.macromolecular.B_iso_or_equiv, Xr(Qe.atom.B_iso_or_equiv)), Mt(fe.structureQuery.atomProperty.macromolecular.entityType, Xr(Qe.entity.type)), Mt(fe.structureQuery.atomProperty.macromolecular.entitySubtype, Xr(Qe.entity.subtype)), Mt(fe.structureQuery.atomProperty.macromolecular.entityPrdId, Xr(Qe.entity.prd_id)), Mt(fe.structureQuery.atomProperty.macromolecular.entityDescription, Xr(Qe.entity.pdbx_description)), Mt(fe.structureQuery.atomProperty.macromolecular.objectPrimitive, Xr(Qe.unit.object_primitive)), Mt(fe.structureQuery.atomProperty.macromolecular.isNonStandard, Xr(Qe.residue.isNonStandard)), Mt(fe.structureQuery.atomProperty.macromolecular.secondaryStructureKey, Xr(Qe.residue.secondary_structure_key)), Mt(fe.structureQuery.atomProperty.macromolecular.secondaryStructureFlags, Xr(Qe.residue.secondary_structure_type)), Mt(fe.structureQuery.atomProperty.macromolecular.chemCompType, Xr(Qe.residue.chem_comp_type)), Mt(fe.structureQuery.bondProperty.order, function(e, t) {
  return e.atomicBond.order;
}), Mt(fe.structureQuery.bondProperty.flags, function(e, t) {
  return e.atomicBond.type;
}), Mt(fe.structureQuery.bondProperty.atomA, function(e, t) {
  return e.atomicBond.a;
}), Mt(fe.structureQuery.bondProperty.atomB, function(e, t) {
  return e.atomicBond.b;
}), Mt(fe.structureQuery.bondProperty.length, function(e, t) {
  return e.atomicBond.length;
}), Mt(fe.internal.generator.bundleElement, function(e, t) {
  return iT(t.groupedUnits(e), t.ranges(e), t.set(e));
}), Mt(fe.internal.generator.bundle, function(e, t) {
  return aT(t.elements(e))(e);
}), Mt(fe.internal.generator.current, function(e, t) {
  return e.tryGetCurrentSelection();
})];
function Xr(e) {
  return function(t, r) {
    return e(r && r[0] && r[0](t) || t.element);
  };
}
function Uw(e, t) {
  return e | (cr.isName(t) ? cr.fromName(t) : 0);
}
function Hw(e, t) {
  switch (t.toLowerCase()) {
    case "helix":
      return 2 | e;
    case "alpha":
      return 4098 | e;
    case "pi":
      return 32770 | e;
    case "310":
      return 2050 | e;
    case "beta":
      return 4 | e;
    case "strand":
      return 4194308 | e;
    case "sheet":
      return 8388612 | e;
    case "turn":
      return 16 | e;
    case "bend":
      return 8 | e;
    case "coil":
      return 536870912 | e;
    default:
      return e;
  }
}
(function() {
  for (var e = 0, t = fee; e < t.length; e++) {
    var r = t[e];
    uP.addSymbol(r);
  }
})();
var $2, pee = /* @__PURE__ */ new Set(["N", "O", "S", "F", "CL", "BR", "I"]);
function mee(e, t, r) {
  var n = !1;
  return $l(e, t, r, function(i, a) {
    (function(o) {
      return pee.has(o);
    })(Br(i, a)) && (n = !0);
  }), n;
}
(function(e) {
  e.Type = "Type", e.Structure = "Structure Property", e.Atom = "Atom Property", e.Bond = "Bond Property", e.Residue = "Residue Property", e.AminoAcid = "Amino Acid", e.NucleicBase = "Nucleic Base", e.Manipulate = "Manipulate Selection", e.Validation = "Validation", e.Misc = "Miscellaneous", e.Internal = "Internal";
})($2 || ($2 = {}));
var hee = function(e, t, r) {
  var n, i;
  return r === void 0 && (r = {}), { label: e, expression: t, description: r.description || "", category: (n = r.category) !== null && n !== void 0 ? n : $2.Misc, isHidden: !!r.isHidden, priority: r.priority || 0, referencesCurrent: !!r.referencesCurrent, get query() {
    return i || (i = z2(t)), i;
  }, ensureCustomProperties: r.ensureCustomProperties };
}("Polymer", Nt.struct.modifier.union([Nt.struct.generator.atomGroups({ "entity-test": Nt.core.logic.and([Nt.core.rel.eq([Nt.ammp("entityType"), "polymer"]), Nt.core.str.match([Nt.re("(polypeptide|cyclic-pseudo-peptide|peptide-like|nucleotide|peptide nucleic acid)", "i"), Nt.ammp("entitySubtype")])]) })]), { category: $2.Type }), qw = { polymer: hee }, zs = function() {
  return tt.Builder().getStructure();
}, rB = function(e, t) {
  for (var r = tt.Builder(), n = new Set(t), i = 0, a = e.units; i < a.length; i++) {
    var o = a[i], u = We([], o.elements, !0).filter(function(s) {
      return !n.has(s);
    });
    u.length && r.addUnit(o.kind, o.model, o.conformation.operator, u, o.traits);
  }
  return r.getStructure();
}, yo = function(e) {
  var t = e.getLoci();
  return t.kind === "structure-loci" ? t.structure : t.kind === "element-loci" ? Xe.toStructure(t) : tt.Empty;
}, kg = function(e) {
  var t = e.getLoci();
  return t.kind === "structure-loci" ? Gi(tt.toStructureElementLoci(t.structure)) : t.kind === "element-loci" ? Gi(t) : [];
}, $n = function(e, t, r, n) {
  if ((t == null ? void 0 : t.length) === 0 && !r) return tt.Empty;
  for (var i = tt.Builder(), a = new Set(t), o = typeof n == "string" ? n : Ii.create22(), u = 0, s = e.units; u < s.length; u++) {
    var c = s[u], l = t != null && t.length ? We([], c.elements, !0).filter(function(d) {
      return a.has(d);
    }) : c.elements;
    l.length && i.addUnit(c.kind, n ? R(R({}, c.model), { id: o }) : c.model, c.conformation.operator, l, c.traits);
  }
  return i.getStructure();
}, n2 = function(e, t) {
  for (var r = tt.Builder(), n = /* @__PURE__ */ new Map(), i = 0, a = function(s, c) {
    var l = e[s], d = l.ref, f = l.elementIds, m = Zr(t.cells.get(d)), v = new Set(f);
    n.set(s, []);
    for (var p = 0, g = m.units; p < g.length; p++) {
      var h = g[p], y = f ? We([], h.elements, !0).filter(function(x) {
        return v.has(x);
      }) : h.elements;
      y.length && (n.get(s).push(i), r.addUnit(h.kind, h.model, h.conformation.operator, y, h.traits, i), i++);
    }
  }, o = 0, u = e.length; o < u; o++) a(o);
  return { unitsMap: n, structure: r.getStructure() };
}, g6 = function(e) {
  if (e.model.sourceData.kind === "gro") return { polymer: qo(c0(s0(e, qw.polymer.expression))), other: qo(c0(s0(e, Nt.struct.modifier.exceptBy({ 0: Hl.toExpression(Hl("(sel.atom.all)", "mol-script")), by: qw.polymer.expression })))) };
  var t = {}, r = {}, n = /* @__PURE__ */ new Set(), i = [], a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
  e.units.forEach(function(s) {
    var c;
    s.elements.forEach(function(v) {
      var p = Os(s, v);
      if (p.groupPDB === "ATOM" && !["UNK", "MOL"].includes(p.residueName)) return Wa(t, p), n.add(p.elementId), void i.push(p.elementId);
      if (p.groupPDB === "HETATM" || ["UNK", "MOL"].includes(p.residueName)) {
        var g = "".concat(p.chainId, "_").concat(p.residueId);
        a.set(g, a.has(g) ? We(We([], a.get(g), !0), [p], !1) : [p]);
      } else Wa(r, p);
    });
    for (var l = 0, d = s.bonds.a.length; l < d; l++) {
      var f = s.elements[s.bonds.a[l]], m = s.elements[s.bonds.b[l]];
      o.has(f) ? (c = o.get(f)) === null || c === void 0 || c.add(m) : o.set(f, /* @__PURE__ */ new Set([m]));
    }
  }), a.forEach(function(s) {
    var c = !1;
    new Set(s.map(function(l) {
      return l.elementId;
    })).forEach(function(l) {
      if (o.has(l)) {
        var d = o.get(l);
        d == null || d.forEach(function(f) {
          n.has(f) && (c = !0);
        });
      }
    }), s.forEach(function(l) {
      c ? (Object.assign(l, { isEutectic: !0 }), i.push(l.elementId), n.add(l.elementId)) : Wa(r, l);
    });
  });
  var u = [];
  return Object.keys(r).forEach(function(s) {
    Object.keys(r[s]).forEach(function(c) {
      u.push.apply(u, r[s][c].map(function(l) {
        return l.elementId;
      }));
    });
  }), { polymer: i, other: u };
}, zg = function(e, t) {
  var r;
  if (!e.elementCount) return "";
  if (t === mr.Pdb) return J_(e, void 0, !0);
  var n = Ko(e), i = (r = n == null ? void 0 : n.entryId) !== null && r !== void 0 ? r : "";
  return t === mr.Sdf || t === mr.Mol ? i ? We([i], p6(e).split(`
`).slice(1), !0).join(`
`) : p6(e) : void 0;
}, vee = function(e, t) {
  var r = Ko(e);
  return t !== mr.Material ? r.sourceData.data : r.sourceData.data.molecules[0];
}, gee = function(e, t, r, n) {
  return _e(void 0, 0, void 0, function() {
    var i, a, o, u, s, c, l;
    return ye(this, function(d) {
      switch (d.label) {
        case 0:
          return i = !((s = e == null ? void 0 : e.models) === null || s === void 0) && s.length ? e.models[0] : e == null ? void 0 : e.model, ((l = n ?? (i ? i.sourceData.kind : (c = e == null ? void 0 : e.parent) === null || c === void 0 ? void 0 : c.model.sourceData.kind)) !== null && l !== void 0 ? l : "sdf") !== "mmCIF" ? [3, 3] : (o = (a = Fc[mr.Pdb]).parse, [4, J_(e, void 0, !0, r)]);
        case 1:
          return [4, o.apply(a, [d.sent()])];
        case 2:
        case 5:
          return [2, d.sent()];
        case 3:
          return [4, p6(e, void 0, 0, t)];
        case 4:
          return u = d.sent(), [4, Fc[mr.Sdf].parse(u)];
      }
    });
  });
}, s0 = function(e, t) {
  return z2(t)(new ff(e));
}, c0 = function(e) {
  var t;
  if (e.structure) t = e.structure;
  else if (e.structures) {
    var r = e.structures.map(function(a) {
      return (a == null ? void 0 : a.units.length) > 0 ? tt.toStructureElementLoci(a) : void 0;
    }).filter(function(a) {
      return a;
    });
    if (r.length === 0) return zs();
    for (var n = r[0], i = 1; i < r.length; i++) n = Xe.union(n, r[i]);
    t = Xe.toStructure(n);
  }
  return t;
}, qo = function(e) {
  var t = [];
  return e.units.forEach(function(r) {
    t.push.apply(t, r.elements);
  }), t;
}, Os = function(e, t) {
  var r;
  return { unitId: e.invariantId, elementId: t, chainId: e.model.atomicHierarchy.chains.auth_asym_id.value(e.chainIndex[t]), groupPDB: e.model.atomicHierarchy.residues.group_PDB.value(e.residueIndex[t]), residueId: e.model.atomicHierarchy.residues.auth_seq_id.value(e.residueIndex[t]), insertCode: e.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(e.residueIndex[t]), residueName: e.model.atomicHierarchy.atoms.label_comp_id.value(t), atomId: e.model.atomicConformation.atomId.value(t), atomName: e.model.atomicHierarchy.atoms.label_atom_id.value(t), typeSymbol: mm(e.model.atomicHierarchy.atoms.type_symbol.value(t)), charge: ((r = Pc.Provider.get(e.model)) === null || r === void 0 ? void 0 : r.data.value(t)) || 0, altId: e.model.atomicHierarchy.atoms.label_alt_id.value(t), cdr: e.model.atomicHierarchy.atoms.cdr.value(t) || 0, bfactor: e.model.atomicHierarchy.atoms.B_iso_or_equiv.value(t), em_confidence: e.model.atomicHierarchy.atoms.em_confidence.value(t), x: e.model.atomicConformation.x[t], y: e.model.atomicConformation.y[t], z: e.model.atomicConformation.z[t], residueIndex: e.residueIndex[t], occupancy: e.model.atomicConformation.occupancy.value(t) };
}, nB = function(e, t, r) {
  var n = r;
  if (e.units.some(function(a) {
    return !!a.elements.includes(t) && (n = a.invariantId, !0);
  }), n === void 0 || !e.unitMap.has(n)) return {};
  var i = e.unitMap.get(n);
  return Os(i, t);
}, iB = function(e, t) {
  e.units.forEach(function(r) {
    r.elements.forEach(function(n) {
      var i = Os(r, n);
      t(i);
    });
  });
}, yee = function(e, t, r) {
  var n = [];
  return t.forEach(function(i) {
    var a = e.managers.cell.get(i.ref), o = Zr(a), u = /* @__PURE__ */ new Map(), s = new Set(i.elementIds);
    o && (o.units.forEach(function(c) {
      c.elements.forEach(function(l) {
        var d;
        if (!i.elementIds || s.has(l)) {
          var f = Os(c, l), m = W2(f, r);
          u.has(m) ? (d = u.get(m)) === null || d === void 0 || d.push(f) : u.set(m, [f]);
        }
      });
    }), u.forEach(function(c) {
      n.push({ ref: i.ref, elementIds: c.map(function(l) {
        return l.elementId;
      }), props: jJ(c[0], r) });
    }));
  }), n;
}, aB = function(e, t) {
  var r = {}, n = /* @__PURE__ */ new Set(), i = t ?? [];
  return t || e.managers.cell.traverse(function(a, o) {
    Zr(a) && !o.isHidden && n.add(a.ref);
  }), n.forEach(function(a) {
    i.push({ ref: a });
  }), i.forEach(function(a) {
    var o, u = a.ref, s = a.elementIds, c = new Set(s), l = e.cells.get(u);
    if (l) {
      var d = Zr(l);
      if (d) {
        var f = [], m = [], v = [], p = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
        d.units.forEach(function(A) {
          var b;
          A.elements.forEach(function(M) {
            var F, P;
            if (!s || c.has(M)) {
              var E = Os(A, M), B = W2(E, kr.Residue);
              X_.has(E.residueName.toUpperCase()) ? f.push(E.elementId) : g0.has(E.residueName.toUpperCase()) ? m.push(E.elementId) : K_.has(E.typeSymbol.toUpperCase()) || Cm.has(E.residueName.toUpperCase()) ? v.push(E.elementId) : E.groupPDB !== "ATOM" || ["UNK", "MOL"].includes(E.residueName) ? E.groupPDB === "HETATM" || ["UNK", "MOL"].includes(E.residueName) ? y.has(B) ? (F = y.get(B)) === null || F === void 0 || F.push(E) : y.set(B, [E]) : h.has(B) ? (P = h.get(B)) === null || P === void 0 || P.push(E) : h.set(B, [E]) : p.add(E.elementId);
            }
          });
          for (var _ = 0, S = A.bonds.a.length; _ < S; _++) {
            var D = A.elements[A.bonds.a[_]], I = A.elements[A.bonds.b[_]];
            x.has(D) ? (b = x.get(D)) === null || b === void 0 || b.add(I) : x.set(D, /* @__PURE__ */ new Set([I]));
          }
        }), y.forEach(function(A, b) {
          var _ = !1, S = new Set(A.map(function(D) {
            return D.elementId;
          }));
          S.forEach(function(D) {
            if (x.has(D)) {
              var I = x.get(D);
              I == null || I.forEach(function(M) {
                p.has(M) && (_ = !0);
              });
            }
          }), A.forEach(function(D) {
            var I;
            _ ? p.add(D.elementId) : h.has(b) ? (I = h.get(b)) === null || I === void 0 || I.push(D) : h.set(b, [D]);
          });
        }), h.forEach(function(A, b) {
          var _ = A.filter(function(S) {
            return S.typeSymbol !== "H";
          });
          _.length > 10 && _.length < 150 ? g.set(b, A) : v.push.apply(v, A.map(function(S) {
            return S.elementId;
          }));
        }), r[u] = ((o = {})[Ea.Protein] = p.size ? [{ ref: u, elementIds: Array.from(p.values()) }] : [], o[Ea.Ligand] = Array.from(g.entries()).map(function(A) {
          var b = A[0], _ = A[1];
          return { ref: u, elementIds: _.map(function(S) {
            return S.elementId;
          }), name: b };
        }), o[Ea.Solvent] = f.length ? [{ ref: u, elementIds: f }] : [], o[Ea.Water] = m.length ? [{ ref: u, elementIds: m }] : [], o[Ea.Other] = v.length ? [{ ref: u, elementIds: v }] : [], o);
      }
    }
  }), r;
}, Ko = function(e) {
  var t;
  return (t = e.model) !== null && t !== void 0 ? t : e.models[0];
}, Qu = function(e) {
  var t, r;
  return (r = (t = e.model) !== null && t !== void 0 ? t : e.models[0]) === null || r === void 0 ? void 0 : r.id;
}, Zr = function(e) {
  var t, r, n, i;
  return (t = e == null ? void 0 : e.model.structure) !== null && t !== void 0 ? t : !((r = e == null ? void 0 : e.model) === null || r === void 0) && r.trajectory ? tt.ofModel((n = e == null ? void 0 : e.model.trajectory) === null || n === void 0 ? void 0 : n.state.getFrameAtIndex((i = e == null ? void 0 : e.model.trajectory) === null || i === void 0 ? void 0 : i.frameIndex)) : void 0;
}, Gg = function(e, t) {
  var r = e.units.filter(function(a) {
    return qe.has(a.elements, t);
  })[0];
  if (!r || Be.isCoarse(r)) return bi.NotHydrogen;
  if (r.model.atomicHierarchy.derived.atom.atomicNumber[t] !== 1) {
    var n = bi.NotHydrogen;
    return $l(e, r, r.elements.indexOf(t), function(a, o) {
      if (a.model.atomicHierarchy.derived.atom.atomicNumber[a.elements[o]] === 1) switch (Gg(e, a.elements[o])) {
        case bi.Polar:
          n = bi.ConnectPolar;
          break;
        case bi.NonPolar:
          n = bi.ConnectNonPolar;
      }
    }), n;
  }
  var i = mee(e, r, qe.indexOf(r.elements, t));
  return i ? bi.Polar : i ? bi.NotHydrogen : bi.NonPolar;
}, bee = function(e, t) {
  return _e(void 0, 0, void 0, function() {
    var r;
    return ye(this, function(n) {
      switch (n.label) {
        case 0:
          return [4, Promise.all(t.filter(function(i) {
            return e.cells.has(i.ref);
          }).map(function(i) {
            return e.managers.cell.getStructure(i.ref);
          }))];
        case 1:
          return r = n.sent(), [2, w$(r)];
      }
    });
  });
}, oB = function(e) {
  return Array.from(e.cells.entries()).map(function(t) {
    var r = t[0], n = t[1];
    return Zr(n) ? n.representations.size === 0 || Array.from(n.representations.values()).filter(function(i) {
      return !i.isHidden;
    }).length === 0 ? { ref: "" } : { ref: r } : { ref: "" };
  }).filter(function(t) {
    return t.ref;
  });
}, np = function(e, t) {
  return nB(e, t).typeSymbol === "H" && Gg(e, t) === bi.NonPolar;
}, $4 = function(e) {
  if (!e) return e;
  var t = [], r = e.sort(function(i, a) {
    return +i - +a;
  }), n = [];
  return r.forEach(function(i, a) {
    n.length !== 0 ? n.length !== 1 ? n.length === 2 && (n[1] === i - 1 ? n[1] = i : (t.push.apply(t, n), n = [i])) : n[0] === i - 1 ? n.push(i) : (t.push(n[0], n[0]), n = [i]) : n.push(i);
  }), n.length && t.push.apply(t, n.length === 2 ? n : [n[0], n[0]]), t;
}, gv = function(e) {
  for (var t = [], r = 0, n = e.length; r < n; r += 2) for (var i = e[r]; i <= e[r + 1]; i++) t.push(i);
  return t;
};
function bf(e, t, r, n) {
  var i, a, o, u, s = 0, c = t.webgl, l = new ui(), d = new or.GeometryState(), f = zc(), m = [], v = Wo.create(), p = Bu.createEmpty();
  function g(h) {
    if (Wo.update(v, h), h.visible !== void 0 && i && i.setVisibility(h.visible && (v.unitTransforms === null || v.unitTransforms.isIdentity)), h.alphaFactor !== void 0 && i && i.setAlphaFactor(h.alphaFactor), h.pickable !== void 0 && i && i.setPickable(h.pickable), h.overpaint !== void 0 && i) {
      var y = um.remap(h.overpaint, a);
      i.setOverpaint(y, c);
    }
    if (h.transparency !== void 0 && i) {
      var x = sm.remap(h.transparency, a);
      i.setTransparency(x, c);
    }
    if (h.substance !== void 0 && i) {
      var A = lm.remap(h.substance, a);
      i.setSubstance(A, c);
    }
    if (h.clipping !== void 0 && i) {
      var b = cm.remap(h.clipping, a);
      i.setClipping(b);
    }
    h.transform !== void 0 && i && i.setTransform(h.transform), h.unitTransforms !== void 0 && i && i.setVisibility(v.visible && (h.unitTransforms === null || h.unitTransforms.isIdentity));
  }
  return { label: e, get groupCount() {
    return i ? i.groupCount : 0;
  }, get props() {
    return u;
  }, get params() {
    return o;
  }, get state() {
    return v;
  }, get theme() {
    return p;
  }, get geometryVersion() {
    return d.version;
  }, renderObjects: m, updated: l, createOrUpdate: function(h, y) {
    var x = this;
    return h === void 0 && (h = {}), y && y !== a && (o = r(t, y), a = y, u || (u = G.getDefaultValues(o))), u = Object.assign({}, u, h), er.create("Creating or updating ComplexRepresentation", function(A) {
      return _e(x, 0, void 0, function() {
        var b, _, S;
        return ye(this, function(D) {
          switch (D.label) {
            case 0:
              return b = !1, i ? !((S = i.mustRecreate) === null || S === void 0) && S.call(i, a, u, c) && (i.destroy(), i = n(f, a, u, c), b = !0) : (i = n(f, a, u, c), b = !0), (_ = i.createOrUpdate({ webgl: c, runtime: A }, p, u, y)) ? [4, _] : [3, 2];
            case 1:
              D.sent(), D.label = 2;
            case 2:
              return b && g(v), m.length = 0, i && i.renderObject && (m.push(i.renderObject), d.add(i.renderObject.id, i.geometryVersion)), d.snapshot(), s += 1, l.next(s), [2];
          }
        });
      });
    });
  }, setState: g, setTheme: function(h) {
    p = h;
  }, getLoci: function(h) {
    return h === void 0 ? tt.Loci(a.target) : i ? i.getLoci(h) : vn;
  }, mark: function(h, y) {
    if (!a || !Pr.is(v.markerActions, y)) return !1;
    if (tt.isLoci(h) || Xe.is(h) || Dt.isLoci(h)) {
      if (!tt.areRootsEquivalent(h.structure, a)) return !1;
      h = Hr.remap(h, a), (tt.isLoci(h) || Xe.is(h) && Xe.isWholeStructure(h)) && (h = B_);
    } else if (!xo(h) && !Kp(h)) return !1;
    return !Hr.isEmpty(h) && !!i && i.mark(h, y);
  }, destroy: function() {
    i && i.destroy();
  } };
}
function uB(e, t, r) {
  var n = t.elements, i = t.model;
  if (Le.indexOf(n, r) !== -1) {
    for (var a = i.atomicHierarchy.residueAtomSegments, o = a.index, u = a.offsets, s = o[r], c = [], l = u[s], d = u[s + 1]; l < d; ++l) {
      var f = Le.indexOf(n, l);
      f !== -1 && c.push(f);
    }
    return Xe(e, [{ unit: t, indices: Le.ofSortedArray(qe.ofSortedArray(c)) }]);
  }
  return vn;
}
function Kw(e, t, r) {
  for (var n = e.structure.child, i = t && n ? e.group.units.filter(function(c) {
    return n.unitMap.has(c.id);
  }) : e.group.units, a = i.length, o = 16 * a, u = r && r.aTransform.ref.value.length >= o ? r.aTransform.ref.value : new Float32Array(o), s = 0; s < a; s++) me.toArray(i[s].conformation.operator.matrix, u, 16 * s);
  return S_(u, a, r);
}
var _ee = G.objectToOptions({ atomic: {}, spheres: {}, gaussians: {} }), Xw = 5e8;
function xee(e, t, r) {
  r === void 0 && (r = Xw);
  var n = function(s, c, l) {
    l === void 0 && (l = Xw);
    var d = qr.size(w(), s);
    w.ceil(d, d), d.sort(function(v, p) {
      return p - v;
    });
    var f = Math.floor(Math.cbrt(l) * Math.cbrt(l)), m = d[0] * d[1];
    return { area: m, areaCells: Math.ceil(m / (c * c)), maxAreaCells: f };
  }(e, t.resolution, r), i = n.area, a = n.areaCells, o = n.maxAreaCells, u = a > o ? Math.sqrt(i / o) : t.resolution;
  return R(R({}, t), { resolution: u });
}
var t8 = { ignoreHydrogens: G.Boolean(!1, { description: "Whether or not to include hydrogen atoms in the surface calculation." }), traceOnly: G.Boolean(!1, { description: "Whether or not to only use trace atoms in the surface calculation." }), includeParent: G.Boolean(!1, { description: "Include elements of the parent structure in surface calculation to get a surface patch of the current structure." }) };
G.getDefaultValues(t8);
var Aee = w();
function See(e, t, r, n) {
  return w.squaredDistance(w.set(Aee, e, t, r), n);
}
function Cee(e, t, r, n) {
  var i, a, o = n.ignoreHydrogens, u = n.traceOnly, s = n.includeParent, c = s ? e.root.unitMap.get(t.id) : t, l = function(F) {
    switch (F.kind) {
      case 0:
        return F.model.atomicConformation;
      case 1:
        return F.model.coarseConformation.spheres;
      case 2:
        return F.model.coarseConformation.gaussians;
    }
  }(c), d = l.x, f = l.y, m = l.z, v = c.elements, p = t.boundary.sphere, g = p.center, h = p.radius, y = (h + 7) * (h + 7);
  if (o || u || s && c !== t) {
    for (var x = [], A = [], b = 0, _ = v.length; b < _; ++b) {
      var S = v[b];
      o && y6(c, S) || u && !cB(c, S) || s && See(d[S], f[S], m[S], g) > y || (x.push(S), A.push(b));
    }
    i = qe.ofSortedArray(x), a = A;
  } else i = v, a = Fs(new Int32Array(i.length));
  s && c !== t && function(F, P, E) {
    for (var B = 0, N = P.length, O = 0, z = E.length; O < z; ++O) {
      var V = qe.indexOfInRange(P, E[O], B, N);
      V === -1 ? F[O] = -2 : (F[O] = V, B = V);
    }
  }(a, t.elements, i);
  var D = { indices: i, x: d, y: f, z: m, id: a }, I = t === c ? t.boundary : X1(D), M = at.create(e, c);
  return { position: D, boundary: I, radius: function(F) {
    return M.element = F, r.size(M);
  } };
}
var sB = j1.H;
function y6(e, t) {
  return !Be.isCoarse(e) && e.model.atomicHierarchy.derived.atom.atomicNumber[t] === sB;
}
function b6(e, t) {
  return e[t] === sB;
}
function cB(e, t) {
  if (Be.isCoarse(e)) return !0;
  var r = e.model.atomicHierarchy.atoms.label_atom_id.value(t);
  return r === "CA" || r === "BB" || r === "P";
}
function Bm(e) {
  return G.MultiSelect(e, _ee, { description: "For which kinds of units/chains to show the representation visuals." });
}
var Ao = { unitKinds: Bm(["atomic", "spheres"]), includeParent: G.Boolean(!1, { isHidden: !0 }) }, lB = R({}, Gt.Params), wee = R({}, ns.Params), dB = R({}, Na.Params), Dee = R({}, vf.Params), fB = R({}, Mr.Params), pB = R({}, jo.Params), mB = R({}, R2.Params), hB = R({}, id.Params);
function Vg(e, t) {
  var r, n, i, a, o, u, s, c, l = e.defaultProps, d = e.createGeometry, f = e.createLocationIterator, m = e.getLoci, v = e.eachLocation, p = e.setUpdateState, g = e.mustRecreate, h = e.processValues, y = e.dispose, x = e.geometryUtils, A = x.updateValues, b = x.updateBoundingSphere, _ = x.updateRenderableState, S = x.createPositionIterator, D = Rs.create(), I = { loci: vn, action: _t.None, status: -1 }, M = Object.assign({}, l), F = Bu.createEmpty(), P = -1;
  function E(O) {
    if (D.createNew) {
      if (s = f(a), !O) throw new Error("expected geometry to be given");
      r = function(z, V, U, H, K, j) {
        var X = oa.getUtils(V), W = X.createValues, Q = X.createRenderableState, te = W(V, w_(), U, H, K), ee = Q(K);
        return x0(V.kind, te, ee, j);
      }(0, O, s, i, n, t), c = S(O, r.values);
    } else {
      if (!r) throw new Error("expected renderObject to be available");
      if (D.updateTransform && Pu((s = f(a)).instanceCount * s.groupCount, r.values), D.createGeometry) {
        if (!O) throw new Error("expected geometry to be given");
        k.updateIfChanged(r.values.drawCount, oa.getDrawCount(O)), k.updateIfChanged(r.values.uVertexCount, oa.getVertexCount(O));
      }
      (D.updateTransform || D.createGeometry) && (b(r.values, O || u), c = S(u, r.values)), D.updateSize && "uSize" in r.values && Lc(s, i.size, r.values), D.updateColor && Xo(s, c, i.color, r.values), A(r.values, n), _(r.state, n);
    }
    M = n, F = i, o = a, O && (u = O, P += 1);
  }
  function B(O, z, V) {
    return function(U) {
      return !!xo(U) || !(!tt.isLoci(U) || !tt.areRootsEquivalent(U.structure, o)) || !!(Xe.is(U) && tt.areRootsEquivalent(U.structure, o) && Xe.isWholeStructure(U));
    }(O) ? z(Ae.ofBounds(0, s.groupCount * s.instanceCount)) : v(O, o, z, V);
  }
  function N(O) {
    r && (h == null || h(r.values, u, M, F, O.webgl));
  }
  return { get groupCount() {
    return s ? s.count : 0;
  }, get renderObject() {
    return s && s.count ? r : void 0;
  }, get geometryVersion() {
    return P;
  }, createOrUpdate: function(O, z, V, U) {
    if (V === void 0 && (V = {}), function(K, j, X) {
      if (!X && !o) throw new Error("missing structure");
      if (n = Object.assign({}, M, j), i = K, a = X, Rs.reset(D), !r || !o) return D.createNew = !0, void (D.createGeometry = !0);
      p(D, n, M, i, F, a, o), tt.areEquivalent(a, o) || (D.createGeometry = !0), tt.areHierarchiesEqual(a, o) || (D.updateTransform = !0, D.createGeometry = !0), Bc.areEqual(K.color, F.color) || (D.updateColor = !0), td(n.unitKinds, M.unitKinds) || (D.createGeometry = !0), o.child !== a.child && (D.createGeometry = !0), D.updateSize && !("uSize" in r.values) && (D.createGeometry = !0), D.createGeometry && (D.updateColor = !0, D.updateSize = !0);
    }(z, V, U || o), D.createGeometry) {
      var H = d(O, a, i, n, u);
      if (u_(H)) return H.then(function(K) {
        E(K), N(O);
      });
      E(H);
    } else E();
    N(O);
  }, getLoci: function(O) {
    return r ? m(O, o, r.id) : vn;
  }, mark: function(O, z) {
    return rr.mark(r, O, z, B, I);
  }, setVisibility: function(O) {
    rr.setVisibility(r, O);
  }, setAlphaFactor: function(O) {
    rr.setAlphaFactor(r, O);
  }, setPickable: function(O) {
    rr.setPickable(r, O);
  }, setColorOnly: function(O) {
    rr.setColorOnly(r, O);
  }, setTransform: function(O, z) {
    rr.setTransform(r, O, z);
  }, setOverpaint: function(O, z) {
    var V = { geometry: u, props: M, webgl: z };
    rr.setOverpaint(r, O, B, !0, V);
  }, setTransparency: function(O, z) {
    var V = { geometry: u, props: M, webgl: z };
    rr.setTransparency(r, O, B, !0, V);
  }, setSubstance: function(O, z) {
    var V = { geometry: u, props: M, webgl: z };
    rr.setSubstance(r, O, B, !0, V);
  }, setClipping: function(O) {
    rr.setClipping(r, O, B, !0);
  }, destroy: function() {
    y == null || y(u), r && (r.state.disposed = !0, r = void 0);
  }, mustRecreate: g };
}
var vB = R(R({}, lB), Ao);
function gB(e, t) {
  return Vg(R(R({}, e), { setUpdateState: function(r, n, i, a, o, u, s) {
    e.setUpdateState(r, n, i, a, o, u, s), eo.areEqual(a.size, o.size) || (r.createGeometry = !0);
  }, geometryUtils: Gt.Utils }), t);
}
var Iee = R(R({}, dB), Ao), Eee = R(R({}, fB), Ao), Mee = R(R({}, pB), Ao);
function Ba(e, t, r, n) {
  var i, a, o, u, s = 0, c = t.webgl, l = new ui(), d = zc(), f = [], m = new or.GeometryState(), v = Wo.create(), p = /* @__PURE__ */ new Map(), g = Bu.createEmpty();
  function h(y, x, A) {
    var b = A.visible, _ = A.alphaFactor, S = A.pickable, D = A.overpaint, I = A.transparency, M = A.substance, F = A.clipping, P = A.transform, E = A.unitTransforms;
    b !== void 0 && y.setVisibility(b), _ !== void 0 && y.setAlphaFactor(_), S !== void 0 && y.setPickable(S), D !== void 0 && y.setOverpaint(D, c), I !== void 0 && y.setTransparency(I, c), M !== void 0 && y.setSubstance(M, c), F !== void 0 && y.setClipping(F), P !== void 0 && y.setTransform(P), E !== void 0 && (E ? y.setTransform(void 0, E.getSymmetryGroupTransforms(x)) : y.setTransform(void 0, null));
  }
  return { label: e, get groupCount() {
    var y = 0;
    return p.forEach(function(x) {
      var A = x.visual;
      A.renderObject && (y += A.groupCount);
    }), y;
  }, get geometryVersion() {
    return m.version;
  }, get props() {
    return u;
  }, get params() {
    return o;
  }, get state() {
    return v;
  }, get theme() {
    return g;
  }, renderObjects: f, updated: l, createOrUpdate: function(y, x) {
    var A = this;
    return y === void 0 && (y = {}), x && x !== i && (o = r(t, x), u || (u = G.getDefaultValues(o))), u = Object.assign({}, u, y), er.create("Creating or updating UnitsRepresentation", function(b) {
      return _e(A, 0, void 0, function() {
        var _, S, D, I, M, F, P, E, B, N, O, z, V;
        return ye(this, function(U) {
          switch (U.label) {
            case 0:
              if (i || x) return [3, 1];
              throw new Error("missing structure");
            case 1:
              if (!x || i) return [3, 8];
              a = x.unitSymmetryGroups, M = 0, U.label = 2;
            case 2:
              return M < a.length ? (B = a[M], E = n(d, x, u, c), (N = E.createOrUpdate({ webgl: c, runtime: b }, g, u, { group: B, structure: x })) ? [4, N] : [3, 4]) : [3, 7];
            case 3:
              U.sent(), U.label = 4;
            case 4:
              return h(E, B, v), p.set(B.hashCode, { visual: E, group: B }), b.shouldUpdate ? [4, b.update({ message: "Creating or updating UnitsVisual", current: M, max: a.length })] : [3, 6];
            case 5:
              U.sent(), U.label = 6;
            case 6:
              return M++, [3, 2];
            case 7:
              return [3, 43];
            case 8:
              if (!x || tt.areUnitIdsAndIndicesEqual(x, i) && x.child === i.child) return [3, 22];
              a = x.unitSymmetryGroups, _ = p, p = /* @__PURE__ */ new Map(), M = 0, U.label = 9;
            case 9:
              return M < a.length ? (B = a[M], (D = _.get(B.hashCode)) ? (E = D.visual, !((O = E.mustRecreate) === null || O === void 0) && O.call(E, { group: B, structure: x }, u, c) ? (E.destroy(), E = n(d, x, u, c), (N = E.createOrUpdate({ webgl: c, runtime: b }, g, u, { group: B, structure: x })) ? [4, N] : [3, 11]) : [3, 12]) : [3, 15]) : [3, 21];
            case 10:
              U.sent(), U.label = 11;
            case 11:
              return h(E, B, v), [3, 14];
            case 12:
              return (N = E.createOrUpdate({ webgl: c, runtime: b }, g, u, { group: B, structure: x })) ? [4, N] : [3, 14];
            case 13:
              U.sent(), U.label = 14;
            case 14:
              return p.set(B.hashCode, { visual: E, group: B }), _.delete(B.hashCode), E.renderObject && qb(S = E.renderObject.values.tMarker.ref.value.array, Ae.ofBounds(0, S.length), _t.RemoveHighlight), [3, 18];
            case 15:
              return E = n(d, x, u, c), (N = E.createOrUpdate({ webgl: c, runtime: b }, g, u, { group: B, structure: x })) ? [4, N] : [3, 17];
            case 16:
              U.sent(), U.label = 17;
            case 17:
              h(E, B, v), p.set(B.hashCode, { visual: E, group: B }), U.label = 18;
            case 18:
              return b.shouldUpdate ? [4, b.update({ message: "Creating or updating UnitsVisual", current: M, max: a.length })] : [3, 20];
            case 19:
              U.sent(), U.label = 20;
            case 20:
              return M++, [3, 9];
            case 21:
              return _.forEach(function(H) {
                H.visual.destroy();
              }), [3, 43];
            case 22:
              if (!x || x === i || !tt.areUnitIdsAndIndicesEqual(x, i)) return [3, 34];
              a = x.unitSymmetryGroups, M = 0, U.label = 23;
            case 23:
              return M < a.length ? (B = a[M], (D = p.get(B.hashCode)) ? (E = D.visual, !((z = E.mustRecreate) === null || z === void 0) && z.call(E, { group: B, structure: x }, u, t.webgl) ? (E.destroy(), E = n(d, x, u, t.webgl), D.visual = E, (N = E.createOrUpdate({ webgl: c, runtime: b }, g, u, { group: B, structure: x })) ? [4, N] : [3, 25]) : [3, 26]) : [3, 29]) : [3, 33];
            case 24:
              U.sent(), U.label = 25;
            case 25:
              return h(E, B, v), [3, 28];
            case 26:
              return (N = E.createOrUpdate({ webgl: c, runtime: b }, g, u, { group: B, structure: x })) ? [4, N] : [3, 28];
            case 27:
              U.sent(), U.label = 28;
            case 28:
              return D.group = B, [3, 30];
            case 29:
              throw new Error("expected to find visual for hashCode ".concat(B.hashCode));
            case 30:
              return b.shouldUpdate ? [4, b.update({ message: "Creating or updating UnitsVisual", current: M, max: a.length })] : [3, 32];
            case 31:
              U.sent(), U.label = 32;
            case 32:
              return M++, [3, 23];
            case 33:
              return [3, 43];
            case 34:
              I = [], p.forEach(function(H) {
                return I.push(H);
              }), M = 0, F = I.length, U.label = 35;
            case 35:
              return M < F ? (P = I[M], E = P.visual, B = P.group, !((V = E.mustRecreate) === null || V === void 0) && V.call(E, { group: B, structure: i }, u, t.webgl) ? (E.destroy(), E = n(d, i, u, c), I[M].visual = E, (N = E.createOrUpdate({ webgl: c, runtime: b }, g, u, { group: B, structure: i })) ? [4, N] : [3, 37]) : [3, 38]) : [3, 43];
            case 36:
              U.sent(), U.label = 37;
            case 37:
              return h(E, B, v), [3, 40];
            case 38:
              return (N = E.createOrUpdate({ webgl: c, runtime: b }, g, u)) ? [4, N] : [3, 40];
            case 39:
              U.sent(), U.label = 40;
            case 40:
              return b.shouldUpdate ? [4, b.update({ message: "Creating or updating UnitsVisual", current: M, max: F })] : [3, 42];
            case 41:
              U.sent(), U.label = 42;
            case 42:
              return ++M, [3, 35];
            case 43:
              return f.length = 0, p.forEach(function(H) {
                var K = H.visual;
                K.renderObject && (f.push(K.renderObject), m.add(K.renderObject.id, K.geometryVersion));
              }), m.snapshot(), x && (i = x), l.next(s++), [2];
          }
        });
      });
    });
  }, setState: function(y) {
    var x = y.visible, A = y.alphaFactor, b = y.pickable, _ = y.overpaint, S = y.transparency, D = y.substance, I = y.clipping, M = y.transform, F = y.unitTransforms, P = y.syncManually, E = y.markerActions, B = {};
    x !== v.visible && (B.visible = x), A !== v.alphaFactor && (B.alphaFactor = A), b !== v.pickable && (B.pickable = b), _ !== void 0 && i && (B.overpaint = um.remap(_, i)), S !== void 0 && i && (B.transparency = sm.remap(S, i)), D !== void 0 && i && (B.substance = lm.remap(D, i)), I !== void 0 && i && (B.clipping = cm.remap(I, i)), M === void 0 || me.areEqual(M, v.transform, pn) || (B.transform = M), F === v.unitTransforms && (F == null ? void 0 : F.version) === y.unitTransformsVersion || (B.unitTransforms = F, v.unitTransformsVersion = F ? F == null ? void 0 : F.version : -1), P !== v.syncManually && (B.syncManually = P), E !== v.markerActions && (B.markerActions = E), p.forEach(function(N) {
      return h(N.visual, N.group, B);
    }), Wo.update(v, B);
  }, setTheme: function(y) {
    g = y;
  }, getLoci: function(y) {
    if (y === void 0) return tt.Loci(i.target);
    var x = vn;
    return p.forEach(function(A) {
      var b = A.visual.getLoci(y);
      Jl(b) || (x = b);
    }), x;
  }, mark: function(y, x) {
    if (!i || !Pr.is(v.markerActions, x)) return !1;
    if (tt.isLoci(y) || Xe.is(y) || Dt.isLoci(y)) {
      if (!tt.areRootsEquivalent(y.structure, i)) return !1;
      y = Hr.remap(y, i), (tt.isLoci(y) || Xe.is(y) && Xe.isWholeStructure(y)) && (y = B_);
    } else if (!xo(y) && !Kp(y)) return !1;
    if (Hr.isEmpty(y)) return !1;
    var A = !1;
    return p.forEach(function(b) {
      var _ = b.visual;
      A = _.mark(y, x) || A;
    }), A;
  }, destroy: function() {
    p.forEach(function(y) {
      return y.visual.destroy();
    }), p.clear();
  } };
}
function Fm(e, t) {
  var r, n, i, a, o, u, s, c, l = e.defaultProps, d = e.createGeometry, f = e.createLocationIterator, m = e.getLoci, v = e.eachLocation, p = e.setUpdateState, g = e.mustRecreate, h = e.processValues, y = e.dispose, x = e.geometryUtils, A = x.createEmpty, b = x.updateValues, _ = x.updateBoundingSphere, S = x.updateRenderableState, D = x.createPositionIterator, I = Rs.create(), M = { loci: vn, action: _t.None, status: -1 }, F = Object.assign({}, l), P = Bu.createEmpty(), E = -1;
  function B(V) {
    if (I.createNew) {
      if (s = f(n), !V) throw new Error("expected geometry to be given");
      r = function(U, H, K, j, X, W) {
        var Q = oa.getUtils(H), te = Q.createValues, ee = Q.createRenderableState, $ = te(H, Kw(U, X.includeParent), K, j, X), ie = ee(X);
        return x0(H.kind, $, ie, W);
      }(n, V, s, P, F, t), c = D(V, r.values);
    } else {
      if (!r) throw new Error("expected renderObject to be available");
      if (I.updateTransform && Pu((s = f(n)).instanceCount * s.groupCount, r.values), I.updateMatrix && Kw(n, F.includeParent, r.values), I.createGeometry) {
        if (!V) throw new Error("expected geometry to be given");
        k.updateIfChanged(r.values.drawCount, oa.getDrawCount(V)), k.updateIfChanged(r.values.uVertexCount, oa.getVertexCount(V));
      }
      (I.updateTransform || I.createGeometry) && (_(r.values, V || u), c = D(V || u, r.values)), I.updateSize && "uSize" in r.values && Lc(s, P.size, r.values), I.updateColor && Xo(s, c, P.color, r.values), b(r.values, F), S(r.state, F);
    }
    i = F, a = P, o = n, V && (u = V, E += 1);
  }
  function N(V, U, H, K, j, X) {
    return function(W, Q) {
      for (var te = 0, ee = W.length; te < ee; ++te)
        if (Be.isAtomic(Q) && W[te] === "atomic" || Be.isSpheres(Q) && W[te] === "spheres" || Be.isGaussians(Q) && W[te] === "gaussians") return !0;
      return !1;
    }(j.unitKinds, U) ? d(V, U, H, K, j, X) : A(X);
  }
  function O(V, U, H) {
    return function(K) {
      return !!xo(K) || !(!tt.isLoci(K) || !tt.areRootsEquivalent(K.structure, o.structure)) || !!(Xe.is(K) && tt.areRootsEquivalent(K.structure, o.structure) && Xe.isWholeStructure(K));
    }(V) ? U(Ae.ofBounds(0, s.groupCount * s.instanceCount)) : v(V, o, U, H);
  }
  function z(V) {
    r && (h == null || h(r.values, u, i, a, V.webgl));
  }
  return { get groupCount() {
    return s ? s.count : 0;
  }, get renderObject() {
    return s && s.count ? r : void 0;
  }, get geometryVersion() {
    return E;
  }, createOrUpdate: function(V, U, H, K) {
    if (function(X, W, Q) {
      if (!Q && !o) throw new Error("missing structureGroup");
      if (F = W, P = X, n = Q, Rs.reset(I), !r || !o) return I.createNew = !0, void (I.createGeometry = !0);
      p(I, F, i, P, a, n, o), tt.areHierarchiesEqual(o.structure, n.structure) || (I.updateTransform = !0, I.updateColor = !0, I.updateSize = !0), Bc.areEqual(P.color, a.color) || (I.updateColor = !0), o.structure.child !== n.structure.child && (I.createGeometry = !0), td(F.unitKinds, i.unitKinds) || (I.createGeometry = !0), n.group.transformHash !== o.group.transformHash && (n.group.units.length !== o.group.units.length || I.updateColor ? I.updateTransform = !0 : I.updateMatrix = !0);
      var te = n.group.units[0], ee = o.group.units[0];
      Be.areOperatorsEqual(te, ee) || (I.updateTransform = !0), Be.areConformationsEqual(te, ee) || (I.createGeometry = !0), I.updateTransform && (I.updateMatrix = !0), I.updateSize && !("uSize" in r.values) && (I.createGeometry = !0), (I.createGeometry || I.updateTransform) && (o.structure.hashCode !== n.structure.hashCode && (I.updateColor = !0, I.updateSize = !0), (P.color.granularity.startsWith("vertex") || r.values.dColorType.ref.value.startsWith("vertex") || P.color.granularity.startsWith("volume") || r.values.dColorType.ref.value.startsWith("volume")) && (I.updateColor = !0));
    }(U, H, K || o), I.createGeometry) {
      var j = N(V, n.group.units[0], n.structure, P, F, u);
      if (u_(j)) return j.then(function(X) {
        B(X), z(V);
      });
      B(j);
    } else B();
    z(V);
  }, getLoci: function(V) {
    return r ? m(V, o, r.id) : vn;
  }, mark: function(V, U) {
    var H = !0;
    if (Xe.is(V)) {
      H = !1;
      for (var K = o.group.units[0].invariantId, j = 0, X = V.elements; j < X.length; j++)
        if (X[j].unit.invariantId === K) {
          H = !0;
          break;
        }
    }
    return !!H && rr.mark(r, V, U, O, M);
  }, setVisibility: function(V) {
    rr.setVisibility(r, V);
  }, setAlphaFactor: function(V) {
    rr.setAlphaFactor(r, V);
  }, setPickable: function(V) {
    rr.setPickable(r, V);
  }, setColorOnly: function(V) {
    rr.setColorOnly(r, V);
  }, setTransform: function(V, U) {
    rr.setTransform(r, V, U);
  }, setOverpaint: function(V, U) {
    var H = { geometry: u, props: i, webgl: U };
    rr.setOverpaint(r, V, O, !0, H);
  }, setTransparency: function(V, U) {
    var H = { geometry: u, props: i, webgl: U };
    rr.setTransparency(r, V, O, !0, H);
  }, setSubstance: function(V, U) {
    var H = { geometry: u, props: i, webgl: U };
    rr.setSubstance(r, V, O, !0, H);
  }, setClipping: function(V) {
    rr.setClipping(r, V, O, !0);
  }, destroy: function() {
    y == null || y(u), r && (r.state.disposed = !0, r = void 0);
  }, mustRecreate: g };
}
R(R({}, mB), Ao), R(R({}, hB), Ao);
var Gc = R(R({}, lB), Ao);
function Vc(e, t) {
  return Fm(R(R({}, e), { setUpdateState: function(r, n, i, a, o, u, s) {
    e.setUpdateState(r, n, i, a, o, u, s), eo.areEqual(a.size, o.size) || (r.createGeometry = !0);
  }, geometryUtils: Gt.Utils }), t);
}
var Tee = R(R({}, wee), Ao), Pee = R(R({}, dB), Ao), Bee = R(R({}, Dee), Ao), r8 = R(R({}, fB), Ao);
function n8(e, t) {
  return Fm(R(R({}, e), { setUpdateState: function(r, n, i, a, o, u, s) {
    e.setUpdateState(r, n, i, a, o, u, s), eo.areEqual(a.size, o.size) || (r.updateSize = !0);
  }, geometryUtils: Mr.Utils }), t);
}
R(R({}, pB), Ao), R(R({}, mB), Ao), R(R({}, hB), Ao);
var Wo = { create: function() {
  return R(R({}, or.createState()), { unitTransforms: null, unitTransformsVersion: -1 });
}, update: function(e, t) {
  or.updateState(e, t), t.unitTransforms !== void 0 && (e.unitTransforms = t.unitTransforms);
} };
function yB(e, t) {
  return { centerA: at.create(e, t), centerB: at.create(e, t) };
}
var Fee = function() {
  function e(t, r) {
    this.unit = r, this.hasNext = !1, this.traceElementIndex = r.model.atomicHierarchy.derived.residue.traceElementIndex, this.gapIt = jr.transientSegments(SB(r), r.elements), this.value = yB(t, r), this.hasNext = this.gapIt.hasNext;
  }
  return e.prototype.move = function() {
    var t = this.unit, r = t.elements, n = t.residueIndex, i = this.gapIt.move();
    return this.value.centerA.element = this.traceElementIndex[n[r[i.start]]], this.value.centerB.element = this.traceElementIndex[n[r[i.end - 1]]], this.hasNext = this.gapIt.hasNext, this.value;
  }, e;
}(), Nee = function() {
  function e(t, r) {
    this.unit = r, this.hasNext = !1, this.gapIt = jr.transientSegments(SB(r), r.elements), this.value = yB(t, r), this.hasNext = this.gapIt.hasNext;
  }
  return e.prototype.move = function() {
    var t = this.gapIt.move();
    return this.value.centerA.element = this.unit.elements[t.start], this.value.centerB.element = this.unit.elements[t.end - 1], this.hasNext = this.gapIt.hasNext, this.value;
  }, e;
}();
function Ree(e) {
  for (var t = e.atomicConformation, r = t.x, n = t.y, i = t.z, a = e.atomicHierarchy.derived.residue, o = a.polymerType, u = a.traceElementIndex, s = o.length, c = Le.ofBounds(0, e.atomicConformation.atomId.rowCount), l = jr.transientSegments(e.atomicRanges.polymerRanges, c), d = Zt.transientSegments(e.atomicHierarchy.residueAtomSegments, c), f = new Float32Array(3 * s), m = new Float32Array(3 * s), v = 0, p = -1, g = -1, h = w(), y = w(), x = w(), A = w(), b = w(), _ = w(), S = w(), D = w(), I = w(), M = w(), F = w(), P = w(), E = w(), B = w(); l.hasNext; ) {
    var N = l.move();
    for (d.setSegment(N), v = -1, g = -1; d.hasNext; ) {
      v += 1;
      var O = d.move().index;
      v === 0 && (g = O);
      var z = 3 * (p = O - 2);
      w.copy(h, y), w.copy(y, x), w.copy(x, A);
      var V = u[O];
      if (w.set(A, r[V], n[V], i[V]), !(v < 3)) {
        w.sub(b, y, h), w.sub(_, x, y), w.sub(S, A, x), w.sub(F, b, _), w.sub(P, _, S), w.cross(E, F, P), w.normalize(E, E), w.toArray(E, m, z);
        var U = Math.cos(w.angle(F, P)), H = w.magnitude(F), K = w.magnitude(P), j = Math.sqrt(K * H) / Math.max(2, 2 * (1 - U));
        w.scale(D, F, j / H), w.sub(D, y, D), w.toArray(D, f, z), w.scale(I, P, j / K), w.sub(I, x, I), w.toArray(I, f, z + 3), w.copy(B, E);
      }
    }
    var X = 3 * g;
    w.fromArray(D, f, X + 3), w.fromArray(I, f, X + 6), w.normalize(E, w.sub(E, D, I));
    var W = u[g];
    w.set(h, r[W], n[W], i[W]), w.copy(M, h), w.projectPointOnVector(M, M, E, D), w.toArray(M, f, X);
    var Q = p + 2, te = 3 * Q;
    w.fromArray(D, f, te - 3), w.fromArray(I, f, te - 6), w.normalize(E, w.sub(E, D, I));
    var ee = u[Q];
    w.set(h, r[ee], n[ee], i[ee]), w.copy(M, h), w.projectPointOnVector(M, M, E, D), w.toArray(M, f, te);
  }
  return { centers: f };
}
var _6 = L1.createProvider({ label: "Helix Orientation", descriptor: rs({ name: "molstar_helix_orientation" }), type: "dynamic", defaultParams: {}, getParams: function() {
  return {};
}, isApplicable: function(e) {
  return !0;
}, obtain: function(e, t) {
  return _e(void 0, 0, void 0, function() {
    return ye(this, function(r) {
      return [2, { value: Ree(t) }];
    });
  });
} });
function Vu(e) {
  return yr.is(e, 2);
}
function bB(e, t, r) {
  switch (r === void 0 && (r = {}), e.kind) {
    case 0:
      return new Oee(e, t, r);
    case 1:
    case 2:
      return new Lee(e, t);
  }
}
var i2 = yr.create(536870912);
function _B(e, t) {
  return { center: at.create(e, t), centerPrev: at.create(e, t), centerNext: at.create(e, t), first: !1, last: !1, initial: !1, final: !1, secStrucFirst: !1, secStrucLast: !1, secStrucType: i2, moleculeType: 0, coarseBackboneFirst: !1, coarseBackboneLast: !1, isCoarseBackbone: !1, p0: w(), p1: w(), p2: w(), p3: w(), p4: w(), d12: w(), d23: w() };
}
var Ft = w(), yv = w(), bv = w(), Oee = function() {
  function e(t, r, n) {
    var i;
    if (n === void 0 && (n = {}), this.unit = t, this.state = 0, this.p0 = w(), this.p1 = w(), this.p2 = w(), this.p3 = w(), this.p4 = w(), this.p5 = w(), this.p6 = w(), this.d01 = w(), this.d12 = w(), this.d23 = w(), this.d34 = w(), this.hasNext = !1, this.atomicConformation = t.model.atomicConformation, this.residueAtomSegments = t.model.atomicHierarchy.residueAtomSegments, this.polymerRanges = t.model.atomicRanges.polymerRanges, this.traceElementIndex = t.model.atomicHierarchy.derived.residue.traceElementIndex, this.directionFromElementIndex = t.model.atomicHierarchy.derived.residue.directionFromElementIndex, this.directionToElementIndex = t.model.atomicHierarchy.derived.residue.directionToElementIndex, this.moleculeType = t.model.atomicHierarchy.derived.residue.moleculeType, this.cyclicPolymerMap = t.model.atomicRanges.cyclicPolymerMap, this.polymerIt = jr.transientSegments(this.polymerRanges, t.elements), this.residueIt = Zt.transientSegments(this.residueAtomSegments, t.elements), this.value = _B(r, t), this.hasNext = this.residueIt.hasNext && this.polymerIt.hasNext, n.ignoreSecondaryStructure || (this.secondaryStructure = (i = Aa.get(r).value) === null || i === void 0 ? void 0 : i.get(t.invariantId)), n.useHelixOrientation) {
      var a = _6.get(t.model).value;
      if (!a) throw new Error("missing helix-orientation");
      this.helixOrientationCenters = a.centers;
    }
  }
  return e.prototype.atomicPos = function(t, r) {
    r !== -1 && (t[0] = this.atomicConformation.x[r], t[1] = this.atomicConformation.y[r], t[2] = this.atomicConformation.z[r]);
  }, e.prototype.pos = function(t, r, n) {
    var i = this.traceElementIndex[r];
    this.helixOrientationCenters && Vu(n) ? w.fromArray(t, this.helixOrientationCenters, 3 * r) : this.atomicPos(t, i);
  }, e.prototype.updateResidueSegmentRange = function(t) {
    var r = this.residueAtomSegments.index;
    this.residueSegmentMin = r[this.polymerRanges[2 * t.index]], this.residueSegmentMax = r[this.polymerRanges[2 * t.index + 1]];
  }, e.prototype.getResidueIndex = function(t) {
    if (t < this.residueSegmentMin) t = (r = this.cyclicPolymerMap.get(this.residueSegmentMin)) !== void 0 ? r - (this.residueSegmentMin - t - 1) : this.residueSegmentMin;
    else if (t > this.residueSegmentMax) {
      var r;
      t = (r = this.cyclicPolymerMap.get(this.residueSegmentMax)) !== void 0 ? r + (t - this.residueSegmentMax - 1) : this.residueSegmentMax;
    }
    return t;
  }, e.prototype.getSecStruc = function(t) {
    if (this.secondaryStructure) {
      var r = this.secondaryStructure, n = r.type[(0, r.getIndex)(t)];
      return Vu(n) ? 2 : n;
    }
    return i2;
  }, e.prototype.setControlPoint = function(t, r, n, i, a) {
    (function(o) {
      return yr.is(o, 4);
    })(a) || this.helixOrientationCenters && Vu(a) ? w.scale(t, w.add(t, r, w.add(t, i, w.add(t, n, n))), 1 / 4) : w.copy(t, n);
  }, e.prototype.setFromToVector = function(t, r, n) {
    this.value.isCoarseBackbone || this.helixOrientationCenters && Vu(n) ? w.set(t, 1, 0, 0) : (this.atomicPos(yv, this.directionFromElementIndex[r]), this.atomicPos(bv, this.directionToElementIndex[r]), w.sub(t, bv, yv));
  }, e.prototype.setDirection = function(t, r, n, i) {
    w.matchDirection(yv, r, n), w.matchDirection(bv, i, n), w.scale(t, w.add(t, yv, w.add(t, bv, w.add(t, n, n))), 1 / 4);
  }, e.prototype.move = function() {
    var t = this, r = t.residueIt, n = t.polymerIt, i = t.value;
    if (this.state === 0) {
      for (; n.hasNext; ) if (this.polymerSegment = n.move(), r.setSegment(this.polymerSegment), this.updateResidueSegmentRange(this.polymerSegment), r.hasNext) {
        this.state = 1;
        var a = this.residueAtomSegments.index[this.unit.elements[this.polymerSegment.start]], o = this.getResidueIndex(a - 1);
        this.currSecStrucType = a === o ? i2 : this.getSecStruc(o), this.nextSecStrucType = this.getSecStruc(a), this.currCoarseBackbone = this.directionFromElementIndex[o] === -1 || this.directionToElementIndex[o] === -1, this.nextCoarseBackbone = this.directionFromElementIndex[a] === -1 || this.directionToElementIndex[a] === -1;
        break;
      }
    }
    if (this.state === 1) {
      var u = r.move().index, s = this.getResidueIndex(u - 3), c = this.getResidueIndex(u - 2), l = this.getResidueIndex(u - 1), d = this.getResidueIndex(u + 1), f = this.getResidueIndex(u + 2), m = this.getResidueIndex(u + 3);
      this.prevSecStrucType = this.currSecStrucType, this.currSecStrucType = this.nextSecStrucType, this.nextSecStrucType = u === d ? i2 : this.getSecStruc(d), this.prevCoarseBackbone = this.currCoarseBackbone, this.currCoarseBackbone = this.nextCoarseBackbone, this.nextCoarseBackbone = this.directionFromElementIndex[d] === -1 || this.directionToElementIndex[d] === -1, i.secStrucType = this.currSecStrucType, i.secStrucFirst = this.prevSecStrucType !== this.currSecStrucType, i.secStrucLast = this.currSecStrucType !== this.nextSecStrucType, i.isCoarseBackbone = this.currCoarseBackbone, i.coarseBackboneFirst = this.prevCoarseBackbone !== this.currCoarseBackbone, i.coarseBackboneLast = this.currCoarseBackbone !== this.nextCoarseBackbone, i.first = u === this.residueSegmentMin, i.last = u === this.residueSegmentMax, i.moleculeType = this.moleculeType[u], i.initial = u === l, i.final = u === d, i.centerPrev.element = this.traceElementIndex[l], i.center.element = this.traceElementIndex[u], i.centerNext.element = this.traceElementIndex[d];
      var v = this.getSecStruc(s), p = this.getSecStruc(c), g = this.getSecStruc(l), h = this.getSecStruc(u), y = this.getSecStruc(d), x = this.getSecStruc(f), A = this.getSecStruc(m);
      this.pos(this.p0, s, v), this.pos(this.p1, c, p), this.pos(this.p2, l, g), this.pos(this.p3, u, h), this.pos(this.p4, d, y), this.pos(this.p5, f, x), this.pos(this.p6, m, A);
      var b = Vu(v), _ = Vu(p), S = Vu(g), D = Vu(h), I = Vu(y), M = Vu(x), F = Vu(A);
      this.helixOrientationCenters && (D !== S ? D ? (w.copy(this.p0, this.p3), w.copy(this.p1, this.p3), w.copy(this.p2, this.p3)) : S && (w.scale(Ft, w.sub(Ft, this.p2, this.p3), 2), w.add(this.p2, this.p3, Ft), w.add(this.p1, this.p2, Ft), w.add(this.p0, this.p1, Ft)) : D !== _ ? D ? (w.copy(this.p0, this.p2), w.copy(this.p1, this.p2)) : _ && (w.scale(Ft, w.sub(Ft, this.p1, this.p2), 2), w.add(this.p1, this.p2, Ft), w.add(this.p0, this.p1, Ft)) : D !== b && (D ? w.copy(this.p0, this.p1) : b && (w.scale(Ft, w.sub(Ft, this.p0, this.p1), 2), w.add(this.p0, this.p1, Ft))), D !== I ? D ? (w.copy(this.p4, this.p3), w.copy(this.p5, this.p3), w.copy(this.p6, this.p3)) : I && (w.scale(Ft, w.sub(Ft, this.p4, this.p3), 2), w.add(this.p4, this.p3, Ft), w.add(this.p5, this.p4, Ft), w.add(this.p6, this.p5, Ft)) : D !== M ? D ? (w.copy(this.p5, this.p4), w.copy(this.p6, this.p4)) : M && (w.scale(Ft, w.sub(Ft, this.p5, this.p4), 2), w.add(this.p5, this.p4, Ft), w.add(this.p6, this.p5, Ft)) : D !== F && (D ? w.copy(this.p6, this.p5) : F && (w.scale(Ft, w.sub(Ft, this.p6, this.p5), 2), w.add(this.p6, this.p5, Ft)))), this.setFromToVector(this.d01, l, g), this.setFromToVector(this.d12, u, h), this.setFromToVector(this.d23, d, y), this.setFromToVector(this.d34, f, x);
      var P = D && this.helixOrientationCenters, E = 1.5;
      u === l || h !== g && P ? (w.setMagnitude(Ft, w.sub(Ft, this.p3, this.p4), E), w.add(this.p2, this.p3, Ft), w.add(this.p1, this.p2, Ft), w.add(this.p0, this.p1, Ft)) : l === c || h !== p && P ? (w.setMagnitude(Ft, w.sub(Ft, this.p2, this.p3), E), w.add(this.p1, this.p2, Ft), w.add(this.p0, this.p1, Ft)) : (c === s || h !== v && P) && (w.setMagnitude(Ft, w.sub(Ft, this.p1, this.p2), E), w.add(this.p0, this.p1, Ft)), u === d || h !== y && P ? (w.setMagnitude(Ft, w.sub(Ft, this.p3, this.p2), E), w.add(this.p4, this.p3, Ft), w.add(this.p5, this.p4, Ft), w.add(this.p6, this.p5, Ft)) : d === f || h !== x && P ? (w.setMagnitude(Ft, w.sub(Ft, this.p4, this.p3), E), w.add(this.p5, this.p4, Ft), w.add(this.p6, this.p5, Ft)) : (f === m || h !== A && P) && (w.setMagnitude(Ft, w.sub(Ft, this.p5, this.p4), E), w.add(this.p6, this.p5, Ft)), this.setControlPoint(i.p0, this.p0, this.p1, this.p2, p), this.setControlPoint(i.p1, this.p1, this.p2, this.p3, g), this.setControlPoint(i.p2, this.p2, this.p3, this.p4, h), this.setControlPoint(i.p3, this.p3, this.p4, this.p5, y), this.setControlPoint(i.p4, this.p4, this.p5, this.p6, x), this.setDirection(i.d12, this.d01, this.d12, this.d23), this.setDirection(i.d23, this.d12, this.d23, this.d34), r.hasNext || (this.state = 0);
    }
    return this.hasNext = r.hasNext || n.hasNext, this.value;
  }, e;
}(), Lee = function() {
  function e(t, r) {
    switch (this.unit = t, this.state = 0, this.hasNext = !1, this.polymerIt = jr.transientSegments(function(n) {
      switch (n.kind) {
        case 0:
          return n.model.atomicRanges.polymerRanges;
        case 1:
          return n.model.coarseHierarchy.spheres.polymerRanges;
        case 2:
          return n.model.coarseHierarchy.gaussians.polymerRanges;
      }
    }(t), t.elements), this.value = _B(r, t), w.set(this.value.d12, 1, 0, 0), w.set(this.value.d23, 1, 0, 0), t.kind) {
      case 1:
        this.conformation = t.model.coarseConformation.spheres;
        break;
      case 2:
        this.conformation = t.model.coarseConformation.gaussians;
    }
    this.hasNext = this.polymerIt.hasNext;
  }
  return e.prototype.getElementIndex = function(t) {
    return Math.min(Math.max(this.polymerSegment.start, t), this.polymerSegment.end - 1);
  }, e.prototype.pos = function(t, r) {
    var n = this.unit.elements[r];
    t[0] = this.conformation.x[n], t[1] = this.conformation.y[n], t[2] = this.conformation.z[n];
  }, e.prototype.move = function() {
    if (this.state === 0) {
      for (; this.polymerIt.hasNext; ) if (this.polymerSegment = this.polymerIt.move(), this.elementIndex = this.polymerSegment.start, this.elementIndex < this.polymerSegment.end) {
        this.state = 1;
        break;
      }
    }
    if (this.state === 1) {
      var t = this.getElementIndex(this.elementIndex - 2), r = this.getElementIndex(this.elementIndex - 1), n = this.getElementIndex(this.elementIndex + 1), i = this.getElementIndex(this.elementIndex + 2);
      this.value.centerPrev.element = this.value.center.unit.elements[r], this.value.center.element = this.value.center.unit.elements[this.elementIndex], this.value.centerNext.element = this.value.center.unit.elements[n], this.pos(this.value.p0, t), this.pos(this.value.p1, r), this.pos(this.value.p2, this.elementIndex), this.pos(this.value.p3, n), this.pos(this.value.p4, i);
      var a = 0.5;
      this.elementIndex === r ? (w.scale(Ft, w.sub(Ft, this.value.p2, this.value.p3), a), w.add(this.value.p1, this.value.p2, Ft), w.add(this.value.p0, this.value.p1, Ft)) : r === t && (w.scale(Ft, w.sub(Ft, this.value.p1, this.value.p2), a), w.add(this.value.p0, this.value.p1, Ft)), this.elementIndex === n ? (w.scale(Ft, w.sub(Ft, this.value.p2, this.value.p1), a), w.add(this.value.p3, this.value.p2, Ft), w.add(this.value.p4, this.value.p3, Ft)) : n === i && (w.scale(Ft, w.sub(Ft, this.value.p3, this.value.p2), a), w.add(this.value.p4, this.value.p3, Ft)), this.value.first = this.elementIndex === this.polymerSegment.start, this.value.last = this.elementIndex === this.polymerSegment.end - 1, this.elementIndex + 1 >= this.polymerSegment.end && (this.state = 0);
    }
    return this.hasNext = this.elementIndex + 1 < this.polymerSegment.end || this.polymerIt.hasNext, this.elementIndex += 1, this.value;
  }, e;
}(), Fd = w.fromArray, d1 = w.toArray, e5 = w.normalize, kee = w.sub, f1 = w.spline, zee = w.slerp, jw = w.copy, Yw = w.cross, t5 = w.orthogonalize, Gee = w.matchDirection, Vee = w.scale, Ww = w.add;
function xB(e) {
  var t = e + 1, r = 3 * t;
  return { curvePoints: new Float32Array(r), tangentVectors: new Float32Array(r), normalVectors: new Float32Array(r), binormalVectors: new Float32Array(r), widthValues: new Float32Array(t), heightValues: new Float32Array(t), linearSegments: e };
}
function AB(e, t, r, n) {
  (function(i, a, o, u) {
    for (var s = i.curvePoints, c = i.tangentVectors, l = i.linearSegments, d = a.p0, f = a.p1, m = a.p2, v = a.p3, p = a.p4, g = a.secStrucFirst, h = a.secStrucLast, y = 1 - u, x = g ? 0.5 : o, A = h ? 0.5 : o, b = 0; b <= l; ++b) {
      var _ = 1 * b / l;
      if (_ < y) {
        var S = Si(x, o, _);
        f1(i5, d, f, m, v, _ + u, S), f1(r5, d, f, m, v, _ + u + 0.01, x), f1(n5, d, f, m, v, _ + u - 0.01, x);
      } else
        S = Si(o, A, _), f1(i5, f, m, v, p, _ - y, S), f1(r5, f, m, v, p, _ - y + 0.01, S), f1(n5, f, m, v, p, _ - y - 0.01, S);
      d1(i5, s, 3 * b), e5(fl, kee(fl, r5, n5)), d1(fl, c, 3 * b);
    }
  })(e, t, r, n), function(i, a) {
    var o = i.curvePoints, u = i.tangentVectors, s = i.normalVectors, c = i.binormalVectors, l = a.d12, d = a.d23, f = o.length / 3;
    Fd(Qw, u, 0), Fd(Jw, u, 3 * (f - 1)), t5(a5, Qw, l), t5(_v, Jw, d), Gee(_v, _v, a5), jw(ip, a5);
    for (var m = f - 1, v = 0; v < f; ++v) {
      var p = RE(0, m, v) * m, g = v === 0 ? 0 : 1 / (f - p);
      Fd(fl, u, 3 * v), t5(Uu, fl, zee(Uee, ip, _v, g)), d1(Uu, s, 3 * v), jw(ip, Uu), e5(p1, Yw(p1, fl, Uu)), d1(p1, c, 3 * v);
    }
    for (v = 1; v < m; ++v) Fd(ip, s, 3 * (v - 1)), Fd(Uu, s, 3 * v), Fd(Zw, s, 3 * (v + 1)), Vee(Uu, Ww(Uu, ip, Ww(Uu, Zw, Uu)), 1 / 3), d1(Uu, s, 3 * v), Fd(fl, u, 3 * v), e5(p1, Yw(p1, fl, Uu)), d1(p1, c, 3 * v);
  }(e, t);
}
var r5 = w(), n5 = w(), i5 = w(), Uee = w(), fl = w(), Uu = w(), p1 = w(), ip = w(), Zw = w(), Qw = w(), Jw = w(), a5 = w(), _v = w();
function $w(e, t, r, n, i, a, o, u) {
  for (var s = e.widthValues, c = e.heightValues, l = e.linearSegments, d = 1 - u, f = 0; f <= l; ++f) {
    var m = 1 * f / l;
    m < d ? (s[f] = Si(t, r, m + u), c[f] = Si(i, a, m + u)) : (s[f] = Si(r, n, m - d), c[f] = Si(a, o, m - d));
  }
}
var eg, x6, tg, Hee = 0.5, qee = 0.9, Kee = 0.5, Xee = 0.3, eD = 2;
function SB(e) {
  switch (e.kind) {
    case 0:
      return e.model.atomicRanges.gapRanges;
    case 1:
      return e.model.coarseHierarchy.spheres.gapRanges;
    case 2:
      return e.model.coarseHierarchy.gaussians.gapRanges;
  }
}
function CB(e, t, r) {
  var n = e.objectId, i = e.instanceId, a = e.groupId;
  if (r === n) {
    var o = t.structure, u = t.group.units[i];
    if (Be.isAtomic(u)) return uB(o, u, u.polymerElements[a]);
    var s = u.elements, c = u.polymerElements[a], l = Le.indexOf(s, c);
    if (l !== -1) return Xe(o, [{ unit: u, indices: Le.ofSingleton(l) }]);
  }
  return vn;
}
function tD(e, t, r, n, i, a) {
  for (var o = -1, u = -1, s = i; s <= a; s++)
    if (!((l = r[s]) < 0) && (o = Le.indexOf(t, l)) >= 0) {
      u = s;
      break;
    }
  if (o < 0) return !1;
  var c = o;
  for (s = a; s > u; s--) {
    var l;
    if (!((l = r[s]) < 0)) {
      var d = Le.indexOf(t, l);
      if (d >= 0) {
        c = d;
        break;
      }
    }
  }
  return n(Ae.ofRange(e + o, e + c));
}
function wB(e, t, r, n, i) {
  var a = !1, o = i.unit.elements, u = i.unit.model.atomicHierarchy.derived.residue.traceElementIndex, s = i.unit.model.atomicHierarchy.residueAtomSegments.index, c = r(i.unit);
  if (Ae.is(i.indices)) a = Ae.start(i.indices) === 0 && Ae.end(i.indices) === i.unit.elements.length ? n(Ae.ofBounds(e, e + t)) || a : tD(e, c, u, n, m = s[o[Ae.min(i.indices)]], v = s[o[Ae.max(i.indices)]]) || a;
  else for (var l = i.indices, d = 0, f = l.length; d < f; d++) {
    for (var m, v = m = s[o[l[d]]], p = d + 1; p < f; ) {
      var g = s[o[l[p]]];
      if (g - v > 1) break;
      v = g, p++;
    }
    d = p - 1, a = tD(e, c, u, n, m, v) || a;
  }
  return a;
}
function jee(e) {
  return e.polymerElements;
}
function DB(e, t, r) {
  var n = !1;
  if (!Xe.is(e)) return !1;
  var i = t.structure, a = t.group;
  if (!tt.areEquivalent(e.structure, i)) return !1;
  for (var o = a.units[0].polymerElements.length, u = 0, s = e.elements; u < s.length; u++) {
    var c = s[u];
    if (a.unitIndexMap.has(c.unit.id)) {
      var l = a.unitIndexMap.get(c.unit.id) * o;
      if (Be.isAtomic(c.unit)) n = wB(l, o, jee, r, c) || n;
      else if (Ae.is(c.indices)) {
        var d = l + Ae.start(c.indices), f = l + Ae.end(c.indices);
        n = r(Ae.ofBounds(d, f)) || n;
      } else for (var m = 0, v = c.indices.length; m < v; m++) {
        d = c.indices[m];
        for (var p = m + 1; p < v && c.indices[p] === d; ) p++;
        m = p - 1, f = c.indices[m], n = r(Ae.ofRange(l + d, l + f)) || n;
      }
    }
  }
  return n;
}
function Yee(e, t, r) {
  var n = e.objectId, i = e.instanceId, a = e.groupId;
  if (r === n) {
    var o = t.structure, u = t.group.units[i], s = Le.indexOf(u.elements, u.gapElements[a]), c = Le.indexOf(u.elements, u.gapElements[a % 2 ? a - 1 : a + 1]);
    if (s !== -1 && c !== -1) return Dt.Loci(o, [Dt.Location(o, u, s, o, u, c), Dt.Location(o, u, c, o, u, s)]);
  }
  return vn;
}
function Wee(e, t, r) {
  var n = !1;
  if (Dt.isLoci(e)) {
    var i = t.structure, a = t.group;
    if (!tt.areRootsEquivalent(e.structure, i)) return !1;
    e = Dt.remapLoci(e, i);
    for (var o = a.units[0].gapElements.length, u = 0, s = e.bonds; u < s.length; u++) {
      var c = s[u], l = a.unitIndexMap.get(c.aUnit.id);
      if (l !== void 0) {
        var d = Le.indexOf(c.aUnit.gapElements, c.aUnit.elements[c.aIndex]), f = Le.indexOf(c.bUnit.gapElements, c.bUnit.elements[c.bIndex]);
        d !== -1 && f !== -1 && r(Ae.ofSingleton(l * o + d)) && (n = !0);
      }
    }
  } else if (Xe.is(e)) {
    if (i = t.structure, a = t.group, !tt.areRootsEquivalent(e.structure, i)) return !1;
    e = Xe.remap(e, i);
    for (var m = a.units[0].gapElements.length, v = function(h) {
      var y = a.unitIndexMap.get(h.unit.id);
      y !== void 0 && Le.forEach(h.indices, function(x) {
        var A = Le.indexOf(h.unit.gapElements, h.unit.elements[x]);
        A !== -1 && r(Ae.ofSingleton(y * m + A)) && (n = !0);
      });
    }, p = 0, g = e.elements; p < g.length; p++)
      v(g[p]);
  }
  return n;
}
function IB(e, t, r) {
  var n = e.objectId, i = e.instanceId, a = e.groupId;
  if (r === n) {
    var o = t.structure, u = t.group.units[i];
    if (Be.isAtomic(u)) return uB(o, u, u.nucleotideElements[a]);
  }
  return vn;
}
function Zee(e) {
  return e.nucleotideElements;
}
function EB(e, t, r) {
  var n = !1;
  if (!Xe.is(e)) return !1;
  var i = t.structure, a = t.group;
  if (!tt.areEquivalent(e.structure, i)) return !1;
  var o = a.units[0];
  if (!Be.isAtomic(o)) return !1;
  for (var u = o.nucleotideElements.length, s = 0, c = e.elements; s < c.length; s++) {
    var l = c[s];
    if (Be.isAtomic(l.unit) && a.unitIndexMap.has(l.unit.id)) {
      var d = a.unitIndexMap.get(l.unit.id) * u;
      Be.isAtomic(l.unit) && (n = wB(d, u, Zee, r, l) || n);
    }
  }
  return n;
}
(function(e) {
  e.fromGroup = function(t) {
    var r = t.group, n = t.structure, i = r.units[0].polymerElements, a = i.length, o = r.units.length, u = at.create(n);
    return ri(a, o, 1, function(s, c) {
      var l = r.units[c];
      return u.unit = l, u.element = i[s], u;
    });
  };
})(eg || (eg = {})), function(e) {
  e.fromGroup = function(t) {
    var r = t.group, n = t.structure, i = r.units[0].gapElements, a = i.length, o = r.units.length, u = at.create(n);
    return ri(a, o, 1, function(s, c) {
      var l = r.units[c];
      return u.unit = l, u.element = i[s], u;
    });
  };
}(x6 || (x6 = {})), function(e) {
  e.fromGroup = function(t) {
    var r = t.group, n = t.structure, i = r.units[0], a = Be.isAtomic(i) ? i.nucleotideElements : [], o = a.length, u = r.units.length, s = at.create(n);
    return ri(o, u, 1, function(c, l) {
      var d = r.units[l];
      return s.unit = d, s.element = a[c], s;
    });
  };
}(tg || (tg = {}));
var ap = w(), xv = w(), rD = w(), nD = w(), iD = w(), aD = w(), Av = w(), o5 = w(), u5 = w(), oD = w(), op = me.identity(), Qee = w(), uD = OT(), MB = { sizeFactor: G.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), radialSegments: G.Numeric(16, { min: 2, max: 56, step: 2 }, ft.CustomQualityParamInfo) };
function Jee(e, t, r, n, i, a) {
  if (!Be.isAtomic(t)) return Gt.createEmpty(a);
  var o = t.nucleotideElements.length;
  if (!o) return Gt.createEmpty(a);
  for (var u = i.sizeFactor, s = i.radialSegments, c = o * (uD.vertices.length / 3 + 2 * s), l = wt.createState(c, c / 4, a), d = t.elements, f = t.model, m = f.atomicHierarchy, v = m.chainAtomSegments, p = m.residueAtomSegments, g = m.atoms, h = m.index, y = f.atomicHierarchy.derived.residue, x = y.moleculeType, A = y.traceElementIndex, b = g.label_comp_id, _ = t.conformation.invariantPosition, S = Zt.transientSegments(v, d), D = Zt.transientSegments(p, d), I = { radiusTop: 1 * u, radiusBottom: 1 * u, radialSegments: s, bottomCap: !0 }, M = 0; S.hasNext; ) for (D.setSegment(S.move()); D.hasNext; ) {
    var F = D.move().index;
    if (y0(x[F])) {
      var P = b.value(p.offsets[F]), E = -1, B = -1, N = -1, O = -1, z = -1, V = -1, U = 2.5 * u, H = 4.5, K = UM(P), j = HM(P);
      if (!K && !j) {
        var X = h.findAtomOnResidue(F, "C4"), W = h.findAtomOnResidue(F, "N9");
        X !== -1 && W !== -1 && w.distance(_(X, ap), _(W, xv)) < 1.6 ? K = !0 : j = !0;
      }
      K ? (H = 4.5, E = h.findAtomOnResidue(F, "N1"), B = h.findAtomOnResidue(F, "C4"), N = h.findAtomOnResidue(F, "C6"), O = h.findAtomOnResidue(F, "C2"), z = h.findAtomOnResidue(F, "N9"), V = A[F]) : j && (H = 3, E = h.findAtomOnResidue(F, "N3"), B = h.findAtomOnResidue(F, "C6"), N = h.findAtomOnResidue(F, "C4"), O = h.findAtomOnResidue(F, "C2"), (z = h.findAtomOnResidue(F, "N1")) === -1 && (z = h.findAtomOnResidue(F, "C1")), V = A[F]), z !== -1 && V !== -1 && (_(z, iD), _(V, aD), l.currentGroup = M, wi(l, iD, aD, 1, I), E !== -1 && B !== -1 && N !== -1 && O !== -1 && (_(E, ap), _(B, xv), _(N, rD), _(O, nD), w.normalize(Av, w.sub(Av, xv, ap)), w.normalize(o5, w.sub(o5, nD, rD)), w.normalize(u5, w.cross(u5, Av, o5)), me.targetTo(op, ap, xv, u5), w.scaleAndAdd(oD, ap, Av, H / 2 - 0.2), me.scale(op, op, w.set(Qee, 4.5, U, H)), me.setTranslation(op, oD), wt.addPrimitive(l, op, uD))), ++M;
    }
  }
  var Q = wt.getMesh(l), te = Me.expand(Me(), t.boundary.sphere, 1 * i.sizeFactor);
  return Q.setBoundingSphere(te), Q;
}
G.getDefaultValues(MB);
var TB = R(R({}, Gc), MB);
function $ee(e) {
  return Vc({ defaultProps: G.getDefaultValues(TB), createGeometry: Jee, createLocationIterator: tg.fromGroup, getLoci: IB, eachLocation: EB, setUpdateState: function(t, r, n) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor || r.radialSegments !== n.radialSegments;
  } }, e);
}
var Sv = w.zero(), pl = w.zero(), Cv = w.zero(), wv = w.zero(), Nd = w.zero(), m1 = w.zero(), Dv = w.zero(), sD = w.zero(), cD = w.zero(), up = w.zero(), ml = w.zero(), PB = { sizeFactor: G.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), radialSegments: G.Numeric(16, { min: 2, max: 56, step: 2 }, ft.CustomQualityParamInfo), detail: G.Numeric(0, { min: 0, max: 3, step: 1 }, ft.CustomQualityParamInfo) };
G.getDefaultValues(PB);
var Iv = new Float32Array(54), ete = new Uint32Array([0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 14, 15, 12, 13, 8, 9, 10, 11, 0, 1]), tte = new Uint32Array([8, 12, 14, 16, 6, 4, 2, 0, 10]), rte = new Uint32Array([9, 11, 1, 3, 5, 7, 17, 15, 13]), Ev = new Float32Array(36), nte = new Uint32Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1]), ite = new Uint32Array([0, 10, 8, 6, 4, 2]), ate = new Uint32Array([1, 3, 5, 7, 9, 11]), lD = w.zero();
function dD(e, t) {
  for (var r = [], n = 2; n < arguments.length; n++) r[n - 2] = arguments[n];
  for (var i = 0, a = r.length; i < a; ++i) {
    var o = r[i];
    w.toArray(w.add(lD, o, t), e, 2 * i * 3), w.toArray(w.sub(lD, o, t), e, 3 * (2 * i + 1));
  }
}
function ote(e, t, r, n, i, a) {
  if (!Be.isAtomic(t)) return Gt.createEmpty(a);
  var o = t.nucleotideElements.length;
  if (!o) return Gt.createEmpty(a);
  for (var u = i.sizeFactor, s = i.radialSegments, c = i.detail, l = o * (26 + 2 * s), d = wt.createState(l, l / 4, a), f = t.elements, m = t.model, v = m.atomicHierarchy, p = v.chainAtomSegments, g = v.residueAtomSegments, h = v.atoms, y = v.index, x = m.atomicHierarchy.derived.residue, A = x.moleculeType, b = x.traceElementIndex, _ = h.label_comp_id, S = t.conformation.invariantPosition, D = Zt.transientSegments(p, f), I = Zt.transientSegments(g, f), M = 1 * u, F = 1.25 * u, P = { radiusTop: 1 * u, radiusBottom: 1 * u, radialSegments: s }, E = 0; D.hasNext; ) for (I.setSegment(D.move()); I.hasNext; ) {
    var B = I.move().index;
    if (y0(A[B])) {
      var N = _.value(g.offsets[B]), O = -1, z = -1, V = -1, U = -1, H = -1, K = -1, j = -1, X = -1, W = -1, Q = -1;
      d.currentGroup = E;
      var te = UM(N), ee = HM(N);
      if (!te && !ee) {
        var $ = y.findAtomOnResidue(B, "C4"), ie = y.findAtomOnResidue(B, "N9");
        $ !== -1 && ie !== -1 && w.distance(S($, Nd), S(ie, up)) < 1.6 ? te = !0 : ee = !0;
      }
      te ? (O = b[B], z = y.findAtomOnResidue(B, "N1"), V = y.findAtomOnResidue(B, "C2"), U = y.findAtomOnResidue(B, "N3"), H = y.findAtomOnResidue(B, "C4"), (K = y.findAtomOnResidue(B, "C5")) === -1 && (K = y.findAtomOnResidue(B, "N5")), j = y.findAtomOnResidue(B, "C6"), (X = y.findAtomOnResidue(B, "N7")) === -1 && (X = y.findAtomOnResidue(B, "C7")), W = y.findAtomOnResidue(B, "C8"), (Q = y.findAtomOnResidue(B, "N9")) !== -1 && O !== -1 && (S(Q, up), S(O, Sv), d.currentGroup = E, wi(d, up, Sv, 1, P), Mi(d, up, M, c)), z !== -1 && V !== -1 && U !== -1 && H !== -1 && K !== -1 && j !== -1 && X !== -1 && W !== -1 && Q !== -1 && (S(z, pl), S(V, Cv), S(U, wv), S(H, Nd), S(K, m1), S(j, Dv), S(X, sD), S(W, cD), w.triangleNormal(ml, pl, Nd, m1), w.scale(ml, ml, F), dD(Iv, ml, pl, Cv, wv, Nd, m1, Dv, sD, cD, up), wt.addTriangleStrip(d, Iv, ete), wt.addTriangleFan(d, Iv, tte), wt.addTriangleFan(d, Iv, rte))) : ee && (O = b[B], (z = y.findAtomOnResidue(B, "N1")) === -1 && (z = y.findAtomOnResidue(B, "C1")), V = y.findAtomOnResidue(B, "C2"), U = y.findAtomOnResidue(B, "N3"), H = y.findAtomOnResidue(B, "C4"), K = y.findAtomOnResidue(B, "C5"), j = y.findAtomOnResidue(B, "C6"), z !== -1 && O !== -1 && (S(z, pl), S(O, Sv), d.currentGroup = E, wi(d, pl, Sv, 1, P), Mi(d, pl, M, c)), z !== -1 && V !== -1 && U !== -1 && H !== -1 && K !== -1 && j !== -1 && (S(V, Cv), S(U, wv), S(H, Nd), S(K, m1), S(j, Dv), w.triangleNormal(ml, pl, Nd, m1), w.scale(ml, ml, F), dD(Ev, ml, pl, Cv, wv, Nd, m1, Dv), wt.addTriangleStrip(d, Ev, nte), wt.addTriangleFan(d, Ev, ite), wt.addTriangleFan(d, Ev, ate))), ++E;
    }
  }
  var ae = wt.getMesh(d), se = Me.expand(Me(), t.boundary.sphere, 1 * i.sizeFactor);
  return ae.setBoundingSphere(se), ae;
}
var BB = R(R({}, Gc), PB);
function ute(e) {
  return Vc({ defaultProps: G.getDefaultValues(BB), createGeometry: ote, createLocationIterator: tg.fromGroup, getLoci: IB, eachLocation: EB, setUpdateState: function(t, r, n) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor || r.radialSegments !== n.radialSegments;
  } }, e);
}
var s5, Rd = w.zero(), h1 = w.zero(), Od = w.zero(), fD = w.zero(), _i = Tg(3, !1), Ld = me.identity(), ste = w.zero(), pD = w.zero(), mD = w.zero(), c5 = w.zero(), cte = 4, lte = 4, dte = 6, fte = (s5 || (s5 = function() {
  for (var e = Mm(8), t = 0; t < 3; ++t) {
    var r = (t + 1) % 3;
    w.set(Rd, _i[3 * t], _i[3 * t + 1], -0.5), w.set(h1, _i[3 * r], _i[3 * r + 1], -0.5), w.set(Od, _i[3 * r], _i[3 * r + 1], 0.5), w.set(fD, _i[3 * t], _i[3 * t + 1], 0.5), e.add(Rd, h1, Od), e.add(Od, fD, Rd);
  }
  return w.set(Rd, _i[0], _i[1], -0.5), w.set(h1, _i[3], _i[4], -0.5), w.set(Od, _i[6], _i[7], -0.5), e.add(Od, h1, Rd), w.set(Rd, _i[0], _i[1], 0.5), w.set(h1, _i[3], _i[4], 0.5), w.set(Od, _i[6], _i[7], 0.5), e.add(Rd, h1, Od), e.getPrimitive();
}()), s5), FB = { sizeFactor: G.Numeric(0.2, { min: 0, max: 10, step: 0.01 }) };
function pte(e, t, r, n, i, a) {
  var o = t.polymerElements.length;
  if (!o) return Gt.createEmpty(a);
  for (var u = i.sizeFactor, s = 24 * o, c = wt.createState(s, s / 10, a), l = xB(1), d = l.normalVectors, f = l.binormalVectors, m = 0, v = bB(t, r); v.hasNext; ) {
    var p = v.move();
    c.currentGroup = m;
    var g = y0(p.moleculeType), h = yr.is(p.secStrucType, 4);
    if (AB(l, p, g || h ? 0.5 : 0.9, g ? 0.3 : 0.5), h && !p.secStrucLast || !h) {
      var y = n.size.size(p.center) * u, x = cte * y, A = lte * y, b = dte * y, _ = g ? f : d;
      w.fromArray(pD, _, 0), w.fromArray(mD, _, 3), w.normalize(c5, w.add(c5, pD, mD)), me.targetTo(Ld, p.p3, p.p1, c5), me.mul(Ld, Ld, me.rotY90Z180), me.scale(Ld, Ld, w.set(ste, b, A, x)), me.setTranslation(Ld, p.p2), wt.addPrimitive(c, Ld, fte);
    }
    ++m;
  }
  var S = wt.getMesh(c), D = Me.expand(Me(), t.boundary.sphere, 1 * i.sizeFactor);
  return S.setBoundingSphere(D), S;
}
G.getDefaultValues(FB);
var NB = R(R({}, Gc), FB);
function mte(e) {
  return Vc({ defaultProps: G.getDefaultValues(NB), createGeometry: pte, createLocationIterator: eg.fromGroup, getLoci: CB, eachLocation: DB, setUpdateState: function(t, r, n) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor;
  } }, e);
}
var l5 = 10, RB = { sizeFactor: G.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), radialSegments: G.Numeric(16, { min: 2, max: 56, step: 2 }, ft.CustomQualityParamInfo) };
function hte(e, t, r, n, i, a) {
  var o = t.gapElements.length;
  if (!o) return Gt.createEmpty(a);
  for (var u = i.sizeFactor, s = i.radialSegments, c = l5 * s * 2 * o * 2, l = wt.createState(c, c / 10, a), d = t.conformation.invariantPosition, f = w.zero(), m = w.zero(), v = { radiusTop: 1, radiusBottom: 1, topCap: !0, bottomCap: !0, radialSegments: s }, p = 0, g = function(_, S) {
    switch (S.kind) {
      case 0:
        return new Fee(_, S);
      case 1:
      case 2:
        return new Nee(_, S);
    }
  }(r, t); g.hasNext; ) {
    var h = g.move(), y = h.centerA, x = h.centerB;
    y.element === x.element || (d(y.element, f), d(x.element, m), v.radiusTop = v.radiusBottom = n.size.size(y) * u, l.currentGroup = p, jp(l, f, m, 0.5, l5, v), v.radiusTop = v.radiusBottom = n.size.size(x) * u, l.currentGroup = p + 1, jp(l, m, f, 0.5, l5, v)), p += 2;
  }
  var A = wt.getMesh(l), b = Me.expand(Me(), t.boundary.sphere, 1 * i.sizeFactor);
  return A.setBoundingSphere(b), A;
}
G.getDefaultValues(RB);
var OB = R(R({}, Gc), RB);
function vte(e) {
  return Vc({ defaultProps: G.getDefaultValues(OB), createGeometry: hte, createLocationIterator: x6.fromGroup, getLoci: Yee, eachLocation: Wee, setUpdateState: function(t, r, n) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor || r.radialSegments !== n.radialSegments;
  } }, e);
}
var Ar = w(), Rr = w(), gte = w(), Go = w(), As = w(), Mv = w(), Tv = w(), sp = w(), Xu = w(), Ss = w(), d5 = w(), hl = w(), vl = w(), gl = w(), yl = w(), bu = w.fromArray, k1 = w.scale, Au = w.add, gc = w.sub, yte = w.magnitude, hD = w.negate, A6 = w.copy, LB = w.cross, bte = w.set, zr = Oe.add3, _te = Oe.add;
function Pv(e, t, r, n, i, a, o, u, s) {
  var c = t.vertices, l = t.normals, d = t.indices, f = c.elementCount;
  if (bu(Ar, n, e), k1(Tv, Ar, o), k1(Mv, Ar, u), bu(Rr, i, e), k1(Go, Rr, a), LB(Ss, Rr, Ar), bu(Xu, r, e), Au(hl, Au(hl, Xu, Go), Mv), gc(vl, Au(vl, Xu, Go), Tv), gc(gl, gc(gl, Xu, Go), Tv), Au(yl, gc(yl, Xu, Go), Mv), o < u ? (zr(c, yl[0], yl[1], yl[2]), zr(c, gl[0], gl[1], gl[2]), zr(c, vl[0], vl[1], vl[2]), zr(c, hl[0], hl[1], hl[2]), A6(As, Mv)) : (zr(c, hl[0], hl[1], hl[2]), zr(c, vl[0], vl[1], vl[2]), zr(c, gl[0], gl[1], gl[2]), zr(c, yl[0], yl[1], yl[2]), A6(As, Tv)), s) {
    for (var m = 0; m < 4; ++m) zr(l, -Ss[0], -Ss[1], -Ss[2]);
    zr(d, f, f + 1, f + 2), zr(d, f + 2, f + 3, f);
  } else {
    for (m = 0; m < 4; ++m) zr(l, Ss[0], Ss[1], Ss[2]);
    zr(d, f + 2, f + 1, f), zr(d, f, f + 3, f + 2);
  }
}
function f5(e, t, r, n, i, a, o, u, s, c) {
  var l = e.currentGroup, d = e.vertices, f = e.normals, m = e.indices, v = e.groups, p = d.elementCount, g = 0;
  u > 0 ? (bu(Ar, t, 0), bu(Rr, t, 3 * i), g = u / yte(gc(gte, Rr, Ar))) : bte(sp, 0, 0, 0);
  for (var h = 0; h <= i; ++h) {
    var y = a[h], x = o[h], A = u === 0 ? x : u * (1 - h / i), b = 3 * h;
    bu(As, r, b), k1(As, As, A), bu(Go, n, b), k1(Go, Go, y), u > 0 && (bu(Ar, r, b), bu(Rr, n, b), k1(sp, LB(sp, Ar, Rr), g)), bu(Xu, t, b), bu(Ss, r, b), bu(d5, n, b), Au(Ar, Au(Ar, Xu, Go), As), Au(Rr, Ss, sp), zr(d, Ar[0], Ar[1], Ar[2]), zr(f, Rr[0], Rr[1], Rr[2]), Au(Ar, gc(Ar, Xu, Go), As), zr(d, Ar[0], Ar[1], Ar[2]), zr(f, Rr[0], Rr[1], Rr[2]), hD(Rr, d5), zr(d, Ar[0], Ar[1], Ar[2]), zr(f, Rr[0], Rr[1], Rr[2]), gc(Ar, gc(Ar, Xu, Go), As), zr(d, Ar[0], Ar[1], Ar[2]), zr(f, Rr[0], Rr[1], Rr[2]), Au(Rr, hD(Rr, Ss), sp), zr(d, Ar[0], Ar[1], Ar[2]), zr(f, Rr[0], Rr[1], Rr[2]), gc(Ar, Au(Ar, Xu, Go), As), zr(d, Ar[0], Ar[1], Ar[2]), zr(f, Rr[0], Rr[1], Rr[2]), A6(Rr, d5), zr(d, Ar[0], Ar[1], Ar[2]), zr(f, Rr[0], Rr[1], Rr[2]), Au(Ar, Au(Ar, Xu, Go), As), zr(d, Ar[0], Ar[1], Ar[2]), zr(f, Rr[0], Rr[1], Rr[2]);
  }
  for (h = 0; h < i; ++h) {
    for (var _ = 0; _ < 2; _++) zr(m, p + 8 * h + 2 * _, p + 8 * (h + 1) + 2 * _ + 1, p + 8 * h + 2 * _ + 1), zr(m, p + 8 * h + 2 * _, p + 8 * (h + 1) + 2 * _, p + 8 * (h + 1) + 2 * _ + 1);
    for (_ = 2; _ < 4; _++) zr(m, p + 8 * h + 2 * _, p + 8 * (h + 1) + 2 * _, p + 8 * h + 2 * _ + 1), zr(m, p + 8 * (h + 1) + 2 * _, p + 8 * (h + 1) + 2 * _ + 1, p + 8 * h + 2 * _ + 1);
  }
  if (s) {
    var y = a[0], x = o[0], S = u === 0 ? x : u;
    Pv(0, e, t, r, n, y, S, S, !1);
  } else u > 0 && (Pv(0, e, t, r, n, y = a[0], u, -(x = o[0]), !1), Pv(0, e, t, r, n, y, -u, x, !1));
  c && u === 0 && Pv(3 * i, e, t, r, n, y = a[i], x = o[i], x, !0), h = 0;
  for (var D = 8 * (i + 1) + (s ? 4 : u > 0 ? 8 : 0) + (c && u === 0 ? 4 : 0); h < D; ++h) _te(v, l);
}
var Zn = w(), gi = w(), Xa = w(), Yi = w(), wa = w();
function Bv(e, t, r, n, i) {
  e[0] = t[0] * n + r[0] * i, e[1] = t[1] * n + r[1] * i, e[2] = t[2] * n + r[2] * i;
}
function v1(e, t, r, n, i, a) {
  e[0] = t[0] * i + r[0] * a + n[0], e[1] = t[1] * i + r[1] * a + n[1], e[2] = t[2] * i + r[2] * a + n[2];
}
var cc = w.fromArray, xte = w.normalize, p5 = w.scaleAndAdd, vD = w.cross, Ate = w.dot, Ste = w.unitX, Da = Oe.add3, m5 = /* @__PURE__ */ new Map();
function gD(e, t, r, n, i, a, o, u, s, c, l) {
  for (var d = e.currentGroup, f = e.vertices, m = e.normals, v = e.indices, p = e.groups, g = f.elementCount, h = function(z, V) {
    var U = V ? 1 : 0, H = Mu(z, U);
    if (!m5.has(H)) {
      for (var K = [], j = [], X = 0; X < z; ++X) {
        var W = (2 * X + U) / z * Math.PI;
        K[X] = Math.cos(W), j[X] = Math.sin(W);
      }
      m5.set(H, { cos: K, sin: j });
    }
    return m5.get(H);
  }(a, l === "rounded"), y = h.cos, x = h.sin, A = Math.round(a / 4), b = 3 * A, _ = 0; _ <= i; ++_) {
    var S = 3 * _;
    cc(Yi, r, S), cc(wa, n, S), cc(Xa, t, S);
    for (var D = o[_], I = u[_], M = l === "rounded" && I > D, F = 0; F < a; ++F) {
      if (M) {
        v1(gi, Yi, wa, Xa, D * y[F], D * x[F]);
        var P = Ate(wa, Ste) < 0 ? F < A || F >= b ? I - D : -I + D : F >= A && F < b ? -I + D : I - D;
        p5(gi, gi, Yi, P), F === A || F === A - 1 ? Bv(Zn, Yi, wa, 0, 1) : F === b || F === b - 1 ? Bv(Zn, Yi, wa, 0, -1) : Bv(Zn, Yi, wa, y[F], x[F]);
      } else v1(gi, Yi, wa, Xa, I * y[F], D * x[F]), Bv(Zn, Yi, wa, D * y[F], I * x[F]);
      xte(Zn, Zn), Da(f, gi[0], gi[1], gi[2]), Da(m, Zn[0], Zn[1], Zn[2]);
    }
  }
  var E = Math.round(a / 2);
  for (_ = 0; _ < i; ++_) {
    for (F = 0; F < E; ++F) Da(v, g + _ * a + (F + 1) % a, g + (_ + 1) * a + (F + 1) % a, g + _ * a + F), Da(v, g + (_ + 1) * a + (F + 1) % a, g + (_ + 1) * a + F, g + _ * a + F);
    for (F = E; F < a; ++F) Da(v, g + _ * a + (F + 1) % a, g + (_ + 1) * a + F, g + _ * a + F), Da(v, g + (_ + 1) * a + (F + 1) % a, g + (_ + 1) * a + F, g + _ * a + (F + 1) % a);
  }
  if (s) {
    var B = 0, N = f.elementCount;
    for (cc(Yi, r, B), cc(wa, n, B), cc(Xa, t, B), vD(Zn, wa, Yi), Da(f, Xa[0], Xa[1], Xa[2]), Da(m, Zn[0], Zn[1], Zn[2]), D = o[0], I = u[0], (M = l === "rounded" && I > D) && (I -= D), g = f.elementCount, _ = 0; _ < a; ++_) M ? (v1(gi, Yi, wa, Xa, D * y[_], D * x[_]), p5(gi, gi, Yi, _ < A || _ >= b ? I : -I)) : v1(gi, Yi, wa, Xa, I * y[_], D * x[_]), Da(f, gi[0], gi[1], gi[2]), Da(m, Zn[0], Zn[1], Zn[2]), Da(v, g + (_ + 1) % a, g + _, N);
  }
  if (c)
    for (B = 3 * i, N = f.elementCount, cc(Yi, r, B), cc(wa, n, B), cc(Xa, t, B), vD(Zn, Yi, wa), Da(f, Xa[0], Xa[1], Xa[2]), Da(m, Zn[0], Zn[1], Zn[2]), D = o[i], I = u[i], (M = l === "rounded" && I > D) && (I -= D), g = f.elementCount, _ = 0; _ < a; ++_) M ? (v1(gi, Yi, wa, Xa, D * y[_], D * x[_]), p5(gi, gi, Yi, _ < A || _ >= b ? I : -I)) : v1(gi, Yi, wa, Xa, I * y[_], D * x[_]), Da(f, gi[0], gi[1], gi[2]), Da(m, Zn[0], Zn[1], Zn[2]), Da(v, g + _, g + (_ + 1) % a, N);
  var O = (i + 1) * a + (s ? a + 1 : 0) + (c ? a + 1 : 0);
  Oe.addRepeat(p, O, d);
}
var lc = w.fromArray, Cte = w.magnitude, h5 = w.sub, yD = w.add, v5 = w.scale, wte = w.negate, Dte = w.copy, Ite = w.cross, pu = Oe.add3, Ete = Oe.add, xi = w(), Wi = w(), Mte = w(), g5 = w(), kd = w(), bD = w(), cp = w(), Tte = w(), y5 = w();
function b5(e, t, r, n, i, a, o, u) {
  var s = e.currentGroup, c = e.vertices, l = e.normals, d = e.indices, f = e.groups, m = c.elementCount, v = 0;
  u > 0 && (lc(xi, t, 0), lc(Wi, t, 3 * i), v = u / Cte(h5(Mte, Wi, xi)));
  for (var p = 0; p <= i; ++p) {
    var g = a[p], h = o[p], y = u === 0 ? h : u * (1 - p / i), x = 3 * p;
    lc(kd, r, x), v5(kd, kd, y), lc(g5, n, x), v5(g5, g5, g), u > 0 && (lc(xi, r, x), lc(Wi, n, x), v5(bD, Ite(bD, xi, Wi), v)), lc(cp, t, x), lc(Tte, r, x), lc(y5, n, x), yD(xi, cp, kd), wte(Wi, y5), pu(c, xi[0], xi[1], xi[2]), pu(l, Wi[0], Wi[1], Wi[2]), h5(xi, cp, kd), pu(c, xi[0], xi[1], xi[2]), pu(l, Wi[0], Wi[1], Wi[2]), yD(xi, cp, kd), Dte(Wi, y5), pu(c, xi[0], xi[1], xi[2]), pu(l, Wi[0], Wi[1], Wi[2]), h5(xi, cp, kd), pu(c, xi[0], xi[1], xi[2]), pu(l, Wi[0], Wi[1], Wi[2]);
  }
  for (p = 0; p < i; ++p) pu(d, m + 4 * p, m + 4 * (p + 1) + 1, m + 4 * p + 1), pu(d, m + 4 * p, m + 4 * (p + 1), m + 4 * (p + 1) + 1), pu(d, m + 4 * p + 2 + 1, m + 4 * (p + 1) + 2 + 1, m + 4 * p + 2), pu(d, m + 4 * p + 2, m + 4 * (p + 1) + 2 + 1, m + 4 * (p + 1) + 2);
  p = 0;
  for (var A = 4 * (i + 1); p < A; ++p) Ete(f, s);
}
var kB = { sizeFactor: G.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), aspectRatio: G.Numeric(5, { min: 0.1, max: 10, step: 0.1 }), arrowFactor: G.Numeric(1.5, { min: 0, max: 3, step: 0.1 }, { description: "Size factor for sheet arrows" }), tubularHelices: G.Boolean(!1, { description: "Draw alpha helices as tubes" }), helixProfile: G.Select("elliptical", G.arrayToOptions(["elliptical", "rounded", "square"]), { description: "Protein and nucleic helix trace profile" }), detail: G.Numeric(0, { min: 0, max: 3, step: 1 }, ft.CustomQualityParamInfo), linearSegments: G.Numeric(8, { min: 1, max: 48, step: 1 }, ft.CustomQualityParamInfo), radialSegments: G.Numeric(16, { min: 2, max: 56, step: 2 }, ft.CustomQualityParamInfo) };
G.getDefaultValues(kB);
var fo = w();
function Pte(e, t, r, n, i, a) {
  var o = t.polymerElements.length;
  if (!o) return Gt.createEmpty(a);
  for (var u = i.sizeFactor, s = i.detail, c = i.linearSegments, l = i.radialSegments, d = i.aspectRatio, f = i.arrowFactor, m = i.tubularHelices, v = i.helixProfile, p = c * l * o + (l + 1) * o * 2, g = wt.createState(p, p / 10, a), h = Be.isCoarse(t), y = xB(c), x = y.curvePoints, A = y.normalVectors, b = y.binormalVectors, _ = y.widthValues, S = y.heightValues, D = 0, I = bB(t, r, { ignoreSecondaryStructure: !1, useHelixOrientation: m }); I.hasNext; ) {
    var M = I.move();
    g.currentGroup = D;
    var F = y0(M.moleculeType), P = yr.is(M.secStrucType, 4), E = yr.is(M.secStrucType, 2), B = F ? Xee : Kee;
    AB(y, M, E && !m ? qee : Hee, B);
    var N = n.size.size(M.centerPrev) * u, O = n.size.size(M.center) * u, z = n.size.size(M.centerNext) * u;
    h && (N *= d / 2, O *= d / 2, z *= d / 2);
    var V = M.secStrucFirst || M.coarseBackboneFirst || M.first, U = M.secStrucLast || M.coarseBackboneLast || M.last, H = c;
    if (M.initial) {
      var K = c - (H = Math.max(Math.round(c * B), 1));
      x.copyWithin(0, 3 * K), b.copyWithin(0, 3 * K), A.copyWithin(0, 3 * K), w.fromArray(fo, x, 3), w.normalize(fo, w.sub(fo, M.p2, fo)), w.scaleAndAdd(fo, M.p2, fo, O * eD), w.toArray(fo, x, 0);
    } else M.final && (H = Math.max(Math.round(c * (1 - B)), 1), w.fromArray(fo, x, 3 * H - 3), w.normalize(fo, w.sub(fo, M.p2, fo)), w.scaleAndAdd(fo, M.p2, fo, O * eD), w.toArray(fo, x, 3 * H));
    if (M.initial === !0 && M.final === !0) Mi(g, M.p2, 2 * O, s);
    else if (P) {
      var j = N * d, X = O * d, W = z * d, Q = M.secStrucLast ? X * f : 0;
      $w(y, N, O, z, j, X, W, B), l === 2 ? b5(g, x, A, b, H, _, S, Q) : f5(g, x, A, b, H, _, S, Q, V, U);
    } else {
      j = void 0, X = void 0, W = void 0, E && !M.isCoarseBackbone ? m ? (j = N *= 1.5 * d, X = O *= 1.5 * d, W = z *= 1.5 * d) : (j = N * d, X = O * d, W = z * d) : F && !M.isCoarseBackbone ? (j = N * d, X = O * d, W = z * d) : (j = N, X = O, W = z), $w(y, N, O, z, j, X, W, B);
      var te = F && !M.isCoarseBackbone ? [b, A] : [A, b], ee = te[0], $ = te[1];
      if (F && !M.isCoarseBackbone) for (var ie = 0, ae = ee.length; ie < ae; ie++) ee[ie] *= -1;
      l === 2 ? F && !M.isCoarseBackbone ? b5(g, x, ee, $, H, S, _, 0) : b5(g, x, ee, $, H, _, S, 0) : l === 4 ? f5(g, x, ee, $, H, _, S, 0, V, U) : X === O ? gD(g, x, ee, $, H, l, _, S, V, U, "elliptical") : v === "square" ? f5(g, x, ee, $, H, _, S, 0, V, U) : gD(g, x, ee, $, H, l, _, S, V, U, v);
    }
    ++D;
  }
  var se = wt.getMesh(g), le = Me.expand(Me(), t.boundary.sphere, 1 * i.sizeFactor);
  return se.setBoundingSphere(le), se;
}
var zB = R(R({}, Gc), kB);
function Bte(e) {
  return Vc({ defaultProps: G.getDefaultValues(zB), createGeometry: Pte, createLocationIterator: eg.fromGroup, getLoci: CB, eachLocation: DB, setUpdateState: function(t, r, n, i, a, o, u) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor || r.tubularHelices !== n.tubularHelices || r.detail !== n.detail || r.linearSegments !== n.linearSegments || r.radialSegments !== n.radialSegments || r.aspectRatio !== n.aspectRatio || r.arrowFactor !== n.arrowFactor || r.helixProfile !== n.helixProfile;
    var s = Aa.get(o.structure).version;
    t.info.secondaryStructureHash !== s && (t.createGeometry = t.info.secondaryStructureHash !== void 0, t.info.secondaryStructureHash = s);
  } }, e);
}
var GB = { "polymer-trace": function(e, t) {
  return Ba("Polymer trace mesh", e, t, Bte);
}, "polymer-gap": function(e, t) {
  return Ba("Polymer gap cylinder", e, t, vte);
}, "nucleotide-block": function(e, t) {
  return Ba("Nucleotide block mesh", e, t, $ee);
}, "nucleotide-ring": function(e, t) {
  return Ba("Nucleotide ring mesh", e, t, ute);
}, "direction-wedge": function(e, t) {
  return Ba("Polymer direction wedge", e, t, mte);
} }, _D = R(R(R(R(R(R({}, zB), OB), TB), BB), NB), { sizeFactor: G.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), visuals: G.MultiSelect(["polymer-trace", "polymer-gap", "nucleotide-ring"], G.objectToOptions(GB)), bumpFrequency: G.Numeric(2, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory) }), hm, vc = { name: "cartoon", label: "Cartoon", description: "Displays ribbons, planks, tubes smoothly following the trace atoms of polymers.", factory: function(e, t) {
  return or.createMulti("Cartoon", e, t, Wo, GB);
}, getParams: function(e, t) {
  var r = G.clone(_D), n = !1, i = !1;
  return t.units.forEach(function(a) {
    !n && Be.isAtomic(a) && a.nucleotideElements.length && (n = !0), !i && a.gapElements.length && (i = !0);
  }), r.visuals.defaultValue = ["polymer-trace"], n && r.visuals.defaultValue.push("nucleotide-ring"), i && r.visuals.defaultValue.push("polymer-gap"), r;
}, defaultValues: G.getDefaultValues(_D), defaultColorTheme: { name: "chain-id" }, defaultSizeTheme: { name: "uniform" }, isApplicable: function(e) {
  return e.polymerResidueCount > 0;
}, ensureCustomProperties: { attach: function(e, t) {
  return _e(void 0, 0, void 0, function() {
    var r, n, i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, Aa.attach(e, t, void 0, !0)];
        case 1:
          a.sent(), r = 0, n = t.models, a.label = 2;
        case 2:
          return r < n.length ? (i = n[r], [4, _6.attach(e, i, void 0, !0)]) : [3, 5];
        case 3:
          a.sent(), a.label = 4;
        case 4:
          return r++, [3, 2];
        case 5:
          return [2];
      }
    });
  });
}, detach: function(e) {
  Aa.ref(e, !1);
  for (var t = 0, r = e.models; t < r.length; t++) {
    var n = r[t];
    _6.ref(n, !1);
  }
} } }, Fte = { create: function(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return e.elementCount ? [4, Aa.attach({ runtime: Ho, assetManager: new bc() }, e)] : [3, 2];
        case 1:
          i.sent(), i.label = 2;
        case 2:
          return (n = vc.factory(t, vc.getParams)).setTheme(r ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("uniform", { structure: e }) }), [4, n.createOrUpdate(R(R({}, vc.defaultValues), { quality: "auto" }), e).run()];
        case 3:
          return i.sent(), [2, n];
      }
    });
  });
}, update: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return e.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: t }), size: r.sizeThemeRegistry.create("uniform", { structure: t }) }), t.elementCount ? [4, Aa.attach({ runtime: Ho, assetManager: new bc() }, t)] : [3, 2];
        case 1:
          i.sent(), i.label = 2;
        case 2:
          return [4, e.createOrUpdate({}, t).run()];
        case 3:
          return i.sent(), [2];
      }
    });
  });
} }, Fv = w(), Nv = w(), zd = w(), _5 = Oe.add, xD = Oe.add3;
(function(e) {
  e.create = function(t, r, n) {
    t === void 0 && (t = 2048), r === void 0 && (r = 1024);
    var i = Oe.create(Float32Array, 1, r, n ? n.groupBuffer.ref.value : t), a = Oe.create(Float32Array, 3, r, n ? n.startBuffer.ref.value : t), o = Oe.create(Float32Array, 3, r, n ? n.endBuffer.ref.value : t), u = Oe.create(Float32Array, 1, r, n ? n.scaleBuffer.ref.value : t), s = Oe.create(Float32Array, 1, r, n ? n.capBuffer.ref.value : t), c = function(d, f, m, v, p, g, h, y, x, A) {
      for (var b = 0; b < 6; ++b) xD(a, d, f, m), xD(o, v, p, g), _5(i, A), _5(u, h), _5(s, (y ? 1 : 0) + (x ? 2 : 0));
    }, l = function(d, f, m, v, p, g, h) {
      var y = w.distance(d, f), x = Math.floor(m / 2), A = 1 / m;
      w.sub(zd, f, d);
      for (var b = 0; b < x; ++b) {
        var _ = A * (2 * b + 1);
        w.setMagnitude(zd, zd, y * _), w.add(Fv, d, zd), w.setMagnitude(zd, zd, y * A * (2 * (b + 1))), w.add(Nv, d, zd), c(Fv[0], Fv[1], Fv[2], Nv[0], Nv[1], Nv[2], v, p, g, h);
      }
    };
    return { add: c, addFixedCountDashes: l, addFixedLengthDashes: function(d, f, m, v, p, g, h) {
      var y = w.distance(d, f);
      l(d, f, y / m, v, p, g, h);
    }, getCylinders: function() {
      var d = i.elementCount / 6, f = Oe.compact(i, !0), m = Oe.compact(a, !0), v = Oe.compact(o, !0), p = Oe.compact(u, !0), g = Oe.compact(s, !0), h = n && d <= n.cylinderCount ? n.mappingBuffer.ref.value : new Float32Array(18 * d), y = n && d <= n.cylinderCount ? n.indexBuffer.ref.value : new Uint32Array(12 * d);
      return (!n || d > n.cylinderCount) && function(x, A, b) {
        for (var _ = 0; _ < x; ++_) {
          var S = 18 * _;
          A[S] = -1, A[S + 1] = 1, A[S + 2] = -1, A[S + 3] = -1, A[S + 4] = -1, A[S + 5] = -1, A[S + 6] = 1, A[S + 7] = 1, A[S + 8] = -1, A[S + 9] = 1, A[S + 10] = 1, A[S + 11] = 1, A[S + 12] = 1, A[S + 13] = -1, A[S + 14] = -1, A[S + 15] = 1, A[S + 16] = -1, A[S + 17] = 1;
        }
        for (_ = 0; _ < x; ++_) {
          var D = 6 * _, I = 12 * _;
          b[I] = D, b[I + 1] = D + 1, b[I + 2] = D + 2, b[I + 3] = D + 1, b[I + 4] = D + 4, b[I + 5] = D + 2, b[I + 6] = D + 2, b[I + 7] = D + 4, b[I + 8] = D + 3, b[I + 9] = D + 4, b[I + 10] = D + 5, b[I + 11] = D + 3;
        }
      }(d, h, y), Na.create(h, y, f, m, v, p, g, d, n);
    } };
  };
})(hm || (hm = {}));
var Ug = { linkScale: G.Numeric(0.45, { min: 0, max: 1, step: 0.01 }), linkSpacing: G.Numeric(1, { min: 0, max: 2, step: 0.01 }), linkCap: G.Boolean(!1), aromaticScale: G.Numeric(0.3, { min: 0, max: 1, step: 0.01 }), aromaticSpacing: G.Numeric(1.5, { min: 0, max: 3, step: 0.01 }), aromaticDashCount: G.Numeric(2, { min: 2, max: 6, step: 2 }), dashCount: G.Numeric(4, { min: 2, max: 10, step: 2 }), dashScale: G.Numeric(0.8, { min: 0, max: 2, step: 0.1 }), dashCap: G.Boolean(!0), stubCap: G.Boolean(!0), radialSegments: G.Numeric(16, { min: 2, max: 56, step: 2 }, ft.CustomQualityParamInfo) };
G.getDefaultValues(Ug);
var VB = { linkScale: G.Numeric(0.5, { min: 0, max: 1, step: 0.1 }), linkSpacing: G.Numeric(0.1, { min: 0, max: 2, step: 0.01 }), aromaticDashCount: G.Numeric(2, { min: 2, max: 6, step: 2 }), dashCount: G.Numeric(4, { min: 2, max: 10, step: 2 }) };
G.getDefaultValues(VB);
var _r = w(), bl = w(), mu = w(), Nte = w.create(0, 1, 0);
function i8(e, t, r, n) {
  w.normalize(bl, w.sub(bl, t, r)), n !== null ? w.sub(mu, t, n) : w.copy(mu, t), w.normalize(mu, mu);
  var i = w.dot(bl, mu);
  return 1 - Math.abs(i) < 1e-5 && (w.set(mu, 1, 0, 0), i = w.dot(bl, mu), 1 - Math.abs(i) < 1e-5 && (w.set(mu, 0, 1, 0), i = w.dot(bl, mu))), w.setMagnitude(bl, bl, i), w.sub(mu, mu, bl), w.normalize(e, mu);
}
var Vo = w.scale, jn = w.add, un = w.sub, ma = w.setMagnitude, Rte = w.dot;
function Hg(e, t, r, n) {
  var i = t.linkCount, a = t.referencePosition, o = t.position, u = t.style, s = t.radius, c = t.ignore, l = t.stub;
  if (!i) return { mesh: Gt.createEmpty(n) };
  for (var d = r.linkScale, f = r.linkSpacing, m = r.radialSegments, v = r.linkCap, p = r.aromaticScale, g = r.aromaticSpacing, h = r.aromaticDashCount, y = r.dashCount, x = r.dashScale, A = r.dashCap, b = r.stubCap, _ = 2 * m * i * 2, S = wt.createState(_, _ / 4, n), D = w(), I = w(), M = w(), F = w(), P = 0, E = { radiusTop: 1, radiusBottom: 1, radialSegments: m, topCap: v, bottomCap: v }, B = y + 1, N = 0, O = i; N < O; ++N) if (!c || !c(N)) {
    o(D, I, N), jn(F, F, D), jn(F, F, I), P += 2, un(_r, I, D);
    var z = Rte(_r, Nte) > 0, V = s(N), U = u ? u(N) : 0, H = b && !!l && l(N), K = z ? [H, v] : [v, H], j = K[0], X = K[1];
    S.currentGroup = N;
    var W = h + 1;
    if (U === 0) E.radiusTop = E.radiusBottom = V, E.topCap = j, E.bottomCap = X, wi(S, D, I, 0.5, E);
    else if (U === 1) E.radiusTop = E.radiusBottom = V * x, E.topCap = E.bottomCap = A, jp(S, D, I, 0.5, B, E);
    else if (U === 2 || U === 3 || U === 4 || U === 5 || U === 7 || U === 8) {
      var Q = U === 2 || U === 3 ? 2 : U === 4 || U === 5 ? 3 : 1.5, te = V * (d / (0.5 * Q)), ee = (V - te) * f;
      if (i8(M, D, I, a ? a(N) : null), E.topCap = j, E.bottomCap = X, U === 7 || U === 8) {
        E.radiusTop = E.radiusBottom = V, wi(S, D, I, 0.5, E);
        var $ = V + p * V + p * V * g;
        ma(_r, un(_r, I, D), 0.5 * V), jn(D, D, _r), un(I, I, _r), E.radiusTop = E.radiusBottom = V * p, E.topCap = E.bottomCap = A, ma(M, M, $), un(D, D, M), un(I, I, M), jp(S, D, I, 0.5, W, E), U === 8 && (ma(M, M, 2 * $), jn(D, D, M), jn(I, I, M), jp(S, D, I, 0.5, W, E));
      } else if (U === 3 || U === 5) {
        var ie = V + te + d * V * f;
        ma(M, M, ie), E.radiusTop = E.radiusBottom = V, wi(S, D, I, 0.5, E), Vo(_r, _r, f * d * 0.2), jn(D, D, _r), un(I, I, _r), E.radiusTop = E.radiusBottom = te, E.topCap = z ? H : A, E.bottomCap = z ? A : H, ma(M, M, ie), un(D, D, M), un(I, I, M), wi(S, D, I, 0.5, E), Q === 3 && (ma(M, M, 2 * ie), jn(D, D, M), jn(I, I, M), wi(S, D, I, 0.5, E));
      } else ma(M, M, ee), E.radiusTop = E.radiusBottom = te, Q === 3 && wi(S, D, I, 0.5, E), NZ(S, D, I, 0.5, M, E);
    } else U === 6 && (Vo(_r, _r, 0.475), jn(D, D, _r), un(I, I, _r), E.radiusTop = E.radiusBottom = V, E.topCap = j, E.bottomCap = X, wi(S, D, I, 0.5, E));
  }
  var ae = n ? Me.clone(n.boundingSphere) : void 0, se = wt.getMesh(S);
  return P === 0 ? { mesh: se } : (w.scale(F, F, 1 / P), ae && w.distance(F, ae.center) / ae.radius < 1 ? { mesh: se, boundingSphere: ae } : { mesh: se });
}
function UB(e, t, r, n) {
  var i = t.linkCount, a = t.referencePosition, o = t.position, u = t.style, s = t.radius, c = t.ignore, l = t.stub;
  if (!i) return { cylinders: Na.createEmpty(n) };
  for (var d = r.linkScale, f = r.linkSpacing, m = r.linkCap, v = r.aromaticScale, p = r.aromaticSpacing, g = r.aromaticDashCount, h = r.dashCount, y = r.dashScale, x = r.dashCap, A = r.stubCap, b = 2 * i, _ = hm.create(b, b / 4, n), S = w(), D = w(), I = w(), M = w(), F = w(), P = 0, E = h % 2 == 1 ? h : h + 1, B = 0.5 - 0.25 / E, N = g + 1, O = 0.5 - 0.25 / N, z = 0, V = i; z < V; ++z) if (!c || !c(z)) {
    o(S, D, z), jn(F, F, S), jn(F, F, D), P += 2;
    var U = s(z), H = u ? u(z) : 0, K = A && !!l && l(z);
    if (H === 0) Vo(I, jn(I, S, D), 0.5), _.add(S[0], S[1], S[2], I[0], I[1], I[2], 1, m, K, z);
    else if (H === 1) Vo(_r, un(_r, D, S), B), un(D, D, _r), _.addFixedCountDashes(S, D, E, y, x, x, z);
    else if (H === 2 || H === 3 || H === 4 || H === 5 || H === 7 || H === 8) {
      var j = H === 2 || H === 3 ? 2 : H === 4 || H === 5 ? 3 : 1.5, X = d / (0.5 * j), W = (U - X * U) * f;
      if (Vo(I, jn(I, S, D), 0.5), i8(M, S, D, a ? a(z) : null), H === 7 || H === 8) {
        _.add(S[0], S[1], S[2], I[0], I[1], I[2], 1, m, K, z);
        var Q = U + v * U + v * U * p;
        Vo(_r, un(_r, D, S), O), un(D, D, _r), ma(_r, un(_r, D, S), 0.5 * U), jn(S, S, _r), ma(M, M, Q), un(S, S, M), un(D, D, M), _.addFixedCountDashes(S, D, N, v, x, x, z), H === 8 && (ma(M, M, 2 * Q), jn(S, S, M), jn(D, D, M), _.addFixedCountDashes(S, D, N, v, x, x, z));
      } else H === 3 || H === 5 ? (ma(M, M, U + X * U + d * U * f), _.add(S[0], S[1], S[2], I[0], I[1], I[2], 1, m, K, z), ma(_r, un(_r, S, D), U / 1.5), un(S, S, _r), j === 3 && _.add(S[0] + M[0], S[1] + M[1], S[2] + M[2], I[0] + M[0], I[1] + M[1], I[2] + M[2], X, m, K, z), _.add(S[0] - M[0], S[1] - M[1], S[2] - M[2], I[0] - M[0], I[1] - M[1], I[2] - M[2], X, x, K, z)) : (ma(M, M, W), j === 3 && _.add(S[0], S[1], S[2], I[0], I[1], I[2], X, m, K, z), _.add(S[0] + M[0], S[1] + M[1], S[2] + M[2], I[0] + M[0], I[1] + M[1], I[2] + M[2], X, m, K, z), _.add(S[0] - M[0], S[1] - M[1], S[2] - M[2], I[0] - M[0], I[1] - M[1], I[2] - M[2], X, m, K, z));
    } else H === 6 && (Vo(_r, un(_r, D, S), 0.475), jn(S, S, _r), un(D, D, _r), _.add(S[0], S[1], S[2], D[0], D[1], D[2], 1, m, K, z));
  }
  var te = n ? Me.clone(n.boundingSphere) : void 0, ee = _.getCylinders();
  return P === 0 ? { cylinders: ee } : (w.scale(F, F, 1 / P), te && w.distance(F, te.center) / te.radius < 1 ? { cylinders: ee, boundingSphere: te } : { cylinders: ee });
}
function HB(e, t, r, n) {
  var i = t.linkCount, a = t.referencePosition, o = t.position, u = t.style, s = t.ignore;
  if (!i) return { lines: Mr.createEmpty(n) };
  for (var c = r.linkScale, l = r.linkSpacing, d = r.aromaticDashCount, f = r.dashCount, m = 2 * i, v = aa.create(m, m / 4, n), p = w(), g = w(), h = w(), y = w(), x = w(), A = 0, b = f % 2 == 1 ? f : f + 1, _ = 0.5 - 0.25 / b, S = d + 1, D = 0.5 - 0.25 / S, I = 0, M = i; I < M; ++I) if (!s || !s(I)) {
    o(p, g, I), jn(x, x, p), jn(x, x, g), A += 2;
    var F = u ? u(I) : 0;
    if (F === 0) Vo(h, jn(h, p, g), 0.5), v.add(p[0], p[1], p[2], h[0], h[1], h[2], I);
    else if (F === 1) Vo(_r, un(_r, g, p), _), un(g, g, _r), v.addFixedCountDashes(p, g, b, I);
    else if (F === 2 || F === 3 || F === 4 || F === 5 || F === 7 || F === 8) {
      var P = F === 2 || F === 3 ? 2 : F === 4 || F === 5 ? 3 : 1.5, E = (1 - c / (0.5 * P) * 1) * l;
      Vo(h, jn(h, p, g), 0.5), i8(y, p, g, a ? a(I) : null), F === 7 || F === 8 ? (v.add(p[0], p[1], p[2], h[0], h[1], h[2], I), Vo(_r, un(_r, g, p), D), un(g, g, _r), ma(y, y, 4.5 * E), un(p, p, y), un(g, g, y), v.addFixedCountDashes(p, g, S, I), F === 8 && (ma(y, y, 4.5 * E * 2), jn(p, p, y), jn(g, g, y), v.addFixedCountDashes(p, g, S, I))) : F === 3 || F === 5 ? (ma(y, y, 3 * E), v.add(p[0], p[1], p[2], h[0], h[1], h[2], I), Vo(_r, un(_r, p, g), l * c), un(p, p, _r), P === 3 && v.add(p[0] + y[0], p[1] + y[1], p[2] + y[2], h[0] + y[0], h[1] + y[1], h[2] + y[2], I), v.add(p[0] - y[0], p[1] - y[1], p[2] - y[2], h[0] - y[0], h[1] - y[1], h[2] - y[2], I)) : (ma(y, y, 1.5 * E), P === 3 && v.add(p[0], p[1], p[2], h[0], h[1], h[2], I), v.add(p[0] + y[0], p[1] + y[1], p[2] + y[2], h[0] + y[0], h[1] + y[1], h[2] + y[2], I), v.add(p[0] - y[0], p[1] - y[1], p[2] - y[2], h[0] - y[0], h[1] - y[1], h[2] - y[2], I));
    } else F === 6 && (Vo(_r, un(_r, g, p), 0.475), jn(p, p, _r), un(g, g, _r), v.add(p[0], p[1], p[2], g[0], g[1], g[2], I));
  }
  var B = n ? Me.clone(n.boundingSphere) : void 0, N = v.getLines();
  return A === 0 ? { lines: N } : (w.scale(x, x, 1 / A), B && w.distance(x, B.center) / B.radius < 1 ? { lines: N, boundingSphere: B } : { lines: N });
}
var a8 = { includeTypes: G.MultiSelect(o_(cr.Names), G.objectToOptions(cr.Names)), excludeTypes: G.MultiSelect([], G.objectToOptions(cr.Names)), ignoreHydrogens: G.Boolean(!1), aromaticBonds: G.Boolean(!0, { description: "Display aromatic bonds with dashes" }), multipleBonds: G.Select("symmetric", G.arrayToOptions(["off", "symmetric", "offset"])) };
G.getDefaultValues(a8);
var o8 = R(R(R({}, Ug), a8), { adjustCylinderLength: G.Boolean(!1, { description: "Shorten cylinders to reduce overlap with spheres. Useful for for transparent bonds. Not working well with aromatic bonds." }) });
G.getDefaultValues(o8);
var od, u8 = R(R({}, VB), a8);
function qg(e, t, r) {
  return !cr.is(e, r) || cr.is(t, r);
}
function qB(e, t, r) {
  var n = t.elements, i = t.model.atomicHierarchy.derived.atom.atomicNumber, a = t.bonds, o = a.a, u = a.b, s = a.edgeProps.flags, c = r.ignoreHydrogens, l = r.includeTypes, d = r.excludeTypes, f = cr.fromNames(l), m = cr.fromNames(d), v = cr.isAll(f) && m === 0, p = e.child, g = p == null ? void 0 : p.unitMap.get(t.id);
  if (p && !g) throw new Error("expected childUnit to exist if child exists");
  if (!v || c || p) return function(h) {
    return !!g && !qe.has(g.elements, n[o[h]]) || c && (b6(i, n[o[h]]) || b6(i, n[u[h]])) || !v && qg(f, m, s[h]);
  };
}
function KB(e, t) {
  var r = e.interUnitBonds.edges, n = t.ignoreHydrogens, i = t.includeTypes, a = t.excludeTypes, o = cr.fromNames(i), u = cr.fromNames(a), s = cr.isAll(o) && u === 0, c = e.child;
  if (!s || n || c) return function(l) {
    if (c) {
      var d = r[l], f = c.unitMap.get(d.unitA);
      if (!f) return !0;
      var m = e.unitMap.get(d.unitA).elements[d.indexA];
      if (!qe.has(f.elements, m)) return !0;
    }
    if (n) {
      d = r[l];
      var v = e.unitMap.get(d.unitA), p = e.unitMap.get(d.unitB);
      if (y6(v, v.elements[d.indexA]) || y6(p, p.elements[d.indexB])) return !0;
    }
    return !(s || !qg(o, u, r[l].props.flag));
  };
}
function S6(e, t, r) {
  var n = e.objectId, i = e.instanceId, a = e.groupId;
  if (r === n) {
    var o = t.structure, u = t.group.units[i];
    if (Be.isAtomic(u)) {
      var s = o.target, c = u.bonds.a[a], l = u.bonds.b[a];
      return Dt.Loci(s, [Dt.Location(s, u, c, s, u, l), Dt.Location(s, u, l, s, u, c)]);
    }
  }
  return vn;
}
function C6(e, t, r, n) {
  var i = !1;
  if (Dt.isLoci(e)) {
    var a = t.structure, o = t.group;
    if (!tt.areEquivalent(e.structure, a)) return !1;
    var u = o.units[0];
    if (!Be.isAtomic(u)) return !1;
    for (var s = 2 * u.bonds.edgeCount, c = 0, l = e.bonds; c < l.length; c++) {
      var d = l[c];
      if (d.aUnit === d.bUnit) {
        var f = o.unitIndexMap.get(d.aUnit.id);
        if (f !== void 0) {
          var m = u.bonds.getDirectedEdgeIndex(d.aIndex, d.bIndex);
          m !== -1 && r(Ae.ofSingleton(f * s + m)) && (i = !0);
        }
      }
    }
  } else if (Xe.is(e)) {
    if (a = t.structure, o = t.group, !tt.areEquivalent(e.structure, a) || (u = o.units[0], !Be.isAtomic(u))) return !1;
    for (var v = 2 * u.bonds.edgeCount, p = function(y) {
      var x = o.unitIndexMap.get(y.unit.id);
      if (x !== void 0) {
        var A = u.bonds, b = A.offset, _ = A.b;
        Le.forEach(y.indices, function(S) {
          for (var D = b[S], I = b[S + 1]; D < I; D++) n && !Le.has(y.indices, _[D]) || r(Ae.ofSingleton(x * v + D)) && (i = !0);
        });
      }
    }, g = 0, h = e.elements; g < h.length; g++)
      p(h[g]);
  }
  return i;
}
function w6(e, t, r) {
  var n = e.objectId, i = e.groupId;
  if (r === n) {
    var a = t.target, o = t.interUnitBonds.edges[i], u = t.unitMap.get(o.unitA), s = t.unitMap.get(o.unitB);
    return Dt.Loci(a, [Dt.Location(a, u, o.indexA, a, s, o.indexB), Dt.Location(a, s, o.indexB, a, u, o.indexA)]);
  }
  return vn;
}
G.getDefaultValues(u8), function(e) {
  e.fromGroup = function(t) {
    var r = t.group, n = t.structure, i = r.units[0], a = Be.isAtomic(i) ? 2 * i.bonds.edgeCount : 0, o = r.units.length, u = Dt.Location(n, void 0, void 0, n, void 0, void 0);
    return ri(a, o, 1, function(s, c) {
      var l = r.units[c];
      return u.aUnit = l, u.bUnit = l, u.aIndex = l.bonds.a[s], u.bIndex = l.bonds.b[s], u;
    });
  }, e.fromStructure = function(t) {
    var r = t.interUnitBonds.edgeCount, n = Dt.Location(t, void 0, void 0, t, void 0, void 0);
    return ri(r, 1, 1, function(i) {
      var a = t.interUnitBonds.edges[i];
      return n.aUnit = t.unitMap.get(a.unitA), n.aIndex = a.indexA, n.bUnit = t.unitMap.get(a.unitB), n.bIndex = a.indexB, n;
    }, !0);
  };
}(od || (od = {}));
var x5 = /* @__PURE__ */ new Map();
function D6(e, t, r, n) {
  var i = !1;
  if (Dt.isLoci(e)) {
    if (!tt.areEquivalent(e.structure, t)) return !1;
    for (var a = 0, o = e.bonds; a < o.length; a++) {
      var u = o[a], s = t.interUnitBonds.getBondIndexFromLocation(u);
      s !== -1 && r(Ae.ofSingleton(s)) && (i = !0);
    }
  } else if (Xe.is(e)) {
    if (!tt.areEquivalent(e.structure, t) || n && e.elements.length === 1) return !1;
    for (var c = 0, l = e.elements; c < l.length; c++) {
      var d = l[c];
      x5.set(d.unit.id, d.indices);
    }
    for (var f = function(p) {
      var g = p.unit;
      if (!Be.isAtomic(g)) return "continue";
      t.interUnitBonds.getConnectedUnits(g.id).forEach(function(h) {
        var y = x5.get(h.unitB);
        n && !y || Le.forEach(p.indices, function(x) {
          h.connectedIndices.includes(x) && h.getEdges(x).forEach(function(A) {
            if (!n || y && Le.has(y, A.indexB)) {
              var b = t.interUnitBonds.getEdgeIndex(x, g.id, A.indexB, h.unitB);
              r(Ae.ofSingleton(b)) && (i = !0);
            }
          });
        });
      });
    }, m = 0, v = e.elements; m < v.length; m++)
      f(d = v[m]);
    x5.clear();
  }
  return i;
}
var A5 = cr.is;
function XB(e, t, r, n) {
  var i, a = e.elements, o = e.bonds, u = o.edgeCount, s = o.a, c = o.b, l = o.edgeProps, d = o.offset, f = l.order, m = l.flags, v = n.sizeFactor, p = n.sizeAspectRatio, g = n.adjustCylinderLength, h = n.aromaticBonds, y = n.includeTypes, x = n.excludeTypes, A = n.multipleBonds, b = A === "off", _ = A === "symmetric", S = qg(cr.fromNames(y), cr.fromNames(x), 32), D = w(), I = w(), M = e.conformation.invariantPosition, F = at.create(t, e), P = Dt.Location(t, e, void 0, t, e, void 0), E = t.child;
  if (n.includeParent && E) {
    var B = E.unitMap.get(e.id);
    if (!B) throw new Error("expected childUnit to exist");
    i = function(U) {
      var H = a[s[U]], K = a[c[U]];
      return qe.has(B.elements, H) && !qe.has(B.elements, K);
    };
  }
  var N = e.rings, O = N.elementRingIndices, z = N.elementAromaticRingIndices, V = h ? e.resonance.delocalizedTriplets : void 0;
  return { linkCount: 2 * u, referencePosition: function(U) {
    var H, K, j = s[U], X = c[U], W = V == null ? void 0 : V.getThirdElement(j, X);
    if (W !== void 0) return M(a[W], D);
    j > X && (j = (H = [X, j])[0], X = H[1]), d[j + 1] - d[j] == 1 && (j = (K = [X, j])[0], X = K[1]);
    for (var Q = z.get(j) || O.get(j), te = 0, ee = d[j], $ = d[j + 1]; ee < $; ++ee) {
      var ie = c[ee];
      if (ie !== X && ie !== j) {
        if (!Q) return M(a[ie], D);
        var ae = z.get(ie) || O.get(ie);
        if (!ae) continue;
        var se = b2(Q, ae);
        se > te && (te = se, M(a[ie], D));
      }
    }
    return te > 0 ? D : null;
  }, position: function(U, H, K) {
    if (M(a[s[K]], U), M(a[c[K]], H), g) {
      var j = function(ee) {
        return F.element = a[s[ee]], r.size.size(F) * v;
      }(K), X = function(ee) {
        return F.element = a[c[ee]], r.size.size(F) * v;
      }(K), W = Math.min(j, X) * p, Q = Math.sqrt(Math.max(0, j * j - W * W)) - 0.05, te = Math.sqrt(Math.max(0, X * X - W * W)) - 0.05;
      if (Q <= 0.01 && te <= 0.01) return;
      w.normalize(I, w.sub(I, H, U)), w.scaleAndAdd(U, U, I, Q), w.scaleAndAdd(H, H, I, -te);
    }
  }, style: function(U) {
    var H = f[U], K = m[U];
    if (A5(K, 2) || A5(K, 4)) return 1;
    if (H === 3) return b ? 0 : _ ? 4 : 5;
    if (h) {
      var j = s[U], X = c[U], W = z.get(j), Q = z.get(X), te = W && Q ? b2(W, Q) : 0;
      if (A5(K, 16) || te && !S) {
        if (te === 2) return 8;
        if (te === 1 || V != null && V.getThirdElement(j, X)) return 7;
      }
    }
    return H !== 2 || b ? 0 : _ ? 2 : 3;
  }, radius: function(U) {
    return function(H) {
      return P.aIndex = s[H], P.bIndex = c[H], r.size.size(P) * v;
    }(U) * p;
  }, ignore: qB(t, e, n), stub: i };
}
function Ote(e, t, r, n, i, a) {
  if (!Be.isAtomic(t) || !t.bonds.edgeCount) return Na.createEmpty(a);
  var o = r.child, u = o == null ? void 0 : o.unitMap.get(t.id);
  if (o && !u) return Na.createEmpty(a);
  var s = UB(0, XB(t, r, n, i), i, a), c = s.cylinders, l = s.boundingSphere;
  if (l) c.setBoundingSphere(l);
  else if (c.cylinderCount > 0) {
    var d = Me.expand(Me(), (u ?? t).boundary.sphere, 1 * i.sizeFactor);
    c.setBoundingSphere(d);
  }
  return c;
}
function Lte(e, t, r, n, i, a) {
  if (!Be.isAtomic(t) || !t.bonds.edgeCount) return Gt.createEmpty(a);
  var o = r.child, u = o == null ? void 0 : o.unitMap.get(t.id);
  if (o && !u) return Gt.createEmpty(a);
  var s = Hg(0, XB(t, r, n, i), i, a), c = s.mesh, l = s.boundingSphere;
  if (l) c.setBoundingSphere(l);
  else if (c.triangleCount > 0) {
    var d = Me.expand(Me(), (u ?? t).boundary.sphere, 1 * i.sizeFactor);
    c.setBoundingSphere(d);
  }
  return c;
}
var rg = R(R(R(R({}, Gc), Pee), o8), { sizeFactor: G.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), sizeAspectRatio: G.Numeric(2 / 3, { min: 0, max: 3, step: 0.01 }), tryUseImpostor: G.Boolean(!0), includeParent: G.Boolean(!1) });
function jB(e, t, r, n) {
  return r.tryUseImpostor && n && n.extensions.fragDepth ? function(i) {
    return function(a, o) {
      return Fm(R(R({}, a), { setUpdateState: function(u, s, c, l, d, f, m) {
        a.setUpdateState(u, s, c, l, d, f, m), eo.areEqual(l.size, d.size) || (u.updateSize = !0);
      }, geometryUtils: Na.Utils }), o);
    }({ defaultProps: G.getDefaultValues(rg), createGeometry: Ote, createLocationIterator: od.fromGroup, getLoci: S6, eachLocation: C6, setUpdateState: function(a, o, u, s, c, l, d) {
      a.createGeometry = o.sizeAspectRatio !== u.sizeAspectRatio || o.linkScale !== u.linkScale || o.linkSpacing !== u.linkSpacing || o.ignoreHydrogens !== u.ignoreHydrogens || o.linkCap !== u.linkCap || o.aromaticScale !== u.aromaticScale || o.aromaticSpacing !== u.aromaticSpacing || o.aromaticDashCount !== u.aromaticDashCount || o.dashCount !== u.dashCount || o.dashScale !== u.dashScale || o.dashCap !== u.dashCap || o.stubCap !== u.stubCap || !Ja(o.includeTypes, u.includeTypes) || !Ja(o.excludeTypes, u.excludeTypes) || o.adjustCylinderLength !== u.adjustCylinderLength || o.aromaticBonds !== u.aromaticBonds || o.multipleBonds !== u.multipleBonds;
      var f = l.group.units[0], m = d.group.units[0];
      Be.isAtomic(f) && Be.isAtomic(m) && (So.areEqual(f.bonds, m.bonds) || (a.createGeometry = !0, a.updateTransform = !0, a.updateColor = !0, a.updateSize = !0));
    }, mustRecreate: function(a, o, u) {
      return !o.tryUseImpostor || !u;
    } }, i);
  }(e) : function(i) {
    return Vc({ defaultProps: G.getDefaultValues(rg), createGeometry: Lte, createLocationIterator: od.fromGroup, getLoci: S6, eachLocation: C6, setUpdateState: function(a, o, u, s, c, l, d) {
      a.createGeometry = o.sizeFactor !== u.sizeFactor || o.sizeAspectRatio !== u.sizeAspectRatio || o.radialSegments !== u.radialSegments || o.linkScale !== u.linkScale || o.linkSpacing !== u.linkSpacing || o.ignoreHydrogens !== u.ignoreHydrogens || o.linkCap !== u.linkCap || o.aromaticScale !== u.aromaticScale || o.aromaticSpacing !== u.aromaticSpacing || o.aromaticDashCount !== u.aromaticDashCount || o.dashCount !== u.dashCount || o.dashScale !== u.dashScale || o.dashCap !== u.dashCap || o.stubCap !== u.stubCap || !Ja(o.includeTypes, u.includeTypes) || !Ja(o.excludeTypes, u.excludeTypes) || o.adjustCylinderLength !== u.adjustCylinderLength || o.aromaticBonds !== u.aromaticBonds || o.multipleBonds !== u.multipleBonds;
      var f = l.group.units[0], m = d.group.units[0];
      Be.isAtomic(f) && Be.isAtomic(m) && (So.areEqual(f.bonds, m.bonds) || (a.createGeometry = !0, a.updateTransform = !0, a.updateColor = !0, a.updateSize = !0));
    }, mustRecreate: function(a, o, u) {
      return o.tryUseImpostor && !!u;
    } }, i);
  }(e);
}
var S5 = new Dt.ElementBondIterator();
function AD(e, t, r, n) {
  for (S5.setElement(t, r, n); S5.hasNext; ) {
    var i = S5.move();
    return i.otherUnit.conformation.position(i.otherUnit.elements[i.otherIndex], e), e;
  }
  return null;
}
var SD = w();
function YB(e, t, r) {
  var n, i = at.create(e), a = Dt.Location(e, void 0, void 0, e, void 0, void 0), o = e.interUnitBonds, u = o.edgeCount, s = o.edges, c = r.sizeFactor, l = r.sizeAspectRatio, d = r.adjustCylinderLength, f = r.aromaticBonds, m = r.multipleBonds, v = m === "off", p = m === "symmetric", g = w(), h = e.child;
  return r.includeParent && h && (n = function(y) {
    var x = s[y], A = h.unitMap.get(x.unitA), b = h.unitMap.get(x.unitB), _ = e.unitMap.get(x.unitA).elements[x.indexA], S = e.unitMap.get(x.unitB).elements[x.indexB];
    return A && qe.has(A.elements, _) && (!b || !qe.has(b.elements, S));
  }), { linkCount: u, referencePosition: function(y) {
    var x, A, b, _, S = s[y];
    if (S.unitA < S.unitB) x = e.unitMap.get(S.unitA), A = e.unitMap.get(S.unitB), b = S.indexA, _ = S.indexB;
    else {
      if (!(S.unitA > S.unitB)) throw new Error("same units in createInterUnitBondCylinderMesh");
      x = e.unitMap.get(S.unitB), A = e.unitMap.get(S.unitA), b = S.indexB, _ = S.indexA;
    }
    return AD(SD, e, x, b) || AD(SD, e, A, _);
  }, position: function(y, x, A) {
    var b = s[A], _ = e.unitMap.get(b.unitA), S = e.unitMap.get(b.unitB);
    if (_.conformation.position(_.elements[b.indexA], y), S.conformation.position(S.elements[b.indexB], x), d) {
      var D = function(E) {
        var B = s[E];
        return i.unit = e.unitMap.get(B.unitA), i.element = i.unit.elements[B.indexA], t.size.size(i) * c;
      }(A), I = function(E) {
        var B = s[E];
        return i.unit = e.unitMap.get(B.unitB), i.element = i.unit.elements[B.indexB], t.size.size(i) * c;
      }(A), M = Math.min(D, I) * l, F = Math.sqrt(Math.max(0, D * D - M * M)) - 0.05, P = Math.sqrt(Math.max(0, I * I - M * M)) - 0.05;
      if (F <= 0.01 && P <= 0.01) return;
      w.normalize(g, w.sub(g, x, y)), w.scaleAndAdd(y, y, g, F), w.scaleAndAdd(x, x, g, -P);
    }
  }, style: function(y) {
    var x = s[y].props.order, A = ya.create(s[y].props.flag);
    return cr.is(A, 2) || cr.is(A, 4) ? 1 : x === 3 ? v ? 0 : p ? 4 : 5 : f && cr.is(A, 16) ? 7 : x !== 2 || v ? 0 : p ? 2 : 3;
  }, radius: function(y) {
    return function(x) {
      var A = s[x];
      return a.aUnit = e.unitMap.get(A.unitA), a.aIndex = A.indexA, a.bUnit = e.unitMap.get(A.unitB), a.bIndex = A.indexB, t.size.size(a) * c;
    }(y) * l;
  }, ignore: KB(e, r), stub: n };
}
function kte(e, t, r, n, i) {
  if (!t.interUnitBonds.edgeCount) return Na.createEmpty(i);
  var a = UB(0, YB(t, r, n), n, i), o = a.cylinders, u = a.boundingSphere;
  if (u) o.setBoundingSphere(u);
  else if (o.cylinderCount > 0) {
    var s = t.child, c = Me.expand(Me(), (s ?? t).boundary.sphere, 1 * n.sizeFactor);
    o.setBoundingSphere(c);
  }
  return o;
}
function zte(e, t, r, n, i) {
  if (!t.interUnitBonds.edgeCount) return Gt.createEmpty(i);
  var a = Hg(0, YB(t, r, n), n, i), o = a.mesh, u = a.boundingSphere;
  if (u) o.setBoundingSphere(u);
  else if (o.triangleCount > 0) {
    var s = t.child, c = Me.expand(Me(), (s ?? t).boundary.sphere, 1 * n.sizeFactor);
    o.setBoundingSphere(c);
  }
  return o;
}
var ng = R(R(R(R({}, vB), Iee), o8), { sizeFactor: G.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), sizeAspectRatio: G.Numeric(2 / 3, { min: 0, max: 3, step: 0.01 }), tryUseImpostor: G.Boolean(!0), includeParent: G.Boolean(!1) });
function WB(e, t, r, n) {
  return r.tryUseImpostor && n && n.extensions.fragDepth ? function(i) {
    return function(a, o) {
      return Vg(R(R({}, a), { setUpdateState: function(u, s, c, l, d, f, m) {
        a.setUpdateState(u, s, c, l, d, f, m), eo.areEqual(l.size, d.size) || (u.updateSize = !0);
      }, geometryUtils: Na.Utils }), o);
    }({ defaultProps: G.getDefaultValues(ng), createGeometry: kte, createLocationIterator: od.fromStructure, getLoci: w6, eachLocation: D6, setUpdateState: function(a, o, u, s, c, l, d) {
      a.createGeometry = o.sizeAspectRatio !== u.sizeAspectRatio || o.linkScale !== u.linkScale || o.linkSpacing !== u.linkSpacing || o.ignoreHydrogens !== u.ignoreHydrogens || o.linkCap !== u.linkCap || o.aromaticScale !== u.aromaticScale || o.aromaticSpacing !== u.aromaticSpacing || o.aromaticDashCount !== u.aromaticDashCount || o.dashCount !== u.dashCount || o.dashScale !== u.dashScale || o.dashCap !== u.dashCap || o.stubCap !== u.stubCap || !Ja(o.includeTypes, u.includeTypes) || !Ja(o.excludeTypes, u.excludeTypes) || o.adjustCylinderLength !== u.adjustCylinderLength || o.multipleBonds !== u.multipleBonds, l.interUnitBonds !== d.interUnitBonds && (a.createGeometry = !0, a.updateTransform = !0, a.updateColor = !0, a.updateSize = !0);
    }, mustRecreate: function(a, o, u) {
      return !o.tryUseImpostor || !u;
    } }, i);
  }(e) : function(i) {
    return gB({ defaultProps: G.getDefaultValues(ng), createGeometry: zte, createLocationIterator: od.fromStructure, getLoci: w6, eachLocation: D6, setUpdateState: function(a, o, u, s, c, l, d) {
      a.createGeometry = o.sizeFactor !== u.sizeFactor || o.sizeAspectRatio !== u.sizeAspectRatio || o.radialSegments !== u.radialSegments || o.linkScale !== u.linkScale || o.linkSpacing !== u.linkSpacing || o.ignoreHydrogens !== u.ignoreHydrogens || o.linkCap !== u.linkCap || o.aromaticScale !== u.aromaticScale || o.aromaticSpacing !== u.aromaticSpacing || o.aromaticDashCount !== u.aromaticDashCount || o.dashCount !== u.dashCount || o.dashScale !== u.dashScale || o.dashCap !== u.dashCap || o.stubCap !== u.stubCap || !Ja(o.includeTypes, u.includeTypes) || !Ja(o.excludeTypes, u.excludeTypes) || o.adjustCylinderLength !== u.adjustCylinderLength || o.multipleBonds !== u.multipleBonds, l.interUnitBonds !== d.interUnitBonds && (a.createGeometry = !0, a.updateTransform = !0, a.updateColor = !0, a.updateSize = !0);
    }, mustRecreate: function(a, o, u) {
      return o.tryUseImpostor && !!u;
    } }, i);
  }(e);
}
var vm, CD = new Float32Array([-1, 1, -1, -1, 1, 1, 1, -1]), g1 = new Uint16Array([0, 1, 2, 1, 3, 2]), C5 = Oe.add3, Gte = Oe.add2, Vte = Oe.add;
(function(e) {
  e.create = function(t, r, n) {
    t === void 0 && (t = 2048), r === void 0 && (r = 1024), t *= 4, r *= 4;
    var i = Oe.create(Float32Array, 3, r, n ? n.centerBuffer.ref.value : t), a = Oe.create(Float32Array, 2, r, n ? n.mappingBuffer.ref.value : t), o = Oe.create(Uint32Array, 3, r / 2, n ? n.indexBuffer.ref.value : t / 2), u = Oe.create(Float32Array, 1, r, n ? n.groupBuffer.ref.value : t);
    return { add: function(s, c, l, d) {
      for (var f = i.elementCount, m = 0; m < 4; ++m) C5(i, s, c, l), Gte(a, CD[2 * m], CD[2 * m + 1]), Vte(u, d);
      C5(o, f + g1[0], f + g1[1], f + g1[2]), C5(o, f + g1[3], f + g1[4], f + g1[5]);
    }, getSpheres: function() {
      var s = Oe.compact(i, !0), c = Oe.compact(a, !0), l = Oe.compact(o, !0), d = Oe.compact(u, !0);
      return ns.create(s, c, l, d, i.elementCount / 4, n);
    } };
  };
})(vm || (vm = {}));
var Nc, ZB = w.add;
function Kg(e, t, r) {
  var n = r.ignoreHydrogens, i = r.traceOnly, a = t.model.atomicHierarchy.derived.atom.atomicNumber, o = Be.isCoarse(t), u = e.child, s = u == null ? void 0 : u.unitMap.get(t.id);
  if (u && !s) throw new Error("expected childUnit to exist if child exists");
  if (u || n || i) return function(c) {
    return !!s && !qe.has(s.elements, c) || !o && n && b6(a, c) || i && !cB(t, c);
  };
}
function Ute(e, t, r, n, i, a) {
  var o = r.child, u = o == null ? void 0 : o.unitMap.get(t.id);
  if (o && !u) return Gt.createEmpty(a);
  for (var s = i.detail, c = i.sizeFactor, l = t.elements, d = l.length, f = d * cP(s), m = wt.createState(f, f / 2, a), v = w(), p = t.conformation.invariantPosition, g = Kg(r, t, i), h = at.create(r, t), y = n.size.size, x = w(), A = 0, b = 0, _ = 0; _ < d; _++) if (!g || !g(l[_])) {
    h.element = l[_], p(l[_], v), ZB(x, x, v), b += 1, m.currentGroup = _;
    var S = y(h);
    S > A && (A = S), Mi(m, v, S * c, s);
  }
  var D, I = a ? Me.clone(a.boundingSphere) : void 0, M = wt.getMesh(m);
  return b === 0 || (w.scale(x, x, 1 / b), D = I && w.distance(x, I.center) / I.radius < 1 ? I : Me.expand(Me(), (u ?? t).boundary.sphere, A * c + 0.05), M.setBoundingSphere(D)), M;
}
function Hte(e, t, r, n, i, a) {
  var o = r.child, u = o == null ? void 0 : o.unitMap.get(t.id);
  if (o && !u) return ns.createEmpty(a);
  for (var s = t.elements, c = s.length, l = vm.create(c, c / 2, a), d = w(), f = t.conformation.invariantPosition, m = Kg(r, t, i), v = at.create(r, t), p = n.size.size, g = w(), h = 0, y = 0, x = 0; x < c; x++) if (!(m != null && m(s[x]))) {
    f(s[x], d), l.add(d[0], d[1], d[2], x), ZB(g, g, d), y += 1, v.element = s[x];
    var A = p(v);
    A > h && (h = A);
  }
  var b, _ = a ? Me.clone(a.boundingSphere) : void 0, S = l.getSpheres();
  return y === 0 || (w.scale(g, g, 1 / y), b = _ && w.distance(g, _.center) / _.radius < 1 ? _ : Me.expand(Me(), (u ?? t).boundary.sphere, h * i.sizeFactor + 0.05), S.setBoundingSphere(b)), S;
}
function l0(e, t, r) {
  var n = !1;
  if (!Xe.is(e)) return !1;
  var i = t.structure, a = t.group;
  if (!tt.areEquivalent(e.structure, i)) return !1;
  for (var o = a.elements.length, u = a.unitIndexMap, s = 0, c = e.elements; s < c.length; s++) {
    var l = c[s], d = u.get(l.unit.id);
    if (d !== void 0) {
      var f = d * o;
      if (Ae.is(l.indices)) {
        var m = f + Ae.start(l.indices), v = f + Ae.end(l.indices);
        r(Ae.ofBounds(m, v)) && (n = !0);
      } else for (var p = 0, g = l.indices.length; p < g; p++) {
        m = l.indices[p];
        for (var h = p + 1; h < g && l.indices[h] === m; ) h++;
        p = h - 1, v = l.indices[p], n = r(Ae.ofRange(f + m, f + v)) || n;
      }
    }
  }
  return n;
}
function d0(e, t, r) {
  var n = e.objectId, i = e.instanceId, a = e.groupId;
  if (r === n) {
    var o = t.structure, u = t.group.units[i], s = Le.ofSingleton(a);
    return Xe(o.target, [{ unit: u, indices: s }]);
  }
  return vn;
}
function qte(e, t, r) {
  var n = !1;
  if (!Xe.is(e) || !tt.areEquivalent(e.structure, t)) return !1;
  for (var i = t.serialMapping.cumulativeUnitElementCount, a = 0, o = e.elements; a < o.length; a++) {
    var u = o[a], s = t.unitIndexMap.get(u.unit.id);
    if (s !== void 0) if (Ae.is(u.indices)) {
      var c = i[s] + Ae.start(u.indices), l = i[s] + Ae.end(u.indices);
      r(Ae.ofBounds(c, l)) && (n = !0);
    } else for (var d = 0, f = u.indices.length; d < f; d++) {
      var m = i[s] + u.indices[d];
      r(Ae.ofSingleton(m)) && (n = !0);
    }
  }
  return n;
}
function Kte(e, t, r) {
  var n = e.objectId, i = e.groupId;
  if (r === n) {
    var a = t.serialMapping, o = a.unitIndices, u = a.cumulativeUnitElementCount, s = o[i], c = t.units[s], l = i - u[s];
    return Xe(t, [{ unit: c, indices: Le.ofSingleton(l) }]);
  }
  return vn;
}
(function(e) {
  e.fromGroup = function(t) {
    var r = t.group, n = t.structure, i = r.elements.length, a = r.units.length, o = at.create(n);
    return ri(i, a, 1, function(u, s) {
      var c = r.units[s];
      return o.unit = c, o.element = c.elements[u], o;
    });
  }, e.fromStructure = function(t) {
    var r = t.units, n = t.elementCount, i = t.serialMapping, a = i.unitIndices, o = i.elementIndices, u = at.create(t);
    return ri(n, 1, 1, function(s) {
      return u.unit = r[a[s]], u.element = o[s], u;
    }, !0);
  };
})(Nc || (Nc = {}));
var gm = R(R(R({}, Gc), Tee), { sizeFactor: G.Numeric(1, { min: 0, max: 10, step: 0.1 }), detail: G.Numeric(0, { min: 0, max: 3, step: 1 }, ft.CustomQualityParamInfo), ignoreHydrogens: G.Boolean(!1), traceOnly: G.Boolean(!1), tryUseImpostor: G.Boolean(!0) });
function s8(e, t, r, n) {
  return r.tryUseImpostor && n && n.extensions.fragDepth ? function(i) {
    return function(a, o) {
      return Fm(R(R({}, a), { setUpdateState: function(u, s, c, l, d, f, m) {
        a.setUpdateState(u, s, c, l, d, f, m), eo.areEqual(l.size, d.size) || (u.updateSize = !0);
      }, geometryUtils: ns.Utils }), o);
    }({ defaultProps: G.getDefaultValues(gm), createGeometry: Hte, createLocationIterator: Nc.fromGroup, getLoci: d0, eachLocation: l0, setUpdateState: function(a, o, u) {
      a.createGeometry = o.ignoreHydrogens !== u.ignoreHydrogens || o.traceOnly !== u.traceOnly;
    }, mustRecreate: function(a, o, u) {
      return !o.tryUseImpostor || !u;
    } }, i);
  }(e) : function(i) {
    return Vc({ defaultProps: G.getDefaultValues(gm), createGeometry: Ute, createLocationIterator: Nc.fromGroup, getLoci: d0, eachLocation: l0, setUpdateState: function(a, o, u) {
      a.createGeometry = o.sizeFactor !== u.sizeFactor || o.detail !== u.detail || o.ignoreHydrogens !== u.ignoreHydrogens || o.traceOnly !== u.traceOnly;
    }, mustRecreate: function(a, o, u) {
      return o.tryUseImpostor && !!u;
    } }, i);
  }(e);
}
var Xte = R(R({}, Mee), { sizeFactor: G.Numeric(0.2, { min: 0, max: 10, step: 0.1 }), background: G.Boolean(!1), backgroundMargin: G.Numeric(0, { min: 0, max: 1, step: 0.01 }), backgroundColor: G.Color(Kt.black), backgroundOpacity: G.Numeric(0.5, { min: 0, max: 1, step: 0.01 }), borderWidth: G.Numeric(0.25, { min: 0, max: 0.5, step: 0.01 }), level: G.Select("element", [["element", "Element"]], { isEssential: !0 }), chainScale: G.Numeric(10, { min: 0, max: 20, step: 0.1 }), residueScale: G.Numeric(1, { min: 0, max: 20, step: 0.1 }), elementScale: G.Numeric(2, { min: 0, max: 20, step: 0.1 }), attachment: G.Select("middle-left", [["bottom-left", "bottom-left"], ["bottom-center", "bottom-center"], ["bottom-right", "bottom-right"], ["middle-left", "middle-left"], ["middle-center", "middle-center"], ["middle-right", "middle-right"], ["top-left", "top-left"], ["top-center", "top-center"], ["top-right", "top-right"]]), tether: G.Boolean(!0), tetherLength: G.Numeric(0.2, { min: 0, max: 5, step: 0.1 }), tetherBaseWidth: G.Numeric(0, { min: 0, max: 1, step: 0.01 }) });
function c8(e) {
  return function(t, r) {
    return Vg(R(R({}, t), { setUpdateState: function(n, i, a, o, u, s, c) {
      t.setUpdateState(n, i, a, o, u, s, c), eo.areEqual(o.size, u.size) || (n.updateSize = !0), i.background !== a.background && (n.createGeometry = !0), i.backgroundMargin !== a.backgroundMargin && (n.createGeometry = !0), i.tether !== a.tether && (n.createGeometry = !0), i.tetherLength !== a.tetherLength && (n.createGeometry = !0), i.tetherBaseWidth !== a.tetherBaseWidth && (n.createGeometry = !0), i.attachment !== a.attachment && (n.createGeometry = !0), i.fontFamily !== a.fontFamily && (n.createGeometry = !0), i.fontQuality !== a.fontQuality && (n.createGeometry = !0), i.fontStyle !== a.fontStyle && (n.createGeometry = !0), i.fontVariant !== a.fontVariant && (n.createGeometry = !0), i.fontWeight !== a.fontWeight && (n.createGeometry = !0);
    }, geometryUtils: jo.Utils }), r);
  }({ defaultProps: G.getDefaultValues(Xte), createGeometry: jte, createLocationIterator: Nc.fromStructure, getLoci: Kte, eachLocation: qte, setUpdateState: function(t, r, n) {
    t.createGeometry = r.level !== n.level || r.level === "element" && r.elementScale !== n.elementScale;
  } }, e);
}
function jte(e, t, r, n, i) {
  return r.size.size = function() {
    return 1;
  }, r.color.color = function(a) {
    if (at.is(a) && Be.isAtomic(a.unit)) {
      var o = (0, Qe.atom.pdbx_formal_charge)(a);
      if (o > 0) return Kt.red;
      if (o < 0) return Kt.blue;
    }
    return Kt.white;
  }, n.sizeFactor = 0.2, function(a, o, u, s, c) {
    for (var l = at.create(o), d = o.units, f = o.serialMapping, m = Qe.atom.pdbx_formal_charge, v = f.cumulativeUnitElementCount, p = o.elementCount, g = ad.create(s, p, p / 2, c), h = !1, y = 0, x = d.length; y < x; ++y) {
      var A = d[y], b = A.conformation.position, _ = A.elements;
      l.unit = A;
      for (var S = v[y], D = 0, I = _.length; D < I; D++) {
        l.element = _[D];
        var M = m(l);
        if (M !== 0) {
          b(l.element, Rv);
          var F = "".concat(M > 0 ? "+" : "").concat(M);
          g.add(F, Rv[0], Rv[1], Rv[2], 0, 5, S + D), h = !0;
        }
      }
      if (!h) {
        var P = o.boundary.sphere.center;
        g.add("", P[0], P[1], P[2], 0, 0, S + 1);
      }
    }
    return g.getText();
  }(0, t, 0, n, i);
}
var Rv = w(), QB = { "element-sphere": function(e, t) {
  return Ba("Element sphere", e, t, s8);
}, "intra-bond": function(e, t) {
  return Ba("Intra-unit bond cylinder", e, t, jB);
}, "inter-bond": function(e, t) {
  return bf("Inter-unit bond cylinder", e, t, WB);
}, "charge-text": function(e, t) {
  return bf("Charge Text", e, t, c8);
} }, wD = R(R(R(R(R({}, gm), { traceOnly: G.Boolean(!1, { isHidden: !0 }) }), rg), ng), { includeParent: G.Boolean(!1), unitKinds: Bm(["atomic"]), sizeFactor: G.Numeric(0.2, { min: 0.01, max: 10, step: 0.01 }), sizeAspectRatio: G.Numeric(0.5, { min: 0.01, max: 3, step: 0.01 }), visuals: G.MultiSelect(["element-sphere", "intra-bond", "inter-bond", "charge-text"], G.objectToOptions(QB)), bumpFrequency: G.Numeric(0, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory) }), Ya = { name: "ball-and-stick", label: "Ball & Stick", description: "Displays atoms as spheres and bonds as cylinders.", factory: function(e, t) {
  return or.createMulti("Ball & Stick", e, t, Wo, QB);
}, getParams: function(e, t) {
  return G.clone(wD);
}, defaultValues: G.getDefaultValues(wD), defaultColorTheme: { name: "element-symbol" }, defaultSizeTheme: { name: "physical" }, isApplicable: function(e) {
  return e.elementCount > 0;
}, getData: function(e, t) {
  return t.includeParent ? e.asParent() : e;
}, mustRecreate: function(e, t) {
  return e.includeParent !== t.includeParent;
} }, JB = { create: function(e, t, r) {
  var n;
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return (i = Ya.factory(t, Ya.getParams)).setTheme(r ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("uniform", { structure: e }) }), [4, i.createOrUpdate(R(R({}, Ya.defaultValues), { aromaticBonds: ((n = e.model) === null || n === void 0 ? void 0 : n.sourceData.kind) === "mmCIF", quality: "auto", visuals: t.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"] }), e).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return e.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: t }), size: r.sizeThemeRegistry.create("uniform", { structure: t }) }), [4, e.createOrUpdate({ visuals: r.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"] }, t).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} };
function An(e, t, r) {
  r === void 0 && (r = {});
  var n, i, a, o, u = 0, s = new ui(), c = or.createState(), l = zc(), d = [], f = -1, m = Bu.createEmpty(), v = G.getDefaultValues(t.Params);
  r.modifyState && or.updateState(c, r.modifyState(c));
  var p = Rs.create();
  function g(h, y) {
    return xo(h) || $t.isLoci(h) && h.shape === i ? y(Ae.ofBounds(0, i.groupCount * i.transforms.length)) : function(x, A, b) {
      if (!Za.isLoci(x) || x.shape !== A) return !1;
      for (var _ = !1, S = A.groupCount, D = x.groups, I = 0, M = D; I < M.length; I++) {
        var F = M[I], P = F.ids, E = F.instance;
        if (Ae.is(P)) {
          var B = E * S + Ae.start(P), N = E * S + Ae.end(P);
          b(Ae.ofBounds(B, N)) && (_ = !0);
        } else for (var O = 0, z = P.length; O < z; O++) {
          var V = E * S + P[O];
          b(Ae.ofSingleton(V)) && (_ = !0);
        }
      }
      return _;
    }(h, i, y);
  }
  return { label: "Shape geometry", get groupCount() {
    return a ? a.count : 0;
  }, get props() {
    return v;
  }, get params() {
  }, get state() {
    return c;
  }, get theme() {
    return m;
  }, renderObjects: d, get geometryVersion() {
    return f;
  }, updated: s, createOrUpdate: function(h, y) {
    var x = this;
    return h === void 0 && (h = {}), r.modifyProps && (h = r.modifyProps(h)), er.create("ShapeRepresentation.create", function(A) {
      return _e(x, 0, void 0, function() {
        var b, _, S, D, I, M, F, P;
        return ye(this, function(E) {
          switch (E.label) {
            case 0:
              return b = Object.assign(v, h), y ? [4, e(A, y, b, i)] : [3, 2];
            case 1:
              return S = E.sent(), [3, 3];
            case 2:
              S = void 0, E.label = 3;
            case 3:
              if (function(B, N) {
                Rs.reset(p), (N || i) && (N && !i ? p.createNew = !0 : N && i && N.id === i.id || (N && i && N.id !== i.id ? (p.updateTransform = !0, p.createGeometry = !0) : N && console.warn("unexpected state")), p.updateTransform && (p.updateColor = !0, p.updateSize = !0), p.createGeometry && (p.updateColor = !0, p.updateSize = !0));
              }(0, _ = S), _ && (i = _, Object.assign(m, $t.getTheme(i))), p.createNew) d.length = 0, a = $t.groupIterator(i), D = $t.createTransform(i.transforms), I = t.createValues(i.geometry, D, a, m, b), M = t.createRenderableState(b), r.modifyState && Object.assign(M, r.modifyState(M)), or.updateState(c, M), (n = x0(i.geometry.kind, I, M, l)) && d.push(n), o = t.createPositionIterator(i.geometry, n.values);
              else {
                if (!n) throw new Error("expected renderObject to be available");
                p.updateTransform && ($t.createTransform(i.transforms, n.values), a = $t.groupIterator(i), F = a.instanceCount, P = a.groupCount, Pu(F * P, n.values)), p.createGeometry && (k.updateIfChanged(n.values.drawCount, oa.getDrawCount(i.geometry)), k.updateIfChanged(n.values.uVertexCount, oa.getVertexCount(i.geometry))), (p.updateTransform || p.createGeometry) && (t.updateBoundingSphere(n.values, i.geometry), o = t.createPositionIterator(i.geometry, n.values)), p.updateColor && Xo(a, o, m.color, n.values), p.updateSize && "uSize" in n.values && Lc(a, m.size, n.values), t.updateValues(n.values, b), t.updateRenderableState(n.state, b);
              }
              return v = b, (p.createGeometry || p.createNew) && (f += 1), s.next(u++), [2];
          }
        });
      });
    });
  }, getLoci: function(h) {
    if (h === void 0) return $t.Loci(i);
    var y = h.objectId, x = h.groupId, A = h.instanceId;
    return n && n.id === y ? Za.Loci(i, [{ ids: Le.ofSingleton(x), instance: A }]) : vn;
  }, mark: function(h, y) {
    if (!Pr.is(c.markerActions, y)) return !1;
    if (Za.isLoci(h) || $t.isLoci(h)) {
      if (h.shape !== i) return !1;
    } else if (!xo(h)) return !1;
    return rr.mark(n, h, y, g);
  }, setState: function(h) {
    r.modifyState && (h = r.modifyState(h)), n && (h.visible !== void 0 && rr.setVisibility(n, h.visible), h.alphaFactor !== void 0 && rr.setAlphaFactor(n, h.alphaFactor), h.pickable !== void 0 && rr.setPickable(n, h.pickable), h.colorOnly !== void 0 && rr.setColorOnly(n, h.colorOnly), h.overpaint !== void 0 && rr.setOverpaint(n, h.overpaint, g, !0), h.transparency !== void 0 && rr.setTransparency(n, h.transparency, g, !0), h.substance !== void 0 && rr.setSubstance(n, h.substance, g, !0), h.transform !== void 0 && rr.setTransform(n, h.transform)), or.updateState(c, h);
  }, setTheme: function(h) {
    Ir && console.warn("The `ShapeRepresentation` theme is fixed to `ShapeGroupColorTheme` and `ShapeGroupSizeTheme`. Colors are taken from `Shape.getColor` and sizes from `Shape.getSize`");
  }, destroy: function() {
    d.length = 0, n && (n.state.disposed = !0, n = void 0);
  } };
}
var S0 = { granularity: "element", condensed: !1, reverse: !1, countsOnly: !1, hidePrefix: !1, htmlStyling: !0 };
function $B(e, t) {
  switch (t === void 0 && (t = {}), e.kind) {
    case "structure-loci":
      return e.structure.models.map(function(c) {
        return c.entry;
      }).filter(function(c) {
        return !!c;
      }).join(", ");
    case "element-loci":
      return function(c, l) {
        l === void 0 && (l = {});
        var d = R(R({}, S0), l), f = function(m, v, p, g, h) {
          v === void 0 && (v = !1), p === void 0 && (p = !1), g === void 0 && (g = !1), h === void 0 && (h = !1);
          var y = m.structureCount, x = m.chainCount, A = m.residueCount, b = m.conformationCount, _ = m.elementCount;
          if (v || _ !== 1 || A !== 0 || x !== 0) {
            if (v || _ !== 0 || A !== 1 || x !== 0) {
              if (v || _ !== 0 || A !== 0 || x !== 1) {
                if (v)
                  return S = [], y > 0 && S.push(I1(y, "Structure")), x > 0 && S.push(I1(x, "Chain")), A > 0 && S.push(I1(A, "Residue")), b > 0 && S.push(I1(b, "Conformation")), _ > 0 && S.push(I1(_, "Element")), S.join("<small> + </small>");
                var S = [];
                return y > 0 && S.push(y === 1 ? fc(m.firstStructureLoc, { hidePrefix: p, condensed: g, granularity: "structure", reverse: h }, !0) : lp(y, m.firstStructureLoc, "structure", p, h, g)), x > 0 && (S.push(x === 1 ? fc(m.firstChainLoc, { condensed: g, granularity: "chain", hidePrefix: p, reverse: h }, !0) : lp(x, m.firstChainLoc, "chain", p, h, g)), p = !0), A > 0 && (S.push(A === 1 ? fc(m.firstResidueLoc, { condensed: g, granularity: "residue", hidePrefix: p, reverse: h }, !0) : lp(A, m.firstResidueLoc, "residue", p, h, g)), p = !0), b > 0 && (S.push(b === 1 ? fc(m.firstConformationLoc, { condensed: g, granularity: "conformation", hidePrefix: p, reverse: h }, !0) : lp(b, m.firstConformationLoc, "conformation", p, h, g)), p = !0), _ > 0 && S.push(_ === 1 ? fc(m.firstElementLoc, { condensed: g, granularity: "element", hidePrefix: p, reverse: h }, !0) : lp(_, m.firstElementLoc, "element", p, h, g)), S.join("<small> + </small>");
              }
              var D = m.firstChainLoc.unit, I = Be.isAtomic(D) && function(M) {
                var F = M.elements, P = M.model, E = P.atomicHierarchy, B = E.chainAtomSegments, N = E.residueAtomSegments, O = B.offsets[B.index[F[0]]], z = B.offsets[B.index[F[F.length - 1]] + 1] - 1;
                return N.index[z] - N.index[O] + 1;
              }(D) === 1 || Be.Traits.is(D.traits, 1) ? "residue" : "chain";
              return fc(m.firstChainLoc, { hidePrefix: p, condensed: g, granularity: I, reverse: h }, !0);
            }
            return fc(m.firstResidueLoc, { hidePrefix: p, condensed: g, granularity: "residue", reverse: h }, !0);
          }
          return fc(m.firstElementLoc, { hidePrefix: p, condensed: g, granularity: "element", reverse: h }, !0);
        }(c, d.countsOnly, d.hidePrefix, d.condensed, d.reverse);
        return d.htmlStyling ? f : t_(f);
      }(mf.ofLoci(e), t);
    case "bond-loci":
      var r = e.bonds[0];
      return r ? eF(r) : "";
    case "shape-loci":
      return e.shape.name;
    case "group-loci":
      var n = e.groups[0];
      return n ? e.shape.getLabel(Le.start(n.ids), n.instance) : "";
    case "every-loci":
      return "Everything";
    case "empty-loci":
      return "Nothing";
    case "data-loci":
      return e.getLabel();
    case "volume-loci":
      return e.volume.label || "Volume";
    case "isosurface-loci":
      return ["".concat(e.volume.label || "Volume"), "Isosurface at ".concat(ar.IsoValue.toString(e.isoValue))].join(" | ");
    case "cell-loci":
      var i = Le.size(e.indices), a = Le.start(e.indices), o = ar.IsoValue.absolute(e.volume.grid.cells.data[a]), u = ar.IsoValue.toRelative(o, e.volume.grid.stats), s = ["".concat(e.volume.label || "Volume"), "".concat(i === 1 ? "Cell #".concat(a) : "".concat(i, " Cells"))];
      return i === 1 && s.push("".concat(ar.IsoValue.toString(o), " (").concat(ar.IsoValue.toString(u), ")")), s.join(" | ");
  }
}
function I1(e, t) {
  return e === 1 ? "1 ".concat(t) : "".concat(e, " ").concat(t, "s");
}
function lp(e, t, r, n, i, a) {
  return "".concat(fc(t, { granularity: r, hidePrefix: n, reverse: i, condensed: a }), " <small>[+ ").concat(I1(e - 1, "other ".concat(e_(r))), "]</small>");
}
function eF(e, t) {
  return t === void 0 && (t = {}), Xg({ loci: [Xe(e.aStructure, [{ unit: e.aUnit, indices: Le.ofSingleton(e.aIndex) }]), Xe(e.bStructure, [{ unit: e.bUnit, indices: Le.ofSingleton(e.bIndex) }])] }, t);
}
function Xg(e, t) {
  t === void 0 && (t = {});
  var r = R(R({}, S0), t), n = function(i, a) {
    for (var o = a.granularity, u = a.hidePrefix, s = a.reverse, c = a.condensed, l = !0, d = 0, f = i.loci; d < f.length; d++) {
      var m = f[d];
      if (!Xe.is(m) || Xe.size(m) !== 1) {
        l = !1;
        break;
      }
    }
    if (l) {
      var v = i.loci.map(function(S) {
        var D = S.elements[0], I = D.unit, M = D.indices;
        return at.create(S.structure, I, I.elements[Le.start(M)]);
      }), p = v.map(function(S) {
        return tF(S, o, u, s || c);
      });
      if (c) return p.map(function(S) {
        return S[0].replace(/\[.*\]/g, "").trim();
      }).filter(function(S) {
        return !!S;
      }).join(" — ");
      for (var g = 0, h = 0, y = Math.min.apply(Math, p.map(function(S) {
        return S.length;
      })) - 1; h < y; ++h) {
        for (var x = !0, A = 1, b = p.length; A < b; ++A) if (p[0][h] !== p[A][h]) {
          x = !1;
          break;
        }
        if (!x) break;
        g += 1;
      }
      if (g > 0) {
        var _ = [p[0].join(" | ")];
        for (A = 1, b = p.length; A < b; ++A) _.push(p[A].slice(g).filter(function(S) {
          return !!S;
        }).join(" | "));
        return _.join(" — ");
      }
      return p.map(function(S) {
        return S.filter(function(D) {
          return !!D;
        }).join(" | ");
      }).filter(function(S) {
        return !!S;
      }).join("</br>");
    }
    return p = i.loci.map(function(S) {
      return $B(S, a);
    }), p.filter(function(S) {
      return !!S;
    }).join(c ? " — " : "</br>");
  }(e, r);
  return r.htmlStyling ? n : t_(n);
}
function fc(e, t, r) {
  var n, i;
  t === void 0 && (t = {});
  var a = R(R({}, S0), t), o = tF(e, a.granularity, a.hidePrefix, a.reverse || a.condensed), u = (a.condensed ? (i = (n = o[0]) === null || n === void 0 ? void 0 : n.replace(/\[.*\]/g, "").trim()) !== null && i !== void 0 ? i : "" : o.filter(function(s) {
    return !!s;
  }).join(" | ")) + (r ? function(s) {
    if (s >= 90) return "<div><small>Plddt ".concat(s, " (Very high)</small></div>");
    if (s < 90 && s >= 70) return "<div><small>Plddt ".concat(s, " (Confident)</small></div>");
    if (s < 70 && s >= 50) return "<div><small>Plddt ".concat(s, " (Low)</small></div>");
    if (s < 50) return "<div><small>Plddt ".concat(s, " (Very low)</small></div>");
  }(Qe.atom.B_iso_or_equiv(e)) : "");
  return a.htmlStyling ? u : t_(u);
}
function tF(e, t, r, n) {
  t === void 0 && (t = "element"), r === void 0 && (r = !1), n === void 0 && (n = !1);
  var i = [];
  if (!r) {
    var a = e.unit.model.entry;
    a.length > 30 && (a = a.substr(0, 27) + "…"), i.push("<small>".concat(a, "</small>")), t !== "structure" && (i.push("<small>Model ".concat(e.unit.model.modelNum, "</small>")), i.push("<small>Instance ".concat(e.unit.conformation.operator.name, "</small>")));
  }
  return Be.isAtomic(e.unit) ? i.push.apply(i, function(o, u, s) {
    s === void 0 && (s = !1);
    var c = at.residueIndex(o), l = Qe.chain.label_asym_id(o), d = Qe.chain.auth_asym_id(o), f = o.unit.model.atomicHierarchy.residues.label_seq_id.valueKind(c) === 0, m = Qe.residue.label_seq_id(o), v = Qe.residue.auth_seq_id(o), p = Qe.residue.pdbx_PDB_ins_code(o), g = Qe.atom.label_comp_id(o), h = Qe.atom.label_atom_id(o), y = Qe.atom.label_alt_id(o), x = Qe.atom.occupancy(o), A = Qe.atom.id(o), b = Qe.residue.microheterogeneityCompIds(o), _ = u === "residue" && b.length > 1 ? "(".concat(b.join("|"), ")") : g, S = [];
    switch (u) {
      case "element":
        S.push("<b>".concat(h, " ").concat(A, "</b>").concat(y ? "%".concat(y) : ""));
      case "conformation":
        u === "conformation" && y && S.push("<small>Conformation</small> <b>".concat(y, "</b>"));
      case "residue":
        var D = m === v && f ? m : v;
        S.push("<b>".concat(_, " ").concat(D, "</b>").concat(D !== m ? " <small>[auth</small> <b>".concat(m, "</b><small>]</small>") : "", "<b>").concat(p || "", "</b>"));
      case "chain":
        l === d ? S.push("<b>".concat(l, "</b>")) : u === "chain" && Be.Traits.is(o.unit.traits, 1) ? S.push("<small>[auth</small> <b>".concat(d, "</b><small>]</small>")) : S.push("<b>".concat(l, "</b> <small>[auth</small> <b>").concat(d, "</b><small>]</small>"));
    }
    return S.length > 0 && x !== 1 && !s && (S[0] = "".concat(S[0], " <small>[occupancy</small> <b>").concat(Math.round(100 * x) / 100, "</b><small>]</small>")), S.reverse();
  }(e, t, n)) : Be.isCoarse(e.unit) ? i.push.apply(i, function(o, u) {
    var s = Qe.coarse.asym_id(o), c = Qe.coarse.seq_id_begin(o), l = Qe.coarse.seq_id_end(o), d = [];
    switch (u) {
      case "element":
      case "conformation":
      case "residue":
        if (c === l) {
          var f = Qe.coarse.entityKey(o), m = o.unit.model.sequence.byEntityKey[f].sequence.compId.value(c - 1);
          d.push("<b>".concat(m, " ").concat(c, "</b>"));
        } else d.push("<b>".concat(c, "-").concat(l, "</b>"));
      case "chain":
        d.push("<b>".concat(s, "</b>"));
    }
    return d.reverse();
  }(e, t)) : i.push("Unknown"), n ? i.reverse() : i;
}
function ym(e, t) {
  t === void 0 && (t = {});
  var r = R(R(R({}, S0), { measureOnly: !1, unitLabel: "Å" }), t), n = e.loci.map(function(s) {
    return Hr.getCenter(s);
  }), i = n[0], a = n[1], o = "".concat(w.distance(i, a).toFixed(2), " ").concat(r.unitLabel);
  if (r.measureOnly) return o;
  var u = Xg(e, r);
  return r.condensed ? "".concat(o, " | ").concat(u) : "Distance ".concat(o, "</br>").concat(u);
}
function l8(e, t) {
  t === void 0 && (t = {});
  var r = R(R(R({}, S0), { measureOnly: !1 }), t), n = e.loci.map(function(d) {
    return Hr.getCenter(d);
  }), i = n[0], a = n[1], o = n[2], u = w.sub(w(), i, a), s = w.sub(w(), o, a), c = "".concat(xa(w.angle(u, s)).toFixed(2), "°");
  if (r.measureOnly) return c;
  var l = Xg(e, r);
  return r.condensed ? "".concat(c, " | ").concat(l) : "Angle ".concat(c, "</br>").concat(l);
}
function d8(e, t) {
  t === void 0 && (t = {});
  var r = R(R(R({}, S0), { measureOnly: !1 }), t), n = e.loci.map(function(l) {
    return Hr.getCenter(l);
  }), i = n[0], a = n[1], o = n[2], u = n[3], s = "".concat(xa(w.dihedralAngle(i, a, o, u)).toFixed(2), "°");
  if (r.measureOnly) return s;
  var c = Xg(e, r);
  return r.condensed ? "".concat(s, " | ").concat(c) : "Dihedral ".concat(s, "</br>").concat(c);
}
var Yte = { customText: G.Text("", { label: "Text", description: "Override the label with custom value.", isEssential: !0 }), textColor: G.Color(Kt.black, { isEssential: !0 }), textSize: G.Numeric(0.5, { min: 0.1, max: 10, step: 0.1 }, { isEssential: !0 }) }, jg = R(R(R({}, jo.Params), Yte), { borderWidth: G.Numeric(0.2, { min: 0, max: 0.5, step: 0.01 }) }), Wte = R(R({}, jg), { offsetZ: G.Numeric(2, { min: 0, max: 10, step: 0.1 }), textSize: G.Numeric(0.7, { min: 0.1, max: 10, step: 0.1 }, { isEssential: !0 }) }), rF = { text: function(e, t) {
  return An(Jte, jo.Utils, { modifyState: function(r) {
    return R(R({}, r), { pickable: !0 });
  } });
} }, Zte = R(R({}, Wte), { scaleByRadius: G.Boolean(!1), visuals: G.MultiSelect(["text"], G.objectToOptions(rF)), textColor: G.Color(He.fromRgb(241, 160, 119), { isEssential: !0 }) }), Qte = Me();
function w5(e, t) {
  return t === void 0 && (t = !1), e.label || $B(e.loci, { hidePrefix: !0, htmlStyling: !1, condensed: t }).split("Plddt")[0];
}
function Jte(e, t, r, n) {
  var i = function(s, c, l) {
    for (var d = ad.create(c, 128, 64, l), f = c.customText.trim(), m = 0, v = s.infos.length; m < v; ++m) {
      var p = s.infos[m], g = Hr.getBoundingSphere(p.loci, Qte);
      if (g) {
        var h = g.center, y = g.radius, x = f || w5(p, !0);
        d.add(x, h[0], h[1], h[2], c.scaleByRadius ? y / 0.9 : 0, c.scaleByRadius ? Math.max(1, y) : 1, m);
      }
    }
    return d.getText();
  }(t, r, n && n.geometry), a = function(s) {
    return s.infos.length === 1 ? w5(s.infos[0]) : "".concat(s.infos.length, " Labels");
  }(t), o = r.customText.trim(), u = o ? function(s) {
    return o;
  } : function(s) {
    return w5(t.infos[s]);
  };
  return $t.create(a, t, i, function() {
    return r.textColor;
  }, function() {
    return r.textSize;
  }, u);
}
var $te = { create: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, u) {
            var s = or.createMulti("Label", o, u, or.StateBuilder, rF);
            return s.setState({ pickable: !0, markerActions: Pr.All }), s;
          }(t, function() {
            return Zte;
          }), [4, i.createOrUpdate(r ?? {}, { infos: e[0].loci ? e : e.map(function(o) {
            return { loci: o };
          }) }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return n && e.setTheme(n), [4, e.createOrUpdate(r ?? {}, { infos: t.map(function(a) {
            return { loci: a };
          }) }).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, nF = { unitLabel: G.Text("Å", { isEssential: !0 }) }, ere = R(R(R({}, Mr.Params), nF), { lineSizeAttenuation: G.Boolean(!0), linesColor: G.Color(Kt.lightgreen, { isEssential: !0 }), linesSize: G.Numeric(0.075, { min: 0.01, max: 5, step: 0.01 }), dashLength: G.Numeric(0.2, { min: 0.01, max: 0.2, step: 0.01 }) }), tre = R(R({}, jg), nF), iF = { lines: function(e, t) {
  return An(nre, Mr.Utils, { modifyState: function(r) {
    return R(R({}, r), { pickable: !0, markerActions: Pr.All });
  } });
}, text: function(e, t) {
  return An(ire, jo.Utils, { modifyState: function(r) {
    return R(R({}, r), { pickable: !1, markerActions: Pr.All });
  } });
} }, rre = R(R(R({}, ere), tre), { visuals: G.MultiSelect(["lines", "text"], G.objectToOptions(iF)) });
function aF(e, t) {
  var r = t.sphereA, n = t.sphereB, i = t.center, a = e.loci, o = a[0], u = a[1];
  return Hr.getBoundingSphere(o, r), Hr.getBoundingSphere(u, n), w.add(i, r.center, n.center), w.scale(i, i, 0.5), t.distance = w.distance(r.center, n.center), t;
}
var Fl = { sphereA: Me(), sphereB: Me(), center: w(), distance: 0 };
function oF(e, t) {
  return e.pairs.length === 1 ? "Distance ".concat(ym(e.pairs[0], { unitLabel: t, measureOnly: !0 })) : "".concat(e.pairs.length, " Distances");
}
function nre(e, t, r, n) {
  var i = function(o, u, s) {
    for (var c = aa.create(128, 64, s), l = 0, d = o.pairs.length; l < d; ++l) aF(o.pairs[l], Fl), c.addFixedLengthDashes(Fl.sphereA.center, Fl.sphereB.center, u.dashLength, l);
    return c.getLines();
  }(t, r, n && n.geometry), a = oF(t, r.unitLabel);
  return $t.create(a, t, i, function() {
    return r.linesColor;
  }, function() {
    return r.linesSize;
  }, function(o) {
    return ym(t.pairs[o], r);
  });
}
function ire(e, t, r, n) {
  var i = function(o, u, s) {
    for (var c = ad.create(u, 128, 64, s), l = 0, d = o.pairs.length; l < d; ++l) {
      aF(o.pairs[l], Fl);
      var f = Fl.center, m = Fl.distance, v = Fl.sphereA, p = Fl.sphereB, g = u.customText || "".concat(m.toFixed(2), " ").concat(u.unitLabel), h = Math.max(2, v.radius, p.radius) / 2;
      c.add(g, f[0], f[1], f[2], 1, h, l);
    }
    return c.getText();
  }(t, r, n && n.geometry), a = oF(t, r.unitLabel);
  return $t.create(a, t, i, function() {
    return r.textColor;
  }, function() {
    return r.textSize;
  }, function(o) {
    return ym(t.pairs[o], r);
  });
}
var are = { create: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, u) {
            var s = or.createMulti("Distance", o, u, or.StateBuilder, iF);
            return s.setState({ pickable: !0, markerActions: Pr.All }), s;
          }(t, function() {
            return rre;
          }), [4, i.createOrUpdate(r ?? {}, { pairs: [{ loci: e.slice(-2) }] }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return n && e.setTheme(n), [4, e.createOrUpdate(r ?? {}, { pairs: [{ loci: t }] }).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, ore = { radius: 1, segments: 36, thetaStart: 0, thetaLength: 2 * Math.PI };
function f8(e) {
  var t = R(R({}, ore), e), r = t.radius, n = t.segments, i = t.thetaStart, a = t.thetaLength, o = a === 2 * Math.PI, u = o ? n + 1 : n + 2, s = new Float32Array(3 * u), c = new Float32Array(3 * u), l = new Uint32Array(3 * n);
  s[0] = 0, s[1] = 0, s[2] = 0, c[0] = 0, c[1] = 1, c[2] = 0;
  for (var d = 0, f = 3; d < n; ++d, f += 3) {
    var m = i + d / n * a;
    s[f] = r * Math.sin(m), s[f + 1] = 0, s[f + 2] = r * Math.cos(m), c[f] = 0, c[f + 1] = 1, c[f + 2] = 0;
  }
  for (d = 1, f = 0; d < n; ++d, f += 3) l[f] = d, l[f + 1] = d + 1, l[f + 2] = 0;
  if (o)
    l[v = 3 * (n - 1)] = n, l[v + 1] = 1, l[v + 2] = 0;
  else {
    var v;
    m = i + a, s[f = 3 * (n + 1)] = r * Math.sin(m), s[f + 1] = 0, s[f + 2] = r * Math.cos(m), c[f] = 0, c[f + 1] = 1, c[f + 2] = 0, l[v = 3 * (n - 1)] = n, l[v + 1] = n + 1, l[v + 2] = 0;
  }
  return { vertices: s, normals: c, indices: l };
}
var uF = { color: G.Color(Kt.lightgreen), arcScale: G.Numeric(0.7, { min: 0.01, max: 1, step: 0.01 }) }, sF = R(R(R({}, Mr.Params), uF), { lineSizeAttenuation: G.Boolean(!0), linesSize: G.Numeric(0.04, { min: 0.01, max: 5, step: 0.01 }), dashLength: G.Numeric(0.04, { min: 0.01, max: 0.2, step: 0.01 }) }), ure = R({}, sF), sre = R({}, sF), cre = R(R(R({}, Gt.Params), uF), { ignoreLight: G.Boolean(!0), sectorOpacity: G.Numeric(0.75, { min: 0, max: 1, step: 0.01 }) }), cF = { vectors: function(e, t) {
  return An(dre, Mr.Utils, { modifyState: function(r) {
    return R(R({}, r), { pickable: !1 });
  } });
}, arc: function(e, t) {
  return An(fre, Mr.Utils, { modifyState: function(r) {
    return R(R({}, r), { pickable: !1 });
  } });
}, sector: function(e, t) {
  return An(pre, Gt.Utils, { modifyProps: function(r) {
    return R(R({}, r), { alpha: r.sectorOpacity });
  }, modifyState: function(r) {
    return R(R({}, r), { markerActions: Pr.Highlighting });
  } });
}, text: function(e, t) {
  return An(mre, jo.Utils, { modifyState: function(r) {
    return R(R({}, r), { markerActions: _t.None });
  } });
} }, lre = R(R(R(R(R({}, ure), sre), cre), jg), { visuals: G.MultiSelect(["vectors", "sector", "text"], G.objectToOptions(cF)) }), _l = w(), dp = me();
function Yg(e, t, r) {
  var n = t.sphereA, i = t.sphereB, a = t.sphereC, o = t.arcDirA, u = t.arcDirC, s = t.arcNormal, c = e.loci, l = c[0], d = c[1], f = c[2];
  Hr.getBoundingSphere(l, n), Hr.getBoundingSphere(d, i), Hr.getBoundingSphere(f, a), w.sub(o, n.center, i.center), w.sub(u, a.center, i.center), w.cross(s, o, u);
  var m = Math.min(w.magnitude(o), w.magnitude(u)) * r;
  return t.radius = m, t.angle = w.angle(o, u), t;
}
function lF(e, t) {
  var r = e.radius, n = e.angle, i = t ? NE(n, r) / t : 32;
  return me.targetTo(dp, e.sphereB.center, e.sphereA.center, e.arcNormal), me.setTranslation(dp, e.sphereB.center), me.mul(dp, dp, me.rotY180), Mg(f8({ radius: r, thetaLength: n, segments: i }), dp);
}
var ea = { sphereA: Me(), sphereB: Me(), sphereC: Me(), arcDirA: w(), arcDirC: w(), arcNormal: w(), radius: 0, angle: 0 };
function Wg(e) {
  return e.triples.length === 1 ? "Angle ".concat(l8(e.triples[0], { measureOnly: !0 })) : "".concat(e.triples.length, " Angles");
}
function dre(e, t, r, n) {
  var i = function(o, u, s) {
    for (var c = aa.create(128, 64, s), l = 0, d = o.triples.length; l < d; ++l) Yg(o.triples[l], ea, u.arcScale), c.addFixedLengthDashes(ea.sphereB.center, ea.sphereA.center, u.dashLength, l), c.addFixedLengthDashes(ea.sphereB.center, ea.sphereC.center, u.dashLength, l);
    return c.getLines();
  }(t, r, n && n.geometry), a = Wg(t);
  return $t.create(a, t, i, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function fre(e, t, r, n) {
  var i = function(o, u, s) {
    for (var c = aa.create(128, 64, s), l = 0, d = o.triples.length; l < d; ++l) {
      Yg(o.triples[l], ea, u.arcScale);
      for (var f = lF(ea, u.dashLength), m = f.indices, v = f.vertices, p = 0, g = m.length; p < g; p += 3) if (p % 2 != 1) {
        var h = 3 * m[p], y = 3 * m[p + 1], x = v[h], A = v[h + 1], b = v[h + 2], _ = v[y], S = v[y + 1], D = v[y + 2];
        c.add(x, A, b, _, S, D, l);
      }
    }
    return c.getLines();
  }(t, r, n && n.geometry), a = Wg(t);
  return $t.create(a, t, i, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function pre(e, t, r, n) {
  var i = function(o, u, s) {
    for (var c = wt.createState(128, 64, s), l = 0, d = o.triples.length; l < d; ++l) {
      Yg(o.triples[l], ea, u.arcScale);
      var f = lF(ea);
      c.currentGroup = l, wt.addPrimitive(c, me.id, f), wt.addPrimitiveFlipped(c, me.id, f);
    }
    return wt.getMesh(c);
  }(t, r, n && n.geometry), a = Wg(t);
  return $t.create(a, t, i, function() {
    return r.color;
  }, function() {
    return 1;
  }, function(o) {
    return l8(t.triples[o]);
  });
}
function mre(e, t, r, n) {
  var i = function(o, u, s) {
    for (var c = ad.create(u, 128, 64, s), l = 0, d = o.triples.length; l < d; ++l) {
      Yg(o.triples[l], ea, u.arcScale), w.add(_l, ea.arcDirA, ea.arcDirC), w.setMagnitude(_l, _l, ea.radius), w.add(_l, ea.sphereB.center, _l);
      var f = xa(ea.angle).toFixed(2), m = u.customText || "".concat(f, "°"), v = Math.max(2, ea.sphereA.radius, ea.sphereB.radius, ea.sphereC.radius) / 2;
      c.add(m, _l[0], _l[1], _l[2], 0.1, v, l);
    }
    return c.getText();
  }(t, r, n && n.geometry), a = Wg(t);
  return $t.create(a, t, i, function() {
    return r.textColor;
  }, function() {
    return r.textSize;
  }, function(o) {
    return l8(t.triples[o]);
  });
}
var hre = { create: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, u) {
            return or.createMulti("Angle", o, u, or.StateBuilder, cF);
          }(t, function() {
            return lre;
          }), [4, i.createOrUpdate(r ?? {}, { triples: [{ loci: e.slice(-3) }] }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return n && e.setTheme(n), [4, e.createOrUpdate(r ?? {}, { triples: [{ loci: t.slice(-3) }] }).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, dF = { color: G.Color(Kt.lightgreen), arcScale: G.Numeric(0.7, { min: 0.01, max: 1, step: 0.01 }) }, Zg = R(R(R({}, Mr.Params), dF), { lineSizeAttenuation: G.Boolean(!0), linesSize: G.Numeric(0.04, { min: 0.01, max: 5, step: 0.01 }), dashLength: G.Numeric(0.04, { min: 0.01, max: 0.2, step: 0.01 }) }), vre = R({}, Zg), gre = R({}, Zg), yre = R({}, Zg), bre = R({}, Zg), _re = R(R(R({}, Gt.Params), dF), { ignoreLight: G.Boolean(!0), sectorOpacity: G.Numeric(0.75, { min: 0, max: 1, step: 0.01 }) }), fF = { vectors: function(e, t) {
  return An(Are, Mr.Utils, { modifyState: function(r) {
    return R(R({}, r), { pickable: !1, markerActions: Pr.All });
  } });
}, extenders: function(e, t) {
  return An(wre, Mr.Utils, { modifyState: function(r) {
    return R(R({}, r), { pickable: !1, markerActions: Pr.All });
  } });
}, connector: function(e, t) {
  return An(Sre, Mr.Utils, { modifyState: function(r) {
    return R(R({}, r), { pickable: !1, markerActions: Pr.All });
  } });
}, arms: function(e, t) {
  return An(Cre, Mr.Utils, { modifyState: function(r) {
    return R(R({}, r), { pickable: !1, markerActions: Pr.All });
  } });
}, arc: function(e, t) {
  return An(Dre, Mr.Utils, { modifyState: function(r) {
    return R(R({}, r), { pickable: !1, markerActions: Pr.All });
  } });
}, sector: function(e, t) {
  return An(Ire, Gt.Utils, { modifyProps: function(r) {
    return R(R({}, r), { alpha: r.sectorOpacity });
  }, modifyState: function(r) {
    return R(R({}, r), { markerActions: Pr.All });
  } });
}, text: function(e, t) {
  return An(Ere, jo.Utils, { modifyState: function(r) {
    return R(R({}, r), { markerActions: Pr.All });
  } });
} }, xre = R(R(R(R(R(R(R({}, vre), gre), yre), bre), _re), jg), { visuals: G.MultiSelect(["extenders", "arms", "sector", "text"], G.objectToOptions(fF)) }), Ta = w(), fp = me();
function Df(e, t, r) {
  var n = t.sphereA, i = t.sphereB, a = t.sphereC, o = t.sphereD, u = t.dirBA, s = t.dirCD, c = t.projA, l = t.projD, d = t.arcPointA, f = t.arcPointD, m = t.arcDirA, v = t.arcDirD, p = t.arcCenter, g = t.arcNormal, h = e.loci, y = h[0], x = h[1], A = h[2], b = h[3];
  Hr.getBoundingSphere(y, n), Hr.getBoundingSphere(x, i), Hr.getBoundingSphere(A, a), Hr.getBoundingSphere(b, o), w.add(p, i.center, a.center), w.scale(p, p, 0.5), w.sub(u, n.center, i.center), w.sub(s, o.center, a.center), w.add(d, p, u), w.add(f, p, s), w.sub(g, a.center, i.center), w.orthogonalize(m, g, u), w.orthogonalize(v, g, s), w.projectPointOnVector(c, d, m, p), w.projectPointOnVector(l, f, v, p);
  var _ = Math.min(w.distance(c, p), w.distance(l, p)) * r;
  w.setMagnitude(m, m, _), w.setMagnitude(v, v, _), w.add(d, p, m), w.add(f, p, v), t.radius = _, t.angle = w.dihedralAngle(n.center, i.center, a.center, o.center), w.matchDirection(Ta, g, w.sub(Ta, d, n.center));
  var S = w.angle(u, Ta), D = _ / Math.cos(S - $7);
  w.add(c, i.center, w.setMagnitude(Ta, u, D)), w.matchDirection(Ta, g, w.sub(Ta, f, o.center));
  var I = w.angle(s, Ta), M = _ / Math.cos(I - $7);
  return w.add(l, a.center, w.setMagnitude(Ta, s, M)), t;
}
function pF(e, t) {
  var r = e.radius, n = e.angle, i = t ? NE(n, r) / t : 32;
  return me.targetTo(fp, e.arcCenter, n < 0 ? e.arcPointD : e.arcPointA, e.arcNormal), me.setTranslation(fp, e.arcCenter), me.mul(fp, fp, me.rotY180), Mg(f8({ radius: r, thetaLength: Math.abs(n), segments: i }), fp);
}
var Yr = { sphereA: Me(), sphereB: Me(), sphereC: Me(), sphereD: Me(), dirBA: w(), dirCD: w(), projA: w(), projD: w(), arcPointA: w(), arcPointD: w(), arcDirA: w(), arcDirD: w(), arcCenter: w(), arcNormal: w(), radius: 0, angle: 0 };
function If(e) {
  return e.quads.length === 1 ? "Dihedral ".concat(d8(e.quads[0], { measureOnly: !0 })) : "".concat(e.quads.length, " Dihedrals");
}
function Are(e, t, r, n) {
  var i = function(o, u, s) {
    for (var c = aa.create(128, 64, s), l = 0, d = o.quads.length; l < d; ++l) Df(o.quads[l], Yr, u.arcScale), c.addFixedLengthDashes(Yr.arcCenter, Yr.arcPointA, u.dashLength, l), c.addFixedLengthDashes(Yr.arcCenter, Yr.arcPointD, u.dashLength, l);
    return c.getLines();
  }(t, r, n && n.geometry), a = If(t);
  return $t.create(a, t, i, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function Sre(e, t, r, n) {
  var i = function(o, u, s) {
    for (var c = aa.create(128, 64, s), l = 0, d = o.quads.length; l < d; ++l) Df(o.quads[l], Yr, u.arcScale), c.addFixedLengthDashes(Yr.sphereB.center, Yr.sphereC.center, u.dashLength, l);
    return c.getLines();
  }(t, r, n && n.geometry), a = If(t);
  return $t.create(a, t, i, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function Cre(e, t, r, n) {
  var i = function(o, u, s) {
    for (var c = aa.create(128, 64, s), l = 0, d = o.quads.length; l < d; ++l) Df(o.quads[l], Yr, u.arcScale), c.addFixedLengthDashes(Yr.sphereB.center, Yr.sphereA.center, u.dashLength, l), c.addFixedLengthDashes(Yr.sphereC.center, Yr.sphereD.center, u.dashLength, l);
    return c.getLines();
  }(t, r, n && n.geometry), a = If(t);
  return $t.create(a, t, i, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function wre(e, t, r, n) {
  var i = function(o, u, s) {
    for (var c = aa.create(128, 64, s), l = 0, d = o.quads.length; l < d; ++l) Df(o.quads[l], Yr, u.arcScale), c.addFixedLengthDashes(Yr.arcPointA, Yr.projA, u.dashLength, l), c.addFixedLengthDashes(Yr.arcPointD, Yr.projD, u.dashLength, l);
    return c.getLines();
  }(t, r, n && n.geometry), a = If(t);
  return $t.create(a, t, i, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function Dre(e, t, r, n) {
  var i = function(o, u, s) {
    for (var c = aa.create(128, 64, s), l = 0, d = o.quads.length; l < d; ++l) {
      Df(o.quads[l], Yr, u.arcScale);
      for (var f = pF(Yr, u.dashLength), m = f.indices, v = f.vertices, p = 0, g = m.length; p < g; p += 3) if (p % 2 != 1) {
        var h = 3 * m[p], y = 3 * m[p + 1], x = v[h], A = v[h + 1], b = v[h + 2], _ = v[y], S = v[y + 1], D = v[y + 2];
        c.add(x, A, b, _, S, D, l);
      }
    }
    return c.getLines();
  }(t, r, n && n.geometry), a = If(t);
  return $t.create(a, t, i, function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "";
  });
}
function Ire(e, t, r, n) {
  var i = function(o, u, s) {
    for (var c = wt.createState(128, 64, s), l = 0, d = o.quads.length; l < d; ++l) {
      Df(o.quads[l], Yr, u.arcScale);
      var f = pF(Yr);
      c.currentGroup = l, wt.addPrimitive(c, me.id, f), wt.addPrimitiveFlipped(c, me.id, f);
    }
    return wt.getMesh(c);
  }(t, r, n && n.geometry), a = If(t);
  return $t.create(a, t, i, function() {
    return r.color;
  }, function() {
    return 1;
  }, function(o) {
    return d8(t.quads[o]);
  });
}
function Ere(e, t, r, n) {
  var i = function(o, u, s) {
    for (var c = ad.create(u, 128, 64, s), l = 0, d = o.quads.length; l < d; ++l) {
      Df(o.quads[l], Yr, u.arcScale), w.add(Ta, Yr.arcDirA, Yr.arcDirD), w.setMagnitude(Ta, Ta, Yr.radius), w.add(Ta, Yr.arcCenter, Ta);
      var f = xa(Yr.angle).toFixed(2);
      f === "-0.00" && (f = "0.00");
      var m = u.customText || "".concat(f, "°"), v = Math.max(2, Yr.sphereA.radius, Yr.sphereB.radius, Yr.sphereC.radius, Yr.sphereD.radius) / 2;
      c.add(m, Ta[0], Ta[1], Ta[2], 0.1, v, l);
    }
    return c.getText();
  }(t, r, n && n.geometry), a = If(t);
  return $t.create(a, t, i, function() {
    return r.textColor;
  }, function() {
    return r.textSize;
  }, function(o) {
    return d8(t.quads[o]);
  });
}
var Mre = { create: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, u) {
            var s = or.createMulti("Dihedral", o, u, or.StateBuilder, fF);
            return s.setState({ pickable: !0, markerActions: Pr.All }), s;
          }(t, function() {
            return xre;
          }), [4, i.createOrUpdate(r ?? {}, { quads: [{ loci: e.slice(-4) }] }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return n && e.setTheme(n), [4, e.createOrUpdate(r ?? {}, { quads: [{ loci: t.slice(-4) }] }).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, D5 = cr.is;
function Tre(e, t, r, n, i, a) {
  if (!Be.isAtomic(t)) return Mr.createEmpty(a);
  var o = r.child, u = o == null ? void 0 : o.unitMap.get(t.id);
  if (o && !u) return Mr.createEmpty(a);
  var s = at.create(r, t), c = t.elements, l = t.bonds, d = l.edgeCount, f = l.a, m = l.b, v = l.edgeProps, p = l.offset;
  if (!d) return Mr.createEmpty(a);
  var g = v.order, h = v.flags, y = i.sizeFactor, x = i.aromaticBonds, A = i.includeTypes, b = i.excludeTypes, _ = i.multipleBonds, S = _ === "off", D = _ === "symmetric", I = qg(cr.fromNames(A), cr.fromNames(b), 32), M = w(), F = t.conformation.invariantPosition, P = t.rings, E = P.elementRingIndices, B = P.elementAromaticRingIndices, N = x ? t.resonance.delocalizedTriplets : void 0, O = { linkCount: 2 * d, referencePosition: function(K) {
    var j, X, W = f[K], Q = m[K], te = N == null ? void 0 : N.getThirdElement(W, Q);
    if (te !== void 0) return F(c[te], M);
    W > Q && (W = (j = [Q, W])[0], Q = j[1]), p[W + 1] - p[W] == 1 && (W = (X = [Q, W])[0], Q = X[1]);
    for (var ee = B.get(W) || E.get(W), $ = 0, ie = p[W], ae = p[W + 1]; ie < ae; ++ie) {
      var se = m[ie];
      if (se !== Q && se !== W) {
        if (!ee) return F(c[se], M);
        var le = B.get(se) || E.get(se);
        if (!le) continue;
        var pe = b2(ee, le);
        pe > $ && ($ = pe, F(c[se], M));
      }
    }
    return $ > 0 ? M : null;
  }, position: function(K, j, X) {
    F(c[f[X]], K), F(c[m[X]], j);
  }, style: function(K) {
    var j = g[K], X = h[K];
    if (D5(X, 2) || D5(X, 4)) return 1;
    if (j === 3) return S ? 0 : D ? 4 : 5;
    if (x) {
      var W = f[K], Q = m[K], te = B.get(W), ee = B.get(Q), $ = te && ee ? b2(te, ee) : 0;
      if (D5(X, 16) || $ && !I) {
        if ($ === 2) return 8;
        if ($ === 1 || N != null && N.getThirdElement(W, Q)) return 7;
      }
    }
    return j !== 2 || S ? 0 : D ? 2 : 3;
  }, radius: function(K) {
    s.element = c[f[K]];
    var j = n.size.size(s);
    s.element = c[m[K]];
    var X = n.size.size(s);
    return Math.min(j, X) * y;
  }, ignore: qB(r, t, i) }, z = HB(0, O, i, a), V = z.lines, U = z.boundingSphere;
  if (U) V.setBoundingSphere(U);
  else if (V.lineCount > 0) {
    var H = Me.expand(Me(), (u ?? t).boundary.sphere, 1 * y);
    V.setBoundingSphere(H);
  }
  return V;
}
var mF = R(R(R({}, r8), u8), { includeParent: G.Boolean(!1) });
function Pre(e) {
  return n8({ defaultProps: G.getDefaultValues(mF), createGeometry: Tre, createLocationIterator: od.fromGroup, getLoci: S6, eachLocation: C6, setUpdateState: function(t, r, n, i, a, o, u) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor || r.linkScale !== n.linkScale || r.linkSpacing !== n.linkSpacing || r.aromaticDashCount !== n.aromaticDashCount || r.dashCount !== n.dashCount || r.ignoreHydrogens !== n.ignoreHydrogens || !Ja(r.includeTypes, n.includeTypes) || !Ja(r.excludeTypes, n.excludeTypes) || r.aromaticBonds !== n.aromaticBonds || r.multipleBonds !== n.multipleBonds;
    var s = o.group.units[0], c = u.group.units[0];
    Be.isAtomic(s) && Be.isAtomic(c) && (So.areEqual(s.bonds, c.bonds) || (t.createGeometry = !0, t.updateTransform = !0, t.updateColor = !0, t.updateSize = !0));
  } }, e);
}
var I5 = new Dt.ElementBondIterator();
function DD(e, t, r, n) {
  for (I5.setElement(t, r, n); I5.hasNext; ) {
    var i = I5.move();
    return i.otherUnit.conformation.position(i.otherUnit.elements[i.otherIndex], e), e;
  }
  return null;
}
function Bre(e, t, r, n, i) {
  var a = t.interUnitBonds, o = a.edgeCount, u = a.edges;
  if (!o) return Mr.createEmpty(i);
  var s = n.sizeFactor, c = n.aromaticBonds, l = n.multipleBonds, d = l === "off", f = l === "symmetric", m = w(), v = at.create(), p = { linkCount: o, referencePosition: function(b) {
    var _, S, D, I, M = u[b];
    if (M.unitA < M.unitB) _ = t.unitMap.get(M.unitA), S = t.unitMap.get(M.unitB), D = M.indexA, I = M.indexB;
    else {
      if (!(M.unitA > M.unitB)) throw new Error("same units in createInterUnitBondLines");
      _ = t.unitMap.get(M.unitB), S = t.unitMap.get(M.unitA), D = M.indexB, I = M.indexA;
    }
    return DD(m, t, _, D) || DD(m, t, S, I);
  }, position: function(b, _, S) {
    var D = u[S], I = t.unitMap.get(D.unitA), M = t.unitMap.get(D.unitB);
    I.conformation.position(I.elements[D.indexA], b), M.conformation.position(M.elements[D.indexB], _);
  }, style: function(b) {
    var _ = u[b].props.order, S = ya.create(u[b].props.flag);
    return cr.is(S, 2) || cr.is(S, 4) ? 1 : _ === 3 ? d ? 0 : f ? 4 : 5 : c && cr.is(S, 16) ? 7 : _ !== 2 || d ? 0 : f ? 2 : 3;
  }, radius: function(b) {
    var _ = u[b];
    v.structure = t, v.unit = t.unitMap.get(_.unitA), v.element = v.unit.elements[_.indexA];
    var S = r.size.size(v);
    v.unit = t.unitMap.get(_.unitB), v.element = v.unit.elements[_.indexB];
    var D = r.size.size(v);
    return Math.min(S, D) * s;
  }, ignore: KB(t, n) }, g = HB(0, p, n, i), h = g.lines, y = g.boundingSphere;
  if (y) h.setBoundingSphere(y);
  else if (h.lineCount > 0) {
    var x = t.child, A = Me.expand(Me(), (x ?? t).boundary.sphere, 1 * s);
    h.setBoundingSphere(A);
  }
  return h;
}
var hF = R(R(R({}, Eee), u8), { includeParent: G.Boolean(!1) });
function Fre(e) {
  return function(t, r) {
    return Vg(R(R({}, t), { setUpdateState: function(n, i, a, o, u, s, c) {
      t.setUpdateState(n, i, a, o, u, s, c), eo.areEqual(o.size, u.size) || (n.updateSize = !0);
    }, geometryUtils: Mr.Utils }), r);
  }({ defaultProps: G.getDefaultValues(hF), createGeometry: Bre, createLocationIterator: od.fromStructure, getLoci: w6, eachLocation: D6, setUpdateState: function(t, r, n, i, a, o, u) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor || r.linkScale !== n.linkScale || r.linkSpacing !== n.linkSpacing || r.aromaticDashCount !== n.aromaticDashCount || r.dashCount !== n.dashCount || r.ignoreHydrogens !== n.ignoreHydrogens || !Ja(r.includeTypes, n.includeTypes) || !Ja(r.excludeTypes, n.excludeTypes) || r.multipleBonds !== n.multipleBonds, o.interUnitBonds !== u.interUnitBonds && (t.createGeometry = !0, t.updateTransform = !0, t.updateColor = !0, t.updateSize = !0);
  } }, e);
}
var I6, Nre = Oe.add3, Rre = Oe.add;
(function(e) {
  e.create = function(t, r, n) {
    t === void 0 && (t = 2048), r === void 0 && (r = 1024);
    var i = Oe.create(Float32Array, 3, r, n ? n.centerBuffer.ref.value : t), a = Oe.create(Float32Array, 1, r, n ? n.groupBuffer.ref.value : t);
    return { add: function(o, u, s, c) {
      Nre(i, o, u, s), Rre(a, c);
    }, getPoints: function() {
      var o = Oe.compact(i, !0), u = Oe.compact(a, !0);
      return vf.create(o, u, i.elementCount, n);
    } };
  };
})(I6 || (I6 = {}));
var ID = w.add, vF = R(R({}, Bee), { pointSizeAttenuation: G.Boolean(!1), ignoreHydrogens: G.Boolean(!1), traceOnly: G.Boolean(!1) });
function Ore(e, t, r, n, i, a) {
  var o = r.child;
  if (o && !o.unitMap.get(t.id)) return vf.createEmpty(a);
  var u = t.elements, s = u.length, c = I6.create(s, s / 10, a), l = w(), d = t.conformation.invariantPosition, f = Kg(r, t, i), m = w(), v = 0;
  if (f) for (var p = 0; p < s; ++p) f(u[p]) || (d(u[p], l), ID(m, m, l), v += 1, c.add(l[0], l[1], l[2], p));
  else for (p = 0; p < s; ++p) d(u[p], l), ID(m, m, l), v += 1, c.add(l[0], l[1], l[2], p);
  var g, h = a ? Me.clone(a.boundingSphere) : void 0, y = c.getPoints();
  return v === 0 || (w.scale(m, m, 1 / v), g = h && w.distance(m, h.center) / h.radius < 1 ? h : Me.expand(Me(), t.boundary.sphere, 1), y.setBoundingSphere(g)), y;
}
function Lre(e) {
  return function(t, r) {
    return Fm(R(R({}, t), { setUpdateState: function(n, i, a, o, u, s, c) {
      t.setUpdateState(n, i, a, o, u, s, c), eo.areEqual(o.size, u.size) || (n.updateSize = !0);
    }, geometryUtils: vf.Utils }), r);
  }({ defaultProps: G.getDefaultValues(vF), createGeometry: Ore, createLocationIterator: Nc.fromGroup, getLoci: d0, eachLocation: l0, setUpdateState: function(t, r, n) {
    t.createGeometry = r.ignoreHydrogens !== n.ignoreHydrogens || r.traceOnly !== n.traceOnly;
  } }, e);
}
var y1 = w.scaleAndAdd, ED = w.unitX, MD = w.unitY, TD = w.unitZ, gF = R(R({}, r8), { lineSizeAttenuation: G.Boolean(!1), ignoreHydrogens: G.Boolean(!1), traceOnly: G.Boolean(!1), crosses: G.Select("lone", G.arrayToOptions(["lone", "all"])), crossSize: G.Numeric(0.35, { min: 0, max: 2, step: 0.01 }) });
function kre(e, t, r, n, i, a) {
  var o = r.child;
  if (o && !o.unitMap.get(t.id)) return Mr.createEmpty(a);
  for (var u = t.elements, s = u.length, c = aa.create(s, s / 10, a), l = w(), d = w(), f = w(), m = t.conformation.invariantPosition, v = Kg(r, t, i), p = i.crossSize / 2, g = i.crosses === "lone", h = 0; h < s; ++h) v && v(u[h]) || g && Be.isAtomic(t) && pm(r, t, h) !== 0 || (m(u[h], l), y1(d, l, ED, p), y1(f, l, ED, -p), c.add(d[0], d[1], d[2], f[0], f[1], f[2], h), y1(d, l, MD, p), y1(f, l, MD, -p), c.add(d[0], d[1], d[2], f[0], f[1], f[2], h), y1(d, l, TD, p), y1(f, l, TD, -p), c.add(d[0], d[1], d[2], f[0], f[1], f[2], h));
  var y = c.getLines(), x = Me.expand(Me(), t.boundary.sphere, 1 * i.sizeFactor);
  return y.setBoundingSphere(x), y;
}
function zre(e) {
  return n8({ defaultProps: G.getDefaultValues(gF), createGeometry: kre, createLocationIterator: Nc.fromGroup, getLoci: d0, eachLocation: l0, setUpdateState: function(t, r, n) {
    t.createGeometry = r.ignoreHydrogens !== n.ignoreHydrogens || r.traceOnly !== n.traceOnly || r.crosses !== n.crosses || r.crossSize !== n.crossSize;
  } }, e);
}
var yF = { "intra-bond": function(e, t) {
  return Ba("Intra-unit bond line", e, t, Pre);
}, "inter-bond": function(e, t) {
  return bf("Inter-unit bond line", e, t, Fre);
}, "element-point": function(e, t) {
  return Ba("Points", e, t, Lre);
}, "element-cross": function(e, t) {
  return Ba("Crosses", e, t, zre);
}, "charge-text": function(e, t) {
  return bf("Charge Text", e, t, c8);
} }, PD = R(R(R(R(R({}, mF), hF), vF), gF), { multipleBonds: G.Select("offset", G.arrayToOptions(["off", "symmetric", "offset"])), includeParent: G.Boolean(!1), sizeFactor: G.Numeric(0.01, { min: 0.01, max: 10, step: 0.01 }), unitKinds: Bm(["atomic"]), visuals: G.MultiSelect(["intra-bond", "inter-bond", "element-point", "element-cross", "charge-text"], G.objectToOptions(yF)), lineSizeAttenuation: G.Boolean(!0), traceOnly: G.Boolean(!1, { isHidden: !0 }), pointSizeAttenuation: G.Boolean(!0), pointStyle: G.Select("circle", G.objectToOptions({ square: "Square", circle: "Circle", fuzzy: "Fuzzy" })) }), E5 = { name: "line", label: "Line", description: "Displays bonds as lines and atoms as points or croses.", factory: function(e, t) {
  return or.createMulti("Line", e, t, Wo, yF);
}, getParams: function(e, t) {
  var r = G.clone(PD);
  return r.pointStyle.defaultValue = "circle", r;
}, defaultValues: G.getDefaultValues(PD), defaultColorTheme: { name: "element-symbol" }, defaultSizeTheme: { name: "uniform" }, isApplicable: function(e) {
  return e.elementCount > 0;
}, getData: function(e, t) {
  return t.includeParent ? e.asParent() : e;
}, mustRecreate: function(e, t) {
  return e.includeParent !== t.includeParent;
} }, Gre = { create: function(e, t, r) {
  var n;
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return (i = E5.factory(t, E5.getParams)).setTheme(r ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("uniform", { structure: e }) }), [4, i.createOrUpdate(R(R({}, E5.defaultValues), { aromaticBonds: ((n = e.model) === null || n === void 0 ? void 0 : n.sourceData.kind) === "mmCIF", quality: "auto", visuals: t.props.hideBond ? ["element-point", "element-cross", "charge-text"] : ["element-point", "element-cross", "charge-text", "intra-bond", "inter-bond"] }), e).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return e.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: t }), size: r.sizeThemeRegistry.create("uniform", { structure: t }) }), [4, e.createOrUpdate({ visuals: r.props.hideBond ? ["element-point", "element-cross", "charge-text"] : ["element-point", "element-cross", "charge-text", "intra-bond", "inter-bond"] }, t).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, bF = { "element-sphere": function(e, t) {
  return Ba("Element sphere", e, t, s8);
}, "intra-bond": function(e, t) {
  return Ba("Intra-unit bond cylinder", e, t, jB);
}, "inter-bond": function(e, t) {
  return bf("Inter-unit bond cylinder", e, t, WB);
}, "charge-text": function(e, t) {
  return bf("Charge Text", e, t, c8);
} }, BD = R(R(R(R(R({}, gm), { traceOnly: G.Boolean(!1, { isHidden: !0 }) }), rg), ng), { includeParent: G.Boolean(!1), unitKinds: Bm(["atomic"]), visuals: G.MultiSelect(["element-sphere", "intra-bond", "inter-bond", "charge-text"], G.objectToOptions(bF)), bumpFrequency: G.Numeric(0, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory), sizeFactor: G.Numeric(0.15, { min: 0.01, max: 10, step: 0.01 }), sizeAspectRatio: G.Numeric(1, { min: 0.01, max: 3, step: 0.01 }), multipleBonds: G.Select("offset", G.arrayToOptions(["off", "symmetric", "offset"])), tryUseImpostor: G.Boolean(!0), linkScale: G.Numeric(0.55, { min: 0, max: 1, step: 0.01 }) }), M5 = { name: "stick", label: "Stick", description: "Displays atoms as spheres and bonds as cylinders.", factory: function(e, t) {
  return or.createMulti("Ball & Stick", e, t, Wo, bF);
}, getParams: function(e, t) {
  return G.clone(BD);
}, defaultValues: G.getDefaultValues(BD), defaultColorTheme: { name: "element-symbol" }, defaultSizeTheme: { name: "uniform" }, isApplicable: function(e) {
  return e.elementCount > 0;
}, getData: function(e, t) {
  return t.includeParent ? e.asParent() : e;
}, mustRecreate: function(e, t) {
  return e.includeParent !== t.includeParent;
} }, Vre = { create: function(e, t, r) {
  var n;
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return (i = M5.factory(t, M5.getParams)).setTheme(r ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("uniform", { structure: e }) }), [4, i.createOrUpdate(R(R({}, M5.defaultValues), { aromaticBonds: ((n = e.model) === null || n === void 0 ? void 0 : n.sourceData.kind) === "mmCIF", quality: "auto", visuals: t.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"] }), e).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return e.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: t }), size: r.sizeThemeRegistry.create("uniform", { structure: t }) }), [4, e.createOrUpdate({ visuals: r.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"] }, t).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, p8 = { probeRadius: G.Numeric(1.4, { min: 0, max: 10, step: 0.1 }, { description: "Radius of the probe tracing the molecular surface." }), resolution: G.Numeric(0.5, { min: 0.01, max: 20, step: 0.01 }, R({ description: "Grid resolution/cell spacing." }, ft.CustomQualityParamInfo)), probePositions: G.Numeric(36, { min: 12, max: 90, step: 1 }, R({ description: "Number of positions tested for probe target intersection." }, ft.CustomQualityParamInfo)) };
function Ure(e, t, r, n, i, a) {
  return _e(this, 0, void 0, function() {
    function o(Ne, nt, re, J, ce) {
      if (d !== -1) {
        if ((he = d) !== J && he !== ce && u(he, Ne, nt, re)) return he;
        d = -1;
      }
      for (var de = 0, ve = S.count; de < ve; ++de) {
        var he;
        if ((he = Le.getAt(D, S.indices[de])) !== J && he !== ce && u(he, Ne, nt, re)) return d = he, he;
      }
      return -1;
    }
    function u(Ne, nt, re, J) {
      var ce = E[Ne], de = I[Ne] - nt, ve = M[Ne] - re, he = F[Ne] - J;
      return de * de + ve * ve + he * he < ce * ce;
    }
    function s() {
      return _e(this, 0, void 0, function() {
        var Ne;
        return ye(this, function(nt) {
          switch (nt.label) {
            case 0:
              Ne = 0, nt.label = 1;
            case 1:
              return Ne < B ? (function(re, J) {
                for (var ce = re; ce < J; ++ce) {
                  var de = Le.getAt(D, ce), ve = I[de], he = M[de], Se = F[de], Re = E[de], Ve = Re * Re;
                  _.find(ve, he, Se, Re);
                  for (var ze = Math.ceil(Re * x), mt = Math.floor(x * (ve - V)), bt = Math.floor(x * (he - U)), Ct = Math.floor(x * (Se - H)), De = Math.max(0, mt - ze), ut = Math.max(0, bt - ze), It = Math.max(0, Ct - ze), ur = Math.min(X, mt + ze + 2), nr = Math.min(W, bt + ze + 2), Er = Math.min(Q, Ct + ze + 2), dr = De; dr < ur; ++dr) for (var ln = we[dr] - ve, Gn = dr * ee, Rn = ut; Rn < nr; ++Rn) for (var Cn = Ge[Rn] - he, Jr = ln * ln + Cn * Cn, ni = Rn * te + Gn, $r = It; $r < Er; ++$r) {
                    var en = Ue[$r] - Se, fi = Jr + en * en;
                    if (fi < Ve) {
                      var pi = $r + ni;
                      le[pi] < 0 && (le[pi] *= -1);
                      var za = Math.sqrt(fi), wn = Re / za;
                      if (o(ln * wn + ve, Cn * wn + he, en * wn + Se, de, -1) === -1) {
                        var dn = Re - za;
                        dn < le[pi] && (le[pi] = dn, pe[pi] = P[ce]);
                      }
                    }
                  }
                }
              }(Ne, Math.min(Ne + Ke, B)), e.shouldUpdate ? [4, e.update({ message: "projecting points", current: Ne, max: B })] : [3, 3]) : [3, 4];
            case 2:
              nt.sent(), nt.label = 3;
            case 3:
              return Ne += Ke, [3, 1];
            case 4:
              return [2];
          }
        });
      });
    }
    function c(Ne, nt) {
      var re = E[Ne], J = E[nt], ce = f[0] = I[nt] - I[Ne], de = f[1] = M[nt] - M[Ne], ve = f[2] = F[nt] - F[Ne], he = ce * ce + de * de + ve * ve, Se = Math.sqrt(he), Re = re * ((re * re + Se * Se - J * J) / (2 * re * Se));
      w.normalize(f, f), function(Ga, mi) {
        Ga[0] = Ga[1] = Ga[2] = 1, mi[0] !== 0 ? Ga[0] = (mi[1] + mi[2]) / -mi[0] : mi[1] !== 0 ? Ga[1] = (mi[0] + mi[2]) / -mi[1] : mi[2] !== 0 && (Ga[2] = (mi[0] + mi[1]) / -mi[2]);
      }(v, f), w.normalize(v, v), w.cross(p, f, v), w.normalize(p, p);
      var Ve = Math.sqrt(re * re - Re * Re);
      w.scale(v, v, Ve), w.scale(p, p, Ve), w.scale(f, f, Re), m[0] = f[0] + I[Ne], m[1] = f[1] + M[Ne], m[2] = f[2] + F[Ne], d = -1;
      for (var ze = 0; ze < y; ++ze) {
        var mt = ie[ze], bt = ae[ze], Ct = m[0] + mt * v[0] + bt * p[0], De = m[1] + mt * v[1] + bt * p[1], ut = m[2] + mt * v[2] + bt * p[2];
        if (o(Ct, De, ut, Ne, nt) === -1) for (var It = Math.floor(x * (Ct - V)), ur = Math.floor(x * (De - U)), nr = Math.floor(x * (ut - H)), Er = Math.max(0, It - A), dr = Math.max(0, ur - A), ln = Math.max(0, nr - A), Gn = Math.min(X, It + A + 2), Rn = Math.min(W, ur + A + 2), Cn = Math.min(Q, nr + A + 2), Jr = Er; Jr < Gn; ++Jr) for (var ni = Ct - we[Jr], $r = Jr * ee, en = dr; en < Rn; ++en) for (var fi = De - Ge[en], pi = ni * ni + fi * fi, za = en * te + $r, wn = ln; wn < Cn; ++wn) {
          var dn = ut - Ue[wn], wo = pi + dn * dn, Do = wn + za, io = le[Do];
          if (io > 0 && wo < io * io) {
            le[Do] = Math.sqrt(wo);
            var os = ni * f[0] + fi * f[1] + dn * f[2];
            pe[Do] = P[Le.indexOf(D, os < 0 ? nt : Ne)];
          }
        }
      }
    }
    function l() {
      return _e(this, 0, void 0, function() {
        var Ne;
        return ye(this, function(nt) {
          switch (nt.label) {
            case 0:
              Ne = 0, nt.label = 1;
            case 1:
              return Ne < B ? (function(re, J) {
                for (var ce = re; ce < J; ++ce) {
                  var de = Le.getAt(D, ce);
                  _.find(I[de], M[de], F[de], E[de]);
                  for (var ve = 0, he = S.count; ve < he; ++ve) {
                    var Se = Le.getAt(D, S.indices[ve]);
                    de < Se && c(de, Se);
                  }
                }
              }(Ne, Math.min(Ne + Ke, B)), e.shouldUpdate ? [4, e.update({ message: "projecting torii", current: Ne, max: B })] : [3, 3]) : [3, 4];
            case 2:
              nt.sent(), nt.label = 3;
            case 3:
              return Ne += Ke, [3, 1];
            case 4:
              return [2];
          }
        });
      });
    }
    var d, f, m, v, p, g, h, y, x, A, b, _, S, D, I, M, F, P, E, B, N, O, z, V, U, H, K, j, X, W, Q, te, ee, $, ie, ae, se, le, pe, we, Ge, Ue, Ke, Ze, Fe, Je;
    return ye(this, function(Ne) {
      switch (Ne.label) {
        case 0:
          return d = -1, f = w(), m = w(), v = w(), p = w(), g = a.resolution, h = a.probeRadius, y = a.probePositions, x = 1 / g, A = Math.max(5, 2 + Math.floor(h * x)), b = w.create(n, n, n), w.scale(b, b, 2), _ = lf(t, r, b), S = _.result, i === null && (i = _.boundary.box), D = t.indices, I = t.x, M = t.y, F = t.z, P = t.id, E = t.radius, B = Le.size(D), N = n + g, O = qr.expand(qr(), i, w.create(N, N, N)), z = O.min, V = z[0], U = z[1], H = z[2], K = qr.scale(qr(), O, x), j = qr.size(w(), K), w.ceil(j, j), X = j[0], W = j[1], Q = j[2], ee = (te = Q) * W, $ = function(nt) {
            for (var re = 0, J = 2 * Math.PI / nt, ce = new Float32Array(nt), de = new Float32Array(nt), ve = 0; ve < nt; ve++) ce[ve] = Math.cos(re), de[ve] = Math.sin(re), re += J;
            return { cosTable: ce, sinTable: de };
          }(y), ie = $.cosTable, ae = $.sinTable, se = zn.Space(j, [0, 1, 2], Float32Array), le = se.create(), pe = se.create(), le.fill(-1001), pe.fill(-1), we = Oy(X, V, g), Ge = Oy(W, U, g), Ue = Oy(Q, H, g), Ke = Math.ceil(1e5 / (Math.pow(Math.pow(n, 3), 3) * x)), [4, s()];
        case 1:
          return Ne.sent(), [4, l()];
        case 2:
          return Ne.sent(), Ze = zn.create(se, le), Fe = zn.create(se, pe), Je = me.identity(), me.fromScaling(Je, w.create(g, g, g)), me.setTranslation(Je, O.min), [2, { field: Ze, idField: Fe, transform: Je, resolution: g, maxRadius: n }];
      }
    });
  });
}
function _F(e, t, r, n) {
  var i = this, a = t.lookup3d.boundary.box, o = xee(a, n), u = function(d, f, m, v) {
    for (var p = v.probeRadius, g = Cee(d, f, m, v), h = g.position, y = g.boundary, x = g.radius, A = h.indices, b = Le.size(A), _ = new Float32Array(Le.end(A)), S = 0, D = 0; D < b; ++D) {
      var I = Le.getAt(A, D), M = x(I);
      S < M && (S = M), _[I] = M + p;
    }
    return { position: R(R({}, h), { radius: _ }), boundary: y, maxRadius: S };
  }(e, t, r, o), s = u.position, c = u.boundary, l = u.maxRadius;
  return er.create("Molecular Surface", function(d) {
    return _e(i, 0, void 0, function() {
      return ye(this, function(f) {
        switch (f.label) {
          case 0:
            return [4, Hre(d, s, c, l, a, o)];
          case 1:
            return [2, f.sent()];
        }
      });
    });
  });
}
function Hre(e, t, r, n, i, a) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(o) {
      return [2, Ure(e, t, r, n, i, a)];
    });
  });
}
function xl(e, t, r) {
  return { i: e, j: t, k: r };
}
function hu(e, t) {
  return { a: e, b: t };
}
G.getDefaultValues(p8);
var Kn = [xl(0, 0, 0), xl(1, 0, 0), xl(1, 1, 0), xl(0, 1, 0), xl(0, 0, 1), xl(1, 0, 1), xl(1, 1, 1), xl(0, 1, 1)], qre = [hu(Kn[0], Kn[1]), hu(Kn[1], Kn[2]), hu(Kn[2], Kn[3]), hu(Kn[3], Kn[0]), hu(Kn[4], Kn[5]), hu(Kn[5], Kn[6]), hu(Kn[6], Kn[7]), hu(Kn[7], Kn[4]), hu(Kn[0], Kn[4]), hu(Kn[1], Kn[5]), hu(Kn[2], Kn[6]), hu(Kn[3], Kn[7])], Kre = [{ i: 0, j: 0, k: 0, e: 0 }, { i: 1, j: 0, k: 0, e: 1 }, { i: 0, j: 1, k: 0, e: 0 }, { i: 0, j: 0, k: 0, e: 1 }, { i: 0, j: 0, k: 1, e: 0 }, { i: 1, j: 0, k: 1, e: 1 }, { i: 0, j: 1, k: 1, e: 0 }, { i: 0, j: 0, k: 1, e: 1 }, { i: 0, j: 0, k: 0, e: 2 }, { i: 1, j: 0, k: 0, e: 2 }, { i: 1, j: 1, k: 0, e: 2 }, { i: 0, j: 1, k: 0, e: 2 }], Xre = [0, 265, 515, 778, 1030, 1295, 1541, 1804, 2060, 2309, 2575, 2822, 3082, 3331, 3593, 3840, 400, 153, 915, 666, 1430, 1183, 1941, 1692, 2460, 2197, 2975, 2710, 3482, 3219, 3993, 3728, 560, 825, 51, 314, 1590, 1855, 1077, 1340, 2620, 2869, 2111, 2358, 3642, 3891, 3129, 3376, 928, 681, 419, 170, 1958, 1711, 1445, 1196, 2988, 2725, 2479, 2214, 4010, 3747, 3497, 3232, 1120, 1385, 1635, 1898, 102, 367, 613, 876, 3180, 3429, 3695, 3942, 2154, 2403, 2665, 2912, 1520, 1273, 2035, 1786, 502, 255, 1013, 764, 3580, 3317, 4095, 3830, 2554, 2291, 3065, 2800, 1616, 1881, 1107, 1370, 598, 863, 85, 348, 3676, 3925, 3167, 3414, 2650, 2899, 2137, 2384, 1984, 1737, 1475, 1226, 966, 719, 453, 204, 4044, 3781, 3535, 3270, 3018, 2755, 2505, 2240, 2240, 2505, 2755, 3018, 3270, 3535, 3781, 4044, 204, 453, 719, 966, 1226, 1475, 1737, 1984, 2384, 2137, 2899, 2650, 3414, 3167, 3925, 3676, 348, 85, 863, 598, 1370, 1107, 1881, 1616, 2800, 3065, 2291, 2554, 3830, 4095, 3317, 3580, 764, 1013, 255, 502, 1786, 2035, 1273, 1520, 2912, 2665, 2403, 2154, 3942, 3695, 3429, 3180, 876, 613, 367, 102, 1898, 1635, 1385, 1120, 3232, 3497, 3747, 4010, 2214, 2479, 2725, 2988, 1196, 1445, 1711, 1958, 170, 419, 681, 928, 3376, 3129, 3891, 3642, 2358, 2111, 2869, 2620, 1340, 1077, 1855, 1590, 314, 51, 825, 560, 3728, 3993, 3219, 3482, 2710, 2975, 2197, 2460, 1692, 1941, 1183, 1430, 666, 915, 153, 400, 3840, 3593, 3331, 3082, 2822, 2575, 2309, 2060, 1804, 1541, 1295, 1030, 778, 515, 265, 0], z1 = [[], [0, 8, 3], [0, 1, 9], [1, 8, 3, 9, 8, 1], [1, 2, 10], [0, 8, 3, 1, 2, 10], [9, 2, 10, 0, 2, 9], [2, 8, 3, 2, 10, 8, 10, 9, 8], [3, 11, 2], [0, 11, 2, 8, 11, 0], [1, 9, 0, 2, 3, 11], [1, 11, 2, 1, 9, 11, 9, 8, 11], [3, 10, 1, 11, 10, 3], [0, 10, 1, 0, 8, 10, 8, 11, 10], [3, 9, 0, 3, 11, 9, 11, 10, 9], [9, 8, 10, 10, 8, 11], [4, 7, 8], [4, 3, 0, 7, 3, 4], [0, 1, 9, 8, 4, 7], [4, 1, 9, 4, 7, 1, 7, 3, 1], [1, 2, 10, 8, 4, 7], [3, 4, 7, 3, 0, 4, 1, 2, 10], [9, 2, 10, 9, 0, 2, 8, 4, 7], [2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4], [8, 4, 7, 3, 11, 2], [11, 4, 7, 11, 2, 4, 2, 0, 4], [9, 0, 1, 8, 4, 7, 2, 3, 11], [4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1], [3, 10, 1, 3, 11, 10, 7, 8, 4], [1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4], [4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3], [4, 7, 11, 4, 11, 9, 9, 11, 10], [9, 5, 4], [9, 5, 4, 0, 8, 3], [0, 5, 4, 1, 5, 0], [8, 5, 4, 8, 3, 5, 3, 1, 5], [1, 2, 10, 9, 5, 4], [3, 0, 8, 1, 2, 10, 4, 9, 5], [5, 2, 10, 5, 4, 2, 4, 0, 2], [2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8], [9, 5, 4, 2, 3, 11], [0, 11, 2, 0, 8, 11, 4, 9, 5], [0, 5, 4, 0, 1, 5, 2, 3, 11], [2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5], [10, 3, 11, 10, 1, 3, 9, 5, 4], [4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10], [5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3], [5, 4, 8, 5, 8, 10, 10, 8, 11], [9, 7, 8, 5, 7, 9], [9, 3, 0, 9, 5, 3, 5, 7, 3], [0, 7, 8, 0, 1, 7, 1, 5, 7], [1, 5, 3, 3, 5, 7], [9, 7, 8, 9, 5, 7, 10, 1, 2], [10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3], [8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2], [2, 10, 5, 2, 5, 3, 3, 5, 7], [7, 9, 5, 7, 8, 9, 3, 11, 2], [9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11], [2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7], [11, 2, 1, 11, 1, 7, 7, 1, 5], [9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11], [5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0], [11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0], [11, 10, 5, 7, 11, 5], [10, 6, 5], [0, 8, 3, 5, 10, 6], [9, 0, 1, 5, 10, 6], [1, 8, 3, 1, 9, 8, 5, 10, 6], [1, 6, 5, 2, 6, 1], [1, 6, 5, 1, 2, 6, 3, 0, 8], [9, 6, 5, 9, 0, 6, 0, 2, 6], [5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8], [2, 3, 11, 10, 6, 5], [11, 0, 8, 11, 2, 0, 10, 6, 5], [0, 1, 9, 2, 3, 11, 5, 10, 6], [5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11], [6, 3, 11, 6, 5, 3, 5, 1, 3], [0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6], [3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9], [6, 5, 9, 6, 9, 11, 11, 9, 8], [5, 10, 6, 4, 7, 8], [4, 3, 0, 4, 7, 3, 6, 5, 10], [1, 9, 0, 5, 10, 6, 8, 4, 7], [10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4], [6, 1, 2, 6, 5, 1, 4, 7, 8], [1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7], [8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6], [7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9], [3, 11, 2, 7, 8, 4, 10, 6, 5], [5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11], [0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6], [9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6], [8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6], [5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11], [0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7], [6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9], [10, 4, 9, 6, 4, 10], [4, 10, 6, 4, 9, 10, 0, 8, 3], [10, 0, 1, 10, 6, 0, 6, 4, 0], [8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10], [1, 4, 9, 1, 2, 4, 2, 6, 4], [3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4], [0, 2, 4, 4, 2, 6], [8, 3, 2, 8, 2, 4, 4, 2, 6], [10, 4, 9, 10, 6, 4, 11, 2, 3], [0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6], [3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10], [6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1], [9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3], [8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1], [3, 11, 6, 3, 6, 0, 0, 6, 4], [6, 4, 8, 11, 6, 8], [7, 10, 6, 7, 8, 10, 8, 9, 10], [0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10], [10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0], [10, 6, 7, 10, 7, 1, 1, 7, 3], [1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7], [2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9], [7, 8, 0, 7, 0, 6, 6, 0, 2], [7, 3, 2, 6, 7, 2], [2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7], [2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7], [1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11], [11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1], [8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6], [0, 9, 1, 11, 6, 7], [7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0], [7, 11, 6], [7, 6, 11], [3, 0, 8, 11, 7, 6], [0, 1, 9, 11, 7, 6], [8, 1, 9, 8, 3, 1, 11, 7, 6], [10, 1, 2, 6, 11, 7], [1, 2, 10, 3, 0, 8, 6, 11, 7], [2, 9, 0, 2, 10, 9, 6, 11, 7], [6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8], [7, 2, 3, 6, 2, 7], [7, 0, 8, 7, 6, 0, 6, 2, 0], [2, 7, 6, 2, 3, 7, 0, 1, 9], [1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6], [10, 7, 6, 10, 1, 7, 1, 3, 7], [10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8], [0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7], [7, 6, 10, 7, 10, 8, 8, 10, 9], [6, 8, 4, 11, 8, 6], [3, 6, 11, 3, 0, 6, 0, 4, 6], [8, 6, 11, 8, 4, 6, 9, 0, 1], [9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6], [6, 8, 4, 6, 11, 8, 2, 10, 1], [1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6], [4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9], [10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3], [8, 2, 3, 8, 4, 2, 4, 6, 2], [0, 4, 2, 4, 6, 2], [1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8], [1, 9, 4, 1, 4, 2, 2, 4, 6], [8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1], [10, 1, 0, 10, 0, 6, 6, 0, 4], [4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3], [10, 9, 4, 6, 10, 4], [4, 9, 5, 7, 6, 11], [0, 8, 3, 4, 9, 5, 11, 7, 6], [5, 0, 1, 5, 4, 0, 7, 6, 11], [11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5], [9, 5, 4, 10, 1, 2, 7, 6, 11], [6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5], [7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2], [3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6], [7, 2, 3, 7, 6, 2, 5, 4, 9], [9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7], [3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0], [6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8], [9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7], [1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4], [4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10], [7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10], [6, 9, 5, 6, 11, 9, 11, 8, 9], [3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5], [0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11], [6, 11, 3, 6, 3, 5, 5, 3, 1], [1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6], [0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10], [11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5], [6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3], [5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2], [9, 5, 6, 9, 6, 0, 0, 6, 2], [1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8], [1, 5, 6, 2, 1, 6], [1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6], [10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0], [0, 3, 8, 5, 6, 10], [10, 5, 6], [11, 5, 10, 7, 5, 11], [11, 5, 10, 11, 7, 5, 8, 3, 0], [5, 11, 7, 5, 10, 11, 1, 9, 0], [10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1], [11, 1, 2, 11, 7, 1, 7, 5, 1], [0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11], [9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7], [7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2], [2, 5, 10, 2, 3, 5, 3, 7, 5], [8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5], [9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2], [9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2], [1, 3, 5, 3, 7, 5], [0, 8, 7, 0, 7, 1, 1, 7, 5], [9, 0, 3, 9, 3, 5, 5, 3, 7], [9, 8, 7, 5, 9, 7], [5, 8, 4, 5, 10, 8, 10, 11, 8], [5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0], [0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5], [10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4], [2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8], [0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11], [0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5], [9, 4, 5, 2, 11, 3], [2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4], [5, 10, 2, 5, 2, 4, 4, 2, 0], [3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9], [5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2], [8, 4, 5, 8, 5, 3, 3, 5, 1], [0, 4, 5, 1, 0, 5], [8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5], [9, 4, 5], [4, 11, 7, 4, 9, 11, 9, 10, 11], [0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11], [1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11], [3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4], [4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2], [9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3], [11, 7, 4, 11, 4, 2, 2, 4, 0], [11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4], [2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9], [9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7], [3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10], [1, 10, 2, 8, 7, 4], [4, 9, 1, 4, 1, 7, 7, 1, 3], [4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1], [4, 0, 3, 7, 4, 3], [4, 8, 7], [9, 10, 8, 10, 11, 8], [3, 0, 9, 3, 9, 11, 11, 9, 10], [0, 1, 10, 0, 10, 8, 8, 10, 11], [3, 1, 10, 11, 3, 10], [1, 2, 11, 1, 11, 9, 9, 11, 8], [3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9], [0, 2, 11, 8, 0, 11], [3, 2, 11], [2, 3, 8, 2, 8, 10, 10, 8, 9], [9, 10, 2, 0, 9, 2], [2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8], [1, 10, 2], [1, 3, 8, 9, 1, 8], [0, 9, 1], [0, 3, 8], []], T5 = [[0, 4, 4, 4, 2, 0, 0, 0, 2, 2, 0, 0], [4, 0, 4, 4, 0, 8, 0, 0, 0, 8, 8, 0], [4, 4, 0, 4, 0, 0, 8, 0, 0, 0, 8, 8], [4, 4, 4, 0, 0, 0, 0, 1, 1, 0, 0, 1], [2, 0, 0, 0, 0, 8, 8, 8, 2, 2, 0, 0], [0, 8, 0, 0, 8, 0, 8, 8, 0, 8, 8, 0], [0, 0, 8, 0, 8, 8, 0, 8, 0, 0, 8, 8], [0, 0, 0, 1, 8, 8, 8, 0, 1, 0, 0, 1], [2, 0, 0, 1, 2, 0, 0, 1, 0, 2, 0, 1], [2, 8, 0, 0, 2, 8, 0, 0, 2, 0, 8, 0], [0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8], [0, 0, 8, 1, 0, 0, 8, 1, 1, 0, 8, 0]];
function xF(e) {
  return R(R({}, e), { bottomLeft: Ci(e.bottomLeft, [0, 0, 0]), topRight: Ci(e.topRight, e.scalarField.space.dimensions) });
}
function AF(e) {
  return { dX: e.topRight[0] - e.bottomLeft[0], dY: e.topRight[1] - e.bottomLeft[1], dZ: e.topRight[2] - e.bottomLeft[2] };
}
function SF(e, t) {
  var r = this;
  return er.create("Marching Cubes Mesh", function(n) {
    return _e(r, 0, void 0, function() {
      var i, a, o, u, s, c, l;
      return ye(this, function(d) {
        switch (d.label) {
          case 0:
            return i = xF(e), a = AF(i), o = a.dX, u = a.dY, s = a.dZ, c = Math.min(262144, Math.max(o * u * s / 32, 1024)), l = function(f, m) {
              var v = Math.min(65536, 4 * f), p = Oe.create(Float32Array, 3, f, m && m.vertexBuffer.ref.value), g = Oe.create(Float32Array, 3, f, m && m.normalBuffer.ref.value), h = Oe.create(Float32Array, 1, f, m && m.groupBuffer.ref.value), y = Oe.create(Uint32Array, 3, v, m && m.indexBuffer.ref.value), x = 0, A = 0;
              return { addVertex: function(b, _, S) {
                return ++x, Oe.add3(p, b, _, S);
              }, addNormal: function(b, _, S) {
                Oe.add3(g, b, _, S);
              }, addGroup: function(b) {
                Oe.add(h, b);
              }, addTriangle: function(b, _, S, D) {
                var I = b[_], M = b[S], F = b[D];
                I >= 0 && M >= 0 && F >= 0 && (++A, Oe.add3(y, I, M, F));
              }, get: function() {
                var b = Oe.compact(p, !0), _ = Oe.compact(g, !0), S = Oe.compact(y, !0), D = Oe.compact(h, !0);
                return Gt.create(b, S, _, D, x, A, m);
              } };
            }(c, t), [4, new wF(n, l, i).run()];
          case 1:
            return d.sent(), [2, l.get()];
        }
      });
    });
  });
}
function CF(e, t) {
  var r = this;
  return er.create("Marching Cubes Lines", function(n) {
    return _e(r, 0, void 0, function() {
      var i, a, o, u, s, c, l;
      return ye(this, function(d) {
        switch (d.label) {
          case 0:
            return i = xF(e), a = AF(i), o = a.dX, u = a.dY, s = a.dZ, c = Math.min(262144, Math.max(o * u * s / 32, 1024)), l = function(f, m) {
              var v = Oe.create(Float32Array, 3, f), p = Oe.create(Float32Array, 1, f), g = Oe.create(Float32Array, 2, f), h = 0;
              return { addVertex: function(y, x, A) {
                return Oe.add3(v, y, x, A);
              }, addNormal: function() {
                return s_;
              }, addGroup: function(y) {
                Oe.add(p, y);
              }, addTriangle: function(y, x, A, b, _) {
                var S = y[x], D = y[A], I = y[b];
                S >= 0 && D >= 0 && I >= 0 && (T5[x][A] & _ && (++h, Oe.add2(g, y[x], y[A])), T5[A][b] & _ && (++h, Oe.add2(g, y[A], y[b])), T5[x][b] & _ && (++h, Oe.add2(g, y[x], y[b])));
              }, get: function() {
                for (var y = Oe.compact(v, !0), x = Oe.compact(g, !0), A = Oe.compact(p, !0), b = aa.create(h, h / 10, m), _ = 0; _ < h; ++_) {
                  var S = x[2 * _], D = x[2 * _ + 1];
                  b.add(y[3 * S], y[3 * S + 1], y[3 * S + 2], y[3 * D], y[3 * D + 1], y[3 * D + 2], A[S]);
                }
                return b.getLines();
              } };
            }(c, t), [4, new wF(n, l, i).run()];
          case 1:
            return d.sent(), [2, l.get()];
        }
      });
    });
  });
}
var wF = function() {
  function e(t, r, n) {
    this.ctx = t, this.minX = 0, this.minY = 0, this.minZ = 0, this.maxX = 0, this.maxY = 0, this.maxZ = 0, this.state = new jre(r, n), this.minX = n.bottomLeft[0], this.minY = n.bottomLeft[1], this.minZ = n.bottomLeft[2], this.maxX = n.topRight[0] - 1, this.maxY = n.topRight[1] - 1, this.maxZ = n.topRight[2] - 1, this.size = (this.maxX - this.minX) * (this.maxY - this.minY) * (this.maxZ - this.minZ), this.sliceSize = (this.maxX - this.minX) * (this.maxY - this.minY);
  }
  return e.prototype.doSlices = function() {
    return _e(this, 0, void 0, function() {
      var t, r;
      return ye(this, function(n) {
        switch (n.label) {
          case 0:
            t = 0, this.edgeFilter = 15, r = this.minZ, n.label = 1;
          case 1:
            return r < this.maxZ ? (this.slice(r), t += this.sliceSize, this.ctx.shouldUpdate ? [4, this.ctx.update({ message: "Computing surface...", current: t, max: this.size })] : [3, 3]) : [3, 4];
          case 2:
            n.sent(), n.label = 3;
          case 3:
            return r++, this.edgeFilter &= -5, [3, 1];
          case 4:
            return [2];
        }
      });
    });
  }, e.prototype.slice = function(t) {
    this.edgeFilter |= 2;
    for (var r = this.minY; r < this.maxY; r++, this.edgeFilter &= -3) {
      this.edgeFilter |= 1;
      for (var n = this.minX; n < this.maxX; n++, this.edgeFilter &= -2) this.state.processCell(n, r, t, this.edgeFilter);
    }
    this.state.clearEdgeVertexIndexSlice(t);
  }, e.prototype.run = function() {
    return _e(this, 0, void 0, function() {
      return ye(this, function(t) {
        switch (t.label) {
          case 0:
            return [4, this.doSlices()];
          case 1:
            return t.sent(), [2];
        }
      });
    });
  }, e;
}(), jre = function() {
  function e(t, r) {
    this.builder = t, this.vertList = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], this.i = 0, this.j = 0, this.k = 0;
    var n = r.scalarField.space.dimensions;
    this.nX = n[0], this.nY = n[1], this.nZ = n[2], this.isoLevel = r.isoLevel, this.scalarFieldGet = r.scalarField.space.get, this.scalarField = r.scalarField.data, r.idField && (this.idField = r.idField.data, this.idFieldGet = r.idField.space.get), this.verticesOnEdges = new Int32Array(3 * this.nX * this.nY * 2);
  }
  return e.prototype.get3dOffsetFromEdgeInfo = function(t) {
    return this.nX * ((this.k + t.k) % 2 * this.nY + this.j + t.j) + this.i + t.i;
  }, e.prototype.clearEdgeVertexIndexSlice = function(t) {
    var r = t % 2 == 0 ? 0 : 3 * this.nX * this.nY, n = t % 2 == 0 ? 3 * this.nX * this.nY : this.verticesOnEdges.length;
    this.verticesOnEdges.fill(0, r, n);
  }, e.prototype.interpolate = function(t) {
    var r = Kre[t], n = 3 * this.get3dOffsetFromEdgeInfo(r) + r.e, i = this.verticesOnEdges[n];
    if (i > 0) return i - 1;
    var a = this.scalarField, o = this.scalarFieldGet, u = qre[t], s = u.a, c = u.b, l = s.i + this.i, d = s.j + this.j, f = s.k + this.k, m = c.i + this.i, v = c.j + this.j, p = c.k + this.k, g = o(a, l, d, f), h = o(a, m, v, p), y = (this.isoLevel - g) / (g - h);
    if (this.idField) {
      var x = this.idFieldGet(this.idField, l, d, f), A = this.idFieldGet(this.idField, m, v, p), b = y < 0.5 ? x : A;
      if (b === -1 && (b = y < 0.5 ? A : x), b === -2) return -1;
      this.builder.addGroup(b);
    } else this.builder.addGroup(0);
    var _ = this.builder.addVertex(l + y * (l - m), d + y * (d - v), f + y * (f - p));
    this.verticesOnEdges[n] = _ + 1;
    var S = o(a, Math.max(0, l - 1), d, f) - o(a, Math.min(this.nX - 1, l + 1), d, f), D = o(a, l, Math.max(0, d - 1), f) - o(a, l, Math.min(this.nY - 1, d + 1), f), I = o(a, l, d, Math.max(0, f - 1)) - o(a, l, d, Math.min(this.nZ, f + 1)), M = S + y * (S - (o(a, Math.max(0, m - 1), v, p) - o(a, Math.min(this.nX - 1, m + 1), v, p))), F = D + y * (D - (o(a, m, Math.max(0, v - 1), p) - o(a, m, Math.min(this.nY - 1, v + 1), p))), P = I + y * (I - (o(a, m, v, Math.max(0, p - 1)) - o(a, m, v, Math.min(this.nZ - 1, p + 1))));
    return this.isoLevel >= 0 ? this.builder.addNormal(M, F, P) : this.builder.addNormal(-M, -F, -P), _;
  }, e.prototype.get = function(t, r, n) {
    return this.scalarFieldGet(this.scalarField, t, r, n);
  }, e.prototype.processCell = function(t, r, n, i) {
    var a = 0;
    if (this.get(t, r, n) < this.isoLevel && (a |= 1), this.get(t + 1, r, n) < this.isoLevel && (a |= 2), this.get(t + 1, r + 1, n) < this.isoLevel && (a |= 4), this.get(t, r + 1, n) < this.isoLevel && (a |= 8), this.get(t, r, n + 1) < this.isoLevel && (a |= 16), this.get(t + 1, r, n + 1) < this.isoLevel && (a |= 32), this.get(t + 1, r + 1, n + 1) < this.isoLevel && (a |= 64), this.get(t, r + 1, n + 1) < this.isoLevel && (a |= 128), a !== 0 && a !== 255) {
      this.i = t, this.j = r, this.k = n;
      var o = Xre[a];
      (1 & o) > 0 && (this.vertList[0] = this.interpolate(0)), (2 & o) > 0 && (this.vertList[1] = this.interpolate(1)), (4 & o) > 0 && (this.vertList[2] = this.interpolate(2)), (8 & o) > 0 && (this.vertList[3] = this.interpolate(3)), (16 & o) > 0 && (this.vertList[4] = this.interpolate(4)), (32 & o) > 0 && (this.vertList[5] = this.interpolate(5)), (64 & o) > 0 && (this.vertList[6] = this.interpolate(6)), (128 & o) > 0 && (this.vertList[7] = this.interpolate(7)), (256 & o) > 0 && (this.vertList[8] = this.interpolate(8)), (512 & o) > 0 && (this.vertList[9] = this.interpolate(9)), (1024 & o) > 0 && (this.vertList[10] = this.interpolate(10)), (2048 & o) > 0 && (this.vertList[11] = this.interpolate(11));
      for (var u = z1[a], s = 0; s < u.length; s += 3) {
        var c = u[s], l = u[s + 1], d = u[s + 2];
        this.isoLevel >= 0 ? this.builder.addTriangle(this.vertList, c, l, d, i) : this.builder.addTriangle(this.vertList, d, l, c, i);
      }
    }
  }, e;
}(), DF = R(R(R(R({}, Gc), p8), t8), wY);
function Yre(e, t, r, n, i, a) {
  return _e(this, 0, void 0, function() {
    var o, u, s, c, l, d, f, m, v;
    return ye(this, function(p) {
      switch (p.label) {
        case 0:
          return [4, _F(r, t, n.size, i).runInContext(e.runtime)];
        case 1:
          return o = p.sent(), u = o.transform, s = o.field, c = o.idField, l = o.resolution, d = o.maxRadius, [4, SF({ isoLevel: i.probeRadius, scalarField: s, idField: c }, a).runAsChild(e.runtime)];
        case 2:
          return f = p.sent(), i.includeParent && (m = Math.ceil(2 / i.resolution), Gt.smoothEdges(f, { iterations: m, maxNewEdgeLength: Math.sqrt(2) })), Gt.transform(f, u), e.webgl && !e.webgl.isWebGL2 && Gt.uniformTriangleGroup(f), v = Me.expand(Me(), t.boundary.sphere, d), f.setBoundingSphere(v), f.meta.resolution = l, [2, f];
      }
    });
  });
}
function Wre(e) {
  return Vc({ defaultProps: G.getDefaultValues(DF), createGeometry: Yre, createLocationIterator: Nc.fromGroup, getLoci: d0, eachLocation: l0, setUpdateState: function(t, r, n) {
    r.resolution !== n.resolution && (t.createGeometry = !0), r.probeRadius !== n.probeRadius && (t.createGeometry = !0), r.probePositions !== n.probePositions && (t.createGeometry = !0), r.ignoreHydrogens !== n.ignoreHydrogens && (t.createGeometry = !0), r.traceOnly !== n.traceOnly && (t.createGeometry = !0), r.includeParent !== n.includeParent && (t.createGeometry = !0), r.smoothColors.name !== n.smoothColors.name ? t.updateColor = !0 : r.smoothColors.name === "on" && n.smoothColors.name === "on" && (r.smoothColors.params.resolutionFactor !== n.smoothColors.params.resolutionFactor && (t.updateColor = !0), r.smoothColors.params.sampleStride !== n.smoothColors.params.sampleStride && (t.updateColor = !0));
  }, processValues: function(t, r, n, i, a) {
    var o = r.meta, u = o.resolution, s = o.colorTexture, c = Xd(n.smoothColors, i.color.preferSmoothing, u);
    c && (function(l, d, f, m, v) {
      if (/* @__PURE__ */ function(g) {
        return g === "group" || g === "groupInstance";
      }(l.dColorType.ref.value)) {
        var p = t2({ vertexCount: l.uVertexCount.ref.value, instanceCount: l.uInstanceCount.ref.value, groupCount: l.uGroupCount.ref.value, transformBuffer: l.aTransform.ref.value, instanceBuffer: l.aInstance.ref.value, positionBuffer: l.aPosition.ref.value, groupBuffer: l.aGroup.ref.value, colorData: l.tColor.ref.value, colorType: l.dColorType.ref.value, boundingSphere: l.boundingSphere.ref.value, invariantBoundingSphere: l.invariantBoundingSphere.ref.value, itemSize: 3 }, d, f, m, v);
        p.kind === "volume" ? (k.updateIfChanged(l.dColorType, p.type), k.update(l.tColorGrid, p.texture), k.update(l.uColorTexDim, p.gridTexDim), k.update(l.uColorGridDim, p.gridDim), k.update(l.uColorGridTransform, p.gridTransform)) : p.kind === "vertex" && (k.updateIfChanged(l.dColorType, p.type), k.update(l.tColor, p.texture), k.update(l.uColorTexDim, p.texDim));
      }
    }(t, c.resolution, c.stride, a, s), r.meta.colorTexture = t.tColorGrid.ref.value);
  }, dispose: function(t) {
    var r;
    (r = t.meta.colorTexture) === null || r === void 0 || r.destroy();
  } }, e);
}
var IF = R(R(R(R({}, r8), p8), t8), { sizeFactor: G.Numeric(1.5, { min: 0, max: 10, step: 0.1 }) });
function Zre(e, t, r, n, i, a) {
  return _e(this, 0, void 0, function() {
    var o, u, s, c, l, d, f;
    return ye(this, function(m) {
      switch (m.label) {
        case 0:
          return [4, _F(r, t, n.size, i).runInContext(e.runtime)];
        case 1:
          return o = m.sent(), u = o.transform, s = o.field, c = o.idField, l = o.maxRadius, [4, CF({ isoLevel: i.probeRadius, scalarField: s, idField: c }, a).runAsChild(e.runtime)];
        case 2:
          return d = m.sent(), Mr.transform(d, u), f = Me.expand(Me(), t.boundary.sphere, l), d.setBoundingSphere(f), [2, d];
      }
    });
  });
}
function Qre(e) {
  return n8({ defaultProps: G.getDefaultValues(IF), createGeometry: Zre, createLocationIterator: Nc.fromGroup, getLoci: d0, eachLocation: l0, setUpdateState: function(t, r, n) {
    r.resolution !== n.resolution && (t.createGeometry = !0), r.probeRadius !== n.probeRadius && (t.createGeometry = !0), r.probePositions !== n.probePositions && (t.createGeometry = !0), r.ignoreHydrogens !== n.ignoreHydrogens && (t.createGeometry = !0), r.includeParent !== n.includeParent && (t.createGeometry = !0);
  } }, e);
}
var EF = { "molecular-surface-mesh": function(e, t) {
  return Ba("Molecular surface mesh", e, t, Wre);
}, "molecular-surface-wireframe": function(e, t) {
  return Ba("Molecular surface wireframe", e, t, Qre);
} }, FD = R(R(R({}, DF), IF), { visuals: G.MultiSelect(["molecular-surface-mesh"], G.objectToOptions(EF)), bumpFrequency: G.Numeric(1, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory) }), P5, B5 = { name: "molecular-surface", label: "Molecular Surface", description: "Displays a molecular surface.", factory: function(e, t) {
  return or.createMulti("Molecular Surface", e, t, Wo, EF);
}, getParams: function(e, t) {
  return G.clone(FD);
}, defaultValues: G.getDefaultValues(FD), defaultColorTheme: { name: "chain-id" }, defaultSizeTheme: { name: "physical" }, isApplicable: function(e) {
  return e.elementCount > 0;
} }, Jre = { parse: function(e, t) {
  var r, n = t.managers.cell.get(e.ref), i = Zr(n);
  return i ? $n(i, (r = e.elementIds) !== null && r !== void 0 ? r : [], !0) : tt.Empty;
}, createTheme: function(e, t, r) {
  return t.managers.representation.createTheme(Te.Surface, this.parse(e, t), r);
}, create: function(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return (n = B5.factory(t, B5.getParams)).setTheme(r ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("physical", { structure: e }) }), [4, n.createOrUpdate(R(R({}, B5.defaultValues), { quality: "auto" }), e).run()];
        case 1:
          return i.sent(), [2, n];
      }
    });
  });
}, update: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return e.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: t }), size: r.sizeThemeRegistry.create("physical", { structure: t }) }), [4, e.createOrUpdate({}, t).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, $re = w.create(0, 0, -0.5), ene = w.create(0, 0, 0.5), Al = w(), Sl = w(), Ov = w(), ND = w();
function tne() {
  return P5 || (P5 = function(e) {
    for (var t = e.length / 3, r = (t === 3 ? 1 : t === 4 ? 2 : t) + t, n = Mm(r, t === 4 ? 3 * t + 4 : 3 * r), i = 0; i < t; ++i) {
      var a = (i + 1) % t;
      w.set(Al, e[3 * i], e[3 * i + 1], -0.5), w.set(Sl, e[3 * a], e[3 * a + 1], -0.5), n.add(Al, Sl, ene);
    }
    if (t === 3) w.set(Al, e[0], e[1], -0.5), w.set(Sl, e[3], e[4], -0.5), w.set(Ov, e[6], e[7], -0.5), n.add(Ov, Sl, Al);
    else if (t === 4) w.set(Al, e[0], e[1], -0.5), w.set(Sl, e[3], e[4], -0.5), w.set(Ov, e[6], e[7], -0.5), w.set(ND, e[9], e[10], -0.5), n.addQuad(ND, Ov, Sl, Al);
    else for (i = 0; i < t; ++i) a = (i + 1) % t, w.set(Al, e[3 * i], e[3 * i + 1], -0.5), w.set(Sl, e[3 * a], e[3 * a + 1], -0.5), n.add($re, Sl, Al);
    return n.getPrimitive();
  }(Tg(8, !0))), P5;
}
var E6 = { center: G.Vec3(w()), vec: G.Vec3(w()), color: G.Color(He.fromRgb(255, 196, 36)), alpha: G.Numeric(0.9, { min: 0, max: 1, step: 0.1 }) }, MF = { "rotate-arrow-cylinder": function(e, t) {
  return An(nne, Na.Utils, { modifyState: function(r) {
    return R(R({}, r), { markerActions: Pr.All });
  } });
}, "rotate-arrow-arrowhead": function(e, t) {
  return An(ine, Gt.Utils);
} }, rne = R(R(R({}, Mr.Params), E6), { visuals: G.MultiSelect(["rotate-arrow-cylinder", "rotate-arrow-arrowhead"], G.objectToOptions(MF)) });
function nne(e, t, r, n) {
  var i = r.center, a = r.vec, o = w.create(0, 0, 0);
  w.normalize(o, a);
  var u = w.create(0, 0, 0);
  w.scale(u, o, 0.25);
  var s = w.create(0, 0, 0);
  w.sub(s, a, u);
  var c = w.create(0, 0, 0);
  w.add(c, i, s);
  var l = w.create(0, 0, 0);
  w.scale(l, o, 0.45), w.sub(c, c, l);
  var d = hm.create(128, 64);
  return d.add(i[0], i[1], i[2], c[0], c[1], c[2], 0.05, !0, !0, 2), $t.create("RotateArrow-cylinder", r, d.getCylinders(), function() {
    return r.color;
  }, function() {
    return r.sizeFactor;
  }, function() {
    return "RotateArrow";
  });
}
function ine(e, t, r, n) {
  var i = wt.createState(256, 128), a = tne(), o = r.center, u = r.vec, s = w.create(0, 0, 0);
  w.normalize(s, u);
  var c = w.create(0, 0, 0);
  w.scale(c, s, 0.1);
  var l = w.create(0, 0, 0);
  w.sub(l, u, c);
  var d = w.create(0, 0, 0);
  w.add(d, o, l);
  var f = w.create(0, 0, 0), m = w.create(0, 0, 0);
  w.scale(m, s, 0.35), w.sub(f, d, m);
  var v = me.identity(), p = w();
  return w.add(p, f, u), me.targetTo(v, p, f, w.create(1, 0, 0)), me.setTranslation(v, f), i.currentGroup = 0, me.scaleUniformly(v, v, 0.4 * 1.5), wt.addPrimitive(i, v, a), $t.create("axes", r, wt.getMesh(i), function() {
    return r.color;
  }, function() {
    return 0.05;
  }, function() {
    return "";
  });
}
R(R(R({}, Na.Params), E6), { color: G.Color(He.fromRgb(255, 196, 36)), sizeFactor: G.Numeric(0.1, { min: 0, max: 10, step: 0.1 }) }), R(R(R({}, Gt.Params), E6), { color: G.Color(Kt.brown) });
var ane = { create: function(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return n = function(a, o) {
            var u = or.createMulti("RotateArrow", a, o, Wo, MF);
            return u.setState({ markerActions: Pr.All }), u;
          }(t, function() {
            return rne;
          }), [4, n.createOrUpdate(e, e).run()];
        case 1:
          return i.sent(), [2, n];
      }
    });
  });
}, update: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return [4, e.createOrUpdate(t, t).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, one = { "element-sphere": function(e, t) {
  return Ba("Sphere mesh", e, t, s8);
} }, RD = R(R({}, gm), { bumpFrequency: G.Numeric(1, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory) }), F5 = { name: "spacefill", label: "Spacefill", description: "Displays atomic/coarse elements as spheres.", factory: function(e, t) {
  return or.createMulti("Spacefill", e, t, Wo, one);
}, getParams: function(e, t) {
  var r = G.clone(RD);
  return t.isCoarseGrained && (r.sizeFactor.defaultValue = 2), r;
}, defaultValues: G.getDefaultValues(RD), defaultColorTheme: { name: "element-symbol" }, defaultSizeTheme: { name: "physical" }, isApplicable: function(e) {
  return e.elementCount > 0;
} }, une = { create: function(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return (n = F5.factory(t, F5.getParams)).setTheme(r ?? { color: t.colorThemeRegistry.create("element-symbol", { structure: e }), size: t.sizeThemeRegistry.create("physical", { structure: e }) }), [4, n.createOrUpdate(R(R({}, F5.defaultValues), { quality: "auto" }), e).run()];
        case 1:
          return i.sent(), [2, n];
      }
    });
  });
}, update: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return e.setTheme(n ?? { color: r.colorThemeRegistry.create("element-symbol", { structure: t }), size: r.sizeThemeRegistry.create("physical", { structure: t }) }), [4, e.createOrUpdate({}, t).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, sne = me.fromTranslation(me(), w.create(0.5, 0.5, 0.5)), cne = Bg(Pg(LT()), sne), Gd = w(), OD = me(), TF = R(R({}, Gt.Params), { alpha: R(R({}, Gt.Params.alpha), { defaultValue: 0.51 }), ignoreLight: R(R({}, Gt.Params.ignoreLight), { defaultValue: !0 }), colorX: G.Color(Kt.red, { isEssential: !0 }), colorY: G.Color(Kt.green, { isEssential: !0 }), colorZ: G.Color(Kt.blue, { isEssential: !0 }), scale: G.Numeric(2, { min: 0.1, max: 5, step: 0.1 }) }), lne = R(R(R({}, Gt.Params), TF), { pocketColor: G.Color(Kt.red), pocketScale: G.Numeric(4, { min: 0.1, max: 5, step: 0.1 }), x: G.Numeric(10), y: G.Numeric(10), z: G.Numeric(10), center: G.Vec3(w()) }), dne = R(R({}, lne), TF), fne = { axes: function(e, t) {
  return An(mne, Gt.Utils);
}, mesh: function(e, t) {
  return An(pne, Gt.Utils);
} };
function pne(e, t, r, n) {
  var i = function(o, u, s) {
    var c = wt.createState(256, 128, s), l = o.gridPocket.fromFractional;
    w.copy(Gd, o.ref), w.subScalar(Gd, Gd, 0.5), me.fromTranslation(OD, Gd);
    var d = Bg(Pg(cne), OD), f = Math.cbrt(o.gridPocket.volume) / 300 * u.pocketScale;
    c.currentGroup = 1, wt.addCage(c, l, d, f, 2, 20);
    var m = Me.fromDimensionsAndTransform(Me(), w.unit, l);
    w.transformMat4(Gd, Gd, l), Me.translate(m, m, Gd), Me.expand(m, m, f);
    var v = wt.getMesh(c);
    return v.setBoundingSphere(m), v;
  }(t, r, n && n.geometry), a = "Grid Pocket Box";
  return $t.create(a, t, i, function() {
    return r.pocketColor;
  }, function() {
    return 1;
  }, function() {
    return a;
  });
}
function LD(e, t, r, n) {
  var i = w(), a = me.ofRows([[e, 0, 0, 0], [0, t, 0, 0], [0, 0, r, 0], [0, 0, 0, 1]]), o = me.invert(me.zero(), a);
  return { ref: w.transformMat4(i, n, o), gridPocket: { fromFractional: a, toFractional: o, x: e, y: t, z: r, center: n, volume: e * t * r } };
}
function mne(e, t, r, n) {
  var i = r.scale, a = function(o, u, s) {
    var c = u.gridPocket, l = c.x, d = c.y, f = c.z, m = c.center, v = c.volume, p = wt.createState(512, 256, s), g = Math.cbrt(v) / 300 * o, h = m[0], y = m[1], x = m[2], A = Math.min(l, d, f), b = w.create(h + A / 3, y, x), _ = w.create(h, y + A / 3, x), S = w.create(h, y, x + A / 3), D = { radiusTop: g, radiusBottom: g, radialSegments: 32 };
    return p.currentGroup = 0, Mi(p, m, g, 2), p.currentGroup = 1, Mi(p, b, g, 2), wi(p, m, b, 1, D), p.currentGroup = 2, Mi(p, _, g, 2), wi(p, m, _, 1, D), p.currentGroup = 3, Mi(p, S, g, 2), wi(p, m, S, 1, D), w.scale(b, b, 0.5), w.scale(_, _, 0.5), w.scale(S, S, 0.5), wt.getMesh(p);
  }(i, t, n == null ? void 0 : n.geometry);
  return a.setBoundingSphere(Me.create(w.create(i / 2, i / 2, i / 2), i + i / 4)), $t.create("axes", {}, a, function(o) {
    switch (o) {
      case 1:
        return r.colorX;
      case 2:
        return r.colorY;
      case 3:
        return r.colorZ;
      default:
        return Kt.grey;
    }
  }, function() {
    return 1;
  }, function() {
    return "";
  });
}
var hne = { create: function(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o, u;
    return ye(this, function(s) {
      switch (s.label) {
        case 0:
          return n = function(c, l) {
            return or.createMulti("Grid Pocket", c, l, or.StateBuilder, fne);
          }(t, function() {
            return dne;
          }), i = e.x, a = e.y, o = e.z, u = e.center, [4, n.createOrUpdate(e, LD(i, a, o, u)).run()];
        case 1:
          return s.sent(), [2, n];
      }
    });
  });
}, update: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    var i, a, o, u;
    return ye(this, function(s) {
      switch (s.label) {
        case 0:
          return i = t.x, a = t.y, o = t.z, u = t.center, [4, e.createOrUpdate(t, LD(i, a, o, u)).run()];
        case 1:
          return s.sent(), [2];
      }
    });
  });
} }, vne = [2, 1, 0, 0, 3, 2, 1, 3, 0, 2, 3, 1], T1 = { radiusFactor: G.Numeric(1, { min: 0.1, max: 3, step: 0.01 }, { description: "Scale the radius of the membrane layer" }), center: G.Vec3(w()), radius: G.Numeric(1), vec: G.Vec3(w()) }, PF = { "pharmacophore-ball-1": function(e, t) {
  return An(_ne, Mr.Utils, { modifyState: function(r) {
    return R(R({}, r), { markerActions: Pr.All });
  } });
}, "pharmacophore-ball-2": function(e, t) {
  return An(xne, Mr.Utils, { modifyState: function(r) {
    return R(R({}, r), { markerActions: Pr.All });
  } });
}, "pharmacophore-sphere-1": function(e, t) {
  return An(Sne, ns.Utils, { modifyState: function(r) {
    return R(R({}, r), { markerActions: Pr.All });
  } });
}, "pharmacophore-sphere-2": function(e, t) {
  return An(Cne, ns.Utils, { modifyState: function(r) {
    return R(R({}, r), { markerActions: Pr.All });
  } });
}, "pharmacophore-cylinder": function(e, t) {
  return An(wne, Na.Utils, { modifyState: function(r) {
    return R(R({}, r), { markerActions: Pr.All });
  } });
}, "pharmacophore-arrowhead": function(e, t) {
  return An(Dne, Gt.Utils);
} }, gne = R(R(R({}, Mr.Params), T1), { color: G.Color(Kt.blue), lineSizeAttenuation: G.Boolean(!1), linesSize: G.Numeric(1, { min: 0.01, max: 50, step: 0.01 }), dashedLines: G.Boolean(!1), alpha: G.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), yne = R(R(R({}, Mr.Params), T1), { color: G.Color(Kt.blue), lineSizeAttenuation: G.Boolean(!1), linesSize: G.Numeric(1, { min: 0.01, max: 50, step: 0.01 }), dashedLines: G.Boolean(!1), alpha: G.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), bne = R(R(R({}, gne), yne), { visuals: G.MultiSelect(["pharmacophore-ball-1", "pharmacophore-ball-2", "pharmacophore-sphere-1", "pharmacophore-sphere-2", "pharmacophore-cylinder", "pharmacophore-arrowhead"], G.objectToOptions(PF)), alpha: G.Numeric(0.2, { min: 0, max: 1, step: 0.1 }) });
function _ne(e, t, r, n) {
  var i = r.radiusFactor, a = r.center, o = i * r.radius, u = aa.create(128, 64, n == null ? void 0 : n.geometry), s = w.create(0, 0, 0);
  w.add(s, a, w.create(0, 1, 0));
  var c = w.create(0, 0, 0);
  w.add(c, a, w.create(0, 0, 1));
  var l = w.create(0, 0, 0);
  w.add(l, a, w.create(1, 0, 0)), ta(u, a, s, o, r), ta(u, a, c, o, r), ta(u, a, l, o, r);
  var d = w.create(0, 0, 0);
  w.add(d, a, w.create(0, 0.5 * o, 0));
  var f = w.create(0, 0, 0);
  w.add(f, d, w.create(0, Math.sqrt(0.75), 0)), ta(u, d, f, Math.sqrt(0.75) * o, r);
  var m = w.create(0, 0, 0);
  w.add(m, a, w.create(0, -0.5 * o, 0));
  var v = w.create(0, 0, 0);
  return w.add(v, m, w.create(0, -Math.sqrt(0.75), 0)), ta(u, m, v, Math.sqrt(0.75) * o, r), d = w.create(0, 0, 0), w.add(d, a, w.create(0.5 * o, 0, 0)), f = w.create(0, 0, 0), w.add(f, d, w.create(Math.sqrt(0.75), 0, 0)), ta(u, d, f, Math.sqrt(0.75) * o, r), m = w.create(0, 0, 0), w.add(m, a, w.create(-0.5 * o, 0, 0)), v = w.create(0, 0, 0), w.add(v, m, w.create(-Math.sqrt(0.75), 0, 0)), ta(u, m, v, Math.sqrt(0.75) * o, r), d = w.create(0, 0, 0), w.add(d, a, w.create(0, 0, 0.5 * o)), f = w.create(0, 0, 0), w.add(f, d, w.create(0, 0, Math.sqrt(0.75))), ta(u, d, f, Math.sqrt(0.75) * o, r), m = w.create(0, 0, 0), w.add(m, a, w.create(0, 0, -0.5 * o)), v = w.create(0, 0, 0), w.add(v, m, w.create(0, 0, -Math.sqrt(0.75))), ta(u, m, v, Math.sqrt(0.75) * o, r), $t.create("pharmacophore-ball-1", r, u.getLines(), function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "pharmacophore";
  });
}
function xne(e, t, r, n) {
  var i = r.radiusFactor, a = r.center, o = r.radius, u = r.vec, s = i * o, c = w.create(0, 0, 0);
  w.add(c, a, u);
  var l = aa.create(128, 64, n == null ? void 0 : n.geometry), d = w.create(0, 0, 0);
  w.add(d, c, w.create(0, 1, 0));
  var f = w.create(0, 0, 0);
  w.add(f, c, w.create(0, 0, 1));
  var m = w.create(0, 0, 0);
  w.add(m, c, w.create(1, 0, 0)), ta(l, c, d, s, r), ta(l, c, f, s, r), ta(l, c, m, s, r);
  var v = w.create(0, 0, 0);
  w.add(v, c, w.create(0, 0.5 * s, 0));
  var p = w.create(0, 0, 0);
  w.add(p, v, w.create(0, Math.sqrt(0.75), 0)), ta(l, v, p, Math.sqrt(0.75) * s, r);
  var g = w.create(0, 0, 0);
  w.add(g, c, w.create(0, -0.5 * s, 0));
  var h = w.create(0, 0, 0);
  return w.add(h, g, w.create(0, -Math.sqrt(0.75), 0)), ta(l, g, h, Math.sqrt(0.75) * s, r), v = w.create(0, 0, 0), w.add(v, c, w.create(0.5 * s, 0, 0)), p = w.create(0, 0, 0), w.add(p, v, w.create(Math.sqrt(0.75), 0, 0)), ta(l, v, p, Math.sqrt(0.75) * s, r), g = w.create(0, 0, 0), w.add(g, c, w.create(-0.5 * s, 0, 0)), h = w.create(0, 0, 0), w.add(h, g, w.create(-Math.sqrt(0.75), 0, 0)), ta(l, g, h, Math.sqrt(0.75) * s, r), v = w.create(0, 0, 0), w.add(v, c, w.create(0, 0, 0.5 * s)), p = w.create(0, 0, 0), w.add(p, v, w.create(0, 0, Math.sqrt(0.75))), ta(l, v, p, Math.sqrt(0.75) * s, r), g = w.create(0, 0, 0), w.add(g, c, w.create(0, 0, -0.5 * s)), h = w.create(0, 0, 0), w.add(h, g, w.create(0, 0, -Math.sqrt(0.75))), ta(l, g, h, Math.sqrt(0.75) * s, r), $t.create("pharmacophore-ball-2", r, l.getLines(), function() {
    return r.color;
  }, function() {
    return r.linesSize;
  }, function() {
    return "pharmacophore";
  });
}
function ta(e, t, r, n, i, a) {
  for (var o = function(x, A, b) {
    w.dot(w.unitY, w.sub(Ane, x, A)) === 0 ? me.targetTo(b1, x, A, w.unitY) : me.targetTo(b1, x, A, w.unitX), me.setTranslation(b1, x), me.mul(b1, b1, me.rotX90);
    var _ = f8({ radius: b, segments: 64 });
    return Mg(_, b1);
  }(t, r, n), u = o.indices, s = o.vertices, c = 0, l = u.length; c < l; c += 3) if (!i.dashedLines || c % 2 != 1) {
    var d = 3 * u[c], f = 3 * u[c + 1], m = s[d], v = s[d + 1], p = s[d + 2], g = s[f], h = s[f + 1], y = s[f + 2];
    e.add(m, v, p, g, h, y, 0);
  }
}
R(R(R({}, ns.Params), T1), { sizeFactor: G.Numeric(1, { min: 0, max: 10, step: 0.1 }), color: G.Color(Kt.green), alpha: G.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), R(R(R({}, ns.Params), T1), { sizeFactor: G.Numeric(1, { min: 0, max: 10, step: 0.1 }), color: G.Color(Kt.brown), alpha: G.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), R(R(R({}, Na.Params), T1), { color: G.Color(Kt.brown), sizeFactor: G.Numeric(0.1, { min: 0, max: 10, step: 0.1 }) }), R(R(R({}, Gt.Params), T1), { color: G.Color(Kt.brown) });
var b1 = me(), Ane = w();
function BF(e, t, r, n) {
  e.add(t[0], t[1], t[2], n);
}
function Sne(e, t, r, n) {
  var i = r.center, a = r.radius, o = r.radiusFactor, u = vm.create(128, 64);
  return BF(u, i, 0, 0), $t.create("pharmacophore-sphere-1", R(R({}, r), { sizeFactor: 0.1 * r.radius }), u.getSpheres(), function() {
    return r.color;
  }, function() {
    return a * o / 2;
  }, function() {
    return "pharmacophore";
  });
}
function Cne(e, t, r, n) {
  var i = r.center, a = r.radius, o = r.vec, u = r.radiusFactor, s = w.create(0, 0, 0);
  w.add(s, i, o);
  var c = vm.create(128, 64);
  return BF(c, s, 0, 1), $t.create("pharmacophore-sphere-2", R(R({}, r), { sizeFactor: 0.1 * r.radius }), c.getSpheres(), function() {
    return r.color;
  }, function() {
    return a * u / 2;
  }, function() {
    return "pharmacophore";
  });
}
function wne(e, t, r, n) {
  var i = r.center, a = r.vec, o = w.create(0, 0, 0);
  w.normalize(o, a);
  var u = w.create(0, 0, 0);
  w.scale(u, o, 0.25);
  var s = w.create(0, 0, 0);
  w.sub(s, a, u);
  var c = w.create(0, 0, 0);
  w.add(c, i, s);
  var l = w.create(0, 0, 0);
  w.scale(l, o, 0.3), w.sub(c, c, l);
  var d = hm.create(128, 64);
  return d.add(i[0], i[1], i[2], c[0], c[1], c[2], 0.025, !0, !0, 2), $t.create("pharmacophore-cylinder", r, d.getCylinders(), function() {
    return r.color;
  }, function() {
    return r.sizeFactor;
  }, function() {
    return "pharmacophore";
  });
}
function Dne(e, t, r, n) {
  var i = r.center, a = r.vec, o = w.create(0, 0, 0);
  w.normalize(o, a);
  var u = w.create(0, 0, 0);
  w.scale(u, o, 0.25);
  var s = w.create(0, 0, 0);
  w.sub(s, a, u);
  var c = w.create(0, 0, 0);
  w.add(c, i, s);
  var l = w.create(0, 0, 0), d = w.create(0, 0, 0);
  w.scale(d, o, 0.3), w.sub(l, c, d);
  var f = w.create(0, 0, 0), m = w.create(1, 2, l[2] - (o[0] * (1 - l[0]) + o[1] * (2 - l[1])) / o[2]);
  w.sub(f, m, l), w.normalize(f, f);
  var v = w.create(0, 0, 0);
  w.scale(v, f, 0.3);
  var p = w.create(0, 0, 0);
  w.add(p, l, v);
  var g = w.create(0, 0, 0);
  w.sub(g, p, l);
  var h = w.create(0, 0, 0), y = w.create(0, 0, 0);
  w.scale(y, g, Math.cos(120 * Math.PI / 180));
  var x = w.create(0, 0, 0);
  w.cross(x, o, g), w.scale(x, x, Math.sin(120 * Math.PI / 180));
  var A = w.create(0, 0, 0);
  w.scale(A, o, w.dot(o, g) * (1 - Math.cos(120 * Math.PI / 180))), w.add(h, y, x), w.add(h, h, A), w.add(h, h, l);
  var b = w.create(0, 0, 0);
  y = w.create(0, 0, 0), w.scale(y, g, Math.cos(240 * Math.PI / 180)), x = w.create(0, 0, 0), w.cross(x, o, g), w.scale(x, x, Math.sin(240 * Math.PI / 180)), A = w.create(0, 0, 0), w.scale(A, o, w.dot(o, g) * (1 - Math.cos(240 * Math.PI / 180))), w.add(b, y, x), w.add(b, b, A), w.add(b, b, l);
  var _ = wt.createState(128, 64), S = function(M) {
    return RT(M, vne);
  }([c[0], c[1], c[2], p[0], p[1], p[2], h[0], h[1], h[2], b[0], b[1], b[2]]), D = me.ofRows([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]), I = me.invert(me.zero(), D);
  return wt.addPrimitive(_, I, S), $t.create("axes", {}, wt.getMesh(_), function() {
    return r.color;
  }, function() {
    return 0.15;
  }, function() {
    return "";
  });
}
var Ine = { create: function(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return n = function(a, o) {
            var u = or.createMulti("Pharmacophore", a, o, Wo, PF);
            return u.setState({ markerActions: Pr.All }), u;
          }(t, function() {
            return bne;
          }), [4, n.createOrUpdate(e, e).run()];
        case 1:
          return i.sent(), [2, n];
      }
    });
  });
}, update: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return [4, e.createOrUpdate(t, t).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} };
function M6(e, t) {
  var r, n, i, a, o, u, s, c, l = e.defaultProps, d = e.createGeometry, f = e.createLocationIterator, m = e.getLoci, v = e.eachLocation, p = e.setUpdateState, g = e.mustRecreate, h = e.dispose, y = e.geometryUtils, x = y.updateValues, A = y.updateBoundingSphere, b = y.updateRenderableState, _ = y.createPositionIterator, S = Rs.create(), D = Object.assign({}, l), I = Bu.createEmpty(), M = -1;
  function F(E) {
    if (S.createNew) {
      if (s = f(a), !E) throw new Error("expected geometry to be given");
      r = function(B, N, O, z, V, U) {
        var H = oa.getUtils(N), K = H.createValues, j = H.createRenderableState, X = K(N, w_(), O, z, V), W = j(V);
        return x0(N.kind, X, W, U);
      }(0, E, s, i, n, t), c = _(E, r.values);
    } else {
      if (!r) throw new Error("expected renderObject to be available");
      if (s.reset(), S.createGeometry) {
        if (!E) throw new Error("expected geometry to be given");
        k.updateIfChanged(r.values.drawCount, oa.getDrawCount(E)), k.updateIfChanged(r.values.uVertexCount, oa.getVertexCount(E));
      }
      (S.updateTransform || S.createGeometry) && (A(r.values, E || u), c = _(E || u, r.values)), S.updateSize && "uSize" in r.values && Lc(s, i.size, r.values), S.updateColor && Xo(s, c, i.color, r.values), x(r.values, n), b(r.state, n);
    }
    D = n, I = i, o = a, E && (u = E, M += 1);
  }
  function P(E, B) {
    return xo(E) ? B(Ae.ofBounds(0, s.groupCount * s.instanceCount)) : v(E, o, D, B);
  }
  return { get groupCount() {
    return s ? s.count : 0;
  }, get renderObject() {
    return r;
  }, get geometryVersion() {
    return M;
  }, createOrUpdate: function(E, B, N, O) {
    return N === void 0 && (N = {}), _e(this, 0, void 0, function() {
      var z;
      return ye(this, function(V) {
        return function(U, H, K) {
          if (!K && !o) throw new Error("missing volume");
          n = Object.assign({}, D, H), i = U, a = K, Rs.reset(S), r && o && ar.areEquivalent(a, o) || (S.createNew = !0), S.createNew ? S.createGeometry = !0 : (p(S, K, n, D, i, I), Bc.areEqual(U.color, I.color) || (S.updateColor = !0), S.createGeometry && (S.updateColor = !0));
        }(B, N, O || o), S.createGeometry ? [2, u_(z = d(E, a, i, n, u)) ? z.then(F) : F(z)] : (F(), [2]);
      });
    });
  }, getLoci: function(E) {
    return r ? m(E, o, D, r.id) : vn;
  }, mark: function(E, B) {
    return rr.mark(r, E, B, P);
  }, setVisibility: function(E) {
    rr.setVisibility(r, E);
  }, setAlphaFactor: function(E) {
    rr.setAlphaFactor(r, E);
  }, setPickable: function(E) {
    rr.setPickable(r, E);
  }, setColorOnly: function(E) {
    rr.setColorOnly(r, E);
  }, setTransform: function(E, B) {
    rr.setTransform(r, E, B);
  }, setOverpaint: function(E) {
    return rr.setOverpaint(r, E, P, !0);
  }, setTransparency: function(E) {
    return rr.setTransparency(r, E, P, !0);
  }, setSubstance: function(E) {
    return rr.setSubstance(r, E, P, !0);
  }, setClipping: function(E) {
    return rr.setClipping(r, E, P, !0);
  }, destroy: function() {
    h == null || h(u), r && (r.state.disposed = !0, r = void 0);
  }, mustRecreate: g };
}
function kD(e, t, r, n, i) {
  var a, o, u, s, c = 0, l = t.webgl, d = new ui(), f = new or.GeometryState(), m = zc(), v = [], p = or.createState(), g = Bu.createEmpty();
  return { label: e, get groupCount() {
    return a ? a.groupCount : 0;
  }, get props() {
    return s;
  }, get params() {
    return u;
  }, get state() {
    return p;
  }, get theme() {
    return g;
  }, get geometryVersion() {
    return f.version;
  }, renderObjects: v, updated: d, createOrUpdate: function(h, y) {
    var x = this;
    h === void 0 && (h = {}), y && y !== o && (u = r(t, y), o = y, s || (s = G.getDefaultValues(u)));
    var A = jb(Object.assign({}, s, h), o);
    return Object.assign(s, h, A), er.create("Creating or updating VolumeRepresentation", function(b) {
      return _e(x, 0, void 0, function() {
        var _, S;
        return ye(this, function(D) {
          switch (D.label) {
            case 0:
              return a ? !((S = a.mustRecreate) === null || S === void 0) && S.call(a, o, s, l) && (a.destroy(), a = n(m, o, s, l)) : a = n(m, o, s, l), (_ = a.createOrUpdate({ webgl: l, runtime: b }, g, s, y)) ? [4, _] : [3, 2];
            case 1:
              D.sent(), D.label = 2;
            case 2:
              return v.length = 0, a && a.renderObject && (v.push(a.renderObject), f.add(a.renderObject.id, a.geometryVersion)), f.snapshot(), d.next(c++), [2];
          }
        });
      });
    });
  }, setState: function(h) {
    h.visible !== void 0 && a && a.setVisibility(h.visible), h.alphaFactor !== void 0 && a && a.setAlphaFactor(h.alphaFactor), h.pickable !== void 0 && a && a.setPickable(h.pickable), h.overpaint !== void 0 && a && a.setOverpaint(h.overpaint), h.transparency !== void 0 && a && a.setTransparency(h.transparency), h.transform !== void 0 && a && a.setTransform(h.transform), or.updateState(p, h);
  }, setTheme: function(h) {
    g = h;
  }, getLoci: function(h) {
    return h === void 0 ? i(o, s) : a ? a.getLoci(h) : vn;
  }, mark: function(h, y) {
    return !!a && a.mark(h, y);
  }, destroy: function() {
    a && a.destroy();
  } };
}
R({}, ft.Params);
var Ene = `
precision highp float;
precision highp int;

#if __VERSION__ == 100
    precision highp sampler2D;
    uniform sampler2D tTexture;
#else
    precision highp isampler2D;
    uniform isampler2D tTexture;
#endif

void main(void) {
    #if __VERSION__ == 100
        gl_FragColor = texture2D(tTexture, vec2(0.5));
    #else
        gl_FragColor = ivec4(texture2D(tTexture, vec2(0.5)).r);
    #endif
}
`, Mne = R(R({}, qi), { tTexture: zt("texture", "rgba", "float", "nearest") }), wu = "histopyramid-sum";
function Tne(e, t) {
  if (e.namedComputeRenderables[wu]) {
    var r = e.namedComputeRenderables[wu].values;
    k.update(r.tTexture, t), e.namedComputeRenderables[wu].update();
  } else e.namedComputeRenderables[wu] = function(n, i) {
    var a = R(R({}, Ui), { tTexture: k.create(i) }), o = R({}, Mne), u = Sn("sum", Fa, Ene, {}, { 0: "ivec4" }), s = Bi(n, "triangles", u, o, a);
    return Fi(s, a);
  }(e, t);
  return e.namedComputeRenderables[wu];
}
var Lv = new Uint8Array(4), zD = new Int32Array(4), kv, zv, Pne = `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tInputLevel;

// previous level used to evaluate the new level
#if __VERSION__ == 100
    uniform sampler2D tPreviousLevel;
#else
    precision highp isampler2D;
    uniform isampler2D tPreviousLevel;
#endif

// inverted size of the previous level texture.
uniform float uSize;
uniform float uTexSize;
uniform bool uFirst;

#include common

void main(void) {
    float k = 0.5 * uSize;
    vec2 position = floor((gl_FragCoord.xy / uTexSize) / uSize) * uSize;

    #if __VERSION__ == 100
        float a, b, c, d;

        if (uFirst) {
            a = texture2D(tInputLevel, position).r * 255.0;
            b = texture2D(tInputLevel, position + vec2(k, 0.0)).r * 255.0;
            c = texture2D(tInputLevel, position + vec2(0.0, k)).r * 255.0;
            d = texture2D(tInputLevel, position + vec2(k, k)).r * 255.0;
        } else {
            a = unpackRGBToInt(texture2D(tPreviousLevel, position).rgb);
            b = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(k, 0.0)).rgb);
            c = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(0.0, k)).rgb);
            d = unpackRGBToInt(texture2D(tPreviousLevel, position + vec2(k, k)).rgb);
        }
        gl_FragColor = vec4(packIntToRGB(a + b + c + d), 1.0);
    #else
        int a, b, c, d;

        if (uFirst) {
            a = int(texture2D(tInputLevel, position).r * 255.0);
            b = int(texture2D(tInputLevel, position + vec2(k, 0.0)).r * 255.0);
            c = int(texture2D(tInputLevel, position + vec2(0.0, k)).r * 255.0);
            d = int(texture2D(tInputLevel, position + vec2(k, k)).r * 255.0);
        } else {
            a = texture2D(tPreviousLevel, position).r;
            b = texture2D(tPreviousLevel, position + vec2(k, 0.0)).r;
            c = texture2D(tPreviousLevel, position + vec2(0.0, k)).r;
            d = texture2D(tPreviousLevel, position + vec2(k, k)).r;
        }
        gl_FragColor = ivec4(a + b + c + d);
    #endif
}
`, Bne = R(R({}, qi), { tInputLevel: zt("texture", "rgba", "float", "nearest"), tPreviousLevel: zt("texture", "rgba", "float", "nearest"), uSize: Ie("f"), uTexSize: Ie("f"), uFirst: Ie("b") }), Nl = "histogram-pyramid";
function Fne(e, t, r) {
  if (e.namedComputeRenderables[Nl]) {
    var n = e.namedComputeRenderables[Nl].values;
    k.update(n.tInputLevel, t), k.update(n.tPreviousLevel, r), e.namedComputeRenderables[Nl].update();
  } else e.namedComputeRenderables[Nl] = function(i, a, o) {
    var u = R(R({}, Ui), { tInputLevel: k.create(a), tPreviousLevel: k.create(o), uSize: k.create(0), uTexSize: k.create(0), uFirst: k.create(!0) }), s = R({}, Bne), c = Sn("reduction", Fa, Pne, {}, { 0: "ivec4" }), l = Bi(i, "triangles", c, s, u);
    return Fi(l, u);
  }(e, t, r);
  return e.namedComputeRenderables[Nl];
}
function Nne(e, t) {
  var r = Math.pow(2, t), n = "level".concat(t), i = e.isWebGL2 ? ig(n, e, "image-int32", "alpha", "int", "nearest") : ig(n, e, "image-uint8", "rgba", "ubyte", "nearest");
  i.define(r, r);
  var a = function(o, u) {
    var s = "".concat(Nl, "-").concat(o);
    return u.namedFramebuffers[s];
  }(n, e);
  return a || (a = FF(n, e), i.attachFramebuffer(a, 0)), { texture: i, framebuffer: a };
}
function FF(e, t) {
  var r = "".concat(Nl, "-").concat(e);
  return t.namedFramebuffers[r] || (t.namedFramebuffers[r] = t.resources.framebuffer()), t.namedFramebuffers[r];
}
function ig(e, t, r, n, i, a) {
  var o = "".concat(Nl, "-").concat(e);
  return t.namedTextures[o] || (t.namedTextures[o] = t.resources.texture(r, n, i, a)), t.namedTextures[o];
}
function Rne(e, t, r, n) {
  var i = e.gl, a = t.getWidth();
  if (a !== t.getHeight() || !function(x) {
    return x !== 0 && !(x & x - 1);
  }(a)) throw new Error("inputTexture must be of square power-of-two size");
  var o = Math.ceil(Math.log(a) / Math.log(2)), u = Math.pow(2, o), s = Math.pow(2, o), c = Math.pow(2, o - 1), l = e.isWebGL2 ? ig("pyramid", e, "image-int32", "alpha", "int", "nearest") : ig("pyramid", e, "image-uint8", "rgba", "ubyte", "nearest");
  l.define(s, c);
  var d = FF("pyramid", e);
  l.attachFramebuffer(d, 0), i.viewport(0, 0, s, c), ir(i) ? i.clearBufferiv(i.COLOR, 0, [0, 0, 0, 0]) : i.clear(i.COLOR_BUFFER_BIT);
  for (var f = [], m = 0; m < o; ++m) f.push(Nne(e, m));
  var v = Fne(e, t, f[0].texture);
  e.state.currentRenderItemId = -1, function(x) {
    var A = x.gl, b = x.state;
    b.disable(A.CULL_FACE), b.disable(A.BLEND), b.disable(A.DEPTH_TEST), b.enable(A.SCISSOR_TEST), b.depthMask(!1), b.colorMask(!0, !0, !0, !0), b.clearColor(0, 0, 0, 0);
  }(e);
  var p = 0;
  for (m = 0; m < o; m++) {
    var g = o - 1 - m;
    f[g].framebuffer.bind();
    var h = Math.pow(2, g);
    k.update(v.values.uSize, Math.pow(2, m + 1) / u), k.update(v.values.uTexSize, h), k.updateIfChanged(v.values.uFirst, m === 0), m > 0 && (k.update(v.values.tPreviousLevel, f[o - m].texture), v.update()), e.state.currentRenderItemId = -1, i.viewport(0, 0, h, h), i.scissor(0, 0, h, h), ir(i) ? i.clearBufferiv(i.COLOR, 0, [0, 0, 0, 0]) : i.clear(i.COLOR_BUFFER_BIT), i.scissor(0, 0, n[0], n[1]), v.render(), l.bind(0), i.copyTexSubImage2D(i.TEXTURE_2D, 0, p, 0, 0, 0, h, h), l.unbind(0), p += h;
  }
  i.finish();
  var y = Math.max(1, function(x, A) {
    var b = x.gl, _ = x.resources, S = Tne(x, A);
    x.state.currentRenderItemId = -1, x.namedFramebuffers[wu] || (x.namedFramebuffers[wu] = _.framebuffer());
    var D = x.namedFramebuffers[wu];
    return x.namedTextures[wu] || (x.namedTextures[wu] = ir(b) ? _.texture("image-int32", "rgba", "int", "nearest") : _.texture("image-uint8", "rgba", "ubyte", "nearest"), x.namedTextures[wu].define(1, 1)), x.namedTextures[wu].attachFramebuffer(D, 0), function(I) {
      var M = I.gl, F = I.state;
      F.disable(M.CULL_FACE), F.disable(M.BLEND), F.disable(M.DEPTH_TEST), F.disable(M.SCISSOR_TEST), F.depthMask(!1), F.colorMask(!0, !0, !0, !0), F.clearColor(0, 0, 0, 0);
    }(x), b.viewport(0, 0, 1, 1), S.render(), b.finish(), x.readPixels(0, 0, 1, 1, ir(b) ? zD : Lv), x.unbindFramebuffer(), ir(b) ? zD[0] : D_(Lv[0], Lv[1], Lv[2]);
  }(e, f[0].texture));
  return { pyramidTex: l, count: y, height: Math.ceil(y / Math.pow(2, o)), levels: o, scale: r };
}
function One() {
  if (kv !== void 0) return kv;
  for (var e = (kv = Di(256, 1, Uint8Array)).array, t = 0, r = z1.length; t < r; ++t) e[t] = z1[t].length / 3;
  return kv;
}
function Lne() {
  if (zv !== void 0) return zv;
  for (var e = (zv = Di(4096, 1, Uint8Array)).array, t = 0, r = z1.length; t < r; ++t) for (var n = 0; n < 16; ++n) n < z1[t].length ? e[16 * t + n] = z1[t][n] : e[16 * t + n] = 255;
  return zv;
}
var kne = `
precision highp float;
precision highp int;
precision highp sampler2D;

#if __VERSION__ == 100
    uniform sampler2D tActiveVoxelsPyramid;
#else
    precision highp isampler2D;
    uniform isampler2D tActiveVoxelsPyramid;
#endif

uniform sampler2D tActiveVoxelsBase;
uniform sampler2D tVolumeData;
uniform sampler2D tTriIndices;

uniform float uIsoValue;
uniform float uLevels;
uniform float uSize;
uniform float uCount;
uniform bool uInvert;

uniform vec3 uGridDim;
uniform vec3 uGridTexDim;
uniform mat4 uGridTransform;

// scale to volume data coord
uniform vec2 uScale;

#include common

// cube corners (excluding origin)
const vec3 c1 = vec3(1., 0., 0.);
const vec3 c2 = vec3(1., 1., 0.);
const vec3 c3 = vec3(0., 1., 0.);
const vec3 c4 = vec3(0., 0., 1.);
const vec3 c5 = vec3(1., 0., 1.);
const vec3 c6 = vec3(1., 1., 1.);
const vec3 c7 = vec3(0., 1., 1.);

vec3 index3dFrom2d(vec2 coord) {
    vec2 gridTexPos = coord * uGridTexDim.xy;
    vec2 columnRow = ivec2Div(gridTexPos, uGridDim.xy);
    vec2 posXY = gridTexPos - columnRow * uGridDim.xy;
    float posZ = columnRow.y * intDiv(uGridTexDim.x, uGridDim.x) + columnRow.x;
    return vec3(posXY, posZ);
}

vec4 texture3dFrom2dNearest(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) {
    float zSlice = floor(pos.z * gridDim.z + 0.5); // round to nearest z-slice
    float column = intDiv(intMod(zSlice * gridDim.x, texDim.x), gridDim.x);
    float row = intDiv(zSlice * gridDim.x, texDim.x);
    vec2 coord = (vec2(column * gridDim.x, row * gridDim.y) + (pos.xy * gridDim.xy)) / (texDim / uScale);
    return texture2D(tex, coord + 0.5 / (texDim / uScale));
}

vec4 voxel(vec3 pos) {
    pos = min(max(vec3(0.0), pos), uGridDim - vec3(1.0));
    return texture3dFrom2dNearest(tVolumeData, pos / uGridDim, uGridDim, uGridTexDim.xy);
}

vec4 voxelPadded(vec3 pos) {
    pos = min(max(vec3(0.0), pos), uGridDim - vec3(vec2(2.0), 1.0)); // remove xy padding
    return texture3dFrom2dNearest(tVolumeData, pos / uGridDim, uGridDim, uGridTexDim.xy);
}

int idot2(const in ivec2 a, const in ivec2 b) {
    return a.x * b.x + a.y * b.y;
}

int idot4(const in ivec4 a, const in ivec4 b) {
    return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
}

#if __VERSION__ == 100
    int pyramidVoxel(vec2 pos) {
        return int(unpackRGBToInt(texture2D(tActiveVoxelsPyramid, pos / (vec2(1.0, 0.5) * uSize)).rgb));
    }
#else
    int pyramidVoxel(vec2 pos) {
        return texture2D(tActiveVoxelsPyramid, pos / (vec2(1.0, 0.5) * uSize)).r;
    }
#endif

vec4 baseVoxel(vec2 pos) {
    return texture2D(tActiveVoxelsBase, pos / uSize);
}

vec4 getGroup(const in vec3 p) {
    vec3 gridDim = uGridDim - vec3(1.0, 1.0, 0.0); // remove xy padding
    // note that we swap x and z because the texture is flipped around y
    #if defined(dAxisOrder_012)
        float group = p.z + p.y * gridDim.z + p.x * gridDim.z * gridDim.y; // 210
    #elif defined(dAxisOrder_021)
        float group = p.y + p.z * gridDim.y + p.x * gridDim.y * gridDim.z; // 120
    #elif defined(dAxisOrder_102)
        float group = p.z + p.x * gridDim.z + p.y * gridDim.z * gridDim.x; // 201
    #elif defined(dAxisOrder_120)
        float group = p.x + p.z * gridDim.x + p.y * gridDim.x * gridDim.z; // 021
    #elif defined(dAxisOrder_201)
        float group = p.y + p.x * gridDim.y + p.z * gridDim.y * gridDim.x; // 102
    #elif defined(dAxisOrder_210)
        float group = p.x + p.y * gridDim.x + p.z * gridDim.x * gridDim.y; // 012
    #endif
    return vec4(group > 16777215.5 ? vec3(1.0) : packIntToRGB(group), 1.0);
}

void main(void) {
    // get 1D index
    int vI = int(gl_FragCoord.x) + int(gl_FragCoord.y) * int(uSize);

    // ignore 1D indices outside of the grid
    if(vI >= int(uCount)) discard;

    ivec2 offset = ivec2(int(uSize) - 2, 0);

    int start = 0;
    ivec4 starts = ivec4(0);
    ivec4 ends = ivec4(0);
    int diff = 2;
    ivec4 m = ivec4(0);
    ivec2 position = ivec2(0);
    ivec4 vI4 = ivec4(vI);

    ivec2 relativePosition = ivec2(0);
    int end = 0;
    ivec2 pos1 = ivec2(0);
    ivec2 pos2 = ivec2(0);
    ivec2 pos3 = ivec2(0);
    ivec2 pos4 = ivec2(0);
    ivec3 vI3 = ivec3(vI);
    ivec3 mask = ivec3(0);

    // traverse the different levels of the pyramid
    for(int i = 1; i < 14; i++) {
        if(float(i) >= uLevels) break;

        offset.x -= diff;
        diff *= 2;
        relativePosition = position + offset;

        end = start + pyramidVoxel(vec2(relativePosition));
        pos1 = ivec2(relativePosition);
        starts.x = start;
        ends.x = end;
        pos2 = ivec2(relativePosition + ivec2(1, 0));
        starts.y = ends.x;
        ends.y = ends.x + pyramidVoxel(vec2(pos2));
        pos3 = relativePosition + ivec2(0, 1);
        starts.z = ends.y;
        ends.z = ends.y + pyramidVoxel(vec2(pos3));
        pos4 = relativePosition + ivec2(1, 1);
        starts.w = ends.z;
        mask = ivec3(greaterThanEqual(vI3, starts.rgb)) * ivec3(lessThan(vI3, ends.rgb));
        m = ivec4(mask, 1 - int(any(bvec3(mask))));

        relativePosition = m.x * pos1 + m.y * pos2 + m.z * pos3 + m.w * pos4;
        start = idot4(m, starts);
        position = 2 * (relativePosition - offset);
    }

    end = start + int(baseVoxel(vec2(position)).r * 255.0);
    pos1 = position;
    starts.x = start;
    ends.x = end;
    pos2 = position + ivec2(1, 0);
    starts.y = ends.x;
    ends.y = ends.x + int(baseVoxel(vec2(pos2)).r * 255.0);
    pos3 = position + ivec2(0, 1);
    starts.z = ends.y;
    ends.z = ends.y + int(baseVoxel(vec2(pos3)).r * 255.0);
    pos4 = position + ivec2(1, 1);
    starts.w = ends.z;
    mask = ivec3(greaterThanEqual(vI3, starts.rgb)) * ivec3(lessThan(vI3, ends.rgb));
    m = ivec4(mask, 1 - int(any(bvec3(mask))));
    position = m.x * pos1 + m.y * pos2 + m.z * pos3 + m.w * pos4;

    vec2 coord2d = (vec2(position) / uSize) / uScale;
    vec3 coord3d = floor(index3dFrom2d(coord2d) + 0.5);

    float edgeIndex = floor(baseVoxel(vec2(position)).a * 255.0 + 0.5);

    // current vertex for the up to 15 MC cases
    int currentVertex = vI - idot4(m, starts);

    // ensure winding-order is the same for negative and positive iso-levels
    if (uInvert) {
        int v = imod(currentVertex + 1, 3);
        if (v == 1) currentVertex += 2;
        else if (v == 0) currentVertex -= 2;
    }

    // get index into triIndices table
    int mcIndex = 16 * int(edgeIndex) + currentVertex;
    vec4 mcData = texture2D(tTriIndices, vec2(imod(mcIndex, 64), mcIndex / 64) / 64.);

    // bit mask to avoid conditionals (see comment below) for getting MC case corner
    vec4 m0 = vec4(floor(mcData.a * 255.0 + 0.5));

    // get edge value masks
    vec4 m1 = vec4(equal(m0, vec4(0., 1., 2., 3.)));
    vec4 m2 = vec4(equal(m0, vec4(4., 5., 6., 7.)));
    vec4 m3 = vec4(equal(m0, vec4(8., 9., 10., 11.)));

    // apply bit masks
    vec3 b0 = coord3d +
                m1.y * c1 +
                m1.z * c2 +
                m1.w * c3 +
                m2.x * c4 +
                m2.y * c5 +
                m2.z * c6 +
                m2.w * c7 +
                m3.y * c1 +
                m3.z * c2 +
                m3.w * c3;
    vec3 b1 = coord3d +
                m1.x * c1 +
                m1.y * c2 +
                m1.z * c3 +
                m2.x * c5 +
                m2.y * c6 +
                m2.z * c7 +
                m2.w * c4 +
                m3.x * c4 +
                m3.y * c5 +
                m3.z * c6 +
                m3.w * c7;

    // the conditionals that are avoided by above bitmasks
    // vec3 b0 = coord3d;
    // vec3 b1 = coord3d;
    // if (mcIndex == 0.0) {
    //     b1 += c1;
    // } else if (mcIndex == 1.0) {
    //     b0 += c1; b1 += c2;
    // } else if (mcIndex == 2.0) {
    //     b0 += c2; b1 += c3;
    // } else if (mcIndex == 3.0) {
    //     b0 += c3;
    // } else if (mcIndex == 4.0) {
    //     b0 += c4; b1 += c5;
    // } else if (mcIndex == 5.0) {
    //     b0 += c5; b1 += c6;
    // } else if (mcIndex == 6.0) {
    //     b0 += c6; b1 += c7;
    // } else if (mcIndex == 7.0) {
    //     b0 += c7; b1 += c4;
    // } else if (mcIndex == 8.0) {
    //     b1 += c4;
    // } else if (mcIndex == 9.0) {
    //     b0 += c1; b1 += c5;
    // } else if (mcIndex == 10.0) {
    //     b0 += c2; b1 += c6;
    // } else if (mcIndex == 11.0) {
    //     b0 += c3; b1 += c7;
    // }
    // b0 = floor(b0 + 0.5);
    // b1 = floor(b1 + 0.5);

    vec4 d0 = voxel(b0);
    vec4 d1 = voxel(b1);

    float v0 = d0.a;
    float v1 = d1.a;

    float t = (uIsoValue - v0) / (v0 - v1);
    gl_FragData[0].xyz = (uGridTransform * vec4(b0 + t * (b0 - b1), 1.0)).xyz;

    // group id
    #if __VERSION__ == 100
        // webgl1 does not support 'flat' interpolation (i.e. no interpolation)
        // so we ensure a constant group id per triangle here
        #ifdef dPackedGroup
            gl_FragData[1] = vec4(voxel(coord3d).rgb, 1.0);
        #else
            gl_FragData[1] = getGroup(coord3d);
        #endif
    #else
        #ifdef dPackedGroup
            gl_FragData[1] = vec4(t < 0.5 ? d0.rgb : d1.rgb, 1.0);
        #else
            gl_FragData[1] = getGroup(t < 0.5 ? b0 : b1);
        #endif
    #endif

    // normals from gradients
    vec3 n0 = -normalize(vec3(
        voxelPadded(b0 - c1).a - voxelPadded(b0 + c1).a,
        voxelPadded(b0 - c3).a - voxelPadded(b0 + c3).a,
        voxelPadded(b0 - c4).a - voxelPadded(b0 + c4).a
    ));
    vec3 n1 = -normalize(vec3(
        voxelPadded(b1 - c1).a - voxelPadded(b1 + c1).a,
        voxelPadded(b1 - c3).a - voxelPadded(b1 + c3).a,
        voxelPadded(b1 - c4).a - voxelPadded(b1 + c4).a
    ));
    gl_FragData[2].xyz = -vec3(
        n0.x + t * (n0.x - n1.x),
        n0.y + t * (n0.y - n1.y),
        n0.z + t * (n0.z - n1.z)
    );

    // ensure normal-direction is the same for negative and positive iso-levels
    if (uInvert) {
        gl_FragData[2].xyz *= -1.0;
    }

    // apply normal matrix
    gl_FragData[2].xyz *= transpose3(inverse3(mat3(uGridTransform)));
}
`, zne = `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tTriCount;
uniform sampler2D tVolumeData;

uniform float uIsoValue;
uniform vec3 uGridDim;
uniform vec3 uGridTexDim;
uniform vec2 uScale;

#include common

// cube corners (excluding origin)
const vec3 c1 = vec3(1., 0., 0.);
const vec3 c2 = vec3(1., 1., 0.);
const vec3 c3 = vec3(0., 1., 0.);
const vec3 c4 = vec3(0., 0., 1.);
const vec3 c5 = vec3(1., 0., 1.);
const vec3 c6 = vec3(1., 1., 1.);
const vec3 c7 = vec3(0., 1., 1.);

vec3 index3dFrom2d(vec2 coord) {
    vec2 gridTexPos = coord * uGridTexDim.xy;
    vec2 columnRow = ivec2Div(gridTexPos, uGridDim.xy);
    vec2 posXY = gridTexPos - columnRow * uGridDim.xy;
    float posZ = columnRow.y * intDiv(uGridTexDim.x, uGridDim.x) + columnRow.x;
    return vec3(posXY, posZ);
}

vec4 texture3dFrom2dNearest(sampler2D tex, vec3 pos, vec3 gridDim, vec2 texDim) {
    float zSlice = floor(pos.z * gridDim.z + 0.5); // round to nearest z-slice
    float column = intDiv(intMod(zSlice * gridDim.x, texDim.x), gridDim.x);
    float row = intDiv(zSlice * gridDim.x, texDim.x);
    vec2 coord = (vec2(column * gridDim.x, row * gridDim.y) + (pos.xy * gridDim.xy)) / (texDim / uScale);
    return texture2D(tex, coord);
}

vec4 voxel(vec3 pos) {
    pos = min(max(vec3(0.0), pos), uGridDim - vec3(1.0));
    return texture3dFrom2dNearest(tVolumeData, pos / uGridDim, uGridDim, uGridTexDim.xy);
}

void main(void) {
    vec2 uv = gl_FragCoord.xy / uGridTexDim.xy;
    vec3 posXYZ = index3dFrom2d(uv);

    // get MC case as the sum of corners that are below the given iso level
    float c = step(voxel(posXYZ).a, uIsoValue)
        + 2. * step(voxel(posXYZ + c1).a, uIsoValue)
        + 4. * step(voxel(posXYZ + c2).a, uIsoValue)
        + 8. * step(voxel(posXYZ + c3).a, uIsoValue)
        + 16. * step(voxel(posXYZ + c4).a, uIsoValue)
        + 32. * step(voxel(posXYZ + c5).a, uIsoValue)
        + 64. * step(voxel(posXYZ + c6).a, uIsoValue)
        + 128. * step(voxel(posXYZ + c7).a, uIsoValue);
    c *= step(c, 254.);

    // handle out of bounds positions
    posXYZ += 1.0;
    posXYZ.xy += 1.0; // pixel padding (usually ok even if the texture has no padding)
    if (posXYZ.x >= uGridDim.x || posXYZ.y >= uGridDim.y || posXYZ.z >= uGridDim.z)
        c = 0.0;

    // get total triangles to generate for calculated MC case from triCount texture
    float totalTrianglesToGenerate = texture2D(tTriCount, vec2(intMod(c, 16.), floor(c / 16.)) / 16.).a;
    gl_FragColor = vec4(vec3(totalTrianglesToGenerate * 3.0), c / 255.0);
}
`, Gne = R(R({}, qi), { tTriCount: zt("image-uint8", "alpha", "ubyte", "nearest"), tVolumeData: zt("texture", "rgba", "ubyte", "nearest"), uIsoValue: Ie("f"), uGridDim: Ie("v3"), uGridTexDim: Ie("v3"), uScale: Ie("v2") }), ju = "active-voxels";
function Vne(e, t, r, n, i, a) {
  if (e.namedComputeRenderables[ju]) {
    var o = e.namedComputeRenderables[ju].values;
    k.update(o.uQuadScale, a), k.update(o.tVolumeData, t), k.updateIfChanged(o.uIsoValue, i), k.update(o.uGridDim, r), k.update(o.uGridTexDim, n), k.update(o.uScale, a), e.namedComputeRenderables[ju].update();
  } else e.namedComputeRenderables[ju] = function(u, s, c, l, d, f) {
    var m = R(R({}, Ui), { tTriCount: k.create(One()), uQuadScale: k.create(f), tVolumeData: k.create(s), uIsoValue: k.create(d), uGridDim: k.create(c), uGridTexDim: k.create(l), uScale: k.create(f) }), v = R({}, Gne), p = Sn("active-voxels", Fa, zne), g = Bi(u, "triangles", p, v, m);
    return Fi(g, m);
  }(e, t, r, n, i, a);
  return e.namedComputeRenderables[ju];
}
var Une = R(R({}, qi), { tTriIndices: zt("image-uint8", "alpha", "ubyte", "nearest"), tActiveVoxelsPyramid: zt("texture", "rgba", "float", "nearest"), tActiveVoxelsBase: zt("texture", "rgba", "float", "nearest"), tVolumeData: zt("texture", "rgba", "ubyte", "nearest"), uIsoValue: Ie("f"), uSize: Ie("f"), uLevels: Ie("f"), uCount: Ie("f"), uInvert: Ie("b"), uGridDim: Ie("v3"), uGridTexDim: Ie("v3"), uGridTransform: Ie("m4"), uScale: Ie("v2"), dPackedGroup: kt("boolean"), dAxisOrder: kt("string", ["012", "021", "102", "120", "201", "210"]) }), Rl = "isosurface";
function Hne(e, t, r, n, i, a, o, u, s, c, l, d, f, m) {
  if (e.namedComputeRenderables[Rl]) {
    var v = e.namedComputeRenderables[Rl].values;
    k.update(v.tActiveVoxelsPyramid, t), k.update(v.tActiveVoxelsBase, r), k.update(v.tVolumeData, n), k.updateIfChanged(v.uIsoValue, u), k.updateIfChanged(v.uSize, Math.pow(2, s)), k.updateIfChanged(v.uLevels, s), k.updateIfChanged(v.uCount, l), k.updateIfChanged(v.uInvert, d), k.update(v.uGridDim, i), k.update(v.uGridTexDim, a), k.update(v.uGridTransform, o), k.update(v.uScale, c), k.update(v.dPackedGroup, f), k.updateIfChanged(v.dAxisOrder, m.join("")), e.namedComputeRenderables[Rl].update();
  } else e.namedComputeRenderables[Rl] = function(p, g, h, y, x, A, b, _, S, D, I, M, F, P) {
    var E = R(R({}, Ui), { tTriIndices: k.create(Lne()), tActiveVoxelsPyramid: k.create(g), tActiveVoxelsBase: k.create(h), tVolumeData: k.create(y), uIsoValue: k.create(_), uSize: k.create(Math.pow(2, S)), uLevels: k.create(S), uCount: k.create(I), uInvert: k.create(M), uGridDim: k.create(x), uGridTexDim: k.create(A), uGridTransform: k.create(b), uScale: k.create(D), dPackedGroup: k.create(F), dAxisOrder: k.create(P.join("")) }), B = R({}, Une), N = Sn("isosurface", Fa, kne, { drawBuffers: "required" }), O = Bi(p, "triangles", N, B, E);
    return Fi(O, E);
  }(e, t, r, n, i, a, o, u, s, c, l, d, f, m);
  return e.namedComputeRenderables[Rl];
}
function qne(e, t, r, n, i, a, o, u, s, c, l, d, f) {
  var m = function(p, g, h, y, x, A) {
    var b = p.gl, _ = p.resources, S = g.getWidth(), D = g.getHeight();
    p.namedFramebuffers[ju] || (p.namedFramebuffers[ju] = _.framebuffer());
    var I = p.namedFramebuffers[ju];
    I.bind(), p.namedTextures[ju] || (p.namedTextures[ju] = _.texture("image-uint8", "rgba", "ubyte", "nearest"));
    var M = p.namedTextures[ju];
    M.define(S, D);
    var F = Vne(p, g, h, y, x, A);
    return p.state.currentRenderItemId = -1, M.attachFramebuffer(I, 0), function(P) {
      var E = P.gl, B = P.state;
      B.disable(E.CULL_FACE), B.disable(E.BLEND), B.disable(E.DEPTH_TEST), B.enable(E.SCISSOR_TEST), B.depthMask(!1), B.colorMask(!0, !0, !0, !0), B.clearColor(0, 0, 0, 0);
    }(p), b.viewport(0, 0, S, D), b.scissor(0, 0, S, D), b.clear(b.COLOR_BUFFER_BIT), b.scissor(0, 0, y[0], y[1]), F.render(), b.finish(), M;
  }(e, t, r, n, o, i), v = function(p, g, h, y, x, A, b, _, S, D, I, M, F, P) {
    var E = p.extensions.drawBuffers;
    if (!E) throw new Error("need WebGL draw buffers");
    var B = p.gl, N = p.resources, O = p.extensions, z = y.pyramidTex, V = y.height, U = y.levels, H = y.scale, K = y.count, j = z.getWidth();
    p.namedFramebuffers[Rl] || (p.namedFramebuffers[Rl] = N.framebuffer());
    var X = p.namedFramebuffers[Rl];
    ir(B) ? (M || (M = O.colorBufferHalfFloat && O.textureHalfFloat ? N.texture("image-float16", "rgba", "fp16", "nearest") : N.texture("image-float32", "rgba", "float", "nearest")), F || (F = N.texture("image-uint8", "rgba", "ubyte", "nearest")), P || (P = O.colorBufferHalfFloat && O.textureHalfFloat ? N.texture("image-float16", "rgba", "fp16", "nearest") : N.texture("image-float32", "rgba", "float", "nearest"))) : (M || (M = N.texture("image-float32", "rgba", "float", "nearest")), F || (F = N.texture("image-float32", "rgba", "float", "nearest")), P || (P = N.texture("image-float32", "rgba", "float", "nearest"))), M.define(j, V), F.define(j, V), P.define(j, V), M.attachFramebuffer(X, 0), F.attachFramebuffer(X, 1), P.attachFramebuffer(X, 2);
    var W = Hne(p, z, g, h, x, A, b, _, U, H, K, S, D, I);
    return p.state.currentRenderItemId = -1, X.bind(), E.drawBuffers([E.COLOR_ATTACHMENT0, E.COLOR_ATTACHMENT1, E.COLOR_ATTACHMENT2]), function(Q) {
      var te = Q.gl, ee = Q.state;
      ee.disable(te.CULL_FACE), ee.disable(te.BLEND), ee.disable(te.DEPTH_TEST), ee.disable(te.SCISSOR_TEST), ee.depthMask(!1), ee.colorMask(!0, !0, !0, !0), ee.clearColor(0, 0, 0, 0);
    }(p), B.viewport(0, 0, j, V), B.clear(B.COLOR_BUFFER_BIT), W.render(), B.finish(), { vertexTexture: M, groupTexture: F, normalTexture: P, vertexCount: K };
  }(e, m, t, Rne(e, m, i, n), r, n, a, o, u, s, c, l, d, f);
  return v;
}
var NF = { isoValue: ar.IsoValueParam }, Rp = 1;
function N5(e, t) {
  return !(e.grid.cells.data.length < Math.pow(10, 3)) && G2(e.grid.cells.space.dimensions, Rp).powerOfTwoSize <= t.maxTextureSize / 2;
}
function Kne(e, t, r, n) {
  return r.tryUseGpu && n && function(i) {
    return i.extensions.colorBufferFloat && i.extensions.textureFloat && i.extensions.drawBuffers;
  }(n) && N5(t, n) ? function(i) {
    return M6({ defaultProps: G.getDefaultValues(F6), createGeometry: jne, createLocationIterator: function(a) {
      return ri(a.grid.cells.data.length, 1, 1, function() {
        return Ns;
      });
    }, getLoci: T6, eachLocation: P6, setUpdateState: function(a, o, u, s) {
      ar.IsoValue.areSame(u.isoValue, s.isoValue, o.grid.stats) || (a.createGeometry = !0);
    }, geometryUtils: id.Utils, mustRecreate: function(a, o, u) {
      return !o.tryUseGpu || !u || !N5(a, u);
    }, dispose: function(a) {
      a.vertexTexture.ref.value.destroy(), a.groupTexture.ref.value.destroy(), a.normalTexture.ref.value.destroy(), a.doubleBuffer.destroy();
    } }, i);
  }(e) : function(i) {
    return M6({ defaultProps: G.getDefaultValues(F6), createGeometry: Xne, createLocationIterator: function(a) {
      return ri(a.grid.cells.data.length, 1, 1, function() {
        return Ns;
      });
    }, getLoci: T6, eachLocation: P6, setUpdateState: function(a, o, u, s) {
      ar.IsoValue.areSame(u.isoValue, s.isoValue, o.grid.stats) || (a.createGeometry = !0);
    }, geometryUtils: Gt.Utils, mustRecreate: function(a, o, u) {
      return o.tryUseGpu && !!u && N5(a, u);
    } }, i);
  }(e);
}
function GD(e, t) {
  return ar.Isosurface.Loci(e, t.isoValue);
}
function T6(e, t, r, n) {
  var i = e.objectId, a = e.groupId;
  return n === i ? ar.Cell.Loci(t, Ae.ofSingleton(a)) : vn;
}
function P6(e, t, r, n) {
  return function(i, a, o, u) {
    var s = !1;
    if (ar.isLoci(i)) {
      if (!ar.areEquivalent(i.volume, a)) return !1;
      u(Ae.ofLength(a.grid.cells.data.length)) && (s = !0);
    } else if (ar.Isosurface.isLoci(i)) {
      if (!ar.areEquivalent(i.volume, a)) return !1;
      if (o) {
        if (!ar.IsoValue.areSame(i.isoValue, o, a.grid.stats)) return !1;
        u(Ae.ofLength(a.grid.cells.data.length)) && (s = !0);
      } else for (var c = a.grid, l = c.stats, d = c.cells.data, f = l.sigma, m = ar.IsoValue.toAbsolute(i.isoValue, l).absoluteValue, v = 0, p = d.length; v < p; ++v) Ln(m, d[v], f) && u(Ae.ofSingleton(v)) && (s = !0);
    } else if (ar.Cell.isLoci(i)) {
      if (!ar.areEquivalent(i.volume, a)) return !1;
      Ae.is(i.indices) ? u(i.indices) && (s = !0) : Le.forEach(i.indices, function(g) {
        u(Ae.ofSingleton(g)) && (s = !0);
      });
    }
    return s;
  }(e, t, r.isoValue, n);
}
function Xne(e, t, r, n, i) {
  return _e(this, 0, void 0, function() {
    var a, o, u;
    return ye(this, function(s) {
      switch (s.label) {
        case 0:
          return e.runtime.update({ message: "Marching cubes..." }), a = Fs(new Int32Array(t.grid.cells.data.length)), [4, SF({ isoLevel: ar.IsoValue.toAbsolute(n.isoValue, t.grid.stats).absoluteValue, scalarField: t.grid.cells, idField: zn.create(t.grid.cells.space, zn.Data1(a)) }, i).runAsChild(e.runtime)];
        case 1:
          return o = s.sent(), u = mo.getGridToCartesianTransform(t.grid), Gt.transform(o, u), e.webgl && !e.webgl.isWebGL2 && Gt.uniformTriangleGroup(o, !1), o.setBoundingSphere(ar.getBoundingSphere(t)), [2, o];
      }
    });
  });
}
var B6, F6 = R(R(R(R({}, Gt.Params), id.Params), NF), { quality: R(R({}, Gt.Params.quality), { isEssential: !1 }), tryUseGpu: G.Boolean(!0) });
function jne(e, t, r, n, i) {
  return _e(this, 0, void 0, function() {
    var a, o, u, s, c, l, d, f, m, v, p, g, h, y, x;
    return ye(this, function(A) {
      if (!e.webgl) throw new Error("webgl context required to create volume isosurface texture-mesh");
      return t.grid.cells.data.length <= 1 ? [2, id.createEmpty(i)] : (a = t.grid.stats, o = a.max, u = a.min, s = o - u, c = ar.IsoValue.toAbsolute(n.isoValue, t.grid.stats).absoluteValue, l = (c - u) / s, d = B6.get(t, e.webgl), f = d.texture, m = d.gridDimension, v = d.gridTexDim, p = d.gridTexScale, g = d.transform, h = t.grid.cells.space.axisOrderSlowToFast, y = i == null ? void 0 : i.doubleBuffer.get(), x = qne(e.webgl, f, m, v, p, g, l, c < 0, !1, h, y == null ? void 0 : y.vertex, y == null ? void 0 : y.group, y == null ? void 0 : y.normal), [2, id.create(x.vertexCount, 1, x.vertexTexture, x.groupTexture, x.normalTexture, ar.getBoundingSphere(t), i)]);
    });
  });
}
function Yne(e, t, r, n, i) {
  return _e(this, 0, void 0, function() {
    var a, o, u;
    return ye(this, function(s) {
      switch (s.label) {
        case 0:
          return e.runtime.update({ message: "Marching cubes..." }), a = Fs(new Int32Array(t.grid.cells.data.length)), [4, CF({ isoLevel: ar.IsoValue.toAbsolute(n.isoValue, t.grid.stats).absoluteValue, scalarField: t.grid.cells, idField: zn.create(t.grid.cells.space, zn.Data1(a)) }, i).runAsChild(e.runtime)];
        case 1:
          return o = s.sent(), u = mo.getGridToCartesianTransform(t.grid), Mr.transform(o, u), o.setBoundingSphere(ar.getBoundingSphere(t)), [2, o];
      }
    });
  });
}
(function(e) {
  var t = "volume-isosurface-texture";
  e.descriptor = rs({ name: t }), e.get = function(r, n) {
    var i = n.resources, a = mo.getGridToCartesianTransform(r.grid), o = w.clone(r.grid.cells.space.dimensions), u = G2(o, Rp), s = u.width, c = u.height, l = u.powerOfTwoSize, d = w.create(s, c, 0), f = ke.create(s / l, c / l);
    if (l > n.maxTextureSize / 2) throw new Error("volume too large for gpu isosurface extraction");
    if (!r._propertyData[t]) {
      r._propertyData[t] = i.texture("image-uint8", "alpha", "ubyte", "linear");
      var m = r._propertyData[t];
      m.define(l, l), m.load(function(v, p, g) {
        var h = v.grid, y = h.cells, x = y.space, A = y.data, b = h.stats, _ = b.max, S = b.min, D = x.dimensions, I = x.dataOffset, M = G2(D, g), F = M.width, P = M.height, E = new Uint8Array(F * P * 1), B = { array: E, width: F, height: P }, N = _ - S, O = D[0], z = D[1], V = D[2], U = O + g, H = z + g;
        w(), w();
        for (var K = 0; K < V; ++K) for (var j = 0; j < z; ++j) for (var X = 0; X < O; ++X) {
          var W = Math.floor(K * U % F / U), Q = 1 * (Math.floor(K * U / F) * H * F + j * F + (W * U + X)), te = I(X, j, K);
          E[Q] = Math.round((A[te] - S) / N * 255);
        }
        return B;
      }(r, 0, Rp), !0), r.customProperties.add(e.descriptor), r.customProperties.assets(e.descriptor, [{ dispose: function() {
        return m.destroy();
      } }]);
    }
    return o[0] += Rp, o[1] += Rp, { texture: r._propertyData[t], transform: a, gridDimension: o, gridTexDim: d, gridTexScale: f };
  };
})(B6 || (B6 = {}));
var RF = R(R(R({}, Mr.Params), NF), { quality: R(R({}, Mr.Params.quality), { isEssential: !1 }), sizeFactor: G.Numeric(3, { min: 0, max: 10, step: 0.1 }) });
function Wne(e) {
  return M6({ defaultProps: G.getDefaultValues(RF), createGeometry: Yne, createLocationIterator: function(t) {
    return ri(t.grid.cells.data.length, 1, 1, function() {
      return Ns;
    });
  }, getLoci: T6, eachLocation: P6, setUpdateState: function(t, r, n, i) {
    ar.IsoValue.areSame(n.isoValue, i.isoValue, r.grid.stats) || (t.createGeometry = !0);
  }, geometryUtils: Mr.Utils }, e);
}
var Dc, N6, ba, R6, OF = { solid: function(e, t) {
  return kD("Isosurface mesh", e, t, Kne, GD);
}, wireframe: function(e, t) {
  return kD("Isosurface wireframe", e, t, Wne, GD);
} }, LF = R(R(R({}, F6), RF), { visuals: G.MultiSelect(["solid"], G.objectToOptions(OF)), bumpFrequency: G.Numeric(1, { min: 0, max: 10, step: 0.1 }, ft.ShadingCategory), alpha: G.Numeric(0.12, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }) });
function Zne(e, t) {
  return or.createMulti("Isosurface", e, t, or.StateBuilder, OF);
}
function VD(e) {
  return e === ba.Float32 ? 4 : e === ba.Int16 || e === ba.Uint16 ? 2 : 1;
}
function Qne(e, t, r, n) {
  return r === void 0 && (r = 0), e === ba.Float32 ? new Float32Array(t, r, n) : e === ba.Int16 ? new Int16Array(t, r, n) : e === ba.Uint16 ? new Uint16Array(t, r, n) : new Int8Array(t, r, n);
}
function Jne(e, t, r, n, i, a) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(o) {
      switch (o.label) {
        case 0:
          return [4, t.readBuffer(r, e.readBuffer, n, i)];
        case 1:
          return o.sent(), e.elementByteSize > 1 && (a !== void 0 && a !== Dc.IsNativeEndianLittle || !Dc.IsNativeEndianLittle) && Dc.flipByteOrder(e.readBuffer, e.valuesBuffer, n, e.elementByteSize, i), [2, e.values];
      }
    });
  });
}
function $ne(e) {
  return _e(this, 0, void 0, function() {
    var t, r, n, i, a, o;
    return ye(this, function(u) {
      switch (u.label) {
        case 0:
          return [4, e.readBuffer(0, 1024)];
        case 1:
          if (t = u.sent().buffer, (r = String.fromCharCode(t.readUInt8(208), t.readUInt8(209), t.readUInt8(210), t.readUInt8(211))) !== "MAP ") throw new Error('ccp4 format error, missing "MAP " string');
          return n = [t.readUInt8(212), t.readUInt8(213)], i = !1, n[0] === 68 && n[1] === 65 ? i = !0 : n[0] === 17 && n[1] === 17 ? i = !1 : t.readInt32LE(12) <= 16 && (i = !0), a = i ? function(s) {
            return t.readInt32LE(4 * s);
          } : function(s) {
            return t.readInt32BE(4 * s);
          }, o = i ? function(s) {
            return t.readFloatLE(4 * s);
          } : function(s) {
            return t.readFloatBE(4 * s);
          }, [2, { header: { NC: a(0), NR: a(1), NS: a(2), MODE: a(3), NCSTART: a(4), NRSTART: a(5), NSSTART: a(6), NX: a(7), NY: a(8), NZ: a(9), xLength: o(10), yLength: o(11), zLength: o(12), alpha: o(13), beta: o(14), gamma: o(15), MAPC: a(16), MAPR: a(17), MAPS: a(18), AMIN: o(19), AMAX: o(20), AMEAN: o(21), ISPG: a(22), NSYMBT: a(23), LSKFLG: a(24), SKWMAT: [], SKWTRN: [], userFlag1: a(39), userFlag2: a(40), originX: o(49), originY: o(50), originZ: o(51), MAP: r, MACHST: n, ARMS: o(54) }, littleEndian: i }];
      }
    });
  });
}
function kF(e) {
  switch (e) {
    case 0:
      return ba.Int8;
    case 1:
      return ba.Int16;
    case 2:
      return ba.Float32;
    case 3:
      throw new Error("mode 3 unsupported, complex 16-bit integers");
    case 4:
      throw new Error("mode 4 unsupported, complex 32-bit reals");
    case 6:
      ba.Uint16;
    case 16:
      throw new Error("mode 16 unsupported, unsigned char * 3 (for rgb data, non-standard)");
  }
  throw new Error("unknown mode '".concat(e, "'"));
}
function zF(e) {
  return e.userFlag1 === -128 && e.userFlag2 === 127;
}
function GF(e) {
  return zF(e) ? ba.Float32 : kF(e.MODE);
}
function eie(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o, u, s, c, l, d, f;
    return ye(this, function(m) {
      switch (m.label) {
        case 0:
          return [4, r.update({ message: "Parsing CCP4/MRC/MAP file..." })];
        case 1:
          return m.sent(), [4, $ne(e)];
        case 2:
          return n = m.sent(), i = n.header, a = n.littleEndian, o = function(v) {
            return 1024 + v.NSYMBT;
          }(i), u = kF(i.MODE), s = GF(i), c = i.NC * i.NR * i.NS, l = VD(u), d = c * l, f = function(v, p) {
            var g = VD(p), h = new ArrayBuffer(g * v), y = Dc.fromArrayBuffer(h), x = Dc.IsNativeEndianLittle ? h : new ArrayBuffer(g * v);
            return { type: p, elementByteSize: g, readBuffer: y, valuesBuffer: new Uint8Array(x), values: Qne(p, x) };
          }(c, s), function(v, p, g, h, y, x) {
            _e(this, 0, void 0, function() {
              var A, b, _, S, D, I;
              return ye(this, function(M) {
                switch (M.label) {
                  case 0:
                    return zF(v) ? (A = 3 * y, [4, g.readBuffer(h, p.readBuffer, y, A)]) : [3, 2];
                  case 1:
                    for (M.sent(), b = new Int8Array(p.valuesBuffer.buffer, A), _ = (v.AMAX - v.AMIN) / 255, S = 0.5 * (v.AMIN + v.AMAX + _), D = 0, I = y; D < I; ++D) p.values[D] = _ * b[D] + S;
                    return [3, 4];
                  case 2:
                    return [4, Jne(p, g, h, y, 0, x)];
                  case 3:
                    M.sent(), M.label = 4;
                  case 4:
                    return [2];
                }
              });
            });
          }(i, f, e, o, d, a), [2, { header: i, values: f.values, name: e.name }];
      }
    });
  });
}
function tie(e, t) {
  return function(r, n) {
    var i = this;
    return er.create("Parse CCP4/MRC/MAP", function(a) {
      return _e(i, 0, void 0, function() {
        var o, u, s;
        return ye(this, function(c) {
          switch (c.label) {
            case 0:
              return c.trys.push([0, 2, , 3]), u = (o = Pi).success, [4, eie(r, 0, a)];
            case 1:
              return [2, u.apply(o, [c.sent()])];
            case 2:
              return s = c.sent(), [2, Pi.error(s)];
            case 3:
              return [2];
          }
        });
      });
    });
  }(N6.fromBuffer(Dc.fromUint8Array(e), t), e.length);
}
function rie(e, t) {
  var r = this;
  return er.create("Create Volume", function(n) {
    return _e(r, 0, void 0, function() {
      var i, a, o, u, s, c, l, d, f, m, v, p, g, h, y, x, A;
      return ye(this, function(b) {
        return i = e.header, a = e.values, o = w.create(i.xLength, i.yLength, i.zLength), u = w.create(Bn(i.alpha), Bn(i.beta), Bn(i.gamma)), s = i.ISPG > 65536 ? 0 : i.ISPG, c = Tu.create(s || "P 1", o, u), l = w.create(i.MAPC - 1, i.MAPR - 1, i.MAPS - 1), d = zn.convertToCanonicalAxisIndicesFastToSlow(l), f = [i.NX, i.NY, i.NZ], m = d([i.NC, i.NR, i.NS]), v = function(_) {
          return _.originX === 0 && _.originY === 0 && _.originZ === 0 ? w.create(_.NCSTART, _.NRSTART, _.NSSTART) : w.create(_.originX / (_.xLength / _.NX), _.originY / (_.yLength / _.NY), _.originZ / (_.zLength / _.NZ));
        }(i), p = d(v), g = w.create(p[0] / f[0], p[1] / f[1], p[2] / f[2]), h = w.create(m[0] / f[0], m[1] / f[1], m[2] / f[2]), y = zn.Space(m, zn.invertAxisOrder(l), function(_) {
          var S = GF(_);
          switch (S) {
            case ba.Float32:
              return Float32Array;
            case ba.Int8:
              return Int8Array;
            case ba.Int16:
              return Int16Array;
            case ba.Uint16:
              return Uint16Array;
          }
          throw Error("".concat(S, " is not a supported value format."));
        }(i)), x = zn.create(y, zn.Data1(a)), A = i.AMIN === 0 && i.AMAX === 0 && i.AMEAN === 0 && i.ARMS === 0, [2, { label: void 0, entryId: void 0, grid: { transform: { kind: "spacegroup", cell: c, fractionalBox: qr.create(g, w.add(w.zero(), g, h)) }, cells: x, stats: { min: isNaN(i.AMIN) || A ? $H(a) : i.AMIN, max: isNaN(i.AMAX) || A ? y2(a) : i.AMAX, mean: isNaN(i.AMEAN) || A ? eq(a) : i.AMEAN, sigma: isNaN(i.ARMS) || i.ARMS === 0 ? tq(a) : i.ARMS } }, sourceData: R6.create(e), customProperties: new v0(), _propertyData: /* @__PURE__ */ Object.create(null) }];
      });
    });
  });
}
G.getDefaultValues(LF), function(e) {
  function t(n) {
    var i = new DataView(n.buffer);
    return Object.assign(n.subarray(0), { readInt8: function(a) {
      return i.getInt8(a);
    }, readUInt8: function(a) {
      return i.getUint8(a);
    }, writeInt8: function(a, o) {
      return i.setInt8(o, a);
    }, writeUInt8: function(a, o) {
      return i.setUint8(o, a);
    }, readInt16LE: function(a) {
      return i.getInt16(a, !0);
    }, readInt32LE: function(a) {
      return i.getInt32(a, !0);
    }, readUInt16LE: function(a) {
      return i.getUint16(a, !0);
    }, readUInt32LE: function(a) {
      return i.getUint32(a, !0);
    }, readFloatLE: function(a) {
      return i.getFloat32(a, !0);
    }, readDoubleLE: function(a) {
      return i.getFloat64(a, !0);
    }, writeInt16LE: function(a, o) {
      return i.setInt16(o, a, !0);
    }, writeInt32LE: function(a, o) {
      return i.setInt32(o, a, !0);
    }, writeUInt16LE: function(a, o) {
      return i.setUint16(o, a, !0);
    }, writeUInt32LE: function(a, o) {
      return i.setUint32(o, a, !0);
    }, writeFloatLE: function(a, o) {
      return i.setFloat32(o, a, !0);
    }, writeDoubleLE: function(a, o) {
      return i.setFloat64(o, a, !0);
    }, readInt16BE: function(a) {
      return i.getInt16(a, !1);
    }, readInt32BE: function(a) {
      return i.getInt32(a, !1);
    }, readUInt16BE: function(a) {
      return i.getUint16(a, !1);
    }, readUInt32BE: function(a) {
      return i.getUint32(a, !1);
    }, readFloatBE: function(a) {
      return i.getFloat32(a, !1);
    }, readDoubleBE: function(a) {
      return i.getFloat64(a, !1);
    }, writeInt16BE: function(a, o) {
      return i.setInt16(o, a, !1);
    }, writeInt32BE: function(a, o) {
      return i.setInt32(o, a, !1);
    }, writeUInt16BE: function(a, o) {
      return i.setUint16(o, a, !1);
    }, writeUInt32BE: function(a, o) {
      return i.setUint32(o, a, !1);
    }, writeFloatBE: function(a, o) {
      return i.setFloat32(o, a, !1);
    }, writeDoubleBE: function(a, o) {
      return i.setFloat64(o, a, !1);
    }, copy: function(a, o, u, s) {
      return o = Ci(o, 0), u = Ci(u, 0), s = Ci(s, n.length), a.set(n.subarray(u, s), o), s - u;
    } });
  }
  function r(n, i, a, o, u) {
    for (var s = 0, c = a; s < c; s += o) for (var l = 0; l < o; l++) i[u + s + o - l - 1] = n[u + s + l];
  }
  e.fromUint8Array = t, e.fromArrayBuffer = function(n) {
    return t(new Uint8Array(n));
  }, e.fromBuffer = function(n) {
    return t(new Uint8Array(n));
  }, e.IsNativeEndianLittle = new Uint16Array(new Uint8Array([18, 52]).buffer)[0] === 13330, e.flipByteOrder = r, e.flipByteOrderInPlace2 = function(n, i, a) {
    i === void 0 && (i = 0);
    for (var o = new Int16Array(n, i, a), u = 0, s = o.length; u < s; ++u) {
      var c = o[u];
      o[u] = (255 & c) << 8 | c >> 8 & 255;
    }
  }, e.ensureLittleEndian = function(n, i, a, o, u) {
    e.IsNativeEndianLittle || !a || o <= 1 || r(n, i, a, o, u);
  };
}(Dc || (Dc = {})), function(e) {
  e.fromBuffer = function(t, r) {
    return { name: r, readBuffer: function(n, i, a, o) {
      var u, s;
      if (typeof i == "number") {
        a = Ci(a, i);
        var c = n;
        u = (l = Math.min(t.length, c + a)) - c, s = Dc.fromUint8Array(new Uint8Array(t.buffer, c, l - c));
      } else {
        a = Ci(a, i.length), c = n;
        var l = Math.min(t.length, c + a);
        i.set(t.subarray(c, l), o), u = l - c, s = i;
      }
      return a !== u && console.warn("byteCount ".concat(a, " and bytesRead ").concat(u, " differ")), Promise.resolve({ bytesRead: u, buffer: s });
    }, writeBuffer: function(n, i, a) {
      return a = Ci(a, i.length), console.error(".writeBuffer not implemented for FileHandle.fromBuffer"), Promise.resolve(0);
    }, writeBufferSync: function(n, i, a) {
      return a = Ci(a, i.length), console.error(".writeSync not implemented for FileHandle.fromBuffer"), 0;
    }, close: s_ };
  };
}(N6 || (N6 = {})), function(e) {
  e.Float32 = "float32", e.Int8 = "int8", e.Int16 = "int16", e.Uint16 = "uint16";
}(ba || (ba = {})), function(e) {
  e.is = function(t) {
    return (t == null ? void 0 : t.kind) === "ccp4";
  }, e.create = function(t) {
    return { kind: "ccp4", name: t.name, data: t };
  };
}(R6 || (R6 = {}));
var nie = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    var t;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, tie(e, "Hermite").run()];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, rie(t.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, iie = { createTheme: function(e, t, r) {
  var n, i;
  if (r != null && r.color) return { color: (n = t.managers.representation.ctx) === null || n === void 0 ? void 0 : n.colorThemeRegistry.create(r.color.name, { volume: e }, r.color.props), size: (i = t.managers.representation.ctx) === null || i === void 0 ? void 0 : i.colorThemeRegistry.create("uniform", {}, {}) };
}, parse: function(e, t) {
  return _e(this, 0, void 0, function() {
    var r;
    return ye(this, function(n) {
      switch (n.label) {
        case 0:
          return [4, e.arrayBuffer()];
        case 1:
          return r = n.sent(), [4, nie.parse(new Uint8Array(r))];
        case 2:
          return [2, n.sent()];
      }
    });
  });
}, create: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return i = Zne(t, function() {
            return LF;
          }), r && i.setTheme(r), [4, i.createOrUpdate(n ?? {}, e).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, r, n, i) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, e.createOrUpdate(i ?? {}, t).run()];
        case 1:
          return a.sent(), n && e.setTheme(n), [2];
      }
    });
  });
} }, aie = { unitLabel: G.Text("Å", { isEssential: !0 }) }, oie = R(R(R({}, Mr.Params), aie), { lineSizeAttenuation: G.Boolean(!1), linesColor: G.Color(He(14080239), { isEssential: !0 }), linesSize: G.Numeric(0.8), alpha: G.Numeric(0.6, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }) }), VF = { lines: function(e, t) {
  return An(cie, Mr.Utils, { modifyState: function(r) {
    return R(R({}, r), { markerActions: Pr.Highlighting });
  } });
} }, uie = R(R({}, oie), { visuals: G.MultiSelect(["lines"], G.objectToOptions(VF)) });
function sie(e, t) {
  var r = t.sphereA, n = t.sphereB, i = t.center, a = e.loci, o = a[0], u = a[1];
  return Hr.getBoundingSphere(o, r), Hr.getBoundingSphere(u, n), w.add(i, r.center, n.center), w.scale(i, i, 0.5), t.distance = w.distance(r.center, n.center), t;
}
var Vd = { sphereA: Me(), sphereB: Me(), center: w(), distance: 0 };
function cie(e, t, r, n) {
  var i = function(o, u, s) {
    for (var c = aa.create(128, 64, s), l = 0, d = o.pairs.length; l < d; ++l) sie(o.pairs[l], Vd), c.add(Vd.sphereA.center[0], Vd.sphereA.center[1], Vd.sphereA.center[2], Vd.sphereB.center[0], Vd.sphereB.center[1], Vd.sphereB.center[2], l);
    return c.getLines();
  }(t, 0, n && n.geometry), a = function(o, u) {
    return o.pairs.length === 1 ? "interactionLine ".concat(ym(o.pairs[0], { unitLabel: u, measureOnly: !0 })) : "".concat(o.pairs.length, " interactionLines");
  }(t, r.unitLabel);
  return $t.create(a, t, i, function() {
    return r.linesColor;
  }, function() {
    return r.linesSize;
  }, function(o) {
    return ym(t.pairs[o], r);
  });
}
var lie = { parse: function(e, t) {
  return e.map(function(r) {
    var n = t.managers.cell.get(r.ref), i = Zr(n);
    return ei(i, r.elementIds);
  });
}, create: function(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return n = function(a, o) {
            var u = or.createMulti("interactionLine", a, o, or.StateBuilder, VF);
            return u.setState({ pickable: !0, markerActions: Pr.All }), u;
          }(t, function() {
            return uie;
          }), [4, n.createOrUpdate({}, { pairs: [{ loci: e }] }).run()];
        case 1:
          return i.sent(), [2, n];
      }
    });
  });
}, update: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return [4, e.createOrUpdate({}, { pairs: [{ loci: t }] }).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, die = me.fromTranslation(me(), w.create(0.5, 0.5, 0.5)), fie = Bg(Pg(LT()), die), Hu = w(), UD = me(), pie = R(R({}, Gt.Params), { cellColor: G.Color(Kt.black), cellScale: G.Numeric(2, { min: 0.1, max: 5, step: 0.1 }), ref: G.Select("model", G.objectToOptions({ origin: "Origin", model: "Model" }), { isEssential: !0 }), attachment: G.Select("corner", G.objectToOptions({ corner: "Corner", center: "Center" }), { isEssential: !0 }) }), mie = { mesh: function(e, t) {
  return An(vie, Gt.Utils);
} }, hie = R({}, pie);
function vie(e, t, r, n) {
  var i = function(o, u, s) {
    var c = wt.createState(256, 128, s), l = o.symmetry.spacegroup.cell.fromFractional;
    w.copy(Hu, o.ref), u.attachment === "center" ? (w.trunc(Hu, Hu), w.subScalar(Hu, Hu, 0.5)) : w.floor(Hu, Hu), me.fromTranslation(UD, Hu);
    var d = Bg(Pg(fie), UD), f = Math.cbrt(o.symmetry.spacegroup.cell.volume) / 300 * u.cellScale;
    c.currentGroup = 1, wt.addCage(c, l, d, f, 2, 20);
    var m = Me.fromDimensionsAndTransform(Me(), w.unit, l);
    w.transformMat4(Hu, Hu, l), Me.translate(m, m, Hu), Me.expand(m, m, f);
    var v = wt.getMesh(c);
    return v.setBoundingSphere(m), v;
  }(t, r, n && n.geometry), a = E2.getUnitcellLabel(t.symmetry);
  return $t.create(a, t, i, function() {
    return r.cellColor;
  }, function() {
    return 1;
  }, function() {
    return a;
  });
}
var gie = { create: function(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n;
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return n = function(a, o) {
            return or.createMulti("Unit Cell", a, o, or.StateBuilder, mie);
          }(t, function() {
            return hie;
          }), [4, n.createOrUpdate({}, e).run()];
        case 1:
          return i.sent(), [2, n];
      }
    });
  });
}, update: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(i) {
      switch (i.label) {
        case 0:
          return [4, e.createOrUpdate({}, t).run()];
        case 1:
          return i.sent(), [2];
      }
    });
  });
} }, yie = { unitLabel: G.Text("Å", { isEssential: !0 }) }, bie = R(R(R({}, Mr.Params), yie), { lineSizeAttenuation: G.Boolean(!1), linesColor: G.Color(Kt.black), linesSize: G.Numeric(2), alpha: G.Numeric(0.6, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }), isDash: G.Boolean(!1), dashLength: G.Numeric(0.04, { min: 0.01, max: 0.2, step: 0.01 }) }), UF = { lines: function(e, t) {
  return An(xie, Mr.Utils, { modifyState: function(r) {
    return R(R({}, r), { markerActions: Pr.Selecting });
  } });
} }, _ie = R(R({}, bie), { visuals: G.MultiSelect(["lines"], G.objectToOptions(UF)) });
function xie(e, t, r, n) {
  var i = function(o, u, s) {
    for (var c = aa.create(128, 64, s), l = 0, d = o.lines.length; l < d; ++l) u.isDash ? c.addFixedLengthDashes(w.create(o.lines[l][0][0], o.lines[l][0][1], o.lines[l][0][2]), w.create(o.lines[l][1][0], o.lines[l][1][1], o.lines[l][1][2]), u.dashLength, l) : c.add(o.lines[l][0][0], o.lines[l][0][1], o.lines[l][0][2], o.lines[l][1][0], o.lines[l][1][1], o.lines[l][1][2], l);
    return c.getLines();
  }(t, r, n && n.geometry), a = function(o, u) {
    return "".concat(o.lines.length, " interactionLines");
  }(t, r.unitLabel);
  return $t.create(a, t, i, function() {
    return r.linesColor;
  }, function() {
    return r.linesSize;
  }, function() {
    return "CustomLines";
  });
}
var Aie = { create: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, u) {
            var s = or.createMulti("customLines", o, u, or.StateBuilder, UF);
            return s.setState({ pickable: !1, markerActions: Pr.Selecting }), s;
          }(t, function() {
            return _ie;
          }), [4, i.createOrUpdate(n ?? {}, { lines: e }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, r, n, i) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, e.createOrUpdate(i ?? {}, { lines: t }).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} }, Sie = R(R({}, Gt.Params), { color: G.Color(Kt.orange), scaleFactor: G.Numeric(1, { min: 0.1, max: 10, step: 0.1 }) }), HF = { plane: function(e, t) {
  return An(wie, Gt.Utils);
} }, Cie = R(R({}, Sie), { visuals: G.MultiSelect(["plane"], G.objectToOptions(HF)) });
function wie(e, t, r, n) {
  var i = function(a, o, u) {
    var s = wt.createState(256, 128, u);
    return a.planes.forEach(function(c) {
      wt.addTriangle(s, w.create.apply(w, c[0]), w.create.apply(w, c[1]), w.create.apply(w, c[2]));
    }), wt.getMesh(s);
  }(t, 0, n && n.geometry);
  return $t.create("CustomPlanes", t, i, function() {
    return r.color;
  }, function() {
    return 1;
  }, function() {
    return "CustomPlanes";
  });
}
var _1, pp, bs, pa, mp, Die = { create: function(e, t, r, n) {
  return _e(this, 0, void 0, function() {
    var i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return i = function(o, u) {
            var s = or.createMulti("CustomPlanes", o, u, or.StateBuilder, HF);
            return s.setState({ pickable: !1, markerActions: Pr.Selecting }), s;
          }(t, function() {
            return Cie;
          }), [4, i.createOrUpdate(n ?? {}, { planes: e }).run()];
        case 1:
          return a.sent(), [2, i];
      }
    });
  });
}, update: function(e, t, r, n, i) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, e.createOrUpdate(i ?? {}, { planes: t }).run()];
        case 1:
          return a.sent(), [2];
      }
    });
  });
} }, Du = ((_1 = {})[Te.Ribbon] = Fte, _1[Te.BallAndStick] = JB, _1[Te.Line] = Gre, _1[Te.Stick] = Vre, _1[Te.CPK] = une, _1), Op = ((pp = {})[Te.Label] = $te, pp[Te.Distance] = are, pp[Te.Angle] = hre, pp[Te.Dihedral] = Mre, pp), a2 = ((bs = {})[Te.Surface] = Jre, bs[Te.IsoSurface] = iie, bs[Te.RotateArrow] = ane, bs[Te.Pocket] = hne, bs[Te.Pharmacophore] = Ine, bs[Te.MappingLine] = lie, bs[Te.UnitCell] = gie, bs[Te.CustomLines] = Aie, bs[Te.CustomPlanes] = Die, bs);
(function(e) {
  e.LigandReceptor = "ligand-receptor", e.IntraLigand = "intra-ligand", e.IntraReceptor = "intra-receptor", e.All = "all";
})(pa || (pa = {}));
var Iie = function(e, t) {
  var r, n, i, a = ha(e.getLoci());
  if (!a || !(!((i = (n = (r = a == null ? void 0 : a.elements) === null || r === void 0 ? void 0 : r[0]) === null || n === void 0 ? void 0 : n.unit) === null || i === void 0) && i.elements)) return Bl.Not;
  var o = new Set(Gi(a)), u = 0;
  return t.forEach(function(s) {
    o.has(s) && u++;
  }), u ? u === t.length ? Bl.Include : u === o.size ? Bl.BeIncluded : Bl.Cross : Bl.Not;
}, Eie = function(e, t) {
  var r, n;
  if (e.ref !== t.ref) return !1;
  if (!(!((r = e.elementIds) === null || r === void 0) && r.length) || !(!((n = t.elementIds) === null || n === void 0) && n.length)) return !0;
  var i = new Set(t.elementIds);
  return e.elementIds.some(function(a) {
    return i.has(a);
  });
}, ag = function(e, t) {
  var r = ha(e.getLoci());
  if (!r) return [];
  var n = ei(r == null ? void 0 : r.structure, t), i = Xe.intersect(r, n);
  return Gi(i);
}, O6 = function(e, t, r, n, i) {
  var a = yo(e);
  if (a) {
    var o = rB(a, t);
    return Du[r].update(e, o, Dl.managers.representation.ctx, n ? n(o) : e.theme), i && e.setState({ transparency: i(o) }), e;
  }
  console.warn("removeElementIdsInRepresentation");
}, Mie = ((mp = {})[Te.Label] = ["customText", "textColor", "textSize"], mp[Te.Distance] = ["linesColor", "textSize", "textColor"], mp[Te.Angle] = ["color", "textSize", "textColor"], mp[Te.Dihedral] = ["color", "textSize", "textColor"], mp), qF = function(e, t) {
  if (u0.has(e)) {
    var r = {};
    return Mie[e].forEach(function(n) {
      r[n] = t.props[n];
    }), r;
  }
}, HD = function(e, t, r, n) {
  var i = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], a = e[0], o = e[1], u = e[2], s = function(E) {
    var B = w.create(E[0], E[1], E[2]);
    return w.normalize(B, B), [B[0], B[1], B[2]];
  }(function(E, B) {
    return [B[0] - E[0], B[1] - E[1], B[2] - E[2]];
  }(e, t)), c = s[0], l = s[1], d = s[2], f = c * c, m = c * l, v = c * d, p = l * l, g = l * d, h = d * d, y = a * c, x = a * l, A = a * d, b = o * c, _ = o * l, S = o * d, D = u * c, I = u * l, M = u * d, F = Math.cos(r * (Math.PI / 180)), P = Math.sin(r * (Math.PI / 180));
  return i[0][0] = f + (p + h) * F, i[0][1] = m * (1 - F) + d * P, i[0][2] = v * (1 - F) - l * P, i[0][3] = 0, i[1][0] = m * (1 - F) - d * P, i[1][1] = p + (f + h) * F, i[1][2] = g * (1 - F) + c * P, i[1][3] = 0, i[2][0] = v * (1 - F) + l * P, i[2][1] = g * (1 - F) - c * P, i[2][2] = h + (f + p) * F, i[2][3] = 0, i[3][0] = (a * (p + h) - c * (_ + M)) * (1 - F) + (S - I) * P, i[3][1] = (o * (f + h) - l * (y + M)) * (1 - F) + (D - A) * P, i[3][2] = (u * (f + p) - d * (y + _)) * (1 - F) + (x - b) * P, i[3][3] = 1, [n[0] * i[0][0] + n[1] * i[1][0] + n[2] * i[2][0] + i[3][0], n[0] * i[0][1] + n[1] * i[1][1] + n[2] * i[2][1] + i[3][1], n[0] * i[0][2] + n[1] * i[1][2] + n[2] * i[2][2] + i[3][2]];
}, KF = function(e, t, r) {
  var n, i, a, o, u, s;
  if (!e.canvas3d) return w.create(0, 0, 0);
  var c = ke.create(0, 0), l = w.create(0, 0, 0), d = w.create(0, 0, 0);
  if (ke.sub(c, ke.copy(c, r), t), ke.squaredMagnitude(c)) {
    var f = (i = (n = e.canvas3d) === null || n === void 0 ? void 0 : n.input.pixelRatio) !== null && i !== void 0 ? i : 1;
    return c[0] *= 1 / e.canvas3d.camera.zoom * e.canvas3d.camera.viewport.width * f, c[1] *= 1 / e.canvas3d.camera.zoom * e.canvas3d.camera.viewport.height * f * (((o = (a = e.layout) === null || a === void 0 ? void 0 : a.canvas.clientWidth) !== null && o !== void 0 ? o : 1) / ((s = (u = e.layout) === null || u === void 0 ? void 0 : u.canvas.clientHeight) !== null && s !== void 0 ? s : 1)), w.cross(l, w.sub(l, e.canvas3d.camera.position, e.canvas3d.camera.target), e.canvas3d.camera.up), w.setMagnitude(l, l, c[0]), w.setMagnitude(d, e.canvas3d.camera.up, c[1]), w.add(l, l, d), w.scale(l, l, 1 / 2100), l;
  }
  return w.create(0, 0, 0);
}, Tie = function(e, t) {
  var r = Xe.getBoundary(ei(e, t));
  return { center: w.create((r.box.max[0] + r.box.min[0]) / 2, (r.box.max[1] + r.box.min[1]) / 2, (r.box.max[2] + r.box.min[2]) / 2), size: w.create(r.box.max[0] - r.box.min[0], r.box.max[1] - r.box.min[1], r.box.max[2] - r.box.min[2]) };
}, Pie = function(e) {
  var t = Ko(e);
  if (t) {
    var r = ia.Provider.get(t);
    if (r) {
      var n = function(i, a, o) {
        var u = w();
        return o.ref === "model" && w.transformMat4(u, nn.getCenter(i), a.spacegroup.cell.toFractional), { symmetry: a, ref: u };
      }(t, r, {});
      return n;
    }
  }
};
window.requestIdleCallback = window.requestIdleCallback || function(e) {
  var t = Date.now();
  return setTimeout(function() {
    e({ didTimeout: !1, timeRemaining: function() {
      return Math.max(0, 50 - (Date.now() - t));
    } });
  }, 1);
};
var L6, k6, hp = new Nu("98"), qD = function() {
  function e(t) {
    this.boundaryHelper = new Nu("98"), this.plugin = t;
  }
  return e.prototype.focus = function(t) {
    var r;
    return _e(this, 0, void 0, function() {
      var n, i, a, o, u, s, c, l, d, f, m, v, p, g, h, y, x = this;
      return ye(this, function(A) {
        switch (A.label) {
          case 0:
            if (n = !1, i = [], a = [], t ? t.forEach(function(b) {
              var _ = x.plugin.cells.get(b.ref);
              _ && (Array.from(_.representations.keys()).some(function(S) {
                return u0.has(S) || TJ.has(S);
              }) ? a.push(b) : i.push(b));
            }) : (a.push.apply(a, Array.from(this.plugin.managers.selection.shape.selection.values()).map(function(b) {
              return { ref: b };
            })), i.push.apply(i, this.plugin.managers.selection.structure.getSelectionCellItems().length ? this.plugin.managers.selection.structure.getSelectionCellItems() : a.length ? [] : this.plugin.managers.cell.getAllDisplayedCellsRef().map(function(b) {
              return { ref: b };
            }))), !i.length && !a.length) return [2];
            o = w.create(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), u = w.create(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), hp.reset(), s = [], a.forEach(function(b) {
              var _ = x.plugin.cells.get(b.ref);
              if (_) if (_.representations.has(Te.Surface)) i.push(_.model.other);
              else {
                if (_.representations.has(Te.Pharmacophore)) {
                  var S = _.model.other, D = S.center, I = S.normal, M = S.radius;
                  if (!I) return w.min(o, o, w.create(D[0] - M, D[1] - M, D[2] - M)), w.max(u, u, w.create(D[0] + M, D[1] + M, D[2] + M)), void (n = !0);
                  var F = w.create((D[0] + I[0]) / 2, (D[1] + I[1]) / 2, (D[2] + I[2]) / 2), P = (w.distance(I, D) + M) / 2;
                  return w.min(o, o, w.create(F[0] - P, F[1] - P, F[2] - P)), w.max(u, u, w.create(F[0] + P, F[1] + P, F[2] + P)), void (n = !0);
                }
                if (_.representations.has(Te.Pocket)) {
                  var E = _.model.other, B = (D = E.center, E.size), N = [(2 * D[0] + B[0]) / 2, (2 * D[1] + B[1]) / 2, (2 * D[2] + B[2]) / 2], O = [(2 * D[0] - B[0]) / 2, (2 * D[1] - B[1]) / 2, (2 * D[2] - B[2]) / 2], z = { min: w.fromArray(w.zero(), O, 0), max: w.fromArray(w.zero(), N, 0) };
                  return w.min(o, o, z.min), w.max(u, u, z.max), void (n = !0);
                }
                i.push.apply(i, _.dependency.on);
              }
            }), c = 0, l = i, A.label = 1;
          case 1:
            return c < l.length ? (d = l[c], this.plugin.cells.get(d.ref) ? [4, this.plugin.managers.cell.getStructure(d.ref)] : [2]) : [3, 4];
          case 2:
            if (!(f = A.sent())) return [2];
            m = ei(f, d.elementIds), (!Xe.isEmpty(m) || ((r = m == null ? void 0 : m.elements) === null || r === void 0 ? void 0 : r.length) > 0) && s.push(Xe.getBoundary(m)), A.label = 3;
          case 3:
            return c++, [3, 1];
          case 4:
            if (!s.length) return n && this.focusSphere({ center: w.create((u[0] + o[0]) / 2, (u[1] + o[1]) / 2, (u[2] + o[2]) / 2), radius: w.distance(u, o) / 2 }), [2];
            for (g = 0, h = s.length; g < h; ++g) v = s[g], p = v.box, y = v.sphere, w.min(o, o, p.min), w.max(u, u, p.max), hp.includePositionRadius(y.center, y.radius);
            for (hp.finishedIncludeStep(), g = 0, h = s.length; g < h; ++g) y = s[g].sphere, hp.radiusPositionRadius(y.center, y.radius);
            return this.focusSphere(hp.getSphere()), [2];
        }
      });
    });
  }, e.prototype.focusSphere = function(t, r) {
    var n, i, a = R({ minRadius: 5, extraRadius: 4, durationMs: 250 }, r), o = a.extraRadius, u = a.minRadius, s = a.durationMs, c = Math.max(t.radius + o, u), l = (n = this.plugin.canvas3d) === null || n === void 0 ? void 0 : n.camera.getFocus(t.center, c);
    (i = this.plugin.canvas3d) === null || i === void 0 || i.requestCameraReset({ durationMs: s, snapshot: l });
  }, e.prototype.reset = function() {
    var t;
    (t = this.plugin.canvas3d) === null || t === void 0 || t.requestCameraReset({ durationMs: 200 });
  }, e.prototype.zoomIn = function() {
    var t, r, n = (t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.camera.getSnapshot();
    if (n) {
      var i = KD(n, 1);
      w.distance(n.target, i) < 10 || (n.position = i, (r = this.plugin.canvas3d) === null || r === void 0 || r.camera.setState(n, 200));
    }
  }, e.prototype.zoomOut = function() {
    var t, r, n = (t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.camera.getSnapshot();
    if (n) {
      var i = KD(n, -1);
      n.position = i, (r = this.plugin.canvas3d) === null || r === void 0 || r.camera.setState(n, 200);
    }
  }, e.prototype.updateAxes = function(t) {
    var r, n, i, a, o, u, s, c, l = { vecA: w.unitX, vecB: w.unitY, vecC: w.unitZ }, d = this.plugin.cells.get(t);
    if (d) {
      var f = Zr(d);
      if (f && (!((a = (i = (n = (r = Ko(f)) === null || r === void 0 ? void 0 : r.sourceData) === null || n === void 0 ? void 0 : n.data) === null || i === void 0 ? void 0 : i.molecules) === null || a === void 0) && a.length)) {
        var m = (s = (u = (o = Ko(f)) === null || o === void 0 ? void 0 : o.sourceData) === null || u === void 0 ? void 0 : u.data) === null || s === void 0 ? void 0 : s.molecules[0].cell, v = m.vecA, p = m.vecB, g = m.vecC;
        l = { vecA: w.scale(w(), v, 1 / w.distance(w(), v)), vecB: w.scale(w(), p, 1 / w.distance(w(), p)), vecC: w.scale(w(), g, 1 / w.distance(w(), g)) };
      }
    }
    (c = this.plugin.canvas3d) === null || c === void 0 || c.setProps({ camera: { helper: { axes: { name: "on", params: l } } } });
  }, e;
}();
function KD(e, t) {
  var r = w();
  w.sub(r, e.target, e.position), w.normalize(r, r), w.scale(r, r, 5 * t);
  var n = e.position;
  return w.add(n, n, r), n;
}
(function(e) {
  e.create = function(t, r) {
    var n = [], i = [], a = [];
    return { add: function(o, u, s) {
      n[n.length] = o, i[i.length] = u, a[a.length] = s;
    }, getContacts: function() {
      for (var o = new So.EdgeBuilder(t.count, n, i), u = new Int8Array(o.slotCount), s = new Int8Array(o.slotCount), c = 0, l = o.edgeCount; c < l; c++) o.addNextEdge(), o.assignProperty(u, a[c]);
      var d, f = o.createGraph({ type: u, flag: s });
      return Object.defineProperty(f, "elementsIndex", { get: function() {
        return d || (d = a6.createElementsIndex(f, t, r));
      } });
    } };
  };
})(L6 || (L6 = {})), function(e) {
  e.create = function() {
    var t = new df.Builder();
    return { startUnitPair: function(r, n) {
      t.startUnitPair(r.id, n.id);
    }, finishUnitPair: function() {
      t.finishUnitPair();
    }, add: function(r, n, i) {
      t.add(r, n, { type: i, flag: no.None });
    }, getContacts: function(r) {
      return new WQ(t.getMap(), r);
    } };
  };
}(k6 || (k6 = {}));
var Bie = { lineOfSightDistFactor: G.Numeric(1, { min: 0, max: 3, step: 0.1 }) }, Fie = 3;
function XF(e, t, r) {
  var n = t.members[t.offsets[t.feature]], i = r.members[r.offsets[r.feature]];
  if (n === i && t.unit === r.unit) return !1;
  var a = Y2(t.unit, n), o = Y2(r.unit, i);
  return (!a || !o || a === o) && (t.unit.residueIndex[t.unit.elements[n]] !== r.unit.residueIndex[r.unit.elements[i]] || t.unit !== r.unit) && !zQ(e, t.unit, n, r.unit, i);
}
function XD(e, t, r, n) {
  var i = Y2(e, t), a = Y2(r, n);
  return i && a && i !== a;
}
function jD(e, t) {
  for (var r = t.feature, n = t.offsets, i = t.members, a = n[r], o = n[r + 1]; a < o; ++a) if (i[a] === e) return !0;
  return !1;
}
var Cl = w(), R5 = w(), O5 = w(), Nie = rT();
function Rie(e, t, r, n) {
  var i = t.feature, a = r.feature, o = t.members[t.offsets[i]], u = r.members[r.offsets[a]];
  Ur.position(R5, t), Ur.position(O5, r), w.scale(Cl, w.add(Cl, R5, O5), 0.5);
  var s = n * Fie, c = e.lookup3d.find(Cl[0], Cl[1], Cl[2], s, Nie), l = c.count, d = c.indices, f = c.units, m = c.squaredDistances;
  if (l === 0) return !0;
  for (var v = 0; v < l; ++v) {
    var p = d[v], g = f[v];
    if (Be.isAtomic(g)) {
      var h = Br(g, p);
      if (h !== "H") {
        var y = Eg(h);
        if (!(y * y * n * n <= m[v] || XD(g, p, t.unit, o) || XD(g, p, r.unit, u) || t.unit === g && jD(p, t) || r.unit === g && jD(p, r) || (g.conformation.position(g.elements[p], Cl), w.squaredDistance(Cl, R5) < 1 || w.squaredDistance(Cl, O5) < 1))) return !1;
      }
    }
  }
  return !0;
}
function Oie(e, t, r, n, i, a, o) {
  for (var u = r.x, s = r.y, c = r.z, l = r.subset(i.requiredFeatures), d = l.lookup3d, f = l.indices, m = Ur.Info(e, t, r), v = R({}, m), p = 0, g = Le.size(f); p < g; ++p) {
    var h = Le.getAt(f, p), y = d.find(u[h], s[h], c[h], i.maxDistance), x = y.count, A = y.indices, b = y.squaredDistances;
    if (x !== 0) {
      m.feature = h;
      for (var _ = 0; _ < x; ++_) {
        var S = Le.getAt(f, A[_]);
        if (!(S <= h)) {
          v.feature = S;
          var D = m.unit.elements[m.members[m.offsets[m.feature]]], I = v.unit.elements[v.members[v.offsets[v.feature]]];
          if ((!o || o(m.unit, D, v.unit, I)) && XF(e, m, v)) {
            var M = i.getType(e, m, v, b[_]);
            M && n.add(h, S, M);
          }
        }
      }
    }
  }
}
var Lie = me(), kie = { distanceMax: G.Numeric(4, { min: 1, max: 5, step: 0.1 }) }, zie = Ur.Provider([8], function(e, t, r) {
  for (var n = t.elements, i = t.model.atomicConformation, a = i.x, o = i.y, u = i.z, s = function(d, f) {
    var m = Br(t, d), v = !1;
    m === "C" ? (v = !0, $l(e, t, d, function(p, g) {
      var h = Br(p, g);
      h !== "C" && h !== "H" && (v = !1);
    })) : m === "F" && (v = !0), v && r.add(8, 0, a[n[d]], o[n[d]], u[n[d]], d);
  }, c = 0, l = n.length; c < l; ++c) s(c);
}), Gie = { name: "hydrophobic", params: kie, createTester: function(e) {
  return { maxDistance: e.distanceMax, requiredFeatures: /* @__PURE__ */ new Set([8]), getType: function(t, r, n, i) {
    return function(a, o, u, s) {
      var c = o.types[o.feature], l = u.types[u.feature];
      if (d = l, c === 8 && d === 8) {
        var d, f = o.members[o.offsets[o.feature]], m = u.members[u.offsets[u.feature]];
        if (Br(o.unit, f) !== "F" || Br(u.unit, m) !== "F") return gr.Hydrophobic;
      }
    }(0, r, n);
  } };
} };
function Vie(e, t) {
  var r = t.contacts, n = function(c, l, d, f, m) {
    var v = f.get(d) || [1 / 0, -1], p = v[0], g = v[1];
    c < p ? (g !== -1 && m(g), f.set(d, [c, l])) : m(l);
  };
  function i(c, l, d, f, m) {
    var v = l.members[l.offsets[l.feature]], p = d.members[d.offsets[d.feature]], g = l.unit.getResidueIndex(v), h = d.unit.getResidueIndex(p), y = "".concat(v, "|").concat(l.unit.id, "|").concat(h, "|").concat(d.unit.id, "|A"), x = "".concat(p, "|").concat(d.unit.id, "|").concat(g, "|").concat(l.unit.id, "|B"), A = Ur.distance(l, d);
    n(A, c, y, f, m), n(A, c, x, f, m);
  }
  var a, o, u = /* @__PURE__ */ new Map(), s = function(c) {
    return r.edges[c].props.flag = no.Filtered;
  };
  return { isApplicable: function(c) {
    return c === gr.Hydrophobic;
  }, handleInterContact: function(c, l, d) {
    i(c, l, d, u, s);
  }, startUnit: function(c, l, d) {
    a = /* @__PURE__ */ new Map(), o = function(f) {
      return l.edgeProps.flag[f] = no.Filtered;
    };
  }, handleIntraContact: function(c, l, d) {
    i(c, l, d, a, o);
  } };
}
function Uie(e, t) {
  var r = t.contacts, n = function(i, a) {
    for (var o = i.types[i.feature] === 9 ? a : i, u = o.members[o.offsets[o.feature]], s = t.unitsContacts.get(o.unit.id), c = s.edgeProps.type, l = s.elementsIndex, d = l.offsets, f = l.indices, m = d[u], v = d[u + 1]; m < v; ++m) if (c[f[m]] === gr.HydrogenBond) return !0;
    var p = r.getEdgeIndices(o.feature, o.unit.id);
    for (m = 0, v = p.length; m < v; ++m) if (r.edges[p[m]].props.type === gr.HydrogenBond) return !0;
    return !1;
  };
  return { isApplicable: function(i) {
    return i === gr.WeakHydrogenBond;
  }, handleInterContact: function(i, a, o) {
    n(a, o) && (r.edges[i].props.flag = no.Filtered);
  }, startUnit: function() {
  }, handleIntraContact: function(i, a, o) {
    n(a, o) && (t.unitsContacts.get(a.unit.id).edgeProps.flag[i] = no.Filtered);
  } };
}
function m8(e, t, r, n, i) {
  for (var a = r.offsets, o = r.feature, u = n.offsets, s = n.feature, c = a[o], l = a[o + 1]; c < l; ++c) for (var d = r.members[c], f = i.getContactIndicesForElement(d, r.unit), m = 0, v = f.length; m < v; ++m) {
    var p = f[m];
    if (e.includes(i.edges[p].props.type)) for (var g = u[s], h = u[s + 1]; g < h; ++g) {
      var y = n.members[g];
      if (i.getContactIndicesForElement(y, n.unit).includes(p)) return void (i.edges[t].props.flag = no.Filtered);
    }
  }
}
function h8(e, t, r, n, i) {
  for (var a = i.edgeProps, o = a.type, u = a.flag, s = i.elementsIndex, c = s.offsets, l = s.indices, d = r.offsets, f = r.feature, m = n.offsets, v = n.feature, p = d[f], g = d[f + 1]; p < g; ++p) for (var h = r.members[p], y = c[h], x = c[h + 1]; y < x; ++y) {
    var A = l[y];
    if (e.includes(o[A])) {
      for (var b = m[v], _ = m[v + 1]; b < _; ++b) for (var S = n.members[b], D = c[S], I = c[S + 1]; D < I; ++D) if (A === l[D]) return void (u[t] = no.Filtered);
    }
  }
}
function Hie(e, t) {
  var r = t.contacts;
  return { isApplicable: function(n) {
    return n === gr.Ionic;
  }, handleInterContact: function(n, i, a) {
    m8([gr.HydrogenBond, gr.WeakHydrogenBond], n, i, a, r);
  }, startUnit: function() {
  }, handleIntraContact: function(n, i, a) {
    h8([gr.HydrogenBond, gr.WeakHydrogenBond], n, i, a, t.unitsContacts.get(i.unit.id));
  } };
}
function qie(e, t) {
  var r = t.contacts;
  return { isApplicable: function(n) {
    return n === gr.Hydrophobic || n === gr.CationPi;
  }, handleInterContact: function(n, i, a) {
    m8([gr.PiStacking], n, i, a, r);
  }, startUnit: function() {
  }, handleIntraContact: function(n, i, a) {
    h8([gr.PiStacking], n, i, a, t.unitsContacts.get(i.unit.id));
  } };
}
function Kie(e, t) {
  var r = t.contacts;
  return { isApplicable: function(n) {
    return n === gr.Ionic;
  }, handleInterContact: function(n, i, a) {
    m8([gr.MetalCoordination], n, i, a, r);
  }, startUnit: function() {
  }, handleIntraContact: function(n, i, a) {
    h8([gr.MetalCoordination], n, i, a, t.unitsContacts.get(i.unit.id));
  } };
}
function Xie(e, t, r, n, i, a) {
  return _e(this, 0, void 0, function() {
    var o, u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _, S, D, I, M;
    return ye(this, function(F) {
      return Be.isAtomic(t) ? (o = r.child, u = o == null ? void 0 : o.unitMap.get(t.id), o && !u ? [2, Gt.createEmpty(a)] : (s = at.create(r, t), c = Yn.get(r).value, l = c.unitsFeatures.get(t.id), d = c.unitsContacts.get(t.id), f = l.x, m = l.y, v = l.z, p = l.members, g = l.offsets, h = d.edgeCount, y = d.a, x = d.b, A = d.edgeProps.flag, b = i.sizeFactor, h ? (_ = { linkCount: 2 * h, position: function(P, E, B) {
        w.set(P, f[y[B]], m[y[B]], v[y[B]]), w.set(E, f[x[B]], m[x[B]], v[x[B]]);
      }, style: function(P) {
        return 1;
      }, radius: function(P) {
        s.element = t.elements[p[g[y[P]]]];
        var E = n.size.size(s);
        s.element = t.elements[p[g[x[P]]]];
        var B = n.size.size(s);
        return Math.min(E, B) * b;
      }, ignore: function(P) {
        if (A[P] === no.Filtered) return !0;
        if (u) for (var E = y[P], B = g[E], N = g[E + 1]; B < N; ++B) {
          var O = t.elements[p[g[B]]];
          if (!qe.has(u.elements, O)) return !0;
        }
        return !1;
      } }, S = Hg(0, _, i, a), D = S.mesh, (I = S.boundingSphere) ? D.setBoundingSphere(I) : D.triangleCount > 0 && (M = Me.expand(Me(), (u ?? t).boundary.sphere, 1 * b), D.setBoundingSphere(M)), [2, D]) : [2, Gt.createEmpty(a)])) : [2, Gt.createEmpty(a)];
    });
  });
}
var jF = R(R(R({}, Gc), Ug), { sizeFactor: G.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), dashCount: G.Numeric(6, { min: 2, max: 10, step: 2 }), dashScale: G.Numeric(0.6, { min: 0, max: 2, step: 0.1 }), includeParent: G.Boolean(!1) });
function jie(e) {
  return Vc({ defaultProps: G.getDefaultValues(jF), createGeometry: Xie, createLocationIterator: Zie, getLoci: Yie, eachLocation: Wie, setUpdateState: function(t, r, n, i, a, o, u) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor || r.dashCount !== n.dashCount || r.dashScale !== n.dashScale || r.dashCap !== n.dashCap || r.radialSegments !== n.radialSegments;
    var s = Yn.get(o.structure).version;
    t.info.interactionsHash !== s && (t.createGeometry = !0, t.updateTransform = !0, t.updateColor = !0, t.info.interactionsHash = s);
  } }, e);
}
function Yie(e, t, r) {
  var n = e.objectId, i = e.instanceId, a = e.groupId;
  if (r === n) {
    var o = t.structure, u = t.group, s = o.unitMap.get(u.units[i].id), c = Yn.get(o).value, l = c.unitsContacts.get(s.id), d = l.a, f = l.b;
    return Rc.Loci(o, c, [{ unitA: s, indexA: d[a], unitB: s, indexB: f[a] }, { unitA: s, indexA: f[a], unitB: s, indexB: d[a] }]);
  }
  return vn;
}
var L5 = /* @__PURE__ */ new Set();
function Wie(e, t, r, n) {
  var i = !1;
  if (Rc.isLoci(e)) {
    var a = t.structure, o = t.group;
    if (!tt.areEquivalent(e.data.structure, a)) return !1;
    var u = Yn.get(a).value;
    if (e.data.interactions !== u) return !1;
    for (var s = o.units[0], c = u.unitsContacts.get(s.id), l = 2 * c.edgeCount, d = 0, f = e.elements; d < f.length; d++)
      if ((F = f[d]).unitA === F.unitB) {
        var m = o.unitIndexMap.get(F.unitA.id);
        if (m !== void 0) {
          var v = c.getDirectedEdgeIndex(F.indexA, F.indexB);
          v !== -1 && r(Ae.ofSingleton(m * l + v)) && (i = !0);
        }
      }
  } else if (Xe.is(e)) {
    if (a = t.structure, o = t.group, !tt.areEquivalent(e.structure, a) || !(u = Yn.get(a).value)) return !1;
    s = o.units[0];
    for (var p = u.unitsContacts.get(s.id), g = u.unitsFeatures.get(s.id), h = 2 * p.edgeCount, y = p.offset, x = g.elementsIndex, A = x.offsets, b = x.indices, _ = g.members, S = g.offsets, D = function(P) {
      var E = o.unitIndexMap.get(P.unit.id);
      if (E === void 0) return "continue";
      Le.forEach(P.indices, function(B) {
        for (var N = A[B], O = A[B + 1]; N < O; ++N) for (var z = b[N], V = y[z], U = y[z + 1]; V < U; ++V) L5.add(V);
      }), L5.forEach(function(B) {
        if (n) {
          for (var N = p.a[B], O = S[N], z = S[N + 1]; O < z; ++O) if (!Le.has(P.indices, _[O])) return;
          var V = p.b[B];
          for (O = S[V], z = S[V + 1]; O < z; ++O) if (!Le.has(P.indices, _[O])) return;
        }
        r(Ae.ofSingleton(E * h + B)) && (i = !0);
      }), L5.clear();
    }, I = 0, M = e.elements; I < M.length; I++) {
      var F;
      D(F = M[I]);
    }
  }
  return i;
}
function Zie(e) {
  var t = e.structure, r = e.group, n = r.units[0], i = Yn.get(t).value, a = i.unitsContacts.get(n.id), o = 2 * a.edgeCount, u = r.units.length, s = Rc.Location(i, t), c = s.element;
  return ri(o, u, 1, function(l, d) {
    var f = r.units[d];
    return c.unitA = f, c.indexA = a.a[l], c.unitB = f, c.indexB = a.b[l], s;
  });
}
function Qie(e, t, r, n, i) {
  if (!t.hasAtomic) return Gt.createEmpty(i);
  var a = at.create(t), o = Yn.get(t).value, u = o.contacts, s = o.unitsFeatures, c = u.edgeCount, l = u.edges, d = n.sizeFactor;
  if (!c) return Gt.createEmpty(i);
  var f = t.child, m = { linkCount: c, position: function(x, A, b) {
    var _ = l[b], S = _.unitA, D = _.indexA, I = _.unitB, M = _.indexB, F = s.get(S), P = s.get(I), E = t.unitMap.get(S), B = t.unitMap.get(I);
    w.set(x, F.x[D], F.y[D], F.z[D]), w.transformMat4(x, x, E.conformation.operator.matrix), w.set(A, P.x[M], P.y[M], P.z[M]), w.transformMat4(A, A, B.conformation.operator.matrix);
  }, style: function(x) {
    return 1;
  }, radius: function(x) {
    var A = l[x], b = s.get(A.unitA);
    a.unit = t.unitMap.get(A.unitA), a.element = a.unit.elements[b.members[b.offsets[A.indexA]]];
    var _ = r.size.size(a), S = s.get(A.unitB);
    a.unit = t.unitMap.get(A.unitB), a.element = a.unit.elements[S.members[S.offsets[A.indexB]]];
    var D = r.size.size(a);
    return Math.min(_, D) * d;
  }, ignore: function(x) {
    if (l[x].props.flag === no.Filtered) return !0;
    if (f) {
      var A = l[x], b = f.unitMap.get(A.unitA);
      if (!b) return !0;
      for (var _ = t.unitMap.get(A.unitA), S = s.get(A.unitA), D = S.offsets, I = S.members, M = D[A.indexA], F = D[A.indexA + 1]; M < F; ++M) {
        var P = _.elements[I[M]];
        if (!qe.has(b.elements, P)) return !0;
      }
    }
    return !1;
  } }, v = Hg(0, m, n, i), p = v.mesh, g = v.boundingSphere;
  if (g) p.setBoundingSphere(g);
  else if (p.triangleCount > 0) {
    var h = t.child, y = Me.expand(Me(), (h ?? t).boundary.sphere, 1 * d);
    p.setBoundingSphere(y);
  }
  return p;
}
var YF = R(R(R({}, vB), Ug), { sizeFactor: G.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), dashCount: G.Numeric(6, { min: 2, max: 10, step: 2 }), dashScale: G.Numeric(0.6, { min: 0, max: 2, step: 0.1 }), includeParent: G.Boolean(!1) });
function Jie(e) {
  return gB({ defaultProps: G.getDefaultValues(YF), createGeometry: Qie, createLocationIterator: tae, getLoci: $ie, eachLocation: eae, setUpdateState: function(t, r, n, i, a, o, u) {
    t.createGeometry = r.sizeFactor !== n.sizeFactor || r.dashCount !== n.dashCount || r.dashScale !== n.dashScale || r.dashCap !== n.dashCap || r.radialSegments !== n.radialSegments;
    var s = Yn.get(o).version;
    t.info.interactionsHash !== s && (t.createGeometry = !0, t.updateTransform = !0, t.updateColor = !0, t.info.interactionsHash = s);
  } }, e);
}
function $ie(e, t, r) {
  var n = e.objectId, i = e.groupId;
  if (r === n) {
    var a = Yn.get(t).value, o = a.contacts.edges[i], u = t.unitMap.get(o.unitA), s = t.unitMap.get(o.unitB);
    return Rc.Loci(t, a, [{ unitA: u, indexA: o.indexA, unitB: s, indexB: o.indexB }, { unitA: s, indexA: o.indexB, unitB: u, indexB: o.indexA }]);
  }
  return vn;
}
var Gv = /* @__PURE__ */ new Map(), k5 = /* @__PURE__ */ new Set();
function eae(e, t, r, n) {
  var i = !1;
  if (Rc.isLoci(e)) {
    if (!tt.areEquivalent(e.data.structure, t)) return !1;
    var a = Yn.get(t).value;
    if (e.data.interactions !== a) return !1;
    for (var o = a.contacts, u = 0, s = e.elements; u < s.length; u++) {
      var c = s[u], l = o.getEdgeIndex(c.indexA, c.unitA.id, c.indexB, c.unitB.id);
      l !== -1 && r(Ae.ofSingleton(l)) && (i = !0);
    }
  } else if (Xe.is(e)) {
    if (!tt.areEquivalent(e.structure, t) || n && e.elements.length === 1 || !(a = Yn.get(t).value)) return !1;
    for (var d = a.contacts, f = a.unitsFeatures, m = 0, v = e.elements; m < v.length; m++) {
      var p = v[m];
      Gv.set(p.unit.id, p.indices);
    }
    for (var g = function(x) {
      var A = x.unit;
      if (!Be.isAtomic(A)) return "continue";
      Le.forEach(x.indices, function(b) {
        for (var _ = 0, S = d.getContactIndicesForElement(b, A); _ < S.length; _++) {
          var D = S[_];
          k5.add(D);
        }
      });
    }, h = 0, y = e.elements; h < y.length; h++)
      g(p = y[h]);
    k5.forEach(function(x) {
      if (n) {
        var A = d.edges[x], b = A.indexA, _ = A.unitA, S = A.indexB, D = A.unitB, I = Gv.get(_), M = Gv.get(D);
        if (!I || !M) return;
        for (var F = f.get(_), P = F.offsets, E = F.members, B = P[b], N = P[b + 1]; B < N; ++B) if (!Le.has(I, E[B])) return;
        var O = f.get(D), z = O.offsets, V = O.members;
        for (B = z[S], N = z[S + 1]; B < N; ++B) if (!Le.has(M, V[B])) return;
      }
      r(Ae.ofSingleton(x)) && (i = !0);
    }), Gv.clear(), k5.clear();
  }
  return i;
}
function tae(e) {
  var t = Yn.get(e).value, r = t.contacts, n = r.edgeCount, i = Rc.Location(t, e), a = i.element;
  return ri(n, 1, 1, function(o) {
    var u = r.edges[o];
    return a.unitA = e.unitMap.get(u.unitA), a.indexA = u.indexA, a.unitB = e.unitMap.get(u.unitB), a.indexB = u.indexB, i;
  }, !0);
}
var WF = { "intra-unit": function(e, t) {
  return Ba("Intra-unit interactions cylinder", e, t, jie);
}, "inter-unit": function(e, t) {
  return bf("Inter-unit interactions cylinder", e, t, Jie);
} }, YD = R(R(R({}, jF), YF), { unitKinds: Bm(["atomic"]), sizeFactor: G.Numeric(0.15, { min: 0.01, max: 1, step: 0.01 }), visuals: G.MultiSelect(["intra-unit", "inter-unit"], G.objectToOptions(WF)) }), vp, Rc, x1 = { name: "interactions", label: "Non-covalent Interactions", description: "Displays non-covalent interactions as dashed cylinders.", factory: function(e, t) {
  return or.createMulti("Interactions", e, t, Wo, WF);
}, getParams: function(e, t) {
  return G.clone(YD);
}, defaultValues: G.getDefaultValues(YD), defaultColorTheme: { name: "interaction-type" }, defaultSizeTheme: { name: "uniform" }, isApplicable: function(e) {
  return e.elementCount > 0 && Yn.isApplicable(e);
}, ensureCustomProperties: { attach: function(e, t) {
  return Yn.attach(e, t, void 0, !0);
}, detach: function(e) {
  return Yn.ref(e, !1);
} }, getData: function(e, t) {
  return t.includeParent ? e.asParent() : e;
}, mustRecreate: function(e, t) {
  return e.includeParent !== t.includeParent;
} }, z5 = { createOrUpdateInCellItems: function(e, t, r, n, i) {
  return _e(this, 0, void 0, function() {
    var a, o, u, s;
    return ye(this, function(c) {
      switch (c.label) {
        case 0:
          return a = n2(e, t).structure, o = R(R({}, Yn.defaultParams), { type: r }), n && (o.providers.defaultValue = n), [4, Yn.attach({ runtime: Ho, assetManager: new bc() }, a, o)];
        case 1:
          return c.sent(), t.managers.cell.traverse(function(l, d) {
            var f;
            d.type === Te.IntraInteractions && (u = l.ref, d.state && ((f = t.canvas3d) === null || f === void 0 || f.remove(d.state), d.state.destroy())), d.type === Te.BetweenInteractions && t.managers.cell.remove([{ ref: l.ref }]);
          }), (s = x1.factory(t.managers.representation.ctx, x1.getParams)).setTheme({ color: t.managers.representation.ctx.colorThemeRegistry.create("interaction-type", { structure: a }), size: t.managers.representation.ctx.sizeThemeRegistry.create("uniform", { structure: a }) }), [4, s.createOrUpdate({}, a).run()];
        case 2:
          return c.sent(), [2, { representation: s, structure: a, ref: u }];
      }
    });
  });
}, createOrUpdateBetweenCellItems: function(e, t, r, n, i) {
  return _e(this, 0, void 0, function() {
    var a, o, u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _;
    return ye(this, function(S) {
      switch (S.label) {
        case 0:
          for (a = n2(We(We([], e, !0), t, !0), r), o = a.unitsMap, u = a.structure, s = R({}, Yn.defaultParams), n && (s.providers.defaultValue = n), c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), p = 0, d = e.length; p < d; p++) o.get(p).forEach(function(D) {
            return c.add(D);
          });
          for (p = 0, d = t.length; p < d; p++) o.get(p + e.length).forEach(function(D) {
            return l.add(D);
          });
          return [4, Yn.attach({ runtime: Ho, assetManager: new bc() }, u, s)];
        case 1:
          if (S.sent(), !u.state.propertyData.molstar_computed_interactions) return [2, {}];
          for (f = u.state.propertyData.molstar_computed_interactions.data.value, m = f.contacts, v = f.unitsFeatures, p = 0, g = m.edgeCount; p < g; ++p) h = m.edges[p], y = u.unitMap.get(h.unitA), x = u.unitMap.get(h.unitB), Ur.Info(u, y, v.get(h.unitA)).feature = h.indexA, Ur.Info(u, x, v.get(h.unitB)).feature = h.indexB, c.has(h.unitA) && l.has(h.unitB) || l.has(h.unitA) && c.has(h.unitB) || (m.edges[p].props.flag = no.Filtered);
          return b = [], r.managers.cell.traverse(function(D, I) {
            var M;
            I.type === Te.BetweenInteractions && (A = D.ref, I.state && ((M = r.canvas3d) === null || M === void 0 || M.remove(I.state), I.state.destroy())), I.type === Te.IntraInteractions && b.push({ ref: D.ref });
          }), [4, r.managers.cell.remove(b)];
        case 2:
          return S.sent(), (_ = x1.factory(r.managers.representation.ctx, x1.getParams)).setTheme({ color: r.managers.representation.ctx.colorThemeRegistry.create("interaction-type", { structure: u }), size: r.managers.representation.ctx.sizeThemeRegistry.create("uniform", { structure: u }) }), [4, _.createOrUpdate({ visuals: ["inter-unit"] }, u).run()];
        case 3:
          return S.sent(), [2, { representation: _, structure: u, ref: A }];
      }
    });
  });
}, createOrUpdateGlobal: function(e, t, r, n, i, a) {
  return _e(this, 0, void 0, function() {
    var o, u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _, S, D, I, M, F, P, E, B, N, O, z, V;
    return ye(this, function(U) {
      switch (U.label) {
        case 0:
          o = /* @__PURE__ */ new Map(), u = [], s = 0, c = [], o_(f0).forEach(function(H) {
            var K = (n ?? P.providers.defaultValue)[H], j = K.name, X = K.params;
            j === "on" && c.push(f0[H].createTester(X));
          }), l = /* @__PURE__ */ new Set(), c.forEach(function(H) {
            return to.add(l, H.requiredFeatures);
          }), d = ZF.filter(function(H) {
            return to.areIntersecting(l, H.types);
          }), I = 0, M = e.length, U.label = 1;
        case 1:
          return I < M ? (f = e[I], (m = t.cells.get(f.ref)) ? (v = f.elementIds ? $n(Zr(m), f.elementIds) : Zr(m), [4, Pm.attach({ runtime: Ho, assetManager: new bc() }, v)]) : [3, 3]) : [3, 4];
        case 2:
          for (U.sent(), v.currentPropertyData.molstar_computed_valence_model.data.value.forEach(function(H) {
            o.set(s, H), s++;
          }), p = 0, g = v.units.length; p < g; p++) h = JF(v, v.units[p], d), u.push(h);
          U.label = 3;
        case 3:
          return I++, [3, 1];
        case 4:
          for (y = n2(e, t), x = y.unitsMap, A = y.structure, b = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map(), D = function(H, K) {
            S.set(e[H].ref, /* @__PURE__ */ new Set());
            var j = x.get(H), X = t.cells.get(e[H].ref);
            if (X) {
              var W = Zr(X).units;
              j.forEach(function(Q, te) {
                b.set(Q, e[H].ref), W && W[te] && _.set("".concat(e[H].ref, "_").concat(W[te].invariantId), Q);
              });
            }
          }, I = 0, M = e.length; I < M; I++) D(I);
          return Object.assign(A.currentPropertyData, { molstar_computed_valence_model: { props: { assignCharge: "auto", assignH: "auto" }, data: { id: 3224, version: 1, value: o } } }), F = /* @__PURE__ */ new Set(), a == null || a.map(function(H) {
            var K = H.ref, j = H.elementIds, X = t.cells.get(K);
            X && Zr(X).units.forEach(function(W) {
              W.elements.filter(function(Q) {
                return j == null ? void 0 : j.includes(Q);
              }).forEach(function(Q) {
                return F.add("".concat(_.get("".concat(K, "_").concat(W.invariantId)), "_").concat(Q));
              });
            });
          }), P = R(R({}, Yn.defaultParams), { type: r, featuresList: u, filterKeys: a ? Array.from(F.values()) : void 0 }), n && (P.providers.defaultValue = n), [4, Yn.attach({ runtime: Ho, assetManager: new bc() }, A, P)];
        case 5:
          return U.sent(), E = A.state.propertyData.molstar_computed_interactions.data.value, B = E.contacts, N = E.unitsContacts, O = E.unitsFeatures, B.edges.forEach(function(H) {
            var K = H.indexA, j = H.indexB, X = H.unitA, W = H.unitB, Q = H.props.flag, te = O.get(X), ee = te.members, $ = te.offsets, ie = O.get(W), ae = ie.members, se = ie.offsets;
            if (Q !== no.Filtered) {
              var le = A.unitMap.get(X).elements[ee[$[K]]], pe = A.unitMap.get(W).elements[ae[se[j]]];
              S.get(b.get(X)).add(le), S.get(b.get(W)).add(pe);
            }
          }), Array.from(N.entries()).forEach(function(H) {
            for (var K = H[0], j = H[1], X = O.get(K), W = X.members, Q = X.offsets, te = j.a, ee = j.b, $ = 0, ie = te.length; $ < ie; $++) {
              var ae = A.unitMap.get(K).elements[W[Q[te[$]]]], se = A.unitMap.get(K).elements[W[Q[ee[$]]]];
              S.get(b.get(K)).add(ae), S.get(b.get(K)).add(se);
            }
          }), t.managers.cell.traverse(function(H, K) {
            var j;
            K.type === Te.IntraInteractions && (z = H.ref, K.state && ((j = t.canvas3d) === null || j === void 0 || j.remove(K.state), K.state.destroy()));
          }), (V = x1.factory(t.managers.representation.ctx, x1.getParams)).setTheme({ color: t.managers.representation.ctx.colorThemeRegistry.create("interaction-type", { structure: A }), size: t.managers.representation.ctx.sizeThemeRegistry.create("uniform", { structure: A }) }), [4, V.createOrUpdate({}, A).run()];
        case 6:
          return U.sent(), [2, { representation: V, structure: A, ref: z, interactionElementIds: Array.from(S.keys()).map(function(H) {
            return { ref: H, elementIds: Array.from(S.get(H).values()) };
          }).filter(function(H) {
            return H.elementIds.length;
          }) }];
      }
    });
  });
} };
(function(e) {
  function t(i, a) {
    var o = a.unitA, u = a.indexA, s = a.unitB, c = a.indexB, l = i.contacts, d = i.unitsContacts;
    if (o === s) {
      var f = d.get(o.id), m = f.getDirectedEdgeIndex(u, c);
      return o6(f.edgeProps.type[m]);
    }
    return m = l.getEdgeIndex(u, o.id, c, s.id), o6(l.edges[m].props.type);
  }
  function r(i, a, o) {
    var u = i.unitsFeatures;
    return K1.fromPairProvider(a.length, function(s, c, l) {
      var d = a[s];
      Ur.setPosition(c, d.unitA, d.indexA, u.get(d.unitA.id)), Ur.setPosition(l, d.unitB, d.indexB, u.get(d.unitB.id));
    }, o);
  }
  function n(i, a, o) {
    var u = o[0];
    if (u === void 0) return "";
    var s = u.unitA, c = u.indexA, l = u.unitB, d = u.indexB, f = a.unitsFeatures, m = f.get(s.id), v = m.members, p = m.offsets, g = f.get(l.id), h = g.members, y = g.offsets, x = { granularity: "element" };
    return (p[c + 1] - p[c] > 1 || y[d + 1] - y[d] > 1) && (x.granularity = "residue"), [t(a, u), eF(Dt.Location(i, s, v[p[c]], i, l, h[y[d]]), x)].join("</br>");
  }
  e.Location = function(i, a, o, u, s, c) {
    return /* @__PURE__ */ function(l, d, f) {
      return { kind: "data-location", tag: l, data: d, element: f };
    }("interactions", { structure: a, interactions: i }, { unitA: o, indexA: u, unitB: s, indexB: c });
  }, e.isLocation = function(i) {
    return !!i && i.kind === "data-location" && i.tag === "interactions";
  }, e.areLocationsEqual = function(i, a) {
    return i.data.structure === a.data.structure && i.data.interactions === a.data.interactions && i.element.indexA === a.element.indexA && i.element.indexB === a.element.indexB && i.element.unitA === a.element.unitA && i.element.unitB === a.element.unitB;
  }, e.locationLabel = function(i) {
    return t(i.data.interactions, i.element);
  }, e.Loci = function(i, a, o) {
    return F_("interactions", { structure: i, interactions: a }, o, function(u) {
      return r(a, o, u);
    }, function() {
      return n(i, a, o);
    });
  }, e.isLoci = function(i) {
    return !!i && i.kind === "data-loci" && i.tag === "interactions";
  }, e.getBoundingSphere = r, e.getLabel = n;
})(Rc || (Rc = {}));
var ZF = [$Q, eJ, tJ, vJ, gJ, yJ, sJ, cJ, zie, DJ, IJ], f0 = { ionic: bJ, "pi-stacking": _J, "cation-pi": xJ, "halogen-bonds": lJ, "hydrogen-bonds": rJ, "weak-hydrogen-bonds": nJ, hydrophobic: Gie, "metal-coordination": EJ }, rae = function(e) {
  e === void 0 && (e = []);
  var t = /* @__PURE__ */ Object.create(null);
  return Object.keys(f0).forEach(function(r) {
    t[r] = G.MappedStatic(e.includes(r) ? "on" : "off", { on: G.Group(f0[r].params), off: G.Group({}) }, { cycle: !0 });
  }), t;
}(["ionic", "cation-pi", "pi-stacking", "hydrogen-bonds", "halogen-bonds", "metal-coordination", "weak-hydrogen-bonds"]), nae = ((vp = {})[pa.LigandReceptor] = {}, vp[pa.IntraLigand] = {}, vp[pa.IntraReceptor] = {}, vp[pa.All] = {}, vp), iae = Object.keys(nae), aae = G.arrayToOptions(iae), QF = { providers: G.Group(rae, { isFlat: !0 }), contacts: G.Group(Bie, { label: "Advanced Options" }), type: G.Select(pa.LigandReceptor, aae, { isEssential: !0, description: "Visual/rendering quality of the representation." }), featuresList: G.Value([], { isHidden: !0 }), filterKeys: G.Value(void 0, { isHidden: !0 }) };
function oae(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o, u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _, S, D, I, M, F;
    return ye(this, function(P) {
      switch (P.label) {
        case 0:
          n = R(R({}, G.getDefaultValues(QF)), r), i = n.type, a = n.featuresList, o = n.filterKeys, u = new Set(o), s = GP(t).data, c = s.ligand, l = s.other, d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set(), Object.keys(c).forEach(function(E) {
            Object.keys(c[E]).forEach(function(B) {
              c[E][B].forEach(function(N) {
                d.add(N.unitId), f.add("".concat(N.unitId, "_").concat(N.elementId));
              });
            });
          }), Object.keys(l).forEach(function(E) {
            Object.keys(l[E]).forEach(function(B) {
              l[E][B].forEach(function(N) {
                d.add(N.unitId), f.add("".concat(N.unitId, "_").concat(N.elementId));
              });
            });
          }), m = [], o_(f0).forEach(function(E) {
            var B = n.providers[E], N = B.name, O = B.params;
            N === "on" && m.push(f0[E].createTester(i === pa.All && ["hydrogen-bonds", "weak-hydrogen-bonds"].includes(E) ? R(R({}, O), { water: !0 }) : O));
          }), v = /* @__PURE__ */ new Set(), m.forEach(function(E) {
            return to.add(v, E.requiredFeatures);
          }), p = ZF.filter(function(E) {
            return to.areIntersecting(v, E.types);
          }), g = Ps.Mutable(), h = Ps.Mutable(), y = 0, x = t.unitSymmetryGroups.length, P.label = 1;
        case 1:
          return y < x ? (A = t.unitSymmetryGroups[y], e.runtime.shouldUpdate ? [4, e.runtime.update({ message: "computing interactions", current: y, max: x })] : [3, 3]) : [3, 5];
        case 2:
          P.sent(), P.label = 3;
        case 3:
          for (b = a && a[y] ? a[y] : JF(t, A.units[0], p), _ = function(E, B, N, O, z, V) {
            var U = L6.create(N, B.elements.length);
            return Be.isAtomic(B) && function(H, K, j, X, W, Q, te) {
              for (var ee = 0, $ = W; ee < $.length; ee++) Oie(H, K, j, X, $[ee], 0, te);
            }(E, B, N, U, O, 0, V), U.getContacts();
          }(t, A.units[0], b, m, n.contacts, function(E, B, N, O) {
            return !!(!o || u.has("".concat(E.invariantId, "_").concat(B)) && u.has("".concat(N.invariantId, "_").concat(O))) && i !== pa.IntraReceptor && (i === pa.All || ["".concat(E.invariantId, "_").concat(B), "".concat(N.invariantId, "_").concat(O)].filter(function(z) {
              return f.has(z);
            }).length === (i === pa.LigandReceptor ? 1 : 2));
          }), S = 0, D = A.units.length; S < D; ++S) I = A.units[S], g.set(I.id, b), h.set(I.id, _);
          P.label = 4;
        case 4:
          return ++y, [3, 1];
        case 5:
          return M = function(E, B, N, O, z) {
            var V = k6.create();
            return tt.eachUnitPair(E, function(U, H) {
              var K = B.get(U.id), j = B.get(H.id);
              (function(X, W, Q, te, ee, $, ie, ae, se) {
                var le = Q.count, pe = Q.x, we = Q.y, Ge = Q.z, Ue = ee.lookup3d, Ke = me.mul(Lie, te.conformation.operator.inverse, W.conformation.operator.matrix), Ze = !me.isIdentity(Ke), Fe = w(), Je = Math.max.apply(Math, ie.map(function(nr) {
                  return nr.maxDistance;
                })), Ne = Ue.boundary.sphere, nt = Ne.center, re = Ne.radius, J = (re + Je) * (re + Je), ce = ae.lineOfSightDistFactor, de = Ur.Info(X, W, Q), ve = Ur.Info(X, te, ee);
                $.startUnitPair(W, te);
                for (var he = 0; he < le; ++he) if (w.set(Fe, pe[he], we[he], Ge[he]), Ze && w.transformMat4(Fe, Fe, Ke), !(w.squaredDistance(Fe, nt) > J)) {
                  var Se = Ue.find(Fe[0], Fe[1], Fe[2], Je), Re = Se.indices, Ve = Se.count, ze = Se.squaredDistances;
                  if (Ve !== 0) {
                    de.feature = he;
                    for (var mt = 0; mt < Ve; ++mt) {
                      var bt = Re[mt];
                      if (ve.feature = bt, (!se || se(de.unit, de.unit.elements[de.members[de.offsets[he]]], ve.unit, ve.unit.elements[ve.members[ve.offsets[bt]]])) && XF(X, de, ve)) for (var Ct = ze[mt], De = 0, ut = ie; De < ut.length; De++) {
                        var It = ut[De];
                        if (Ct < It.maxDistance * It.maxDistance) {
                          var ur = It.getType(X, de, ve, Ct);
                          if (ur && Rie(X, de, ve, ce)) {
                            $.add(he, bt, ur);
                            break;
                          }
                        }
                      }
                    }
                  }
                }
                $.finishUnitPair();
              })(E, U, K, H, j, V, N, O, z == null ? void 0 : z.elementIdFilter);
            }, { maxRadius: Math.max.apply(Math, N.map(function(U) {
              return U.maxDistance;
            })), validUnit: function(U) {
              return Be.isAtomic(U);
            }, validUnitPair: function(U, H) {
              return tt.validUnitPair(E, U, H) && (!(z != null && z.unitFilter) || z.unitFilter(U, H));
            } }), V.getContacts(B);
          }(t, g, m, n.contacts, { unitFilter: function(E, B) {
            return i === pa.LigandReceptor ? [E.invariantId, B.invariantId].filter(function(N) {
              return d.has(N);
            }).length >= 1 : i !== pa.IntraLigand || [E.invariantId, B.invariantId].filter(function(N) {
              return d.has(N);
            }).length === 2;
          }, elementIdFilter: function(E, B, N, O) {
            return !!(!o || u.has("".concat(E.invariantId, "_").concat(B)) && u.has("".concat(N.invariantId, "_").concat(O))) && (i === pa.All || ["".concat(E.invariantId, "_").concat(B), "".concat(N.invariantId, "_").concat(O)].filter(function(z) {
              return f.has(z);
            }).length === (i === pa.LigandReceptor ? 1 : i === pa.IntraReceptor ? 0 : 2));
          } }), function(E, B) {
            for (var N = B.contacts, O = B.unitsContacts, z = B.unitsFeatures, V = [Vie(0, B), Uie(0, B), Hie(0, B), qie(0, B), Kie(0, B)], U = /* @__PURE__ */ new Set(), H = /* @__PURE__ */ new Map(), K = /* @__PURE__ */ new Map(), j = 0, X = N.edgeCount; j < X; ++j) {
              var W = N.edges[j], Q = E.unitMap.get(W.unitA), te = E.unitMap.get(W.unitB);
              if ((Fe = Ur.Info(E, Q, z.get(W.unitA))).feature = W.indexA, (Je = Ur.Info(E, te, z.get(W.unitB))).feature = W.indexB, W.props.type === 5) {
                for (var ee = [], $ = (re = Fe.types[Fe.feature] === 5 ? Fe : Je).offsets[re.feature], ie = re.offsets[re.feature + 1]; $ < ie; $++) ee.push(re.members[$]);
                ee.length > 1 && H.set(j, ee), ee.length === 1 && U.add(ee[0]);
              }
              if (O.size) for (var ae = 0, se = V; ae < se.length; ae++) (de = se[ae]).isApplicable(W.props.type) && de.handleInterContact(j, Fe, Je);
            }
            for (var le = O.keys(); ; ) {
              var pe = le.next(), we = pe.done, Ge = pe.value;
              if (we) break;
              var Ue = O.get(Ge), Ke = z.get(Ge), Ze = E.unitMap.get(Ge);
              if (Be.isAtomic(Ze)) {
                for (var Fe = Ur.Info(E, Ze, Ke), Je = Ur.Info(E, Ze, Ke), Ne = 0, nt = V; Ne < nt.length; Ne++) (de = nt[Ne]).startUnit(Ze, Ue, Ke);
                for (j = 0, X = 2 * Ue.edgeCount; j < X; ++j) {
                  if (Fe.feature = Ue.a[j], Je.feature = Ue.b[j], Ue.edgeProps.type[j] === 5) {
                    var re;
                    for (ee = [], $ = (re = Fe.types[Fe.feature] === 5 ? Fe : Je).offsets[re.feature], ie = re.offsets[re.feature + 1]; $ < ie; $++) ee.push(re.members[$]);
                    ee.length > 1 && K.set(j, { elements: ee, value: Ge }), ee.length === 1 && U.add(ee[0]);
                  }
                  for (var J = 0, ce = V; J < ce.length; J++) {
                    var de;
                    (de = ce[J]).isApplicable(Ue.edgeProps.type[j]) && de.handleIntraContact(j, Fe, Je);
                  }
                }
              }
            }
            H.forEach(function(ve, he) {
              ve.filter(function(Se) {
                return U.has(Se);
              }).length > 0 && (N.edges[he].props.flag = no.Filtered);
            }), K.forEach(function(ve, he) {
              var Se = ve.elements, Re = ve.value;
              Se.filter(function(Ve) {
                return U.has(Ve);
              }).length > 0 && (O.get(Re).edgeProps.flag[he] = no.Filtered);
            });
          }(t, F = { unitsFeatures: g, unitsContacts: h, contacts: M }), [2, F];
      }
    });
  });
}
function JF(e, t, r) {
  var n = t.elements.length, i = i6.create(n, n / 2);
  if (Be.isAtomic(t)) for (var a = 0, o = r; a < o.length; a++)
    o[a].add(e, t, i);
  return i.getFeatures(n);
}
var G5 = R({}, QF), Yn = Y1.createProvider({ label: "Interactions", descriptor: rs({ name: "molstar_computed_interactions" }), type: "local", defaultParams: G5, getParams: function(e) {
  return G5;
}, isApplicable: function(e) {
  return !e.isCoarseGrained;
}, obtain: function(e, t, r) {
  return _e(void 0, 0, void 0, function() {
    var n, i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return n = R(R({}, G.getDefaultValues(G5)), r), i = {}, [4, oae(e, t, n)];
        case 1:
          return [2, (i.value = a.sent(), i)];
      }
    });
  });
} }), z6 = He(13421772), Pa = { HydrogenBond: 16751667, Hydrophobic: 8421504, HalogenBond: 6154474, Ionic: 15820019, MetalCoordination: 11646163, CationPi: 3392621, PiStacking: 4436985, WeakHydrogenBond: 16771231 }, uae = [["Hydrogen Bond", Pa.HydrogenBond], ["Hydrophobic", Pa.Hydrophobic], ["Halogen Bond", Pa.HalogenBond], ["Ionic", Pa.Ionic], ["Metal Coordination", Pa.MetalCoordination], ["Cation Pi", Pa.CationPi], ["Pi Stacking", Pa.PiStacking], ["Weak HydrogenBond", Pa.WeakHydrogenBond]];
function WD(e) {
  switch (e) {
    case gr.HydrogenBond:
      return Pa.HydrogenBond;
    case gr.Hydrophobic:
      return Pa.Hydrophobic;
    case gr.HalogenBond:
      return Pa.HalogenBond;
    case gr.Ionic:
      return Pa.Ionic;
    case gr.MetalCoordination:
      return Pa.MetalCoordination;
    case gr.CationPi:
      return Pa.CationPi;
    case gr.PiStacking:
      return Pa.PiStacking;
    case gr.WeakHydrogenBond:
      return Pa.WeakHydrogenBond;
    case gr.Unknown:
      return z6;
  }
}
var ZD = {}, gp, wl, yp, Ud, Vv, sae = { name: "interaction-type", label: "Interaction Type", category: "Miscellaneous", factory: function e(t, r) {
  var n, i = t.structure ? Yn.get(t.structure) : void 0, a = i ? h0(i.id, i.version) : -1;
  return n = i && i.value ? function(o) {
    if (Rc.isLocation(o)) {
      var u = o.data.interactions, s = u.unitsContacts, c = u.contacts, l = o.element, d = l.unitA, f = l.unitB, m = l.indexA, v = l.indexB;
      if (d === f) {
        var p = s.get(d.id), g = p.getDirectedEdgeIndex(m, v);
        return WD(p.edgeProps.type[g]);
      }
      return g = c.getEdgeIndex(m, d.id, v, f.id), WD(c.edges[g].props.type);
    }
    return z6;
  } : function() {
    return z6;
  }, { factory: e, granularity: "group", color: n, props: r, contextHash: a, description: "Assigns colors according the interaction type of a link.", legend: is(uae) };
}, getParams: function(e) {
  return ZD;
}, defaultValues: G.getDefaultValues(ZD), isApplicable: function(e) {
  return !!e.structure;
}, ensureCustomProperties: { attach: function(e, t) {
  return t.structure ? Yn.attach(e, t.structure, void 0, !0) : Promise.resolve();
}, detach: function(e) {
  return e.structure && Yn.ref(e.structure, !1);
} } }, G6 = { color: (gp = {}, gp[At.ATOM] = { name: "element-symbol", props: { carbonColor: { name: "uniform", params: { value: He(14474728) } } } }, gp[At.RIBBON] = { name: "uniform", props: { value: He(14474728) } }, gp[At.SURFACE] = { name: "uniform" }, gp), size: (wl = {}, wl[Te.BallAndStick] = { name: "physical" }, wl[Te.Stick] = { name: "uniform" }, wl[Te.Line] = { name: "physical" }, wl[Te.CPK] = { name: "physical" }, wl[Te.Ribbon] = { name: "uniform" }, wl[Te.Surface] = { name: "physical" }, wl), transparency: (yp = {}, yp[At.ATOM] = 0, yp[At.RIBBON] = 0, yp[At.SURFACE] = 0, yp) }, V5 = { name: "element-symbol", props: { carbonColor: { name: "uniform", params: { value: He(4777267) } } } }, cae = function() {
  function e(t, r) {
    this.plugin = t, this.defaultTheme = R(R({}, G6), r);
  }
  return e.prototype.createColorTheme = function(t, r, n) {
    var i, a, o, u, s, c = this;
    return t.name === "multi-theme" ? (i = this.ctx) === null || i === void 0 ? void 0 : i.colorThemeRegistry.create("multi-theme", { structure: r }, { themes: (u = !((o = (a = t.props) === null || a === void 0 ? void 0 : a.themes) === null || o === void 0) && o.length ? t.props.themes : [this.defaultTheme.color[n]]) === null || u === void 0 ? void 0 : u.map(function(l) {
      return { colorTheme: c.createColorTheme(l, l.elementIds ? $n(r, l.elementIds) : r, n), bundle: $a.fromLoci(ei(r, l.elementIds)) };
    }) }) : (s = this.ctx) === null || s === void 0 ? void 0 : s.colorThemeRegistry.create(t.name, { structure: t.elementIds ? $n(r, t.elementIds) : r }, t.props);
  }, e.prototype.createTheme = function(t, r, n) {
    var i = Object.keys(xn).find(function(u) {
      return xn[u].includes(t);
    }), a = n != null && n.color ? n == null ? void 0 : n.color : this.defaultTheme.color[i], o = n != null && n.size ? n == null ? void 0 : n.size : this.defaultTheme.size[t];
    return { color: this.createColorTheme(a, r, i), size: this.ctx.sizeThemeRegistry.create(o.name, { structure: r }, o.props) };
  }, e.prototype.createTransparencyLayers = function(t, r) {
    if (!(r != null && r.length)) return { kind: "empty-loci", layers: [] };
    var n = r.map(function(i) {
      var a = i.elementIds, o = i.value;
      return { loci: ei(t, a), value: o !== void 0 ? 1 - o : 0 };
    });
    return { kind: "element-loci", layers: n };
  }, e.prototype.setColorTheme = function(t, r, n) {
    var i = this;
    t.forEach(function(a) {
      var o, u, s, c, l = a.ref, d = a.elementIds, f = i.plugin.cells.get(l);
      if (!(f != null && f.model.structure) && (f != null && f.representations.has(Te.Surface))) {
        if (n !== At.SURFACE) return;
        var m = Xe.toStructure(ha(f.representations.get(Te.Surface).state.getLoci())), v = qo(m);
        return f.theme.color = ((o = { Atom: [], Ribbon: [] })[At.SURFACE] = [R({ elementIds: v }, r)], o), void a2[Te.Surface].update((s = f == null ? void 0 : f.representations.get(Te.Surface)) === null || s === void 0 ? void 0 : s.state, m, i.ctx, i.createTheme(Te.Surface, m, { color: r }));
      }
      var p = We([], d ?? [], !0);
      d || p.push.apply(p, Gi(tt.toStructureElementLoci(Zr(f))));
      var g = new Set(p);
      f && (f.theme.color ? (!((c = f.theme.color[n]) === null || c === void 0) && c.length && (f.theme.color[n].forEach(function(h, y) {
        f.theme.color[n][y].elementIds = f.theme.color[n][y].elementIds.filter(function(x) {
          return !g.has(x);
        });
      }), f.theme.color[n] = f.theme.color[n].filter(function(h) {
        var y = h.elementIds;
        return y == null ? void 0 : y.length;
      })), f.theme.color[n].push(R({ elementIds: Array.from(g.values()) }, r))) : f.theme.color = ((u = { Atom: [], Ribbon: [], Surface: [] })[n] = [R({ elementIds: Array.from(g.values()) }, r)], u), xn[n].forEach(function(h) {
        var y, x = f.representations.get(h);
        if (x) {
          var A = yo(x.state);
          Du[h].update(x.state, A, i.ctx, { color: i.ctx.colorThemeRegistry.create("multi-theme", { structure: A }, { themes: (y = f.theme.color[n]) === null || y === void 0 ? void 0 : y.map(function(b) {
            return { colorTheme: i.createColorTheme(b, A, n), bundle: $a.fromLoci(ei(A, b.elementIds)) };
          }) }), size: x.state.theme.size });
        }
      }));
    }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: setColorTheme" });
  }, e.prototype.setTransparency = function(t, r, n) {
    var i = this, a = /* @__PURE__ */ new Set();
    t.forEach(function(u) {
      var s, c, l, d, f = u.ref, m = u.elementIds, v = i.plugin.cells.get(f);
      if (!(v != null && v.model.structure) && (v != null && v.representations.has(Te.Surface))) {
        if (n !== At.SURFACE) return;
        var p = Xe.toStructure(ha(v.representations.get(Te.Surface).state.getLoci())), g = qo(p);
        return v.theme.transparency = ((s = {})[At.SURFACE] = [{ elementIds: g, value: r }], s), void ((l = v == null ? void 0 : v.representations.get(Te.Surface)) === null || l === void 0 || l.state.setState({ transparency: i.createTransparencyLayers(yo((d = v == null ? void 0 : v.representations.get(Te.Surface)) === null || d === void 0 ? void 0 : d.state), v == null ? void 0 : v.theme.transparency[n]) }));
      }
      var h = We([], m ?? [], !0);
      !m && v && (p = Zr(v)) && h.push.apply(h, Gi(tt.toStructureElementLoci(p)));
      var y = new Set(h);
      if (v) if (a.add(f), v.theme.transparency) {
        var x = v.theme.transparency[n];
        x.length && (x.forEach(function(A, b) {
          A.elementIds, x[b].elementIds = h.filter(function(_) {
            return !y.has(_);
          });
        }), v.theme.transparency[n] = x.filter(function(A) {
          return A.elementIds, h.length;
        })), v.theme.transparency[n].push({ elementIds: Array.from(y.values()), value: r });
      } else v.theme.transparency = ((c = {})[At.ATOM] = [], c[At.RIBBON] = [], c[At.SURFACE] = [], c[n] = { elementIds: Array.from(y.values()), value: r }, c);
    });
    var o = xn[n];
    a.forEach(function(u) {
      var s = i.plugin.cells.get(u);
      o.forEach(function(c) {
        var l = s == null ? void 0 : s.representations.get(c);
        if (l) {
          var d = yo(l.state), f = i.createTransparencyLayers(d, s == null ? void 0 : s.theme.transparency[n]);
          l.state.setState({ transparency: f });
        }
      });
    }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: setColorTheme" });
  }, e.prototype.setDefaultTheme = function(t) {
    var r;
    this.defaultTheme = R(R(R({}, G6), (r = this.defaultTheme) !== null && r !== void 0 ? r : {}), t);
  }, e;
}(), bp = [Te.BallAndStick, Te.Line, Te.Stick, Te.CPK], lae = function(e) {
  function t(r, n, i) {
    var a = e.call(this, r, n) || this;
    return a.ev = ro.create(), a.event = { interactionParamsUpdated: a.ev(), interactionUpdated: a.ev() }, a.plugin = r, a.type = pa.LigandReceptor, a.interactionParams = R(R({}, i), s6()), a;
  }
  return ga(t, e), t.prototype.showInteractionInCellItems = function(r, n, i, a) {
    var o;
    return _e(this, 0, void 0, function() {
      var u, s, c, l, d, f, m = this;
      return ye(this, function(v) {
        switch (v.label) {
          case 0:
            return u = /* @__PURE__ */ new Map(), a && Array.from(r.map(function(p) {
              return p.ref;
            })).forEach(function(p) {
              var g = m.plugin.cells.get(p);
              if (g) {
                var h = [];
                xn[At.ATOM].forEach(function(y) {
                  g.representations.has(y) && g.representations.get(y).state && h.push.apply(h, Gi(ha(g.representations.get(y).state.getLoci())));
                }), u.set(p, new Set(h));
              }
            }), s = a ? r.map(function(p) {
              var g, h, y = p.ref, x = p.elementIds, A = x ? x.filter(function(b) {
                var _;
                return (_ = u.get(y)) === null || _ === void 0 ? void 0 : _.has(b);
              }) : Array.from((h = (g = u.get(y)) === null || g === void 0 ? void 0 : g.values()) !== null && h !== void 0 ? h : []);
              return { ref: y, elementIds: A };
            }).filter(function(p) {
              return p.elementIds.length;
            }) : r, [4, z5.createOrUpdateInCellItems(s, this.plugin, n, this.interactionParams, i)];
          case 1:
            return c = v.sent(), l = c.representation, d = c.ref, f = { representations: [{ state: l, isHidden: !1, type: Te.IntraInteractions }], model: { other: null }, dependency: { on: r } }, (o = this.plugin.canvas3d) === null || o === void 0 || o.add(l), d ? (this.plugin.managers.cell.update(d, f), [2, d]) : [2, this.plugin.managers.cell.create(f)];
        }
      });
    });
  }, t.prototype.showInteractionBetweenCellItems = function(r, n, i, a) {
    var o;
    return a === void 0 && (a = !1), _e(this, 0, void 0, function() {
      var u, s, c, l, d, f, m, v = this;
      return ye(this, function(p) {
        switch (p.label) {
          case 0:
            return u = /* @__PURE__ */ new Map(), a && Array.from(We(We([], r, !0), n, !0).map(function(g) {
              return g.ref;
            })).forEach(function(g) {
              var h = v.plugin.cells.get(g);
              if (h) {
                var y = [];
                xn[At.ATOM].forEach(function(x) {
                  h.representations.has(x) && h.representations.get(x).state && y.push.apply(y, Gi(ha(h.representations.get(x).state.getLoci())));
                }), u.set(g, new Set(y));
              }
            }), s = a ? r.map(function(g) {
              var h, y, x = g.ref, A = g.elementIds, b = A ? A.filter(function(_) {
                var S;
                return (S = u.get(x)) === null || S === void 0 ? void 0 : S.has(_);
              }) : Array.from((y = (h = u.get(x)) === null || h === void 0 ? void 0 : h.values()) !== null && y !== void 0 ? y : []);
              return { ref: x, elementIds: b };
            }).filter(function(g) {
              return g.elementIds.length;
            }) : r, c = a ? n.map(function(g) {
              var h, y, x = g.ref, A = g.elementIds, b = A ? A.filter(function(_) {
                var S;
                return (S = u.get(x)) === null || S === void 0 ? void 0 : S.has(_);
              }) : Array.from((y = (h = u.get(x)) === null || h === void 0 ? void 0 : h.values()) !== null && y !== void 0 ? y : []);
              return { ref: x, elementIds: b };
            }).filter(function(g) {
              return g.elementIds.length;
            }) : n, [4, z5.createOrUpdateBetweenCellItems(s, c, this.plugin, this.interactionParams, i)];
          case 1:
            return l = p.sent(), d = l.representation, f = l.ref, d ? (m = { representations: [{ state: d, isHidden: !1, type: Te.BetweenInteractions }], model: { other: { itemsA: s, itemsB: c } }, dependency: { on: s.concat(c) } }, (o = this.plugin.canvas3d) === null || o === void 0 || o.add(d), f ? (this.plugin.managers.cell.update(f, m), [2]) : [2, this.plugin.managers.cell.create(m)]) : [2];
        }
      });
    });
  }, t.prototype.setInteractionParams = function(r, n) {
    var i = this, a = new Set(Object.keys(this.interactionParams).filter(function(u) {
      var s;
      return ((s = i.interactionParams[u]) === null || s === void 0 ? void 0 : s.name) === "on";
    }));
    if (this.type === n && r.length === a.size && r.every(function(u) {
      return a.has(u);
    })) return !1;
    this.type = n, this.interactionParams = s6(r);
    var o = !1;
    return this.plugin.managers.cell.traverse(function(u, s) {
      s.type === Te.IntraInteractions && (o = !0, i.showGlobalInteraction(void 0, "lightPlugin.managers.representation.interactions.setInteractionParams"));
    }), this.event.interactionParamsUpdated.next({ params: this.interactionParams, type: n }), o;
  }, t.prototype.showGlobalInteraction = function(r, n) {
    var i;
    return _e(this, 0, void 0, function() {
      var a, o, u, s, c, l, d, f, m, v, p, g, h, y, x, A = this;
      return ye(this, function(b) {
        switch (b.label) {
          case 0:
            return a = /* @__PURE__ */ new Map(), o = oB(this.plugin), r && Array.from(o.map(function(_) {
              return _.ref;
            })).forEach(function(_) {
              var S = A.plugin.cells.get(_);
              if (S) {
                var D = [];
                xn[At.ATOM].forEach(function(I) {
                  S.representations.has(I) && S.representations.get(I).state && D.push.apply(D, Gi(ha(S.representations.get(I).state.getLoci())));
                }), a.set(_, new Set(D));
              }
            }), u = r ? o.map(function(_) {
              var S, D, I = _.ref, M = _.elementIds, F = M ? M.filter(function(P) {
                var E;
                return (E = a.get(I)) === null || E === void 0 ? void 0 : E.has(P);
              }) : Array.from((D = (S = a.get(I)) === null || S === void 0 ? void 0 : S.values()) !== null && D !== void 0 ? D : []);
              return { ref: I, elementIds: F };
            }).filter(function(_) {
              return _.elementIds.length;
            }) : void 0, [4, z5.createOrUpdateGlobal(o, this.plugin, this.type, this.interactionParams, void 0, u)];
          case 1:
            if (s = b.sent(), c = s.representation, l = s.ref, d = s.interactionElementIds, f = { representations: [{ state: c, isHidden: !1, type: Te.IntraInteractions }], model: { other: { type: this.type } }, dependency: { on: o } }, (i = this.plugin.canvas3d) === null || i === void 0 || i.add(c), r) return [3, 5];
            m = [], v = {}, d.forEach(function(_) {
              var S, D = _.ref, I = _.elementIds, M = A.plugin.cells.get(D);
              if (M) {
                v[D] = ((S = {})[Te.BallAndStick] = /* @__PURE__ */ new Set(), S[Te.Line] = /* @__PURE__ */ new Set(), S[Te.Stick] = /* @__PURE__ */ new Set(), S[Te.CPK] = /* @__PURE__ */ new Set(), S);
                var F = new Set(I);
                bp.forEach(function(P) {
                  if (M.representations.has(P) && M.representations.get(P).state) {
                    var E = kg(M.representations.get(P).state);
                    v[D][P] = new Set(E), F.forEach(function(B) {
                      v[D][P].has(B) && F.delete(B);
                    });
                  }
                }), F.size && m.push({ ref: D, elementIds: Array.from(F.values()) });
              }
            }), (x = {})[Te.BallAndStick] = [], x[Te.Line] = [], x[Te.Stick] = [], x[Te.CPK] = [], p = x, m.forEach(function(_) {
              var S, D = _.ref, I = _.elementIds, M = ((S = {})[Te.BallAndStick] = [], S[Te.Line] = [], S[Te.Stick] = [], S[Te.CPK] = [], S), F = /* @__PURE__ */ new Map();
              if (I != null && I.length) {
                var P = A.plugin.managers.cell.get(D), E = Zr(P);
                if (E) {
                  var B = new Set(I), N = new Set(I.map(function(z) {
                    return W2(nB(E, z), kr.Residue);
                  })), O = /* @__PURE__ */ new Map();
                  E.units.forEach(function(z) {
                    z.elements.forEach(function(V) {
                      var U = Os(z, V), H = W2(U, kr.Residue);
                      N.has(H) && (F.has(H) || F.set(H, /* @__PURE__ */ new Set()), (B.has(V) || U.typeSymbol !== "H" || Gg(E, V) === bi.Polar) && O.set(H, We([V], O.has(H) ? O.get(H) : [], !0)), bp.some(function(K) {
                        var j, X;
                        !((j = v[D][K]) === null || j === void 0) && j.has(V) && ((X = F.get(H)) === null || X === void 0 || X.add(K));
                      }));
                    });
                  }), N.forEach(function(z) {
                    var V, U, H = F.get(z);
                    H && H.size !== 0 ? H.size > 0 && (U = M[Array.from(H.values())[0]]).push.apply(U, O.get(z)) : (V = M[Te.Stick]).push.apply(V, O.get(z));
                  }), bp.forEach(function(z) {
                    M[z].length && p[z].push({ ref: D, elementIds: M[z] });
                  });
                }
              }
            }), g = 0, h = bp.length, b.label = 2;
          case 2:
            return g < h ? (y = bp[g], p[y].length ? [4, this.plugin.managers.representation.setMolecularRepr(p[y], y, !0, !1)] : [3, 4]) : [3, 5];
          case 3:
            b.sent(), b.label = 4;
          case 4:
            return g++, [3, 2];
          case 5:
            return l ? (this.plugin.managers.cell.update(l, f), this.event.interactionUpdated.next({ from: n }), [2, d]) : (this.event.interactionUpdated.next({ from: n }), [4, this.plugin.managers.cell.create(f)]);
          case 6:
            return b.sent(), [2, d];
        }
      });
    });
  }, t;
}(cae), $F = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    var t;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, KP(e).run()];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, XP(t.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, dae = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    var t;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, $_(e).run()];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, dd(t.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, fae = function(e, t) {
  return _e(void 0, 0, void 0, function() {
    var r, n, i;
    return ye(this, function(a) {
      switch (a.label) {
        case 0:
          return [4, $_(e).run()];
        case 1:
          if ((r = a.sent()).isError) throw r;
          return n = r.result, t && (o = t[0], n.molecules[0], u = o.graph.graphs, s = u.nodes, c = u.adjacency, l = [], d = [], s.forEach(function(f, m) {
            c[m].forEach(function(v) {
              v.to_jimage.some(function(p) {
                return p !== 0;
              }) || (l.push(f.id), d.push(v.id));
            });
          }), i = { count: l.length, atomA: l, atomB: d }, n.molecules[0] = R(R({}, n.molecules[0]), { bonds: i })), [4, dd(n).run()];
        case 2:
          return [2, a.sent()];
      }
      var o, u, s, c, l, d;
    });
  });
}, pae = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    var t;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, VP(e).run()];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, UP(t.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, mae = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    var t;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, ZP(e).run()];
        case 1:
          if ((t = r.sent()).isError) throw t;
          return [4, QP(t.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, hae = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    return ye(this, function(t) {
      switch (t.label) {
        case 0:
          return [4, dd(JP(e)).run()];
        case 1:
          return [2, t.sent()];
      }
    });
  });
} }, vae = { parse: function(e) {
  return _e(this, 0, void 0, function() {
    var t;
    return ye(this, function(r) {
      switch (r.label) {
        case 0:
          return [4, $P(e).run()];
        case 1:
          if ((t = r.sent()).isError) throw new Error(t.message);
          return [4, dd(t.result).run()];
        case 2:
          return [2, r.sent()];
      }
    });
  });
} }, V6 = ((Ud = {})[mr.Dump] = dae, Ud[mr.Gro] = $F, Ud[mr.Pdb] = pae, Ud[mr.Xyz] = mae, Ud[mr.Material] = hae, Ud[mr.Pymatgen] = vae, Ud), QD = function(e) {
  function t(r, n, i) {
    var a = e.call(this, r, n) || this;
    return a.defaultTheme = R(R({}, G6), n), a.plugin = r, a.interactionParams = R(R({}, i), s6()), a.showPolarHydrogenOnly = !0, a.ctx = { webgl: void 0, colorThemeRegistry: Bc.createRegistry(), sizeThemeRegistry: eo.createRegistry(), props: { hideBond: !1 } }, a;
  }
  return ga(t, e), Object.defineProperty(t.prototype, "hideBond", { get: function() {
    var r, n;
    return (n = (r = this.ctx) === null || r === void 0 ? void 0 : r.props.hideBond) !== null && n !== void 0 && n;
  }, set: function(r) {
    this.ctx.props.hideBond !== r && (this.ctx.props.hideBond = r, this.plugin.managers.cell.traverse(function(n, i) {
      var a, o, u, s, c;
      if (MJ.has(i.type)) {
        var l = r ? (u = (o = (a = i.state) === null || a === void 0 ? void 0 : a.props) === null || o === void 0 ? void 0 : o.visuals) === null || u === void 0 ? void 0 : u.filter(function(d) {
          return d !== "intra-bond" && d !== "inter-bond";
        }) : Array.from(new Set(We(We([], (c = (s = i.state) === null || s === void 0 ? void 0 : s.props) === null || c === void 0 ? void 0 : c.visuals, !0), ["inter-bond", "intra-bond"], !1)));
        i.state.createOrUpdate({ visuals: l }, yo(i.state)).run();
      }
    }));
  }, enumerable: !1, configurable: !0 }), t.prototype.createContext = function() {
    this.ctx = { webgl: this.plugin.canvas3d.webgl, colorThemeRegistry: Bc.createRegistry(), sizeThemeRegistry: eo.createRegistry(), props: { hideBond: !1 } }, this.ctx.colorThemeRegistry.add(sae);
  }, t.prototype.createMolecular = function(r) {
    var n, i, a, o, u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _, S, D, I;
    return _e(this, 0, void 0, function() {
      var M, F, P, E, B, N, O, z, V, U, H, K, j, X, W, Q, te, ee, $, ie, ae, se, le, pe, we, Ge, Ue, Ke = this;
      return ye(this, function(Ze) {
        switch (Ze.label) {
          case 0:
            M = r.format, F = r.reprType, P = r.theme, E = P === void 0 ? {} : P, B = r.elementIds, N = r.ref, O = r.defaultShown, z = r.updateInteraction, V = z === void 0 || z, U = r.autoConvertToTrajectory, H = U !== void 0 && U, Ze.label = 1;
          case 1:
            return Ze.trys.push([1, 12, , 13]), (K = typeof r.data == "string" || r.data instanceof File) ? [4, of(r.data)] : [3, 3];
          case 2:
            return X = Ze.sent(), [3, 4];
          case 3:
            X = r.data, Ze.label = 4;
          case 4:
            return j = X, [4, Fc[M].parse(j)];
          case 5:
            return (W = Ze.sent()).length > 1 && H && V6[M] ? [4, this.plugin.managers.trajectory.importTrajectory({ data: j, format: M })] : [3, 7];
          case 6:
            return [2, (Q = Ze.sent()) ? [Q] : []];
          case 7:
            te = r.data instanceof File ? r.data.name : "", ee = O ?? W.length, $ = Object.keys(xn).find(function(Fe) {
              return xn[Fe].includes(F);
            }), ie = [], ae = 0, se = function(Fe) {
              var Je, Ne, nt, re, J, ce, de, ve, he, Se, Re, Ve, ze, mt, bt, Ct, De, ut, It, ur;
              return ye(this, function(nr) {
                switch (nr.label) {
                  case 0:
                    return Je = We([], B ?? [], !0), Ne = Fe, le.showPolarHydrogenOnly && D1.has(F) && (Je = (B ?? qo(Fe)).filter(function(Er) {
                      return !np(Fe, Er);
                    }), Ne = $n(Fe, Je)), nt = !ee, re = M === mr.Material || ((n = zg(Fe, M)) !== null && n !== void 0 ? n : K) ? j : vee(Fe, M), J = { representations: [{ isHidden: nt, type: F }], model: {}, assets: [{ format: M, data: ["sdf", "mol"].includes(M) && te && !(re != null && re.split(`
`)[0].trim()) ? We(["".concat(te).concat(ae > 0 ? "_".concat(ae) : "")], re.split(`
`).slice(1), !0).join(`
`) : re }], theme: { color: (ze = {}, ze[$] = [R({ elementIds: B ?? Gi(tt.toStructureElementLoci(Fe)) }, (a = (i = E[$]) === null || i === void 0 ? void 0 : i.color) !== null && a !== void 0 ? a : $ === At.ATOM ? V5 : le.defaultTheme.color[$])], ze), transparency: (mt = {}, mt[At.ATOM] = [], mt[At.RIBBON] = [], mt[At.SURFACE] = [], mt[$] = !((o = E[$]) === null || o === void 0) && o.transparency ? [(u = E[$]) === null || u === void 0 ? void 0 : u.transparency] : [], mt), size: (bt = {}, bt[At.ATOM] = [], bt[At.RIBBON] = [], bt[At.SURFACE] = [], bt[$] = !((s = E[$]) === null || s === void 0) && s.size ? [(c = E[$]) === null || c === void 0 ? void 0 : c.size] : [], bt) }, ref: N }, ae++, nt ? [3, 2] : [4, Du[F].create(Ne, le.ctx, le.createTheme(F, Fe, R(R({}, E[$]), $ !== At.ATOM || !((l = E[$]) === null || l === void 0) && l.color ? {} : { color: V5 })))];
                  case 1:
                    return ce = nr.sent(), !((d = E[$]) === null || d === void 0) && d.transparency && ce.setState({ transparency: le.createTransparencyLayers(Fe, [(f = E[$]) === null || f === void 0 ? void 0 : f.transparency]) }), ee--, (m = le.plugin.canvas3d) === null || m === void 0 || m.add(ce), Object.assign(J.representations[0], { state: ce }), [3, 3];
                  case 2:
                    Object.assign(J.representations[0], { cache: { isHidden: nt, type: F, elementIds: Je } }), nr.label = 3;
                  case 3:
                    return de = le.plugin.managers.cell.create(J), ie.push(de), M !== mr.Pdb || B != null && B.length ? [3, 7] : (ve = g6(Fe), he = ve.polymer, (Se = ve.other).length ? nt ? [3, 6] : (Re = $n(Fe, he), [4, Du[Te.Ribbon].update(J.representations[0].state, $n(Fe, he), le.ctx, le.createTheme(Te.Ribbon, Re, E[At.RIBBON]))]) : [3, 7]);
                  case 4:
                    return nr.sent(), Ve = $n(Fe, Se), le.plugin.managers.cell.update(de, { representations: [], model: { structure: Fe }, theme: { color: (Ct = {}, Ct[At.ATOM] = [R({ elementIds: Se ?? Gi(tt.toStructureElementLoci(Fe)) }, (p = (v = E[At.ATOM]) === null || v === void 0 ? void 0 : v.color) !== null && p !== void 0 ? p : { name: "element-symbol", props: { carbonColor: { name: "uniform", params: { value: He(4777267) } } } })], Ct), transparency: (De = {}, De[At.ATOM] = !((g = E[At.ATOM]) === null || g === void 0) && g.transparency ? [(h = E[At.ATOM]) === null || h === void 0 ? void 0 : h.transparency] : [], De), size: (ut = {}, ut[At.ATOM] = [], ut[At.RIBBON] = [], ut[At.SURFACE] = [], ut[$] = !((y = E[At.ATOM]) === null || y === void 0) && y.size ? [(x = E[At.ATOM]) === null || x === void 0 ? void 0 : x.size] : [], ut) } }), [4, le.addMolecularRepr(de, { elementIds: Se, reprType: Te.BallAndStick, isHidden: nt, theme: le.createTheme(Te.BallAndStick, Ve, R({ color: R({ elementIds: Se }, V5) }, E[At.ATOM])), transparency: !((A = E[At.ATOM]) === null || A === void 0) && A.transparency ? [(b = E[At.ATOM]) === null || b === void 0 ? void 0 : b.transparency] : void 0 })];
                  case 5:
                    return nr.sent(), [3, 7];
                  case 6:
                    le.plugin.managers.cell.update(de, { representations: [R(R({}, J.representations[0]), { cache: R(R({}, J.representations[0].cache), { elementIds: he }) }), { isHidden: nt, type: Te.BallAndStick, cache: { isHidden: nt, type: Te.BallAndStick, elementIds: Se } }], model: {}, theme: { color: (It = {}, It[At.ATOM] = [R({ elementIds: Se ?? Gi(tt.toStructureElementLoci(Fe)) }, (S = (_ = E[At.ATOM]) === null || _ === void 0 ? void 0 : _.color) !== null && S !== void 0 ? S : { name: "element-symbol", props: { carbonColor: { name: "uniform", params: { value: He(4777267) } } } })], It), transparency: (ur = {}, ur[At.ATOM] = !((D = E[At.ATOM]) === null || D === void 0) && D.transparency ? [(I = E[At.ATOM]) === null || I === void 0 ? void 0 : I.transparency] : [], ur) } }), nr.label = 7;
                  case 7:
                    return nt || le.plugin.managers.cell.update(de, { model: { structure: Fe } }), V && le.plugin.managers.cell.traverse(function(Er, dr) {
                      dr.type === Te.IntraInteractions && Ke.plugin.managers.representation.showGlobalInteraction(void 0, "lightPlugin.managers.representation.createMolecular");
                    }), le.plugin.managers.snapshot.event.changed.next({ from: "repr: createMolecular" }), [2];
                }
              });
            }, le = this, pe = 0, we = W, Ze.label = 8;
          case 8:
            return pe < we.length ? (Ge = we[pe], [5, se(Ge)]) : [3, 11];
          case 9:
            Ze.sent(), Ze.label = 10;
          case 10:
            return pe++, [3, 8];
          case 11:
            return [2, ie];
          case 12:
            return Ue = Ze.sent(), console.log(Ue), [2, []];
          case 13:
            return [2];
        }
      });
    });
  }, t.prototype.updateMolecular = function(r) {
    var n;
    return _e(this, 0, void 0, function() {
      var i, a, o, u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _, S, D, I, M = this;
      return ye(this, function(F) {
        for (i = r.ref, a = r.structure, o = this.plugin.managers.cell.get(i), u = Xe.toExpression(tt.toStructureElementLoci(o.model.structure)), s = Xe.toExpression(tt.toStructureElementLoci(a)), c = Nt.struct.modifier.exceptBy({ 0: s, by: u }), (l = qo(c0(s0(a, c)))).length && (((d = o.theme.color[At.ATOM]) == null ? void 0 : d.length) === 1 ? d[0].elementIds ? (D = d[0].elementIds).push.apply(D, l) : d[0].elementIds = We([], l, !0) : d == null || d.push(R({ elementIds: l }, this.defaultTheme.color[At.ATOM])), this.plugin.managers.cell.update(i, { representations: [], model: {}, theme: { color: (I = {}, I[At.ATOM] = d, I) } })), (f = [Te.BallAndStick, Te.Stick, Te.Line, Te.CPK]).forEach(function(P) {
          !m && o.representations.has(P) && (m = P);
        }), v = function(P) {
          var E = P[0], B = P[1], N = Object.keys(xn).find(function(H) {
            return xn[H].includes(E);
          }), O = o.theme.color[N], z = B.state.getLoci(), V = Xe.toExpression(tt.toStructureElementLoci(z.structure));
          f.includes(E) && E !== m || (V = Nt.struct.modifier.union([Nt.struct.combinator.merge([c, V])]));
          var U = c0(s0(a, V));
          Du[E].update(B.state, U, p.ctx, p.createTheme(E, a, { color: { name: "multi-theme", props: { themes: O } }, size: o.theme.size && (!((n = o.theme.size[N]) === null || n === void 0) && n.length) ? o.theme.size[N][0] : p.defaultTheme.size[E] })), B.state.setState({ transparency: p.createTransparencyLayers(U, o == null ? void 0 : o.theme.transparency[N]) });
        }, p = this, g = 0, h = Array.from(o.representations); g < h.length; g++) y = h[g], v(y);
        for (x = function(P) {
          var E = A.plugin.cells.get(P);
          E && E.representations.forEach(function(B, N) {
            N === Te.IntraInteractions && M.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.representation.updateMolecular"), Object.keys(Op).includes(N) && M.plugin.managers.representation.updateMeasurement({ items: E.dependency.on, ref: P });
          });
        }, A = this, b = 0, _ = o.dependency.by; b < _.length; b++) S = _[b], x(S);
        return this.plugin.managers.snapshot.event.changed.next({ from: "repr: updateMolecular" }), [2, o];
      });
    });
  }, t.prototype.createMeasurement = function(r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o, u, s, c, l, d, f, m, v;
      return ye(this, function(p) {
        switch (p.label) {
          case 0:
            if (n = r.type, i = r.theme, a = r.items, o = r.ref, u = r.isHidden, !u0.has(n)) return console.warn("There is no ".concat(n, " type ")), [2, ""];
            s = [], c = 0, l = a, p.label = 1;
          case 1:
            return c < l.length ? (d = l[c], [4, this.plugin.managers.cell.getStructure(d.ref)]) : [3, 4];
          case 2:
            if (!(f = p.sent())) return [2, ""];
            s.push(ei(f, d.elementIds)), p.label = 3;
          case 3:
            return c++, [3, 1];
          case 4:
            return [4, Op[n].create(s, this.ctx, r.props, i)];
          case 5:
            return m = p.sent(), v = this.plugin.managers.cell.create({ representations: [{ state: m, isHidden: u != null && u, type: n }], model: { loci: s }, dependency: { on: a }, ref: o }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: createMeasurement" }), [2, v];
        }
      });
    });
  }, t.prototype.updateMeasurement = function(r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o, u, s, c, l, d, f = this;
      return ye(this, function(m) {
        switch (m.label) {
          case 0:
            return n = r.items, i = r.ref, a = r.params, o = this.plugin.cells.get(i), u = n.filter(function(v) {
              return Zr(f.plugin.cells.get(v.ref));
            }), s = u.map(function(v) {
              return ei(Zr(f.plugin.cells.get(v.ref)), v.elementIds);
            }), o ? (c = Array.from(o.representations)[0], l = c[0], d = c[1], l && d ? d.state ? [4, Op[l].update(d.state, s, a)] : [3, 2] : (console.error("There is no ".concat(l)), [2, !1])) : (console.warn("There is no ".concat(i)), [2, !1]);
          case 1:
            m.sent(), m.label = 2;
          case 2:
            return this.plugin.managers.cell.update(i, { model: { loci: s } }), [2, !0];
        }
      });
    });
  }, t.prototype.createStaticLabel = function(r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o, u, s, c, l, d, f, m;
      return ye(this, function(v) {
        switch (v.label) {
          case 0:
            n = r.theme, i = r.items, a = r.ref, o = r.isHidden, u = [], s = 0, c = i, v.label = 1;
          case 1:
            return s < c.length ? (l = c[s], [4, this.plugin.managers.cell.getStructure(l.item.ref)]) : [3, 4];
          case 2:
            if (!(d = v.sent())) return [2, ""];
            u.push({ loci: ei(d, l.item.elementIds), label: l.label }), v.label = 3;
          case 3:
            return s++, [3, 1];
          case 4:
            return [4, Op[Te.Label].create(u, this.ctx, r.props, n)];
          case 5:
            return f = v.sent(), m = this.plugin.managers.cell.create({ representations: [{ state: f, isHidden: o != null && o, type: Te.Label }], model: { loci: u.map(function(p) {
              return p.loci;
            }) }, dependency: { on: i.map(function(p) {
              return p.item;
            }) }, ref: a }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: createMeasurement" }), [2, m];
        }
      });
    });
  }, t.prototype.createOther = function(r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o, u, s, c, l, d, f, m, v, p, g, h, y;
      return ye(this, function(x) {
        switch (x.label) {
          case 0:
            return n = r.type, i = r.theme, a = r.data, o = r.ref, u = r.isHidden, s = u !== void 0 && u, c = r.serverData, l = r.params, a2[n] ? (d = a2[n]).parse ? [4, d.parse(a, this.plugin)] : [3, 2] : (console.warn("There is no ".concat(n, " type ")), [2]);
          case 1:
            return m = x.sent(), [3, 3];
          case 2:
            m = a, x.label = 3;
          case 3:
            return f = m, [4, d.create(f, this.ctx, d.createTheme ? d.createTheme(n === Te.IsoSurface ? f : a, this.plugin, i) : void 0, l)];
          case 4:
            return v = x.sent(), n === Te.Surface && (i != null && i.transparency) && v.setState({ transparency: this.createTransparencyLayers(f, [i == null ? void 0 : i.transparency]) }), p = this.plugin.managers.cell.create({ representations: [{ state: v, isHidden: s, type: n }], model: { other: c ? { serverData: c, data: a } : a }, theme: n === Te.Surface ? { color: (g = {}, g[At.SURFACE] = i != null && i.color ? [i == null ? void 0 : i.color] : [], g), transparency: (h = {}, h[At.SURFACE] = i != null && i.transparency ? [i == null ? void 0 : i.transparency] : [], h), size: (y = {}, y[At.SURFACE] = i != null && i.size ? [i == null ? void 0 : i.size] : [], y) } : void 0, ref: o, dependency: n === Te.Surface ? { on: [a] } : n === Te.MappingLine ? { on: a } : void 0 }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: createOther" }), [2, p];
        }
      });
    });
  }, t.prototype.updateOther = function(r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o, u, s;
      return ye(this, function(c) {
        switch (c.label) {
          case 0:
            return n = r.data, i = r.ref, (a = this.plugin.cells.get(i)) ? (o = Array.from(a.representations)[0], u = o[0], s = o[1], u && s ? [4, a2[u].update(s.state, n, this.ctx)] : (console.error("There is no ".concat(u)), [2, !1])) : (console.warn("There is no ".concat(i)), [2, !1]);
          case 1:
            return c.sent(), this.plugin.managers.cell.update(i, { model: { other: n } }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: updateOther" }), [2, !0];
        }
      });
    });
  }, t.prototype.addMolecularRepr = function(r, n) {
    var i;
    return _e(this, 0, void 0, function() {
      var a, o, u, s, c, l, d, f, m, v;
      return ye(this, function(p) {
        switch (p.label) {
          case 0:
            return a = n.elementIds, o = n.reprType, u = n.isHidden, s = n.theme, c = n.transparency, l = this.plugin.managers.cell.get(r), d = Zr(l), l && d ? (f = We([], a ?? [], !0), D1.has(o) && this.showPolarHydrogenOnly && (f = (a || qo(d)).filter(function(g) {
              return !np(d, g);
            })), m = $n(d, f, !0), [4, Du[o].create(m, this.ctx, s)]) : [2];
          case 1:
            return v = p.sent(), c && v.setState({ transparency: this.createTransparencyLayers(m, c) }), u || (i = this.plugin.canvas3d) === null || i === void 0 || i.add(v), l.representations.set(o, { state: v, isHidden: u, type: o }), this.plugin.managers.snapshot.event.changed.next({ from: "repr: addMolecularRepr" }), [2];
        }
      });
    });
  }, t.prototype.checkStructuresDisplayed = function(r, n) {
    var i, a = this.plugin.managers.cell.get(r.ref), o = Zr(a), u = new Set(n && !D1.has(n) || !this.showPolarHydrogenOnly ? r.elementIds : ((i = r.elementIds) !== null && i !== void 0 ? i : []).filter(function(s) {
      return !np(o, s);
    }));
    return (n ? [a.representations.get(n)] : Array.from(a.representations.values())).filter(function(s) {
      return (s == null ? void 0 : s.isHidden) !== !0 && (s == null ? void 0 : s.state);
    }).forEach(function(s) {
      var c, l, d;
      if (u.size) {
        var f = ha(s.state.getLoci());
        f && (!((d = (l = (c = f == null ? void 0 : f.elements) === null || c === void 0 ? void 0 : c[0]) === null || l === void 0 ? void 0 : l.unit) === null || d === void 0) && d.elements) && Gi(f).forEach(function(m) {
          return u.delete(m);
        });
      }
    }), u.size === 0;
  }, t.prototype.setMolecularRepr = function(r, n, i, a, o) {
    var u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _, S;
    return a === void 0 && (a = !0), o === void 0 && (o = !0), _e(this, 0, void 0, function() {
      var D, I, M, F, P, E, B, N, O, z, V, U, H, K, j, X, W, Q, te, ee, $ = this;
      return ye(this, function(ie) {
        switch (ie.label) {
          case 0:
            if (D = /* @__PURE__ */ new Map(), I = r.filter(function(ae) {
              return Zr($.plugin.managers.cell.get(ae.ref));
            }), M = !!a && I.every(function(ae) {
              return $.checkStructuresDisplayed(ae, n);
            }), F = Object.keys(xn).find(function(ae) {
              return xn[ae].includes(n);
            }), P = [], !M) return [3, 5];
            E = function(ae) {
              var se, le, pe;
              return ye(this, function(we) {
                switch (we.label) {
                  case 0:
                    return D.set(ae.ref, /* @__PURE__ */ new Set()), se = B.plugin.managers.cell.get(ae.ref), le = se.representations.get(n), pe = se.theme.color[F], [4, O6(le == null ? void 0 : le.state, (u = ae.elementIds) !== null && u !== void 0 ? u : [], n, function(Ge) {
                      var Ue;
                      return $.createTheme(n, Ge, { color: { name: "multi-theme", props: { themes: pe } }, size: se.theme.size && (!((Ue = se.theme.size[F]) === null || Ue === void 0) && Ue.length) ? se.theme.size[F][0] : $.defaultTheme.size[n] });
                    }, function(Ge) {
                      return $.createTransparencyLayers(Ge, se == null ? void 0 : se.theme.transparency[F]);
                    })];
                  case 1:
                    return we.sent(), (s = D.get(ae.ref)) === null || s === void 0 || s.add(n), se.dependency.by.length && P.push.apply(P, se.dependency.by), [2];
                }
              });
            }, B = this, N = 0, O = I, ie.label = 1;
          case 1:
            return N < O.length ? (K = O[N], [5, E(K)]) : [3, 4];
          case 2:
            ie.sent(), ie.label = 3;
          case 3:
            return N++, [3, 1];
          case 4:
            return [3, 9];
          case 5:
            z = function(ae) {
              var se, le, pe, we, Ge, Ue, Ke, Ze, Fe, Je, Ne, nt, re, J, ce, de, ve, he, Se;
              return ye(this, function(Re) {
                switch (Re.label) {
                  case 0:
                    if (D.set(ae.ref, /* @__PURE__ */ new Set()), se = V.plugin.managers.cell.get(ae.ref), le = se.representations.get(n), pe = Zr(se), we = se.theme.color[F], Ge = [], we == null || we.forEach(function(Ve) {
                      var ze;
                      Ge.push.apply(Ge, (ze = Ve.elementIds) !== null && ze !== void 0 ? ze : []);
                    }), Ue = new Set(Ge), (Ke = ((c = ae.elementIds) !== null && c !== void 0 ? c : []).filter(function(Ve) {
                      return !Ue.has(Ve);
                    })).length && (we == null || we.push(R({ elementIds: Ke }, V.defaultTheme.color[F])), se.theme.color = R(R({}, se.theme.color), ((Se = {})[F] = we, Se))), Ze = [], !i) return [3, 4];
                    Fe = function(Ve) {
                      var ze;
                      return ye(this, function(mt) {
                        switch (mt.label) {
                          case 0:
                            return !a && Ve.type !== Te.Ribbon && n !== Te.Ribbon && (ze = ag(Ve.state, (l = ae.elementIds) !== null && l !== void 0 ? l : [])).length ? (ae.elementIds = (d = ae.elementIds) === null || d === void 0 ? void 0 : d.filter(function(bt) {
                              return !ze.includes(bt);
                            }), [2, "continue"]) : Ve.type === n || Ve.type === Te.Ribbon || Ve.isHidden || Iie(Ve.state, (f = ae.elementIds) !== null && f !== void 0 ? f : []) === Bl.Not ? [2, "continue"] : (Ze.push.apply(Ze, ag(Ve == null ? void 0 : Ve.state, (m = ae.elementIds) !== null && m !== void 0 ? m : [])), [4, O6(Ve == null ? void 0 : Ve.state, (v = ae.elementIds) !== null && v !== void 0 ? v : [], Ve == null ? void 0 : Ve.type, function(bt) {
                              var Ct;
                              return $.createTheme(Ve == null ? void 0 : Ve.type, bt, { color: { name: "multi-theme", props: { themes: we } }, size: se.theme.size && (!((Ct = se.theme.size[F]) === null || Ct === void 0) && Ct.length) ? se.theme.size[F][0] : $.defaultTheme.size[Ve == null ? void 0 : Ve.type] });
                            }, function(bt) {
                              return $.createTransparencyLayers(bt, se == null ? void 0 : se.theme.transparency[F]);
                            })]);
                          case 1:
                            return mt.sent(), (p = D.get(ae.ref)) === null || p === void 0 || p.add(Ve.type), [2];
                        }
                      });
                    }, Je = 0, Ne = Array.from(se.representations), Re.label = 1;
                  case 1:
                    return Je < Ne.length ? (nt = Ne[Je], re = nt[1], [5, Fe(re)]) : [3, 4];
                  case 2:
                    Re.sent(), Re.label = 3;
                  case 3:
                    return Je++, [3, 1];
                  case 4:
                    return J = new Set(Ze), le ? (ce = (g = kg(le.state)) !== null && g !== void 0 ? g : [], de = $n(pe, Array.from(new Set(ce.concat(D1.has(n) && V.showPolarHydrogenOnly ? ((h = ae.elementIds) !== null && h !== void 0 ? h : []).filter(function(Ve) {
                      return J.has(Ve) || !np(pe, Ve);
                    }) : (y = ae.elementIds) !== null && y !== void 0 ? y : [])))), ve = V.createTransparencyLayers(de, se == null ? void 0 : se.theme.transparency[F]), [4, Du[n].update(le == null ? void 0 : le.state, de, V.ctx, V.createTheme(n, de, { color: { name: "multi-theme", props: { themes: we } }, size: se.theme.size && (!((x = se.theme.size[F]) === null || x === void 0) && x.length) ? se.theme.size[F][0] : V.defaultTheme.size[n] }))]) : [3, 6];
                  case 5:
                    return Re.sent(), (A = D.get(ae.ref)) === null || A === void 0 || A.add(n), le.state.setState({ transparency: ve }), [3, 8];
                  case 6:
                    return de = $n(pe, D1.has(n) && V.showPolarHydrogenOnly ? ae.elementIds.filter(function(Ve) {
                      return J.has(Ve) || !np(pe, Ve);
                    }) : ae.elementIds), ve = V.createTransparencyLayers(se == null ? void 0 : se.model.structure, se == null ? void 0 : se.theme.transparency[F]), [4, Du[n].create(de, V.plugin.managers.representation.ctx, V.createTheme(n, de, { color: { name: "multi-theme", props: { themes: we } }, size: se.theme.size && (!((b = se.theme.size[F]) === null || b === void 0) && b.length) ? se.theme.size[F][0] : V.defaultTheme.size[n] }))];
                  case 7:
                    he = Re.sent(), (_ = D.get(ae.ref)) === null || _ === void 0 || _.add(n), (S = V.plugin.canvas3d) === null || S === void 0 || S.add(he), he.setState({ transparency: ve }), se.representations.set(n, { state: he, isHidden: !1, type: n }), Re.label = 8;
                  case 8:
                    return se.dependency.by.length && P.push.apply(P, se.dependency.by), [2];
                }
              });
            }, V = this, U = 0, H = I, ie.label = 6;
          case 6:
            return U < H.length ? (K = H[U], [5, z(K)]) : [3, 9];
          case 7:
            ie.sent(), ie.label = 8;
          case 8:
            return U++, [3, 6];
          case 9:
            for (j = this.plugin.managers.selection.structure.getSelection(), D.forEach(function(ae, se) {
              var le;
              if (ae.size) {
                var pe = $.plugin.cells.get(se), we = (le = j[se]) !== null && le !== void 0 ? le : [];
                ae.forEach(function(Ge) {
                  var Ue, Ke = pe == null ? void 0 : pe.representations.get(Ge);
                  if (Ke) {
                    var Ze = ei(yo(Ke.state), we);
                    (Ue = $.plugin.canvas3d) === null || Ue === void 0 || Ue.mark({ loci: Ze, repr: Ke.state }, _t.Select);
                  }
                });
              }
            }), X = Array.from(new Set(P).values()), W = 0, Q = X; W < Q.length; W++) te = Q[W], (ee = this.plugin.cells.get(te)) && ee.representations.forEach(function(ae, se) {
              se === Te.IntraInteractions && o && $.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.representation.setMolecularRepr");
            });
            return this.plugin.managers.snapshot.event.changed.next({ from: "repr: setMolecularRepr" }), [2];
        }
      });
    });
  }, t.prototype.showOrHideHs = function(r, n, i) {
    var a = this, o = i ?? this.plugin.managers.selection.structure.getSelectionCellItems(), u = [];
    o.forEach(function(f) {
      var m = a.plugin.cells.get(f.ref);
      if (m) {
        var v = Zr(m);
        if (v) {
          f.elementIds || Object.assign(f, { elementIds: qo(v) });
          var p = f.elementIds.map(function(A) {
            return Gg(v, A);
          }), g = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
          m.representations.forEach(function(A, b) {
            if ([Te.BallAndStick, Te.CPK, Te.Stick, Te.Line].includes(b)) {
              var _ = ha(A.state.getLoci());
              if (!_) return;
              var S = Gi(_);
              h.set(b, We([], S, !0)), S.forEach(function(D) {
                g.set(D, b);
              });
            }
          });
          var y = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
          p.forEach(function(A, b) {
            var _;
            if (f.elementIds) {
              var S = f.elementIds[b], D = v.units.filter(function(I) {
                return qe.indexOf(I.elements, S) !== -1;
              })[0];
              (!n && A === bi.NonPolar || !r && A === bi.Polar) && g.has(S) ? y.has(g.get(S)) ? (_ = y.get(g.get(S))) === null || _ === void 0 || _.add(S) : y.set(g.get(S), /* @__PURE__ */ new Set([S])) : ((!n && A === bi.ConnectNonPolar || !r && A === bi.ConnectPolar) && $l(v, D, D.elements.indexOf(S), function(I, M) {
                var F;
                I.model.atomicHierarchy.derived.atom.atomicNumber[I.elements[M]] === 1 && g.has(I.elements[M]) && (y.has(g.get(S)) ? (F = y.get(g.get(S))) === null || F === void 0 || F.add(I.elements[M]) : y.set(g.get(S), /* @__PURE__ */ new Set([I.elements[M]])));
              }), !(n && A === bi.NonPolar || r && A === bi.Polar) || g.has(S) ? (n && A === bi.ConnectNonPolar || r && A === bi.ConnectPolar) && g.has(S) && $l(v, D, D.elements.indexOf(S), function(I, M) {
                var F;
                I.model.atomicHierarchy.derived.atom.atomicNumber[I.elements[M]] !== 1 || g.has(I.elements[M]) || (x.has(g.get(S)) ? (F = x.get(g.get(S))) === null || F === void 0 || F.add(I.elements[M]) : x.set(g.get(S), /* @__PURE__ */ new Set([I.elements[M]])));
              }) : $l(v, D, D.elements.indexOf(S), function(I, M) {
                var F;
                I.model.atomicHierarchy.derived.atom.atomicNumber[I.elements[M]] !== 1 && g.has(I.elements[M]) && (x.has(g.get(I.elements[M])) ? (F = x.get(g.get(I.elements[M]))) === null || F === void 0 || F.add(S) : x.set(g.get(I.elements[M]), /* @__PURE__ */ new Set([S])));
              }));
            }
          }), m.representations.forEach(function(A, b) {
            var _;
            if ([Te.BallAndStick, Te.CPK, Te.Stick, Te.Line].includes(b)) {
              var S = !1, D = h.get(b);
              if (y.has(b) && y.get(b).size > 0) {
                var I = y.get(b);
                D = D == null ? void 0 : D.filter(function(E) {
                  return !I.has(E);
                }), S = !0;
              }
              if (x.has(b) && x.get(b).size > 0) {
                var M = x.get(b);
                D = Array.from(new Set(We(We([], Array.from(M.values()), !0), D, !0))), S = !0;
              }
              if (S) {
                var F = $n(v, D), P = m.theme.color[At.ATOM];
                Du[b].update(A.state, F, a.ctx, a.createTheme(b, F, { color: { name: "multi-theme", props: { themes: P } }, size: m.theme.size && (!((_ = m.theme.size[At.ATOM]) === null || _ === void 0) && _.length) ? m.theme.size[At.ATOM][0] : a.defaultTheme.size[b] }));
              }
            }
          }), m.dependency.by.length && u.push.apply(u, m.dependency.by);
        }
      }
    });
    for (var s = 0, c = Array.from(new Set(u).values()); s < c.length; s++) {
      var l = c[s], d = this.plugin.cells.get(l);
      d && d.representations.forEach(function(f, m) {
        m === Te.IntraInteractions && a.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.representation.showOrHideHs");
      });
    }
  }, t.prototype.redraw = function() {
    var r = this;
    this.plugin.canvas3d && (this.plugin.canvas3d.clear(), Array.from(this.plugin.cells.values()).forEach(function(n) {
      n.representations.forEach(function(i) {
        var a;
        i.isHidden !== !0 && i.state && ((a = r.plugin.canvas3d) === null || a === void 0 || a.add(i.state));
      });
    }));
  }, t.prototype.updateBondThresholds = function(r) {
    var n = this, i = r.reduce(function(o, u) {
      var s;
      return R(R({}, o), ((s = {})[ZM(tm[u.atomA], tm[u.atomB])] = u.distance, s));
    }, {});
    Object.assign(WM, i), Object.assign(YM, i);
    var a = /* @__PURE__ */ new Set();
    this.plugin.managers.cell.traverse(function(o, u) {
      return _e(n, 0, void 0, function() {
        var s, c, l, d;
        return ye(this, function(f) {
          switch (f.label) {
            case 0:
              return a.has(o.ref) || !o.model.structure ? [2] : (s = o.assets[0], c = s.format, l = s.data, [4, Fc[c].parse(l)]);
            case 1:
              return d = f.sent(), this.plugin.managers.editor.coverStructure(o.ref, d[0], o.assets[0]), a.add(o.ref), [2];
          }
        });
      });
    });
  }, t;
}(lae), U5 = ((Vv = {})[At.ATOM] = [], Vv[At.RIBBON] = [], Vv[At.SURFACE] = [], Vv), JD = function() {
  function e(t) {
    var r, n = this;
    this.plugin = t, (r = this.plugin.canvas3d) === null || r === void 0 || r.reprCount.subscribe(function(i) {
      if (i > 100 && n.idleCellSet.size) {
        var a = Array.from(n.idleCellSet.values())[0];
        n.idleCellSet.delete(a), n.clearReprState(a);
      }
    }), this.idleCellSet = /* @__PURE__ */ new Set();
  }
  return e.prototype.get = function(t) {
    var r = this.plugin.cells.get(t);
    if (r) return r;
    console.error("no ".concat(t, " cell"));
  }, e.prototype.getHierarchy = function(t) {
    var r = this, n = this.get(t);
    if (!(n != null && n.model.structure)) return console.error("".concat(t, " cell does not have structure")), { data: { polymer: {}, water: {}, otherSolvent: {}, metal: {}, ion: {}, ligand: {}, other: {} }, extraData: { sequenceData: {} } };
    var i = [], a = [];
    n.dependency.by.forEach(function(u) {
      var s, c, l;
      if (r.plugin.cells.has(u)) {
        var d = r.get(u);
        d && (d.representations.has(Te.Label) && a.push({ ref: u, dependencies: We([], d.dependency.on, !0), label: ((c = (s = d.representations.get(Te.Label)) === null || s === void 0 ? void 0 : s.state) !== null && c !== void 0 ? c : (l = d.representations.get(Te.Label)) === null || l === void 0 ? void 0 : l.cache).props.customText }), d.representations.has(Te.Surface) && i.push({ ref: u, dependencies: We([], d.dependency.on, !0) }));
      }
    });
    var o = GP(n.model.structure);
    return R(R({}, o), { extraData: R(R({}, o.extraData), { label: a, surface: i }) });
  }, e.prototype.getSequence = function(t) {
    return _e(this, 0, void 0, function() {
      var r;
      return ye(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, this.getStructure(t)];
          case 1:
            return (r = n.sent()) ? [2, XJ(r)] : [2];
        }
      });
    });
  }, e.prototype.getStructure = function(t) {
    var r;
    return _e(this, 0, void 0, function() {
      var n, i, a, o, u, s, c, l;
      return ye(this, function(d) {
        switch (d.label) {
          case 0:
            return (n = this.get(t)) ? (i = Zr(n)) ? [2, i] : i || !(!((r = n.assets) === null || r === void 0) && r.length) ? [3, 5] : (a = n.assets[0], o = a.data, u = a.format, l = (c = Fc[u]).parse, [4, of(o)]) : [2];
          case 1:
            return [4, l.apply(c, [d.sent()])];
          case 2:
            return s = d.sent()[0], u !== mr.Pdb || !s.elementCount || nn.hasSecondaryStructure(s == null ? void 0 : s.model) ? [3, 4] : [4, Aa.attach({}, s, { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } }, !0)];
          case 3:
            d.sent(), d.label = 4;
          case 4:
            return this.update(t, { model: { structure: s } }), [2, s];
          case 5:
            return [2];
        }
      });
    });
  }, e.prototype.getLoci = function(t) {
    return _e(this, 0, void 0, function() {
      var r;
      return ye(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, this.getStructure(t.ref)];
          case 1:
            return (r = n.sent()) ? [2, ei(r, t.elementIds)] : [2, vn];
        }
      });
    });
  }, e.prototype.getMolecularName = function(t) {
    var r, n, i, a, o, u, s = this.get(t);
    if (!s.model.structure) return !((r = s.assets) === null || r === void 0) && r.length && ["sdf", "mol"].includes(s.assets[0].format) ? "".concat(s.assets[0].data).split(`
`)[0] : "";
    var c = ((i = (n = s.model.structure) === null || n === void 0 ? void 0 : n.state.model) !== null && i !== void 0 ? i : !((a = s.model.structure) === null || a === void 0) && a.state.models) ? (o = s.model.structure) === null || o === void 0 ? void 0 : o.state.models[0] : void 0;
    if (!c) return "";
    var l = (u = c.sourceData) === null || u === void 0 ? void 0 : u.kind;
    return l === "sdf" || l === "mol" ? c.entryId : "";
  }, e.prototype.isFromPdb = function(t) {
    var r, n = this.plugin.cells.get(t);
    if (!n) return !1;
    var i = Zr(n);
    return !!i && ((r = Ko(i)) === null || r === void 0 ? void 0 : r.sourceData.kind) === "mmCIF";
  }, e.prototype.getCellPdbId = function(t) {
    if (!this.isFromPdb(t)) return "";
    var r = this.plugin.cells.get(t);
    if (!r) return "";
    var n = Zr(r);
    if (!n) return "";
    var i = "";
    if (this.plugin.managers.cell.isFromPdb(t)) {
      for (var a = Q_(n, ["HEADER"]), o = 0, u = a.length; o < u && !i; o++) if (a[o].startsWith("HEADER") && a[o].length >= 66) {
        var s = a[o].slice(62, 66).replace(" ", "");
        s.length === 4 && /^[A-Za-z0-9]*$/.test(s) && (i = s);
      }
    }
    return i;
  }, e.prototype.getMeasurementName = function(t, r) {
    var n, i, a = this.get(t);
    if (!a.representations.get(r)) return console.warn("There is no ".concat(r, " in ").concat(t, " cell"));
    var o = ((i = (n = a.model) === null || n === void 0 ? void 0 : n.loci) !== null && i !== void 0 ? i : []).map(function(u) {
      return Hr.getCenter(u);
    });
    return r === Te.Distance ? "".concat(w.distance(o[0], o[1]).toFixed(2), "Å") : r === Te.Angle ? "".concat(xa(w.angle(w.sub(w(), o[0], o[1]), w.sub(w(), o[2], o[1]))).toFixed(2), "°") : r === Te.Dihedral ? "".concat(xa(w.dihedralAngle(o[0], o[1], o[2], o[3])).toFixed(2), "°") : "";
  }, e.prototype.create = function(t) {
    var r, n, i = this, a = t.representations, o = t.model, u = t.assets, s = t.dependency, c = t.ref, l = t.theme, d = c ?? Ii.create22(), f = /* @__PURE__ */ new Map();
    return a.forEach(function(m) {
      var v;
      !m.isHidden && m.state && ((v = i.plugin.canvas3d) === null || v === void 0 || v.add(m.state)), f.set(m.type, m);
    }), this.plugin.cells.set(d, { ref: d, representations: f, dependency: R({ on: [], by: [] }, s), theme: { color: R(R({}, U5), l == null ? void 0 : l.color), size: R(R({}, U5), l == null ? void 0 : l.size), transparency: R(R({}, U5), l == null ? void 0 : l.transparency) }, assets: u, model: o }), !((r = s == null ? void 0 : s.on) === null || r === void 0) && r.length && Array.from(new Set(s == null ? void 0 : s.on)).forEach(function(m) {
      i.addDependency(m.ref, { by: [d] });
    }), !((n = s == null ? void 0 : s.by) === null || n === void 0) && n.length && Array.from(new Set(s == null ? void 0 : s.by)).forEach(function(m) {
      i.addDependency(m, { on: [{ ref: d }] });
    }), this.plugin.managers.snapshot.event.changed.next({ from: "cell:create" }), d;
  }, e.prototype.createEmptyMolecularCell = function(t) {
    var r, n, i, a;
    return _e(this, 0, void 0, function() {
      var o, u, s, c;
      return ye(this, function(l) {
        switch (l.label) {
          case 0:
            return o = zs(), [4, JB.create(o, this.plugin.managers.representation.ctx)];
          case 1:
            return u = l.sent(), [2, this.create({ representations: [{ state: u, isHidden: !1, type: Te.BallAndStick }], model: { structure: o }, assets: [{ format: mr.Sdf, data: "" }], theme: { transparency: (s = {}, s[At.ATOM] = t && (!((r = t[At.ATOM]) === null || r === void 0) && r.transparency) ? [(n = t[At.ATOM]) === null || n === void 0 ? void 0 : n.transparency] : [], s[At.RIBBON] = [], s[At.SURFACE] = [], s), size: (c = {}, c[At.ATOM] = t && (!((i = t[At.ATOM]) === null || i === void 0) && i.size) ? [(a = t[At.ATOM]) === null || a === void 0 ? void 0 : a.size] : [], c[At.RIBBON] = [], c[At.SURFACE] = [], c) } })];
        }
      });
    });
  }, e.prototype.copyMolecular = function(t, r) {
    var n, i, a, o, u, s;
    return _e(this, 0, void 0, function() {
      var c, l, d, f, m, v;
      return ye(this, function(p) {
        switch (p.label) {
          case 0:
            c = [], l = function(g) {
              var h, y, x, A, b, _, S, D, I, M, F, P, E;
              return ye(this, function(B) {
                switch (B.label) {
                  case 0:
                    return h = d.get(g.ref), [4, d.getStructure(g.ref)];
                  case 1:
                    return y = B.sent(), x = [], (A = $n(y, (n = g.elementIds) !== null && n !== void 0 ? n : [], !0, !0)).elementCount ? [4, Aa.attach({}, A, void 0, !0)] : [3, 3];
                  case 2:
                    B.sent(), B.label = 3;
                  case 3:
                    return b = Qu(A), g.representationType ? (_ = Object.keys(xn).find(function(N) {
                      return xn[N].includes(g.representationType);
                    }), [4, Du[g.representationType].create(A, d.plugin.managers.representation.ctx, d.plugin.managers.representation.createTheme(g.representationType, A, { color: { name: "multi-theme", props: { themes: h.theme.color[_] } }, size: h.theme.size && (!((i = h.theme.size[_]) === null || i === void 0) && i.length) ? h.theme.size[_][0] : d.plugin.managers.representation.defaultTheme.size[g.representationType] }))]) : [3, 5];
                  case 4:
                    return S = B.sent(), x.push({ state: S, isHidden: (a = r == null ? void 0 : r.isHidden) === null || a === void 0 || a, type: g.representationType }), [3, 9];
                  case 5:
                    D = function(N, O) {
                      var z, V, U;
                      return ye(this, function(H) {
                        switch (H.label) {
                          case 0:
                            return z = Object.keys(xn).find(function(K) {
                              return xn[K].includes(N);
                            }), !(!((o = g.elementIds) === null || o === void 0) && o.length) || ag(O.state, g.elementIds).length ? (V = $n(O.state ? yo(O.state) : $n(A, O.cache.elementIds, !0), (u = g.elementIds) !== null && u !== void 0 ? u : [], !0, b), [4, Du[N].create(V, d.plugin.managers.representation.ctx, d.plugin.managers.representation.createTheme(N, V, { color: { name: "multi-theme", props: { themes: h.theme.color[z] } }, size: d.plugin.managers.representation.defaultTheme.size[N] }))]) : [3, 2];
                          case 1:
                            U = H.sent(), x.push({ state: U, isHidden: (s = r == null ? void 0 : r.isHidden) === null || s === void 0 || s, type: N }), H.label = 2;
                          case 2:
                            return [2];
                        }
                      });
                    }, I = 0, M = Array.from(h.representations), B.label = 6;
                  case 6:
                    return I < M.length ? (F = M[I], P = F[0], E = F[1], [5, D(P, E)]) : [3, 9];
                  case 7:
                    B.sent(), B.label = 8;
                  case 8:
                    return I++, [3, 6];
                  case 9:
                    return c.push(d.create({ representations: x, model: { structure: A }, assets: h.assets, theme: R({}, h.theme) })), [2];
                }
              });
            }, d = this, f = 0, m = t, p.label = 1;
          case 1:
            return f < m.length ? (v = m[f], [5, l(v)]) : [3, 4];
          case 2:
            p.sent(), p.label = 3;
          case 3:
            return f++, [3, 1];
          case 4:
            return this.plugin.managers.snapshot.event.changed.next({ from: "cell:copyMolecular" }), [2, c];
        }
      });
    });
  }, e.prototype.update = function(t, r) {
    var n, i, a, o, u, s, c, l = this, d = this.plugin.managers.cell.get(t);
    d.model = Object.assign(d.model, r.model), r.theme && (d.theme = { color: R(R({}, d.theme.color), r.theme.color), size: R(R({}, d.theme.size), r.theme.size), transparency: R(R({}, d.theme.transparency), r.theme.transparency) }), !((n = r.representations) === null || n === void 0) && n.length && r.representations.forEach(function(f) {
      var m;
      d.representations.set(f.type, Object.assign((m = d.representations.get(f.type)) !== null && m !== void 0 ? m : {}, f));
    }), !((a = (i = r.dependency) === null || i === void 0 ? void 0 : i.on) === null || a === void 0) && a.length && (this.removeDependency(t, { on: d.dependency.on }), Array.from(new Set((o = r.dependency) === null || o === void 0 ? void 0 : o.on)).forEach(function(f) {
      l.addDependency(f.ref, { by: [t] });
    })), !((s = (u = r.dependency) === null || u === void 0 ? void 0 : u.by) === null || s === void 0) && s.length && (this.removeDependency(t, { by: d.dependency.by }), Array.from(new Set((c = r.dependency) === null || c === void 0 ? void 0 : c.by)).forEach(function(f) {
      l.addDependency(f, { on: [{ ref: t }] });
    })), d.dependency = R(R({}, d.dependency), r.dependency), r.assets && (d.assets = r.assets), this.plugin.managers.snapshot.event.changed.next({ from: "cell:update" });
  }, e.prototype.remove = function(t, r) {
    var n, i;
    return _e(this, 0, void 0, function() {
      var a, o, u, s, c, l, d, f = this;
      return ye(this, function(m) {
        switch (m.label) {
          case 0:
            a = "", o = /* @__PURE__ */ new Map(), u = function(v) {
              var p, g, h, y, x, A, b, _, S, D, I, M;
              return ye(this, function(F) {
                switch (F.label) {
                  case 0:
                    return s.plugin.cells.has(v.ref) ? (p = s.get(v.ref), [4, s.getStructure(v.ref)]) : [2, "continue"];
                  case 1:
                    if (g = F.sent(), v.ref && g && s.plugin.managers.selection.structure.remove({ item: { ref: v.ref, elementIds: (n = v.elementIds) !== null && n !== void 0 ? n : qo(g) } }), o.has(v.ref) && o.get(v.ref) !== void 0 ? o.set(v.ref, v.elementIds === void 0 ? void 0 : We(We([], v.elementIds, !0), o.get(v.ref), !0)) : o.set(v.ref, v.elementIds), r) p.representations.forEach(function(P) {
                      var E, B;
                      if (u0.has(P.type) && p.dependency.on.length) {
                        var N = p.dependency.on.some(function(O) {
                          return Eie(O, r);
                        });
                        N && (!P.isHidden && P.state && ((E = f.plugin.canvas3d) === null || E === void 0 || E.remove(P.state)), p.representations.delete(P.type));
                      }
                      P.type === Te.Surface && (r.elementIds || (P.state && ((B = f.plugin.canvas3d) === null || B === void 0 || B.remove(P.state)), p.representations.delete(P.type)));
                    });
                    else if (!((i = v == null ? void 0 : v.elementIds) === null || i === void 0) && i.length) {
                      for (h = function(P, E) {
                        var B = Object.keys(xn).find(function(N) {
                          return xn[N].includes(P);
                        });
                        O6(E.state, v.elementIds, P, function(N) {
                          var O;
                          return f.plugin.managers.representation.createTheme(P, N, { color: { name: "multi-theme", props: { themes: p.theme.color[B] } }, size: p.theme.size && (!((O = p.theme.size[B]) === null || O === void 0) && O.length) ? p.theme.size[B][0] : f.plugin.managers.representation.defaultTheme.size[E.type] });
                        }, function(N) {
                          var O;
                          return f.plugin.managers.representation.createTransparencyLayers(N, We([], (O = p == null ? void 0 : p.theme.transparency[B]) !== null && O !== void 0 ? O : [], !0));
                        });
                      }, y = 0, x = Array.from(p.representations); y < x.length; y++) A = x[y], b = A[0], _ = A[1], h(b, _);
                      g && (p.model.structure = rB(g, v.elementIds));
                    } else p.representations.forEach(function(P) {
                      var E;
                      !P.isHidden && P.state && ((E = f.plugin.canvas3d) === null || E === void 0 || E.remove(P.state)), p.representations.delete(P.type);
                    });
                    if (!p.dependency.by.length) return [3, 6];
                    S = 0, D = Array.from(new Set(p.dependency.by)), F.label = 2;
                  case 2:
                    return S < D.length ? (I = D[S], (M = s.plugin.cells.get(I)) != null && M.representations.has(Te.IntraInteractions) ? (a = I, [3, 5]) : [3, 3]) : [3, 6];
                  case 3:
                    return [4, s.remove([{ ref: I }], v)];
                  case 4:
                    F.sent(), F.label = 5;
                  case 5:
                    return S++, [3, 2];
                  case 6:
                    return p.representations.size || (p.dependency.on.length && Array.from(new Set(p.dependency.on)).forEach(function(P) {
                      var E = f.plugin.cells.get(P.ref);
                      if (E) {
                        var B = E.dependency.by.findIndex(function(N) {
                          return N === v.ref;
                        });
                        B !== -1 && E.dependency.by.splice(B, 1);
                      }
                    }), s.plugin.cells.delete(v.ref)), [2];
                }
              });
            }, s = this, c = 0, l = t, m.label = 1;
          case 1:
            return c < l.length ? (d = l[c], [5, u(d)]) : [3, 4];
          case 2:
            m.sent(), m.label = 3;
          case 3:
            return c++, [3, 1];
          case 4:
            return a && this.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.cell.remove"), this.plugin.managers.snapshot.event.changed.next({ from: "cell:remove" }), [2];
        }
      });
    });
  }, e.prototype.extractMolecular = function(t, r) {
    var n, i, a, o, u;
    return _e(this, 0, void 0, function() {
      var s, c, l, d, f, m, v, p, g, h, y, x, A, b, _, S;
      return ye(this, function(D) {
        switch (D.label) {
          case 0:
            s = [], c = 0, l = t, D.label = 1;
          case 1:
            return c < l.length ? (d = l[c], f = this.get(d.ref), [4, this.getStructure(d.ref)]) : [3, 8];
          case 2:
            m = D.sent(), v = $n(m, (n = d.elementIds) !== null && n !== void 0 ? n : [], !0, !0), p = !((i = f.assets) === null || i === void 0) && i.length && (!((a = f.assets[0]) === null || a === void 0) && a.format) ? f.assets[0].format : mr.Pdb, g = [], h = function(I, M) {
              var F, P, E, B;
              return ye(this, function(N) {
                switch (N.label) {
                  case 0:
                    return F = Object.keys(xn).find(function(O) {
                      return xn[O].includes(I);
                    }), (P = ag(M.state, d.elementIds)).length ? (E = $n(v, P), [4, Du[I].create(E, y.plugin.managers.representation.ctx, y.plugin.managers.representation.createTheme(I, E, { color: { name: "multi-theme", props: { themes: f.theme.color[F] } }, size: f.theme.size && (!((o = f.theme.size[F]) === null || o === void 0) && o.length) ? f.theme.size[F][0] : y.plugin.managers.representation.defaultTheme.size[M.type] }))]) : [3, 2];
                  case 1:
                    B = N.sent(), g.push({ state: B, isHidden: (u = r == null ? void 0 : r.isHidden) === null || u === void 0 || u, type: I }), N.label = 2;
                  case 2:
                    return [2];
                }
              });
            }, y = this, x = 0, A = Array.from(f.representations), D.label = 3;
          case 3:
            return x < A.length ? (b = A[x], _ = b[0], S = b[1], [5, h(_, S)]) : [3, 6];
          case 4:
            D.sent(), D.label = 5;
          case 5:
            return x++, [3, 3];
          case 6:
            s.push(this.create({ representations: g, model: { structure: v }, assets: [{ format: p, data: zg(v, p) }], theme: R({}, f.theme) })), this.remove([d]), D.label = 7;
          case 7:
            return c++, [3, 1];
          case 8:
            return this.plugin.managers.snapshot.event.changed.next({ from: "cell:extractMolecular" }), [2, s];
        }
      });
    });
  }, e.prototype.addDependency = function(t, r) {
    var n, i, a = this.get(t);
    !((n = r.on) === null || n === void 0) && n.length && (a.dependency.on = a.dependency.on.concat(r.on)), !((i = r.by) === null || i === void 0) && i.length && (a.dependency.by = Array.from(new Set(a.dependency.by.concat(r.by))));
  }, e.prototype.removeDependency = function(t, r) {
    var n, i, a = this;
    !((n = r.on) === null || n === void 0) && n.length && r.on.forEach(function(o) {
      a.plugin.cells.has(o.ref) && (a.get(o.ref).dependency.by = a.get(o.ref).dependency.by.filter(function(u) {
        return u !== t;
      }));
    }), !((i = r.by) === null || i === void 0) && i.length && r.by.forEach(function(o) {
      a.plugin.cells.has(o) && (a.get(o).dependency.on = a.get(o).dependency.on.filter(function(u) {
        return u.ref !== t;
      }));
    });
  }, e.prototype.query = function(t) {
    var r = [];
    return this.plugin.cells.forEach(function(n) {
      n.representations.forEach(function(i) {
        t(n, i) && r.push(n);
      });
    }), r;
  }, e.prototype.traverse = function(t) {
    this.plugin.cells.forEach(function(r) {
      r.representations.forEach(function(n) {
        t(r, n);
      });
    });
  }, e.prototype.getAllDisplayedCellsRef = function() {
    var t = /* @__PURE__ */ new Set();
    return this.plugin.managers.cell.traverse(function(r, n) {
      [Te.Ribbon, Te.BallAndStick, Te.Line, Te.Stick, Te.CPK].includes(n.type) && !n.isHidden && Zr(r) && t.add(r.ref);
    }), Array.from(t.values());
  }, e.prototype.clearReprState = function(t) {
    var r = this, n = this.get(t), i = /* @__PURE__ */ new Map(), a = n.model.structure;
    if (a) {
      if (a) {
        var o = 0;
        a.units.forEach(function(u) {
          u.elements.forEach(function(s) {
            i.set(s, o++);
          });
        });
      }
      Array.from(n.representations.entries()).forEach(function(u) {
        var s;
        u[0];
        var c = u[1];
        c.state && ((s = r.plugin.canvas3d) === null || s === void 0 || s.remove(c.state), n.representations.set(c.type, { isHidden: c.isHidden, type: c.type, cache: { type: c.type, elementIds: kg(c.state).map(function(l) {
          return i && (i != null && i.has(l)) ? i == null ? void 0 : i.get(l) : l;
        }), isHidden: c.isHidden, params: u0.has(c.type) ? qF(c.type, c.state) : void 0 } }));
      });
    }
  }, e.prototype.recoveryCache = function(t, r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o, u;
      return ye(this, function(s) {
        switch (s.label) {
          case 0:
            return n = this.get(t), i = Array.from(n.representations.values()), r ? [4, this.recoveryReprCache(n, r)] : [3, 2];
          case 1:
            s.sent(), s.label = 2;
          case 2:
            a = 0, o = i, s.label = 3;
          case 3:
            return a < o.length ? (u = o[a]).cache ? [4, this.recoveryReprCache(n, u.cache)] : [3, 5] : [3, 6];
          case 4:
            s.sent(), s.label = 5;
          case 5:
            return a++, [3, 3];
          case 6:
            return [2];
        }
      });
    });
  }, e.prototype.recoveryReprCache = function(t, r) {
    var n, i;
    return _e(this, 0, void 0, function() {
      var a, o, u, s;
      return ye(this, function(c) {
        switch (c.label) {
          case 0:
            return [4, this.getStructure(t.ref)];
          case 1:
            return (a = c.sent()) ? (o = Object.keys(xn).find(function(l) {
              return xn[l].includes(r.type);
            }), u = t.theme.color[o], s = t.theme.transparency ? t.theme.transparency[o] : void 0, [4, this.plugin.managers.representation.addMolecularRepr(t.ref, { reprType: r.type, elementIds: r.elementIds, isHidden: r.isHidden, theme: this.plugin.managers.representation.createTheme(r.type, $n(a, (n = r.elementIds) !== null && n !== void 0 ? n : [], !0), { color: { name: "multi-theme", props: { themes: u } }, size: t.theme.size && (!((i = t.theme.size[o]) === null || i === void 0) && i.length) ? t.theme.size[o][0] : this.plugin.managers.representation.defaultTheme.size[r.type] }), transparency: s })]) : [2];
          case 2:
            return c.sent(), [2];
        }
      });
    });
  }, e.prototype.overlapLigands = function(t, r, n) {
    return _e(this, 0, void 0, function() {
      var i, a, o, u, s, c, l, d, f, m, v;
      return ye(this, function(p) {
        switch (p.label) {
          case 0:
            return i = function(g) {
              var h = ot(g), y = ot.readLine(h).trim(), x = ot.readLine(h).trim(), A = ot.readLine(h).trim(), b = ot.readLine(h), _ = +b.substr(0, 3), S = +b.substr(3, 3);
              return { title: y, program: x, comment: A, atoms: Y_(h, _), bonds: W_(h, S), formalCharges: Z_(h) };
            }(n), a = [Array.from(i.atoms.x.toArray()).reduce(function(g, h) {
              return g + h;
            }) / i.atoms.count, Array.from(i.atoms.y.toArray()).reduce(function(g, h) {
              return g + h;
            }) / i.atoms.count, Array.from(i.atoms.z.toArray()).reduce(function(g, h) {
              return g + h;
            }) / i.atoms.count], [4, this.getStructure(t)];
          case 1:
            for (o = p.sent(), u = ei(o, r), s = Xe.getBoundary(u).sphere.center, c = [s[0] - a[0], s[1] - a[1], s[2] - a[2]], l = [], d = /* @__PURE__ */ new Map(), m = 0, v = i.formalCharges.atomIdx.rowCount; m < v; m++) d.set(i.formalCharges.atomIdx.value(m) - 1, i.formalCharges.charge.value(m));
            for (m = 0, v = i.atoms.count; m < v; m++) l.push({ x: i.atoms.x.value(m) + c[0], y: i.atoms.y.value(m) + c[1], z: i.atoms.z.value(m) + c[2], type_symbol: i.atoms.type_symbol.value(m), charge: d.get(m) || 0 });
            for (f = [], m = 0, v = i.bonds.count; m < v; m++) f.push({ a: i.bonds.atomIdxA.value(m), b: i.bonds.atomIdxB.value(m), order: i.bonds.order.value(m) });
            return [2, { atoms: l, bonds: f }];
        }
      });
    });
  }, e.prototype.getUnitCellData = function(t) {
    var r = this.get(t);
    if (r) {
      var n = Zr(r);
      return Pie(n);
    }
  }, e;
}(), A1 = { createByTrajectory: function(e, t) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o, u, s, c, l, d, f, m, v, p;
    return ye(this, function(g) {
      switch (g.label) {
        case 0:
          return r = e.trajectory, n = e.frameIndex, i = e.mode, a = r, o = tt.ofModel(a.getFrameAtIndex(n)), u = [], i !== Jd.Drug ? [3, 7] : (s = g6(o), c = s.polymer, l = s.other, c.length ? (d = $n(o, c)).elementCount ? [4, Aa.attach({ runtime: Ho, assetManager: new bc() }, d, { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } })] : [3, 2] : [3, 4]);
        case 1:
          g.sent(), g.label = 2;
        case 2:
          return (f = vc.factory(t, vc.getParams)).setTheme({ color: t.colorThemeRegistry.create("uniform", { structure: d }, { value: He(14474728) }), size: t.sizeThemeRegistry.create("uniform", { structure: d }) }), [4, f.createOrUpdate(R(R({}, vc.defaultValues), { quality: "auto" }), d).run()];
        case 3:
          g.sent(), u.push({ state: f, type: Te.Ribbon }), g.label = 4;
        case 4:
          return l.length ? (m = $n(o, l), (v = Ya.factory(t, Ya.getParams)).setTheme({ color: t.colorThemeRegistry.create("element-symbol", { structure: m }, { carbonColor: { name: "uniform", params: { value: He(14474728) } } }), size: t.sizeThemeRegistry.create("physical", { structure: m }) }), [4, v.createOrUpdate(R(R({}, Ya.defaultValues), { quality: "auto" }), m).run()]) : [3, 6];
        case 5:
          g.sent(), u.push({ state: v, type: Te.BallAndStick }), g.label = 6;
        case 6:
          return [3, 9];
        case 7:
          return (p = Ya.factory(t, Ya.getParams)).setTheme({ color: t.colorThemeRegistry.create("material-element-symbol", { structure: o }), size: t.sizeThemeRegistry.create("physical", { structure: o }) }), [4, p.createOrUpdate(R(R({}, Ya.defaultValues), { quality: "auto" }), o).run()];
        case 8:
          g.sent(), u.push({ state: p, type: Te.BallAndStick }), g.label = 9;
        case 9:
          return [2, { model: a, reprs: u }];
      }
    });
  });
}, create: function(e, t) {
  return _e(this, 0, void 0, function() {
    var r, n, i, a, o, u, s, c, l, d, f, m, v, p, g;
    return ye(this, function(h) {
      switch (h.label) {
        case 0:
          return r = e.model, n = e.coordinates, i = e.frameIndex, a = e.mode, o = nn.trajectoryFromModelAndCoordinates(r, n), u = tt.ofModel(o.getFrameAtIndex(i)), s = [], a !== Jd.Drug ? [3, 7] : (c = g6(u), l = c.polymer, d = c.other, l.length ? (f = $n(u, l)).elementCount ? [4, Aa.attach({ runtime: Ho, assetManager: new bc() }, f, { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } })] : [3, 2] : [3, 4]);
        case 1:
          h.sent(), h.label = 2;
        case 2:
          return (m = vc.factory(t, vc.getParams)).setTheme({ color: t.colorThemeRegistry.create("uniform", { structure: f }, { value: He(14474728) }), size: t.sizeThemeRegistry.create("uniform", { structure: f }) }), [4, m.createOrUpdate(R(R({}, vc.defaultValues), { quality: "auto" }), f).run()];
        case 3:
          h.sent(), s.push({ state: m, type: Te.Ribbon }), h.label = 4;
        case 4:
          return d.length ? (v = $n(u, d), (p = Ya.factory(t, Ya.getParams)).setTheme({ color: t.colorThemeRegistry.create("element-symbol", { structure: v }, { carbonColor: { name: "uniform", params: { value: He(14474728) } } }), size: t.sizeThemeRegistry.create("physical", { structure: v }) }), [4, p.createOrUpdate(R(R({}, Ya.defaultValues), { quality: "auto" }), v).run()]) : [3, 6];
        case 5:
          h.sent(), s.push({ state: p, type: Te.BallAndStick }), h.label = 6;
        case 6:
          return [3, 9];
        case 7:
          return (g = Ya.factory(t, Ya.getParams)).setTheme({ color: t.colorThemeRegistry.create("material-element-symbol", { structure: u }), size: t.sizeThemeRegistry.create("physical", { structure: u }) }), [4, g.createOrUpdate(R(R({}, Ya.defaultValues), { quality: "auto" }), u).run()];
        case 8:
          h.sent(), s.push({ state: g, type: Te.BallAndStick }), h.label = 9;
        case 9:
          return [2, { model: o, reprs: s }];
      }
    });
  });
}, update: function(e, t, r) {
  return _e(this, 0, void 0, function() {
    var n, i, a, o;
    return ye(this, function(u) {
      switch (u.label) {
        case 0:
          return n = t.trajectory, i = t.frameIndex, a = t.mode, (o = tt.ofModel(n.getFrameAtIndex(i))).elementCount ? [4, Aa.attach({ runtime: Ho, assetManager: new bc() }, o, { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } })] : [3, 2];
        case 1:
          u.sent(), u.label = 2;
        case 2:
          return [4, Promise.all(e.map(function(s) {
            var c = Object.keys(xn).find(function(f) {
              return xn[f].includes(s.type);
            }), l = Xe.toExpression(tt.toStructureElementLoci(s.getLoci().structure)), d = c0(s0(o, l));
            s.setTheme({ color: r.colorThemeRegistry.create(a === Jd.Drug ? c === At.RIBBON ? "uniform" : "element-symbol" : "material-element-symbol", { structure: d }, a === Jd.Drug ? c === At.RIBBON ? { value: He(14474728) } : { carbonColor: { name: "uniform", params: { value: He(14474728) } } } : {}), size: r.sizeThemeRegistry.create(c === At.RIBBON ? "uniform" : "physical", { structure: d }, s.theme.size.props) }), s.createOrUpdate({}, d).run();
          }))];
        case 3:
          return u.sent(), [2];
      }
    });
  });
} }, $D = function() {
  function e(t) {
    this.ev = ro.create(), this.updated = this.ev(), this.plugin = t, this.paused = !1;
  }
  return e.prototype.import = function(t, r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o, u, s;
      return ye(this, function(c) {
        switch (c.label) {
          case 0:
            return [4, of(t.data)];
          case 1:
            return n = c.sent(), [4, Fc[t.format].parse(n)];
          case 2:
            return i = c.sent(), [4, zJ(r.data)];
          case 3:
            return a = c.sent(), [4, Fc[r.format].parse(a)];
          case 4:
            return o = c.sent(), [4, A1.create({ model: t.format === mr.Gro ? i : i[0].model, coordinates: o, frameIndex: 0, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)];
          case 5:
            return u = c.sent(), s = Gi(tt.toStructureElementLoci(t.format === mr.Gro ? tt.ofModel(u.model.frames[0], { dynamicBonds: !0 }) : i[0])), [2, this.plugin.managers.cell.create({ representations: u.reprs.map(function(l) {
              return R({ isHidden: !1 }, l);
            }), model: { trajectory: { state: u.model, frameIndex: 0 } }, assets: [{ data: n, format: t.format }, { data: a, format: r.format }], theme: { color: { Atom: [R({ elementIds: s }, this.plugin.managers.representation.defaultTheme.color[At.ATOM])], Ribbon: [R({ elementIds: s }, this.plugin.managers.representation.defaultTheme.color[At.RIBBON])] } } })];
        }
      });
    });
  }, e.prototype.importWithGro = function(t) {
    return _e(this, 0, void 0, function() {
      var r, n, i;
      return ye(this, function(a) {
        switch (a.label) {
          case 0:
            return [4, of(t.data)];
          case 1:
            return r = a.sent(), [4, $F.parse(r)];
          case 2:
            return n = a.sent(), [4, A1.createByTrajectory({ trajectory: n, frameIndex: 0, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)];
          case 3:
            return i = a.sent(), [2, this.plugin.managers.cell.create({ representations: i.reprs.map(function(o) {
              return R({ isHidden: !1 }, o);
            }), model: { trajectory: { state: i.model, frameIndex: 0 } }, assets: [{ data: r, format: t.format }] })];
        }
      });
    });
  }, e.prototype.importTrajectory = function(t) {
    return _e(this, 0, void 0, function() {
      var r, n, i, a;
      return ye(this, function(o) {
        switch (o.label) {
          case 0:
            return V6[t.format] ? typeof t.data == "string" || t.data instanceof File ? [4, of(t.data)] : [3, 2] : [2];
          case 1:
            return n = o.sent(), [3, 3];
          case 2:
            n = t.data, o.label = 3;
          case 3:
            return r = n, [4, V6[t.format].parse(r)];
          case 4:
            return i = o.sent(), [4, A1.createByTrajectory({ trajectory: i, frameIndex: 0, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)];
          case 5:
            return a = o.sent(), [2, this.plugin.managers.cell.create({ representations: a.reprs.map(function(u) {
              return R({ isHidden: !1 }, u);
            }), model: { trajectory: { state: a.model, frameIndex: 0 } }, assets: [{ data: r, format: t.format }] })];
        }
      });
    });
  }, e.prototype.getTrajectoryCell = function(t) {
    var r = [];
    if (t) {
      var n = this.plugin.cells.get(t);
      if (!(n != null && n.model.trajectory)) return [];
      r.push(n);
    } else this.plugin.cells.forEach(function(i) {
      i.model.trajectory && r.push(i);
    });
    return r;
  }, e.prototype.play = function(t) {
    var r = this;
    this.paused = !1;
    var n = function() {
      r.next(t), r.paused || window.requestAnimationFrame(n);
    };
    window.requestAnimationFrame(n);
  }, e.prototype.next = function(t) {
    return _e(this, 0, void 0, function() {
      var r, n, i, a, o, u, s, c;
      return ye(this, function(l) {
        switch (l.label) {
          case 0:
            r = this.getTrajectoryCell(t), n = 0, i = r, l.label = 1;
          case 1:
            return n < i.length ? (a = i[n], o = a.model.trajectory, u = o.state, s = o.frameIndex, c = s >= u.frameCount - 1 ? 0 : s + 1, [4, A1.update(Array.from(a.representations).map(function(d) {
              return d[0], d[1].state;
            }), { trajectory: u, frameIndex: c, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)]) : [3, 4];
          case 2:
            l.sent(), a.model.trajectory.frameIndex = c, this.updateDependencyByCells(t), t && this.updated.next({ ref: t, frame: c }), l.label = 3;
          case 3:
            return n++, [3, 1];
          case 4:
            return [2];
        }
      });
    });
  }, e.prototype.setFrameIndex = function(t, r) {
    var n;
    return _e(this, 0, void 0, function() {
      var i, a, o, u;
      return ye(this, function(s) {
        switch (s.label) {
          case 0:
            i = this.getTrajectoryCell(r), a = 0, o = i, s.label = 1;
          case 1:
            return a < o.length ? (u = o[a], [4, A1.update(Array.from(u.representations).map(function(c) {
              return c[0], c[1].state;
            }), { trajectory: (n = u.model.trajectory) === null || n === void 0 ? void 0 : n.state, frameIndex: t, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)]) : [3, 4];
          case 2:
            s.sent(), u.model.trajectory.frameIndex = t, s.label = 3;
          case 3:
            return a++, [3, 1];
          case 4:
            return [2];
        }
      });
    });
  }, e.prototype.updateDependencyByCells = function(t) {
    return _e(this, 0, void 0, function() {
      var r, n, i, a, o, u, s, c, l, d = this;
      return ye(this, function(f) {
        for (r = this.getTrajectoryCell(t), n = 0, i = r; n < i.length; n++) if ((a = i[n]).dependency.by.length) for (o = function(m) {
          var v = u.plugin.cells.get(m);
          v && v.representations.forEach(function(p, g) {
            g === Te.IntraInteractions && d.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.trajectory.updateDependencyByCells"), Object.keys(Op).includes(g) && d.plugin.managers.representation.updateMeasurement({ items: v.dependency.on, ref: m });
          });
        }, u = this, s = 0, c = a.dependency.by; s < c.length; s++) l = c[s], o(l);
        return [2];
      });
    });
  }, e.prototype.mergeDumpAndPymatgen = function(t, r) {
    return _e(this, 0, void 0, function() {
      var n, i, a;
      return ye(this, function(o) {
        switch (o.label) {
          case 0:
            return (n = this.getTrajectoryCell(r)).length && n[0].assets[0].format === mr.Dump ? (i = n[0], [4, fae(i.assets[0].data, t)]) : [2];
          case 1:
            return a = o.sent(), i.model.trajectory = { state: a, frameIndex: i.model.trajectory.frameIndex }, [4, A1.update(Array.from(i.representations).map(function(u) {
              return u[0], u[1].state;
            }), { trajectory: a, frameIndex: i.model.trajectory.frameIndex, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)];
          case 2:
            return o.sent(), i.model.trajectory.frameIndex = i.model.trajectory.frameIndex, this.updateDependencyByCells(r), [2];
        }
      });
    });
  }, e.prototype.pause = function() {
    this.paused = !0;
  }, e;
}();
function eI(e) {
  try {
    e.dispatchEvent(new MouseEvent("click"));
  } catch {
    var t = document.createEvent("MouseEvents");
    t.initMouseEvent("click", !0, !0, window, 0, 0, 0, 80, 20, !1, !1, !1, !1, 0, null), e.dispatchEvent(t);
  }
}
function eN(e, t) {
  if (t === void 0 && (t = "download"), e) if ("download" in HTMLAnchorElement.prototype) {
    var r = document.createElement("a");
    r.download = t, r.rel = "noopener", typeof e == "string" ? (r.href = e, eI(r)) : (r.href = URL.createObjectURL(e), setTimeout(function() {
      return URL.revokeObjectURL(r.href);
    }, 4e4), setTimeout(function() {
      return eI(r);
    }));
  } else if (typeof navigator < "u" && navigator.msSaveOrOpenBlob) navigator.msSaveOrOpenBlob(e, t);
  else {
    var n = window.navigator.userAgent, i = /Safari/i.test(n), a = /CriOS\/[\d]+/.test(n), o = function(c) {
      var l;
      l = a ? c : c.replace(/^data:[^;]*;/, "data:attachment/file;"), window.open(l, "_blank") || (window.location.href = l);
    };
    if ((i || a) && FileReader) if (e instanceof Blob) {
      var u = new FileReader();
      u.onloadend = function() {
        return o(u.result);
      }, u.readAsDataURL(e);
    } else o(e);
    else {
      var s = URL.createObjectURL(typeof e == "string" ? new Blob([e]) : e);
      location.href = s, setTimeout(function() {
        return URL.revokeObjectURL(s);
      }, 4e4);
    }
  }
}
var _u, Qp, tI = function() {
  function e(t) {
    this.ev = ro.create(), this.event = { changed: this.ev() }, this.plugin = t;
  }
  return e.prototype.setSnapshot = function(t, r) {
    var n, i, a, o, u;
    return _e(this, 0, void 0, function() {
      var s, c, l, d, f, m, v, p;
      return ye(this, function(g) {
        switch (g.label) {
          case 0:
            for (s = /* @__PURE__ */ new Map(), ((n = t == null ? void 0 : t.params) === null || n === void 0 ? void 0 : n.showPolarHydrogenOnly) !== void 0 && (this.plugin.managers.representation.showPolarHydrogenOnly = t.params.showPolarHydrogenOnly), ((i = t == null ? void 0 : t.params) === null || i === void 0 ? void 0 : i.interactionParams) !== void 0 && (this.plugin.managers.representation.interactionParams = t.params.interactionParams), c = 0, l = t.cells; c < l.length; c++) p = l[c], s.set(p.ref, { ref: p.ref, assets: p.assets, dependency: p.dependency, model: {}, representations: /* @__PURE__ */ new Map(), theme: p.theme });
            this.plugin.cells = s, d = function(h) {
              var y, x, A, b, _, S, D, I, M, F, P, E, B, N, O, z, V, U, H, K, j;
              return ye(this, function(X) {
                switch (X.label) {
                  case 0:
                    return y = h.model, x = y.structure, y.trajectory, A = y.other, b = h.representations, _ = h.dependency, S = h.theme, D = void 0, x ? b != null && b.some(function(W) {
                      return W.isHidden !== !0;
                    }) ? (I = typeof x.data == "string" || x.data instanceof File, P = (F = Fc[x.format]).parse, I ? [4, of(x.data)] : [3, 2]) : [3, 7] : [3, 8];
                  case 1:
                    return E = X.sent(), [3, 3];
                  case 2:
                    E = x.data, X.label = 3;
                  case 3:
                    return [4, P.apply(F, [E])];
                  case 4:
                    return M = X.sent(), x.format !== mr.Pdb || !M[0].elementCount || nn.hasSecondaryStructure((a = M[0]) === null || a === void 0 ? void 0 : a.model) ? [3, 6] : [4, Aa.attach({}, M[0], { type: { name: "dssp", params: { oldDefinition: !0, oldOrdering: !0 } } }, !0)];
                  case 5:
                    X.sent(), X.label = 6;
                  case 6:
                    return D = M[0], f.plugin.managers.cell.update(h.ref, { representations: [], model: { structure: M[0] }, assets: [{ format: x.format, data: x.data }] }), [3, 8];
                  case 7:
                    f.plugin.managers.cell.update(h.ref, { representations: [], model: { structure: void 0 }, assets: [{ format: x.format, data: x.data }] }), X.label = 8;
                  case 8:
                    return B = h.theme, S && (N = {}, Object.keys(S).forEach(function(W) {
                      var Q = S[W];
                      if (Q) {
                        var te = {};
                        Object.keys(Q).forEach(function(ee) {
                          var $ = Q[ee], ie = [];
                          $ != null && $.length && $.forEach(function(ae) {
                            ie.push(R(R({}, ae), { elementIds: ae.elementIds ? gv(ae.elementIds) : ae.elementIds }));
                          }), te[ee] = ie;
                        }), N[W] = te;
                      }
                    }), B = N, f.plugin.managers.cell.update(h.ref, { representations: [], model: {}, theme: N })), b != null && b.length ? D ? [3, 9] : (f.plugin.managers.cell.update(h.ref, { representations: b == null ? void 0 : b.map(function(W) {
                      var Q;
                      return W.cache ? W : R(R({}, W), { elementIds: [], cache: R(R({}, W), { elementIds: !((Q = W.elementIds) === null || Q === void 0) && Q.length ? gv(W.elementIds) : W.elementIds }) });
                    }), model: {} }), [3, 13]) : [3, 13];
                  case 9:
                    O = function(W) {
                      var Q, te, ee, $;
                      return ye(this, function(ie) {
                        switch (ie.label) {
                          case 0:
                            return !((o = W.elementIds) === null || o === void 0) && o.length ? (Q = Object.keys(xn).find(function(ae) {
                              return xn[ae].includes(W.type);
                            }), te = B.color[Q], ee = B.transparency ? B.transparency[Q] : void 0, $ = W.elementIds ? gv(W.elementIds) : [], [4, f.plugin.managers.representation.addMolecularRepr(h.ref, { reprType: W.type, elementIds: $, isHidden: W.isHidden, theme: f.plugin.managers.representation.createTheme(W.type, $n(D, $, !0), { color: { name: "multi-theme", props: { themes: te } }, size: B.size && (!((u = B.size[Q]) === null || u === void 0) && u.length) ? B.size[Q][0] : f.plugin.managers.representation.defaultTheme.size[W.type] }), transparency: ee })]) : [3, 2];
                          case 1:
                            ie.sent(), ie.label = 2;
                          case 2:
                            return [2];
                        }
                      });
                    }, z = 0, V = b, X.label = 10;
                  case 10:
                    return z < V.length ? (U = V[z], [5, O(U)]) : [3, 13];
                  case 11:
                    X.sent(), X.label = 12;
                  case 12:
                    return z++, [3, 10];
                  case 13:
                    return A ? (U = b[0], A.serverData && !A.data && r ? [4, r(A.serverData)] : [3, 15]) : [3, 18];
                  case 14:
                    return K = X.sent(), [3, 16];
                  case 15:
                    K = A, X.label = 16;
                  case 16:
                    return H = K, [4, f.plugin.managers.representation.createOther({ data: U.type === Te.IsoSurface ? new File([H.data], H.name) : H, serverData: A.serverData, type: U.type, ref: h.ref, isHidden: U.isHidden })];
                  case 17:
                    X.sent(), X.label = 18;
                  case 18:
                    return _.on.length ? (j = _.on.map(function(W) {
                      return R(R({}, W), { elementIds: W.elementIds ? gv(W.elementIds) : W.elementIds });
                    }), [4, f.plugin.managers.representation.createMeasurement({ items: j, type: b[0].type, ref: h.ref, props: b[0].params, isHidden: b[0].isHidden })]) : [3, 20];
                  case 19:
                    X.sent(), f.plugin.managers.cell.update(h.ref, { representations: [], model: {}, dependency: R(R({}, h.dependency), { on: j }) }), X.label = 20;
                  case 20:
                    return [2];
                }
              });
            }, f = this, m = 0, v = t.cells, g.label = 1;
          case 1:
            return m < v.length ? (p = v[m], [5, d(p)]) : [3, 4];
          case 2:
            g.sent(), g.label = 3;
          case 3:
            return m++, [3, 1];
          case 4:
            return this.refresh(), [2];
        }
      });
    });
  }, e.prototype.getSnapshot = function(t) {
    return _e(this, 0, void 0, function() {
      var r, n, i = this;
      return ye(this, function(a) {
        switch (a.label) {
          case 0:
            return this.timestamp = Date.now(), r = [], n = {}, Array.from(this.plugin.cells.values()).map(function(o) {
              var u = o.model.structure, s = o.ref;
              if (u) {
                var c = /* @__PURE__ */ new Map(), l = 0;
                u.units.forEach(function(d) {
                  d.elements.forEach(function(f) {
                    c.set(f, l++);
                  });
                }), n[s] = c;
              }
            }), [4, Promise.all(Array.from(this.plugin.cells.values()).map(function(o) {
              return _e(i, 0, void 0, function() {
                var u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _, S, D, I, M, F;
                return ye(this, function(P) {
                  switch (P.label) {
                    case 0:
                      return u = o.representations, s = o.assets, c = o.model, l = c.structure, d = c.trajectory, f = c.other, m = function(E, B) {
                        var N = {};
                        for (var O in E) Object.prototype.hasOwnProperty.call(E, O) && B.indexOf(O) < 0 && (N[O] = E[O]);
                        if (E != null && typeof Object.getOwnPropertySymbols == "function") {
                          var z = 0;
                          for (O = Object.getOwnPropertySymbols(E); z < O.length; z++) B.indexOf(O[z]) < 0 && Object.prototype.propertyIsEnumerable.call(E, O[z]) && (N[O[z]] = E[O[z]]);
                        }
                        return N;
                      }(o, ["representations", "assets", "model"]), (v = Tc(m)).model = {}, u.get(Te.IntraInteractions) || u.get(Te.BetweenInteractions) ? [2] : (l ? v.model.structure = { data: (D = (S = zg(l, s == null ? void 0 : s[0].format)) !== null && S !== void 0 ? S : s == null ? void 0 : s[0].data) !== null && D !== void 0 ? D : Ko(l).sourceData.data, format: s == null ? void 0 : s[0].format } : s && (v.assets = s), d && (v.model.trajectory = { data: "提取的结构信息", format: s == null ? void 0 : s[0].format }), f ? u.get(Te.IsoSurface) ? (p = !!o.model.other.serverData, g = p ? o.model.other.data : o.model.other, h = v.model, t ? (y = { serverData: p ? o.model.other.serverData : o.model.other }, [3, 3]) : [3, 1]) : [3, 4] : [3, 5]);
                    case 1:
                      return _ = {}, x = Uint8Array.bind, [4, g.arrayBuffer()];
                    case 2:
                      _.data = new (x.apply(Uint8Array, [void 0, P.sent()]))(), _.name = g.name, _.serverData = p ? o.model.other.serverData : o.model.other, y = _, P.label = 3;
                    case 3:
                      return h.other = y, [3, 5];
                    case 4:
                      v.model.other = o.model.other, P.label = 5;
                    case 5:
                      return u != null && u.size && (v.representations = [], A = n[m.ref], u.forEach(function(E) {
                        v.representations.push({ type: E.type, elementIds: E.state ? $4(kg(E.state).map(function(B) {
                          return A && (A != null && A.has(B)) ? A == null ? void 0 : A.get(B) : B;
                        })) : [], isHidden: E.isHidden, params: u0.has(E.type) && E.state ? qF(E.type, E.state) : void 0, cache: E.cache });
                      }), m.theme && Object.keys(m.theme).forEach(function(E) {
                        var B = m.theme[E];
                        if (B) {
                          var N = {};
                          Object.keys(B).forEach(function(O) {
                            var z = B[O], V = [];
                            z != null && z.length && z.forEach(function(U) {
                              V.push(R(R({}, U), { elementIds: $4(U.elementIds && A ? U.elementIds.map(function(H) {
                                var K;
                                return (K = A.get(H)) !== null && K !== void 0 ? K : H;
                              }) : U.elementIds) }));
                            }), N[O] = V;
                          }), v.theme[E] = N;
                        }
                      })), !((M = (I = m.dependency) === null || I === void 0 ? void 0 : I.on) === null || M === void 0) && M.length && (b = [], (F = m.dependency) === null || F === void 0 || F.on.forEach(function(E) {
                        var B = n[m.ref];
                        b.push(R(R({}, E), { elementIds: $4(E.elementIds && B ? E.elementIds.map(function(N) {
                          var O;
                          return (O = B.get(N)) !== null && O !== void 0 ? O : N;
                        }) : E.elementIds) }));
                      }), v.dependency.on = b), r.push(v), [2];
                  }
                });
              });
            }))];
          case 1:
            return a.sent(), [2, { cells: r, timestamp: this.timestamp, params: { interactionParams: Tc(this.plugin.managers.representation.interactionParams), showPolarHydrogenOnly: this.plugin.managers.representation.showPolarHydrogenOnly } }];
        }
      });
    });
  }, e.prototype.refresh = function() {
    var t, r, n, i = this.plugin;
    (t = i.canvas3d) === null || t === void 0 || t.pause(!0), (r = i.canvas3d) === null || r === void 0 || r.clear(), i.cells.forEach(function(a) {
      a.representations.forEach(function(o) {
        var u;
        !o.isHidden && o.state && ((u = i.canvas3d) === null || u === void 0 || u.add(o.state));
      });
    }), (n = i.canvas3d) === null || n === void 0 || n.animate();
  }, e.prototype.downloadAsImage = function(t, r) {
    var n, i;
    return _e(this, 0, void 0, function() {
      var a, o, u, s, c, l, d, f, m, v, p, g, h, y;
      return ye(this, function(x) {
        switch (x.label) {
          case 0:
            if (a = r || { width: ((n = this.plugin.canvas3d) === null || n === void 0 ? void 0 : n.webgl.gl.drawingBufferWidth) || 0, height: ((i = this.plugin.canvas3d) === null || i === void 0 ? void 0 : i.webgl.gl.drawingBufferHeight) || 0 }, o = a.width, u = a.height, s = { x: 0, y: 0, width: 1, height: 1 }, (c = { x: Math.floor(s.x * o), y: Math.floor(s.y * u), width: Math.ceil(s.width * o), height: Math.ceil(s.height * u) }).width + c.x > o && (c.width = o - c.x), c.height + c.y > u && (c.height = u - c.y), o <= 0 || u <= 0) return [2];
            if (l = this.plugin.canvas3d, d = l.webgl.extensions, f = d.colorBufferFloat, m = d.textureFloat, v = l.props.postprocessing.occlusion, p = l.getImagePass({ transparentBackground: !0, cameraHelper: { axes: { name: "off", params: {} } }, multiSample: R(R({}, l.props.multiSample), { mode: "on", sampleLevel: f && m ? 4 : 2 }), postprocessing: R(R({}, l.props.postprocessing), { occlusion: v.name === "on" ? { name: "on", params: R(R({}, v.params), { samples: 128, resolutionScale: l.webgl.pixelRatio }) } : v }), marking: R({}, l.props.marking) }), g = p.getImageData(o, u, c), (h = document.createElement("canvas")).width = g.width, h.height = g.height, !(y = h.getContext("2d"))) throw new Error("Could not create canvas 2d context");
            return y.putImageData(g, 0, 0), [4, GJ(h, "png")];
          case 1:
            return eN(x.sent(), t), [2];
        }
      });
    });
  }, e;
}(), gae = { Dihedral: Te.Dihedral, Distance: Te.Distance, Angle: Te.Angle, Label: Te.Label, "Molecular Surface": Te.Surface }, yae = function() {
  function e(t) {
    var r = this;
    this.ev = ro.create(), this.prev = /* @__PURE__ */ new Map(), this.event = { change: this.ev(), add: this.ev(), remove: this.ev(), clear: this.ev() }, this.plugin = t, this.selection = /* @__PURE__ */ new Set(), this.event.change.subscribe(function(n) {
      var i = n.current, a = i.repr;
      if (i.loci.kind !== "empty-loci") {
        var o = gae[a.label];
        o === Te.Surface && (n.current.loci = n.current.repr.getLoci()), t.cells.forEach(function(u) {
          var s;
          u.representations.has(o) && ((s = u.representations.get(o)) === null || s === void 0 ? void 0 : s.state) === a && (r.selection.has(u.ref) ? n.button !== 2 && r.remove({ item: { ref: u.ref }, loci: n.current }) : r.add({ item: { ref: u.ref }, loci: n.current }));
        });
      } else r.clear();
    });
  }
  return e.prototype.add = function(t) {
    var r, n, i = t.item.ref;
    this.selection.add(i);
    var a = this.plugin.cells.get(i);
    if (a) {
      var o = Array.from(a.representations.values())[0];
      if (t != null && t.loci || o.state) {
        var u = (r = t.loci) !== null && r !== void 0 ? r : { repr: o.state, loci: o.state.getLoci() };
        (n = this.plugin.canvas3d) === null || n === void 0 || n.mark(u, _t.Select), this.event.add.next({ ref: i, loci: u }), this.prev.set(i, u), this.plugin.managers.selection.event.changed.next({});
      }
    }
  }, e.prototype.remove = function(t) {
    var r, n, i = t.item.ref;
    this.selection.delete(i);
    var a = this.plugin.cells.get(i);
    if (a) {
      var o = Array.from(a.representations.values())[0];
      if (o.state) {
        var u = (r = t.loci) !== null && r !== void 0 ? r : { repr: o.state, loci: o.state.getLoci() };
        (n = this.plugin.canvas3d) === null || n === void 0 || n.mark(u, _t.Deselect), this.event.remove.next({ ref: i, loci: u }), this.prev.delete(i), this.plugin.managers.selection.event.changed.next({});
      }
    }
  }, e.prototype.clear = function() {
    var t = this;
    this.selection.clear(), this.prev.forEach(function(r) {
      var n;
      (n = t.plugin.canvas3d) === null || n === void 0 || n.mark(r, _t.Deselect);
    }), this.prev.clear(), this.event.clear.next({}), this.plugin.managers.selection.event.changed.next({});
  }, e;
}(), bae = function() {
  function e(t) {
    var r = this;
    this.ev = ro.create(), this.lociGranularity = "residue", this.prev = [], this.event = { change: this.ev(), add: this.ev(), remove: this.ev(), clear: this.ev() }, this.plugin = t, this.selection = /* @__PURE__ */ new Map(), this.event.change.subscribe(function(n) {
      if (n.current.loci.kind === "element-loci" && r.plugin.cells.forEach(function(u, s) {
        var c;
        if (u != null && u.model.structure && Qu(u == null ? void 0 : u.model.structure) === Qu(n.current.loci.structure) || u.model.trajectory && (u == null ? void 0 : u.model.trajectory.state.getFrameAtIndex(u.model.trajectory.frameIndex).id) === Qu(n.current.loci.structure)) {
          var l = Zr(u);
          n.current.loci = Hr.normalize(ei(l, Gi(n.current.loci)), r.lociGranularity, !0);
          var d = Gi(n.current.loci), f = new Set((c = r.selection.get(s)) !== null && c !== void 0 ? c : []), m = f.size ? d.filter(function(v) {
            return !f.has(v);
          }) : d;
          n.button !== 2 && m.length === 0 ? r.remove({ item: { ref: s, elementIds: d }, reprLoci: n.current }) : r.add({ item: { ref: s, elementIds: m }, reprLoci: n.current });
        }
      }), n.current.loci.kind === "bond-loci") {
        var i = n.current.loci;
        n.current.loci = Hr.normalize(n.current.loci, r.lociGranularity, !0);
        var a = /* @__PURE__ */ new Set();
        i.bonds.forEach(function(u) {
          a.add(u.aUnit.elements[u.aIndex]), a.add(u.bUnit.elements[u.bIndex]);
        });
        var o = Gi(n.current.loci);
        r.plugin.cells.forEach(function(u, s) {
          var c;
          if (u != null && u.model.structure && Qu(u == null ? void 0 : u.model.structure) === Qu(i.bonds[0].aStructure)) {
            var l = new Set((c = r.selection.get(s)) !== null && c !== void 0 ? c : []), d = l.size ? o.filter(function(f) {
              return !l.has(f);
            }) : o;
            n.button !== 2 && d.length === 0 ? r.remove({ item: { ref: s, elementIds: o }, reprLoci: n.current }) : r.add({ item: { ref: s, elementIds: d }, reprLoci: n.current });
          }
        });
      }
      n.current.loci.kind === "empty-loci" && r.clear();
    });
  }
  return Object.defineProperty(e.prototype, "granularity", { get: function() {
    return BJ[this.lociGranularity];
  }, enumerable: !1, configurable: !0 }), e.prototype.getSelectionCellItems = function(t) {
    t === void 0 && (t = !1);
    var r = Array.from(this.selection).map(function(n) {
      return { ref: n[0], elementIds: n[1] };
    }).filter(function(n) {
      var i;
      return (i = n.elementIds) === null || i === void 0 ? void 0 : i.length;
    });
    return t && !r.length ? oB(this.plugin) : r;
  }, e.prototype.getSelection = function() {
    return Array.from(this.selection).reduce(function(t, r) {
      var n;
      return R(R({}, t), ((n = {})[r[0]] = r[1], n));
    }, {});
  }, e.prototype.add = function(t, r, n) {
    var i, a, o = this;
    r === void 0 && (r = !0), n === void 0 && (n = !1);
    var u = t.item, s = u.ref, c = u.elementIds;
    if (!c || c.length) {
      this.selection.set(s, Array.from(new Set(We(We([], (i = this.selection.get(s)) !== null && i !== void 0 ? i : [], !0), c ?? [], !0))));
      var l = this.plugin.cells.get(s);
      if (l) {
        var d = Zr(l);
        if (d) {
          var f, m = this.selection.get(s);
          l == null || l.representations.forEach(function(v) {
            var p;
            if (!v.isHidden && v.state) {
              var g = r ? Hr.normalize(Xe.intersect(ei(yo(v.state), m), ha(v.state.getLoci())), o.lociGranularity, !0) : Xe.intersect(ei(yo(v.state), m), ha(v.state.getLoci()));
              f = { loci: g, repr: v.state }, (p = o.plugin.canvas3d) === null || p === void 0 || p.mark(f, _t.Select);
            }
          }), this.prev.push({ ref: s, elementIds: c }), n || (this.event.add.next({ loci: (a = t.reprLoci) !== null && a !== void 0 ? a : { loci: ei(d, m) }, item: t.item }), this.plugin.managers.selection.event.changed.next({}));
        }
      }
    } else console.warn("add selection, elementIds is empty");
  }, e.prototype.remove = function(t, r, n) {
    var i, a = this;
    r === void 0 && (r = !0), n === void 0 && (n = !1);
    var o = t.item, u = o.ref, s = o.elementIds;
    if (!s || s.length) {
      if (this.selection.has(u)) {
        var c = /* @__PURE__ */ new Set(), l = [], d = new Set(s);
        this.selection.get(u).forEach(function(g) {
          d.has(g) ? c.add(g) : l.push(g);
        }), l.length ? this.selection.set(u, l) : this.selection.delete(u);
        var f, m = this.plugin.cells.get(u), v = (i = this.selection.get(u)) !== null && i !== void 0 ? i : [];
        m == null || m.representations.forEach(function(g) {
          var h, y;
          if (!g.isHidden && g.state) {
            var x = r ? Hr.normalize(Xe.intersect(ei(yo(g.state), v), ha(g.state.getLoci())), a.lociGranularity, !0) : Xe.intersect(ei(yo(g.state), v), ha(g.state.getLoci()));
            (h = a.plugin.canvas3d) === null || h === void 0 || h.mark({ loci: ha(g.state.getLoci()), repr: g.state }, _t.Deselect), f = { loci: x, repr: g.state }, (y = a.plugin.canvas3d) === null || y === void 0 || y.mark(f, _t.Select);
          }
        });
        var p = [];
        this.prev.forEach(function(g) {
          var h = g.ref, y = g.elementIds;
          if (h === u) {
            var x = [];
            y == null || y.forEach(function(A) {
              c.has(A) || x.push(A);
            }), x.length && p.push({ ref: h, elementIds: x });
          }
        }), this.prev = p, n || (this.event.remove.next({ loci: f, item: t.item }), this.plugin.managers.selection.event.changed.next({}));
      }
    } else console.warn("remove selection, elementIds is empty");
  }, e.prototype.clear = function() {
    var t = this;
    Array.from(this.selection.keys()).forEach(function(r) {
      var n = t.plugin.cells.get(r);
      n && (n == null || n.representations.forEach(function(i) {
        var a;
        !i.isHidden && i.state && ((a = t.plugin.canvas3d) === null || a === void 0 || a.mark({ loci: ha(i.state.getLoci()), repr: i.state }, _t.Deselect));
      }));
    }), this.selection.clear(), this.prev = [], this.event.clear.next({}), this.plugin.managers.selection.event.changed.next({});
  }, e.prototype.setGranularity = function(t) {
    this.lociGranularity = PJ[t];
  }, e.prototype.expand = function(t, r) {
    var n = this, i = r ?? this.getSelectionCellItems(), a = this.plugin.managers.cell.getAllDisplayedCellsRef(), o = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), s = n2(a.map(function(A) {
      return { ref: A };
    }), this.plugin), c = s.unitsMap, l = s.structure;
    c.forEach(function(A, b) {
      o.set(a[b], A.map(function(_) {
        return l.unitMap.get(_);
      })), A.forEach(function(_) {
        return u.set(_, a[b]);
      });
    });
    var d = LP(i.map(function(A) {
      var b, _ = o.get(A.ref), S = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map();
      _.forEach(function(M, F) {
        S.set(F, new Set(M.elements)), D.set(F, []);
      }), (b = A.elementIds) === null || b === void 0 || b.forEach(function(M) {
        S.forEach(function(F, P) {
          var E;
          F.has(M) && ((E = D.get(P)) === null || E === void 0 || E.push(_[P].elements.indexOf(M)));
        });
      });
      var I = Array.from(D.entries()).filter(function(M) {
        return M[0], M[1].length;
      }).map(function(M) {
        var F = M[0], P = M[1];
        return { unit: _[F], indices: P };
      });
      return I;
    })), f = Xe(l, d), m = Xe.toExpression(f), v = Nt.struct.modifier.union([Nt.struct.modifier.exceptBy({ 0: Nt.struct.modifier.includeSurroundings({ 0: m, radius: t.radius, "as-whole-residues": t.asWholeResidue }), by: m })]), p = c0(s0(l, v)), g = /* @__PURE__ */ new Map();
    p.units.forEach(function(A) {
      var b, _ = u.get(A.id);
      _ && (g.has(_) ? (b = g.get(_)) === null || b === void 0 || b.push.apply(b, A.elements) : g.set(_, We([], A.elements, !0)));
    });
    var h = Array.from(g.entries()).map(function(A) {
      return { ref: A[0], elementIds: A[1] };
    }), y = aB(this.plugin, h), x = FJ[t.filter];
    t.excludeSelectedAtoms && this.clear(), Object.keys(y).forEach(function(A) {
      var b = [];
      x.forEach(function(_) {
        y[A][_].forEach(function(S) {
          return b.push.apply(b, S.elementIds);
        });
      }), n.add({ item: { ref: A, elementIds: b } }, !1);
    });
  }, e;
}(), rI = function() {
  function e(t) {
    this.ev = ro.create(), this.event = { changed: this.ev() }, this.plugin = t, this.structure = new bae(t), this.shape = new yae(t);
  }
  return e.prototype.clear = function() {
    this.structure.clear(), this.shape.clear();
  }, e;
}(), nI = function() {
  function e(t) {
    this.ev = ro.create(), this.allowEmptyClick = !0, this.allowSelect = !0, this.rightClick = this.ev(), this.plugin = t, this.allowEmptyClick = !0, this.allowSelect = !0;
  }
  return e.prototype.subscribe = function() {
    var t, r, n = this;
    (t = this.plugin.canvas3d) === null || t === void 0 || t.interaction.click.subscribe(function(i) {
      if (i.current.loci.kind === "empty-loci") {
        if (!n.allowEmptyClick || i.button === 2) return;
        n.plugin.managers.selection.shape.event.change.next(i), n.plugin.managers.selection.structure.event.change.next(i);
      } else if (n.allowSelect) i.current.repr.label === "Molecular Surface" || i.current.loci.kind === "group-loci" ? n.plugin.managers.selection.shape.event.change.next(i) : i.current.loci.kind !== "element-loci" && i.current.loci.kind !== "bond-loci" || n.plugin.managers.selection.structure.event.change.next(i);
      else if (i.button !== 2) return;
      i.button === 2 && n.rightClick.next({ loci: i.current, modifiers: i.modifiers, isEmpty: i.current.loci.kind === "empty-loci", isSelection: !1, reprType: kP[i.current.repr.label] });
    }), (r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.hover.subscribe(function(i) {
      i.current.loci.kind !== "empty-loci" ? n.plugin.managers.highlight.setHoverSelection(i.current) : n.plugin.managers.highlight.setHoverSelection();
    });
  }, e.prototype.setAllowEmptyClick = function(t) {
    this.allowEmptyClick = t;
  }, e.prototype.setAllowSelect = function(t) {
    this.allowSelect = t;
  }, e;
}(), _ae = { interval: void 0, observers: void 0, cRef: "", elementId: -1, totalOffset: w.create(0, 0, 0) }, xae = function() {
  function e(t) {
    this.state = _ae, this.intervalTime = 300, this.plugin = t;
  }
  return e.prototype.start = function() {
    var t, r, n = this;
    this.plugin.managers.editor.disabledInteraction = ["click", "drag"], this.plugin.managers.selection.structure.setGranularity(kr.Atom), this.state.observers = (t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.interaction.drag.observers.pop(), this.state.interval = setInterval(function() {
      if (n.state.totalOffset.filter(function(a) {
        return a !== 0;
      }).length !== 0 && n.state.elementId !== -1) {
        var i = We([], n.state.totalOffset, !0);
        n.state.totalOffset = w.create(0, 0, 0), n.plugin.managers.editor.executeEdit(n.state.cRef, function(a, o) {
          var u = We([], a, !0), s = We([], o, !0);
          return u.forEach(function(c) {
            c.elementId === n.state.elementId && (c.x -= i[0], c.y -= i[1], c.z -= i[2]);
          }), { editedAtomList: u, editedBondList: s };
        }, function(a, o) {
          var u = We([], a, !0), s = We([], o, !0);
          return u.forEach(function(c) {
            c.elementId === n.state.elementId && (c.x -= i[0], c.y -= i[1], c.z -= i[2]);
          }), { editedAtomList: u, editedBondList: s };
        });
      }
    }, this.intervalTime), (r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.drag.subscribe(function(i) {
      var a = i.current.loci;
      if (a.kind === "element-loci") {
        var o = Le.toArray(a.elements[0].indices);
        if (o.length === 1) {
          n.plugin.cells.forEach(function(s, c) {
            s.model.structure && Xe.isSubset(tt.toStructureElementLoci(s.model.structure), a) && (n.state.cRef = c);
          });
          var u = KF(n.plugin, i.pageStart, i.pageEnd);
          w.add(n.state.totalOffset, n.state.totalOffset, u), n.state.elementId = a.elements[0].unit.elements[o[0]];
        }
      }
    });
  }, e.prototype.end = function() {
    var t, r;
    this.state.interval && clearInterval(this.state.interval), (t = this.plugin.canvas3d) === null || t === void 0 || t.interaction.drag.observers.pop(), this.state.observers && ((r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.drag.subscribe(this.state.observers)), this.state.observers = void 0, this.state.cRef = "", this.state.elementId = -1, this.state.totalOffset = w.create(0, 0, 0);
  }, e;
}(), Aae = { elementType: "C", drawClickObserver: void 0, position: void 0, isDelete: !1 }, Sae = function() {
  function e(t) {
    this.ev = ro.create(), this.state = Aae, this.event = { update: this.ev() }, this.plugin = t;
  }
  return e.prototype.setElementType = function(t) {
    this.state.elementType = t;
  }, e.prototype.setPosition = function(t) {
    this.state.position = t;
  }, e.prototype.setIsDelete = function(t) {
    this.state.isDelete = t;
  }, e.prototype.start = function() {
    var t, r, n = this;
    this.plugin.managers.editor.disabledInteraction = ["click"], this.plugin.managers.selection.structure.setGranularity(kr.Atom), this.state.drawClickObserver = (t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.interaction.click.observers.pop(), (r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.click.subscribe(function(i) {
      return _e(n, 0, void 0, function() {
        var a, o, u, s, c, l, d, f, m, v, p, g, h, y = this;
        return ye(this, function(x) {
          switch (x.label) {
            case 0:
              return i.current.loci && i.current.loci.kind === "element-loci" ? (a = i.current.loci, (o = Le.toArray(a.elements[0].indices)).length !== 1 ? [3, 5] : (this.plugin.cells.forEach(function(A, b) {
                A.model.structure && Xe.isSubset(tt.toStructureElementLoci(A.model.structure), a) && (u = b);
              }), s = a.elements[0].unit.elements[o[0]], u ? this.state.isDelete ? [3, 2] : [4, this.plugin.managers.editor.editAtomType(this.state.elementType, [{ ref: u, elementIds: [s] }])] : [2])) : [3, 6];
            case 1:
              return x.sent(), [3, 4];
            case 2:
              return [4, this.plugin.managers.cell.remove([{ ref: u, elementIds: [s] }])];
            case 3:
              x.sent(), x.label = 4;
            case 4:
              this.event.update.next({ isUpdateHierarchy: !0, cRef: u }), x.label = 5;
            case 5:
              return [3, 9];
            case 6:
              return !i.current.loci || i.current.loci.kind !== "empty-loci" || this.state.isDelete ? [3, 9] : (c = Array.from(this.plugin.cells.entries()).filter(function(A) {
                A[0];
                var b = A[1];
                return b.model.structure && (Array.from(b.representations.values()).findIndex(function(_) {
                  return _.isHidden === !1;
                }) !== -1 || !b.representations.size);
              }), c.length ? (l = ((v = c[0][1].model.structure) === null || v === void 0 ? void 0 : v.units.length) === 0, (d = (((p = this.plugin.canvas3d) === null || p === void 0 ? void 0 : p.getPosition(i.page[0], i.page[1])) || { position: void 0 }).position) ? c.length !== 1 ? [3, 8] : (f = c[0][1].model.structure) ? (m = "".concat(Math.max.apply(Math, Array.from((h = (g = f.model) === null || g === void 0 ? void 0 : g.atomicConformation.atomId.toArray()) !== null && h !== void 0 ? h : [0])) + 1), [4, this.plugin.managers.editor.executeEdit(c[0][0], function(A, b) {
                return { editedAtomList: We(We([], A, !0), [rp(m, y.state.elementType, d)], !1), editedBondList: We([], b, !0), affectedAtomIds: [+m] };
              }, function(A, b) {
                return { editedAtomList: We(We([], A, !0), [rp(m, y.state.elementType, d)], !1), editedBondList: We([], b, !0) };
              })]) : [2] : [3, 9]) : (this.event.update.next({ hasMultiRef: !0 }), [2]));
            case 7:
              return x.sent(), this.event.update.next({ isUpdateHierarchy: !0, cRef: c[0][0], isEmpty: l }), [3, 9];
            case 8:
              this.setPosition(d), this.event.update.next({ hasMultiRef: !0, newAtom: rp("", this.state.elementType, d) }), x.label = 9;
            case 9:
              return [2];
          }
        });
      });
    });
  }, e.prototype.end = function() {
    var t, r;
    (t = this.plugin.canvas3d) === null || t === void 0 || t.interaction.click.observers.pop(), this.state.drawClickObserver && ((r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.click.subscribe(this.state.drawClickObserver)), this.state.drawClickObserver = void 0;
  }, e.prototype.addAtomByRef = function(t) {
    var r, n, i = this;
    if (this.state.position) {
      var a = this.plugin.cells.get(t);
      if (a) {
        var o = a.model.structure;
        if (o) {
          var u = "".concat(Math.max.apply(Math, Array.from((n = (r = o.model) === null || r === void 0 ? void 0 : r.atomicConformation.atomId.toArray()) !== null && n !== void 0 ? n : [0])) + 1);
          this.plugin.managers.editor.executeEdit(t, function(s, c) {
            return { editedAtomList: We(We([], s, !0), [rp(u, i.state.elementType, i.state.position)], !1), editedBondList: We([], c, !0), affectedAtomIds: [+u] };
          }, function(s, c) {
            return { editedAtomList: We(We([], s, !0), [rp(u, i.state.elementType, i.state.position)], !1), editedBondList: We([], c, !0) };
          }), this.setPosition();
        }
      }
    }
  }, e;
}(), Cae = { interval: void 0, dragObserver: void 0, cRef: "", elementIds: [], unit: void 0, rotateOffset: w.create(0, 0, 0), rotateAtoms: [], arrowCRef: void 0, invert: !1, pointA: w.create(0, 0, 0), pointB: w.create(0, 0, 0) }, wae = function() {
  function e(t) {
    this.state = Cae, this.intervalTime = 300, this.plugin = t;
  }
  return e.prototype.start = function() {
    var t, r, n;
    return _e(this, 0, void 0, function() {
      var i, a = this;
      return ye(this, function(o) {
        switch (o.label) {
          case 0:
            return this.plugin.managers.editor.disabledInteraction = ["drag"], this.plugin.managers.selection.structure.setGranularity(kr.Atom), this.state.dragObserver = (t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.interaction.drag.observers.pop(), i = function() {
              return _e(a, 0, void 0, function() {
                var u, s, c, l, d, f, m, v, p, g, h, y, x, A, b, _, S, D, I, M, F, P, E, B;
                return ye(this, function(N) {
                  switch (N.label) {
                    case 0:
                      if (this.state.arrowCRef && (this.plugin.managers.cell.remove([{ ref: this.state.arrowCRef }]), this.state.arrowCRef = void 0), u = this.plugin.managers.selection.structure.selection, this.state.cRef = "", this.state.elementIds = [], this.state.unit = void 0, s = Array.from(u.entries()).filter(function(O) {
                        return O[0], O[1].length > 0;
                      }), s.length !== 1) return [3, 2];
                      if ((c = s[0][1]).length !== 2) return [3, 2];
                      if (this.state.cRef = s[0][0], this.state.elementIds = We([], c, !0), !(l = (B = this.plugin.cells.get(s[0][0])) === null || B === void 0 ? void 0 : B.model.structure)) return [2];
                      for (d = l.units.find(function(O) {
                        return qe.has(O.elements, c[0]) && qe.has(O.elements, c[1]);
                      }), this.state.unit = d, m = (f = d).bonds, v = f.conformation, p = f.rings, g = f.elements, h = /* @__PURE__ */ new Map(), y = -1, x = 0, A = m.a.length; x < A; x++) {
                        if (y === -1 && (g[m.a[x]] === c[0] && g[m.b[x]] === c[1] && m.edgeProps.order[x] === 1 || g[m.a[x]] === c[1] && g[m.b[x]] === c[0] && m.edgeProps.order[x] === 1)) {
                          for (b = 0, _ = p.all.length; b < _; b++) if (p.all[b].includes(c[0]) && p.all[b].includes(c[1])) return [2];
                          y = x;
                        }
                        h.has(g[m.a[x]]) ? h.set(g[m.a[x]], We(We([], h.get(g[m.a[x]]), !0), [g[m.b[x]]], !1)) : h.set(g[m.a[x]], [g[m.b[x]]]);
                      }
                      return y !== -1 && h.get(c[0]).length > 1 && h.get(c[1]).length > 1 ? (S = this.state.invert ? 1 : 0, D = this.state.invert ? 0 : 1, this.state.pointA = w.create(v.x(c[D]), v.y(c[D]), v.z(c[D])), this.state.pointB = w.create(v.x(c[S]), v.y(c[S]), v.z(c[S])), I = this.state, [4, this.plugin.managers.representation.createOther({ data: { center: this.state.pointA, vec: w.create(this.state.pointB[0] - this.state.pointA[0], this.state.pointB[1] - this.state.pointA[1], this.state.pointB[2] - this.state.pointA[2]), color: He.fromRgb(255, 196, 36), alpha: 0.9 }, type: Te.RotateArrow })]) : [3, 2];
                    case 1:
                      for (I.arrowCRef = N.sent(), M = We([], h.get(c[S]).filter(function(O) {
                        return O !== c[D] && O !== c[S];
                      }), !0), F = [c[S]], this.state.rotateAtoms = We([], M, !0); M.length; ) P = M.shift(), (E = this.state.rotateAtoms).push.apply(E, h.get(P)), F.push(P), M.push.apply(M, h.get(P).filter(function(O) {
                        return !F.includes(O);
                      }));
                      this.state.rotateAtoms = Array.from(new Set(this.state.rotateAtoms.filter(function(O) {
                        return O !== c[D] && O !== c[S];
                      }))), N.label = 2;
                    case 2:
                      return [2];
                  }
                });
              });
            }, [4, i()];
          case 1:
            return o.sent(), this.plugin.managers.selection.structure.event.add.subscribe(function() {
              a.state.invert = !1, a.state.rotateOffset = w.create(0, 0, 0), a.state.rotateAtoms = [], a.state.cRef = "", a.state.elementIds = [], a.state.unit = void 0, i();
            }), this.plugin.managers.selection.structure.event.remove.subscribe(function() {
              a.state.invert = !1, a.state.rotateOffset = w.create(0, 0, 0), a.state.rotateAtoms = [], a.state.cRef = "", a.state.elementIds = [], a.state.unit = void 0, i();
            }), this.plugin.managers.selection.structure.event.clear.subscribe(function() {
              a.state.invert = !1, a.state.rotateOffset = w.create(0, 0, 0), a.state.rotateAtoms = [], a.state.cRef = "", a.state.elementIds = [], a.state.unit = void 0, a.state.arrowCRef && a.plugin.managers.cell.remove([{ ref: a.state.arrowCRef }]);
            }), (r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.click.subscribe(function(u) {
              u.current.loci.kind === "group-loci" && (u.current.repr ? u.current.repr.label === "RotateArrow" : u.current.loci.shape.name.split("-").shift() === "RotateArrow") && (a.state.invert = !a.state.invert, i());
            }), this.state.interval = setInterval(function() {
              if (a.state.rotateOffset.filter(function(d) {
                return d !== 0;
              }).length !== 0 && a.state.cRef && a.state.elementIds.length === 2 && a.state.rotateAtoms.length !== 0) {
                var u = a.state.elementIds, s = a.state.unit.conformation, c = w.angle(w.sub(w.create(0, 0, 0), a.state.pointA, a.state.pointB), w.create(a.state.rotateOffset[0], a.state.rotateOffset[1], a.state.rotateOffset[2]));
                w.cross(w.create(0, 0, 0), w.sub(w.create(0, 0, 0), a.state.pointA, a.state.pointB), w.create(a.state.rotateOffset[0], a.state.rotateOffset[1], a.state.rotateOffset[2]))[2] < 0 && (c = 2 * Math.PI - c);
                var l = 5 * w.distance(w.create(0, 0, 0), w.create(a.state.rotateOffset[0], a.state.rotateOffset[1], a.state.rotateOffset[2])) * (c < Math.PI && c > 0 ? -1 : 1);
                a.state.rotateOffset = w.create(0, 0, 0), a.plugin.managers.editor.executeEdit(a.state.cRef, function(d, f) {
                  var m = We([], d, !0), v = We([], f, !0);
                  return m.forEach(function(p) {
                    if (a.state.rotateAtoms.includes(p.elementId)) {
                      var g = HD([s.x(u[1]), s.y(u[1]), s.z(u[1])], [s.x(u[0]), s.y(u[0]), s.z(u[0])], l, [p.x, p.y, p.z]);
                      p.x = g[0], p.y = g[1], p.z = g[2];
                    }
                  }), { editedAtomList: m, editedBondList: v };
                }, function(d, f) {
                  var m = We([], d, !0), v = We([], f, !0);
                  return m.forEach(function(p) {
                    if (a.state.rotateAtoms.includes(p.elementId)) {
                      var g = HD([s.x(u[1]), s.y(u[1]), s.z(u[1])], [s.x(u[0]), s.y(u[0]), s.z(u[0])], l, [p.x, p.y, p.z]);
                      p.x = g[0], p.y = g[1], p.z = g[2];
                    }
                  }), { editedAtomList: m, editedBondList: v };
                });
              }
            }, this.intervalTime), (n = this.plugin.canvas3d) === null || n === void 0 || n.interaction.drag.subscribe(function(u) {
              if (a.state.rotateAtoms.length) {
                var s = KF(a.plugin, u.pageStart, u.pageEnd);
                a.state.rotateOffset[0] += s[0], a.state.rotateOffset[1] += s[1], a.state.rotateOffset[2] += s[2];
              }
            }), [2];
        }
      });
    });
  }, e.prototype.end = function() {
    var t, r, n;
    this.state.arrowCRef && (this.plugin.managers.cell.remove([{ ref: this.state.arrowCRef }]), this.state.arrowCRef = void 0), this.state.interval && clearInterval(this.state.interval), (t = this.plugin.canvas3d) === null || t === void 0 || t.interaction.drag.observers.pop(), this.state.dragObserver && ((r = this.plugin.canvas3d) === null || r === void 0 || r.interaction.drag.subscribe(this.state.dragObserver)), this.state.invert = !1, this.state.dragObserver = void 0, this.state.rotateOffset = w.create(0, 0, 0), this.state.rotateAtoms = [], this.state.elementIds = [], this.state.unit = void 0, this.plugin.managers.selection.structure.event.add.observers.pop(), this.plugin.managers.selection.structure.event.remove.observers.pop(), this.plugin.managers.selection.structure.event.clear.observers.pop(), (n = this.plugin.canvas3d) === null || n === void 0 || n.interaction.click.observers.pop();
  }, e;
}();
(function(e) {
  e[e.None = 0] = "None", e[e.Drag = 1] = "Drag", e[e.Rotate = 2] = "Rotate", e[e.Draw = 3] = "Draw";
})(_u || (_u = {})), function(e) {
  e[e.SINGLE = 1] = "SINGLE", e[e.DOUBLE = 2] = "DOUBLE", e[e.TRIPLE = 3] = "TRIPLE", e[e.AROMATIC = 4] = "AROMATIC", e[e.SINGLE_OR_DOUBLE = 5] = "SINGLE_OR_DOUBLE", e[e.SINGLE_OR_AROMATIC = 6] = "SINGLE_OR_AROMATIC", e[e.DOUBLE_OR_AROMATIC = 7] = "DOUBLE_OR_AROMATIC", e[e.ANY = 8] = "ANY";
}(Qp || (Qp = {}));
var iI = [Qp.SINGLE, Qp.DOUBLE, Qp.TRIPLE], aI = function() {
  function e(t) {
    var r;
    this.state = { mode: _u.None, editAtomDisabled: !1, addBondDisabled: !1, editBondDisabled: !1, selectedPdb: !1, isMergeNeeded: !1 }, this.ev = ro.create(), this.editStateUpdated = this.ev(), this.editStructureUpdated = this.ev(), this.plugin = t, this.instance = ((r = {})[_u.Drag] = new xae(t), r[_u.Rotate] = new wae(t), r[_u.Draw] = new Sae(t), r[_u.None] = void 0, r);
  }
  return Object.defineProperty(e.prototype, "isEditing", { get: function() {
    var t;
    return !!(!((t = this.plugin.canvas3d) === null || t === void 0) && t.controls.isEditing);
  }, set: function(t) {
    var r, n, i = ((r = this.plugin.canvas3d) === null || r === void 0 ? void 0 : r.controls.isEditing) === !1 && t;
    if ((n = this.plugin.canvas3d) === null || n === void 0 || n.controls.setEditState(t), i && this.setState(this.getEditState()), !t) {
      var a = [];
      this.plugin.cells.forEach(function(o, u) {
        o.representations.has(Te.RotateArrow) && a.push({ ref: u });
      }), this.plugin.managers.cell.remove(a);
    }
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "disabledInteraction", { get: function() {
    var t;
    return ((t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.controls.disabledInteraction) || [];
  }, set: function(t) {
    var r;
    (r = this.plugin.canvas3d) === null || r === void 0 || r.controls.setDisabledInteractionState(t);
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "isLockCamera", { get: function() {
    var t;
    return !!(!((t = this.plugin.canvas3d) === null || t === void 0) && t.controls.isLockCamera);
  }, set: function(t) {
    var r;
    (r = this.plugin.canvas3d) === null || r === void 0 || r.controls.setLockCameraState(t);
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "drawEditor", { get: function() {
    return this.instance[_u.Draw];
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "rotateEditor", { get: function() {
    return this.instance[_u.Rotate];
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "dragEditor", { get: function() {
    return this.instance[_u.Drag];
  }, enumerable: !1, configurable: !0 }), e.prototype.setState = function(t) {
    Object.assign(this.state, t), this.editStateUpdated.next(this.state);
  }, e.prototype.setEditorMode = function(t, r, n) {
    r === void 0 && (r = !1), n === void 0 && (n = ["click", "drag"]), this.isEditing = t, this.isLockCamera = r, this.disabledInteraction = n;
  }, e.prototype.getEditState = function() {
    var t, r, n, i, a = this, o = !0, u = !0, s = !0, c = !1, l = !1;
    if (!this.isEditing) return { editAtomDisabled: o, addBondDisabled: u, editBondDisabled: s, selectedPdb: c, isMergeNeeded: l };
    var d = this.plugin.managers.selection.structure.selection, f = [];
    if (d.forEach(function(y, x) {
      f.push(x), c = c || a.plugin.managers.cell.isFromPdb(x);
    }), f.length > 0) for (var m = 0, v = f.length; m < v; m++) {
      var p = f[m];
      d.has(p) && (o = !1);
    }
    if (f.length === 0 || f.length > 2) return { editAtomDisabled: o, addBondDisabled: u, editBondDisabled: s, selectedPdb: c, isMergeNeeded: l };
    if (f.length === 2) (g = We(We([], (t = d.get(f[0])) !== null && t !== void 0 ? t : [], !0), (r = d.get(f[1])) !== null && r !== void 0 ? r : [], !0)).length === 2 && (u = !1, l = !0);
    else if (f.length === 1) {
      var g;
      if (((g = d.get(f[0])) == null ? void 0 : g.length) === 2) {
        u = !1;
        var h = this.plugin.cells.get(f[0]);
        !((n = h == null ? void 0 : h.model.structure) === null || n === void 0) && n.units.length && ((i = h == null ? void 0 : h.model.structure) === null || i === void 0 ? void 0 : i.units[0]).bonds.getEdgeIndex(g[0], g[1]) !== -1 && (s = !1);
      }
    }
    return { editAtomDisabled: o, addBondDisabled: u, editBondDisabled: s, selectedPdb: c, isMergeNeeded: l };
  }, e.prototype.coverStructure = function(t, r, n) {
    return _e(this, 0, void 0, function() {
      var i, a, o, u = this;
      return ye(this, function(s) {
        switch (s.label) {
          case 0:
            return i = n.format, a = n.data, [4, this.plugin.managers.representation.updateMolecular({ ref: t, structure: r })];
          case 1:
            return (o = s.sent()).model.structure = r, this.plugin.managers.cell.update(t, { model: o.model, representations: Array.from(o.representations.values()), assets: [{ format: i, data: a }] }), this.editStructureUpdated.next(t), this.plugin.managers.cell.traverse(function(c, l) {
              l.type === Te.IntraInteractions && u.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.editor.executeEdit");
            }), [2];
        }
      });
    });
  }, e.prototype.executeEdit = function(t, r, n, i) {
    var a, o, u;
    return _e(this, 0, void 0, function() {
      var s, c, l, d, f, m = this;
      return ye(this, function(v) {
        switch (v.label) {
          case 0:
            return s = this.plugin.cells.get(t), (c = (a = s == null ? void 0 : s.model) === null || a === void 0 ? void 0 : a.structure) ? [4, gee(c, r, n, i)] : [2];
          case 1:
            return (l = v.sent()).length <= 0 ? [2] : [4, this.plugin.managers.representation.updateMolecular({ ref: t, structure: l[0] })];
          case 2:
            return (d = v.sent()).model.structure = l[0], f = ((u = (o = Ko(l[0])) === null || o === void 0 ? void 0 : o.sourceData) === null || u === void 0 ? void 0 : u.kind) !== "mmCIF" ? mr.Sdf : mr.Pdb, this.plugin.managers.cell.update(t, { model: d.model, representations: Array.from(d.representations.values()), assets: [{ format: f, data: zg(l[0], f) }] }), this.editStructureUpdated.next(t), this.plugin.managers.cell.traverse(function(p, g) {
              g.type === Te.IntraInteractions && m.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.editor.executeEdit");
            }), [2];
        }
      });
    });
  }, e.prototype.coverSourceData = function(t, r, n, i) {
    var a, o, u, s, c, l, d;
    return _e(this, 0, void 0, function() {
      var f, m, v, p, g, h, y, x, A, b, _, S = this;
      return ye(this, function(D) {
        switch (D.label) {
          case 0:
            return this.plugin.cells.has(t) ? (v = (m = Fc[r]).parse, [4, of(n)]) : [2];
          case 1:
            return [4, v.apply(m, [D.sent()])];
          case 2:
            return f = D.sent(), i ? ((p = this.plugin.cells.get(t)) == null || p.representations.forEach(function(I) {
              var M;
              I.state && ((M = S.plugin.canvas3d) === null || M === void 0 || M.remove(I.state));
            }), this.plugin.managers.cell.update(t, { model: { structure: f[0] }, representations: [], assets: [{ format: r, data: n }] }), p.representations = /* @__PURE__ */ new Map(), [4, this.plugin.managers.representation.setMolecularRepr([{ ref: t, elementIds: qo(f[0]) }], i, !1)]) : [3, 4];
          case 3:
            return D.sent(), g = this.plugin.managers.selection.structure.getSelection(), h = (a = g[t]) !== null && a !== void 0 ? a : [], (y = (o = this.plugin.cells.get(t)) === null || o === void 0 ? void 0 : o.representations.get(i)) && (x = ei(yo(y.state), h), (u = this.plugin.canvas3d) === null || u === void 0 || u.mark({ loci: x, repr: y.state }, _t.Select)), [2];
          case 4:
            return [4, this.plugin.managers.representation.updateMolecular({ ref: t, structure: f[0] })];
          case 5:
            return (A = D.sent()).model.structure = f[0], this.plugin.managers.cell.update(t, { model: A.model, representations: Array.from(A.representations.values()), assets: [{ format: r, data: n }] }), b = this.plugin.managers.selection.structure.getSelection(), _ = (s = b[t]) !== null && s !== void 0 ? s : [], (c = this.plugin.cells.get(t)) === null || c === void 0 || c.representations.values(), Array.from((d = (l = this.plugin.cells.get(t)) === null || l === void 0 ? void 0 : l.representations.values()) !== null && d !== void 0 ? d : []).forEach(function(I) {
              var M, F = ei(yo(I.state), _);
              (M = S.plugin.canvas3d) === null || M === void 0 || M.mark({ loci: F, repr: I.state }, _t.Select);
            }), this.plugin.managers.cell.traverse(function(I, M) {
              M.type === Te.IntraInteractions && S.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.editor.coverSourceData");
            }), [2];
        }
      });
    });
  }, e.prototype.edit = function(t, r) {
    return _e(this, 0, void 0, function() {
      var n, i, a, o = this;
      return ye(this, function(u) {
        switch (u.label) {
          case 0:
            return n = this.isLockCamera, this.isLockCamera = !0, i = r ?? this.plugin.managers.selection.structure.getSelectionCellItems(), [4, Promise.all(i.map(function(s) {
              var c = s.ref, l = s.elementIds;
              return t(c, l ?? []);
            }))];
          case 1:
            return u.sent(), a = this.plugin.managers.selection.structure.getSelection(), i.forEach(function(s) {
              var c, l, d = s.ref, f = o.plugin.cells.get(d), m = (c = a[d]) !== null && c !== void 0 ? c : [];
              Array.from((l = f == null ? void 0 : f.representations.values()) !== null && l !== void 0 ? l : []).forEach(function(v) {
                var p, g = ei(yo(v.state), m);
                (p = o.plugin.canvas3d) === null || p === void 0 || p.mark({ loci: g, repr: v.state }, _t.Select);
              });
            }), this.isLockCamera = n, [2];
        }
      });
    });
  }, e.prototype.deleteAtoms = function(t) {
    return _e(this, 0, void 0, function() {
      var r, n, i = this;
      return ye(this, function(a) {
        switch (a.label) {
          case 0:
            return r = {}, n = function(o, u) {
              return i.executeEdit(o, function(s, c) {
                var l = new Set(u), d = /* @__PURE__ */ new Map(), f = [];
                s.forEach(function(v) {
                  var p = l.has(v.elementId);
                  return p || (r[v.elementId] = f.length, f.push(R({}, v)), d.set(v.elementId + 1, f.length)), !p;
                });
                var m = c.filter(function(v) {
                  var p = l.has(v.a - 1) || l.has(v.b - 1);
                  return d.has(v.a) && (v.a = d.get(v.a)), d.has(v.b) && (v.b = d.get(v.b)), !p;
                });
                return { editedAtomList: f, editedBondList: m };
              }, function(s, c) {
                var l = new Set(u), d = [];
                s.forEach(function(m) {
                  l.has(m.elementId) || (r[m.elementId] = d.length, d.push(m));
                });
                var f = We([], c, !0);
                return { editedAtomList: d, editedBondList: f, affectedAtomIds: [] };
              });
            }, [4, this.edit(n, t)];
          case 1:
            return a.sent(), [2, r];
        }
      });
    });
  }, e.prototype.editAtomCharge = function(t, r) {
    var n = this;
    return this.edit(function(i, a) {
      return n.executeEdit(i, function(o, u) {
        var s = new Set(a), c = We([], o, !0), l = We([], u, !0), d = [];
        return c.forEach(function(f) {
          if (s.has(f.elementId)) {
            var m = f.charge !== void 0 ? f.charge + t : t;
            m <= 3 && m >= -3 && (f.charge = m, d.push(parseInt(f.atom_id, 10)));
          }
        }), { editedAtomList: c, editedBondList: l, affectedAtomIds: d };
      }, function(o, u) {
        var s = new Set(a), c = We([], o, !0), l = We([], u, !0), d = [];
        return c.forEach(function(f) {
          if (s.has(f.elementId)) {
            var m = f.charge !== void 0 ? f.charge + t : t;
            m <= 3 && m >= -3 && (f.charge = m, d.push(parseInt(f.atom_id, 10)));
          }
        }), { editedAtomList: c, editedBondList: l, affectedAtomIds: d };
      });
    }, r);
  }, e.prototype.editAtomType = function(t, r) {
    var n = this, i = t ?? this.instance[_u.Draw].state.elementType;
    return this.edit(function(a, o) {
      return n.executeEdit(a, function(u, s) {
        var c = new Set(o), l = We([], u, !0), d = We([], s, !0), f = [];
        return l.forEach(function(m) {
          c.has(m.elementId) && (m.auth_atom_id = i, m.type_symbol = i, f.push(parseInt(m.atom_id, 10)));
        }), { editedAtomList: l, editedBondList: d, affectedAtomIds: f };
      }, function(u, s) {
        var c = new Set(o), l = We([], u, !0), d = We([], s, !0), f = [];
        return l.forEach(function(m) {
          c.has(m.elementId) && (m.auth_atom_id = i, m.type_symbol = i, f.push(parseInt(m.atom_id, 10)));
        }), { editedAtomList: l, editedBondList: d, affectedAtomIds: f };
      });
    }, r);
  }, e.prototype.editBondOrder = function(t, r) {
    var n = this;
    return this.edit(function(i, a) {
      return n.executeEdit(i, function(o, u) {
        var s = We([], o, !0), c = We([], u, !0), l = /* @__PURE__ */ new Set();
        return c.forEach(function(d) {
          if (d.a - 1 === a[0] && d.b - 1 === a[1] || d.a - 1 === a[1] && d.b - 1 === a[0]) {
            var f = d.order + t;
            iI.includes(f) && (d.order = f, l.add(d.a - 1), l.add(d.b - 1));
          }
        }), { editedAtomList: s, editedBondList: c, affectedAtomIds: Array.from(l) };
      }, function(o, u) {
        var s = We([], o, !0), c = We([], u, !0), l = /* @__PURE__ */ new Set();
        return c.forEach(function(d) {
          if (d.a === a[0] && d.b === a[1] || d.a === a[1] && d.b === a[0]) {
            var f = d.order + t;
            iI.includes(f) && (d.order = f, l.add(d.atom_idA === void 0 ? d.a - 1 : parseInt(d.atom_idA, 10)), l.add(d.atom_idB === void 0 ? d.b - 1 : parseInt(d.atom_idB, 10)));
          }
        }), { editedAtomList: s, editedBondList: c, affectedAtomIds: Array.from(l) };
      });
    }, r);
  }, e.prototype.addOrDelBond = function(t, r) {
    var n, i = this;
    if (!r || r.length === 1 && ((n = r[0].elementIds) === null || n === void 0 ? void 0 : n.length) === 2) {
      if (!r) {
        var a = this.plugin.managers.selection.structure.selection;
        if (a.size !== 1 && Array.from(a.values())[0].length !== 2) return;
      }
      return this.edit(function(o, u) {
        return i.executeEdit(o, function(s, c) {
          var l = We([], s, !0), d = We([], c, !0), f = We([], u, !0);
          return t ? d.filter(function(m) {
            return m.a - 1 === u[0] && m.b - 1 === u[1] || m.a - 1 === u[1] && m.b - 1 === u[0];
          }).length === 0 && d.push({ a: u[0] + 1, b: u[1] + 1, order: 1 }) : d = d.filter(function(m) {
            return !(m.a - 1 === u[0] && m.b - 1 === u[1] || m.a - 1 === u[1] && m.b - 1 === u[0]);
          }), { editedAtomList: l, editedBondList: d, affectedAtomIds: f };
        }, function(s, c) {
          var l, d = We([], s, !0), f = We([], c, !0), m = [];
          if (t) {
            if (f.filter(function(y) {
              return y.a === u[0] && y.b === u[1] || y.a === u[1] && y.b === u[0];
            }).length === 0) {
              var v = (l = i.plugin.cells.get(o)) === null || l === void 0 ? void 0 : l.model.structure;
              if (v && v.units.length > 0) {
                var p = v.units[0], g = p.model.atomicConformation.atomId.value(u[0]), h = p.model.atomicConformation.atomId.value(u[1]);
                f.push({ a: u[0], b: u[1], order: 1, atom_idA: "".concat(g), atom_idB: "".concat(h) }), m.push(g, h);
              }
            }
          } else f = f.filter(function(y) {
            return !(y.a === u[0] && y.b === u[1] || y.a === u[1] && y.b === u[0]) || (m.push(y.atom_idA === void 0 ? y.a - 1 : parseInt(y.atom_idA, 10), y.atom_idB === void 0 ? y.b - 1 : parseInt(y.atom_idB, 10)), !1);
          });
          return { editedAtomList: d, editedBondList: f, affectedAtomIds: m };
        });
      }, r);
    }
  }, e.prototype.changeEditorMode = function(t) {
    var r = this.instance[this.state.mode];
    this.isLockCamera = !1, this.disabledInteraction = [], r && r.end();
    var n = this.instance[t];
    n && (this.isEditing = !0, this.isLockCamera = !0, n.start()), this.setState({ mode: t });
  }, e.prototype.start = function() {
    var t = this;
    this.plugin.managers.selection.event.changed.subscribe(function() {
      t.setState(t.getEditState());
    });
  }, e;
}(), oI = function() {
  function e(t) {
    this.ev = ro.create(), this.info = this.ev(), this.handleHighlightLocis = [], this.plugin = t;
  }
  return e.prototype.setHoverSelection = function(t, r) {
    var n, i, a, o = this;
    if (r === void 0 && (r = !0), this.hoverLoci && ((n = this.plugin.canvas3d) === null || n === void 0 || n.mark(this.hoverLoci, _t.RemoveHighlight)), !((i = this.handleHighlightLocis) === null || i === void 0) && i.length && this.handleHighlightLocis.forEach(function(s) {
      var c;
      (c = o.plugin.canvas3d) === null || c === void 0 || c.mark(s, _t.RemoveHighlight);
    }), t) {
      var u = { loci: Hr.normalize(t.loci, this.plugin.managers.selection.structure.lociGranularity), repr: t.repr };
      (a = this.plugin.canvas3d) === null || a === void 0 || a.mark(u, _t.Highlight), this.hoverLoci = u, r && this.info.next({ loci: u, info: this.createHighlightInfo(u) });
    } else this.info.next({});
  }, e.prototype.addHighlightLocis = function(t, r) {
    var n, i = this;
    r === void 0 && (r = !0), r && (this.handleHighlightLocis.forEach(function(a) {
      var o;
      (o = i.plugin.canvas3d) === null || o === void 0 || o.mark(a, _t.RemoveHighlight);
    }), this.handleHighlightLocis = []), t.forEach(function(a) {
      var o;
      (o = i.plugin.canvas3d) === null || o === void 0 || o.mark(a, _t.Highlight);
    }), (n = this.handleHighlightLocis).push.apply(n, t);
  }, e.prototype.createHighlightInfo = function(t) {
    if (t.loci.kind === "element-loci") {
      var r = "";
      if (Array.from(this.plugin.cells.entries()).some(function(p) {
        var g = p[0], h = p[1];
        return !(r || !Zr(h) || Qu(Zr(h)) !== Qu(t.loci.structure)) && (r = g, !0);
      }), !r) return;
      var n, i = this.plugin.cells.get(r), a = "";
      if (Object.entries(xn).forEach(function(p) {
        var g = p[0];
        p[1].includes(kP[t.repr.label]) && (n = g);
      }), n && i.theme.color && i.theme.color[n]) {
        var o = i.theme.color[n], u = Gi(t.loci);
        o.forEach(function(p) {
          var g = new Set(p.elementIds);
          u.filter(function(h) {
            return !g.has(h);
          }).length === 0 && (a = p.name);
        });
      }
      return m = R({ type: Wp.Structure, ref: r, colorThemeName: a }, NJ(t.loci, this.plugin.managers.selection.structure.granularity));
    }
    if (t.loci.kind === "data-loci" && t.loci.tag === "interactions") {
      var s = "", c = "", l = t.loci.elements[0], d = l.unitA, f = l.unitB;
      Array.from(this.plugin.cells.entries()).some(function(p) {
        var g = p[0], h = p[1];
        if (s && c) return !0;
        if (h.model.structure) {
          var y = Qu(h.model.structure);
          y === d.model.id && (s = g), y === f.model.id && (c = g);
        }
        return !1;
      });
      var m = R({ type: Wp.Interaction }, RJ(t.loci));
      return Object.assign(m.infoA, { ref: s }), Object.assign(m.infoB, { ref: c }), m;
    }
    if (t.loci.kind === "group-loci") return {};
    if (t.loci.kind === "bond-loci") {
      var v = "";
      return Array.from(this.plugin.cells.entries()).some(function(p) {
        var g = p[0], h = p[1];
        return !(v || !h.model.structure || Qu(h.model.structure) !== Qu(t.loci.structure)) && (v = g, !0);
      }), m = { infoA: Os(t.loci.bonds[0].aUnit, t.loci.bonds[0].aUnit.elements[t.loci.bonds[0].aIndex]), infoB: Os(t.loci.bonds[0].bUnit, t.loci.bonds[0].bUnit.elements[t.loci.bonds[0].bIndex]), ref: v, type: Wp.Bond };
    }
  }, e.prototype.clear = function() {
    this.hoverLoci = void 0;
  }, e;
}(), Dae = [["viewport", "Viewport"], ["hd", "HD (1280 * 720 pixels)"], ["full-hd", "Full HD (1920 x 1080 pixels)"], ["ultra-hd", "Ultra HD (3840 x 2160 pixels)"], ["custom", "Custom"]], uI = function() {
  function e(t) {
    this.plugin = t, this.ev = ro.create(), this._params = void 0, this.behaviors = { values: this.ev.behavior({ transparent: this.params.transparent.defaultValue, axes: { name: "off", params: {} }, resolution: this.params.resolution.defaultValue }), cropParams: this.ev.behavior({ auto: !1, relativePadding: 0.1 }), relativeCrop: this.ev.behavior({ x: 0, y: 0, width: 1, height: 1 }) }, this.events = { previewed: this.ev() }, this._previewPass = void 0, this._imagePass = void 0, this.canvas = document.createElement("canvas"), this.previewCanvas = document.createElement("canvas"), this.previewData = { image: { data: new Uint8ClampedArray(1), width: 1, height: 0 }, background: He(0), transparent: !1 };
  }
  return e.prototype.createParams = function() {
    var t = Math.min(this.plugin.canvas3d ? this.plugin.canvas3d.webgl.maxRenderbufferSize : 4096, 4096);
    return { resolution: G.MappedStatic("ultra-hd", { viewport: G.Group({}), hd: G.Group({}), "full-hd": G.Group({}), "ultra-hd": G.Group({}), custom: G.Group({ width: G.Numeric(1920, { min: 128, max: t, step: 1 }), height: G.Numeric(1080, { min: 128, max: t, step: 1 }) }, { isFlat: !0 }) }, { options: Dae }), transparent: G.Boolean(!1), axes: Lg.axes };
  }, Object.defineProperty(e.prototype, "params", { get: function() {
    return this._params ? this._params : this._params = this.createParams();
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "values", { get: function() {
    return this.behaviors.values.value;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "cropParams", { get: function() {
    return this.behaviors.cropParams.value;
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "relativeCrop", { get: function() {
    return this.behaviors.relativeCrop.value;
  }, enumerable: !1, configurable: !0 }), e.prototype.getCanvasSize = function() {
    var t, r;
    return { width: ((t = this.plugin.canvas3d) === null || t === void 0 ? void 0 : t.webgl.gl.drawingBufferWidth) || 0, height: ((r = this.plugin.canvas3d) === null || r === void 0 ? void 0 : r.webgl.gl.drawingBufferHeight) || 0 };
  }, e.prototype.getSize = function() {
    var t = this.values;
    switch (t.resolution.name) {
      case "viewport":
        return this.getCanvasSize();
      case "hd":
        return { width: 1280, height: 720 };
      case "full-hd":
        return { width: 1920, height: 1080 };
      case "ultra-hd":
        return { width: 3840, height: 2160 };
      default:
        return { width: t.resolution.params.width, height: t.resolution.params.height };
    }
  }, e.prototype.createPass = function(t) {
    var r = this.plugin.canvas3d, n = r.webgl.extensions, i = n.colorBufferFloat, a = n.textureFloat, o = r.props.postprocessing.occlusion;
    return r.getImagePass({ transparentBackground: this.values.transparent, cameraHelper: { axes: this.values.axes }, multiSample: { mode: t ? "on" : "off", sampleLevel: i && a ? 4 : 2 }, postprocessing: R(R({}, r.props.postprocessing), { occlusion: o.name === "on" ? { name: "on", params: R(R({}, o.params), { samples: 128, resolutionScale: 1 }) } : o }), marking: R({}, r.props.marking) });
  }, Object.defineProperty(e.prototype, "previewPass", { get: function() {
    return this._previewPass || (this._previewPass = this.createPass(!1));
  }, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "imagePass", { get: function() {
    if (this._imagePass) {
      var t = this.plugin.canvas3d, r = t.props.postprocessing.occlusion;
      return this._imagePass.setProps({ cameraHelper: { axes: this.values.axes }, transparentBackground: this.values.transparent, postprocessing: R(R({}, t.props.postprocessing), { occlusion: r.name === "on" ? { name: "on", params: R(R({}, r.params), { samples: 128, resolutionScale: 1 }) } : r }), marking: R({}, t.props.marking) }), this._imagePass;
    }
    return this._imagePass = this.createPass(!0);
  }, enumerable: !1, configurable: !0 }), e.prototype.resetCrop = function() {
    this.behaviors.relativeCrop.next({ x: 0, y: 0, width: 1, height: 1 });
  }, e.prototype.toggleAutocrop = function() {
    this.cropParams.auto ? (this.behaviors.cropParams.next(R(R({}, this.cropParams), { auto: !1 })), this.resetCrop()) : this.behaviors.cropParams.next(R(R({}, this.cropParams), { auto: !0 }));
  }, Object.defineProperty(e.prototype, "isFullFrame", { get: function() {
    var t = this.relativeCrop;
    return Ln(t.x, 0, 1e-5) && Ln(t.y, 0, 1e-5) && Ln(t.width, 1, 1e-5) && Ln(t.height, 1, 1e-5);
  }, enumerable: !1, configurable: !0 }), e.prototype.autocrop = function(t) {
    t === void 0 && (t = this.cropParams.relativePadding);
    for (var r = this.previewData.image, n = r.data, i = r.width, a = r.height, o = this.previewData.transparent, u = o ? this.previewData.background : 4278190080 | this.previewData.background, s = i, c = 0, l = a, d = 0, f = 0; f < a; f++) for (var m = f * i, v = 0; v < i; v++) {
      var p = 4 * (m + v);
      if (o) {
        if (n[p + 3] === 0) continue;
      } else if ((n[p] << 16 | n[p + 1] << 8 | n[p + 2] | n[p + 3] << 24) === u) continue;
      v < s && (s = v), v > c && (c = v), f < l && (l = f), f > d && (d = f);
    }
    if (s > c) {
      var g = s;
      s = c, c = g;
    }
    l > d && (g = l, l = d, d = g);
    var h = c - s + 1, y = d - l + 1;
    s -= t * h, c += t * h, l -= t * y, d += t * y;
    var x = { x: Math.max(0, s / i), y: Math.max(0, l / a), width: Math.min(1, (c - s + 1) / i), height: Math.min(1, (d - l + 1) / a) };
    this.behaviors.relativeCrop.next(x);
  }, e.prototype.getPreview = function(t) {
    t === void 0 && (t = 320);
    var r = this.getSize(), n = r.width, i = r.height;
    if (!(n <= 0 || i <= 0)) {
      var a = n / i, o = 0, u = 0;
      a > 1 ? (o = t, u = Math.round(t / a)) : (u = t, o = Math.round(t * a));
      var s = this.plugin.canvas3d.props;
      this.previewPass.setProps({ cameraHelper: { axes: this.values.axes }, transparentBackground: this.values.transparent, postprocessing: s.postprocessing, marking: s.marking });
      var c = this.previewPass.getImageData(o, u), l = this.previewCanvas;
      l.width = c.width, l.height = c.height, this.previewData.image = c, this.previewData.background = s.renderer.backgroundColor, this.previewData.transparent = this.values.transparent;
      var d = l.getContext("2d");
      if (!d) throw new Error("Could not create canvas 2d context");
      return d.putImageData(c, 0, 0), this.cropParams.auto && this.autocrop(), this.events.previewed.next(void 0), { canvas: l, width: o, height: u };
    }
  }, e.prototype.getSizeAndViewport = function() {
    var t = this.getSize(), r = t.width, n = t.height, i = this.relativeCrop, a = { x: Math.floor(i.x * r), y: Math.floor(i.y * n), width: Math.ceil(i.width * r), height: Math.ceil(i.height * n) };
    return a.width + a.x > r && (a.width = r - a.x), a.height + a.y > n && (a.height = n - a.y), { width: r, height: n, viewport: a };
  }, e.prototype.draw = function() {
    return _e(this, 0, void 0, function() {
      var t, r, n, i, a, o, u;
      return ye(this, function(s) {
        if (t = this.getSizeAndViewport(), r = t.width, n = t.height, i = t.viewport, r <= 0 || n <= 0) return [2];
        if (a = this.imagePass.getImageData(r, n, i), (o = this.canvas).width = a.width, o.height = a.height, !(u = o.getContext("2d"))) throw new Error("Could not create canvas 2d context");
        return u.putImageData(a, 0, 0), [2];
      });
    });
  }, e.prototype.getImageDataUri = function() {
    return _e(this, 0, void 0, function() {
      return ye(this, function(t) {
        switch (t.label) {
          case 0:
            return [4, this.draw()];
          case 1:
            return t.sent(), [2, this.canvas.toDataURL("png")];
        }
      });
    });
  }, e.prototype.copyToClipboard = function() {
    return _e(this, 0, void 0, function() {
      var t, r, n;
      return ye(this, function(i) {
        switch (i.label) {
          case 0:
            return (t = navigator.clipboard) != null && t.write ? [4, this.draw()] : [2];
          case 1:
            return i.sent(), [4, Sw(this.canvas, "png")];
          case 2:
            return r = i.sent(), n = new ClipboardItem({ "image/png": r }), [4, t.write([n])];
          case 3:
            return i.sent(), [2];
        }
      });
    });
  }, e.prototype.getAxesScale = function() {
    var t = this.getSize(), r = t.width * t.height;
    switch (!0) {
      case r <= 921600:
        return 0.22;
      case r <= 2073600:
        return 0.33;
      case r <= 8294400:
        return 0.5;
      default:
        return 0.65;
    }
  }, e.prototype.download = function(t) {
    return _e(this, 0, void 0, function() {
      return ye(this, function(r) {
        switch (r.label) {
          case 0:
            return this.behaviors.values.next({ transparent: this.values.transparent, axes: R(R({}, this.values.axes), { params: R(R(R({}, this.params.axes.defaultValue), this.values.axes.params), { scale: this.getAxesScale() }) }), resolution: this.values.resolution }), [4, this.draw()];
          case 1:
            return r.sent(), this.behaviors.cropParams.next(R(R({}, this.cropParams), { auto: !1 })), this.resetCrop(), [4, Sw(this.canvas, "png")];
          case 2:
            return eN(r.sent(), t), this.behaviors.values.next({ transparent: this.values.transparent, axes: R(R({}, this.values.axes), { params: R(R(R({}, this.params.axes.defaultValue), this.values.axes.params), { scale: 0.11 }) }), resolution: this.values.resolution }), [2];
        }
      });
    });
  }, e;
}(), Iae = G.getDefaultValues(j2), tN = function() {
  function e() {
    this.mode = Jd.Drug, this.cells = /* @__PURE__ */ new Map(), this.managers = { camera: new qD(this), representation: new QD(this), cell: new JD(this), trajectory: new $D(this), snapshot: new tI(this), selection: new rI(this), events: new nI(this), highlight: new oI(this), editor: new aI(this), screenshot: new uI(this) };
  }
  var t;
  return e.prototype.createCanvas = function(r, n) {
    var i = document.createElement("canvas");
    r.appendChild(i), Aw(i, r), this.layout = { root: r, canvas: i }, this.canvas3d = r6.create(t6.fromCanvas(i), G.merge(j2, G.getDefaultValues(j2), R({ camera: { mode: "orthographic", helper: { axes: { name: "on", params: {} } }, stereo: { name: "off", params: {} }, fov: 90, manualReset: !1 }, cameraResetDurationMs: 0, cameraFog: { name: "on", params: { intensity: 50 } }, renderer: R(R({}, Iae.renderer), { backgroundColor: He(15922682) }), postprocessing: { occlusion: { name: "off", params: {} }, outline: { name: "off", params: {} }, antialiasing: { name: "fxaa", params: { edgeThresholdMin: 0.0312, edgeThresholdMax: 0.063, iterations: 12, subpixelQuality: 0.3 } }, background: { variant: { name: "off", params: {} } }, shadow: { name: "off", params: {} } }, helper: { handle: { handle: { name: "off" } } }, transparentBackground: !1 }, n))), this.canvas3d.animate(), this.managers.representation.createContext(), this.managers.events.subscribe(), this.managers.editor.start();
  }, e.prototype.focus = function(r, n) {
    return _e(this, 0, void 0, function() {
      var i, a, o, u, s = this;
      return ye(this, function(c) {
        switch (c.label) {
          case 0:
            return i = [], a = new Set(r.map(function(l) {
              var d, f, m;
              return i.push.apply(i, (m = (f = (d = s.cells.get(l.ref)) === null || d === void 0 ? void 0 : d.dependency) === null || f === void 0 ? void 0 : f.by) !== null && m !== void 0 ? m : []), l.ref;
            })), o = new Set(i), u = Array.from(this.cells).map(function(l) {
              return { ref: l[0] };
            }).filter(function(l) {
              return !a.has(l.ref) && !o.has(l.ref);
            }), this.hide(u, !0), [4, this.show(r, n)];
          case 1:
            return c.sent(), [2, u];
        }
      });
    });
  }, e.prototype.show = function(r, n) {
    var i;
    return _e(this, 0, void 0, function() {
      var a, o, u, s, c, l = this;
      return ye(this, function(d) {
        switch (d.label) {
          case 0:
            a = function(f) {
              var m, v, p, g, h, y, x, A;
              return ye(this, function(b) {
                switch (b.label) {
                  case 0:
                    return o.managers.cell.idleCellSet.delete(f.ref), m = o.managers.cell.get(f.ref), [4, o.managers.cell.getStructure(f.ref)];
                  case 1:
                    if (b.sent(), !m || !f.representationType && Array.from(m.representations.values()).some(function(_) {
                      return !_.isHidden;
                    })) return [2, "continue"];
                    v = 0, p = Array.from(m.representations), b.label = 2;
                  case 2:
                    return v < p.length ? (g = p[v], h = g[0], (y = g[1]).state ? (!y.isHidden || f.representationType && f.representationType !== h || ((i = o.canvas3d) === null || i === void 0 || i.add(y.state), m.representations.set(h, R(R({}, y), { isHidden: !1 }))), [3, 5]) : [3, 3]) : [3, 6];
                  case 3:
                    return y.cache ? [4, Dl.managers.cell.recoveryReprCache(m, R(R({}, y.cache), { isHidden: !1 }))] : [3, 5];
                  case 4:
                    b.sent(), b.label = 5;
                  case 5:
                    return v++, [3, 2];
                  case 6:
                    return m.dependency.by.length && (x = [], A = m.dependency.by.filter(function(_) {
                      var S = l.cells.has(_);
                      if (S) {
                        if (l.cells.get(_).dependency.on.some(function(D) {
                          var I, M;
                          return Array.from((M = (I = l.cells.get(D.ref)) === null || I === void 0 ? void 0 : I.representations.values()) !== null && M !== void 0 ? M : []).filter(function(F) {
                            return F.isHidden !== !0;
                          }).length === 0;
                        })) return !1;
                      } else x.push(_);
                      return S;
                    }), o.show(A.map(function(_) {
                      return { ref: _ };
                    }), !0), x.length && o.managers.cell.update(f.ref, { model: {}, dependency: { by: A } })), [2];
                }
              });
            }, o = this, u = 0, s = r, d.label = 1;
          case 1:
            return u < s.length ? (c = s[u], [5, a(c)]) : [3, 4];
          case 2:
            d.sent(), d.label = 3;
          case 3:
            return u++, [3, 1];
          case 4:
            return n || this.managers.cell.traverse(function(f, m) {
              m.type === Te.IntraInteractions && l.managers.representation.showGlobalInteraction(void 0, "lightPlugin.show");
            }), this.managers.snapshot.event.changed.next({ from: "show" }), [2];
        }
      });
    });
  }, e.prototype.hide = function(r, n) {
    var i = this;
    r.forEach(function(a) {
      i.managers.cell.idleCellSet.add(a.ref);
      var o = i.cells.get(a.ref);
      if (o && (i.managers.selection.shape.selection.has(a.ref) && i.managers.selection.shape.remove({ item: a }), i.managers.selection.structure.selection.has(a.ref) && i.managers.selection.structure.remove({ item: { ref: a.ref, elementIds: qo(Zr(o)) } }), o.representations.forEach(function(c, l) {
        var d;
        c.isHidden || a.representationType && a.representationType !== l || (c.state && ((d = i.canvas3d) === null || d === void 0 || d.remove(c.state)), o.representations.set(l, R(R(R({}, c), { isHidden: !0 }), c.cache ? { cache: R(R({}, c.cache), { isHidden: !0 }) } : {})));
      }), o.dependency.by.length)) {
        var u = [], s = o.dependency.by.filter(function(c) {
          var l = i.cells.has(c);
          l || u.push(c);
          var d = i.cells.get(c);
          return !(d != null && d.representations.has(Te.IntraInteractions)) && l;
        });
        i.hide(s.map(function(c) {
          return { ref: c };
        }), !0), u.length && i.managers.cell.update(a.ref, { model: {}, dependency: { by: s } });
      }
    }), n || this.managers.cell.traverse(function(a, o) {
      o.type === Te.IntraInteractions && i.managers.representation.showGlobalInteraction(void 0, "lightPlugin.show");
    }), this.managers.snapshot.event.changed.next({ from: "hide" });
  }, e.prototype.toggle = function(r) {
    var n = this, i = r.types, a = r.forceAction, o = r.refs, u = Array.from(this.cells).filter(function(l) {
      var d = l[0], f = l[1], m = (!o || o.includes(d)) && i.some(function(v) {
        return f.representations.get(v);
      });
      return !!m && !!f.dependency.on.every(function(v) {
        var p = n.cells.get(v.ref);
        return !!p && !Array.from(p.representations.values()).every(function(g) {
          return g.isHidden === !0;
        });
      });
    });
    if (u.length) {
      var s = a ?? u.some(function(l) {
        l[0];
        var d = l[1];
        return i.some(function(f) {
          var m;
          return (m = d.representations.get(f)) === null || m === void 0 ? void 0 : m.isHidden;
        });
      }) ? "show" : "hide", c = LP(u.map(function(l) {
        var d = l[0], f = l[1];
        return Array.from(f.representations).filter(function(m) {
          var v = m[0];
          return i.includes(v);
        }).map(function(m) {
          return { representationType: m[0], ref: d };
        });
      }));
      this[s](c);
    }
  }, e.prototype.refresh = function(r) {
    var n, i, a, o, u;
    this.canvas3d && (!((i = (n = this.layout) === null || n === void 0 ? void 0 : n.root.children[0]) === null || i === void 0) && i.clientWidth) && (r != null && r.fixCamera && (u = this.canvas3d.camera.getSnapshot()), Aw(this.layout.canvas, this.layout.root), (a = this.canvas3d) === null || a === void 0 || a.handleResize(), r != null && r.fixCamera ? (o = this.canvas3d) === null || o === void 0 || o.camera.setState(u) : this.managers.camera.focus());
  }, e.prototype.clear = function() {
    var r;
    this.managers.selection.clear(), this.managers.highlight.clear(), this.managers.editor.changeEditorMode(_u.None), this.cells = /* @__PURE__ */ new Map(), (r = this.canvas3d) === null || r === void 0 || r.clear();
  }, e.prototype.dispose = function() {
    var r;
    (r = this.canvas3d) === null || r === void 0 || r.dispose(), this.layout = void 0, this.canvas3d = void 0, this.cells = /* @__PURE__ */ new Map(), this.managers = { camera: new qD(this), representation: new QD(this), cell: new JD(this), trajectory: new $D(this), snapshot: new tI(this), selection: new rI(this), events: new nI(this), highlight: new oI(this), editor: new aI(this), screenshot: new uI(this) };
  }, t = e, e.Utils = { sliceCellItems: function(r, n) {
    return yee(Dl, r, n);
  }, queryCellItems: function(r) {
    return aB(Dl, r);
  }, exportToPdb: function(r) {
    return _e(void 0, 0, void 0, function() {
      return ye(t, function(n) {
        switch (n.label) {
          case 0:
            return [4, Dl.managers.cell.getStructure(r.ref)];
          case 1:
            return [2, J_(n.sent(), r.elementIds, !1)];
        }
      });
    });
  }, getBox: function(r) {
    return _e(void 0, 0, void 0, function() {
      var n, i;
      return ye(t, function(a) {
        switch (a.label) {
          case 0:
            return [4, Dl.managers.cell.getStructure(r.ref)];
          case 1:
            return n = a.sent(), [2, Tie(n, (i = r.elementIds) !== null && i !== void 0 ? i : [])];
        }
      });
    });
  }, splitMolecularContent: function(r, n) {
    return D$(r, n);
  }, checkMolecularContentVerify: function(r, n) {
    return M$(r, n);
  }, getMergedContent: function(r) {
    return bee(Dl, r);
  }, traverseAtoms: function(r, n) {
    return _e(void 0, 0, void 0, function() {
      var i;
      return ye(t, function(a) {
        switch (a.label) {
          case 0:
            return [4, Dl.managers.cell.getStructure(r)];
          case 1:
            return (i = a.sent()) ? (iB(i, n), [2]) : [2];
        }
      });
    });
  } }, e;
}(), Dl = new tN();
function p0() {
  return p0 = Object.assign ? Object.assign.bind() : function(e) {
    for (var t = 1; t < arguments.length; t++) {
      var r = arguments[t];
      for (var n in r) ({}).hasOwnProperty.call(r, n) && (e[n] = r[n]);
    }
    return e;
  }, p0.apply(null, arguments);
}
var rN = {
  // minimum relative difference between two compared values,
  // used by all comparison functions
  relTol: 1e-12,
  // minimum absolute difference between two compared values,
  // used by all comparison functions
  absTol: 1e-15,
  // type of default matrix output. Choose 'matrix' (default) or 'array'
  matrix: "Matrix",
  // type of default number output. Choose 'number' (default) 'BigNumber', 'bigint', or 'Fraction'
  number: "number",
  // type of fallback used for config { number: 'bigint' } when a value cannot be represented
  // in the configured numeric type. Choose 'number' (default) or 'BigNumber'.
  numberFallback: "number",
  // number of significant digits in BigNumbers
  precision: 64,
  // predictable output type of functions. When true, output type depends only
  // on the input types. When false (default), output type can vary depending
  // on input values. For example `math.sqrt(-4)` returns `complex('2i')` when
  // predictable is false, and returns `NaN` when true.
  predictable: !1,
  // random seed for seeded pseudo random number generation
  // null = randomly seed
  randomSeed: null
};
function En(e) {
  return typeof e == "number";
}
function ti(e) {
  return !e || typeof e != "object" || typeof e.constructor != "function" ? !1 : e.isBigNumber === !0 && typeof e.constructor.prototype == "object" && e.constructor.prototype.isBigNumber === !0 || typeof e.constructor.isDecimal == "function" && e.constructor.isDecimal(e) === !0;
}
function Eae(e) {
  return typeof e == "bigint";
}
function v8(e) {
  return e && typeof e == "object" && Object.getPrototypeOf(e).isComplex === !0 || !1;
}
function g8(e) {
  return e && typeof e == "object" && Object.getPrototypeOf(e).isFraction === !0 || !1;
}
function nN(e) {
  return e && e.constructor.prototype.isUnit === !0 || !1;
}
function Yu(e) {
  return typeof e == "string";
}
var bn = Array.isArray;
function Nn(e) {
  return e && e.constructor.prototype.isMatrix === !0 || !1;
}
function og(e) {
  return Array.isArray(e) || Nn(e);
}
function iN(e) {
  return e && e.isDenseMatrix && e.constructor.prototype.isMatrix === !0 || !1;
}
function aN(e) {
  return e && e.isSparseMatrix && e.constructor.prototype.isMatrix === !0 || !1;
}
function oN(e) {
  return e && e.constructor.prototype.isRange === !0 || !1;
}
function y8(e) {
  return e && e.constructor.prototype.isIndex === !0 || !1;
}
function Mae(e) {
  return typeof e == "boolean";
}
function Tae(e) {
  return e && e.constructor.prototype.isResultSet === !0 || !1;
}
function Pae(e) {
  return e && e.constructor.prototype.isHelp === !0 || !1;
}
function Bae(e) {
  return typeof e == "function";
}
function Fae(e) {
  return e instanceof Date;
}
function Nae(e) {
  return e instanceof RegExp;
}
function b8(e) {
  return !!(e && typeof e == "object" && e.constructor === Object && !v8(e) && !g8(e));
}
function Rae(e) {
  return e === null;
}
function Oae(e) {
  return e === void 0;
}
function Lae(e) {
  return e && e.isAccessorNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function kae(e) {
  return e && e.isArrayNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function zae(e) {
  return e && e.isAssignmentNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function Gae(e) {
  return e && e.isBlockNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function Vae(e) {
  return e && e.isConditionalNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function Uae(e) {
  return e && e.isConstantNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function Hae(e) {
  return e && e.isFunctionAssignmentNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function qae(e) {
  return e && e.isFunctionNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function Kae(e) {
  return e && e.isIndexNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function Xae(e) {
  return e && e.isNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function jae(e) {
  return e && e.isObjectNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function Yae(e) {
  return e && e.isOperatorNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function Wae(e) {
  return e && e.isParenthesisNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function Zae(e) {
  return e && e.isRangeNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function Qae(e) {
  return e && e.isRelationalNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function Jae(e) {
  return e && e.isSymbolNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function $ae(e) {
  return e && e.constructor.prototype.isChain === !0 || !1;
}
function Ic(e) {
  var t = typeof e;
  return t === "object" ? e === null ? "null" : ti(e) ? "BigNumber" : e.constructor && e.constructor.name ? e.constructor.name : "Object" : t;
}
function Wr(e) {
  var t = typeof e;
  if (t === "number" || t === "bigint" || t === "string" || t === "boolean" || e === null || e === void 0)
    return e;
  if (typeof e.clone == "function")
    return e.clone();
  if (Array.isArray(e))
    return e.map(function(r) {
      return Wr(r);
    });
  if (e instanceof Date) return new Date(e.valueOf());
  if (ti(e)) return e;
  if (b8(e))
    return eoe(e, Wr);
  throw new TypeError("Cannot clone: unknown type of value (value: ".concat(e, ")"));
}
function eoe(e, t) {
  var r = {};
  for (var n in e)
    bm(e, n) && (r[n] = t(e[n]));
  return r;
}
function uN(e, t) {
  for (var r in t)
    bm(t, r) && (e[r] = t[r]);
  return e;
}
function ud(e, t) {
  var r, n, i;
  if (Array.isArray(e)) {
    if (!Array.isArray(t) || e.length !== t.length)
      return !1;
    for (n = 0, i = e.length; n < i; n++)
      if (!ud(e[n], t[n]))
        return !1;
    return !0;
  } else {
    if (typeof e == "function")
      return e === t;
    if (e instanceof Object) {
      if (Array.isArray(t) || !(t instanceof Object))
        return !1;
      for (r in e)
        if (!(r in t) || !ud(e[r], t[r]))
          return !1;
      for (r in t)
        if (!(r in e))
          return !1;
      return !0;
    } else
      return e === t;
  }
}
function bm(e, t) {
  return e && Object.hasOwnProperty.call(e, t);
}
function toe(e, t) {
  for (var r = {}, n = 0; n < t.length; n++) {
    var i = t[n], a = e[i];
    a !== void 0 && (r[i] = a);
  }
  return r;
}
var roe = ["Matrix", "Array"], noe = ["number", "BigNumber", "Fraction"], sa = function(t) {
  if (t)
    throw new Error(`The global config is readonly. 
Please create a mathjs instance if you want to change the default configuration. 
Example:

  import { create, all } from 'mathjs';
  const mathjs = create(all);
  mathjs.config({ number: 'BigNumber' });
`);
  return Object.freeze(rN);
};
p0(sa, rN, {
  MATRIX_OPTIONS: roe,
  NUMBER_OPTIONS: noe
});
function sI() {
  return !0;
}
function vu() {
  return !1;
}
function S1() {
}
const cI = "Argument is not a typed-function.";
function sN() {
  function e(re) {
    return typeof re == "object" && re !== null && re.constructor === Object;
  }
  const t = [{
    name: "number",
    test: function(re) {
      return typeof re == "number";
    }
  }, {
    name: "string",
    test: function(re) {
      return typeof re == "string";
    }
  }, {
    name: "boolean",
    test: function(re) {
      return typeof re == "boolean";
    }
  }, {
    name: "Function",
    test: function(re) {
      return typeof re == "function";
    }
  }, {
    name: "Array",
    test: Array.isArray
  }, {
    name: "Date",
    test: function(re) {
      return re instanceof Date;
    }
  }, {
    name: "RegExp",
    test: function(re) {
      return re instanceof RegExp;
    }
  }, {
    name: "Object",
    test: e
  }, {
    name: "null",
    test: function(re) {
      return re === null;
    }
  }, {
    name: "undefined",
    test: function(re) {
      return re === void 0;
    }
  }], r = {
    name: "any",
    test: sI,
    isAny: !0
  };
  let n, i, a = 0, o = {
    createCount: 0
  };
  function u(re) {
    const J = n.get(re);
    if (J)
      return J;
    let ce = 'Unknown type "' + re + '"';
    const de = re.toLowerCase();
    let ve;
    for (ve of i)
      if (ve.toLowerCase() === de) {
        ce += '. Did you mean "' + ve + '" ?';
        break;
      }
    throw new TypeError(ce);
  }
  function s(re) {
    let J = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "any";
    const ce = J ? u(J).index : i.length, de = [];
    for (let he = 0; he < re.length; ++he) {
      if (!re[he] || typeof re[he].name != "string" || typeof re[he].test != "function")
        throw new TypeError("Object with properties {name: string, test: function} expected");
      const Se = re[he].name;
      if (n.has(Se))
        throw new TypeError('Duplicate type name "' + Se + '"');
      de.push(Se), n.set(Se, {
        name: Se,
        test: re[he].test,
        isAny: re[he].isAny,
        index: ce + he,
        conversionsTo: []
        // Newly added type can't have any conversions to it
      });
    }
    const ve = i.slice(ce);
    i = i.slice(0, ce).concat(de).concat(ve);
    for (let he = ce + de.length; he < i.length; ++he)
      n.get(i[he]).index = he;
  }
  function c() {
    n = /* @__PURE__ */ new Map(), i = [], a = 0, s([r], !1);
  }
  c(), s(t);
  function l() {
    let re;
    for (re of i)
      n.get(re).conversionsTo = [];
    a = 0;
  }
  function d(re) {
    const J = i.filter((ce) => {
      const de = n.get(ce);
      return !de.isAny && de.test(re);
    });
    return J.length ? J : ["any"];
  }
  function f(re) {
    return re && typeof re == "function" && "_typedFunctionData" in re;
  }
  function m(re, J, ce) {
    if (!f(re))
      throw new TypeError(cI);
    const de = ce && ce.exact, ve = Array.isArray(J) ? J.join(",") : J, he = A(ve), Se = g(he);
    if (!de || Se in re.signatures) {
      const mt = re._typedFunctionData.signatureMap.get(Se);
      if (mt)
        return mt;
    }
    const Re = he.length;
    let Ve;
    if (de) {
      Ve = [];
      let mt;
      for (mt in re.signatures)
        Ve.push(re._typedFunctionData.signatureMap.get(mt));
    } else
      Ve = re._typedFunctionData.signatures;
    for (let mt = 0; mt < Re; ++mt) {
      const bt = he[mt], Ct = [];
      let De;
      for (De of Ve) {
        const ut = D(De.params, mt);
        if (!(!ut || bt.restParam && !ut.restParam)) {
          if (!ut.hasAny) {
            const It = x(ut);
            if (bt.types.some((ur) => !It.has(ur.name)))
              continue;
          }
          Ct.push(De);
        }
      }
      if (Ve = Ct, Ve.length === 0) break;
    }
    let ze;
    for (ze of Ve)
      if (ze.params.length <= Re)
        return ze;
    throw new TypeError("Signature not found (signature: " + (re.name || "unnamed") + "(" + g(he, ", ") + "))");
  }
  function v(re, J, ce) {
    return m(re, J, ce).implementation;
  }
  function p(re, J) {
    const ce = u(J);
    if (ce.test(re))
      return re;
    const de = ce.conversionsTo;
    if (de.length === 0)
      throw new Error("There are no conversions to " + J + " defined.");
    for (let ve = 0; ve < de.length; ve++)
      if (u(de[ve].from).test(re))
        return de[ve].convert(re);
    throw new Error("Cannot convert " + re + " to " + J);
  }
  function g(re) {
    let J = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ",";
    return re.map((ce) => ce.name).join(J);
  }
  function h(re) {
    const J = re.indexOf("...") === 0, de = (J ? re.length > 3 ? re.slice(3) : "any" : re).split("|").map((Re) => u(Re.trim()));
    let ve = !1, he = J ? "..." : "";
    return {
      types: de.map(function(Re) {
        return ve = Re.isAny || ve, he += Re.name + "|", {
          name: Re.name,
          typeIndex: Re.index,
          test: Re.test,
          isAny: Re.isAny,
          conversion: null,
          conversionIndex: -1
        };
      }),
      name: he.slice(0, -1),
      // remove trailing '|' from above
      hasAny: ve,
      hasConversion: !1,
      restParam: J
    };
  }
  function y(re) {
    const J = re.types.map((Se) => Se.name), ce = z(J);
    let de = re.hasAny, ve = re.name;
    const he = ce.map(function(Se) {
      const Re = u(Se.from);
      return de = Re.isAny || de, ve += "|" + Se.from, {
        name: Se.from,
        typeIndex: Re.index,
        test: Re.test,
        isAny: Re.isAny,
        conversion: Se,
        conversionIndex: Se.index
      };
    });
    return {
      types: re.types.concat(he),
      name: ve,
      hasAny: de,
      hasConversion: he.length > 0,
      restParam: re.restParam
    };
  }
  function x(re) {
    return re.typeSet || (re.typeSet = /* @__PURE__ */ new Set(), re.types.forEach((J) => re.typeSet.add(J.name))), re.typeSet;
  }
  function A(re) {
    const J = [];
    if (typeof re != "string")
      throw new TypeError("Signatures must be strings");
    const ce = re.trim();
    if (ce === "")
      return J;
    const de = ce.split(",");
    for (let ve = 0; ve < de.length; ++ve) {
      const he = h(de[ve].trim());
      if (he.restParam && ve !== de.length - 1)
        throw new SyntaxError('Unexpected rest parameter "' + de[ve] + '": only allowed for the last parameter');
      if (he.types.length === 0)
        return null;
      J.push(he);
    }
    return J;
  }
  function b(re) {
    const J = ie(re);
    return J ? J.restParam : !1;
  }
  function _(re) {
    if (!re || re.types.length === 0)
      return sI;
    if (re.types.length === 1)
      return u(re.types[0].name).test;
    if (re.types.length === 2) {
      const J = u(re.types[0].name).test, ce = u(re.types[1].name).test;
      return function(ve) {
        return J(ve) || ce(ve);
      };
    } else {
      const J = re.types.map(function(ce) {
        return u(ce.name).test;
      });
      return function(de) {
        for (let ve = 0; ve < J.length; ve++)
          if (J[ve](de))
            return !0;
        return !1;
      };
    }
  }
  function S(re) {
    let J, ce, de;
    if (b(re)) {
      J = $(re).map(_);
      const ve = J.length, he = _(ie(re)), Se = function(Re) {
        for (let Ve = ve; Ve < Re.length; Ve++)
          if (!he(Re[Ve]))
            return !1;
        return !0;
      };
      return function(Ve) {
        for (let ze = 0; ze < J.length; ze++)
          if (!J[ze](Ve[ze]))
            return !1;
        return Se(Ve) && Ve.length >= ve + 1;
      };
    } else
      return re.length === 0 ? function(he) {
        return he.length === 0;
      } : re.length === 1 ? (ce = _(re[0]), function(he) {
        return ce(he[0]) && he.length === 1;
      }) : re.length === 2 ? (ce = _(re[0]), de = _(re[1]), function(he) {
        return ce(he[0]) && de(he[1]) && he.length === 2;
      }) : (J = re.map(_), function(he) {
        for (let Se = 0; Se < J.length; Se++)
          if (!J[Se](he[Se]))
            return !1;
        return he.length === J.length;
      });
  }
  function D(re, J) {
    return J < re.length ? re[J] : b(re) ? ie(re) : null;
  }
  function I(re, J) {
    const ce = D(re, J);
    return ce ? x(ce) : /* @__PURE__ */ new Set();
  }
  function M(re) {
    return re.conversion === null || re.conversion === void 0;
  }
  function F(re, J) {
    const ce = /* @__PURE__ */ new Set();
    return re.forEach((de) => {
      const ve = I(de.params, J);
      let he;
      for (he of ve)
        ce.add(he);
    }), ce.has("any") ? ["any"] : Array.from(ce);
  }
  function P(re, J, ce) {
    let de, ve;
    const he = re || "unnamed";
    let Se = ce, Re;
    for (Re = 0; Re < J.length; Re++) {
      const bt = [];
      if (Se.forEach((Ct) => {
        const De = D(Ct.params, Re), ut = _(De);
        (Re < Ct.params.length || b(Ct.params)) && ut(J[Re]) && bt.push(Ct);
      }), bt.length === 0) {
        if (ve = F(Se, Re), ve.length > 0) {
          const Ct = d(J[Re]);
          return de = new TypeError("Unexpected type of argument in function " + he + " (expected: " + ve.join(" or ") + ", actual: " + Ct.join(" | ") + ", index: " + Re + ")"), de.data = {
            category: "wrongType",
            fn: he,
            index: Re,
            actual: Ct,
            expected: ve
          }, de;
        }
      } else
        Se = bt;
    }
    const Ve = Se.map(function(bt) {
      return b(bt.params) ? 1 / 0 : bt.params.length;
    });
    if (J.length < Math.min.apply(null, Ve))
      return ve = F(Se, Re), de = new TypeError("Too few arguments in function " + he + " (expected: " + ve.join(" or ") + ", index: " + J.length + ")"), de.data = {
        category: "tooFewArgs",
        fn: he,
        index: J.length,
        expected: ve
      }, de;
    const ze = Math.max.apply(null, Ve);
    if (J.length > ze)
      return de = new TypeError("Too many arguments in function " + he + " (expected: " + ze + ", actual: " + J.length + ")"), de.data = {
        category: "tooManyArgs",
        fn: he,
        index: J.length,
        expectedLength: ze
      }, de;
    const mt = [];
    for (let bt = 0; bt < J.length; ++bt)
      mt.push(d(J[bt]).join("|"));
    return de = new TypeError('Arguments of type "' + mt.join(", ") + '" do not match any of the defined signatures of function ' + he + "."), de.data = {
      category: "mismatch",
      actual: mt
    }, de;
  }
  function E(re) {
    let J = i.length + 1;
    for (let ce = 0; ce < re.types.length; ce++)
      M(re.types[ce]) && (J = Math.min(J, re.types[ce].typeIndex));
    return J;
  }
  function B(re) {
    let J = a + 1;
    for (let ce = 0; ce < re.types.length; ce++)
      M(re.types[ce]) || (J = Math.min(J, re.types[ce].conversionIndex));
    return J;
  }
  function N(re, J) {
    if (re.hasAny) {
      if (!J.hasAny)
        return 1;
    } else if (J.hasAny)
      return -1;
    if (re.restParam) {
      if (!J.restParam)
        return 1;
    } else if (J.restParam)
      return -1;
    if (re.hasConversion) {
      if (!J.hasConversion)
        return 1;
    } else if (J.hasConversion)
      return -1;
    const ce = E(re) - E(J);
    if (ce < 0)
      return -1;
    if (ce > 0)
      return 1;
    const de = B(re) - B(J);
    return de < 0 ? -1 : de > 0 ? 1 : 0;
  }
  function O(re, J) {
    const ce = re.params, de = J.params, ve = ie(ce), he = ie(de), Se = b(ce), Re = b(de);
    if (Se && ve.hasAny) {
      if (!Re || !he.hasAny)
        return 1;
    } else if (Re && he.hasAny)
      return -1;
    let Ve = 0, ze = 0, mt;
    for (mt of ce)
      mt.hasAny && ++Ve, mt.hasConversion && ++ze;
    let bt = 0, Ct = 0;
    for (mt of de)
      mt.hasAny && ++bt, mt.hasConversion && ++Ct;
    if (Ve !== bt)
      return Ve - bt;
    if (Se && ve.hasConversion) {
      if (!Re || !he.hasConversion)
        return 1;
    } else if (Re && he.hasConversion)
      return -1;
    if (ze !== Ct)
      return ze - Ct;
    if (Se) {
      if (!Re)
        return 1;
    } else if (Re)
      return -1;
    const De = (ce.length - de.length) * (Se ? -1 : 1);
    if (De !== 0)
      return De;
    const ut = [];
    let It = 0;
    for (let nr = 0; nr < ce.length; ++nr) {
      const Er = N(ce[nr], de[nr]);
      ut.push(Er), It += Er;
    }
    if (It !== 0)
      return It;
    let ur;
    for (ur of ut)
      if (ur !== 0)
        return ur;
    return 0;
  }
  function z(re) {
    if (re.length === 0)
      return [];
    const J = re.map(u);
    re.length > 1 && J.sort((ve, he) => ve.index - he.index);
    let ce = J[0].conversionsTo;
    if (re.length === 1)
      return ce;
    ce = ce.concat([]);
    const de = new Set(re);
    for (let ve = 1; ve < J.length; ++ve) {
      let he;
      for (he of J[ve].conversionsTo)
        de.has(he.from) || (ce.push(he), de.add(he.from));
    }
    return ce;
  }
  function V(re, J) {
    let ce = J;
    if (re.some((ve) => ve.hasConversion)) {
      const ve = b(re), he = re.map(U);
      ce = function() {
        const Re = [], Ve = ve ? arguments.length - 1 : arguments.length;
        for (let ze = 0; ze < Ve; ze++)
          Re[ze] = he[ze](arguments[ze]);
        return ve && (Re[Ve] = arguments[Ve].map(he[Ve])), J.apply(this, Re);
      };
    }
    let de = ce;
    if (b(re)) {
      const ve = re.length - 1;
      de = function() {
        return ce.apply(this, ae(arguments, 0, ve).concat([ae(arguments, ve)]));
      };
    }
    return de;
  }
  function U(re) {
    let J, ce, de, ve;
    const he = [], Se = [];
    switch (re.types.forEach(function(Re) {
      Re.conversion && (he.push(u(Re.conversion.from).test), Se.push(Re.conversion.convert));
    }), Se.length) {
      case 0:
        return function(Ve) {
          return Ve;
        };
      case 1:
        return J = he[0], de = Se[0], function(Ve) {
          return J(Ve) ? de(Ve) : Ve;
        };
      case 2:
        return J = he[0], ce = he[1], de = Se[0], ve = Se[1], function(Ve) {
          return J(Ve) ? de(Ve) : ce(Ve) ? ve(Ve) : Ve;
        };
      default:
        return function(Ve) {
          for (let ze = 0; ze < Se.length; ze++)
            if (he[ze](Ve))
              return Se[ze](Ve);
          return Ve;
        };
    }
  }
  function H(re) {
    function J(ce, de, ve) {
      if (de < ce.length) {
        const he = ce[de];
        let Se = [];
        if (he.restParam) {
          const Re = he.types.filter(M);
          Re.length < he.types.length && Se.push({
            types: Re,
            name: "..." + Re.map((Ve) => Ve.name).join("|"),
            hasAny: Re.some((Ve) => Ve.isAny),
            hasConversion: !1,
            restParam: !0
          }), Se.push(he);
        } else
          Se = he.types.map(function(Re) {
            return {
              types: [Re],
              name: Re.name,
              hasAny: Re.isAny,
              hasConversion: Re.conversion,
              restParam: !1
            };
          });
        return le(Se, function(Re) {
          return J(ce, de + 1, ve.concat([Re]));
        });
      } else
        return [ve];
    }
    return J(re, 0, []);
  }
  function K(re, J) {
    const ce = Math.max(re.length, J.length);
    for (let Re = 0; Re < ce; Re++) {
      const Ve = I(re, Re), ze = I(J, Re);
      let mt = !1, bt;
      for (bt of ze)
        if (Ve.has(bt)) {
          mt = !0;
          break;
        }
      if (!mt)
        return !1;
    }
    const de = re.length, ve = J.length, he = b(re), Se = b(J);
    return he ? Se ? de === ve : ve >= de : Se ? de >= ve : de === ve;
  }
  function j(re) {
    return re.map((J) => Ke(J) ? Ge(J.referToSelf.callback) : Ue(J) ? we(J.referTo.references, J.referTo.callback) : J);
  }
  function X(re, J, ce) {
    const de = [];
    let ve;
    for (ve of re) {
      let he = ce[ve];
      if (typeof he != "number")
        throw new TypeError('No definition for referenced signature "' + ve + '"');
      if (he = J[he], typeof he != "function")
        return !1;
      de.push(he);
    }
    return de;
  }
  function W(re, J, ce) {
    const de = j(re), ve = new Array(de.length).fill(!1);
    let he = !0;
    for (; he; ) {
      he = !1;
      let Se = !0;
      for (let Re = 0; Re < de.length; ++Re) {
        if (ve[Re]) continue;
        const Ve = de[Re];
        if (Ke(Ve))
          de[Re] = Ve.referToSelf.callback(ce), de[Re].referToSelf = Ve.referToSelf, ve[Re] = !0, Se = !1;
        else if (Ue(Ve)) {
          const ze = X(Ve.referTo.references, de, J);
          ze ? (de[Re] = Ve.referTo.callback.apply(this, ze), de[Re].referTo = Ve.referTo, ve[Re] = !0, Se = !1) : he = !0;
        }
      }
      if (Se && he)
        throw new SyntaxError("Circular reference detected in resolving typed.referTo");
    }
    return de;
  }
  function Q(re) {
    const J = /\bthis(\(|\.signatures\b)/;
    Object.keys(re).forEach((ce) => {
      const de = re[ce];
      if (J.test(de.toString()))
        throw new SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.");
    });
  }
  function te(re, J) {
    if (o.createCount++, Object.keys(J).length === 0)
      throw new SyntaxError("No signatures provided");
    o.warnAgainstDeprecatedThis && Q(J);
    const ce = [], de = [], ve = {}, he = [];
    let Se;
    for (Se in J) {
      if (!Object.prototype.hasOwnProperty.call(J, Se))
        continue;
      const Fr = A(Se);
      if (!Fr) continue;
      ce.forEach(function(us) {
        if (K(us, Fr))
          throw new TypeError('Conflicting signatures "' + g(us) + '" and "' + g(Fr) + '".');
      }), ce.push(Fr);
      const Ki = de.length;
      de.push(J[Se]);
      const E0 = Fr.map(y);
      let Wc;
      for (Wc of H(E0)) {
        const us = g(Wc);
        he.push({
          params: Wc,
          name: us,
          fn: Ki
        }), Wc.every((Ff) => !Ff.hasConversion) && (ve[us] = Ki);
      }
    }
    he.sort(O);
    const Re = W(de, ve, Vs);
    let Ve;
    for (Ve in ve)
      Object.prototype.hasOwnProperty.call(ve, Ve) && (ve[Ve] = Re[ve[Ve]]);
    const ze = [], mt = /* @__PURE__ */ new Map();
    for (Ve of he)
      mt.has(Ve.name) || (Ve.fn = Re[Ve.fn], ze.push(Ve), mt.set(Ve.name, Ve));
    const bt = ze[0] && ze[0].params.length <= 2 && !b(ze[0].params), Ct = ze[1] && ze[1].params.length <= 2 && !b(ze[1].params), De = ze[2] && ze[2].params.length <= 2 && !b(ze[2].params), ut = ze[3] && ze[3].params.length <= 2 && !b(ze[3].params), It = ze[4] && ze[4].params.length <= 2 && !b(ze[4].params), ur = ze[5] && ze[5].params.length <= 2 && !b(ze[5].params), nr = bt && Ct && De && ut && It && ur;
    for (let Fr = 0; Fr < ze.length; ++Fr)
      ze[Fr].test = S(ze[Fr].params);
    const Er = bt ? _(ze[0].params[0]) : vu, dr = Ct ? _(ze[1].params[0]) : vu, ln = De ? _(ze[2].params[0]) : vu, Gn = ut ? _(ze[3].params[0]) : vu, Rn = It ? _(ze[4].params[0]) : vu, Cn = ur ? _(ze[5].params[0]) : vu, Jr = bt ? _(ze[0].params[1]) : vu, ni = Ct ? _(ze[1].params[1]) : vu, $r = De ? _(ze[2].params[1]) : vu, en = ut ? _(ze[3].params[1]) : vu, fi = It ? _(ze[4].params[1]) : vu, pi = ur ? _(ze[5].params[1]) : vu;
    for (let Fr = 0; Fr < ze.length; ++Fr)
      ze[Fr].implementation = V(ze[Fr].params, ze[Fr].fn);
    const za = bt ? ze[0].implementation : S1, wn = Ct ? ze[1].implementation : S1, dn = De ? ze[2].implementation : S1, wo = ut ? ze[3].implementation : S1, Do = It ? ze[4].implementation : S1, io = ur ? ze[5].implementation : S1, os = bt ? ze[0].params.length : -1, Ga = Ct ? ze[1].params.length : -1, mi = De ? ze[2].params.length : -1, Gs = ut ? ze[3].params.length : -1, Hc = It ? ze[4].params.length : -1, qc = ur ? ze[5].params.length : -1, Kc = nr ? 6 : 0, Xc = ze.length, jc = ze.map((Fr) => Fr.test), Bf = ze.map((Fr) => Fr.implementation), Yc = function() {
      for (let Ki = Kc; Ki < Xc; Ki++)
        if (jc[Ki](arguments))
          return Bf[Ki].apply(this, arguments);
      return o.onMismatch(re, arguments, ze);
    };
    function Vs(Fr, Ki) {
      return arguments.length === os && Er(Fr) && Jr(Ki) ? za.apply(this, arguments) : arguments.length === Ga && dr(Fr) && ni(Ki) ? wn.apply(this, arguments) : arguments.length === mi && ln(Fr) && $r(Ki) ? dn.apply(this, arguments) : arguments.length === Gs && Gn(Fr) && en(Ki) ? wo.apply(this, arguments) : arguments.length === Hc && Rn(Fr) && fi(Ki) ? Do.apply(this, arguments) : arguments.length === qc && Cn(Fr) && pi(Ki) ? io.apply(this, arguments) : Yc.apply(this, arguments);
    }
    try {
      Object.defineProperty(Vs, "name", {
        value: re
      });
    } catch {
    }
    return Vs.signatures = ve, Vs._typedFunctionData = {
      signatures: ze,
      signatureMap: mt
    }, Vs;
  }
  function ee(re, J, ce) {
    throw P(re, J, ce);
  }
  function $(re) {
    return ae(re, 0, re.length - 1);
  }
  function ie(re) {
    return re[re.length - 1];
  }
  function ae(re, J, ce) {
    return Array.prototype.slice.call(re, J, ce);
  }
  function se(re, J) {
    for (let ce = 0; ce < re.length; ce++)
      if (J(re[ce]))
        return re[ce];
  }
  function le(re, J) {
    return Array.prototype.concat.apply([], re.map(J));
  }
  function pe() {
    const re = $(arguments).map((ce) => g(A(ce))), J = ie(arguments);
    if (typeof J != "function")
      throw new TypeError("Callback function expected as last argument");
    return we(re, J);
  }
  function we(re, J) {
    return {
      referTo: {
        references: re,
        callback: J
      }
    };
  }
  function Ge(re) {
    if (typeof re != "function")
      throw new TypeError("Callback function expected as first argument");
    return {
      referToSelf: {
        callback: re
      }
    };
  }
  function Ue(re) {
    return re && typeof re.referTo == "object" && Array.isArray(re.referTo.references) && typeof re.referTo.callback == "function";
  }
  function Ke(re) {
    return re && typeof re.referToSelf == "object" && typeof re.referToSelf.callback == "function";
  }
  function Ze(re, J) {
    if (!re)
      return J;
    if (J && J !== re) {
      const ce = new Error("Function names do not match (expected: " + re + ", actual: " + J + ")");
      throw ce.data = {
        actual: J,
        expected: re
      }, ce;
    }
    return re;
  }
  function Fe(re) {
    let J;
    for (const ce in re)
      Object.prototype.hasOwnProperty.call(re, ce) && (f(re[ce]) || typeof re[ce].signature == "string") && (J = Ze(J, re[ce].name));
    return J;
  }
  function Je(re, J) {
    let ce;
    for (ce in J)
      if (Object.prototype.hasOwnProperty.call(J, ce)) {
        if (ce in re && J[ce] !== re[ce]) {
          const de = new Error('Signature "' + ce + '" is defined twice');
          throw de.data = {
            signature: ce,
            sourceFunction: J[ce],
            destFunction: re[ce]
          }, de;
        }
        re[ce] = J[ce];
      }
  }
  const Ne = o;
  o = function(re) {
    const J = typeof re == "string", ce = J ? 1 : 0;
    let de = J ? re : "";
    const ve = {};
    for (let he = ce; he < arguments.length; ++he) {
      const Se = arguments[he];
      let Re = {}, Ve;
      if (typeof Se == "function" ? (Ve = Se.name, typeof Se.signature == "string" ? Re[Se.signature] = Se : f(Se) && (Re = Se.signatures)) : e(Se) && (Re = Se, J || (Ve = Fe(Se))), Object.keys(Re).length === 0) {
        const ze = new TypeError("Argument to 'typed' at index " + he + " is not a (typed) function, nor an object with signatures as keys and functions as values.");
        throw ze.data = {
          index: he,
          argument: Se
        }, ze;
      }
      J || (de = Ze(de, Ve)), Je(ve, Re);
    }
    return te(de || "", ve);
  }, o.create = sN, o.createCount = Ne.createCount, o.onMismatch = ee, o.throwMismatchError = ee, o.createError = P, o.clear = c, o.clearConversions = l, o.addTypes = s, o._findType = u, o.referTo = pe, o.referToSelf = Ge, o.convert = p, o.findSignature = m, o.find = v, o.isTypedFunction = f, o.warnAgainstDeprecatedThis = !0, o.addType = function(re, J) {
    let ce = "any";
    J !== !1 && n.has("Object") && (ce = "Object"), o.addTypes([re], ce);
  };
  function nt(re) {
    if (!re || typeof re.from != "string" || typeof re.to != "string" || typeof re.convert != "function")
      throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");
    if (re.to === re.from)
      throw new SyntaxError('Illegal to define conversion from "' + re.from + '" to itself.');
  }
  return o.addConversion = function(re) {
    let J = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
      override: !1
    };
    nt(re);
    const ce = u(re.to), de = ce.conversionsTo.find((ve) => ve.from === re.from);
    if (de)
      if (J && J.override)
        o.removeConversion({
          from: de.from,
          to: re.to,
          convert: de.convert
        });
      else
        throw new Error('There is already a conversion from "' + re.from + '" to "' + ce.name + '"');
    ce.conversionsTo.push({
      from: re.from,
      convert: re.convert,
      index: a++
    });
  }, o.addConversions = function(re, J) {
    re.forEach((ce) => o.addConversion(ce, J));
  }, o.removeConversion = function(re) {
    nt(re);
    const J = u(re.to), ce = se(J.conversionsTo, (ve) => ve.from === re.from);
    if (!ce)
      throw new Error("Attempt to remove nonexistent conversion from " + re.from + " to " + re.to);
    if (ce.convert !== re.convert)
      throw new Error("Conversion to remove does not match existing conversion");
    const de = J.conversionsTo.indexOf(ce);
    J.conversionsTo.splice(de, 1);
  }, o.resolve = function(re, J) {
    if (!f(re))
      throw new TypeError(cI);
    const ce = re._typedFunctionData.signatures;
    for (let de = 0; de < ce.length; ++de)
      if (ce[de].test(J))
        return ce[de];
    return null;
  }, o;
}
const lI = sN();
function Mn(e) {
  return typeof e == "boolean" ? !0 : isFinite(e) ? e === Math.round(e) : !1;
}
var ioe = Math.sign || function(e) {
  return e > 0 ? 1 : e < 0 ? -1 : 0;
};
function H5(e, t, r) {
  var n = {
    2: "0b",
    8: "0o",
    16: "0x"
  }, i = n[t], a = "";
  if (r) {
    if (r < 1)
      throw new Error("size must be in greater than 0");
    if (!Mn(r))
      throw new Error("size must be an integer");
    if (e > 2 ** (r - 1) - 1 || e < -(2 ** (r - 1)))
      throw new Error("Value must be in range [-2^".concat(r - 1, ", 2^").concat(r - 1, "-1]"));
    if (!Mn(e))
      throw new Error("Value must be an integer");
    e < 0 && (e = e + 2 ** r), a = "i".concat(r);
  }
  var o = "";
  return e < 0 && (e = -e, o = "-"), "".concat(o).concat(i).concat(e.toString(t)).concat(a);
}
function U6(e, t) {
  if (typeof t == "function")
    return t(e);
  if (e === 1 / 0)
    return "Infinity";
  if (e === -1 / 0)
    return "-Infinity";
  if (isNaN(e))
    return "NaN";
  var {
    notation: r,
    precision: n,
    wordSize: i
  } = cN(t);
  switch (r) {
    case "fixed":
      return lN(e, n);
    case "exponential":
      return dN(e, n);
    case "engineering":
      return aoe(e, n);
    case "bin":
      return H5(e, 2, i);
    case "oct":
      return H5(e, 8, i);
    case "hex":
      return H5(e, 16, i);
    case "auto":
      return ooe(e, n, t).replace(/((\.\d*?)(0+))($|e)/, function() {
        var a = arguments[2], o = arguments[4];
        return a !== "." ? a + o : o;
      });
    default:
      throw new Error('Unknown notation "' + r + '". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.');
  }
}
function cN(e) {
  var t = "auto", r, n;
  if (e !== void 0)
    if (En(e))
      r = e;
    else if (ti(e))
      r = e.toNumber();
    else if (b8(e))
      e.precision !== void 0 && (r = dI(e.precision, () => {
        throw new Error('Option "precision" must be a number or BigNumber');
      })), e.wordSize !== void 0 && (n = dI(e.wordSize, () => {
        throw new Error('Option "wordSize" must be a number or BigNumber');
      })), e.notation && (t = e.notation);
    else
      throw new Error("Unsupported type of options, number, BigNumber, or object expected");
  return {
    notation: t,
    precision: r,
    wordSize: n
  };
}
function Nm(e) {
  var t = String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);
  if (!t)
    throw new SyntaxError("Invalid number " + e);
  var r = t[1], n = t[2], i = parseFloat(t[4] || "0"), a = n.indexOf(".");
  i += a !== -1 ? a - 1 : n.length - 1;
  var o = n.replace(".", "").replace(/^0*/, function(u) {
    return i -= u.length, "";
  }).replace(/0*$/, "").split("").map(function(u) {
    return parseInt(u);
  });
  return o.length === 0 && (o.push(0), i++), {
    sign: r,
    coefficients: o,
    exponent: i
  };
}
function aoe(e, t) {
  if (isNaN(e) || !isFinite(e))
    return String(e);
  var r = Nm(e), n = Qg(r, t), i = n.exponent, a = n.coefficients, o = i % 3 === 0 ? i : i < 0 ? i - 3 - i % 3 : i - i % 3;
  if (En(t))
    for (; t > a.length || i - o + 1 > a.length; )
      a.push(0);
  else
    for (var u = Math.abs(i - o) - (a.length - 1), s = 0; s < u; s++)
      a.push(0);
  for (var c = Math.abs(i - o), l = 1; c > 0; )
    l++, c--;
  var d = a.slice(l).join(""), f = En(t) && d.length || d.match(/[1-9]/) ? "." + d : "", m = a.slice(0, l).join("") + f + "e" + (i >= 0 ? "+" : "") + o.toString();
  return n.sign + m;
}
function lN(e, t) {
  if (isNaN(e) || !isFinite(e))
    return String(e);
  var r = Nm(e), n = typeof t == "number" ? Qg(r, r.exponent + 1 + t) : r, i = n.coefficients, a = n.exponent + 1, o = a + (t || 0);
  return i.length < o && (i = i.concat(G1(o - i.length))), a < 0 && (i = G1(-a + 1).concat(i), a = 1), a < i.length && i.splice(a, 0, a === 0 ? "0." : "."), n.sign + i.join("");
}
function dN(e, t) {
  if (isNaN(e) || !isFinite(e))
    return String(e);
  var r = Nm(e), n = t ? Qg(r, t) : r, i = n.coefficients, a = n.exponent;
  i.length < t && (i = i.concat(G1(t - i.length)));
  var o = i.shift();
  return n.sign + o + (i.length > 0 ? "." + i.join("") : "") + "e" + (a >= 0 ? "+" : "") + a;
}
function ooe(e, t, r) {
  if (isNaN(e) || !isFinite(e))
    return String(e);
  var n = fI(r == null ? void 0 : r.lowerExp, -3), i = fI(r == null ? void 0 : r.upperExp, 5), a = Nm(e), o = t ? Qg(a, t) : a;
  if (o.exponent < n || o.exponent >= i)
    return dN(e, t);
  var u = o.coefficients, s = o.exponent;
  u.length < t && (u = u.concat(G1(t - u.length))), u = u.concat(G1(s - u.length + 1 + (u.length < t ? t - u.length : 0))), u = G1(-s).concat(u);
  var c = s > 0 ? s : 0;
  return c < u.length - 1 && u.splice(c + 1, 0, "."), o.sign + u.join("");
}
function Qg(e, t) {
  for (var r = {
    sign: e.sign,
    coefficients: e.coefficients,
    exponent: e.exponent
  }, n = r.coefficients; t <= 0; )
    n.unshift(0), r.exponent++, t++;
  if (n.length > t) {
    var i = n.splice(t, n.length - t);
    if (i[0] >= 5) {
      var a = t - 1;
      for (n[a]++; n[a] === 10; )
        n.pop(), a === 0 && (n.unshift(0), r.exponent++, a++), a--, n[a]++;
    }
  }
  return r;
}
function G1(e) {
  for (var t = [], r = 0; r < e; r++)
    t.push(0);
  return t;
}
function uoe(e) {
  return e.toExponential().replace(/e.*$/, "").replace(/^0\.?0*|\./, "").length;
}
function Zo(e, t) {
  var r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1e-8, n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0;
  if (r <= 0)
    throw new Error("Relative tolerance must be greater than 0");
  if (n < 0)
    throw new Error("Absolute tolerance must be at least 0");
  return isNaN(e) || isNaN(t) ? !1 : !isFinite(e) || !isFinite(t) ? e === t : e === t ? !0 : Math.abs(e - t) <= Math.max(r * Math.max(Math.abs(e), Math.abs(t)), n);
}
function dI(e, t) {
  if (En(e))
    return e;
  if (ti(e))
    return e.toNumber();
  t();
}
function fI(e, t) {
  return En(e) ? e : ti(e) ? e.toNumber() : t;
}
function gt(e, t, r, n) {
  function i(a) {
    var o = toe(a, t.map(loe));
    return soe(e, t, a), r(o);
  }
  return i.isFactory = !0, i.fn = e, i.dependencies = t.slice().sort(), n && (i.meta = n), i;
}
function soe(e, t, r) {
  var n = t.filter((a) => !coe(a)).every((a) => r[a] !== void 0);
  if (!n) {
    var i = t.filter((a) => r[a] === void 0);
    throw new Error('Cannot create function "'.concat(e, '", ') + "some dependencies are missing: ".concat(i.map((a) => '"'.concat(a, '"')).join(", "), "."));
  }
}
function coe(e) {
  return e && e[0] === "?";
}
function loe(e) {
  return e && e[0] === "?" ? e.slice(1) : e;
}
function doe(e, t) {
  if (pN(e) && fN(e, t))
    return e[t];
  throw typeof e[t] == "function" && moe(e, t) ? new Error('Cannot access method "' + t + '" as a property') : new Error('No access to property "' + t + '"');
}
function foe(e, t, r) {
  if (pN(e) && fN(e, t))
    return e[t] = r, r;
  throw new Error('No access to property "' + t + '"');
}
function poe(e, t) {
  return t in e;
}
function fN(e, t) {
  return !e || typeof e != "object" ? !1 : bm(hoe, t) ? !0 : !(t in Object.prototype || t in Function.prototype);
}
function moe(e, t) {
  return e == null || typeof e[t] != "function" || bm(e, t) && Object.getPrototypeOf && t in Object.getPrototypeOf(e) ? !1 : bm(voe, t) ? !0 : !(t in Object.prototype || t in Function.prototype);
}
function pN(e) {
  return typeof e == "object" && e && e.constructor === Object;
}
var hoe = {
  length: !0,
  name: !0
}, voe = {
  toString: !0,
  valueOf: !0,
  toLocaleString: !0
};
class goe {
  constructor(t) {
    this.wrappedObject = t, this[Symbol.iterator] = this.entries;
  }
  keys() {
    return Object.keys(this.wrappedObject).values();
  }
  get(t) {
    return doe(this.wrappedObject, t);
  }
  set(t, r) {
    return foe(this.wrappedObject, t, r), this;
  }
  has(t) {
    return poe(this.wrappedObject, t);
  }
  entries() {
    return yoe(this.keys(), (t) => [t, this.get(t)]);
  }
  forEach(t) {
    for (var r of this.keys())
      t(this.get(r), r, this);
  }
  delete(t) {
    delete this.wrappedObject[t];
  }
  clear() {
    for (var t of this.keys())
      this.delete(t);
  }
  get size() {
    return Object.keys(this.wrappedObject).length;
  }
}
function yoe(e, t) {
  return {
    next: () => {
      var r = e.next();
      return r.done ? r : {
        value: t(r.value),
        done: !1
      };
    }
  };
}
function boe(e) {
  return e ? e instanceof Map || e instanceof goe || typeof e.set == "function" && typeof e.get == "function" && typeof e.keys == "function" && typeof e.has == "function" : !1;
}
var mN = function() {
  return mN = lI.create, lI;
}, _oe = ["?BigNumber", "?Complex", "?DenseMatrix", "?Fraction"], xoe = /* @__PURE__ */ gt("typed", _oe, function(t) {
  var {
    BigNumber: r,
    Complex: n,
    DenseMatrix: i,
    Fraction: a
  } = t, o = mN();
  return o.clear(), o.addTypes([
    {
      name: "number",
      test: En
    },
    {
      name: "Complex",
      test: v8
    },
    {
      name: "BigNumber",
      test: ti
    },
    {
      name: "bigint",
      test: Eae
    },
    {
      name: "Fraction",
      test: g8
    },
    {
      name: "Unit",
      test: nN
    },
    // The following type matches a valid variable name, i.e., an alphanumeric
    // string starting with an alphabetic character. It is used (at least)
    // in the definition of the derivative() function, as the argument telling
    // what to differentiate over must (currently) be a variable.
    {
      name: "identifier",
      test: (u) => Yu && /^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD887][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF39\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD888[\uDC00-\uDFAF])*$/.test(u)
    },
    {
      name: "string",
      test: Yu
    },
    {
      name: "Chain",
      test: $ae
    },
    {
      name: "Array",
      test: bn
    },
    {
      name: "Matrix",
      test: Nn
    },
    {
      name: "DenseMatrix",
      test: iN
    },
    {
      name: "SparseMatrix",
      test: aN
    },
    {
      name: "Range",
      test: oN
    },
    {
      name: "Index",
      test: y8
    },
    {
      name: "boolean",
      test: Mae
    },
    {
      name: "ResultSet",
      test: Tae
    },
    {
      name: "Help",
      test: Pae
    },
    {
      name: "function",
      test: Bae
    },
    {
      name: "Date",
      test: Fae
    },
    {
      name: "RegExp",
      test: Nae
    },
    {
      name: "null",
      test: Rae
    },
    {
      name: "undefined",
      test: Oae
    },
    {
      name: "AccessorNode",
      test: Lae
    },
    {
      name: "ArrayNode",
      test: kae
    },
    {
      name: "AssignmentNode",
      test: zae
    },
    {
      name: "BlockNode",
      test: Gae
    },
    {
      name: "ConditionalNode",
      test: Vae
    },
    {
      name: "ConstantNode",
      test: Uae
    },
    {
      name: "FunctionNode",
      test: qae
    },
    {
      name: "FunctionAssignmentNode",
      test: Hae
    },
    {
      name: "IndexNode",
      test: Kae
    },
    {
      name: "Node",
      test: Xae
    },
    {
      name: "ObjectNode",
      test: jae
    },
    {
      name: "OperatorNode",
      test: Yae
    },
    {
      name: "ParenthesisNode",
      test: Wae
    },
    {
      name: "RangeNode",
      test: Zae
    },
    {
      name: "RelationalNode",
      test: Qae
    },
    {
      name: "SymbolNode",
      test: Jae
    },
    {
      name: "Map",
      test: boe
    },
    {
      name: "Object",
      test: b8
    }
    // order 'Object' last, it matches on other classes too
  ]), o.addConversions([{
    from: "number",
    to: "BigNumber",
    convert: function(s) {
      if (r || Uv(s), uoe(s) > 15)
        throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: " + s + "). Use function bignumber(x) to convert to BigNumber.");
      return new r(s);
    }
  }, {
    from: "number",
    to: "Complex",
    convert: function(s) {
      return n || Hv(s), new n(s, 0);
    }
  }, {
    from: "BigNumber",
    to: "Complex",
    convert: function(s) {
      return n || Hv(s), new n(s.toNumber(), 0);
    }
  }, {
    from: "bigint",
    to: "number",
    convert: function(s) {
      if (s > Number.MAX_SAFE_INTEGER)
        throw new TypeError("Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: " + s + ")");
      return Number(s);
    }
  }, {
    from: "bigint",
    to: "BigNumber",
    convert: function(s) {
      return r || Uv(s), new r(s.toString());
    }
  }, {
    from: "bigint",
    to: "Fraction",
    convert: function(s) {
      return a || qv(s), new a(s.toString());
    }
  }, {
    from: "Fraction",
    to: "BigNumber",
    convert: function(s) {
      throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.");
    }
  }, {
    from: "Fraction",
    to: "Complex",
    convert: function(s) {
      return n || Hv(s), new n(s.valueOf(), 0);
    }
  }, {
    from: "number",
    to: "Fraction",
    convert: function(s) {
      a || qv(s);
      var c = new a(s);
      if (c.valueOf() !== s)
        throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: " + s + "). Use function fraction(x) to convert to Fraction.");
      return c;
    }
  }, {
    // FIXME: add conversion from Fraction to number, for example for `sqrt(fraction(1,3))`
    //  from: 'Fraction',
    //  to: 'number',
    //  convert: function (x) {
    //    return x.valueOf()
    //  }
    // }, {
    from: "string",
    to: "number",
    convert: function(s) {
      var c = Number(s);
      if (isNaN(c))
        throw new Error('Cannot convert "' + s + '" to a number');
      return c;
    }
  }, {
    from: "string",
    to: "BigNumber",
    convert: function(s) {
      r || Uv(s);
      try {
        return new r(s);
      } catch {
        throw new Error('Cannot convert "' + s + '" to BigNumber');
      }
    }
  }, {
    from: "string",
    to: "bigint",
    convert: function(s) {
      try {
        return BigInt(s);
      } catch {
        throw new Error('Cannot convert "' + s + '" to BigInt');
      }
    }
  }, {
    from: "string",
    to: "Fraction",
    convert: function(s) {
      a || qv(s);
      try {
        return new a(s);
      } catch {
        throw new Error('Cannot convert "' + s + '" to Fraction');
      }
    }
  }, {
    from: "string",
    to: "Complex",
    convert: function(s) {
      n || Hv(s);
      try {
        return new n(s);
      } catch {
        throw new Error('Cannot convert "' + s + '" to Complex');
      }
    }
  }, {
    from: "boolean",
    to: "number",
    convert: function(s) {
      return +s;
    }
  }, {
    from: "boolean",
    to: "BigNumber",
    convert: function(s) {
      return r || Uv(s), new r(+s);
    }
  }, {
    from: "boolean",
    to: "bigint",
    convert: function(s) {
      return BigInt(+s);
    }
  }, {
    from: "boolean",
    to: "Fraction",
    convert: function(s) {
      return a || qv(s), new a(+s);
    }
  }, {
    from: "boolean",
    to: "string",
    convert: function(s) {
      return String(s);
    }
  }, {
    from: "Array",
    to: "Matrix",
    convert: function(s) {
      return i || Aoe(), new i(s);
    }
  }, {
    from: "Matrix",
    to: "Array",
    convert: function(s) {
      return s.valueOf();
    }
  }]), o.onMismatch = (u, s, c) => {
    var l = o.createError(u, s, c);
    if (["wrongType", "mismatch"].includes(l.data.category) && s.length === 1 && og(s[0]) && // check if the function can be unary:
    c.some((f) => !f.params.includes(","))) {
      var d = new TypeError("Function '".concat(u, "' doesn't apply to matrices. To call it ") + "elementwise on a matrix 'M', try 'map(M, ".concat(u, ")'."));
      throw d.data = l.data, d;
    }
    throw l;
  }, o.onMismatch = (u, s, c) => {
    var l = o.createError(u, s, c);
    if (["wrongType", "mismatch"].includes(l.data.category) && s.length === 1 && og(s[0]) && // check if the function can be unary:
    c.some((f) => !f.params.includes(","))) {
      var d = new TypeError("Function '".concat(u, "' doesn't apply to matrices. To call it ") + "elementwise on a matrix 'M', try 'map(M, ".concat(u, ")'."));
      throw d.data = l.data, d;
    }
    throw l;
  }, o;
});
function Uv(e) {
  throw new Error("Cannot convert value ".concat(e, " into a BigNumber: no class 'BigNumber' provided"));
}
function Hv(e) {
  throw new Error("Cannot convert value ".concat(e, " into a Complex number: no class 'Complex' provided"));
}
function Aoe() {
  throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided");
}
function qv(e) {
  throw new Error("Cannot convert value ".concat(e, " into a Fraction, no class 'Fraction' provided."));
}
/*!
 *  decimal.js v10.4.3
 *  An arbitrary-precision Decimal type for JavaScript.
 *  https://github.com/MikeMcl/decimal.js
 *  Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
 *  MIT Licence
 */
var P1 = 9e15, fd = 1e9, H6 = "0123456789abcdef", ug = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058", sg = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789", q6 = {
  // These values must be integers within the stated ranges (inclusive).
  // Most of these values can be changed at run-time using the `Decimal.config` method.
  // The maximum number of significant digits of the result of a calculation or base conversion.
  // E.g. `Decimal.config({ precision: 20 });`
  precision: 20,
  // 1 to MAX_DIGITS
  // The rounding mode used when rounding to `precision`.
  //
  // ROUND_UP         0 Away from zero.
  // ROUND_DOWN       1 Towards zero.
  // ROUND_CEIL       2 Towards +Infinity.
  // ROUND_FLOOR      3 Towards -Infinity.
  // ROUND_HALF_UP    4 Towards nearest neighbour. If equidistant, up.
  // ROUND_HALF_DOWN  5 Towards nearest neighbour. If equidistant, down.
  // ROUND_HALF_EVEN  6 Towards nearest neighbour. If equidistant, towards even neighbour.
  // ROUND_HALF_CEIL  7 Towards nearest neighbour. If equidistant, towards +Infinity.
  // ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
  //
  // E.g.
  // `Decimal.rounding = 4;`
  // `Decimal.rounding = Decimal.ROUND_HALF_UP;`
  rounding: 4,
  // 0 to 8
  // The modulo mode used when calculating the modulus: a mod n.
  // The quotient (q = a / n) is calculated according to the corresponding rounding mode.
  // The remainder (r) is calculated as: r = a - n * q.
  //
  // UP         0 The remainder is positive if the dividend is negative, else is negative.
  // DOWN       1 The remainder has the same sign as the dividend (JavaScript %).
  // FLOOR      3 The remainder has the same sign as the divisor (Python %).
  // HALF_EVEN  6 The IEEE 754 remainder function.
  // EUCLID     9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive.
  //
  // Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian
  // division (9) are commonly used for the modulus operation. The other rounding modes can also
  // be used, but they may not give useful results.
  modulo: 1,
  // 0 to 9
  // The exponent value at and beneath which `toString` returns exponential notation.
  // JavaScript numbers: -7
  toExpNeg: -7,
  // 0 to -EXP_LIMIT
  // The exponent value at and above which `toString` returns exponential notation.
  // JavaScript numbers: 21
  toExpPos: 21,
  // 0 to EXP_LIMIT
  // The minimum exponent value, beneath which underflow to zero occurs.
  // JavaScript numbers: -324  (5e-324)
  minE: -P1,
  // -1 to -EXP_LIMIT
  // The maximum exponent value, above which overflow to Infinity occurs.
  // JavaScript numbers: 308  (1.7976931348623157e+308)
  maxE: P1,
  // 1 to EXP_LIMIT
  // Whether to use cryptographically-secure random number generation, if available.
  crypto: !1
  // true/false
}, hN, _c, lr = !0, Jg = "[DecimalError] ", sd = Jg + "Invalid argument: ", vN = Jg + "Precision limit exceeded", gN = Jg + "crypto unavailable", yN = "[object Decimal]", Oa = Math.floor, Li = Math.pow, Soe = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i, Coe = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i, woe = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i, bN = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, ts = 1e7, Wt = 7, Doe = 9007199254740991, Ioe = ug.length - 1, K6 = sg.length - 1, lt = { toStringTag: yN };
lt.absoluteValue = lt.abs = function() {
  var e = new this.constructor(this);
  return e.s < 0 && (e.s = 1), Ut(e);
};
lt.ceil = function() {
  return Ut(new this.constructor(this), this.e + 1, 2);
};
lt.clampedTo = lt.clamp = function(e, t) {
  var r, n = this, i = n.constructor;
  if (e = new i(e), t = new i(t), !e.s || !t.s) return new i(NaN);
  if (e.gt(t)) throw Error(sd + t);
  return r = n.cmp(e), r < 0 ? e : n.cmp(t) > 0 ? t : new i(n);
};
lt.comparedTo = lt.cmp = function(e) {
  var t, r, n, i, a = this, o = a.d, u = (e = new a.constructor(e)).d, s = a.s, c = e.s;
  if (!o || !u)
    return !s || !c ? NaN : s !== c ? s : o === u ? 0 : !o ^ s < 0 ? 1 : -1;
  if (!o[0] || !u[0]) return o[0] ? s : u[0] ? -c : 0;
  if (s !== c) return s;
  if (a.e !== e.e) return a.e > e.e ^ s < 0 ? 1 : -1;
  for (n = o.length, i = u.length, t = 0, r = n < i ? n : i; t < r; ++t)
    if (o[t] !== u[t]) return o[t] > u[t] ^ s < 0 ? 1 : -1;
  return n === i ? 0 : n > i ^ s < 0 ? 1 : -1;
};
lt.cosine = lt.cos = function() {
  var e, t, r = this, n = r.constructor;
  return r.d ? r.d[0] ? (e = n.precision, t = n.rounding, n.precision = e + Math.max(r.e, r.sd()) + Wt, n.rounding = 1, r = Eoe(n, CN(n, r)), n.precision = e, n.rounding = t, Ut(_c == 2 || _c == 3 ? r.neg() : r, e, t, !0)) : new n(1) : new n(NaN);
};
lt.cubeRoot = lt.cbrt = function() {
  var e, t, r, n, i, a, o, u, s, c, l = this, d = l.constructor;
  if (!l.isFinite() || l.isZero()) return new d(l);
  for (lr = !1, a = l.s * Li(l.s * l, 1 / 3), !a || Math.abs(a) == 1 / 0 ? (r = _a(l.d), e = l.e, (a = (e - r.length + 1) % 3) && (r += a == 1 || a == -2 ? "0" : "00"), a = Li(r, 1 / 3), e = Oa((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2)), a == 1 / 0 ? r = "5e" + e : (r = a.toExponential(), r = r.slice(0, r.indexOf("e") + 1) + e), n = new d(r), n.s = l.s) : n = new d(a.toString()), o = (e = d.precision) + 3; ; )
    if (u = n, s = u.times(u).times(u), c = s.plus(l), n = Tn(c.plus(l).times(u), c.plus(s), o + 2, 1), _a(u.d).slice(0, o) === (r = _a(n.d)).slice(0, o))
      if (r = r.slice(o - 3, o + 1), r == "9999" || !i && r == "4999") {
        if (!i && (Ut(u, e + 1, 0), u.times(u).times(u).eq(l))) {
          n = u;
          break;
        }
        o += 4, i = 1;
      } else {
        (!+r || !+r.slice(1) && r.charAt(0) == "5") && (Ut(n, e + 1, 1), t = !n.times(n).times(n).eq(l));
        break;
      }
  return lr = !0, Ut(n, e, d.rounding, t);
};
lt.decimalPlaces = lt.dp = function() {
  var e, t = this.d, r = NaN;
  if (t) {
    if (e = t.length - 1, r = (e - Oa(this.e / Wt)) * Wt, e = t[e], e) for (; e % 10 == 0; e /= 10) r--;
    r < 0 && (r = 0);
  }
  return r;
};
lt.dividedBy = lt.div = function(e) {
  return Tn(this, new this.constructor(e));
};
lt.dividedToIntegerBy = lt.divToInt = function(e) {
  var t = this, r = t.constructor;
  return Ut(Tn(t, new r(e), 0, 1, 1), r.precision, r.rounding);
};
lt.equals = lt.eq = function(e) {
  return this.cmp(e) === 0;
};
lt.floor = function() {
  return Ut(new this.constructor(this), this.e + 1, 3);
};
lt.greaterThan = lt.gt = function(e) {
  return this.cmp(e) > 0;
};
lt.greaterThanOrEqualTo = lt.gte = function(e) {
  var t = this.cmp(e);
  return t == 1 || t === 0;
};
lt.hyperbolicCosine = lt.cosh = function() {
  var e, t, r, n, i, a = this, o = a.constructor, u = new o(1);
  if (!a.isFinite()) return new o(a.s ? 1 / 0 : NaN);
  if (a.isZero()) return u;
  r = o.precision, n = o.rounding, o.precision = r + Math.max(a.e, a.sd()) + 4, o.rounding = 1, i = a.d.length, i < 32 ? (e = Math.ceil(i / 3), t = (1 / e3(4, e)).toString()) : (e = 16, t = "2.3283064365386962890625e-10"), a = m0(o, 1, a.times(t), new o(1), !0);
  for (var s, c = e, l = new o(8); c--; )
    s = a.times(a), a = u.minus(s.times(l.minus(s.times(l))));
  return Ut(a, o.precision = r, o.rounding = n, !0);
};
lt.hyperbolicSine = lt.sinh = function() {
  var e, t, r, n, i = this, a = i.constructor;
  if (!i.isFinite() || i.isZero()) return new a(i);
  if (t = a.precision, r = a.rounding, a.precision = t + Math.max(i.e, i.sd()) + 4, a.rounding = 1, n = i.d.length, n < 3)
    i = m0(a, 2, i, i, !0);
  else {
    e = 1.4 * Math.sqrt(n), e = e > 16 ? 16 : e | 0, i = i.times(1 / e3(5, e)), i = m0(a, 2, i, i, !0);
    for (var o, u = new a(5), s = new a(16), c = new a(20); e--; )
      o = i.times(i), i = i.times(u.plus(o.times(s.times(o).plus(c))));
  }
  return a.precision = t, a.rounding = r, Ut(i, t, r, !0);
};
lt.hyperbolicTangent = lt.tanh = function() {
  var e, t, r = this, n = r.constructor;
  return r.isFinite() ? r.isZero() ? new n(r) : (e = n.precision, t = n.rounding, n.precision = e + 7, n.rounding = 1, Tn(r.sinh(), r.cosh(), n.precision = e, n.rounding = t)) : new n(r.s);
};
lt.inverseCosine = lt.acos = function() {
  var e, t = this, r = t.constructor, n = t.abs().cmp(1), i = r.precision, a = r.rounding;
  return n !== -1 ? n === 0 ? t.isNeg() ? $u(r, i, a) : new r(0) : new r(NaN) : t.isZero() ? $u(r, i + 4, a).times(0.5) : (r.precision = i + 6, r.rounding = 1, t = t.asin(), e = $u(r, i + 4, a).times(0.5), r.precision = i, r.rounding = a, e.minus(t));
};
lt.inverseHyperbolicCosine = lt.acosh = function() {
  var e, t, r = this, n = r.constructor;
  return r.lte(1) ? new n(r.eq(1) ? 0 : NaN) : r.isFinite() ? (e = n.precision, t = n.rounding, n.precision = e + Math.max(Math.abs(r.e), r.sd()) + 4, n.rounding = 1, lr = !1, r = r.times(r).minus(1).sqrt().plus(r), lr = !0, n.precision = e, n.rounding = t, r.ln()) : new n(r);
};
lt.inverseHyperbolicSine = lt.asinh = function() {
  var e, t, r = this, n = r.constructor;
  return !r.isFinite() || r.isZero() ? new n(r) : (e = n.precision, t = n.rounding, n.precision = e + 2 * Math.max(Math.abs(r.e), r.sd()) + 6, n.rounding = 1, lr = !1, r = r.times(r).plus(1).sqrt().plus(r), lr = !0, n.precision = e, n.rounding = t, r.ln());
};
lt.inverseHyperbolicTangent = lt.atanh = function() {
  var e, t, r, n, i = this, a = i.constructor;
  return i.isFinite() ? i.e >= 0 ? new a(i.abs().eq(1) ? i.s / 0 : i.isZero() ? i : NaN) : (e = a.precision, t = a.rounding, n = i.sd(), Math.max(n, e) < 2 * -i.e - 1 ? Ut(new a(i), e, t, !0) : (a.precision = r = n - i.e, i = Tn(i.plus(1), new a(1).minus(i), r + e, 1), a.precision = e + 4, a.rounding = 1, i = i.ln(), a.precision = e, a.rounding = t, i.times(0.5))) : new a(NaN);
};
lt.inverseSine = lt.asin = function() {
  var e, t, r, n, i = this, a = i.constructor;
  return i.isZero() ? new a(i) : (t = i.abs().cmp(1), r = a.precision, n = a.rounding, t !== -1 ? t === 0 ? (e = $u(a, r + 4, n).times(0.5), e.s = i.s, e) : new a(NaN) : (a.precision = r + 6, a.rounding = 1, i = i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(), a.precision = r, a.rounding = n, i.times(2)));
};
lt.inverseTangent = lt.atan = function() {
  var e, t, r, n, i, a, o, u, s, c = this, l = c.constructor, d = l.precision, f = l.rounding;
  if (c.isFinite()) {
    if (c.isZero())
      return new l(c);
    if (c.abs().eq(1) && d + 4 <= K6)
      return o = $u(l, d + 4, f).times(0.25), o.s = c.s, o;
  } else {
    if (!c.s) return new l(NaN);
    if (d + 4 <= K6)
      return o = $u(l, d + 4, f).times(0.5), o.s = c.s, o;
  }
  for (l.precision = u = d + 10, l.rounding = 1, r = Math.min(28, u / Wt + 2 | 0), e = r; e; --e) c = c.div(c.times(c).plus(1).sqrt().plus(1));
  for (lr = !1, t = Math.ceil(u / Wt), n = 1, s = c.times(c), o = new l(c), i = c; e !== -1; )
    if (i = i.times(s), a = o.minus(i.div(n += 2)), i = i.times(s), o = a.plus(i.div(n += 2)), o.d[t] !== void 0) for (e = t; o.d[e] === a.d[e] && e--; ) ;
  return r && (o = o.times(2 << r - 1)), lr = !0, Ut(o, l.precision = d, l.rounding = f, !0);
};
lt.isFinite = function() {
  return !!this.d;
};
lt.isInteger = lt.isInt = function() {
  return !!this.d && Oa(this.e / Wt) > this.d.length - 2;
};
lt.isNaN = function() {
  return !this.s;
};
lt.isNegative = lt.isNeg = function() {
  return this.s < 0;
};
lt.isPositive = lt.isPos = function() {
  return this.s > 0;
};
lt.isZero = function() {
  return !!this.d && this.d[0] === 0;
};
lt.lessThan = lt.lt = function(e) {
  return this.cmp(e) < 0;
};
lt.lessThanOrEqualTo = lt.lte = function(e) {
  return this.cmp(e) < 1;
};
lt.logarithm = lt.log = function(e) {
  var t, r, n, i, a, o, u, s, c = this, l = c.constructor, d = l.precision, f = l.rounding, m = 5;
  if (e == null)
    e = new l(10), t = !0;
  else {
    if (e = new l(e), r = e.d, e.s < 0 || !r || !r[0] || e.eq(1)) return new l(NaN);
    t = e.eq(10);
  }
  if (r = c.d, c.s < 0 || !r || !r[0] || c.eq(1))
    return new l(r && !r[0] ? -1 / 0 : c.s != 1 ? NaN : r ? 0 : 1 / 0);
  if (t)
    if (r.length > 1)
      a = !0;
    else {
      for (i = r[0]; i % 10 === 0; ) i /= 10;
      a = i !== 1;
    }
  if (lr = !1, u = d + m, o = Xl(c, u), n = t ? cg(l, u + 10) : Xl(e, u), s = Tn(o, n, u, 1), _m(s.d, i = d, f))
    do
      if (u += 10, o = Xl(c, u), n = t ? cg(l, u + 10) : Xl(e, u), s = Tn(o, n, u, 1), !a) {
        +_a(s.d).slice(i + 1, i + 15) + 1 == 1e14 && (s = Ut(s, d + 1, 0));
        break;
      }
    while (_m(s.d, i += 10, f));
  return lr = !0, Ut(s, d, f);
};
lt.minus = lt.sub = function(e) {
  var t, r, n, i, a, o, u, s, c, l, d, f, m = this, v = m.constructor;
  if (e = new v(e), !m.d || !e.d)
    return !m.s || !e.s ? e = new v(NaN) : m.d ? e.s = -e.s : e = new v(e.d || m.s !== e.s ? m : NaN), e;
  if (m.s != e.s)
    return e.s = -e.s, m.plus(e);
  if (c = m.d, f = e.d, u = v.precision, s = v.rounding, !c[0] || !f[0]) {
    if (f[0]) e.s = -e.s;
    else if (c[0]) e = new v(m);
    else return new v(s === 3 ? -0 : 0);
    return lr ? Ut(e, u, s) : e;
  }
  if (r = Oa(e.e / Wt), l = Oa(m.e / Wt), c = c.slice(), a = l - r, a) {
    for (d = a < 0, d ? (t = c, a = -a, o = f.length) : (t = f, r = l, o = c.length), n = Math.max(Math.ceil(u / Wt), o) + 2, a > n && (a = n, t.length = 1), t.reverse(), n = a; n--; ) t.push(0);
    t.reverse();
  } else {
    for (n = c.length, o = f.length, d = n < o, d && (o = n), n = 0; n < o; n++)
      if (c[n] != f[n]) {
        d = c[n] < f[n];
        break;
      }
    a = 0;
  }
  for (d && (t = c, c = f, f = t, e.s = -e.s), o = c.length, n = f.length - o; n > 0; --n) c[o++] = 0;
  for (n = f.length; n > a; ) {
    if (c[--n] < f[n]) {
      for (i = n; i && c[--i] === 0; ) c[i] = ts - 1;
      --c[i], c[n] += ts;
    }
    c[n] -= f[n];
  }
  for (; c[--o] === 0; ) c.pop();
  for (; c[0] === 0; c.shift()) --r;
  return c[0] ? (e.d = c, e.e = $g(c, r), lr ? Ut(e, u, s) : e) : new v(s === 3 ? -0 : 0);
};
lt.modulo = lt.mod = function(e) {
  var t, r = this, n = r.constructor;
  return e = new n(e), !r.d || !e.s || e.d && !e.d[0] ? new n(NaN) : !e.d || r.d && !r.d[0] ? Ut(new n(r), n.precision, n.rounding) : (lr = !1, n.modulo == 9 ? (t = Tn(r, e.abs(), 0, 3, 1), t.s *= e.s) : t = Tn(r, e, 0, n.modulo, 1), t = t.times(e), lr = !0, r.minus(t));
};
lt.naturalExponential = lt.exp = function() {
  return X6(this);
};
lt.naturalLogarithm = lt.ln = function() {
  return Xl(this);
};
lt.negated = lt.neg = function() {
  var e = new this.constructor(this);
  return e.s = -e.s, Ut(e);
};
lt.plus = lt.add = function(e) {
  var t, r, n, i, a, o, u, s, c, l, d = this, f = d.constructor;
  if (e = new f(e), !d.d || !e.d)
    return !d.s || !e.s ? e = new f(NaN) : d.d || (e = new f(e.d || d.s === e.s ? d : NaN)), e;
  if (d.s != e.s)
    return e.s = -e.s, d.minus(e);
  if (c = d.d, l = e.d, u = f.precision, s = f.rounding, !c[0] || !l[0])
    return l[0] || (e = new f(d)), lr ? Ut(e, u, s) : e;
  if (a = Oa(d.e / Wt), n = Oa(e.e / Wt), c = c.slice(), i = a - n, i) {
    for (i < 0 ? (r = c, i = -i, o = l.length) : (r = l, n = a, o = c.length), a = Math.ceil(u / Wt), o = a > o ? a + 1 : o + 1, i > o && (i = o, r.length = 1), r.reverse(); i--; ) r.push(0);
    r.reverse();
  }
  for (o = c.length, i = l.length, o - i < 0 && (i = o, r = l, l = c, c = r), t = 0; i; )
    t = (c[--i] = c[i] + l[i] + t) / ts | 0, c[i] %= ts;
  for (t && (c.unshift(t), ++n), o = c.length; c[--o] == 0; ) c.pop();
  return e.d = c, e.e = $g(c, n), lr ? Ut(e, u, s) : e;
};
lt.precision = lt.sd = function(e) {
  var t, r = this;
  if (e !== void 0 && e !== !!e && e !== 1 && e !== 0) throw Error(sd + e);
  return r.d ? (t = _N(r.d), e && r.e + 1 > t && (t = r.e + 1)) : t = NaN, t;
};
lt.round = function() {
  var e = this, t = e.constructor;
  return Ut(new t(e), e.e + 1, t.rounding);
};
lt.sine = lt.sin = function() {
  var e, t, r = this, n = r.constructor;
  return r.isFinite() ? r.isZero() ? new n(r) : (e = n.precision, t = n.rounding, n.precision = e + Math.max(r.e, r.sd()) + Wt, n.rounding = 1, r = Toe(n, CN(n, r)), n.precision = e, n.rounding = t, Ut(_c > 2 ? r.neg() : r, e, t, !0)) : new n(NaN);
};
lt.squareRoot = lt.sqrt = function() {
  var e, t, r, n, i, a, o = this, u = o.d, s = o.e, c = o.s, l = o.constructor;
  if (c !== 1 || !u || !u[0])
    return new l(!c || c < 0 && (!u || u[0]) ? NaN : u ? o : 1 / 0);
  for (lr = !1, c = Math.sqrt(+o), c == 0 || c == 1 / 0 ? (t = _a(u), (t.length + s) % 2 == 0 && (t += "0"), c = Math.sqrt(t), s = Oa((s + 1) / 2) - (s < 0 || s % 2), c == 1 / 0 ? t = "5e" + s : (t = c.toExponential(), t = t.slice(0, t.indexOf("e") + 1) + s), n = new l(t)) : n = new l(c.toString()), r = (s = l.precision) + 3; ; )
    if (a = n, n = a.plus(Tn(o, a, r + 2, 1)).times(0.5), _a(a.d).slice(0, r) === (t = _a(n.d)).slice(0, r))
      if (t = t.slice(r - 3, r + 1), t == "9999" || !i && t == "4999") {
        if (!i && (Ut(a, s + 1, 0), a.times(a).eq(o))) {
          n = a;
          break;
        }
        r += 4, i = 1;
      } else {
        (!+t || !+t.slice(1) && t.charAt(0) == "5") && (Ut(n, s + 1, 1), e = !n.times(n).eq(o));
        break;
      }
  return lr = !0, Ut(n, s, l.rounding, e);
};
lt.tangent = lt.tan = function() {
  var e, t, r = this, n = r.constructor;
  return r.isFinite() ? r.isZero() ? new n(r) : (e = n.precision, t = n.rounding, n.precision = e + 10, n.rounding = 1, r = r.sin(), r.s = 1, r = Tn(r, new n(1).minus(r.times(r)).sqrt(), e + 10, 0), n.precision = e, n.rounding = t, Ut(_c == 2 || _c == 4 ? r.neg() : r, e, t, !0)) : new n(NaN);
};
lt.times = lt.mul = function(e) {
  var t, r, n, i, a, o, u, s, c, l = this, d = l.constructor, f = l.d, m = (e = new d(e)).d;
  if (e.s *= l.s, !f || !f[0] || !m || !m[0])
    return new d(!e.s || f && !f[0] && !m || m && !m[0] && !f ? NaN : !f || !m ? e.s / 0 : e.s * 0);
  for (r = Oa(l.e / Wt) + Oa(e.e / Wt), s = f.length, c = m.length, s < c && (a = f, f = m, m = a, o = s, s = c, c = o), a = [], o = s + c, n = o; n--; ) a.push(0);
  for (n = c; --n >= 0; ) {
    for (t = 0, i = s + n; i > n; )
      u = a[i] + m[n] * f[i - n - 1] + t, a[i--] = u % ts | 0, t = u / ts | 0;
    a[i] = (a[i] + t) % ts | 0;
  }
  for (; !a[--o]; ) a.pop();
  return t ? ++r : a.shift(), e.d = a, e.e = $g(a, r), lr ? Ut(e, d.precision, d.rounding) : e;
};
lt.toBinary = function(e, t) {
  return _8(this, 2, e, t);
};
lt.toDecimalPlaces = lt.toDP = function(e, t) {
  var r = this, n = r.constructor;
  return r = new n(r), e === void 0 ? r : (Co(e, 0, fd), t === void 0 ? t = n.rounding : Co(t, 0, 8), Ut(r, e + r.e + 1, t));
};
lt.toExponential = function(e, t) {
  var r, n = this, i = n.constructor;
  return e === void 0 ? r = Ls(n, !0) : (Co(e, 0, fd), t === void 0 ? t = i.rounding : Co(t, 0, 8), n = Ut(new i(n), e + 1, t), r = Ls(n, !0, e + 1)), n.isNeg() && !n.isZero() ? "-" + r : r;
};
lt.toFixed = function(e, t) {
  var r, n, i = this, a = i.constructor;
  return e === void 0 ? r = Ls(i) : (Co(e, 0, fd), t === void 0 ? t = a.rounding : Co(t, 0, 8), n = Ut(new a(i), e + i.e + 1, t), r = Ls(n, !1, e + n.e + 1)), i.isNeg() && !i.isZero() ? "-" + r : r;
};
lt.toFraction = function(e) {
  var t, r, n, i, a, o, u, s, c, l, d, f, m = this, v = m.d, p = m.constructor;
  if (!v) return new p(m);
  if (c = r = new p(1), n = s = new p(0), t = new p(n), a = t.e = _N(v) - m.e - 1, o = a % Wt, t.d[0] = Li(10, o < 0 ? Wt + o : o), e == null)
    e = a > 0 ? t : c;
  else {
    if (u = new p(e), !u.isInt() || u.lt(c)) throw Error(sd + u);
    e = u.gt(t) ? a > 0 ? t : c : u;
  }
  for (lr = !1, u = new p(_a(v)), l = p.precision, p.precision = a = v.length * Wt * 2; d = Tn(u, t, 0, 1, 1), i = r.plus(d.times(n)), i.cmp(e) != 1; )
    r = n, n = i, i = c, c = s.plus(d.times(i)), s = i, i = t, t = u.minus(d.times(i)), u = i;
  return i = Tn(e.minus(r), n, 0, 1, 1), s = s.plus(i.times(c)), r = r.plus(i.times(n)), s.s = c.s = m.s, f = Tn(c, n, a, 1).minus(m).abs().cmp(Tn(s, r, a, 1).minus(m).abs()) < 1 ? [c, n] : [s, r], p.precision = l, lr = !0, f;
};
lt.toHexadecimal = lt.toHex = function(e, t) {
  return _8(this, 16, e, t);
};
lt.toNearest = function(e, t) {
  var r = this, n = r.constructor;
  if (r = new n(r), e == null) {
    if (!r.d) return r;
    e = new n(1), t = n.rounding;
  } else {
    if (e = new n(e), t === void 0 ? t = n.rounding : Co(t, 0, 8), !r.d) return e.s ? r : e;
    if (!e.d)
      return e.s && (e.s = r.s), e;
  }
  return e.d[0] ? (lr = !1, r = Tn(r, e, 0, t, 1).times(e), lr = !0, Ut(r)) : (e.s = r.s, r = e), r;
};
lt.toNumber = function() {
  return +this;
};
lt.toOctal = function(e, t) {
  return _8(this, 8, e, t);
};
lt.toPower = lt.pow = function(e) {
  var t, r, n, i, a, o, u = this, s = u.constructor, c = +(e = new s(e));
  if (!u.d || !e.d || !u.d[0] || !e.d[0]) return new s(Li(+u, c));
  if (u = new s(u), u.eq(1)) return u;
  if (n = s.precision, a = s.rounding, e.eq(1)) return Ut(u, n, a);
  if (t = Oa(e.e / Wt), t >= e.d.length - 1 && (r = c < 0 ? -c : c) <= Doe)
    return i = xN(s, u, r, n), e.s < 0 ? new s(1).div(i) : Ut(i, n, a);
  if (o = u.s, o < 0) {
    if (t < e.d.length - 1) return new s(NaN);
    if (e.d[t] & 1 || (o = 1), u.e == 0 && u.d[0] == 1 && u.d.length == 1)
      return u.s = o, u;
  }
  return r = Li(+u, c), t = r == 0 || !isFinite(r) ? Oa(c * (Math.log("0." + _a(u.d)) / Math.LN10 + u.e + 1)) : new s(r + "").e, t > s.maxE + 1 || t < s.minE - 1 ? new s(t > 0 ? o / 0 : 0) : (lr = !1, s.rounding = u.s = 1, r = Math.min(12, (t + "").length), i = X6(e.times(Xl(u, n + r)), n), i.d && (i = Ut(i, n + 5, 1), _m(i.d, n, a) && (t = n + 10, i = Ut(X6(e.times(Xl(u, t + r)), t), t + 5, 1), +_a(i.d).slice(n + 1, n + 15) + 1 == 1e14 && (i = Ut(i, n + 1, 0)))), i.s = o, lr = !0, s.rounding = a, Ut(i, n, a));
};
lt.toPrecision = function(e, t) {
  var r, n = this, i = n.constructor;
  return e === void 0 ? r = Ls(n, n.e <= i.toExpNeg || n.e >= i.toExpPos) : (Co(e, 1, fd), t === void 0 ? t = i.rounding : Co(t, 0, 8), n = Ut(new i(n), e, t), r = Ls(n, e <= n.e || n.e <= i.toExpNeg, e)), n.isNeg() && !n.isZero() ? "-" + r : r;
};
lt.toSignificantDigits = lt.toSD = function(e, t) {
  var r = this, n = r.constructor;
  return e === void 0 ? (e = n.precision, t = n.rounding) : (Co(e, 1, fd), t === void 0 ? t = n.rounding : Co(t, 0, 8)), Ut(new n(r), e, t);
};
lt.toString = function() {
  var e = this, t = e.constructor, r = Ls(e, e.e <= t.toExpNeg || e.e >= t.toExpPos);
  return e.isNeg() && !e.isZero() ? "-" + r : r;
};
lt.truncated = lt.trunc = function() {
  return Ut(new this.constructor(this), this.e + 1, 1);
};
lt.valueOf = lt.toJSON = function() {
  var e = this, t = e.constructor, r = Ls(e, e.e <= t.toExpNeg || e.e >= t.toExpPos);
  return e.isNeg() ? "-" + r : r;
};
function _a(e) {
  var t, r, n, i = e.length - 1, a = "", o = e[0];
  if (i > 0) {
    for (a += o, t = 1; t < i; t++)
      n = e[t] + "", r = Wt - n.length, r && (a += Ml(r)), a += n;
    o = e[t], n = o + "", r = Wt - n.length, r && (a += Ml(r));
  } else if (o === 0)
    return "0";
  for (; o % 10 === 0; ) o /= 10;
  return a + o;
}
function Co(e, t, r) {
  if (e !== ~~e || e < t || e > r)
    throw Error(sd + e);
}
function _m(e, t, r, n) {
  var i, a, o, u;
  for (a = e[0]; a >= 10; a /= 10) --t;
  return --t < 0 ? (t += Wt, i = 0) : (i = Math.ceil((t + 1) / Wt), t %= Wt), a = Li(10, Wt - t), u = e[i] % a | 0, n == null ? t < 3 ? (t == 0 ? u = u / 100 | 0 : t == 1 && (u = u / 10 | 0), o = r < 4 && u == 99999 || r > 3 && u == 49999 || u == 5e4 || u == 0) : o = (r < 4 && u + 1 == a || r > 3 && u + 1 == a / 2) && (e[i + 1] / a / 100 | 0) == Li(10, t - 2) - 1 || (u == a / 2 || u == 0) && (e[i + 1] / a / 100 | 0) == 0 : t < 4 ? (t == 0 ? u = u / 1e3 | 0 : t == 1 ? u = u / 100 | 0 : t == 2 && (u = u / 10 | 0), o = (n || r < 4) && u == 9999 || !n && r > 3 && u == 4999) : o = ((n || r < 4) && u + 1 == a || !n && r > 3 && u + 1 == a / 2) && (e[i + 1] / a / 1e3 | 0) == Li(10, t - 3) - 1, o;
}
function o2(e, t, r) {
  for (var n, i = [0], a, o = 0, u = e.length; o < u; ) {
    for (a = i.length; a--; ) i[a] *= t;
    for (i[0] += H6.indexOf(e.charAt(o++)), n = 0; n < i.length; n++)
      i[n] > r - 1 && (i[n + 1] === void 0 && (i[n + 1] = 0), i[n + 1] += i[n] / r | 0, i[n] %= r);
  }
  return i.reverse();
}
function Eoe(e, t) {
  var r, n, i;
  if (t.isZero()) return t;
  n = t.d.length, n < 32 ? (r = Math.ceil(n / 3), i = (1 / e3(4, r)).toString()) : (r = 16, i = "2.3283064365386962890625e-10"), e.precision += r, t = m0(e, 1, t.times(i), new e(1));
  for (var a = r; a--; ) {
    var o = t.times(t);
    t = o.times(o).minus(o).times(8).plus(1);
  }
  return e.precision -= r, t;
}
var Tn = /* @__PURE__ */ function() {
  function e(n, i, a) {
    var o, u = 0, s = n.length;
    for (n = n.slice(); s--; )
      o = n[s] * i + u, n[s] = o % a | 0, u = o / a | 0;
    return u && n.unshift(u), n;
  }
  function t(n, i, a, o) {
    var u, s;
    if (a != o)
      s = a > o ? 1 : -1;
    else
      for (u = s = 0; u < a; u++)
        if (n[u] != i[u]) {
          s = n[u] > i[u] ? 1 : -1;
          break;
        }
    return s;
  }
  function r(n, i, a, o) {
    for (var u = 0; a--; )
      n[a] -= u, u = n[a] < i[a] ? 1 : 0, n[a] = u * o + n[a] - i[a];
    for (; !n[0] && n.length > 1; ) n.shift();
  }
  return function(n, i, a, o, u, s) {
    var c, l, d, f, m, v, p, g, h, y, x, A, b, _, S, D, I, M, F, P, E = n.constructor, B = n.s == i.s ? 1 : -1, N = n.d, O = i.d;
    if (!N || !N[0] || !O || !O[0])
      return new E(
        // Return NaN if either NaN, or both Infinity or 0.
        !n.s || !i.s || (N ? O && N[0] == O[0] : !O) ? NaN : (
          // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
          N && N[0] == 0 || !O ? B * 0 : B / 0
        )
      );
    for (s ? (m = 1, l = n.e - i.e) : (s = ts, m = Wt, l = Oa(n.e / m) - Oa(i.e / m)), F = O.length, I = N.length, h = new E(B), y = h.d = [], d = 0; O[d] == (N[d] || 0); d++) ;
    if (O[d] > (N[d] || 0) && l--, a == null ? (_ = a = E.precision, o = E.rounding) : u ? _ = a + (n.e - i.e) + 1 : _ = a, _ < 0)
      y.push(1), v = !0;
    else {
      if (_ = _ / m + 2 | 0, d = 0, F == 1) {
        for (f = 0, O = O[0], _++; (d < I || f) && _--; d++)
          S = f * s + (N[d] || 0), y[d] = S / O | 0, f = S % O | 0;
        v = f || d < I;
      } else {
        for (f = s / (O[0] + 1) | 0, f > 1 && (O = e(O, f, s), N = e(N, f, s), F = O.length, I = N.length), D = F, x = N.slice(0, F), A = x.length; A < F; ) x[A++] = 0;
        P = O.slice(), P.unshift(0), M = O[0], O[1] >= s / 2 && ++M;
        do
          f = 0, c = t(O, x, F, A), c < 0 ? (b = x[0], F != A && (b = b * s + (x[1] || 0)), f = b / M | 0, f > 1 ? (f >= s && (f = s - 1), p = e(O, f, s), g = p.length, A = x.length, c = t(p, x, g, A), c == 1 && (f--, r(p, F < g ? P : O, g, s))) : (f == 0 && (c = f = 1), p = O.slice()), g = p.length, g < A && p.unshift(0), r(x, p, A, s), c == -1 && (A = x.length, c = t(O, x, F, A), c < 1 && (f++, r(x, F < A ? P : O, A, s))), A = x.length) : c === 0 && (f++, x = [0]), y[d++] = f, c && x[0] ? x[A++] = N[D] || 0 : (x = [N[D]], A = 1);
        while ((D++ < I || x[0] !== void 0) && _--);
        v = x[0] !== void 0;
      }
      y[0] || y.shift();
    }
    if (m == 1)
      h.e = l, hN = v;
    else {
      for (d = 1, f = y[0]; f >= 10; f /= 10) d++;
      h.e = d + l * m - 1, Ut(h, u ? a + h.e + 1 : a, o, v);
    }
    return h;
  };
}();
function Ut(e, t, r, n) {
  var i, a, o, u, s, c, l, d, f, m = e.constructor;
  e: if (t != null) {
    if (d = e.d, !d) return e;
    for (i = 1, u = d[0]; u >= 10; u /= 10) i++;
    if (a = t - i, a < 0)
      a += Wt, o = t, l = d[f = 0], s = l / Li(10, i - o - 1) % 10 | 0;
    else if (f = Math.ceil((a + 1) / Wt), u = d.length, f >= u)
      if (n) {
        for (; u++ <= f; ) d.push(0);
        l = s = 0, i = 1, a %= Wt, o = a - Wt + 1;
      } else
        break e;
    else {
      for (l = u = d[f], i = 1; u >= 10; u /= 10) i++;
      a %= Wt, o = a - Wt + i, s = o < 0 ? 0 : l / Li(10, i - o - 1) % 10 | 0;
    }
    if (n = n || t < 0 || d[f + 1] !== void 0 || (o < 0 ? l : l % Li(10, i - o - 1)), c = r < 4 ? (s || n) && (r == 0 || r == (e.s < 0 ? 3 : 2)) : s > 5 || s == 5 && (r == 4 || n || r == 6 && // Check whether the digit to the left of the rounding digit is odd.
    (a > 0 ? o > 0 ? l / Li(10, i - o) : 0 : d[f - 1]) % 10 & 1 || r == (e.s < 0 ? 8 : 7)), t < 1 || !d[0])
      return d.length = 0, c ? (t -= e.e + 1, d[0] = Li(10, (Wt - t % Wt) % Wt), e.e = -t || 0) : d[0] = e.e = 0, e;
    if (a == 0 ? (d.length = f, u = 1, f--) : (d.length = f + 1, u = Li(10, Wt - a), d[f] = o > 0 ? (l / Li(10, i - o) % Li(10, o) | 0) * u : 0), c)
      for (; ; )
        if (f == 0) {
          for (a = 1, o = d[0]; o >= 10; o /= 10) a++;
          for (o = d[0] += u, u = 1; o >= 10; o /= 10) u++;
          a != u && (e.e++, d[0] == ts && (d[0] = 1));
          break;
        } else {
          if (d[f] += u, d[f] != ts) break;
          d[f--] = 0, u = 1;
        }
    for (a = d.length; d[--a] === 0; ) d.pop();
  }
  return lr && (e.e > m.maxE ? (e.d = null, e.e = NaN) : e.e < m.minE && (e.e = 0, e.d = [0])), e;
}
function Ls(e, t, r) {
  if (!e.isFinite()) return SN(e);
  var n, i = e.e, a = _a(e.d), o = a.length;
  return t ? (r && (n = r - o) > 0 ? a = a.charAt(0) + "." + a.slice(1) + Ml(n) : o > 1 && (a = a.charAt(0) + "." + a.slice(1)), a = a + (e.e < 0 ? "e" : "e+") + e.e) : i < 0 ? (a = "0." + Ml(-i - 1) + a, r && (n = r - o) > 0 && (a += Ml(n))) : i >= o ? (a += Ml(i + 1 - o), r && (n = r - i - 1) > 0 && (a = a + "." + Ml(n))) : ((n = i + 1) < o && (a = a.slice(0, n) + "." + a.slice(n)), r && (n = r - o) > 0 && (i + 1 === o && (a += "."), a += Ml(n))), a;
}
function $g(e, t) {
  var r = e[0];
  for (t *= Wt; r >= 10; r /= 10) t++;
  return t;
}
function cg(e, t, r) {
  if (t > Ioe)
    throw lr = !0, r && (e.precision = r), Error(vN);
  return Ut(new e(ug), t, 1, !0);
}
function $u(e, t, r) {
  if (t > K6) throw Error(vN);
  return Ut(new e(sg), t, r, !0);
}
function _N(e) {
  var t = e.length - 1, r = t * Wt + 1;
  if (t = e[t], t) {
    for (; t % 10 == 0; t /= 10) r--;
    for (t = e[0]; t >= 10; t /= 10) r++;
  }
  return r;
}
function Ml(e) {
  for (var t = ""; e--; ) t += "0";
  return t;
}
function xN(e, t, r, n) {
  var i, a = new e(1), o = Math.ceil(n / Wt + 4);
  for (lr = !1; ; ) {
    if (r % 2 && (a = a.times(t), mI(a.d, o) && (i = !0)), r = Oa(r / 2), r === 0) {
      r = a.d.length - 1, i && a.d[r] === 0 && ++a.d[r];
      break;
    }
    t = t.times(t), mI(t.d, o);
  }
  return lr = !0, a;
}
function pI(e) {
  return e.d[e.d.length - 1] & 1;
}
function AN(e, t, r) {
  for (var n, i = new e(t[0]), a = 0; ++a < t.length; )
    if (n = new e(t[a]), n.s)
      i[r](n) && (i = n);
    else {
      i = n;
      break;
    }
  return i;
}
function X6(e, t) {
  var r, n, i, a, o, u, s, c = 0, l = 0, d = 0, f = e.constructor, m = f.rounding, v = f.precision;
  if (!e.d || !e.d[0] || e.e > 17)
    return new f(e.d ? e.d[0] ? e.s < 0 ? 0 : 1 / 0 : 1 : e.s ? e.s < 0 ? 0 : e : NaN);
  for (t == null ? (lr = !1, s = v) : s = t, u = new f(0.03125); e.e > -2; )
    e = e.times(u), d += 5;
  for (n = Math.log(Li(2, d)) / Math.LN10 * 2 + 5 | 0, s += n, r = a = o = new f(1), f.precision = s; ; ) {
    if (a = Ut(a.times(e), s, 1), r = r.times(++l), u = o.plus(Tn(a, r, s, 1)), _a(u.d).slice(0, s) === _a(o.d).slice(0, s)) {
      for (i = d; i--; ) o = Ut(o.times(o), s, 1);
      if (t == null)
        if (c < 3 && _m(o.d, s - n, m, c))
          f.precision = s += 10, r = a = u = new f(1), l = 0, c++;
        else
          return Ut(o, f.precision = v, m, lr = !0);
      else
        return f.precision = v, o;
    }
    o = u;
  }
}
function Xl(e, t) {
  var r, n, i, a, o, u, s, c, l, d, f, m = 1, v = 10, p = e, g = p.d, h = p.constructor, y = h.rounding, x = h.precision;
  if (p.s < 0 || !g || !g[0] || !p.e && g[0] == 1 && g.length == 1)
    return new h(g && !g[0] ? -1 / 0 : p.s != 1 ? NaN : g ? 0 : p);
  if (t == null ? (lr = !1, l = x) : l = t, h.precision = l += v, r = _a(g), n = r.charAt(0), Math.abs(a = p.e) < 15e14) {
    for (; n < 7 && n != 1 || n == 1 && r.charAt(1) > 3; )
      p = p.times(e), r = _a(p.d), n = r.charAt(0), m++;
    a = p.e, n > 1 ? (p = new h("0." + r), a++) : p = new h(n + "." + r.slice(1));
  } else
    return c = cg(h, l + 2, x).times(a + ""), p = Xl(new h(n + "." + r.slice(1)), l - v).plus(c), h.precision = x, t == null ? Ut(p, x, y, lr = !0) : p;
  for (d = p, s = o = p = Tn(p.minus(1), p.plus(1), l, 1), f = Ut(p.times(p), l, 1), i = 3; ; ) {
    if (o = Ut(o.times(f), l, 1), c = s.plus(Tn(o, new h(i), l, 1)), _a(c.d).slice(0, l) === _a(s.d).slice(0, l))
      if (s = s.times(2), a !== 0 && (s = s.plus(cg(h, l + 2, x).times(a + ""))), s = Tn(s, new h(m), l, 1), t == null)
        if (_m(s.d, l - v, y, u))
          h.precision = l += v, c = o = p = Tn(d.minus(1), d.plus(1), l, 1), f = Ut(p.times(p), l, 1), i = u = 1;
        else
          return Ut(s, h.precision = x, y, lr = !0);
      else
        return h.precision = x, s;
    s = c, i += 2;
  }
}
function SN(e) {
  return String(e.s * e.s / 0);
}
function j6(e, t) {
  var r, n, i;
  for ((r = t.indexOf(".")) > -1 && (t = t.replace(".", "")), (n = t.search(/e/i)) > 0 ? (r < 0 && (r = n), r += +t.slice(n + 1), t = t.substring(0, n)) : r < 0 && (r = t.length), n = 0; t.charCodeAt(n) === 48; n++) ;
  for (i = t.length; t.charCodeAt(i - 1) === 48; --i) ;
  if (t = t.slice(n, i), t) {
    if (i -= n, e.e = r = r - n - 1, e.d = [], n = (r + 1) % Wt, r < 0 && (n += Wt), n < i) {
      for (n && e.d.push(+t.slice(0, n)), i -= Wt; n < i; ) e.d.push(+t.slice(n, n += Wt));
      t = t.slice(n), n = Wt - t.length;
    } else
      n -= i;
    for (; n--; ) t += "0";
    e.d.push(+t), lr && (e.e > e.constructor.maxE ? (e.d = null, e.e = NaN) : e.e < e.constructor.minE && (e.e = 0, e.d = [0]));
  } else
    e.e = 0, e.d = [0];
  return e;
}
function Moe(e, t) {
  var r, n, i, a, o, u, s, c, l;
  if (t.indexOf("_") > -1) {
    if (t = t.replace(/(\d)_(?=\d)/g, "$1"), bN.test(t)) return j6(e, t);
  } else if (t === "Infinity" || t === "NaN")
    return +t || (e.s = NaN), e.e = NaN, e.d = null, e;
  if (Coe.test(t))
    r = 16, t = t.toLowerCase();
  else if (Soe.test(t))
    r = 2;
  else if (woe.test(t))
    r = 8;
  else
    throw Error(sd + t);
  for (a = t.search(/p/i), a > 0 ? (s = +t.slice(a + 1), t = t.substring(2, a)) : t = t.slice(2), a = t.indexOf("."), o = a >= 0, n = e.constructor, o && (t = t.replace(".", ""), u = t.length, a = u - a, i = xN(n, new n(r), a, a * 2)), c = o2(t, r, ts), l = c.length - 1, a = l; c[a] === 0; --a) c.pop();
  return a < 0 ? new n(e.s * 0) : (e.e = $g(c, l), e.d = c, lr = !1, o && (e = Tn(e, i, u * 4)), s && (e = e.times(Math.abs(s) < 54 ? Li(2, s) : _f.pow(2, s))), lr = !0, e);
}
function Toe(e, t) {
  var r, n = t.d.length;
  if (n < 3)
    return t.isZero() ? t : m0(e, 2, t, t);
  r = 1.4 * Math.sqrt(n), r = r > 16 ? 16 : r | 0, t = t.times(1 / e3(5, r)), t = m0(e, 2, t, t);
  for (var i, a = new e(5), o = new e(16), u = new e(20); r--; )
    i = t.times(t), t = t.times(a.plus(i.times(o.times(i).minus(u))));
  return t;
}
function m0(e, t, r, n, i) {
  var a, o, u, s, c = e.precision, l = Math.ceil(c / Wt);
  for (lr = !1, s = r.times(r), u = new e(n); ; ) {
    if (o = Tn(u.times(s), new e(t++ * t++), c, 1), u = i ? n.plus(o) : n.minus(o), n = Tn(o.times(s), new e(t++ * t++), c, 1), o = u.plus(n), o.d[l] !== void 0) {
      for (a = l; o.d[a] === u.d[a] && a--; ) ;
      if (a == -1) break;
    }
    a = u, u = n, n = o, o = a;
  }
  return lr = !0, o.d.length = l + 1, o;
}
function e3(e, t) {
  for (var r = e; --t; ) r *= e;
  return r;
}
function CN(e, t) {
  var r, n = t.s < 0, i = $u(e, e.precision, 1), a = i.times(0.5);
  if (t = t.abs(), t.lte(a))
    return _c = n ? 4 : 1, t;
  if (r = t.divToInt(i), r.isZero())
    _c = n ? 3 : 2;
  else {
    if (t = t.minus(r.times(i)), t.lte(a))
      return _c = pI(r) ? n ? 2 : 3 : n ? 4 : 1, t;
    _c = pI(r) ? n ? 1 : 4 : n ? 3 : 2;
  }
  return t.minus(i).abs();
}
function _8(e, t, r, n) {
  var i, a, o, u, s, c, l, d, f, m = e.constructor, v = r !== void 0;
  if (v ? (Co(r, 1, fd), n === void 0 ? n = m.rounding : Co(n, 0, 8)) : (r = m.precision, n = m.rounding), !e.isFinite())
    l = SN(e);
  else {
    for (l = Ls(e), o = l.indexOf("."), v ? (i = 2, t == 16 ? r = r * 4 - 3 : t == 8 && (r = r * 3 - 2)) : i = t, o >= 0 && (l = l.replace(".", ""), f = new m(1), f.e = l.length - o, f.d = o2(Ls(f), 10, i), f.e = f.d.length), d = o2(l, 10, i), a = s = d.length; d[--s] == 0; ) d.pop();
    if (!d[0])
      l = v ? "0p+0" : "0";
    else {
      if (o < 0 ? a-- : (e = new m(e), e.d = d, e.e = a, e = Tn(e, f, r, n, 0, i), d = e.d, a = e.e, c = hN), o = d[r], u = i / 2, c = c || d[r + 1] !== void 0, c = n < 4 ? (o !== void 0 || c) && (n === 0 || n === (e.s < 0 ? 3 : 2)) : o > u || o === u && (n === 4 || c || n === 6 && d[r - 1] & 1 || n === (e.s < 0 ? 8 : 7)), d.length = r, c)
        for (; ++d[--r] > i - 1; )
          d[r] = 0, r || (++a, d.unshift(1));
      for (s = d.length; !d[s - 1]; --s) ;
      for (o = 0, l = ""; o < s; o++) l += H6.charAt(d[o]);
      if (v) {
        if (s > 1)
          if (t == 16 || t == 8) {
            for (o = t == 16 ? 4 : 3, --s; s % o; s++) l += "0";
            for (d = o2(l, i, t), s = d.length; !d[s - 1]; --s) ;
            for (o = 1, l = "1."; o < s; o++) l += H6.charAt(d[o]);
          } else
            l = l.charAt(0) + "." + l.slice(1);
        l = l + (a < 0 ? "p" : "p+") + a;
      } else if (a < 0) {
        for (; ++a; ) l = "0" + l;
        l = "0." + l;
      } else if (++a > s) for (a -= s; a--; ) l += "0";
      else a < s && (l = l.slice(0, a) + "." + l.slice(a));
    }
    l = (t == 16 ? "0x" : t == 2 ? "0b" : t == 8 ? "0o" : "") + l;
  }
  return e.s < 0 ? "-" + l : l;
}
function mI(e, t) {
  if (e.length > t)
    return e.length = t, !0;
}
function Poe(e) {
  return new this(e).abs();
}
function Boe(e) {
  return new this(e).acos();
}
function Foe(e) {
  return new this(e).acosh();
}
function Noe(e, t) {
  return new this(e).plus(t);
}
function Roe(e) {
  return new this(e).asin();
}
function Ooe(e) {
  return new this(e).asinh();
}
function Loe(e) {
  return new this(e).atan();
}
function koe(e) {
  return new this(e).atanh();
}
function zoe(e, t) {
  e = new this(e), t = new this(t);
  var r, n = this.precision, i = this.rounding, a = n + 4;
  return !e.s || !t.s ? r = new this(NaN) : !e.d && !t.d ? (r = $u(this, a, 1).times(t.s > 0 ? 0.25 : 0.75), r.s = e.s) : !t.d || e.isZero() ? (r = t.s < 0 ? $u(this, n, i) : new this(0), r.s = e.s) : !e.d || t.isZero() ? (r = $u(this, a, 1).times(0.5), r.s = e.s) : t.s < 0 ? (this.precision = a, this.rounding = 1, r = this.atan(Tn(e, t, a, 1)), t = $u(this, a, 1), this.precision = n, this.rounding = i, r = e.s < 0 ? r.minus(t) : r.plus(t)) : r = this.atan(Tn(e, t, a, 1)), r;
}
function Goe(e) {
  return new this(e).cbrt();
}
function Voe(e) {
  return Ut(e = new this(e), e.e + 1, 2);
}
function Uoe(e, t, r) {
  return new this(e).clamp(t, r);
}
function Hoe(e) {
  if (!e || typeof e != "object") throw Error(Jg + "Object expected");
  var t, r, n, i = e.defaults === !0, a = [
    "precision",
    1,
    fd,
    "rounding",
    0,
    8,
    "toExpNeg",
    -P1,
    0,
    "toExpPos",
    0,
    P1,
    "maxE",
    0,
    P1,
    "minE",
    -P1,
    0,
    "modulo",
    0,
    9
  ];
  for (t = 0; t < a.length; t += 3)
    if (r = a[t], i && (this[r] = q6[r]), (n = e[r]) !== void 0)
      if (Oa(n) === n && n >= a[t + 1] && n <= a[t + 2]) this[r] = n;
      else throw Error(sd + r + ": " + n);
  if (r = "crypto", i && (this[r] = q6[r]), (n = e[r]) !== void 0)
    if (n === !0 || n === !1 || n === 0 || n === 1)
      if (n)
        if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes))
          this[r] = !0;
        else
          throw Error(gN);
      else
        this[r] = !1;
    else
      throw Error(sd + r + ": " + n);
  return this;
}
function qoe(e) {
  return new this(e).cos();
}
function Koe(e) {
  return new this(e).cosh();
}
function wN(e) {
  var t, r, n;
  function i(a) {
    var o, u, s, c = this;
    if (!(c instanceof i)) return new i(a);
    if (c.constructor = i, hI(a)) {
      c.s = a.s, lr ? !a.d || a.e > i.maxE ? (c.e = NaN, c.d = null) : a.e < i.minE ? (c.e = 0, c.d = [0]) : (c.e = a.e, c.d = a.d.slice()) : (c.e = a.e, c.d = a.d ? a.d.slice() : a.d);
      return;
    }
    if (s = typeof a, s === "number") {
      if (a === 0) {
        c.s = 1 / a < 0 ? -1 : 1, c.e = 0, c.d = [0];
        return;
      }
      if (a < 0 ? (a = -a, c.s = -1) : c.s = 1, a === ~~a && a < 1e7) {
        for (o = 0, u = a; u >= 10; u /= 10) o++;
        lr ? o > i.maxE ? (c.e = NaN, c.d = null) : o < i.minE ? (c.e = 0, c.d = [0]) : (c.e = o, c.d = [a]) : (c.e = o, c.d = [a]);
        return;
      } else if (a * 0 !== 0) {
        a || (c.s = NaN), c.e = NaN, c.d = null;
        return;
      }
      return j6(c, a.toString());
    } else if (s !== "string")
      throw Error(sd + a);
    return (u = a.charCodeAt(0)) === 45 ? (a = a.slice(1), c.s = -1) : (u === 43 && (a = a.slice(1)), c.s = 1), bN.test(a) ? j6(c, a) : Moe(c, a);
  }
  if (i.prototype = lt, i.ROUND_UP = 0, i.ROUND_DOWN = 1, i.ROUND_CEIL = 2, i.ROUND_FLOOR = 3, i.ROUND_HALF_UP = 4, i.ROUND_HALF_DOWN = 5, i.ROUND_HALF_EVEN = 6, i.ROUND_HALF_CEIL = 7, i.ROUND_HALF_FLOOR = 8, i.EUCLID = 9, i.config = i.set = Hoe, i.clone = wN, i.isDecimal = hI, i.abs = Poe, i.acos = Boe, i.acosh = Foe, i.add = Noe, i.asin = Roe, i.asinh = Ooe, i.atan = Loe, i.atanh = koe, i.atan2 = zoe, i.cbrt = Goe, i.ceil = Voe, i.clamp = Uoe, i.cos = qoe, i.cosh = Koe, i.div = Xoe, i.exp = joe, i.floor = Yoe, i.hypot = Woe, i.ln = Zoe, i.log = Qoe, i.log10 = $oe, i.log2 = Joe, i.max = eue, i.min = tue, i.mod = rue, i.mul = nue, i.pow = iue, i.random = aue, i.round = oue, i.sign = uue, i.sin = sue, i.sinh = cue, i.sqrt = lue, i.sub = due, i.sum = fue, i.tan = pue, i.tanh = mue, i.trunc = hue, e === void 0 && (e = {}), e && e.defaults !== !0)
    for (n = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"], t = 0; t < n.length; ) e.hasOwnProperty(r = n[t++]) || (e[r] = this[r]);
  return i.config(e), i;
}
function Xoe(e, t) {
  return new this(e).div(t);
}
function joe(e) {
  return new this(e).exp();
}
function Yoe(e) {
  return Ut(e = new this(e), e.e + 1, 3);
}
function Woe() {
  var e, t, r = new this(0);
  for (lr = !1, e = 0; e < arguments.length; )
    if (t = new this(arguments[e++]), t.d)
      r.d && (r = r.plus(t.times(t)));
    else {
      if (t.s)
        return lr = !0, new this(1 / 0);
      r = t;
    }
  return lr = !0, r.sqrt();
}
function hI(e) {
  return e instanceof _f || e && e.toStringTag === yN || !1;
}
function Zoe(e) {
  return new this(e).ln();
}
function Qoe(e, t) {
  return new this(e).log(t);
}
function Joe(e) {
  return new this(e).log(2);
}
function $oe(e) {
  return new this(e).log(10);
}
function eue() {
  return AN(this, arguments, "lt");
}
function tue() {
  return AN(this, arguments, "gt");
}
function rue(e, t) {
  return new this(e).mod(t);
}
function nue(e, t) {
  return new this(e).mul(t);
}
function iue(e, t) {
  return new this(e).pow(t);
}
function aue(e) {
  var t, r, n, i, a = 0, o = new this(1), u = [];
  if (e === void 0 ? e = this.precision : Co(e, 1, fd), n = Math.ceil(e / Wt), this.crypto)
    if (crypto.getRandomValues)
      for (t = crypto.getRandomValues(new Uint32Array(n)); a < n; )
        i = t[a], i >= 429e7 ? t[a] = crypto.getRandomValues(new Uint32Array(1))[0] : u[a++] = i % 1e7;
    else if (crypto.randomBytes) {
      for (t = crypto.randomBytes(n *= 4); a < n; )
        i = t[a] + (t[a + 1] << 8) + (t[a + 2] << 16) + ((t[a + 3] & 127) << 24), i >= 214e7 ? crypto.randomBytes(4).copy(t, a) : (u.push(i % 1e7), a += 4);
      a = n / 4;
    } else
      throw Error(gN);
  else for (; a < n; ) u[a++] = Math.random() * 1e7 | 0;
  for (n = u[--a], e %= Wt, n && e && (i = Li(10, Wt - e), u[a] = (n / i | 0) * i); u[a] === 0; a--) u.pop();
  if (a < 0)
    r = 0, u = [0];
  else {
    for (r = -1; u[0] === 0; r -= Wt) u.shift();
    for (n = 1, i = u[0]; i >= 10; i /= 10) n++;
    n < Wt && (r -= Wt - n);
  }
  return o.e = r, o.d = u, o;
}
function oue(e) {
  return Ut(e = new this(e), e.e + 1, this.rounding);
}
function uue(e) {
  return e = new this(e), e.d ? e.d[0] ? e.s : 0 * e.s : e.s || NaN;
}
function sue(e) {
  return new this(e).sin();
}
function cue(e) {
  return new this(e).sinh();
}
function lue(e) {
  return new this(e).sqrt();
}
function due(e, t) {
  return new this(e).sub(t);
}
function fue() {
  var e = 0, t = arguments, r = new this(t[e]);
  for (lr = !1; r.s && ++e < t.length; ) r = r.plus(t[e]);
  return lr = !0, Ut(r, this.precision, this.rounding);
}
function pue(e) {
  return new this(e).tan();
}
function mue(e) {
  return new this(e).tanh();
}
function hue(e) {
  return Ut(e = new this(e), e.e + 1, 1);
}
lt[Symbol.for("nodejs.util.inspect.custom")] = lt.toString;
lt[Symbol.toStringTag] = "Decimal";
var _f = lt.constructor = wN(q6);
ug = new _f(ug);
sg = new _f(sg);
var vue = "BigNumber", gue = ["?on", "config"], yue = /* @__PURE__ */ gt(vue, gue, (e) => {
  var {
    on: t,
    config: r
  } = e, n = _f.clone({
    precision: r.precision,
    modulo: _f.EUCLID
  });
  return n.prototype = Object.create(n.prototype), n.prototype.type = "BigNumber", n.prototype.isBigNumber = !0, n.prototype.toJSON = function() {
    return {
      mathjs: "BigNumber",
      value: this.toString()
    };
  }, n.fromJSON = function(i) {
    return new n(i.value);
  }, t && t("config", function(i, a) {
    i.precision !== a.precision && n.config({
      precision: i.precision
    });
  }), n;
}, {
  isClass: !0
}), _p = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function bue(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
var DN = { exports: {} };
/**
 * @license Complex.js v2.1.1 12/05/2020
 *
 * Copyright (c) 2020, Robert Eisele (robert@xarg.org)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 **/
(function(e, t) {
  (function(r) {
    var n = Math.cosh || function(d) {
      return Math.abs(d) < 1e-9 ? 1 - d : (Math.exp(d) + Math.exp(-d)) * 0.5;
    }, i = Math.sinh || function(d) {
      return Math.abs(d) < 1e-9 ? d : (Math.exp(d) - Math.exp(-d)) * 0.5;
    }, a = function(d) {
      var f = Math.PI / 4;
      if (-f > d || d > f)
        return Math.cos(d) - 1;
      var m = d * d;
      return m * (m * (m * (m * (m * (m * (m * (m / 20922789888e3 - 1 / 87178291200) + 1 / 479001600) - 1 / 3628800) + 1 / 40320) - 1 / 720) + 1 / 24) - 1 / 2);
    }, o = function(d, f) {
      var m = Math.abs(d), v = Math.abs(f);
      return m < 3e3 && v < 3e3 ? Math.sqrt(m * m + v * v) : (m < v ? (m = v, v = d / f) : v = f / d, m * Math.sqrt(1 + v * v));
    }, u = function() {
      throw SyntaxError("Invalid Param");
    };
    function s(d, f) {
      var m = Math.abs(d), v = Math.abs(f);
      return d === 0 ? Math.log(v) : f === 0 ? Math.log(m) : m < 3e3 && v < 3e3 ? Math.log(d * d + f * f) * 0.5 : (d = d / 2, f = f / 2, 0.5 * Math.log(d * d + f * f) + Math.LN2);
    }
    var c = function(d, f) {
      var m = { re: 0, im: 0 };
      if (d == null)
        m.re = m.im = 0;
      else if (f !== void 0)
        m.re = d, m.im = f;
      else
        switch (typeof d) {
          case "object":
            if ("im" in d && "re" in d)
              m.re = d.re, m.im = d.im;
            else if ("abs" in d && "arg" in d) {
              if (!Number.isFinite(d.abs) && Number.isFinite(d.arg))
                return l.INFINITY;
              m.re = d.abs * Math.cos(d.arg), m.im = d.abs * Math.sin(d.arg);
            } else if ("r" in d && "phi" in d) {
              if (!Number.isFinite(d.r) && Number.isFinite(d.phi))
                return l.INFINITY;
              m.re = d.r * Math.cos(d.phi), m.im = d.r * Math.sin(d.phi);
            } else d.length === 2 ? (m.re = d[0], m.im = d[1]) : u();
            break;
          case "string":
            m.im = /* void */
            m.re = 0;
            var v = d.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g), p = 1, g = 0;
            v === null && u();
            for (var h = 0; h < v.length; h++) {
              var y = v[h];
              y === " " || y === "	" || y === `
` || (y === "+" ? p++ : y === "-" ? g++ : y === "i" || y === "I" ? (p + g === 0 && u(), v[h + 1] !== " " && !isNaN(v[h + 1]) ? (m.im += parseFloat((g % 2 ? "-" : "") + v[h + 1]), h++) : m.im += parseFloat((g % 2 ? "-" : "") + "1"), p = g = 0) : ((p + g === 0 || isNaN(y)) && u(), v[h + 1] === "i" || v[h + 1] === "I" ? (m.im += parseFloat((g % 2 ? "-" : "") + y), h++) : m.re += parseFloat((g % 2 ? "-" : "") + y), p = g = 0));
            }
            p + g > 0 && u();
            break;
          case "number":
            m.im = 0, m.re = d;
            break;
          default:
            u();
        }
      return isNaN(m.re) || isNaN(m.im), m;
    };
    function l(d, f) {
      if (!(this instanceof l))
        return new l(d, f);
      var m = c(d, f);
      this.re = m.re, this.im = m.im;
    }
    l.prototype = {
      re: 0,
      im: 0,
      /**
       * Calculates the sign of a complex number, which is a normalized complex
       *
       * @returns {Complex}
       */
      sign: function() {
        var d = this.abs();
        return new l(
          this.re / d,
          this.im / d
        );
      },
      /**
       * Adds two complex numbers
       *
       * @returns {Complex}
       */
      add: function(d, f) {
        var m = new l(d, f);
        return this.isInfinite() && m.isInfinite() ? l.NAN : this.isInfinite() || m.isInfinite() ? l.INFINITY : new l(
          this.re + m.re,
          this.im + m.im
        );
      },
      /**
       * Subtracts two complex numbers
       *
       * @returns {Complex}
       */
      sub: function(d, f) {
        var m = new l(d, f);
        return this.isInfinite() && m.isInfinite() ? l.NAN : this.isInfinite() || m.isInfinite() ? l.INFINITY : new l(
          this.re - m.re,
          this.im - m.im
        );
      },
      /**
       * Multiplies two complex numbers
       *
       * @returns {Complex}
       */
      mul: function(d, f) {
        var m = new l(d, f);
        return this.isInfinite() && m.isZero() || this.isZero() && m.isInfinite() ? l.NAN : this.isInfinite() || m.isInfinite() ? l.INFINITY : m.im === 0 && this.im === 0 ? new l(this.re * m.re, 0) : new l(
          this.re * m.re - this.im * m.im,
          this.re * m.im + this.im * m.re
        );
      },
      /**
       * Divides two complex numbers
       *
       * @returns {Complex}
       */
      div: function(d, f) {
        var m = new l(d, f);
        if (this.isZero() && m.isZero() || this.isInfinite() && m.isInfinite())
          return l.NAN;
        if (this.isInfinite() || m.isZero())
          return l.INFINITY;
        if (this.isZero() || m.isInfinite())
          return l.ZERO;
        d = this.re, f = this.im;
        var v = m.re, p = m.im, g, h;
        return p === 0 ? new l(d / v, f / v) : Math.abs(v) < Math.abs(p) ? (h = v / p, g = v * h + p, new l(
          (d * h + f) / g,
          (f * h - d) / g
        )) : (h = p / v, g = p * h + v, new l(
          (d + f * h) / g,
          (f - d * h) / g
        ));
      },
      /**
       * Calculate the power of two complex numbers
       *
       * @returns {Complex}
       */
      pow: function(d, f) {
        var m = new l(d, f);
        if (d = this.re, f = this.im, m.isZero())
          return l.ONE;
        if (m.im === 0) {
          if (f === 0 && d > 0)
            return new l(Math.pow(d, m.re), 0);
          if (d === 0)
            switch ((m.re % 4 + 4) % 4) {
              case 0:
                return new l(Math.pow(f, m.re), 0);
              case 1:
                return new l(0, Math.pow(f, m.re));
              case 2:
                return new l(-Math.pow(f, m.re), 0);
              case 3:
                return new l(0, -Math.pow(f, m.re));
            }
        }
        if (d === 0 && f === 0 && m.re > 0 && m.im >= 0)
          return l.ZERO;
        var v = Math.atan2(f, d), p = s(d, f);
        return d = Math.exp(m.re * p - m.im * v), f = m.im * p + m.re * v, new l(
          d * Math.cos(f),
          d * Math.sin(f)
        );
      },
      /**
       * Calculate the complex square root
       *
       * @returns {Complex}
       */
      sqrt: function() {
        var d = this.re, f = this.im, m = this.abs(), v, p;
        if (d >= 0) {
          if (f === 0)
            return new l(Math.sqrt(d), 0);
          v = 0.5 * Math.sqrt(2 * (m + d));
        } else
          v = Math.abs(f) / Math.sqrt(2 * (m - d));
        return d <= 0 ? p = 0.5 * Math.sqrt(2 * (m - d)) : p = Math.abs(f) / Math.sqrt(2 * (m + d)), new l(v, f < 0 ? -p : p);
      },
      /**
       * Calculate the complex exponent
       *
       * @returns {Complex}
       */
      exp: function() {
        var d = Math.exp(this.re);
        return this.im, new l(
          d * Math.cos(this.im),
          d * Math.sin(this.im)
        );
      },
      /**
       * Calculate the complex exponent and subtracts one.
       *
       * This may be more accurate than `Complex(x).exp().sub(1)` if
       * `x` is small.
       *
       * @returns {Complex}
       */
      expm1: function() {
        var d = this.re, f = this.im;
        return new l(
          Math.expm1(d) * Math.cos(f) + a(f),
          Math.exp(d) * Math.sin(f)
        );
      },
      /**
       * Calculate the natural log
       *
       * @returns {Complex}
       */
      log: function() {
        var d = this.re, f = this.im;
        return new l(
          s(d, f),
          Math.atan2(f, d)
        );
      },
      /**
       * Calculate the magnitude of the complex number
       *
       * @returns {number}
       */
      abs: function() {
        return o(this.re, this.im);
      },
      /**
       * Calculate the angle of the complex number
       *
       * @returns {number}
       */
      arg: function() {
        return Math.atan2(this.im, this.re);
      },
      /**
       * Calculate the sine of the complex number
       *
       * @returns {Complex}
       */
      sin: function() {
        var d = this.re, f = this.im;
        return new l(
          Math.sin(d) * n(f),
          Math.cos(d) * i(f)
        );
      },
      /**
       * Calculate the cosine
       *
       * @returns {Complex}
       */
      cos: function() {
        var d = this.re, f = this.im;
        return new l(
          Math.cos(d) * n(f),
          -Math.sin(d) * i(f)
        );
      },
      /**
       * Calculate the tangent
       *
       * @returns {Complex}
       */
      tan: function() {
        var d = 2 * this.re, f = 2 * this.im, m = Math.cos(d) + n(f);
        return new l(
          Math.sin(d) / m,
          i(f) / m
        );
      },
      /**
       * Calculate the cotangent
       *
       * @returns {Complex}
       */
      cot: function() {
        var d = 2 * this.re, f = 2 * this.im, m = Math.cos(d) - n(f);
        return new l(
          -Math.sin(d) / m,
          i(f) / m
        );
      },
      /**
       * Calculate the secant
       *
       * @returns {Complex}
       */
      sec: function() {
        var d = this.re, f = this.im, m = 0.5 * n(2 * f) + 0.5 * Math.cos(2 * d);
        return new l(
          Math.cos(d) * n(f) / m,
          Math.sin(d) * i(f) / m
        );
      },
      /**
       * Calculate the cosecans
       *
       * @returns {Complex}
       */
      csc: function() {
        var d = this.re, f = this.im, m = 0.5 * n(2 * f) - 0.5 * Math.cos(2 * d);
        return new l(
          Math.sin(d) * n(f) / m,
          -Math.cos(d) * i(f) / m
        );
      },
      /**
       * Calculate the complex arcus sinus
       *
       * @returns {Complex}
       */
      asin: function() {
        var d = this.re, f = this.im, m = new l(
          f * f - d * d + 1,
          -2 * d * f
        ).sqrt(), v = new l(
          m.re - f,
          m.im + d
        ).log();
        return new l(v.im, -v.re);
      },
      /**
       * Calculate the complex arcus cosinus
       *
       * @returns {Complex}
       */
      acos: function() {
        var d = this.re, f = this.im, m = new l(
          f * f - d * d + 1,
          -2 * d * f
        ).sqrt(), v = new l(
          m.re - f,
          m.im + d
        ).log();
        return new l(Math.PI / 2 - v.im, v.re);
      },
      /**
       * Calculate the complex arcus tangent
       *
       * @returns {Complex}
       */
      atan: function() {
        var d = this.re, f = this.im;
        if (d === 0) {
          if (f === 1)
            return new l(0, 1 / 0);
          if (f === -1)
            return new l(0, -1 / 0);
        }
        var m = d * d + (1 - f) * (1 - f), v = new l(
          (1 - f * f - d * d) / m,
          -2 * d / m
        ).log();
        return new l(-0.5 * v.im, 0.5 * v.re);
      },
      /**
       * Calculate the complex arcus cotangent
       *
       * @returns {Complex}
       */
      acot: function() {
        var d = this.re, f = this.im;
        if (f === 0)
          return new l(Math.atan2(1, d), 0);
        var m = d * d + f * f;
        return m !== 0 ? new l(
          d / m,
          -f / m
        ).atan() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).atan();
      },
      /**
       * Calculate the complex arcus secant
       *
       * @returns {Complex}
       */
      asec: function() {
        var d = this.re, f = this.im;
        if (d === 0 && f === 0)
          return new l(0, 1 / 0);
        var m = d * d + f * f;
        return m !== 0 ? new l(
          d / m,
          -f / m
        ).acos() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).acos();
      },
      /**
       * Calculate the complex arcus cosecans
       *
       * @returns {Complex}
       */
      acsc: function() {
        var d = this.re, f = this.im;
        if (d === 0 && f === 0)
          return new l(Math.PI / 2, 1 / 0);
        var m = d * d + f * f;
        return m !== 0 ? new l(
          d / m,
          -f / m
        ).asin() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).asin();
      },
      /**
       * Calculate the complex sinh
       *
       * @returns {Complex}
       */
      sinh: function() {
        var d = this.re, f = this.im;
        return new l(
          i(d) * Math.cos(f),
          n(d) * Math.sin(f)
        );
      },
      /**
       * Calculate the complex cosh
       *
       * @returns {Complex}
       */
      cosh: function() {
        var d = this.re, f = this.im;
        return new l(
          n(d) * Math.cos(f),
          i(d) * Math.sin(f)
        );
      },
      /**
       * Calculate the complex tanh
       *
       * @returns {Complex}
       */
      tanh: function() {
        var d = 2 * this.re, f = 2 * this.im, m = n(d) + Math.cos(f);
        return new l(
          i(d) / m,
          Math.sin(f) / m
        );
      },
      /**
       * Calculate the complex coth
       *
       * @returns {Complex}
       */
      coth: function() {
        var d = 2 * this.re, f = 2 * this.im, m = n(d) - Math.cos(f);
        return new l(
          i(d) / m,
          -Math.sin(f) / m
        );
      },
      /**
       * Calculate the complex coth
       *
       * @returns {Complex}
       */
      csch: function() {
        var d = this.re, f = this.im, m = Math.cos(2 * f) - n(2 * d);
        return new l(
          -2 * i(d) * Math.cos(f) / m,
          2 * n(d) * Math.sin(f) / m
        );
      },
      /**
       * Calculate the complex sech
       *
       * @returns {Complex}
       */
      sech: function() {
        var d = this.re, f = this.im, m = Math.cos(2 * f) + n(2 * d);
        return new l(
          2 * n(d) * Math.cos(f) / m,
          -2 * i(d) * Math.sin(f) / m
        );
      },
      /**
       * Calculate the complex asinh
       *
       * @returns {Complex}
       */
      asinh: function() {
        var d = this.im;
        this.im = -this.re, this.re = d;
        var f = this.asin();
        return this.re = -this.im, this.im = d, d = f.re, f.re = -f.im, f.im = d, f;
      },
      /**
       * Calculate the complex acosh
       *
       * @returns {Complex}
       */
      acosh: function() {
        var d = this.acos();
        if (d.im <= 0) {
          var f = d.re;
          d.re = -d.im, d.im = f;
        } else {
          var f = d.im;
          d.im = -d.re, d.re = f;
        }
        return d;
      },
      /**
       * Calculate the complex atanh
       *
       * @returns {Complex}
       */
      atanh: function() {
        var d = this.re, f = this.im, m = d > 1 && f === 0, v = 1 - d, p = 1 + d, g = v * v + f * f, h = g !== 0 ? new l(
          (p * v - f * f) / g,
          (f * v + p * f) / g
        ) : new l(
          d !== -1 ? d / 0 : 0,
          f !== 0 ? f / 0 : 0
        ), y = h.re;
        return h.re = s(h.re, h.im) / 2, h.im = Math.atan2(h.im, y) / 2, m && (h.im = -h.im), h;
      },
      /**
       * Calculate the complex acoth
       *
       * @returns {Complex}
       */
      acoth: function() {
        var d = this.re, f = this.im;
        if (d === 0 && f === 0)
          return new l(0, Math.PI / 2);
        var m = d * d + f * f;
        return m !== 0 ? new l(
          d / m,
          -f / m
        ).atanh() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).atanh();
      },
      /**
       * Calculate the complex acsch
       *
       * @returns {Complex}
       */
      acsch: function() {
        var d = this.re, f = this.im;
        if (f === 0)
          return new l(
            d !== 0 ? Math.log(d + Math.sqrt(d * d + 1)) : 1 / 0,
            0
          );
        var m = d * d + f * f;
        return m !== 0 ? new l(
          d / m,
          -f / m
        ).asinh() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).asinh();
      },
      /**
       * Calculate the complex asech
       *
       * @returns {Complex}
       */
      asech: function() {
        var d = this.re, f = this.im;
        if (this.isZero())
          return l.INFINITY;
        var m = d * d + f * f;
        return m !== 0 ? new l(
          d / m,
          -f / m
        ).acosh() : new l(
          d !== 0 ? d / 0 : 0,
          f !== 0 ? -f / 0 : 0
        ).acosh();
      },
      /**
       * Calculate the complex inverse 1/z
       *
       * @returns {Complex}
       */
      inverse: function() {
        if (this.isZero())
          return l.INFINITY;
        if (this.isInfinite())
          return l.ZERO;
        var d = this.re, f = this.im, m = d * d + f * f;
        return new l(d / m, -f / m);
      },
      /**
       * Returns the complex conjugate
       *
       * @returns {Complex}
       */
      conjugate: function() {
        return new l(this.re, -this.im);
      },
      /**
       * Gets the negated complex number
       *
       * @returns {Complex}
       */
      neg: function() {
        return new l(-this.re, -this.im);
      },
      /**
       * Ceils the actual complex number
       *
       * @returns {Complex}
       */
      ceil: function(d) {
        return d = Math.pow(10, d || 0), new l(
          Math.ceil(this.re * d) / d,
          Math.ceil(this.im * d) / d
        );
      },
      /**
       * Floors the actual complex number
       *
       * @returns {Complex}
       */
      floor: function(d) {
        return d = Math.pow(10, d || 0), new l(
          Math.floor(this.re * d) / d,
          Math.floor(this.im * d) / d
        );
      },
      /**
       * Ceils the actual complex number
       *
       * @returns {Complex}
       */
      round: function(d) {
        return d = Math.pow(10, d || 0), new l(
          Math.round(this.re * d) / d,
          Math.round(this.im * d) / d
        );
      },
      /**
       * Compares two complex numbers
       *
       * **Note:** new Complex(Infinity).equals(Infinity) === false
       *
       * @returns {boolean}
       */
      equals: function(d, f) {
        var m = new l(d, f);
        return Math.abs(m.re - this.re) <= l.EPSILON && Math.abs(m.im - this.im) <= l.EPSILON;
      },
      /**
       * Clones the actual object
       *
       * @returns {Complex}
       */
      clone: function() {
        return new l(this.re, this.im);
      },
      /**
       * Gets a string of the actual complex number
       *
       * @returns {string}
       */
      toString: function() {
        var d = this.re, f = this.im, m = "";
        return this.isNaN() ? "NaN" : this.isInfinite() ? "Infinity" : (Math.abs(d) < l.EPSILON && (d = 0), Math.abs(f) < l.EPSILON && (f = 0), f === 0 ? m + d : (d !== 0 ? (m += d, m += " ", f < 0 ? (f = -f, m += "-") : m += "+", m += " ") : f < 0 && (f = -f, m += "-"), f !== 1 && (m += f), m + "i"));
      },
      /**
       * Returns the actual number as a vector
       *
       * @returns {Array}
       */
      toVector: function() {
        return [this.re, this.im];
      },
      /**
       * Returns the actual real value of the current object
       *
       * @returns {number|null}
       */
      valueOf: function() {
        return this.im === 0 ? this.re : null;
      },
      /**
       * Determines whether a complex number is not on the Riemann sphere.
       *
       * @returns {boolean}
       */
      isNaN: function() {
        return isNaN(this.re) || isNaN(this.im);
      },
      /**
       * Determines whether or not a complex number is at the zero pole of the
       * Riemann sphere.
       *
       * @returns {boolean}
       */
      isZero: function() {
        return this.im === 0 && this.re === 0;
      },
      /**
       * Determines whether a complex number is not at the infinity pole of the
       * Riemann sphere.
       *
       * @returns {boolean}
       */
      isFinite: function() {
        return isFinite(this.re) && isFinite(this.im);
      },
      /**
       * Determines whether or not a complex number is at the infinity pole of the
       * Riemann sphere.
       *
       * @returns {boolean}
       */
      isInfinite: function() {
        return !(this.isNaN() || this.isFinite());
      }
    }, l.ZERO = new l(0, 0), l.ONE = new l(1, 0), l.I = new l(0, 1), l.PI = new l(Math.PI, 0), l.E = new l(Math.E, 0), l.INFINITY = new l(1 / 0, 1 / 0), l.NAN = new l(NaN, NaN), l.EPSILON = 1e-15, Object.defineProperty(l, "__esModule", { value: !0 }), l.default = l, l.Complex = l, e.exports = l;
  })();
})(DN);
var _ue = DN.exports;
const da = /* @__PURE__ */ bue(_ue);
var xue = "Complex", Aue = [], Sue = /* @__PURE__ */ gt(xue, Aue, () => (Object.defineProperty(da, "name", {
  value: "Complex"
}), da.prototype.constructor = da, da.prototype.type = "Complex", da.prototype.isComplex = !0, da.prototype.toJSON = function() {
  return {
    mathjs: "Complex",
    re: this.re,
    im: this.im
  };
}, da.prototype.toPolar = function() {
  return {
    r: this.abs(),
    phi: this.arg()
  };
}, da.prototype.format = function(e) {
  var t = "", r = this.im, n = this.re, i = U6(this.re, e), a = U6(this.im, e), o = En(e) ? e : e ? e.precision : null;
  if (o !== null) {
    var u = Math.pow(10, -o);
    Math.abs(n / r) < u && (n = 0), Math.abs(r / n) < u && (r = 0);
  }
  return r === 0 ? t = i : n === 0 ? r === 1 ? t = "i" : r === -1 ? t = "-i" : t = a + "i" : r < 0 ? r === -1 ? t = i + " - i" : t = i + " - " + a.substring(1) + "i" : r === 1 ? t = i + " + i" : t = i + " + " + a + "i", t;
}, da.fromPolar = function(e) {
  switch (arguments.length) {
    case 1: {
      var t = arguments[0];
      if (typeof t == "object")
        return da(t);
      throw new TypeError("Input has to be an object with r and phi keys.");
    }
    case 2: {
      var r = arguments[0], n = arguments[1];
      if (En(r)) {
        if (nN(n) && n.hasBase("ANGLE") && (n = n.toNumber("rad")), En(n))
          return new da({
            r,
            phi: n
          });
        throw new TypeError("Phi is not a number nor an angle unit.");
      } else
        throw new TypeError("Radius r is not a number.");
    }
    default:
      throw new SyntaxError("Wrong number of arguments in function fromPolar");
  }
}, da.prototype.valueOf = da.prototype.toString, da.fromJSON = function(e) {
  return new da(e);
}, da.compare = function(e, t) {
  return e.re > t.re ? 1 : e.re < t.re ? -1 : e.im > t.im ? 1 : e.im < t.im ? -1 : 0;
}, da), {
  isClass: !0
});
/**
 * @license Fraction.js v4.3.7 31/08/2023
 * https://www.xarg.org/2014/03/rational-numbers-in-javascript/
 *
 * Copyright (c) 2023, Robert Eisele (robert@raw.org)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 **/
var Cue = 2e3, Bt = {
  s: 1,
  n: 0,
  d: 1
};
function dc(e, t) {
  if (isNaN(e = parseInt(e, 10)))
    throw u2();
  return e * t;
}
function Qn(e, t) {
  if (t === 0)
    throw x8();
  var r = Object.create(Ma.prototype);
  r.s = e < 0 ? -1 : 1, e = e < 0 ? -e : e;
  var n = B1(e, t);
  return r.n = e / n, r.d = t / n, r;
}
function vI(e) {
  for (var t = {}, r = e, n = 2, i = 4; i <= r; ) {
    for (; r % n === 0; )
      r /= n, t[n] = (t[n] || 0) + 1;
    i += 1 + 2 * n++;
  }
  return r !== e ? r > 1 && (t[r] = (t[r] || 0) + 1) : t[e] = (t[e] || 0) + 1, t;
}
var ko = function(e, t) {
  var r = 0, n = 1, i = 1, a = 0, o = 0, u = 0, s = 1, c = 1, l = 0, d = 1, f = 1, m = 1, v = 1e7, p;
  if (e != null) if (t !== void 0) {
    if (r = e, n = t, i = r * n, r % 1 !== 0 || n % 1 !== 0)
      throw Eue();
  } else
    switch (typeof e) {
      case "object": {
        if ("d" in e && "n" in e)
          r = e.n, n = e.d, "s" in e && (r *= e.s);
        else if (0 in e)
          r = e[0], 1 in e && (n = e[1]);
        else
          throw u2();
        i = r * n;
        break;
      }
      case "number": {
        if (e < 0 && (i = e, e = -e), e % 1 === 0)
          r = e;
        else if (e > 0) {
          for (e >= 1 && (c = Math.pow(10, Math.floor(1 + Math.log(e) / Math.LN10)), e /= c); d <= v && m <= v; )
            if (p = (l + f) / (d + m), e === p) {
              d + m <= v ? (r = l + f, n = d + m) : m > d ? (r = f, n = m) : (r = l, n = d);
              break;
            } else
              e > p ? (l += f, d += m) : (f += l, m += d), d > v ? (r = f, n = m) : (r = l, n = d);
          r *= c;
        } else (isNaN(e) || isNaN(t)) && (n = r = NaN);
        break;
      }
      case "string": {
        if (d = e.match(/\d+|./g), d === null)
          throw u2();
        if (d[l] === "-" ? (i = -1, l++) : d[l] === "+" && l++, d.length === l + 1 ? o = dc(d[l++], i) : d[l + 1] === "." || d[l] === "." ? (d[l] !== "." && (a = dc(d[l++], i)), l++, (l + 1 === d.length || d[l + 1] === "(" && d[l + 3] === ")" || d[l + 1] === "'" && d[l + 3] === "'") && (o = dc(d[l], i), s = Math.pow(10, d[l].length), l++), (d[l] === "(" && d[l + 2] === ")" || d[l] === "'" && d[l + 2] === "'") && (u = dc(d[l + 1], i), c = Math.pow(10, d[l + 1].length) - 1, l += 3)) : d[l + 1] === "/" || d[l + 1] === ":" ? (o = dc(d[l], i), s = dc(d[l + 2], 1), l += 3) : d[l + 3] === "/" && d[l + 1] === " " && (a = dc(d[l], i), o = dc(d[l + 2], i), s = dc(d[l + 4], 1), l += 5), d.length <= l) {
          n = s * c, i = /* void */
          r = u + n * a + c * o;
          break;
        }
      }
      default:
        throw u2();
    }
  if (n === 0)
    throw x8();
  Bt.s = i < 0 ? -1 : 1, Bt.n = Math.abs(r), Bt.d = Math.abs(n);
};
function wue(e, t, r) {
  for (var n = 1; t > 0; e = e * e % r, t >>= 1)
    t & 1 && (n = n * e % r);
  return n;
}
function Due(e, t) {
  for (; t % 2 === 0; t /= 2)
    ;
  for (; t % 5 === 0; t /= 5)
    ;
  if (t === 1)
    return 0;
  for (var r = 10 % t, n = 1; r !== 1; n++)
    if (r = r * 10 % t, n > Cue)
      return 0;
  return n;
}
function Iue(e, t, r) {
  for (var n = 1, i = wue(10, r, t), a = 0; a < 300; a++) {
    if (n === i)
      return a;
    n = n * 10 % t, i = i * 10 % t;
  }
  return 0;
}
function B1(e, t) {
  if (!e)
    return t;
  if (!t)
    return e;
  for (; ; ) {
    if (e %= t, !e)
      return t;
    if (t %= e, !t)
      return e;
  }
}
function Ma(e, t) {
  if (ko(e, t), this instanceof Ma)
    e = B1(Bt.d, Bt.n), this.s = Bt.s, this.n = Bt.n / e, this.d = Bt.d / e;
  else
    return Qn(Bt.s * Bt.n, Bt.d);
}
var x8 = function() {
  return new Error("Division by Zero");
}, u2 = function() {
  return new Error("Invalid argument");
}, Eue = function() {
  return new Error("Parameters must be integer");
};
Ma.prototype = {
  s: 1,
  n: 0,
  d: 1,
  /**
   * Calculates the absolute value
   *
   * Ex: new Fraction(-4).abs() => 4
   **/
  abs: function() {
    return Qn(this.n, this.d);
  },
  /**
   * Inverts the sign of the current fraction
   *
   * Ex: new Fraction(-4).neg() => 4
   **/
  neg: function() {
    return Qn(-this.s * this.n, this.d);
  },
  /**
   * Adds two rational numbers
   *
   * Ex: new Fraction({n: 2, d: 3}).add("14.9") => 467 / 30
   **/
  add: function(e, t) {
    return ko(e, t), Qn(
      this.s * this.n * Bt.d + Bt.s * this.d * Bt.n,
      this.d * Bt.d
    );
  },
  /**
   * Subtracts two rational numbers
   *
   * Ex: new Fraction({n: 2, d: 3}).add("14.9") => -427 / 30
   **/
  sub: function(e, t) {
    return ko(e, t), Qn(
      this.s * this.n * Bt.d - Bt.s * this.d * Bt.n,
      this.d * Bt.d
    );
  },
  /**
   * Multiplies two rational numbers
   *
   * Ex: new Fraction("-17.(345)").mul(3) => 5776 / 111
   **/
  mul: function(e, t) {
    return ko(e, t), Qn(
      this.s * Bt.s * this.n * Bt.n,
      this.d * Bt.d
    );
  },
  /**
   * Divides two rational numbers
   *
   * Ex: new Fraction("-17.(345)").inverse().div(3)
   **/
  div: function(e, t) {
    return ko(e, t), Qn(
      this.s * Bt.s * this.n * Bt.d,
      this.d * Bt.n
    );
  },
  /**
   * Clones the actual object
   *
   * Ex: new Fraction("-17.(345)").clone()
   **/
  clone: function() {
    return Qn(this.s * this.n, this.d);
  },
  /**
   * Calculates the modulo of two rational numbers - a more precise fmod
   *
   * Ex: new Fraction('4.(3)').mod([7, 8]) => (13/3) % (7/8) = (5/6)
   **/
  mod: function(e, t) {
    if (isNaN(this.n) || isNaN(this.d))
      return new Ma(NaN);
    if (e === void 0)
      return Qn(this.s * this.n % this.d, 1);
    if (ko(e, t), Bt.n === 0 && this.d === 0)
      throw x8();
    return Qn(
      this.s * (Bt.d * this.n) % (Bt.n * this.d),
      Bt.d * this.d
    );
  },
  /**
   * Calculates the fractional gcd of two rational numbers
   *
   * Ex: new Fraction(5,8).gcd(3,7) => 1/56
   */
  gcd: function(e, t) {
    return ko(e, t), Qn(B1(Bt.n, this.n) * B1(Bt.d, this.d), Bt.d * this.d);
  },
  /**
   * Calculates the fractional lcm of two rational numbers
   *
   * Ex: new Fraction(5,8).lcm(3,7) => 15
   */
  lcm: function(e, t) {
    return ko(e, t), Bt.n === 0 && this.n === 0 ? Qn(0, 1) : Qn(Bt.n * this.n, B1(Bt.n, this.n) * B1(Bt.d, this.d));
  },
  /**
   * Calculates the ceil of a rational number
   *
   * Ex: new Fraction('4.(3)').ceil() => (5 / 1)
   **/
  ceil: function(e) {
    return e = Math.pow(10, e || 0), isNaN(this.n) || isNaN(this.d) ? new Ma(NaN) : Qn(Math.ceil(e * this.s * this.n / this.d), e);
  },
  /**
   * Calculates the floor of a rational number
   *
   * Ex: new Fraction('4.(3)').floor() => (4 / 1)
   **/
  floor: function(e) {
    return e = Math.pow(10, e || 0), isNaN(this.n) || isNaN(this.d) ? new Ma(NaN) : Qn(Math.floor(e * this.s * this.n / this.d), e);
  },
  /**
   * Rounds a rational number
   *
   * Ex: new Fraction('4.(3)').round() => (4 / 1)
   **/
  round: function(e) {
    return e = Math.pow(10, e || 0), isNaN(this.n) || isNaN(this.d) ? new Ma(NaN) : Qn(Math.round(e * this.s * this.n / this.d), e);
  },
  /**
   * Rounds a rational number to a multiple of another rational number
   *
   * Ex: new Fraction('0.9').roundTo("1/8") => 7 / 8
   **/
  roundTo: function(e, t) {
    return ko(e, t), Qn(this.s * Math.round(this.n * Bt.d / (this.d * Bt.n)) * Bt.n, Bt.d);
  },
  /**
   * Gets the inverse of the fraction, means numerator and denominator are exchanged
   *
   * Ex: new Fraction([-3, 4]).inverse() => -4 / 3
   **/
  inverse: function() {
    return Qn(this.s * this.d, this.n);
  },
  /**
   * Calculates the fraction to some rational exponent, if possible
   *
   * Ex: new Fraction(-1,2).pow(-3) => -8
   */
  pow: function(e, t) {
    if (ko(e, t), Bt.d === 1)
      return Bt.s < 0 ? Qn(Math.pow(this.s * this.d, Bt.n), Math.pow(this.n, Bt.n)) : Qn(Math.pow(this.s * this.n, Bt.n), Math.pow(this.d, Bt.n));
    if (this.s < 0) return null;
    var r = vI(this.n), n = vI(this.d), i = 1, a = 1;
    for (var o in r)
      if (o !== "1") {
        if (o === "0") {
          i = 0;
          break;
        }
        if (r[o] *= Bt.n, r[o] % Bt.d === 0)
          r[o] /= Bt.d;
        else return null;
        i *= Math.pow(o, r[o]);
      }
    for (var o in n)
      if (o !== "1") {
        if (n[o] *= Bt.n, n[o] % Bt.d === 0)
          n[o] /= Bt.d;
        else return null;
        a *= Math.pow(o, n[o]);
      }
    return Bt.s < 0 ? Qn(a, i) : Qn(i, a);
  },
  /**
   * Check if two rational numbers are the same
   *
   * Ex: new Fraction(19.6).equals([98, 5]);
   **/
  equals: function(e, t) {
    return ko(e, t), this.s * this.n * Bt.d === Bt.s * Bt.n * this.d;
  },
  /**
   * Check if two rational numbers are the same
   *
   * Ex: new Fraction(19.6).equals([98, 5]);
   **/
  compare: function(e, t) {
    ko(e, t);
    var r = this.s * this.n * Bt.d - Bt.s * Bt.n * this.d;
    return (0 < r) - (r < 0);
  },
  simplify: function(e) {
    if (isNaN(this.n) || isNaN(this.d))
      return this;
    e = e || 1e-3;
    for (var t = this.abs(), r = t.toContinued(), n = 1; n < r.length; n++) {
      for (var i = Qn(r[n - 1], 1), a = n - 2; a >= 0; a--)
        i = i.inverse().add(r[a]);
      if (Math.abs(i.sub(t).valueOf()) < e)
        return i.mul(this.s);
    }
    return this;
  },
  /**
   * Check if two rational numbers are divisible
   *
   * Ex: new Fraction(19.6).divisible(1.5);
   */
  divisible: function(e, t) {
    return ko(e, t), !(!(Bt.n * this.d) || this.n * Bt.d % (Bt.n * this.d));
  },
  /**
   * Returns a decimal representation of the fraction
   *
   * Ex: new Fraction("100.'91823'").valueOf() => 100.91823918239183
   **/
  valueOf: function() {
    return this.s * this.n / this.d;
  },
  /**
   * Returns a string-fraction representation of a Fraction object
   *
   * Ex: new Fraction("1.'3'").toFraction(true) => "4 1/3"
   **/
  toFraction: function(e) {
    var t, r = "", n = this.n, i = this.d;
    return this.s < 0 && (r += "-"), i === 1 ? r += n : (e && (t = Math.floor(n / i)) > 0 && (r += t, r += " ", n %= i), r += n, r += "/", r += i), r;
  },
  /**
   * Returns a latex representation of a Fraction object
   *
   * Ex: new Fraction("1.'3'").toLatex() => "\frac{4}{3}"
   **/
  toLatex: function(e) {
    var t, r = "", n = this.n, i = this.d;
    return this.s < 0 && (r += "-"), i === 1 ? r += n : (e && (t = Math.floor(n / i)) > 0 && (r += t, n %= i), r += "\\frac{", r += n, r += "}{", r += i, r += "}"), r;
  },
  /**
   * Returns an array of continued fraction elements
   *
   * Ex: new Fraction("7/8").toContinued() => [0,1,7]
   */
  toContinued: function() {
    var e, t = this.n, r = this.d, n = [];
    if (isNaN(t) || isNaN(r))
      return n;
    do
      n.push(Math.floor(t / r)), e = t % r, t = r, r = e;
    while (t !== 1);
    return n;
  },
  /**
   * Creates a string representation of a fraction with all digits
   *
   * Ex: new Fraction("100.'91823'").toString() => "100.(91823)"
   **/
  toString: function(e) {
    var t = this.n, r = this.d;
    if (isNaN(t) || isNaN(r))
      return "NaN";
    e = e || 15;
    var n = Due(t, r), i = Iue(t, r, n), a = this.s < 0 ? "-" : "";
    if (a += t / r | 0, t %= r, t *= 10, t && (a += "."), n) {
      for (var o = i; o--; )
        a += t / r | 0, t %= r, t *= 10;
      a += "(";
      for (var o = n; o--; )
        a += t / r | 0, t %= r, t *= 10;
      a += ")";
    } else
      for (var o = e; t && o--; )
        a += t / r | 0, t %= r, t *= 10;
    return a;
  }
};
var Mue = "Fraction", Tue = [], Pue = /* @__PURE__ */ gt(Mue, Tue, () => (Object.defineProperty(Ma, "name", {
  value: "Fraction"
}), Ma.prototype.constructor = Ma, Ma.prototype.type = "Fraction", Ma.prototype.isFraction = !0, Ma.prototype.toJSON = function() {
  return {
    mathjs: "Fraction",
    n: this.s * this.n,
    d: this.d
  };
}, Ma.fromJSON = function(e) {
  return new Ma(e);
}, Ma), {
  isClass: !0
}), Bue = "Matrix", Fue = [], Nue = /* @__PURE__ */ gt(Bue, Fue, () => {
  function e() {
    if (!(this instanceof e))
      throw new SyntaxError("Constructor must be called with the new operator");
  }
  return e.prototype.type = "Matrix", e.prototype.isMatrix = !0, e.prototype.storage = function() {
    throw new Error("Cannot invoke storage on a Matrix interface");
  }, e.prototype.datatype = function() {
    throw new Error("Cannot invoke datatype on a Matrix interface");
  }, e.prototype.create = function(t, r) {
    throw new Error("Cannot invoke create on a Matrix interface");
  }, e.prototype.subset = function(t, r, n) {
    throw new Error("Cannot invoke subset on a Matrix interface");
  }, e.prototype.get = function(t) {
    throw new Error("Cannot invoke get on a Matrix interface");
  }, e.prototype.set = function(t, r, n) {
    throw new Error("Cannot invoke set on a Matrix interface");
  }, e.prototype.resize = function(t, r) {
    throw new Error("Cannot invoke resize on a Matrix interface");
  }, e.prototype.reshape = function(t, r) {
    throw new Error("Cannot invoke reshape on a Matrix interface");
  }, e.prototype.clone = function() {
    throw new Error("Cannot invoke clone on a Matrix interface");
  }, e.prototype.size = function() {
    throw new Error("Cannot invoke size on a Matrix interface");
  }, e.prototype.map = function(t, r) {
    throw new Error("Cannot invoke map on a Matrix interface");
  }, e.prototype.forEach = function(t) {
    throw new Error("Cannot invoke forEach on a Matrix interface");
  }, e.prototype[Symbol.iterator] = function() {
    throw new Error("Cannot iterate a Matrix interface");
  }, e.prototype.toArray = function() {
    throw new Error("Cannot invoke toArray on a Matrix interface");
  }, e.prototype.valueOf = function() {
    throw new Error("Cannot invoke valueOf on a Matrix interface");
  }, e.prototype.format = function(t) {
    throw new Error("Cannot invoke format on a Matrix interface");
  }, e.prototype.toString = function() {
    throw new Error("Cannot invoke toString on a Matrix interface");
  }, e;
}, {
  isClass: !0
});
function q5(e, t, r) {
  var n = e.constructor, i = new n(2), a = "";
  if (r) {
    if (r < 1)
      throw new Error("size must be in greater than 0");
    if (!Mn(r))
      throw new Error("size must be an integer");
    if (e.greaterThan(i.pow(r - 1).sub(1)) || e.lessThan(i.pow(r - 1).mul(-1)))
      throw new Error("Value must be in range [-2^".concat(r - 1, ", 2^").concat(r - 1, "-1]"));
    if (!e.isInteger())
      throw new Error("Value must be an integer");
    e.lessThan(0) && (e = e.add(i.pow(r))), a = "i".concat(r);
  }
  switch (t) {
    case 2:
      return "".concat(e.toBinary()).concat(a);
    case 8:
      return "".concat(e.toOctal()).concat(a);
    case 16:
      return "".concat(e.toHexadecimal()).concat(a);
    default:
      throw new Error("Base ".concat(t, " not supported "));
  }
}
function Rue(e, t) {
  if (typeof t == "function")
    return t(e);
  if (!e.isFinite())
    return e.isNaN() ? "NaN" : e.gt(0) ? "Infinity" : "-Infinity";
  var {
    notation: r,
    precision: n,
    wordSize: i
  } = cN(t);
  switch (r) {
    case "fixed":
      return Lue(e, n);
    case "exponential":
      return gI(e, n);
    case "engineering":
      return Oue(e, n);
    case "bin":
      return q5(e, 2, i);
    case "oct":
      return q5(e, 8, i);
    case "hex":
      return q5(e, 16, i);
    case "auto": {
      var a = yI(t == null ? void 0 : t.lowerExp, -3), o = yI(t == null ? void 0 : t.upperExp, 5);
      if (e.isZero()) return "0";
      var u, s = e.toSignificantDigits(n), c = s.e;
      return c >= a && c < o ? u = s.toFixed() : u = gI(e, n), u.replace(/((\.\d*?)(0+))($|e)/, function() {
        var l = arguments[2], d = arguments[4];
        return l !== "." ? l + d : d;
      });
    }
    default:
      throw new Error('Unknown notation "' + r + '". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.');
  }
}
function Oue(e, t) {
  var r = e.e, n = r % 3 === 0 ? r : r < 0 ? r - 3 - r % 3 : r - r % 3, i = e.mul(Math.pow(10, -n)), a = i.toPrecision(t);
  if (a.includes("e")) {
    var o = e.constructor;
    a = new o(a).toFixed();
  }
  return a + "e" + (r >= 0 ? "+" : "") + n.toString();
}
function gI(e, t) {
  return t !== void 0 ? e.toExponential(t - 1) : e.toExponential();
}
function Lue(e, t) {
  return e.toFixed(t);
}
function yI(e, t) {
  return En(e) ? e : ti(e) ? e.toNumber() : t;
}
function kn(e, t) {
  var r = kue(e, t);
  return t && typeof t == "object" && "truncate" in t && r.length > t.truncate ? r.substring(0, t.truncate - 3) + "..." : r;
}
function kue(e, t) {
  if (typeof e == "number")
    return U6(e, t);
  if (ti(e))
    return Rue(e, t);
  if (zue(e))
    return !t || t.fraction !== "decimal" ? e.s * e.n + "/" + e.d : e.toString();
  if (Array.isArray(e))
    return IN(e, t);
  if (Yu(e))
    return bI(e);
  if (typeof e == "function")
    return e.syntax ? String(e.syntax) : "function";
  if (e && typeof e == "object") {
    if (typeof e.format == "function")
      return e.format(t);
    if (e && e.toString(t) !== {}.toString())
      return e.toString(t);
    var r = Object.keys(e).map((n) => bI(n) + ": " + kn(e[n], t));
    return "{" + r.join(", ") + "}";
  }
  return String(e);
}
function bI(e) {
  for (var t = String(e), r = "", n = 0; n < t.length; ) {
    var i = t.charAt(n);
    r += i in _I ? _I[i] : i, n++;
  }
  return '"' + r + '"';
}
var _I = {
  '"': '\\"',
  "\\": "\\\\",
  "\b": "\\b",
  "\f": "\\f",
  "\n": "\\n",
  "\r": "\\r",
  "	": "\\t"
};
function IN(e, t) {
  if (Array.isArray(e)) {
    for (var r = "[", n = e.length, i = 0; i < n; i++)
      i !== 0 && (r += ", "), r += IN(e[i], t);
    return r += "]", r;
  } else
    return kn(e, t);
}
function zue(e) {
  return e && typeof e == "object" && typeof e.s == "number" && typeof e.n == "number" && typeof e.d == "number" || !1;
}
function Qr(e, t, r) {
  if (!(this instanceof Qr))
    throw new SyntaxError("Constructor must be called with the new operator");
  this.actual = e, this.expected = t, this.relation = r, this.message = "Dimension mismatch (" + (Array.isArray(e) ? "[" + e.join(", ") + "]" : e) + " " + (this.relation || "!=") + " " + (Array.isArray(t) ? "[" + t.join(", ") + "]" : t) + ")", this.stack = new Error().stack;
}
Qr.prototype = new RangeError();
Qr.prototype.constructor = RangeError;
Qr.prototype.name = "DimensionError";
Qr.prototype.isDimensionError = !0;
function Ef(e, t, r) {
  if (!(this instanceof Ef))
    throw new SyntaxError("Constructor must be called with the new operator");
  this.index = e, arguments.length < 3 ? (this.min = 0, this.max = t) : (this.min = t, this.max = r), this.min !== void 0 && this.index < this.min ? this.message = "Index out of range (" + this.index + " < " + this.min + ")" : this.max !== void 0 && this.index >= this.max ? this.message = "Index out of range (" + this.index + " > " + (this.max - 1) + ")" : this.message = "Index out of range (" + this.index + ")", this.stack = new Error().stack;
}
Ef.prototype = new RangeError();
Ef.prototype.constructor = RangeError;
Ef.prototype.name = "IndexError";
Ef.prototype.isIndexError = !0;
function Fn(e) {
  for (var t = []; Array.isArray(e); )
    t.push(e.length), e = e[0];
  return t;
}
function EN(e, t, r) {
  var n, i = e.length;
  if (i !== t[r])
    throw new Qr(i, t[r]);
  if (r < t.length - 1) {
    var a = r + 1;
    for (n = 0; n < i; n++) {
      var o = e[n];
      if (!Array.isArray(o))
        throw new Qr(t.length - 1, t.length, "<");
      EN(e[n], t, a);
    }
  } else
    for (n = 0; n < i; n++)
      if (Array.isArray(e[n]))
        throw new Qr(t.length + 1, t.length, ">");
}
function xI(e, t) {
  var r = t.length === 0;
  if (r) {
    if (Array.isArray(e))
      throw new Qr(e.length, 0);
  } else
    EN(e, t, 0);
}
function Xn(e, t) {
  if (e !== void 0) {
    if (!En(e) || !Mn(e))
      throw new TypeError("Index must be an integer (value: " + e + ")");
    if (e < 0 || typeof t == "number" && e >= t)
      throw new Ef(e, t);
  }
}
function lg(e, t, r) {
  if (!Array.isArray(t))
    throw new TypeError("Array expected");
  if (t.length === 0)
    throw new Error("Resizing to scalar is not supported");
  t.forEach(function(i) {
    if (!En(i) || !Mn(i) || i < 0)
      throw new TypeError("Invalid size, must contain positive integers (size: " + kn(t) + ")");
  }), (En(e) || ti(e)) && (e = [e]);
  var n = r !== void 0 ? r : 0;
  return Y6(e, t, 0, n), e;
}
function Y6(e, t, r, n) {
  var i, a, o = e.length, u = t[r], s = Math.min(o, u);
  if (e.length = u, r < t.length - 1) {
    var c = r + 1;
    for (i = 0; i < s; i++)
      a = e[i], Array.isArray(a) || (a = [a], e[i] = a), Y6(a, t, c, n);
    for (i = s; i < u; i++)
      a = [], e[i] = a, Y6(a, t, c, n);
  } else {
    for (i = 0; i < s; i++)
      for (; Array.isArray(e[i]); )
        e[i] = e[i][0];
    for (i = s; i < u; i++)
      e[i] = n;
  }
}
function A8(e, t) {
  var r = W6(e), n = r.length;
  if (!Array.isArray(e) || !Array.isArray(t))
    throw new TypeError("Array expected");
  if (t.length === 0)
    throw new Qr(0, n, "!=");
  t = S8(t, n);
  var i = MN(t);
  if (n !== i)
    throw new Qr(i, n, "!=");
  try {
    return Gue(r, t);
  } catch (a) {
    throw a instanceof Qr ? new Qr(i, n, "!=") : a;
  }
}
function S8(e, t) {
  var r = MN(e), n = e.slice(), i = -1, a = e.indexOf(i), o = e.indexOf(i, a + 1) >= 0;
  if (o)
    throw new Error("More than one wildcard in sizes");
  var u = a >= 0, s = t % r === 0;
  if (u)
    if (s)
      n[a] = -t / r;
    else
      throw new Error("Could not replace wildcard, since " + t + " is no multiple of " + -r);
  return n;
}
function MN(e) {
  return e.reduce((t, r) => t * r, 1);
}
function Gue(e, t) {
  for (var r = e, n, i = t.length - 1; i > 0; i--) {
    var a = t[i];
    n = [];
    for (var o = r.length / a, u = 0; u < o; u++)
      n.push(r.slice(u * a, (u + 1) * a));
    r = n;
  }
  return r;
}
function AI(e, t) {
  for (var r = Fn(e); Array.isArray(e) && e.length === 1; )
    e = e[0], r.shift();
  for (var n = r.length; r[n - 1] === 1; )
    n--;
  return n < r.length && (e = TN(e, n, 0), r.length = n), e;
}
function TN(e, t, r) {
  var n, i;
  if (r < t) {
    var a = r + 1;
    for (n = 0, i = e.length; n < i; n++)
      e[n] = TN(e[n], t, a);
  } else
    for (; Array.isArray(e); )
      e = e[0];
  return e;
}
function PN(e, t, r, n) {
  var i = n || Fn(e);
  if (r)
    for (var a = 0; a < r; a++)
      e = [e], i.unshift(1);
  for (e = BN(e, t, 0); i.length < t; )
    i.push(1);
  return e;
}
function BN(e, t, r) {
  var n, i;
  if (Array.isArray(e)) {
    var a = r + 1;
    for (n = 0, i = e.length; n < i; n++)
      e[n] = BN(e[n], t, a);
  } else
    for (var o = r; o < t; o++)
      e = [e];
  return e;
}
function W6(e) {
  if (!Array.isArray(e))
    return e;
  var t = [];
  return e.forEach(function r(n) {
    Array.isArray(n) ? n.forEach(r) : t.push(n);
  }), t;
}
function xm(e, t) {
  for (var r, n = 0, i = 0; i < e.length; i++) {
    var a = e[i], o = Array.isArray(a);
    if (i === 0 && o && (n = a.length), o && a.length !== n)
      return;
    var u = o ? xm(a, t) : t(a);
    if (r === void 0)
      r = u;
    else if (r !== u)
      return "mixed";
  }
  return r;
}
function FN(e, t, r, n) {
  if (n < r) {
    if (e.length !== t.length)
      throw new Qr(e.length, t.length);
    for (var i = [], a = 0; a < e.length; a++)
      i[a] = FN(e[a], t[a], r, n + 1);
    return i;
  } else
    return e.concat(t);
}
function NN() {
  var e = Array.prototype.slice.call(arguments, 0, -1), t = Array.prototype.slice.call(arguments, -1);
  if (e.length === 1)
    return e[0];
  if (e.length > 1)
    return e.slice(1).reduce(function(r, n) {
      return FN(r, n, t, 0);
    }, e[0]);
  throw new Error("Wrong number of arguments in function concat");
}
function RN() {
  for (var e = arguments.length, t = new Array(e), r = 0; r < e; r++)
    t[r] = arguments[r];
  for (var n = t.map((f) => f.length), i = Math.max(...n), a = new Array(i).fill(null), o = 0; o < t.length; o++)
    for (var u = t[o], s = n[o], c = 0; c < s; c++) {
      var l = i - s + c;
      u[c] > a[l] && (a[l] = u[c]);
    }
  for (var d = 0; d < t.length; d++)
    ON(t[d], a);
  return a;
}
function ON(e, t) {
  for (var r = t.length, n = e.length, i = 0; i < n; i++) {
    var a = r - n + i;
    if (e[i] < t[a] && e[i] > 1 || e[i] > t[a])
      throw new Error("shape missmatch: missmatch is found in arg with shape (".concat(e, ") not possible to broadcast dimension ").concat(n, " with size ").concat(e[i], " to size ").concat(t[a]));
  }
}
function Z6(e, t) {
  var r = Fn(e);
  if (ud(r, t))
    return e;
  ON(r, t);
  var n = RN(r, t), i = n.length, a = [...Array(i - r.length).fill(1), ...r], o = Uue(e);
  r.length < i && (o = A8(o, a), r = Fn(o));
  for (var u = 0; u < i; u++)
    r[u] < n[u] && (o = Vue(o, n[u], u), r = Fn(o));
  return o;
}
function Vue(e, t, r) {
  return NN(...Array(t).fill(e), r);
}
function Uue(e) {
  return p0([], e);
}
function Hue(e) {
  var t = 0, r = 1, n = /* @__PURE__ */ Object.create(null), i = /* @__PURE__ */ Object.create(null), a = 0, o = function(s) {
    var c = i[s];
    if (c && (delete n[c], delete i[s], --t, r === c)) {
      if (!t) {
        a = 0, r = 1;
        return;
      }
      for (; !Object.prototype.hasOwnProperty.call(n, ++r); )
        ;
    }
  };
  return e = Math.abs(e), {
    hit: function(s) {
      var c = i[s], l = ++a;
      if (n[l] = s, i[s] = l, !c)
        return ++t, t <= e ? void 0 : (s = n[r], o(s), s);
      if (delete n[c], r === c)
        for (; !Object.prototype.hasOwnProperty.call(n, ++r); )
          ;
    },
    delete: o,
    clear: function() {
      t = a = 0, r = 1, n = /* @__PURE__ */ Object.create(null), i = /* @__PURE__ */ Object.create(null);
    }
  };
}
function t3(e) {
  var {
    hasher: t,
    limit: r
  } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
  return r = r ?? Number.POSITIVE_INFINITY, t = t ?? JSON.stringify, function n() {
    typeof n.cache != "object" && (n.cache = {
      values: /* @__PURE__ */ new Map(),
      lru: Hue(r || Number.POSITIVE_INFINITY)
    });
    for (var i = [], a = 0; a < arguments.length; a++)
      i[a] = arguments[a];
    var o = t(i);
    if (n.cache.values.has(o))
      return n.cache.lru.hit(o), n.cache.values.get(o);
    var u = e.apply(e, i);
    return n.cache.values.set(o, u), n.cache.values.delete(n.cache.lru.hit(o)), u;
  };
}
function LN(e) {
  return Object.keys(e.signatures || {}).reduce(function(t, r) {
    var n = (r.match(/,/g) || []).length + 1;
    return Math.max(t, n);
  }, -1);
}
var que = "DenseMatrix", Kue = ["Matrix"], Xue = /* @__PURE__ */ gt(que, Kue, (e) => {
  var {
    Matrix: t
  } = e;
  function r(l, d) {
    if (!(this instanceof r))
      throw new SyntaxError("Constructor must be called with the new operator");
    if (d && !Yu(d))
      throw new Error("Invalid datatype: " + d);
    if (Nn(l))
      l.type === "DenseMatrix" ? (this._data = Wr(l._data), this._size = Wr(l._size), this._datatype = d || l._datatype) : (this._data = l.toArray(), this._size = l.size(), this._datatype = d || l._datatype);
    else if (l && bn(l.data) && bn(l.size))
      this._data = l.data, this._size = l.size, xI(this._data, this._size), this._datatype = d || l.datatype;
    else if (bn(l))
      this._data = c(l), this._size = Fn(this._data), xI(this._data, this._size), this._datatype = d;
    else {
      if (l)
        throw new TypeError("Unsupported type of data (" + Ic(l) + ")");
      this._data = [], this._size = [0], this._datatype = d;
    }
  }
  r.prototype = new t(), r.prototype.createDenseMatrix = function(l, d) {
    return new r(l, d);
  }, Object.defineProperty(r, "name", {
    value: "DenseMatrix"
  }), r.prototype.constructor = r, r.prototype.type = "DenseMatrix", r.prototype.isDenseMatrix = !0, r.prototype.getDataType = function() {
    return xm(this._data, Ic);
  }, r.prototype.storage = function() {
    return "dense";
  }, r.prototype.datatype = function() {
    return this._datatype;
  }, r.prototype.create = function(l, d) {
    return new r(l, d);
  }, r.prototype.subset = function(l, d, f) {
    switch (arguments.length) {
      case 1:
        return n(this, l);
      case 2:
      case 3:
        return a(this, l, d, f);
      default:
        throw new SyntaxError("Wrong number of arguments");
    }
  }, r.prototype.get = function(l) {
    if (!bn(l))
      throw new TypeError("Array expected");
    if (l.length !== this._size.length)
      throw new Qr(l.length, this._size.length);
    for (var d = 0; d < l.length; d++)
      Xn(l[d], this._size[d]);
    for (var f = this._data, m = 0, v = l.length; m < v; m++) {
      var p = l[m];
      Xn(p, f.length), f = f[p];
    }
    return f;
  }, r.prototype.set = function(l, d, f) {
    if (!bn(l))
      throw new TypeError("Array expected");
    if (l.length < this._size.length)
      throw new Qr(l.length, this._size.length, "<");
    var m, v, p, g = l.map(function(y) {
      return y + 1;
    });
    s(this, g, f);
    var h = this._data;
    for (m = 0, v = l.length - 1; m < v; m++)
      p = l[m], Xn(p, h.length), h = h[p];
    return p = l[l.length - 1], Xn(p, h.length), h[p] = d, this;
  };
  function n(l, d) {
    if (!y8(d))
      throw new TypeError("Invalid index");
    var f = d.isScalar();
    if (f)
      return l.get(d.min());
    var m = d.size();
    if (m.length !== l._size.length)
      throw new Qr(m.length, l._size.length);
    for (var v = d.min(), p = d.max(), g = 0, h = l._size.length; g < h; g++)
      Xn(v[g], l._size[g]), Xn(p[g], l._size[g]);
    return new r(i(l._data, d, m.length, 0), l._datatype);
  }
  function i(l, d, f, m) {
    var v = m === f - 1, p = d.dimension(m);
    return v ? p.map(function(g) {
      return Xn(g, l.length), l[g];
    }).valueOf() : p.map(function(g) {
      Xn(g, l.length);
      var h = l[g];
      return i(h, d, f, m + 1);
    }).valueOf();
  }
  function a(l, d, f, m) {
    if (!d || d.isIndex !== !0)
      throw new TypeError("Invalid index");
    var v = d.size(), p = d.isScalar(), g;
    if (Nn(f) ? (g = f.size(), f = f.valueOf()) : g = Fn(f), p) {
      if (g.length !== 0)
        throw new TypeError("Scalar expected");
      l.set(d.min(), f, m);
    } else {
      if (!ud(g, v))
        try {
          g.length === 0 ? f = Z6([f], v) : f = Z6(f, v), g = Fn(f);
        } catch {
        }
      if (v.length < l._size.length)
        throw new Qr(v.length, l._size.length, "<");
      if (g.length < v.length) {
        for (var h = 0, y = 0; v[h] === 1 && g[h] === 1; )
          h++;
        for (; v[h] === 1; )
          y++, h++;
        f = PN(f, v.length, y, g);
      }
      if (!ud(v, g))
        throw new Qr(v, g, ">");
      var x = d.max().map(function(_) {
        return _ + 1;
      });
      s(l, x, m);
      var A = v.length, b = 0;
      o(l._data, d, f, A, b);
    }
    return l;
  }
  function o(l, d, f, m, v) {
    var p = v === m - 1, g = d.dimension(v);
    p ? g.forEach(function(h, y) {
      Xn(h), l[h] = f[y[0]];
    }) : g.forEach(function(h, y) {
      Xn(h), o(l[h], d, f[y[0]], m, v + 1);
    });
  }
  r.prototype.resize = function(l, d, f) {
    if (!og(l))
      throw new TypeError("Array or Matrix expected");
    var m = l.valueOf().map((p) => Array.isArray(p) && p.length === 1 ? p[0] : p), v = f ? this.clone() : this;
    return u(v, m, d);
  };
  function u(l, d, f) {
    if (d.length === 0) {
      for (var m = l._data; bn(m); )
        m = m[0];
      return m;
    }
    return l._size = d.slice(0), l._data = lg(l._data, l._size, f), l;
  }
  r.prototype.reshape = function(l, d) {
    var f = d ? this.clone() : this;
    f._data = A8(f._data, l);
    var m = f._size.reduce((v, p) => v * p);
    return f._size = S8(l, m), f;
  };
  function s(l, d, f) {
    for (var m = l._size.slice(0), v = !1; m.length < d.length; )
      m.push(0), v = !0;
    for (var p = 0, g = d.length; p < g; p++)
      d[p] > m[p] && (m[p] = d[p], v = !0);
    v && u(l, m, f);
  }
  r.prototype.clone = function() {
    var l = new r({
      data: Wr(this._data),
      size: Wr(this._size),
      datatype: this._datatype
    });
    return l;
  }, r.prototype.size = function() {
    return this._size.slice(0);
  }, r.prototype.map = function(l) {
    var d = this, f = LN(l), m = function g(h, y) {
      return bn(h) ? h.map(function(x, A) {
        return g(x, y.concat(A));
      }) : f === 1 ? l(h) : f === 2 ? l(h, y) : l(h, y, d);
    }, v = m(this._data, []), p = this._datatype !== void 0 ? xm(v, Ic) : void 0;
    return new r(v, p);
  }, r.prototype.forEach = function(l) {
    var d = this, f = function m(v, p) {
      bn(v) ? v.forEach(function(g, h) {
        m(g, p.concat(h));
      }) : l(v, p, d);
    };
    f(this._data, []);
  }, r.prototype[Symbol.iterator] = function* () {
    var l = function* d(f, m) {
      if (bn(f))
        for (var v = 0; v < f.length; v++)
          yield* d(f[v], m.concat(v));
      else
        yield {
          value: f,
          index: m
        };
    };
    yield* l(this._data, []);
  }, r.prototype.rows = function() {
    var l = [], d = this.size();
    if (d.length !== 2)
      throw new TypeError("Rows can only be returned for a 2D matrix.");
    var f = this._data;
    for (var m of f)
      l.push(new r([m], this._datatype));
    return l;
  }, r.prototype.columns = function() {
    var l = this, d = [], f = this.size();
    if (f.length !== 2)
      throw new TypeError("Rows can only be returned for a 2D matrix.");
    for (var m = this._data, v = function(h) {
      var y = m.map((x) => [x[h]]);
      d.push(new r(y, l._datatype));
    }, p = 0; p < f[1]; p++)
      v(p);
    return d;
  }, r.prototype.toArray = function() {
    return Wr(this._data);
  }, r.prototype.valueOf = function() {
    return this._data;
  }, r.prototype.format = function(l) {
    return kn(this._data, l);
  }, r.prototype.toString = function() {
    return kn(this._data);
  }, r.prototype.toJSON = function() {
    return {
      mathjs: "DenseMatrix",
      data: this._data,
      size: this._size,
      datatype: this._datatype
    };
  }, r.prototype.diagonal = function(l) {
    if (l) {
      if (ti(l) && (l = l.toNumber()), !En(l) || !Mn(l))
        throw new TypeError("The parameter k must be an integer number");
    } else
      l = 0;
    for (var d = l > 0 ? l : 0, f = l < 0 ? -l : 0, m = this._size[0], v = this._size[1], p = Math.min(m - f, v - d), g = [], h = 0; h < p; h++)
      g[h] = this._data[h + f][h + d];
    return new r({
      data: g,
      size: [p],
      datatype: this._datatype
    });
  }, r.diagonal = function(l, d, f, m) {
    if (!bn(l))
      throw new TypeError("Array expected, size parameter");
    if (l.length !== 2)
      throw new Error("Only two dimensions matrix are supported");
    if (l = l.map(function(S) {
      if (ti(S) && (S = S.toNumber()), !En(S) || !Mn(S) || S < 1)
        throw new Error("Size values must be positive integers");
      return S;
    }), f) {
      if (ti(f) && (f = f.toNumber()), !En(f) || !Mn(f))
        throw new TypeError("The parameter k must be an integer number");
    } else
      f = 0;
    var v = f > 0 ? f : 0, p = f < 0 ? -f : 0, g = l[0], h = l[1], y = Math.min(g - p, h - v), x;
    if (bn(d)) {
      if (d.length !== y)
        throw new Error("Invalid value array length");
      x = function(D) {
        return d[D];
      };
    } else if (Nn(d)) {
      var A = d.size();
      if (A.length !== 1 || A[0] !== y)
        throw new Error("Invalid matrix length");
      x = function(D) {
        return d.get([D]);
      };
    } else
      x = function() {
        return d;
      };
    m || (m = ti(x(0)) ? x(0).mul(0) : 0);
    var b = [];
    if (l.length > 0) {
      b = lg(b, l, m);
      for (var _ = 0; _ < y; _++)
        b[_ + p][_ + v] = x(_);
    }
    return new r({
      data: b,
      size: [g, h]
    });
  }, r.fromJSON = function(l) {
    return new r(l);
  }, r.prototype.swapRows = function(l, d) {
    if (!En(l) || !Mn(l) || !En(d) || !Mn(d))
      throw new Error("Row index must be positive integers");
    if (this._size.length !== 2)
      throw new Error("Only two dimensional matrix is supported");
    return Xn(l, this._size[0]), Xn(d, this._size[0]), r._swapRows(l, d, this._data), this;
  }, r._swapRows = function(l, d, f) {
    var m = f[l];
    f[l] = f[d], f[d] = m;
  };
  function c(l) {
    return Nn(l) ? c(l.valueOf()) : bn(l) ? l.map(c) : l;
  }
  return r;
}, {
  isClass: !0
});
function ua(e, t, r) {
  return e && typeof e.map == "function" ? e.map(function(n) {
    return ua(n, t);
  }) : t(e);
}
var SI = "isInteger", jue = ["typed"], Yue = /* @__PURE__ */ gt(SI, jue, (e) => {
  var {
    typed: t
  } = e;
  return t(SI, {
    number: Mn,
    // TODO: what to do with isInteger(add(0.1, 0.2))  ?
    BigNumber: function(n) {
      return n.isInt();
    },
    bigint: function(n) {
      return !0;
    },
    Fraction: function(n) {
      return n.d === 1 && isFinite(n.n);
    },
    "Array | Matrix": t.referToSelf((r) => (n) => ua(n, r))
  });
}), C8 = "number", r3 = "number, number";
function kN(e) {
  return Math.abs(e);
}
kN.signature = C8;
function zN(e, t) {
  return e + t;
}
zN.signature = r3;
function GN(e, t) {
  return e - t;
}
GN.signature = r3;
function VN(e, t) {
  return e * t;
}
VN.signature = r3;
function UN(e) {
  return -e;
}
UN.signature = C8;
function Q6(e) {
  return ioe(e);
}
Q6.signature = C8;
function HN(e, t) {
  return e * e < 1 && t === 1 / 0 || e * e > 1 && t === -1 / 0 ? 0 : Math.pow(e, t);
}
HN.signature = r3;
function xp(e) {
  var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
  if (!Mn(t) || t < 0 || t > 15)
    throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");
  return parseFloat(lN(e, t));
}
var Wue = Math.PI, Zue = "number";
function qN(e) {
  return e > 0;
}
qN.signature = Zue;
function ks(e, t) {
  var r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1e-9, n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0;
  if (r <= 0)
    throw new Error("Relative tolerance must be greater than 0");
  if (n < 0)
    throw new Error("Absolute tolerance must be at least 0");
  return e.isNaN() || t.isNaN() ? !1 : !e.isFinite() || !t.isFinite() ? e.eq(t) : e.eq(t) ? !0 : e.minus(t).abs().lte(e.constructor.max(e.constructor.max(e.abs(), t.abs()).mul(r), n));
}
var CI = "isPositive", Que = ["typed", "config"], Jue = /* @__PURE__ */ gt(CI, Que, (e) => {
  var {
    typed: t,
    config: r
  } = e;
  return t(CI, {
    number: (n) => Zo(n, 0, r.relTol, r.absTol) ? !1 : qN(n),
    BigNumber: (n) => ks(n, new n.constructor(0), r.relTol, r.absTol) ? !1 : !n.isNeg() && !n.isZero() && !n.isNaN(),
    bigint: (n) => n > 0n,
    Fraction: (n) => n.s > 0 && n.n > 0,
    Unit: t.referToSelf((n) => (i) => t.find(n, i.valueType())(i.value)),
    "Array | Matrix": t.referToSelf((n) => (i) => ua(i, n))
  });
}), wI = "isZero", $ue = ["typed", "equalScalar"], ese = /* @__PURE__ */ gt(wI, $ue, (e) => {
  var {
    typed: t,
    equalScalar: r
  } = e;
  return t(wI, {
    "number | BigNumber | Complex | Fraction": (n) => r(n, 0),
    bigint: (n) => n === 0n,
    Unit: t.referToSelf((n) => (i) => t.find(n, i.valueType())(i.value)),
    "Array | Matrix": t.referToSelf((n) => (i) => ua(i, n))
  });
});
function tse(e, t, r, n) {
  return Zo(e.re, t.re, r, n) && Zo(e.im, t.im, r, n);
}
var Rm = /* @__PURE__ */ gt("compareUnits", ["typed"], (e) => {
  var {
    typed: t
  } = e;
  return {
    "Unit, Unit": t.referToSelf((r) => (n, i) => {
      if (!n.equalBase(i))
        throw new Error("Cannot compare units with different base");
      return t.find(r, [n.valueType(), i.valueType()])(n.value, i.value);
    })
  };
}), dg = "equalScalar", rse = ["typed", "config"], nse = /* @__PURE__ */ gt(dg, rse, (e) => {
  var {
    typed: t,
    config: r
  } = e, n = Rm({
    typed: t
  });
  return t(dg, {
    "boolean, boolean": function(a, o) {
      return a === o;
    },
    "number, number": function(a, o) {
      return Zo(a, o, r.relTol, r.absTol);
    },
    "BigNumber, BigNumber": function(a, o) {
      return a.eq(o) || ks(a, o, r.relTol, r.absTol);
    },
    "bigint, bigint": function(a, o) {
      return a === o;
    },
    "Fraction, Fraction": function(a, o) {
      return a.equals(o);
    },
    "Complex, Complex": function(a, o) {
      return tse(a, o, r.relTol, r.absTol);
    }
  }, n);
});
gt(dg, ["typed", "config"], (e) => {
  var {
    typed: t,
    config: r
  } = e;
  return t(dg, {
    "number, number": function(i, a) {
      return Zo(i, a, r.relTol, r.absTol);
    }
  });
});
var ise = "SparseMatrix", ase = ["typed", "equalScalar", "Matrix"], ose = /* @__PURE__ */ gt(ise, ase, (e) => {
  var {
    typed: t,
    equalScalar: r,
    Matrix: n
  } = e;
  function i(p, g) {
    if (!(this instanceof i))
      throw new SyntaxError("Constructor must be called with the new operator");
    if (g && !Yu(g))
      throw new Error("Invalid datatype: " + g);
    if (Nn(p))
      a(this, p, g);
    else if (p && bn(p.index) && bn(p.ptr) && bn(p.size))
      this._values = p.values, this._index = p.index, this._ptr = p.ptr, this._size = p.size, this._datatype = g || p.datatype;
    else if (bn(p))
      o(this, p, g);
    else {
      if (p)
        throw new TypeError("Unsupported type of data (" + Ic(p) + ")");
      this._values = [], this._index = [], this._ptr = [0], this._size = [0, 0], this._datatype = g;
    }
  }
  function a(p, g, h) {
    g.type === "SparseMatrix" ? (p._values = g._values ? Wr(g._values) : void 0, p._index = Wr(g._index), p._ptr = Wr(g._ptr), p._size = Wr(g._size), p._datatype = h || g._datatype) : o(p, g.valueOf(), h || g._datatype);
  }
  function o(p, g, h) {
    p._values = [], p._index = [], p._ptr = [], p._datatype = h;
    var y = g.length, x = 0, A = r, b = 0;
    if (Yu(h) && (A = t.find(r, [h, h]) || r, b = t.convert(0, h)), y > 0) {
      var _ = 0;
      do {
        p._ptr.push(p._index.length);
        for (var S = 0; S < y; S++) {
          var D = g[S];
          if (bn(D)) {
            if (_ === 0 && x < D.length && (x = D.length), _ < D.length) {
              var I = D[_];
              A(I, b) || (p._values.push(I), p._index.push(S));
            }
          } else
            _ === 0 && x < 1 && (x = 1), A(D, b) || (p._values.push(D), p._index.push(S));
        }
        _++;
      } while (_ < x);
    }
    p._ptr.push(p._index.length), p._size = [y, x];
  }
  i.prototype = new n(), i.prototype.createSparseMatrix = function(p, g) {
    return new i(p, g);
  }, Object.defineProperty(i, "name", {
    value: "SparseMatrix"
  }), i.prototype.constructor = i, i.prototype.type = "SparseMatrix", i.prototype.isSparseMatrix = !0, i.prototype.getDataType = function() {
    return xm(this._values, Ic);
  }, i.prototype.storage = function() {
    return "sparse";
  }, i.prototype.datatype = function() {
    return this._datatype;
  }, i.prototype.create = function(p, g) {
    return new i(p, g);
  }, i.prototype.density = function() {
    var p = this._size[0], g = this._size[1];
    return p !== 0 && g !== 0 ? this._index.length / (p * g) : 0;
  }, i.prototype.subset = function(p, g, h) {
    if (!this._values)
      throw new Error("Cannot invoke subset on a Pattern only matrix");
    switch (arguments.length) {
      case 1:
        return u(this, p);
      case 2:
      case 3:
        return s(this, p, g, h);
      default:
        throw new SyntaxError("Wrong number of arguments");
    }
  };
  function u(p, g) {
    if (!y8(g))
      throw new TypeError("Invalid index");
    var h = g.isScalar();
    if (h)
      return p.get(g.min());
    var y = g.size();
    if (y.length !== p._size.length)
      throw new Qr(y.length, p._size.length);
    var x, A, b, _, S = g.min(), D = g.max();
    for (x = 0, A = p._size.length; x < A; x++)
      Xn(S[x], p._size[x]), Xn(D[x], p._size[x]);
    var I = p._values, M = p._index, F = p._ptr, P = g.dimension(0), E = g.dimension(1), B = [], N = [];
    P.forEach(function(U, H) {
      N[U] = H[0], B[U] = !0;
    });
    var O = I ? [] : void 0, z = [], V = [];
    return E.forEach(function(U) {
      for (V.push(z.length), b = F[U], _ = F[U + 1]; b < _; b++)
        x = M[b], B[x] === !0 && (z.push(N[x]), O && O.push(I[b]));
    }), V.push(z.length), new i({
      values: O,
      index: z,
      ptr: V,
      size: y,
      datatype: p._datatype
    });
  }
  function s(p, g, h, y) {
    if (!g || g.isIndex !== !0)
      throw new TypeError("Invalid index");
    var x = g.size(), A = g.isScalar(), b;
    if (Nn(h) ? (b = h.size(), h = h.toArray()) : b = Fn(h), A) {
      if (b.length !== 0)
        throw new TypeError("Scalar expected");
      p.set(g.min(), h, y);
    } else {
      if (x.length !== 1 && x.length !== 2)
        throw new Qr(x.length, p._size.length, "<");
      if (b.length < x.length) {
        for (var _ = 0, S = 0; x[_] === 1 && b[_] === 1; )
          _++;
        for (; x[_] === 1; )
          S++, _++;
        h = PN(h, x.length, S, b);
      }
      if (!ud(x, b))
        throw new Qr(x, b, ">");
      if (x.length === 1) {
        var D = g.dimension(0);
        D.forEach(function(F, P) {
          Xn(F), p.set([F, 0], h[P[0]], y);
        });
      } else {
        var I = g.dimension(0), M = g.dimension(1);
        I.forEach(function(F, P) {
          Xn(F), M.forEach(function(E, B) {
            Xn(E), p.set([F, E], h[P[0]][B[0]], y);
          });
        });
      }
    }
    return p;
  }
  i.prototype.get = function(p) {
    if (!bn(p))
      throw new TypeError("Array expected");
    if (p.length !== this._size.length)
      throw new Qr(p.length, this._size.length);
    if (!this._values)
      throw new Error("Cannot invoke get on a Pattern only matrix");
    var g = p[0], h = p[1];
    Xn(g, this._size[0]), Xn(h, this._size[1]);
    var y = c(g, this._ptr[h], this._ptr[h + 1], this._index);
    return y < this._ptr[h + 1] && this._index[y] === g ? this._values[y] : 0;
  }, i.prototype.set = function(p, g, h) {
    if (!bn(p))
      throw new TypeError("Array expected");
    if (p.length !== this._size.length)
      throw new Qr(p.length, this._size.length);
    if (!this._values)
      throw new Error("Cannot invoke set on a Pattern only matrix");
    var y = p[0], x = p[1], A = this._size[0], b = this._size[1], _ = r, S = 0;
    Yu(this._datatype) && (_ = t.find(r, [this._datatype, this._datatype]) || r, S = t.convert(0, this._datatype)), (y > A - 1 || x > b - 1) && (f(this, Math.max(y + 1, A), Math.max(x + 1, b), h), A = this._size[0], b = this._size[1]), Xn(y, A), Xn(x, b);
    var D = c(y, this._ptr[x], this._ptr[x + 1], this._index);
    return D < this._ptr[x + 1] && this._index[D] === y ? _(g, S) ? l(D, x, this._values, this._index, this._ptr) : this._values[D] = g : _(g, S) || d(D, y, x, g, this._values, this._index, this._ptr), this;
  };
  function c(p, g, h, y) {
    if (h - g === 0)
      return h;
    for (var x = g; x < h; x++)
      if (y[x] === p)
        return x;
    return g;
  }
  function l(p, g, h, y, x) {
    h.splice(p, 1), y.splice(p, 1);
    for (var A = g + 1; A < x.length; A++)
      x[A]--;
  }
  function d(p, g, h, y, x, A, b) {
    x.splice(p, 0, y), A.splice(p, 0, g);
    for (var _ = h + 1; _ < b.length; _++)
      b[_]++;
  }
  i.prototype.resize = function(p, g, h) {
    if (!og(p))
      throw new TypeError("Array or Matrix expected");
    var y = p.valueOf().map((A) => Array.isArray(A) && A.length === 1 ? A[0] : A);
    if (y.length !== 2)
      throw new Error("Only two dimensions matrix are supported");
    y.forEach(function(A) {
      if (!En(A) || !Mn(A) || A < 0)
        throw new TypeError("Invalid size, must contain positive integers (size: " + kn(y) + ")");
    });
    var x = h ? this.clone() : this;
    return f(x, y[0], y[1], g);
  };
  function f(p, g, h, y) {
    var x = y || 0, A = r, b = 0;
    Yu(p._datatype) && (A = t.find(r, [p._datatype, p._datatype]) || r, b = t.convert(0, p._datatype), x = t.convert(x, p._datatype));
    var _ = !A(x, b), S = p._size[0], D = p._size[1], I, M, F;
    if (h > D) {
      for (M = D; M < h; M++)
        if (p._ptr[M] = p._values.length, _)
          for (I = 0; I < S; I++)
            p._values.push(x), p._index.push(I);
      p._ptr[h] = p._values.length;
    } else h < D && (p._ptr.splice(h + 1, D - h), p._values.splice(p._ptr[h], p._values.length), p._index.splice(p._ptr[h], p._index.length));
    if (D = h, g > S) {
      if (_) {
        var P = 0;
        for (M = 0; M < D; M++) {
          p._ptr[M] = p._ptr[M] + P, F = p._ptr[M + 1] + P;
          var E = 0;
          for (I = S; I < g; I++, E++)
            p._values.splice(F + E, 0, x), p._index.splice(F + E, 0, I), P++;
        }
        p._ptr[D] = p._values.length;
      }
    } else if (g < S) {
      var B = 0;
      for (M = 0; M < D; M++) {
        p._ptr[M] = p._ptr[M] - B;
        var N = p._ptr[M], O = p._ptr[M + 1] - B;
        for (F = N; F < O; F++)
          I = p._index[F], I > g - 1 && (p._values.splice(F, 1), p._index.splice(F, 1), B++);
      }
      p._ptr[M] = p._values.length;
    }
    return p._size[0] = g, p._size[1] = h, p;
  }
  i.prototype.reshape = function(p, g) {
    if (!bn(p))
      throw new TypeError("Array expected");
    if (p.length !== 2)
      throw new Error("Sparse matrices can only be reshaped in two dimensions");
    p.forEach(function(U) {
      if (!En(U) || !Mn(U) || U <= -2 || U === 0)
        throw new TypeError("Invalid size, must contain positive integers or -1 (size: " + kn(p) + ")");
    });
    var h = this._size[0] * this._size[1];
    p = S8(p, h);
    var y = p[0] * p[1];
    if (h !== y)
      throw new Error("Reshaping sparse matrix will result in the wrong number of elements");
    var x = g ? this.clone() : this;
    if (this._size[0] === p[0] && this._size[1] === p[1])
      return x;
    for (var A = [], b = 0; b < x._ptr.length; b++)
      for (var _ = 0; _ < x._ptr[b + 1] - x._ptr[b]; _++)
        A.push(b);
    for (var S = x._values.slice(), D = x._index.slice(), I = 0; I < x._index.length; I++) {
      var M = D[I], F = A[I], P = M * x._size[1] + F;
      A[I] = P % p[1], D[I] = Math.floor(P / p[1]);
    }
    x._values.length = 0, x._index.length = 0, x._ptr.length = p[1] + 1, x._size = p.slice();
    for (var E = 0; E < x._ptr.length; E++)
      x._ptr[E] = 0;
    for (var B = 0; B < S.length; B++) {
      var N = D[B], O = A[B], z = S[B], V = c(N, x._ptr[O], x._ptr[O + 1], x._index);
      d(V, N, O, z, x._values, x._index, x._ptr);
    }
    return x;
  }, i.prototype.clone = function() {
    var p = new i({
      values: this._values ? Wr(this._values) : void 0,
      index: Wr(this._index),
      ptr: Wr(this._ptr),
      size: Wr(this._size),
      datatype: this._datatype
    });
    return p;
  }, i.prototype.size = function() {
    return this._size.slice(0);
  }, i.prototype.map = function(p, g) {
    if (!this._values)
      throw new Error("Cannot invoke map on a Pattern only matrix");
    var h = this, y = this._size[0], x = this._size[1], A = LN(p), b = function(S, D, I) {
      return A === 1 ? p(S) : A === 2 ? p(S, [D, I]) : p(S, [D, I], h);
    };
    return m(this, 0, y - 1, 0, x - 1, b, g);
  };
  function m(p, g, h, y, x, A, b) {
    var _ = [], S = [], D = [], I = r, M = 0;
    Yu(p._datatype) && (I = t.find(r, [p._datatype, p._datatype]) || r, M = t.convert(0, p._datatype));
    for (var F = function(X, W, Q) {
      X = A(X, W, Q), I(X, M) || (_.push(X), S.push(W));
    }, P = y; P <= x; P++) {
      D.push(_.length);
      var E = p._ptr[P], B = p._ptr[P + 1];
      if (b)
        for (var N = E; N < B; N++) {
          var O = p._index[N];
          O >= g && O <= h && F(p._values[N], O - g, P - y);
        }
      else {
        for (var z = {}, V = E; V < B; V++) {
          var U = p._index[V];
          z[U] = p._values[V];
        }
        for (var H = g; H <= h; H++) {
          var K = H in z ? z[H] : 0;
          F(K, H - g, P - y);
        }
      }
    }
    return D.push(_.length), new i({
      values: _,
      index: S,
      ptr: D,
      size: [h - g + 1, x - y + 1]
    });
  }
  i.prototype.forEach = function(p, g) {
    if (!this._values)
      throw new Error("Cannot invoke forEach on a Pattern only matrix");
    for (var h = this, y = this._size[0], x = this._size[1], A = 0; A < x; A++) {
      var b = this._ptr[A], _ = this._ptr[A + 1];
      if (g)
        for (var S = b; S < _; S++) {
          var D = this._index[S];
          p(this._values[S], [D, A], h);
        }
      else {
        for (var I = {}, M = b; M < _; M++) {
          var F = this._index[M];
          I[F] = this._values[M];
        }
        for (var P = 0; P < y; P++) {
          var E = P in I ? I[P] : 0;
          p(E, [P, A], h);
        }
      }
    }
  }, i.prototype[Symbol.iterator] = function* () {
    if (!this._values)
      throw new Error("Cannot iterate a Pattern only matrix");
    for (var p = this._size[1], g = 0; g < p; g++)
      for (var h = this._ptr[g], y = this._ptr[g + 1], x = h; x < y; x++) {
        var A = this._index[x];
        yield {
          value: this._values[x],
          index: [A, g]
        };
      }
  }, i.prototype.toArray = function() {
    return v(this._values, this._index, this._ptr, this._size, !0);
  }, i.prototype.valueOf = function() {
    return v(this._values, this._index, this._ptr, this._size, !1);
  };
  function v(p, g, h, y, x) {
    var A = y[0], b = y[1], _ = [], S, D;
    for (S = 0; S < A; S++)
      for (_[S] = [], D = 0; D < b; D++)
        _[S][D] = 0;
    for (D = 0; D < b; D++)
      for (var I = h[D], M = h[D + 1], F = I; F < M; F++)
        S = g[F], _[S][D] = p ? x ? Wr(p[F]) : p[F] : 1;
    return _;
  }
  return i.prototype.format = function(p) {
    for (var g = this._size[0], h = this._size[1], y = this.density(), x = "Sparse Matrix [" + kn(g, p) + " x " + kn(h, p) + "] density: " + kn(y, p) + `
`, A = 0; A < h; A++)
      for (var b = this._ptr[A], _ = this._ptr[A + 1], S = b; S < _; S++) {
        var D = this._index[S];
        x += `
    (` + kn(D, p) + ", " + kn(A, p) + ") ==> " + (this._values ? kn(this._values[S], p) : "X");
      }
    return x;
  }, i.prototype.toString = function() {
    return kn(this.toArray());
  }, i.prototype.toJSON = function() {
    return {
      mathjs: "SparseMatrix",
      values: this._values,
      index: this._index,
      ptr: this._ptr,
      size: this._size,
      datatype: this._datatype
    };
  }, i.prototype.diagonal = function(p) {
    if (p) {
      if (ti(p) && (p = p.toNumber()), !En(p) || !Mn(p))
        throw new TypeError("The parameter k must be an integer number");
    } else
      p = 0;
    var g = p > 0 ? p : 0, h = p < 0 ? -p : 0, y = this._size[0], x = this._size[1], A = Math.min(y - h, x - g), b = [], _ = [], S = [];
    S[0] = 0;
    for (var D = g; D < x && b.length < A; D++)
      for (var I = this._ptr[D], M = this._ptr[D + 1], F = I; F < M; F++) {
        var P = this._index[F];
        if (P === D - g + h) {
          b.push(this._values[F]), _[b.length - 1] = P - h;
          break;
        }
      }
    return S.push(b.length), new i({
      values: b,
      index: _,
      ptr: S,
      size: [A, 1]
    });
  }, i.fromJSON = function(p) {
    return new i(p);
  }, i.diagonal = function(p, g, h, y, x) {
    if (!bn(p))
      throw new TypeError("Array expected, size parameter");
    if (p.length !== 2)
      throw new Error("Only two dimensions matrix are supported");
    if (p = p.map(function(U) {
      if (ti(U) && (U = U.toNumber()), !En(U) || !Mn(U) || U < 1)
        throw new Error("Size values must be positive integers");
      return U;
    }), h) {
      if (ti(h) && (h = h.toNumber()), !En(h) || !Mn(h))
        throw new TypeError("The parameter k must be an integer number");
    } else
      h = 0;
    var A = r, b = 0;
    Yu(x) && (A = t.find(r, [x, x]) || r, b = t.convert(0, x));
    var _ = h > 0 ? h : 0, S = h < 0 ? -h : 0, D = p[0], I = p[1], M = Math.min(D - S, I - _), F;
    if (bn(g)) {
      if (g.length !== M)
        throw new Error("Invalid value array length");
      F = function(H) {
        return g[H];
      };
    } else if (Nn(g)) {
      var P = g.size();
      if (P.length !== 1 || P[0] !== M)
        throw new Error("Invalid matrix length");
      F = function(H) {
        return g.get([H]);
      };
    } else
      F = function() {
        return g;
      };
    for (var E = [], B = [], N = [], O = 0; O < I; O++) {
      N.push(E.length);
      var z = O - _;
      if (z >= 0 && z < M) {
        var V = F(z);
        A(V, b) || (B.push(z + S), E.push(V));
      }
    }
    return N.push(E.length), new i({
      values: E,
      index: B,
      ptr: N,
      size: [D, I]
    });
  }, i.prototype.swapRows = function(p, g) {
    if (!En(p) || !Mn(p) || !En(g) || !Mn(g))
      throw new Error("Row index must be positive integers");
    if (this._size.length !== 2)
      throw new Error("Only two dimensional matrix is supported");
    return Xn(p, this._size[0]), Xn(g, this._size[0]), i._swapRows(p, g, this._size[1], this._values, this._index, this._ptr), this;
  }, i._forEachRow = function(p, g, h, y, x) {
    for (var A = y[p], b = y[p + 1], _ = A; _ < b; _++)
      x(h[_], g[_]);
  }, i._swapRows = function(p, g, h, y, x, A) {
    for (var b = 0; b < h; b++) {
      var _ = A[b], S = A[b + 1], D = c(p, _, S, x), I = c(g, _, S, x);
      if (D < S && I < S && x[D] === p && x[I] === g) {
        if (y) {
          var M = y[D];
          y[D] = y[I], y[I] = M;
        }
        continue;
      }
      if (D < S && x[D] === p && (I >= S || x[I] !== g)) {
        var F = y ? y[D] : void 0;
        x.splice(I, 0, g), y && y.splice(I, 0, F), x.splice(I <= D ? D + 1 : D, 1), y && y.splice(I <= D ? D + 1 : D, 1);
        continue;
      }
      if (I < S && x[I] === g && (D >= S || x[D] !== p)) {
        var P = y ? y[I] : void 0;
        x.splice(D, 0, p), y && y.splice(D, 0, P), x.splice(D <= I ? I + 1 : I, 1), y && y.splice(D <= I ? I + 1 : I, 1);
      }
    }
  }, i;
}, {
  isClass: !0
}), use = "number", sse = ["typed"];
function cse(e) {
  var t = e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);
  if (t) {
    var r = {
      "0b": 2,
      "0o": 8,
      "0x": 16
    }[t[1]], n = t[2], i = t[3];
    return {
      input: e,
      radix: r,
      integerPart: n,
      fractionalPart: i
    };
  } else
    return null;
}
function lse(e) {
  for (var t = parseInt(e.integerPart, e.radix), r = 0, n = 0; n < e.fractionalPart.length; n++) {
    var i = parseInt(e.fractionalPart[n], e.radix);
    r += i / Math.pow(e.radix, n + 1);
  }
  var a = t + r;
  if (isNaN(a))
    throw new SyntaxError('String "' + e.input + '" is not a valid number');
  return a;
}
var dse = /* @__PURE__ */ gt(use, sse, (e) => {
  var {
    typed: t
  } = e, r = t("number", {
    "": function() {
      return 0;
    },
    number: function(i) {
      return i;
    },
    string: function(i) {
      if (i === "NaN") return NaN;
      var a = cse(i);
      if (a)
        return lse(a);
      var o = 0, u = i.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);
      u && (o = Number(u[2]), i = u[1]);
      var s = Number(i);
      if (isNaN(s))
        throw new SyntaxError('String "' + i + '" is not a valid number');
      if (u) {
        if (s > 2 ** o - 1)
          throw new SyntaxError('String "'.concat(i, '" is out of range'));
        s >= 2 ** (o - 1) && (s = s - 2 ** o);
      }
      return s;
    },
    BigNumber: function(i) {
      return i.toNumber();
    },
    bigint: function(i) {
      return Number(i);
    },
    Fraction: function(i) {
      return i.valueOf();
    },
    Unit: t.referToSelf((n) => (i) => {
      var a = i.clone();
      return a.value = n(i.value), a;
    }),
    null: function(i) {
      return 0;
    },
    "Unit, string | Unit": function(i, a) {
      return i.toNumber(a);
    },
    "Array | Matrix": t.referToSelf((n) => (i) => ua(i, n))
  });
  return r.fromJSON = function(n) {
    return parseFloat(n.value);
  }, r;
}), fse = "bignumber", pse = ["typed", "BigNumber"], mse = /* @__PURE__ */ gt(fse, pse, (e) => {
  var {
    typed: t,
    BigNumber: r
  } = e;
  return t("bignumber", {
    "": function() {
      return new r(0);
    },
    number: function(i) {
      return new r(i + "");
    },
    string: function(i) {
      var a = i.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);
      if (a) {
        var o = a[2], u = r(a[1]), s = new r(2).pow(Number(o));
        if (u.gt(s.sub(1)))
          throw new SyntaxError('String "'.concat(i, '" is out of range'));
        var c = new r(2).pow(Number(o) - 1);
        return u.gte(c) ? u.sub(s) : u;
      }
      return new r(i);
    },
    BigNumber: function(i) {
      return i;
    },
    bigint: function(i) {
      return new r(i.toString());
    },
    Unit: t.referToSelf((n) => (i) => {
      var a = i.clone();
      return a.value = n(i.value), a;
    }),
    Fraction: function(i) {
      return new r(i.n).div(i.d).times(i.s);
    },
    null: function(i) {
      return new r(0);
    },
    "Array | Matrix": t.referToSelf((n) => (i) => ua(i, n))
  });
}), hse = "complex", vse = ["typed", "Complex"], gse = /* @__PURE__ */ gt(hse, vse, (e) => {
  var {
    typed: t,
    Complex: r
  } = e;
  return t("complex", {
    "": function() {
      return r.ZERO;
    },
    number: function(i) {
      return new r(i, 0);
    },
    "number, number": function(i, a) {
      return new r(i, a);
    },
    // TODO: this signature should be redundant
    "BigNumber, BigNumber": function(i, a) {
      return new r(i.toNumber(), a.toNumber());
    },
    Fraction: function(i) {
      return new r(i.valueOf(), 0);
    },
    Complex: function(i) {
      return i.clone();
    },
    string: function(i) {
      return r(i);
    },
    null: function(i) {
      return r(0);
    },
    Object: function(i) {
      if ("re" in i && "im" in i)
        return new r(i.re, i.im);
      if ("r" in i && "phi" in i || "abs" in i && "arg" in i)
        return new r(i);
      throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)");
    },
    "Array | Matrix": t.referToSelf((n) => (i) => ua(i, n))
  });
}), yse = "fraction", bse = ["typed", "Fraction"], _se = /* @__PURE__ */ gt(yse, bse, (e) => {
  var {
    typed: t,
    Fraction: r
  } = e;
  return t("fraction", {
    number: function(i) {
      if (!isFinite(i) || isNaN(i))
        throw new Error(i + " cannot be represented as a fraction");
      return new r(i);
    },
    string: function(i) {
      return new r(i);
    },
    "number, number": function(i, a) {
      return new r(i, a);
    },
    null: function(i) {
      return new r(0);
    },
    BigNumber: function(i) {
      return new r(i.toString());
    },
    bigint: function(i) {
      return new r(i.toString());
    },
    Fraction: function(i) {
      return i;
    },
    Unit: t.referToSelf((n) => (i) => {
      var a = i.clone();
      return a.value = n(i.value), a;
    }),
    Object: function(i) {
      return new r(i);
    },
    "Array | Matrix": t.referToSelf((n) => (i) => ua(i, n))
  });
}), DI = "matrix", xse = ["typed", "Matrix", "DenseMatrix", "SparseMatrix"], Ase = /* @__PURE__ */ gt(DI, xse, (e) => {
  var {
    typed: t,
    Matrix: r,
    DenseMatrix: n,
    SparseMatrix: i
  } = e;
  return t(DI, {
    "": function() {
      return a([]);
    },
    string: function(u) {
      return a([], u);
    },
    "string, string": function(u, s) {
      return a([], u, s);
    },
    Array: function(u) {
      return a(u);
    },
    Matrix: function(u) {
      return a(u, u.storage());
    },
    "Array | Matrix, string": a,
    "Array | Matrix, string, string": a
  });
  function a(o, u, s) {
    if (u === "dense" || u === "default" || u === void 0)
      return new n(o, s);
    if (u === "sparse")
      return new i(o, s);
    throw new TypeError("Unknown matrix type " + JSON.stringify(u) + ".");
  }
}), II = "matrixFromColumns", Sse = ["typed", "matrix", "flatten", "size"], Cse = /* @__PURE__ */ gt(II, Sse, (e) => {
  var {
    typed: t,
    matrix: r,
    flatten: n,
    size: i
  } = e;
  return t(II, {
    "...Array": function(s) {
      return a(s);
    },
    "...Matrix": function(s) {
      return r(a(s.map((c) => c.toArray())));
    }
    // TODO implement this properly for SparseMatrix
  });
  function a(u) {
    if (u.length === 0) throw new TypeError("At least one column is needed to construct a matrix.");
    for (var s = o(u[0]), c = [], l = 0; l < s; l++)
      c[l] = [];
    for (var d of u) {
      var f = o(d);
      if (f !== s)
        throw new TypeError("The vectors had different length: " + (s | 0) + " ≠ " + (f | 0));
      for (var m = n(d), v = 0; v < s; v++)
        c[v].push(m[v]);
    }
    return c;
  }
  function o(u) {
    var s = i(u);
    if (s.length === 1)
      return s[0];
    if (s.length === 2) {
      if (s[0] === 1)
        return s[1];
      if (s[1] === 1)
        return s[0];
      throw new TypeError("At least one of the arguments is not a vector.");
    } else
      throw new TypeError("Only one- or two-dimensional vectors are supported.");
  }
}), EI = "unaryMinus", wse = ["typed"], Dse = /* @__PURE__ */ gt(EI, wse, (e) => {
  var {
    typed: t
  } = e;
  return t(EI, {
    number: UN,
    "Complex | BigNumber | Fraction": (r) => r.neg(),
    bigint: (r) => -r,
    Unit: t.referToSelf((r) => (n) => {
      var i = n.clone();
      return i.value = t.find(r, i.valueType())(n.value), i;
    }),
    // deep map collection, skip zeros since unaryMinus(0) = 0
    "Array | Matrix": t.referToSelf((r) => (n) => ua(n, r))
    // TODO: add support for string
  });
}), MI = "abs", Ise = ["typed"], Ese = /* @__PURE__ */ gt(MI, Ise, (e) => {
  var {
    typed: t
  } = e;
  return t(MI, {
    number: kN,
    "Complex | BigNumber | Fraction | Unit": (r) => r.abs(),
    bigint: (r) => r < 0n ? -r : r,
    // deep map collection, skip zeros since abs(0) = 0
    "Array | Matrix": t.referToSelf((r) => (n) => ua(n, r))
  });
}), TI = "addScalar", Mse = ["typed"], Tse = /* @__PURE__ */ gt(TI, Mse, (e) => {
  var {
    typed: t
  } = e;
  return t(TI, {
    "number, number": zN,
    "Complex, Complex": function(n, i) {
      return n.add(i);
    },
    "BigNumber, BigNumber": function(n, i) {
      return n.plus(i);
    },
    "bigint, bigint": function(n, i) {
      return n + i;
    },
    "Fraction, Fraction": function(n, i) {
      return n.add(i);
    },
    "Unit, Unit": t.referToSelf((r) => (n, i) => {
      if (n.value === null || n.value === void 0)
        throw new Error("Parameter x contains a unit with undefined value");
      if (i.value === null || i.value === void 0)
        throw new Error("Parameter y contains a unit with undefined value");
      if (!n.equalBase(i)) throw new Error("Units do not match");
      var a = n.clone();
      return a.value = t.find(r, [a.valueType(), i.valueType()])(a.value, i.value), a.fixPrefix = !1, a;
    })
  });
}), PI = "subtractScalar", Pse = ["typed"], Bse = /* @__PURE__ */ gt(PI, Pse, (e) => {
  var {
    typed: t
  } = e;
  return t(PI, {
    "number, number": GN,
    "Complex, Complex": function(n, i) {
      return n.sub(i);
    },
    "BigNumber, BigNumber": function(n, i) {
      return n.minus(i);
    },
    "bigint, bigint": function(n, i) {
      return n - i;
    },
    "Fraction, Fraction": function(n, i) {
      return n.sub(i);
    },
    "Unit, Unit": t.referToSelf((r) => (n, i) => {
      if (n.value === null || n.value === void 0)
        throw new Error("Parameter x contains a unit with undefined value");
      if (i.value === null || i.value === void 0)
        throw new Error("Parameter y contains a unit with undefined value");
      if (!n.equalBase(i)) throw new Error("Units do not match");
      var a = n.clone();
      return a.value = t.find(r, [a.valueType(), i.valueType()])(a.value, i.value), a.fixPrefix = !1, a;
    })
  });
}), Fse = "matAlgo11xS0s", Nse = ["typed", "equalScalar"], Om = /* @__PURE__ */ gt(Fse, Nse, (e) => {
  var {
    typed: t,
    equalScalar: r
  } = e;
  return function(i, a, o, u) {
    var s = i._values, c = i._index, l = i._ptr, d = i._size, f = i._datatype;
    if (!s)
      throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");
    var m = d[0], v = d[1], p, g = r, h = 0, y = o;
    typeof f == "string" && (p = f, g = t.find(r, [p, p]), h = t.convert(0, p), a = t.convert(a, p), y = t.find(o, [p, p]));
    for (var x = [], A = [], b = [], _ = 0; _ < v; _++) {
      b[_] = A.length;
      for (var S = l[_], D = l[_ + 1], I = S; I < D; I++) {
        var M = c[I], F = u ? y(a, s[I]) : y(s[I], a);
        g(F, h) || (A.push(M), x.push(F));
      }
    }
    return b[v] = A.length, i.createSparseMatrix({
      values: x,
      index: A,
      ptr: b,
      size: [m, v],
      datatype: p
    });
  };
}), Rse = "matAlgo12xSfs", Ose = ["typed", "DenseMatrix"], Uc = /* @__PURE__ */ gt(Rse, Ose, (e) => {
  var {
    typed: t,
    DenseMatrix: r
  } = e;
  return function(i, a, o, u) {
    var s = i._values, c = i._index, l = i._ptr, d = i._size, f = i._datatype;
    if (!s)
      throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");
    var m = d[0], v = d[1], p, g = o;
    typeof f == "string" && (p = f, a = t.convert(a, p), g = t.find(o, [p, p]));
    for (var h = [], y = [], x = [], A = 0; A < v; A++) {
      for (var b = A + 1, _ = l[A], S = l[A + 1], D = _; D < S; D++) {
        var I = c[D];
        y[I] = s[D], x[I] = b;
      }
      for (var M = 0; M < m; M++)
        A === 0 && (h[M] = []), x[M] === b ? h[M][A] = u ? g(a, y[M]) : g(y[M], a) : h[M][A] = u ? g(a, 0) : g(0, a);
    }
    return new r({
      data: h,
      size: [m, v],
      datatype: p
    });
  };
}), Lse = "matAlgo14xDs", kse = ["typed"], Lm = /* @__PURE__ */ gt(Lse, kse, (e) => {
  var {
    typed: t
  } = e;
  return function(i, a, o, u) {
    var s = i._data, c = i._size, l = i._datatype, d, f = o;
    typeof l == "string" && (d = l, a = t.convert(a, d), f = t.find(o, [d, d]));
    var m = c.length > 0 ? r(f, 0, c, c[0], s, a, u) : [];
    return i.createDenseMatrix({
      data: m,
      size: Wr(c),
      datatype: d
    });
  };
  function r(n, i, a, o, u, s, c) {
    var l = [];
    if (i === a.length - 1)
      for (var d = 0; d < o; d++)
        l[d] = c ? n(s, u[d]) : n(u[d], s);
    else
      for (var f = 0; f < o; f++)
        l[f] = r(n, i + 1, a, a[i + 1], u[f], s, c);
    return l;
  }
}), J6 = "floor", zse = ["typed", "config", "round", "matrix", "equalScalar", "zeros", "DenseMatrix"], Gse = /* @__PURE__ */ gt(J6, ["typed", "config", "round"], (e) => {
  var {
    typed: t,
    config: r,
    round: n
  } = e;
  return t(J6, {
    number: function(a) {
      return Zo(a, n(a), r.relTol, r.absTol) ? n(a) : Math.floor(a);
    },
    "number, number": function(a, o) {
      if (Zo(a, n(a, o), r.relTol, r.absTol))
        return n(a, o);
      var [u, s] = "".concat(a, "e").split("e"), c = Math.floor(Number("".concat(u, "e").concat(Number(s) + o)));
      return [u, s] = "".concat(c, "e").split("e"), Number("".concat(u, "e").concat(Number(s) - o));
    }
  });
}), Vse = /* @__PURE__ */ gt(J6, zse, (e) => {
  var {
    typed: t,
    config: r,
    round: n,
    matrix: i,
    equalScalar: a,
    zeros: o,
    DenseMatrix: u
  } = e, s = Om({
    typed: t,
    equalScalar: a
  }), c = Uc({
    typed: t,
    DenseMatrix: u
  }), l = Lm({
    typed: t
  }), d = Gse({
    typed: t,
    config: r,
    round: n
  });
  return t("floor", {
    number: d.signatures.number,
    "number,number": d.signatures["number,number"],
    Complex: function(m) {
      return m.floor();
    },
    "Complex, number": function(m, v) {
      return m.floor(v);
    },
    "Complex, BigNumber": function(m, v) {
      return m.floor(v.toNumber());
    },
    BigNumber: function(m) {
      return ks(m, n(m), r.relTol, r.absTol) ? n(m) : m.floor();
    },
    "BigNumber, BigNumber": function(m, v) {
      return ks(m, n(m, v), r.relTol, r.absTol) ? n(m, v) : m.toDecimalPlaces(v.toNumber(), _f.ROUND_FLOOR);
    },
    Fraction: function(m) {
      return m.floor();
    },
    "Fraction, number": function(m, v) {
      return m.floor(v);
    },
    "Fraction, BigNumber": function(m, v) {
      return m.floor(v.toNumber());
    },
    "Array | Matrix": t.referToSelf((f) => (m) => ua(m, f)),
    "Array, number | BigNumber": t.referToSelf((f) => (m, v) => ua(m, (p) => f(p, v))),
    "SparseMatrix, number | BigNumber": t.referToSelf((f) => (m, v) => s(m, v, f, !1)),
    "DenseMatrix, number | BigNumber": t.referToSelf((f) => (m, v) => l(m, v, f, !1)),
    "number | Complex | Fraction | BigNumber, Array": t.referToSelf((f) => (m, v) => l(i(v), m, f, !0).valueOf()),
    "number | Complex | Fraction | BigNumber, Matrix": t.referToSelf((f) => (m, v) => a(m, 0) ? o(v.size(), v.storage()) : v.storage() === "dense" ? l(v, m, f, !0) : c(v, m, f, !0))
  });
}), Use = "matAlgo02xDS0", Hse = ["typed", "equalScalar"], qse = /* @__PURE__ */ gt(Use, Hse, (e) => {
  var {
    typed: t,
    equalScalar: r
  } = e;
  return function(i, a, o, u) {
    var s = i._data, c = i._size, l = i._datatype || i.getDataType(), d = a._values, f = a._index, m = a._ptr, v = a._size, p = a._datatype || a._data === void 0 ? a._datatype : a.getDataType();
    if (c.length !== v.length)
      throw new Qr(c.length, v.length);
    if (c[0] !== v[0] || c[1] !== v[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + c + ") must match Matrix B (" + v + ")");
    if (!d)
      throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");
    var g = c[0], h = c[1], y, x = r, A = 0, b = o;
    typeof l == "string" && l === p && l !== "mixed" && (y = l, x = t.find(r, [y, y]), A = t.convert(0, y), b = t.find(o, [y, y]));
    for (var _ = [], S = [], D = [], I = 0; I < h; I++) {
      D[I] = S.length;
      for (var M = m[I], F = m[I + 1], P = M; P < F; P++) {
        var E = f[P], B = u ? b(d[P], s[E][I]) : b(s[E][I], d[P]);
        x(B, A) || (S.push(E), _.push(B));
      }
    }
    return D[h] = S.length, a.createSparseMatrix({
      values: _,
      index: S,
      ptr: D,
      size: [g, h],
      datatype: l === i._datatype && p === a._datatype ? y : void 0
    });
  };
}), Kse = "matAlgo03xDSf", Xse = ["typed"], Mf = /* @__PURE__ */ gt(Kse, Xse, (e) => {
  var {
    typed: t
  } = e;
  return function(n, i, a, o) {
    var u = n._data, s = n._size, c = n._datatype || n.getDataType(), l = i._values, d = i._index, f = i._ptr, m = i._size, v = i._datatype || i._data === void 0 ? i._datatype : i.getDataType();
    if (s.length !== m.length)
      throw new Qr(s.length, m.length);
    if (s[0] !== m[0] || s[1] !== m[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + s + ") must match Matrix B (" + m + ")");
    if (!l)
      throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");
    var p = s[0], g = s[1], h, y = 0, x = a;
    typeof c == "string" && c === v && c !== "mixed" && (h = c, y = t.convert(0, h), x = t.find(a, [h, h]));
    for (var A = [], b = 0; b < p; b++)
      A[b] = [];
    for (var _ = [], S = [], D = 0; D < g; D++) {
      for (var I = D + 1, M = f[D], F = f[D + 1], P = M; P < F; P++) {
        var E = d[P];
        _[E] = o ? x(l[P], u[E][D]) : x(u[E][D], l[P]), S[E] = I;
      }
      for (var B = 0; B < p; B++)
        S[B] === I ? A[B][D] = _[B] : A[B][D] = o ? x(y, u[B][D]) : x(u[B][D], y);
    }
    return n.createDenseMatrix({
      data: A,
      size: [p, g],
      datatype: c === n._datatype && v === i._datatype ? h : void 0
    });
  };
}), jse = "matAlgo05xSfSf", Yse = ["typed", "equalScalar"], KN = /* @__PURE__ */ gt(jse, Yse, (e) => {
  var {
    typed: t,
    equalScalar: r
  } = e;
  return function(i, a, o) {
    var u = i._values, s = i._index, c = i._ptr, l = i._size, d = i._datatype || i._data === void 0 ? i._datatype : i.getDataType(), f = a._values, m = a._index, v = a._ptr, p = a._size, g = a._datatype || a._data === void 0 ? a._datatype : a.getDataType();
    if (l.length !== p.length)
      throw new Qr(l.length, p.length);
    if (l[0] !== p[0] || l[1] !== p[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + l + ") must match Matrix B (" + p + ")");
    var h = l[0], y = l[1], x, A = r, b = 0, _ = o;
    typeof d == "string" && d === g && d !== "mixed" && (x = d, A = t.find(r, [x, x]), b = t.convert(0, x), _ = t.find(o, [x, x]));
    var S = u && f ? [] : void 0, D = [], I = [], M = S ? [] : void 0, F = S ? [] : void 0, P = [], E = [], B, N, O, z;
    for (N = 0; N < y; N++) {
      I[N] = D.length;
      var V = N + 1;
      for (O = c[N], z = c[N + 1]; O < z; O++)
        B = s[O], D.push(B), P[B] = V, M && (M[B] = u[O]);
      for (O = v[N], z = v[N + 1]; O < z; O++)
        B = m[O], P[B] !== V && D.push(B), E[B] = V, F && (F[B] = f[O]);
      if (S)
        for (O = I[N]; O < D.length; ) {
          B = D[O];
          var U = P[B], H = E[B];
          if (U === V || H === V) {
            var K = U === V ? M[B] : b, j = H === V ? F[B] : b, X = _(K, j);
            A(X, b) ? D.splice(O, 1) : (S.push(X), O++);
          }
        }
    }
    return I[y] = D.length, i.createSparseMatrix({
      values: S,
      index: D,
      ptr: I,
      size: [h, y],
      datatype: d === i._datatype && g === a._datatype ? x : void 0
    });
  };
}), Wse = "matAlgo13xDD", Zse = ["typed"], Qse = /* @__PURE__ */ gt(Wse, Zse, (e) => {
  var {
    typed: t
  } = e;
  return function(i, a, o) {
    var u = i._data, s = i._size, c = i._datatype, l = a._data, d = a._size, f = a._datatype, m = [];
    if (s.length !== d.length)
      throw new Qr(s.length, d.length);
    for (var v = 0; v < s.length; v++) {
      if (s[v] !== d[v])
        throw new RangeError("Dimension mismatch. Matrix A (" + s + ") must match Matrix B (" + d + ")");
      m[v] = s[v];
    }
    var p, g = o;
    typeof c == "string" && c === f && (p = c, g = t.find(o, [p, p]));
    var h = m.length > 0 ? r(g, 0, m, m[0], u, l) : [];
    return i.createDenseMatrix({
      data: h,
      size: m,
      datatype: p
    });
  };
  function r(n, i, a, o, u, s) {
    var c = [];
    if (i === a.length - 1)
      for (var l = 0; l < o; l++)
        c[l] = n(u[l], s[l]);
    else
      for (var d = 0; d < o; d++)
        c[d] = r(n, i + 1, a, a[i + 1], u[d], s[d]);
    return c;
  }
});
function Zi(e, t) {
  if (ud(e.size(), t.size()))
    return [e, t];
  var r = RN(e.size(), t.size());
  return [e, t].map((n) => Jse(n, r));
}
function Jse(e, t) {
  return ud(e.size(), t) ? e : e.create(Z6(e.valueOf(), t), e.datatype());
}
var $se = "matrixAlgorithmSuite", ece = ["typed", "matrix"], pd = /* @__PURE__ */ gt($se, ece, (e) => {
  var {
    typed: t,
    matrix: r
  } = e, n = Qse({
    typed: t
  }), i = Lm({
    typed: t
  });
  return function(o) {
    var u = o.elop, s = o.SD || o.DS, c;
    u ? (c = {
      "DenseMatrix, DenseMatrix": (m, v) => n(...Zi(m, v), u),
      "Array, Array": (m, v) => n(...Zi(r(m), r(v)), u).valueOf(),
      "Array, DenseMatrix": (m, v) => n(...Zi(r(m), v), u),
      "DenseMatrix, Array": (m, v) => n(...Zi(m, r(v)), u)
    }, o.SS && (c["SparseMatrix, SparseMatrix"] = (m, v) => o.SS(...Zi(m, v), u, !1)), o.DS && (c["DenseMatrix, SparseMatrix"] = (m, v) => o.DS(...Zi(m, v), u, !1), c["Array, SparseMatrix"] = (m, v) => o.DS(...Zi(r(m), v), u, !1)), s && (c["SparseMatrix, DenseMatrix"] = (m, v) => s(...Zi(v, m), u, !0), c["SparseMatrix, Array"] = (m, v) => s(...Zi(r(v), m), u, !0))) : (c = {
      "DenseMatrix, DenseMatrix": t.referToSelf((m) => (v, p) => n(...Zi(v, p), m)),
      "Array, Array": t.referToSelf((m) => (v, p) => n(...Zi(r(v), r(p)), m).valueOf()),
      "Array, DenseMatrix": t.referToSelf((m) => (v, p) => n(...Zi(r(v), p), m)),
      "DenseMatrix, Array": t.referToSelf((m) => (v, p) => n(...Zi(v, r(p)), m))
    }, o.SS && (c["SparseMatrix, SparseMatrix"] = t.referToSelf((m) => (v, p) => o.SS(...Zi(v, p), m, !1))), o.DS && (c["DenseMatrix, SparseMatrix"] = t.referToSelf((m) => (v, p) => o.DS(...Zi(v, p), m, !1)), c["Array, SparseMatrix"] = t.referToSelf((m) => (v, p) => o.DS(...Zi(r(v), p), m, !1))), s && (c["SparseMatrix, DenseMatrix"] = t.referToSelf((m) => (v, p) => s(...Zi(p, v), m, !0)), c["SparseMatrix, Array"] = t.referToSelf((m) => (v, p) => s(...Zi(r(p), v), m, !0))));
    var l = o.scalar || "any", d = o.Ds || o.Ss;
    d && (u ? (c["DenseMatrix," + l] = (m, v) => i(m, v, u, !1), c[l + ", DenseMatrix"] = (m, v) => i(v, m, u, !0), c["Array," + l] = (m, v) => i(r(m), v, u, !1).valueOf(), c[l + ", Array"] = (m, v) => i(r(v), m, u, !0).valueOf()) : (c["DenseMatrix," + l] = t.referToSelf((m) => (v, p) => i(v, p, m, !1)), c[l + ", DenseMatrix"] = t.referToSelf((m) => (v, p) => i(p, v, m, !0)), c["Array," + l] = t.referToSelf((m) => (v, p) => i(r(v), p, m, !1).valueOf()), c[l + ", Array"] = t.referToSelf((m) => (v, p) => i(r(p), v, m, !0).valueOf())));
    var f = o.sS !== void 0 ? o.sS : o.Ss;
    return u ? (o.Ss && (c["SparseMatrix," + l] = (m, v) => o.Ss(m, v, u, !1)), f && (c[l + ", SparseMatrix"] = (m, v) => f(v, m, u, !0))) : (o.Ss && (c["SparseMatrix," + l] = t.referToSelf((m) => (v, p) => o.Ss(v, p, m, !1))), f && (c[l + ", SparseMatrix"] = t.referToSelf((m) => (v, p) => f(p, v, m, !0)))), u && u.signatures && uN(c, u.signatures), c;
  };
}), BI = "mod", tce = ["typed", "config", "round", "matrix", "equalScalar", "zeros", "DenseMatrix", "concat"], rce = /* @__PURE__ */ gt(BI, tce, (e) => {
  var {
    typed: t,
    config: r,
    round: n,
    matrix: i,
    equalScalar: a,
    zeros: o,
    DenseMatrix: u,
    concat: s
  } = e, c = Vse({
    typed: t,
    config: r,
    round: n,
    matrix: i,
    equalScalar: a,
    zeros: o,
    DenseMatrix: u
  }), l = qse({
    typed: t,
    equalScalar: a
  }), d = Mf({
    typed: t
  }), f = KN({
    typed: t,
    equalScalar: a
  }), m = Om({
    typed: t,
    equalScalar: a
  }), v = Uc({
    typed: t,
    DenseMatrix: u
  }), p = pd({
    typed: t,
    matrix: i,
    concat: s
  });
  return t(BI, {
    "number, number": g,
    "BigNumber, BigNumber": function(y, x) {
      return x.isZero() ? y : y.sub(x.mul(c(y.div(x))));
    },
    "bigint, bigint": function(y, x) {
      if (x === 0n)
        return y;
      if (y < 0) {
        var A = y % x;
        return A === 0n ? A : A + x;
      }
      return y % x;
    },
    "Fraction, Fraction": function(y, x) {
      return x.equals(0) ? y : y.sub(x.mul(c(y.div(x))));
    }
  }, p({
    SS: f,
    DS: d,
    SD: l,
    Ss: m,
    sS: v
  }));
  function g(h, y) {
    return y === 0 ? h : h - y * c(h / y);
  }
}), nce = "matAlgo01xDSid", ice = ["typed"], XN = /* @__PURE__ */ gt(nce, ice, (e) => {
  var {
    typed: t
  } = e;
  return function(n, i, a, o) {
    var u = n._data, s = n._size, c = n._datatype || n.getDataType(), l = i._values, d = i._index, f = i._ptr, m = i._size, v = i._datatype || i._data === void 0 ? i._datatype : i.getDataType();
    if (s.length !== m.length)
      throw new Qr(s.length, m.length);
    if (s[0] !== m[0] || s[1] !== m[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + s + ") must match Matrix B (" + m + ")");
    if (!l)
      throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");
    var p = s[0], g = s[1], h = typeof c == "string" && c !== "mixed" && c === v ? c : void 0, y = h ? t.find(a, [h, h]) : a, x, A, b = [];
    for (x = 0; x < p; x++)
      b[x] = [];
    var _ = [], S = [];
    for (A = 0; A < g; A++) {
      for (var D = A + 1, I = f[A], M = f[A + 1], F = I; F < M; F++)
        x = d[F], _[x] = o ? y(l[F], u[x][A]) : y(u[x][A], l[F]), S[x] = D;
      for (x = 0; x < p; x++)
        S[x] === D ? b[x][A] = _[x] : b[x][A] = u[x][A];
    }
    return n.createDenseMatrix({
      data: b,
      size: [p, g],
      datatype: c === n._datatype && v === i._datatype ? h : void 0
    });
  };
}), ace = "matAlgo04xSidSid", oce = ["typed", "equalScalar"], uce = /* @__PURE__ */ gt(ace, oce, (e) => {
  var {
    typed: t,
    equalScalar: r
  } = e;
  return function(i, a, o) {
    var u = i._values, s = i._index, c = i._ptr, l = i._size, d = i._datatype || i._data === void 0 ? i._datatype : i.getDataType(), f = a._values, m = a._index, v = a._ptr, p = a._size, g = a._datatype || a._data === void 0 ? a._datatype : a.getDataType();
    if (l.length !== p.length)
      throw new Qr(l.length, p.length);
    if (l[0] !== p[0] || l[1] !== p[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + l + ") must match Matrix B (" + p + ")");
    var h = l[0], y = l[1], x, A = r, b = 0, _ = o;
    typeof d == "string" && d === g && d !== "mixed" && (x = d, A = t.find(r, [x, x]), b = t.convert(0, x), _ = t.find(o, [x, x]));
    var S = u && f ? [] : void 0, D = [], I = [], M = u && f ? [] : void 0, F = u && f ? [] : void 0, P = [], E = [], B, N, O, z, V;
    for (N = 0; N < y; N++) {
      I[N] = D.length;
      var U = N + 1;
      for (z = c[N], V = c[N + 1], O = z; O < V; O++)
        B = s[O], D.push(B), P[B] = U, M && (M[B] = u[O]);
      for (z = v[N], V = v[N + 1], O = z; O < V; O++)
        if (B = m[O], P[B] === U) {
          if (M) {
            var H = _(M[B], f[O]);
            A(H, b) ? P[B] = null : M[B] = H;
          }
        } else
          D.push(B), E[B] = U, F && (F[B] = f[O]);
      if (M && F)
        for (O = I[N]; O < D.length; )
          B = D[O], P[B] === U ? (S[O] = M[B], O++) : E[B] === U ? (S[O] = F[B], O++) : D.splice(O, 1);
    }
    return I[y] = D.length, i.createSparseMatrix({
      values: S,
      index: D,
      ptr: I,
      size: [h, y],
      datatype: d === i._datatype && g === a._datatype ? x : void 0
    });
  };
}), sce = "matAlgo10xSids", cce = ["typed", "DenseMatrix"], jN = /* @__PURE__ */ gt(sce, cce, (e) => {
  var {
    typed: t,
    DenseMatrix: r
  } = e;
  return function(i, a, o, u) {
    var s = i._values, c = i._index, l = i._ptr, d = i._size, f = i._datatype;
    if (!s)
      throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");
    var m = d[0], v = d[1], p, g = o;
    typeof f == "string" && (p = f, a = t.convert(a, p), g = t.find(o, [p, p]));
    for (var h = [], y = [], x = [], A = 0; A < v; A++) {
      for (var b = A + 1, _ = l[A], S = l[A + 1], D = _; D < S; D++) {
        var I = c[D];
        y[I] = s[D], x[I] = b;
      }
      for (var M = 0; M < m; M++)
        A === 0 && (h[M] = []), x[M] === b ? h[M][A] = u ? g(a, y[M]) : g(y[M], a) : h[M][A] = a;
    }
    return new r({
      data: h,
      size: [m, v],
      datatype: p
    });
  };
}), lce = "multiplyScalar", dce = ["typed"], fce = /* @__PURE__ */ gt(lce, dce, (e) => {
  var {
    typed: t
  } = e;
  return t("multiplyScalar", {
    "number, number": VN,
    "Complex, Complex": function(n, i) {
      return n.mul(i);
    },
    "BigNumber, BigNumber": function(n, i) {
      return n.times(i);
    },
    "bigint, bigint": function(n, i) {
      return n * i;
    },
    "Fraction, Fraction": function(n, i) {
      return n.mul(i);
    },
    "number | Fraction | BigNumber | Complex, Unit": (r, n) => n.multiply(r),
    "Unit, number | Fraction | BigNumber | Complex | Unit": (r, n) => r.multiply(n)
  });
}), FI = "multiply", pce = ["typed", "matrix", "addScalar", "multiplyScalar", "equalScalar", "dot"], mce = /* @__PURE__ */ gt(FI, pce, (e) => {
  var {
    typed: t,
    matrix: r,
    addScalar: n,
    multiplyScalar: i,
    equalScalar: a,
    dot: o
  } = e, u = Om({
    typed: t,
    equalScalar: a
  }), s = Lm({
    typed: t
  });
  function c(b, _) {
    switch (b.length) {
      case 1:
        switch (_.length) {
          case 1:
            if (b[0] !== _[0])
              throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");
            break;
          case 2:
            if (b[0] !== _[0])
              throw new RangeError("Dimension mismatch in multiplication. Vector length (" + b[0] + ") must match Matrix rows (" + _[0] + ")");
            break;
          default:
            throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has " + _.length + " dimensions)");
        }
        break;
      case 2:
        switch (_.length) {
          case 1:
            if (b[1] !== _[0])
              throw new RangeError("Dimension mismatch in multiplication. Matrix columns (" + b[1] + ") must match Vector length (" + _[0] + ")");
            break;
          case 2:
            if (b[1] !== _[0])
              throw new RangeError("Dimension mismatch in multiplication. Matrix A columns (" + b[1] + ") must match Matrix B rows (" + _[0] + ")");
            break;
          default:
            throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has " + _.length + " dimensions)");
        }
        break;
      default:
        throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has " + b.length + " dimensions)");
    }
  }
  function l(b, _, S) {
    if (S === 0)
      throw new Error("Cannot multiply two empty vectors");
    return o(b, _);
  }
  function d(b, _) {
    if (_.storage() !== "dense")
      throw new Error("Support for SparseMatrix not implemented");
    return f(b, _);
  }
  function f(b, _) {
    var S = b._data, D = b._size, I = b._datatype || b.getDataType(), M = _._data, F = _._size, P = _._datatype || _.getDataType(), E = D[0], B = F[1], N, O = n, z = i;
    I && P && I === P && typeof I == "string" && I !== "mixed" && (N = I, O = t.find(n, [N, N]), z = t.find(i, [N, N]));
    for (var V = [], U = 0; U < B; U++) {
      for (var H = z(S[0], M[0][U]), K = 1; K < E; K++)
        H = O(H, z(S[K], M[K][U]));
      V[U] = H;
    }
    return b.createDenseMatrix({
      data: V,
      size: [B],
      datatype: I === b._datatype && P === _._datatype ? N : void 0
    });
  }
  var m = t("_multiplyMatrixVector", {
    "DenseMatrix, any": p,
    "SparseMatrix, any": y
  }), v = t("_multiplyMatrixMatrix", {
    "DenseMatrix, DenseMatrix": g,
    "DenseMatrix, SparseMatrix": h,
    "SparseMatrix, DenseMatrix": x,
    "SparseMatrix, SparseMatrix": A
  });
  function p(b, _) {
    var S = b._data, D = b._size, I = b._datatype || b.getDataType(), M = _._data, F = _._datatype || _.getDataType(), P = D[0], E = D[1], B, N = n, O = i;
    I && F && I === F && typeof I == "string" && I !== "mixed" && (B = I, N = t.find(n, [B, B]), O = t.find(i, [B, B]));
    for (var z = [], V = 0; V < P; V++) {
      for (var U = S[V], H = O(U[0], M[0]), K = 1; K < E; K++)
        H = N(H, O(U[K], M[K]));
      z[V] = H;
    }
    return b.createDenseMatrix({
      data: z,
      size: [P],
      datatype: I === b._datatype && F === _._datatype ? B : void 0
    });
  }
  function g(b, _) {
    var S = b._data, D = b._size, I = b._datatype || b.getDataType(), M = _._data, F = _._size, P = _._datatype || _.getDataType(), E = D[0], B = D[1], N = F[1], O, z = n, V = i;
    I && P && I === P && typeof I == "string" && I !== "mixed" && I !== "mixed" && (O = I, z = t.find(n, [O, O]), V = t.find(i, [O, O]));
    for (var U = [], H = 0; H < E; H++) {
      var K = S[H];
      U[H] = [];
      for (var j = 0; j < N; j++) {
        for (var X = V(K[0], M[0][j]), W = 1; W < B; W++)
          X = z(X, V(K[W], M[W][j]));
        U[H][j] = X;
      }
    }
    return b.createDenseMatrix({
      data: U,
      size: [E, N],
      datatype: I === b._datatype && P === _._datatype ? O : void 0
    });
  }
  function h(b, _) {
    var S = b._data, D = b._size, I = b._datatype || b.getDataType(), M = _._values, F = _._index, P = _._ptr, E = _._size, B = _._datatype || _._data === void 0 ? _._datatype : _.getDataType();
    if (!M)
      throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");
    var N = D[0], O = E[1], z, V = n, U = i, H = a, K = 0;
    I && B && I === B && typeof I == "string" && I !== "mixed" && (z = I, V = t.find(n, [z, z]), U = t.find(i, [z, z]), H = t.find(a, [z, z]), K = t.convert(0, z));
    for (var j = [], X = [], W = [], Q = _.createSparseMatrix({
      values: j,
      index: X,
      ptr: W,
      size: [N, O],
      datatype: I === b._datatype && B === _._datatype ? z : void 0
    }), te = 0; te < O; te++) {
      W[te] = X.length;
      var ee = P[te], $ = P[te + 1];
      if ($ > ee)
        for (var ie = 0, ae = 0; ae < N; ae++) {
          for (var se = ae + 1, le = void 0, pe = ee; pe < $; pe++) {
            var we = F[pe];
            ie !== se ? (le = U(S[ae][we], M[pe]), ie = se) : le = V(le, U(S[ae][we], M[pe]));
          }
          ie === se && !H(le, K) && (X.push(ae), j.push(le));
        }
    }
    return W[O] = X.length, Q;
  }
  function y(b, _) {
    var S = b._values, D = b._index, I = b._ptr, M = b._datatype || b._data === void 0 ? b._datatype : b.getDataType();
    if (!S)
      throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");
    var F = _._data, P = _._datatype || _.getDataType(), E = b._size[0], B = _._size[0], N = [], O = [], z = [], V, U = n, H = i, K = a, j = 0;
    M && P && M === P && typeof M == "string" && M !== "mixed" && (V = M, U = t.find(n, [V, V]), H = t.find(i, [V, V]), K = t.find(a, [V, V]), j = t.convert(0, V));
    var X = [], W = [];
    z[0] = 0;
    for (var Q = 0; Q < B; Q++) {
      var te = F[Q];
      if (!K(te, j))
        for (var ee = I[Q], $ = I[Q + 1], ie = ee; ie < $; ie++) {
          var ae = D[ie];
          W[ae] ? X[ae] = U(X[ae], H(te, S[ie])) : (W[ae] = !0, O.push(ae), X[ae] = H(te, S[ie]));
        }
    }
    for (var se = O.length, le = 0; le < se; le++) {
      var pe = O[le];
      N[le] = X[pe];
    }
    return z[1] = O.length, b.createSparseMatrix({
      values: N,
      index: O,
      ptr: z,
      size: [E, 1],
      datatype: M === b._datatype && P === _._datatype ? V : void 0
    });
  }
  function x(b, _) {
    var S = b._values, D = b._index, I = b._ptr, M = b._datatype || b._data === void 0 ? b._datatype : b.getDataType();
    if (!S)
      throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");
    var F = _._data, P = _._datatype || _.getDataType(), E = b._size[0], B = _._size[0], N = _._size[1], O, z = n, V = i, U = a, H = 0;
    M && P && M === P && typeof M == "string" && M !== "mixed" && (O = M, z = t.find(n, [O, O]), V = t.find(i, [O, O]), U = t.find(a, [O, O]), H = t.convert(0, O));
    for (var K = [], j = [], X = [], W = b.createSparseMatrix({
      values: K,
      index: j,
      ptr: X,
      size: [E, N],
      datatype: M === b._datatype && P === _._datatype ? O : void 0
    }), Q = [], te = [], ee = 0; ee < N; ee++) {
      X[ee] = j.length;
      for (var $ = ee + 1, ie = 0; ie < B; ie++) {
        var ae = F[ie][ee];
        if (!U(ae, H))
          for (var se = I[ie], le = I[ie + 1], pe = se; pe < le; pe++) {
            var we = D[pe];
            te[we] !== $ ? (te[we] = $, j.push(we), Q[we] = V(ae, S[pe])) : Q[we] = z(Q[we], V(ae, S[pe]));
          }
      }
      for (var Ge = X[ee], Ue = j.length, Ke = Ge; Ke < Ue; Ke++) {
        var Ze = j[Ke];
        K[Ke] = Q[Ze];
      }
    }
    return X[N] = j.length, W;
  }
  function A(b, _) {
    var S = b._values, D = b._index, I = b._ptr, M = b._datatype || b._data === void 0 ? b._datatype : b.getDataType(), F = _._values, P = _._index, E = _._ptr, B = _._datatype || _._data === void 0 ? _._datatype : _.getDataType(), N = b._size[0], O = _._size[1], z = S && F, V, U = n, H = i;
    M && B && M === B && typeof M == "string" && M !== "mixed" && (V = M, U = t.find(n, [V, V]), H = t.find(i, [V, V]));
    for (var K = z ? [] : void 0, j = [], X = [], W = b.createSparseMatrix({
      values: K,
      index: j,
      ptr: X,
      size: [N, O],
      datatype: M === b._datatype && B === _._datatype ? V : void 0
    }), Q = z ? [] : void 0, te = [], ee, $, ie, ae, se, le, pe, we, Ge = 0; Ge < O; Ge++) {
      X[Ge] = j.length;
      var Ue = Ge + 1;
      for (se = E[Ge], le = E[Ge + 1], ae = se; ae < le; ae++)
        if (we = P[ae], z)
          for ($ = I[we], ie = I[we + 1], ee = $; ee < ie; ee++)
            pe = D[ee], te[pe] !== Ue ? (te[pe] = Ue, j.push(pe), Q[pe] = H(F[ae], S[ee])) : Q[pe] = U(Q[pe], H(F[ae], S[ee]));
        else
          for ($ = I[we], ie = I[we + 1], ee = $; ee < ie; ee++)
            pe = D[ee], te[pe] !== Ue && (te[pe] = Ue, j.push(pe));
      if (z)
        for (var Ke = X[Ge], Ze = j.length, Fe = Ke; Fe < Ze; Fe++) {
          var Je = j[Fe];
          K[Fe] = Q[Je];
        }
    }
    return X[O] = j.length, W;
  }
  return t(FI, i, {
    // we extend the signatures of multiplyScalar with signatures dealing with matrices
    "Array, Array": t.referTo("Matrix, Matrix", (b) => (_, S) => {
      c(Fn(_), Fn(S));
      var D = b(r(_), r(S));
      return Nn(D) ? D.valueOf() : D;
    }),
    "Matrix, Matrix": function(_, S) {
      var D = _.size(), I = S.size();
      return c(D, I), D.length === 1 ? I.length === 1 ? l(_, S, D[0]) : d(_, S) : I.length === 1 ? m(_, S) : v(_, S);
    },
    "Matrix, Array": t.referTo("Matrix,Matrix", (b) => (_, S) => b(_, r(S))),
    "Array, Matrix": t.referToSelf((b) => (_, S) => b(r(_, S.storage()), S)),
    "SparseMatrix, any": function(_, S) {
      return u(_, S, i, !1);
    },
    "DenseMatrix, any": function(_, S) {
      return s(_, S, i, !1);
    },
    "any, SparseMatrix": function(_, S) {
      return u(S, _, i, !0);
    },
    "any, DenseMatrix": function(_, S) {
      return s(S, _, i, !0);
    },
    "Array, any": function(_, S) {
      return s(r(_), S, i, !1).valueOf();
    },
    "any, Array": function(_, S) {
      return s(r(S), _, i, !0).valueOf();
    },
    "any, any": i,
    "any, any, ...any": t.referToSelf((b) => (_, S, D) => {
      for (var I = b(_, S), M = 0; M < D.length; M++)
        I = b(I, D[M]);
      return I;
    })
  });
}), NI = "sign", hce = ["typed", "BigNumber", "Fraction", "complex"], vce = /* @__PURE__ */ gt(NI, hce, (e) => {
  var {
    typed: t,
    BigNumber: r,
    complex: n,
    Fraction: i
  } = e;
  return t(NI, {
    number: Q6,
    Complex: function(o) {
      return o.im === 0 ? n(Q6(o.re)) : o.sign();
    },
    BigNumber: function(o) {
      return new r(o.cmp(0));
    },
    bigint: function(o) {
      return o > 0n ? 1n : o < 0n ? -1n : 0n;
    },
    Fraction: function(o) {
      return new i(o.s, 1);
    },
    // deep map collection, skip zeros since sign(0) = 0
    "Array | Matrix": t.referToSelf((a) => (o) => ua(o, a)),
    Unit: t.referToSelf((a) => (o) => {
      if (!o._isDerived() && o.units[0].unit.offset !== 0)
        throw new TypeError("sign is ambiguous for units with offset");
      return t.find(a, o.valueType())(o.value);
    })
  });
}), gce = "sqrt", yce = ["config", "typed", "Complex"], bce = /* @__PURE__ */ gt(gce, yce, (e) => {
  var {
    config: t,
    typed: r,
    Complex: n
  } = e;
  return r("sqrt", {
    number: i,
    Complex: function(o) {
      return o.sqrt();
    },
    BigNumber: function(o) {
      return !o.isNegative() || t.predictable ? o.sqrt() : i(o.toNumber());
    },
    Unit: function(o) {
      return o.pow(0.5);
    }
  });
  function i(a) {
    return isNaN(a) ? NaN : a >= 0 || t.predictable ? Math.sqrt(a) : new n(a, 0).sqrt();
  }
}), RI = "subtract", _ce = ["typed", "matrix", "equalScalar", "subtractScalar", "unaryMinus", "DenseMatrix", "concat"], xce = /* @__PURE__ */ gt(RI, _ce, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    subtractScalar: i,
    unaryMinus: a,
    DenseMatrix: o,
    concat: u
  } = e, s = XN({
    typed: t
  }), c = Mf({
    typed: t
  }), l = KN({
    typed: t,
    equalScalar: n
  }), d = jN({
    typed: t,
    DenseMatrix: o
  }), f = Uc({
    typed: t,
    DenseMatrix: o
  }), m = pd({
    typed: t,
    matrix: r,
    concat: u
  });
  return t(RI, {
    "any, any": i
  }, m({
    elop: i,
    SS: l,
    DS: s,
    SD: c,
    Ss: f,
    sS: d
  }));
}), Ace = "matAlgo07xSSf", Sce = ["typed", "DenseMatrix"], km = /* @__PURE__ */ gt(Ace, Sce, (e) => {
  var {
    typed: t,
    DenseMatrix: r
  } = e;
  return function(a, o, u) {
    var s = a._size, c = a._datatype || a._data === void 0 ? a._datatype : a.getDataType(), l = o._size, d = o._datatype || o._data === void 0 ? o._datatype : o.getDataType();
    if (s.length !== l.length)
      throw new Qr(s.length, l.length);
    if (s[0] !== l[0] || s[1] !== l[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + s + ") must match Matrix B (" + l + ")");
    var f = s[0], m = s[1], v, p = 0, g = u;
    typeof c == "string" && c === d && c !== "mixed" && (v = c, p = t.convert(0, v), g = t.find(u, [v, v]));
    var h, y, x = [];
    for (h = 0; h < f; h++)
      x[h] = [];
    var A = [], b = [], _ = [], S = [];
    for (y = 0; y < m; y++) {
      var D = y + 1;
      for (n(a, y, _, A, D), n(o, y, S, b, D), h = 0; h < f; h++) {
        var I = _[h] === D ? A[h] : p, M = S[h] === D ? b[h] : p;
        x[h][y] = g(I, M);
      }
    }
    return new r({
      data: x,
      size: [f, m],
      datatype: c === a._datatype && d === o._datatype ? v : void 0
    });
  };
  function n(i, a, o, u, s) {
    for (var c = i._values, l = i._index, d = i._ptr, f = d[a], m = d[a + 1]; f < m; f++) {
      var v = l[f];
      o[v] = s, u[v] = c[f];
    }
  }
}), OI = "conj", Cce = ["typed"], wce = /* @__PURE__ */ gt(OI, Cce, (e) => {
  var {
    typed: t
  } = e;
  return t(OI, {
    "number | BigNumber | Fraction": (r) => r,
    Complex: (r) => r.conjugate(),
    "Array | Matrix": t.referToSelf((r) => (n) => ua(n, r))
  });
}), LI = "im", Dce = ["typed"], Ice = /* @__PURE__ */ gt(LI, Dce, (e) => {
  var {
    typed: t
  } = e;
  return t(LI, {
    number: () => 0,
    "BigNumber | Fraction": (r) => r.mul(0),
    Complex: (r) => r.im,
    "Array | Matrix": t.referToSelf((r) => (n) => ua(n, r))
  });
}), kI = "re", Ece = ["typed"], Mce = /* @__PURE__ */ gt(kI, Ece, (e) => {
  var {
    typed: t
  } = e;
  return t(kI, {
    "number | BigNumber | Fraction": (r) => r,
    Complex: (r) => r.re,
    "Array | Matrix": t.referToSelf((r) => (n) => ua(n, r))
  });
}), zI = "concat", Tce = ["typed", "matrix", "isInteger"], Pce = /* @__PURE__ */ gt(zI, Tce, (e) => {
  var {
    typed: t,
    matrix: r,
    isInteger: n
  } = e;
  return t(zI, {
    // TODO: change signature to '...Array | Matrix, dim?' when supported
    "...Array | Matrix | number | BigNumber": function(a) {
      var o, u = a.length, s = -1, c, l = !1, d = [];
      for (o = 0; o < u; o++) {
        var f = a[o];
        if (Nn(f) && (l = !0), En(f) || ti(f)) {
          if (o !== u - 1)
            throw new Error("Dimension must be specified as last argument");
          if (c = s, s = f.valueOf(), !n(s))
            throw new TypeError("Integer number expected for dimension");
          if (s < 0 || o > 0 && s > c)
            throw new Ef(s, c + 1);
        } else {
          var m = Wr(f).valueOf(), v = Fn(m);
          if (d[o] = m, c = s, s = v.length - 1, o > 0 && s !== c)
            throw new Qr(c + 1, s + 1);
        }
      }
      if (d.length === 0)
        throw new SyntaxError("At least one matrix expected");
      for (var p = d.shift(); d.length; )
        p = NN(p, d.shift(), s);
      return l ? r(p) : p;
    },
    "...string": function(a) {
      return a.join("");
    }
  });
}), GI = "column", Bce = ["typed", "Index", "matrix", "range"], Fce = /* @__PURE__ */ gt(GI, Bce, (e) => {
  var {
    typed: t,
    Index: r,
    matrix: n,
    range: i
  } = e;
  return t(GI, {
    "Matrix, number": a,
    "Array, number": function(u, s) {
      return a(n(Wr(u)), s).valueOf();
    }
  });
  function a(o, u) {
    if (o.size().length !== 2)
      throw new Error("Only two dimensional matrix is supported");
    Xn(u, o.size()[1]);
    var s = i(0, o.size()[0]), c = new r(s, u), l = o.subset(c);
    return Nn(l) ? l : n([[l]]);
  }
}), VI = "cross", Nce = ["typed", "matrix", "subtract", "multiply"], Rce = /* @__PURE__ */ gt(VI, Nce, (e) => {
  var {
    typed: t,
    matrix: r,
    subtract: n,
    multiply: i
  } = e;
  return t(VI, {
    "Matrix, Matrix": function(u, s) {
      return r(a(u.toArray(), s.toArray()));
    },
    "Matrix, Array": function(u, s) {
      return r(a(u.toArray(), s));
    },
    "Array, Matrix": function(u, s) {
      return r(a(u, s.toArray()));
    },
    "Array, Array": a
  });
  function a(o, u) {
    var s = Math.max(Fn(o).length, Fn(u).length);
    o = AI(o), u = AI(u);
    var c = Fn(o), l = Fn(u);
    if (c.length !== 1 || l.length !== 1 || c[0] !== 3 || l[0] !== 3)
      throw new RangeError("Vectors with length 3 expected (Size A = [" + c.join(", ") + "], B = [" + l.join(", ") + "])");
    var d = [n(i(o[1], u[2]), i(o[2], u[1])), n(i(o[2], u[0]), i(o[0], u[2])), n(i(o[0], u[1]), i(o[1], u[0]))];
    return s > 1 ? [d] : d;
  }
}), UI = "diag", Oce = ["typed", "matrix", "DenseMatrix", "SparseMatrix"], Lce = /* @__PURE__ */ gt(UI, Oce, (e) => {
  var {
    typed: t,
    matrix: r,
    DenseMatrix: n,
    SparseMatrix: i
  } = e;
  return t(UI, {
    // FIXME: simplify this huge amount of signatures as soon as typed-function supports optional arguments
    Array: function(c) {
      return a(c, 0, Fn(c), null);
    },
    "Array, number": function(c, l) {
      return a(c, l, Fn(c), null);
    },
    "Array, BigNumber": function(c, l) {
      return a(c, l.toNumber(), Fn(c), null);
    },
    "Array, string": function(c, l) {
      return a(c, 0, Fn(c), l);
    },
    "Array, number, string": function(c, l, d) {
      return a(c, l, Fn(c), d);
    },
    "Array, BigNumber, string": function(c, l, d) {
      return a(c, l.toNumber(), Fn(c), d);
    },
    Matrix: function(c) {
      return a(c, 0, c.size(), c.storage());
    },
    "Matrix, number": function(c, l) {
      return a(c, l, c.size(), c.storage());
    },
    "Matrix, BigNumber": function(c, l) {
      return a(c, l.toNumber(), c.size(), c.storage());
    },
    "Matrix, string": function(c, l) {
      return a(c, 0, c.size(), l);
    },
    "Matrix, number, string": function(c, l, d) {
      return a(c, l, c.size(), d);
    },
    "Matrix, BigNumber, string": function(c, l, d) {
      return a(c, l.toNumber(), c.size(), d);
    }
  });
  function a(s, c, l, d) {
    if (!Mn(c))
      throw new TypeError("Second parameter in function diag must be an integer");
    var f = c > 0 ? c : 0, m = c < 0 ? -c : 0;
    switch (l.length) {
      case 1:
        return o(s, c, d, l[0], m, f);
      case 2:
        return u(s, c, d, l, m, f);
    }
    throw new RangeError("Matrix for function diag must be 2 dimensional");
  }
  function o(s, c, l, d, f, m) {
    var v = [d + f, d + m];
    if (l && l !== "sparse" && l !== "dense")
      throw new TypeError("Unknown matrix type ".concat(l, '"'));
    var p = l === "sparse" ? i.diagonal(v, s, c) : n.diagonal(v, s, c);
    return l !== null ? p : p.valueOf();
  }
  function u(s, c, l, d, f, m) {
    if (Nn(s)) {
      var v = s.diagonal(c);
      return l !== null ? l !== v.storage() ? r(v, l) : v : v.valueOf();
    }
    for (var p = Math.min(d[0] - f, d[1] - m), g = [], h = 0; h < p; h++)
      g[h] = s[h + f][h + m];
    return l !== null ? r(g) : g;
  }
}), HI = "flatten", kce = ["typed", "matrix"], zce = /* @__PURE__ */ gt(HI, kce, (e) => {
  var {
    typed: t,
    matrix: r
  } = e;
  return t(HI, {
    Array: function(i) {
      return W6(i);
    },
    Matrix: function(i) {
      var a = W6(i.toArray());
      return r(a);
    }
  });
}), qI = "getMatrixDataType", Gce = ["typed"], Vce = /* @__PURE__ */ gt(qI, Gce, (e) => {
  var {
    typed: t
  } = e;
  return t(qI, {
    Array: function(n) {
      return xm(n, Ic);
    },
    Matrix: function(n) {
      return n.getDataType();
    }
  });
}), KI = "identity", Uce = ["typed", "config", "matrix", "BigNumber", "DenseMatrix", "SparseMatrix"], Hce = /* @__PURE__ */ gt(KI, Uce, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    BigNumber: i,
    DenseMatrix: a,
    SparseMatrix: o
  } = e;
  return t(KI, {
    "": function() {
      return r.matrix === "Matrix" ? n([]) : [];
    },
    string: function(l) {
      return n(l);
    },
    "number | BigNumber": function(l) {
      return s(l, l, r.matrix === "Matrix" ? "dense" : void 0);
    },
    "number | BigNumber, string": function(l, d) {
      return s(l, l, d);
    },
    "number | BigNumber, number | BigNumber": function(l, d) {
      return s(l, d, r.matrix === "Matrix" ? "dense" : void 0);
    },
    "number | BigNumber, number | BigNumber, string": function(l, d, f) {
      return s(l, d, f);
    },
    Array: function(l) {
      return u(l);
    },
    "Array, string": function(l, d) {
      return u(l, d);
    },
    Matrix: function(l) {
      return u(l.valueOf(), l.storage());
    },
    "Matrix, string": function(l, d) {
      return u(l.valueOf(), d);
    }
  });
  function u(c, l) {
    switch (c.length) {
      case 0:
        return l ? n(l) : [];
      case 1:
        return s(c[0], c[0], l);
      case 2:
        return s(c[0], c[1], l);
      default:
        throw new Error("Vector containing two values expected");
    }
  }
  function s(c, l, d) {
    var f = ti(c) || ti(l) ? i : null;
    if (ti(c) && (c = c.toNumber()), ti(l) && (l = l.toNumber()), !Mn(c) || c < 1)
      throw new Error("Parameters in function identity must be positive integers");
    if (!Mn(l) || l < 1)
      throw new Error("Parameters in function identity must be positive integers");
    var m = f ? new i(1) : 1, v = f ? new f(0) : 0, p = [c, l];
    if (d) {
      if (d === "sparse")
        return o.diagonal(p, m, 0, v);
      if (d === "dense")
        return a.diagonal(p, m, 0, v);
      throw new TypeError('Unknown matrix type "'.concat(d, '"'));
    }
    for (var g = lg([], p, v), h = c < l ? c : l, y = 0; y < h; y++)
      g[y][y] = m;
    return g;
  }
});
function YN() {
  throw new Error('No "bignumber" implementation available');
}
function qce() {
  throw new Error('No "fraction" implementation available');
}
function WN() {
  throw new Error('No "matrix" implementation available');
}
var XI = "range", Kce = ["typed", "config", "?matrix", "?bignumber", "smaller", "smallerEq", "larger", "largerEq", "add", "isPositive"], Xce = /* @__PURE__ */ gt(XI, Kce, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    bignumber: i,
    smaller: a,
    smallerEq: o,
    larger: u,
    largerEq: s,
    add: c,
    isPositive: l
  } = e;
  return t(XI, {
    // TODO: simplify signatures when typed-function supports default values and optional arguments
    // TODO: a number or boolean should not be converted to string here
    string: f,
    "string, boolean": f,
    "number, number": function(g, h) {
      return d(m(g, h, 1, !1));
    },
    "number, number, number": function(g, h, y) {
      return d(m(g, h, y, !1));
    },
    "number, number, boolean": function(g, h, y) {
      return d(m(g, h, 1, y));
    },
    "number, number, number, boolean": function(g, h, y, x) {
      return d(m(g, h, y, x));
    },
    "BigNumber, BigNumber": function(g, h) {
      var y = g.constructor;
      return d(m(g, h, new y(1), !1));
    },
    "BigNumber, BigNumber, BigNumber": function(g, h, y) {
      return d(m(g, h, y, !1));
    },
    "BigNumber, BigNumber, boolean": function(g, h, y) {
      var x = g.constructor;
      return d(m(g, h, new x(1), y));
    },
    "BigNumber, BigNumber, BigNumber, boolean": function(g, h, y, x) {
      return d(m(g, h, y, x));
    },
    "Unit, Unit, Unit": function(g, h, y) {
      return d(m(g, h, y, !1));
    },
    "Unit, Unit, Unit, boolean": function(g, h, y, x) {
      return d(m(g, h, y, x));
    }
  });
  function d(p) {
    return r.matrix === "Matrix" ? n ? n(p) : WN() : p;
  }
  function f(p, g) {
    var h = v(p);
    if (!h)
      throw new SyntaxError('String "' + p + '" is no valid range');
    return r.number === "BigNumber" ? (i === void 0 && YN(), d(m(i(h.start), i(h.end), i(h.step)))) : d(m(h.start, h.end, h.step, g));
  }
  function m(p, g, h, y) {
    for (var x = [], A = l(h) ? y ? o : a : y ? s : u, b = p; A(b, g); )
      x.push(b), b = c(b, h);
    return x;
  }
  function v(p) {
    var g = p.split(":"), h = g.map(function(x) {
      return Number(x);
    }), y = h.some(function(x) {
      return isNaN(x);
    });
    if (y)
      return null;
    switch (h.length) {
      case 2:
        return {
          start: h[0],
          end: h[1],
          step: 1
        };
      case 3:
        return {
          start: h[0],
          end: h[2],
          step: h[1]
        };
      default:
        return null;
    }
  }
}), jI = "reshape", jce = ["typed", "isInteger", "matrix"], Yce = /* @__PURE__ */ gt(jI, jce, (e) => {
  var {
    typed: t,
    isInteger: r
  } = e;
  return t(jI, {
    "Matrix, Array": function(i, a) {
      return i.reshape(a, !0);
    },
    "Array, Array": function(i, a) {
      return a.forEach(function(o) {
        if (!r(o))
          throw new TypeError("Invalid size for dimension: " + o);
      }), A8(i, a);
    }
  });
}), YI = "size", Wce = ["typed", "config", "?matrix"], Zce = /* @__PURE__ */ gt(YI, Wce, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n
  } = e;
  return t(YI, {
    Matrix: function(a) {
      return a.create(a.size());
    },
    Array: Fn,
    string: function(a) {
      return r.matrix === "Array" ? [a.length] : n([a.length]);
    },
    "number | Complex | BigNumber | Unit | boolean | null": function(a) {
      return r.matrix === "Array" ? [] : n ? n([]) : WN();
    }
  });
}), WI = "transpose", Qce = ["typed", "matrix"], Jce = /* @__PURE__ */ gt(WI, Qce, (e) => {
  var {
    typed: t,
    matrix: r
  } = e;
  return t(WI, {
    Array: (o) => n(r(o)).valueOf(),
    Matrix: n,
    any: Wr
    // scalars
  });
  function n(o) {
    var u = o.size(), s;
    switch (u.length) {
      case 1:
        s = o.clone();
        break;
      case 2:
        {
          var c = u[0], l = u[1];
          if (l === 0)
            throw new RangeError("Cannot transpose a 2D matrix with no columns (size: " + kn(u) + ")");
          switch (o.storage()) {
            case "dense":
              s = i(o, c, l);
              break;
            case "sparse":
              s = a(o, c, l);
              break;
          }
        }
        break;
      default:
        throw new RangeError("Matrix must be a vector or two dimensional (size: " + kn(u) + ")");
    }
    return s;
  }
  function i(o, u, s) {
    for (var c = o._data, l = [], d, f = 0; f < s; f++) {
      d = l[f] = [];
      for (var m = 0; m < u; m++)
        d[m] = Wr(c[m][f]);
    }
    return o.createDenseMatrix({
      data: l,
      size: [s, u],
      datatype: o._datatype
    });
  }
  function a(o, u, s) {
    for (var c = o._values, l = o._index, d = o._ptr, f = c ? [] : void 0, m = [], v = [], p = [], g = 0; g < u; g++)
      p[g] = 0;
    var h, y, x;
    for (h = 0, y = l.length; h < y; h++)
      p[l[h]]++;
    for (var A = 0, b = 0; b < u; b++)
      v.push(A), A += p[b], p[b] = v[b];
    for (v.push(A), x = 0; x < s; x++)
      for (var _ = d[x], S = d[x + 1], D = _; D < S; D++) {
        var I = p[l[D]]++;
        m[I] = x, c && (f[I] = Wr(c[D]));
      }
    return o.createSparseMatrix({
      values: f,
      index: m,
      ptr: v,
      size: [s, u],
      datatype: o._datatype
    });
  }
}), ZI = "ctranspose", $ce = ["typed", "transpose", "conj"], ele = /* @__PURE__ */ gt(ZI, $ce, (e) => {
  var {
    typed: t,
    transpose: r,
    conj: n
  } = e;
  return t(ZI, {
    any: function(a) {
      return n(r(a));
    }
  });
}), QI = "zeros", tle = ["typed", "config", "matrix", "BigNumber"], rle = /* @__PURE__ */ gt(QI, tle, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    BigNumber: i
  } = e;
  return t(QI, {
    "": function() {
      return r.matrix === "Array" ? a([]) : a([], "default");
    },
    // math.zeros(m, n, p, ..., format)
    // TODO: more accurate signature '...number | BigNumber, string' as soon as typed-function supports this
    "...number | BigNumber | string": function(c) {
      var l = c[c.length - 1];
      if (typeof l == "string") {
        var d = c.pop();
        return a(c, d);
      } else return r.matrix === "Array" ? a(c) : a(c, "default");
    },
    Array: a,
    Matrix: function(c) {
      var l = c.storage();
      return a(c.valueOf(), l);
    },
    "Array | Matrix, string": function(c, l) {
      return a(c.valueOf(), l);
    }
  });
  function a(s, c) {
    var l = o(s), d = l ? new i(0) : 0;
    if (u(s), c) {
      var f = n(c);
      return s.length > 0 ? f.resize(s, d) : f;
    } else {
      var m = [];
      return s.length > 0 ? lg(m, s, d) : m;
    }
  }
  function o(s) {
    var c = !1;
    return s.forEach(function(l, d, f) {
      ti(l) && (c = !0, f[d] = l.toNumber());
    }), c;
  }
  function u(s) {
    s.forEach(function(c) {
      if (typeof c != "number" || !Mn(c) || c < 0)
        throw new Error("Parameters in function zeros must be positive integers");
    });
  }
}), nle = "numeric", ile = ["number", "?bignumber", "?fraction"], ale = /* @__PURE__ */ gt(nle, ile, (e) => {
  var {
    number: t,
    bignumber: r,
    fraction: n
  } = e, i = {
    string: !0,
    number: !0,
    BigNumber: !0,
    Fraction: !0
  }, a = {
    number: (o) => t(o),
    BigNumber: r ? (o) => r(o) : YN,
    bigint: (o) => BigInt(o),
    Fraction: n ? (o) => n(o) : qce
  };
  return function(u) {
    var s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "number", c = arguments.length > 2 ? arguments[2] : void 0;
    if (c !== void 0)
      throw new SyntaxError("numeric() takes one or two arguments");
    var l = Ic(u);
    if (!(l in i))
      throw new TypeError("Cannot convert " + u + ' of type "' + l + '"; valid input types are ' + Object.keys(i).join(", "));
    if (!(s in a))
      throw new TypeError("Cannot convert " + u + ' to type "' + s + '"; valid output types are ' + Object.keys(a).join(", "));
    return s === l ? u : a[s](u);
  };
}), JI = "divideScalar", ole = ["typed", "numeric"], ule = /* @__PURE__ */ gt(JI, ole, (e) => {
  var {
    typed: t,
    numeric: r
  } = e;
  return t(JI, {
    "number, number": function(i, a) {
      return i / a;
    },
    "Complex, Complex": function(i, a) {
      return i.div(a);
    },
    "BigNumber, BigNumber": function(i, a) {
      return i.div(a);
    },
    "bigint, bigint": function(i, a) {
      return i / a;
    },
    "Fraction, Fraction": function(i, a) {
      return i.div(a);
    },
    "Unit, number | Complex | Fraction | BigNumber | Unit": (n, i) => n.divide(i),
    "number | Fraction | Complex | BigNumber, Unit": (n, i) => i.divideInto(n)
  });
}), $I = "pow", sle = ["typed", "config", "identity", "multiply", "matrix", "inv", "fraction", "number", "Complex"], cle = /* @__PURE__ */ gt($I, sle, (e) => {
  var {
    typed: t,
    config: r,
    identity: n,
    multiply: i,
    matrix: a,
    inv: o,
    number: u,
    fraction: s,
    Complex: c
  } = e;
  return t($I, {
    "number, number": l,
    "Complex, Complex": function(v, p) {
      return v.pow(p);
    },
    "BigNumber, BigNumber": function(v, p) {
      return p.isInteger() || v >= 0 || r.predictable ? v.pow(p) : new c(v.toNumber(), 0).pow(p.toNumber(), 0);
    },
    "bigint, bigint": (m, v) => m ** v,
    "Fraction, Fraction": function(v, p) {
      var g = v.pow(p);
      if (g != null)
        return g;
      if (r.predictable)
        throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");
      return l(v.valueOf(), p.valueOf());
    },
    "Array, number": d,
    "Array, BigNumber": function(v, p) {
      return d(v, p.toNumber());
    },
    "Matrix, number": f,
    "Matrix, BigNumber": function(v, p) {
      return f(v, p.toNumber());
    },
    "Unit, number | BigNumber": function(v, p) {
      return v.pow(p);
    }
  });
  function l(m, v) {
    if (r.predictable && !Mn(v) && m < 0)
      try {
        var p = s(v), g = u(p);
        if ((v === g || Math.abs((v - g) / v) < 1e-14) && p.d % 2 === 1)
          return (p.n % 2 === 0 ? 1 : -1) * Math.pow(-m, v);
      } catch {
      }
    return r.predictable && (m < -1 && v === 1 / 0 || m > -1 && m < 0 && v === -1 / 0) ? NaN : Mn(v) || m >= 0 || r.predictable ? HN(m, v) : m * m < 1 && v === 1 / 0 || m * m > 1 && v === -1 / 0 ? 0 : new c(m, 0).pow(v, 0);
  }
  function d(m, v) {
    if (!Mn(v))
      throw new TypeError("For A^b, b must be an integer (value is " + v + ")");
    var p = Fn(m);
    if (p.length !== 2)
      throw new Error("For A^b, A must be 2 dimensional (A has " + p.length + " dimensions)");
    if (p[0] !== p[1])
      throw new Error("For A^b, A must be square (size is " + p[0] + "x" + p[1] + ")");
    if (v < 0)
      try {
        return d(o(m), -v);
      } catch (y) {
        throw y.message === "Cannot calculate inverse, determinant is zero" ? new TypeError("For A^b, when A is not invertible, b must be a positive integer (value is " + v + ")") : y;
      }
    for (var g = n(p[0]).valueOf(), h = m; v >= 1; )
      (v & 1) === 1 && (g = i(h, g)), v >>= 1, h = i(h, h);
    return g;
  }
  function f(m, v) {
    return a(d(m.valueOf(), v));
  }
}), C1 = "Number of decimals in function round must be an integer", eE = "round", lle = ["typed", "config", "matrix", "equalScalar", "zeros", "BigNumber", "DenseMatrix"], dle = /* @__PURE__ */ gt(eE, lle, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    equalScalar: i,
    zeros: a,
    BigNumber: o,
    DenseMatrix: u
  } = e, s = Om({
    typed: t,
    equalScalar: i
  }), c = Uc({
    typed: t,
    DenseMatrix: u
  }), l = Lm({
    typed: t
  });
  function d(f) {
    return Math.abs(Nm(f).exponent);
  }
  return t(eE, {
    number: function(m) {
      var v = xp(m, d(r.relTol)), p = Zo(m, v, r.relTol, r.absTol) ? v : m;
      return xp(p);
    },
    "number, number": function(m, v) {
      var p = d(r.relTol);
      if (v >= p)
        return xp(m, v);
      var g = xp(m, p), h = Zo(m, g, r.relTol, r.absTol) ? g : m;
      return xp(h, v);
    },
    "number, BigNumber": function(m, v) {
      if (!v.isInteger())
        throw new TypeError(C1);
      return new o(m).toDecimalPlaces(v.toNumber());
    },
    Complex: function(m) {
      return m.round();
    },
    "Complex, number": function(m, v) {
      if (v % 1)
        throw new TypeError(C1);
      return m.round(v);
    },
    "Complex, BigNumber": function(m, v) {
      if (!v.isInteger())
        throw new TypeError(C1);
      var p = v.toNumber();
      return m.round(p);
    },
    BigNumber: function(m) {
      var v = new o(m).toDecimalPlaces(d(r.relTol)), p = ks(m, v, r.relTol, r.absTol) ? v : m;
      return p.toDecimalPlaces(0);
    },
    "BigNumber, BigNumber": function(m, v) {
      if (!v.isInteger())
        throw new TypeError(C1);
      var p = d(r.relTol);
      if (v >= p)
        return m.toDecimalPlaces(v.toNumber());
      var g = m.toDecimalPlaces(p), h = ks(m, g, r.relTol, r.absTol) ? g : m;
      return h.toDecimalPlaces(v.toNumber());
    },
    Fraction: function(m) {
      return m.round();
    },
    "Fraction, number": function(m, v) {
      if (v % 1)
        throw new TypeError(C1);
      return m.round(v);
    },
    "Fraction, BigNumber": function(m, v) {
      if (!v.isInteger())
        throw new TypeError(C1);
      return m.round(v.toNumber());
    },
    "Unit, number, Unit": t.referToSelf((f) => function(m, v, p) {
      var g = m.toNumeric(p);
      return p.multiply(f(g, v));
    }),
    "Unit, BigNumber, Unit": t.referToSelf((f) => (m, v, p) => f(m, v.toNumber(), p)),
    "Unit, Unit": t.referToSelf((f) => (m, v) => f(m, 0, v)),
    "Array | Matrix, number, Unit": t.referToSelf((f) => (m, v, p) => ua(m, (g) => f(g, v, p))),
    "Array | Matrix, BigNumber, Unit": t.referToSelf((f) => (m, v, p) => f(m, v.toNumber(), p)),
    "Array | Matrix, Unit": t.referToSelf((f) => (m, v) => f(m, 0, v)),
    "Array | Matrix": t.referToSelf((f) => (m) => ua(m, f)),
    "SparseMatrix, number | BigNumber": t.referToSelf((f) => (m, v) => s(m, v, f, !1)),
    "DenseMatrix, number | BigNumber": t.referToSelf((f) => (m, v) => l(m, v, f, !1)),
    "Array, number | BigNumber": t.referToSelf((f) => (m, v) => l(n(m), v, f, !1).valueOf()),
    "number | Complex | BigNumber | Fraction, SparseMatrix": t.referToSelf((f) => (m, v) => i(m, 0) ? a(v.size(), v.storage()) : c(v, m, f, !0)),
    "number | Complex | BigNumber | Fraction, DenseMatrix": t.referToSelf((f) => (m, v) => i(m, 0) ? a(v.size(), v.storage()) : l(v, m, f, !0)),
    "number | Complex | BigNumber | Fraction, Array": t.referToSelf((f) => (m, v) => l(n(v), m, f, !0).valueOf())
  });
});
function ZN(e) {
  var {
    DenseMatrix: t
  } = e;
  return function(n, i, a) {
    var o = n.size();
    if (o.length !== 2)
      throw new RangeError("Matrix must be two dimensional (size: " + kn(o) + ")");
    var u = o[0], s = o[1];
    if (u !== s)
      throw new RangeError("Matrix must be square (size: " + kn(o) + ")");
    var c = [];
    if (Nn(i)) {
      var l = i.size(), d = i._data;
      if (l.length === 1) {
        if (l[0] !== u)
          throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
        for (var f = 0; f < u; f++)
          c[f] = [d[f]];
        return new t({
          data: c,
          size: [u, 1],
          datatype: i._datatype
        });
      }
      if (l.length === 2) {
        if (l[0] !== u || l[1] !== 1)
          throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
        if (iN(i)) {
          if (a) {
            c = [];
            for (var m = 0; m < u; m++)
              c[m] = [d[m][0]];
            return new t({
              data: c,
              size: [u, 1],
              datatype: i._datatype
            });
          }
          return i;
        }
        if (aN(i)) {
          for (var v = 0; v < u; v++)
            c[v] = [0];
          for (var p = i._values, g = i._index, h = i._ptr, y = h[1], x = h[0]; x < y; x++) {
            var A = g[x];
            c[A][0] = p[x];
          }
          return new t({
            data: c,
            size: [u, 1],
            datatype: i._datatype
          });
        }
      }
      throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.");
    }
    if (bn(i)) {
      var b = Fn(i);
      if (b.length === 1) {
        if (b[0] !== u)
          throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
        for (var _ = 0; _ < u; _++)
          c[_] = [i[_]];
        return new t({
          data: c,
          size: [u, 1]
        });
      }
      if (b.length === 2) {
        if (b[0] !== u || b[1] !== 1)
          throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
        for (var S = 0; S < u; S++)
          c[S] = [i[S][0]];
        return new t({
          data: c,
          size: [u, 1]
        });
      }
      throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.");
    }
  };
}
var tE = "usolve", fle = ["typed", "matrix", "divideScalar", "multiplyScalar", "subtractScalar", "equalScalar", "DenseMatrix"], ple = /* @__PURE__ */ gt(tE, fle, (e) => {
  var {
    typed: t,
    matrix: r,
    divideScalar: n,
    multiplyScalar: i,
    subtractScalar: a,
    equalScalar: o,
    DenseMatrix: u
  } = e, s = ZN({
    DenseMatrix: u
  });
  return t(tE, {
    "SparseMatrix, Array | Matrix": function(f, m) {
      return l(f, m);
    },
    "DenseMatrix, Array | Matrix": function(f, m) {
      return c(f, m);
    },
    "Array, Array | Matrix": function(f, m) {
      var v = r(f), p = c(v, m);
      return p.valueOf();
    }
  });
  function c(d, f) {
    f = s(d, f, !0);
    for (var m = f._data, v = d._size[0], p = d._size[1], g = [], h = d._data, y = p - 1; y >= 0; y--) {
      var x = m[y][0] || 0, A = void 0;
      if (o(x, 0))
        A = 0;
      else {
        var b = h[y][y];
        if (o(b, 0))
          throw new Error("Linear system cannot be solved since matrix is singular");
        A = n(x, b);
        for (var _ = y - 1; _ >= 0; _--)
          m[_] = [a(m[_][0] || 0, i(A, h[_][y]))];
      }
      g[y] = [A];
    }
    return new u({
      data: g,
      size: [v, 1]
    });
  }
  function l(d, f) {
    f = s(d, f, !0);
    for (var m = f._data, v = d._size[0], p = d._size[1], g = d._values, h = d._index, y = d._ptr, x = [], A = p - 1; A >= 0; A--) {
      var b = m[A][0] || 0;
      if (o(b, 0))
        x[A] = [0];
      else {
        for (var _ = 0, S = [], D = [], I = y[A], M = y[A + 1], F = M - 1; F >= I; F--) {
          var P = h[F];
          P === A ? _ = g[F] : P < A && (S.push(g[F]), D.push(P));
        }
        if (o(_, 0))
          throw new Error("Linear system cannot be solved since matrix is singular");
        for (var E = n(b, _), B = 0, N = D.length; B < N; B++) {
          var O = D[B];
          m[O] = [a(m[O][0], i(E, S[B]))];
        }
        x[A] = [E];
      }
    }
    return new u({
      data: x,
      size: [v, 1]
    });
  }
}), rE = "usolveAll", mle = ["typed", "matrix", "divideScalar", "multiplyScalar", "subtractScalar", "equalScalar", "DenseMatrix"], hle = /* @__PURE__ */ gt(rE, mle, (e) => {
  var {
    typed: t,
    matrix: r,
    divideScalar: n,
    multiplyScalar: i,
    subtractScalar: a,
    equalScalar: o,
    DenseMatrix: u
  } = e, s = ZN({
    DenseMatrix: u
  });
  return t(rE, {
    "SparseMatrix, Array | Matrix": function(f, m) {
      return l(f, m);
    },
    "DenseMatrix, Array | Matrix": function(f, m) {
      return c(f, m);
    },
    "Array, Array | Matrix": function(f, m) {
      var v = r(f), p = c(v, m);
      return p.map((g) => g.valueOf());
    }
  });
  function c(d, f) {
    for (var m = [s(d, f, !0)._data.map((D) => D[0])], v = d._data, p = d._size[0], g = d._size[1], h = g - 1; h >= 0; h--)
      for (var y = m.length, x = 0; x < y; x++) {
        var A = m[x];
        if (o(v[h][h], 0))
          if (o(A[h], 0)) {
            if (x === 0) {
              var _ = [...A];
              _[h] = 1;
              for (var S = h - 1; S >= 0; S--)
                _[S] = a(_[S], v[S][h]);
              m.push(_);
            }
          } else {
            if (x === 0)
              return [];
            m.splice(x, 1), x -= 1, y -= 1;
          }
        else {
          A[h] = n(A[h], v[h][h]);
          for (var b = h - 1; b >= 0; b--)
            A[b] = a(A[b], i(A[h], v[b][h]));
        }
      }
    return m.map((D) => new u({
      data: D.map((I) => [I]),
      size: [p, 1]
    }));
  }
  function l(d, f) {
    for (var m = [s(d, f, !0)._data.map((K) => K[0])], v = d._size[0], p = d._size[1], g = d._values, h = d._index, y = d._ptr, x = p - 1; x >= 0; x--)
      for (var A = m.length, b = 0; b < A; b++) {
        for (var _ = m[b], S = [], D = [], I = y[x], M = y[x + 1], F = 0, P = M - 1; P >= I; P--) {
          var E = h[P];
          E === x ? F = g[P] : E < x && (S.push(g[P]), D.push(E));
        }
        if (o(F, 0))
          if (o(_[x], 0)) {
            if (b === 0) {
              var z = [..._];
              z[x] = 1;
              for (var V = 0, U = D.length; V < U; V++) {
                var H = D[V];
                z[H] = a(z[H], S[V]);
              }
              m.push(z);
            }
          } else {
            if (b === 0)
              return [];
            m.splice(b, 1), b -= 1, A -= 1;
          }
        else {
          _[x] = n(_[x], F);
          for (var B = 0, N = D.length; B < N; B++) {
            var O = D[B];
            _[O] = a(_[O], i(_[x], S[B]));
          }
        }
      }
    return m.map((K) => new u({
      data: K.map((j) => [j]),
      size: [v, 1]
    }));
  }
}), fg = "equal", vle = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"], gle = /* @__PURE__ */ gt(fg, vle, (e) => {
  var {
    typed: t,
    matrix: r,
    equalScalar: n,
    DenseMatrix: i,
    concat: a
  } = e, o = Mf({
    typed: t
  }), u = km({
    typed: t,
    DenseMatrix: i
  }), s = Uc({
    typed: t,
    DenseMatrix: i
  }), c = pd({
    typed: t,
    matrix: r,
    concat: a
  });
  return t(fg, yle({
    typed: t,
    equalScalar: n
  }), c({
    elop: n,
    SS: u,
    DS: o,
    Ss: s
  }));
}), yle = gt(fg, ["typed", "equalScalar"], (e) => {
  var {
    typed: t,
    equalScalar: r
  } = e;
  return t(fg, {
    "any, any": function(i, a) {
      return i === null ? a === null : a === null ? i === null : i === void 0 ? a === void 0 : a === void 0 ? i === void 0 : r(i, a);
    }
  });
}), pg = "smaller", ble = ["typed", "config", "matrix", "DenseMatrix", "concat"], _le = /* @__PURE__ */ gt(pg, ble, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    DenseMatrix: i,
    concat: a
  } = e, o = Mf({
    typed: t
  }), u = km({
    typed: t,
    DenseMatrix: i
  }), s = Uc({
    typed: t,
    DenseMatrix: i
  }), c = pd({
    typed: t,
    matrix: n,
    concat: a
  }), l = Rm({
    typed: t
  });
  return t(pg, xle({
    typed: t,
    config: r
  }), {
    "boolean, boolean": (d, f) => d < f,
    "BigNumber, BigNumber": function(f, m) {
      return f.lt(m) && !ks(f, m, r.relTol, r.absTol);
    },
    "bigint, bigint": (d, f) => d < f,
    "Fraction, Fraction": (d, f) => d.compare(f) === -1,
    "Complex, Complex": function(f, m) {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, l, c({
    SS: u,
    DS: o,
    Ss: s
  }));
}), xle = /* @__PURE__ */ gt(pg, ["typed", "config"], (e) => {
  var {
    typed: t,
    config: r
  } = e;
  return t(pg, {
    "number, number": function(i, a) {
      return i < a && !Zo(i, a, r.relTol, r.absTol);
    }
  });
}), mg = "smallerEq", Ale = ["typed", "config", "matrix", "DenseMatrix", "concat"], Sle = /* @__PURE__ */ gt(mg, Ale, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    DenseMatrix: i,
    concat: a
  } = e, o = Mf({
    typed: t
  }), u = km({
    typed: t,
    DenseMatrix: i
  }), s = Uc({
    typed: t,
    DenseMatrix: i
  }), c = pd({
    typed: t,
    matrix: n,
    concat: a
  }), l = Rm({
    typed: t
  });
  return t(mg, Cle({
    typed: t,
    config: r
  }), {
    "boolean, boolean": (d, f) => d <= f,
    "BigNumber, BigNumber": function(f, m) {
      return f.lte(m) || ks(f, m, r.relTol, r.absTol);
    },
    "bigint, bigint": (d, f) => d <= f,
    "Fraction, Fraction": (d, f) => d.compare(f) !== 1,
    "Complex, Complex": function() {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, l, c({
    SS: u,
    DS: o,
    Ss: s
  }));
}), Cle = /* @__PURE__ */ gt(mg, ["typed", "config"], (e) => {
  var {
    typed: t,
    config: r
  } = e;
  return t(mg, {
    "number, number": function(i, a) {
      return i <= a || Zo(i, a, r.relTol, r.absTol);
    }
  });
}), hg = "larger", wle = ["typed", "config", "matrix", "DenseMatrix", "concat"], Dle = /* @__PURE__ */ gt(hg, wle, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    DenseMatrix: i,
    concat: a
  } = e, o = Mf({
    typed: t
  }), u = km({
    typed: t,
    DenseMatrix: i
  }), s = Uc({
    typed: t,
    DenseMatrix: i
  }), c = pd({
    typed: t,
    matrix: n,
    concat: a
  }), l = Rm({
    typed: t
  });
  return t(hg, Ile({
    typed: t,
    config: r
  }), {
    "boolean, boolean": (d, f) => d > f,
    "BigNumber, BigNumber": function(f, m) {
      return f.gt(m) && !ks(f, m, r.relTol, r.absTol);
    },
    "bigint, bigint": (d, f) => d > f,
    "Fraction, Fraction": (d, f) => d.compare(f) === 1,
    "Complex, Complex": function() {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, l, c({
    SS: u,
    DS: o,
    Ss: s
  }));
}), Ile = /* @__PURE__ */ gt(hg, ["typed", "config"], (e) => {
  var {
    typed: t,
    config: r
  } = e;
  return t(hg, {
    "number, number": function(i, a) {
      return i > a && !Zo(i, a, r.relTol, r.absTol);
    }
  });
}), vg = "largerEq", Ele = ["typed", "config", "matrix", "DenseMatrix", "concat"], Mle = /* @__PURE__ */ gt(vg, Ele, (e) => {
  var {
    typed: t,
    config: r,
    matrix: n,
    DenseMatrix: i,
    concat: a
  } = e, o = Mf({
    typed: t
  }), u = km({
    typed: t,
    DenseMatrix: i
  }), s = Uc({
    typed: t,
    DenseMatrix: i
  }), c = pd({
    typed: t,
    matrix: n,
    concat: a
  }), l = Rm({
    typed: t
  });
  return t(vg, Tle({
    typed: t,
    config: r
  }), {
    "boolean, boolean": (d, f) => d >= f,
    "BigNumber, BigNumber": function(f, m) {
      return f.gte(m) || ks(f, m, r.relTol, r.absTol);
    },
    "bigint, bigint": function(f, m) {
      return f >= m;
    },
    "Fraction, Fraction": (d, f) => d.compare(f) !== -1,
    "Complex, Complex": function() {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, l, c({
    SS: u,
    DS: o,
    Ss: s
  }));
}), Tle = /* @__PURE__ */ gt(vg, ["typed", "config"], (e) => {
  var {
    typed: t,
    config: r
  } = e;
  return t(vg, {
    "number, number": function(i, a) {
      return i >= a || Zo(i, a, r.relTol, r.absTol);
    }
  });
}), Ple = "ImmutableDenseMatrix", Ble = ["smaller", "DenseMatrix"], Fle = /* @__PURE__ */ gt(Ple, Ble, (e) => {
  var {
    smaller: t,
    DenseMatrix: r
  } = e;
  function n(i, a) {
    if (!(this instanceof n))
      throw new SyntaxError("Constructor must be called with the new operator");
    if (a && !Yu(a))
      throw new Error("Invalid datatype: " + a);
    if (Nn(i) || bn(i)) {
      var o = new r(i, a);
      this._data = o._data, this._size = o._size, this._datatype = o._datatype, this._min = null, this._max = null;
    } else if (i && bn(i.data) && bn(i.size))
      this._data = i.data, this._size = i.size, this._datatype = i.datatype, this._min = typeof i.min < "u" ? i.min : null, this._max = typeof i.max < "u" ? i.max : null;
    else {
      if (i)
        throw new TypeError("Unsupported type of data (" + Ic(i) + ")");
      this._data = [], this._size = [0], this._datatype = a, this._min = null, this._max = null;
    }
  }
  return n.prototype = new r(), n.prototype.type = "ImmutableDenseMatrix", n.prototype.isImmutableDenseMatrix = !0, n.prototype.subset = function(i) {
    switch (arguments.length) {
      case 1: {
        var a = r.prototype.subset.call(this, i);
        return Nn(a) ? new n({
          data: a._data,
          size: a._size,
          datatype: a._datatype
        }) : a;
      }
      case 2:
      case 3:
        throw new Error("Cannot invoke set subset on an Immutable Matrix instance");
      default:
        throw new SyntaxError("Wrong number of arguments");
    }
  }, n.prototype.set = function() {
    throw new Error("Cannot invoke set on an Immutable Matrix instance");
  }, n.prototype.resize = function() {
    throw new Error("Cannot invoke resize on an Immutable Matrix instance");
  }, n.prototype.reshape = function() {
    throw new Error("Cannot invoke reshape on an Immutable Matrix instance");
  }, n.prototype.clone = function() {
    return new n({
      data: Wr(this._data),
      size: Wr(this._size),
      datatype: this._datatype
    });
  }, n.prototype.toJSON = function() {
    return {
      mathjs: "ImmutableDenseMatrix",
      data: this._data,
      size: this._size,
      datatype: this._datatype
    };
  }, n.fromJSON = function(i) {
    return new n(i);
  }, n.prototype.swapRows = function() {
    throw new Error("Cannot invoke swapRows on an Immutable Matrix instance");
  }, n.prototype.min = function() {
    if (this._min === null) {
      var i = null;
      this.forEach(function(a) {
        (i === null || t(a, i)) && (i = a);
      }), this._min = i !== null ? i : void 0;
    }
    return this._min;
  }, n.prototype.max = function() {
    if (this._max === null) {
      var i = null;
      this.forEach(function(a) {
        (i === null || t(i, a)) && (i = a);
      }), this._max = i !== null ? i : void 0;
    }
    return this._max;
  }, n;
}, {
  isClass: !0
}), Nle = "Index", Rle = ["ImmutableDenseMatrix", "getMatrixDataType"], Ole = /* @__PURE__ */ gt(Nle, Rle, (e) => {
  var {
    ImmutableDenseMatrix: t,
    getMatrixDataType: r
  } = e;
  function n(a) {
    if (!(this instanceof n))
      throw new SyntaxError("Constructor must be called with the new operator");
    this._dimensions = [], this._sourceSize = [], this._isScalar = !0;
    for (var o = 0, u = arguments.length; o < u; o++) {
      var s = arguments[o], c = bn(s), l = Nn(s), d = null;
      if (oN(s))
        this._dimensions.push(s), this._isScalar = !1;
      else if (c || l) {
        var f = void 0;
        r(s) === "boolean" ? (c && (f = i(nE(s).valueOf())), l && (f = i(nE(s._data).valueOf())), d = s.valueOf().length) : f = i(s.valueOf()), this._dimensions.push(f);
        var m = f.size();
        (m.length !== 1 || m[0] !== 1 || d !== null) && (this._isScalar = !1);
      } else if (typeof s == "number")
        this._dimensions.push(i([s]));
      else if (typeof s == "string")
        this._dimensions.push(s);
      else
        throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");
      this._sourceSize.push(d);
    }
  }
  n.prototype.type = "Index", n.prototype.isIndex = !0;
  function i(a) {
    for (var o = 0, u = a.length; o < u; o++)
      if (typeof a[o] != "number" || !Mn(a[o]))
        throw new TypeError("Index parameters must be positive integer numbers");
    return new t(a);
  }
  return n.prototype.clone = function() {
    var a = new n();
    return a._dimensions = Wr(this._dimensions), a._isScalar = this._isScalar, a._sourceSize = this._sourceSize, a;
  }, n.create = function(a) {
    var o = new n();
    return n.apply(o, a), o;
  }, n.prototype.size = function() {
    for (var a = [], o = 0, u = this._dimensions.length; o < u; o++) {
      var s = this._dimensions[o];
      a[o] = typeof s == "string" ? 1 : s.size()[0];
    }
    return a;
  }, n.prototype.max = function() {
    for (var a = [], o = 0, u = this._dimensions.length; o < u; o++) {
      var s = this._dimensions[o];
      a[o] = typeof s == "string" ? s : s.max();
    }
    return a;
  }, n.prototype.min = function() {
    for (var a = [], o = 0, u = this._dimensions.length; o < u; o++) {
      var s = this._dimensions[o];
      a[o] = typeof s == "string" ? s : s.min();
    }
    return a;
  }, n.prototype.forEach = function(a) {
    for (var o = 0, u = this._dimensions.length; o < u; o++)
      a(this._dimensions[o], o, this);
  }, n.prototype.dimension = function(a) {
    return this._dimensions[a] || null;
  }, n.prototype.isObjectProperty = function() {
    return this._dimensions.length === 1 && typeof this._dimensions[0] == "string";
  }, n.prototype.getObjectProperty = function() {
    return this.isObjectProperty() ? this._dimensions[0] : null;
  }, n.prototype.isScalar = function() {
    return this._isScalar;
  }, n.prototype.toArray = function() {
    for (var a = [], o = 0, u = this._dimensions.length; o < u; o++) {
      var s = this._dimensions[o];
      a.push(typeof s == "string" ? s : s.toArray());
    }
    return a;
  }, n.prototype.valueOf = n.prototype.toArray, n.prototype.toString = function() {
    for (var a = [], o = 0, u = this._dimensions.length; o < u; o++) {
      var s = this._dimensions[o];
      typeof s == "string" ? a.push(JSON.stringify(s)) : a.push(s.toString());
    }
    return "[" + a.join(", ") + "]";
  }, n.prototype.toJSON = function() {
    return {
      mathjs: "Index",
      dimensions: this._dimensions
    };
  }, n.fromJSON = function(a) {
    return n.create(a.dimensions);
  }, n;
}, {
  isClass: !0
});
function nE(e) {
  var t = [];
  return e.forEach((r, n) => {
    r && t.push(n);
  }), t;
}
t3(function(e) {
  return new e(1).exp();
}, {
  hasher: n3
});
t3(function(e) {
  return new e(1).plus(new e(5).sqrt()).div(2);
}, {
  hasher: n3
});
var QN = t3(function(e) {
  return e.acos(-1);
}, {
  hasher: n3
});
t3(function(e) {
  return QN(e).times(2);
}, {
  hasher: n3
});
function n3(e) {
  return e[0].precision;
}
var Lle = "atan", kle = ["typed"], zle = /* @__PURE__ */ gt(Lle, kle, (e) => {
  var {
    typed: t
  } = e;
  return t("atan", {
    number: function(n) {
      return Math.atan(n);
    },
    Complex: function(n) {
      return n.atan();
    },
    BigNumber: function(n) {
      return n.atan();
    }
  });
}), JN = /* @__PURE__ */ gt("trigUnit", ["typed"], (e) => {
  var {
    typed: t
  } = e;
  return {
    Unit: t.referToSelf((r) => (n) => {
      if (!n.hasBase(n.constructor.BASE_UNITS.ANGLE))
        throw new TypeError("Unit in function cot is no angle");
      return t.find(r, n.valueType())(n.value);
    })
  };
}), iE = "cos", Gle = ["typed"], Vle = /* @__PURE__ */ gt(iE, Gle, (e) => {
  var {
    typed: t
  } = e, r = JN({
    typed: t
  });
  return t(iE, {
    number: Math.cos,
    "Complex | BigNumber": (n) => n.cos()
  }, r);
}), aE = "sin", Ule = ["typed"], Hle = /* @__PURE__ */ gt(aE, Ule, (e) => {
  var {
    typed: t
  } = e, r = JN({
    typed: t
  });
  return t(aE, {
    number: Math.sin,
    "Complex | BigNumber": (n) => n.sin()
  }, r);
}), oE = "add", qle = ["typed", "matrix", "addScalar", "equalScalar", "DenseMatrix", "SparseMatrix", "concat"], Kle = /* @__PURE__ */ gt(oE, qle, (e) => {
  var {
    typed: t,
    matrix: r,
    addScalar: n,
    equalScalar: i,
    DenseMatrix: a,
    SparseMatrix: o,
    concat: u
  } = e, s = XN({
    typed: t
  }), c = uce({
    typed: t,
    equalScalar: i
  }), l = jN({
    typed: t,
    DenseMatrix: a
  }), d = pd({
    typed: t,
    matrix: r,
    concat: u
  });
  return t(oE, {
    "any, any": n,
    "any, any, ...any": t.referToSelf((f) => (m, v, p) => {
      for (var g = f(m, v), h = 0; h < p.length; h++)
        g = f(g, p[h]);
      return g;
    })
  }, d({
    elop: n,
    DS: s,
    SS: c,
    Ss: l
  }));
}), uE = "norm", Xle = ["typed", "abs", "add", "pow", "conj", "sqrt", "multiply", "equalScalar", "larger", "smaller", "matrix", "ctranspose", "eigs"], jle = /* @__PURE__ */ gt(uE, Xle, (e) => {
  var {
    typed: t,
    abs: r,
    add: n,
    pow: i,
    conj: a,
    sqrt: o,
    multiply: u,
    equalScalar: s,
    larger: c,
    smaller: l,
    matrix: d,
    ctranspose: f,
    eigs: m
  } = e;
  return t(uE, {
    number: Math.abs,
    Complex: function(D) {
      return D.abs();
    },
    BigNumber: function(D) {
      return D.abs();
    },
    boolean: function(D) {
      return Math.abs(D);
    },
    Array: function(D) {
      return _(d(D), 2);
    },
    Matrix: function(D) {
      return _(D, 2);
    },
    "Array, number | BigNumber | string": function(D, I) {
      return _(d(D), I);
    },
    "Matrix, number | BigNumber | string": function(D, I) {
      return _(D, I);
    }
  });
  function v(S) {
    var D = 0;
    return S.forEach(function(I) {
      var M = r(I);
      c(M, D) && (D = M);
    }, !0), D;
  }
  function p(S) {
    var D;
    return S.forEach(function(I) {
      var M = r(I);
      (!D || l(M, D)) && (D = M);
    }, !0), D || 0;
  }
  function g(S, D) {
    if (D === Number.POSITIVE_INFINITY || D === "inf")
      return v(S);
    if (D === Number.NEGATIVE_INFINITY || D === "-inf")
      return p(S);
    if (D === "fro")
      return _(S, 2);
    if (typeof D == "number" && !isNaN(D)) {
      if (!s(D, 0)) {
        var I = 0;
        return S.forEach(function(M) {
          I = n(i(r(M), D), I);
        }, !0), i(I, 1 / D);
      }
      return Number.POSITIVE_INFINITY;
    }
    throw new Error("Unsupported parameter value");
  }
  function h(S) {
    var D = 0;
    return S.forEach(function(I, M) {
      D = n(D, u(I, a(I)));
    }), r(o(D));
  }
  function y(S) {
    var D = [], I = 0;
    return S.forEach(function(M, F) {
      var P = F[1], E = n(D[P] || 0, r(M));
      c(E, I) && (I = E), D[P] = E;
    }, !0), I;
  }
  function x(S) {
    var D = S.size();
    if (D[0] !== D[1])
      throw new RangeError("Invalid matrix dimensions");
    var I = f(S), M = u(I, S), F = m(M).values.toArray(), P = F[F.length - 1];
    return r(o(P));
  }
  function A(S) {
    var D = [], I = 0;
    return S.forEach(function(M, F) {
      var P = F[0], E = n(D[P] || 0, r(M));
      c(E, I) && (I = E), D[P] = E;
    }, !0), I;
  }
  function b(S, D) {
    if (D === 1)
      return y(S);
    if (D === Number.POSITIVE_INFINITY || D === "inf")
      return A(S);
    if (D === "fro")
      return h(S);
    if (D === 2)
      return x(S);
    throw new Error("Unsupported parameter value " + D);
  }
  function _(S, D) {
    var I = S.size();
    if (I.length === 1)
      return g(S, D);
    if (I.length === 2) {
      if (I[0] && I[1])
        return b(S, D);
      throw new RangeError("Invalid matrix dimensions");
    }
  }
}), sE = "dot", Yle = ["typed", "addScalar", "multiplyScalar", "conj", "size"], Wle = /* @__PURE__ */ gt(sE, Yle, (e) => {
  var {
    typed: t,
    addScalar: r,
    multiplyScalar: n,
    conj: i,
    size: a
  } = e;
  return t(sE, {
    "Array | DenseMatrix, Array | DenseMatrix": u,
    "SparseMatrix, SparseMatrix": s
  });
  function o(l, d) {
    var f = c(l), m = c(d), v, p;
    if (f.length === 1)
      v = f[0];
    else if (f.length === 2 && f[1] === 1)
      v = f[0];
    else
      throw new RangeError("Expected a column vector, instead got a matrix of size (" + f.join(", ") + ")");
    if (m.length === 1)
      p = m[0];
    else if (m.length === 2 && m[1] === 1)
      p = m[0];
    else
      throw new RangeError("Expected a column vector, instead got a matrix of size (" + m.join(", ") + ")");
    if (v !== p) throw new RangeError("Vectors must have equal length (" + v + " != " + p + ")");
    if (v === 0) throw new RangeError("Cannot calculate the dot product of empty vectors");
    return v;
  }
  function u(l, d) {
    var f = o(l, d), m = Nn(l) ? l._data : l, v = Nn(l) ? l._datatype || l.getDataType() : void 0, p = Nn(d) ? d._data : d, g = Nn(d) ? d._datatype || d.getDataType() : void 0, h = c(l).length === 2, y = c(d).length === 2, x = r, A = n;
    if (v && g && v === g && typeof v == "string" && v !== "mixed") {
      var b = v;
      x = t.find(r, [b, b]), A = t.find(n, [b, b]);
    }
    if (!h && !y) {
      for (var _ = A(i(m[0]), p[0]), S = 1; S < f; S++)
        _ = x(_, A(i(m[S]), p[S]));
      return _;
    }
    if (!h && y) {
      for (var D = A(i(m[0]), p[0][0]), I = 1; I < f; I++)
        D = x(D, A(i(m[I]), p[I][0]));
      return D;
    }
    if (h && !y) {
      for (var M = A(i(m[0][0]), p[0]), F = 1; F < f; F++)
        M = x(M, A(i(m[F][0]), p[F]));
      return M;
    }
    if (h && y) {
      for (var P = A(i(m[0][0]), p[0][0]), E = 1; E < f; E++)
        P = x(P, A(i(m[E][0]), p[E][0]));
      return P;
    }
  }
  function s(l, d) {
    o(l, d);
    for (var f = l._index, m = l._values, v = d._index, p = d._values, g = 0, h = r, y = n, x = 0, A = 0; x < f.length && A < v.length; ) {
      var b = f[x], _ = v[A];
      if (b < _) {
        x++;
        continue;
      }
      if (b > _) {
        A++;
        continue;
      }
      b === _ && (g = h(g, y(m[x], p[A])), x++, A++);
    }
    return g;
  }
  function c(l) {
    return Nn(l) ? l.size() : a(l);
  }
}), cE = "qr", Zle = ["typed", "matrix", "zeros", "identity", "isZero", "equal", "sign", "sqrt", "conj", "unaryMinus", "addScalar", "divideScalar", "multiplyScalar", "subtractScalar", "complex"], Qle = /* @__PURE__ */ gt(cE, Zle, (e) => {
  var {
    typed: t,
    matrix: r,
    zeros: n,
    identity: i,
    isZero: a,
    equal: o,
    sign: u,
    sqrt: s,
    conj: c,
    unaryMinus: l,
    addScalar: d,
    divideScalar: f,
    multiplyScalar: m,
    subtractScalar: v,
    complex: p
  } = e;
  return p0(t(cE, {
    DenseMatrix: function(A) {
      return h(A);
    },
    SparseMatrix: function(A) {
      return y();
    },
    Array: function(A) {
      var b = r(A), _ = h(b);
      return {
        Q: _.Q.valueOf(),
        R: _.R.valueOf()
      };
    }
  }), {
    _denseQRimpl: g
  });
  function g(x) {
    var A = x._size[0], b = x._size[1], _ = i([A], "dense"), S = _._data, D = x.clone(), I = D._data, M, F, P, E = n([A], "");
    for (P = 0; P < Math.min(b, A); ++P) {
      var B = I[P][P], N = l(o(B, 0) ? 1 : u(B)), O = c(N), z = 0;
      for (M = P; M < A; M++)
        z = d(z, m(I[M][P], c(I[M][P])));
      var V = m(N, s(z));
      if (!a(V)) {
        var U = v(B, V);
        for (E[P] = 1, M = P + 1; M < A; M++)
          E[M] = f(I[M][P], U);
        var H = l(c(f(U, V))), K = void 0;
        for (F = P; F < b; F++) {
          for (K = 0, M = P; M < A; M++)
            K = d(K, m(c(E[M]), I[M][F]));
          for (K = m(K, H), M = P; M < A; M++)
            I[M][F] = m(v(I[M][F], m(E[M], K)), O);
        }
        for (M = 0; M < A; M++) {
          for (K = 0, F = P; F < A; F++)
            K = d(K, m(S[M][F], E[F]));
          for (K = m(K, H), F = P; F < A; ++F)
            S[M][F] = f(v(S[M][F], m(K, c(E[F]))), O);
        }
      }
    }
    return {
      Q: _,
      R: D,
      toString: function() {
        return "Q: " + this.Q.toString() + `
R: ` + this.R.toString();
      }
    };
  }
  function h(x) {
    var A = g(x), b = A.R._data;
    if (x._data.length > 0)
      for (var _ = b[0][0].type === "Complex" ? p(0) : 0, S = 0; S < b.length; ++S)
        for (var D = 0; D < S && D < (b[0] || []).length; ++D)
          b[S][D] = _;
    return A;
  }
  function y(x) {
    throw new Error("qr not implemented for sparse matrices yet");
  }
}), lE = "det", Jle = ["typed", "matrix", "subtractScalar", "multiply", "divideScalar", "isZero", "unaryMinus"], $le = /* @__PURE__ */ gt(lE, Jle, (e) => {
  var {
    typed: t,
    matrix: r,
    subtractScalar: n,
    multiply: i,
    divideScalar: a,
    isZero: o,
    unaryMinus: u
  } = e;
  return t(lE, {
    any: function(l) {
      return Wr(l);
    },
    "Array | Matrix": function(l) {
      var d;
      switch (Nn(l) ? d = l.size() : Array.isArray(l) ? (l = r(l), d = l.size()) : d = [], d.length) {
        case 0:
          return Wr(l);
        case 1:
          if (d[0] === 1)
            return Wr(l.valueOf()[0]);
          if (d[0] === 0)
            return 1;
          throw new RangeError("Matrix must be square (size: " + kn(d) + ")");
        case 2: {
          var f = d[0], m = d[1];
          if (f === m)
            return s(l.clone().valueOf(), f);
          if (m === 0)
            return 1;
          throw new RangeError("Matrix must be square (size: " + kn(d) + ")");
        }
        default:
          throw new RangeError("Matrix must be two dimensional (size: " + kn(d) + ")");
      }
    }
  });
  function s(c, l, d) {
    if (l === 1)
      return Wr(c[0][0]);
    if (l === 2)
      return n(i(c[0][0], c[1][1]), i(c[1][0], c[0][1]));
    for (var f = !1, m = new Array(l).fill(0).map((S, D) => D), v = 0; v < l; v++) {
      var p = m[v];
      if (o(c[p][v])) {
        var g = void 0;
        for (g = v + 1; g < l; g++)
          if (!o(c[m[g]][v])) {
            p = m[g], m[g] = m[v], m[v] = p, f = !f;
            break;
          }
        if (g === l) return c[p][v];
      }
      for (var h = c[p][v], y = v === 0 ? 1 : c[m[v - 1]][v - 1], x = v + 1; x < l; x++)
        for (var A = m[x], b = v + 1; b < l; b++)
          c[A][b] = a(n(i(c[A][b], h), i(c[A][v], c[p][b])), y);
    }
    var _ = c[m[l - 1]][l - 1];
    return f ? u(_) : _;
  }
}), dE = "inv", ede = ["typed", "matrix", "divideScalar", "addScalar", "multiply", "unaryMinus", "det", "identity", "abs"], tde = /* @__PURE__ */ gt(dE, ede, (e) => {
  var {
    typed: t,
    matrix: r,
    divideScalar: n,
    addScalar: i,
    multiply: a,
    unaryMinus: o,
    det: u,
    identity: s,
    abs: c
  } = e;
  return t(dE, {
    "Array | Matrix": function(f) {
      var m = Nn(f) ? f.size() : Fn(f);
      switch (m.length) {
        case 1:
          if (m[0] === 1)
            return Nn(f) ? r([n(1, f.valueOf()[0])]) : [n(1, f[0])];
          throw new RangeError("Matrix must be square (size: " + kn(m) + ")");
        case 2: {
          var v = m[0], p = m[1];
          if (v === p)
            return Nn(f) ? r(l(f.valueOf(), v, p), f.storage()) : l(f, v, p);
          throw new RangeError("Matrix must be square (size: " + kn(m) + ")");
        }
        default:
          throw new RangeError("Matrix must be two dimensional (size: " + kn(m) + ")");
      }
    },
    any: function(f) {
      return n(1, f);
    }
  });
  function l(d, f, m) {
    var v, p, g, h, y;
    if (f === 1) {
      if (h = d[0][0], h === 0)
        throw Error("Cannot calculate inverse, determinant is zero");
      return [[n(1, h)]];
    } else if (f === 2) {
      var x = u(d);
      if (x === 0)
        throw Error("Cannot calculate inverse, determinant is zero");
      return [[n(d[1][1], x), n(o(d[0][1]), x)], [n(o(d[1][0]), x), n(d[0][0], x)]];
    } else {
      var A = d.concat();
      for (v = 0; v < f; v++)
        A[v] = A[v].concat();
      for (var b = s(f).valueOf(), _ = 0; _ < m; _++) {
        var S = c(A[_][_]), D = _;
        for (v = _ + 1; v < f; )
          c(A[v][_]) > S && (S = c(A[v][_]), D = v), v++;
        if (S === 0)
          throw Error("Cannot calculate inverse, determinant is zero");
        v = D, v !== _ && (y = A[_], A[_] = A[v], A[v] = y, y = b[_], b[_] = b[v], b[v] = y);
        var I = A[_], M = b[_];
        for (v = 0; v < f; v++) {
          var F = A[v], P = b[v];
          if (v !== _) {
            if (F[_] !== 0) {
              for (g = n(o(F[_]), I[_]), p = _; p < m; p++)
                F[p] = i(F[p], a(g, I[p]));
              for (p = 0; p < m; p++)
                P[p] = i(P[p], a(g, M[p]));
            }
          } else {
            for (g = I[_], p = _; p < m; p++)
              F[p] = n(F[p], g);
            for (p = 0; p < m; p++)
              P[p] = n(P[p], g);
          }
        }
      }
      return b;
    }
  }
});
function rde(e) {
  var {
    addScalar: t,
    subtract: r,
    flatten: n,
    multiply: i,
    multiplyScalar: a,
    divideScalar: o,
    sqrt: u,
    abs: s,
    bignumber: c,
    diag: l,
    size: d,
    reshape: f,
    inv: m,
    qr: v,
    usolve: p,
    usolveAll: g,
    equal: h,
    complex: y,
    larger: x,
    smaller: A,
    matrixFromColumns: b,
    dot: _
  } = e;
  function S(j, X, W, Q) {
    var te = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, ee = D(j, X, W, Q, te);
    I(j, X, W, Q, te, ee);
    var {
      values: $,
      C: ie
    } = M(j, X, W, Q, te);
    if (te) {
      var ae = F(j, X, ie, ee, $, W, Q);
      return {
        values: $,
        eigenvectors: ae
      };
    }
    return {
      values: $
    };
  }
  function D(j, X, W, Q, te) {
    var ee = Q === "BigNumber", $ = Q === "Complex", ie = ee ? c(0) : 0, ae = ee ? c(1) : $ ? y(1) : 1, se = ee ? c(1) : 1, le = ee ? c(10) : 2, pe = a(le, le), we;
    te && (we = Array(X).fill(ae));
    for (var Ge = !1; !Ge; ) {
      Ge = !0;
      for (var Ue = 0; Ue < X; Ue++) {
        for (var Ke = ie, Ze = ie, Fe = 0; Fe < X; Fe++)
          Ue !== Fe && (Ke = t(Ke, s(j[Fe][Ue])), Ze = t(Ze, s(j[Ue][Fe])));
        if (!h(Ke, 0) && !h(Ze, 0)) {
          for (var Je = se, Ne = Ke, nt = o(Ze, le), re = a(Ze, le); A(Ne, nt); )
            Ne = a(Ne, pe), Je = a(Je, le);
          for (; x(Ne, re); )
            Ne = o(Ne, pe), Je = o(Je, le);
          var J = A(o(t(Ne, Ze), Je), a(t(Ke, Ze), 0.95));
          if (J) {
            Ge = !1;
            for (var ce = o(1, Je), de = 0; de < X; de++)
              Ue !== de && (j[Ue][de] = a(j[Ue][de], ce), j[de][Ue] = a(j[de][Ue], Je));
            te && (we[Ue] = a(we[Ue], ce));
          }
        }
      }
    }
    return te ? l(we) : null;
  }
  function I(j, X, W, Q, te, ee) {
    var $ = Q === "BigNumber", ie = Q === "Complex", ae = $ ? c(0) : ie ? y(0) : 0;
    $ && (W = c(W));
    for (var se = 0; se < X - 2; se++) {
      for (var le = 0, pe = ae, we = se + 1; we < X; we++) {
        var Ge = j[we][se];
        A(s(pe), s(Ge)) && (pe = Ge, le = we);
      }
      if (!A(s(pe), W)) {
        if (le !== se + 1) {
          var Ue = j[le];
          j[le] = j[se + 1], j[se + 1] = Ue;
          for (var Ke = 0; Ke < X; Ke++) {
            var Ze = j[Ke][le];
            j[Ke][le] = j[Ke][se + 1], j[Ke][se + 1] = Ze;
          }
          if (te) {
            var Fe = ee[le];
            ee[le] = ee[se + 1], ee[se + 1] = Fe;
          }
        }
        for (var Je = se + 2; Je < X; Je++) {
          var Ne = o(j[Je][se], pe);
          if (Ne !== 0) {
            for (var nt = 0; nt < X; nt++)
              j[Je][nt] = r(j[Je][nt], a(Ne, j[se + 1][nt]));
            for (var re = 0; re < X; re++)
              j[re][se + 1] = t(j[re][se + 1], a(Ne, j[re][Je]));
            if (te)
              for (var J = 0; J < X; J++)
                ee[Je][J] = r(ee[Je][J], a(Ne, ee[se + 1][J]));
          }
        }
      }
    }
    return ee;
  }
  function M(j, X, W, Q, te) {
    var ee = Q === "BigNumber", $ = Q === "Complex", ie = ee ? c(1) : $ ? y(1) : 1;
    ee && (W = c(W));
    for (var ae = Wr(j), se = [], le = X, pe = [], we = te ? l(Array(X).fill(ie)) : void 0, Ge = te ? l(Array(le).fill(ie)) : void 0, Ue = 0; Ue <= 100; ) {
      Ue += 1;
      for (var Ke = ae[le - 1][le - 1], Ze = 0; Ze < le; Ze++)
        ae[Ze][Ze] = r(ae[Ze][Ze], Ke);
      var {
        Q: Fe,
        R: Je
      } = v(ae);
      ae = i(Je, Fe);
      for (var Ne = 0; Ne < le; Ne++)
        ae[Ne][Ne] = t(ae[Ne][Ne], Ke);
      if (te && (Ge = i(Ge, Fe)), le === 1 || A(s(ae[le - 1][le - 2]), W)) {
        Ue = 0, se.push(ae[le - 1][le - 1]), te && (pe.unshift([[1]]), B(Ge, X), we = i(we, Ge), le > 1 && (Ge = l(Array(le - 1).fill(ie)))), le -= 1, ae.pop();
        for (var nt = 0; nt < le; nt++)
          ae[nt].pop();
      } else if (le === 2 || A(s(ae[le - 2][le - 3]), W)) {
        Ue = 0;
        var re = P(ae[le - 2][le - 2], ae[le - 2][le - 1], ae[le - 1][le - 2], ae[le - 1][le - 1]);
        se.push(...re), te && (pe.unshift(E(ae[le - 2][le - 2], ae[le - 2][le - 1], ae[le - 1][le - 2], ae[le - 1][le - 1], re[0], re[1], W, Q)), B(Ge, X), we = i(we, Ge), le > 2 && (Ge = l(Array(le - 2).fill(ie)))), le -= 2, ae.pop(), ae.pop();
        for (var J = 0; J < le; J++)
          ae[J].pop(), ae[J].pop();
      }
      if (le === 0)
        break;
    }
    if (se.sort((ve, he) => +r(s(ve), s(he))), Ue > 100) {
      var ce = Error("The eigenvalues failed to converge. Only found these eigenvalues: " + se.join(", "));
      throw ce.values = se, ce.vectors = [], ce;
    }
    var de = te ? i(we, N(pe, X)) : void 0;
    return {
      values: se,
      C: de
    };
  }
  function F(j, X, W, Q, te, ee, $) {
    var ie = m(W), ae = i(ie, j, W), se = $ === "BigNumber", le = $ === "Complex", pe = se ? c(0) : le ? y(0) : 0, we = se ? c(1) : le ? y(1) : 1, Ge = [], Ue = [];
    for (var Ke of te) {
      var Ze = O(Ge, Ke, h);
      Ze === -1 ? (Ge.push(Ke), Ue.push(1)) : Ue[Ze] += 1;
    }
    for (var Fe = [], Je = Ge.length, Ne = Array(X).fill(pe), nt = l(Array(X).fill(we)), re = function() {
      var de = Ge[J], ve = r(ae, i(de, nt)), he = g(ve, Ne);
      for (he.shift(); he.length < Ue[J]; ) {
        var Se = z(ve, X, he, ee, $);
        if (Se === null)
          break;
        he.push(Se);
      }
      var Re = i(m(Q), W);
      he = he.map((Ve) => i(Re, Ve)), Fe.push(...he.map((Ve) => ({
        value: de,
        vector: n(Ve)
      })));
    }, J = 0; J < Je; J++)
      re();
    return Fe;
  }
  function P(j, X, W, Q) {
    var te = t(j, Q), ee = r(a(j, Q), a(X, W)), $ = a(te, 0.5), ie = a(u(r(a(te, te), a(4, ee))), 0.5);
    return [t($, ie), r($, ie)];
  }
  function E(j, X, W, Q, te, ee, $, ie) {
    var ae = ie === "BigNumber", se = ie === "Complex", le = ae ? c(0) : se ? y(0) : 0, pe = ae ? c(1) : se ? y(1) : 1;
    if (A(s(W), $))
      return [[pe, le], [le, pe]];
    if (x(s(r(te, ee)), $))
      return [[r(te, Q), r(ee, Q)], [W, W]];
    var we = r(j, te), Ge = r(Q, te);
    return A(s(X), $) && A(s(Ge), $) ? [[we, pe], [W, le]] : [[X, le], [Ge, pe]];
  }
  function B(j, X) {
    for (var W = 0; W < j.length; W++)
      j[W].push(...Array(X - j[W].length).fill(0));
    for (var Q = j.length; Q < X; Q++)
      j.push(Array(X).fill(0)), j[Q][Q] = 1;
    return j;
  }
  function N(j, X) {
    for (var W = [], Q = 0; Q < X; Q++)
      W[Q] = Array(X).fill(0);
    var te = 0;
    for (var ee of j) {
      for (var $ = ee.length, ie = 0; ie < $; ie++)
        for (var ae = 0; ae < $; ae++)
          W[te + ie][te + ae] = ee[ie][ae];
      te += $;
    }
    return W;
  }
  function O(j, X, W) {
    for (var Q = 0; Q < j.length; Q++)
      if (W(j[Q], X))
        return Q;
    return -1;
  }
  function z(j, X, W, Q, te) {
    for (var ee = te === "BigNumber" ? c(1e3) : 1e3, $, ie = 0; ie < 5; ++ie) {
      $ = V(X, W, te);
      try {
        $ = p(j, $);
      } catch {
        continue;
      }
      if (x(H($), ee))
        break;
    }
    if (ie >= 5)
      return null;
    for (ie = 0; ; ) {
      var ae = p(j, $);
      if (A(H(U($, [ae])), Q))
        break;
      if (++ie >= 10)
        return null;
      $ = K(ae);
    }
    return $;
  }
  function V(j, X, W) {
    var Q = W === "BigNumber", te = W === "Complex", ee = Array(j).fill(0).map(($) => 2 * Math.random() - 1);
    return Q && (ee = ee.map(($) => c($))), te && (ee = ee.map(($) => y($))), ee = U(ee, X), K(ee, W);
  }
  function U(j, X) {
    var W = d(j);
    for (var Q of X)
      Q = f(Q, W), j = r(j, i(o(_(Q, j), _(Q, Q)), Q));
    return j;
  }
  function H(j) {
    return s(u(_(j, j)));
  }
  function K(j, X) {
    var W = X === "BigNumber", Q = X === "Complex", te = W ? c(1) : Q ? y(1) : 1;
    return i(o(te, H(j)), j);
  }
  return S;
}
function nde(e) {
  var {
    config: t,
    addScalar: r,
    subtract: n,
    abs: i,
    atan: a,
    cos: o,
    sin: u,
    multiplyScalar: s,
    inv: c,
    bignumber: l,
    multiply: d,
    add: f
  } = e;
  function m(I, M) {
    var F = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : t.relTol, P = arguments.length > 3 ? arguments[3] : void 0, E = arguments.length > 4 ? arguments[4] : void 0;
    if (P === "number")
      return v(I, F, E);
    if (P === "BigNumber")
      return p(I, F, E);
    throw TypeError("Unsupported data type: " + P);
  }
  function v(I, M, F) {
    var P = I.length, E = Math.abs(M / P), B, N;
    if (F) {
      N = new Array(P);
      for (var O = 0; O < P; O++)
        N[O] = Array(P).fill(0), N[O][O] = 1;
    }
    for (var z = _(I); Math.abs(z[1]) >= Math.abs(E); ) {
      var V = z[0][0], U = z[0][1];
      B = g(I[V][V], I[U][U], I[V][U]), I = b(I, B, V, U), F && (N = y(N, B, V, U)), z = _(I);
    }
    for (var H = Array(P).fill(0), K = 0; K < P; K++)
      H[K] = I[K][K];
    return D(Wr(H), N, F);
  }
  function p(I, M, F) {
    var P = I.length, E = i(M / P), B, N;
    if (F) {
      N = new Array(P);
      for (var O = 0; O < P; O++)
        N[O] = Array(P).fill(0), N[O][O] = 1;
    }
    for (var z = S(I); i(z[1]) >= i(E); ) {
      var V = z[0][0], U = z[0][1];
      B = h(I[V][V], I[U][U], I[V][U]), I = A(I, B, V, U), F && (N = x(N, B, V, U)), z = S(I);
    }
    for (var H = Array(P).fill(0), K = 0; K < P; K++)
      H[K] = I[K][K];
    return D(Wr(H), N, F);
  }
  function g(I, M, F) {
    var P = M - I;
    return Math.abs(P) <= t.relTol ? Math.PI / 4 : 0.5 * Math.atan(2 * F / (M - I));
  }
  function h(I, M, F) {
    var P = n(M, I);
    return i(P) <= t.relTol ? l(-1).acos().div(4) : s(0.5, a(d(2, F, c(P))));
  }
  function y(I, M, F, P) {
    for (var E = I.length, B = Math.cos(M), N = Math.sin(M), O = Array(E).fill(0), z = Array(E).fill(0), V = 0; V < E; V++)
      O[V] = B * I[V][F] - N * I[V][P], z[V] = N * I[V][F] + B * I[V][P];
    for (var U = 0; U < E; U++)
      I[U][F] = O[U], I[U][P] = z[U];
    return I;
  }
  function x(I, M, F, P) {
    for (var E = I.length, B = o(M), N = u(M), O = Array(E).fill(l(0)), z = Array(E).fill(l(0)), V = 0; V < E; V++)
      O[V] = n(s(B, I[V][F]), s(N, I[V][P])), z[V] = r(s(N, I[V][F]), s(B, I[V][P]));
    for (var U = 0; U < E; U++)
      I[U][F] = O[U], I[U][P] = z[U];
    return I;
  }
  function A(I, M, F, P) {
    for (var E = I.length, B = l(o(M)), N = l(u(M)), O = s(B, B), z = s(N, N), V = Array(E).fill(l(0)), U = Array(E).fill(l(0)), H = d(l(2), B, N, I[F][P]), K = r(n(s(O, I[F][F]), H), s(z, I[P][P])), j = f(s(z, I[F][F]), H, s(O, I[P][P])), X = 0; X < E; X++)
      V[X] = n(s(B, I[F][X]), s(N, I[P][X])), U[X] = r(s(N, I[F][X]), s(B, I[P][X]));
    I[F][F] = K, I[P][P] = j, I[F][P] = l(0), I[P][F] = l(0);
    for (var W = 0; W < E; W++)
      W !== F && W !== P && (I[F][W] = V[W], I[W][F] = V[W], I[P][W] = U[W], I[W][P] = U[W]);
    return I;
  }
  function b(I, M, F, P) {
    for (var E = I.length, B = Math.cos(M), N = Math.sin(M), O = B * B, z = N * N, V = Array(E).fill(0), U = Array(E).fill(0), H = O * I[F][F] - 2 * B * N * I[F][P] + z * I[P][P], K = z * I[F][F] + 2 * B * N * I[F][P] + O * I[P][P], j = 0; j < E; j++)
      V[j] = B * I[F][j] - N * I[P][j], U[j] = N * I[F][j] + B * I[P][j];
    I[F][F] = H, I[P][P] = K, I[F][P] = 0, I[P][F] = 0;
    for (var X = 0; X < E; X++)
      X !== F && X !== P && (I[F][X] = V[X], I[X][F] = V[X], I[P][X] = U[X], I[X][P] = U[X]);
    return I;
  }
  function _(I) {
    for (var M = I.length, F = 0, P = [0, 1], E = 0; E < M; E++)
      for (var B = E + 1; B < M; B++)
        Math.abs(F) < Math.abs(I[E][B]) && (F = Math.abs(I[E][B]), P = [E, B]);
    return [P, F];
  }
  function S(I) {
    for (var M = I.length, F = 0, P = [0, 1], E = 0; E < M; E++)
      for (var B = E + 1; B < M; B++)
        i(F) < i(I[E][B]) && (F = i(I[E][B]), P = [E, B]);
    return [P, F];
  }
  function D(I, M, F) {
    var P = I.length, E = Array(P), B;
    if (F) {
      B = Array(P);
      for (var N = 0; N < P; N++)
        B[N] = Array(P);
    }
    for (var O = 0; O < P; O++) {
      for (var z = 0, V = I[0], U = 0; U < I.length; U++)
        i(I[U]) < i(V) && (z = U, V = I[z]);
      if (E[O] = I.splice(z, 1)[0], F)
        for (var H = 0; H < P; H++)
          B[O][H] = M[H][z], M[H].splice(z, 1);
    }
    if (!F) return {
      values: E
    };
    var K = B.map((j, X) => ({
      value: E[X],
      vector: j
    }));
    return {
      values: E,
      eigenvectors: K
    };
  }
  return m;
}
var ide = "eigs", ade = ["config", "typed", "matrix", "addScalar", "equal", "subtract", "abs", "atan", "cos", "sin", "multiplyScalar", "divideScalar", "inv", "bignumber", "multiply", "add", "larger", "column", "flatten", "number", "complex", "sqrt", "diag", "size", "reshape", "qr", "usolve", "usolveAll", "im", "re", "smaller", "matrixFromColumns", "dot"], ode = /* @__PURE__ */ gt(ide, ade, (e) => {
  var {
    config: t,
    typed: r,
    matrix: n,
    addScalar: i,
    subtract: a,
    equal: o,
    abs: u,
    atan: s,
    cos: c,
    sin: l,
    multiplyScalar: d,
    divideScalar: f,
    inv: m,
    bignumber: v,
    multiply: p,
    add: g,
    larger: h,
    column: y,
    flatten: x,
    number: A,
    complex: b,
    sqrt: _,
    diag: S,
    size: D,
    reshape: I,
    qr: M,
    usolve: F,
    usolveAll: P,
    im: E,
    re: B,
    smaller: N,
    matrixFromColumns: O,
    dot: z
  } = e, V = nde({
    config: t,
    addScalar: i,
    subtract: a,
    column: y,
    flatten: x,
    equal: o,
    abs: u,
    atan: s,
    cos: c,
    sin: l,
    multiplyScalar: d,
    inv: m,
    bignumber: v,
    complex: b,
    multiply: p,
    add: g
  }), U = rde({
    config: t,
    addScalar: i,
    subtract: a,
    multiply: p,
    multiplyScalar: d,
    flatten: x,
    divideScalar: f,
    sqrt: _,
    abs: u,
    bignumber: v,
    diag: S,
    size: D,
    reshape: I,
    qr: M,
    inv: m,
    usolve: F,
    usolveAll: P,
    equal: o,
    complex: b,
    larger: h,
    smaller: N,
    matrixFromColumns: O,
    dot: z
  });
  return r("eigs", {
    // The conversion to matrix in the first two implementations,
    // just to convert back to an array right away in
    // computeValuesAndVectors, is unfortunate, and should perhaps be
    // streamlined. It is done because the Matrix object carries some
    // type information about its entries, and so constructing the matrix
    // is a roundabout way of doing type detection.
    Array: function(ee) {
      return H(n(ee));
    },
    "Array, number|BigNumber": function(ee, $) {
      return H(n(ee), {
        precision: $
      });
    },
    "Array, Object"(te, ee) {
      return H(n(te), ee);
    },
    Matrix: function(ee) {
      return H(ee, {
        matricize: !0
      });
    },
    "Matrix, number|BigNumber": function(ee, $) {
      return H(ee, {
        precision: $,
        matricize: !0
      });
    },
    "Matrix, Object": function(ee, $) {
      var ie = {
        matricize: !0
      };
      return p0(ie, $), H(ee, ie);
    }
  });
  function H(te) {
    var ee, $ = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, ie = "eigenvectors" in $ ? $.eigenvectors : !0, ae = (ee = $.precision) !== null && ee !== void 0 ? ee : t.relTol, se = K(te, ae, ie);
    return $.matricize && (se.values = n(se.values), ie && (se.eigenvectors = se.eigenvectors.map((le) => {
      var {
        value: pe,
        vector: we
      } = le;
      return {
        value: pe,
        vector: n(we)
      };
    }))), ie && Object.defineProperty(se, "vectors", {
      enumerable: !1,
      // to make sure that the eigenvectors can still be
      // converted to string.
      get: () => {
        throw new Error("eigs(M).vectors replaced with eigs(M).eigenvectors");
      }
    }), se;
  }
  function K(te, ee, $) {
    var ie = te.toArray(), ae = te.size();
    if (ae.length !== 2 || ae[0] !== ae[1])
      throw new RangeError("Matrix must be square (size: ".concat(kn(ae), ")"));
    var se = ae[0];
    if (X(ie, se, ee) && (W(ie, se), j(ie, se, ee))) {
      var le = Q(te, ie, se);
      return V(ie, se, ee, le, $);
    }
    var pe = Q(te, ie, se);
    return U(ie, se, ee, pe, $);
  }
  function j(te, ee, $) {
    for (var ie = 0; ie < ee; ie++)
      for (var ae = ie; ae < ee; ae++)
        if (h(v(u(a(te[ie][ae], te[ae][ie]))), $))
          return !1;
    return !0;
  }
  function X(te, ee, $) {
    for (var ie = 0; ie < ee; ie++)
      for (var ae = 0; ae < ee; ae++)
        if (h(v(u(E(te[ie][ae]))), $))
          return !1;
    return !0;
  }
  function W(te, ee) {
    for (var $ = 0; $ < ee; $++)
      for (var ie = 0; ie < ee; ie++)
        te[$][ie] = B(te[$][ie]);
  }
  function Q(te, ee, $) {
    var ie = te.datatype();
    if (ie === "number" || ie === "BigNumber" || ie === "Complex")
      return ie;
    for (var ae = !1, se = !1, le = !1, pe = 0; pe < $; pe++)
      for (var we = 0; we < $; we++) {
        var Ge = ee[pe][we];
        if (En(Ge) || g8(Ge))
          ae = !0;
        else if (ti(Ge))
          se = !0;
        else if (v8(Ge))
          le = !0;
        else
          throw TypeError("Unsupported type in Matrix: " + Ic(Ge));
      }
    if (se && le && console.warn("Complex BigNumbers not supported, this operation will lose precission."), le) {
      for (var Ue = 0; Ue < $; Ue++)
        for (var Ke = 0; Ke < $; Ke++)
          ee[Ue][Ke] = b(ee[Ue][Ke]);
      return "Complex";
    }
    if (se) {
      for (var Ze = 0; Ze < $; Ze++)
        for (var Fe = 0; Fe < $; Fe++)
          ee[Ze][Fe] = v(ee[Ze][Fe]);
      return "BigNumber";
    }
    if (ae) {
      for (var Je = 0; Je < $; Je++)
        for (var Ne = 0; Ne < $; Ne++)
          ee[Je][Ne] = A(ee[Je][Ne]);
      return "number";
    } else
      throw TypeError("Matrix contains unsupported types only.");
  }
}), ude = "divide", sde = ["typed", "matrix", "multiply", "equalScalar", "divideScalar", "inv"], cde = /* @__PURE__ */ gt(ude, sde, (e) => {
  var {
    typed: t,
    matrix: r,
    multiply: n,
    equalScalar: i,
    divideScalar: a,
    inv: o
  } = e, u = Om({
    typed: t,
    equalScalar: i
  }), s = Lm({
    typed: t
  });
  return t("divide", uN({
    // we extend the signatures of divideScalar with signatures dealing with matrices
    "Array | Matrix, Array | Matrix": function(l, d) {
      return n(l, o(d));
    },
    "DenseMatrix, any": function(l, d) {
      return s(l, d, a, !1);
    },
    "SparseMatrix, any": function(l, d) {
      return u(l, d, a, !1);
    },
    "Array, any": function(l, d) {
      return s(r(l), d, a, !1).valueOf();
    },
    "any, Array | Matrix": function(l, d) {
      return n(l, o(d));
    }
  }, a.signatures));
}), lde = /* @__PURE__ */ dde("pi", ["config", "?BigNumber"], (e) => {
  var {
    config: t,
    BigNumber: r
  } = e;
  return t.number === "BigNumber" ? QN(r) : Wue;
});
function dde(e, t, r) {
  return gt(e, t, r, {
    recreateOnConfigChange: !0
  });
}
var Tf = /* @__PURE__ */ yue({
  config: sa
}), i3 = /* @__PURE__ */ Sue({}), w8 = /* @__PURE__ */ Pue({}), D8 = /* @__PURE__ */ Nue({}), ka = /* @__PURE__ */ Xue({
  Matrix: D8
}), Kv = /* @__PURE__ */ lde({
  BigNumber: Tf,
  config: sa
}), Lt = /* @__PURE__ */ xoe({
  BigNumber: Tf,
  Complex: i3,
  DenseMatrix: ka,
  Fraction: w8
}), $d = /* @__PURE__ */ Ese({
  typed: Lt
}), C0 = /* @__PURE__ */ Tse({
  typed: Lt
}), fde = /* @__PURE__ */ zle({
  typed: Lt
}), I8 = /* @__PURE__ */ gse({
  Complex: i3,
  typed: Lt
}), a3 = /* @__PURE__ */ wce({
  typed: Lt
}), s2 = /* @__PURE__ */ Vle({
  typed: Lt
}), Ru = /* @__PURE__ */ nse({
  config: sa,
  typed: Lt
}), pde = /* @__PURE__ */ Vce({
  typed: Lt
}), mde = /* @__PURE__ */ Ice({
  typed: Lt
}), $N = /* @__PURE__ */ Yue({
  typed: Lt
}), hde = /* @__PURE__ */ Jue({
  config: sa,
  typed: Lt
}), eR = /* @__PURE__ */ ese({
  equalScalar: Ru,
  typed: Lt
}), w0 = /* @__PURE__ */ fce({
  typed: Lt
}), E8 = /* @__PURE__ */ dse({
  typed: Lt
}), vde = /* @__PURE__ */ Mce({
  typed: Lt
}), gde = /* @__PURE__ */ vce({
  BigNumber: Tf,
  Fraction: w8,
  complex: I8,
  typed: Lt
}), tR = /* @__PURE__ */ Hle({
  typed: Lt
}), o3 = /* @__PURE__ */ ose({
  Matrix: D8,
  equalScalar: Ru,
  typed: Lt
}), zm = /* @__PURE__ */ Bse({
  typed: Lt
}), M8 = /* @__PURE__ */ mse({
  BigNumber: Tf,
  typed: Lt
}), u3 = /* @__PURE__ */ bce({
  Complex: i3,
  config: sa,
  typed: Lt
}), s3 = /* @__PURE__ */ Dse({
  typed: Lt
}), rR = /* @__PURE__ */ _se({
  Fraction: w8,
  typed: Lt
}), Kr = /* @__PURE__ */ Ase({
  DenseMatrix: ka,
  Matrix: D8,
  SparseMatrix: o3,
  typed: Lt
}), yde = /* @__PURE__ */ ale({
  bignumber: M8,
  fraction: rR,
  number: E8
}), bde = /* @__PURE__ */ Yce({
  isInteger: $N,
  matrix: Kr,
  typed: Lt
}), T8 = /* @__PURE__ */ Zce({
  matrix: Kr,
  config: sa,
  typed: Lt
}), nR = /* @__PURE__ */ Jce({
  matrix: Kr,
  typed: Lt
}), P8 = /* @__PURE__ */ rle({
  BigNumber: Tf,
  config: sa,
  matrix: Kr,
  typed: Lt
}), md = /* @__PURE__ */ Pce({
  isInteger: $N,
  matrix: Kr,
  typed: Lt
}), _de = /* @__PURE__ */ ele({
  conj: a3,
  transpose: nR,
  typed: Lt
}), xde = /* @__PURE__ */ Lce({
  DenseMatrix: ka,
  SparseMatrix: o3,
  matrix: Kr,
  typed: Lt
}), Pf = /* @__PURE__ */ ule({
  numeric: yde,
  typed: Lt
}), iR = /* @__PURE__ */ gle({
  DenseMatrix: ka,
  concat: md,
  equalScalar: Ru,
  matrix: Kr,
  typed: Lt
}), aR = /* @__PURE__ */ zce({
  matrix: Kr,
  typed: Lt
}), Gm = /* @__PURE__ */ Hce({
  BigNumber: Tf,
  DenseMatrix: ka,
  SparseMatrix: o3,
  config: sa,
  matrix: Kr,
  typed: Lt
}), Ade = /* @__PURE__ */ Mle({
  DenseMatrix: ka,
  concat: md,
  config: sa,
  matrix: Kr,
  typed: Lt
}), Sde = /* @__PURE__ */ Cse({
  flatten: aR,
  matrix: Kr,
  size: T8,
  typed: Lt
}), Cde = /* @__PURE__ */ Qle({
  addScalar: C0,
  complex: I8,
  conj: a3,
  divideScalar: Pf,
  equal: iR,
  identity: Gm,
  isZero: eR,
  matrix: Kr,
  multiplyScalar: w0,
  sign: gde,
  sqrt: u3,
  subtractScalar: zm,
  typed: Lt,
  unaryMinus: s3,
  zeros: P8
}), wde = /* @__PURE__ */ dle({
  BigNumber: Tf,
  DenseMatrix: ka,
  config: sa,
  equalScalar: Ru,
  matrix: Kr,
  typed: Lt,
  zeros: P8
}), c3 = /* @__PURE__ */ _le({
  DenseMatrix: ka,
  concat: md,
  config: sa,
  matrix: Kr,
  typed: Lt
}), oR = /* @__PURE__ */ xce({
  DenseMatrix: ka,
  concat: md,
  equalScalar: Ru,
  matrix: Kr,
  subtractScalar: zm,
  typed: Lt,
  unaryMinus: s3
}), Dde = /* @__PURE__ */ ple({
  DenseMatrix: ka,
  divideScalar: Pf,
  equalScalar: Ru,
  matrix: Kr,
  multiplyScalar: w0,
  subtractScalar: zm,
  typed: Lt
}), yc = /* @__PURE__ */ Kle({
  DenseMatrix: ka,
  SparseMatrix: o3,
  addScalar: C0,
  concat: md,
  equalScalar: Ru,
  matrix: Kr,
  typed: Lt
}), B8 = /* @__PURE__ */ Wle({
  addScalar: C0,
  conj: a3,
  multiplyScalar: w0,
  size: T8,
  typed: Lt
}), Ide = /* @__PURE__ */ Fle({
  DenseMatrix: ka,
  smaller: c3
}), Ede = /* @__PURE__ */ Ole({
  ImmutableDenseMatrix: Ide,
  getMatrixDataType: pde
}), F8 = /* @__PURE__ */ Dle({
  DenseMatrix: ka,
  concat: md,
  config: sa,
  matrix: Kr,
  typed: Lt
}), Mde = /* @__PURE__ */ rce({
  DenseMatrix: ka,
  concat: md,
  config: sa,
  equalScalar: Ru,
  matrix: Kr,
  round: wde,
  typed: Lt,
  zeros: P8
}), Fu = /* @__PURE__ */ mce({
  addScalar: C0,
  dot: B8,
  equalScalar: Ru,
  matrix: Kr,
  multiplyScalar: w0,
  typed: Lt
}), Tde = /* @__PURE__ */ hle({
  DenseMatrix: ka,
  divideScalar: Pf,
  equalScalar: Ru,
  matrix: Kr,
  multiplyScalar: w0,
  subtractScalar: zm,
  typed: Lt
}), fE = /* @__PURE__ */ Rce({
  matrix: Kr,
  multiply: Fu,
  subtract: oR,
  typed: Lt
}), uR = /* @__PURE__ */ $le({
  divideScalar: Pf,
  isZero: eR,
  matrix: Kr,
  multiply: Fu,
  subtractScalar: zm,
  typed: Lt,
  unaryMinus: s3
}), Pde = /* @__PURE__ */ Sle({
  DenseMatrix: ka,
  concat: md,
  config: sa,
  matrix: Kr,
  typed: Lt
}), Bde = /* @__PURE__ */ Xce({
  bignumber: M8,
  matrix: Kr,
  add: yc,
  config: sa,
  isPositive: hde,
  larger: F8,
  largerEq: Ade,
  smaller: c3,
  smallerEq: Pde,
  typed: Lt
}), Fde = /* @__PURE__ */ Fce({
  Index: Ede,
  matrix: Kr,
  range: Bde,
  typed: Lt
}), l3 = /* @__PURE__ */ tde({
  abs: $d,
  addScalar: C0,
  det: uR,
  divideScalar: Pf,
  identity: Gm,
  matrix: Kr,
  multiply: Fu,
  typed: Lt,
  unaryMinus: s3
}), Nde = /* @__PURE__ */ cle({
  Complex: i3,
  config: sa,
  fraction: rR,
  identity: Gm,
  inv: l3,
  matrix: Kr,
  multiply: Fu,
  number: E8,
  typed: Lt
}), Rde = /* @__PURE__ */ cde({
  divideScalar: Pf,
  equalScalar: Ru,
  inv: l3,
  matrix: Kr,
  multiply: Fu,
  typed: Lt
}), Ode = /* @__PURE__ */ ode({
  abs: $d,
  add: yc,
  addScalar: C0,
  atan: fde,
  bignumber: M8,
  column: Fde,
  complex: I8,
  config: sa,
  cos: s2,
  diag: xde,
  divideScalar: Pf,
  dot: B8,
  equal: iR,
  flatten: aR,
  im: mde,
  inv: l3,
  larger: F8,
  matrix: Kr,
  matrixFromColumns: Sde,
  multiply: Fu,
  multiplyScalar: w0,
  number: E8,
  qr: Cde,
  re: vde,
  reshape: bde,
  sin: tR,
  size: T8,
  smaller: c3,
  sqrt: u3,
  subtract: oR,
  typed: Lt,
  usolve: Dde,
  usolveAll: Tde
}), sR = /* @__PURE__ */ jle({
  abs: $d,
  add: yc,
  conj: a3,
  ctranspose: _de,
  eigs: Ode,
  equalScalar: Ru,
  larger: F8,
  matrix: Kr,
  multiply: Fu,
  pow: Nde,
  smaller: c3,
  sqrt: u3,
  typed: Lt
}), gg = { exports: {} };
/**
 * @license
 * Lodash <https://lodash.com/>
 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
 * Released under MIT license <https://lodash.com/license>
 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
 */
gg.exports;
(function(e, t) {
  (function() {
    var r, n = "4.17.21", i = 200, a = "Unsupported core-js use. Try https://npms.io/search?q=ponyfill.", o = "Expected a function", u = "Invalid `variable` option passed into `_.template`", s = "__lodash_hash_undefined__", c = 500, l = "__lodash_placeholder__", d = 1, f = 2, m = 4, v = 1, p = 2, g = 1, h = 2, y = 4, x = 8, A = 16, b = 32, _ = 64, S = 128, D = 256, I = 512, M = 30, F = "...", P = 800, E = 16, B = 1, N = 2, O = 3, z = 1 / 0, V = 9007199254740991, U = 17976931348623157e292, H = NaN, K = 4294967295, j = K - 1, X = K >>> 1, W = [
      ["ary", S],
      ["bind", g],
      ["bindKey", h],
      ["curry", x],
      ["curryRight", A],
      ["flip", I],
      ["partial", b],
      ["partialRight", _],
      ["rearg", D]
    ], Q = "[object Arguments]", te = "[object Array]", ee = "[object AsyncFunction]", $ = "[object Boolean]", ie = "[object Date]", ae = "[object DOMException]", se = "[object Error]", le = "[object Function]", pe = "[object GeneratorFunction]", we = "[object Map]", Ge = "[object Number]", Ue = "[object Null]", Ke = "[object Object]", Ze = "[object Promise]", Fe = "[object Proxy]", Je = "[object RegExp]", Ne = "[object Set]", nt = "[object String]", re = "[object Symbol]", J = "[object Undefined]", ce = "[object WeakMap]", de = "[object WeakSet]", ve = "[object ArrayBuffer]", he = "[object DataView]", Se = "[object Float32Array]", Re = "[object Float64Array]", Ve = "[object Int8Array]", ze = "[object Int16Array]", mt = "[object Int32Array]", bt = "[object Uint8Array]", Ct = "[object Uint8ClampedArray]", De = "[object Uint16Array]", ut = "[object Uint32Array]", It = /\b__p \+= '';/g, ur = /\b(__p \+=) '' \+/g, nr = /(__e\(.*?\)|\b__t\)) \+\n'';/g, Er = /&(?:amp|lt|gt|quot|#39);/g, dr = /[&<>"']/g, ln = RegExp(Er.source), Gn = RegExp(dr.source), Rn = /<%-([\s\S]+?)%>/g, Cn = /<%([\s\S]+?)%>/g, Jr = /<%=([\s\S]+?)%>/g, ni = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, $r = /^\w*$/, en = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, fi = /[\\^$.*+?()[\]{}|]/g, pi = RegExp(fi.source), za = /^\s+/, wn = /\s/, dn = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, wo = /\{\n\/\* \[wrapped with (.+)\] \*/, Do = /,? & /, io = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g, os = /[()=,{}\[\]\/\s]/, Ga = /\\(\\)?/g, mi = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g, Gs = /\w*$/, Hc = /^[-+]0x[0-9a-f]+$/i, qc = /^0b[01]+$/i, Kc = /^\[object .+?Constructor\]$/, Xc = /^0o[0-7]+$/i, jc = /^(?:0|[1-9]\d*)$/, Bf = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g, Yc = /($^)/, Vs = /['\n\r\u2028\u2029\\]/g, Fr = "\\ud800-\\udfff", Ki = "\\u0300-\\u036f", E0 = "\\ufe20-\\ufe2f", Wc = "\\u20d0-\\u20ff", us = Ki + E0 + Wc, Ff = "\\u2700-\\u27bf", Vm = "a-z\\xdf-\\xf6\\xf8-\\xff", d3 = "\\xac\\xb1\\xd7\\xf7", Io = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", f3 = "\\u2000-\\u206f", p3 = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", Um = "A-Z\\xc0-\\xd6\\xd8-\\xde", Hm = "\\ufe0e\\ufe0f", qm = d3 + Io + f3 + p3, M0 = "['’]", m3 = "[" + Fr + "]", Km = "[" + qm + "]", Nf = "[" + us + "]", Xm = "\\d+", h3 = "[" + Ff + "]", jm = "[" + Vm + "]", Ym = "[^" + Fr + qm + Xm + Ff + Vm + Um + "]", T0 = "\\ud83c[\\udffb-\\udfff]", v3 = "(?:" + Nf + "|" + T0 + ")", Wm = "[^" + Fr + "]", Rf = "(?:\\ud83c[\\udde6-\\uddff]){2}", P0 = "[\\ud800-\\udbff][\\udc00-\\udfff]", Zc = "[" + Um + "]", N8 = "\\u200d", R8 = "(?:" + jm + "|" + Ym + ")", lR = "(?:" + Zc + "|" + Ym + ")", O8 = "(?:" + M0 + "(?:d|ll|m|re|s|t|ve))?", L8 = "(?:" + M0 + "(?:D|LL|M|RE|S|T|VE))?", k8 = v3 + "?", z8 = "[" + Hm + "]?", dR = "(?:" + N8 + "(?:" + [Wm, Rf, P0].join("|") + ")" + z8 + k8 + ")*", fR = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", pR = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", G8 = z8 + k8 + dR, mR = "(?:" + [h3, Rf, P0].join("|") + ")" + G8, hR = "(?:" + [Wm + Nf + "?", Nf, Rf, P0, m3].join("|") + ")", vR = RegExp(M0, "g"), gR = RegExp(Nf, "g"), g3 = RegExp(T0 + "(?=" + T0 + ")|" + hR + G8, "g"), yR = RegExp([
      Zc + "?" + jm + "+" + O8 + "(?=" + [Km, Zc, "$"].join("|") + ")",
      lR + "+" + L8 + "(?=" + [Km, Zc + R8, "$"].join("|") + ")",
      Zc + "?" + R8 + "+" + O8,
      Zc + "+" + L8,
      pR,
      fR,
      Xm,
      mR
    ].join("|"), "g"), bR = RegExp("[" + N8 + Fr + us + Hm + "]"), _R = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/, xR = [
      "Array",
      "Buffer",
      "DataView",
      "Date",
      "Error",
      "Float32Array",
      "Float64Array",
      "Function",
      "Int8Array",
      "Int16Array",
      "Int32Array",
      "Map",
      "Math",
      "Object",
      "Promise",
      "RegExp",
      "Set",
      "String",
      "Symbol",
      "TypeError",
      "Uint8Array",
      "Uint8ClampedArray",
      "Uint16Array",
      "Uint32Array",
      "WeakMap",
      "_",
      "clearTimeout",
      "isFinite",
      "parseInt",
      "setTimeout"
    ], AR = -1, On = {};
    On[Se] = On[Re] = On[Ve] = On[ze] = On[mt] = On[bt] = On[Ct] = On[De] = On[ut] = !0, On[Q] = On[te] = On[ve] = On[$] = On[he] = On[ie] = On[se] = On[le] = On[we] = On[Ge] = On[Ke] = On[Je] = On[Ne] = On[nt] = On[ce] = !1;
    var Pn = {};
    Pn[Q] = Pn[te] = Pn[ve] = Pn[he] = Pn[$] = Pn[ie] = Pn[Se] = Pn[Re] = Pn[Ve] = Pn[ze] = Pn[mt] = Pn[we] = Pn[Ge] = Pn[Ke] = Pn[Je] = Pn[Ne] = Pn[nt] = Pn[re] = Pn[bt] = Pn[Ct] = Pn[De] = Pn[ut] = !0, Pn[se] = Pn[le] = Pn[ce] = !1;
    var SR = {
      // Latin-1 Supplement block.
      À: "A",
      Á: "A",
      Â: "A",
      Ã: "A",
      Ä: "A",
      Å: "A",
      à: "a",
      á: "a",
      â: "a",
      ã: "a",
      ä: "a",
      å: "a",
      Ç: "C",
      ç: "c",
      Ð: "D",
      ð: "d",
      È: "E",
      É: "E",
      Ê: "E",
      Ë: "E",
      è: "e",
      é: "e",
      ê: "e",
      ë: "e",
      Ì: "I",
      Í: "I",
      Î: "I",
      Ï: "I",
      ì: "i",
      í: "i",
      î: "i",
      ï: "i",
      Ñ: "N",
      ñ: "n",
      Ò: "O",
      Ó: "O",
      Ô: "O",
      Õ: "O",
      Ö: "O",
      Ø: "O",
      ò: "o",
      ó: "o",
      ô: "o",
      õ: "o",
      ö: "o",
      ø: "o",
      Ù: "U",
      Ú: "U",
      Û: "U",
      Ü: "U",
      ù: "u",
      ú: "u",
      û: "u",
      ü: "u",
      Ý: "Y",
      ý: "y",
      ÿ: "y",
      Æ: "Ae",
      æ: "ae",
      Þ: "Th",
      þ: "th",
      ß: "ss",
      // Latin Extended-A block.
      Ā: "A",
      Ă: "A",
      Ą: "A",
      ā: "a",
      ă: "a",
      ą: "a",
      Ć: "C",
      Ĉ: "C",
      Ċ: "C",
      Č: "C",
      ć: "c",
      ĉ: "c",
      ċ: "c",
      č: "c",
      Ď: "D",
      Đ: "D",
      ď: "d",
      đ: "d",
      Ē: "E",
      Ĕ: "E",
      Ė: "E",
      Ę: "E",
      Ě: "E",
      ē: "e",
      ĕ: "e",
      ė: "e",
      ę: "e",
      ě: "e",
      Ĝ: "G",
      Ğ: "G",
      Ġ: "G",
      Ģ: "G",
      ĝ: "g",
      ğ: "g",
      ġ: "g",
      ģ: "g",
      Ĥ: "H",
      Ħ: "H",
      ĥ: "h",
      ħ: "h",
      Ĩ: "I",
      Ī: "I",
      Ĭ: "I",
      Į: "I",
      İ: "I",
      ĩ: "i",
      ī: "i",
      ĭ: "i",
      į: "i",
      ı: "i",
      Ĵ: "J",
      ĵ: "j",
      Ķ: "K",
      ķ: "k",
      ĸ: "k",
      Ĺ: "L",
      Ļ: "L",
      Ľ: "L",
      Ŀ: "L",
      Ł: "L",
      ĺ: "l",
      ļ: "l",
      ľ: "l",
      ŀ: "l",
      ł: "l",
      Ń: "N",
      Ņ: "N",
      Ň: "N",
      Ŋ: "N",
      ń: "n",
      ņ: "n",
      ň: "n",
      ŋ: "n",
      Ō: "O",
      Ŏ: "O",
      Ő: "O",
      ō: "o",
      ŏ: "o",
      ő: "o",
      Ŕ: "R",
      Ŗ: "R",
      Ř: "R",
      ŕ: "r",
      ŗ: "r",
      ř: "r",
      Ś: "S",
      Ŝ: "S",
      Ş: "S",
      Š: "S",
      ś: "s",
      ŝ: "s",
      ş: "s",
      š: "s",
      Ţ: "T",
      Ť: "T",
      Ŧ: "T",
      ţ: "t",
      ť: "t",
      ŧ: "t",
      Ũ: "U",
      Ū: "U",
      Ŭ: "U",
      Ů: "U",
      Ű: "U",
      Ų: "U",
      ũ: "u",
      ū: "u",
      ŭ: "u",
      ů: "u",
      ű: "u",
      ų: "u",
      Ŵ: "W",
      ŵ: "w",
      Ŷ: "Y",
      ŷ: "y",
      Ÿ: "Y",
      Ź: "Z",
      Ż: "Z",
      Ž: "Z",
      ź: "z",
      ż: "z",
      ž: "z",
      Ĳ: "IJ",
      ĳ: "ij",
      Œ: "Oe",
      œ: "oe",
      ŉ: "'n",
      ſ: "s"
    }, CR = {
      "&": "&amp;",
      "<": "&lt;",
      ">": "&gt;",
      '"': "&quot;",
      "'": "&#39;"
    }, wR = {
      "&amp;": "&",
      "&lt;": "<",
      "&gt;": ">",
      "&quot;": '"',
      "&#39;": "'"
    }, DR = {
      "\\": "\\",
      "'": "'",
      "\n": "n",
      "\r": "r",
      "\u2028": "u2028",
      "\u2029": "u2029"
    }, IR = parseFloat, ER = parseInt, V8 = typeof _p == "object" && _p && _p.Object === Object && _p, MR = typeof self == "object" && self && self.Object === Object && self, ca = V8 || MR || Function("return this")(), y3 = t && !t.nodeType && t, hd = y3 && !0 && e && !e.nodeType && e, U8 = hd && hd.exports === y3, b3 = U8 && V8.process, Jo = function() {
      try {
        var Ee = hd && hd.require && hd.require("util").types;
        return Ee || b3 && b3.binding && b3.binding("util");
      } catch {
      }
    }(), H8 = Jo && Jo.isArrayBuffer, q8 = Jo && Jo.isDate, K8 = Jo && Jo.isMap, X8 = Jo && Jo.isRegExp, j8 = Jo && Jo.isSet, Y8 = Jo && Jo.isTypedArray;
    function Eo(Ee, $e, je) {
      switch (je.length) {
        case 0:
          return Ee.call($e);
        case 1:
          return Ee.call($e, je[0]);
        case 2:
          return Ee.call($e, je[0], je[1]);
        case 3:
          return Ee.call($e, je[0], je[1], je[2]);
      }
      return Ee.apply($e, je);
    }
    function TR(Ee, $e, je, Tt) {
      for (var hr = -1, tn = Ee == null ? 0 : Ee.length; ++hr < tn; ) {
        var Ni = Ee[hr];
        $e(Tt, Ni, je(Ni), Ee);
      }
      return Tt;
    }
    function $o(Ee, $e) {
      for (var je = -1, Tt = Ee == null ? 0 : Ee.length; ++je < Tt && $e(Ee[je], je, Ee) !== !1; )
        ;
      return Ee;
    }
    function PR(Ee, $e) {
      for (var je = Ee == null ? 0 : Ee.length; je-- && $e(Ee[je], je, Ee) !== !1; )
        ;
      return Ee;
    }
    function W8(Ee, $e) {
      for (var je = -1, Tt = Ee == null ? 0 : Ee.length; ++je < Tt; )
        if (!$e(Ee[je], je, Ee))
          return !1;
      return !0;
    }
    function Qc(Ee, $e) {
      for (var je = -1, Tt = Ee == null ? 0 : Ee.length, hr = 0, tn = []; ++je < Tt; ) {
        var Ni = Ee[je];
        $e(Ni, je, Ee) && (tn[hr++] = Ni);
      }
      return tn;
    }
    function Zm(Ee, $e) {
      var je = Ee == null ? 0 : Ee.length;
      return !!je && Of(Ee, $e, 0) > -1;
    }
    function _3(Ee, $e, je) {
      for (var Tt = -1, hr = Ee == null ? 0 : Ee.length; ++Tt < hr; )
        if (je($e, Ee[Tt]))
          return !0;
      return !1;
    }
    function Vn(Ee, $e) {
      for (var je = -1, Tt = Ee == null ? 0 : Ee.length, hr = Array(Tt); ++je < Tt; )
        hr[je] = $e(Ee[je], je, Ee);
      return hr;
    }
    function Jc(Ee, $e) {
      for (var je = -1, Tt = $e.length, hr = Ee.length; ++je < Tt; )
        Ee[hr + je] = $e[je];
      return Ee;
    }
    function x3(Ee, $e, je, Tt) {
      var hr = -1, tn = Ee == null ? 0 : Ee.length;
      for (Tt && tn && (je = Ee[++hr]); ++hr < tn; )
        je = $e(je, Ee[hr], hr, Ee);
      return je;
    }
    function BR(Ee, $e, je, Tt) {
      var hr = Ee == null ? 0 : Ee.length;
      for (Tt && hr && (je = Ee[--hr]); hr--; )
        je = $e(je, Ee[hr], hr, Ee);
      return je;
    }
    function A3(Ee, $e) {
      for (var je = -1, Tt = Ee == null ? 0 : Ee.length; ++je < Tt; )
        if ($e(Ee[je], je, Ee))
          return !0;
      return !1;
    }
    var FR = S3("length");
    function NR(Ee) {
      return Ee.split("");
    }
    function RR(Ee) {
      return Ee.match(io) || [];
    }
    function Z8(Ee, $e, je) {
      var Tt;
      return je(Ee, function(hr, tn, Ni) {
        if ($e(hr, tn, Ni))
          return Tt = tn, !1;
      }), Tt;
    }
    function Qm(Ee, $e, je, Tt) {
      for (var hr = Ee.length, tn = je + (Tt ? 1 : -1); Tt ? tn-- : ++tn < hr; )
        if ($e(Ee[tn], tn, Ee))
          return tn;
      return -1;
    }
    function Of(Ee, $e, je) {
      return $e === $e ? jR(Ee, $e, je) : Qm(Ee, Q8, je);
    }
    function OR(Ee, $e, je, Tt) {
      for (var hr = je - 1, tn = Ee.length; ++hr < tn; )
        if (Tt(Ee[hr], $e))
          return hr;
      return -1;
    }
    function Q8(Ee) {
      return Ee !== Ee;
    }
    function J8(Ee, $e) {
      var je = Ee == null ? 0 : Ee.length;
      return je ? w3(Ee, $e) / je : H;
    }
    function S3(Ee) {
      return function($e) {
        return $e == null ? r : $e[Ee];
      };
    }
    function C3(Ee) {
      return function($e) {
        return Ee == null ? r : Ee[$e];
      };
    }
    function $8(Ee, $e, je, Tt, hr) {
      return hr(Ee, function(tn, Ni, Dn) {
        je = Tt ? (Tt = !1, tn) : $e(je, tn, Ni, Dn);
      }), je;
    }
    function LR(Ee, $e) {
      var je = Ee.length;
      for (Ee.sort($e); je--; )
        Ee[je] = Ee[je].value;
      return Ee;
    }
    function w3(Ee, $e) {
      for (var je, Tt = -1, hr = Ee.length; ++Tt < hr; ) {
        var tn = $e(Ee[Tt]);
        tn !== r && (je = je === r ? tn : je + tn);
      }
      return je;
    }
    function D3(Ee, $e) {
      for (var je = -1, Tt = Array(Ee); ++je < Ee; )
        Tt[je] = $e(je);
      return Tt;
    }
    function kR(Ee, $e) {
      return Vn($e, function(je) {
        return [je, Ee[je]];
      });
    }
    function ex(Ee) {
      return Ee && Ee.slice(0, ix(Ee) + 1).replace(za, "");
    }
    function Mo(Ee) {
      return function($e) {
        return Ee($e);
      };
    }
    function I3(Ee, $e) {
      return Vn($e, function(je) {
        return Ee[je];
      });
    }
    function B0(Ee, $e) {
      return Ee.has($e);
    }
    function tx(Ee, $e) {
      for (var je = -1, Tt = Ee.length; ++je < Tt && Of($e, Ee[je], 0) > -1; )
        ;
      return je;
    }
    function rx(Ee, $e) {
      for (var je = Ee.length; je-- && Of($e, Ee[je], 0) > -1; )
        ;
      return je;
    }
    function zR(Ee, $e) {
      for (var je = Ee.length, Tt = 0; je--; )
        Ee[je] === $e && ++Tt;
      return Tt;
    }
    var GR = C3(SR), VR = C3(CR);
    function UR(Ee) {
      return "\\" + DR[Ee];
    }
    function HR(Ee, $e) {
      return Ee == null ? r : Ee[$e];
    }
    function Lf(Ee) {
      return bR.test(Ee);
    }
    function qR(Ee) {
      return _R.test(Ee);
    }
    function KR(Ee) {
      for (var $e, je = []; !($e = Ee.next()).done; )
        je.push($e.value);
      return je;
    }
    function E3(Ee) {
      var $e = -1, je = Array(Ee.size);
      return Ee.forEach(function(Tt, hr) {
        je[++$e] = [hr, Tt];
      }), je;
    }
    function nx(Ee, $e) {
      return function(je) {
        return Ee($e(je));
      };
    }
    function $c(Ee, $e) {
      for (var je = -1, Tt = Ee.length, hr = 0, tn = []; ++je < Tt; ) {
        var Ni = Ee[je];
        (Ni === $e || Ni === l) && (Ee[je] = l, tn[hr++] = je);
      }
      return tn;
    }
    function Jm(Ee) {
      var $e = -1, je = Array(Ee.size);
      return Ee.forEach(function(Tt) {
        je[++$e] = Tt;
      }), je;
    }
    function XR(Ee) {
      var $e = -1, je = Array(Ee.size);
      return Ee.forEach(function(Tt) {
        je[++$e] = [Tt, Tt];
      }), je;
    }
    function jR(Ee, $e, je) {
      for (var Tt = je - 1, hr = Ee.length; ++Tt < hr; )
        if (Ee[Tt] === $e)
          return Tt;
      return -1;
    }
    function YR(Ee, $e, je) {
      for (var Tt = je + 1; Tt--; )
        if (Ee[Tt] === $e)
          return Tt;
      return Tt;
    }
    function kf(Ee) {
      return Lf(Ee) ? ZR(Ee) : FR(Ee);
    }
    function Ou(Ee) {
      return Lf(Ee) ? QR(Ee) : NR(Ee);
    }
    function ix(Ee) {
      for (var $e = Ee.length; $e-- && wn.test(Ee.charAt($e)); )
        ;
      return $e;
    }
    var WR = C3(wR);
    function ZR(Ee) {
      for (var $e = g3.lastIndex = 0; g3.test(Ee); )
        ++$e;
      return $e;
    }
    function QR(Ee) {
      return Ee.match(g3) || [];
    }
    function JR(Ee) {
      return Ee.match(yR) || [];
    }
    var $R = function Ee($e) {
      $e = $e == null ? ca : zf.defaults(ca.Object(), $e, zf.pick(ca, xR));
      var je = $e.Array, Tt = $e.Date, hr = $e.Error, tn = $e.Function, Ni = $e.Math, Dn = $e.Object, M3 = $e.RegExp, eO = $e.String, eu = $e.TypeError, $m = je.prototype, tO = tn.prototype, Gf = Dn.prototype, eh = $e["__core-js_shared__"], th = tO.toString, fn = Gf.hasOwnProperty, rO = 0, ax = function() {
        var C = /[^.]+$/.exec(eh && eh.keys && eh.keys.IE_PROTO || "");
        return C ? "Symbol(src)_1." + C : "";
      }(), rh = Gf.toString, nO = th.call(Dn), iO = ca._, aO = M3(
        "^" + th.call(fn).replace(fi, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
      ), nh = U8 ? $e.Buffer : r, el = $e.Symbol, ih = $e.Uint8Array, ox = nh ? nh.allocUnsafe : r, ah = nx(Dn.getPrototypeOf, Dn), ux = Dn.create, sx = Gf.propertyIsEnumerable, oh = $m.splice, cx = el ? el.isConcatSpreadable : r, F0 = el ? el.iterator : r, vd = el ? el.toStringTag : r, uh = function() {
        try {
          var C = xd(Dn, "defineProperty");
          return C({}, "", {}), C;
        } catch {
        }
      }(), oO = $e.clearTimeout !== ca.clearTimeout && $e.clearTimeout, uO = Tt && Tt.now !== ca.Date.now && Tt.now, sO = $e.setTimeout !== ca.setTimeout && $e.setTimeout, sh = Ni.ceil, ch = Ni.floor, T3 = Dn.getOwnPropertySymbols, cO = nh ? nh.isBuffer : r, lx = $e.isFinite, lO = $m.join, dO = nx(Dn.keys, Dn), Ri = Ni.max, Sa = Ni.min, fO = Tt.now, pO = $e.parseInt, dx = Ni.random, mO = $m.reverse, P3 = xd($e, "DataView"), N0 = xd($e, "Map"), B3 = xd($e, "Promise"), Vf = xd($e, "Set"), R0 = xd($e, "WeakMap"), O0 = xd(Dn, "create"), lh = R0 && new R0(), Uf = {}, hO = Ad(P3), vO = Ad(N0), gO = Ad(B3), yO = Ad(Vf), bO = Ad(R0), dh = el ? el.prototype : r, L0 = dh ? dh.valueOf : r, fx = dh ? dh.toString : r;
      function ne(C) {
        if (ii(C) && !br(C) && !(C instanceof Nr)) {
          if (C instanceof tu)
            return C;
          if (fn.call(C, "__wrapped__"))
            return p7(C);
        }
        return new tu(C);
      }
      var Hf = /* @__PURE__ */ function() {
        function C() {
        }
        return function(T) {
          if (!Wn(T))
            return {};
          if (ux)
            return ux(T);
          C.prototype = T;
          var L = new C();
          return C.prototype = r, L;
        };
      }();
      function fh() {
      }
      function tu(C, T) {
        this.__wrapped__ = C, this.__actions__ = [], this.__chain__ = !!T, this.__index__ = 0, this.__values__ = r;
      }
      ne.templateSettings = {
        /**
         * Used to detect `data` property values to be HTML-escaped.
         *
         * @memberOf _.templateSettings
         * @type {RegExp}
         */
        escape: Rn,
        /**
         * Used to detect code to be evaluated.
         *
         * @memberOf _.templateSettings
         * @type {RegExp}
         */
        evaluate: Cn,
        /**
         * Used to detect `data` property values to inject.
         *
         * @memberOf _.templateSettings
         * @type {RegExp}
         */
        interpolate: Jr,
        /**
         * Used to reference the data object in the template text.
         *
         * @memberOf _.templateSettings
         * @type {string}
         */
        variable: "",
        /**
         * Used to import variables into the compiled template.
         *
         * @memberOf _.templateSettings
         * @type {Object}
         */
        imports: {
          /**
           * A reference to the `lodash` function.
           *
           * @memberOf _.templateSettings.imports
           * @type {Function}
           */
          _: ne
        }
      }, ne.prototype = fh.prototype, ne.prototype.constructor = ne, tu.prototype = Hf(fh.prototype), tu.prototype.constructor = tu;
      function Nr(C) {
        this.__wrapped__ = C, this.__actions__ = [], this.__dir__ = 1, this.__filtered__ = !1, this.__iteratees__ = [], this.__takeCount__ = K, this.__views__ = [];
      }
      function _O() {
        var C = new Nr(this.__wrapped__);
        return C.__actions__ = ao(this.__actions__), C.__dir__ = this.__dir__, C.__filtered__ = this.__filtered__, C.__iteratees__ = ao(this.__iteratees__), C.__takeCount__ = this.__takeCount__, C.__views__ = ao(this.__views__), C;
      }
      function xO() {
        if (this.__filtered__) {
          var C = new Nr(this);
          C.__dir__ = -1, C.__filtered__ = !0;
        } else
          C = this.clone(), C.__dir__ *= -1;
        return C;
      }
      function AO() {
        var C = this.__wrapped__.value(), T = this.__dir__, L = br(C), q = T < 0, Z = L ? C.length : 0, ue = NL(0, Z, this.__views__), ge = ue.start, Ce = ue.end, Pe = Ce - ge, rt = q ? Ce : ge - 1, it = this.__iteratees__, dt = it.length, St = 0, Rt = Sa(Pe, this.__takeCount__);
        if (!L || !q && Z == Pe && Rt == Pe)
          return Ox(C, this.__actions__);
        var Qt = [];
        e:
          for (; Pe-- && St < Rt; ) {
            rt += T;
            for (var wr = -1, Jt = C[rt]; ++wr < dt; ) {
              var Tr = it[wr], Lr = Tr.iteratee, Bo = Tr.type, Ha = Lr(Jt);
              if (Bo == N)
                Jt = Ha;
              else if (!Ha) {
                if (Bo == B)
                  continue e;
                break e;
              }
            }
            Qt[St++] = Jt;
          }
        return Qt;
      }
      Nr.prototype = Hf(fh.prototype), Nr.prototype.constructor = Nr;
      function gd(C) {
        var T = -1, L = C == null ? 0 : C.length;
        for (this.clear(); ++T < L; ) {
          var q = C[T];
          this.set(q[0], q[1]);
        }
      }
      function SO() {
        this.__data__ = O0 ? O0(null) : {}, this.size = 0;
      }
      function CO(C) {
        var T = this.has(C) && delete this.__data__[C];
        return this.size -= T ? 1 : 0, T;
      }
      function wO(C) {
        var T = this.__data__;
        if (O0) {
          var L = T[C];
          return L === s ? r : L;
        }
        return fn.call(T, C) ? T[C] : r;
      }
      function DO(C) {
        var T = this.__data__;
        return O0 ? T[C] !== r : fn.call(T, C);
      }
      function IO(C, T) {
        var L = this.__data__;
        return this.size += this.has(C) ? 0 : 1, L[C] = O0 && T === r ? s : T, this;
      }
      gd.prototype.clear = SO, gd.prototype.delete = CO, gd.prototype.get = wO, gd.prototype.has = DO, gd.prototype.set = IO;
      function Us(C) {
        var T = -1, L = C == null ? 0 : C.length;
        for (this.clear(); ++T < L; ) {
          var q = C[T];
          this.set(q[0], q[1]);
        }
      }
      function EO() {
        this.__data__ = [], this.size = 0;
      }
      function MO(C) {
        var T = this.__data__, L = ph(T, C);
        if (L < 0)
          return !1;
        var q = T.length - 1;
        return L == q ? T.pop() : oh.call(T, L, 1), --this.size, !0;
      }
      function TO(C) {
        var T = this.__data__, L = ph(T, C);
        return L < 0 ? r : T[L][1];
      }
      function PO(C) {
        return ph(this.__data__, C) > -1;
      }
      function BO(C, T) {
        var L = this.__data__, q = ph(L, C);
        return q < 0 ? (++this.size, L.push([C, T])) : L[q][1] = T, this;
      }
      Us.prototype.clear = EO, Us.prototype.delete = MO, Us.prototype.get = TO, Us.prototype.has = PO, Us.prototype.set = BO;
      function Hs(C) {
        var T = -1, L = C == null ? 0 : C.length;
        for (this.clear(); ++T < L; ) {
          var q = C[T];
          this.set(q[0], q[1]);
        }
      }
      function FO() {
        this.size = 0, this.__data__ = {
          hash: new gd(),
          map: new (N0 || Us)(),
          string: new gd()
        };
      }
      function NO(C) {
        var T = wh(this, C).delete(C);
        return this.size -= T ? 1 : 0, T;
      }
      function RO(C) {
        return wh(this, C).get(C);
      }
      function OO(C) {
        return wh(this, C).has(C);
      }
      function LO(C, T) {
        var L = wh(this, C), q = L.size;
        return L.set(C, T), this.size += L.size == q ? 0 : 1, this;
      }
      Hs.prototype.clear = FO, Hs.prototype.delete = NO, Hs.prototype.get = RO, Hs.prototype.has = OO, Hs.prototype.set = LO;
      function yd(C) {
        var T = -1, L = C == null ? 0 : C.length;
        for (this.__data__ = new Hs(); ++T < L; )
          this.add(C[T]);
      }
      function kO(C) {
        return this.__data__.set(C, s), this;
      }
      function zO(C) {
        return this.__data__.has(C);
      }
      yd.prototype.add = yd.prototype.push = kO, yd.prototype.has = zO;
      function Lu(C) {
        var T = this.__data__ = new Us(C);
        this.size = T.size;
      }
      function GO() {
        this.__data__ = new Us(), this.size = 0;
      }
      function VO(C) {
        var T = this.__data__, L = T.delete(C);
        return this.size = T.size, L;
      }
      function UO(C) {
        return this.__data__.get(C);
      }
      function HO(C) {
        return this.__data__.has(C);
      }
      function qO(C, T) {
        var L = this.__data__;
        if (L instanceof Us) {
          var q = L.__data__;
          if (!N0 || q.length < i - 1)
            return q.push([C, T]), this.size = ++L.size, this;
          L = this.__data__ = new Hs(q);
        }
        return L.set(C, T), this.size = L.size, this;
      }
      Lu.prototype.clear = GO, Lu.prototype.delete = VO, Lu.prototype.get = UO, Lu.prototype.has = HO, Lu.prototype.set = qO;
      function px(C, T) {
        var L = br(C), q = !L && Sd(C), Z = !L && !q && al(C), ue = !L && !q && !Z && jf(C), ge = L || q || Z || ue, Ce = ge ? D3(C.length, eO) : [], Pe = Ce.length;
        for (var rt in C)
          (T || fn.call(C, rt)) && !(ge && // Safari 9 has enumerable `arguments.length` in strict mode.
          (rt == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
          Z && (rt == "offset" || rt == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
          ue && (rt == "buffer" || rt == "byteLength" || rt == "byteOffset") || // Skip index properties.
          js(rt, Pe))) && Ce.push(rt);
        return Ce;
      }
      function mx(C) {
        var T = C.length;
        return T ? C[H3(0, T - 1)] : r;
      }
      function KO(C, T) {
        return Dh(ao(C), bd(T, 0, C.length));
      }
      function XO(C) {
        return Dh(ao(C));
      }
      function F3(C, T, L) {
        (L !== r && !ku(C[T], L) || L === r && !(T in C)) && qs(C, T, L);
      }
      function k0(C, T, L) {
        var q = C[T];
        (!(fn.call(C, T) && ku(q, L)) || L === r && !(T in C)) && qs(C, T, L);
      }
      function ph(C, T) {
        for (var L = C.length; L--; )
          if (ku(C[L][0], T))
            return L;
        return -1;
      }
      function jO(C, T, L, q) {
        return tl(C, function(Z, ue, ge) {
          T(q, Z, L(Z), ge);
        }), q;
      }
      function hx(C, T) {
        return C && cs(T, Xi(T), C);
      }
      function YO(C, T) {
        return C && cs(T, uo(T), C);
      }
      function qs(C, T, L) {
        T == "__proto__" && uh ? uh(C, T, {
          configurable: !0,
          enumerable: !0,
          value: L,
          writable: !0
        }) : C[T] = L;
      }
      function N3(C, T) {
        for (var L = -1, q = T.length, Z = je(q), ue = C == null; ++L < q; )
          Z[L] = ue ? r : my(C, T[L]);
        return Z;
      }
      function bd(C, T, L) {
        return C === C && (L !== r && (C = C <= L ? C : L), T !== r && (C = C >= T ? C : T)), C;
      }
      function ru(C, T, L, q, Z, ue) {
        var ge, Ce = T & d, Pe = T & f, rt = T & m;
        if (L && (ge = Z ? L(C, q, Z, ue) : L(C)), ge !== r)
          return ge;
        if (!Wn(C))
          return C;
        var it = br(C);
        if (it) {
          if (ge = OL(C), !Ce)
            return ao(C, ge);
        } else {
          var dt = Ca(C), St = dt == le || dt == pe;
          if (al(C))
            return zx(C, Ce);
          if (dt == Ke || dt == Q || St && !Z) {
            if (ge = Pe || St ? {} : i7(C), !Ce)
              return Pe ? wL(C, YO(ge, C)) : CL(C, hx(ge, C));
          } else {
            if (!Pn[dt])
              return Z ? C : {};
            ge = LL(C, dt, Ce);
          }
        }
        ue || (ue = new Lu());
        var Rt = ue.get(C);
        if (Rt)
          return Rt;
        ue.set(C, ge), F7(C) ? C.forEach(function(Jt) {
          ge.add(ru(Jt, T, L, Jt, C, ue));
        }) : P7(C) && C.forEach(function(Jt, Tr) {
          ge.set(Tr, ru(Jt, T, L, Tr, C, ue));
        });
        var Qt = rt ? Pe ? ey : $3 : Pe ? uo : Xi, wr = it ? r : Qt(C);
        return $o(wr || C, function(Jt, Tr) {
          wr && (Tr = Jt, Jt = C[Tr]), k0(ge, Tr, ru(Jt, T, L, Tr, C, ue));
        }), ge;
      }
      function WO(C) {
        var T = Xi(C);
        return function(L) {
          return vx(L, C, T);
        };
      }
      function vx(C, T, L) {
        var q = L.length;
        if (C == null)
          return !q;
        for (C = Dn(C); q--; ) {
          var Z = L[q], ue = T[Z], ge = C[Z];
          if (ge === r && !(Z in C) || !ue(ge))
            return !1;
        }
        return !0;
      }
      function gx(C, T, L) {
        if (typeof C != "function")
          throw new eu(o);
        return K0(function() {
          C.apply(r, L);
        }, T);
      }
      function z0(C, T, L, q) {
        var Z = -1, ue = Zm, ge = !0, Ce = C.length, Pe = [], rt = T.length;
        if (!Ce)
          return Pe;
        L && (T = Vn(T, Mo(L))), q ? (ue = _3, ge = !1) : T.length >= i && (ue = B0, ge = !1, T = new yd(T));
        e:
          for (; ++Z < Ce; ) {
            var it = C[Z], dt = L == null ? it : L(it);
            if (it = q || it !== 0 ? it : 0, ge && dt === dt) {
              for (var St = rt; St--; )
                if (T[St] === dt)
                  continue e;
              Pe.push(it);
            } else ue(T, dt, q) || Pe.push(it);
          }
        return Pe;
      }
      var tl = qx(ss), yx = qx(O3, !0);
      function ZO(C, T) {
        var L = !0;
        return tl(C, function(q, Z, ue) {
          return L = !!T(q, Z, ue), L;
        }), L;
      }
      function mh(C, T, L) {
        for (var q = -1, Z = C.length; ++q < Z; ) {
          var ue = C[q], ge = T(ue);
          if (ge != null && (Ce === r ? ge === ge && !Po(ge) : L(ge, Ce)))
            var Ce = ge, Pe = ue;
        }
        return Pe;
      }
      function QO(C, T, L, q) {
        var Z = C.length;
        for (L = Sr(L), L < 0 && (L = -L > Z ? 0 : Z + L), q = q === r || q > Z ? Z : Sr(q), q < 0 && (q += Z), q = L > q ? 0 : R7(q); L < q; )
          C[L++] = T;
        return C;
      }
      function bx(C, T) {
        var L = [];
        return tl(C, function(q, Z, ue) {
          T(q, Z, ue) && L.push(q);
        }), L;
      }
      function la(C, T, L, q, Z) {
        var ue = -1, ge = C.length;
        for (L || (L = zL), Z || (Z = []); ++ue < ge; ) {
          var Ce = C[ue];
          T > 0 && L(Ce) ? T > 1 ? la(Ce, T - 1, L, q, Z) : Jc(Z, Ce) : q || (Z[Z.length] = Ce);
        }
        return Z;
      }
      var R3 = Kx(), _x = Kx(!0);
      function ss(C, T) {
        return C && R3(C, T, Xi);
      }
      function O3(C, T) {
        return C && _x(C, T, Xi);
      }
      function hh(C, T) {
        return Qc(T, function(L) {
          return Ys(C[L]);
        });
      }
      function _d(C, T) {
        T = nl(T, C);
        for (var L = 0, q = T.length; C != null && L < q; )
          C = C[ls(T[L++])];
        return L && L == q ? C : r;
      }
      function xx(C, T, L) {
        var q = T(C);
        return br(C) ? q : Jc(q, L(C));
      }
      function Va(C) {
        return C == null ? C === r ? J : Ue : vd && vd in Dn(C) ? FL(C) : XL(C);
      }
      function L3(C, T) {
        return C > T;
      }
      function JO(C, T) {
        return C != null && fn.call(C, T);
      }
      function $O(C, T) {
        return C != null && T in Dn(C);
      }
      function eL(C, T, L) {
        return C >= Sa(T, L) && C < Ri(T, L);
      }
      function k3(C, T, L) {
        for (var q = L ? _3 : Zm, Z = C[0].length, ue = C.length, ge = ue, Ce = je(ue), Pe = 1 / 0, rt = []; ge--; ) {
          var it = C[ge];
          ge && T && (it = Vn(it, Mo(T))), Pe = Sa(it.length, Pe), Ce[ge] = !L && (T || Z >= 120 && it.length >= 120) ? new yd(ge && it) : r;
        }
        it = C[0];
        var dt = -1, St = Ce[0];
        e:
          for (; ++dt < Z && rt.length < Pe; ) {
            var Rt = it[dt], Qt = T ? T(Rt) : Rt;
            if (Rt = L || Rt !== 0 ? Rt : 0, !(St ? B0(St, Qt) : q(rt, Qt, L))) {
              for (ge = ue; --ge; ) {
                var wr = Ce[ge];
                if (!(wr ? B0(wr, Qt) : q(C[ge], Qt, L)))
                  continue e;
              }
              St && St.push(Qt), rt.push(Rt);
            }
          }
        return rt;
      }
      function tL(C, T, L, q) {
        return ss(C, function(Z, ue, ge) {
          T(q, L(Z), ue, ge);
        }), q;
      }
      function G0(C, T, L) {
        T = nl(T, C), C = s7(C, T);
        var q = C == null ? C : C[ls(iu(T))];
        return q == null ? r : Eo(q, C, L);
      }
      function Ax(C) {
        return ii(C) && Va(C) == Q;
      }
      function rL(C) {
        return ii(C) && Va(C) == ve;
      }
      function nL(C) {
        return ii(C) && Va(C) == ie;
      }
      function V0(C, T, L, q, Z) {
        return C === T ? !0 : C == null || T == null || !ii(C) && !ii(T) ? C !== C && T !== T : iL(C, T, L, q, V0, Z);
      }
      function iL(C, T, L, q, Z, ue) {
        var ge = br(C), Ce = br(T), Pe = ge ? te : Ca(C), rt = Ce ? te : Ca(T);
        Pe = Pe == Q ? Ke : Pe, rt = rt == Q ? Ke : rt;
        var it = Pe == Ke, dt = rt == Ke, St = Pe == rt;
        if (St && al(C)) {
          if (!al(T))
            return !1;
          ge = !0, it = !1;
        }
        if (St && !it)
          return ue || (ue = new Lu()), ge || jf(C) ? t7(C, T, L, q, Z, ue) : PL(C, T, Pe, L, q, Z, ue);
        if (!(L & v)) {
          var Rt = it && fn.call(C, "__wrapped__"), Qt = dt && fn.call(T, "__wrapped__");
          if (Rt || Qt) {
            var wr = Rt ? C.value() : C, Jt = Qt ? T.value() : T;
            return ue || (ue = new Lu()), Z(wr, Jt, L, q, ue);
          }
        }
        return St ? (ue || (ue = new Lu()), BL(C, T, L, q, Z, ue)) : !1;
      }
      function aL(C) {
        return ii(C) && Ca(C) == we;
      }
      function z3(C, T, L, q) {
        var Z = L.length, ue = Z, ge = !q;
        if (C == null)
          return !ue;
        for (C = Dn(C); Z--; ) {
          var Ce = L[Z];
          if (ge && Ce[2] ? Ce[1] !== C[Ce[0]] : !(Ce[0] in C))
            return !1;
        }
        for (; ++Z < ue; ) {
          Ce = L[Z];
          var Pe = Ce[0], rt = C[Pe], it = Ce[1];
          if (ge && Ce[2]) {
            if (rt === r && !(Pe in C))
              return !1;
          } else {
            var dt = new Lu();
            if (q)
              var St = q(rt, it, Pe, C, T, dt);
            if (!(St === r ? V0(it, rt, v | p, q, dt) : St))
              return !1;
          }
        }
        return !0;
      }
      function Sx(C) {
        if (!Wn(C) || VL(C))
          return !1;
        var T = Ys(C) ? aO : Kc;
        return T.test(Ad(C));
      }
      function oL(C) {
        return ii(C) && Va(C) == Je;
      }
      function uL(C) {
        return ii(C) && Ca(C) == Ne;
      }
      function sL(C) {
        return ii(C) && Bh(C.length) && !!On[Va(C)];
      }
      function Cx(C) {
        return typeof C == "function" ? C : C == null ? so : typeof C == "object" ? br(C) ? Ix(C[0], C[1]) : Dx(C) : X7(C);
      }
      function G3(C) {
        if (!q0(C))
          return dO(C);
        var T = [];
        for (var L in Dn(C))
          fn.call(C, L) && L != "constructor" && T.push(L);
        return T;
      }
      function cL(C) {
        if (!Wn(C))
          return KL(C);
        var T = q0(C), L = [];
        for (var q in C)
          q == "constructor" && (T || !fn.call(C, q)) || L.push(q);
        return L;
      }
      function V3(C, T) {
        return C < T;
      }
      function wx(C, T) {
        var L = -1, q = oo(C) ? je(C.length) : [];
        return tl(C, function(Z, ue, ge) {
          q[++L] = T(Z, ue, ge);
        }), q;
      }
      function Dx(C) {
        var T = ry(C);
        return T.length == 1 && T[0][2] ? o7(T[0][0], T[0][1]) : function(L) {
          return L === C || z3(L, C, T);
        };
      }
      function Ix(C, T) {
        return iy(C) && a7(T) ? o7(ls(C), T) : function(L) {
          var q = my(L, C);
          return q === r && q === T ? hy(L, C) : V0(T, q, v | p);
        };
      }
      function vh(C, T, L, q, Z) {
        C !== T && R3(T, function(ue, ge) {
          if (Z || (Z = new Lu()), Wn(ue))
            lL(C, T, ge, L, vh, q, Z);
          else {
            var Ce = q ? q(oy(C, ge), ue, ge + "", C, T, Z) : r;
            Ce === r && (Ce = ue), F3(C, ge, Ce);
          }
        }, uo);
      }
      function lL(C, T, L, q, Z, ue, ge) {
        var Ce = oy(C, L), Pe = oy(T, L), rt = ge.get(Pe);
        if (rt) {
          F3(C, L, rt);
          return;
        }
        var it = ue ? ue(Ce, Pe, L + "", C, T, ge) : r, dt = it === r;
        if (dt) {
          var St = br(Pe), Rt = !St && al(Pe), Qt = !St && !Rt && jf(Pe);
          it = Pe, St || Rt || Qt ? br(Ce) ? it = Ce : hi(Ce) ? it = ao(Ce) : Rt ? (dt = !1, it = zx(Pe, !0)) : Qt ? (dt = !1, it = Gx(Pe, !0)) : it = [] : X0(Pe) || Sd(Pe) ? (it = Ce, Sd(Ce) ? it = O7(Ce) : (!Wn(Ce) || Ys(Ce)) && (it = i7(Pe))) : dt = !1;
        }
        dt && (ge.set(Pe, it), Z(it, Pe, q, ue, ge), ge.delete(Pe)), F3(C, L, it);
      }
      function Ex(C, T) {
        var L = C.length;
        if (L)
          return T += T < 0 ? L : 0, js(T, L) ? C[T] : r;
      }
      function Mx(C, T, L) {
        T.length ? T = Vn(T, function(ue) {
          return br(ue) ? function(ge) {
            return _d(ge, ue.length === 1 ? ue[0] : ue);
          } : ue;
        }) : T = [so];
        var q = -1;
        T = Vn(T, Mo(jt()));
        var Z = wx(C, function(ue, ge, Ce) {
          var Pe = Vn(T, function(rt) {
            return rt(ue);
          });
          return { criteria: Pe, index: ++q, value: ue };
        });
        return LR(Z, function(ue, ge) {
          return SL(ue, ge, L);
        });
      }
      function dL(C, T) {
        return Tx(C, T, function(L, q) {
          return hy(C, q);
        });
      }
      function Tx(C, T, L) {
        for (var q = -1, Z = T.length, ue = {}; ++q < Z; ) {
          var ge = T[q], Ce = _d(C, ge);
          L(Ce, ge) && U0(ue, nl(ge, C), Ce);
        }
        return ue;
      }
      function fL(C) {
        return function(T) {
          return _d(T, C);
        };
      }
      function U3(C, T, L, q) {
        var Z = q ? OR : Of, ue = -1, ge = T.length, Ce = C;
        for (C === T && (T = ao(T)), L && (Ce = Vn(C, Mo(L))); ++ue < ge; )
          for (var Pe = 0, rt = T[ue], it = L ? L(rt) : rt; (Pe = Z(Ce, it, Pe, q)) > -1; )
            Ce !== C && oh.call(Ce, Pe, 1), oh.call(C, Pe, 1);
        return C;
      }
      function Px(C, T) {
        for (var L = C ? T.length : 0, q = L - 1; L--; ) {
          var Z = T[L];
          if (L == q || Z !== ue) {
            var ue = Z;
            js(Z) ? oh.call(C, Z, 1) : X3(C, Z);
          }
        }
        return C;
      }
      function H3(C, T) {
        return C + ch(dx() * (T - C + 1));
      }
      function pL(C, T, L, q) {
        for (var Z = -1, ue = Ri(sh((T - C) / (L || 1)), 0), ge = je(ue); ue--; )
          ge[q ? ue : ++Z] = C, C += L;
        return ge;
      }
      function q3(C, T) {
        var L = "";
        if (!C || T < 1 || T > V)
          return L;
        do
          T % 2 && (L += C), T = ch(T / 2), T && (C += C);
        while (T);
        return L;
      }
      function Dr(C, T) {
        return uy(u7(C, T, so), C + "");
      }
      function mL(C) {
        return mx(Yf(C));
      }
      function hL(C, T) {
        var L = Yf(C);
        return Dh(L, bd(T, 0, L.length));
      }
      function U0(C, T, L, q) {
        if (!Wn(C))
          return C;
        T = nl(T, C);
        for (var Z = -1, ue = T.length, ge = ue - 1, Ce = C; Ce != null && ++Z < ue; ) {
          var Pe = ls(T[Z]), rt = L;
          if (Pe === "__proto__" || Pe === "constructor" || Pe === "prototype")
            return C;
          if (Z != ge) {
            var it = Ce[Pe];
            rt = q ? q(it, Pe, Ce) : r, rt === r && (rt = Wn(it) ? it : js(T[Z + 1]) ? [] : {});
          }
          k0(Ce, Pe, rt), Ce = Ce[Pe];
        }
        return C;
      }
      var Bx = lh ? function(C, T) {
        return lh.set(C, T), C;
      } : so, vL = uh ? function(C, T) {
        return uh(C, "toString", {
          configurable: !0,
          enumerable: !1,
          value: gy(T),
          writable: !0
        });
      } : so;
      function gL(C) {
        return Dh(Yf(C));
      }
      function nu(C, T, L) {
        var q = -1, Z = C.length;
        T < 0 && (T = -T > Z ? 0 : Z + T), L = L > Z ? Z : L, L < 0 && (L += Z), Z = T > L ? 0 : L - T >>> 0, T >>>= 0;
        for (var ue = je(Z); ++q < Z; )
          ue[q] = C[q + T];
        return ue;
      }
      function yL(C, T) {
        var L;
        return tl(C, function(q, Z, ue) {
          return L = T(q, Z, ue), !L;
        }), !!L;
      }
      function gh(C, T, L) {
        var q = 0, Z = C == null ? q : C.length;
        if (typeof T == "number" && T === T && Z <= X) {
          for (; q < Z; ) {
            var ue = q + Z >>> 1, ge = C[ue];
            ge !== null && !Po(ge) && (L ? ge <= T : ge < T) ? q = ue + 1 : Z = ue;
          }
          return Z;
        }
        return K3(C, T, so, L);
      }
      function K3(C, T, L, q) {
        var Z = 0, ue = C == null ? 0 : C.length;
        if (ue === 0)
          return 0;
        T = L(T);
        for (var ge = T !== T, Ce = T === null, Pe = Po(T), rt = T === r; Z < ue; ) {
          var it = ch((Z + ue) / 2), dt = L(C[it]), St = dt !== r, Rt = dt === null, Qt = dt === dt, wr = Po(dt);
          if (ge)
            var Jt = q || Qt;
          else rt ? Jt = Qt && (q || St) : Ce ? Jt = Qt && St && (q || !Rt) : Pe ? Jt = Qt && St && !Rt && (q || !wr) : Rt || wr ? Jt = !1 : Jt = q ? dt <= T : dt < T;
          Jt ? Z = it + 1 : ue = it;
        }
        return Sa(ue, j);
      }
      function Fx(C, T) {
        for (var L = -1, q = C.length, Z = 0, ue = []; ++L < q; ) {
          var ge = C[L], Ce = T ? T(ge) : ge;
          if (!L || !ku(Ce, Pe)) {
            var Pe = Ce;
            ue[Z++] = ge === 0 ? 0 : ge;
          }
        }
        return ue;
      }
      function Nx(C) {
        return typeof C == "number" ? C : Po(C) ? H : +C;
      }
      function To(C) {
        if (typeof C == "string")
          return C;
        if (br(C))
          return Vn(C, To) + "";
        if (Po(C))
          return fx ? fx.call(C) : "";
        var T = C + "";
        return T == "0" && 1 / C == -z ? "-0" : T;
      }
      function rl(C, T, L) {
        var q = -1, Z = Zm, ue = C.length, ge = !0, Ce = [], Pe = Ce;
        if (L)
          ge = !1, Z = _3;
        else if (ue >= i) {
          var rt = T ? null : ML(C);
          if (rt)
            return Jm(rt);
          ge = !1, Z = B0, Pe = new yd();
        } else
          Pe = T ? [] : Ce;
        e:
          for (; ++q < ue; ) {
            var it = C[q], dt = T ? T(it) : it;
            if (it = L || it !== 0 ? it : 0, ge && dt === dt) {
              for (var St = Pe.length; St--; )
                if (Pe[St] === dt)
                  continue e;
              T && Pe.push(dt), Ce.push(it);
            } else Z(Pe, dt, L) || (Pe !== Ce && Pe.push(dt), Ce.push(it));
          }
        return Ce;
      }
      function X3(C, T) {
        return T = nl(T, C), C = s7(C, T), C == null || delete C[ls(iu(T))];
      }
      function Rx(C, T, L, q) {
        return U0(C, T, L(_d(C, T)), q);
      }
      function yh(C, T, L, q) {
        for (var Z = C.length, ue = q ? Z : -1; (q ? ue-- : ++ue < Z) && T(C[ue], ue, C); )
          ;
        return L ? nu(C, q ? 0 : ue, q ? ue + 1 : Z) : nu(C, q ? ue + 1 : 0, q ? Z : ue);
      }
      function Ox(C, T) {
        var L = C;
        return L instanceof Nr && (L = L.value()), x3(T, function(q, Z) {
          return Z.func.apply(Z.thisArg, Jc([q], Z.args));
        }, L);
      }
      function j3(C, T, L) {
        var q = C.length;
        if (q < 2)
          return q ? rl(C[0]) : [];
        for (var Z = -1, ue = je(q); ++Z < q; )
          for (var ge = C[Z], Ce = -1; ++Ce < q; )
            Ce != Z && (ue[Z] = z0(ue[Z] || ge, C[Ce], T, L));
        return rl(la(ue, 1), T, L);
      }
      function Lx(C, T, L) {
        for (var q = -1, Z = C.length, ue = T.length, ge = {}; ++q < Z; ) {
          var Ce = q < ue ? T[q] : r;
          L(ge, C[q], Ce);
        }
        return ge;
      }
      function Y3(C) {
        return hi(C) ? C : [];
      }
      function W3(C) {
        return typeof C == "function" ? C : so;
      }
      function nl(C, T) {
        return br(C) ? C : iy(C, T) ? [C] : f7(an(C));
      }
      var bL = Dr;
      function il(C, T, L) {
        var q = C.length;
        return L = L === r ? q : L, !T && L >= q ? C : nu(C, T, L);
      }
      var kx = oO || function(C) {
        return ca.clearTimeout(C);
      };
      function zx(C, T) {
        if (T)
          return C.slice();
        var L = C.length, q = ox ? ox(L) : new C.constructor(L);
        return C.copy(q), q;
      }
      function Z3(C) {
        var T = new C.constructor(C.byteLength);
        return new ih(T).set(new ih(C)), T;
      }
      function _L(C, T) {
        var L = T ? Z3(C.buffer) : C.buffer;
        return new C.constructor(L, C.byteOffset, C.byteLength);
      }
      function xL(C) {
        var T = new C.constructor(C.source, Gs.exec(C));
        return T.lastIndex = C.lastIndex, T;
      }
      function AL(C) {
        return L0 ? Dn(L0.call(C)) : {};
      }
      function Gx(C, T) {
        var L = T ? Z3(C.buffer) : C.buffer;
        return new C.constructor(L, C.byteOffset, C.length);
      }
      function Vx(C, T) {
        if (C !== T) {
          var L = C !== r, q = C === null, Z = C === C, ue = Po(C), ge = T !== r, Ce = T === null, Pe = T === T, rt = Po(T);
          if (!Ce && !rt && !ue && C > T || ue && ge && Pe && !Ce && !rt || q && ge && Pe || !L && Pe || !Z)
            return 1;
          if (!q && !ue && !rt && C < T || rt && L && Z && !q && !ue || Ce && L && Z || !ge && Z || !Pe)
            return -1;
        }
        return 0;
      }
      function SL(C, T, L) {
        for (var q = -1, Z = C.criteria, ue = T.criteria, ge = Z.length, Ce = L.length; ++q < ge; ) {
          var Pe = Vx(Z[q], ue[q]);
          if (Pe) {
            if (q >= Ce)
              return Pe;
            var rt = L[q];
            return Pe * (rt == "desc" ? -1 : 1);
          }
        }
        return C.index - T.index;
      }
      function Ux(C, T, L, q) {
        for (var Z = -1, ue = C.length, ge = L.length, Ce = -1, Pe = T.length, rt = Ri(ue - ge, 0), it = je(Pe + rt), dt = !q; ++Ce < Pe; )
          it[Ce] = T[Ce];
        for (; ++Z < ge; )
          (dt || Z < ue) && (it[L[Z]] = C[Z]);
        for (; rt--; )
          it[Ce++] = C[Z++];
        return it;
      }
      function Hx(C, T, L, q) {
        for (var Z = -1, ue = C.length, ge = -1, Ce = L.length, Pe = -1, rt = T.length, it = Ri(ue - Ce, 0), dt = je(it + rt), St = !q; ++Z < it; )
          dt[Z] = C[Z];
        for (var Rt = Z; ++Pe < rt; )
          dt[Rt + Pe] = T[Pe];
        for (; ++ge < Ce; )
          (St || Z < ue) && (dt[Rt + L[ge]] = C[Z++]);
        return dt;
      }
      function ao(C, T) {
        var L = -1, q = C.length;
        for (T || (T = je(q)); ++L < q; )
          T[L] = C[L];
        return T;
      }
      function cs(C, T, L, q) {
        var Z = !L;
        L || (L = {});
        for (var ue = -1, ge = T.length; ++ue < ge; ) {
          var Ce = T[ue], Pe = q ? q(L[Ce], C[Ce], Ce, L, C) : r;
          Pe === r && (Pe = C[Ce]), Z ? qs(L, Ce, Pe) : k0(L, Ce, Pe);
        }
        return L;
      }
      function CL(C, T) {
        return cs(C, ny(C), T);
      }
      function wL(C, T) {
        return cs(C, r7(C), T);
      }
      function bh(C, T) {
        return function(L, q) {
          var Z = br(L) ? TR : jO, ue = T ? T() : {};
          return Z(L, C, jt(q, 2), ue);
        };
      }
      function qf(C) {
        return Dr(function(T, L) {
          var q = -1, Z = L.length, ue = Z > 1 ? L[Z - 1] : r, ge = Z > 2 ? L[2] : r;
          for (ue = C.length > 3 && typeof ue == "function" ? (Z--, ue) : r, ge && Ua(L[0], L[1], ge) && (ue = Z < 3 ? r : ue, Z = 1), T = Dn(T); ++q < Z; ) {
            var Ce = L[q];
            Ce && C(T, Ce, q, ue);
          }
          return T;
        });
      }
      function qx(C, T) {
        return function(L, q) {
          if (L == null)
            return L;
          if (!oo(L))
            return C(L, q);
          for (var Z = L.length, ue = T ? Z : -1, ge = Dn(L); (T ? ue-- : ++ue < Z) && q(ge[ue], ue, ge) !== !1; )
            ;
          return L;
        };
      }
      function Kx(C) {
        return function(T, L, q) {
          for (var Z = -1, ue = Dn(T), ge = q(T), Ce = ge.length; Ce--; ) {
            var Pe = ge[C ? Ce : ++Z];
            if (L(ue[Pe], Pe, ue) === !1)
              break;
          }
          return T;
        };
      }
      function DL(C, T, L) {
        var q = T & g, Z = H0(C);
        function ue() {
          var ge = this && this !== ca && this instanceof ue ? Z : C;
          return ge.apply(q ? L : this, arguments);
        }
        return ue;
      }
      function Xx(C) {
        return function(T) {
          T = an(T);
          var L = Lf(T) ? Ou(T) : r, q = L ? L[0] : T.charAt(0), Z = L ? il(L, 1).join("") : T.slice(1);
          return q[C]() + Z;
        };
      }
      function Kf(C) {
        return function(T) {
          return x3(q7(H7(T).replace(vR, "")), C, "");
        };
      }
      function H0(C) {
        return function() {
          var T = arguments;
          switch (T.length) {
            case 0:
              return new C();
            case 1:
              return new C(T[0]);
            case 2:
              return new C(T[0], T[1]);
            case 3:
              return new C(T[0], T[1], T[2]);
            case 4:
              return new C(T[0], T[1], T[2], T[3]);
            case 5:
              return new C(T[0], T[1], T[2], T[3], T[4]);
            case 6:
              return new C(T[0], T[1], T[2], T[3], T[4], T[5]);
            case 7:
              return new C(T[0], T[1], T[2], T[3], T[4], T[5], T[6]);
          }
          var L = Hf(C.prototype), q = C.apply(L, T);
          return Wn(q) ? q : L;
        };
      }
      function IL(C, T, L) {
        var q = H0(C);
        function Z() {
          for (var ue = arguments.length, ge = je(ue), Ce = ue, Pe = Xf(Z); Ce--; )
            ge[Ce] = arguments[Ce];
          var rt = ue < 3 && ge[0] !== Pe && ge[ue - 1] !== Pe ? [] : $c(ge, Pe);
          if (ue -= rt.length, ue < L)
            return Qx(
              C,
              T,
              _h,
              Z.placeholder,
              r,
              ge,
              rt,
              r,
              r,
              L - ue
            );
          var it = this && this !== ca && this instanceof Z ? q : C;
          return Eo(it, this, ge);
        }
        return Z;
      }
      function jx(C) {
        return function(T, L, q) {
          var Z = Dn(T);
          if (!oo(T)) {
            var ue = jt(L, 3);
            T = Xi(T), L = function(Ce) {
              return ue(Z[Ce], Ce, Z);
            };
          }
          var ge = C(T, L, q);
          return ge > -1 ? Z[ue ? T[ge] : ge] : r;
        };
      }
      function Yx(C) {
        return Xs(function(T) {
          var L = T.length, q = L, Z = tu.prototype.thru;
          for (C && T.reverse(); q--; ) {
            var ue = T[q];
            if (typeof ue != "function")
              throw new eu(o);
            if (Z && !ge && Ch(ue) == "wrapper")
              var ge = new tu([], !0);
          }
          for (q = ge ? q : L; ++q < L; ) {
            ue = T[q];
            var Ce = Ch(ue), Pe = Ce == "wrapper" ? ty(ue) : r;
            Pe && ay(Pe[0]) && Pe[1] == (S | x | b | D) && !Pe[4].length && Pe[9] == 1 ? ge = ge[Ch(Pe[0])].apply(ge, Pe[3]) : ge = ue.length == 1 && ay(ue) ? ge[Ce]() : ge.thru(ue);
          }
          return function() {
            var rt = arguments, it = rt[0];
            if (ge && rt.length == 1 && br(it))
              return ge.plant(it).value();
            for (var dt = 0, St = L ? T[dt].apply(this, rt) : it; ++dt < L; )
              St = T[dt].call(this, St);
            return St;
          };
        });
      }
      function _h(C, T, L, q, Z, ue, ge, Ce, Pe, rt) {
        var it = T & S, dt = T & g, St = T & h, Rt = T & (x | A), Qt = T & I, wr = St ? r : H0(C);
        function Jt() {
          for (var Tr = arguments.length, Lr = je(Tr), Bo = Tr; Bo--; )
            Lr[Bo] = arguments[Bo];
          if (Rt)
            var Ha = Xf(Jt), Fo = zR(Lr, Ha);
          if (q && (Lr = Ux(Lr, q, Z, Rt)), ue && (Lr = Hx(Lr, ue, ge, Rt)), Tr -= Fo, Rt && Tr < rt) {
            var vi = $c(Lr, Ha);
            return Qx(
              C,
              T,
              _h,
              Jt.placeholder,
              L,
              Lr,
              vi,
              Ce,
              Pe,
              rt - Tr
            );
          }
          var zu = dt ? L : this, Zs = St ? zu[C] : C;
          return Tr = Lr.length, Ce ? Lr = jL(Lr, Ce) : Qt && Tr > 1 && Lr.reverse(), it && Pe < Tr && (Lr.length = Pe), this && this !== ca && this instanceof Jt && (Zs = wr || H0(Zs)), Zs.apply(zu, Lr);
        }
        return Jt;
      }
      function Wx(C, T) {
        return function(L, q) {
          return tL(L, C, T(q), {});
        };
      }
      function xh(C, T) {
        return function(L, q) {
          var Z;
          if (L === r && q === r)
            return T;
          if (L !== r && (Z = L), q !== r) {
            if (Z === r)
              return q;
            typeof L == "string" || typeof q == "string" ? (L = To(L), q = To(q)) : (L = Nx(L), q = Nx(q)), Z = C(L, q);
          }
          return Z;
        };
      }
      function Q3(C) {
        return Xs(function(T) {
          return T = Vn(T, Mo(jt())), Dr(function(L) {
            var q = this;
            return C(T, function(Z) {
              return Eo(Z, q, L);
            });
          });
        });
      }
      function Ah(C, T) {
        T = T === r ? " " : To(T);
        var L = T.length;
        if (L < 2)
          return L ? q3(T, C) : T;
        var q = q3(T, sh(C / kf(T)));
        return Lf(T) ? il(Ou(q), 0, C).join("") : q.slice(0, C);
      }
      function EL(C, T, L, q) {
        var Z = T & g, ue = H0(C);
        function ge() {
          for (var Ce = -1, Pe = arguments.length, rt = -1, it = q.length, dt = je(it + Pe), St = this && this !== ca && this instanceof ge ? ue : C; ++rt < it; )
            dt[rt] = q[rt];
          for (; Pe--; )
            dt[rt++] = arguments[++Ce];
          return Eo(St, Z ? L : this, dt);
        }
        return ge;
      }
      function Zx(C) {
        return function(T, L, q) {
          return q && typeof q != "number" && Ua(T, L, q) && (L = q = r), T = Ws(T), L === r ? (L = T, T = 0) : L = Ws(L), q = q === r ? T < L ? 1 : -1 : Ws(q), pL(T, L, q, C);
        };
      }
      function Sh(C) {
        return function(T, L) {
          return typeof T == "string" && typeof L == "string" || (T = au(T), L = au(L)), C(T, L);
        };
      }
      function Qx(C, T, L, q, Z, ue, ge, Ce, Pe, rt) {
        var it = T & x, dt = it ? ge : r, St = it ? r : ge, Rt = it ? ue : r, Qt = it ? r : ue;
        T |= it ? b : _, T &= ~(it ? _ : b), T & y || (T &= ~(g | h));
        var wr = [
          C,
          T,
          Z,
          Rt,
          dt,
          Qt,
          St,
          Ce,
          Pe,
          rt
        ], Jt = L.apply(r, wr);
        return ay(C) && c7(Jt, wr), Jt.placeholder = q, l7(Jt, C, T);
      }
      function J3(C) {
        var T = Ni[C];
        return function(L, q) {
          if (L = au(L), q = q == null ? 0 : Sa(Sr(q), 292), q && lx(L)) {
            var Z = (an(L) + "e").split("e"), ue = T(Z[0] + "e" + (+Z[1] + q));
            return Z = (an(ue) + "e").split("e"), +(Z[0] + "e" + (+Z[1] - q));
          }
          return T(L);
        };
      }
      var ML = Vf && 1 / Jm(new Vf([, -0]))[1] == z ? function(C) {
        return new Vf(C);
      } : _y;
      function Jx(C) {
        return function(T) {
          var L = Ca(T);
          return L == we ? E3(T) : L == Ne ? XR(T) : kR(T, C(T));
        };
      }
      function Ks(C, T, L, q, Z, ue, ge, Ce) {
        var Pe = T & h;
        if (!Pe && typeof C != "function")
          throw new eu(o);
        var rt = q ? q.length : 0;
        if (rt || (T &= ~(b | _), q = Z = r), ge = ge === r ? ge : Ri(Sr(ge), 0), Ce = Ce === r ? Ce : Sr(Ce), rt -= Z ? Z.length : 0, T & _) {
          var it = q, dt = Z;
          q = Z = r;
        }
        var St = Pe ? r : ty(C), Rt = [
          C,
          T,
          L,
          q,
          Z,
          it,
          dt,
          ue,
          ge,
          Ce
        ];
        if (St && qL(Rt, St), C = Rt[0], T = Rt[1], L = Rt[2], q = Rt[3], Z = Rt[4], Ce = Rt[9] = Rt[9] === r ? Pe ? 0 : C.length : Ri(Rt[9] - rt, 0), !Ce && T & (x | A) && (T &= ~(x | A)), !T || T == g)
          var Qt = DL(C, T, L);
        else T == x || T == A ? Qt = IL(C, T, Ce) : (T == b || T == (g | b)) && !Z.length ? Qt = EL(C, T, L, q) : Qt = _h.apply(r, Rt);
        var wr = St ? Bx : c7;
        return l7(wr(Qt, Rt), C, T);
      }
      function $x(C, T, L, q) {
        return C === r || ku(C, Gf[L]) && !fn.call(q, L) ? T : C;
      }
      function e7(C, T, L, q, Z, ue) {
        return Wn(C) && Wn(T) && (ue.set(T, C), vh(C, T, r, e7, ue), ue.delete(T)), C;
      }
      function TL(C) {
        return X0(C) ? r : C;
      }
      function t7(C, T, L, q, Z, ue) {
        var ge = L & v, Ce = C.length, Pe = T.length;
        if (Ce != Pe && !(ge && Pe > Ce))
          return !1;
        var rt = ue.get(C), it = ue.get(T);
        if (rt && it)
          return rt == T && it == C;
        var dt = -1, St = !0, Rt = L & p ? new yd() : r;
        for (ue.set(C, T), ue.set(T, C); ++dt < Ce; ) {
          var Qt = C[dt], wr = T[dt];
          if (q)
            var Jt = ge ? q(wr, Qt, dt, T, C, ue) : q(Qt, wr, dt, C, T, ue);
          if (Jt !== r) {
            if (Jt)
              continue;
            St = !1;
            break;
          }
          if (Rt) {
            if (!A3(T, function(Tr, Lr) {
              if (!B0(Rt, Lr) && (Qt === Tr || Z(Qt, Tr, L, q, ue)))
                return Rt.push(Lr);
            })) {
              St = !1;
              break;
            }
          } else if (!(Qt === wr || Z(Qt, wr, L, q, ue))) {
            St = !1;
            break;
          }
        }
        return ue.delete(C), ue.delete(T), St;
      }
      function PL(C, T, L, q, Z, ue, ge) {
        switch (L) {
          case he:
            if (C.byteLength != T.byteLength || C.byteOffset != T.byteOffset)
              return !1;
            C = C.buffer, T = T.buffer;
          case ve:
            return !(C.byteLength != T.byteLength || !ue(new ih(C), new ih(T)));
          case $:
          case ie:
          case Ge:
            return ku(+C, +T);
          case se:
            return C.name == T.name && C.message == T.message;
          case Je:
          case nt:
            return C == T + "";
          case we:
            var Ce = E3;
          case Ne:
            var Pe = q & v;
            if (Ce || (Ce = Jm), C.size != T.size && !Pe)
              return !1;
            var rt = ge.get(C);
            if (rt)
              return rt == T;
            q |= p, ge.set(C, T);
            var it = t7(Ce(C), Ce(T), q, Z, ue, ge);
            return ge.delete(C), it;
          case re:
            if (L0)
              return L0.call(C) == L0.call(T);
        }
        return !1;
      }
      function BL(C, T, L, q, Z, ue) {
        var ge = L & v, Ce = $3(C), Pe = Ce.length, rt = $3(T), it = rt.length;
        if (Pe != it && !ge)
          return !1;
        for (var dt = Pe; dt--; ) {
          var St = Ce[dt];
          if (!(ge ? St in T : fn.call(T, St)))
            return !1;
        }
        var Rt = ue.get(C), Qt = ue.get(T);
        if (Rt && Qt)
          return Rt == T && Qt == C;
        var wr = !0;
        ue.set(C, T), ue.set(T, C);
        for (var Jt = ge; ++dt < Pe; ) {
          St = Ce[dt];
          var Tr = C[St], Lr = T[St];
          if (q)
            var Bo = ge ? q(Lr, Tr, St, T, C, ue) : q(Tr, Lr, St, C, T, ue);
          if (!(Bo === r ? Tr === Lr || Z(Tr, Lr, L, q, ue) : Bo)) {
            wr = !1;
            break;
          }
          Jt || (Jt = St == "constructor");
        }
        if (wr && !Jt) {
          var Ha = C.constructor, Fo = T.constructor;
          Ha != Fo && "constructor" in C && "constructor" in T && !(typeof Ha == "function" && Ha instanceof Ha && typeof Fo == "function" && Fo instanceof Fo) && (wr = !1);
        }
        return ue.delete(C), ue.delete(T), wr;
      }
      function Xs(C) {
        return uy(u7(C, r, v7), C + "");
      }
      function $3(C) {
        return xx(C, Xi, ny);
      }
      function ey(C) {
        return xx(C, uo, r7);
      }
      var ty = lh ? function(C) {
        return lh.get(C);
      } : _y;
      function Ch(C) {
        for (var T = C.name + "", L = Uf[T], q = fn.call(Uf, T) ? L.length : 0; q--; ) {
          var Z = L[q], ue = Z.func;
          if (ue == null || ue == C)
            return Z.name;
        }
        return T;
      }
      function Xf(C) {
        var T = fn.call(ne, "placeholder") ? ne : C;
        return T.placeholder;
      }
      function jt() {
        var C = ne.iteratee || yy;
        return C = C === yy ? Cx : C, arguments.length ? C(arguments[0], arguments[1]) : C;
      }
      function wh(C, T) {
        var L = C.__data__;
        return GL(T) ? L[typeof T == "string" ? "string" : "hash"] : L.map;
      }
      function ry(C) {
        for (var T = Xi(C), L = T.length; L--; ) {
          var q = T[L], Z = C[q];
          T[L] = [q, Z, a7(Z)];
        }
        return T;
      }
      function xd(C, T) {
        var L = HR(C, T);
        return Sx(L) ? L : r;
      }
      function FL(C) {
        var T = fn.call(C, vd), L = C[vd];
        try {
          C[vd] = r;
          var q = !0;
        } catch {
        }
        var Z = rh.call(C);
        return q && (T ? C[vd] = L : delete C[vd]), Z;
      }
      var ny = T3 ? function(C) {
        return C == null ? [] : (C = Dn(C), Qc(T3(C), function(T) {
          return sx.call(C, T);
        }));
      } : xy, r7 = T3 ? function(C) {
        for (var T = []; C; )
          Jc(T, ny(C)), C = ah(C);
        return T;
      } : xy, Ca = Va;
      (P3 && Ca(new P3(new ArrayBuffer(1))) != he || N0 && Ca(new N0()) != we || B3 && Ca(B3.resolve()) != Ze || Vf && Ca(new Vf()) != Ne || R0 && Ca(new R0()) != ce) && (Ca = function(C) {
        var T = Va(C), L = T == Ke ? C.constructor : r, q = L ? Ad(L) : "";
        if (q)
          switch (q) {
            case hO:
              return he;
            case vO:
              return we;
            case gO:
              return Ze;
            case yO:
              return Ne;
            case bO:
              return ce;
          }
        return T;
      });
      function NL(C, T, L) {
        for (var q = -1, Z = L.length; ++q < Z; ) {
          var ue = L[q], ge = ue.size;
          switch (ue.type) {
            case "drop":
              C += ge;
              break;
            case "dropRight":
              T -= ge;
              break;
            case "take":
              T = Sa(T, C + ge);
              break;
            case "takeRight":
              C = Ri(C, T - ge);
              break;
          }
        }
        return { start: C, end: T };
      }
      function RL(C) {
        var T = C.match(wo);
        return T ? T[1].split(Do) : [];
      }
      function n7(C, T, L) {
        T = nl(T, C);
        for (var q = -1, Z = T.length, ue = !1; ++q < Z; ) {
          var ge = ls(T[q]);
          if (!(ue = C != null && L(C, ge)))
            break;
          C = C[ge];
        }
        return ue || ++q != Z ? ue : (Z = C == null ? 0 : C.length, !!Z && Bh(Z) && js(ge, Z) && (br(C) || Sd(C)));
      }
      function OL(C) {
        var T = C.length, L = new C.constructor(T);
        return T && typeof C[0] == "string" && fn.call(C, "index") && (L.index = C.index, L.input = C.input), L;
      }
      function i7(C) {
        return typeof C.constructor == "function" && !q0(C) ? Hf(ah(C)) : {};
      }
      function LL(C, T, L) {
        var q = C.constructor;
        switch (T) {
          case ve:
            return Z3(C);
          case $:
          case ie:
            return new q(+C);
          case he:
            return _L(C, L);
          case Se:
          case Re:
          case Ve:
          case ze:
          case mt:
          case bt:
          case Ct:
          case De:
          case ut:
            return Gx(C, L);
          case we:
            return new q();
          case Ge:
          case nt:
            return new q(C);
          case Je:
            return xL(C);
          case Ne:
            return new q();
          case re:
            return AL(C);
        }
      }
      function kL(C, T) {
        var L = T.length;
        if (!L)
          return C;
        var q = L - 1;
        return T[q] = (L > 1 ? "& " : "") + T[q], T = T.join(L > 2 ? ", " : " "), C.replace(dn, `{
/* [wrapped with ` + T + `] */
`);
      }
      function zL(C) {
        return br(C) || Sd(C) || !!(cx && C && C[cx]);
      }
      function js(C, T) {
        var L = typeof C;
        return T = T ?? V, !!T && (L == "number" || L != "symbol" && jc.test(C)) && C > -1 && C % 1 == 0 && C < T;
      }
      function Ua(C, T, L) {
        if (!Wn(L))
          return !1;
        var q = typeof T;
        return (q == "number" ? oo(L) && js(T, L.length) : q == "string" && T in L) ? ku(L[T], C) : !1;
      }
      function iy(C, T) {
        if (br(C))
          return !1;
        var L = typeof C;
        return L == "number" || L == "symbol" || L == "boolean" || C == null || Po(C) ? !0 : $r.test(C) || !ni.test(C) || T != null && C in Dn(T);
      }
      function GL(C) {
        var T = typeof C;
        return T == "string" || T == "number" || T == "symbol" || T == "boolean" ? C !== "__proto__" : C === null;
      }
      function ay(C) {
        var T = Ch(C), L = ne[T];
        if (typeof L != "function" || !(T in Nr.prototype))
          return !1;
        if (C === L)
          return !0;
        var q = ty(L);
        return !!q && C === q[0];
      }
      function VL(C) {
        return !!ax && ax in C;
      }
      var UL = eh ? Ys : Ay;
      function q0(C) {
        var T = C && C.constructor, L = typeof T == "function" && T.prototype || Gf;
        return C === L;
      }
      function a7(C) {
        return C === C && !Wn(C);
      }
      function o7(C, T) {
        return function(L) {
          return L == null ? !1 : L[C] === T && (T !== r || C in Dn(L));
        };
      }
      function HL(C) {
        var T = Th(C, function(q) {
          return L.size === c && L.clear(), q;
        }), L = T.cache;
        return T;
      }
      function qL(C, T) {
        var L = C[1], q = T[1], Z = L | q, ue = Z < (g | h | S), ge = q == S && L == x || q == S && L == D && C[7].length <= T[8] || q == (S | D) && T[7].length <= T[8] && L == x;
        if (!(ue || ge))
          return C;
        q & g && (C[2] = T[2], Z |= L & g ? 0 : y);
        var Ce = T[3];
        if (Ce) {
          var Pe = C[3];
          C[3] = Pe ? Ux(Pe, Ce, T[4]) : Ce, C[4] = Pe ? $c(C[3], l) : T[4];
        }
        return Ce = T[5], Ce && (Pe = C[5], C[5] = Pe ? Hx(Pe, Ce, T[6]) : Ce, C[6] = Pe ? $c(C[5], l) : T[6]), Ce = T[7], Ce && (C[7] = Ce), q & S && (C[8] = C[8] == null ? T[8] : Sa(C[8], T[8])), C[9] == null && (C[9] = T[9]), C[0] = T[0], C[1] = Z, C;
      }
      function KL(C) {
        var T = [];
        if (C != null)
          for (var L in Dn(C))
            T.push(L);
        return T;
      }
      function XL(C) {
        return rh.call(C);
      }
      function u7(C, T, L) {
        return T = Ri(T === r ? C.length - 1 : T, 0), function() {
          for (var q = arguments, Z = -1, ue = Ri(q.length - T, 0), ge = je(ue); ++Z < ue; )
            ge[Z] = q[T + Z];
          Z = -1;
          for (var Ce = je(T + 1); ++Z < T; )
            Ce[Z] = q[Z];
          return Ce[T] = L(ge), Eo(C, this, Ce);
        };
      }
      function s7(C, T) {
        return T.length < 2 ? C : _d(C, nu(T, 0, -1));
      }
      function jL(C, T) {
        for (var L = C.length, q = Sa(T.length, L), Z = ao(C); q--; ) {
          var ue = T[q];
          C[q] = js(ue, L) ? Z[ue] : r;
        }
        return C;
      }
      function oy(C, T) {
        if (!(T === "constructor" && typeof C[T] == "function") && T != "__proto__")
          return C[T];
      }
      var c7 = d7(Bx), K0 = sO || function(C, T) {
        return ca.setTimeout(C, T);
      }, uy = d7(vL);
      function l7(C, T, L) {
        var q = T + "";
        return uy(C, kL(q, YL(RL(q), L)));
      }
      function d7(C) {
        var T = 0, L = 0;
        return function() {
          var q = fO(), Z = E - (q - L);
          if (L = q, Z > 0) {
            if (++T >= P)
              return arguments[0];
          } else
            T = 0;
          return C.apply(r, arguments);
        };
      }
      function Dh(C, T) {
        var L = -1, q = C.length, Z = q - 1;
        for (T = T === r ? q : T; ++L < T; ) {
          var ue = H3(L, Z), ge = C[ue];
          C[ue] = C[L], C[L] = ge;
        }
        return C.length = T, C;
      }
      var f7 = HL(function(C) {
        var T = [];
        return C.charCodeAt(0) === 46 && T.push(""), C.replace(en, function(L, q, Z, ue) {
          T.push(Z ? ue.replace(Ga, "$1") : q || L);
        }), T;
      });
      function ls(C) {
        if (typeof C == "string" || Po(C))
          return C;
        var T = C + "";
        return T == "0" && 1 / C == -z ? "-0" : T;
      }
      function Ad(C) {
        if (C != null) {
          try {
            return th.call(C);
          } catch {
          }
          try {
            return C + "";
          } catch {
          }
        }
        return "";
      }
      function YL(C, T) {
        return $o(W, function(L) {
          var q = "_." + L[0];
          T & L[1] && !Zm(C, q) && C.push(q);
        }), C.sort();
      }
      function p7(C) {
        if (C instanceof Nr)
          return C.clone();
        var T = new tu(C.__wrapped__, C.__chain__);
        return T.__actions__ = ao(C.__actions__), T.__index__ = C.__index__, T.__values__ = C.__values__, T;
      }
      function WL(C, T, L) {
        (L ? Ua(C, T, L) : T === r) ? T = 1 : T = Ri(Sr(T), 0);
        var q = C == null ? 0 : C.length;
        if (!q || T < 1)
          return [];
        for (var Z = 0, ue = 0, ge = je(sh(q / T)); Z < q; )
          ge[ue++] = nu(C, Z, Z += T);
        return ge;
      }
      function ZL(C) {
        for (var T = -1, L = C == null ? 0 : C.length, q = 0, Z = []; ++T < L; ) {
          var ue = C[T];
          ue && (Z[q++] = ue);
        }
        return Z;
      }
      function QL() {
        var C = arguments.length;
        if (!C)
          return [];
        for (var T = je(C - 1), L = arguments[0], q = C; q--; )
          T[q - 1] = arguments[q];
        return Jc(br(L) ? ao(L) : [L], la(T, 1));
      }
      var JL = Dr(function(C, T) {
        return hi(C) ? z0(C, la(T, 1, hi, !0)) : [];
      }), $L = Dr(function(C, T) {
        var L = iu(T);
        return hi(L) && (L = r), hi(C) ? z0(C, la(T, 1, hi, !0), jt(L, 2)) : [];
      }), ek = Dr(function(C, T) {
        var L = iu(T);
        return hi(L) && (L = r), hi(C) ? z0(C, la(T, 1, hi, !0), r, L) : [];
      });
      function tk(C, T, L) {
        var q = C == null ? 0 : C.length;
        return q ? (T = L || T === r ? 1 : Sr(T), nu(C, T < 0 ? 0 : T, q)) : [];
      }
      function rk(C, T, L) {
        var q = C == null ? 0 : C.length;
        return q ? (T = L || T === r ? 1 : Sr(T), T = q - T, nu(C, 0, T < 0 ? 0 : T)) : [];
      }
      function nk(C, T) {
        return C && C.length ? yh(C, jt(T, 3), !0, !0) : [];
      }
      function ik(C, T) {
        return C && C.length ? yh(C, jt(T, 3), !0) : [];
      }
      function ak(C, T, L, q) {
        var Z = C == null ? 0 : C.length;
        return Z ? (L && typeof L != "number" && Ua(C, T, L) && (L = 0, q = Z), QO(C, T, L, q)) : [];
      }
      function m7(C, T, L) {
        var q = C == null ? 0 : C.length;
        if (!q)
          return -1;
        var Z = L == null ? 0 : Sr(L);
        return Z < 0 && (Z = Ri(q + Z, 0)), Qm(C, jt(T, 3), Z);
      }
      function h7(C, T, L) {
        var q = C == null ? 0 : C.length;
        if (!q)
          return -1;
        var Z = q - 1;
        return L !== r && (Z = Sr(L), Z = L < 0 ? Ri(q + Z, 0) : Sa(Z, q - 1)), Qm(C, jt(T, 3), Z, !0);
      }
      function v7(C) {
        var T = C == null ? 0 : C.length;
        return T ? la(C, 1) : [];
      }
      function ok(C) {
        var T = C == null ? 0 : C.length;
        return T ? la(C, z) : [];
      }
      function uk(C, T) {
        var L = C == null ? 0 : C.length;
        return L ? (T = T === r ? 1 : Sr(T), la(C, T)) : [];
      }
      function sk(C) {
        for (var T = -1, L = C == null ? 0 : C.length, q = {}; ++T < L; ) {
          var Z = C[T];
          q[Z[0]] = Z[1];
        }
        return q;
      }
      function g7(C) {
        return C && C.length ? C[0] : r;
      }
      function ck(C, T, L) {
        var q = C == null ? 0 : C.length;
        if (!q)
          return -1;
        var Z = L == null ? 0 : Sr(L);
        return Z < 0 && (Z = Ri(q + Z, 0)), Of(C, T, Z);
      }
      function lk(C) {
        var T = C == null ? 0 : C.length;
        return T ? nu(C, 0, -1) : [];
      }
      var dk = Dr(function(C) {
        var T = Vn(C, Y3);
        return T.length && T[0] === C[0] ? k3(T) : [];
      }), fk = Dr(function(C) {
        var T = iu(C), L = Vn(C, Y3);
        return T === iu(L) ? T = r : L.pop(), L.length && L[0] === C[0] ? k3(L, jt(T, 2)) : [];
      }), pk = Dr(function(C) {
        var T = iu(C), L = Vn(C, Y3);
        return T = typeof T == "function" ? T : r, T && L.pop(), L.length && L[0] === C[0] ? k3(L, r, T) : [];
      });
      function mk(C, T) {
        return C == null ? "" : lO.call(C, T);
      }
      function iu(C) {
        var T = C == null ? 0 : C.length;
        return T ? C[T - 1] : r;
      }
      function hk(C, T, L) {
        var q = C == null ? 0 : C.length;
        if (!q)
          return -1;
        var Z = q;
        return L !== r && (Z = Sr(L), Z = Z < 0 ? Ri(q + Z, 0) : Sa(Z, q - 1)), T === T ? YR(C, T, Z) : Qm(C, Q8, Z, !0);
      }
      function vk(C, T) {
        return C && C.length ? Ex(C, Sr(T)) : r;
      }
      var gk = Dr(y7);
      function y7(C, T) {
        return C && C.length && T && T.length ? U3(C, T) : C;
      }
      function yk(C, T, L) {
        return C && C.length && T && T.length ? U3(C, T, jt(L, 2)) : C;
      }
      function bk(C, T, L) {
        return C && C.length && T && T.length ? U3(C, T, r, L) : C;
      }
      var _k = Xs(function(C, T) {
        var L = C == null ? 0 : C.length, q = N3(C, T);
        return Px(C, Vn(T, function(Z) {
          return js(Z, L) ? +Z : Z;
        }).sort(Vx)), q;
      });
      function xk(C, T) {
        var L = [];
        if (!(C && C.length))
          return L;
        var q = -1, Z = [], ue = C.length;
        for (T = jt(T, 3); ++q < ue; ) {
          var ge = C[q];
          T(ge, q, C) && (L.push(ge), Z.push(q));
        }
        return Px(C, Z), L;
      }
      function sy(C) {
        return C == null ? C : mO.call(C);
      }
      function Ak(C, T, L) {
        var q = C == null ? 0 : C.length;
        return q ? (L && typeof L != "number" && Ua(C, T, L) ? (T = 0, L = q) : (T = T == null ? 0 : Sr(T), L = L === r ? q : Sr(L)), nu(C, T, L)) : [];
      }
      function Sk(C, T) {
        return gh(C, T);
      }
      function Ck(C, T, L) {
        return K3(C, T, jt(L, 2));
      }
      function wk(C, T) {
        var L = C == null ? 0 : C.length;
        if (L) {
          var q = gh(C, T);
          if (q < L && ku(C[q], T))
            return q;
        }
        return -1;
      }
      function Dk(C, T) {
        return gh(C, T, !0);
      }
      function Ik(C, T, L) {
        return K3(C, T, jt(L, 2), !0);
      }
      function Ek(C, T) {
        var L = C == null ? 0 : C.length;
        if (L) {
          var q = gh(C, T, !0) - 1;
          if (ku(C[q], T))
            return q;
        }
        return -1;
      }
      function Mk(C) {
        return C && C.length ? Fx(C) : [];
      }
      function Tk(C, T) {
        return C && C.length ? Fx(C, jt(T, 2)) : [];
      }
      function Pk(C) {
        var T = C == null ? 0 : C.length;
        return T ? nu(C, 1, T) : [];
      }
      function Bk(C, T, L) {
        return C && C.length ? (T = L || T === r ? 1 : Sr(T), nu(C, 0, T < 0 ? 0 : T)) : [];
      }
      function Fk(C, T, L) {
        var q = C == null ? 0 : C.length;
        return q ? (T = L || T === r ? 1 : Sr(T), T = q - T, nu(C, T < 0 ? 0 : T, q)) : [];
      }
      function Nk(C, T) {
        return C && C.length ? yh(C, jt(T, 3), !1, !0) : [];
      }
      function Rk(C, T) {
        return C && C.length ? yh(C, jt(T, 3)) : [];
      }
      var Ok = Dr(function(C) {
        return rl(la(C, 1, hi, !0));
      }), Lk = Dr(function(C) {
        var T = iu(C);
        return hi(T) && (T = r), rl(la(C, 1, hi, !0), jt(T, 2));
      }), kk = Dr(function(C) {
        var T = iu(C);
        return T = typeof T == "function" ? T : r, rl(la(C, 1, hi, !0), r, T);
      });
      function zk(C) {
        return C && C.length ? rl(C) : [];
      }
      function Gk(C, T) {
        return C && C.length ? rl(C, jt(T, 2)) : [];
      }
      function Vk(C, T) {
        return T = typeof T == "function" ? T : r, C && C.length ? rl(C, r, T) : [];
      }
      function cy(C) {
        if (!(C && C.length))
          return [];
        var T = 0;
        return C = Qc(C, function(L) {
          if (hi(L))
            return T = Ri(L.length, T), !0;
        }), D3(T, function(L) {
          return Vn(C, S3(L));
        });
      }
      function b7(C, T) {
        if (!(C && C.length))
          return [];
        var L = cy(C);
        return T == null ? L : Vn(L, function(q) {
          return Eo(T, r, q);
        });
      }
      var Uk = Dr(function(C, T) {
        return hi(C) ? z0(C, T) : [];
      }), Hk = Dr(function(C) {
        return j3(Qc(C, hi));
      }), qk = Dr(function(C) {
        var T = iu(C);
        return hi(T) && (T = r), j3(Qc(C, hi), jt(T, 2));
      }), Kk = Dr(function(C) {
        var T = iu(C);
        return T = typeof T == "function" ? T : r, j3(Qc(C, hi), r, T);
      }), Xk = Dr(cy);
      function jk(C, T) {
        return Lx(C || [], T || [], k0);
      }
      function Yk(C, T) {
        return Lx(C || [], T || [], U0);
      }
      var Wk = Dr(function(C) {
        var T = C.length, L = T > 1 ? C[T - 1] : r;
        return L = typeof L == "function" ? (C.pop(), L) : r, b7(C, L);
      });
      function _7(C) {
        var T = ne(C);
        return T.__chain__ = !0, T;
      }
      function Zk(C, T) {
        return T(C), C;
      }
      function Ih(C, T) {
        return T(C);
      }
      var Qk = Xs(function(C) {
        var T = C.length, L = T ? C[0] : 0, q = this.__wrapped__, Z = function(ue) {
          return N3(ue, C);
        };
        return T > 1 || this.__actions__.length || !(q instanceof Nr) || !js(L) ? this.thru(Z) : (q = q.slice(L, +L + (T ? 1 : 0)), q.__actions__.push({
          func: Ih,
          args: [Z],
          thisArg: r
        }), new tu(q, this.__chain__).thru(function(ue) {
          return T && !ue.length && ue.push(r), ue;
        }));
      });
      function Jk() {
        return _7(this);
      }
      function $k() {
        return new tu(this.value(), this.__chain__);
      }
      function ez() {
        this.__values__ === r && (this.__values__ = N7(this.value()));
        var C = this.__index__ >= this.__values__.length, T = C ? r : this.__values__[this.__index__++];
        return { done: C, value: T };
      }
      function tz() {
        return this;
      }
      function rz(C) {
        for (var T, L = this; L instanceof fh; ) {
          var q = p7(L);
          q.__index__ = 0, q.__values__ = r, T ? Z.__wrapped__ = q : T = q;
          var Z = q;
          L = L.__wrapped__;
        }
        return Z.__wrapped__ = C, T;
      }
      function nz() {
        var C = this.__wrapped__;
        if (C instanceof Nr) {
          var T = C;
          return this.__actions__.length && (T = new Nr(this)), T = T.reverse(), T.__actions__.push({
            func: Ih,
            args: [sy],
            thisArg: r
          }), new tu(T, this.__chain__);
        }
        return this.thru(sy);
      }
      function iz() {
        return Ox(this.__wrapped__, this.__actions__);
      }
      var az = bh(function(C, T, L) {
        fn.call(C, L) ? ++C[L] : qs(C, L, 1);
      });
      function oz(C, T, L) {
        var q = br(C) ? W8 : ZO;
        return L && Ua(C, T, L) && (T = r), q(C, jt(T, 3));
      }
      function uz(C, T) {
        var L = br(C) ? Qc : bx;
        return L(C, jt(T, 3));
      }
      var sz = jx(m7), cz = jx(h7);
      function lz(C, T) {
        return la(Eh(C, T), 1);
      }
      function dz(C, T) {
        return la(Eh(C, T), z);
      }
      function fz(C, T, L) {
        return L = L === r ? 1 : Sr(L), la(Eh(C, T), L);
      }
      function x7(C, T) {
        var L = br(C) ? $o : tl;
        return L(C, jt(T, 3));
      }
      function A7(C, T) {
        var L = br(C) ? PR : yx;
        return L(C, jt(T, 3));
      }
      var pz = bh(function(C, T, L) {
        fn.call(C, L) ? C[L].push(T) : qs(C, L, [T]);
      });
      function mz(C, T, L, q) {
        C = oo(C) ? C : Yf(C), L = L && !q ? Sr(L) : 0;
        var Z = C.length;
        return L < 0 && (L = Ri(Z + L, 0)), Fh(C) ? L <= Z && C.indexOf(T, L) > -1 : !!Z && Of(C, T, L) > -1;
      }
      var hz = Dr(function(C, T, L) {
        var q = -1, Z = typeof T == "function", ue = oo(C) ? je(C.length) : [];
        return tl(C, function(ge) {
          ue[++q] = Z ? Eo(T, ge, L) : G0(ge, T, L);
        }), ue;
      }), vz = bh(function(C, T, L) {
        qs(C, L, T);
      });
      function Eh(C, T) {
        var L = br(C) ? Vn : wx;
        return L(C, jt(T, 3));
      }
      function gz(C, T, L, q) {
        return C == null ? [] : (br(T) || (T = T == null ? [] : [T]), L = q ? r : L, br(L) || (L = L == null ? [] : [L]), Mx(C, T, L));
      }
      var yz = bh(function(C, T, L) {
        C[L ? 0 : 1].push(T);
      }, function() {
        return [[], []];
      });
      function bz(C, T, L) {
        var q = br(C) ? x3 : $8, Z = arguments.length < 3;
        return q(C, jt(T, 4), L, Z, tl);
      }
      function _z(C, T, L) {
        var q = br(C) ? BR : $8, Z = arguments.length < 3;
        return q(C, jt(T, 4), L, Z, yx);
      }
      function xz(C, T) {
        var L = br(C) ? Qc : bx;
        return L(C, Ph(jt(T, 3)));
      }
      function Az(C) {
        var T = br(C) ? mx : mL;
        return T(C);
      }
      function Sz(C, T, L) {
        (L ? Ua(C, T, L) : T === r) ? T = 1 : T = Sr(T);
        var q = br(C) ? KO : hL;
        return q(C, T);
      }
      function Cz(C) {
        var T = br(C) ? XO : gL;
        return T(C);
      }
      function wz(C) {
        if (C == null)
          return 0;
        if (oo(C))
          return Fh(C) ? kf(C) : C.length;
        var T = Ca(C);
        return T == we || T == Ne ? C.size : G3(C).length;
      }
      function Dz(C, T, L) {
        var q = br(C) ? A3 : yL;
        return L && Ua(C, T, L) && (T = r), q(C, jt(T, 3));
      }
      var Iz = Dr(function(C, T) {
        if (C == null)
          return [];
        var L = T.length;
        return L > 1 && Ua(C, T[0], T[1]) ? T = [] : L > 2 && Ua(T[0], T[1], T[2]) && (T = [T[0]]), Mx(C, la(T, 1), []);
      }), Mh = uO || function() {
        return ca.Date.now();
      };
      function Ez(C, T) {
        if (typeof T != "function")
          throw new eu(o);
        return C = Sr(C), function() {
          if (--C < 1)
            return T.apply(this, arguments);
        };
      }
      function S7(C, T, L) {
        return T = L ? r : T, T = C && T == null ? C.length : T, Ks(C, S, r, r, r, r, T);
      }
      function C7(C, T) {
        var L;
        if (typeof T != "function")
          throw new eu(o);
        return C = Sr(C), function() {
          return --C > 0 && (L = T.apply(this, arguments)), C <= 1 && (T = r), L;
        };
      }
      var ly = Dr(function(C, T, L) {
        var q = g;
        if (L.length) {
          var Z = $c(L, Xf(ly));
          q |= b;
        }
        return Ks(C, q, T, L, Z);
      }), w7 = Dr(function(C, T, L) {
        var q = g | h;
        if (L.length) {
          var Z = $c(L, Xf(w7));
          q |= b;
        }
        return Ks(T, q, C, L, Z);
      });
      function D7(C, T, L) {
        T = L ? r : T;
        var q = Ks(C, x, r, r, r, r, r, T);
        return q.placeholder = D7.placeholder, q;
      }
      function I7(C, T, L) {
        T = L ? r : T;
        var q = Ks(C, A, r, r, r, r, r, T);
        return q.placeholder = I7.placeholder, q;
      }
      function E7(C, T, L) {
        var q, Z, ue, ge, Ce, Pe, rt = 0, it = !1, dt = !1, St = !0;
        if (typeof C != "function")
          throw new eu(o);
        T = au(T) || 0, Wn(L) && (it = !!L.leading, dt = "maxWait" in L, ue = dt ? Ri(au(L.maxWait) || 0, T) : ue, St = "trailing" in L ? !!L.trailing : St);
        function Rt(vi) {
          var zu = q, Zs = Z;
          return q = Z = r, rt = vi, ge = C.apply(Zs, zu), ge;
        }
        function Qt(vi) {
          return rt = vi, Ce = K0(Tr, T), it ? Rt(vi) : ge;
        }
        function wr(vi) {
          var zu = vi - Pe, Zs = vi - rt, j7 = T - zu;
          return dt ? Sa(j7, ue - Zs) : j7;
        }
        function Jt(vi) {
          var zu = vi - Pe, Zs = vi - rt;
          return Pe === r || zu >= T || zu < 0 || dt && Zs >= ue;
        }
        function Tr() {
          var vi = Mh();
          if (Jt(vi))
            return Lr(vi);
          Ce = K0(Tr, wr(vi));
        }
        function Lr(vi) {
          return Ce = r, St && q ? Rt(vi) : (q = Z = r, ge);
        }
        function Bo() {
          Ce !== r && kx(Ce), rt = 0, q = Pe = Z = Ce = r;
        }
        function Ha() {
          return Ce === r ? ge : Lr(Mh());
        }
        function Fo() {
          var vi = Mh(), zu = Jt(vi);
          if (q = arguments, Z = this, Pe = vi, zu) {
            if (Ce === r)
              return Qt(Pe);
            if (dt)
              return kx(Ce), Ce = K0(Tr, T), Rt(Pe);
          }
          return Ce === r && (Ce = K0(Tr, T)), ge;
        }
        return Fo.cancel = Bo, Fo.flush = Ha, Fo;
      }
      var Mz = Dr(function(C, T) {
        return gx(C, 1, T);
      }), Tz = Dr(function(C, T, L) {
        return gx(C, au(T) || 0, L);
      });
      function Pz(C) {
        return Ks(C, I);
      }
      function Th(C, T) {
        if (typeof C != "function" || T != null && typeof T != "function")
          throw new eu(o);
        var L = function() {
          var q = arguments, Z = T ? T.apply(this, q) : q[0], ue = L.cache;
          if (ue.has(Z))
            return ue.get(Z);
          var ge = C.apply(this, q);
          return L.cache = ue.set(Z, ge) || ue, ge;
        };
        return L.cache = new (Th.Cache || Hs)(), L;
      }
      Th.Cache = Hs;
      function Ph(C) {
        if (typeof C != "function")
          throw new eu(o);
        return function() {
          var T = arguments;
          switch (T.length) {
            case 0:
              return !C.call(this);
            case 1:
              return !C.call(this, T[0]);
            case 2:
              return !C.call(this, T[0], T[1]);
            case 3:
              return !C.call(this, T[0], T[1], T[2]);
          }
          return !C.apply(this, T);
        };
      }
      function Bz(C) {
        return C7(2, C);
      }
      var Fz = bL(function(C, T) {
        T = T.length == 1 && br(T[0]) ? Vn(T[0], Mo(jt())) : Vn(la(T, 1), Mo(jt()));
        var L = T.length;
        return Dr(function(q) {
          for (var Z = -1, ue = Sa(q.length, L); ++Z < ue; )
            q[Z] = T[Z].call(this, q[Z]);
          return Eo(C, this, q);
        });
      }), dy = Dr(function(C, T) {
        var L = $c(T, Xf(dy));
        return Ks(C, b, r, T, L);
      }), M7 = Dr(function(C, T) {
        var L = $c(T, Xf(M7));
        return Ks(C, _, r, T, L);
      }), Nz = Xs(function(C, T) {
        return Ks(C, D, r, r, r, T);
      });
      function Rz(C, T) {
        if (typeof C != "function")
          throw new eu(o);
        return T = T === r ? T : Sr(T), Dr(C, T);
      }
      function Oz(C, T) {
        if (typeof C != "function")
          throw new eu(o);
        return T = T == null ? 0 : Ri(Sr(T), 0), Dr(function(L) {
          var q = L[T], Z = il(L, 0, T);
          return q && Jc(Z, q), Eo(C, this, Z);
        });
      }
      function Lz(C, T, L) {
        var q = !0, Z = !0;
        if (typeof C != "function")
          throw new eu(o);
        return Wn(L) && (q = "leading" in L ? !!L.leading : q, Z = "trailing" in L ? !!L.trailing : Z), E7(C, T, {
          leading: q,
          maxWait: T,
          trailing: Z
        });
      }
      function kz(C) {
        return S7(C, 1);
      }
      function zz(C, T) {
        return dy(W3(T), C);
      }
      function Gz() {
        if (!arguments.length)
          return [];
        var C = arguments[0];
        return br(C) ? C : [C];
      }
      function Vz(C) {
        return ru(C, m);
      }
      function Uz(C, T) {
        return T = typeof T == "function" ? T : r, ru(C, m, T);
      }
      function Hz(C) {
        return ru(C, d | m);
      }
      function qz(C, T) {
        return T = typeof T == "function" ? T : r, ru(C, d | m, T);
      }
      function Kz(C, T) {
        return T == null || vx(C, T, Xi(T));
      }
      function ku(C, T) {
        return C === T || C !== C && T !== T;
      }
      var Xz = Sh(L3), jz = Sh(function(C, T) {
        return C >= T;
      }), Sd = Ax(/* @__PURE__ */ function() {
        return arguments;
      }()) ? Ax : function(C) {
        return ii(C) && fn.call(C, "callee") && !sx.call(C, "callee");
      }, br = je.isArray, Yz = H8 ? Mo(H8) : rL;
      function oo(C) {
        return C != null && Bh(C.length) && !Ys(C);
      }
      function hi(C) {
        return ii(C) && oo(C);
      }
      function Wz(C) {
        return C === !0 || C === !1 || ii(C) && Va(C) == $;
      }
      var al = cO || Ay, Zz = q8 ? Mo(q8) : nL;
      function Qz(C) {
        return ii(C) && C.nodeType === 1 && !X0(C);
      }
      function Jz(C) {
        if (C == null)
          return !0;
        if (oo(C) && (br(C) || typeof C == "string" || typeof C.splice == "function" || al(C) || jf(C) || Sd(C)))
          return !C.length;
        var T = Ca(C);
        if (T == we || T == Ne)
          return !C.size;
        if (q0(C))
          return !G3(C).length;
        for (var L in C)
          if (fn.call(C, L))
            return !1;
        return !0;
      }
      function $z(C, T) {
        return V0(C, T);
      }
      function eG(C, T, L) {
        L = typeof L == "function" ? L : r;
        var q = L ? L(C, T) : r;
        return q === r ? V0(C, T, r, L) : !!q;
      }
      function fy(C) {
        if (!ii(C))
          return !1;
        var T = Va(C);
        return T == se || T == ae || typeof C.message == "string" && typeof C.name == "string" && !X0(C);
      }
      function tG(C) {
        return typeof C == "number" && lx(C);
      }
      function Ys(C) {
        if (!Wn(C))
          return !1;
        var T = Va(C);
        return T == le || T == pe || T == ee || T == Fe;
      }
      function T7(C) {
        return typeof C == "number" && C == Sr(C);
      }
      function Bh(C) {
        return typeof C == "number" && C > -1 && C % 1 == 0 && C <= V;
      }
      function Wn(C) {
        var T = typeof C;
        return C != null && (T == "object" || T == "function");
      }
      function ii(C) {
        return C != null && typeof C == "object";
      }
      var P7 = K8 ? Mo(K8) : aL;
      function rG(C, T) {
        return C === T || z3(C, T, ry(T));
      }
      function nG(C, T, L) {
        return L = typeof L == "function" ? L : r, z3(C, T, ry(T), L);
      }
      function iG(C) {
        return B7(C) && C != +C;
      }
      function aG(C) {
        if (UL(C))
          throw new hr(a);
        return Sx(C);
      }
      function oG(C) {
        return C === null;
      }
      function uG(C) {
        return C == null;
      }
      function B7(C) {
        return typeof C == "number" || ii(C) && Va(C) == Ge;
      }
      function X0(C) {
        if (!ii(C) || Va(C) != Ke)
          return !1;
        var T = ah(C);
        if (T === null)
          return !0;
        var L = fn.call(T, "constructor") && T.constructor;
        return typeof L == "function" && L instanceof L && th.call(L) == nO;
      }
      var py = X8 ? Mo(X8) : oL;
      function sG(C) {
        return T7(C) && C >= -V && C <= V;
      }
      var F7 = j8 ? Mo(j8) : uL;
      function Fh(C) {
        return typeof C == "string" || !br(C) && ii(C) && Va(C) == nt;
      }
      function Po(C) {
        return typeof C == "symbol" || ii(C) && Va(C) == re;
      }
      var jf = Y8 ? Mo(Y8) : sL;
      function cG(C) {
        return C === r;
      }
      function lG(C) {
        return ii(C) && Ca(C) == ce;
      }
      function dG(C) {
        return ii(C) && Va(C) == de;
      }
      var fG = Sh(V3), pG = Sh(function(C, T) {
        return C <= T;
      });
      function N7(C) {
        if (!C)
          return [];
        if (oo(C))
          return Fh(C) ? Ou(C) : ao(C);
        if (F0 && C[F0])
          return KR(C[F0]());
        var T = Ca(C), L = T == we ? E3 : T == Ne ? Jm : Yf;
        return L(C);
      }
      function Ws(C) {
        if (!C)
          return C === 0 ? C : 0;
        if (C = au(C), C === z || C === -z) {
          var T = C < 0 ? -1 : 1;
          return T * U;
        }
        return C === C ? C : 0;
      }
      function Sr(C) {
        var T = Ws(C), L = T % 1;
        return T === T ? L ? T - L : T : 0;
      }
      function R7(C) {
        return C ? bd(Sr(C), 0, K) : 0;
      }
      function au(C) {
        if (typeof C == "number")
          return C;
        if (Po(C))
          return H;
        if (Wn(C)) {
          var T = typeof C.valueOf == "function" ? C.valueOf() : C;
          C = Wn(T) ? T + "" : T;
        }
        if (typeof C != "string")
          return C === 0 ? C : +C;
        C = ex(C);
        var L = qc.test(C);
        return L || Xc.test(C) ? ER(C.slice(2), L ? 2 : 8) : Hc.test(C) ? H : +C;
      }
      function O7(C) {
        return cs(C, uo(C));
      }
      function mG(C) {
        return C ? bd(Sr(C), -V, V) : C === 0 ? C : 0;
      }
      function an(C) {
        return C == null ? "" : To(C);
      }
      var hG = qf(function(C, T) {
        if (q0(T) || oo(T)) {
          cs(T, Xi(T), C);
          return;
        }
        for (var L in T)
          fn.call(T, L) && k0(C, L, T[L]);
      }), L7 = qf(function(C, T) {
        cs(T, uo(T), C);
      }), Nh = qf(function(C, T, L, q) {
        cs(T, uo(T), C, q);
      }), vG = qf(function(C, T, L, q) {
        cs(T, Xi(T), C, q);
      }), gG = Xs(N3);
      function yG(C, T) {
        var L = Hf(C);
        return T == null ? L : hx(L, T);
      }
      var bG = Dr(function(C, T) {
        C = Dn(C);
        var L = -1, q = T.length, Z = q > 2 ? T[2] : r;
        for (Z && Ua(T[0], T[1], Z) && (q = 1); ++L < q; )
          for (var ue = T[L], ge = uo(ue), Ce = -1, Pe = ge.length; ++Ce < Pe; ) {
            var rt = ge[Ce], it = C[rt];
            (it === r || ku(it, Gf[rt]) && !fn.call(C, rt)) && (C[rt] = ue[rt]);
          }
        return C;
      }), _G = Dr(function(C) {
        return C.push(r, e7), Eo(k7, r, C);
      });
      function xG(C, T) {
        return Z8(C, jt(T, 3), ss);
      }
      function AG(C, T) {
        return Z8(C, jt(T, 3), O3);
      }
      function SG(C, T) {
        return C == null ? C : R3(C, jt(T, 3), uo);
      }
      function CG(C, T) {
        return C == null ? C : _x(C, jt(T, 3), uo);
      }
      function wG(C, T) {
        return C && ss(C, jt(T, 3));
      }
      function DG(C, T) {
        return C && O3(C, jt(T, 3));
      }
      function IG(C) {
        return C == null ? [] : hh(C, Xi(C));
      }
      function EG(C) {
        return C == null ? [] : hh(C, uo(C));
      }
      function my(C, T, L) {
        var q = C == null ? r : _d(C, T);
        return q === r ? L : q;
      }
      function MG(C, T) {
        return C != null && n7(C, T, JO);
      }
      function hy(C, T) {
        return C != null && n7(C, T, $O);
      }
      var TG = Wx(function(C, T, L) {
        T != null && typeof T.toString != "function" && (T = rh.call(T)), C[T] = L;
      }, gy(so)), PG = Wx(function(C, T, L) {
        T != null && typeof T.toString != "function" && (T = rh.call(T)), fn.call(C, T) ? C[T].push(L) : C[T] = [L];
      }, jt), BG = Dr(G0);
      function Xi(C) {
        return oo(C) ? px(C) : G3(C);
      }
      function uo(C) {
        return oo(C) ? px(C, !0) : cL(C);
      }
      function FG(C, T) {
        var L = {};
        return T = jt(T, 3), ss(C, function(q, Z, ue) {
          qs(L, T(q, Z, ue), q);
        }), L;
      }
      function NG(C, T) {
        var L = {};
        return T = jt(T, 3), ss(C, function(q, Z, ue) {
          qs(L, Z, T(q, Z, ue));
        }), L;
      }
      var RG = qf(function(C, T, L) {
        vh(C, T, L);
      }), k7 = qf(function(C, T, L, q) {
        vh(C, T, L, q);
      }), OG = Xs(function(C, T) {
        var L = {};
        if (C == null)
          return L;
        var q = !1;
        T = Vn(T, function(ue) {
          return ue = nl(ue, C), q || (q = ue.length > 1), ue;
        }), cs(C, ey(C), L), q && (L = ru(L, d | f | m, TL));
        for (var Z = T.length; Z--; )
          X3(L, T[Z]);
        return L;
      });
      function LG(C, T) {
        return z7(C, Ph(jt(T)));
      }
      var kG = Xs(function(C, T) {
        return C == null ? {} : dL(C, T);
      });
      function z7(C, T) {
        if (C == null)
          return {};
        var L = Vn(ey(C), function(q) {
          return [q];
        });
        return T = jt(T), Tx(C, L, function(q, Z) {
          return T(q, Z[0]);
        });
      }
      function zG(C, T, L) {
        T = nl(T, C);
        var q = -1, Z = T.length;
        for (Z || (Z = 1, C = r); ++q < Z; ) {
          var ue = C == null ? r : C[ls(T[q])];
          ue === r && (q = Z, ue = L), C = Ys(ue) ? ue.call(C) : ue;
        }
        return C;
      }
      function GG(C, T, L) {
        return C == null ? C : U0(C, T, L);
      }
      function VG(C, T, L, q) {
        return q = typeof q == "function" ? q : r, C == null ? C : U0(C, T, L, q);
      }
      var G7 = Jx(Xi), V7 = Jx(uo);
      function UG(C, T, L) {
        var q = br(C), Z = q || al(C) || jf(C);
        if (T = jt(T, 4), L == null) {
          var ue = C && C.constructor;
          Z ? L = q ? new ue() : [] : Wn(C) ? L = Ys(ue) ? Hf(ah(C)) : {} : L = {};
        }
        return (Z ? $o : ss)(C, function(ge, Ce, Pe) {
          return T(L, ge, Ce, Pe);
        }), L;
      }
      function HG(C, T) {
        return C == null ? !0 : X3(C, T);
      }
      function qG(C, T, L) {
        return C == null ? C : Rx(C, T, W3(L));
      }
      function KG(C, T, L, q) {
        return q = typeof q == "function" ? q : r, C == null ? C : Rx(C, T, W3(L), q);
      }
      function Yf(C) {
        return C == null ? [] : I3(C, Xi(C));
      }
      function XG(C) {
        return C == null ? [] : I3(C, uo(C));
      }
      function jG(C, T, L) {
        return L === r && (L = T, T = r), L !== r && (L = au(L), L = L === L ? L : 0), T !== r && (T = au(T), T = T === T ? T : 0), bd(au(C), T, L);
      }
      function YG(C, T, L) {
        return T = Ws(T), L === r ? (L = T, T = 0) : L = Ws(L), C = au(C), eL(C, T, L);
      }
      function WG(C, T, L) {
        if (L && typeof L != "boolean" && Ua(C, T, L) && (T = L = r), L === r && (typeof T == "boolean" ? (L = T, T = r) : typeof C == "boolean" && (L = C, C = r)), C === r && T === r ? (C = 0, T = 1) : (C = Ws(C), T === r ? (T = C, C = 0) : T = Ws(T)), C > T) {
          var q = C;
          C = T, T = q;
        }
        if (L || C % 1 || T % 1) {
          var Z = dx();
          return Sa(C + Z * (T - C + IR("1e-" + ((Z + "").length - 1))), T);
        }
        return H3(C, T);
      }
      var ZG = Kf(function(C, T, L) {
        return T = T.toLowerCase(), C + (L ? U7(T) : T);
      });
      function U7(C) {
        return vy(an(C).toLowerCase());
      }
      function H7(C) {
        return C = an(C), C && C.replace(Bf, GR).replace(gR, "");
      }
      function QG(C, T, L) {
        C = an(C), T = To(T);
        var q = C.length;
        L = L === r ? q : bd(Sr(L), 0, q);
        var Z = L;
        return L -= T.length, L >= 0 && C.slice(L, Z) == T;
      }
      function JG(C) {
        return C = an(C), C && Gn.test(C) ? C.replace(dr, VR) : C;
      }
      function $G(C) {
        return C = an(C), C && pi.test(C) ? C.replace(fi, "\\$&") : C;
      }
      var eV = Kf(function(C, T, L) {
        return C + (L ? "-" : "") + T.toLowerCase();
      }), tV = Kf(function(C, T, L) {
        return C + (L ? " " : "") + T.toLowerCase();
      }), rV = Xx("toLowerCase");
      function nV(C, T, L) {
        C = an(C), T = Sr(T);
        var q = T ? kf(C) : 0;
        if (!T || q >= T)
          return C;
        var Z = (T - q) / 2;
        return Ah(ch(Z), L) + C + Ah(sh(Z), L);
      }
      function iV(C, T, L) {
        C = an(C), T = Sr(T);
        var q = T ? kf(C) : 0;
        return T && q < T ? C + Ah(T - q, L) : C;
      }
      function aV(C, T, L) {
        C = an(C), T = Sr(T);
        var q = T ? kf(C) : 0;
        return T && q < T ? Ah(T - q, L) + C : C;
      }
      function oV(C, T, L) {
        return L || T == null ? T = 0 : T && (T = +T), pO(an(C).replace(za, ""), T || 0);
      }
      function uV(C, T, L) {
        return (L ? Ua(C, T, L) : T === r) ? T = 1 : T = Sr(T), q3(an(C), T);
      }
      function sV() {
        var C = arguments, T = an(C[0]);
        return C.length < 3 ? T : T.replace(C[1], C[2]);
      }
      var cV = Kf(function(C, T, L) {
        return C + (L ? "_" : "") + T.toLowerCase();
      });
      function lV(C, T, L) {
        return L && typeof L != "number" && Ua(C, T, L) && (T = L = r), L = L === r ? K : L >>> 0, L ? (C = an(C), C && (typeof T == "string" || T != null && !py(T)) && (T = To(T), !T && Lf(C)) ? il(Ou(C), 0, L) : C.split(T, L)) : [];
      }
      var dV = Kf(function(C, T, L) {
        return C + (L ? " " : "") + vy(T);
      });
      function fV(C, T, L) {
        return C = an(C), L = L == null ? 0 : bd(Sr(L), 0, C.length), T = To(T), C.slice(L, L + T.length) == T;
      }
      function pV(C, T, L) {
        var q = ne.templateSettings;
        L && Ua(C, T, L) && (T = r), C = an(C), T = Nh({}, T, q, $x);
        var Z = Nh({}, T.imports, q.imports, $x), ue = Xi(Z), ge = I3(Z, ue), Ce, Pe, rt = 0, it = T.interpolate || Yc, dt = "__p += '", St = M3(
          (T.escape || Yc).source + "|" + it.source + "|" + (it === Jr ? mi : Yc).source + "|" + (T.evaluate || Yc).source + "|$",
          "g"
        ), Rt = "//# sourceURL=" + (fn.call(T, "sourceURL") ? (T.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++AR + "]") + `
`;
        C.replace(St, function(Jt, Tr, Lr, Bo, Ha, Fo) {
          return Lr || (Lr = Bo), dt += C.slice(rt, Fo).replace(Vs, UR), Tr && (Ce = !0, dt += `' +
__e(` + Tr + `) +
'`), Ha && (Pe = !0, dt += `';
` + Ha + `;
__p += '`), Lr && (dt += `' +
((__t = (` + Lr + `)) == null ? '' : __t) +
'`), rt = Fo + Jt.length, Jt;
        }), dt += `';
`;
        var Qt = fn.call(T, "variable") && T.variable;
        if (!Qt)
          dt = `with (obj) {
` + dt + `
}
`;
        else if (os.test(Qt))
          throw new hr(u);
        dt = (Pe ? dt.replace(It, "") : dt).replace(ur, "$1").replace(nr, "$1;"), dt = "function(" + (Qt || "obj") + `) {
` + (Qt ? "" : `obj || (obj = {});
`) + "var __t, __p = ''" + (Ce ? ", __e = _.escape" : "") + (Pe ? `, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
` : `;
`) + dt + `return __p
}`;
        var wr = K7(function() {
          return tn(ue, Rt + "return " + dt).apply(r, ge);
        });
        if (wr.source = dt, fy(wr))
          throw wr;
        return wr;
      }
      function mV(C) {
        return an(C).toLowerCase();
      }
      function hV(C) {
        return an(C).toUpperCase();
      }
      function vV(C, T, L) {
        if (C = an(C), C && (L || T === r))
          return ex(C);
        if (!C || !(T = To(T)))
          return C;
        var q = Ou(C), Z = Ou(T), ue = tx(q, Z), ge = rx(q, Z) + 1;
        return il(q, ue, ge).join("");
      }
      function gV(C, T, L) {
        if (C = an(C), C && (L || T === r))
          return C.slice(0, ix(C) + 1);
        if (!C || !(T = To(T)))
          return C;
        var q = Ou(C), Z = rx(q, Ou(T)) + 1;
        return il(q, 0, Z).join("");
      }
      function yV(C, T, L) {
        if (C = an(C), C && (L || T === r))
          return C.replace(za, "");
        if (!C || !(T = To(T)))
          return C;
        var q = Ou(C), Z = tx(q, Ou(T));
        return il(q, Z).join("");
      }
      function bV(C, T) {
        var L = M, q = F;
        if (Wn(T)) {
          var Z = "separator" in T ? T.separator : Z;
          L = "length" in T ? Sr(T.length) : L, q = "omission" in T ? To(T.omission) : q;
        }
        C = an(C);
        var ue = C.length;
        if (Lf(C)) {
          var ge = Ou(C);
          ue = ge.length;
        }
        if (L >= ue)
          return C;
        var Ce = L - kf(q);
        if (Ce < 1)
          return q;
        var Pe = ge ? il(ge, 0, Ce).join("") : C.slice(0, Ce);
        if (Z === r)
          return Pe + q;
        if (ge && (Ce += Pe.length - Ce), py(Z)) {
          if (C.slice(Ce).search(Z)) {
            var rt, it = Pe;
            for (Z.global || (Z = M3(Z.source, an(Gs.exec(Z)) + "g")), Z.lastIndex = 0; rt = Z.exec(it); )
              var dt = rt.index;
            Pe = Pe.slice(0, dt === r ? Ce : dt);
          }
        } else if (C.indexOf(To(Z), Ce) != Ce) {
          var St = Pe.lastIndexOf(Z);
          St > -1 && (Pe = Pe.slice(0, St));
        }
        return Pe + q;
      }
      function _V(C) {
        return C = an(C), C && ln.test(C) ? C.replace(Er, WR) : C;
      }
      var xV = Kf(function(C, T, L) {
        return C + (L ? " " : "") + T.toUpperCase();
      }), vy = Xx("toUpperCase");
      function q7(C, T, L) {
        return C = an(C), T = L ? r : T, T === r ? qR(C) ? JR(C) : RR(C) : C.match(T) || [];
      }
      var K7 = Dr(function(C, T) {
        try {
          return Eo(C, r, T);
        } catch (L) {
          return fy(L) ? L : new hr(L);
        }
      }), AV = Xs(function(C, T) {
        return $o(T, function(L) {
          L = ls(L), qs(C, L, ly(C[L], C));
        }), C;
      });
      function SV(C) {
        var T = C == null ? 0 : C.length, L = jt();
        return C = T ? Vn(C, function(q) {
          if (typeof q[1] != "function")
            throw new eu(o);
          return [L(q[0]), q[1]];
        }) : [], Dr(function(q) {
          for (var Z = -1; ++Z < T; ) {
            var ue = C[Z];
            if (Eo(ue[0], this, q))
              return Eo(ue[1], this, q);
          }
        });
      }
      function CV(C) {
        return WO(ru(C, d));
      }
      function gy(C) {
        return function() {
          return C;
        };
      }
      function wV(C, T) {
        return C == null || C !== C ? T : C;
      }
      var DV = Yx(), IV = Yx(!0);
      function so(C) {
        return C;
      }
      function yy(C) {
        return Cx(typeof C == "function" ? C : ru(C, d));
      }
      function EV(C) {
        return Dx(ru(C, d));
      }
      function MV(C, T) {
        return Ix(C, ru(T, d));
      }
      var TV = Dr(function(C, T) {
        return function(L) {
          return G0(L, C, T);
        };
      }), PV = Dr(function(C, T) {
        return function(L) {
          return G0(C, L, T);
        };
      });
      function by(C, T, L) {
        var q = Xi(T), Z = hh(T, q);
        L == null && !(Wn(T) && (Z.length || !q.length)) && (L = T, T = C, C = this, Z = hh(T, Xi(T)));
        var ue = !(Wn(L) && "chain" in L) || !!L.chain, ge = Ys(C);
        return $o(Z, function(Ce) {
          var Pe = T[Ce];
          C[Ce] = Pe, ge && (C.prototype[Ce] = function() {
            var rt = this.__chain__;
            if (ue || rt) {
              var it = C(this.__wrapped__), dt = it.__actions__ = ao(this.__actions__);
              return dt.push({ func: Pe, args: arguments, thisArg: C }), it.__chain__ = rt, it;
            }
            return Pe.apply(C, Jc([this.value()], arguments));
          });
        }), C;
      }
      function BV() {
        return ca._ === this && (ca._ = iO), this;
      }
      function _y() {
      }
      function FV(C) {
        return C = Sr(C), Dr(function(T) {
          return Ex(T, C);
        });
      }
      var NV = Q3(Vn), RV = Q3(W8), OV = Q3(A3);
      function X7(C) {
        return iy(C) ? S3(ls(C)) : fL(C);
      }
      function LV(C) {
        return function(T) {
          return C == null ? r : _d(C, T);
        };
      }
      var kV = Zx(), zV = Zx(!0);
      function xy() {
        return [];
      }
      function Ay() {
        return !1;
      }
      function GV() {
        return {};
      }
      function VV() {
        return "";
      }
      function UV() {
        return !0;
      }
      function HV(C, T) {
        if (C = Sr(C), C < 1 || C > V)
          return [];
        var L = K, q = Sa(C, K);
        T = jt(T), C -= K;
        for (var Z = D3(q, T); ++L < C; )
          T(L);
        return Z;
      }
      function qV(C) {
        return br(C) ? Vn(C, ls) : Po(C) ? [C] : ao(f7(an(C)));
      }
      function KV(C) {
        var T = ++rO;
        return an(C) + T;
      }
      var XV = xh(function(C, T) {
        return C + T;
      }, 0), jV = J3("ceil"), YV = xh(function(C, T) {
        return C / T;
      }, 1), WV = J3("floor");
      function ZV(C) {
        return C && C.length ? mh(C, so, L3) : r;
      }
      function QV(C, T) {
        return C && C.length ? mh(C, jt(T, 2), L3) : r;
      }
      function JV(C) {
        return J8(C, so);
      }
      function $V(C, T) {
        return J8(C, jt(T, 2));
      }
      function eU(C) {
        return C && C.length ? mh(C, so, V3) : r;
      }
      function tU(C, T) {
        return C && C.length ? mh(C, jt(T, 2), V3) : r;
      }
      var rU = xh(function(C, T) {
        return C * T;
      }, 1), nU = J3("round"), iU = xh(function(C, T) {
        return C - T;
      }, 0);
      function aU(C) {
        return C && C.length ? w3(C, so) : 0;
      }
      function oU(C, T) {
        return C && C.length ? w3(C, jt(T, 2)) : 0;
      }
      return ne.after = Ez, ne.ary = S7, ne.assign = hG, ne.assignIn = L7, ne.assignInWith = Nh, ne.assignWith = vG, ne.at = gG, ne.before = C7, ne.bind = ly, ne.bindAll = AV, ne.bindKey = w7, ne.castArray = Gz, ne.chain = _7, ne.chunk = WL, ne.compact = ZL, ne.concat = QL, ne.cond = SV, ne.conforms = CV, ne.constant = gy, ne.countBy = az, ne.create = yG, ne.curry = D7, ne.curryRight = I7, ne.debounce = E7, ne.defaults = bG, ne.defaultsDeep = _G, ne.defer = Mz, ne.delay = Tz, ne.difference = JL, ne.differenceBy = $L, ne.differenceWith = ek, ne.drop = tk, ne.dropRight = rk, ne.dropRightWhile = nk, ne.dropWhile = ik, ne.fill = ak, ne.filter = uz, ne.flatMap = lz, ne.flatMapDeep = dz, ne.flatMapDepth = fz, ne.flatten = v7, ne.flattenDeep = ok, ne.flattenDepth = uk, ne.flip = Pz, ne.flow = DV, ne.flowRight = IV, ne.fromPairs = sk, ne.functions = IG, ne.functionsIn = EG, ne.groupBy = pz, ne.initial = lk, ne.intersection = dk, ne.intersectionBy = fk, ne.intersectionWith = pk, ne.invert = TG, ne.invertBy = PG, ne.invokeMap = hz, ne.iteratee = yy, ne.keyBy = vz, ne.keys = Xi, ne.keysIn = uo, ne.map = Eh, ne.mapKeys = FG, ne.mapValues = NG, ne.matches = EV, ne.matchesProperty = MV, ne.memoize = Th, ne.merge = RG, ne.mergeWith = k7, ne.method = TV, ne.methodOf = PV, ne.mixin = by, ne.negate = Ph, ne.nthArg = FV, ne.omit = OG, ne.omitBy = LG, ne.once = Bz, ne.orderBy = gz, ne.over = NV, ne.overArgs = Fz, ne.overEvery = RV, ne.overSome = OV, ne.partial = dy, ne.partialRight = M7, ne.partition = yz, ne.pick = kG, ne.pickBy = z7, ne.property = X7, ne.propertyOf = LV, ne.pull = gk, ne.pullAll = y7, ne.pullAllBy = yk, ne.pullAllWith = bk, ne.pullAt = _k, ne.range = kV, ne.rangeRight = zV, ne.rearg = Nz, ne.reject = xz, ne.remove = xk, ne.rest = Rz, ne.reverse = sy, ne.sampleSize = Sz, ne.set = GG, ne.setWith = VG, ne.shuffle = Cz, ne.slice = Ak, ne.sortBy = Iz, ne.sortedUniq = Mk, ne.sortedUniqBy = Tk, ne.split = lV, ne.spread = Oz, ne.tail = Pk, ne.take = Bk, ne.takeRight = Fk, ne.takeRightWhile = Nk, ne.takeWhile = Rk, ne.tap = Zk, ne.throttle = Lz, ne.thru = Ih, ne.toArray = N7, ne.toPairs = G7, ne.toPairsIn = V7, ne.toPath = qV, ne.toPlainObject = O7, ne.transform = UG, ne.unary = kz, ne.union = Ok, ne.unionBy = Lk, ne.unionWith = kk, ne.uniq = zk, ne.uniqBy = Gk, ne.uniqWith = Vk, ne.unset = HG, ne.unzip = cy, ne.unzipWith = b7, ne.update = qG, ne.updateWith = KG, ne.values = Yf, ne.valuesIn = XG, ne.without = Uk, ne.words = q7, ne.wrap = zz, ne.xor = Hk, ne.xorBy = qk, ne.xorWith = Kk, ne.zip = Xk, ne.zipObject = jk, ne.zipObjectDeep = Yk, ne.zipWith = Wk, ne.entries = G7, ne.entriesIn = V7, ne.extend = L7, ne.extendWith = Nh, by(ne, ne), ne.add = XV, ne.attempt = K7, ne.camelCase = ZG, ne.capitalize = U7, ne.ceil = jV, ne.clamp = jG, ne.clone = Vz, ne.cloneDeep = Hz, ne.cloneDeepWith = qz, ne.cloneWith = Uz, ne.conformsTo = Kz, ne.deburr = H7, ne.defaultTo = wV, ne.divide = YV, ne.endsWith = QG, ne.eq = ku, ne.escape = JG, ne.escapeRegExp = $G, ne.every = oz, ne.find = sz, ne.findIndex = m7, ne.findKey = xG, ne.findLast = cz, ne.findLastIndex = h7, ne.findLastKey = AG, ne.floor = WV, ne.forEach = x7, ne.forEachRight = A7, ne.forIn = SG, ne.forInRight = CG, ne.forOwn = wG, ne.forOwnRight = DG, ne.get = my, ne.gt = Xz, ne.gte = jz, ne.has = MG, ne.hasIn = hy, ne.head = g7, ne.identity = so, ne.includes = mz, ne.indexOf = ck, ne.inRange = YG, ne.invoke = BG, ne.isArguments = Sd, ne.isArray = br, ne.isArrayBuffer = Yz, ne.isArrayLike = oo, ne.isArrayLikeObject = hi, ne.isBoolean = Wz, ne.isBuffer = al, ne.isDate = Zz, ne.isElement = Qz, ne.isEmpty = Jz, ne.isEqual = $z, ne.isEqualWith = eG, ne.isError = fy, ne.isFinite = tG, ne.isFunction = Ys, ne.isInteger = T7, ne.isLength = Bh, ne.isMap = P7, ne.isMatch = rG, ne.isMatchWith = nG, ne.isNaN = iG, ne.isNative = aG, ne.isNil = uG, ne.isNull = oG, ne.isNumber = B7, ne.isObject = Wn, ne.isObjectLike = ii, ne.isPlainObject = X0, ne.isRegExp = py, ne.isSafeInteger = sG, ne.isSet = F7, ne.isString = Fh, ne.isSymbol = Po, ne.isTypedArray = jf, ne.isUndefined = cG, ne.isWeakMap = lG, ne.isWeakSet = dG, ne.join = mk, ne.kebabCase = eV, ne.last = iu, ne.lastIndexOf = hk, ne.lowerCase = tV, ne.lowerFirst = rV, ne.lt = fG, ne.lte = pG, ne.max = ZV, ne.maxBy = QV, ne.mean = JV, ne.meanBy = $V, ne.min = eU, ne.minBy = tU, ne.stubArray = xy, ne.stubFalse = Ay, ne.stubObject = GV, ne.stubString = VV, ne.stubTrue = UV, ne.multiply = rU, ne.nth = vk, ne.noConflict = BV, ne.noop = _y, ne.now = Mh, ne.pad = nV, ne.padEnd = iV, ne.padStart = aV, ne.parseInt = oV, ne.random = WG, ne.reduce = bz, ne.reduceRight = _z, ne.repeat = uV, ne.replace = sV, ne.result = zG, ne.round = nU, ne.runInContext = Ee, ne.sample = Az, ne.size = wz, ne.snakeCase = cV, ne.some = Dz, ne.sortedIndex = Sk, ne.sortedIndexBy = Ck, ne.sortedIndexOf = wk, ne.sortedLastIndex = Dk, ne.sortedLastIndexBy = Ik, ne.sortedLastIndexOf = Ek, ne.startCase = dV, ne.startsWith = fV, ne.subtract = iU, ne.sum = aU, ne.sumBy = oU, ne.template = pV, ne.times = HV, ne.toFinite = Ws, ne.toInteger = Sr, ne.toLength = R7, ne.toLower = mV, ne.toNumber = au, ne.toSafeInteger = mG, ne.toString = an, ne.toUpper = hV, ne.trim = vV, ne.trimEnd = gV, ne.trimStart = yV, ne.truncate = bV, ne.unescape = _V, ne.uniqueId = KV, ne.upperCase = xV, ne.upperFirst = vy, ne.each = x7, ne.eachRight = A7, ne.first = g7, by(ne, function() {
        var C = {};
        return ss(ne, function(T, L) {
          fn.call(ne.prototype, L) || (C[L] = T);
        }), C;
      }(), { chain: !1 }), ne.VERSION = n, $o(["bind", "bindKey", "curry", "curryRight", "partial", "partialRight"], function(C) {
        ne[C].placeholder = ne;
      }), $o(["drop", "take"], function(C, T) {
        Nr.prototype[C] = function(L) {
          L = L === r ? 1 : Ri(Sr(L), 0);
          var q = this.__filtered__ && !T ? new Nr(this) : this.clone();
          return q.__filtered__ ? q.__takeCount__ = Sa(L, q.__takeCount__) : q.__views__.push({
            size: Sa(L, K),
            type: C + (q.__dir__ < 0 ? "Right" : "")
          }), q;
        }, Nr.prototype[C + "Right"] = function(L) {
          return this.reverse()[C](L).reverse();
        };
      }), $o(["filter", "map", "takeWhile"], function(C, T) {
        var L = T + 1, q = L == B || L == O;
        Nr.prototype[C] = function(Z) {
          var ue = this.clone();
          return ue.__iteratees__.push({
            iteratee: jt(Z, 3),
            type: L
          }), ue.__filtered__ = ue.__filtered__ || q, ue;
        };
      }), $o(["head", "last"], function(C, T) {
        var L = "take" + (T ? "Right" : "");
        Nr.prototype[C] = function() {
          return this[L](1).value()[0];
        };
      }), $o(["initial", "tail"], function(C, T) {
        var L = "drop" + (T ? "" : "Right");
        Nr.prototype[C] = function() {
          return this.__filtered__ ? new Nr(this) : this[L](1);
        };
      }), Nr.prototype.compact = function() {
        return this.filter(so);
      }, Nr.prototype.find = function(C) {
        return this.filter(C).head();
      }, Nr.prototype.findLast = function(C) {
        return this.reverse().find(C);
      }, Nr.prototype.invokeMap = Dr(function(C, T) {
        return typeof C == "function" ? new Nr(this) : this.map(function(L) {
          return G0(L, C, T);
        });
      }), Nr.prototype.reject = function(C) {
        return this.filter(Ph(jt(C)));
      }, Nr.prototype.slice = function(C, T) {
        C = Sr(C);
        var L = this;
        return L.__filtered__ && (C > 0 || T < 0) ? new Nr(L) : (C < 0 ? L = L.takeRight(-C) : C && (L = L.drop(C)), T !== r && (T = Sr(T), L = T < 0 ? L.dropRight(-T) : L.take(T - C)), L);
      }, Nr.prototype.takeRightWhile = function(C) {
        return this.reverse().takeWhile(C).reverse();
      }, Nr.prototype.toArray = function() {
        return this.take(K);
      }, ss(Nr.prototype, function(C, T) {
        var L = /^(?:filter|find|map|reject)|While$/.test(T), q = /^(?:head|last)$/.test(T), Z = ne[q ? "take" + (T == "last" ? "Right" : "") : T], ue = q || /^find/.test(T);
        Z && (ne.prototype[T] = function() {
          var ge = this.__wrapped__, Ce = q ? [1] : arguments, Pe = ge instanceof Nr, rt = Ce[0], it = Pe || br(ge), dt = function(Tr) {
            var Lr = Z.apply(ne, Jc([Tr], Ce));
            return q && St ? Lr[0] : Lr;
          };
          it && L && typeof rt == "function" && rt.length != 1 && (Pe = it = !1);
          var St = this.__chain__, Rt = !!this.__actions__.length, Qt = ue && !St, wr = Pe && !Rt;
          if (!ue && it) {
            ge = wr ? ge : new Nr(this);
            var Jt = C.apply(ge, Ce);
            return Jt.__actions__.push({ func: Ih, args: [dt], thisArg: r }), new tu(Jt, St);
          }
          return Qt && wr ? C.apply(this, Ce) : (Jt = this.thru(dt), Qt ? q ? Jt.value()[0] : Jt.value() : Jt);
        });
      }), $o(["pop", "push", "shift", "sort", "splice", "unshift"], function(C) {
        var T = $m[C], L = /^(?:push|sort|unshift)$/.test(C) ? "tap" : "thru", q = /^(?:pop|shift)$/.test(C);
        ne.prototype[C] = function() {
          var Z = arguments;
          if (q && !this.__chain__) {
            var ue = this.value();
            return T.apply(br(ue) ? ue : [], Z);
          }
          return this[L](function(ge) {
            return T.apply(br(ge) ? ge : [], Z);
          });
        };
      }), ss(Nr.prototype, function(C, T) {
        var L = ne[T];
        if (L) {
          var q = L.name + "";
          fn.call(Uf, q) || (Uf[q] = []), Uf[q].push({ name: T, func: L });
        }
      }), Uf[_h(r, h).name] = [{
        name: "wrapper",
        func: r
      }], Nr.prototype.clone = _O, Nr.prototype.reverse = xO, Nr.prototype.value = AO, ne.prototype.at = Qk, ne.prototype.chain = Jk, ne.prototype.commit = $k, ne.prototype.next = ez, ne.prototype.plant = rz, ne.prototype.reverse = nz, ne.prototype.toJSON = ne.prototype.valueOf = ne.prototype.value = iz, ne.prototype.first = ne.prototype.head, F0 && (ne.prototype[F0] = tz), ne;
    }, zf = $R();
    hd ? ((hd.exports = zf)._ = zf, y3._ = zf) : ca._ = zf;
  }).call(_p);
})(gg, gg.exports);
var Lde = gg.exports;
function pE(e) {
  const t = e.map((r) => r);
  return Rde(t, sR(t));
}
function kde(e, t = [0, 0, 1], r) {
  if (!r) {
    const P = fE(t, [1, 0, 0]);
    sR(P) < 1e-5 ? r = [0, 0, 1] : r = [1, 0, 0];
  }
  const n = r, i = pE(t), a = pE(n.map((P, E) => P - B8(n, i) * i[E])), o = fE(i, a);
  let u = 90, s = 90, c = 90, l, d, f;
  typeof e == "number" ? l = d = f = e : e.length === 1 ? l = d = f = e[0] : e.length === 3 ? [l, d, f] = e : [l, d, f, u, s, c] = e;
  const m = 2 * Number.EPSILON;
  let v = $d(u - 90) < m ? 0 : s2(u * Kv / 180), p = $d(s - 90) < m ? 0 : s2(s * Kv / 180), g, h;
  $d(c - 90) < m ? (g = 0, h = 1) : $d(c + 90) < m ? (g = 0, h = -1) : (g = s2(c * Kv / 180), h = tR(c * Kv / 180));
  const y = [l, 0, 0], x = [d * g, d * h, 0], A = p, b = (v - p * g) / h, _ = 1 - A * A - b * b;
  if (_ < 0) throw new Error("cz_sqr is negative, which is not possible");
  const S = u3(_), D = [f * A, f * b, f * S], I = Kr([y, x, D]), M = Kr([a, o, i]);
  return Fu(I, nR(M)).toArray();
}
const w1 = 5e-3;
function yg(e, t = e.length, r = []) {
  if (t === 0) return [];
  if (t === 1) return [...r, ...e.map((n) => [n])];
  if (e.length === t) return yg(e, t - 1, [e.slice()]);
  for (let n = 0; n < e.length - 1; n++)
    for (let i = n + 1; i < e.length; i++)
      r.push([e[n], e[i]]);
  return yg(e, t - 1, r);
}
function zde(e, t) {
  return e.every((r, n) => r === t[n]);
}
function mE(e) {
  return zde(e, [0, 0, 0]);
}
function Gde(e) {
  const t = {
    expand: [1, 1, 1],
    atoms: [],
    lattice: void 0
  }, r = e != null && e.lattice ? cR(e == null ? void 0 : e.lattice) : void 0, n = e.atoms.map((i, a) => bg(i, {
    lattice: r,
    order: a
  }));
  return t.lattice = r, t.atoms = n, t;
}
function Vde(e) {
  if (!e.lattice)
    return e;
  const t = Gde({
    lattice: e.lattice,
    atoms: e.atoms
  }), { atoms: r } = t, n = Hde(r, e.lattice);
  return t.atoms = [...t.atoms, ...n], console.log("createSymmetryMaterial", t), t;
}
function Ude(e) {
  const t = [], r = [];
  return e.atoms.map((n) => {
    t.push(n.element), r.push(n.xyz);
  }), {
    elements: t,
    xyzs: r,
    lattice: e.lattice
  };
}
function hE(e, t) {
  let r = [0, 0, 0];
  e.forEach((i, a) => {
    i && (r = yc(r, Fu(t[a], i)));
  });
  const n = Gm(4).toArray();
  return r.forEach((i, a) => {
    n[3][a] = i;
  }), n;
}
function vE(e, t) {
  const [r, n, i] = e, a = 1 / (t[0][3] * r + t[1][3] * n + t[2][3] * i + t[3][3] || 1), o = (t[0][0] * r + t[1][0] * n + t[2][0] * i + t[3][0]) * a, u = (t[0][1] * r + t[1][1] * n + t[2][1] * i + t[3][1]) * a, s = (t[0][2] * r + t[1][2] * n + t[2][2] * i + t[3][2]) * a;
  return [o, u, s];
}
function cR(e) {
  const { a: t, b: r, c: n, alpha: i, beta: a, gamma: o, spacegroup: u } = e, s = e.matrix || kde([t, r, n, i, a, o]), c = l3(s), l = s[0], d = s[1], f = s[2], m = uR(s);
  return {
    spacegroup: u,
    a: t,
    b: r,
    c: n,
    volume: m,
    alpha: i,
    beta: a,
    gamma: o,
    vecA: l,
    vecB: d,
    vecC: f,
    matrix: s,
    invertMatrix: c
  };
}
function bg(e, t) {
  const { element: r } = e, { order: n, lattice: i, symmetry: a } = t || {};
  if (!e.abc && !e.xyz)
    throw new Error("createAtom: Need xyz or abc!");
  if (!i && !e.xyz)
    throw new Error("createAtom: Need xyz or lattice!");
  let o = (() => {
    const { xyz: c, abc: l } = e;
    if (!i)
      return;
    if (!l)
      return Fu(c, i.invertMatrix);
    if (!a || mE(a))
      return l;
    const d = hE(a, Gm(3).toArray());
    return vE(l, d);
  })(), u = (() => {
    const { xyz: c, abc: l } = e;
    if (!i)
      return c;
    if (!c)
      return Fu(l, i.matrix);
    if (!a || mE(a))
      return c;
    const d = hE(a, i.matrix);
    return vE(c, d);
  })();
  if (u[0] === 9.098622252945479 || n === 18)
    debugger;
  return o && o.some((c) => c < 0 || c > 1) && (o = Mde(o, 1), u = Fu(o, i.matrix)), {
    element: r,
    xyz: u,
    abc: o,
    order: n,
    symmetry: a
  };
}
function Hde(e, t) {
  const r = [];
  return e.forEach((n, i) => {
    const { abc: a } = n;
    if (!(!a || a[0] === void 0)) {
      {
        const o = [];
        Math.abs(a[0]) <= w1 && o.push(0), Math.abs(a[1]) <= w1 && o.push(1), Math.abs(a[2]) <= w1 && o.push(2), yg(o).map((c) => [
          Number(c.includes(0)),
          Number(c.includes(1)),
          Number(c.includes(2))
        ]).forEach((c) => {
          const l = bg(n, {
            order: i,
            lattice: t,
            symmetry: c
          });
          r.push(l);
        });
      }
      {
        const o = [];
        Math.abs(1 - a[0]) <= w1 && o.push(0), Math.abs(1 - a[1]) <= w1 && o.push(1), Math.abs(1 - a[2]) <= w1 && o.push(2), yg(o).map((c) => [
          -Number(c.includes(0)),
          -Number(c.includes(1)),
          -Number(c.includes(2))
        ]).forEach((c) => {
          const l = bg(n, {
            order: i,
            lattice: t,
            symmetry: c
          });
          r.push(l);
        });
      }
    }
  }), r;
}
function qde(e) {
  const t = e[0], r = e[1], n = e[2], i = [0, 0, 0], a = t, o = r, u = yc(t, r), s = n, c = yc(t, n), l = yc(r, n), d = yc(yc(t, r), n);
  return [i, a, o, u, s, c, l, d];
}
function Kde(e) {
  const [t, r, n, i, a, o, u, s] = e;
  return [
    [t, r],
    [t, n],
    [r, i],
    [n, i],
    [t, a],
    [r, o],
    [n, u],
    [i, s],
    [a, o],
    [a, u],
    [o, s],
    [u, s]
  ];
}
function Xde(e) {
  const { length: t, angle: r, spacegroup: n, atoms: i } = e, a = {
    expand: [1, 1, 1],
    atoms: [],
    lattice: void 0
  }, o = (() => {
    if (!t || !r || !n)
      return;
    const [s, c, l] = t, [d, f, m] = r, v = {
      symbol: n[1],
      no: n[0]
    };
    return cR({
      spacegroup: v,
      a: s,
      b: c,
      c: l,
      alpha: d,
      beta: f,
      gamma: m
    });
  })(), u = i.map((s, c) => {
    const l = {
      element: s.formula,
      xyz: s.cart_coord,
      abc: s.frac_coord
    };
    return bg(l, {
      lattice: o,
      order: c
    });
  });
  return a.lattice = o, a.atoms = u, console.log("ase2Material", a), a;
}
const {
  SvelteComponent: jde,
  append: Xt,
  attr: sn,
  destroy_each: $6,
  detach: D0,
  element: _n,
  ensure_array_like: F1,
  flush: Hd,
  init: Yde,
  insert: I0,
  listen: Xv,
  noop: gE,
  null_to_empty: jl,
  run_all: Wde,
  safe_not_equal: Zde,
  set_data: sf,
  set_style: N1,
  space: na,
  text: Iu
} = window.__gradio__svelte__internal;
function yE(e, t, r) {
  const n = e.slice();
  return n[29] = t[r], n;
}
function bE(e, t, r) {
  const n = e.slice();
  return n[7] = t[r], n[33] = r, n;
}
function _E(e, t, r) {
  const n = e.slice();
  return n[7] = t[r], n;
}
function xE(e) {
  let t, r, n, i;
  return {
    c() {
      t = _n("div"), r = _n("div"), n = Iu(
        /*tooltipText*/
        e[3]
      ), sn(r, "class", jl("tooltip-inner") + " svelte-141sw17"), sn(t, "class", "tooltip svelte-141sw17"), sn(t, "style", i = `top: ${/*mousePosition*/
      e[2].y - 45}px;left: ${/*mousePosition*/
      e[2].x - 8}px;`);
    },
    m(a, o) {
      I0(a, t, o), Xt(t, r), Xt(r, n);
    },
    p(a, o) {
      o[0] & /*tooltipText*/
      8 && sf(
        n,
        /*tooltipText*/
        a[3]
      ), o[0] & /*mousePosition*/
      4 && i !== (i = `top: ${/*mousePosition*/
      a[2].y - 45}px;left: ${/*mousePosition*/
      a[2].x - 8}px;`) && sn(t, "style", i);
    },
    d(a) {
      a && D0(t);
    }
  };
}
function AE(e) {
  let t, r, n, i, a, o, u, s, c, l, d, f, m = (
    /*lattice*/
    e[4].volume.toFixed(3) + ""
  ), v, p, g, h, y, x, A, b = (
    /*lattice*/
    e[4].spacegroup.symbol + ""
  ), _, S, D = (
    /*lattice*/
    e[4].spacegroup.no + ""
  ), I, M, F = F1(["a", "b", "c"]), P = [];
  for (let N = 0; N < 3; N += 1)
    P[N] = SE(_E(e, F, N));
  let E = F1(["α", "β", "γ"]), B = [];
  for (let N = 0; N < 3; N += 1)
    B[N] = CE(bE(e, E, N));
  return {
    c() {
      t = _n("div"), r = _n("h6"), r.textContent = "Lattice", n = na(), i = _n("div"), a = _n("div");
      for (let N = 0; N < 3; N += 1)
        P[N].c();
      o = na(), u = _n("div");
      for (let N = 0; N < 3; N += 1)
        B[N].c();
      s = na(), c = _n("div"), l = _n("span"), l.textContent = "Volume", d = na(), f = _n("span"), v = Iu(m), p = Iu("(Å3)"), g = na(), h = _n("div"), y = _n("span"), y.textContent = "Space Group", x = na(), A = _n("span"), _ = Iu(b), S = Iu("("), I = Iu(D), M = Iu(")"), N1(r, "font-weight", "600"), sn(a, "class", "lattice-params-half"), sn(u, "class", "lattice-params-half"), sn(i, "class", "lattice-params svelte-141sw17"), sn(l, "class", jl("text-color-tertiary mr-16") + " svelte-141sw17"), sn(c, "class", jl("row") + " svelte-141sw17"), N1(c, "justify-content", "space-between"), N1(c, "margin-top", "8px"), sn(y, "class", jl("text-color-tertiary mr-16") + " svelte-141sw17"), sn(h, "class", jl("row") + " svelte-141sw17"), N1(h, "justify-content", "space-between"), sn(t, "class", "lattice-content svelte-141sw17");
    },
    m(N, O) {
      I0(N, t, O), Xt(t, r), Xt(t, n), Xt(t, i), Xt(i, a);
      for (let z = 0; z < 3; z += 1)
        P[z] && P[z].m(a, null);
      Xt(i, o), Xt(i, u);
      for (let z = 0; z < 3; z += 1)
        B[z] && B[z].m(u, null);
      Xt(t, s), Xt(t, c), Xt(c, l), Xt(c, d), Xt(c, f), Xt(f, v), Xt(f, p), Xt(t, g), Xt(t, h), Xt(h, y), Xt(h, x), Xt(h, A), Xt(A, _), Xt(A, S), Xt(A, I), Xt(A, M);
    },
    p(N, O) {
      if (O[0] & /*lattice*/
      16) {
        F = F1(["a", "b", "c"]);
        let z;
        for (z = 0; z < 3; z += 1) {
          const V = _E(N, F, z);
          P[z] ? P[z].p(V, O) : (P[z] = SE(V), P[z].c(), P[z].m(a, null));
        }
        for (; z < 3; z += 1)
          P[z].d(1);
      }
      if (O[0] & /*lattice*/
      16) {
        E = F1(["α", "β", "γ"]);
        let z;
        for (z = 0; z < 3; z += 1) {
          const V = bE(N, E, z);
          B[z] ? B[z].p(V, O) : (B[z] = CE(V), B[z].c(), B[z].m(u, null));
        }
        for (; z < 3; z += 1)
          B[z].d(1);
      }
      O[0] & /*lattice*/
      16 && m !== (m = /*lattice*/
      N[4].volume.toFixed(3) + "") && sf(v, m), O[0] & /*lattice*/
      16 && b !== (b = /*lattice*/
      N[4].spacegroup.symbol + "") && sf(_, b), O[0] & /*lattice*/
      16 && D !== (D = /*lattice*/
      N[4].spacegroup.no + "") && sf(I, D);
    },
    d(N) {
      N && D0(t), $6(P, N), $6(B, N);
    }
  };
}
function SE(e) {
  let t, r, n, i, a = (
    /*lattice*/
    e[4][
      /*key*/
      e[7]
    ].toFixed(3) + ""
  ), o, u, s;
  return {
    c() {
      t = _n("div"), r = _n("span"), r.textContent = `${/*key*/
      e[7]}`, n = na(), i = _n("span"), o = Iu(a), u = Iu("(Å)"), s = na(), sn(r, "class", "text-color-tertiary svelte-141sw17"), N1(r, "margin-right", "8px"), sn(t, "class", "lattice-params-item svelte-141sw17");
    },
    m(c, l) {
      I0(c, t, l), Xt(t, r), Xt(t, n), Xt(t, i), Xt(i, o), Xt(i, u), Xt(t, s);
    },
    p(c, l) {
      l[0] & /*lattice*/
      16 && a !== (a = /*lattice*/
      c[4][
        /*key*/
        c[7]
      ].toFixed(3) + "") && sf(o, a);
    },
    d(c) {
      c && D0(t);
    }
  };
}
function CE(e) {
  let t, r, n, i, a = (
    /*lattice*/
    e[4][["alpha", "beta", "gamma"][
      /*idx*/
      e[33]
    ]].toFixed(3) + ""
  ), o, u, s;
  return {
    c() {
      t = _n("div"), r = _n("span"), r.textContent = `${/*key*/
      e[7]}`, n = na(), i = _n("span"), o = Iu(a), u = Iu("°"), s = na(), sn(r, "class", "text-color-tertiary svelte-141sw17"), N1(r, "margin-right", "8px"), sn(t, "class", "lattice-params-item svelte-141sw17");
    },
    m(c, l) {
      I0(c, t, l), Xt(t, r), Xt(t, n), Xt(t, i), Xt(i, o), Xt(i, u), Xt(t, s);
    },
    p(c, l) {
      l[0] & /*lattice*/
      16 && a !== (a = /*lattice*/
      c[4][["alpha", "beta", "gamma"][
        /*idx*/
        c[33]
      ]].toFixed(3) + "") && sf(o, a);
    },
    d(c) {
      c && D0(t);
    }
  };
}
function wE(e) {
  let t, r, n, i, a = (
    /*atom*/
    e[29] + ""
  ), o, u;
  return {
    c() {
      t = _n("div"), r = _n("div"), i = na(), o = Iu(a), u = na(), sn(r, "style", n = `background-color: ${DE(O2[
        /*atom*/
        e[29].toUpperCase()
      ])}`), sn(r, "class", jl("atom-model-legend-item-ball") + " svelte-141sw17"), sn(t, "class", jl("atom-model-legend-item") + " svelte-141sw17");
    },
    m(s, c) {
      I0(s, t, c), Xt(t, r), Xt(t, i), Xt(t, o), Xt(t, u);
    },
    p(s, c) {
      c[0] & /*atomList*/
      64 && n !== (n = `background-color: ${DE(O2[
        /*atom*/
        s[29].toUpperCase()
      ])}`) && sn(r, "style", n), c[0] & /*atomList*/
      64 && a !== (a = /*atom*/
      s[29] + "") && sf(o, a);
    },
    d(s) {
      s && D0(t);
    }
  };
}
function Qde(e) {
  let t, r, n, i, a, o, u, s, c, l, d, f, m, v, p, g, h = !!/*tooltipText*/
  e[3] && xE(e), y = (
    /*latticeInfoVisible*/
    e[1] && !!/*lattice*/
    e[4] && AE(e)
  ), x = F1(
    /*atomList*/
    e[6]
  ), A = [];
  for (let b = 0; b < x.length; b += 1)
    A[b] = wE(yE(e, x, b));
  return {
    c() {
      t = _n("div"), r = _n("div"), n = na(), h && h.c(), i = na(), y && y.c(), a = na(), o = _n("div");
      for (let b = 0; b < A.length; b += 1)
        A[b].c();
      u = na(), s = _n("div"), c = _n("button"), c.innerHTML = '<svg width="1em" height="1em" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.02 3.334l-.012 9.333M3.336 8h9.333" stroke="#A2A5C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"></path></svg>', l = na(), d = _n("button"), d.innerHTML = '<svg width="1em" height="1em" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3.336 8h9.333" stroke="#A2A5C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"></path></svg>', f = na(), m = _n("button"), m.innerHTML = '<svg width="1em" height="1em" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8.0026 14.6673C11.6845 14.6673 14.6693 11.6825 14.6693 8.00065C14.6693 4.31875 11.6845 1.33398 8.0026 1.33398C4.32071 1.33398 1.33594 4.31875 1.33594 8.00065C1.33594 11.6825 4.32071 14.6673 8.0026 14.6673Z" stroke="#A2A5C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"></path><path d="M8 12.334V14.6673" stroke="#A2A5C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"></path><path d="M12 8H14.6667" stroke="#A2A5C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"></path><path d="M1.33594 8H3.66927" stroke="#A2A5C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"></path><path d="M8 3.66732V1.33398" stroke="#A2A5C4" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"></path><circle cx="8" cy="8" r="1" stroke="#A2A5C4"></circle></svg>', sn(r, "id", `material-viewer-canvas-${/*key*/
      e[7]}`), sn(r, "style", "width: 100%;height: 100%;min-height: 240px;"), sn(o, "class", jl("atom-model-legend-container") + " svelte-141sw17"), sn(c, "class", "material-viewer-toolbar-btn svelte-141sw17"), sn(d, "class", "material-viewer-toolbar-btn svelte-141sw17"), sn(m, "class", "material-viewer-toolbar-btn svelte-141sw17"), sn(s, "class", "material-viewer-toolbar svelte-141sw17"), sn(t, "class", "material-viewer-container svelte-141sw17"), sn(t, "style", v = `height: ${/*height*/
      e[0]}px;`);
    },
    m(b, _) {
      I0(b, t, _), Xt(t, r), Xt(t, n), h && h.m(t, null), Xt(t, i), y && y.m(t, null), Xt(t, a), Xt(t, o);
      for (let S = 0; S < A.length; S += 1)
        A[S] && A[S].m(o, null);
      Xt(t, u), Xt(t, s), Xt(s, c), Xt(s, l), Xt(s, d), Xt(s, f), Xt(s, m), p || (g = [
        Xv(
          r,
          "mousemove",
          /*mousemove_handler*/
          e[13]
        ),
        Xv(
          c,
          "click",
          /*click_handler*/
          e[14]
        ),
        Xv(
          d,
          "click",
          /*click_handler_1*/
          e[15]
        ),
        Xv(
          m,
          "click",
          /*click_handler_2*/
          e[16]
        )
      ], p = !0);
    },
    p(b, _) {
      if (/*tooltipText*/
      b[3] ? h ? h.p(b, _) : (h = xE(b), h.c(), h.m(t, i)) : h && (h.d(1), h = null), /*latticeInfoVisible*/
      b[1] && /*lattice*/
      b[4] ? y ? y.p(b, _) : (y = AE(b), y.c(), y.m(t, a)) : y && (y.d(1), y = null), _[0] & /*atomList*/
      64) {
        x = F1(
          /*atomList*/
          b[6]
        );
        let S;
        for (S = 0; S < x.length; S += 1) {
          const D = yE(b, x, S);
          A[S] ? A[S].p(D, _) : (A[S] = wE(D), A[S].c(), A[S].m(o, null));
        }
        for (; S < A.length; S += 1)
          A[S].d(1);
        A.length = x.length;
      }
      _[0] & /*height*/
      1 && v !== (v = `height: ${/*height*/
      b[0]}px;`) && sn(t, "style", v);
    },
    i: gE,
    o: gE,
    d(b) {
      b && D0(t), h && h.d(), y && y.d(), $6(A, b), p = !1, Wde(g);
    }
  };
}
function DE(e) {
  let t = e.toString(16);
  for (; t.length < 6; )
    t = "0" + t;
  return "#" + t;
}
function Jde(e, t, r) {
  var n = this && this.__awaiter || function(B, N, O, z) {
    function V(U) {
      return U instanceof O ? U : new O(function(H) {
        H(U);
      });
    }
    return new (O || (O = Promise))(function(U, H) {
      function K(W) {
        try {
          X(z.next(W));
        } catch (Q) {
          H(Q);
        }
      }
      function j(W) {
        try {
          X(z.throw(W));
        } catch (Q) {
          H(Q);
        }
      }
      function X(W) {
        W.done ? U(W.value) : V(W.value).then(K, j);
      }
      X((z = z.apply(B, N || [])).next());
    });
  };
  let { gradio: i } = t, { materialFile: a = "" } = t, { value: o = "" } = t, { value_is_output: u = !1 } = t, { height: s } = t, { style: c } = t, { latticeInfoVisible: l } = t;
  window.process = {
    env: { NODE_ENV: "production", LANG: "" }
  };
  let d = new tN();
  const m = (() => {
    function B() {
      return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
    }
    return `${B() + B()}-${B()}-${B()}-${B()}-${B()}${B()}${B()}`;
  })();
  function v() {
    i.dispatch("change"), u || i.dispatch("input");
  }
  let p = { x: -1e3, y: -1e3 }, g = "", h, y = [];
  const x = (B, N) => n(void 0, void 0, void 0, function* () {
    if (B) {
      const O = qde(B.matrix), z = Kde(O);
      return d.managers.representation.createOther({
        data: z,
        type: Te.CustomLines,
        params: { alpha: 1 }
      });
    }
  }), A = (B, N) => {
    var O;
    const z = {
      vecA: w.unitX,
      vecB: w.unitY,
      vecC: w.unitZ
    }, V = (() => {
      if (!B)
        return {};
      const U = B.matrix;
      return {
        vecA: w.normalize(w.zero(), w.create.apply(null, U[0])),
        vecB: w.normalize(w.zero(), w.create.apply(null, U[1])),
        vecC: w.normalize(w.zero(), w.create.apply(null, U[2]))
      };
    })();
    return (O = d == null ? void 0 : d.canvas3d) === null || O === void 0 ? void 0 : O.setProps({
      camera: {
        helper: {
          axes: {
            name: "on",
            params: Object.assign(Object.assign({}, z), V)
          }
        }
      }
    });
  };
  function b() {
    return n(this, void 0, void 0, function* () {
      if (!d.canvas3d) return;
      const B = Ude(Vde(Xde(JSON.parse(a)[0]))), [N] = yield d.managers.representation.createMolecular({
        format: mr.Material,
        reprType: D1.has(c) ? c : Te.BallAndStick,
        data: B,
        theme: {
          [At.ATOM]: {
            color: { name: "material-element-symbol" }
          }
        }
      }), O = /* @__PURE__ */ new Set(), z = yield d.managers.cell.getStructure(N);
      z && (iB(z, (V) => {
        O.add(V.typeSymbol);
      }), r(6, y = new Array(...O.values())), x(B.lattice), A(B.lattice), r(4, h = B.lattice));
    });
  }
  function _() {
    r(5, d.managers.representation.showPolarHydrogenOnly = !1, d), d.createCanvas(document.getElementById(`material-viewer-canvas-${m}`)), d.managers.selection.structure.setGranularity(kr.Atom), d.managers.events.setAllowSelect(!1), d.managers.highlight.info.subscribe((N) => {
      var O;
      if (((O = N.info) === null || O === void 0 ? void 0 : O.granularity) === kr.Atom) {
        const { atomName: z, x: V, y: U, z: H } = N.info;
        r(3, g = `${z} (${[V, U, H].map((K) => K.toFixed(3)).join(", ")})`);
      } else
        r(3, g = "");
    }), new ResizeObserver(Lde.debounce(
      () => {
        d.refresh({ fixCamera: !0 });
      },
      300
    )).observe(document.getElementById(`material-viewer-canvas-${m}`)), window.__material_viewer = d, setTimeout(() => d.refresh(), 50);
  }
  const S = setInterval(
    () => {
      var B;
      !((B = document.getElementById(`material-viewer-canvas-${m}`)) === null || B === void 0) && B.clientHeight && !d.canvas3d && (clearInterval(S), _(), b());
    },
    500
  );
  function D() {
    d.canvas3d && (d.clear(), b());
  }
  const I = () => {
    setTimeout(
      () => {
        d.refresh({ fixCamera: !0 });
      },
      0
    );
  }, M = (B) => {
    r(2, p = { x: B.offsetX, y: B.offsetY });
  }, F = () => d.managers.camera.zoomIn(), P = () => d.managers.camera.zoomOut(), E = () => d.managers.camera.reset();
  return e.$$set = (B) => {
    "gradio" in B && r(9, i = B.gradio), "materialFile" in B && r(10, a = B.materialFile), "value" in B && r(8, o = B.value), "value_is_output" in B && r(11, u = B.value_is_output), "height" in B && r(0, s = B.height), "style" in B && r(12, c = B.style), "latticeInfoVisible" in B && r(1, l = B.latticeInfoVisible);
  }, e.$$.update = () => {
    e.$$.dirty[0] & /*value*/
    256 && o === null && r(8, o = ""), e.$$.dirty[0] & /*value*/
    256 && v(), e.$$.dirty[0] & /*mousePosition*/
    4, e.$$.dirty[0] & /*tooltipText*/
    8, e.$$.dirty[0] & /*lattice*/
    16, e.$$.dirty[0] & /*materialFile*/
    1024 && D(), e.$$.dirty[0] & /*height*/
    1 && I();
  }, [
    s,
    l,
    p,
    g,
    h,
    d,
    y,
    m,
    o,
    i,
    a,
    u,
    c,
    M,
    F,
    P,
    E
  ];
}
class $de extends jde {
  constructor(t) {
    super(), Yde(
      this,
      t,
      Jde,
      Qde,
      Zde,
      {
        gradio: 9,
        materialFile: 10,
        value: 8,
        value_is_output: 11,
        height: 0,
        style: 12,
        latticeInfoVisible: 1
      },
      null,
      [-1, -1]
    );
  }
  get gradio() {
    return this.$$.ctx[9];
  }
  set gradio(t) {
    this.$$set({ gradio: t }), Hd();
  }
  get materialFile() {
    return this.$$.ctx[10];
  }
  set materialFile(t) {
    this.$$set({ materialFile: t }), Hd();
  }
  get value() {
    return this.$$.ctx[8];
  }
  set value(t) {
    this.$$set({ value: t }), Hd();
  }
  get value_is_output() {
    return this.$$.ctx[11];
  }
  set value_is_output(t) {
    this.$$set({ value_is_output: t }), Hd();
  }
  get height() {
    return this.$$.ctx[0];
  }
  set height(t) {
    this.$$set({ height: t }), Hd();
  }
  get style() {
    return this.$$.ctx[12];
  }
  set style(t) {
    this.$$set({ style: t }), Hd();
  }
  get latticeInfoVisible() {
    return this.$$.ctx[1];
  }
  set latticeInfoVisible(t) {
    this.$$set({ latticeInfoVisible: t }), Hd();
  }
}
const {
  SvelteComponent: efe,
  attr: K5,
  create_component: tfe,
  destroy_component: rfe,
  detach: nfe,
  element: ife,
  flush: Qi,
  init: afe,
  insert: ofe,
  mount_component: ufe,
  safe_not_equal: sfe,
  transition_in: cfe,
  transition_out: lfe
} = window.__gradio__svelte__internal;
function dfe(e) {
  let t, r, n, i;
  return r = new $de({
    props: {
      gradio: (
        /*gradio*/
        e[1]
      ),
      materialFile: (
        /*materialFile*/
        e[2]
      ),
      value: (
        /*value*/
        e[0]
      ),
      value_is_output: (
        /*value_is_output*/
        e[3]
      ),
      height: (
        /*height*/
        e[4]
      ),
      style: (
        /*style*/
        e[5]
      ),
      latticeInfoVisible: (
        /*latticeInfoVisible*/
        e[6]
      )
    }
  }), {
    c() {
      t = ife("div"), tfe(r.$$.fragment), K5(t, "class", "material-viewer-index-container svelte-1d67499"), K5(t, "style", n = `height: ${/*height*/
      e[4]}px;`);
    },
    m(a, o) {
      ofe(a, t, o), ufe(r, t, null), i = !0;
    },
    p(a, [o]) {
      const u = {};
      o & /*gradio*/
      2 && (u.gradio = /*gradio*/
      a[1]), o & /*materialFile*/
      4 && (u.materialFile = /*materialFile*/
      a[2]), o & /*value*/
      1 && (u.value = /*value*/
      a[0]), o & /*value_is_output*/
      8 && (u.value_is_output = /*value_is_output*/
      a[3]), o & /*height*/
      16 && (u.height = /*height*/
      a[4]), o & /*style*/
      32 && (u.style = /*style*/
      a[5]), o & /*latticeInfoVisible*/
      64 && (u.latticeInfoVisible = /*latticeInfoVisible*/
      a[6]), r.$set(u), (!i || o & /*height*/
      16 && n !== (n = `height: ${/*height*/
      a[4]}px;`)) && K5(t, "style", n);
    },
    i(a) {
      i || (cfe(r.$$.fragment, a), i = !0);
    },
    o(a) {
      lfe(r.$$.fragment, a), i = !1;
    },
    d(a) {
      a && nfe(t), rfe(r);
    }
  };
}
function ffe(e, t, r) {
  this && this.__awaiter;
  let { gradio: n } = t, { materialFile: i = "" } = t, { label: a = "Textbox" } = t, { elem_id: o = "" } = t, { elem_classes: u = [] } = t, { visible: s = !0 } = t, { value: c = "" } = t, { placeholder: l = "" } = t, { show_label: d } = t, { scale: f = null } = t, { min_width: m = void 0 } = t, { loading_status: v = void 0 } = t, { value_is_output: p = !1 } = t, { interactive: g } = t, { rtl: h = !1 } = t, { height: y } = t, { style: x } = t, { latticeInfoVisible: A } = t;
  window.process = {
    env: { NODE_ENV: "production", LANG: "" }
  };
  function b() {
    n.dispatch("change"), p || n.dispatch("input");
  }
  return e.$$set = (_) => {
    "gradio" in _ && r(1, n = _.gradio), "materialFile" in _ && r(2, i = _.materialFile), "label" in _ && r(7, a = _.label), "elem_id" in _ && r(8, o = _.elem_id), "elem_classes" in _ && r(9, u = _.elem_classes), "visible" in _ && r(10, s = _.visible), "value" in _ && r(0, c = _.value), "placeholder" in _ && r(11, l = _.placeholder), "show_label" in _ && r(12, d = _.show_label), "scale" in _ && r(13, f = _.scale), "min_width" in _ && r(14, m = _.min_width), "loading_status" in _ && r(15, v = _.loading_status), "value_is_output" in _ && r(3, p = _.value_is_output), "interactive" in _ && r(16, g = _.interactive), "rtl" in _ && r(17, h = _.rtl), "height" in _ && r(4, y = _.height), "style" in _ && r(5, x = _.style), "latticeInfoVisible" in _ && r(6, A = _.latticeInfoVisible);
  }, e.$$.update = () => {
    e.$$.dirty & /*value*/
    1 && c === null && r(0, c = ""), e.$$.dirty & /*value*/
    1 && b();
  }, [
    c,
    n,
    i,
    p,
    y,
    x,
    A,
    a,
    o,
    u,
    s,
    l,
    d,
    f,
    m,
    v,
    g,
    h
  ];
}
class pfe extends efe {
  constructor(t) {
    super(), afe(this, t, ffe, dfe, sfe, {
      gradio: 1,
      materialFile: 2,
      label: 7,
      elem_id: 8,
      elem_classes: 9,
      visible: 10,
      value: 0,
      placeholder: 11,
      show_label: 12,
      scale: 13,
      min_width: 14,
      loading_status: 15,
      value_is_output: 3,
      interactive: 16,
      rtl: 17,
      height: 4,
      style: 5,
      latticeInfoVisible: 6
    });
  }
  get gradio() {
    return this.$$.ctx[1];
  }
  set gradio(t) {
    this.$$set({ gradio: t }), Qi();
  }
  get materialFile() {
    return this.$$.ctx[2];
  }
  set materialFile(t) {
    this.$$set({ materialFile: t }), Qi();
  }
  get label() {
    return this.$$.ctx[7];
  }
  set label(t) {
    this.$$set({ label: t }), Qi();
  }
  get elem_id() {
    return this.$$.ctx[8];
  }
  set elem_id(t) {
    this.$$set({ elem_id: t }), Qi();
  }
  get elem_classes() {
    return this.$$.ctx[9];
  }
  set elem_classes(t) {
    this.$$set({ elem_classes: t }), Qi();
  }
  get visible() {
    return this.$$.ctx[10];
  }
  set visible(t) {
    this.$$set({ visible: t }), Qi();
  }
  get value() {
    return this.$$.ctx[0];
  }
  set value(t) {
    this.$$set({ value: t }), Qi();
  }
  get placeholder() {
    return this.$$.ctx[11];
  }
  set placeholder(t) {
    this.$$set({ placeholder: t }), Qi();
  }
  get show_label() {
    return this.$$.ctx[12];
  }
  set show_label(t) {
    this.$$set({ show_label: t }), Qi();
  }
  get scale() {
    return this.$$.ctx[13];
  }
  set scale(t) {
    this.$$set({ scale: t }), Qi();
  }
  get min_width() {
    return this.$$.ctx[14];
  }
  set min_width(t) {
    this.$$set({ min_width: t }), Qi();
  }
  get loading_status() {
    return this.$$.ctx[15];
  }
  set loading_status(t) {
    this.$$set({ loading_status: t }), Qi();
  }
  get value_is_output() {
    return this.$$.ctx[3];
  }
  set value_is_output(t) {
    this.$$set({ value_is_output: t }), Qi();
  }
  get interactive() {
    return this.$$.ctx[16];
  }
  set interactive(t) {
    this.$$set({ interactive: t }), Qi();
  }
  get rtl() {
    return this.$$.ctx[17];
  }
  set rtl(t) {
    this.$$set({ rtl: t }), Qi();
  }
  get height() {
    return this.$$.ctx[4];
  }
  set height(t) {
    this.$$set({ height: t }), Qi();
  }
  get style() {
    return this.$$.ctx[5];
  }
  set style(t) {
    this.$$set({ style: t }), Qi();
  }
  get latticeInfoVisible() {
    return this.$$.ctx[6];
  }
  set latticeInfoVisible(t) {
    this.$$set({ latticeInfoVisible: t }), Qi();
  }
}
export {
  pfe as default
};
