var cc = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function qg(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
function F3(e) {
  if (e.__esModule) return e;
  var r = e.default;
  if (typeof r == "function") {
    var t = function n() {
      return this instanceof n ? Reflect.construct(r, arguments, this.constructor) : r.apply(this, arguments);
    };
    t.prototype = r.prototype;
  } else t = {};
  return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(e).forEach(function(n) {
    var a = Object.getOwnPropertyDescriptor(e, n);
    Object.defineProperty(t, n, a.get ? a : {
      enumerable: !0,
      get: function() {
        return e[n];
      }
    });
  }), t;
}
var _x = {};
/*! *****************************************************************************
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 IP = function(e, r) {
  return IP = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, n) {
    t.__proto__ = n;
  } || function(t, n) {
    for (var a in n) Object.prototype.hasOwnProperty.call(n, a) && (t[a] = n[a]);
  }, IP(e, r);
};
function kY(e, r) {
  if (typeof r != "function" && r !== null)
    throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
  IP(e, r);
  function t() {
    this.constructor = e;
  }
  e.prototype = r === null ? Object.create(r) : (t.prototype = r.prototype, new t());
}
var BP = function() {
  return BP = Object.assign || function(r) {
    for (var t, n = 1, a = arguments.length; n < a; n++) {
      t = arguments[n];
      for (var i in t) Object.prototype.hasOwnProperty.call(t, i) && (r[i] = t[i]);
    }
    return r;
  }, BP.apply(this, arguments);
};
function UY(e, r) {
  var t = {};
  for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && r.indexOf(n) < 0 && (t[n] = e[n]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var a = 0, n = Object.getOwnPropertySymbols(e); a < n.length; a++)
      r.indexOf(n[a]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[a]) && (t[n[a]] = e[n[a]]);
  return t;
}
function zY(e, r, t, n) {
  var a = arguments.length, i = a < 3 ? r : n === null ? n = Object.getOwnPropertyDescriptor(r, t) : n, o;
  if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(e, r, t, n);
  else for (var c = e.length - 1; c >= 0; c--) (o = e[c]) && (i = (a < 3 ? o(i) : a > 3 ? o(r, t, i) : o(r, t)) || i);
  return a > 3 && i && Object.defineProperty(r, t, i), i;
}
function GY(e, r) {
  return function(t, n) {
    r(t, n, e);
  };
}
function qY(e, r) {
  if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(e, r);
}
function HY(e, r, t, n) {
  function a(i) {
    return i instanceof t ? i : new t(function(o) {
      o(i);
    });
  }
  return new (t || (t = Promise))(function(i, o) {
    function c(l) {
      try {
        u(n.next(l));
      } catch (f) {
        o(f);
      }
    }
    function s(l) {
      try {
        u(n.throw(l));
      } catch (f) {
        o(f);
      }
    }
    function u(l) {
      l.done ? i(l.value) : a(l.value).then(c, s);
    }
    u((n = n.apply(e, r || [])).next());
  });
}
function jY(e, r) {
  var t = { label: 0, sent: function() {
    if (i[0] & 1) throw i[1];
    return i[1];
  }, trys: [], ops: [] }, n, a, i, o;
  return o = { next: c(0), throw: c(1), return: c(2) }, typeof Symbol == "function" && (o[Symbol.iterator] = function() {
    return this;
  }), o;
  function c(u) {
    return function(l) {
      return s([u, l]);
    };
  }
  function s(u) {
    if (n) throw new TypeError("Generator is already executing.");
    for (; t; ) try {
      if (n = 1, a && (i = u[0] & 2 ? a.return : u[0] ? a.throw || ((i = a.return) && i.call(a), 0) : a.next) && !(i = i.call(a, u[1])).done) return i;
      switch (a = 0, i && (u = [u[0] & 2, i.value]), u[0]) {
        case 0:
        case 1:
          i = u;
          break;
        case 4:
          return t.label++, { value: u[1], done: !1 };
        case 5:
          t.label++, a = u[1], u = [0];
          continue;
        case 7:
          u = t.ops.pop(), t.trys.pop();
          continue;
        default:
          if (i = t.trys, !(i = i.length > 0 && i[i.length - 1]) && (u[0] === 6 || u[0] === 2)) {
            t = 0;
            continue;
          }
          if (u[0] === 3 && (!i || u[1] > i[0] && u[1] < i[3])) {
            t.label = u[1];
            break;
          }
          if (u[0] === 6 && t.label < i[1]) {
            t.label = i[1], i = u;
            break;
          }
          if (i && t.label < i[2]) {
            t.label = i[2], t.ops.push(u);
            break;
          }
          i[2] && t.ops.pop(), t.trys.pop();
          continue;
      }
      u = r.call(e, t);
    } catch (l) {
      u = [6, l], a = 0;
    } finally {
      n = i = 0;
    }
    if (u[0] & 5) throw u[1];
    return { value: u[0] ? u[1] : void 0, done: !0 };
  }
}
var Fw = Object.create ? function(e, r, t, n) {
  n === void 0 && (n = t), Object.defineProperty(e, n, { enumerable: !0, get: function() {
    return r[t];
  } });
} : function(e, r, t, n) {
  n === void 0 && (n = t), e[n] = r[t];
};
function $Y(e, r) {
  for (var t in e) t !== "default" && !Object.prototype.hasOwnProperty.call(r, t) && Fw(r, e, t);
}
function NP(e) {
  var r = typeof Symbol == "function" && Symbol.iterator, t = r && e[r], n = 0;
  if (t) return t.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(r ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function jk(e, r) {
  var t = typeof Symbol == "function" && e[Symbol.iterator];
  if (!t) return e;
  var n = t.call(e), a, i = [], o;
  try {
    for (; (r === void 0 || r-- > 0) && !(a = n.next()).done; ) i.push(a.value);
  } catch (c) {
    o = { error: c };
  } finally {
    try {
      a && !a.done && (t = n.return) && t.call(n);
    } finally {
      if (o) throw o.error;
    }
  }
  return i;
}
function KY() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e = e.concat(jk(arguments[r]));
  return e;
}
function WY() {
  for (var e = 0, r = 0, t = arguments.length; r < t; r++) e += arguments[r].length;
  for (var n = Array(e), a = 0, r = 0; r < t; r++)
    for (var i = arguments[r], o = 0, c = i.length; o < c; o++, a++)
      n[a] = i[o];
  return n;
}
function XY(e, r, t) {
  if (t || arguments.length === 2) for (var n = 0, a = r.length, i; n < a; n++)
    (i || !(n in r)) && (i || (i = Array.prototype.slice.call(r, 0, n)), i[n] = r[n]);
  return e.concat(i || Array.prototype.slice.call(r));
}
function sg(e) {
  return this instanceof sg ? (this.v = e, this) : new sg(e);
}
function YY(e, r, t) {
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  var n = t.apply(e, r || []), a, i = [];
  return a = {}, o("next"), o("throw"), o("return"), a[Symbol.asyncIterator] = function() {
    return this;
  }, a;
  function o(d) {
    n[d] && (a[d] = function(m) {
      return new Promise(function(p, v) {
        i.push([d, m, p, v]) > 1 || c(d, m);
      });
    });
  }
  function c(d, m) {
    try {
      s(n[d](m));
    } catch (p) {
      f(i[0][3], p);
    }
  }
  function s(d) {
    d.value instanceof sg ? Promise.resolve(d.value.v).then(u, l) : f(i[0][2], d);
  }
  function u(d) {
    c("next", d);
  }
  function l(d) {
    c("throw", d);
  }
  function f(d, m) {
    d(m), i.shift(), i.length && c(i[0][0], i[0][1]);
  }
}
function QY(e) {
  var r, t;
  return r = {}, n("next"), n("throw", function(a) {
    throw a;
  }), n("return"), r[Symbol.iterator] = function() {
    return this;
  }, r;
  function n(a, i) {
    r[a] = e[a] ? function(o) {
      return (t = !t) ? { value: sg(e[a](o)), done: a === "return" } : i ? i(o) : o;
    } : i;
  }
}
function ZY(e) {
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  var r = e[Symbol.asyncIterator], t;
  return r ? r.call(e) : (e = typeof NP == "function" ? NP(e) : e[Symbol.iterator](), t = {}, n("next"), n("throw"), n("return"), t[Symbol.asyncIterator] = function() {
    return this;
  }, t);
  function n(i) {
    t[i] = e[i] && function(o) {
      return new Promise(function(c, s) {
        o = e[i](o), a(c, s, o.done, o.value);
      });
    };
  }
  function a(i, o, c, s) {
    Promise.resolve(s).then(function(u) {
      i({ value: u, done: c });
    }, o);
  }
}
function JY(e, r) {
  return Object.defineProperty ? Object.defineProperty(e, "raw", { value: r }) : e.raw = r, e;
}
var eQ = Object.create ? function(e, r) {
  Object.defineProperty(e, "default", { enumerable: !0, value: r });
} : function(e, r) {
  e.default = r;
};
function rQ(e) {
  if (e && e.__esModule) return e;
  var r = {};
  if (e != null) for (var t in e) t !== "default" && Object.prototype.hasOwnProperty.call(e, t) && Fw(r, e, t);
  return eQ(r, e), r;
}
function tQ(e) {
  return e && e.__esModule ? e : { default: e };
}
function nQ(e, r, t, n) {
  if (t === "a" && !n) throw new TypeError("Private accessor was defined without a getter");
  if (typeof r == "function" ? e !== r || !n : !r.has(e)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
  return t === "m" ? n : t === "a" ? n.call(e) : n ? n.value : r.get(e);
}
function aQ(e, r, t, n, a) {
  if (n === "m") throw new TypeError("Private method is not writable");
  if (n === "a" && !a) throw new TypeError("Private accessor was defined without a setter");
  if (typeof r == "function" ? e !== r || !a : !r.has(e)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
  return n === "a" ? a.call(e, t) : a ? a.value = t : r.set(e, t), t;
}
const iQ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  get __assign() {
    return BP;
  },
  __asyncDelegator: QY,
  __asyncGenerator: YY,
  __asyncValues: ZY,
  __await: sg,
  __awaiter: HY,
  __classPrivateFieldGet: nQ,
  __classPrivateFieldSet: aQ,
  __createBinding: Fw,
  __decorate: zY,
  __exportStar: $Y,
  __extends: kY,
  __generator: jY,
  __importDefault: tQ,
  __importStar: rQ,
  __makeTemplateObject: JY,
  __metadata: qY,
  __param: GY,
  __read: jk,
  __rest: UY,
  __spread: KY,
  __spreadArray: XY,
  __spreadArrays: WY,
  __values: NP
}, Symbol.toStringTag, { value: "Module" })), Te = /* @__PURE__ */ F3(iQ);
var pp = {};
Object.defineProperty(pp, "__esModule", { value: !0 });
pp.BitFlags = void 0;
var VP;
(function(e) {
  function r(a) {
    return a;
  }
  e.create = r;
  function t(a, i) {
    return (a & i) !== 0;
  }
  e.has = t;
  function n(a, i) {
    return !!i && (a & i) === i;
  }
  e.hasAll = n;
})(VP || (VP = {}));
pp.BitFlags = VP;
var L3 = {};
Object.defineProperty(L3, "__esModule", { value: !0 });
L3.StringBuilder = void 0;
var RP;
(function(e) {
  function r(b) {
    return b === void 0 && (b = 512), {
      current: [],
      offset: 0,
      capacity: b,
      chunks: []
    };
  }
  e.create = r;
  function t(b) {
    return b.chunks.length ? (b.offset > 0 && (b.chunks[b.chunks.length] = b.current.length === b.offset ? b.current.join("") : b.current.slice(0, b.offset).join("")), b.chunks.join("")) : b.current.length === b.offset ? b.current.join("") : b.current.splice(0, b.offset).join("");
  }
  e.getString = t;
  function n(b) {
    for (var g = 0, _ = 0, A = b.chunks; _ < A.length; _++) {
      var M = A[_];
      g += M.length;
    }
    for (var P = 0; P < b.offset; P++)
      g += b.current[P].length;
    return g;
  }
  e.getSize = n;
  function a(b) {
    return b.offset > 0 && (b.current.length === b.offset ? b.chunks[b.chunks.length] = b.current.join("") : b.chunks[b.chunks.length] = b.current.slice(0, b.offset).join(""), b.offset = 0), b.chunks;
  }
  e.getChunks = a;
  var i = [];
  (function() {
    for (var b = "", g = 0; g < 512; g++)
      i[g] = b, b = b + " ";
  })();
  function o(b) {
    l(b, `
`);
  }
  e.newline = o;
  function c(b, g) {
    g > 0 && l(b, i[g]);
  }
  e.whitespace = c;
  function s(b) {
    l(b, " ");
  }
  e.whitespace1 = s;
  function u(b, g) {
    g && (b.offset === b.capacity && (b.chunks[b.chunks.length] = b.current.join(""), b.offset = 0), b.current[b.offset++] = g);
  }
  e.write = u;
  function l(b, g) {
    b.offset === b.capacity && (b.chunks[b.chunks.length] = b.current.join(""), b.offset = 0), b.current[b.offset++] = g;
  }
  e.writeSafe = l;
  function f(b, g, _) {
    if (!g) {
      c(b, _);
      return;
    }
    var A = _ - g.length;
    c(b, A), l(b, g);
  }
  e.writePadLeft = f;
  function d(b, g, _) {
    if (!g) {
      c(b, _);
      return;
    }
    var A = _ - g.length;
    l(b, g), c(b, A);
  }
  e.writePadRight = d;
  function m(b, g) {
    l(b, "" + g);
  }
  e.writeInteger = m;
  function p(b, g) {
    l(b, "" + g + " ");
  }
  e.writeIntegerAndSpace = p;
  function v(b, g, _) {
    var A = "" + g, M = _ - A.length;
    c(b, M), l(b, A);
  }
  e.writeIntegerPadLeft = v;
  function h(b, g, _) {
    var A = "" + g, M = _ - A.length;
    l(b, A), c(b, M);
  }
  e.writeIntegerPadRight = h;
  function y(b, g, _) {
    l(b, "" + Math.round(_ * g) / _);
  }
  e.writeFloat = y;
  function C(b, g, _, A) {
    var M = "" + Math.round(_ * g) / _, P = A - M.length;
    c(b, P), l(b, M);
  }
  e.writeFloatPadLeft = C;
  function S(b, g, _, A) {
    var M = "" + Math.round(_ * g) / _, P = A - M.length;
    l(b, M), c(b, P);
  }
  e.writeFloatPadRight = S;
})(RP || (RP = {}));
L3.StringBuilder = RP;
var Hg = {}, Eu = {};
Object.defineProperty(Eu, "__esModule", { value: !0 });
Eu.formatTimespan = Eu.now = void 0;
var oQ = function() {
  if (typeof window < "u" && window.performance) {
    var e = window.performance;
    return function() {
      return e.now();
    };
  } else return typeof process < "u" && process.hrtime !== "undefined" && typeof process.hrtime == "function" ? function() {
    var r = process.hrtime();
    return r[0] * 1e3 + r[1] / 1e6;
  } : Date.now ? function() {
    return Date.now();
  } : function() {
    return +/* @__PURE__ */ new Date();
  };
}();
Eu.now = oQ;
function uQ(e, r) {
  if (r === void 0 && (r = !0), isNaN(e))
    return "n/a";
  for (var t = Math.floor(e / (60 * 60 * 1e3)), n = Math.floor(e / (60 * 1e3) % 60), a = Math.floor(e / 1e3 % 60), i = Math.floor(e % 1e3).toString(); i.length < 3; )
    i = "0" + i;
  for (; !r && i.length > 1 && i[i.length - 1] === "0"; )
    i = i.substr(0, i.length - 1);
  return t > 0 ? "".concat(t, "h").concat(n, "m").concat(a, ".").concat(i, "s") : n > 0 ? "".concat(n, "m").concat(a, ".").concat(i, "s") : a > 0 ? "".concat(a, ".").concat(i, "s") : "".concat(e.toFixed(0), "ms");
}
Eu.formatTimespan = uQ;
Object.defineProperty(Hg, "__esModule", { value: !0 });
Hg.UUID = void 0;
var l6 = Eu, OP;
(function(e) {
  var r = typeof btoa < "u" ? btoa : function(o) {
    return Buffer.from(o).toString("base64");
  }, t = [];
  function n() {
    for (var o = +/* @__PURE__ */ new Date() + (0, l6.now)(), c = 0; c < 16; c++)
      t[c] = String.fromCharCode((o + Math.random() * 255) % 255 | 0), o = Math.floor(o / 255);
    return r(t.join("")).replace(/\+/g, "-").replace(/\//g, "_").substr(0, 22);
  }
  e.create22 = n;
  function a() {
    var o = +/* @__PURE__ */ new Date() + (0, l6.now)(), c = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(s) {
      var u = (o + Math.random() * 16) % 16 | 0;
      return o = Math.floor(o / 16), (s === "x" ? u : u & 3 | 8).toString(16);
    });
    return c;
  }
  e.createv4 = a;
  function i(o) {
    return typeof o == "string";
  }
  e.is = i;
})(OP || (OP = {}));
Hg.UUID = OP;
var Cv = {};
Object.defineProperty(Cv, "__esModule", { value: !0 });
Cv.Mask = Cv.sortAsc = void 0;
function sQ(e, r) {
  return e - r;
}
function $k(e) {
  return Array.prototype.sort.call(e, sQ), e;
}
Cv.sortAsc = $k;
var FP;
(function(e) {
  var r = (
    /** @class */
    function() {
      function m() {
        this.size = 0;
      }
      return m.prototype.has = function(p) {
        return !1;
      }, m.prototype.forEach = function(p, v) {
        return v;
      }, m;
    }()
  ), t = (
    /** @class */
    function() {
      function m(p) {
        this.idx = p, this.size = 1;
      }
      return m.prototype.has = function(p) {
        return p === this.idx;
      }, m.prototype.forEach = function(p, v) {
        return p(this.idx, v), v;
      }, m;
    }()
  ), n = (
    /** @class */
    function() {
      function m(p, v) {
        this.mask = p, this.size = v, this.length = p.length;
      }
      return m.prototype.has = function(p) {
        return p < this.length && !!this.mask[p];
      }, m.prototype._forEach = function(p, v) {
        for (var h = 0; h < this.length; h++)
          this.mask[h] && p(h, v);
      }, m.prototype.forEach = function(p, v) {
        return this._forEach(p, v), v;
      }, m;
    }()
  ), a = (
    /** @class */
    function() {
      function m(p) {
        this.size = p;
      }
      return m.prototype.has = function(p) {
        return !0;
      }, m.prototype._forEach = function(p, v) {
        for (var h = 0; h < this.size; h++)
          p(h, v);
      }, m.prototype.forEach = function(p, v) {
        return this._forEach(p, v), v;
      }, m;
    }()
  ), i = (
    /** @class */
    function() {
      function m(p) {
        this.set = p, this._flat = void 0, this.size = p.size;
      }
      return m.prototype.has = function(p) {
        return this.set.has(p);
      }, m.prototype._forEach = function(p, v) {
        for (var h = 0, y = this.flatten(); h < y.length; h++) {
          var C = y[h];
          p(C, v);
        }
      }, m.prototype.flatten = function() {
        if (this._flat)
          return this._flat;
        var p = new Int32Array(this.size), v = 0;
        return this.set.forEach(function(h) {
          return p[v++] = h;
        }), $k(p), this._flat = p, this._flat;
      }, m.prototype.forEach = function(p, v) {
        return this._forEach(p, v), v;
      }, m;
    }()
  );
  function o(m) {
    return new a(m);
  }
  e.always = o, e.never = new r();
  function c(m) {
    return new i(m);
  }
  e.ofSet = c;
  function s(m) {
    return new t(m);
  }
  e.singleton = s;
  function u(m) {
    var p = m.length;
    if (p === 0)
      return new r();
    if (p === 1)
      return new t(m[0]);
    for (var v = 0, h = 0, y = m; h < y.length; h++) {
      var C = y[h];
      C > v && (v = C);
    }
    if (p === v)
      return new a(p);
    var S = p / v;
    if (S < 1 / 12) {
      for (var b = /* @__PURE__ */ new Set(), g = 0, _ = m; g < _.length; g++) {
        var C = _[g];
        b.add(C);
      }
      return new i(b);
    }
    for (var A = new Int8Array(v + 1), M = 0, P = m; M < P.length; M++) {
      var C = P[M];
      A[C] = 1;
    }
    return new n(A, m.length);
  }
  e.ofUniqueIndices = u;
  function l(m, p) {
    return new n(m, p);
  }
  e.ofMask = l;
  function f(m, p) {
    for (var v = 0, h = p; v < h.length; v++) {
      var y = h[v];
      if (m.has(y))
        return !0;
    }
    return !1;
  }
  e.hasAny = f;
  function d(m, p) {
    var v = 0, h = 0;
    if (p.forEach(function(S) {
      m.has(S) || (v++, S > h && (h = S));
    }), v / h < 1 / 12) {
      var y = /* @__PURE__ */ new Set();
      return p.forEach(function(S) {
        m.has(S) || y.add(S);
      }), c(y);
    } else {
      var C = new Uint8Array(h + 1);
      return p.forEach(function(S) {
        m.has(S) || (C[S] = 1);
      }), l(C, v);
    }
  }
  e.complement = d;
})(FP || (FP = {}));
Cv.Mask = FP;
var Jl = {}, Ra = {};
Object.defineProperty(Ra, "__esModule", { value: !0 });
Ra.idFactory = void 0;
function lQ(e, r) {
  e === void 0 && (e = 0), r === void 0 && (r = Number.MAX_SAFE_INTEGER);
  var t = e;
  return function() {
    var n = t;
    return t = (t + 1) % r, n;
  };
}
Ra.idFactory = lQ;
Object.defineProperty(Jl, "__esModule", { value: !0 });
Jl.ValueCell = Jl.ValueBox = Jl.ValueRef = void 0;
var cQ = Ra, sv;
(function(e) {
  function r(n) {
    return { ref: n };
  }
  e.create = r;
  function t(n, a) {
    return n.ref = a, n;
  }
  e.set = t;
})(sv || (sv = {}));
Jl.ValueRef = sv;
var dQ = (0, cQ.idFactory)(0, 2147483647), lg;
(function(e) {
  function r(n, a) {
    return { id: dQ(), version: 0, value: n, metadata: a };
  }
  e.create = r;
  function t(n, a) {
    return {
      id: n.id,
      version: n.version + 1,
      value: a,
      metadata: n.metadata
    };
  }
  e.withValue = t;
})(lg || (lg = {}));
Jl.ValueBox = lg;
var LP;
(function(e) {
  function r(i, o) {
    return sv.create(lg.create(i, o));
  }
  e.create = r;
  function t(i, o) {
    return sv.set(i, lg.withValue(i.ref, o));
  }
  e.update = t;
  function n(i, o) {
    return sv.set(i, o);
  }
  e.set = n;
  function a(i, o) {
    return i.ref.value !== o ? t(i, o) : i;
  }
  e.updateIfChanged = a;
})(LP || (LP = {}));
Jl.ValueCell = LP;
var bx = {}, Sx = {}, im = {}, kn = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.spiral2d = e.arcLength = e.absMax = e.isPowerOfTwo = e.radToDeg = e.degToRad = e.PiDiv180 = e.halfPI = void 0, e.halfPI = Math.PI / 2, e.PiDiv180 = Math.PI / 180;
  function r(c) {
    return c * e.PiDiv180;
  }
  e.degToRad = r;
  function t(c) {
    return c / e.PiDiv180;
  }
  e.radToDeg = t;
  function n(c) {
    return c !== 0 && (c & c - 1) === 0;
  }
  e.isPowerOfTwo = n;
  function a() {
    for (var c = [], s = 0; s < arguments.length; s++)
      c[s] = arguments[s];
    for (var u = 0, l = 0, f = 0, d = c.length; f < d; ++f) {
      var m = c[f], p = Math.abs(m);
      p > l && (u = m, l = p);
    }
    return u;
  }
  e.absMax = a;
  function i(c, s) {
    return c * s;
  }
  e.arcLength = i;
  function o(c) {
    for (var s, u = 0, l = 0, f = [0, -1], d = c * 2 + 1, m = d / 2, p = [], v = Math.pow(d, 2); v > 0; --v)
      -m < u && u <= m && -m < l && l <= m && p.push([u, l]), (u === l || u < 0 && u === -l || u > 0 && u === 1 - l) && (s = [-f[1], f[0]], f[0] = s[0], f[1] = s[1]), u += f[0], l += f[1];
    return p;
  }
  e.spiral2d = o;
})(kn);
var om = {}, Zr = {};
Object.defineProperty(Zr, "__esModule", { value: !0 });
Zr.almostIdentity = Zr.smootheststep = Zr.smootherstep = Zr.smoothstep = Zr.quadraticBezier = Zr.spline = Zr.lerp = Zr.damp = Zr.saturate = Zr.pclamp = Zr.clamp = Zr.normalize = void 0;
function k3(e, r, t) {
  return (e - r) / (t - r);
}
Zr.normalize = k3;
function Lw(e, r, t) {
  return Math.max(r, Math.min(t, e));
}
Zr.clamp = Lw;
function fQ(e) {
  return Lw(e, 0, 100);
}
Zr.pclamp = fQ;
function U3(e) {
  return Lw(e, 0, 1);
}
Zr.saturate = U3;
function mQ(e, r) {
  var t = e * r;
  return Math.abs(t) < 0.1 ? 0 : t;
}
Zr.damp = mQ;
function vQ(e, r, t) {
  return e + (r - e) * t;
}
Zr.lerp = vQ;
function pQ(e, r, t, n, a, i) {
  var o = (t - e) * i, c = (n - r) * i, s = a * a, u = a * s;
  return (2 * r - 2 * t + o + c) * u + (-3 * r + 3 * t - 2 * o - c) * s + o * a + r;
}
Zr.spline = pQ;
function hQ(e, r, t, n) {
  var a = 1 - n;
  return a * a * e + 2 * a * n * r + n * n * t;
}
Zr.quadraticBezier = hQ;
function gQ(e, r, t) {
  return t = U3(k3(t, e, r)), t * t * (3 - 2 * t);
}
Zr.smoothstep = gQ;
function yQ(e, r, t) {
  return t = U3(k3(t, e, r)), t * t * t * (t * (t * 6 - 15) + 10);
}
Zr.smootherstep = yQ;
function _Q(e, r, t) {
  return t = U3(k3(t, e, r)), -20 * Math.pow(t, 7) + 70 * Math.pow(t, 6) - 84 * Math.pow(t, 5) + 35 * Math.pow(t, 4);
}
Zr.smootheststep = _Q;
function bQ(e, r, t) {
  if (e > r)
    return e;
  var n = 2 * t - r, a = 2 * r - 3 * t, i = e / r;
  return (n * i + a) * i * i + t;
}
Zr.almostIdentity = bQ;
var c6;
function kw() {
  if (c6) return om;
  c6 = 1, Object.defineProperty(om, "__esModule", { value: !0 }), om.Lab = void 0;
  var e = Iu(), r = Uw(), t = kn, n = Zr;
  function a() {
    return a.zero();
  }
  return om.Lab = a, function(i) {
    function o() {
      var B = [0.1, 0, 0];
      return B[0] = 0, B;
    }
    i.zero = o;
    function c(B, D, N) {
      var O = o();
      return O[0] = B, O[1] = D, O[2] = N, O;
    }
    i.create = c;
    function s(B, D) {
      var N = e.Color.toRgb(D), O = N[0], V = N[1], k = N[2], G = I(O, V, k), L = G[0], R = G[1], F = G[2], U = 116 * R - 16;
      return B[0] = U < 0 ? 0 : U, B[1] = 500 * (L - R), B[2] = 200 * (R - F), B;
    }
    i.fromColor = s;
    function u(B, D) {
      return r.Hcl.toLab(B, D);
    }
    i.fromHcl = u;
    function l(B) {
      var D = (B[0] + 16) / 116, N = isNaN(B[1]) ? D : D + B[1] / 500, O = isNaN(B[2]) ? D : D - B[2] / 200;
      D = b * x(D), N = S * x(N), O = g * x(O);
      var V = T(3.2404542 * N - 1.5371385 * D - 0.4985314 * O), k = T(-0.969266 * N + 1.8760108 * D + 0.041556 * O), G = T(0.0556434 * N - 0.2040259 * D + 1.0572252 * O);
      return e.Color.fromRgb(Math.round((0, n.clamp)(V, 0, 255)), Math.round((0, n.clamp)(k, 0, 255)), Math.round((0, n.clamp)(G, 0, 255)));
    }
    i.toColor = l;
    function f(B, D) {
      var N = D[0], O = D[1], V = D[2], k = Math.sqrt(O * O + V * V), G = ((0, t.radToDeg)(Math.atan2(V, O)) + 360) % 360;
      return Math.round(k * 1e4) === 0 && (G = Number.NaN), B[0] = G, B[1] = k, B[2] = N, B;
    }
    i.toHcl = f;
    function d(B, D) {
      return B[0] = D[0], B[1] = D[1], B[2] = D[2], B;
    }
    i.copy = d;
    function m(B, D, N) {
      return B[0] = D[0] - C * N, B[1] = D[1], B[2] = D[2], B;
    }
    i.darken = m;
    function p(B, D, N) {
      return m(B, D, -N);
    }
    i.lighten = p;
    var v = [0, 0, 0];
    function h(B, D, N) {
      return f(v, D), r.Hcl.toLab(B, r.Hcl.saturate(v, v, N));
    }
    i.saturate = h;
    function y(B, D, N) {
      return h(B, D, -N);
    }
    i.desaturate = y;
    var C = 18, S = 0.95047, b = 1, g = 1.08883, _ = 0.137931034, A = 0.206896552, M = 0.12841855, P = 8856452e-9;
    function T(B) {
      return 255 * (B <= 304e-5 ? 12.92 * B : 1.055 * Math.pow(B, 1 / 2.4) - 0.055);
    }
    function x(B) {
      return B > A ? B * B * B : M * (B - _);
    }
    function w(B) {
      return (B /= 255) <= 0.04045 ? B / 12.92 : Math.pow((B + 0.055) / 1.055, 2.4);
    }
    function E(B) {
      return B > P ? Math.pow(B, 1 / 3) : B / M + _;
    }
    function I(B, D, N) {
      B = w(B), D = w(D), N = w(N);
      var O = E((0.4124564 * B + 0.3575761 * D + 0.1804375 * N) / S), V = E((0.2126729 * B + 0.7151522 * D + 0.072175 * N) / b), k = E((0.0193339 * B + 0.119192 * D + 0.9503041 * N) / g);
      return [O, V, k];
    }
  }(a || (a = {})), om.Lab = a, om;
}
var d6;
function Uw() {
  if (d6) return im;
  d6 = 1, Object.defineProperty(im, "__esModule", { value: !0 }), im.Hcl = void 0;
  var e = kn, r = kw();
  function t() {
    return t.zero();
  }
  return im.Hcl = t, function(n) {
    function a() {
      var S = [0.1, 0, 0];
      return S[0] = 0, S;
    }
    n.zero = a;
    function i(S, b, g) {
      var _ = a();
      return _[0] = S, _[1] = b, _[2] = g, _;
    }
    n.create = i;
    var o = [0, 0, 0];
    function c(S, b) {
      return r.Lab.toHcl(S, r.Lab.fromColor(o, b));
    }
    n.fromColor = c;
    function s(S, b) {
      return r.Lab.toHcl(S, b);
    }
    n.fromLab = s;
    var u = [0, 0, 0];
    function l(S) {
      return r.Lab.toColor(f(u, S));
    }
    n.toColor = l;
    function f(S, b) {
      var g = b[0], _ = b[1], A = b[2];
      return isNaN(g) && (g = 0), g = (0, e.degToRad)(g), S[0] = A, S[1] = Math.cos(g) * _, S[2] = Math.sin(g) * _, S;
    }
    n.toLab = f;
    function d(S, b) {
      return S[0] = b[0], S[1] = b[1], S[2] = b[2], S;
    }
    n.copy = d;
    function m(S, b, g) {
      return S[0] = b[0], S[1] = Math.max(0, b[1] + C * g), S[2] = b[2], S;
    }
    n.saturate = m;
    function p(S, b, g) {
      return m(S, b, -g);
    }
    n.desaturate = p;
    var v = [0, 0, 0];
    function h(S, b, g) {
      return f(v, b), r.Lab.toHcl(S, r.Lab.darken(v, v, g));
    }
    n.darken = h;
    function y(S, b, g) {
      return h(S, b, -g);
    }
    n.lighten = y;
    var C = 18;
  }(t || (t = {})), im.Hcl = t, im;
}
var f6;
function Iu() {
  return f6 || (f6 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.ColorSwatch = e.getAdjustedColorMap = e.ColorMap = e.ColorTable = e.ColorList = e.Color = void 0;
    var r = Uw(), t = kw();
    function n(u) {
      return u;
    }
    e.Color = n, function(u) {
      function l(O) {
        return "rgb(".concat(O >> 16 & 255, ", ").concat(O >> 8 & 255, ", ").concat(O & 255, ")");
      }
      u.toStyle = l;
      function f(O) {
        return "0x" + ("000000" + O.toString(16)).slice(-6);
      }
      u.toHexString = f;
      function d(O) {
        return "RGB: ".concat(u.toRgb(O).join(", "));
      }
      u.toRgbString = d;
      function m(O) {
        return [O >> 16 & 255, O >> 8 & 255, O & 255];
      }
      u.toRgb = m;
      function p(O) {
        return [
          (O >> 16 & 255) / 255,
          (O >> 8 & 255) / 255,
          (O & 255) / 255
        ];
      }
      u.toRgbNormalized = p;
      function v(O, V, k) {
        return O << 16 | V << 8 | k;
      }
      u.fromRgb = v;
      function h(O, V, k) {
        return O * 255 << 16 | V * 255 << 8 | k * 255;
      }
      u.fromNormalizedRgb = h;
      function y(O, V) {
        return v(O[V], O[V + 1], O[V + 2]);
      }
      u.fromArray = y;
      function C(O, V) {
        return h(O[V], O[V + 1], O[V + 2]);
      }
      u.fromNormalizedArray = C;
      function S(O, V, k) {
        return V[k] = O >> 16 & 255, V[k + 1] = O >> 8 & 255, V[k + 2] = O & 255, V;
      }
      u.toArray = S;
      function b(O, V, k) {
        return V[k] = (O >> 16 & 255) / 255, V[k + 1] = (O >> 8 & 255) / 255, V[k + 2] = (O & 255) / 255, V;
      }
      u.toArrayNormalized = b;
      function g(O, V) {
        return O[0] = V >> 16 & 255, O[1] = V >> 8 & 255, O[2] = V & 255, O;
      }
      u.toVec3 = g;
      function _(O, V) {
        return O[0] = (V >> 16 & 255) / 255, O[1] = (V >> 8 & 255) / 255, O[2] = (V & 255) / 255, O;
      }
      u.toVec3Normalized = _;
      function A(O, V, k) {
        var G = O >> 16 & 255, L = O >> 8 & 255, R = O & 255, F = V >> 16 & 255, U = V >> 8 & 255, H = V & 255, q = G + (F - G) * k, K = L + (U - L) * k, Y = R + (H - R) * k;
        return q << 16 | K << 8 | Y;
      }
      u.interpolate = A;
      var M = [0, 0, 0];
      function P(O, V) {
        return r.Hcl.fromColor(M, O), r.Hcl.toColor(r.Hcl.saturate(M, M, V));
      }
      u.saturate = P;
      function T(O, V) {
        return P(O, -V);
      }
      u.desaturate = T;
      var x = [0, 0, 0];
      function w(O, V) {
        return t.Lab.fromColor(x, O), t.Lab.toColor(t.Lab.darken(x, x, V));
      }
      u.darken = w;
      function E(O, V) {
        return w(O, -V);
      }
      u.lighten = E;
      function I(O) {
        return O < 0.04045 ? O * 0.0773993808 : Math.pow(O * 0.9478672986 + 0.0521327014, 2.4);
      }
      function B(O) {
        return h(I((O >> 16 & 255) / 255), I((O >> 8 & 255) / 255), I((O & 255) / 255));
      }
      u.sRGBToLinear = B;
      function D(O) {
        return O < 31308e-7 ? O * 12.92 : 1.055 * Math.pow(O, 0.41666) - 0.055;
      }
      function N(O) {
        return h(D((O >> 16 & 255) / 255), D((O >> 8 & 255) / 255), D((O & 255) / 255));
      }
      u.linearToSRGB = N;
    }(n = e.Color || (e.Color = {}));
    function a(u, l, f, d) {
      return { label: u, description: f, list: d, type: l };
    }
    e.ColorList = a;
    function i(u) {
      return u;
    }
    e.ColorTable = i;
    function o(u) {
      return u;
    }
    e.ColorMap = o;
    function c(u, l, f) {
      var d = {};
      for (var m in u) {
        var p = u[m];
        p = n.saturate(p, l), p = n.darken(p, -f), d[m] = p;
      }
      return d;
    }
    e.getAdjustedColorMap = c;
    function s(u) {
      return u;
    }
    e.ColorSwatch = s;
  }(Sx)), Sx;
}
var Cx = {}, _c = {}, cs = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.stripTags = e.trimCharEnd = e.trimCharStart = e.trimChar = e.interpolate = e.substringStartsWith = e.stringToWords = e.kebabCaseToWords = e.splitKebabCase = e.snakeCaseToWords = e.splitSnakeCase = e.capitalize = e.upperCaseAny = e.upperCase = e.lowerCase = e.camelCaseToWords = e.splitCamelCase = e.indentString = void 0;
  var r = Te, t = /^/mg;
  function n(g, _, A) {
    return _ === 0 ? g : g.replace(t, A.repeat(_));
  }
  e.indentString = n;
  function a(g, _) {
    return _ === void 0 && (_ = " "), g.replace(/([a-z\xE0-\xFF])([A-Z\xC0\xDF])/g, "$1".concat(_, "$2"));
  }
  e.splitCamelCase = a;
  function i(g) {
    return u(a(g));
  }
  e.camelCaseToWords = i;
  var o = function(g) {
    return g.toLowerCase();
  };
  e.lowerCase = o;
  var c = function(g) {
    return g.toUpperCase();
  };
  e.upperCase = c;
  function s(g) {
    return g ? typeof g == "string" ? g.toUpperCase() : "".concat(g).toUpperCase() : "";
  }
  e.upperCaseAny = s;
  function u(g) {
    return g.toLowerCase().replace(/^\w|\s\w/g, e.upperCase);
  }
  e.capitalize = u;
  function l(g) {
    return g.replace(/_/g, " ");
  }
  e.splitSnakeCase = l;
  function f(g) {
    return u(l(g));
  }
  e.snakeCaseToWords = f;
  function d(g) {
    return g.replace(/-/g, " ");
  }
  e.splitKebabCase = d;
  function m(g) {
    return u(d(g));
  }
  e.kebabCaseToWords = m;
  function p(g) {
    return u(a(l(d(g))));
  }
  e.stringToWords = p;
  function v(g, _, A, M) {
    var P = M.length;
    if (P > A - _)
      return !1;
    for (var T = 0; T < P; T++)
      if (g.charCodeAt(_ + T) !== M.charCodeAt(T))
        return !1;
    return !0;
  }
  e.substringStartsWith = v;
  function h(g, _) {
    var A = Object.keys(_), M = Object.values(_);
    return new (Function.bind.apply(Function, (0, r.__spreadArray)((0, r.__spreadArray)([void 0], A, !1), ["return `".concat(g, "`;")], !1)))().apply(void 0, M);
  }
  e.interpolate = h;
  function y(g, _) {
    for (var A = 0, M = g.length; A < M && g[A] === _; )
      ++A;
    for (; M > A && g[M - 1] === _; )
      --M;
    return A > 0 || M < g.length ? g.substring(A, M) : g;
  }
  e.trimChar = y;
  function C(g, _) {
    for (var A = 0, M = g.length; A < M && g[A] === _; )
      ++A;
    return A > 0 ? g.substring(A, M) : g;
  }
  e.trimCharStart = C;
  function S(g, _) {
    for (var A = g.length; A > 0 && g[A - 1] === _; )
      --A;
    return A < g.length ? g.substring(0, A) : g;
  }
  e.trimCharEnd = S;
  function b(g) {
    return g.replace(/<\/?[^>]+>/g, "");
  }
  e.stripTags = b;
})(cs);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.getColorListFromName = e.ColorListOptionsSet = e.ColorListOptionsScale = e.ColorListOptions = e.ColorListNames = e.ColorLists = void 0;
  var r = Iu(), t = cs;
  e.ColorLists = {
    /**
     * Brewer Color Lists
     *
     * Copyright (c) 2002 Cynthia Brewer, Mark Harrower, and The Pennsylvania State University.
     * Licensed under the Apache License, Version 2.0 (the "License");
     */
    "orange-red": (0, r.ColorList)("Orange-Red", "sequential", "Orange-Red, sequential color scheme from ColorBrewer 2.0", [
      16775148,
      16705736,
      16635038,
      16628612,
      16551257,
      15689032,
      14102559,
      11730944,
      8323072
    ]),
    "purple-blue": (0, r.ColorList)("Purple-Blue", "sequential", "Purple-Blue, sequential color scheme from ColorBrewer 2.0", [
      16775163,
      15525874,
      13685222,
      10927579,
      7645647,
      3576e3,
      356528,
      285325,
      145496
    ]),
    "blue-purple": (0, r.ColorList)("Blue-Purple", "sequential", "Blue-Purple, sequential color scheme from ColorBrewer 2.0", [
      16252157,
      14740724,
      12571622,
      10403034,
      9213638,
      9202609,
      8929693,
      8458108,
      5046347
    ]),
    oranges: (0, r.ColorList)("Oranges", "sequential", "", [
      16774635,
      16705230,
      16634018,
      16625259,
      16616764,
      15821075,
      14239745,
      10892803,
      8333060
    ]),
    "blue-green": (0, r.ColorList)("Blue-Green", "sequential", "", [
      16252157,
      15070713,
      13429990,
      10082505,
      6734500,
      4304502,
      2329413,
      27948,
      17435
    ]),
    "yellow-orange-brown": (0, r.ColorList)("Yellow-Orange-Brown", "sequential", "", [
      16777189,
      16775100,
      16704401,
      16696399,
      16685353,
      15495188,
      13388802,
      10040324,
      6694150
    ]),
    "yellow-green": (0, r.ColorList)("Yellow-Green", "sequential", "", [
      16777189,
      16252089,
      14282915,
      11394446,
      7915129,
      4303709,
      2327619,
      26679,
      17705
    ]),
    reds: (0, r.ColorList)("Reds", "sequential", "", [
      16774640,
      16703698,
      16563105,
      16552562,
      16476746,
      15678252,
      13309981,
      10817301,
      6750221
    ]),
    "red-purple": (0, r.ColorList)("Red-Purple", "sequential", "", [
      16775155,
      16638173,
      16565696,
      16424885,
      16214177,
      14496919,
      11403646,
      7995767,
      4784234
    ]),
    greens: (0, r.ColorList)("Greens", "sequential", "", [
      16252149,
      15070688,
      13101504,
      10607003,
      7652470,
      4303709,
      2329413,
      27948,
      17435
    ]),
    "yellow-green-blue": (0, r.ColorList)("Yellow-Green-Blue", "sequential", "", [
      16777177,
      15595697,
      13101492,
      8375739,
      4306628,
      1937856,
      2252456,
      2438292,
      531800
    ]),
    purples: (0, r.ColorList)("Purples", "sequential", "", [
      16579581,
      15724021,
      14342891,
      12369372,
      10394312,
      8420794,
      6967715,
      5515151,
      4128893
    ]),
    "green-blue": (0, r.ColorList)("Green-Blue", "sequential", "", [
      16252144,
      14742491,
      13429701,
      11066805,
      8113348,
      5157843,
      2854078,
      551084,
      540801
    ]),
    greys: (0, r.ColorList)("Greys", "sequential", "", [
      16777215,
      15790320,
      14277081,
      12434877,
      9868950,
      7566195,
      5395026,
      2434341,
      0
    ]),
    "yellow-orange-red": (0, r.ColorList)("Yellow-Orange-Red", "sequential", "", [
      16777164,
      16772512,
      16701814,
      16691788,
      16616764,
      16535082,
      14883356,
      12386342,
      8388646
    ]),
    "purple-red": (0, r.ColorList)("Purple-Red", "sequential", "", [
      16250105,
      15196655,
      13941210,
      13210823,
      14640560,
      15149450,
      13505110,
      9961539,
      6750239
    ]),
    blues: (0, r.ColorList)("Blues", "sequential", "", [
      16251903,
      14609399,
      13032431,
      10406625,
      7057110,
      4362950,
      2191797,
      545180,
      536683
    ]),
    "purple-blue-green": (0, r.ColorList)("Purple-Blue-Green", "sequential", "", [
      16775163,
      15524592,
      13685222,
      10927579,
      6793679,
      3576e3,
      164234,
      93273,
      83510
    ]),
    spectral: (0, r.ColorList)("Spectral", "diverging", "", [
      10355010,
      13975119,
      16018755,
      16625249,
      16703627,
      16777151,
      15136152,
      11263396,
      6734501,
      3311805,
      6180770
    ]),
    "red-yellow-green": (0, r.ColorList)("Red-Yellow-Green", "diverging", "", [
      10813478,
      14102567,
      16018755,
      16625249,
      16703627,
      16777151,
      14282635,
      10934634,
      6733155,
      1742928,
      26679
    ]),
    "red-blue": (0, r.ColorList)("Red-Blue", "diverging", "", [
      6750239,
      11671595,
      14049357,
      16033154,
      16636871,
      16250871,
      13755888,
      9618910,
      4428739,
      2188972,
      340065
    ]),
    "pink-yellow-green": (0, r.ColorList)("Pink-Yellow-Green", "diverging", "", [
      9306450,
      12917629,
      14579630,
      15840986,
      16638191,
      16250871,
      15136208,
      12116358,
      8371265,
      5083681,
      2581529
    ]),
    "purple-green": (0, r.ColorList)("Purple-Green", "diverging", "", [
      4194379,
      7744131,
      10055851,
      12756431,
      15193320,
      16250871,
      14282963,
      10935200,
      5942881,
      1800247,
      17435
    ]),
    "red-yellow-blue": (0, r.ColorList)("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": (0, r.ColorList)("Brown-White-Green", "diverging", "", [
      5517317,
      9195786,
      12550445,
      14664317,
      16181443,
      16119285,
      13101797,
      8441281,
      3512207,
      91742,
      15408
    ]),
    "red-grey": (0, r.ColorList)("Red-Grey", "diverging", "", [
      6750239,
      11671595,
      14049357,
      16033154,
      16636871,
      16777215,
      14737632,
      12237498,
      8882055,
      5066061,
      1710618
    ]),
    "orange-purple": (0, r.ColorList)("Orange-Purple", "diverging", "", [
      8338184,
      11753478,
      14713364,
      16627811,
      16703670,
      16250871,
      14211819,
      11709394,
      8418220,
      5515144,
      2949195
    ]),
    "set-2": (0, r.ColorList)("Set-2", "qualitative", "", [
      6734501,
      16551266,
      9281739,
      15174339,
      10934356,
      16767279,
      15058068,
      11776947
    ]),
    accent: (0, r.ColorList)("Accent", "qualitative", "", [
      8374655,
      12496596,
      16629894,
      16777113,
      3697840,
      15729279,
      12540695,
      6710886
    ]),
    "set-1": (0, r.ColorList)("Set-1", "qualitative", "", [
      14948892,
      3636920,
      5091146,
      9981603,
      16744192,
      16777011,
      10901032,
      16220607,
      10066329
    ]),
    "set-3": (0, r.ColorList)("Set-3", "qualitative", "", [
      9294791,
      16777139,
      12499674,
      16482418,
      8434131,
      16626786,
      11787881,
      16567781,
      14277081,
      12353725,
      13429701,
      16772463
    ]),
    // C链颜色 进的前几个
    "dark-2": (0, r.ColorList)("Dark-2", "qualitative", "", [
      1810039,
      14245634,
      7696563,
      15149450,
      6727198,
      15117058,
      10909213,
      6710886
    ]),
    paired: (0, r.ColorList)("Paired", "qualitative", "", [
      10931939,
      2062516,
      11722634,
      3383340,
      16489113,
      14883356,
      16629615,
      16744192,
      13284054,
      6962586,
      16777113,
      11622696
    ]),
    "pastel-2": (0, r.ColorList)("Pastel-2", "qualitative", "", [
      11789005,
      16633260,
      13358568,
      16042724,
      15136201,
      16773806,
      15852236,
      13421772
    ]),
    "pastel-1": (0, r.ColorList)("Pastel-1", "qualitative", "", [
      16495790,
      11783651,
      13429701,
      14601188,
      16701862,
      16777164,
      15063229,
      16636652,
      15921906
    ]),
    "many-distinct": (0, r.ColorList)("Many-Distinct", "qualitative", "", [
      // dark-2 0x9c97ff 0xaba2d8
      8948459,
      11646160,
      16116990,
      6994595,
      6727198,
      15117058,
      10909213,
      6710886,
      // set-1
      14948892,
      3636920,
      5091146,
      9981603,
      16744192,
      16777011,
      10901032,
      16220607,
      10066329,
      // set-2
      6734501,
      16551266,
      9281739,
      15174339,
      10934356,
      16767279,
      15058068,
      11776947
    ]),
    /**
     * Matplotlib colormaps, including various perceptually uniform shades, see https://bids.github.io/colormap/
     */
    magma: (0, r.ColorList)("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: (0, r.ColorList)("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: (0, r.ColorList)("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: (0, r.ColorList)("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: (0, r.ColorList)("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: (0, r.ColorList)("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
    ]),
    /**
     * https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html
     */
    turbo: (0, r.ColorList)("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
    ]),
    /**
     * Other
     */
    rainbow: (0, r.ColorList)("Rainbow", "sequential", "", [3367393, 3516485, 16383744, 15501073, 12526114]),
    "red-white-blue": (0, r.ColorList)("Red-White-Blue", "diverging", "", [12526114, 16777215, 3367393])
  }, e.ColorListNames = Object.keys(e.ColorLists), e.ColorListOptions = e.ColorListNames.map(function(a) {
    return [
      a,
      e.ColorLists[a].label,
      (0, t.capitalize)(e.ColorLists[a].type)
    ];
  }), e.ColorListOptionsScale = e.ColorListOptions.filter(function(a) {
    return e.ColorLists[a[0]].type === "diverging" || e.ColorLists[a[0]].type === "sequential";
  }), e.ColorListOptionsSet = e.ColorListOptions.filter(function(a) {
    return e.ColorLists[a[0]].type === "qualitative";
  });
  function n(a) {
    return a in e.ColorLists ? e.ColorLists[a] : (console.warn("unknown color list named '".concat(a, "'")), e.ColorLists["red-yellow-blue"]);
  }
  e.getColorListFromName = n;
})(_c);
var ti = {};
Object.defineProperty(ti, "__esModule", { value: !0 });
ti.ScaleLegend = ti.TableLegend = void 0;
function SQ(e) {
  return { kind: "table-legend", table: e };
}
ti.TableLegend = SQ;
function CQ(e, r, t) {
  return { kind: "scale-legend", minLabel: e, maxLabel: r, colors: t };
}
ti.ScaleLegend = CQ;
var Ax = {}, ah = {}, xx = {}, ih = {}, Tx = {}, z3 = {};
Object.defineProperty(z3, "__esModule", { value: !0 });
z3.ChunkedArray = void 0;
var kP;
(function(e) {
  function r(d) {
    return d.creator && d.chunkSize;
  }
  e.is = r;
  function t(d) {
    var m = d.growBy * d.elementSize;
    d.currentSize = m, d.currentIndex = 0, d.currentChunk = new d.ctor(m), d.allocatedSize += m, d.chunks[d.chunks.length] = d.currentChunk;
  }
  function n(d, m, p, v, h) {
    d.currentIndex >= d.currentSize && t(d);
    var y = d.currentChunk, C = d.currentIndex;
    return y[C] = m, y[C + 1] = p, y[C + 2] = v, y[C + 3] = h, d.currentIndex += 4, d.elementCount++;
  }
  e.add4 = n;
  function a(d, m, p, v) {
    d.currentIndex >= d.currentSize && t(d);
    var h = d.currentChunk, y = d.currentIndex;
    return h[y] = m, h[y + 1] = p, h[y + 2] = v, d.currentIndex += 3, d.elementCount++;
  }
  e.add3 = a;
  function i(d, m, p) {
    d.currentIndex >= d.currentSize && t(d);
    var v = d.currentChunk, h = d.currentIndex;
    return v[h] = m, v[h + 1] = p, d.currentIndex += 2, d.elementCount++;
  }
  e.add2 = i;
  function o(d, m) {
    return d.currentIndex >= d.currentSize && t(d), d.currentChunk[d.currentIndex] = m, d.currentIndex += 1, d.elementCount++;
  }
  e.add = o;
  function c(d, m, p) {
    for (var v = 0; v < m; v++)
      d.currentIndex >= d.currentSize && t(d), d.currentChunk[d.currentIndex++] = p, d.elementCount++;
    return d.elementCount;
  }
  e.addRepeat = c;
  function s(d, m) {
    for (var p = d.elementSize, v = 0, h = m.length; v < h; v += p) {
      d.currentIndex >= d.currentSize && t(d);
      for (var y = d.currentChunk, C = 0; C < p; C++)
        y[d.currentIndex++] = m[v + C];
      d.elementCount++;
    }
    return d.elementCount;
  }
  e.addMany = s;
  function u(d, m) {
    return m === void 0 && (m = !1), l(d, m);
  }
  e.compact = u;
  function l(d, m) {
    var p = d.ctor, v = d.chunks, h = d.currentIndex;
    if (!v.length)
      return new p(0);
    if (v.length === 1 && (m || h === d.allocatedSize))
      return v[0];
    for (var y = 0, C = 0, S = v.length - 1; C < S; C++)
      y += v[C].length;
    y += d.currentIndex;
    var b = new p(y), g = 0;
    if (b.buffer)
      for (var C = 0, S = v.length - 1; C < S; C++)
        b.set(v[C], g), g += v[C].length;
    else
      for (var C = 0, S = v.length - 1; C < S; C++) {
        for (var _ = v[C], A = 0, M = _.length; A < M; A++)
          b[g + A] = _[A];
        g += _.length;
      }
    var P = v[v.length - 1];
    if (b.buffer && h >= d.currentSize)
      b.set(P, g);
    else
      for (var A = 0, M = P.length; A < M; A++)
        b[g + A] = P[A];
    return b;
  }
  e._compact = l;
  function f(d, m, p, v) {
    var h = {
      ctor: d,
      elementSize: m,
      growBy: Math.max(1, Math.ceil(p)),
      allocatedSize: 0,
      elementCount: 0,
      currentSize: 0,
      currentChunk: void 0,
      currentIndex: 0,
      chunks: []
    };
    if (typeof v > "u")
      return h;
    if (typeof v == "number")
      return h.currentChunk = new d(v * m), h.allocatedSize = v * m, h.currentSize = h.currentChunk.length, h.chunks[0] = h.currentChunk, h;
    var y = v;
    if (y.length % m !== 0)
      throw new Error("initialChunk length must be a multiple of the element size.");
    return h.currentChunk = y, h.allocatedSize = y.length, h.currentSize = y.length, h.chunks[0] = y, h;
  }
  e.create = f;
})(kP || (kP = {}));
z3.ChunkedArray = kP;
var G3 = {}, go = {};
Object.defineProperty(go, "__esModule", { value: !0 });
go.sort = go.sortArrayRange = go.sortArray = go.arraySwap = go.arrayLess = void 0;
function cg(e, r, t) {
  return e[r] - e[t];
}
go.arrayLess = cg;
function Wm(e, r, t) {
  var n = e[r];
  e[r] = e[t], e[t] = n;
}
go.arraySwap = Wm;
function Kk(e, r, t, n) {
  var a = t + n >> 1;
  return r(e, t, n) > 0 ? r(e, t, a) > 0 ? r(e, a, n) > 0 ? a : n : t : r(e, n, a) > 0 ? r(e, a, t) > 0 ? a : t : n;
}
function AQ(e, r, t) {
  var n = e.cmp, a = e.swap, i = e.data, o = e.parts, c = r + 1, s = t;
  for (a(i, r, Kk(i, n, r, t)); n(i, s, r) > 0; )
    --s;
  for (var u = r + 1; u <= s; u++) {
    var l = n(i, u, r);
    if (l > 0) {
      for (a(i, u, s), --s; n(i, s, r) > 0; )
        --s;
      u--;
    } else l === 0 && (a(i, u, c), c++);
  }
  for (var u = r; u < c; u++)
    a(i, u, r + s - u);
  o[0] = s - c + r + 1, o[1] = s;
}
function xQ(e, r, t) {
  for (var n = e.data, a = e.cmp, i = e.swap, o = r + 1; o <= t; o++)
    for (var c = o - 1; c >= r && a(n, c, c + 1) > 0; )
      i(n, c, c + 1), c = c - 1;
}
function gb(e, r, t) {
  for (var n = e.parts; r < t; ) {
    if (t - r < 16) {
      xQ(e, r, t);
      return;
    }
    AQ(e, r, t);
    var a = n[0], i = n[1];
    a - r < t - i ? (gb(e, r, a - 1), r = i + 1) : (gb(e, i + 1, t), t = a - 1);
  }
}
function TQ(e, r, t, n) {
  var a = t + 1, i = n;
  Wm(e, t, Kk(e, cg, t, n));
  for (var o = e[t]; e[i] > o; )
    --i;
  for (var c = t + 1; c <= i; c++) {
    var s = e[c];
    if (s > o) {
      for (Wm(e, c, i), --i; e[i] > o; )
        --i;
      c--;
    } else s === o && (Wm(e, c, a), ++a);
  }
  for (var c = t; c < a; c++)
    Wm(e, c, t + i - c);
  r[0] = i - a + t + 1, r[1] = i;
}
function PQ(e, r, t) {
  for (var n = r + 1; n <= t; n++) {
    for (var a = e[n], i = n - 1; i >= r && e[i] > a; )
      e[i + 1] = e[i], i = i - 1;
    e[i + 1] = a;
  }
}
function UP(e, r, t, n) {
  for (; t < n; ) {
    if (n - t < 16) {
      PQ(e, t, n);
      return;
    }
    TQ(e, r, t, n);
    var a = r[0], i = r[1];
    a - t < n - i ? (UP(e, r, t, a - 1), t = i + 1) : (UP(e, r, i + 1, n), n = a - 1);
  }
}
function MQ(e, r) {
  return r === void 0 && (r = cg), Wk(e, 0, e.length, r);
}
go.sortArray = MQ;
function Wk(e, r, t, n) {
  return n === void 0 && (n = cg), n === cg ? UP(e, [0, 0], r, t - 1) : gb({ data: e, cmp: n, swap: Wm, parts: [0, 0] }, r, t - 1), e;
}
go.sortArrayRange = Wk;
function wQ(e, r, t, n, a) {
  var i = { data: e, cmp: n, swap: a, parts: [0, 0] };
  return gb(i, r, t - 1), e;
}
go.sort = wQ;
Object.defineProperty(G3, "__esModule", { value: !0 });
G3.makeBuckets = void 0;
var m6 = go;
function EQ(e, r, t) {
  return e[r].key < e[t].key ? -1 : 1;
}
function DQ(e, r, t, n, a) {
  for (var i = /* @__PURE__ */ new Map(), o = [], c = r(e[0]), s = !0, u = n; u < a; u++) {
    var l = r(e[u]);
    if (i.has(l))
      i.get(l).count++, c !== l && (s = !1);
    else {
      var f = { key: l, count: 1, offset: u };
      i.set(l, f), o[o.length] = f;
    }
    c = l;
  }
  var d = new Int32Array(o.length + 1);
  d[o.length] = a;
  var m = !0;
  if (t) {
    for (var u = 1, p = o.length; u < p; u++)
      if (o[u - 1].key > o[u].key) {
        m = !1;
        break;
      }
  }
  if (s && m) {
    for (var u = 0; u < o.length; u++)
      d[u] = o[u].offset;
    return d;
  }
  t && !m && (0, m6.sort)(o, 0, o.length, EQ, m6.arraySwap);
  for (var v = 0, u = 0; u < o.length; u++) {
    var h = o[u];
    h.offset = v, v += h.count;
  }
  for (var y = new Int32Array(a - n), u = n; u < a; u++) {
    var l = r(e[u]), f = i.get(l);
    y[f.offset++] = e[u];
  }
  for (var u = 0, p = y.length; u < p; u++)
    e[u + n] = y[u];
  d[0] = n;
  for (var u = 1; u < o.length; u++)
    d[u] = o[u - 1].offset + n;
  return d;
}
function IQ(e, r, t) {
  var n = t && t.start || 0, a = t && t.end || e.length;
  if (a - n <= 0)
    throw new Error("Can only bucket non-empty collections.");
  return DQ(e, r, !!(t && t.sort), n, a);
}
G3.makeBuckets = IQ;
var Av = {};
Object.defineProperty(Av, "__esModule", { value: !0 });
Av.EquivalenceClasses = Av.EquivalenceClassesImpl = void 0;
var Xk = (
  /** @class */
  function() {
    function e(r, t) {
      this.getHash = r, this.areEqual = t, this.id = 0, this.byHash = /* @__PURE__ */ new Map(), this.groups = [];
    }
    return e.prototype.createGroup = function(r, t) {
      var n = this.id++, a = [r];
      return this.groups[n] = a, { id: n, keys: a, value: t };
    }, e.prototype.add = function(r, t) {
      var n = this.getHash(t);
      if (this.byHash.has(n)) {
        for (var a = this.byHash.get(n), i = 0, o = a.length; i < o; i++) {
          var c = a[i];
          if (this.areEqual(t, c.value))
            return c.keys[c.keys.length] = r, c.value;
        }
        var s = this.createGroup(r, t);
        return a[a.length] = s, s.value;
      } else {
        var s = this.createGroup(r, t);
        return this.byHash.set(n, [s]), s.value;
      }
    }, e;
  }()
);
Av.EquivalenceClassesImpl = Xk;
function BQ(e, r) {
  return new Xk(e, r);
}
Av.EquivalenceClasses = BQ;
var ea = {};
Object.defineProperty(ea, "__esModule", { value: !0 });
ea.hashFnv32a = ea.invertCantorPairing = ea.sortedCantorPairing = ea.cantorPairing = ea.hashString = ea.hash4 = ea.hash3 = ea.hash2 = ea.hash1 = void 0;
function NQ(e) {
  var r = e ^ e >> 4;
  return r = (r ^ 3735928559) + (r << 5), r = r ^ r >> 11, r;
}
ea.hash1 = NQ;
function VQ(e, r) {
  var t = 23;
  return t = 31 * t + e | 0, t = 31 * t + r | 0, t = t ^ t >> 4, t = (t ^ 3735928559) + (t << 5), t = t ^ t >> 11, t;
}
ea.hash2 = VQ;
function RQ(e, r, t) {
  var n = 23;
  return n = 31 * n + e | 0, n = 31 * n + r | 0, n = 31 * n + t | 0, n = n ^ n >> 4, n = (n ^ 3735928559) + (n << 5), n = n ^ n >> 11, n;
}
ea.hash3 = RQ;
function OQ(e, r, t, n) {
  var a = 23;
  return a = 31 * a + e | 0, a = 31 * a + r | 0, a = 31 * a + t | 0, a = 31 * a + n | 0, a = a ^ a >> 4, a = (a ^ 3735928559) + (a << 5), a = a ^ a >> 11, a;
}
ea.hash4 = OQ;
function FQ(e) {
  for (var r = 0, t = 0, n = e.length; t < n; t++)
    r = (r << 5) - r + e.charCodeAt(t++) | 0;
  return r;
}
ea.hashString = FQ;
function zP(e, r) {
  return (e + r) * (e + r + 1) / 2 + r;
}
ea.cantorPairing = zP;
function LQ(e, r) {
  return e < r ? zP(e, r) : zP(r, e);
}
ea.sortedCantorPairing = LQ;
function kQ(e, r) {
  var t = Math.floor((Math.sqrt(8 * r + 1) - 1) / 2), n = (t * t + t) / 2, a = r - n;
  return e[0] = t - a, e[1] = a, e;
}
ea.invertCantorPairing = kQ;
function UQ(e) {
  for (var r = 2166136261, t = 0, n = e.length; t < n; ++t)
    r ^= e[t], r += (r << 1) + (r << 4) + (r << 7) + (r << 8) + (r << 24);
  return r >>> 0;
}
ea.hashFnv32a = UQ;
var uf = {}, Px = {}, oh = {}, uh = {}, jg = {}, zi = {};
Object.defineProperty(zi, "__esModule", { value: !0 });
zi.typedArrayWindow = zi.isTypedArray = zi.createAndFillArray = zi.fillArrayValues = zi.createArray = zi.getArrayBounds = void 0;
function zw(e, r) {
  var t = r && typeof r.start < "u" ? Math.max(Math.min(r.start, e - 1), 0) : 0, n = r && typeof r.end < "u" ? Math.min(r.end, e) : e;
  return { start: t, end: n };
}
zi.getArrayBounds = zw;
function Yk(e, r) {
  var t = r && typeof r.array < "u" ? r.array : Array, n = zw(e, r), a = n.start, i = n.end;
  return { array: new t(i - a), start: a, end: i };
}
zi.createArray = Yk;
function Qk(e, r, t) {
  for (var n = 0, a = r.length; n < a; n++)
    r[n] = e(t + n);
  return r;
}
zi.fillArrayValues = Qk;
function zQ(e, r, t) {
  var n = Yk(e, t), a = n.array, i = n.start;
  return Qk(r, a, i);
}
zi.createAndFillArray = zQ;
function GQ(e) {
  return !!e.buffer && typeof e.byteLength == "number" && typeof e.BYTES_PER_ELEMENT == "number";
}
zi.isTypedArray = GQ;
function qQ(e, r) {
  var t = e.constructor, n = e.buffer, a = e.length, i = e.byteOffset, o = e.BYTES_PER_ELEMENT, c = zw(a, r), s = c.start, u = c.end;
  return s === 0 && u === a ? e : new t(n, i + o * s, Math.min(a, u - s));
}
zi.typedArrayWindow = qQ;
var Re = {}, q3 = {}, bc = {}, Ci = {};
Object.defineProperty(Ci, "__esModule", { value: !0 });
Ci.equalEps = Ci.EPSILON = void 0;
Ci.EPSILON = 1e-6;
function HQ(e, r, t) {
  return Math.abs(e - r) <= t;
}
Ci.equalEps = HQ;
Object.defineProperty(bc, "__esModule", { value: !0 });
bc.Mat4 = void 0;
var tn = Ci, sf = kn;
function dg() {
  return dg.zero();
}
bc.Mat4 = dg;
(function(e) {
  function r() {
    var z = [0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
    return z[0] = 0, z;
  }
  e.zero = r;
  function t() {
    var z = r();
    return z[0] = 1, z[1] = 0, z[2] = 0, z[3] = 0, z[4] = 0, z[5] = 1, z[6] = 0, z[7] = 0, z[8] = 0, z[9] = 0, z[10] = 1, z[11] = 0, z[12] = 0, z[13] = 0, z[14] = 0, z[15] = 1, z;
  }
  e.identity = t;
  function n(z) {
    return z[0] = 1, z[1] = 0, z[2] = 0, z[3] = 0, z[4] = 0, z[5] = 1, z[6] = 0, z[7] = 0, z[8] = 0, z[9] = 0, z[10] = 1, z[11] = 0, z[12] = 0, z[13] = 0, z[14] = 0, z[15] = 1, z;
  }
  e.setIdentity = n;
  function a(z) {
    for (var j = 0; j < 16; j++)
      z[j] = 0;
    return z;
  }
  e.setZero = a;
  function i(z) {
    for (var j = r(), ae = 0; ae < 4; ae++)
      for (var le = z[ae], ie = 0; ie < 4; ie++)
        j[4 * ie + ae] = le[ie];
    return j;
  }
  e.ofRows = i;
  var o = t();
  function c(z, j) {
    return u(z, o, typeof j > "u" ? tn.EPSILON : j);
  }
  e.isIdentity = c;
  function s(z) {
    for (var j = 0; j < 16; j++)
      if (isNaN(z[j]))
        return !0;
    return !1;
  }
  e.hasNaN = s;
  function u(z, j, ae) {
    for (var le = 0; le < 16; le++)
      if (Math.abs(z[le] - j[le]) > ae)
        return !1;
    return !0;
  }
  e.areEqual = u;
  function l(z, j, ae, le) {
    z[4 * ae + j] = le;
  }
  e.setValue = l;
  function f(z, j, ae) {
    return z[4 * ae + j];
  }
  e.getValue = f;
  function d(z, j, ae) {
    return j[ae + 0] = z[0], j[ae + 1] = z[1], j[ae + 2] = z[2], j[ae + 3] = z[3], j[ae + 4] = z[4], j[ae + 5] = z[5], j[ae + 6] = z[6], j[ae + 7] = z[7], j[ae + 8] = z[8], j[ae + 9] = z[9], j[ae + 10] = z[10], j[ae + 11] = z[11], j[ae + 12] = z[12], j[ae + 13] = z[13], j[ae + 14] = z[14], j[ae + 15] = z[15], j;
  }
  e.toArray = d;
  function m(z, j, ae) {
    return z[0] = j[ae + 0], z[1] = j[ae + 1], z[2] = j[ae + 2], z[3] = j[ae + 3], z[4] = j[ae + 4], z[5] = j[ae + 5], z[6] = j[ae + 6], z[7] = j[ae + 7], z[8] = j[ae + 8], z[9] = j[ae + 9], z[10] = j[ae + 10], z[11] = j[ae + 11], z[12] = j[ae + 12], z[13] = j[ae + 13], z[14] = j[ae + 14], z[15] = j[ae + 15], z;
  }
  e.fromArray = m;
  function p(z, j, ae, le) {
    return a(z), l(z, 0, 0, j[0]), l(z, 1, 0, j[1]), l(z, 2, 0, j[2]), l(z, 0, 1, ae[0]), l(z, 1, 1, ae[1]), l(z, 2, 1, ae[2]), l(z, 0, 2, le[0]), l(z, 1, 2, le[1]), l(z, 2, 2, le[2]), l(z, 3, 3, 1), z;
  }
  e.fromBasis = p;
  function v(z, j) {
    return z[0] = j[0], z[1] = j[1], z[2] = j[2], z[3] = j[3], z[4] = j[4], z[5] = j[5], z[6] = j[6], z[7] = j[7], z[8] = j[8], z[9] = j[9], z[10] = j[10], z[11] = j[11], z[12] = j[12], z[13] = j[13], z[14] = j[14], z[15] = j[15], z;
  }
  e.copy = v;
  function h(z) {
    return v(r(), z);
  }
  e.clone = h;
  function y(z, j) {
    return z[0] = j[12], z[1] = j[13], z[2] = j[14], z;
  }
  e.getTranslation = y;
  function C(z, j) {
    var ae = j[0], le = j[1], ie = j[2], re = j[4], ee = j[5], ne = j[6], se = j[8], ce = j[9], de = j[10];
    return z[0] = Math.sqrt(ae * ae + le * le + ie * ie), z[1] = Math.sqrt(re * re + ee * ee + ne * ne), z[2] = Math.sqrt(se * se + ce * ce + de * de), z;
  }
  e.getScaling = C;
  function S(z, j) {
    var ae = j[0] + j[5] + j[10], le = 0;
    return ae > 0 ? (le = Math.sqrt(ae + 1) * 2, z[3] = 0.25 * le, z[0] = (j[6] - j[9]) / le, z[1] = (j[8] - j[2]) / le, z[2] = (j[1] - j[4]) / le) : j[0] > j[5] && j[0] > j[10] ? (le = Math.sqrt(1 + j[0] - j[5] - j[10]) * 2, z[3] = (j[6] - j[9]) / le, z[0] = 0.25 * le, z[1] = (j[1] + j[4]) / le, z[2] = (j[8] + j[2]) / le) : j[5] > j[10] ? (le = Math.sqrt(1 + j[5] - j[0] - j[10]) * 2, z[3] = (j[8] - j[2]) / le, z[0] = (j[1] + j[4]) / le, z[1] = 0.25 * le, z[2] = (j[6] + j[9]) / le) : (le = Math.sqrt(1 + j[10] - j[0] - j[5]) * 2, z[3] = (j[1] - j[4]) / le, z[0] = (j[8] + j[2]) / le, z[1] = (j[6] + j[9]) / le, z[2] = 0.25 * le), z;
  }
  e.getRotation = S;
  function b(z, j) {
    var ae = 1 / Math.sqrt(j[0] * j[0] + j[1] * j[1] + j[2] * j[2]), le = 1 / Math.sqrt(j[4] * j[4] + j[5] * j[5] + j[6] * j[6]), ie = 1 / Math.sqrt(j[8] * j[8] + j[9] * j[9] + j[10] * j[10]);
    return z[0] = j[0] * ae, z[1] = j[1] * ae, z[2] = j[2] * ae, z[3] = 0, z[4] = j[4] * le, z[5] = j[5] * le, z[6] = j[6] * le, z[7] = 0, z[8] = j[8] * ie, z[9] = j[9] * ie, z[10] = j[10] * ie, z[11] = 0, z[12] = 0, z[13] = 0, z[14] = 0, z[15] = 1, z;
  }
  e.extractRotation = b;
  function g(z, j) {
    if (z === j) {
      var ae = j[1], le = j[2], ie = j[3], re = j[6], ee = j[7], ne = j[11];
      z[1] = j[4], z[2] = j[8], z[3] = j[12], z[4] = ae, z[6] = j[9], z[7] = j[13], z[8] = le, z[9] = re, z[11] = j[14], z[12] = ie, z[13] = ee, z[14] = ne;
    } else
      z[0] = j[0], z[1] = j[4], z[2] = j[8], z[3] = j[12], z[4] = j[1], z[5] = j[5], z[6] = j[9], z[7] = j[13], z[8] = j[2], z[9] = j[6], z[10] = j[10], z[11] = j[14], z[12] = j[3], z[13] = j[7], z[14] = j[11], z[15] = j[15];
    return z;
  }
  e.transpose = g;
  function _(z, j) {
    var ae = j[0], le = j[1], ie = j[2], re = j[3], ee = j[4], ne = j[5], se = j[6], ce = j[7], de = j[8], me = j[9], he = j[10], _e = j[11], Se = j[12], Pe = j[13], De = j[14], Ee = j[15], Me = ae * ne - le * ee, ue = ae * se - ie * ee, pe = ae * ce - re * ee, Ae = le * se - ie * ne, ye = le * ce - re * ne, be = ie * ce - re * se, fe = de * Pe - me * Se, ge = de * De - he * Se, xe = de * Ee - _e * Se, we = me * De - he * Pe, Ve = me * Ee - _e * Pe, Ne = he * Ee - _e * De, Oe = Me * Ne - ue * Ve + pe * we + Ae * xe - ye * ge + be * fe;
    return Oe ? (Oe = 1 / Oe, z[0] = (ne * Ne - se * Ve + ce * we) * Oe, z[1] = (ie * Ve - le * Ne - re * we) * Oe, z[2] = (Pe * be - De * ye + Ee * Ae) * Oe, z[3] = (he * ye - me * be - _e * Ae) * Oe, z[4] = (se * xe - ee * Ne - ce * ge) * Oe, z[5] = (ae * Ne - ie * xe + re * ge) * Oe, z[6] = (De * pe - Se * be - Ee * ue) * Oe, z[7] = (de * be - he * pe + _e * ue) * Oe, z[8] = (ee * Ve - ne * xe + ce * fe) * Oe, z[9] = (le * xe - ae * Ve - re * fe) * Oe, z[10] = (Se * ye - Pe * pe + Ee * Me) * Oe, z[11] = (me * pe - de * ye - _e * Me) * Oe, z[12] = (ne * ge - ee * we - se * fe) * Oe, z[13] = (ae * we - le * ge + ie * fe) * Oe, z[14] = (Pe * ue - Se * Ae - De * Me) * Oe, z[15] = (de * Ae - me * ue + he * Me) * Oe, !0) : !1;
  }
  e.tryInvert = _;
  function A(z, j) {
    return _(z, j) || console.warn("non-invertible matrix.", j), z;
  }
  e.invert = A;
  function M(z, j, ae) {
    var le = j[0], ie = j[1], re = j[2], ee = j[3], ne = j[4], se = j[5], ce = j[6], de = j[7], me = j[8], he = j[9], _e = j[10], Se = j[11], Pe = j[12], De = j[13], Ee = j[14], Me = j[15], ue = ae[0], pe = ae[1], Ae = ae[2], ye = ae[3];
    return z[0] = ue * le + pe * ne + Ae * me + ye * Pe, z[1] = ue * ie + pe * se + Ae * he + ye * De, z[2] = ue * re + pe * ce + Ae * _e + ye * Ee, z[3] = ue * ee + pe * de + Ae * Se + ye * Me, ue = ae[4], pe = ae[5], Ae = ae[6], ye = ae[7], z[4] = ue * le + pe * ne + Ae * me + ye * Pe, z[5] = ue * ie + pe * se + Ae * he + ye * De, z[6] = ue * re + pe * ce + Ae * _e + ye * Ee, z[7] = ue * ee + pe * de + Ae * Se + ye * Me, ue = ae[8], pe = ae[9], Ae = ae[10], ye = ae[11], z[8] = ue * le + pe * ne + Ae * me + ye * Pe, z[9] = ue * ie + pe * se + Ae * he + ye * De, z[10] = ue * re + pe * ce + Ae * _e + ye * Ee, z[11] = ue * ee + pe * de + Ae * Se + ye * Me, ue = ae[12], pe = ae[13], Ae = ae[14], ye = ae[15], z[12] = ue * le + pe * ne + Ae * me + ye * Pe, z[13] = ue * ie + pe * se + Ae * he + ye * De, z[14] = ue * re + pe * ce + Ae * _e + ye * Ee, z[15] = ue * ee + pe * de + Ae * Se + ye * Me, z;
  }
  e.mul = M;
  function P(z, j, ae, le, ie, re) {
    var ee = j[0 + ie], ne = j[1 + ie], se = j[2 + ie], ce = j[3 + ie], de = j[4 + ie], me = j[5 + ie], he = j[6 + ie], _e = j[7 + ie], Se = j[8 + ie], Pe = j[9 + ie], De = j[10 + ie], Ee = j[11 + ie], Me = j[12 + ie], ue = j[13 + ie], pe = j[14 + ie], Ae = j[15 + ie], ye = ae[0 + re], be = ae[1 + re], fe = ae[2 + re], ge = ae[3 + re];
    return z[0 + le] = ye * ee + be * de + fe * Se + ge * Me, z[1 + le] = ye * ne + be * me + fe * Pe + ge * ue, z[2 + le] = ye * se + be * he + fe * De + ge * pe, z[3 + le] = ye * ce + be * _e + fe * Ee + ge * Ae, ye = ae[4 + re], be = ae[5 + re], fe = ae[6 + re], ge = ae[7 + re], z[4 + le] = ye * ee + be * de + fe * Se + ge * Me, z[5 + le] = ye * ne + be * me + fe * Pe + ge * ue, z[6 + le] = ye * se + be * he + fe * De + ge * pe, z[7 + le] = ye * ce + be * _e + fe * Ee + ge * Ae, ye = ae[8 + re], be = ae[9 + re], fe = ae[10 + re], ge = ae[11 + re], z[8 + le] = ye * ee + be * de + fe * Se + ge * Me, z[9 + le] = ye * ne + be * me + fe * Pe + ge * ue, z[10 + le] = ye * se + be * he + fe * De + ge * pe, z[11 + le] = ye * ce + be * _e + fe * Ee + ge * Ae, ye = ae[12 + re], be = ae[13 + re], fe = ae[14 + re], ge = ae[15 + re], z[12 + le] = ye * ee + be * de + fe * Se + ge * Me, z[13 + le] = ye * ne + be * me + fe * Pe + ge * ue, z[14 + le] = ye * se + be * he + fe * De + ge * pe, z[15 + le] = ye * ce + be * _e + fe * Ee + ge * Ae, z;
  }
  e.mulOffset = P;
  function T(z, j, ae, le) {
    return M(z, M(z, j, ae), le);
  }
  e.mul3 = T;
  function x(z, j, ae) {
    var le = ae[0], ie = ae[1], re = ae[2], ee, ne, se, ce, de, me, he, _e, Se, Pe, De, Ee;
    return j === z ? (z[12] = j[0] * le + j[4] * ie + j[8] * re + j[12], z[13] = j[1] * le + j[5] * ie + j[9] * re + j[13], z[14] = j[2] * le + j[6] * ie + j[10] * re + j[14], z[15] = j[3] * le + j[7] * ie + j[11] * re + j[15]) : (ee = j[0], ne = j[1], se = j[2], ce = j[3], de = j[4], me = j[5], he = j[6], _e = j[7], Se = j[8], Pe = j[9], De = j[10], Ee = j[11], z[0] = ee, z[1] = ne, z[2] = se, z[3] = ce, z[4] = de, z[5] = me, z[6] = he, z[7] = _e, z[8] = Se, z[9] = Pe, z[10] = De, z[11] = Ee, z[12] = ee * le + de * ie + Se * re + j[12], z[13] = ne * le + me * ie + Pe * re + j[13], z[14] = se * le + he * ie + De * re + j[14], z[15] = ce * le + _e * ie + Ee * re + j[15]), z;
  }
  e.translate = x;
  function w(z, j) {
    return z[0] = 1, z[1] = 0, z[2] = 0, z[3] = 0, z[4] = 0, z[5] = 1, z[6] = 0, z[7] = 0, z[8] = 0, z[9] = 0, z[10] = 1, z[11] = 0, z[12] = j[0], z[13] = j[1], z[14] = j[2], z[15] = 1, z;
  }
  e.fromTranslation = w;
  function E(z, j) {
    return z[12] = j[0], z[13] = j[1], z[14] = j[2], z;
  }
  e.setTranslation = E;
  function I(z, j, ae, le) {
    return z[0] = ae[0], z[4] = ae[1], z[8] = ae[2], z[1] = le[0], z[5] = le[1], z[9] = le[2], z[2] = j[0], z[6] = j[1], z[10] = j[2], z;
  }
  e.setAxes = I;
  function B(z, j, ae, le) {
    var ie = le[0], re = le[1], ee = le[2], ne = Math.sqrt(ie * ie + re * re + ee * ee);
    if (Math.abs(ne) < tn.EPSILON)
      return t();
    ne = 1 / ne, ie *= ne, re *= ne, ee *= ne;
    var se = Math.sin(ae), ce = Math.cos(ae), de = 1 - ce, me = j[0], he = j[1], _e = j[2], Se = j[3], Pe = j[4], De = j[5], Ee = j[6], Me = j[7], ue = j[8], pe = j[9], Ae = j[10], ye = j[11], be = ie * ie * de + ce, fe = re * ie * de + ee * se, ge = ee * ie * de - re * se, xe = ie * re * de - ee * se, we = re * re * de + ce, Ve = ee * re * de + ie * se, Ne = ie * ee * de + re * se, Oe = re * ee * de - ie * se, ze = ee * ee * de + ce;
    return z[0] = me * be + Pe * fe + ue * ge, z[1] = he * be + De * fe + pe * ge, z[2] = _e * be + Ee * fe + Ae * ge, z[3] = Se * be + Me * fe + ye * ge, z[4] = me * xe + Pe * we + ue * Ve, z[5] = he * xe + De * we + pe * Ve, z[6] = _e * xe + Ee * we + Ae * Ve, z[7] = Se * xe + Me * we + ye * Ve, z[8] = me * Ne + Pe * Oe + ue * ze, z[9] = he * Ne + De * Oe + pe * ze, z[10] = _e * Ne + Ee * Oe + Ae * ze, z[11] = Se * Ne + Me * Oe + ye * ze, j !== z && (z[12] = j[12], z[13] = j[13], z[14] = j[14], z[15] = j[15]), z;
  }
  e.rotate = B;
  function D(z, j, ae) {
    var le = ae[0], ie = ae[1], re = ae[2], ee = Math.sqrt(le * le + ie * ie + re * re);
    if (Math.abs(ee) < tn.EPSILON)
      return n(z);
    ee = 1 / ee, le *= ee, ie *= ee, re *= ee;
    var ne = Math.sin(j), se = Math.cos(j), ce = 1 - se;
    return z[0] = le * le * ce + se, z[1] = ie * le * ce + re * ne, z[2] = re * le * ce - ie * ne, z[3] = 0, z[4] = le * ie * ce - re * ne, z[5] = ie * ie * ce + se, z[6] = re * ie * ce + le * ne, z[7] = 0, z[8] = le * re * ce + ie * ne, z[9] = ie * re * ce - le * ne, z[10] = re * re * ce + se, z[11] = 0, z[12] = 0, z[13] = 0, z[14] = 0, z[15] = 1, z;
  }
  e.fromRotation = D;
  function N(z, j, ae) {
    var le = ae[0], ie = ae[1], re = ae[2];
    return z[0] = j[0] * le, z[1] = j[1] * le, z[2] = j[2] * le, z[3] = j[3] * le, z[4] = j[4] * ie, z[5] = j[5] * ie, z[6] = j[6] * ie, z[7] = j[7] * ie, z[8] = j[8] * re, z[9] = j[9] * re, z[10] = j[10] * re, z[11] = j[11] * re, z[12] = j[12], z[13] = j[13], z[14] = j[14], z[15] = j[15], z;
  }
  e.scale = N;
  function O(z, j, ae) {
    return z[0] = j[0] * ae, z[1] = j[1] * ae, z[2] = j[2] * ae, z[3] = j[3] * ae, z[4] = j[4] * ae, z[5] = j[5] * ae, z[6] = j[6] * ae, z[7] = j[7] * ae, z[8] = j[8] * ae, z[9] = j[9] * ae, z[10] = j[10] * ae, z[11] = j[11] * ae, z[12] = j[12], z[13] = j[13], z[14] = j[14], z[15] = j[15], z;
  }
  e.scaleUniformly = O;
  function V(z, j) {
    return z[0] = j[0], z[1] = 0, z[2] = 0, z[3] = 0, z[4] = 0, z[5] = j[1], z[6] = 0, z[7] = 0, z[8] = 0, z[9] = 0, z[10] = j[2], z[11] = 0, z[12] = 0, z[13] = 0, z[14] = 0, z[15] = 1, z;
  }
  e.fromScaling = V;
  function k(z, j) {
    return z[0] = j, z[1] = 0, z[2] = 0, z[3] = 0, z[4] = 0, z[5] = j, z[6] = 0, z[7] = 0, z[8] = 0, z[9] = 0, z[10] = j, z[11] = 0, z[12] = 0, z[13] = 0, z[14] = 0, z[15] = 1, z;
  }
  e.fromUniformScaling = k;
  function G(z, j) {
    return z[0] = j[0], z[1] = j[1], z[2] = j[2], z[4] = j[3], z[5] = j[4], z[6] = j[5], z[8] = j[6], z[9] = j[7], z[10] = j[8], z;
  }
  e.fromMat3 = G;
  function L(z) {
    for (var j = "", ae = 0; ae < 4; ae++) {
      for (var le = 0; le < 4; le++)
        j += z[4 * le + ae].toString(), le < 3 && (j += " ");
      ae < 3 && (j += `
`);
    }
    return j;
  }
  e.makeTable = L;
  function R(z) {
    var j = z[0], ae = z[1], le = z[2], ie = z[3], re = z[4], ee = z[5], ne = z[6], se = z[7], ce = z[8], de = z[9], me = z[10], he = z[11], _e = z[12], Se = z[13], Pe = z[14], De = z[15], Ee = j * ee - ae * re, Me = j * ne - le * re, ue = j * se - ie * re, pe = ae * ne - le * ee, Ae = ae * se - ie * ee, ye = le * se - ie * ne, be = ce * Se - de * _e, fe = ce * Pe - me * _e, ge = ce * De - he * _e, xe = de * Pe - me * Se, we = de * De - he * Se, Ve = me * De - he * Pe;
    return Ee * Ve - Me * we + ue * xe + pe * ge - Ae * fe + ye * be;
  }
  e.determinant = R;
  function F(z, j) {
    return U(z, typeof j < "u" ? j : tn.EPSILON);
  }
  e.isRotationAndTranslation = F;
  function U(z, j) {
    var ae = z[0], le = z[1], ie = z[2], re = z[3], ee = z[4], ne = z[5], se = z[6], ce = z[7], de = z[8], me = z[9], he = z[10], _e = z[11], Se = z[15];
    if (!(0, tn.equalEps)(Se, 1, j) || !(0, tn.equalEps)(re, 0, j) || !(0, tn.equalEps)(ce, 0, j) || !(0, tn.equalEps)(_e, 0, j))
      return !1;
    var Pe = Math.abs(ae * (ne * he - se * me) - le * (ee * he - se * de) + ie * (ee * me - ne * de));
    return !!(0, tn.equalEps)(Pe, 1, j);
  }
  function H(z, j) {
    return q(z, typeof j < "u" ? j : tn.EPSILON);
  }
  e.isTranslationAndUniformScaling = H;
  function q(z, j) {
    var ae = z[0];
    return (
      // 0 base scaling
      (0, tn.equalEps)(z[1], 0, j) && (0, tn.equalEps)(z[2], 0, j) && (0, tn.equalEps)(z[3], 0, j) && (0, tn.equalEps)(z[4], 0, j) && (0, tn.equalEps)(z[5], ae, j) && (0, tn.equalEps)(z[6], 0, j) && (0, tn.equalEps)(z[7], 0, j) && (0, tn.equalEps)(z[8], 0, j) && (0, tn.equalEps)(z[9], 0, j) && (0, tn.equalEps)(z[10], ae, j) && (0, tn.equalEps)(z[11], 0, j) && // 12, 13, 14 translation can be anything
      (0, tn.equalEps)(z[15], 1, j)
    );
  }
  function K(z, j) {
    var ae = j[0], le = j[1], ie = j[2], re = j[3], ee = ae + ae, ne = le + le, se = ie + ie, ce = ae * ee, de = le * ee, me = le * ne, he = ie * ee, _e = ie * ne, Se = ie * se, Pe = re * ee, De = re * ne, Ee = re * se;
    return z[0] = 1 - me - Se, z[1] = de + Ee, z[2] = he - De, z[3] = 0, z[4] = de - Ee, z[5] = 1 - ce - Se, z[6] = _e + Pe, z[7] = 0, z[8] = he + De, z[9] = _e - Pe, z[10] = 1 - ce - me, z[11] = 0, z[12] = 0, z[13] = 0, z[14] = 0, z[15] = 1, z;
  }
  e.fromQuat = K;
  function Y(z, j, ae, le, ie, re, ee) {
    var ne = 2 * re / (ae - j), se = 2 * re / (le - ie), ce = (ae + j) / (ae - j), de = (le + ie) / (le - ie), me = -(ee + re) / (ee - re), he = -2 * ee * re / (ee - re);
    return z[0] = ne, z[1] = 0, z[2] = 0, z[3] = 0, z[4] = 0, z[5] = se, z[6] = 0, z[7] = 0, z[8] = ce, z[9] = de, z[10] = me, z[11] = -1, z[12] = 0, z[13] = 0, z[14] = he, z[15] = 0, z;
  }
  e.perspective = Y;
  function X(z, j, ae, le, ie, re, ee) {
    var ne = 1 / (ae - j), se = 1 / (le - ie), ce = 1 / (ee - re), de = (ae + j) * ne, me = (le + ie) * se, he = (ee + re) * ce;
    return z[0] = 2 * ne, z[1] = 0, z[2] = 0, z[3] = 0, z[4] = 0, z[5] = 2 * se, z[6] = 0, z[7] = 0, z[8] = 0, z[9] = 0, z[10] = -2 * ce, z[11] = 0, z[12] = -de, z[13] = -me, z[14] = -he, z[15] = 1, z;
  }
  e.ortho = X;
  function Z(z, j, ae, le) {
    var ie, re, ee, ne, se, ce, de, me, he, _e, Se = j[0], Pe = j[1], De = j[2], Ee = le[0], Me = le[1], ue = le[2], pe = ae[0], Ae = ae[1], ye = ae[2];
    return Math.abs(Se - pe) < tn.EPSILON && Math.abs(Pe - Ae) < tn.EPSILON && Math.abs(De - ye) < tn.EPSILON ? n(z) : (de = Se - pe, me = Pe - Ae, he = De - ye, _e = 1 / Math.sqrt(de * de + me * me + he * he), de *= _e, me *= _e, he *= _e, ie = Me * he - ue * me, re = ue * de - Ee * he, ee = Ee * me - Me * de, _e = Math.sqrt(ie * ie + re * re + ee * ee), _e ? (_e = 1 / _e, ie *= _e, re *= _e, ee *= _e) : (ie = 0, re = 0, ee = 0), ne = me * ee - he * re, se = he * ie - de * ee, ce = de * re - me * ie, _e = Math.sqrt(ne * ne + se * se + ce * ce), _e ? (_e = 1 / _e, ne *= _e, se *= _e, ce *= _e) : (ne = 0, se = 0, ce = 0), z[0] = ie, z[1] = ne, z[2] = de, z[3] = 0, z[4] = re, z[5] = se, z[6] = me, z[7] = 0, z[8] = ee, z[9] = ce, z[10] = he, z[11] = 0, z[12] = -(ie * Se + re * Pe + ee * De), z[13] = -(ne * Se + se * Pe + ce * De), z[14] = -(de * Se + me * Pe + he * De), z[15] = 1, z);
  }
  e.lookAt = Z;
  function J(z, j, ae, le) {
    var ie = j[0], re = j[1], ee = j[2], ne = le[0], se = le[1], ce = le[2], de = ie - ae[0], me = re - ae[1], he = ee - ae[2], _e = de * de + me * me + he * he;
    _e > 0 && (_e = 1 / Math.sqrt(_e), de *= _e, me *= _e, he *= _e);
    var Se = se * he - ce * me, Pe = ce * de - ne * he, De = ne * me - se * de;
    return _e = Se * Se + Pe * Pe + De * De, _e > 0 && (_e = 1 / Math.sqrt(_e), Se *= _e, Pe *= _e, De *= _e), z[0] = Se, z[1] = Pe, z[2] = De, z[3] = 0, z[4] = me * De - he * Pe, z[5] = he * Se - de * De, z[6] = de * Pe - me * Se, z[7] = 0, z[8] = de, z[9] = me, z[10] = he, z[11] = 0, z[12] = ie, z[13] = re, z[14] = ee, z[15] = 1, z;
  }
  e.targetTo = J;
  function $(z, j) {
    a(z);
    for (var ae = 0; ae < 4; ae++) {
      var le = j[ae];
      l(z, ae, le, 1);
    }
    return z;
  }
  e.fromPermutation = $;
  function Q(z) {
    var j = z[0] * z[0] + z[1] * z[1] + z[2] * z[2], ae = z[4] * z[4] + z[5] * z[5] + z[6] * z[6], le = z[8] * z[8] + z[9] * z[9] + z[10] * z[10];
    return Math.sqrt(Math.max(j, ae, le));
  }
  e.getMaxScaleOnAxis = Q;
  var W = [1, 0, 0], te = [0, 1, 0], oe = [0, 0, 1];
  e.rotX90 = D(r(), (0, sf.degToRad)(90), W), e.rotX180 = D(r(), (0, sf.degToRad)(180), W), e.rotY90 = D(r(), (0, sf.degToRad)(90), te), e.rotY180 = D(r(), (0, sf.degToRad)(180), te), e.rotY270 = D(r(), (0, sf.degToRad)(270), te), e.rotZ90 = D(r(), (0, sf.degToRad)(90), oe), e.rotZ180 = D(r(), (0, sf.degToRad)(180), oe), e.rotXY90 = M(r(), e.rotX90, e.rotY90), e.rotZY90 = M(r(), e.rotZ90, e.rotY90), e.rotZYZ90 = M(r(), e.rotZY90, e.rotZ90), e.rotZ90X180 = M(r(), e.rotZ90, e.rotX180), e.rotY90Z180 = M(r(), e.rotY90, e.rotZ180), e.id = t();
})(dg || (dg = {}));
bc.Mat4 = dg;
var x0 = {}, Yo = {};
Object.defineProperty(Yo, "__esModule", { value: !0 });
Yo.Vec3 = void 0;
var Mx = bc, Nc = Zr, Wy = Ci;
function fg() {
  return fg.zero();
}
Yo.Vec3 = fg;
(function(e) {
  function r() {
    var fe = [0.1, 0, 0];
    return fe[0] = 0, fe;
  }
  e.zero = r;
  function t(fe) {
    var ge = r();
    return ge[0] = fe[0], ge[1] = fe[1], ge[2] = fe[2], ge;
  }
  e.clone = t;
  function n(fe) {
    return isNaN(fe[0]) || isNaN(fe[1]) || isNaN(fe[2]);
  }
  e.hasNaN = n;
  function a(fe) {
    return fe[0] = NaN, fe[1] = NaN, fe[2] = NaN, fe;
  }
  e.setNaN = a;
  function i(fe) {
    return u(fe.x, fe.y, fe.z);
  }
  e.fromObj = i;
  function o(fe) {
    return { x: fe[0], y: fe[1], z: fe[2] };
  }
  e.toObj = o;
  function c(fe, ge, xe) {
    return fe[0] = ge[xe + 0], fe[1] = ge[xe + 1], fe[2] = ge[xe + 2], fe;
  }
  e.fromArray = c;
  function s(fe, ge, xe) {
    return ge[xe + 0] = fe[0], ge[xe + 1] = fe[1], ge[xe + 2] = fe[2], ge;
  }
  e.toArray = s;
  function u(fe, ge, xe) {
    var we = r();
    return we[0] = fe, we[1] = ge, we[2] = xe, we;
  }
  e.create = u;
  function l(fe) {
    var ge = r();
    return ge[0] = fe[0], ge[1] = fe[1], ge[2] = fe[2], ge;
  }
  e.ofArray = l;
  function f(fe, ge, xe, we) {
    return fe[0] = ge, fe[1] = xe, fe[2] = we, fe;
  }
  e.set = f;
  function d(fe, ge) {
    return fe[0] = ge[0], fe[1] = ge[1], fe[2] = ge[2], fe;
  }
  e.copy = d;
  function m(fe, ge, xe) {
    return fe[0] = ge[0] + xe[0], fe[1] = ge[1] + xe[1], fe[2] = ge[2] + xe[2], fe;
  }
  e.add = m;
  function p(fe, ge, xe) {
    return fe[0] = ge[0] - xe[0], fe[1] = ge[1] - xe[1], fe[2] = ge[2] - xe[2], fe;
  }
  e.sub = p;
  function v(fe, ge, xe) {
    return fe[0] = ge[0] * xe[0], fe[1] = ge[1] * xe[1], fe[2] = ge[2] * xe[2], fe;
  }
  e.mul = v;
  function h(fe, ge, xe) {
    return fe[0] = ge[0] / xe[0], fe[1] = ge[1] / xe[1], fe[2] = ge[2] / xe[2], fe;
  }
  e.div = h;
  function y(fe, ge, xe) {
    return fe[0] = ge[0] * xe, fe[1] = ge[1] * xe, fe[2] = ge[2] * xe, fe;
  }
  e.scale = y;
  function C(fe, ge, xe, we) {
    return fe[0] = ge[0] + xe[0] * we, fe[1] = ge[1] + xe[1] * we, fe[2] = ge[2] + xe[2] * we, fe;
  }
  e.scaleAndAdd = C;
  function S(fe, ge, xe, we) {
    return fe[0] = ge[0] - xe[0] * we, fe[1] = ge[1] - xe[1] * we, fe[2] = ge[2] - xe[2] * we, fe;
  }
  e.scaleAndSub = S;
  function b(fe, ge, xe) {
    return fe[0] = ge[0] + xe, fe[1] = ge[1] + xe, fe[2] = ge[2] + xe, fe;
  }
  e.addScalar = b;
  function g(fe, ge, xe) {
    return fe[0] = ge[0] - xe, fe[1] = ge[1] - xe, fe[2] = ge[2] - xe, fe;
  }
  e.subScalar = g;
  function _(fe, ge) {
    return fe[0] = Math.round(ge[0]), fe[1] = Math.round(ge[1]), fe[2] = Math.round(ge[2]), fe;
  }
  e.round = _;
  function A(fe, ge) {
    return fe[0] = Math.ceil(ge[0]), fe[1] = Math.ceil(ge[1]), fe[2] = Math.ceil(ge[2]), fe;
  }
  e.ceil = A;
  function M(fe, ge) {
    return fe[0] = Math.floor(ge[0]), fe[1] = Math.floor(ge[1]), fe[2] = Math.floor(ge[2]), fe;
  }
  e.floor = M;
  function P(fe, ge) {
    return fe[0] = Math.trunc(ge[0]), fe[1] = Math.trunc(ge[1]), fe[2] = Math.trunc(ge[2]), fe;
  }
  e.trunc = P;
  function T(fe, ge) {
    return fe[0] = Math.abs(ge[0]), fe[1] = Math.abs(ge[1]), fe[2] = Math.abs(ge[2]), fe;
  }
  e.abs = T;
  function x(fe, ge, xe) {
    return fe[0] = Math.min(ge[0], xe[0]), fe[1] = Math.min(ge[1], xe[1]), fe[2] = Math.min(ge[2], xe[2]), fe;
  }
  e.min = x;
  function w(fe, ge, xe) {
    return fe[0] = Math.max(ge[0], xe[0]), fe[1] = Math.max(ge[1], xe[1]), fe[2] = Math.max(ge[2], xe[2]), fe;
  }
  e.max = w;
  function E(fe, ge) {
    var xe = ge[0] - fe[0], we = ge[1] - fe[1], Ve = ge[2] - fe[2];
    return Math.sqrt(xe * xe + we * we + Ve * Ve);
  }
  e.distance = E;
  function I(fe, ge) {
    var xe = ge[0] - fe[0], we = ge[1] - fe[1], Ve = ge[2] - fe[2];
    return xe * xe + we * we + Ve * Ve;
  }
  e.squaredDistance = I;
  function B(fe) {
    var ge = fe[0], xe = fe[1], we = fe[2];
    return Math.sqrt(ge * ge + xe * xe + we * we);
  }
  e.magnitude = B;
  function D(fe) {
    var ge = fe[0], xe = fe[1], we = fe[2];
    return ge * ge + xe * xe + we * we;
  }
  e.squaredMagnitude = D;
  function N(fe, ge, xe) {
    return y(fe, k(fe, ge), xe);
  }
  e.setMagnitude = N;
  function O(fe, ge) {
    return fe[0] = -ge[0], fe[1] = -ge[1], fe[2] = -ge[2], fe;
  }
  e.negate = O;
  function V(fe, ge) {
    return fe[0] = 1 / ge[0], fe[1] = 1 / ge[1], fe[2] = 1 / ge[2], fe;
  }
  e.inverse = V;
  function k(fe, ge) {
    var xe = ge[0], we = ge[1], Ve = ge[2], Ne = xe * xe + we * we + Ve * Ve;
    return Ne > 0 && (Ne = 1 / Math.sqrt(Ne), fe[0] = ge[0] * Ne, fe[1] = ge[1] * Ne, fe[2] = ge[2] * Ne), fe;
  }
  e.normalize = k;
  function G(fe, ge) {
    return fe[0] * ge[0] + fe[1] * ge[1] + fe[2] * ge[2];
  }
  e.dot = G;
  function L(fe, ge, xe) {
    var we = ge[0], Ve = ge[1], Ne = ge[2], Oe = xe[0], ze = xe[1], ke = xe[2];
    return fe[0] = Ve * ke - Ne * ze, fe[1] = Ne * Oe - we * ke, fe[2] = we * ze - Ve * Oe, fe;
  }
  e.cross = L;
  function R(fe, ge, xe, we) {
    var Ve = ge[0], Ne = ge[1], Oe = ge[2];
    return fe[0] = Ve + we * (xe[0] - Ve), fe[1] = Ne + we * (xe[1] - Ne), fe[2] = Oe + we * (xe[2] - Oe), fe;
  }
  e.lerp = R;
  var F = r();
  function U(fe, ge, xe, we) {
    var Ve = (0, Nc.clamp)(G(ge, xe), -1, 1), Ne = Math.acos(Ve) * we;
    return C(F, xe, ge, -Ve), k(F, F), m(fe, y(fe, ge, Math.cos(Ne)), y(F, F, Math.sin(Ne)));
  }
  e.slerp = U;
  function H(fe, ge, xe, we, Ve, Ne) {
    var Oe = Ne * Ne, ze = Oe * (2 * Ne - 3) + 1, ke = Oe * (Ne - 2) + Ne, je = Oe * (Ne - 1), Xe = Oe * (3 - 2 * Ne);
    return fe[0] = ge[0] * ze + xe[0] * ke + we[0] * je + Ve[0] * Xe, fe[1] = ge[1] * ze + xe[1] * ke + we[1] * je + Ve[1] * Xe, fe[2] = ge[2] * ze + xe[2] * ke + we[2] * je + Ve[2] * Xe, fe;
  }
  e.hermite = H;
  function q(fe, ge, xe, we, Ve, Ne) {
    var Oe = 1 - Ne, ze = Oe * Oe, ke = Ne * Ne, je = ze * Oe, Xe = 3 * Ne * ze, Fe = 3 * ke * Oe, He = ke * Ne;
    return fe[0] = ge[0] * je + xe[0] * Xe + we[0] * Fe + Ve[0] * He, fe[1] = ge[1] * je + xe[1] * Xe + we[1] * Fe + Ve[1] * He, fe[2] = ge[2] * je + xe[2] * Xe + we[2] * Fe + Ve[2] * He, fe;
  }
  e.bezier = q;
  function K(fe, ge, xe, we, Ve) {
    return fe[0] = (0, Nc.quadraticBezier)(ge[0], xe[0], we[0], Ve), fe[1] = (0, Nc.quadraticBezier)(ge[1], xe[1], we[1], Ve), fe[2] = (0, Nc.quadraticBezier)(ge[2], xe[2], we[2], Ve), fe;
  }
  e.quadraticBezier = K;
  function Y(fe, ge, xe, we, Ve, Ne, Oe) {
    return fe[0] = (0, Nc.spline)(ge[0], xe[0], we[0], Ve[0], Ne, Oe), fe[1] = (0, Nc.spline)(ge[1], xe[1], we[1], Ve[1], Ne, Oe), fe[2] = (0, Nc.spline)(ge[2], xe[2], we[2], Ve[2], Ne, Oe), fe;
  }
  e.spline = Y;
  function X(fe, ge) {
    var xe = Math.random() * 2 * Math.PI, we = Math.random() * 2 - 1, Ve = Math.sqrt(1 - we * we) * ge;
    return fe[0] = Math.cos(xe) * Ve, fe[1] = Math.sin(xe) * Ve, fe[2] = we * ge, fe;
  }
  e.random = X;
  function Z(fe, ge, xe) {
    var we = ge[0], Ve = ge[1], Ne = ge[2], Oe = 1 / (xe[3] * we + xe[7] * Ve + xe[11] * Ne + xe[15] || 1);
    return fe[0] = (xe[0] * we + xe[4] * Ve + xe[8] * Ne + xe[12]) * Oe, fe[1] = (xe[1] * we + xe[5] * Ve + xe[9] * Ne + xe[13]) * Oe, fe[2] = (xe[2] * we + xe[6] * Ve + xe[10] * Ne + xe[14]) * Oe, fe;
  }
  e.transformMat4 = Z;
  function J(fe, ge, xe, we, Ve, Ne) {
    var Oe = ge[0 + Ve], ze = ge[1 + Ve], ke = ge[2 + Ve], je = 1 / (xe[3 + Ne] * Oe + xe[7 + Ne] * ze + xe[11 + Ne] * ke + xe[15 + Ne] || 1);
    return fe[0 + we] = (xe[0 + Ne] * Oe + xe[4 + Ne] * ze + xe[8 + Ne] * ke + xe[12 + Ne]) * je, fe[1 + we] = (xe[1 + Ne] * Oe + xe[5 + Ne] * ze + xe[9 + Ne] * ke + xe[13 + Ne]) * je, fe[2 + we] = (xe[2 + Ne] * Oe + xe[6 + Ne] * ze + xe[10 + Ne] * ke + xe[14 + Ne]) * je, fe;
  }
  e.transformMat4Offset = J;
  function $(fe, ge, xe) {
    var we = ge[0], Ve = ge[1], Ne = ge[2];
    return fe[0] = we * xe[0] + Ve * xe[3] + Ne * xe[6], fe[1] = we * xe[1] + Ve * xe[4] + Ne * xe[7], fe[2] = we * xe[2] + Ve * xe[5] + Ne * xe[8], fe;
  }
  e.transformMat3 = $;
  function Q(fe, ge, xe) {
    var we = ge[0], Ve = ge[1], Ne = ge[2], Oe = xe[0], ze = xe[1], ke = xe[2], je = xe[3], Xe = je * we + ze * Ne - ke * Ve, Fe = je * Ve + ke * we - Oe * Ne, He = je * Ne + Oe * Ve - ze * we, Be = -Oe * we - ze * Ve - ke * Ne;
    return fe[0] = Xe * je + Be * -Oe + Fe * -ke - He * -ze, fe[1] = Fe * je + Be * -ze + He * -Oe - Xe * -ke, fe[2] = He * je + Be * -ke + Xe * -ze - Fe * -Oe, fe;
  }
  e.transformQuat = Q;
  function W(fe, ge) {
    var xe = Math.sqrt(D(fe) * D(ge));
    if (xe === 0)
      return Math.PI / 2;
    var we = G(fe, ge) / xe;
    return Math.acos((0, Nc.clamp)(we, -1, 1));
  }
  e.angle = W;
  var te = r(), oe = r(), z = r(), j = r(), ae = r(), le = r(), ie = r();
  function re(fe, ge, xe, we) {
    p(te, fe, ge), p(oe, xe, ge), p(z, ge, xe), p(j, we, xe), L(ae, te, oe), L(le, z, j);
    var Ve = W(ae, le);
    return L(ie, ae, le), G(oe, ie) > 0 ? Ve : -Ve;
  }
  e.dihedralAngle = re;
  function ee(fe, ge, xe, we) {
    return e.set(fe, we * Math.cos(xe) * Math.sin(ge), we * Math.sin(xe) * Math.sin(ge), we * Math.cos(ge));
  }
  e.directionFromSpherical = ee;
  function ne(fe, ge) {
    return fe[0] === ge[0] && fe[1] === ge[1] && fe[2] === ge[2];
  }
  e.exactEquals = ne;
  function se(fe, ge) {
    var xe = fe[0], we = fe[1], Ve = fe[2], Ne = ge[0], Oe = ge[1], ze = ge[2];
    return Math.abs(xe - Ne) <= Wy.EPSILON * Math.max(1, Math.abs(xe), Math.abs(Ne)) && Math.abs(we - Oe) <= Wy.EPSILON * Math.max(1, Math.abs(we), Math.abs(Oe)) && Math.abs(Ve - ze) <= Wy.EPSILON * Math.max(1, Math.abs(Ve), Math.abs(ze));
  }
  e.equals = se;
  var ce = r();
  function de(fe, ge, xe) {
    var we = W(ge, xe);
    if (Math.abs(we) < 1e-4)
      return Mx.Mat4.setIdentity(fe);
    if (Math.abs(we - Math.PI) < Wy.EPSILON)
      return Mx.Mat4.fromScaling(fe, e.negUnit);
    var Ve = L(ce, ge, xe);
    return Mx.Mat4.fromRotation(fe, we, Ve);
  }
  e.makeRotation = de;
  function me(fe) {
    return fe[0] === 0 && fe[1] === 0 && fe[2] === 0;
  }
  e.isZero = me;
  function he(fe, ge, xe, we) {
    p(fe, ge, we);
    var Ve = G(xe, fe) / D(xe);
    return m(fe, y(fe, xe, Ve), we);
  }
  e.projectPointOnVector = he;
  var _e = r();
  function Se(fe, ge, xe, we) {
    return k(_e, xe), p(fe, ge, we), p(fe, ge, y(_e, _e, G(fe, _e)));
  }
  e.projectPointOnPlane = Se;
  function Pe(fe, ge, xe) {
    var we = G(xe, ge) / D(xe);
    return y(fe, xe, we);
  }
  e.projectOnVector = Pe;
  var De = r();
  function Ee(fe, ge, xe) {
    return Pe(De, ge, xe), p(fe, ge, De);
  }
  e.projectOnPlane = Ee;
  function Me(fe, ge, xe) {
    return k(fe, L(fe, L(fe, ge, xe), ge));
  }
  e.orthogonalize = Me;
  function ue(fe, ge, xe) {
    return G(ge, xe) > 0 ? d(fe, ge) : O(fe, d(fe, ge)), fe;
  }
  e.matchDirection = ue;
  var pe = r(), Ae = r();
  function ye(fe, ge, xe, we) {
    return p(pe, xe, ge), p(Ae, we, ge), k(fe, L(fe, pe, Ae));
  }
  e.triangleNormal = ye;
  function be(fe, ge) {
    return "[".concat(fe[0].toPrecision(ge), " ").concat(fe[1].toPrecision(ge), " ").concat(fe[2].toPrecision(ge), "]");
  }
  e.toString = be, e.origin = u(0, 0, 0), e.unit = u(1, 1, 1), e.negUnit = u(-1, -1, -1), e.unitX = u(1, 0, 0), e.unitY = u(0, 1, 0), e.unitZ = u(0, 0, 1), e.negUnitX = u(-1, 0, 0), e.negUnitY = u(0, -1, 0), e.negUnitZ = u(0, 0, -1);
})(fg || (fg = {}));
Yo.Vec3 = fg;
Object.defineProperty(x0, "__esModule", { value: !0 });
x0.Mat3 = void 0;
var jQ = Ci, au = Yo;
function mg() {
  return mg.zero();
}
x0.Mat3 = mg;
(function(e) {
  function r() {
    var R = [0.1, 0, 0, 0, 0, 0, 0, 0, 0];
    return R[0] = 0, R;
  }
  e.zero = r;
  function t() {
    var R = r();
    return R[0] = 1, R[1] = 0, R[2] = 0, R[3] = 0, R[4] = 1, R[5] = 0, R[6] = 0, R[7] = 0, R[8] = 1, R;
  }
  e.identity = t;
  function n(R) {
    return R[0] = 1, R[1] = 0, R[2] = 0, R[3] = 0, R[4] = 1, R[5] = 0, R[6] = 0, R[7] = 0, R[8] = 1, R;
  }
  e.setIdentity = n;
  function a(R, F, U) {
    return F[U + 0] = R[0], F[U + 1] = R[1], F[U + 2] = R[2], F[U + 3] = R[3], F[U + 4] = R[4], F[U + 5] = R[5], F[U + 6] = R[6], F[U + 7] = R[7], F[U + 8] = R[8], F;
  }
  e.toArray = a;
  function i(R, F, U) {
    return R[0] = F[U + 0], R[1] = F[U + 1], R[2] = F[U + 2], R[3] = F[U + 3], R[4] = F[U + 4], R[5] = F[U + 5], R[6] = F[U + 6], R[7] = F[U + 7], R[8] = F[U + 8], R;
  }
  e.fromArray = i;
  function o(R, F) {
    return R[0] = F[0], R[1] = F[1], R[2] = F[2], R[3] = F[4], R[4] = F[5], R[5] = F[6], R[6] = F[8], R[7] = F[9], R[8] = F[10], R;
  }
  e.fromMat4 = o;
  function c(R, F, U, H, q, K, Y, X, Z) {
    var J = r();
    return J[0] = R, J[1] = F, J[2] = U, J[3] = H, J[4] = q, J[5] = K, J[6] = Y, J[7] = X, J[8] = Z, J;
  }
  e.create = c;
  var s = t();
  function u(R, F) {
    return d(R, s, typeof F > "u" ? jQ.EPSILON : F);
  }
  e.isIdentity = u;
  function l(R) {
    for (var F = 0; F < 9; F++)
      if (isNaN(R[F]))
        return !0;
    return !1;
  }
  e.hasNaN = l;
  function f(R) {
    return v(r(), R);
  }
  e.clone = f;
  function d(R, F, U) {
    for (var H = 0; H < 9; H++)
      if (Math.abs(R[H] - F[H]) > U)
        return !1;
    return !0;
  }
  e.areEqual = d;
  function m(R, F, U, H) {
    R[3 * U + F] = H;
  }
  e.setValue = m;
  function p(R, F, U) {
    return R[3 * U + F];
  }
  e.getValue = p;
  function v(R, F) {
    return R[0] = F[0], R[1] = F[1], R[2] = F[2], R[3] = F[3], R[4] = F[4], R[5] = F[5], R[6] = F[6], R[7] = F[7], R[8] = F[8], R;
  }
  e.copy = v;
  function h(R, F) {
    if (R === F) {
      var U = F[1], H = F[2], q = F[5];
      R[1] = F[3], R[2] = F[6], R[3] = U, R[5] = F[7], R[6] = H, R[7] = q;
    } else
      R[0] = F[0], R[1] = F[3], R[2] = F[6], R[3] = F[1], R[4] = F[4], R[5] = F[7], R[6] = F[2], R[7] = F[5], R[8] = F[8];
    return R;
  }
  e.transpose = h;
  function y(R, F) {
    var U = F[0], H = F[1], q = F[2], K = F[3], Y = F[4], X = F[5], Z = F[6], J = F[7], $ = F[8], Q = $ * Y - X * J, W = -$ * K + X * Z, te = J * K - Y * Z, oe = U * Q + H * W + q * te;
    return oe ? (oe = 1 / oe, R[0] = Q * oe, R[1] = (-$ * H + q * J) * oe, R[2] = (X * H - q * Y) * oe, R[3] = W * oe, R[4] = ($ * U - q * Z) * oe, R[5] = (-X * U + q * K) * oe, R[6] = te * oe, R[7] = (-J * U + H * Z) * oe, R[8] = (Y * U - H * K) * oe, R) : (console.warn("non-invertible matrix.", F), R);
  }
  e.invert = y;
  function C(R, F) {
    return R === F ? (R[3] = F[1], R[6] = F[2], R[7] = F[5]) : (R[0] = F[0], R[1] = F[1], R[2] = F[2], R[3] = F[1], R[4] = F[4], R[5] = F[5], R[6] = F[2], R[7] = F[5], R[8] = F[8]), R;
  }
  e.symmtricFromUpper = C;
  function S(R, F) {
    return R === F ? (R[1] = F[3], R[2] = F[6], R[5] = F[7]) : (R[0] = F[0], R[1] = F[3], R[2] = F[6], R[3] = F[3], R[4] = F[4], R[5] = F[7], R[6] = F[6], R[7] = F[7], R[8] = F[8]), R;
  }
  e.symmtricFromLower = S;
  function b(R) {
    var F = R[0], U = R[1], H = R[2], q = R[3], K = R[4], Y = R[5], X = R[6], Z = R[7], J = R[8], $ = J * K - Y * Z, Q = -J * q + Y * X, W = Z * q - K * X;
    return F * $ + U * Q + H * W;
  }
  e.determinant = b;
  function g(R) {
    return R[0] + R[4] + R[8];
  }
  e.trace = g;
  function _(R, F, U) {
    return R[0] = F[0] - U[0], R[1] = F[1] - U[1], R[2] = F[2] - U[2], R[3] = F[3] - U[3], R[4] = F[4] - U[4], R[5] = F[5] - U[5], R[6] = F[6] - U[6], R[7] = F[7] - U[7], R[8] = F[8] - U[8], R;
  }
  e.sub = _;
  function A(R, F, U) {
    return R[0] = F[0] + U[0], R[1] = F[1] + U[1], R[2] = F[2] + U[2], R[3] = F[3] + U[3], R[4] = F[4] + U[4], R[5] = F[5] + U[5], R[6] = F[6] + U[6], R[7] = F[7] + U[7], R[8] = F[8] + U[8], R;
  }
  e.add = A;
  function M(R, F, U) {
    var H = F[0], q = F[1], K = F[2], Y = F[3], X = F[4], Z = F[5], J = F[6], $ = F[7], Q = F[8], W = U[0], te = U[1], oe = U[2], z = U[3], j = U[4], ae = U[5], le = U[6], ie = U[7], re = U[8];
    return R[0] = W * H + te * Y + oe * J, R[1] = W * q + te * X + oe * $, R[2] = W * K + te * Z + oe * Q, R[3] = z * H + j * Y + ae * J, R[4] = z * q + j * X + ae * $, R[5] = z * K + j * Z + ae * Q, R[6] = le * H + ie * Y + re * J, R[7] = le * q + ie * X + re * $, R[8] = le * K + ie * Z + re * Q, R;
  }
  e.mul = M;
  function P(R, F, U) {
    return R[0] = F[0] - U, R[1] = F[1] - U, R[2] = F[2] - U, R[3] = F[3] - U, R[4] = F[4] - U, R[5] = F[5] - U, R[6] = F[6] - U, R[7] = F[7] - U, R[8] = F[8] - U, R;
  }
  e.subScalar = P;
  function T(R, F, U) {
    return R[0] = F[0] + U, R[1] = F[1] + U, R[2] = F[2] + U, R[3] = F[3] + U, R[4] = F[4] + U, R[5] = F[5] + U, R[6] = F[6] + U, R[7] = F[7] + U, R[8] = F[8] + U, R;
  }
  e.addScalar = T;
  function x(R, F, U) {
    return R[0] = F[0] * U, R[1] = F[1] * U, R[2] = F[2] * U, R[3] = F[3] * U, R[4] = F[4] * U, R[5] = F[5] * U, R[6] = F[6] * U, R[7] = F[7] * U, R[8] = F[8] * U, R;
  }
  e.mulScalar = x;
  var w = Math.PI / 3, E = r();
  function I(R, F) {
    var U = F[1] * F[1] + F[2] * F[2] + F[5] * F[5];
    if (U === 0)
      R[0] = F[0], R[1] = F[4], R[2] = F[8];
    else {
      var H = g(F) / 3, q = F[0] - H, K = F[4] - H, Y = F[8] - H, X = q * q + K * K + Y * Y + 2 * U, Z = Math.sqrt(X / 6);
      x(E, e.Identity, H), _(E, F, E), x(E, E, 1 / Z);
      var J = b(E) / 2, $ = J <= -1 ? w : J >= 1 ? 0 : Math.acos(J) / 3;
      R[0] = H + 2 * Z * Math.cos($), R[2] = H + 2 * Z * Math.cos($ + 2 * w), R[1] = 3 * H - R[0] - R[2];
    }
    return R;
  }
  e.symmetricEigenvalues = I;
  var B = [0.1, 0, 0], D = [0.1, 0, 0], N = [0.1, 0, 0], O = [0.1, 0, 0], V = [0.1, 0, 0], k = [0.1, 0, 0];
  function G(R, F, U) {
    au.Vec3.set(B, F[0] - U, F[1], F[2]), au.Vec3.set(D, F[1], F[4] - U, F[5]), au.Vec3.set(N, F[2], F[5], F[8] - U), au.Vec3.cross(O, B, D), au.Vec3.cross(V, B, N), au.Vec3.cross(k, D, N);
    var H = au.Vec3.dot(O, O), q = au.Vec3.dot(V, V), K = au.Vec3.dot(k, k), Y = H, X = 0;
    return q > Y && (Y = q, X = 1), K > Y && (X = 2), X === 0 ? au.Vec3.scale(R, O, 1 / Math.sqrt(H)) : X === 1 ? au.Vec3.scale(R, V, 1 / Math.sqrt(q)) : au.Vec3.scale(R, k, 1 / Math.sqrt(K)), R;
  }
  e.eigenvector = G;
  function L(R, F) {
    return o(R, F), y(R, R), h(R, R), R;
  }
  e.directionTransform = L, e.Identity = t();
})(mg || (mg = {}));
x0.Mat3 = mg;
var $g = {};
Object.defineProperty($g, "__esModule", { value: !0 });
$g.Vec2 = void 0;
function vg() {
  return vg.zero();
}
$g.Vec2 = vg;
(function(e) {
  function r() {
    var P = [0.1, 0];
    return P[0] = 0, P;
  }
  e.zero = r;
  function t(P) {
    var T = r();
    return T[0] = P[0], T[1] = P[1], T;
  }
  e.clone = t;
  function n(P, T) {
    var x = r();
    return x[0] = P, x[1] = T, x;
  }
  e.create = n;
  function a(P) {
    return isNaN(P[0]) || isNaN(P[1]);
  }
  e.hasNaN = a;
  function i(P, T, x) {
    return T[x + 0] = P[0], T[x + 1] = P[1], T;
  }
  e.toArray = i;
  function o(P, T, x) {
    return P[0] = T[x + 0], P[1] = T[x + 1], P;
  }
  e.fromArray = o;
  function c(P, T) {
    return P[0] = T[0], P[1] = T[1], P;
  }
  e.copy = c;
  function s(P, T, x) {
    return P[0] = T, P[1] = x, P;
  }
  e.set = s;
  function u(P, T, x) {
    return P[0] = T[0] + x[0], P[1] = T[1] + x[1], P;
  }
  e.add = u;
  function l(P, T, x) {
    return P[0] = T[0] - x[0], P[1] = T[1] - x[1], P;
  }
  e.sub = l;
  function f(P, T, x) {
    return P[0] = T[0] * x[0], P[1] = T[1] * x[1], P;
  }
  e.mul = f;
  function d(P, T, x) {
    return P[0] = T[0] / x[0], P[1] = T[1] / x[1], P;
  }
  e.div = d;
  function m(P, T, x) {
    return P[0] = T[0] * x, P[1] = T[1] * x, P;
  }
  e.scale = m;
  function p(P, T) {
    return P[0] = Math.round(T[0]), P[1] = Math.round(T[1]), P;
  }
  e.round = p;
  function v(P, T) {
    return P[0] = Math.ceil(T[0]), P[1] = Math.ceil(T[1]), P;
  }
  e.ceil = v;
  function h(P, T) {
    return P[0] = Math.floor(T[0]), P[1] = Math.floor(T[1]), P;
  }
  e.floor = h;
  function y(P, T) {
    var x = T[0] - P[0], w = T[1] - P[1];
    return Math.sqrt(x * x + w * w);
  }
  e.distance = y;
  function C(P, T) {
    var x = T[0] - P[0], w = T[1] - P[1];
    return x * x + w * w;
  }
  e.squaredDistance = C;
  function S(P) {
    var T = P[0], x = P[1];
    return Math.sqrt(T * T + x * x);
  }
  e.magnitude = S;
  function b(P) {
    var T = P[0], x = P[1];
    return T * T + x * x;
  }
  e.squaredMagnitude = b;
  function g(P, T) {
    return P[0] = 1 / T[0], P[1] = 1 / T[1], P;
  }
  e.inverse = g;
  function _(P, T) {
    return P[0] === T[0] && P[1] === T[1];
  }
  e.areEqual = _;
  function A(P, T) {
    return "[".concat(P[0].toPrecision(T), " ").concat(P[1].toPrecision(T), "}]");
  }
  e.toString = A;
  function M(P, T) {
    var x = T[0], w = T[1], E = x * x + w * w;
    return E > 0 && (E = 1 / Math.sqrt(E), P[0] = T[0] * E, P[1] = T[1] * E), P;
  }
  e.normalize = M;
})(vg || (vg = {}));
$g.Vec2 = vg;
var Kg = {};
Object.defineProperty(Kg, "__esModule", { value: !0 });
Kg.Vec4 = void 0;
var Xy = Ci;
function pg() {
  return pg.zero();
}
Kg.Vec4 = pg;
(function(e) {
  function r() {
    var w = [0.1, 0, 0, 0];
    return w[0] = 0, w;
  }
  e.zero = r;
  function t(w) {
    var E = r();
    return E[0] = w[0], E[1] = w[1], E[2] = w[2], E[3] = w[3], E;
  }
  e.clone = t;
  function n(w, E, I, B) {
    var D = r();
    return D[0] = w, D[1] = E, D[2] = I, D[3] = B, D;
  }
  e.create = n;
  function a(w, E) {
    return w[0] = E.center[0], w[1] = E.center[1], w[2] = E.center[2], w[3] = E.radius, w;
  }
  e.fromSphere = a;
  function i(w) {
    return a(r(), w);
  }
  e.ofSphere = i;
  function o(w) {
    return isNaN(w[0]) || isNaN(w[1]) || isNaN(w[2]) || isNaN(w[3]);
  }
  e.hasNaN = o;
  function c(w, E, I) {
    return E[I + 0] = w[0], E[I + 1] = w[1], E[I + 2] = w[2], E[I + 3] = w[3], E;
  }
  e.toArray = c;
  function s(w, E, I) {
    return w[0] = E[I + 0], w[1] = E[I + 1], w[2] = E[I + 2], w[3] = E[I + 3], w;
  }
  e.fromArray = s;
  function u(w, E, I) {
    E[I + 0] = w[0], E[I + 1] = w[1], E[I + 2] = w[2];
  }
  e.toVec3Array = u;
  function l(w, E, I) {
    return w[0] = E[I + 0], w[1] = E[I + 1], w[2] = E[I + 2], w[3] = 0, w;
  }
  e.fromVec3Array = l;
  function f(w, E) {
    return w[0] = E[0], w[1] = E[1], w[2] = E[2], w[3] = E[3], w;
  }
  e.copy = f;
  function d(w, E, I, B, D) {
    return w[0] = E, w[1] = I, w[2] = B, w[3] = D, w;
  }
  e.set = d;
  function m(w, E, I) {
    return w[0] = E[0] + I[0], w[1] = E[1] + I[1], w[2] = E[2] + I[2], w[3] = E[3] + I[3], w;
  }
  e.add = m;
  function p(w, E) {
    var I = E[0] - w[0], B = E[1] - w[1], D = E[2] - w[2], N = E[3] - w[3];
    return Math.sqrt(I * I + B * B + D * D + N * N);
  }
  e.distance = p;
  function v(w, E, I) {
    return w[0] = E[0] * I, w[1] = E[1] * I, w[2] = E[2] * I, w[4] = E[4] * I, w;
  }
  e.scale = v;
  function h(w, E) {
    return w[0] = Math.round(E[0]), w[1] = Math.round(E[1]), w[2] = Math.round(E[2]), w[3] = Math.round(E[3]), w;
  }
  e.round = h;
  function y(w, E) {
    return w[0] = Math.ceil(E[0]), w[1] = Math.ceil(E[1]), w[2] = Math.ceil(E[2]), w[3] = Math.ceil(E[3]), w;
  }
  e.ceil = y;
  function C(w, E) {
    return w[0] = Math.floor(E[0]), w[1] = Math.floor(E[1]), w[2] = Math.floor(E[2]), w[3] = Math.floor(E[3]), w;
  }
  e.floor = C;
  function S(w, E) {
    var I = E[0] - w[0], B = E[1] - w[1], D = E[2] - w[2], N = E[3] - w[3];
    return I * I + B * B + D * D + N * N;
  }
  e.squaredDistance = S;
  function b(w) {
    var E = w[0], I = w[1], B = w[2], D = w[3];
    return Math.sqrt(E * E + I * I + B * B + D * D);
  }
  e.norm = b;
  function g(w) {
    var E = w[0], I = w[1], B = w[2], D = w[3];
    return E * E + I * I + B * B + D * D;
  }
  e.squaredNorm = g;
  function _(w, E, I) {
    var B = E[0], D = E[1], N = E[2], O = E[3];
    return w[0] = I[0] * B + I[4] * D + I[8] * N + I[12] * O, w[1] = I[1] * B + I[5] * D + I[9] * N + I[13] * O, w[2] = I[2] * B + I[6] * D + I[10] * N + I[14] * O, w[3] = I[3] * B + I[7] * D + I[11] * N + I[15] * O, w;
  }
  e.transformMat4 = _;
  function A(w, E) {
    return w[0] * E[0] + w[1] * E[1] + w[2] * E[2] + w[3] * E[3];
  }
  e.dot = A;
  function M(w, E) {
    return w[0] = 1 / E[0], w[1] = 1 / E[1], w[2] = 1 / E[2], w[3] = 1 / E[3], w;
  }
  e.inverse = M;
  function P(w, E) {
    return w[0] === E[0] && w[1] === E[1] && w[2] === E[2] && w[3] === E[3];
  }
  e.exactEquals = P;
  function T(w, E) {
    var I = w[0], B = w[1], D = w[2], N = w[3], O = E[0], V = E[1], k = E[2], G = E[3];
    return Math.abs(I - O) <= Xy.EPSILON * Math.max(1, Math.abs(I), Math.abs(O)) && Math.abs(B - V) <= Xy.EPSILON * Math.max(1, Math.abs(B), Math.abs(V)) && Math.abs(D - k) <= Xy.EPSILON * Math.max(1, Math.abs(D), Math.abs(k)) && Math.abs(N - G) <= Xy.EPSILON * Math.max(1, Math.abs(N), Math.abs(G));
  }
  e.equals = T;
  function x(w, E) {
    return "[".concat(w[0].toPrecision(E), " ").concat(w[1].toPrecision(E), " ").concat(w[2].toPrecision(E), "  ").concat(w[3].toPrecision(E), "]");
  }
  e.toString = x;
})(pg || (pg = {}));
Kg.Vec4 = pg;
var hp = {};
Object.defineProperty(hp, "__esModule", { value: !0 });
hp.Quat = void 0;
var Ms = Yo, sh = Ci;
function hg() {
  return hg.zero();
}
hp.Quat = hg;
(function(e) {
  function r() {
    var L = [0.1, 0, 0, 0];
    return L[0] = 0, L;
  }
  e.zero = r;
  function t() {
    var L = r();
    return L[3] = 1, L;
  }
  e.identity = t;
  function n(L) {
    L[0] = 0, L[1] = 0, L[2] = 0, L[3] = 1;
  }
  e.setIdentity = n;
  function a(L) {
    return isNaN(L[0]) || isNaN(L[1]) || isNaN(L[2]) || isNaN(L[3]);
  }
  e.hasNaN = a;
  function i(L, R, F, U) {
    var H = t();
    return H[0] = L, H[1] = R, H[2] = F, H[3] = U, H;
  }
  e.create = i;
  function o(L, R, F) {
    F = F * 0.5;
    var U = Math.sin(F);
    return L[0] = U * R[0], L[1] = U * R[1], L[2] = U * R[2], L[3] = Math.cos(F), L;
  }
  e.setAxisAngle = o;
  function c(L, R) {
    var F = Math.acos(R[3]) * 2, U = Math.sin(F / 2);
    return U !== 0 ? (L[0] = R[0] / U, L[1] = R[1] / U, L[2] = R[2] / U) : (L[0] = 1, L[1] = 0, L[2] = 0), F;
  }
  e.getAxisAngle = c;
  function s(L, R, F) {
    var U = R[0], H = R[1], q = R[2], K = R[3], Y = F[0], X = F[1], Z = F[2], J = F[3];
    return L[0] = U * J + K * Y + H * Z - q * X, L[1] = H * J + K * X + q * Y - U * Z, L[2] = q * J + K * Z + U * X - H * Y, L[3] = K * J - U * Y - H * X - q * Z, L;
  }
  e.multiply = s;
  function u(L, R, F) {
    F *= 0.5;
    var U = R[0], H = R[1], q = R[2], K = R[3], Y = Math.sin(F), X = Math.cos(F);
    return L[0] = U * X + K * Y, L[1] = H * X + q * Y, L[2] = q * X - H * Y, L[3] = K * X - U * Y, L;
  }
  e.rotateX = u;
  function l(L, R, F) {
    F *= 0.5;
    var U = R[0], H = R[1], q = R[2], K = R[3], Y = Math.sin(F), X = Math.cos(F);
    return L[0] = U * X - q * Y, L[1] = H * X + K * Y, L[2] = q * X + U * Y, L[3] = K * X - H * Y, L;
  }
  e.rotateY = l;
  function f(L, R, F) {
    F *= 0.5;
    var U = R[0], H = R[1], q = R[2], K = R[3], Y = Math.sin(F), X = Math.cos(F);
    return L[0] = U * X + H * Y, L[1] = H * X - U * Y, L[2] = q * X + K * Y, L[3] = K * X - q * Y, L;
  }
  e.rotateZ = f;
  function d(L, R) {
    var F = R[0], U = R[1], H = R[2];
    return L[0] = F, L[1] = U, L[2] = H, L[3] = Math.sqrt(Math.abs(1 - F * F - U * U - H * H)), L;
  }
  e.calculateW = d;
  function m(L, R, F, U) {
    var H = R[0], q = R[1], K = R[2], Y = R[3], X = F[0], Z = F[1], J = F[2], $ = F[3], Q, W, te, oe, z;
    return W = H * X + q * Z + K * J + Y * $, W < 0 && (W = -W, X = -X, Z = -Z, J = -J, $ = -$), 1 - W > 1e-6 ? (Q = Math.acos(W), te = Math.sin(Q), oe = Math.sin((1 - U) * Q) / te, z = Math.sin(U * Q) / te) : (oe = 1 - U, z = U), L[0] = oe * H + z * X, L[1] = oe * q + z * Z, L[2] = oe * K + z * J, L[3] = oe * Y + z * $, L;
  }
  e.slerp = m;
  function p(L, R) {
    var F = R[0], U = R[1], H = R[2], q = R[3], K = F * F + U * U + H * H + q * q, Y = K ? 1 / K : 0;
    return L[0] = -F * Y, L[1] = -U * Y, L[2] = -H * Y, L[3] = q * Y, L;
  }
  e.invert = p;
  function v(L, R) {
    return L[0] = -R[0], L[1] = -R[1], L[2] = -R[2], L[3] = R[3], L;
  }
  e.conjugate = v;
  function h(L, R) {
    var F = R[0] + R[4] + R[8], U;
    if (F > 0)
      U = Math.sqrt(F + 1), L[3] = 0.5 * U, U = 0.5 / U, L[0] = (R[5] - R[7]) * U, L[1] = (R[6] - R[2]) * U, L[2] = (R[1] - R[3]) * U;
    else {
      var H = 0;
      R[4] > R[0] && (H = 1), R[8] > R[H * 3 + H] && (H = 2);
      var q = (H + 1) % 3, K = (H + 2) % 3;
      U = Math.sqrt(R[H * 3 + H] - R[q * 3 + q] - R[K * 3 + K] + 1), L[H] = 0.5 * U, U = 0.5 / U, L[3] = (R[q * 3 + K] - R[K * 3 + q]) * U, L[q] = (R[q * 3 + H] + R[H * 3 + q]) * U, L[K] = (R[K * 3 + H] + R[H * 3 + K]) * U;
    }
    return L;
  }
  e.fromMat3 = h;
  var y = [0, 0, 0];
  function C(L, R, F) {
    var U = Ms.Vec3.dot(R, F) + 1;
    return U < sh.EPSILON ? (U = 0, Math.abs(R[0]) > Math.abs(R[2]) ? Ms.Vec3.set(y, -R[1], R[0], 0) : Ms.Vec3.set(y, 0, -R[2], R[1])) : Ms.Vec3.cross(y, R, F), L[0] = y[0], L[1] = y[1], L[2] = y[2], L[3] = U, x(L, L), L;
  }
  e.fromUnitVec3 = C;
  function S(L) {
    var R = r();
    return R[0] = L[0], R[1] = L[1], R[2] = L[2], R[3] = L[3], R;
  }
  e.clone = S;
  function b(L, R, F) {
    return R[F + 0] = L[0], R[F + 1] = L[1], R[F + 2] = L[2], R[F + 3] = L[3], R;
  }
  e.toArray = b;
  function g(L, R, F) {
    return L[0] = R[F + 0], L[1] = R[F + 1], L[2] = R[F + 2], L[3] = R[F + 3], L;
  }
  e.fromArray = g;
  function _(L, R) {
    return L[0] = R[0], L[1] = R[1], L[2] = R[2], L[3] = R[3], L;
  }
  e.copy = _;
  function A(L, R, F, U, H) {
    return L[0] = R, L[1] = F, L[2] = U, L[3] = H, L;
  }
  e.set = A;
  function M(L, R) {
    return L[0] === R[0] && L[1] === R[1] && L[2] === R[2] && L[3] === R[3];
  }
  e.exactEquals = M;
  function P(L, R) {
    var F = L[0], U = L[1], H = L[2], q = L[3], K = R[0], Y = R[1], X = R[2], Z = R[3];
    return Math.abs(F - K) <= sh.EPSILON * Math.max(1, Math.abs(F), Math.abs(K)) && Math.abs(U - Y) <= sh.EPSILON * Math.max(1, Math.abs(U), Math.abs(Y)) && Math.abs(H - X) <= sh.EPSILON * Math.max(1, Math.abs(H), Math.abs(X)) && Math.abs(q - Z) <= sh.EPSILON * Math.max(1, Math.abs(q), Math.abs(Z));
  }
  e.equals = P;
  function T(L, R, F) {
    return L[0] = R[0] + F[0], L[1] = R[1] + F[1], L[2] = R[2] + F[2], L[3] = R[3] + F[3], L;
  }
  e.add = T;
  function x(L, R) {
    var F = R[0], U = R[1], H = R[2], q = R[3], K = F * F + U * U + H * H + q * q;
    return K > 0 && (K = 1 / Math.sqrt(K), L[0] = F * K, L[1] = U * K, L[2] = H * K, L[3] = q * K), L;
  }
  e.normalize = x;
  var w = [0, 0, 0], E = [1, 0, 0], I = [0, 1, 0];
  function B(L, R, F) {
    var U = Ms.Vec3.dot(R, F);
    return U < -0.999999 ? (Ms.Vec3.cross(w, E, R), Ms.Vec3.magnitude(w) < 1e-6 && Ms.Vec3.cross(w, I, R), Ms.Vec3.normalize(w, w), o(L, w, Math.PI), L) : U > 0.999999 ? (L[0] = 0, L[1] = 0, L[2] = 0, L[3] = 1, L) : (Ms.Vec3.cross(w, R, F), L[0] = w[0], L[1] = w[1], L[2] = w[2], L[3] = 1 + U, x(L, L));
  }
  e.rotationTo = B;
  var D = r(), N = r();
  function O(L, R, F, U, H, q) {
    return m(D, R, H, q), m(N, F, U, q), m(L, D, N, 2 * q * (1 - q)), L;
  }
  e.sqlerp = O;
  var V = [0, 0, 0, 0, 0, 0, 0, 0, 0];
  function k(L, R, F, U) {
    return V[0] = F[0], V[3] = F[1], V[6] = F[2], V[1] = U[0], V[4] = U[1], V[7] = U[2], V[2] = -R[0], V[5] = -R[1], V[8] = -R[2], x(L, h(L, V));
  }
  e.setAxes = k;
  function G(L, R) {
    return "[".concat(L[0].toPrecision(R), " ").concat(L[1].toPrecision(R), " ").concat(L[2].toPrecision(R), "  ").concat(L[3].toPrecision(R), "]");
  }
  e.toString = G, e.Identity = t();
})(hg || (hg = {}));
hp.Quat = hg;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.EPSILON = e.Quat = e.Vec4 = e.Vec3 = e.Vec2 = e.Mat3 = e.Mat4 = void 0;
  var r = bc;
  Object.defineProperty(e, "Mat4", { enumerable: !0, get: function() {
    return r.Mat4;
  } });
  var t = x0;
  Object.defineProperty(e, "Mat3", { enumerable: !0, get: function() {
    return t.Mat3;
  } });
  var n = $g;
  Object.defineProperty(e, "Vec2", { enumerable: !0, get: function() {
    return n.Vec2;
  } });
  var a = Yo;
  Object.defineProperty(e, "Vec3", { enumerable: !0, get: function() {
    return a.Vec3;
  } });
  var i = Kg;
  Object.defineProperty(e, "Vec4", { enumerable: !0, get: function() {
    return i.Vec4;
  } });
  var o = hp;
  Object.defineProperty(e, "Quat", { enumerable: !0, get: function() {
    return o.Quat;
  } });
  var c = Ci;
  Object.defineProperty(e, "EPSILON", { enumerable: !0, get: function() {
    return c.EPSILON;
  } });
})(q3);
var Zk = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Tensor = void 0;
  var r = x0, t = bc;
  (function(n) {
    function a(M, P, T) {
      for (var x = [], w = 0; w < P.length; w++)
        x[w] = P[P.length - w - 1];
      for (var E = [1], w = 1; w < M.length; w++)
        E[w] = M[x[w - 1]];
      return {
        dimensions: M,
        axisOrderFastToSlow: x,
        axisOrderSlowToFast: P,
        accessDimensions: E,
        defaultCtor: T || Float64Array
      };
    }
    function i(M, P) {
      return { space: M, data: P };
    }
    n.create = i;
    function o(M, P, T) {
      var x = a(M, P, T), w = h(x), E = w.get, I = w.set, B = w.add, D = w.dataOffset, N = w.getCoords;
      return {
        rank: M.length,
        dimensions: M,
        axisOrderSlowToFast: P,
        create: y(x),
        get: E,
        set: I,
        add: B,
        dataOffset: D,
        getCoords: N
      };
    }
    n.Space = o;
    function c(M) {
      return M;
    }
    n.Data1 = c;
    function s(M, P) {
      return o([M], [0], P);
    }
    n.Vector = s;
    function u(M, P, T) {
      return o([M, P], [1, 0], T);
    }
    n.ColumnMajorMatrix = u;
    function l(M, P, T) {
      return o([M, P], [0, 1], T);
    }
    n.RowMajorMatrix = l;
    function f(M, P, T) {
      if (P.rank !== 2)
        throw new Error("Invalid tensor rank");
      for (var x = Math.min(4, P.dimensions[0]), w = Math.min(4, P.dimensions[1]), E = 0; E < x; E++)
        for (var I = 0; I < w; I++)
          t.Mat4.setValue(M, E, I, P.get(T, E, I));
      return M;
    }
    n.toMat4 = f;
    function d(M, P, T) {
      if (P.rank !== 2)
        throw new Error("Invalid tensor rank");
      for (var x = Math.min(3, P.dimensions[0]), w = Math.min(3, P.dimensions[1]), E = 0; E < x; E++)
        for (var I = 0; I < w; I++)
          r.Mat3.setValue(M, E, I, P.get(T, E, I));
      return M;
    }
    n.toMat3 = d;
    function m(M, P, T) {
      if (P.rank !== 1)
        throw new Error("Invalid tensor rank");
      for (var x = Math.min(3, P.dimensions[0]), w = 0; w < x; w++)
        M[w] = T[w];
      return M;
    }
    n.toVec3 = m;
    function p(M, P, T) {
      if (P.rank !== 1)
        throw new Error("Invalid tensor rank");
      for (var x = Math.min(4, P.dimensions[0]), w = 0; w < x; w++)
        M[w] = T[w];
      return M;
    }
    n.toVec4 = p;
    function v(M, P) {
      var T = M.length;
      if (T !== P.length)
        return !1;
      for (var x = 0; x < T; x++)
        if (M[x] !== P[x])
          return !1;
      return !0;
    }
    n.areEqualExact = v;
    function h(M) {
      var P = M.dimensions, T = M.axisOrderFastToSlow;
      switch (P.length) {
        case 1:
          return {
            get: function(Z, J) {
              return Z[J];
            },
            set: function(Z, J, $) {
              return Z[J] = $;
            },
            add: function(Z, J, $) {
              return Z[J] += $;
            },
            dataOffset: function(Z) {
              return Z;
            },
            getCoords: function(Z, J) {
              return J[0] = Z, J;
            }
          };
        case 2: {
          if (T[0] === 0 && T[1] === 1) {
            var x = P[0];
            return {
              get: function(Z, J, $) {
                return Z[$ * x + J];
              },
              set: function(Z, J, $, Q) {
                return Z[$ * x + J] = Q;
              },
              add: function(Z, J, $, Q) {
                return Z[$ * x + J] += Q;
              },
              dataOffset: function(Z, J) {
                return J * x + Z;
              },
              getCoords: function(Z, J) {
                return J[0] = Z % x, J[1] = Math.floor(Z / x), J;
              }
            };
          }
          if (T[0] === 1 && T[1] === 0) {
            var w = P[1];
            return {
              get: function(Z, J, $) {
                return Z[J * w + $];
              },
              set: function(Z, J, $, Q) {
                return Z[J * w + $] = Q;
              },
              add: function(Z, J, $, Q) {
                return Z[J * w + $] += Q;
              },
              dataOffset: function(Z, J) {
                return Z * w + J;
              },
              getCoords: function(Z, J) {
                return J[0] = Math.floor(Z / w), J[1] = Z % w, J;
              }
            };
          }
          throw new Error("bad axis order");
        }
        case 3: {
          if (T[0] === 0 && T[1] === 1 && T[2] === 2) {
            var E = P[0], I = P[1], B = E * I;
            return {
              get: function(Z, J, $, Q) {
                return Z[J + $ * E + Q * B];
              },
              set: function(Z, J, $, Q, W) {
                return Z[J + $ * E + Q * B] = W;
              },
              add: function(Z, J, $, Q, W) {
                return Z[J + $ * E + Q * B] += W;
              },
              dataOffset: function(Z, J, $) {
                return Z + J * E + $ * B;
              },
              getCoords: function(Z, J) {
                var $ = Math.floor(Z / E);
                return J[0] = Z % E, J[1] = $ % I, J[2] = Math.floor($ / I), J;
              }
            };
          }
          if (T[0] === 0 && T[1] === 2 && T[2] === 1) {
            var D = P[0], N = P[2], O = D * N;
            return {
              get: function(Z, J, $, Q) {
                return Z[J + Q * D + $ * O];
              },
              set: function(Z, J, $, Q, W) {
                return Z[J + Q * D + $ * O] = W;
              },
              add: function(Z, J, $, Q, W) {
                return Z[J + Q * D + $ * O] += W;
              },
              dataOffset: function(Z, J, $) {
                return Z + $ * D + J * O;
              },
              getCoords: function(Z, J) {
                var $ = Math.floor(Z / D);
                return J[0] = Z % D, J[1] = Math.floor($ / N), J[2] = $ % N, J;
              }
            };
          }
          if (T[0] === 1 && T[1] === 0 && T[2] === 2) {
            var V = P[1], k = P[0], G = V * k;
            return {
              get: function(Z, J, $, Q) {
                return Z[$ + J * V + Q * G];
              },
              set: function(Z, J, $, Q, W) {
                return Z[$ + J * V + Q * G] = W;
              },
              add: function(Z, J, $, Q, W) {
                return Z[$ + J * V + Q * G] += W;
              },
              dataOffset: function(Z, J, $) {
                return J + Z * V + $ * G;
              },
              getCoords: function(Z, J) {
                var $ = Math.floor(Z / V);
                return J[0] = $ % k, J[1] = Z % V, J[2] = Math.floor($ / k), J;
              }
            };
          }
          if (T[0] === 1 && T[1] === 2 && T[2] === 0) {
            var L = P[1], R = P[2], F = L * R;
            return {
              get: function(Z, J, $, Q) {
                return Z[$ + Q * L + J * F];
              },
              set: function(Z, J, $, Q, W) {
                return Z[$ + Q * L + J * F] = W;
              },
              add: function(Z, J, $, Q, W) {
                return Z[$ + Q * L + J * F] += W;
              },
              dataOffset: function(Z, J, $) {
                return J + $ * L + Z * F;
              },
              getCoords: function(Z, J) {
                var $ = Math.floor(Z / L);
                return J[0] = Math.floor($ / R), J[1] = Z % L, J[2] = $ % R, J;
              }
            };
          }
          if (T[0] === 2 && T[1] === 0 && T[2] === 1) {
            var U = P[2], H = P[0], q = U * H;
            return {
              get: function(Z, J, $, Q) {
                return Z[Q + J * U + $ * q];
              },
              set: function(Z, J, $, Q, W) {
                return Z[Q + J * U + $ * q] = W;
              },
              add: function(Z, J, $, Q, W) {
                return Z[Q + J * U + $ * q] += W;
              },
              dataOffset: function(Z, J, $) {
                return $ + Z * U + J * q;
              },
              getCoords: function(Z, J) {
                var $ = Math.floor(Z / U);
                return J[0] = $ % H, J[1] = Math.floor($ / H), J[2] = Z % U, J;
              }
            };
          }
          if (T[0] === 2 && T[1] === 1 && T[2] === 0) {
            var K = P[2], Y = P[1], X = K * Y;
            return {
              get: function(Z, J, $, Q) {
                return Z[Q + $ * K + J * X];
              },
              set: function(Z, J, $, Q, W) {
                return Z[Q + $ * K + J * X] = W;
              },
              add: function(Z, J, $, Q, W) {
                return Z[Q + $ * K + J * X] += W;
              },
              dataOffset: function(Z, J, $) {
                return $ + J * K + Z * X;
              },
              getCoords: function(Z, J) {
                var $ = Math.floor(Z / K);
                return J[0] = Math.floor($ / Y), J[1] = $ % Y, J[2] = Z % K, J;
              }
            };
          }
          throw new Error("bad axis order");
        }
        default:
          return {
            get: function(Z) {
              for (var J = [], $ = 1; $ < arguments.length; $++)
                J[$ - 1] = arguments[$];
              return Z[C(M, J)];
            },
            set: function(Z) {
              for (var J = [], $ = 1; $ < arguments.length; $++)
                J[$ - 1] = arguments[$];
              return Z[C(M, J)] = J[J.length - 1];
            },
            add: function(Z) {
              for (var J = [], $ = 1; $ < arguments.length; $++)
                J[$ - 1] = arguments[$];
              return Z[C(M, J)] += J[J.length - 1];
            },
            dataOffset: function() {
              for (var Z = [], J = 0; J < arguments.length; J++)
                Z[J] = arguments[J];
              return C(M, Z);
            },
            getCoords: function(Z, J) {
              return S(M, Z, J);
            }
          };
      }
    }
    function y(M) {
      for (var P = M.dimensions, T = 1, x = 0, w = P.length; x < w; x++)
        T *= P[x];
      return function(E) {
        return new (E || M.defaultCtor)(T);
      };
    }
    function C(M, P) {
      for (var T = M.accessDimensions, x = M.axisOrderFastToSlow, w = T.length - 1, E = T[w] * P[x[w]], I = w - 1; I >= 0; I--)
        E = (E + P[x[I]]) * T[I];
      return E;
    }
    function S(M, P, T) {
      for (var x = M.dimensions, w = M.axisOrderFastToSlow, E = x.length, I = P, B = 0; B < E; B++) {
        var D = x[w[B]];
        T[w[B]] = I % D, I = Math.floor(I / D);
      }
      return T[w[E + 1]] = I, T;
    }
    function b(M) {
      for (var P = [], T = 0; T < M.length; T++)
        P[T] = M[M.length - T - 1];
      return P;
    }
    n.invertAxisOrder = b;
    function g(M, P) {
      for (var T = [], x = 0; x < M.length; x++)
        T[x] = M[P[x]];
      return T;
    }
    function _(M) {
      for (var P = new Int32Array(M.length), T = 0; T < M.length; T++)
        P[M[T]] = T;
      return function(x) {
        return g(x, P);
      };
    }
    n.convertToCanonicalAxisIndicesFastToSlow = _;
    function A(M) {
      for (var P = new Int32Array(M.length), T = 0; T < M.length; T++)
        P[M[M.length - T - 1]] = T;
      return function(x) {
        return g(x, P);
      };
    }
    n.convertToCanonicalAxisIndicesSlowToFast = A;
  })(e.Tensor || (e.Tensor = {}));
})(Zk);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 });
  var r = Te;
  (0, r.__exportStar)(q3, e), (0, r.__exportStar)(Zk, e);
})(Re);
var Qa = {};
Object.defineProperty(Qa, "__esModule", { value: !0 });
Qa.getNumberType = Qa.parseFloat = Qa.parseFloatSkipLeadingWhitespace = Qa.parseInt = Qa.parseIntSkipLeadingWhitespace = void 0;
function $Q(e, r, t) {
  for (; r < t && e.charCodeAt(r) === 32; )
    r++;
  return Gw(e, r, t);
}
Qa.parseIntSkipLeadingWhitespace = $Q;
function Gw(e, r, t) {
  var n = r, a = 0, i = 1;
  for (e.charCodeAt(n) === 45 ? (i = -1, ++n) : e.charCodeAt(n) === 43 && ++n; n < t; n++) {
    var o = e.charCodeAt(n) - 48;
    if (o > 9 || o < 0)
      return i * a | 0;
    a = 10 * a + o | 0;
  }
  return i * a;
}
Qa.parseInt = Gw;
function v6(e, r, t, n) {
  return r.charCodeAt(t) === 43 && t++, e * Math.pow(10, Gw(r, t, n));
}
function KQ(e, r, t) {
  for (; r < t && e.charCodeAt(r) === 32; )
    r++;
  return Jk(e, r, t);
}
Qa.parseFloatSkipLeadingWhitespace = KQ;
function Jk(e, r, t) {
  var n = r, a = 1, i = 0, o = 0, c = 1;
  for (e.charCodeAt(n) === 45 ? (a = -1, ++n) : e.charCodeAt(n) === 43 && ++n; n < t; ) {
    var s = e.charCodeAt(n) - 48;
    if (s >= 0 && s < 10)
      i = i * 10 + s, ++n;
    else if (s === -2) {
      for (++n; n < t; )
        if (s = e.charCodeAt(n) - 48, s >= 0 && s < 10)
          o = 10 * o + s, c = 10 * c, ++n;
        else return s === 53 || s === 21 ? v6(a * (i + o / c), e, n + 1, t) : a * (i + o / c);
      return a * (i + o / c);
    } else {
      if (s === 53 || s === 21)
        return v6(a * i, e, n + 1, t);
      break;
    }
  }
  return a * i;
}
Qa.parseFloat = Jk;
function WQ(e, r, t) {
  for (e.charCodeAt(r) === 45 && r++; r < t; r++) {
    var n = e.charCodeAt(r) - 48;
    if (n > 9 || n < 0)
      return !1;
  }
  return !0;
}
function p6(e, r, t) {
  return e.charCodeAt(r) === 43 && r++, WQ(e, r, t) ? 2 : 3;
}
function XQ(e) {
  var r = 0, t = e.length;
  if (e.charCodeAt(r) === 45 && ++r, e.charCodeAt(r) === 46 && t - r === 1)
    return 3;
  for (; r < t; ) {
    var n = e.charCodeAt(r) - 48;
    if (n >= 0 && n < 10)
      ++r;
    else if (n === -2) {
      ++r;
      for (var a = !1; r < t; )
        if (n = e.charCodeAt(r) - 48, n >= 0 && n < 10)
          a = !0, ++r;
        else return n === 53 || n === 21 ? p6(e, r + 1, t) : 3;
      return a ? 1 : 0;
    } else {
      if (n === 53 || n === 21)
        return r === 0 || r === 1 && e.charCodeAt(0) === 45 ? 3 : p6(e, r + 1, t);
      break;
    }
  }
  return r === t ? 0 : 3;
}
Qa.getNumberType = XQ;
Object.defineProperty(jg, "__esModule", { value: !0 });
jg.Column = void 0;
var GP = Te, js = (0, GP.__importStar)(zi), h6 = Re, g6 = Qa, yb;
(function(e) {
  var r;
  (function(T) {
    T.str = { "@type": "str", T: "", valueType: "str" }, T.int = { "@type": "int", T: 0, valueType: "int" }, T.coord = { "@type": "coord", T: 0, valueType: "float" }, T.float = { "@type": "float", T: 0, valueType: "float" };
    function x(V) {
      return V === void 0 && (V = ""), { "@type": "str", T: V, valueType: "str" };
    }
    T.Str = x;
    function w(V) {
      return V === void 0 && (V = 0), { "@type": "int", T: V, valueType: "int" };
    }
    T.Int = w;
    function E(V) {
      return V === void 0 && (V = 0), { "@type": "float", T: V, valueType: "float" };
    }
    T.Float = E;
    function I(V, k) {
      return k === void 0 && (k = T.float), { "@type": "tensor", T: V.create(), space: V, valueType: "tensor", baseType: k };
    }
    T.Tensor = I;
    function B(V, k) {
      return k === void 0 && (k = T.float), I(h6.Tensor.Vector(V, k["@type"] === "int" ? Int32Array : Float64Array), k);
    }
    T.Vector = B;
    function D(V, k, G) {
      return G === void 0 && (G = T.float), I(h6.Tensor.ColumnMajorMatrix(V, k, G["@type"] === "int" ? Int32Array : Float64Array), G);
    }
    T.Matrix = D;
    function N(V, k) {
      return typeof k < "u" ? (0, GP.__assign)((0, GP.__assign)({}, V), { T: k }) : V;
    }
    T.Aliased = N;
    function O(V, k, G) {
      return G === void 0 && (G = []), { "@type": "list", T: G, separator: V, itemParse: k, valueType: "list" };
    }
    T.List = O;
  })(r = e.Schema || (e.Schema = {}));
  function t(T) {
    return !!T && !!T.schema && !!T.value;
  }
  e.is = t;
  function n(T, x) {
    return y6(
      x.T,
      T,
      x,
      1
      /* NotPresent */
    );
  }
  e.Undefined = n;
  function a(T, x, w) {
    return y6(
      T,
      x,
      w,
      0
      /* Present */
    );
  }
  e.ofConst = a;
  function i(T) {
    return Yy(T);
  }
  e.ofLambda = i;
  function o(T, x) {
    return i({
      value: function(w) {
        return w + T;
      },
      rowCount: Math.max(x - T + 1, 0),
      schema: r.int
    });
  }
  e.range = o;
  function c(T) {
    return Hl(T);
  }
  e.ofArray = c;
  function s(T) {
    return Hl({ array: T, schema: r.int });
  }
  e.ofIntArray = s;
  function u(T) {
    return Hl({ array: T, schema: r.float });
  }
  e.ofFloatArray = u;
  function l(T) {
    return Hl({ array: T, schema: r.str });
  }
  e.ofStringArray = l;
  function f(T) {
    return Hl({ array: T, schema: r.Aliased(r.str) });
  }
  e.ofStringAliasArray = f;
  function d(T, x) {
    return x === void 0 && (x = ","), Hl({ array: T, schema: r.List(x, function(w) {
      return w;
    }) });
  }
  e.ofStringListArray = d;
  function m(T) {
    var x = T.count, w = T.data, E = T.indices;
    return Yy({
      value: function(I) {
        return (0, g6.parseInt)(w, E[2 * I], E[2 * I + 1]) || 0;
      },
      rowCount: x,
      schema: r.int
    });
  }
  e.ofIntTokens = m;
  function p(T) {
    var x = T.count, w = T.data, E = T.indices;
    return Yy({
      value: function(I) {
        return (0, g6.parseFloat)(w, E[2 * I], E[2 * I + 1]) || 0;
      },
      rowCount: x,
      schema: r.float
    });
  }
  e.ofFloatTokens = p;
  function v(T) {
    var x = T.count, w = T.data, E = T.indices;
    return Yy({
      value: function(I) {
        var B = w.substring(E[2 * I], E[2 * I + 1]);
        return B === "." || B === "?" ? "" : B;
      },
      rowCount: x,
      schema: r.str
    });
  }
  e.ofStringTokens = v;
  function h(T, x, w) {
    return ZQ(T, x, w);
  }
  e.window = h;
  function y(T, x, w) {
    return w === void 0 && (w = !0), tZ(T, x, w);
  }
  e.view = y;
  function C(T) {
    return YQ(T);
  }
  e.createFirstIndexMap = C;
  function S(T) {
    return QQ(T);
  }
  e.createIndexer = S;
  function b(T, x, w) {
    return iZ(T, x, w || Array);
  }
  e.mapToArray = b;
  function g(T, x) {
    return oZ(T, x);
  }
  e.areEqual = g;
  function _(T, x) {
    return lZ(T, x);
  }
  e.indicesOf = _;
  function A(T, x) {
    return T.__array ? T : T.isDefined ? Hl({ array: T.toArray({ array: x }), schema: T.schema, valueKind: T.valueKind }) : n(T.rowCount, T.schema);
  }
  e.asArrayColumn = A;
  function M(T, x, w) {
    if (w === void 0 && (w = 0), !!T.isDefined) {
      var E = T.__array;
      if (E)
        for (var I = 0, B = E.length; I < B; I++)
          x[w + I] = E[I];
      else
        for (var I = 0, B = T.rowCount; I < B; I++)
          x[w + I] = T.value(I);
    }
  }
  e.copyToArray = M;
  function P(T) {
    for (var x = 0, w = T.rowCount; x < w; x++)
      if (x !== T.value(x))
        return !1;
    return !0;
  }
  e.isIdentity = P;
})(yb || (yb = {}));
jg.Column = yb;
function YQ(e) {
  for (var r = /* @__PURE__ */ new Map(), t = 0, n = e.rowCount; t < n; t++) {
    var a = e.value(t);
    r.has(a) || r.set(e.value(t), t);
  }
  return r;
}
function QQ(e) {
  for (var r = /* @__PURE__ */ new Map(), t = 0, n = e.rowCount; t < n; t++) {
    var a = e.value(t);
    r.has(a) || r.set(e.value(t), t);
  }
  return function(i) {
    return r.has(i) ? r.get(i) : -1;
  };
}
function y6(e, r, t, n) {
  var a = function(i) {
    return e;
  };
  return {
    schema: t,
    __array: void 0,
    isDefined: n === 0,
    rowCount: r,
    value: a,
    valueKind: function(i) {
      return n;
    },
    toArray: function(i) {
      for (var o = js.createArray(r, i).array, c = 0, s = o.length; c < s; c++)
        o[c] = e;
      return o;
    },
    areValuesEqual: function(i, o) {
      return !0;
    }
  };
}
function Yy(e) {
  var r = e.value, t = e.valueKind, n = e.areValuesEqual, a = e.rowCount, i = e.schema;
  return {
    schema: i,
    __array: void 0,
    isDefined: !0,
    rowCount: a,
    value: r,
    valueKind: t || function(o) {
      return 0;
    },
    toArray: function(o) {
      for (var c = js.createArray(a, o), s = c.array, u = c.start, l = 0, f = s.length; l < f; l++)
        s[l] = r(l + u);
      return s;
    },
    areValuesEqual: n || function(o, c) {
      return r(o) === r(c);
    }
  };
}
function Hl(e) {
  var r = e.array, t = e.schema, n = e.valueKind, a = r.length, i = t.valueType === "str" ? function(c) {
    var s = r[c];
    return typeof s == "string" ? s : "" + s;
  } : function(c) {
    return r[c];
  }, o = js.isTypedArray(r);
  return {
    schema: t,
    __array: r,
    isDefined: !0,
    rowCount: a,
    value: i,
    valueKind: n || function(c) {
      return 0;
    },
    toArray: t.valueType === "str" ? function(c) {
      for (var s = js.getArrayBounds(a, c), u = s.start, l = s.end, f = new (c && typeof c.array < "u" ? c.array : r.constructor)(l - u), d = 0, m = l - u; d < m; d++) {
        var p = r[u + d];
        f[d] = typeof p == "string" ? p : "" + p;
      }
      return f;
    } : o ? function(c) {
      return js.typedArrayWindow(r, c);
    } : function(c) {
      var s = js.getArrayBounds(a, c), u = s.start, l = s.end;
      if (u === 0 && l === r.length)
        return r;
      for (var f = new (c && typeof c.array < "u" ? c.array : r.constructor)(l - u), d = 0, m = l - u; d < m; d++)
        f[d] = r[u + d];
      return f;
    },
    areValuesEqual: function(c, s) {
      return r[c] === r[s];
    }
  };
}
function ZQ(e, r, t) {
  return e.isDefined ? r === 0 && t === e.rowCount ? e : e.__array && js.isTypedArray(e.__array) ? JQ(e, r, t) : eZ(e, r, t) : yb.Undefined(t - r, e.schema);
}
function JQ(e, r, t) {
  var n = js.typedArrayWindow(e.__array, { start: r, end: t }), a = e.valueKind;
  return Hl({ array: n, schema: e.schema, valueKind: function(i) {
    return a(r + i);
  } });
}
function eZ(e, r, t) {
  var n = e.value, a = e.valueKind, i = e.areValuesEqual, o = r === 0 ? n : function(s) {
    return n(s + r);
  }, c = t - r;
  return {
    schema: e.schema,
    __array: void 0,
    isDefined: e.isDefined,
    rowCount: c,
    value: o,
    valueKind: r === 0 ? a : function(s) {
      return a(s + r);
    },
    toArray: function(s) {
      for (var u = js.createArray(c, s).array, l = 0, f = u.length; l < f; l++)
        u[l] = n(l + r);
      return u;
    },
    areValuesEqual: r === 0 ? i : function(s, u) {
      return i(s + r, u + r);
    }
  };
}
function rZ(e, r) {
  if (e.length !== r)
    return !1;
  for (var t = 0, n = e.length; t < n; t++)
    if (e[t] !== t)
      return !1;
  return !0;
}
function tZ(e, r, t) {
  return e.rowCount === 0 || t && rZ(r, e.rowCount) ? e : e.__array && typeof e.value(0) == typeof e.__array[0] ? nZ(e, r) : aZ(e, r);
}
function nZ(e, r) {
  for (var t = e.__array, n = new t.constructor(r.length), a = 0, i = r.length; a < i; a++)
    n[a] = t[r[a]];
  var o = e.valueKind;
  return Hl({ array: n, schema: e.schema, valueKind: function(c) {
    return o(r[c]);
  } });
}
function aZ(e, r) {
  var t = e.value, n = e.valueKind, a = e.areValuesEqual, i = function(c) {
    return t(r[c]);
  }, o = r.length;
  return {
    schema: e.schema,
    __array: void 0,
    isDefined: e.isDefined,
    rowCount: o,
    value: i,
    valueKind: function(c) {
      return n(r[c]);
    },
    toArray: function(c) {
      for (var s = js.createArray(o, c).array, u = 0, l = s.length; u < l; u++)
        s[u] = t(r[u]);
      return s;
    },
    areValuesEqual: function(c, s) {
      return a(r[c], r[s]);
    }
  };
}
function iZ(e, r, t) {
  for (var n = new t(e.rowCount), a = 0, i = e.rowCount; a < i; a++)
    n[a] = r(e.value(a));
  return n;
}
function oZ(e, r) {
  return e === r ? !0 : e.rowCount !== r.rowCount || e.isDefined !== r.isDefined || e.schema.valueType !== r.schema.valueType ? !1 : e.__array && r.__array ? uZ(e, r) : sZ(e, r);
}
function uZ(e, r) {
  for (var t = e.__array, n = r.__array, a = 0, i = e.rowCount; a < i; a++)
    if (t[a] !== n[a])
      return !1;
  return !0;
}
function sZ(e, r) {
  for (var t = e.value, n = r.value, a = 0, i = e.rowCount; a < i; a++)
    if (t(a) !== n(a))
      return !1;
  return !0;
}
function lZ(e, r) {
  for (var t = [], n = e.value, a = 0, i = e.rowCount; a < i; a++)
    r(n(a)) && (t[t.length] = a);
  return t;
}
var _6;
function eU() {
  if (_6) return uh;
  _6 = 1, Object.defineProperty(uh, "__esModule", { value: !0 }), uh.Table = void 0;
  var e = Te, r = jg, t = go, n = We(), a;
  return function(i) {
    function o(P) {
      return P && typeof P._rowCount == "number" && !!P._columns && !!P._schema;
    }
    i.is = o;
    function c(P, T, x) {
      x === void 0 && (x = {});
      var w = /* @__PURE__ */ Object.create(null), E = Object.keys(P);
      w._rowCount = T._rowCount, w._columns = E, w._schema = P;
      for (var I = 0, B = E; I < B.length; I++) {
        var D = B[I];
        if (T[D])
          w[D] = T[D];
        else if (x[D])
          w[D] = x[D];
        else
          throw Error("Cannot find column '".concat(D, "'."));
      }
      return w;
    }
    i.pickColumns = c;
    function s(P, T) {
      var x = Object.keys(T), w = T[x[0]].rowCount;
      return (0, e.__assign)({ _rowCount: w, _columns: x, _schema: P }, T);
    }
    i.ofColumns = s;
    function u(P, T, x) {
      var w = /* @__PURE__ */ Object.create(null), E = Object.keys(P);
      w._rowCount = x, w._columns = E, w._schema = P;
      for (var I = 0, B = E; I < B.length; I++) {
        var D = B[I];
        D in T ? w[D] = T[D] : w[D] = r.Column.Undefined(x, P[D]);
      }
      return w;
    }
    i.ofPartialColumns = u;
    function l(P, T) {
      var x = /* @__PURE__ */ Object.create(null), w = Object.keys(P);
      x._rowCount = T, x._columns = w, x._schema = P;
      for (var E = 0, I = w; E < I.length; E++) {
        var B = I[E];
        x[B] = r.Column.Undefined(T, P[B]);
      }
      return x;
    }
    i.ofUndefinedColumns = l;
    function f(P, T) {
      var x = /* @__PURE__ */ Object.create(null), w = T.length, E = Object.keys(P);
      x._rowCount = w, x._columns = E, x._schema = P;
      for (var I = function(O) {
        x[O] = r.Column.ofLambda({
          rowCount: w,
          schema: P[O],
          value: function(V) {
            return T[V][O];
          },
          valueKind: function(V) {
            return typeof T[V][O] > "u" ? 1 : 0;
          }
        });
      }, B = 0, D = E; B < D.length; B++) {
        var N = D[B];
        I(N);
      }
      return x;
    }
    i.ofRows = f;
    function d(P, T) {
      var x, w = /* @__PURE__ */ Object.create(null), E = Object.keys(P);
      w._rowCount = 0, w._columns = E, w._schema = P;
      for (var I = 0, B = E; I < B.length; I++) {
        var D = B[I];
        typeof T[D] < "u" ? (w[D] = r.Column.ofArray({ array: T[D], schema: P[D] }), w._rowCount = (x = T[D]) === null || x === void 0 ? void 0 : x.length) : w[D] = r.Column.Undefined(w._rowCount, P[D]);
      }
      return w;
    }
    i.ofArrays = d;
    function m(P, T, x) {
      var w = /* @__PURE__ */ Object.create(null), E = Object.keys(T);
      w._rowCount = x.length, w._columns = E, w._schema = T;
      for (var I = 0, B = E; I < B.length; I++) {
        var D = B[I];
        w[D] = r.Column.view(P[D], x);
      }
      return w;
    }
    i.view = m;
    function p(P, T, x) {
      for (var w = [], E = 0, I = P._rowCount; E < I; ++E)
        x(E) && w.push(E);
      return m(P, T, w);
    }
    i.pick = p;
    function v(P, T, x, w) {
      if (x === 0 && w === P._rowCount)
        return P;
      var E = /* @__PURE__ */ Object.create(null), I = Object.keys(T);
      E._rowCount = w - x, E._columns = I, E._schema = T;
      for (var B = 0, D = I; B < D.length; B++) {
        var N = D[B];
        E[N] = r.Column.window(P[N], x, w);
      }
      return E;
    }
    i.window = v;
    function h(P, T) {
      var x = /* @__PURE__ */ Object.create(null), w = Object.keys(T);
      x._rowCount = 0;
      for (var E = 0, I = P; E < I.length; E++) {
        var B = I[E];
        x._rowCount += B._rowCount;
      }
      for (var D = {}, N = 0, O = w; N < O.length; N++) {
        var V = O[N];
        D[V] = new Array(x._rowCount);
      }
      x._columns = w, x._schema = T;
      for (var k = 0, G = 0, L = P; G < L.length; G++) {
        for (var B = L[G], R = 0, F = w; R < F.length; R++) {
          var U = F[R];
          r.Column.copyToArray(B[U], D[U], k);
        }
        k += B._rowCount;
      }
      for (var H = 0, q = w; H < q.length; H++) {
        var U = q[H];
        x[U] = r.Column.ofArray({ array: D[U], schema: T[U] });
      }
      return x;
    }
    i.concat = h;
    function y(P, T, x) {
      P[T] = r.Column.asArrayColumn(P[T], x);
    }
    i.columnToArray = y;
    function C(P, T) {
      for (var x = new Int32Array(P._rowCount), w = 0, E = x.length; w < E; w++)
        x[w] = w;
      (0, t.sortArray)(x, function(V, k, G) {
        return T(k, G);
      });
      for (var I = !0, w = 0, E = x.length; w < E; w++)
        if (x[w] !== w) {
          I = !1;
          break;
        }
      if (I)
        return P;
      var B = /* @__PURE__ */ Object.create(null);
      B._rowCount = P._rowCount, B._columns = P._columns, B._schema = P._schema;
      for (var D = 0, N = P._columns; D < N.length; D++) {
        var O = N[D];
        B[O] = r.Column.view(P[O], x, !1);
      }
      return B;
    }
    i.sort = C;
    function S(P, T) {
      if (P._rowCount !== T._rowCount || P._columns.length !== T._columns.length)
        return !1;
      for (var x = 0, w = P._columns; x < w.length; x++) {
        var E = w[x];
        if (!T[E])
          return !1;
      }
      for (var I = 0, B = P._columns; I < B.length; I++) {
        var E = B[I];
        if (!r.Column.areEqual(P[E], T[E]))
          return !1;
      }
      return !0;
    }
    i.areEqual = S;
    function b(P, T) {
      for (var x = /* @__PURE__ */ Object.create(null), w = P._columns, E = 0; E < w.length; E++) {
        var I = w[E];
        x[I] = P[I].value(T);
      }
      return x;
    }
    i.getRow = b;
    function g(P, T) {
      for (var x = 0, w = P._rowCount; x < w; ++x)
        if (T(x))
          return b(P, x);
    }
    i.pickRow = g;
    function _(P) {
      for (var T = [], x = P._rowCount, w = 0; w < x; w++)
        T[w] = b(P, w);
      return T;
    }
    i.getRows = _;
    function A(P) {
      for (var T = {}, x = P._columns, w = 0; w < x.length; w++) {
        var E = x[w];
        T[E] = P[E].toArray();
      }
      return T;
    }
    i.toArrays = A;
    function M(P) {
      var T = n.StringBuilder.create(), x = P._columns, w = P._rowCount, E = 1;
      n.StringBuilder.write(T, "|");
      for (var I = 0; I < x.length; I++)
        n.StringBuilder.write(T, x[I]), n.StringBuilder.write(T, "|"), E += x[I].length + 1;
      n.StringBuilder.newline(T), n.StringBuilder.write(T, new Array(E + 1).join("-")), n.StringBuilder.newline(T);
      for (var B = 0; B < w; B++) {
        n.StringBuilder.write(T, "|");
        for (var I = 0; I < x.length; I++) {
          var D = P[x[I]];
          D.valueKind(B) === 0 ? (n.StringBuilder.write(T, D.value(B)), n.StringBuilder.write(T, "|")) : n.StringBuilder.write(T, ".|");
        }
        n.StringBuilder.newline(T);
      }
      return n.StringBuilder.getString(T);
    }
    i.formatToString = M;
  }(a || (a = {})), uh.Table = a, uh;
}
var b6;
function cZ() {
  if (b6) return oh;
  b6 = 1, Object.defineProperty(oh, "__esModule", { value: !0 }), oh.Database = void 0;
  var e = eU(), r;
  return function(t) {
    function n(i, o, c) {
      var s = Object.keys(c), u = /* @__PURE__ */ Object.create(null), l = [];
      u._name = i, u._tableNames = l, u._schema = o;
      for (var f = 0, d = s; f < d.length; f++) {
        var m = d[f];
        e.Table.is(c[m]) && (u[m] = c[m], l[l.length] = m);
      }
      return u;
    }
    t.ofTables = n;
    function a(i) {
      for (var o = {}, c = 0, s = i._tableNames; c < s.length; c++) {
        var u = s[c];
        o[u] = e.Table.getRows(i[u]);
      }
      return o;
    }
    t.getTablesAsRows = a;
  }(r || (r = {})), oh.Database = r, oh;
}
var S6;
function mr() {
  return S6 || (S6 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.ColumnHelpers = e.Column = e.Table = e.Database = void 0;
    var r = Te, t = cZ();
    Object.defineProperty(e, "Database", { enumerable: !0, get: function() {
      return t.Database;
    } });
    var n = eU();
    Object.defineProperty(e, "Table", { enumerable: !0, get: function() {
      return n.Table;
    } });
    var a = jg;
    Object.defineProperty(e, "Column", { enumerable: !0, get: function() {
      return a.Column;
    } });
    var i = (0, r.__importStar)(zi);
    e.ColumnHelpers = i;
  }(Px)), Px;
}
var C6;
function dZ() {
  if (C6) return uf;
  C6 = 1, Object.defineProperty(uf, "__esModule", { value: !0 }), uf.groupBy = uf.Grouper = void 0;
  var e = mr(), r = (
    /** @class */
    function() {
      function a(i) {
        this.getKey = i, this.map = /* @__PURE__ */ new Map(), this.keys = [], this.groups = [];
      }
      return a.prototype.add = function(i) {
        var o = this.getKey(i);
        if (this.map.has(o)) {
          var c = this.map.get(o);
          c[c.length] = i;
        } else {
          var c = [i];
          this.map.set(o, c), this.keys[this.keys.length] = o, this.groups[this.groups.length] = c;
        }
      }, a.prototype.getGrouping = function() {
        return { keys: this.keys, groups: this.groups, map: this.map };
      }, a;
    }()
  );
  function t(a) {
    return new r(a);
  }
  uf.Grouper = t;
  function n(a, i) {
    var o = t(i);
    if (e.Column.is(a))
      for (var c = a.value, s = 0, u = a.rowCount; s < u; s++)
        o.add(c(s));
    else
      for (var s = 0, u = a.length; s < u; s++)
        o.add(a[s]);
    return o.getGrouping();
  }
  return uf.groupBy = n, uf;
}
var $o = {};
Object.defineProperty($o, "__esModule", { value: !0 });
$o.arrayGetCtor = $o.arrayPickIndices = $o.createRangeArray = $o.iterableToArray = $o.arrayFind = void 0;
function fZ(e, r) {
  for (var t = 0, n = e.length; t < n; t++)
    if (r(e[t]))
      return e[t];
}
$o.arrayFind = fZ;
function mZ(e) {
  if (Array.from)
    return Array.from(e);
  for (var r = []; ; ) {
    var t = e.next(), n = t.done, a = t.value;
    if (n)
      break;
    r[r.length] = a;
  }
  return r;
}
$o.iterableToArray = mZ;
function vZ(e, r, t) {
  for (var n = r - e + 1, a = t ? new t(n) : new Int32Array(n), i = 0; i < n; i++)
    a[i] = i + e;
  return a;
}
$o.createRangeArray = vZ;
function pZ(e, r) {
  for (var t = new (rU(e))(r.length), n = 0, a = r.length; n < a; n++)
    t[n] = e[r[n]];
  return t;
}
$o.arrayPickIndices = pZ;
function rU(e) {
  var r = e.constructor;
  if (!r)
    throw new Error("data does not define a constructor and it should");
  return r;
}
$o.arrayGetCtor = rU;
var A6;
function wr() {
  return A6 || (A6 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 });
    var r = Te;
    (0, r.__exportStar)(z3, e), (0, r.__exportStar)(G3, e), (0, r.__exportStar)(Av, e), (0, r.__exportStar)(ea, e), (0, r.__exportStar)(go, e), (0, r.__exportStar)(dZ(), e), (0, r.__exportStar)($o, e);
  }(Tx)), Tx;
}
var x6;
function qw() {
  if (x6) return ih;
  x6 = 1, Object.defineProperty(ih, "__esModule", { value: !0 }), ih.IntTuple = void 0;
  var e = wr(), r;
  return function(t) {
    t.Zero = 0;
    var n = function() {
      var C = new ArrayBuffer(8), S = new ArrayBuffer(8);
      return {
        _int32: new Int32Array(C),
        _float64: new Float64Array(C),
        _int32_1: new Int32Array(S),
        _float64_1: new Float64Array(S)
      };
    }(), a = n._int32, i = n._float64, o = n._int32_1, c = n._float64_1;
    function s(C) {
      return typeof C == "number";
    }
    t.is = s;
    function u(C, S) {
      return a[0] = C, a[1] = S, i[0];
    }
    t.create = u;
    function l(C) {
      return i[0] = C, a[1] - a[0];
    }
    t.diff = l;
    function f(C) {
      return i[0] = C, a[0];
    }
    t.fst = f;
    function d(C) {
      return i[0] = C, a[1];
    }
    t.snd = d;
    function m(C, S) {
      return i[0] = C, c[0] = S, a[0] === o[0] && a[1] === o[1];
    }
    t.areEqual = m;
    function p(C, S) {
      i[0] = C, c[0] = S;
      var b = a[0] - o[0];
      return b !== 0 ? b : a[1] - o[1];
    }
    t.compare = p;
    function v(C, S, b) {
      i[0] = C[S], c[0] = C[b];
      var g = a[0] - o[0];
      return g !== 0 ? g : a[1] - o[1];
    }
    t.compareInArray = v;
    function h(C) {
      return i[0] = C, (0, e.hash2)(a[0], a[1]);
    }
    t.hashCode = h;
    function y(C) {
      return i[0] = C, "(".concat(a[0], ", ").concat(a[1], ")");
    }
    t.toString = y;
  }(r || (r = {})), ih.IntTuple = r, ih;
}
var T6;
function hZ() {
  return T6 || (T6 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.intersectionSize = e.intersect = e.findRange = e.findPredecessorIndexInInterval = e.findPredecessorIndex = e.isSubInterval = e.areIntersecting = e.areEqual = e.getAt = e.indexOf = e.has = e.toString = e.hashCode = e.size = e.max = e.min = e.end = e.start = e.is = e.ofLength = e.ofBounds = e.ofRange = e.Empty = void 0;
    var r = qw();
    e.Empty = r.IntTuple.Zero;
    function t(h, y) {
      return y < h ? r.IntTuple.create(h, h) : r.IntTuple.create(h, y + 1);
    }
    e.ofRange = t;
    function n(h, y) {
      return y <= h ? r.IntTuple.create(h, h) : r.IntTuple.create(h, y);
    }
    e.ofBounds = n;
    function a(h) {
      return h < 0 ? r.IntTuple.create(0, 0) : r.IntTuple.create(0, h);
    }
    e.ofLength = a, e.is = r.IntTuple.is, e.start = r.IntTuple.fst, e.end = r.IntTuple.snd, e.min = r.IntTuple.fst;
    function i(h) {
      return r.IntTuple.snd(h) - 1;
    }
    e.max = i, e.size = r.IntTuple.diff, e.hashCode = r.IntTuple.hashCode, e.toString = r.IntTuple.toString;
    function o(h, y) {
      return r.IntTuple.fst(h) <= y && y < r.IntTuple.snd(h);
    }
    e.has = o;
    function c(h, y) {
      var C = (0, e.start)(h);
      return y >= C && y < (0, e.end)(h) ? y - C : -1;
    }
    e.indexOf = c;
    function s(h, y) {
      return r.IntTuple.fst(h) + y;
    }
    e.getAt = s, e.areEqual = r.IntTuple.areEqual;
    function u(h, y) {
      var C = (0, e.size)(h), S = (0, e.size)(y);
      return C === 0 && S === 0 ? !0 : C > 0 && S > 0 && i(h) >= (0, e.min)(y) && (0, e.min)(h) <= i(y);
    }
    e.areIntersecting = u;
    function l(h, y) {
      return (0, e.size)(h) ? (0, e.size)(y) ? (0, e.start)(h) <= (0, e.start)(y) && (0, e.end)(h) >= (0, e.end)(y) : !0 : (0, e.size)(y) === 0;
    }
    e.isSubInterval = l;
    function f(h, y) {
      var C = (0, e.start)(h);
      if (y <= C)
        return 0;
      var S = (0, e.end)(h);
      return y >= S ? S - C : y - C;
    }
    e.findPredecessorIndex = f;
    function d(h, y, C) {
      var S = (0, e.start)(C), b = (0, e.start)(h);
      if (y <= S + b)
        return S;
      var g = (0, e.end)(C);
      return y >= g + b ? g : y - b;
    }
    e.findPredecessorIndexInInterval = d;
    function m(h, y, C) {
      return n(f(h, y), f(h, C + 1));
    }
    e.findRange = m;
    function p(h, y) {
      return u(h, y) ? n(Math.max((0, e.start)(h), (0, e.start)(y)), Math.min((0, e.end)(h), (0, e.end)(y))) : e.Empty;
    }
    e.intersect = p;
    function v(h, y) {
      return (0, e.size)(m(h, (0, e.min)(y), i(y)));
    }
    e.intersectionSize = v;
  }(xx)), xx;
}
var P6;
function gp() {
  if (P6) return ah;
  P6 = 1, Object.defineProperty(ah, "__esModule", { value: !0 }), ah.Interval = void 0;
  var e = Te, r = (0, e.__importStar)(hZ()), t;
  return function(n) {
    n.Empty = r.Empty, n.ofSingleton = function(a) {
      return r.ofRange(a, a);
    }, n.ofRange = r.ofRange, n.ofBounds = r.ofBounds, n.ofLength = r.ofLength, n.is = r.is, n.has = r.has, n.indexOf = r.indexOf, n.getAt = r.getAt, n.start = r.start, n.end = r.end, n.min = r.min, n.max = r.max, n.size = r.size, n.hashCode = r.hashCode, n.toString = r.toString, n.areEqual = r.areEqual, n.areIntersecting = r.areIntersecting, n.isSubInterval = r.isSubInterval, n.findPredecessorIndex = r.findPredecessorIndex, n.findPredecessorIndexInInterval = r.findPredecessorIndexInInterval, n.findRange = r.findRange, n.intersectionSize = r.intersectionSize, n.intersect = r.intersect;
  }(t || (t = {})), ah.Interval = t, ah;
}
var lh = {}, wx = {}, ch = {}, Ex = {}, M6;
function gZ() {
  return M6 || (M6 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.indicesOf = e.deduplicate = e.subtract = e.intersect = e.intersectionSize = e.union = e.isSubset = e.areIntersecting = e.findRange = e.findPredecessorIndexInInterval = e.findPredecessorIndex = e.areEqual = e.getAt = e.has = e.indexOfInRange = e.indexOfInInterval = e.indexOf = e.toString = e.hashCode = e.size = e.max = e.min = e.end = e.start = e.isRange = e.is = e.ofRange = e.ofUnsortedArray = e.ofSortedArray = e.ofSingleton = e.Empty = void 0;
    var r = wr(), t = gp();
    e.Empty = [];
    function n(R) {
      return [R];
    }
    e.ofSingleton = n;
    function a(R) {
      return R;
    }
    e.ofSortedArray = a;
    function i(R) {
      return (0, r.sortArray)(R), R;
    }
    e.ofUnsortedArray = i;
    function o(R, F) {
      if (F < R)
        return [];
      for (var U = new Int32Array(F - R + 1), H = R; H <= F; H++)
        U[H - R] = H;
      return U;
    }
    e.ofRange = o;
    function c(R) {
      return R && (Array.isArray(R) || !!R.buffer);
    }
    e.is = c;
    function s(R) {
      return R[R.length - 1] - R[0] + 1 === R.length;
    }
    e.isRange = s;
    function u(R) {
      return R[0];
    }
    e.start = u;
    function l(R) {
      return R[R.length - 1] + 1;
    }
    e.end = l;
    function f(R) {
      return R[0];
    }
    e.min = f;
    function d(R) {
      return R[R.length - 1];
    }
    e.max = d;
    function m(R) {
      return R.length;
    }
    e.size = m;
    function p(R) {
      var F = R.length;
      return F ? F > 2 ? (0, r.hash4)(F, R[0], R[F - 1], R[F >> 1]) : (0, r.hash3)(F, R[0], R[F - 1]) : 0;
    }
    e.hashCode = p;
    function v(R) {
      var F = R.length;
      return F > 5 ? "[".concat(R[0], ", ").concat(R[1], ", ..., ").concat(R[F - 1], "], length ").concat(F) : "[".concat(R.join(", "), "]");
    }
    e.toString = v;
    function h(R, F) {
      var U = R.length;
      return U === 0 ? -1 : R[0] <= F && F <= R[U - 1] ? P(R, F, 0, U) : -1;
    }
    e.indexOf = h;
    function y(R, F, U) {
      return C(R, F, t.Interval.start(U), t.Interval.end(U));
    }
    e.indexOfInInterval = y;
    function C(R, F, U, H) {
      var q = R.length;
      return q === 0 || H <= U ? -1 : R[U] <= F && F <= R[H - 1] ? P(R, F, U, H) : -1;
    }
    e.indexOfInRange = C;
    function S(R, F) {
      return h(R, F) >= 0;
    }
    e.has = S;
    function b(R, F) {
      return R[F];
    }
    e.getAt = b;
    function g(R, F) {
      if (R === F)
        return !0;
      var U = R.length;
      if (U !== F.length || R[0] !== F[0] || R[U - 1] !== F[U - 1])
        return !1;
      if (s(R))
        return !0;
      U--;
      for (var H = 1; H < U; H++)
        if (R[H] !== F[H])
          return !1;
      return !0;
    }
    e.areEqual = g;
    function _(R, F) {
      var U = R.length;
      return F <= R[0] ? 0 : F > R[U - 1] ? U : T(R, F, 0, U);
    }
    e.findPredecessorIndex = _;
    function A(R, F, U) {
      var H = t.Interval.start(U), q = t.Interval.end(U), K = R[H];
      return F <= K ? H : q > H && F > R[q - 1] ? q : F - K <= 11 ? x(R, F, H + 1, q) : T(R, F, H, q);
    }
    e.findPredecessorIndexInInterval = A;
    function M(R, F, U) {
      return t.Interval.ofBounds(_(R, F), _(R, U + 1));
    }
    e.findRange = M;
    function P(R, F, U, H) {
      for (var q = U, K = H - 1; q <= K; ) {
        if (q + 11 > K) {
          for (var Y = q; Y <= K; Y++)
            if (F === R[Y])
              return Y;
          return -1;
        }
        var X = q + K >> 1, Z = R[X];
        if (F < Z)
          K = X - 1;
        else if (F > Z)
          q = X + 1;
        else
          return X;
      }
      return -1;
    }
    function T(R, F, U, H) {
      for (var q = U, K = H - 1; q < K; ) {
        if (q + 11 > K) {
          for (var Y = q; Y <= K; Y++)
            if (F <= R[Y])
              return Y;
          return K + 1;
        }
        var X = q + K >> 1, Z = R[X];
        if (F < Z)
          K = X - 1;
        else if (F > Z)
          q = X + 1;
        else
          return X;
      }
      return q > K ? K + 1 : R[q] >= F ? q : q + 1;
    }
    function x(R, F, U, H) {
      for (var q = U; q < H; q++)
        if (F <= R[q])
          return q;
      return H;
    }
    function w(R, F) {
      if (R === F)
        return !0;
      for (var U = L(R, F), H = U.startI, q = U.startJ, K = U.endI, Y = U.endJ; H < K && q < Y; ) {
        var X = R[H], Z = F[q];
        if (X < Z)
          H++;
        else if (X > Z)
          q++;
        else
          return !0;
      }
      return !1;
    }
    e.areIntersecting = w;
    function E(R, F) {
      if (R === F)
        return !0;
      var U = F.length, H = L(R, F), q = H.startI, K = H.startJ, Y = H.endI, X = H.endJ;
      if (X - K < U || Y - q < U)
        return !1;
      for (var Z = 0; q < Y && K < X; ) {
        var J = R[q], $ = F[K];
        J < $ ? q++ : J > $ ? K++ : (q++, K++, Z++);
      }
      return Z === U;
    }
    e.isSubset = E;
    function I(R, F) {
      if (R === F)
        return R;
      var U = R.length, H = F.length;
      if (U === 0)
        return F;
      if (H === 0)
        return R;
      if (R[0] > F[0])
        return I(F, R);
      var q = L(R, F), K = q.startI, Y = q.startJ, X = q.endI, Z = q.endJ, J = D(R, F, K, Y, X, Z);
      if (J === U && J === H || J === H)
        return R;
      if (J === U)
        return F;
      var $ = new Int32Array(U + H - J), Q = 0, W = 0, te = 0;
      for (Q = 0; Q < K; Q++)
        $[te++] = R[Q];
      for (; W < Z && R[K] > F[W]; )
        $[te++] = F[W++];
      for (; Q < X && W < Z; ) {
        var oe = R[Q], z = F[W];
        oe < z ? ($[te++] = oe, Q++) : oe > z ? ($[te++] = z, W++) : ($[te++] = oe, Q++, W++);
      }
      for (; Q < X; Q++)
        $[te++] = R[Q];
      for (; W < Z; W++)
        $[te++] = F[W];
      for (; Q < U; Q++)
        $[te++] = R[Q];
      for (; W < H; W++)
        $[te++] = F[W];
      return $;
    }
    e.union = I;
    function B(R, F) {
      if (R === F)
        return m(R);
      var U = L(R, F), H = U.startI, q = U.startJ, K = U.endI, Y = U.endJ;
      return D(R, F, H, q, K, Y);
    }
    e.intersectionSize = B;
    function D(R, F, U, H, q, K) {
      for (var Y = U, X = H, Z = 0; Y < q && X < K; ) {
        var J = R[Y], $ = F[X];
        J < $ ? Y++ : J > $ ? X++ : (Y++, X++, Z++);
      }
      return Z;
    }
    function N(R, F) {
      if (R === F)
        return R;
      var U = L(R, F), H = U.startI, q = U.startJ, K = U.endI, Y = U.endJ, X = D(R, F, H, q, K, Y), Z = R.length, J = F.length;
      if (!X)
        return e.Empty;
      if (X === Z && X === J || X === J)
        return F;
      if (X === Z)
        return R;
      for (var $ = new Int32Array(X), Q = 0, W = H, te = q; W < K && te < Y; ) {
        var oe = R[W], z = F[te];
        oe < z ? W++ : (oe > z || ($[Q++] = oe, W++), te++);
      }
      return $;
    }
    e.intersect = N;
    function O(R, F) {
      if (R === F)
        return e.Empty;
      for (var U = R.length, H = L(R, F), q = H.startI, K = H.startJ, Y = H.endI, X = H.endJ, Z = q, J = K, $ = 0; Z < Y && J < X; ) {
        var Q = R[Z], W = F[J];
        Q < W ? Z++ : Q > W ? J++ : (Z++, J++, $++);
      }
      if (!$)
        return R;
      if ($ >= U)
        return e.Empty;
      for (var te = new Int32Array(U - $), oe = 0, z = 0; z < q; z++)
        te[oe++] = R[z];
      for (Z = q, J = K; Z < Y && J < X; ) {
        var Q = R[Z], W = F[J];
        Q < W ? (te[oe++] = Q, Z++) : (Q > W || Z++, J++);
      }
      for (; Z < U; Z++)
        te[oe++] = R[Z];
      return te;
    }
    e.subtract = O;
    function V(R) {
      if (R.length < 2)
        return R;
      for (var F = 1, U = 0, H = R.length - 1; U < H; U++)
        R[U] !== R[U + 1] && F++;
      if (F === R.length)
        return R;
      for (var q = new Int32Array(F), K = 0, U = 0, H = R.length - 1; U < H; U++)
        R[U] !== R[U + 1] && (q[K++] = R[U]);
      return q[K] = R[R.length - 1], q;
    }
    e.deduplicate = V;
    function k(R, F) {
      if (g(R, F))
        return (0, r.createRangeArray)(0, R.length - 1);
      for (var U = L(R, F), H = U.startI, q = U.startJ, K = U.endI, Y = U.endJ, X = H, Z = q, J = 0; X < K && Z < Y; ) {
        var $ = R[X], Q = F[Z];
        $ < Q ? X++ : $ > Q ? Z++ : (X++, Z++, J++);
      }
      var W = R.length;
      if (!J)
        return e.Empty;
      if (J === W)
        return (0, r.createRangeArray)(0, R.length - 1);
      var te = new Int32Array(J), oe = 0;
      for (X = H, Z = q; X < K && Z < Y; ) {
        var $ = R[X], Q = F[Z];
        $ < Q ? X++ : ($ > Q || (te[oe++] = X, X++), Z++);
      }
      return te;
    }
    e.indicesOf = k;
    var G = { startI: 0, startJ: 0, endI: 0, endJ: 0 };
    function L(R, F) {
      var U = R.length, H = F.length, q = U / H;
      return U >= 128 || H >= 128 || q <= 0.34 || q >= 2.99 ? (G.startI = _(R, u(F)), G.startJ = _(F, u(R)), G.endI = _(R, l(F)), G.endJ = _(F, l(R))) : (G.startI = 0, G.startJ = 0, G.endI = U, G.endJ = H), G;
    }
  }(Ex)), Ex;
}
var w6;
function Wg() {
  if (w6) return ch;
  w6 = 1, Object.defineProperty(ch, "__esModule", { value: !0 }), ch.SortedArray = void 0;
  var e = Te, r = (0, e.__importStar)(gZ()), t;
  return function(n) {
    n.Empty = r.Empty, n.ofUnsortedArray = r.ofUnsortedArray, n.ofSingleton = r.ofSingleton, n.ofSortedArray = r.ofSortedArray, n.ofRange = r.ofRange, n.ofBounds = function(a, i) {
      return r.ofRange(a, i - 1);
    }, n.is = r.is, n.isRange = r.isRange, n.has = r.has, n.indexOf = r.indexOf, n.indexOfInInterval = r.indexOfInInterval, n.indexOfInRange = r.indexOfInRange, n.start = r.start, n.end = r.end, n.min = r.min, n.max = r.max, n.size = r.size, n.hashCode = r.hashCode, n.toString = r.toString, n.areEqual = r.areEqual, n.areIntersecting = r.areIntersecting, n.isSubset = r.isSubset, n.union = r.union, n.intersect = r.intersect, n.subtract = r.subtract, n.findPredecessorIndex = r.findPredecessorIndex, n.findPredecessorIndexInInterval = r.findPredecessorIndexInInterval, n.findRange = r.findRange, n.intersectionSize = r.intersectionSize, n.deduplicate = r.deduplicate, n.indicesOf = r.indicesOf;
  }(t || (t = {})), ch.SortedArray = t, ch;
}
var E6;
function yZ() {
  return E6 || (E6 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.indexedIntersect = e.forEachSegment = e.forEach = e.subtract = e.intersect = e.union = e.intersectionSize = e.findRange = e.findPredecessorIndexInInterval = e.findPredecessorIndex = e.isSubset = e.areIntersecting = e.areEqual = e.toString = e.hashCode = e.end = e.start = e.max = e.min = e.getAt = e.indexOf = e.has = e.size = e.ofSortedArray = e.ofBounds = e.ofRange = e.ofSingleton = e.Empty = void 0;
    var r = Wg(), t = gp();
    e.Empty = t.Interval.Empty, e.ofSingleton = t.Interval.ofSingleton, e.ofRange = t.Interval.ofRange, e.ofBounds = t.Interval.ofBounds;
    function n(F) {
      return F.length ? r.SortedArray.isRange(F) ? t.Interval.ofRange(F[0], F[F.length - 1]) : F : e.Empty;
    }
    e.ofSortedArray = n;
    function a(F) {
      return t.Interval.is(F) ? t.Interval.size(F) : r.SortedArray.size(F);
    }
    e.size = a;
    function i(F, U) {
      return t.Interval.is(F) ? t.Interval.has(F, U) : r.SortedArray.has(F, U);
    }
    e.has = i;
    function o(F, U) {
      return t.Interval.is(F) ? t.Interval.indexOf(F, U) : r.SortedArray.indexOf(F, U);
    }
    e.indexOf = o;
    function c(F, U) {
      return t.Interval.is(F) ? t.Interval.getAt(F, U) : F[U];
    }
    e.getAt = c;
    function s(F) {
      return t.Interval.is(F) ? t.Interval.min(F) : r.SortedArray.min(F);
    }
    e.min = s;
    function u(F) {
      return t.Interval.is(F) ? t.Interval.max(F) : r.SortedArray.max(F);
    }
    e.max = u;
    function l(F) {
      return t.Interval.is(F) ? t.Interval.start(F) : r.SortedArray.start(F);
    }
    e.start = l;
    function f(F) {
      return t.Interval.is(F) ? t.Interval.end(F) : r.SortedArray.end(F);
    }
    e.end = f;
    function d(F) {
      return t.Interval.is(F) ? t.Interval.hashCode(F) : r.SortedArray.hashCode(F);
    }
    e.hashCode = d;
    function m(F) {
      return t.Interval.is(F) ? t.Interval.toString(F) : r.SortedArray.toString(F);
    }
    e.toString = m;
    function p(F, U) {
      return t.Interval.is(F) ? t.Interval.is(U) ? t.Interval.areEqual(F, U) : M(F, U) : t.Interval.is(U) ? M(U, F) : r.SortedArray.areEqual(F, U);
    }
    e.areEqual = p;
    function v(F, U) {
      return t.Interval.is(F) ? t.Interval.is(U) ? t.Interval.areIntersecting(F, U) : P(U, F) : t.Interval.is(U) ? P(F, U) : r.SortedArray.areIntersecting(F, U);
    }
    e.areIntersecting = v;
    function h(F, U) {
      return t.Interval.is(F) ? t.Interval.is(U) ? t.Interval.isSubInterval(F, U) : x(F, U) : t.Interval.is(U) ? T(F, U) : r.SortedArray.isSubset(F, U);
    }
    e.isSubset = h;
    function y(F, U) {
      return t.Interval.is(F) ? t.Interval.findPredecessorIndex(F, U) : r.SortedArray.findPredecessorIndex(F, U);
    }
    e.findPredecessorIndex = y;
    function C(F, U, H) {
      return t.Interval.is(F) ? t.Interval.findPredecessorIndexInInterval(F, U, H) : r.SortedArray.findPredecessorIndexInInterval(F, U, H);
    }
    e.findPredecessorIndexInInterval = C;
    function S(F, U, H) {
      return t.Interval.is(F) ? t.Interval.findRange(F, U, H) : r.SortedArray.findRange(F, U, H);
    }
    e.findRange = S;
    function b(F, U) {
      return t.Interval.is(F) ? t.Interval.is(U) ? t.Interval.intersectionSize(F, U) : D(U, F) : t.Interval.is(U) ? D(F, U) : r.SortedArray.intersectionSize(F, U);
    }
    e.intersectionSize = b;
    function g(F, U) {
      return t.Interval.is(F) ? t.Interval.is(U) ? I(F, U) : B(U, F) : t.Interval.is(U) ? B(F, U) : n(r.SortedArray.union(F, U));
    }
    e.union = g;
    function _(F, U) {
      return t.Interval.is(F) ? t.Interval.is(U) ? t.Interval.intersect(F, U) : N(U, F) : t.Interval.is(U) ? N(F, U) : n(r.SortedArray.intersect(F, U));
    }
    e.intersect = _;
    function A(F, U) {
      return t.Interval.is(F) ? t.Interval.is(U) ? O(F, U) : k(F, U) : t.Interval.is(U) ? V(F, U) : n(r.SortedArray.subtract(F, U));
    }
    e.subtract = A;
    function M(F, U) {
      return t.Interval.size(F) === r.SortedArray.size(U) && t.Interval.start(F) === r.SortedArray.start(U) && t.Interval.end(F) === r.SortedArray.end(U);
    }
    function P(F, U) {
      return F.length !== 0 && t.Interval.size(r.SortedArray.findRange(F, t.Interval.min(U), t.Interval.max(U))) !== 0;
    }
    function T(F, U) {
      var H = t.Interval.min(U), q = t.Interval.max(U);
      if (q - H + 1 === 0)
        return !0;
      var K = r.SortedArray.min(F), Y = r.SortedArray.max(F);
      if (H < K || q > Y)
        return !1;
      var X = r.SortedArray.findRange(F, H, q);
      return t.Interval.size(X) === t.Interval.size(U);
    }
    function x(F, U) {
      var H = t.Interval.min(F), q = t.Interval.max(F);
      if (q - H + 1 === 0)
        return !1;
      var K = r.SortedArray.min(U), Y = r.SortedArray.max(U);
      return K >= H && Y <= q;
    }
    function w(F, U) {
      var H = a(F), q = a(U);
      return H === 0 && q === 0 ? !0 : H > 0 && q > 0 && u(F) >= s(U) && s(F) <= u(U);
    }
    function E(F, U) {
      return a(F) ? a(U) ? s(F) <= s(U) && u(F) >= u(U) : !0 : a(U) === 0;
    }
    function I(F, U) {
      if (t.Interval.areEqual(F, U))
        return F;
      var H = t.Interval.size(F), q = t.Interval.size(U);
      if (!q)
        return F;
      if (!H)
        return U;
      var K = t.Interval.min(F), Y = t.Interval.min(U);
      if (w(F, U))
        return t.Interval.ofRange(Math.min(K, Y), Math.max(t.Interval.max(F), t.Interval.max(U)));
      var X, Z, J, $;
      K < Y ? (X = H, Z = K, J = q, $ = Y) : (X = q, Z = Y, J = H, $ = K);
      for (var Q = new Int32Array(H + q), W = 0; W < X; W++)
        Q[W] = W + Z;
      for (var W = 0; W < J; W++)
        Q[W + X] = W + $;
      return n(Q);
    }
    function B(F, U) {
      var H = t.Interval.size(U);
      if (!H)
        return F;
      if (E(U, F))
        return U;
      for (var q = t.Interval.min(U), K = t.Interval.max(U), Y = r.SortedArray.findRange(F, q, K), X = t.Interval.start(Y), Z = t.Interval.end(Y), J = new Int32Array(X + (F.length - Z) + H), $ = 0, Q = 0; Q < X; Q++)
        J[$++] = F[Q];
      for (var Q = q; Q <= K; Q++)
        J[$++] = Q;
      for (var Q = Z, W = F.length; Q < W; Q++)
        J[$++] = F[Q];
      return n(J);
    }
    function D(F, U) {
      if (!t.Interval.size(U))
        return 0;
      var H = r.SortedArray.findRange(F, t.Interval.min(U), t.Interval.max(U));
      return t.Interval.end(H) - t.Interval.start(H);
    }
    function N(F, U) {
      if (!t.Interval.size(U))
        return e.Empty;
      var H = r.SortedArray.findRange(F, t.Interval.min(U), t.Interval.max(U)), q = t.Interval.start(H), K = t.Interval.end(H), Y = K - q;
      if (!Y)
        return e.Empty;
      if (Y === F.length)
        return F;
      for (var X = new Int32Array(Y), Z = 0, J = q; J < K; J++)
        X[Z++] = F[J];
      return n(X);
    }
    function O(F, U) {
      if (t.Interval.areEqual(F, U))
        return e.Empty;
      if (!t.Interval.areIntersecting(F, U))
        return F;
      var H = t.Interval.min(F), q = t.Interval.max(F), K = t.Interval.min(U), Y = t.Interval.max(U);
      if (q < H || Y < K)
        return F;
      if (t.Interval.isSubInterval(U, F))
        return e.Empty;
      if (t.Interval.isSubInterval(F, U)) {
        var X = K - H, Z = q - Y;
        if (X <= 0)
          return t.Interval.ofRange(Y + 1, Y + Z);
        if (Z <= 0)
          return t.Interval.ofRange(H, H + X - 1);
        for (var J = new Int32Array(X + Z), $ = 0, Q = 0; Q < X; Q++)
          J[$++] = H + Q;
        for (var Q = 1; Q <= Z; Q++)
          J[$++] = Y + Q;
        return n(J);
      }
      return H < K ? t.Interval.ofRange(H, K - 1) : t.Interval.ofRange(Y + 1, q);
    }
    function V(F, U) {
      var H = t.Interval.min(U), q = t.Interval.max(U);
      if (q < H)
        return F;
      var K = r.SortedArray.findRange(F, H, q), Y = t.Interval.start(K), X = t.Interval.end(K), Z = F.length - (X - Y);
      if (Z <= 0)
        return e.Empty;
      if (Z === F.length)
        return F;
      for (var J = new Int32Array(Z), $ = 0, Q = 0; Q < Y; Q++)
        J[$++] = F[Q];
      for (var Q = X, W = F.length; Q < W; Q++)
        J[$++] = F[Q];
      return n(J);
    }
    function k(F, U) {
      var H = t.Interval.min(F), q = t.Interval.max(F);
      if (q < H)
        return F;
      var K = q - H + 1, Y = r.SortedArray.findRange(U, H, q), X = t.Interval.start(Y), Z = t.Interval.end(Y), J = Z - X;
      if (J === 0)
        return F;
      var $ = K - J;
      if ($ <= 0)
        return e.Empty;
      for (var Q = new Int32Array($), W = U.length - 1, te = U[Math.min(X, W)], oe = U[Math.min(Z, W)], z = 0, j = H; j < te; j++)
        Q[z++] = j;
      for (var j = te; j <= oe; j++)
        r.SortedArray.indexOfInInterval(U, j, Y) < 0 && (Q[z++] = j);
      for (var j = oe + 1; j <= q; j++)
        Q[z++] = j;
      return n(Q);
    }
    function G(F, U, H) {
      if (t.Interval.is(F))
        for (var q = t.Interval.min(F), K = q, Y = t.Interval.max(F); K <= Y; K++)
          U(K, K - q, H);
      else
        for (var K = 0, Y = F.length; K < Y; K++)
          U(F[K], K, H);
      return H;
    }
    e.forEach = G;
    function L(F, U, H, q) {
      if (t.Interval.is(F))
        for (var K = 0, Y = t.Interval.min(F), X = t.Interval.max(F); Y <= X; Y++) {
          for (var Z = U(Y), J = Y + 1; J < X && U(J) === Z; )
            J++;
          Y = J - 1, H(Z, K, q), K++;
        }
      else
        for (var K = 0, Y = 0, X = F.length; Y < X; Y++) {
          for (var Z = U(F[Y]), J = Y + 1; J < X && U(F[J]) === Z; )
            J++;
          Y = J - 1, H(Z, K, q), K++;
        }
      return q;
    }
    e.forEachSegment = L;
    function R(F, U, H) {
      if (U === H)
        return F;
      var q = a(F), K = U.length, Y = H.length;
      if (q === 0 || K === 0 || Y === 0)
        return e.Empty;
      for (var X = r.SortedArray.findPredecessorIndex(H, U[s(F)]), Z = r.SortedArray.findPredecessorIndex(H, U[u(F)] + 1), J = 0, $ = 0, Q = 0, W = X; Q < q && W < Z; ) {
        var te = U[c(F, Q)], oe = H[W];
        te < oe ? Q++ : (te > oe || (J++, Q++), W++);
      }
      if (J === 0)
        return e.Empty;
      if (J === K && J === Y)
        return F;
      var z = new Int32Array(J);
      for ($ = 0, Q = 0, W = X; Q < q && W < Z; ) {
        var te = U[c(F, Q)], oe = H[W];
        te < oe ? Q++ : (te > oe || (z[$++] = W, Q++), W++);
      }
      return n(z);
    }
    e.indexedIntersect = R;
  }(wx)), wx;
}
var D6;
function tU() {
  if (D6) return lh;
  D6 = 1, Object.defineProperty(lh, "__esModule", { value: !0 }), lh.OrderedSet = void 0;
  var e = Te, r = (0, e.__importStar)(yZ()), t = gp(), n;
  return function(a) {
    a.Empty = r.Empty, a.ofSingleton = r.ofSingleton, a.ofRange = r.ofRange, a.ofBounds = r.ofBounds, a.ofSortedArray = r.ofSortedArray, a.has = r.has, a.indexOf = r.indexOf, a.getAt = r.getAt, a.min = r.min, a.max = r.max, a.start = r.start, a.end = r.end, a.size = r.size, a.hashCode = r.hashCode, a.areEqual = r.areEqual, a.areIntersecting = r.areIntersecting, a.isSubset = r.isSubset, a.union = r.union, a.intersect = r.intersect, a.indexedIntersect = r.indexedIntersect, a.subtract = r.subtract, a.findPredecessorIndex = r.findPredecessorIndex, a.findPredecessorIndexInInterval = r.findPredecessorIndexInInterval, a.findRange = r.findRange, a.intersectionSize = r.intersectionSize;
    function i(f, d, m) {
      return r.forEach(f, d, m);
    }
    a.forEach = i;
    function o(f, d, m, p) {
      return r.forEachSegment(f, d, m, p);
    }
    a.forEachSegment = o;
    function c(f) {
      return t.Interval.is(f);
    }
    a.isInterval = c;
    function s(f) {
      return !t.Interval.is(f);
    }
    a.isSortedArray = s;
    function u(f) {
      var d = [];
      return a.forEach(f, function(m) {
        return d.push(m);
      }), d;
    }
    a.toArray = u;
    function l(f) {
      return r.toString(f);
    }
    a.toString = l;
  }(n || (n = {})), lh.OrderedSet = n, lh;
}
var dh = {}, ka = {}, I6;
function _Z() {
  if (I6) return ka;
  I6 = 1, Object.defineProperty(ka, "__esModule", { value: !0 }), ka.segments = ka.SegmentIterator = ka.projectValue = ka.getSegment = ka.count = ka.ofOffsets = ka.create = void 0;
  var e = tU(), r = gp(), t = Wg();
  function n(l) {
    for (var f = t.SortedArray.ofSortedArray(l), d = t.SortedArray.max(f), m = new Int32Array(d), p = 0, v = l.length - 1; p < v; p++)
      for (var h = l[p], y = l[p + 1]; h < y; h++)
        m[h] = p;
    return { offsets: f, index: m, count: l.length - 1 };
  }
  ka.create = n;
  function a(l, f) {
    for (var d = r.Interval.start(f), m = new Int32Array(l.length + 1), p = 0, v = l.length; p < v; p++)
      m[p] = l[p] - d;
    return m[l.length] = r.Interval.end(f) - d, n(m);
  }
  ka.ofOffsets = a;
  function i(l) {
    var f = l.count;
    return f;
  }
  ka.count = i;
  function o(l, f) {
    var d = l.index;
    return d[f];
  }
  ka.getSegment = o;
  function c(l, f, d) {
    var m = l.offsets, p = e.OrderedSet.max(m), v = d >= p ? -1 : e.OrderedSet.findPredecessorIndex(m, d - 1);
    return e.OrderedSet.findRange(f, e.OrderedSet.getAt(m, v), e.OrderedSet.getAt(m, v + 1) - 1);
  }
  ka.projectValue = c;
  var s = (
    /** @class */
    function() {
      function l(f, d, m, p) {
        this.segments = f, this.segmentMap = d, this.set = m, this.segmentMin = 0, this.segmentMax = 0, this.setRange = r.Interval.Empty, this.value = { index: 0, start: 0, end: 0 }, this.hasNext = !1, this.setRange = p, this.updateSegmentRange();
      }
      return l.prototype.move = function() {
        for (; this.hasNext; )
          if (this.updateValue()) {
            this.value.index = this.segmentMin++, this.hasNext = this.segmentMax >= this.segmentMin && r.Interval.size(this.setRange) > 0;
            break;
          } else
            this.updateSegmentRange();
        return this.value;
      }, l.prototype.updateValue = function() {
        var f = this.segments[this.segmentMin + 1], d = e.OrderedSet.findPredecessorIndexInInterval(this.set, f, this.setRange);
        return this.value.start = r.Interval.start(this.setRange), this.value.end = d, this.setRange = r.Interval.ofBounds(d, r.Interval.end(this.setRange)), d > this.value.start;
      }, l.prototype.updateSegmentRange = function() {
        var f = r.Interval.min(this.setRange), d = r.Interval.max(this.setRange);
        if (d < f) {
          this.hasNext = !1;
          return;
        }
        this.segmentMin = this.segmentMap[e.OrderedSet.getAt(this.set, f)], this.segmentMax = this.segmentMap[e.OrderedSet.getAt(this.set, d)], this.hasNext = this.segmentMax >= this.segmentMin;
      }, l.prototype.setSegment = function(f) {
        this.setRange = r.Interval.ofBounds(f.start, f.end), this.updateSegmentRange();
      }, l;
    }()
  );
  ka.SegmentIterator = s;
  function u(l, f, d) {
    var m = typeof d < "u" ? r.Interval.ofBounds(d.start, d.end) : r.Interval.ofBounds(0, e.OrderedSet.size(f));
    return new s(l.offsets, l.index, f, m);
  }
  return ka.segments = u, ka;
}
var B6;
function nU() {
  if (B6) return dh;
  B6 = 1, Object.defineProperty(dh, "__esModule", { value: !0 }), dh.Segmentation = void 0;
  var e = Te, r = (0, e.__importStar)(_Z()), t;
  return function(n) {
    n.create = r.create, n.ofOffsets = r.ofOffsets, n.count = r.count, n.getSegment = r.getSegment, n.projectValue = r.projectValue, n.transientSegments = r.segments;
  }(t || (t = {})), dh.Segmentation = t, dh;
}
var H3 = {};
Object.defineProperty(H3, "__esModule", { value: !0 });
H3.LinkedIndex = void 0;
function bZ(e) {
  return new SZ(e);
}
H3.LinkedIndex = bZ;
var SZ = (
  /** @class */
  function() {
    function e(r) {
      this.head = r > 0 ? 0 : -1, this.prev = new Int32Array(r), this.next = new Int32Array(r);
      for (var t = 0; t < r; t++)
        this.next[t] = t + 1, this.prev[t] = t - 1;
      this.prev[0] = -1, this.next[r - 1] = -1;
    }
    return e.prototype.remove = function(r) {
      var t = this, n = t.prev, a = t.next, i = n[r], o = a[r];
      i >= 0 && (a[i] = o, n[r] = -1), o >= 0 && (n[o] = i, a[r] = -1), r === this.head && (i < 0 ? this.head = o : this.head = i);
    }, e.prototype.has = function(r) {
      return this.prev[r] >= 0 || this.next[r] >= 0 || this.head === r;
    }, e;
  }()
), fh = {}, N6;
function CZ() {
  if (N6) return fh;
  N6 = 1, Object.defineProperty(fh, "__esModule", { value: !0 }), fh.IntMap = void 0;
  var e = wr(), r;
  return function(t) {
    t.Empty = /* @__PURE__ */ new Map();
    function n(s) {
      return (0, e.iterableToArray)(s.keys());
    }
    t.keyArray = n;
    function a() {
      return /* @__PURE__ */ new Map();
    }
    t.Mutable = a;
    function i(s) {
      return s;
    }
    t.asImmutable = i;
    function o(s) {
      for (var u = a(), l = s.keys(); ; ) {
        var f = l.next(), d = f.done, m = f.value;
        if (d)
          break;
        u.set(m, s.get(m));
      }
      return u;
    }
    t.copy = o;
    function c(s, u) {
      for (var l = u.keys(); ; ) {
        var f = l.next(), d = f.done, m = f.value;
        if (d)
          break;
        s.set(m, u.get(m));
      }
      return s;
    }
    t.addFrom = c;
  }(r || (r = {})), fh.IntMap = r, fh;
}
var yp = {};
Object.defineProperty(yp, "__esModule", { value: !0 });
yp.Iterator = void 0;
var AZ = (
  /** @class */
  function() {
    function e(r) {
      this.xs = [], this.index = -1, this.length = 0, this.hasNext = !1, this.length = r.length, this.hasNext = r.length > 0, this.xs = r, this.index = -1, this.lastValue = r.length > 0 ? r[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;
  }()
), V6 = (
  /** @class */
  function() {
    function e(r, t) {
      this.max = t, this.value = 0, this.hasNext = !1, this.value = r - 1, this.hasNext = t >= r;
    }
    return e.prototype.move = function() {
      return ++this.value, this.hasNext = this.value < this.max, this.value;
    }, e;
  }()
), xZ = (
  /** @class */
  function() {
    function e(r) {
      this.value = r, this.hasNext = !0;
    }
    return e.prototype.move = function() {
      return this.hasNext = !1, this.value;
    }, e;
  }()
), TZ = (
  /** @class */
  function() {
    function e(r, t) {
      this.base = r, this.f = t, this.hasNext = !1, this.hasNext = r.hasNext;
    }
    return e.prototype.move = function() {
      var r = this.f(this.base.move());
      return this.hasNext = this.base.hasNext, r;
    }, e;
  }()
), PZ = (
  /** @class */
  function() {
    function e(r, t) {
      this.base = r, this.p = t, this.hasNext = this.findNext();
    }
    return e.prototype.move = function() {
      var r = this.next;
      return this.hasNext = this.findNext(), r;
    }, e.prototype.findNext = function() {
      for (; this.base.hasNext; )
        if (this.next = this.base.move(), this.p(this.next))
          return !0;
      return !1;
    }, e;
  }()
), qP;
(function(e) {
  e.Empty = new V6(0, -1);
  function r(c) {
    return new AZ(c);
  }
  e.Array = r;
  function t(c) {
    return new xZ(c);
  }
  e.Value = t;
  function n(c, s) {
    return new V6(c, s);
  }
  e.Range = n;
  function a(c, s) {
    return new TZ(c, s);
  }
  e.map = a;
  function i(c, s) {
    return new PZ(c, s);
  }
  e.filter = i;
  function o(c, s, u) {
    for (; c.hasNext; ) {
      var l = s(c.move(), u);
      if (l)
        return u;
    }
    return u;
  }
  e.forEach = o;
})(qP || (qP = {}));
yp.Iterator = qP;
var R6;
function Qe() {
  return R6 || (R6 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.Iterator = e.IntMap = e.LinkedIndex = e.Tuple = e.SortedArray = e.Segmentation = e.OrderedSet = e.Interval = void 0;
    var r = gp();
    Object.defineProperty(e, "Interval", { enumerable: !0, get: function() {
      return r.Interval;
    } });
    var t = tU();
    Object.defineProperty(e, "OrderedSet", { enumerable: !0, get: function() {
      return t.OrderedSet;
    } });
    var n = nU();
    Object.defineProperty(e, "Segmentation", { enumerable: !0, get: function() {
      return n.Segmentation;
    } });
    var a = Wg();
    Object.defineProperty(e, "SortedArray", { enumerable: !0, get: function() {
      return a.SortedArray;
    } });
    var i = qw();
    Object.defineProperty(e, "Tuple", { enumerable: !0, get: function() {
      return i.IntTuple;
    } });
    var o = H3;
    Object.defineProperty(e, "LinkedIndex", { enumerable: !0, get: function() {
      return o.LinkedIndex;
    } });
    var c = CZ();
    Object.defineProperty(e, "IntMap", { enumerable: !0, get: function() {
      return c.IntMap;
    } });
    var s = yp;
    Object.defineProperty(e, "Iterator", { enumerable: !0, get: function() {
      return s.Iterator;
    } });
  }(Ax)), Ax;
}
var O6;
function aU() {
  return O6 || (O6 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.ColorScale = e.DefaultColorScaleProps = void 0;
    var r = Te, t = Iu(), n = _c, a = We(), i = ti, o = Qe(), c = Zr;
    e.DefaultColorScaleProps = {
      domain: [0, 1],
      reverse: !1,
      listOrName: "red-yellow-blue",
      minLabel: "",
      maxLabel: ""
    }, function(s) {
      function u(l) {
        var f = (0, r.__assign)((0, r.__assign)({}, e.DefaultColorScaleProps), l), d = f.domain, m = f.reverse, p = f.listOrName, v = typeof p == "string" ? (0, n.getColorListFromName)(p).list : p, h = m ? v.slice().reverse() : v, y = h.length - 1, C = 0, S = 0, b = 0;
        function g(I, B) {
          S = I, b = B, C = b - S || 1;
        }
        g(d[0], d[1]);
        var _ = (0, a.defaults)(l.minLabel, S.toString()), A = (0, a.defaults)(l.maxLabel, b.toString()), M, P = h.every(function(I) {
          return Array.isArray(I);
        });
        if (P) {
          var T = (0, r.__spreadArray)([], h, !0);
          T.sort(function(I, B) {
            return I[1] - B[1];
          });
          var x = T.map(function(I) {
            return I[0];
          }), w = o.SortedArray.ofSortedArray(T.map(function(I) {
            return I[1];
          })), E = x.length - 1;
          M = function(I) {
            var B = (0, c.clamp)((I - S) / C, 0, 1), D = o.SortedArray.findPredecessorIndex(w, B);
            if (D === 0)
              return x[S];
            if (D > E)
              return x[E];
            var N = w[D - 1], O = w[D], V = (0, c.clamp)((B - N) / (O - N), 0, 1);
            return t.Color.interpolate(x[D - 1], x[D], V);
          };
        } else
          M = function(I) {
            var B = Math.min(h.length - 1, Math.max(0, (I - S) / C * y)), D = Math.floor(B), N = h[D], O = h[Math.ceil(B)];
            return t.Color.interpolate(N, O, B - D);
          };
        return {
          color: M,
          colorToArray: function(I, B, D) {
            t.Color.toArray(M(I), B, D);
          },
          normalizedColorToArray: function(I, B, D) {
            t.Color.toArrayNormalized(M(I), B, D);
          },
          setDomain: g,
          get legend() {
            return (0, i.ScaleLegend)(_, A, h);
          }
        };
      }
      s.create = u;
    }(e.ColorScale || (e.ColorScale = {}));
  }(Cx)), Cx;
}
var F6;
function Tr() {
  return F6 || (F6 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.ColorScale = e.ColorTable = e.ColorMap = e.Color = void 0;
    var r = Iu();
    Object.defineProperty(e, "Color", { enumerable: !0, get: function() {
      return r.Color;
    } }), Object.defineProperty(e, "ColorMap", { enumerable: !0, get: function() {
      return r.ColorMap;
    } }), Object.defineProperty(e, "ColorTable", { enumerable: !0, get: function() {
      return r.ColorTable;
    } });
    var t = aU();
    Object.defineProperty(e, "ColorScale", { enumerable: !0, get: function() {
      return t.ColorScale;
    } });
  }(bx)), bx;
}
var ds = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.SetUtils = void 0;
  var r = $o;
  (function(t) {
    function n(v) {
      return (0, r.iterableToArray)(v.values());
    }
    t.toArray = n;
    function a(v, h) {
      var y = !0;
      return h.forEach(function(C) {
        v.has(C) || (y = !1);
      }), y;
    }
    t.isSuperset = a;
    function i(v) {
      for (var h = [], y = 1; y < arguments.length; y++)
        h[y - 1] = arguments[y];
      for (var C = 0; C < h.length; C++)
        h[C].forEach(function(S) {
          return v.add(S);
        });
      return v;
    }
    t.add = i;
    function o(v, h) {
      var y = new Set(v);
      return h.forEach(function(C) {
        return y.add(C);
      }), y;
    }
    t.union = o;
    function c() {
      for (var v = [], h = 0; h < arguments.length; h++)
        v[h] = arguments[h];
      if (v.length === 0)
        return /* @__PURE__ */ new Set();
      v.length === 1 && new Set(v[0]);
      for (var y = new Set(v[0]), C = 1, S = v.length; C < S; C++)
        v[C].forEach(function(b) {
          return y.add(b);
        });
      return y;
    }
    t.unionMany = c;
    function s(v) {
      if (v.length === 0)
        return /* @__PURE__ */ new Set();
      for (var h = new Set(v[0]), y = 1; y < v.length; y++)
        for (var C = 0, S = v[y]; C < S.length; C++) {
          var b = S[C];
          h.add(b);
        }
      return h;
    }
    t.unionManyArrays = s;
    function u(v, h) {
      var y = /* @__PURE__ */ new Set();
      return h.forEach(function(C) {
        v.has(C) && y.add(C);
      }), y;
    }
    t.intersection = u;
    function l(v, h) {
      var y = !1;
      return h.forEach(function(C) {
        v.has(C) && (y = !0);
      }), y;
    }
    t.areIntersecting = l;
    function f(v, h) {
      var y = 0;
      return h.forEach(function(C) {
        v.has(C) && (y += 1);
      }), y;
    }
    t.intersectionSize = f;
    function d(v, h) {
      var y = new Set(v);
      return h.forEach(function(C) {
        return y.delete(C);
      }), y;
    }
    t.difference = d;
    function m(v, h) {
      var y = v.size;
      return v.forEach(function(C) {
        h.has(C) && (y -= 1);
      }), y;
    }
    t.differenceSize = m;
    function p(v, h) {
      if (v.size !== h.size)
        return !1;
      var y = !0;
      return h.forEach(function(C) {
        v.has(C) || (y = !1);
      }), y;
    }
    t.areEqual = p;
  })(e.SetUtils || (e.SetUtils = {}));
})(ds);
var Ft = {};
Object.defineProperty(Ft, "__esModule", { value: !0 });
Ft.isPromiseLike = Ft.assertUnreachable = Ft.ObjectKeys = void 0;
function MZ(e) {
  return Object.keys(e);
}
Ft.ObjectKeys = MZ;
function wZ(e) {
  throw new Error("unreachable");
}
Ft.assertUnreachable = wZ;
function EZ(e) {
  return typeof (e == null ? void 0 : e.then) == "function";
}
Ft.isPromiseLike = EZ;
var L6;
function We() {
  return L6 || (L6 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.formatBytes = e.formatProgress = e.formatTime = e.merge = e.assign = e.shallowClone = e.extend = e.defaults = e.shallowEqualArrays = e.shallowEqualObjects = e.shallowEqual = e.deepEqual = e.arrayEqual = e.round = e.noop = e.Mask = e.UUID = e.StringBuilder = e.BitFlags = void 0;
    var r = Te, t = pp;
    Object.defineProperty(e, "BitFlags", { enumerable: !0, get: function() {
      return t.BitFlags;
    } });
    var n = L3;
    Object.defineProperty(e, "StringBuilder", { enumerable: !0, get: function() {
      return n.StringBuilder;
    } });
    var a = Hg;
    Object.defineProperty(e, "UUID", { enumerable: !0, get: function() {
      return a.UUID;
    } });
    var i = Cv;
    Object.defineProperty(e, "Mask", { enumerable: !0, get: function() {
      return i.Mask;
    } }), (0, r.__exportStar)(Jl, e), (0, r.__exportStar)(Tr(), e), (0, r.__exportStar)(ds, e), (0, r.__exportStar)(Ft, e);
    var o = function() {
    };
    e.noop = o;
    function c(M, P) {
      var T = Math.pow(10, P);
      return Math.round(T * M) / T;
    }
    e.round = c;
    function s(M, P) {
      var T = M.length;
      if (T !== P.length)
        return !1;
      for (var x = 0; x < T; x++)
        if (M[x] !== P[x])
          return !1;
      return !0;
    }
    e.arrayEqual = s;
    var u = Object.prototype.hasOwnProperty;
    function l(M, P) {
      if (M === P)
        return !0;
      var T = Array.isArray(M), x = Array.isArray(P);
      if (T && x) {
        if (M.length !== P.length)
          return !1;
        for (var w = 0; w < M.length; w++)
          if (!l(M[w], P[w]))
            return !1;
        return !0;
      }
      if (T !== x)
        return !1;
      if (M && P && typeof M == "object" && typeof P == "object") {
        var E = Object.keys(M);
        if (E.length !== Object.keys(P).length)
          return !1;
        var I = M instanceof Date, B = P instanceof Date;
        if (I && B)
          return M.getTime() === P.getTime();
        if (I !== B)
          return !1;
        var D = M instanceof RegExp, N = P instanceof RegExp;
        if (D && N)
          return M.toString() === P.toString();
        if (D !== N)
          return !1;
        for (var w = 0; w < E.length; w++)
          if (!u.call(P, E[w]))
            return !1;
        for (var w = 0; w < E.length; w++)
          if (!l(M[E[w]], P[E[w]]))
            return !1;
        return !0;
      }
      return !1;
    }
    e.deepEqual = l;
    function f(M, P) {
      if (M === P)
        return !0;
      var T = Array.isArray(M), x = Array.isArray(P);
      return T && x ? m(M, P) : T !== x ? !1 : M && P && typeof M == "object" && typeof P == "object" ? d(M, P) : !1;
    }
    e.shallowEqual = f;
    function d(M, P) {
      if (M === P)
        return !0;
      if (!M || !P)
        return !1;
      var T = Object.keys(M);
      if (Object.keys(P).length !== T.length)
        return !1;
      for (var x = 0, w = T; x < w.length; x++) {
        var E = w[x];
        if (!u.call(M, E) || M[E] !== P[E])
          return !1;
      }
      return !0;
    }
    e.shallowEqualObjects = d;
    function m(M, P) {
      if (M === P)
        return !0;
      if (!M || !P || M.length !== P.length)
        return !1;
      for (var T = 0, x = M.length; T < x; ++T)
        if (M[T] !== P[T])
          return !1;
      return !0;
    }
    e.shallowEqualArrays = m;
    function p(M, P) {
      return M !== void 0 ? M : P;
    }
    e.defaults = p;
    function v(M, P, T) {
      for (var x, w = P, E = M, I = T, B = 0, D = Object.keys(P); B < D.length; B++) {
        var N = D[B];
        x = w[N], x !== void 0 ? E[N] = x : T && (E[N] = I[N]);
      }
      if (T)
        for (var O = 0, V = Object.keys(T); O < V.length; O++) {
          var N = V[O];
          x = E[N], x === void 0 && (E[N] = I[N]);
        }
      return M;
    }
    e.extend = v;
    function h(M) {
      return v({}, M);
    }
    e.shallowClone = h;
    function y(M) {
      for (var P = 1; P < arguments.length; P++)
        for (var T = arguments[P], x = 0, w = Object.keys(T); x < w.length; x++) {
          var E = w[x];
          u.call(T, E) && (M[E] = T[E]);
        }
      return M;
    }
    e.assign = Object.assign || y;
    function C(M, P) {
      for (var T = !1, x = 0, w = Object.keys(P); x < w.length; x++) {
        var E = w[x];
        if (u.call(P, E) && P[E] !== M[E]) {
          T = !0;
          break;
        }
      }
      return T ? (0, e.assign)(h(M), P) : M;
    }
    function S(M) {
      for (var P = M, T = 1; T < arguments.length; T++)
        if (arguments[T] && (P = C(M, arguments[T]), P !== M)) {
          for (var x = T + 1; x < arguments.length; x++)
            P = (0, e.assign)(P, arguments[x]);
          break;
        }
      return P;
    }
    e.merge = S;
    function b(M) {
      return (M < 10 ? "0" : "") + M;
    }
    function g(M) {
      var P = M.getHours(), T = M.getMinutes(), x = M.getSeconds();
      return "".concat(P, ":").concat(b(T), ":").concat(b(x));
    }
    e.formatTime = g;
    function _(M) {
      var P = M.root.progress;
      if (P.isIndeterminate)
        return P.message;
      var T = (100 * P.current / P.max).toFixed(2);
      return "".concat(P.message, " ").concat(T, "%");
    }
    e.formatProgress = _;
    function A(M) {
      var P = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], T = Math.floor(Math.log(M) / Math.log(1024));
      return "".concat((M / Math.pow(1024, T)).toFixed(2), " ").concat(P[T]);
    }
    e.formatBytes = A;
  }(_x)), _x;
}
var DZ = We(), Dx = {}, iU = {}, HP = function(e, r) {
  return HP = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, n) {
    t.__proto__ = n;
  } || function(t, n) {
    for (var a in n) Object.prototype.hasOwnProperty.call(n, a) && (t[a] = n[a]);
  }, HP(e, r);
};
function Kn(e, r) {
  if (typeof r != "function" && r !== null)
    throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
  HP(e, r);
  function t() {
    this.constructor = e;
  }
  e.prototype = r === null ? Object.create(r) : (t.prototype = r.prototype, new t());
}
function IZ(e, r, t, n) {
  function a(i) {
    return i instanceof t ? i : new t(function(o) {
      o(i);
    });
  }
  return new (t || (t = Promise))(function(i, o) {
    function c(l) {
      try {
        u(n.next(l));
      } catch (f) {
        o(f);
      }
    }
    function s(l) {
      try {
        u(n.throw(l));
      } catch (f) {
        o(f);
      }
    }
    function u(l) {
      l.done ? i(l.value) : a(l.value).then(c, s);
    }
    u((n = n.apply(e, r || [])).next());
  });
}
function Hw(e, r) {
  var t = { label: 0, sent: function() {
    if (i[0] & 1) throw i[1];
    return i[1];
  }, trys: [], ops: [] }, n, a, i, o;
  return o = { next: c(0), throw: c(1), return: c(2) }, typeof Symbol == "function" && (o[Symbol.iterator] = function() {
    return this;
  }), o;
  function c(u) {
    return function(l) {
      return s([u, l]);
    };
  }
  function s(u) {
    if (n) throw new TypeError("Generator is already executing.");
    for (; o && (o = 0, u[0] && (t = 0)), t; ) try {
      if (n = 1, a && (i = u[0] & 2 ? a.return : u[0] ? a.throw || ((i = a.return) && i.call(a), 0) : a.next) && !(i = i.call(a, u[1])).done) return i;
      switch (a = 0, i && (u = [u[0] & 2, i.value]), u[0]) {
        case 0:
        case 1:
          i = u;
          break;
        case 4:
          return t.label++, { value: u[1], done: !1 };
        case 5:
          t.label++, a = u[1], u = [0];
          continue;
        case 7:
          u = t.ops.pop(), t.trys.pop();
          continue;
        default:
          if (i = t.trys, !(i = i.length > 0 && i[i.length - 1]) && (u[0] === 6 || u[0] === 2)) {
            t = 0;
            continue;
          }
          if (u[0] === 3 && (!i || u[1] > i[0] && u[1] < i[3])) {
            t.label = u[1];
            break;
          }
          if (u[0] === 6 && t.label < i[1]) {
            t.label = i[1], i = u;
            break;
          }
          if (i && t.label < i[2]) {
            t.label = i[2], t.ops.push(u);
            break;
          }
          i[2] && t.ops.pop(), t.trys.pop();
          continue;
      }
      u = r.call(e, t);
    } catch (l) {
      u = [6, l], a = 0;
    } finally {
      n = i = 0;
    }
    if (u[0] & 5) throw u[1];
    return { value: u[0] ? u[1] : void 0, done: !0 };
  }
}
function bo(e) {
  var r = typeof Symbol == "function" && Symbol.iterator, t = r && e[r], n = 0;
  if (t) return t.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(r ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function jt(e, r) {
  var t = typeof Symbol == "function" && e[Symbol.iterator];
  if (!t) return e;
  var n = t.call(e), a, i = [], o;
  try {
    for (; (r === void 0 || r-- > 0) && !(a = n.next()).done; ) i.push(a.value);
  } catch (c) {
    o = { error: c };
  } finally {
    try {
      a && !a.done && (t = n.return) && t.call(n);
    } finally {
      if (o) throw o.error;
    }
  }
  return i;
}
function $t(e, r, t) {
  if (t || arguments.length === 2) for (var n = 0, a = r.length, i; n < a; n++)
    (i || !(n in r)) && (i || (i = Array.prototype.slice.call(r, 0, n)), i[n] = r[n]);
  return e.concat(i || Array.prototype.slice.call(r));
}
function lv(e) {
  return this instanceof lv ? (this.v = e, this) : new lv(e);
}
function BZ(e, r, t) {
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  var n = t.apply(e, r || []), a, i = [];
  return a = {}, c("next"), c("throw"), c("return", o), a[Symbol.asyncIterator] = function() {
    return this;
  }, a;
  function o(m) {
    return function(p) {
      return Promise.resolve(p).then(m, f);
    };
  }
  function c(m, p) {
    n[m] && (a[m] = function(v) {
      return new Promise(function(h, y) {
        i.push([m, v, h, y]) > 1 || s(m, v);
      });
    }, p && (a[m] = p(a[m])));
  }
  function s(m, p) {
    try {
      u(n[m](p));
    } catch (v) {
      d(i[0][3], v);
    }
  }
  function u(m) {
    m.value instanceof lv ? Promise.resolve(m.value.v).then(l, f) : d(i[0][2], m);
  }
  function l(m) {
    s("next", m);
  }
  function f(m) {
    s("throw", m);
  }
  function d(m, p) {
    m(p), i.shift(), i.length && s(i[0][0], i[0][1]);
  }
}
function NZ(e) {
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  var r = e[Symbol.asyncIterator], t;
  return r ? r.call(e) : (e = typeof bo == "function" ? bo(e) : e[Symbol.iterator](), t = {}, n("next"), n("throw"), n("return"), t[Symbol.asyncIterator] = function() {
    return this;
  }, t);
  function n(i) {
    t[i] = e[i] && function(o) {
      return new Promise(function(c, s) {
        o = e[i](o), a(c, s, o.done, o.value);
      });
    };
  }
  function a(i, o, c, s) {
    Promise.resolve(s).then(function(u) {
      i({ value: u, done: c });
    }, o);
  }
}
function Ur(e) {
  return typeof e == "function";
}
function T0(e) {
  var r = function(n) {
    Error.call(n), n.stack = new Error().stack;
  }, t = e(r);
  return t.prototype = Object.create(Error.prototype), t.prototype.constructor = t, t;
}
var $_ = T0(function(e) {
  return function(t) {
    e(this), this.message = t ? t.length + ` errors occurred during unsubscription:
` + t.map(function(n, a) {
      return a + 1 + ") " + n.toString();
    }).join(`
  `) : "", this.name = "UnsubscriptionError", this.errors = t;
  };
});
function dc(e, r) {
  if (e) {
    var t = e.indexOf(r);
    0 <= t && e.splice(t, 1);
  }
}
var Wi = function() {
  function e(r) {
    this.initialTeardown = r, this.closed = !1, this._parentage = null, this._teardowns = null;
  }
  return e.prototype.unsubscribe = function() {
    var r, t, n, a, i;
    if (!this.closed) {
      this.closed = !0;
      var o = this._parentage;
      if (o)
        if (this._parentage = null, Array.isArray(o))
          try {
            for (var c = bo(o), s = c.next(); !s.done; s = c.next()) {
              var u = s.value;
              u.remove(this);
            }
          } catch (v) {
            r = { error: v };
          } finally {
            try {
              s && !s.done && (t = c.return) && t.call(c);
            } finally {
              if (r) throw r.error;
            }
          }
        else
          o.remove(this);
      var l = this.initialTeardown;
      if (Ur(l))
        try {
          l();
        } catch (v) {
          i = v instanceof $_ ? v.errors : [v];
        }
      var f = this._teardowns;
      if (f) {
        this._teardowns = null;
        try {
          for (var d = bo(f), m = d.next(); !m.done; m = d.next()) {
            var p = m.value;
            try {
              k6(p);
            } catch (v) {
              i = i ?? [], v instanceof $_ ? i = $t($t([], jt(i)), jt(v.errors)) : i.push(v);
            }
          }
        } catch (v) {
          n = { error: v };
        } finally {
          try {
            m && !m.done && (a = d.return) && a.call(d);
          } finally {
            if (n) throw n.error;
          }
        }
      }
      if (i)
        throw new $_(i);
    }
  }, e.prototype.add = function(r) {
    var t;
    if (r && r !== this)
      if (this.closed)
        k6(r);
      else {
        if (r instanceof e) {
          if (r.closed || r._hasParent(this))
            return;
          r._addParent(this);
        }
        (this._teardowns = (t = this._teardowns) !== null && t !== void 0 ? t : []).push(r);
      }
  }, e.prototype._hasParent = function(r) {
    var t = this._parentage;
    return t === r || Array.isArray(t) && t.includes(r);
  }, e.prototype._addParent = function(r) {
    var t = this._parentage;
    this._parentage = Array.isArray(t) ? (t.push(r), t) : t ? [t, r] : r;
  }, e.prototype._removeParent = function(r) {
    var t = this._parentage;
    t === r ? this._parentage = null : Array.isArray(t) && dc(t, r);
  }, e.prototype.remove = function(r) {
    var t = this._teardowns;
    t && dc(t, r), r instanceof e && r._removeParent(this);
  }, e.EMPTY = function() {
    var r = new e();
    return r.closed = !0, r;
  }(), e;
}(), oU = Wi.EMPTY;
function uU(e) {
  return e instanceof Wi || e && "closed" in e && Ur(e.remove) && Ur(e.add) && Ur(e.unsubscribe);
}
function k6(e) {
  Ur(e) ? e() : e.unsubscribe();
}
var Ud = {
  onUnhandledError: null,
  onStoppedNotification: null,
  Promise: void 0,
  useDeprecatedSynchronousErrorHandling: !1,
  useDeprecatedNextContext: !1
}, jw = {
  setTimeout: function() {
    for (var e = [], r = 0; r < arguments.length; r++)
      e[r] = arguments[r];
    return setTimeout.apply(void 0, $t([], jt(e)));
  },
  clearTimeout: function(e) {
    var r = jw.delegate;
    return ((r == null ? void 0 : r.clearTimeout) || clearTimeout)(e);
  },
  delegate: void 0
};
function sU(e) {
  jw.setTimeout(function() {
    var r = Ud.onUnhandledError;
    if (r)
      r(e);
    else
      throw e;
  });
}
function Ln() {
}
var VZ = function() {
  return $w("C", void 0, void 0);
}();
function RZ(e) {
  return $w("E", void 0, e);
}
function OZ(e) {
  return $w("N", e, void 0);
}
function $w(e, r, t) {
  return {
    kind: e,
    value: r,
    error: t
  };
}
var Kf = null;
function K_(e) {
  if (Ud.useDeprecatedSynchronousErrorHandling) {
    var r = !Kf;
    if (r && (Kf = { errorThrown: !1, error: null }), e(), r) {
      var t = Kf, n = t.errorThrown, a = t.error;
      if (Kf = null, n)
        throw a;
    }
  } else
    e();
}
function FZ(e) {
  Ud.useDeprecatedSynchronousErrorHandling && Kf && (Kf.errorThrown = !0, Kf.error = e);
}
var j3 = function(e) {
  Kn(r, e);
  function r(t) {
    var n = e.call(this) || this;
    return n.isStopped = !1, t ? (n.destination = t, uU(t) && t.add(n)) : n.destination = LZ, n;
  }
  return r.create = function(t, n, a) {
    return new gg(t, n, a);
  }, r.prototype.next = function(t) {
    this.isStopped ? Bx(OZ(t), this) : this._next(t);
  }, r.prototype.error = function(t) {
    this.isStopped ? Bx(RZ(t), this) : (this.isStopped = !0, this._error(t));
  }, r.prototype.complete = function() {
    this.isStopped ? Bx(VZ, this) : (this.isStopped = !0, this._complete());
  }, r.prototype.unsubscribe = function() {
    this.closed || (this.isStopped = !0, e.prototype.unsubscribe.call(this), this.destination = null);
  }, r.prototype._next = function(t) {
    this.destination.next(t);
  }, r.prototype._error = function(t) {
    try {
      this.destination.error(t);
    } finally {
      this.unsubscribe();
    }
  }, r.prototype._complete = function() {
    try {
      this.destination.complete();
    } finally {
      this.unsubscribe();
    }
  }, r;
}(Wi), gg = function(e) {
  Kn(r, e);
  function r(t, n, a) {
    var i = e.call(this) || this, o;
    if (Ur(t))
      o = t;
    else if (t) {
      o = t.next, n = t.error, a = t.complete;
      var c;
      i && Ud.useDeprecatedNextContext ? (c = Object.create(t), c.unsubscribe = function() {
        return i.unsubscribe();
      }) : c = t, o = o == null ? void 0 : o.bind(c), n = n == null ? void 0 : n.bind(c), a = a == null ? void 0 : a.bind(c);
    }
    return i.destination = {
      next: o ? Ix(o) : Ln,
      error: Ix(n ?? lU),
      complete: a ? Ix(a) : Ln
    }, i;
  }
  return r;
}(j3);
function Ix(e, r) {
  return function() {
    for (var t = [], n = 0; n < arguments.length; n++)
      t[n] = arguments[n];
    try {
      e.apply(void 0, $t([], jt(t)));
    } catch (a) {
      Ud.useDeprecatedSynchronousErrorHandling ? FZ(a) : sU(a);
    }
  };
}
function lU(e) {
  throw e;
}
function Bx(e, r) {
  var t = Ud.onStoppedNotification;
  t && jw.setTimeout(function() {
    return t(e, r);
  });
}
var LZ = {
  closed: !0,
  next: Ln,
  error: lU,
  complete: Ln
}, $3 = function() {
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
}();
function ni(e) {
  return e;
}
function Kw() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  return cU(e);
}
function cU(e) {
  return e.length === 0 ? ni : e.length === 1 ? e[0] : function(t) {
    return e.reduce(function(n, a) {
      return a(n);
    }, t);
  };
}
var mt = function() {
  function e(r) {
    r && (this._subscribe = r);
  }
  return e.prototype.lift = function(r) {
    var t = new e();
    return t.source = this, t.operator = r, t;
  }, e.prototype.subscribe = function(r, t, n) {
    var a = this, i = UZ(r) ? r : new gg(r, t, n);
    return K_(function() {
      var o = a, c = o.operator, s = o.source;
      i.add(c ? c.call(i, s) : s ? a._subscribe(i) : a._trySubscribe(i));
    }), i;
  }, e.prototype._trySubscribe = function(r) {
    try {
      return this._subscribe(r);
    } catch (t) {
      r.error(t);
    }
  }, e.prototype.forEach = function(r, t) {
    var n = this;
    return t = U6(t), new t(function(a, i) {
      var o = new gg({
        next: function(c) {
          try {
            r(c);
          } catch (s) {
            i(s), o.unsubscribe();
          }
        },
        error: i,
        complete: a
      });
      n.subscribe(o);
    });
  }, e.prototype._subscribe = function(r) {
    var t;
    return (t = this.source) === null || t === void 0 ? void 0 : t.subscribe(r);
  }, e.prototype[$3] = function() {
    return this;
  }, e.prototype.pipe = function() {
    for (var r = [], t = 0; t < arguments.length; t++)
      r[t] = arguments[t];
    return cU(r)(this);
  }, e.prototype.toPromise = function(r) {
    var t = this;
    return r = U6(r), new r(function(n, a) {
      var i;
      t.subscribe(function(o) {
        return i = o;
      }, function(o) {
        return a(o);
      }, function() {
        return n(i);
      });
    });
  }, e.create = function(r) {
    return new e(r);
  }, e;
}();
function U6(e) {
  var r;
  return (r = e ?? Ud.Promise) !== null && r !== void 0 ? r : Promise;
}
function kZ(e) {
  return e && Ur(e.next) && Ur(e.error) && Ur(e.complete);
}
function UZ(e) {
  return e && e instanceof j3 || kZ(e) && uU(e);
}
function dU(e) {
  return Ur(e == null ? void 0 : e.lift);
}
function rr(e) {
  return function(r) {
    if (dU(r))
      return r.lift(function(t) {
        try {
          return e(t, this);
        } catch (n) {
          this.error(n);
        }
      });
    throw new TypeError("Unable to lift unknown Observable type");
  };
}
var Ze = function(e) {
  Kn(r, e);
  function r(t, n, a, i, o) {
    var c = e.call(this, t) || this;
    return c.onFinalize = o, c._next = n ? function(s) {
      try {
        n(s);
      } catch (u) {
        t.error(u);
      }
    } : e.prototype._next, c._error = i ? function(s) {
      try {
        i(s);
      } catch (u) {
        t.error(u);
      } finally {
        this.unsubscribe();
      }
    } : e.prototype._error, c._complete = a ? function() {
      try {
        a();
      } catch (s) {
        t.error(s);
      } finally {
        this.unsubscribe();
      }
    } : e.prototype._complete, c;
  }
  return r.prototype.unsubscribe = function() {
    var t, n = this.closed;
    e.prototype.unsubscribe.call(this), !n && ((t = this.onFinalize) === null || t === void 0 || t.call(this));
  }, r;
}(j3);
function fU() {
  return rr(function(e, r) {
    var t = null;
    e._refCount++;
    var n = new Ze(r, void 0, void 0, void 0, function() {
      if (!e || e._refCount <= 0 || 0 < --e._refCount) {
        t = null;
        return;
      }
      var a = e._connection, i = t;
      t = null, a && (!i || a === i) && a.unsubscribe(), r.unsubscribe();
    });
    e.subscribe(n), n.closed || (t = e.connect());
  });
}
var K3 = function(e) {
  Kn(r, e);
  function r(t, n) {
    var a = e.call(this) || this;
    return a.source = t, a.subjectFactory = n, a._subject = null, a._refCount = 0, a._connection = null, dU(t) && (a.lift = t.lift), a;
  }
  return r.prototype._subscribe = function(t) {
    return this.getSubject().subscribe(t);
  }, r.prototype.getSubject = function() {
    var t = this._subject;
    return (!t || t.isStopped) && (this._subject = this.subjectFactory()), this._subject;
  }, r.prototype._teardown = function() {
    this._refCount = 0;
    var t = this._connection;
    this._subject = this._connection = null, t == null || t.unsubscribe();
  }, r.prototype.connect = function() {
    var t = this, n = this._connection;
    if (!n) {
      n = this._connection = new Wi();
      var a = this.getSubject();
      n.add(this.source.subscribe(new Ze(a, void 0, function() {
        t._teardown(), a.complete();
      }, function(i) {
        t._teardown(), a.error(i);
      }, function() {
        return t._teardown();
      }))), n.closed && (this._connection = null, n = Wi.EMPTY);
    }
    return n;
  }, r.prototype.refCount = function() {
    return fU()(this);
  }, r;
}(mt), mU = {
  now: function() {
    return (mU.delegate || performance).now();
  },
  delegate: void 0
}, yg = {
  schedule: function(e) {
    var r = requestAnimationFrame, t = cancelAnimationFrame, n = r(function(a) {
      t = void 0, e(a);
    });
    return new Wi(function() {
      return t == null ? void 0 : t(n);
    });
  },
  requestAnimationFrame: function() {
    for (var e = [], r = 0; r < arguments.length; r++)
      e[r] = arguments[r];
    var t = yg.delegate;
    return ((t == null ? void 0 : t.requestAnimationFrame) || requestAnimationFrame).apply(void 0, $t([], jt(e)));
  },
  cancelAnimationFrame: function() {
    for (var e = [], r = 0; r < arguments.length; r++)
      e[r] = arguments[r];
    var t = yg.delegate;
    return ((t == null ? void 0 : t.cancelAnimationFrame) || cancelAnimationFrame).apply(void 0, $t([], jt(e)));
  },
  delegate: void 0
};
function zZ(e) {
  return e ? vU(e) : GZ;
}
function vU(e) {
  var r = yg.schedule;
  return new mt(function(t) {
    var n = new Wi(), a = e || mU, i = a.now(), o = function(c) {
      var s = a.now();
      t.next({
        timestamp: e ? s : c,
        elapsed: s - i
      }), t.closed || n.add(r(o));
    };
    return n.add(r(o)), n;
  });
}
var GZ = vU(), pU = T0(function(e) {
  return function() {
    e(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
  };
}), Sa = function(e) {
  Kn(r, e);
  function r() {
    var t = e.call(this) || this;
    return t.closed = !1, t.observers = [], t.isStopped = !1, t.hasError = !1, t.thrownError = null, t;
  }
  return r.prototype.lift = function(t) {
    var n = new z6(this, this);
    return n.operator = t, n;
  }, r.prototype._throwIfClosed = function() {
    if (this.closed)
      throw new pU();
  }, r.prototype.next = function(t) {
    var n = this;
    K_(function() {
      var a, i;
      if (n._throwIfClosed(), !n.isStopped) {
        var o = n.observers.slice();
        try {
          for (var c = bo(o), s = c.next(); !s.done; s = c.next()) {
            var u = s.value;
            u.next(t);
          }
        } catch (l) {
          a = { error: l };
        } finally {
          try {
            s && !s.done && (i = c.return) && i.call(c);
          } finally {
            if (a) throw a.error;
          }
        }
      }
    });
  }, r.prototype.error = function(t) {
    var n = this;
    K_(function() {
      if (n._throwIfClosed(), !n.isStopped) {
        n.hasError = n.isStopped = !0, n.thrownError = t;
        for (var a = n.observers; a.length; )
          a.shift().error(t);
      }
    });
  }, r.prototype.complete = function() {
    var t = this;
    K_(function() {
      if (t._throwIfClosed(), !t.isStopped) {
        t.isStopped = !0;
        for (var n = t.observers; n.length; )
          n.shift().complete();
      }
    });
  }, r.prototype.unsubscribe = function() {
    this.isStopped = this.closed = !0, this.observers = null;
  }, Object.defineProperty(r.prototype, "observed", {
    get: function() {
      var t;
      return ((t = this.observers) === null || t === void 0 ? void 0 : t.length) > 0;
    },
    enumerable: !1,
    configurable: !0
  }), r.prototype._trySubscribe = function(t) {
    return this._throwIfClosed(), e.prototype._trySubscribe.call(this, t);
  }, r.prototype._subscribe = function(t) {
    return this._throwIfClosed(), this._checkFinalizedStatuses(t), this._innerSubscribe(t);
  }, r.prototype._innerSubscribe = function(t) {
    var n = this, a = n.hasError, i = n.isStopped, o = n.observers;
    return a || i ? oU : (o.push(t), new Wi(function() {
      return dc(o, t);
    }));
  }, r.prototype._checkFinalizedStatuses = function(t) {
    var n = this, a = n.hasError, i = n.thrownError, o = n.isStopped;
    a ? t.error(i) : o && t.complete();
  }, r.prototype.asObservable = function() {
    var t = new mt();
    return t.source = this, t;
  }, r.create = function(t, n) {
    return new z6(t, n);
  }, r;
}(mt), z6 = function(e) {
  Kn(r, e);
  function r(t, n) {
    var a = e.call(this) || this;
    return a.destination = t, a.source = n, a;
  }
  return r.prototype.next = function(t) {
    var n, a;
    (a = (n = this.destination) === null || n === void 0 ? void 0 : n.next) === null || a === void 0 || a.call(n, t);
  }, r.prototype.error = function(t) {
    var n, a;
    (a = (n = this.destination) === null || n === void 0 ? void 0 : n.error) === null || a === void 0 || a.call(n, t);
  }, r.prototype.complete = function() {
    var t, n;
    (n = (t = this.destination) === null || t === void 0 ? void 0 : t.complete) === null || n === void 0 || n.call(t);
  }, r.prototype._subscribe = function(t) {
    var n, a;
    return (a = (n = this.source) === null || n === void 0 ? void 0 : n.subscribe(t)) !== null && a !== void 0 ? a : oU;
  }, r;
}(Sa), hU = function(e) {
  Kn(r, e);
  function r(t) {
    var n = e.call(this) || this;
    return n._value = t, n;
  }
  return Object.defineProperty(r.prototype, "value", {
    get: function() {
      return this.getValue();
    },
    enumerable: !1,
    configurable: !0
  }), r.prototype._subscribe = function(t) {
    var n = e.prototype._subscribe.call(this, t);
    return !n.closed && t.next(this._value), n;
  }, r.prototype.getValue = function() {
    var t = this, n = t.hasError, a = t.thrownError, i = t._value;
    if (n)
      throw a;
    return this._throwIfClosed(), i;
  }, r.prototype.next = function(t) {
    e.prototype.next.call(this, this._value = t);
  }, r;
}(Sa), W3 = {
  now: function() {
    return (W3.delegate || Date).now();
  },
  delegate: void 0
}, Ww = function(e) {
  Kn(r, e);
  function r(t, n, a) {
    t === void 0 && (t = 1 / 0), n === void 0 && (n = 1 / 0), a === void 0 && (a = W3);
    var i = e.call(this) || this;
    return i._bufferSize = t, i._windowTime = n, i._timestampProvider = a, i._buffer = [], i._infiniteTimeWindow = !0, i._infiniteTimeWindow = n === 1 / 0, i._bufferSize = Math.max(1, t), i._windowTime = Math.max(1, n), i;
  }
  return r.prototype.next = function(t) {
    var n = this, a = n.isStopped, i = n._buffer, o = n._infiniteTimeWindow, c = n._timestampProvider, s = n._windowTime;
    a || (i.push(t), !o && i.push(c.now() + s)), this._trimBuffer(), e.prototype.next.call(this, t);
  }, r.prototype._subscribe = function(t) {
    this._throwIfClosed(), this._trimBuffer();
    for (var n = this._innerSubscribe(t), a = this, i = a._infiniteTimeWindow, o = a._buffer, c = o.slice(), s = 0; s < c.length && !t.closed; s += i ? 1 : 2)
      t.next(c[s]);
    return this._checkFinalizedStatuses(t), n;
  }, r.prototype._trimBuffer = function() {
    var t = this, n = t._bufferSize, a = t._timestampProvider, i = t._buffer, o = t._infiniteTimeWindow, c = (o ? 1 : 2) * n;
    if (n < 1 / 0 && c < i.length && i.splice(0, i.length - c), !o) {
      for (var s = a.now(), u = 0, l = 1; l < i.length && i[l] <= s; l += 2)
        u = l;
      u && i.splice(0, u + 1);
    }
  }, r;
}(Sa), Xw = function(e) {
  Kn(r, e);
  function r() {
    var t = e !== null && e.apply(this, arguments) || this;
    return t._value = null, t._hasValue = !1, t._isComplete = !1, t;
  }
  return r.prototype._checkFinalizedStatuses = function(t) {
    var n = this, a = n.hasError, i = n._hasValue, o = n._value, c = n.thrownError, s = n.isStopped, u = n._isComplete;
    a ? t.error(c) : (s || u) && (i && t.next(o), t.complete());
  }, r.prototype.next = function(t) {
    this.isStopped || (this._value = t, this._hasValue = !0);
  }, r.prototype.complete = function() {
    var t = this, n = t._hasValue, a = t._value, i = t._isComplete;
    i || (this._isComplete = !0, n && e.prototype.next.call(this, a), e.prototype.complete.call(this));
  }, r;
}(Sa), qZ = function(e) {
  Kn(r, e);
  function r(t, n) {
    return e.call(this) || this;
  }
  return r.prototype.schedule = function(t, n) {
    return this;
  }, r;
}(Wi), jP = {
  setInterval: function() {
    for (var e = [], r = 0; r < arguments.length; r++)
      e[r] = arguments[r];
    return setInterval.apply(void 0, $t([], jt(e)));
  },
  clearInterval: function(e) {
    var r = jP.delegate;
    return ((r == null ? void 0 : r.clearInterval) || clearInterval)(e);
  },
  delegate: void 0
}, Xg = function(e) {
  Kn(r, e);
  function r(t, n) {
    var a = e.call(this, t, n) || this;
    return a.scheduler = t, a.work = n, a.pending = !1, a;
  }
  return r.prototype.schedule = function(t, n) {
    if (n === void 0 && (n = 0), this.closed)
      return this;
    this.state = t;
    var a = this.id, i = this.scheduler;
    return a != null && (this.id = this.recycleAsyncId(i, a, n)), this.pending = !0, this.delay = n, this.id = this.id || this.requestAsyncId(i, this.id, n), this;
  }, r.prototype.requestAsyncId = function(t, n, a) {
    return a === void 0 && (a = 0), jP.setInterval(t.flush.bind(t, this), a);
  }, r.prototype.recycleAsyncId = function(t, n, a) {
    if (a === void 0 && (a = 0), a != null && this.delay === a && this.pending === !1)
      return n;
    jP.clearInterval(n);
  }, r.prototype.execute = function(t, n) {
    if (this.closed)
      return new Error("executing a cancelled action");
    this.pending = !1;
    var a = this._execute(t, n);
    if (a)
      return a;
    this.pending === !1 && this.id != null && (this.id = this.recycleAsyncId(this.scheduler, this.id, null));
  }, r.prototype._execute = function(t, n) {
    var a = !1, i;
    try {
      this.work(t);
    } catch (o) {
      a = !0, i = o || new Error("Scheduled action threw falsy error");
    }
    if (a)
      return this.unsubscribe(), i;
  }, r.prototype.unsubscribe = function() {
    if (!this.closed) {
      var t = this, n = t.id, a = t.scheduler, i = a.actions;
      this.work = this.state = this.scheduler = null, this.pending = !1, dc(i, this), n != null && (this.id = this.recycleAsyncId(a, n, null)), this.delay = null, e.prototype.unsubscribe.call(this);
    }
  }, r;
}(qZ), HZ = 1, Nx, $P = {};
function G6(e) {
  return e in $P ? (delete $P[e], !0) : !1;
}
var gU = {
  setImmediate: function(e) {
    var r = HZ++;
    return $P[r] = !0, Nx || (Nx = Promise.resolve()), Nx.then(function() {
      return G6(r) && e();
    }), r;
  },
  clearImmediate: function(e) {
    G6(e);
  }
}, jZ = gU.setImmediate, $Z = gU.clearImmediate, KP = {
  setImmediate: function() {
    for (var e = [], r = 0; r < arguments.length; r++)
      e[r] = arguments[r];
    return jZ.apply(void 0, $t([], jt(e)));
  },
  clearImmediate: function(e) {
    var r = KP.delegate;
    return ((r == null ? void 0 : r.clearImmediate) || $Z)(e);
  },
  delegate: void 0
}, KZ = function(e) {
  Kn(r, e);
  function r(t, n) {
    var a = e.call(this, t, n) || this;
    return a.scheduler = t, a.work = n, a;
  }
  return r.prototype.requestAsyncId = function(t, n, a) {
    return a === void 0 && (a = 0), a !== null && a > 0 ? e.prototype.requestAsyncId.call(this, t, n, a) : (t.actions.push(this), t._scheduled || (t._scheduled = KP.setImmediate(t.flush.bind(t, void 0))));
  }, r.prototype.recycleAsyncId = function(t, n, a) {
    if (a === void 0 && (a = 0), a != null && a > 0 || a == null && this.delay > 0)
      return e.prototype.recycleAsyncId.call(this, t, n, a);
    t.actions.some(function(i) {
      return i.id === n;
    }) || (KP.clearImmediate(n), t._scheduled = void 0);
  }, r;
}(Xg), WP = function() {
  function e(r, t) {
    t === void 0 && (t = e.now), this.schedulerActionCtor = r, this.now = t;
  }
  return e.prototype.schedule = function(r, t, n) {
    return t === void 0 && (t = 0), new this.schedulerActionCtor(this, r).schedule(n, t);
  }, e.now = W3.now, e;
}(), Yg = function(e) {
  Kn(r, e);
  function r(t, n) {
    n === void 0 && (n = WP.now);
    var a = e.call(this, t, n) || this;
    return a.actions = [], a._active = !1, a._scheduled = void 0, a;
  }
  return r.prototype.flush = function(t) {
    var n = this.actions;
    if (this._active) {
      n.push(t);
      return;
    }
    var a;
    this._active = !0;
    do
      if (a = t.execute(t.state, t.delay))
        break;
    while (t = n.shift());
    if (this._active = !1, a) {
      for (; t = n.shift(); )
        t.unsubscribe();
      throw a;
    }
  }, r;
}(WP), WZ = function(e) {
  Kn(r, e);
  function r() {
    return e !== null && e.apply(this, arguments) || this;
  }
  return r.prototype.flush = function(t) {
    this._active = !0;
    var n = this._scheduled;
    this._scheduled = void 0;
    var a = this.actions, i;
    t = t || a.shift();
    do
      if (i = t.execute(t.state, t.delay))
        break;
    while ((t = a[0]) && t.id === n && a.shift());
    if (this._active = !1, i) {
      for (; (t = a[0]) && t.id === n && a.shift(); )
        t.unsubscribe();
      throw i;
    }
  }, r;
}(Yg), yU = new WZ(KZ), XZ = yU, Bu = new Yg(Xg), Yw = Bu, YZ = function(e) {
  Kn(r, e);
  function r(t, n) {
    var a = e.call(this, t, n) || this;
    return a.scheduler = t, a.work = n, a;
  }
  return r.prototype.schedule = function(t, n) {
    return n === void 0 && (n = 0), n > 0 ? e.prototype.schedule.call(this, t, n) : (this.delay = n, this.state = t, this.scheduler.flush(this), this);
  }, r.prototype.execute = function(t, n) {
    return n > 0 || this.closed ? e.prototype.execute.call(this, t, n) : this._execute(t, n);
  }, r.prototype.requestAsyncId = function(t, n, a) {
    return a === void 0 && (a = 0), a != null && a > 0 || a == null && this.delay > 0 ? e.prototype.requestAsyncId.call(this, t, n, a) : t.flush(this);
  }, r;
}(Xg), QZ = function(e) {
  Kn(r, e);
  function r() {
    return e !== null && e.apply(this, arguments) || this;
  }
  return r;
}(Yg), _U = new QZ(YZ), ZZ = _U, JZ = function(e) {
  Kn(r, e);
  function r(t, n) {
    var a = e.call(this, t, n) || this;
    return a.scheduler = t, a.work = n, a;
  }
  return r.prototype.requestAsyncId = function(t, n, a) {
    return a === void 0 && (a = 0), a !== null && a > 0 ? e.prototype.requestAsyncId.call(this, t, n, a) : (t.actions.push(this), t._scheduled || (t._scheduled = yg.requestAnimationFrame(function() {
      return t.flush(void 0);
    })));
  }, r.prototype.recycleAsyncId = function(t, n, a) {
    if (a === void 0 && (a = 0), a != null && a > 0 || a == null && this.delay > 0)
      return e.prototype.recycleAsyncId.call(this, t, n, a);
    t.actions.some(function(i) {
      return i.id === n;
    }) || (yg.cancelAnimationFrame(n), t._scheduled = void 0);
  }, r;
}(Xg), eJ = function(e) {
  Kn(r, e);
  function r() {
    return e !== null && e.apply(this, arguments) || this;
  }
  return r.prototype.flush = function(t) {
    this._active = !0;
    var n = this._scheduled;
    this._scheduled = void 0;
    var a = this.actions, i;
    t = t || a.shift();
    do
      if (i = t.execute(t.state, t.delay))
        break;
    while ((t = a[0]) && t.id === n && a.shift());
    if (this._active = !1, i) {
      for (; (t = a[0]) && t.id === n && a.shift(); )
        t.unsubscribe();
      throw i;
    }
  }, r;
}(Yg), bU = new eJ(JZ), rJ = bU, tJ = function(e) {
  Kn(r, e);
  function r(t, n) {
    t === void 0 && (t = SU), n === void 0 && (n = 1 / 0);
    var a = e.call(this, t, function() {
      return a.frame;
    }) || this;
    return a.maxFrames = n, a.frame = 0, a.index = -1, a;
  }
  return r.prototype.flush = function() {
    for (var t = this, n = t.actions, a = t.maxFrames, i, o; (o = n[0]) && o.delay <= a && (n.shift(), this.frame = o.delay, !(i = o.execute(o.state, o.delay))); )
      ;
    if (i) {
      for (; o = n.shift(); )
        o.unsubscribe();
      throw i;
    }
  }, r.frameTimeFactor = 10, r;
}(Yg), SU = function(e) {
  Kn(r, e);
  function r(t, n, a) {
    a === void 0 && (a = t.index += 1);
    var i = e.call(this, t, n) || this;
    return i.scheduler = t, i.work = n, i.index = a, i.active = !0, i.index = t.index = a, i;
  }
  return r.prototype.schedule = function(t, n) {
    if (n === void 0 && (n = 0), Number.isFinite(n)) {
      if (!this.id)
        return e.prototype.schedule.call(this, t, n);
      this.active = !1;
      var a = new r(this.scheduler, this.work);
      return this.add(a), a.schedule(t, n);
    } else
      return Wi.EMPTY;
  }, r.prototype.requestAsyncId = function(t, n, a) {
    a === void 0 && (a = 0), this.delay = t.frame + a;
    var i = t.actions;
    return i.push(this), i.sort(r.sortActions), !0;
  }, r.prototype.recycleAsyncId = function(t, n, a) {
  }, r.prototype._execute = function(t, n) {
    if (this.active === !0)
      return e.prototype._execute.call(this, t, n);
  }, r.sortActions = function(t, n) {
    return t.delay === n.delay ? t.index === n.index ? 0 : t.index > n.index ? 1 : -1 : t.delay > n.delay ? 1 : -1;
  }, r;
}(Xg), fs = new mt(function(e) {
  return e.complete();
});
function nJ(e) {
  return e ? aJ(e) : fs;
}
function aJ(e) {
  return new mt(function(r) {
    return e.schedule(function() {
      return r.complete();
    });
  });
}
function X3(e) {
  return e && Ur(e.schedule);
}
function Qw(e) {
  return e[e.length - 1];
}
function Qg(e) {
  return Ur(Qw(e)) ? e.pop() : void 0;
}
function Sc(e) {
  return X3(Qw(e)) ? e.pop() : void 0;
}
function CU(e, r) {
  return typeof Qw(e) == "number" ? e.pop() : r;
}
var Zw = function(e) {
  return e && typeof e.length == "number" && typeof e != "function";
};
function AU(e) {
  return Ur(e == null ? void 0 : e.then);
}
function xU(e) {
  return Ur(e[$3]);
}
function TU(e) {
  return Symbol.asyncIterator && Ur(e == null ? void 0 : e[Symbol.asyncIterator]);
}
function PU(e) {
  return new TypeError("You provided " + (e !== null && typeof e == "object" ? "an invalid object" : "'" + e + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
}
function iJ() {
  return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
}
var MU = iJ();
function wU(e) {
  return Ur(e == null ? void 0 : e[MU]);
}
function EU(e) {
  return BZ(this, arguments, function() {
    var t, n, a, i;
    return Hw(this, function(o) {
      switch (o.label) {
        case 0:
          t = e.getReader(), o.label = 1;
        case 1:
          o.trys.push([1, , 9, 10]), o.label = 2;
        case 2:
          return [4, lv(t.read())];
        case 3:
          return n = o.sent(), a = n.value, i = n.done, i ? [4, lv(void 0)] : [3, 5];
        case 4:
          return [2, o.sent()];
        case 5:
          return [4, lv(a)];
        case 6:
          return [4, o.sent()];
        case 7:
          return o.sent(), [3, 2];
        case 8:
          return [3, 10];
        case 9:
          return t.releaseLock(), [7];
        case 10:
          return [2];
      }
    });
  });
}
function DU(e) {
  return Ur(e == null ? void 0 : e.getReader);
}
function et(e) {
  if (e instanceof mt)
    return e;
  if (e != null) {
    if (xU(e))
      return oJ(e);
    if (Zw(e))
      return uJ(e);
    if (AU(e))
      return sJ(e);
    if (TU(e))
      return IU(e);
    if (wU(e))
      return lJ(e);
    if (DU(e))
      return cJ(e);
  }
  throw PU(e);
}
function oJ(e) {
  return new mt(function(r) {
    var t = e[$3]();
    if (Ur(t.subscribe))
      return t.subscribe(r);
    throw new TypeError("Provided object does not correctly implement Symbol.observable");
  });
}
function uJ(e) {
  return new mt(function(r) {
    for (var t = 0; t < e.length && !r.closed; t++)
      r.next(e[t]);
    r.complete();
  });
}
function sJ(e) {
  return new mt(function(r) {
    e.then(function(t) {
      r.closed || (r.next(t), r.complete());
    }, function(t) {
      return r.error(t);
    }).then(null, sU);
  });
}
function lJ(e) {
  return new mt(function(r) {
    var t, n;
    try {
      for (var a = bo(e), i = a.next(); !i.done; i = a.next()) {
        var o = i.value;
        if (r.next(o), r.closed)
          return;
      }
    } catch (c) {
      t = { error: c };
    } finally {
      try {
        i && !i.done && (n = a.return) && n.call(a);
      } finally {
        if (t) throw t.error;
      }
    }
    r.complete();
  });
}
function IU(e) {
  return new mt(function(r) {
    dJ(e, r).catch(function(t) {
      return r.error(t);
    });
  });
}
function cJ(e) {
  return IU(EU(e));
}
function dJ(e, r) {
  var t, n, a, i;
  return IZ(this, void 0, void 0, function() {
    var o, c;
    return Hw(this, function(s) {
      switch (s.label) {
        case 0:
          s.trys.push([0, 5, 6, 11]), t = NZ(e), s.label = 1;
        case 1:
          return [4, t.next()];
        case 2:
          if (n = s.sent(), !!n.done) return [3, 4];
          if (o = n.value, r.next(o), r.closed)
            return [2];
          s.label = 3;
        case 3:
          return [3, 1];
        case 4:
          return [3, 11];
        case 5:
          return c = s.sent(), a = { error: c }, [3, 11];
        case 6:
          return s.trys.push([6, , 9, 10]), n && !n.done && (i = t.return) ? [4, i.call(t)] : [3, 8];
        case 7:
          s.sent(), s.label = 8;
        case 8:
          return [3, 10];
        case 9:
          if (a) throw a.error;
          return [7];
        case 10:
          return [7];
        case 11:
          return r.complete(), [2];
      }
    });
  });
}
function So(e, r, t, n, a) {
  n === void 0 && (n = 0), a === void 0 && (a = !1);
  var i = r.schedule(function() {
    t(), a ? e.add(this.schedule(null, n)) : this.unsubscribe();
  }, n);
  if (e.add(i), !a)
    return i;
}
function Y3(e, r) {
  return r === void 0 && (r = 0), rr(function(t, n) {
    t.subscribe(new Ze(n, function(a) {
      return So(n, e, function() {
        return n.next(a);
      }, r);
    }, function() {
      return So(n, e, function() {
        return n.complete();
      }, r);
    }, function(a) {
      return So(n, e, function() {
        return n.error(a);
      }, r);
    }));
  });
}
function Q3(e, r) {
  return r === void 0 && (r = 0), rr(function(t, n) {
    n.add(e.schedule(function() {
      return t.subscribe(n);
    }, r));
  });
}
function fJ(e, r) {
  return et(e).pipe(Q3(r), Y3(r));
}
function mJ(e, r) {
  return et(e).pipe(Q3(r), Y3(r));
}
function vJ(e, r) {
  return new mt(function(t) {
    var n = 0;
    return r.schedule(function() {
      n === e.length ? t.complete() : (t.next(e[n++]), t.closed || this.schedule());
    });
  });
}
function BU(e, r) {
  return new mt(function(t) {
    var n;
    return So(t, r, function() {
      n = e[MU](), So(t, r, function() {
        var a, i, o;
        try {
          a = n.next(), i = a.value, o = a.done;
        } catch (c) {
          t.error(c);
          return;
        }
        o ? t.complete() : t.next(i);
      }, 0, !0);
    }), function() {
      return Ur(n == null ? void 0 : n.return) && n.return();
    };
  });
}
function NU(e, r) {
  if (!e)
    throw new Error("Iterable cannot be null");
  return new mt(function(t) {
    So(t, r, function() {
      var n = e[Symbol.asyncIterator]();
      So(t, r, function() {
        n.next().then(function(a) {
          a.done ? t.complete() : t.next(a.value);
        });
      }, 0, !0);
    });
  });
}
function pJ(e, r) {
  return NU(EU(e), r);
}
function VU(e, r) {
  if (e != null) {
    if (xU(e))
      return fJ(e, r);
    if (Zw(e))
      return vJ(e, r);
    if (AU(e))
      return mJ(e, r);
    if (TU(e))
      return NU(e, r);
    if (wU(e))
      return BU(e, r);
    if (DU(e))
      return pJ(e, r);
  }
  throw PU(e);
}
function ms(e, r) {
  return r ? VU(e, r) : et(e);
}
function Jw() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  var t = Sc(e);
  return ms(e, t);
}
function RU(e, r) {
  var t = Ur(e) ? e : function() {
    return e;
  }, n = function(a) {
    return a.error(t());
  };
  return new mt(r ? function(a) {
    return r.schedule(n, 0, a);
  } : n);
}
var XP;
(function(e) {
  e.NEXT = "N", e.ERROR = "E", e.COMPLETE = "C";
})(XP || (XP = {}));
var W_ = function() {
  function e(r, t, n) {
    this.kind = r, this.value = t, this.error = n, this.hasValue = r === "N";
  }
  return e.prototype.observe = function(r) {
    return OU(this, r);
  }, e.prototype.do = function(r, t, n) {
    var a = this, i = a.kind, o = a.value, c = a.error;
    return i === "N" ? r == null ? void 0 : r(o) : i === "E" ? t == null ? void 0 : t(c) : n == null ? void 0 : n();
  }, e.prototype.accept = function(r, t, n) {
    var a;
    return Ur((a = r) === null || a === void 0 ? void 0 : a.next) ? this.observe(r) : this.do(r, t, n);
  }, e.prototype.toObservable = function() {
    var r = this, t = r.kind, n = r.value, a = r.error, i = t === "N" ? Jw(n) : t === "E" ? RU(function() {
      return a;
    }) : t === "C" ? fs : 0;
    if (!i)
      throw new TypeError("Unexpected notification kind " + t);
    return i;
  }, e.createNext = function(r) {
    return new e("N", r);
  }, e.createError = function(r) {
    return new e("E", void 0, r);
  }, e.createComplete = function() {
    return e.completeNotification;
  }, e.completeNotification = new e("C"), e;
}();
function OU(e, r) {
  var t, n, a, i = e, o = i.kind, c = i.value, s = i.error;
  if (typeof o != "string")
    throw new TypeError('Invalid notification, missing "kind"');
  o === "N" ? (t = r.next) === null || t === void 0 || t.call(r, c) : o === "E" ? (n = r.error) === null || n === void 0 || n.call(r, s) : (a = r.complete) === null || a === void 0 || a.call(r);
}
function hJ(e) {
  return !!e && (e instanceof mt || Ur(e.lift) && Ur(e.subscribe));
}
var P0 = T0(function(e) {
  return function() {
    e(this), this.name = "EmptyError", this.message = "no elements in sequence";
  };
});
function gJ(e, r) {
  var t = typeof r == "object";
  return new Promise(function(n, a) {
    var i = !1, o;
    e.subscribe({
      next: function(c) {
        o = c, i = !0;
      },
      error: a,
      complete: function() {
        i ? n(o) : t ? n(r.defaultValue) : a(new P0());
      }
    });
  });
}
function yJ(e, r) {
  var t = typeof r == "object";
  return new Promise(function(n, a) {
    var i = new gg({
      next: function(o) {
        n(o), i.unsubscribe();
      },
      error: a,
      complete: function() {
        t ? n(r.defaultValue) : a(new P0());
      }
    });
    e.subscribe(i);
  });
}
var YP = T0(function(e) {
  return function() {
    e(this), this.name = "ArgumentOutOfRangeError", this.message = "argument out of range";
  };
}), FU = T0(function(e) {
  return function(t) {
    e(this), this.name = "NotFoundError", this.message = t;
  };
}), LU = T0(function(e) {
  return function(t) {
    e(this), this.name = "SequenceError", this.message = t;
  };
});
function eE(e) {
  return e instanceof Date && !isNaN(e);
}
var kU = T0(function(e) {
  return function(t) {
    t === void 0 && (t = null), e(this), this.message = "Timeout has occurred", this.name = "TimeoutError", this.info = t;
  };
});
function UU(e, r) {
  var t = eE(e) ? { first: e } : typeof e == "number" ? { each: e } : e, n = t.first, a = t.each, i = t.with, o = i === void 0 ? _J : i, c = t.scheduler, s = c === void 0 ? r ?? Bu : c, u = t.meta, l = u === void 0 ? null : u;
  if (n == null && a == null)
    throw new TypeError("No timeout provided.");
  return rr(function(f, d) {
    var m, p, v = null, h = 0, y = function(C) {
      p = So(d, s, function() {
        try {
          m.unsubscribe(), et(o({
            meta: l,
            lastValue: v,
            seen: h
          })).subscribe(d);
        } catch (S) {
          d.error(S);
        }
      }, C);
    };
    m = f.subscribe(new Ze(d, function(C) {
      p == null || p.unsubscribe(), h++, d.next(v = C), a > 0 && y(a);
    }, void 0, void 0, function() {
      p != null && p.closed || p == null || p.unsubscribe(), v = null;
    })), y(n != null ? typeof n == "number" ? n : +n - s.now() : a);
  });
}
function _J(e) {
  throw new kU(e);
}
function zd(e, r) {
  return rr(function(t, n) {
    var a = 0;
    t.subscribe(new Ze(n, function(i) {
      n.next(e.call(r, i, a++));
    }));
  });
}
var bJ = Array.isArray;
function SJ(e, r) {
  return bJ(r) ? e.apply(void 0, $t([], jt(r))) : e(r);
}
function M0(e) {
  return zd(function(r) {
    return SJ(e, r);
  });
}
function _b(e, r, t, n) {
  if (t)
    if (X3(t))
      n = t;
    else
      return function() {
        for (var a = [], i = 0; i < arguments.length; i++)
          a[i] = arguments[i];
        return _b(e, r, n).apply(this, a).pipe(M0(t));
      };
  return n ? function() {
    for (var a = [], i = 0; i < arguments.length; i++)
      a[i] = arguments[i];
    return _b(e, r).apply(this, a).pipe(Q3(n), Y3(n));
  } : function() {
    for (var a = this, i = [], o = 0; o < arguments.length; o++)
      i[o] = arguments[o];
    var c = new Xw(), s = !0;
    return new mt(function(u) {
      var l = c.subscribe(u);
      if (s) {
        s = !1;
        var f = !1, d = !1;
        r.apply(a, $t($t([], jt(i)), [
          function() {
            for (var m = [], p = 0; p < arguments.length; p++)
              m[p] = arguments[p];
            if (e) {
              var v = m.shift();
              if (v != null) {
                c.error(v);
                return;
              }
            }
            c.next(1 < m.length ? m : m[0]), d = !0, f && c.complete();
          }
        ])), d && c.complete(), f = !0;
      }
      return l;
    });
  };
}
function CJ(e, r, t) {
  return _b(!1, e, r, t);
}
function AJ(e, r, t) {
  return _b(!0, e, r, t);
}
var xJ = Array.isArray, TJ = Object.getPrototypeOf, PJ = Object.prototype, MJ = Object.keys;
function zU(e) {
  if (e.length === 1) {
    var r = e[0];
    if (xJ(r))
      return { args: r, keys: null };
    if (wJ(r)) {
      var t = MJ(r);
      return {
        args: t.map(function(n) {
          return r[n];
        }),
        keys: t
      };
    }
  }
  return { args: e, keys: null };
}
function wJ(e) {
  return e && typeof e == "object" && TJ(e) === PJ;
}
function GU(e, r) {
  return e.reduce(function(t, n, a) {
    return t[n] = r[a], t;
  }, {});
}
function qU() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  var t = Sc(e), n = Qg(e), a = zU(e), i = a.args, o = a.keys;
  if (i.length === 0)
    return ms([], t);
  var c = new mt(HU(i, t, o ? function(s) {
    return GU(o, s);
  } : ni));
  return n ? c.pipe(M0(n)) : c;
}
function HU(e, r, t) {
  return t === void 0 && (t = ni), function(n) {
    q6(r, function() {
      for (var a = e.length, i = new Array(a), o = a, c = a, s = function(l) {
        q6(r, function() {
          var f = ms(e[l], r), d = !1;
          f.subscribe(new Ze(n, function(m) {
            i[l] = m, d || (d = !0, c--), c || n.next(t(i.slice()));
          }, function() {
            --o || n.complete();
          }));
        }, n);
      }, u = 0; u < a; u++)
        s(u);
    }, n);
  };
}
function q6(e, r, t) {
  e ? So(t, e, r) : r();
}
function rE(e, r, t, n, a, i, o, c) {
  var s = [], u = 0, l = 0, f = !1, d = function() {
    f && !s.length && !u && r.complete();
  }, m = function(v) {
    return u < n ? p(v) : s.push(v);
  }, p = function(v) {
    i && r.next(v), u++;
    var h = !1;
    et(t(v, l++)).subscribe(new Ze(r, function(y) {
      a == null || a(y), i ? m(y) : r.next(y);
    }, function() {
      h = !0;
    }, void 0, function() {
      if (h)
        try {
          u--;
          for (var y = function() {
            var C = s.shift();
            o ? So(r, o, function() {
              return p(C);
            }) : p(C);
          }; s.length && u < n; )
            y();
          d();
        } catch (C) {
          r.error(C);
        }
    }));
  };
  return e.subscribe(new Ze(r, m, function() {
    f = !0, d();
  })), function() {
    c == null || c();
  };
}
function os(e, r, t) {
  return t === void 0 && (t = 1 / 0), Ur(r) ? os(function(n, a) {
    return zd(function(i, o) {
      return r(n, i, a, o);
    })(et(e(n, a)));
  }, t) : (typeof r == "number" && (t = r), rr(function(n, a) {
    return rE(n, a, e, t);
  }));
}
function Z3(e) {
  return e === void 0 && (e = 1 / 0), os(ni, e);
}
function tE() {
  return Z3(1);
}
function _g() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  return tE()(ms(e, Sc(e)));
}
function Zg(e) {
  return new mt(function(r) {
    et(e()).subscribe(r);
  });
}
var EJ = {
  connector: function() {
    return new Sa();
  },
  resetOnDisconnect: !0
};
function DJ(e, r) {
  r === void 0 && (r = EJ);
  var t = null, n = r.connector, a = r.resetOnDisconnect, i = a === void 0 ? !0 : a, o = n(), c = new mt(function(s) {
    return o.subscribe(s);
  });
  return c.connect = function() {
    return (!t || t.closed) && (t = Zg(function() {
      return e;
    }).subscribe(o), i && t.add(function() {
      return o = n();
    })), t;
  }, c;
}
function IJ() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  var t = Qg(e), n = zU(e), a = n.args, i = n.keys, o = new mt(function(c) {
    var s = a.length;
    if (!s) {
      c.complete();
      return;
    }
    for (var u = new Array(s), l = s, f = s, d = function(p) {
      var v = !1;
      et(a[p]).subscribe(new Ze(c, function(h) {
        v || (v = !0, f--), u[p] = h;
      }, function() {
        return l--;
      }, void 0, function() {
        (!l || !v) && (f || c.next(i ? GU(i, u) : u), c.complete());
      }));
    }, m = 0; m < s; m++)
      d(m);
  });
  return t ? o.pipe(M0(t)) : o;
}
var BJ = ["addListener", "removeListener"], NJ = ["addEventListener", "removeEventListener"], VJ = ["on", "off"];
function QP(e, r, t, n) {
  if (Ur(t) && (n = t, t = void 0), n)
    return QP(e, r, t).pipe(M0(n));
  var a = jt(FJ(e) ? NJ.map(function(c) {
    return function(s) {
      return e[c](r, s, t);
    };
  }) : RJ(e) ? BJ.map(H6(e, r)) : OJ(e) ? VJ.map(H6(e, r)) : [], 2), i = a[0], o = a[1];
  if (!i && Zw(e))
    return os(function(c) {
      return QP(c, r, t);
    })(et(e));
  if (!i)
    throw new TypeError("Invalid event target");
  return new mt(function(c) {
    var s = function() {
      for (var u = [], l = 0; l < arguments.length; l++)
        u[l] = arguments[l];
      return c.next(1 < u.length ? u : u[0]);
    };
    return i(s), function() {
      return o(s);
    };
  });
}
function H6(e, r) {
  return function(t) {
    return function(n) {
      return e[t](r, n);
    };
  };
}
function RJ(e) {
  return Ur(e.addListener) && Ur(e.removeListener);
}
function OJ(e) {
  return Ur(e.on) && Ur(e.off);
}
function FJ(e) {
  return Ur(e.addEventListener) && Ur(e.removeEventListener);
}
function jU(e, r, t) {
  return t ? jU(e, r).pipe(M0(t)) : new mt(function(n) {
    var a = function() {
      for (var o = [], c = 0; c < arguments.length; c++)
        o[c] = arguments[c];
      return n.next(o.length === 1 ? o[0] : o);
    }, i = e(a);
    return Ur(r) ? function() {
      return r(a, i);
    } : void 0;
  });
}
function LJ(e, r, t, n, a) {
  var i, o, c, s;
  arguments.length === 1 ? (i = e, s = i.initialState, r = i.condition, t = i.iterate, o = i.resultSelector, c = o === void 0 ? ni : o, a = i.scheduler) : (s = e, !n || X3(n) ? (c = ni, a = n) : c = n);
  function u() {
    var l;
    return Hw(this, function(f) {
      switch (f.label) {
        case 0:
          l = s, f.label = 1;
        case 1:
          return !r || r(l) ? [4, c(l)] : [3, 4];
        case 2:
          f.sent(), f.label = 3;
        case 3:
          return l = t(l), [3, 1];
        case 4:
          return [2];
      }
    });
  }
  return Zg(a ? function() {
    return BU(u(), a);
  } : u);
}
function kJ(e, r, t) {
  return Zg(function() {
    return e() ? r : t;
  });
}
function w0(e, r, t) {
  e === void 0 && (e = 0), t === void 0 && (t = Yw);
  var n = -1;
  return r != null && (X3(r) ? t = r : n = r), new mt(function(a) {
    var i = eE(e) ? +e - t.now() : e;
    i < 0 && (i = 0);
    var o = 0;
    return t.schedule(function() {
      a.closed || (a.next(o++), 0 <= n ? this.schedule(void 0, n) : a.complete());
    }, i);
  });
}
function $U(e, r) {
  return e === void 0 && (e = 0), r === void 0 && (r = Bu), e < 0 && (e = 0), w0(e, e, r);
}
function UJ() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  var t = Sc(e), n = CU(e, 1 / 0), a = e;
  return a.length ? a.length === 1 ? et(a[0]) : Z3(n)(ms(a, t)) : fs;
}
var KU = new mt(Ln);
function zJ() {
  return KU;
}
var GJ = Array.isArray;
function _p(e) {
  return e.length === 1 && GJ(e[0]) ? e[0] : e;
}
function qJ() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  var t = _p(e);
  return rr(function(n, a) {
    var i = $t([n], jt(t)), o = function() {
      if (!a.closed)
        if (i.length > 0) {
          var c = void 0;
          try {
            c = et(i.shift());
          } catch {
            o();
            return;
          }
          var s = new Ze(a, void 0, Ln, Ln);
          a.add(c.subscribe(s)), s.add(o);
        } else
          a.complete();
    };
    o();
  });
}
function HJ() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  return qJ(_p(e))(fs);
}
function jJ(e, r) {
  return ms(Object.entries(e), r);
}
function $J(e, r) {
  return function(t, n) {
    return !e.call(r, t, n);
  };
}
function u0(e, r) {
  return rr(function(t, n) {
    var a = 0;
    t.subscribe(new Ze(n, function(i) {
      return e.call(r, i, a++) && n.next(i);
    }));
  });
}
function KJ(e, r, t) {
  return [u0(r, t)(et(e)), u0($J(r, t))(et(e))];
}
function WJ() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  return e = _p(e), e.length === 1 ? et(e[0]) : new mt(WU(e));
}
function WU(e) {
  return function(r) {
    for (var t = [], n = function(i) {
      t.push(et(e[i]).subscribe(new Ze(r, function(o) {
        if (t) {
          for (var c = 0; c < t.length; c++)
            c !== i && t[c].unsubscribe();
          t = null;
        }
        r.next(o);
      })));
    }, a = 0; t && !r.closed && a < e.length; a++)
      n(a);
  };
}
function XJ(e, r, t) {
  if (r == null && (r = e, e = 0), r <= 0)
    return fs;
  var n = r + e;
  return new mt(t ? function(a) {
    var i = e;
    return t.schedule(function() {
      i < n ? (a.next(i++), this.schedule()) : a.complete();
    });
  } : function(a) {
    for (var i = e; i < n && !a.closed; )
      a.next(i++);
    a.complete();
  });
}
function YJ(e, r) {
  return new mt(function(t) {
    var n = e(), a = r(n), i = a ? et(a) : fs;
    return i.subscribe(t), function() {
      n && n.unsubscribe();
    };
  });
}
function nE() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  var t = Qg(e), n = _p(e);
  return n.length ? new mt(function(a) {
    var i = n.map(function() {
      return [];
    }), o = n.map(function() {
      return !1;
    });
    a.add(function() {
      i = o = null;
    });
    for (var c = function(u) {
      et(n[u]).subscribe(new Ze(a, function(l) {
        if (i[u].push(l), i.every(function(d) {
          return d.length;
        })) {
          var f = i.map(function(d) {
            return d.shift();
          });
          a.next(t ? t.apply(void 0, $t([], jt(f))) : f), i.some(function(d, m) {
            return !d.length && o[m];
          }) && a.complete();
        }
      }, function() {
        o[u] = !0, !i[u].length && a.complete();
      }));
    }, s = 0; !a.closed && s < n.length; s++)
      c(s);
    return function() {
      i = o = null;
    };
  }) : fs;
}
function XU(e) {
  return rr(function(r, t) {
    var n = !1, a = null, i = null, o = !1, c = function() {
      if (i == null || i.unsubscribe(), i = null, n) {
        n = !1;
        var u = a;
        a = null, t.next(u);
      }
      o && t.complete();
    }, s = function() {
      i = null, o && t.complete();
    };
    r.subscribe(new Ze(t, function(u) {
      n = !0, a = u, i || et(e(u)).subscribe(i = new Ze(t, c, s));
    }, function() {
      o = !0, (!n || !i || i.closed) && t.complete();
    }));
  });
}
function QJ(e, r) {
  return r === void 0 && (r = Bu), XU(function() {
    return w0(e, r);
  });
}
function ZJ(e) {
  return rr(function(r, t) {
    var n = [];
    return r.subscribe(new Ze(t, function(a) {
      return n.push(a);
    }, function() {
      t.next(n), t.complete();
    })), e.subscribe(new Ze(t, function() {
      var a = n;
      n = [], t.next(a);
    }, Ln)), function() {
      n = null;
    };
  });
}
function JJ(e, r) {
  return r === void 0 && (r = null), r = r ?? e, rr(function(t, n) {
    var a = [], i = 0;
    t.subscribe(new Ze(n, function(o) {
      var c, s, u, l, f = null;
      i++ % r === 0 && a.push([]);
      try {
        for (var d = bo(a), m = d.next(); !m.done; m = d.next()) {
          var p = m.value;
          p.push(o), e <= p.length && (f = f ?? [], f.push(p));
        }
      } catch (y) {
        c = { error: y };
      } finally {
        try {
          m && !m.done && (s = d.return) && s.call(d);
        } finally {
          if (c) throw c.error;
        }
      }
      if (f)
        try {
          for (var v = bo(f), h = v.next(); !h.done; h = v.next()) {
            var p = h.value;
            dc(a, p), n.next(p);
          }
        } catch (y) {
          u = { error: y };
        } finally {
          try {
            h && !h.done && (l = v.return) && l.call(v);
          } finally {
            if (u) throw u.error;
          }
        }
    }, function() {
      var o, c;
      try {
        for (var s = bo(a), u = s.next(); !u.done; u = s.next()) {
          var l = u.value;
          n.next(l);
        }
      } catch (f) {
        o = { error: f };
      } finally {
        try {
          u && !u.done && (c = s.return) && c.call(s);
        } finally {
          if (o) throw o.error;
        }
      }
      n.complete();
    }, void 0, function() {
      a = null;
    }));
  });
}
function eee(e) {
  for (var r, t, n = [], a = 1; a < arguments.length; a++)
    n[a - 1] = arguments[a];
  var i = (r = Sc(n)) !== null && r !== void 0 ? r : Bu, o = (t = n[0]) !== null && t !== void 0 ? t : null, c = n[1] || 1 / 0;
  return rr(function(s, u) {
    var l = [], f = !1, d = function(v) {
      var h = v.buffer, y = v.subs;
      y.unsubscribe(), dc(l, v), u.next(h), f && m();
    }, m = function() {
      if (l) {
        var v = new Wi();
        u.add(v);
        var h = [], y = {
          buffer: h,
          subs: v
        };
        l.push(y), So(v, i, function() {
          return d(y);
        }, e);
      }
    };
    o !== null && o >= 0 ? So(u, i, m, o, !0) : f = !0, m();
    var p = new Ze(u, function(v) {
      var h, y, C = l.slice();
      try {
        for (var S = bo(C), b = S.next(); !b.done; b = S.next()) {
          var g = b.value, _ = g.buffer;
          _.push(v), c <= _.length && d(g);
        }
      } catch (A) {
        h = { error: A };
      } finally {
        try {
          b && !b.done && (y = S.return) && y.call(S);
        } finally {
          if (h) throw h.error;
        }
      }
    }, function() {
      for (; l != null && l.length; )
        u.next(l.shift().buffer);
      p == null || p.unsubscribe(), u.complete(), u.unsubscribe();
    }, void 0, function() {
      return l = null;
    });
    s.subscribe(p);
  });
}
function ree(e, r) {
  return rr(function(t, n) {
    var a = [];
    et(e).subscribe(new Ze(n, function(i) {
      var o = [];
      a.push(o);
      var c = new Wi(), s = function() {
        dc(a, o), n.next(o), c.unsubscribe();
      };
      c.add(et(r(i)).subscribe(new Ze(n, s, Ln)));
    }, Ln)), t.subscribe(new Ze(n, function(i) {
      var o, c;
      try {
        for (var s = bo(a), u = s.next(); !u.done; u = s.next()) {
          var l = u.value;
          l.push(i);
        }
      } catch (f) {
        o = { error: f };
      } finally {
        try {
          u && !u.done && (c = s.return) && c.call(s);
        } finally {
          if (o) throw o.error;
        }
      }
    }, function() {
      for (; a.length > 0; )
        n.next(a.shift());
      n.complete();
    }));
  });
}
function tee(e) {
  return rr(function(r, t) {
    var n = null, a = null, i = function() {
      a == null || a.unsubscribe();
      var o = n;
      n = [], o && t.next(o), et(e()).subscribe(a = new Ze(t, i, Ln));
    };
    i(), r.subscribe(new Ze(t, function(o) {
      return n == null ? void 0 : n.push(o);
    }, function() {
      n && t.next(n), t.complete();
    }, void 0, function() {
      return n = a = null;
    }));
  });
}
function YU(e) {
  return rr(function(r, t) {
    var n = null, a = !1, i;
    n = r.subscribe(new Ze(t, void 0, void 0, function(o) {
      i = et(e(o, YU(e)(r))), n ? (n.unsubscribe(), n = null, i.subscribe(t)) : a = !0;
    })), a && (n.unsubscribe(), n = null, i.subscribe(t));
  });
}
function QU(e, r, t, n, a) {
  return function(i, o) {
    var c = t, s = r, u = 0;
    i.subscribe(new Ze(o, function(l) {
      var f = u++;
      s = c ? e(s, l, f) : (c = !0, l), n && o.next(s);
    }, a && function() {
      c && o.next(s), o.complete();
    }));
  };
}
function Jg(e, r) {
  return rr(QU(e, r, arguments.length >= 2, !1, !0));
}
var nee = function(e, r) {
  return e.push(r), e;
};
function ZU() {
  return rr(function(e, r) {
    Jg(nee, [])(e).subscribe(r);
  });
}
function JU(e, r) {
  return Kw(ZU(), os(function(t) {
    return e(t);
  }), r ? M0(r) : ni);
}
function ez(e) {
  return JU(qU, e);
}
var aee = ez;
function rz() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  var t = Qg(e);
  return t ? Kw(rz.apply(void 0, $t([], jt(e))), M0(t)) : rr(function(n, a) {
    HU($t([n], jt(_p(e))))(a);
  });
}
function iee() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  return rz.apply(void 0, $t([], jt(e)));
}
function ZP(e, r) {
  return Ur(r) ? os(e, r, 1) : os(e, 1);
}
function oee(e, r) {
  return Ur(r) ? ZP(function() {
    return e;
  }, r) : ZP(function() {
    return e;
  });
}
function uee() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  var t = Sc(e);
  return rr(function(n, a) {
    tE()(ms($t([n], jt(e)), t)).subscribe(a);
  });
}
function see() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  return uee.apply(void 0, $t([], jt(e)));
}
function lee(e) {
  return new mt(function(r) {
    return e.subscribe(r);
  });
}
var cee = {
  connector: function() {
    return new Sa();
  }
};
function aE(e, r) {
  r === void 0 && (r = cee);
  var t = r.connector;
  return rr(function(n, a) {
    var i = t();
    ms(e(lee(i))).subscribe(a), a.add(n.subscribe(i));
  });
}
function dee(e) {
  return Jg(function(r, t, n) {
    return !e || e(t, n) ? r + 1 : r;
  }, 0);
}
function fee(e) {
  return rr(function(r, t) {
    var n = !1, a = null, i = null, o = function() {
      if (i == null || i.unsubscribe(), i = null, n) {
        n = !1;
        var c = a;
        a = null, t.next(c);
      }
    };
    r.subscribe(new Ze(t, function(c) {
      i == null || i.unsubscribe(), n = !0, a = c, i = new Ze(t, o, Ln), et(e(c)).subscribe(i);
    }, function() {
      o(), t.complete();
    }, void 0, function() {
      a = i = null;
    }));
  });
}
function mee(e, r) {
  return r === void 0 && (r = Bu), rr(function(t, n) {
    var a = null, i = null, o = null, c = function() {
      if (a) {
        a.unsubscribe(), a = null;
        var u = i;
        i = null, n.next(u);
      }
    };
    function s() {
      var u = o + e, l = r.now();
      if (l < u) {
        a = this.schedule(void 0, u - l), n.add(a);
        return;
      }
      c();
    }
    t.subscribe(new Ze(n, function(u) {
      i = u, o = r.now(), a || (a = r.schedule(s, e), n.add(a));
    }, function() {
      c(), n.complete();
    }, void 0, function() {
      i = a = null;
    }));
  });
}
function J3(e) {
  return rr(function(r, t) {
    var n = !1;
    r.subscribe(new Ze(t, function(a) {
      n = !0, t.next(a);
    }, function() {
      n || t.next(e), t.complete();
    }));
  });
}
function xv(e) {
  return e <= 0 ? function() {
    return fs;
  } : rr(function(r, t) {
    var n = 0;
    r.subscribe(new Ze(t, function(a) {
      ++n <= e && (t.next(a), e <= n && t.complete());
    }));
  });
}
function tz() {
  return rr(function(e, r) {
    e.subscribe(new Ze(r, Ln));
  });
}
function nz(e) {
  return zd(function() {
    return e;
  });
}
function iE(e, r) {
  return r ? function(t) {
    return _g(r.pipe(xv(1), tz()), t.pipe(iE(e)));
  } : os(function(t, n) {
    return e(t, n).pipe(xv(1), nz(t));
  });
}
function vee(e, r) {
  r === void 0 && (r = Bu);
  var t = w0(e, r);
  return iE(function() {
    return t;
  });
}
function pee() {
  return rr(function(e, r) {
    e.subscribe(new Ze(r, function(t) {
      return OU(t, r);
    }));
  });
}
function hee(e, r) {
  return rr(function(t, n) {
    var a = /* @__PURE__ */ new Set();
    t.subscribe(new Ze(n, function(i) {
      var o = e ? e(i) : i;
      a.has(o) || (a.add(o), n.next(i));
    })), r == null || r.subscribe(new Ze(n, function() {
      return a.clear();
    }, Ln));
  });
}
function az(e, r) {
  return r === void 0 && (r = ni), e = e ?? gee, rr(function(t, n) {
    var a, i = !0;
    t.subscribe(new Ze(n, function(o) {
      var c = r(o);
      (i || !e(a, c)) && (i = !1, a = c, n.next(o));
    }));
  });
}
function gee(e, r) {
  return e === r;
}
function yee(e, r) {
  return az(function(t, n) {
    return r ? r(t[e], n[e]) : t[e] === n[e];
  });
}
function eS(e) {
  return e === void 0 && (e = _ee), rr(function(r, t) {
    var n = !1;
    r.subscribe(new Ze(t, function(a) {
      n = !0, t.next(a);
    }, function() {
      return n ? t.complete() : t.error(e());
    }));
  });
}
function _ee() {
  return new P0();
}
function bee(e, r) {
  if (e < 0)
    throw new YP();
  var t = arguments.length >= 2;
  return function(n) {
    return n.pipe(u0(function(a, i) {
      return i === e;
    }), xv(1), t ? J3(r) : eS(function() {
      return new YP();
    }));
  };
}
function See() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  return function(t) {
    return _g(t, Jw.apply(void 0, $t([], jt(e))));
  };
}
function Cee(e, r) {
  return rr(function(t, n) {
    var a = 0;
    t.subscribe(new Ze(n, function(i) {
      e.call(r, i, a++, t) || (n.next(!1), n.complete());
    }, function() {
      n.next(!0), n.complete();
    }));
  });
}
function iz() {
  return rr(function(e, r) {
    var t = !1, n = null;
    e.subscribe(new Ze(r, function(a) {
      n || (n = et(a).subscribe(new Ze(r, void 0, function() {
        n = null, t && r.complete();
      })));
    }, function() {
      t = !0, !n && r.complete();
    }));
  });
}
var Aee = iz;
function oz(e, r) {
  return r ? function(t) {
    return t.pipe(oz(function(n, a) {
      return et(e(n, a)).pipe(zd(function(i, o) {
        return r(n, i, a, o);
      }));
    }));
  } : rr(function(t, n) {
    var a = 0, i = null, o = !1;
    t.subscribe(new Ze(n, function(c) {
      i || (i = new Ze(n, void 0, function() {
        i = null, o && n.complete();
      }), et(e(c, a++)).subscribe(i));
    }, function() {
      o = !0, !i && n.complete();
    }));
  });
}
function xee(e, r, t) {
  return r === void 0 && (r = 1 / 0), r = (r || 0) < 1 ? 1 / 0 : r, rr(function(n, a) {
    return rE(n, a, e, r, void 0, !0, t);
  });
}
function Tee(e) {
  return rr(function(r, t) {
    try {
      r.subscribe(t);
    } finally {
      t.add(e);
    }
  });
}
function Pee(e, r) {
  return rr(uz(e, r, "value"));
}
function uz(e, r, t) {
  var n = t === "index";
  return function(a, i) {
    var o = 0;
    a.subscribe(new Ze(i, function(c) {
      var s = o++;
      e.call(r, c, s, a) && (i.next(n ? s : c), i.complete());
    }, function() {
      i.next(n ? -1 : void 0), i.complete();
    }));
  };
}
function Mee(e, r) {
  return rr(uz(e, r, "index"));
}
function wee(e, r) {
  var t = arguments.length >= 2;
  return function(n) {
    return n.pipe(e ? u0(function(a, i) {
      return e(a, i, n);
    }) : ni, xv(1), t ? J3(r) : eS(function() {
      return new P0();
    }));
  };
}
function Eee(e, r, t, n) {
  return rr(function(a, i) {
    var o;
    !r || typeof r == "function" ? o = r : (t = r.duration, o = r.element, n = r.connector);
    var c = /* @__PURE__ */ new Map(), s = function(d) {
      c.forEach(d), d(i);
    }, u = function(d) {
      return s(function(m) {
        return m.error(d);
      });
    }, l = new Dee(i, function(d) {
      try {
        var m = e(d), p = c.get(m);
        if (!p) {
          c.set(m, p = n ? n() : new Sa());
          var v = f(m, p);
          if (i.next(v), t) {
            var h = new Ze(p, function() {
              p.complete(), h == null || h.unsubscribe();
            }, void 0, void 0, function() {
              return c.delete(m);
            });
            l.add(et(t(v)).subscribe(h));
          }
        }
        p.next(o ? o(d) : d);
      } catch (y) {
        u(y);
      }
    }, function() {
      return s(function(d) {
        return d.complete();
      });
    }, u, function() {
      return c.clear();
    });
    a.subscribe(l);
    function f(d, m) {
      var p = new mt(function(v) {
        l.activeGroups++;
        var h = m.subscribe(v);
        return function() {
          h.unsubscribe(), --l.activeGroups === 0 && l.teardownAttempted && l.unsubscribe();
        };
      });
      return p.key = d, p;
    }
  });
}
var Dee = function(e) {
  Kn(r, e);
  function r() {
    var t = e !== null && e.apply(this, arguments) || this;
    return t.activeGroups = 0, t.teardownAttempted = !1, t;
  }
  return r.prototype.unsubscribe = function() {
    this.teardownAttempted = !0, this.activeGroups === 0 && e.prototype.unsubscribe.call(this);
  }, r;
}(Ze);
function Iee() {
  return rr(function(e, r) {
    e.subscribe(new Ze(r, function() {
      r.next(!1), r.complete();
    }, function() {
      r.next(!0), r.complete();
    }));
  });
}
function sz(e) {
  return e <= 0 ? function() {
    return fs;
  } : rr(function(r, t) {
    var n = [];
    r.subscribe(new Ze(t, function(a) {
      n.push(a), e < n.length && n.shift();
    }, function() {
      var a, i;
      try {
        for (var o = bo(n), c = o.next(); !c.done; c = o.next()) {
          var s = c.value;
          t.next(s);
        }
      } catch (u) {
        a = { error: u };
      } finally {
        try {
          c && !c.done && (i = o.return) && i.call(o);
        } finally {
          if (a) throw a.error;
        }
      }
      t.complete();
    }, void 0, function() {
      n = null;
    }));
  });
}
function Bee(e, r) {
  var t = arguments.length >= 2;
  return function(n) {
    return n.pipe(e ? u0(function(a, i) {
      return e(a, i, n);
    }) : ni, sz(1), t ? J3(r) : eS(function() {
      return new P0();
    }));
  };
}
function Nee() {
  return rr(function(e, r) {
    e.subscribe(new Ze(r, function(t) {
      r.next(W_.createNext(t));
    }, function() {
      r.next(W_.createComplete()), r.complete();
    }, function(t) {
      r.next(W_.createError(t)), r.complete();
    }));
  });
}
function Vee(e) {
  return Jg(Ur(e) ? function(r, t) {
    return e(r, t) > 0 ? r : t;
  } : function(r, t) {
    return r > t ? r : t;
  });
}
var Ree = os;
function Oee(e, r, t) {
  return t === void 0 && (t = 1 / 0), Ur(r) ? os(function() {
    return e;
  }, r, t) : (typeof r == "number" && (t = r), os(function() {
    return e;
  }, t));
}
function Fee(e, r, t) {
  return t === void 0 && (t = 1 / 0), rr(function(n, a) {
    var i = r;
    return rE(n, a, function(o, c) {
      return e(i, o, c);
    }, t, function(o) {
      i = o;
    }, !1, void 0, function() {
      return i = null;
    });
  });
}
function Lee() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  var t = Sc(e), n = CU(e, 1 / 0);
  return e = _p(e), rr(function(a, i) {
    Z3(n)(ms($t([a], jt(e)), t)).subscribe(i);
  });
}
function kee() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  return Lee.apply(void 0, $t([], jt(e)));
}
function Uee(e) {
  return Jg(Ur(e) ? function(r, t) {
    return e(r, t) < 0 ? r : t;
  } : function(r, t) {
    return r < t ? r : t;
  });
}
function oE(e, r) {
  var t = Ur(e) ? e : function() {
    return e;
  };
  return Ur(r) ? aE(r, {
    connector: t
  }) : function(n) {
    return new K3(n, t);
  };
}
function zee() {
  return rr(function(e, r) {
    var t, n = !1;
    e.subscribe(new Ze(r, function(a) {
      var i = t;
      t = a, n && r.next([i, a]), n = !0;
    }));
  });
}
function Gee() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  var t = e.length;
  if (t === 0)
    throw new Error("list of properties cannot be empty.");
  return zd(function(n) {
    for (var a = n, i = 0; i < t; i++) {
      var o = a == null ? void 0 : a[e[i]];
      if (typeof o < "u")
        a = o;
      else
        return;
    }
    return a;
  });
}
function qee(e) {
  return e ? function(r) {
    return aE(e)(r);
  } : function(r) {
    return oE(new Sa())(r);
  };
}
function Hee(e) {
  return function(r) {
    var t = new hU(e);
    return new K3(r, function() {
      return t;
    });
  };
}
function jee() {
  return function(e) {
    var r = new Xw();
    return new K3(e, function() {
      return r;
    });
  };
}
function $ee(e, r, t, n) {
  t && !Ur(t) && (n = t);
  var a = Ur(t) ? t : void 0;
  return function(i) {
    return oE(new Ww(e, r, n), a)(i);
  };
}
function Kee() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  return e.length ? rr(function(t, n) {
    WU($t([t], jt(e)))(n);
  }) : ni;
}
function Wee(e) {
  var r, t = 1 / 0, n;
  return e != null && (typeof e == "object" ? (r = e.count, t = r === void 0 ? 1 / 0 : r, n = e.delay) : t = e), t <= 0 ? function() {
    return fs;
  } : rr(function(a, i) {
    var o = 0, c, s = function() {
      if (c == null || c.unsubscribe(), c = null, n != null) {
        var l = typeof n == "number" ? w0(n) : et(n(o)), f = new Ze(i, function() {
          f.unsubscribe(), u();
        });
        l.subscribe(f);
      } else
        u();
    }, u = function() {
      var l = !1;
      c = a.subscribe(new Ze(i, void 0, function() {
        ++o < t ? c ? s() : l = !0 : i.complete();
      })), l && s();
    };
    u();
  });
}
function Xee(e) {
  return rr(function(r, t) {
    var n, a = !1, i, o = !1, c = !1, s = function() {
      return c && o && (t.complete(), !0);
    }, u = function() {
      return i || (i = new Sa(), e(i).subscribe(new Ze(t, function() {
        n ? l() : a = !0;
      }, function() {
        o = !0, s();
      }))), i;
    }, l = function() {
      c = !1, n = r.subscribe(new Ze(t, void 0, function() {
        c = !0, !s() && u().next();
      })), a && (n.unsubscribe(), n = null, a = !1, l());
    };
    l();
  });
}
function Yee(e) {
  e === void 0 && (e = 1 / 0);
  var r;
  e && typeof e == "object" ? r = e : r = {
    count: e
  };
  var t = r.count, n = t === void 0 ? 1 / 0 : t, a = r.delay, i = r.resetOnSuccess, o = i === void 0 ? !1 : i;
  return n <= 0 ? ni : rr(function(c, s) {
    var u = 0, l, f = function() {
      var d = !1;
      l = c.subscribe(new Ze(s, function(m) {
        o && (u = 0), s.next(m);
      }, void 0, function(m) {
        if (u++ < n) {
          var p = function() {
            l ? (l.unsubscribe(), l = null, f()) : d = !0;
          };
          if (a != null) {
            var v = typeof a == "number" ? w0(a) : et(a(m, u)), h = new Ze(s, function() {
              h.unsubscribe(), p();
            }, function() {
              s.complete();
            });
            v.subscribe(h);
          } else
            p();
        } else
          s.error(m);
      })), d && (l.unsubscribe(), l = null, f());
    };
    f();
  });
}
function Qee(e) {
  return rr(function(r, t) {
    var n, a = !1, i, o = function() {
      n = r.subscribe(new Ze(t, void 0, void 0, function(c) {
        i || (i = new Sa(), e(i).subscribe(new Ze(t, function() {
          return n ? o() : a = !0;
        }))), i && i.next(c);
      })), a && (n.unsubscribe(), n = null, a = !1, o());
    };
    o();
  });
}
function lz(e) {
  return rr(function(r, t) {
    var n = !1, a = null;
    r.subscribe(new Ze(t, function(o) {
      n = !0, a = o;
    }));
    var i = function() {
      if (n) {
        n = !1;
        var o = a;
        a = null, t.next(o);
      }
    };
    e.subscribe(new Ze(t, i, Ln));
  });
}
function Zee(e, r) {
  return r === void 0 && (r = Bu), lz($U(e, r));
}
function cz(e, r) {
  return rr(QU(e, r, arguments.length >= 2, !0));
}
function Jee(e, r) {
  return r === void 0 && (r = function(t, n) {
    return t === n;
  }), rr(function(t, n) {
    var a = j6(), i = j6(), o = function(s) {
      n.next(s), n.complete();
    }, c = function(s, u) {
      var l = new Ze(n, function(f) {
        var d = u.buffer, m = u.complete;
        d.length === 0 ? m ? o(!1) : s.buffer.push(f) : !r(f, d.shift()) && o(!1);
      }, function() {
        s.complete = !0;
        var f = u.complete, d = u.buffer;
        f && o(d.length === 0), l == null || l.unsubscribe();
      });
      return l;
    };
    t.subscribe(c(a, i)), e.subscribe(c(i, a));
  });
}
function j6() {
  return {
    buffer: [],
    complete: !1
  };
}
function dz(e) {
  e === void 0 && (e = {});
  var r = e.connector, t = r === void 0 ? function() {
    return new Sa();
  } : r, n = e.resetOnError, a = n === void 0 ? !0 : n, i = e.resetOnComplete, o = i === void 0 ? !0 : i, c = e.resetOnRefCountZero, s = c === void 0 ? !0 : c;
  return function(u) {
    var l = null, f = null, d = null, m = 0, p = !1, v = !1, h = function() {
      f == null || f.unsubscribe(), f = null;
    }, y = function() {
      h(), l = d = null, p = v = !1;
    }, C = function() {
      var S = l;
      y(), S == null || S.unsubscribe();
    };
    return rr(function(S, b) {
      m++, !v && !p && h();
      var g = d = d ?? t();
      b.add(function() {
        m--, m === 0 && !v && !p && (f = Vx(C, s));
      }), g.subscribe(b), l || (l = new gg({
        next: function(_) {
          return g.next(_);
        },
        error: function(_) {
          v = !0, h(), f = Vx(y, a, _), g.error(_);
        },
        complete: function() {
          p = !0, h(), f = Vx(y, o), g.complete();
        }
      }), ms(S).subscribe(l));
    })(u);
  };
}
function Vx(e, r) {
  for (var t = [], n = 2; n < arguments.length; n++)
    t[n - 2] = arguments[n];
  return r === !0 ? (e(), null) : r === !1 ? null : r.apply(void 0, $t([], jt(t))).pipe(xv(1)).subscribe(function() {
    return e();
  });
}
function ere(e, r, t) {
  var n, a, i, o = !1;
  return e && typeof e == "object" ? (i = (n = e.bufferSize) !== null && n !== void 0 ? n : 1 / 0, r = (a = e.windowTime) !== null && a !== void 0 ? a : 1 / 0, o = !!e.refCount, t = e.scheduler) : i = e ?? 1 / 0, dz({
    connector: function() {
      return new Ww(i, r, t);
    },
    resetOnError: !0,
    resetOnComplete: !1,
    resetOnRefCountZero: o
  });
}
function rre(e) {
  return rr(function(r, t) {
    var n = !1, a, i = !1, o = 0;
    r.subscribe(new Ze(t, function(c) {
      i = !0, (!e || e(c, o++, r)) && (n && t.error(new LU("Too many matching values")), n = !0, a = c);
    }, function() {
      n ? (t.next(a), t.complete()) : t.error(i ? new FU("No matching values") : new P0());
    }));
  });
}
function tre(e) {
  return u0(function(r, t) {
    return e <= t;
  });
}
function nre(e) {
  return e <= 0 ? ni : rr(function(r, t) {
    var n = new Array(e), a = 0;
    return r.subscribe(new Ze(t, function(i) {
      var o = a++;
      if (o < e)
        n[o] = i;
      else {
        var c = o % e, s = n[c];
        n[c] = i, t.next(s);
      }
    })), function() {
      n = null;
    };
  });
}
function are(e) {
  return rr(function(r, t) {
    var n = !1, a = new Ze(t, function() {
      a == null || a.unsubscribe(), n = !0;
    }, Ln);
    et(e).subscribe(a), r.subscribe(new Ze(t, function(i) {
      return n && t.next(i);
    }));
  });
}
function ire(e) {
  return rr(function(r, t) {
    var n = !1, a = 0;
    r.subscribe(new Ze(t, function(i) {
      return (n || (n = !e(i, a++))) && t.next(i);
    }));
  });
}
function ore() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  var t = Sc(e);
  return rr(function(n, a) {
    (t ? _g(e, n, t) : _g(e, n)).subscribe(a);
  });
}
function bg(e, r) {
  return rr(function(t, n) {
    var a = null, i = 0, o = !1, c = function() {
      return o && !a && n.complete();
    };
    t.subscribe(new Ze(n, function(s) {
      a == null || a.unsubscribe();
      var u = 0, l = i++;
      et(e(s, l)).subscribe(a = new Ze(n, function(f) {
        return n.next(r ? r(s, f, l, u++) : f);
      }, function() {
        a = null, c();
      }));
    }, function() {
      o = !0, c();
    }));
  });
}
function ure() {
  return bg(ni);
}
function sre(e, r) {
  return Ur(r) ? bg(function() {
    return e;
  }, r) : bg(function() {
    return e;
  });
}
function lre(e, r) {
  return rr(function(t, n) {
    var a = r;
    return bg(function(i, o) {
      return e(a, i, o);
    }, function(i, o) {
      return a = o, o;
    })(t).subscribe(n), function() {
      a = null;
    };
  });
}
function cre(e) {
  return rr(function(r, t) {
    et(e).subscribe(new Ze(t, function() {
      return t.complete();
    }, Ln)), !t.closed && r.subscribe(t);
  });
}
function dre(e, r) {
  return r === void 0 && (r = !1), rr(function(t, n) {
    var a = 0;
    t.subscribe(new Ze(n, function(i) {
      var o = e(i, a++);
      (o || r) && n.next(i), !o && n.complete();
    }));
  });
}
function fre(e, r, t) {
  var n = Ur(e) || r || t ? { next: e, error: r, complete: t } : e;
  return n ? rr(function(a, i) {
    var o;
    (o = n.subscribe) === null || o === void 0 || o.call(n);
    var c = !0;
    a.subscribe(new Ze(i, function(s) {
      var u;
      (u = n.next) === null || u === void 0 || u.call(n, s), i.next(s);
    }, function() {
      var s;
      c = !1, (s = n.complete) === null || s === void 0 || s.call(n), i.complete();
    }, function(s) {
      var u;
      c = !1, (u = n.error) === null || u === void 0 || u.call(n, s), i.error(s);
    }, function() {
      var s, u;
      c && ((s = n.unsubscribe) === null || s === void 0 || s.call(n)), (u = n.finalize) === null || u === void 0 || u.call(n);
    }));
  }) : ni;
}
var fz = {
  leading: !0,
  trailing: !1
};
function mz(e, r) {
  return r === void 0 && (r = fz), rr(function(t, n) {
    var a = r.leading, i = r.trailing, o = !1, c = null, s = null, u = !1, l = function() {
      s == null || s.unsubscribe(), s = null, i && (m(), u && n.complete());
    }, f = function() {
      s = null, u && n.complete();
    }, d = function(p) {
      return s = et(e(p)).subscribe(new Ze(n, l, f));
    }, m = function() {
      if (o) {
        o = !1;
        var p = c;
        c = null, n.next(p), !u && d(p);
      }
    };
    t.subscribe(new Ze(n, function(p) {
      o = !0, c = p, !(s && !s.closed) && (a ? m() : d(p));
    }, function() {
      u = !0, !(i && o && s && !s.closed) && n.complete();
    }));
  });
}
function mre(e, r, t) {
  r === void 0 && (r = Bu), t === void 0 && (t = fz);
  var n = w0(e, r);
  return mz(function() {
    return n;
  }, t);
}
function vre(e) {
  return e === void 0 && (e = Bu), function(r) {
    return Zg(function() {
      return r.pipe(cz(function(t, n) {
        var a = t.current;
        return { value: n, current: e.now(), last: a };
      }, {
        current: e.now(),
        value: void 0,
        last: void 0
      }), zd(function(t) {
        var n = t.current, a = t.last, i = t.value;
        return new pre(i, n - a);
      }));
    });
  };
}
var pre = /* @__PURE__ */ function() {
  function e(r, t) {
    this.value = r, this.interval = t;
  }
  return e;
}();
function hre(e, r, t) {
  var n, a, i;
  if (t = t ?? Yw, eE(e) ? n = e : typeof e == "number" && (a = e), r)
    i = function() {
      return r;
    };
  else
    throw new TypeError("No observable provided to switch to");
  if (n == null && a == null)
    throw new TypeError("No timeout provided.");
  return UU({
    first: n,
    each: a,
    scheduler: t,
    with: i
  });
}
function gre(e) {
  return e === void 0 && (e = W3), zd(function(r) {
    return { value: r, timestamp: e.now() };
  });
}
function yre(e) {
  return rr(function(r, t) {
    var n = new Sa();
    t.next(n.asObservable());
    var a = function(i) {
      n.error(i), t.error(i);
    };
    return r.subscribe(new Ze(t, function(i) {
      return n == null ? void 0 : n.next(i);
    }, function() {
      n.complete(), t.complete();
    }, a)), e.subscribe(new Ze(t, function() {
      n.complete(), t.next(n = new Sa());
    }, Ln, a)), function() {
      n == null || n.unsubscribe(), n = null;
    };
  });
}
function _re(e, r) {
  r === void 0 && (r = 0);
  var t = r > 0 ? r : e;
  return rr(function(n, a) {
    var i = [new Sa()], o = [], c = 0;
    a.next(i[0].asObservable()), n.subscribe(new Ze(a, function(s) {
      var u, l;
      try {
        for (var f = bo(i), d = f.next(); !d.done; d = f.next()) {
          var m = d.value;
          m.next(s);
        }
      } catch (h) {
        u = { error: h };
      } finally {
        try {
          d && !d.done && (l = f.return) && l.call(f);
        } finally {
          if (u) throw u.error;
        }
      }
      var p = c - e + 1;
      if (p >= 0 && p % t === 0 && i.shift().complete(), ++c % t === 0) {
        var v = new Sa();
        i.push(v), a.next(v.asObservable());
      }
    }, function() {
      for (; i.length > 0; )
        i.shift().complete();
      a.complete();
    }, function(s) {
      for (; i.length > 0; )
        i.shift().error(s);
      a.error(s);
    }, function() {
      o = null, i = null;
    }));
  });
}
function bre(e) {
  for (var r, t, n = [], a = 1; a < arguments.length; a++)
    n[a - 1] = arguments[a];
  var i = (r = Sc(n)) !== null && r !== void 0 ? r : Bu, o = (t = n[0]) !== null && t !== void 0 ? t : null, c = n[1] || 1 / 0;
  return rr(function(s, u) {
    var l = [], f = !1, d = function(h) {
      var y = h.window, C = h.subs;
      y.complete(), C.unsubscribe(), dc(l, h), f && m();
    }, m = function() {
      if (l) {
        var h = new Wi();
        u.add(h);
        var y = new Sa(), C = {
          window: y,
          subs: h,
          seen: 0
        };
        l.push(C), u.next(y.asObservable()), So(h, i, function() {
          return d(C);
        }, e);
      }
    };
    o !== null && o >= 0 ? So(u, i, m, o, !0) : f = !0, m();
    var p = function(h) {
      return l.slice().forEach(h);
    }, v = function(h) {
      p(function(y) {
        var C = y.window;
        return h(C);
      }), h(u), u.unsubscribe();
    };
    return s.subscribe(new Ze(u, function(h) {
      p(function(y) {
        y.window.next(h), c <= ++y.seen && d(y);
      });
    }, function() {
      return v(function(h) {
        return h.complete();
      });
    }, function(h) {
      return v(function(y) {
        return y.error(h);
      });
    })), function() {
      l = null;
    };
  });
}
function Sre(e, r) {
  return rr(function(t, n) {
    var a = [], i = function(o) {
      for (; 0 < a.length; )
        a.shift().error(o);
      n.error(o);
    };
    et(e).subscribe(new Ze(n, function(o) {
      var c = new Sa();
      a.push(c);
      var s = new Wi(), u = function() {
        dc(a, c), c.complete(), s.unsubscribe();
      }, l;
      try {
        l = et(r(o));
      } catch (f) {
        i(f);
        return;
      }
      n.next(c.asObservable()), s.add(l.subscribe(new Ze(n, u, Ln, i)));
    }, Ln)), t.subscribe(new Ze(n, function(o) {
      var c, s, u = a.slice();
      try {
        for (var l = bo(u), f = l.next(); !f.done; f = l.next()) {
          var d = f.value;
          d.next(o);
        }
      } catch (m) {
        c = { error: m };
      } finally {
        try {
          f && !f.done && (s = l.return) && s.call(l);
        } finally {
          if (c) throw c.error;
        }
      }
    }, function() {
      for (; 0 < a.length; )
        a.shift().complete();
      n.complete();
    }, i, function() {
      for (; 0 < a.length; )
        a.shift().unsubscribe();
    }));
  });
}
function Cre(e) {
  return rr(function(r, t) {
    var n, a, i = function(c) {
      n.error(c), t.error(c);
    }, o = function() {
      a == null || a.unsubscribe(), n == null || n.complete(), n = new Sa(), t.next(n.asObservable());
      var c;
      try {
        c = et(e());
      } catch (s) {
        i(s);
        return;
      }
      c.subscribe(a = new Ze(t, o, o, i));
    };
    o(), r.subscribe(new Ze(t, function(c) {
      return n.next(c);
    }, function() {
      n.complete(), t.complete();
    }, i, function() {
      a == null || a.unsubscribe(), n = null;
    }));
  });
}
function Are() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  var t = Qg(e);
  return rr(function(n, a) {
    for (var i = e.length, o = new Array(i), c = e.map(function() {
      return !1;
    }), s = !1, u = function(f) {
      et(e[f]).subscribe(new Ze(a, function(d) {
        o[f] = d, !s && !c[f] && (c[f] = !0, (s = c.every(ni)) && (c = null));
      }, Ln));
    }, l = 0; l < i; l++)
      u(l);
    n.subscribe(new Ze(a, function(f) {
      if (s) {
        var d = $t([f], jt(o));
        a.next(t ? t.apply(void 0, $t([], jt(d))) : d);
      }
    }));
  });
}
function xre(e) {
  return JU(nE, e);
}
function Tre() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  return rr(function(t, n) {
    nE.apply(void 0, $t([t], jt(e))).subscribe(n);
  });
}
function Pre() {
  for (var e = [], r = 0; r < arguments.length; r++)
    e[r] = arguments[r];
  return Tre.apply(void 0, $t([], jt(e)));
}
const Mre = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  ArgumentOutOfRangeError: YP,
  AsyncSubject: Xw,
  BehaviorSubject: hU,
  ConnectableObservable: K3,
  EMPTY: fs,
  EmptyError: P0,
  NEVER: KU,
  NotFoundError: FU,
  Notification: W_,
  get NotificationKind() {
    return XP;
  },
  ObjectUnsubscribedError: pU,
  Observable: mt,
  ReplaySubject: Ww,
  Scheduler: WP,
  SequenceError: LU,
  Subject: Sa,
  Subscriber: j3,
  Subscription: Wi,
  TimeoutError: kU,
  UnsubscriptionError: $_,
  VirtualAction: SU,
  VirtualTimeScheduler: tJ,
  animationFrame: rJ,
  animationFrameScheduler: bU,
  animationFrames: zZ,
  asap: XZ,
  asapScheduler: yU,
  async: Yw,
  asyncScheduler: Bu,
  audit: XU,
  auditTime: QJ,
  bindCallback: CJ,
  bindNodeCallback: AJ,
  buffer: ZJ,
  bufferCount: JJ,
  bufferTime: eee,
  bufferToggle: ree,
  bufferWhen: tee,
  catchError: YU,
  combineAll: aee,
  combineLatest: qU,
  combineLatestAll: ez,
  combineLatestWith: iee,
  concat: _g,
  concatAll: tE,
  concatMap: ZP,
  concatMapTo: oee,
  concatWith: see,
  config: Ud,
  connect: aE,
  connectable: DJ,
  count: dee,
  debounce: fee,
  debounceTime: mee,
  defaultIfEmpty: J3,
  defer: Zg,
  delay: vee,
  delayWhen: iE,
  dematerialize: pee,
  distinct: hee,
  distinctUntilChanged: az,
  distinctUntilKeyChanged: yee,
  elementAt: bee,
  empty: nJ,
  endWith: See,
  every: Cee,
  exhaust: Aee,
  exhaustAll: iz,
  exhaustMap: oz,
  expand: xee,
  filter: u0,
  finalize: Tee,
  find: Pee,
  findIndex: Mee,
  first: wee,
  firstValueFrom: yJ,
  flatMap: Ree,
  forkJoin: IJ,
  from: ms,
  fromEvent: QP,
  fromEventPattern: jU,
  generate: LJ,
  groupBy: Eee,
  identity: ni,
  ignoreElements: tz,
  iif: kJ,
  interval: $U,
  isEmpty: Iee,
  isObservable: hJ,
  last: Bee,
  lastValueFrom: gJ,
  map: zd,
  mapTo: nz,
  materialize: Nee,
  max: Vee,
  merge: UJ,
  mergeAll: Z3,
  mergeMap: os,
  mergeMapTo: Oee,
  mergeScan: Fee,
  mergeWith: kee,
  min: Uee,
  multicast: oE,
  never: zJ,
  noop: Ln,
  observable: $3,
  observeOn: Y3,
  of: Jw,
  onErrorResumeNext: HJ,
  pairs: jJ,
  pairwise: zee,
  partition: KJ,
  pipe: Kw,
  pluck: Gee,
  publish: qee,
  publishBehavior: Hee,
  publishLast: jee,
  publishReplay: $ee,
  queue: ZZ,
  queueScheduler: _U,
  race: WJ,
  raceWith: Kee,
  range: XJ,
  reduce: Jg,
  refCount: fU,
  repeat: Wee,
  repeatWhen: Xee,
  retry: Yee,
  retryWhen: Qee,
  sample: lz,
  sampleTime: Zee,
  scan: cz,
  scheduled: VU,
  sequenceEqual: Jee,
  share: dz,
  shareReplay: ere,
  single: rre,
  skip: tre,
  skipLast: nre,
  skipUntil: are,
  skipWhile: ire,
  startWith: ore,
  subscribeOn: Q3,
  switchAll: ure,
  switchMap: bg,
  switchMapTo: sre,
  switchScan: lre,
  take: xv,
  takeLast: sz,
  takeUntil: cre,
  takeWhile: dre,
  tap: fre,
  throttle: mz,
  throttleTime: mre,
  throwError: RU,
  throwIfEmpty: eS,
  timeInterval: vre,
  timeout: UU,
  timeoutWith: hre,
  timer: w0,
  timestamp: gre,
  toArray: ZU,
  using: YJ,
  window: yre,
  windowCount: _re,
  windowTime: bre,
  windowToggle: Sre,
  windowWhen: Cre,
  withLatestFrom: Are,
  zip: nE,
  zipAll: xre,
  zipWith: Pre
}, Symbol.toStringTag, { value: "Module" })), cl = /* @__PURE__ */ F3(Mre);
var ey = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.InputObserver = e.ButtonsType = e.ModifiersKeys = e.DefaultInputObserverProps = e.getModifiers = e.getButton = e.getButtons = void 0;
  var r = Te, t = cl, n = Re, a = We();
  function i(m) {
    if (typeof m == "object") {
      if ("buttons" in m)
        return m.buttons;
      if ("which" in m) {
        var p = m.which;
        if (p === 2)
          return 4;
        if (p === 3)
          return 2;
        if (p > 0)
          return 1 << p - 1;
      }
    }
    return 0;
  }
  e.getButtons = i;
  function o(m) {
    if (typeof m == "object" && "button" in m) {
      var p = m.button;
      if (p === 1)
        return 4;
      if (p === 2)
        return 2;
      if (p >= 0)
        return 1 << p;
    }
    return 0;
  }
  e.getButton = o;
  function c(m) {
    return {
      alt: "altKey" in m ? m.altKey : !1,
      shift: "shiftKey" in m ? m.shiftKey : !1,
      control: "ctrlKey" in m ? m.ctrlKey : !1,
      meta: "metaKey" in m ? m.metaKey : !1
    };
  }
  e.getModifiers = c, e.DefaultInputObserverProps = {
    noScroll: !0,
    noMiddleClickScroll: !0,
    noContextMenu: !0,
    noPinchZoom: !0,
    noTextSelect: !0,
    preventGestures: !1,
    mask: function(m, p) {
      return !0;
    },
    pixelScale: 1
  }, function(m) {
    m.None = h();
    function p(y, C) {
      return y.shift === C.shift && y.alt === C.alt && y.control === C.control && y.meta === C.meta;
    }
    m.areEqual = p;
    function v(y) {
      if (!y)
        return 0;
      var C = 0;
      return y.shift && C++, y.alt && C++, y.control && C++, y.meta && C++, C;
    }
    m.size = v;
    function h(y) {
      return y === void 0 && (y = {}), {
        shift: !!y.shift,
        alt: !!y.alt,
        control: !!y.control,
        meta: !!y.meta
      };
    }
    m.create = h;
  }(e.ModifiersKeys || (e.ModifiersKeys = {}));
  var s;
  (function(m) {
    m.has = a.BitFlags.has, m.create = a.BitFlags.create;
  })(s = e.ButtonsType || (e.ButtonsType = {}));
  function u() {
    return {
      drag: new t.Subject(),
      interactionEnd: new t.Subject(),
      click: new t.Subject(),
      move: new t.Subject(),
      wheel: new t.Subject(),
      pinch: new t.Subject(),
      gesture: new t.Subject(),
      resize: new t.Subject(),
      leave: new t.Subject(),
      enter: new t.Subject(),
      modifiers: new t.Subject(),
      key: new t.Subject()
    };
  }
  var l = ["Backspace", "Delete"], f;
  (function(m) {
    function p(h) {
      h === void 0 && (h = {});
      var y = (0, r.__assign)((0, r.__assign)({}, e.DefaultInputObserverProps), h), C = y.noScroll, S = y.noContextMenu;
      return (0, r.__assign)((0, r.__assign)({ noScroll: C, noContextMenu: S, width: 0, height: 0, pixelRatio: 1 }, u()), { dispose: a.noop });
    }
    m.create = p;
    function v(h, y) {
      y === void 0 && (y = {});
      var C = (0, r.__assign)((0, r.__assign)({}, e.DefaultInputObserverProps), y), S = C.noScroll, b = C.noMiddleClickScroll, g = C.noContextMenu, _ = C.noPinchZoom, A = C.noTextSelect, M = C.mask, P = C.pixelScale, T = C.preventGestures, x = h.clientWidth * G(), w = h.clientHeight * G(), E = 0, I = 0, B = (0, n.Vec2)(), D = (0, n.Vec2)(), N = (0, n.Vec2)(), O = (0, n.Vec2)(), V = (0, n.Vec2)(), k = {
        shift: !1,
        alt: !1,
        control: !1,
        meta: !1
      };
      function G() {
        return window.devicePixelRatio * P;
      }
      function L() {
        return (0, r.__assign)({}, k);
      }
      var R = 0, F = !1, U = s.create(
        0
        /* None */
      ), H = 0, q = !1, K = u(), Y = K.drag, X = K.interactionEnd, Z = K.wheel, J = K.pinch, $ = K.gesture, Q = K.click, W = K.move, te = K.leave, oe = K.enter, z = K.resize, j = K.modifiers, ae = K.key;
      return le(), (0, r.__assign)((0, r.__assign)({
        get noScroll() {
          return S;
        },
        set noScroll(Be) {
          S = Be;
        },
        get noContextMenu() {
          return g;
        },
        set noContextMenu(Be) {
          g = Be;
        },
        get width() {
          return x;
        },
        get height() {
          return w;
        },
        get pixelRatio() {
          return G();
        }
      }, K), { dispose: ie });
      function le() {
        h.addEventListener("contextmenu", re, !1), h.addEventListener("wheel", be, !1), h.addEventListener("mousedown", De, !1), window.addEventListener("mousemove", Ee, !1), window.addEventListener("mouseup", Me, !1), h.addEventListener("mouseenter", ze, !1), h.addEventListener("mouseleave", ke, !1), h.addEventListener("touchstart", _e, !1), h.addEventListener("touchmove", Pe, !1), h.addEventListener("touchend", Se, !1), h.addEventListener("gesturechange", Ne, !1), h.addEventListener("gesturestart", we, !1), h.addEventListener("gestureend", Oe, !1), window.addEventListener("blur", ne), window.addEventListener("keyup", ce, !1), window.addEventListener("keydown", se, !1), window.addEventListener("keypress", de, !1), window.addEventListener("resize", je, !1);
      }
      function ie() {
        F || (F = !0, h.removeEventListener("contextmenu", re, !1), h.removeEventListener("wheel", be, !1), h.removeEventListener("mousedown", De, !1), window.removeEventListener("mousemove", Ee, !1), window.removeEventListener("mouseup", Me, !1), h.removeEventListener("mouseenter", ze, !1), h.removeEventListener("mouseleave", ke, !1), h.removeEventListener("touchstart", _e, !1), h.removeEventListener("touchmove", Pe, !1), h.removeEventListener("touchend", Se, !1), h.removeEventListener("gesturechange", Ne, !1), h.removeEventListener("gesturestart", we, !1), h.removeEventListener("gestureend", Oe, !1), window.removeEventListener("blur", ne), window.removeEventListener("keyup", ce, !1), window.removeEventListener("keydown", se, !1), window.removeEventListener("keypress", de, !1), window.removeEventListener("resize", je, !1));
      }
      function re(Be) {
        M(Be.clientX, Be.clientY) && g && Be.preventDefault();
      }
      function ee(Be) {
        k.alt = Be.altKey, k.shift = Be.shiftKey, k.control = Be.ctrlKey, k.meta = Be.metaKey;
      }
      function ne() {
        (U || k.shift || k.alt || k.meta || k.control) && (U = 0, k.shift = k.alt = k.control = k.meta = !1);
      }
      function se(Be) {
        var Ye = !1;
        !k.alt && Be.altKey && (Ye = !0, k.alt = !0), !k.shift && Be.shiftKey && (Ye = !0, k.shift = !0), !k.control && Be.ctrlKey && (Ye = !0, k.control = !0), !k.meta && Be.metaKey && (Ye = !0, k.meta = !0), Ye && q && j.next(L());
      }
      function ce(Be) {
        var Ye = !1;
        k.alt && !Be.altKey && (Ye = !0, k.alt = !1), k.shift && !Be.shiftKey && (Ye = !0, k.shift = !1), k.control && !Be.ctrlKey && (Ye = !0, k.control = !1), k.meta && !Be.metaKey && (Ye = !0, k.meta = !1), Ye && q && j.next(L()), l.includes(Be.key) && de(Be);
      }
      function de(Be) {
        ae.next({
          key: Be.key,
          modifiers: L()
        });
      }
      function me(Be) {
        var Ye = Be.touches[0], cr = Be.touches[1];
        return {
          clientX: (Ye.clientX + cr.clientX) / 2,
          clientY: (Ye.clientY + cr.clientY) / 2,
          pageX: (Ye.pageX + cr.pageX) / 2,
          pageY: (Ye.pageY + cr.pageY) / 2
        };
      }
      function he(Be) {
        var Ye = Be.touches[0].pageX - Be.touches[1].pageX, cr = Be.touches[0].pageY - Be.touches[1].pageY;
        return Math.sqrt(Ye * Ye + cr * cr);
      }
      function _e(Be) {
        if (Be.preventDefault(), Be.touches.length === 1)
          U = H = 1, pe(Be.touches[0]);
        else if (Be.touches.length === 2) {
          U = 0, H = 2, pe(me(Be));
          var Ye = he(Be);
          E = Ye, J.next({
            distance: Ye,
            fraction: 1,
            fractionDelta: 0,
            delta: 0,
            isStart: !0,
            buttons: U,
            button: H,
            modifiers: L()
          });
        } else Be.touches.length === 3 && (U = H = 8, pe(me(Be)));
      }
      function Se(Be) {
        ue();
      }
      function Pe(Be) {
        if (H = 0, _ && (Be.preventDefault(), Be.stopPropagation(), Be.originalEvent && (Be.originalEvent.preventDefault(), Be.originalEvent.stopPropagation())), Be.touches.length === 1)
          U = 1, ye(Be.touches[0]);
        else if (Be.touches.length === 2) {
          var Ye = he(Be), cr = E - Ye;
          if (Math.abs(cr) < 4)
            U = 2, ye(me(Be));
          else {
            U = 4, ee(Be);
            var Ar = E / Ye;
            J.next({
              delta: cr,
              fraction: Ar,
              fractionDelta: I - Ar,
              distance: Ye,
              isStart: !1,
              buttons: U,
              button: H,
              modifiers: L()
            }), I = Ar;
          }
          E = Ye;
        } else Be.touches.length === 3 && (U = 8, ye(me(Be)));
      }
      function De(Be) {
        ee(Be), U = i(Be), H = o(Be), b && U === 4 && Be.preventDefault, pe(Be);
      }
      function Ee(Be) {
        ee(Be), U = i(Be), H = 0, ye(Be);
      }
      function Me(Be) {
        ee(Be), U = i(Be), H = o(Be), Ae(Be), ue();
      }
      function ue() {
        X.next(void 0);
      }
      function pe(Be) {
        M(Be.clientX, Be.clientY) && (He(D, Be), n.Vec2.copy(B, D), Xe(D) && (R = 1));
      }
      function Ae(Be) {
        if (R = 0, !!M(Be.clientX, Be.clientY) && (He(N, Be), n.Vec2.distance(N, B) < 4)) {
          var Ye = Be.pageX, cr = Be.pageY, Ar = N[0], Lr = N[1];
          Q.next({ x: Ar, y: Lr, pageX: Ye, pageY: cr, buttons: U, button: H, modifiers: L() });
        }
      }
      function ye(Be) {
        var Ye;
        He(N, Be);
        var cr = Be.pageX, Ar = Be.pageY, Lr = N[0], It = N[1], en = Xe(N);
        if (W.next({ x: Lr, y: It, pageX: cr, pageY: Ar, buttons: U, button: H, modifiers: L(), inside: en }), R !== 0 && (A && ((Ye = Be.preventDefault) === null || Ye === void 0 || Ye.call(Be)), n.Vec2.div(O, n.Vec2.sub(O, N, D), Fe(V)), !(n.Vec2.magnitude(O) < n.EPSILON))) {
          var Sn = R === 1;
          if (!(Sn && !M(Be.clientX, Be.clientY))) {
            var Wn = O[0], oa = O[1];
            Y.next({ x: Lr, y: It, dx: Wn, dy: oa, pageX: cr, pageY: Ar, buttons: U, button: H, modifiers: L(), isStart: Sn }), n.Vec2.copy(D, N), R = 2;
          }
        }
      }
      function be(Be) {
        if (M(Be.clientX, Be.clientY)) {
          He(N, Be);
          var Ye = Be.pageX, cr = Be.pageY, Ar = N[0], Lr = N[1];
          S && Be.preventDefault();
          var It = d(Be);
          U = H = 4, (It.dx || It.dy || It.dz) && Z.next((0, r.__assign)((0, r.__assign)({ x: Ar, y: Lr, pageX: Ye, pageY: cr }, It), { buttons: U, button: H, modifiers: L() }));
        }
      }
      function fe(Be) {
        var Ye, cr;
        T && (Be.preventDefault(), (Ye = Be.stopImmediatePropagation) === null || Ye === void 0 || Ye.call(Be), (cr = Be.stopPropagation) === null || cr === void 0 || cr.call(Be));
      }
      var ge = 0, xe = 0;
      function we(Be) {
        fe(Be), ge = Be.scale, xe = Be.rotation, $.next({ scale: Be.scale, rotation: Be.rotation, deltaRotation: 0, deltaScale: 0, isStart: !0 });
      }
      function Ve(Be, Ye) {
        $.next({
          scale: Be.scale,
          rotation: Be.rotation,
          deltaRotation: xe - Be.rotation,
          deltaScale: ge - Be.scale,
          isEnd: Ye
        }), xe = Be.rotation, ge = Be.scale;
      }
      function Ne(Be) {
        fe(Be), Ve(Be);
      }
      function Oe(Be) {
        fe(Be), Ve(Be, !0);
      }
      function ze(Be) {
        q = !0, oe.next(void 0);
      }
      function ke(Be) {
        q = !1, te.next(void 0);
      }
      function je(Be) {
        z.next({});
      }
      function Xe(Be) {
        if (h instanceof Window || h instanceof Document || h === document.body)
          return !0;
        var Ye = h.getBoundingClientRect();
        return Be[0] >= 0 && Be[1] >= 0 && Be[0] < Ye.width && Be[1] < Ye.height;
      }
      function Fe(Be) {
        return Be[0] = h.clientWidth, Be[1] = h.clientHeight, Be;
      }
      function He(Be, Ye) {
        x = h.clientWidth * G(), w = h.clientHeight * G();
        var cr = Ye.clientX || 0, Ar = Ye.clientY || 0, Lr = h.getBoundingClientRect();
        return Be[0] = cr - Lr.left, Be[1] = Ar - Lr.top, Be;
      }
    }
    m.fromElement = v;
  })(f || (f = {})), e.InputObserver = f;
  function d(m) {
    var p = 10, v = 40, h = 800, y = 0, C = 0, S = 0, b = 0, g = 0;
    return "detail" in m && (C = m.detail), "wheelDelta" in m && (C = -m.wheelDelta / 120), "wheelDeltaY" in m && (C = -m.wheelDeltaY / 120), "wheelDeltaX" in m && (y = -m.wheelDeltaX / 120), "axis" in m && m.axis === m.HORIZONTAL_AXIS && (y = C, C = 0), S = y * p, b = C * p, "deltaY" in m && (b = m.deltaY), "deltaX" in m && (S = m.deltaX), "deltaZ" in m && (g = m.deltaZ), (S || b || g) && m.deltaMode && (m.deltaMode === 1 ? (S *= v, b *= v, g *= v) : (S *= h, b *= h, g *= h)), S && !y && (y = S < 1 ? -1 : 1), b && !C && (C = b < 1 ? -1 : 1), { spinX: y, spinY: C, dx: S, dy: b, dz: g };
  }
})(ey);
var vz = {}, ri = {};
Object.defineProperty(ri, "__esModule", { value: !0 });
ri.cameraUnproject = ri.cameraProject = ri.Viewport = void 0;
var wre = Te, bb = Re;
function Sg() {
  return Sg.zero();
}
ri.Viewport = Sg;
(function(e) {
  function r() {
    return { x: 0, y: 0, width: 0, height: 0 };
  }
  e.zero = r;
  function t(s, u, l, f) {
    return { x: s, y: u, width: l, height: f };
  }
  e.create = t;
  function n(s) {
    return (0, wre.__assign)({}, s);
  }
  e.clone = n;
  function a(s, u) {
    return Object.assign(s, u);
  }
  e.copy = a;
  function i(s, u, l, f, d) {
    return s.x = u, s.y = l, s.width = f, s.height = d, s;
  }
  e.set = i;
  function o(s, u) {
    return s[0] = u.x, s[1] = u.y, s[2] = u.width, s[3] = u.height, s;
  }
  e.toVec4 = o;
  function c(s, u) {
    return s.x === u.x && s.y === u.y && s.width === u.width && s.height === u.height;
  }
  e.equals = c;
})(Sg || (Sg = {}));
ri.Viewport = Sg;
var ws = (0, bb.Vec4)();
function Ere(e, r, t, n) {
  var a = t.x, i = t.y, o = t.width, c = t.height;
  bb.Vec4.set(ws, r[0], r[1], r[2], 1), bb.Vec4.transformMat4(ws, ws, n);
  var s = ws[3];
  return s !== 0 && (ws[0] /= s, ws[1] /= s, ws[2] /= s), e[0] = (ws[0] + 1) * o * 0.5 + a, e[1] = (1 - ws[1]) * c * 0.5 + i, e[2] = (ws[2] + 1) * 0.5, e[3] = s === 0 ? 0 : 1 / s, e;
}
ri.cameraProject = Ere;
function Dre(e, r, t, n) {
  var a = t.x, i = t.y, o = t.width, c = t.height, s = r[0] - a, u = c - r[1] - 1 - i, l = r[2];
  return e[0] = 2 * s / o - 1, e[1] = 2 * u / c - 1, e[2] = 2 * l - 1, bb.Vec3.transformMat4(e, e, n);
}
ri.cameraUnproject = Dre;
var Le = {}, nn = {};
Object.defineProperty(nn, "__esModule", { value: !0 });
nn.objectForEach = nn.mapObjectMap = nn.deepClone = nn.shallowMergeArray = nn.shallowMerge = nn.shallowEqual = nn.shallowMerge2 = nn.assignIfUndefined = void 0;
var rS = Object.prototype.hasOwnProperty;
function Ire(e, r) {
  for (var t = 0, n = Object.keys(r); t < n.length; t++) {
    var a = n[t];
    rS.call(r, a) && typeof e[a] > "u" && (e[a] = r[a]);
  }
  return e;
}
nn.assignIfUndefined = Ire;
function pz(e, r) {
  for (var t = !1, n = 0, a = Object.keys(r); n < a.length; n++) {
    var i = a[n];
    if (rS.call(r, i) && r[i] !== e[i]) {
      t = !0;
      break;
    }
  }
  return t ? Object.assign({}, e, r) : e;
}
nn.shallowMerge2 = pz;
function Bre(e, r) {
  if (!e)
    return !r;
  if (!r)
    return !1;
  var t = Object.keys(e);
  if (Object.keys(r).length !== t.length)
    return !1;
  for (var n = 0, a = t; n < a.length; n++) {
    var i = a[n];
    if (!rS.call(e, i) || e[i] !== r[i])
      return !1;
  }
  return !0;
}
nn.shallowEqual = Bre;
function Nre(e) {
  for (var r = [], t = 1; t < arguments.length; t++)
    r[t - 1] = arguments[t];
  return hz(e, r);
}
nn.shallowMerge = Nre;
function hz(e, r) {
  for (var t = e, n = 0; n < r.length; n++)
    if (r[n] && (t = pz(e, r[n]), t !== e)) {
      for (var a = n + 1; a < r.length; a++)
        t = Object.assign(t, r[a]);
      break;
    }
  return t;
}
nn.shallowMergeArray = hz;
function JP(e) {
  if (e === null || typeof e != "object")
    return e;
  if (e instanceof Array) {
    for (var r = [], t = 0, n = e.length; t < n; t++)
      r[t] = JP(e[t]);
    return r;
  }
  if (typeof e == "object" && !("prototype" in e)) {
    var r = {};
    for (var a in e)
      rS.call(e, a) && (r[a] = JP(e[a]));
    return r;
  }
  throw new Error(`Can't clone, type "`.concat(typeof e, '" unsupported'));
}
nn.deepClone = JP;
function Vre(e, r) {
  for (var t = {}, n = 0, a = Object.keys(e); n < a.length; n++) {
    var i = a[n];
    t[i] = r(e[i]);
  }
  return t;
}
nn.mapObjectMap = Vre;
function Rre(e, r) {
  if (e)
    for (var t = 0, n = Object.keys(e); t < n.length; t++) {
      var a = n[t];
      r(e[a], a);
    }
}
nn.objectForEach = Rre;
var lf = {}, Rx = {}, Kr = {}, mh = {}, Ou = {}, ry = {};
Object.defineProperty(ry, "__esModule", { value: !0 });
ry.Scheduler = void 0;
var Ore = Te;
function Fre() {
  var e = function() {
    var v = typeof window < "u" && window, h = typeof self < "u" && typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope && self, y = typeof cc < "u" && cc;
    return v || y || h;
  }(), r = {}, t = typeof document < "u" ? document : void 0, n = 1, a;
  function i(v) {
    for (var h = [], y = 1; y < arguments.length; y++)
      h[y - 1] = arguments[y];
    typeof v != "function" && (v = new Function("" + v));
    var C = { callback: v, args: h };
    return r[n] = C, a(n), n++;
  }
  function o(v) {
    delete r[v];
  }
  function c(v) {
    var h = v.callback, y = v.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);
        break;
    }
  }
  function s(v) {
    var h = r[v];
    o(v), c(h);
  }
  function u() {
    a = function(v) {
      process.nextTick(function() {
        s(v);
      });
    };
  }
  function l() {
    if (e && e.postMessage && !e.importScripts) {
      var v = !0, h = e.onmessage;
      return e.onmessage = function() {
        v = !1;
      }, e.postMessage("", "*"), e.onmessage = h, v;
    }
  }
  function f() {
    var v = "setImmediate$" + Math.random() + "$", h = function(y) {
      y.source === e && typeof y.data == "string" && y.data.indexOf(v) === 0 && s(+y.data.slice(v.length));
    };
    window.addEventListener ? window.addEventListener("message", h, !1) : window.attachEvent("onmessage", h), a = function(y) {
      window.postMessage(v + y, "*");
    };
  }
  function d() {
    var v = new MessageChannel();
    v.port1.onmessage = function(h) {
      var y = h.data;
      s(y);
    }, a = function(h) {
      v.port2.postMessage(h);
    };
  }
  function m() {
    var v = t.documentElement;
    a = function(h) {
      var y = t.createElement("script");
      y.onreadystatechange = function() {
        s(h), y.onreadystatechange = null, v.removeChild(y), y = null;
      }, v.appendChild(y);
    };
  }
  function p() {
    a = function(v) {
      setTimeout(s, 0, v);
    };
  }
  return typeof process < "u" && {}.toString.call(process) === "[object process]" ? u() : l() ? f() : typeof MessageChannel < "u" ? d() : t && "onreadystatechange" in t.createElement("script") ? m() : p(), {
    setImmediate: i,
    clearImmediate: o
  };
}
var eM = function() {
  return typeof setImmediate < "u" ? typeof window < "u" ? {
    setImmediate: function(e) {
      for (var r, t = [], n = 1; n < arguments.length; n++)
        t[n - 1] = arguments[n];
      return (r = window).setImmediate.apply(r, (0, Ore.__spreadArray)([e], t, !1));
    },
    clearImmediate: function(e) {
      return window.clearImmediate(e);
    }
  } : { setImmediate, clearImmediate } : Fre();
}();
function Lre(e) {
  eM.setImmediate(e);
}
var kre = {
  setImmediate: eM.setImmediate,
  clearImmediate: eM.clearImmediate,
  immediatePromise: function() {
    return new Promise(Lre);
  },
  delay: function(e, r) {
    return r === void 0 && (r = void 0), new Promise(function(t) {
      return setTimeout(t, e, r);
    });
  }
};
ry.Scheduler = kre;
var gz = {}, Zt = {};
Object.defineProperty(Zt, "__esModule", { value: !0 });
Zt.setDebugMode = Zt.setProductionMode = Zt.isDebugMode = Zt.isProductionMode = void 0;
var yz = function() {
  try {
    return !1;
  } catch {
    return !1;
  }
}();
Zt.isProductionMode = yz;
var _z = function() {
  try {
    return !1;
  } catch {
    return !1;
  }
}();
Zt.isDebugMode = _z;
function Ure(e) {
  typeof e < "u" && (Zt.isProductionMode = yz = e);
}
Zt.setProductionMode = Ure;
function zre(e) {
  typeof e < "u" && (Zt.isDebugMode = _z = e);
}
Zt.setDebugMode = zre;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.UserTiming = void 0;
  var r = Zt, t = typeof performance < "u" && !!performance.mark && performance.measure, n = t && !r.isProductionMode;
  (function(a) {
    function i(l) {
      return "startTask".concat(l.id);
    }
    function o(l) {
      return "endTask".concat(l.id);
    }
    function c(l) {
      n && performance.mark(i(l));
    }
    a.markStart = c;
    function s(l) {
      n && performance.mark(o(l));
    }
    a.markEnd = s;
    function u(l) {
      n && performance.measure("✳️ ".concat(l.name), i(l), o(l));
    }
    a.measure = u;
  })(e.UserTiming || (e.UserTiming = {}));
})(gz);
var $6;
function Gre() {
  if ($6) return Ou;
  $6 = 1, Object.defineProperty(Ou, "__esModule", { value: !0 }), Ou.ExecuteObservableChild = Ou.ExecuteInContext = Ou.CreateObservableCtx = Ou.ExecuteObservable = void 0;
  var e = Te, r = uE(), t = Eu, n = ry, a = gz;
  function i(b, g, _) {
    _ === void 0 && (_ = 250);
    var A = l(b, g, _), M = new S(A, A.root);
    return v(b, M);
  }
  Ou.ExecuteObservable = i;
  function o(b, g, _) {
    _ === void 0 && (_ = 250);
    var A = l(b, g, _);
    return new S(A, A.root);
  }
  Ou.CreateObservableCtx = o;
  function c(b, g) {
    return v(g, b);
  }
  Ou.ExecuteInContext = c;
  function s(b, g, _) {
    return b.runChild(g, _);
  }
  Ou.ExecuteObservableChild = s;
  function u(b) {
    return {
      taskId: b.id,
      taskName: b.name,
      message: "",
      startedTime: 0,
      canAbort: !0,
      isIndeterminate: !0,
      current: 0,
      max: 0
    };
  }
  function l(b, g, _) {
    var A = { abortRequested: !1, treeAborted: !1, reason: "" };
    return {
      updateRateMs: _,
      lastNotified: (0, t.now)(),
      observer: g,
      abortToken: A,
      taskId: b.id,
      root: { progress: u(b), children: [] },
      tryAbort: f(A)
    };
  }
  function f(b) {
    return function(g) {
      b.abortRequested = !0, b.reason = g || b.reason;
    };
  }
  function d(b) {
    return { progress: (0, e.__assign)({}, b.progress), children: b.children.map(d) };
  }
  function m(b) {
    return b.progress.canAbort && b.children.every(m);
  }
  function p(b) {
    return { root: d(b.root), canAbort: m(b.root), requestAbort: b.tryAbort };
  }
  function v(b, g) {
    return (0, e.__awaiter)(this, void 0, void 0, function() {
      var _, A;
      return (0, e.__generator)(this, function(M) {
        switch (M.label) {
          case 0:
            a.UserTiming.markStart(b), g.node.progress.startedTime = (0, t.now)(), M.label = 1;
          case 1:
            return M.trys.push([1, 3, , 7]), [4, b.f(g)];
          case 2:
            return _ = M.sent(), a.UserTiming.markEnd(b), a.UserTiming.measure(b), g.info.abortToken.abortRequested && h(g.info), [2, _];
          case 3:
            return A = M.sent(), r.Task.isAbort(A) ? (g.isAborted = !0, g.node.children.length > 0 ? [4, new Promise(function(P) {
              g.onChildrenFinished = P;
            })] : [3, 5]) : [3, 6];
          case 4:
            M.sent(), M.label = 5;
          case 5:
            b.onAbort && b.onAbort(), M.label = 6;
          case 6:
            throw A;
          case 7:
            return [
              2
              /*return*/
            ];
        }
      });
    });
  }
  function h(b) {
    throw b.abortToken.treeAborted || (b.abortToken.treeAborted = !0, y(b.root), C(b, (0, t.now)())), r.Task.Aborted(b.abortToken.reason);
  }
  function y(b) {
    var g = b.progress;
    g.isIndeterminate = !0, g.canAbort = !1, g.message = "Aborting...";
    for (var _ = 0, A = b.children; _ < A.length; _++) {
      var M = A[_];
      y(M);
    }
  }
  function C(b, g) {
    b.lastNotified = g;
    var _ = p(b);
    b.observer(_);
  }
  var S = (
    /** @class */
    function() {
      function b(g, _) {
        this.isSynchronous = !1, this.isExecuting = !0, this.lastUpdatedTime = 0, this.onChildrenFinished = void 0, this.node = _, this.info = g;
      }
      return b.prototype.checkAborted = function() {
        this.info.abortToken.abortRequested && (this.isAborted = !0, h(this.info));
      }, Object.defineProperty(b.prototype, "shouldUpdate", {
        get: function() {
          return this.checkAborted(), (0, t.now)() - this.lastUpdatedTime > this.info.updateRateMs;
        },
        enumerable: !1,
        configurable: !0
      }), b.prototype.updateProgress = function(g) {
        if (this.checkAborted(), !!g) {
          var _ = this.node.progress;
          typeof g == "string" ? (_.message = g, _.isIndeterminate = !0) : (typeof g.canAbort < "u" && (_.canAbort = g.canAbort), typeof g.message < "u" && (_.message = g.message), typeof g.current < "u" && (_.current = g.current), typeof g.max < "u" && (_.max = g.max), _.isIndeterminate = typeof _.current > "u" || typeof _.max > "u", typeof g.isIndeterminate < "u" && (_.isIndeterminate = g.isIndeterminate));
        }
      }, b.prototype.update = function(g, _) {
        if (this.lastUpdatedTime = (0, t.now)(), this.updateProgress(g), !_)
          return C(this.info, this.lastUpdatedTime), this.checkAborted(), n.Scheduler.immediatePromise();
      }, b.prototype.runChild = function(g, _) {
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var A, M, P, T, x, w, E;
          return (0, e.__generator)(this, function(I) {
            switch (I.label) {
              case 0:
                this.updateProgress(_), A = { progress: u(g), children: [] }, M = this.node.children, M.push(A), P = new b(this.info, A), I.label = 1;
              case 1:
                return I.trys.push([1, 3, 4, 5]), [4, v(g, P)];
              case 2:
                return [2, I.sent()];
              case 3:
                if (T = I.sent(), r.Task.isAbort(T) && this.isAborted)
                  return [2, void 0];
                throw T;
              case 4:
                if (x = M.indexOf(A), x >= 0) {
                  for (w = x, E = M.length - 1; w < E; w++)
                    M[w] = M[w + 1];
                  M.pop();
                }
                return M.length === 0 && this.onChildrenFinished && this.onChildrenFinished(), [
                  7
                  /*endfinally*/
                ];
              case 5:
                return [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, b;
    }()
  );
  return Ou;
}
var us = {};
Object.defineProperty(us, "__esModule", { value: !0 });
us.SyncRuntimeContext = us.SynchronousRuntimeContext = void 0;
var bz = (
  /** @class */
  function() {
    function e() {
      this.shouldUpdate = !1, this.isSynchronous = !0;
    }
    return e.prototype.update = function(r, t) {
    }, e;
  }()
);
us.SynchronousRuntimeContext = bz;
us.SyncRuntimeContext = new bz();
var K6;
function uE() {
  if (K6) return mh;
  K6 = 1, Object.defineProperty(mh, "__esModule", { value: !0 }), mh.Task = void 0;
  var e = Te, r = Gre(), t = us, n = Ra, a;
  return function(i) {
    var o = (
      /** @class */
      function() {
        function h(y, C, S) {
          this.name = y, this.f = C, this.onAbort = S, this.id = v();
        }
        return h.prototype.run = function(y, C) {
          return C === void 0 && (C = 250), y ? (0, r.ExecuteObservable)(this, y, C) : this.f(t.SyncRuntimeContext);
        }, h.prototype.runAsChild = function(y, C) {
          return y.isSynchronous ? this.f(t.SyncRuntimeContext) : (0, r.ExecuteObservableChild)(y, this, C);
        }, h.prototype.runInContext = function(y) {
          return y.isSynchronous ? this.f(t.SyncRuntimeContext) : (0, r.ExecuteInContext)(y, this);
        }, h;
      }()
    );
    function c(h) {
      var y = h;
      return !!h && typeof y.id == "number" && typeof y.name == "string" && !!y.run;
    }
    i.is = c;
    function s(h) {
      return !!h && !!h.isAborted;
    }
    i.isAbort = s;
    function u(h) {
      return { isAborted: !0, reason: h, toString: function() {
        return "Aborted".concat(h ? ": " + h : "");
      } };
    }
    i.Aborted = u;
    function l(h, y, C) {
      return new o(h, y, C);
    }
    i.create = l;
    function f(h, y) {
      var C = this;
      return l(h, function(S) {
        return (0, e.__awaiter)(C, void 0, void 0, function() {
          return (0, e.__generator)(this, function(b) {
            return [2, y];
          });
        });
      });
    }
    i.constant = f;
    function d() {
      var h = this;
      return l("", function(y) {
        return (0, e.__awaiter)(h, void 0, void 0, function() {
          return (0, e.__generator)(this, function(C) {
            return [
              2
              /*return*/
            ];
          });
        });
      });
    }
    i.empty = d;
    function m(h, y) {
      var C = this;
      return l(h, function(S) {
        return (0, e.__awaiter)(C, void 0, void 0, function() {
          return (0, e.__generator)(this, function(b) {
            throw new Error(y);
          });
        });
      });
    }
    i.fail = m;
    function p(h, y) {
      return c(h) ? y ? h.runInContext(y) : h.run() : h;
    }
    i.resolveInContext = p;
    var v = (0, n.idFactory)(0, 1073741823);
  }(a || (a = {})), mh.Task = a, mh;
}
var tS = {};
Object.defineProperty(tS, "__esModule", { value: !0 });
tS.RuntimeContext = void 0;
var qre = us, rM;
(function(e) {
  e.Synchronous = qre.SyncRuntimeContext;
})(rM || (rM = {}));
tS.RuntimeContext = rM;
var nS = {};
Object.defineProperty(nS, "__esModule", { value: !0 });
nS.Progress = void 0;
var tM;
(function(e) {
  function r(n, a) {
    a === void 0 && (a = "");
    var i = n.progress;
    if (!n.children.length)
      return i.isIndeterminate ? "".concat(a).concat(i.taskName, ": ").concat(i.message) : "".concat(a).concat(i.taskName, ": [").concat(i.current, "/").concat(i.max, "] ").concat(i.message);
    var o = a + "  |_ ", c = n.children.map(function(s) {
      return r(s, o);
    });
    return i.isIndeterminate ? "".concat(a).concat(i.taskName, ": ").concat(i.message, `
`).concat(c.join(`
`)) : "".concat(a).concat(i.taskName, ": [").concat(i.current, "/").concat(i.max, "] ").concat(i.message, `
`).concat(c.join(`
`));
  }
  function t(n) {
    return r(n.root);
  }
  e.format = t;
})(tM || (tM = {}));
nS.Progress = tM;
var aS = {};
Object.defineProperty(aS, "__esModule", { value: !0 });
aS.MultistepTask = void 0;
var W6 = Te, Hre = uE();
function jre(e, r, t, n) {
  var a = this;
  return function(i) {
    return Hre.Task.create(e, function(o) {
      return (0, W6.__awaiter)(a, void 0, void 0, function() {
        return (0, W6.__generator)(this, function(c) {
          return [2, t(i, function(s) {
            return o.update({ message: "".concat(r[s]), current: s + 1, max: r.length });
          }, o)];
        });
      });
    }, n);
  };
}
aS.MultistepTask = jre;
var iS = {};
Object.defineProperty(iS, "__esModule", { value: !0 });
iS.chunkedSubtask = void 0;
var X6 = Te, Ox = Eu;
function $re(e, r, t, n, a) {
  return (0, X6.__awaiter)(this, void 0, void 0, function() {
    var i, o, c, s, u, l, f;
    return (0, X6.__generator)(this, function(d) {
      switch (d.label) {
        case 0:
          if (i = Math.max(r, 0), o = 0, c = 0, e.isSynchronous)
            return n(Number.MAX_SAFE_INTEGER, t), [2, t];
          s = (0, Ox.now)(), u = 0, l = 0, d.label = 1;
        case 1:
          return (u = n(i, t)) > 0 ? (o += u, f = (0, Ox.now)() - s, l += f, c += f, e.shouldUpdate ? [4, a(e, t, o)] : [3, 3]) : [3, 4];
        case 2:
          d.sent(), i = Math.round(l * o / c) + 1, s = (0, Ox.now)(), l = 0, d.label = 3;
        case 3:
          return [3, 1];
        case 4:
          return e.shouldUpdate ? [4, a(e, t, o)] : [3, 6];
        case 5:
          d.sent(), d.label = 6;
        case 6:
          return [2, t];
      }
    });
  });
}
iS.chunkedSubtask = $re;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.chunkedSubtask = e.MultistepTask = e.Scheduler = e.Progress = e.RuntimeContext = e.Task = e.SyncRuntimeContext = void 0;
  var r = uE();
  Object.defineProperty(e, "Task", { enumerable: !0, get: function() {
    return r.Task;
  } });
  var t = tS;
  Object.defineProperty(e, "RuntimeContext", { enumerable: !0, get: function() {
    return t.RuntimeContext;
  } });
  var n = nS;
  Object.defineProperty(e, "Progress", { enumerable: !0, get: function() {
    return n.Progress;
  } });
  var a = ry;
  Object.defineProperty(e, "Scheduler", { enumerable: !0, get: function() {
    return a.Scheduler;
  } });
  var i = aS;
  Object.defineProperty(e, "MultistepTask", { enumerable: !0, get: function() {
    return i.MultistepTask;
  } });
  var o = iS;
  Object.defineProperty(e, "chunkedSubtask", { enumerable: !0, get: function() {
    return o.chunkedSubtask;
  } });
  var c = us;
  Object.defineProperty(e, "SyncRuntimeContext", { enumerable: !0, get: function() {
    return c.SyncRuntimeContext;
  } });
})(Kr);
var Ba = {}, ra = {};
Object.defineProperty(ra, "__esModule", { value: !0 });
ra.sizeUTF8 = ra.writeUTF8 = ra.readUTF8 = ra.writeUint = ra.readUint = ra.writeUshort = ra.readUshort = ra.toInt32 = ra.toUint32 = void 0;
function Kre(e) {
  return e >>> 0;
}
ra.toUint32 = Kre;
function Wre(e) {
  return e >> 0;
}
ra.toInt32 = Wre;
function Xre(e, r) {
  return e[r] | e[r + 1] << 8;
}
ra.readUshort = Xre;
function Yre(e, r, t) {
  e[r] = t & 255, e[r + 1] = t >> 8 & 255;
}
ra.writeUshort = Yre;
function Qre(e, r) {
  return e[r + 3] * (256 * 256 * 256) + (e[r + 2] << 16 | e[r + 1] << 8 | e[r]);
}
ra.readUint = Qre;
function Zre(e, r, t) {
  e[r] = t & 255, e[r + 1] = t >> 8 & 255, e[r + 2] = t >> 16 & 255, e[r + 3] = t >> 24 & 255;
}
ra.writeUint = Zre;
function Jre(e, r, t) {
  for (var n = "", a = 0; a < t; a++)
    n += String.fromCharCode(e[r + a]);
  return n;
}
function ete(e) {
  return e.length < 2 ? "0" + e : e;
}
function rte(e, r, t) {
  for (var n = "", a, i = 0; i < t; i++)
    n += "%" + ete(e[r + i].toString(16));
  try {
    a = decodeURIComponent(n);
  } catch {
    return Jre(e, r, t);
  }
  return a;
}
ra.readUTF8 = rte;
function tte(e, r, t) {
  for (var n = t.length, a = 0, i = 0; i < n; i++) {
    var o = t.charCodeAt(i);
    if (!(o & 4294967168))
      e[r + a] = o, a++;
    else if (!(o & 4294965248))
      e[r + a] = 192 | o >> 6, e[r + a + 1] = 128 | o >> 0 & 63, a += 2;
    else if (!(o & 4294901760))
      e[r + a] = 224 | o >> 12, e[r + a + 1] = 128 | o >> 6 & 63, e[r + a + 2] = 128 | o >> 0 & 63, a += 3;
    else if (!(o & 4294967295 - (1 << 21) + 1))
      e[r + a] = 240 | o >> 18, e[r + a + 1] = 128 | o >> 12 & 63, e[r + a + 2] = 128 | o >> 6 & 63, e[r + a + 3] = 128 | o >> 0 & 63, a += 4;
    else
      throw new Error("e");
  }
  return a;
}
ra.writeUTF8 = tte;
function nte(e) {
  for (var r = e.length, t = 0, n = 0; n < r; n++) {
    var a = e.charCodeAt(n);
    if (!(a & 4294967168))
      t++;
    else if (!(a & 4294965248))
      t += 2;
    else if (!(a & 4294901760))
      t += 3;
    else if (!(a & 4294967295 - (1 << 21) + 1))
      t += 4;
    else
      throw new Error("e");
  }
  return t;
}
ra.sizeUTF8 = nte;
var Tv = {};
Object.defineProperty(Tv, "__esModule", { value: !0 });
Tv.adler = Tv.crc = void 0;
var ate = function() {
  for (var e = new Uint32Array(256), r = 0; r < 256; r++) {
    for (var t = r, n = 0; n < 8; n++)
      t & 1 ? t = 3988292384 ^ t >>> 1 : t = t >>> 1;
    e[r] = t;
  }
  return e;
}();
function ite(e, r, t, n) {
  for (var a = 0; a < n; a++)
    e = ate[(e ^ r[t + a]) & 255] ^ e >>> 8;
  return e;
}
function ote(e, r, t) {
  return ite(4294967295, e, r, t) ^ 4294967295;
}
Tv.crc = ote;
function ute(e, r, t) {
  for (var n = 1, a = 0, i = r, o = r + t; i < o; ) {
    for (var c = Math.min(i + 5552, o); i < c; )
      n += e[i++], a += n;
    n = n % 65521, a = a % 65521;
  }
  return a << 16 | n;
}
Tv.adler = ute;
var oS = {}, sE = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.revCodes = e.makeCodes = e.codes2map = e.U = void 0, e.U = function() {
    var a = Uint16Array, i = Uint32Array;
    return {
      next_code: new a(16),
      bl_count: new a(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 a(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 i(32),
      flmap: new a(512),
      fltree: [],
      fdmap: new a(32),
      fdtree: [],
      lmap: new a(32768),
      ltree: [],
      ttree: [],
      dmap: new a(32768),
      dtree: [],
      imap: new a(512),
      itree: [],
      // rev9 : new u16(  512)
      rev15: new a(32768),
      lhst: new i(286),
      dhst: new i(30),
      ihst: new i(19),
      lits: new i(15e3),
      strt: new a(65536),
      prev: new a(32768)
    };
  }(), function() {
    for (var a = 32768, i = 0; i < a; i++) {
      var o = i;
      o = (o & 2863311530) >>> 1 | (o & 1431655765) << 1, o = (o & 3435973836) >>> 2 | (o & 858993459) << 2, o = (o & 4042322160) >>> 4 | (o & 252645135) << 4, o = (o & 4278255360) >>> 8 | (o & 16711935) << 8, e.U.rev15[i] = (o >>> 16 | o << 16) >>> 17;
    }
    function c(s, u, l) {
      for (; u-- !== 0; )
        s.push(0, l);
    }
    for (var i = 0; i < 32; i++)
      e.U.ldef[i] = e.U.of0[i] << 3 | e.U.exb[i], e.U.ddef[i] = e.U.df0[i] << 4 | e.U.dxb[i];
    c(e.U.fltree, 144, 8), c(e.U.fltree, 112, 9), c(e.U.fltree, 24, 7), c(e.U.fltree, 8, 8), t(e.U.fltree, 9), r(e.U.fltree, 9, e.U.flmap), n(e.U.fltree, 9), c(e.U.fdtree, 32, 5), t(e.U.fdtree, 5), r(e.U.fdtree, 5, e.U.fdmap), n(e.U.fdtree, 5), c(e.U.itree, 19, 0), c(e.U.ltree, 286, 0), c(e.U.dtree, 30, 0), c(e.U.ttree, 320, 0);
  }();
  function r(a, i, o) {
    for (var c = a.length, s = e.U.rev15, u = 0; u < c; u += 2)
      if (a[u + 1] !== 0)
        for (var l = u >> 1, f = a[u + 1], d = l << 4 | f, m = i - f, p = a[u] << m, v = p + (1 << m); p !== v; ) {
          var h = s[p] >>> 15 - i;
          o[h] = d, p++;
        }
  }
  e.codes2map = r;
  function t(a, i) {
    for (var o = a.length, c = e.U.bl_count, s = 0; s <= i; s++)
      c[s] = 0;
    for (var s = 1; s < o; s += 2)
      c[a[s]]++;
    var u = e.U.next_code, l = 0;
    c[0] = 0;
    for (var f = 1; f <= i; f++)
      l = l + c[f - 1] << 1, u[f] = l;
    for (var d = 0; d < o; d += 2) {
      var m = a[d + 1];
      m !== 0 && (a[d] = u[m], u[m]++);
    }
  }
  e.makeCodes = t;
  function n(a, i) {
    for (var o = e.U.rev15, c = 15 - i, s = 0; s < a.length; s += 2) {
      var u = a[s] << i - a[s + 1];
      a[s] = o[u] >>> c;
    }
  }
  e.revCodes = n;
})(sE);
Object.defineProperty(oS, "__esModule", { value: !0 });
oS._inflate = void 0;
var Y6 = Te, At = sE;
function ste(e, r) {
  var t = r === void 0;
  return r === void 0 && (r = new Uint8Array(e.length >>> 2 << 3)), {
    data: e,
    buf: r,
    noBuf: t,
    BFINAL: 0,
    off: 0,
    pos: 0
  };
}
function lte(e, r) {
  for (var t = e.data, n = e.noBuf, a = e.buf, i = e.BFINAL, o = e.off, c = e.pos, s = 0; i === 0 && s < r; ) {
    var u = void 0, l = void 0, f = 0, d = 0;
    i = Lx(t, c, 1), s += 1;
    var m = Lx(t, c + 1, 2);
    if (c += 3, m === 0) {
      c & 7 && (c += 8 - (c & 7));
      var p = (c >>> 3) + 4, v = t[p - 4] | t[p - 3] << 8;
      n && (a = Fx(a, o + v)), a.set(new Uint8Array(t.buffer, t.byteOffset + p, v), o), c = p + v << 3, o += v;
      continue;
    }
    if (n && (a = Fx(a, o + (1 << 17))), m === 1)
      u = At.U.flmap, l = At.U.fdmap, f = 511, d = 31;
    else if (m === 2) {
      var h = ed(t, c, 5) + 257, y = ed(t, c + 5, 5) + 1, C = ed(t, c + 10, 4) + 4;
      c += 14;
      for (var S = 0; S < 38; S += 2)
        At.U.itree[S] = 0, At.U.itree[S + 1] = 0;
      for (var b = 1, S = 0; S < C; S++) {
        var g = ed(t, c + S * 3, 3);
        At.U.itree[(At.U.ordr[S] << 1) + 1] = g, g > b && (b = g);
      }
      c += 3 * C, (0, At.makeCodes)(At.U.itree, b), (0, At.codes2map)(At.U.itree, b, At.U.imap), u = At.U.lmap, l = At.U.dmap, c = dte(At.U.imap, (1 << b) - 1, h + y, t, c, At.U.ttree);
      var _ = Q6(At.U.ttree, 0, h, At.U.ltree);
      f = (1 << _) - 1;
      var A = Q6(At.U.ttree, h, y, At.U.dtree);
      d = (1 << A) - 1, (0, At.makeCodes)(At.U.ltree, _), (0, At.codes2map)(At.U.ltree, _, u), (0, At.makeCodes)(At.U.dtree, A), (0, At.codes2map)(At.U.dtree, A, l);
    } else
      throw new Error("unknown BTYPE ".concat(m));
    for (; ; ) {
      var M = u[nM(t, c) & f];
      c += M & 15;
      var P = M >>> 4;
      if (!(P >>> 8))
        a[o++] = P;
      else {
        if (P === 256)
          break;
        var T = o + P - 254;
        if (P > 264) {
          var x = At.U.ldef[P - 257];
          T = o + (x >>> 3) + ed(t, c, x & 7), c += x & 7;
        }
        var w = l[nM(t, c) & d];
        c += w & 15;
        var E = w >>> 4, I = At.U.ddef[E], B = (I >>> 4) + Lx(t, c, I & 15);
        for (c += I & 15, n && (a = Fx(a, o + (1 << 17))); o < T; )
          a[o] = a[o++ - B], a[o] = a[o++ - B], a[o] = a[o++ - B], a[o] = a[o++ - B];
        o = T;
      }
    }
  }
  e.buf = a, e.BFINAL = i, e.off = o, e.pos = c;
}
function cte(e, r, t) {
  return (0, Y6.__awaiter)(this, void 0, void 0, function() {
    var n;
    return (0, Y6.__generator)(this, function(a) {
      switch (a.label) {
        case 0:
          if (r[0] === 3 && r[1] === 0)
            return [2, t || new Uint8Array(0)];
          n = ste(r, t), a.label = 1;
        case 1:
          return n.BFINAL !== 0 ? [3, 4] : e.shouldUpdate ? [4, e.update({ message: "Inflating blocks...", current: n.pos, max: r.length })] : [3, 3];
        case 2:
          a.sent(), a.label = 3;
        case 3:
          return lte(n, 100), [3, 1];
        case 4:
          return [2, n.buf.length === n.off ? n.buf : n.buf.slice(0, n.off)];
      }
    });
  });
}
oS._inflate = cte;
function Fx(e, r) {
  var t = e.length;
  if (r <= t)
    return e;
  var n = new Uint8Array(Math.max(t << 1, r));
  return n.set(e, 0), n;
}
function dte(e, r, t, n, a, i) {
  for (var o = 0; o < t; ) {
    var c = e[nM(n, a) & r];
    a += c & 15;
    var s = c >>> 4;
    if (s <= 15)
      i[o] = s, o++;
    else {
      var u = 0, l = 0;
      s === 16 ? (l = 3 + ed(n, a, 2), a += 2, u = i[o - 1]) : s === 17 ? (l = 3 + ed(n, a, 3), a += 3) : s === 18 && (l = 11 + ed(n, a, 7), a += 7);
      for (var f = o + l; o < f; )
        i[o] = u, o++;
    }
  }
  return a;
}
function Q6(e, r, t, n) {
  for (var a = 0, i = 0, o = n.length >>> 1; i < t; ) {
    var c = e[i + r];
    n[i << 1] = 0, n[(i << 1) + 1] = c, c > a && (a = c), i++;
  }
  for (; i < o; )
    n[i << 1] = 0, n[(i << 1) + 1] = 0, i++;
  return a;
}
function ed(e, r, t) {
  return (e[r >>> 3] | e[(r >>> 3) + 1] << 8) >>> (r & 7) & (1 << t) - 1;
}
function Lx(e, r, t) {
  return (e[r >>> 3] | e[(r >>> 3) + 1] << 8 | e[(r >>> 3) + 2] << 16) >>> (r & 7) & (1 << t) - 1;
}
function nM(e, r) {
  return (e[r >>> 3] | e[(r >>> 3) + 1] << 8 | e[(r >>> 3) + 2] << 16) >>> (r & 7);
}
var uS = {}, sS = {};
Object.defineProperty(sS, "__esModule", { value: !0 });
sS._hufTree = void 0;
function fte(e, r, t) {
  for (var n = [], a = e.length, i = r.length, o = 0; o < i; o += 2)
    r[o] = 0, r[o + 1] = 0;
  for (var o = 0; o < a; o++)
    e[o] !== 0 && n.push({ lit: o, f: e[o], d: void 0 });
  var c = n.length, s = n.slice(0);
  if (c === 0)
    return 0;
  if (c === 1) {
    var u = n[0].lit, l = u === 0 ? 1 : 0;
    return r[(u << 1) + 1] = 1, r[(l << 1) + 1] = 1, 1;
  }
  n.sort(function(y, C) {
    return y.f - C.f;
  });
  var f = n[0], d = n[1], m = 0, p = 1, v = 2;
  for (n[0] = {
    lit: -1,
    f: f.f + d.f,
    l: f,
    r: d,
    d: 0
  }; p !== c - 1; )
    m !== p && (v === c || n[m].f < n[v].f) ? f = n[m++] : f = n[v++], m !== p && (v === c || n[m].f < n[v].f) ? d = n[m++] : d = n[v++], n[p++] = {
      lit: -1,
      f: f.f + d.f,
      l: f,
      r: d,
      d: void 0
    };
  var h = aM(n[p - 1], 0);
  h > t && (mte(s, t, h), h = t);
  for (var o = 0; o < c; o++)
    r[(s[o].lit << 1) + 1] = s[o].d;
  return h;
}
sS._hufTree = fte;
function aM(e, r) {
  return e.lit !== -1 ? (e.d = r, r) : Math.max(aM(e.l, r + 1), aM(e.r, r + 1));
}
function mte(e, r, t) {
  var n = 0, a = 0, i = 1 << t - r;
  for (e.sort(function(c, s) {
    return s.d === c.d ? c.f - s.f : s.d - c.d;
  }), n = 0; n < e.length && e[n].d > r; n++) {
    var o = e[n].d;
    e[n].d = r, a += i - (1 << t - o);
  }
  for (a = a >>> t - r; a > 0; ) {
    var o = e[n].d;
    o < r ? (e[n].d++, a -= 1 << r - o - 1) : n++;
  }
  for (; n >= 0; n--)
    e[n].d === r && a < 0 && (e[n].d--, a++);
  a !== 0 && console.log("debt left");
}
Object.defineProperty(uS, "__esModule", { value: !0 });
uS._deflateRaw = void 0;
var Z6 = Te, vte = Ft, kx = sS, or = sE;
function pte(e, r, t, n) {
  var a = or.U.lits, i = or.U.strt, o = or.U.prev;
  return {
    data: e,
    out: r,
    opt: gte[n],
    i: 0,
    pos: t << 3,
    cvrd: 0,
    dlen: e.length,
    li: 0,
    lc: 0,
    bs: 0,
    ebits: 0,
    c: 0,
    nc: 0,
    lits: a,
    strt: i,
    prev: o
  };
}
function hte(e, r) {
  for (var t = e.data, n = e.dlen, a = e.out, i = e.opt, o = e.i, c = e.pos, s = e.cvrd, u = e.li, l = e.lc, f = e.bs, d = e.ebits, m = e.c, p = e.nc, v = or.U.lits, h = or.U.strt, y = or.U.prev, C = Math.min(o + r, n); o < C; o++) {
    if (m = p, o + 1 < n - 2) {
      p = lE(t, o + 1);
      var S = o + 1 & 32767;
      y[S] = h[p], h[p] = S;
    }
    if (s <= o) {
      (u > 14e3 || l > 26697) && n - o > 100 && (s < o && (v[u] = o - s, u += 2, s = o), c = Sz(o === n - 1 || s === n ? 1 : 0, v, u, d, t, f, o - f, a, c), u = l = d = 0, f = o);
      var b = 0;
      if (o < n - 2 && (b = _te(t, o, y, m, Math.min(i[2], n - o), i[3])), b !== 0) {
        var g = b >>> 16, _ = b & 65535, A = rI(g, or.U.of0);
        or.U.lhst[257 + A]++;
        var M = rI(_, or.U.df0);
        or.U.dhst[M]++, d += or.U.exb[A] + or.U.dxb[M], v[u] = g << 23 | o - s, v[u + 1] = _ << 16 | A << 8 | M, u += 2, s = o + g;
      } else
        or.U.lhst[t[o]]++;
      l++;
    }
  }
  e.i = o, e.pos = c, e.cvrd = s, e.li = u, e.lc = l, e.bs = f, e.ebits = d, e.c = m, e.nc = p;
}
var gte = [
  /*      good lazy nice chain */
  /* 0 */
  [0, 0, 0, 0, 0],
  /* 1 */
  [4, 4, 8, 4, 0],
  /* 2 */
  [4, 5, 16, 8, 0],
  /* 3 */
  [4, 6, 16, 16, 0],
  /* 4 */
  [4, 10, 16, 32, 0],
  /* 5 */
  [8, 16, 32, 32, 0],
  /* 6 */
  [8, 16, 128, 128, 0],
  /* 7 */
  [8, 32, 128, 256, 0],
  /* 8 */
  [32, 128, 258, 1024, 1],
  /* 9 */
  [32, 258, 258, 4096, 1]
  /* max compression */
];
function yte(e, r, t, n, a) {
  return (0, Z6.__awaiter)(this, void 0, void 0, function() {
    var i, o, c, s, u, l, f, d, m, p, v, h;
    return (0, Z6.__generator)(this, function(y) {
      switch (y.label) {
        case 0:
          if (i = pte(r, t, n, a), o = i.dlen, a === 0) {
            for (c = i.i, s = i.pos; c < o; )
              u = Math.min(65535, o - c), qf(t, s, c + u === o ? 1 : 0), s = Cz(r, c, u, t, s + 8), c += u;
            return [2, s >>> 3];
          }
          o > 2 && (i.nc = lE(r, 0), i.strt[i.nc] = 0), y.label = 1;
        case 1:
          return i.i < o ? e.shouldUpdate ? [4, e.update({
            message: "Deflating...",
            current: i.i,
            max: o
          })] : [3, 3] : [3, 4];
        case 2:
          y.sent(), y.label = 3;
        case 3:
          return hte(i, 1024 * 1024), [3, 1];
        case 4:
          for (l = i.li, f = i.cvrd, d = i.pos, m = i.i, p = i.lits, v = i.bs, h = i.ebits, (v !== m || r.length === 0) && (f < m && (p[l] = m - f, l += 2, f = m), d = Sz(1, p, l, h, r, v, m - v, t, d)); d & 7; )
            d++;
          return [2, d >>> 3];
      }
    });
  });
}
uS._deflateRaw = yte;
function _te(e, r, t, n, a, i) {
  var o = r & 32767, c = t[o], s = o - c + 32768 & 32767;
  if (c === o || n !== lE(e, r - s))
    return 0;
  for (var u = 0, l = 0, f = Math.min(32767, r); s <= f && --i !== 0 && c !== o; ) {
    if (u === 0 || e[r + u] === e[r + u - s]) {
      var d = bte(e, r, s);
      if (d > u) {
        if (u = d, l = s, u >= a)
          break;
        s + 2 < d && (d = s + 2);
        for (var m = 0, p = 0; p < d - 2; p++) {
          var v = r - s + p + 32768 & 32767, h = t[v], y = v - h + 32768 & 32767;
          y > m && (m = y, c = v);
        }
      }
    }
    o = c, c = t[o], s += o - c + 32768 & 32767;
  }
  return u << 16 | l;
}
function bte(e, r, t) {
  if (e[r] !== e[r - t] || e[r + 1] !== e[r + 1 - t] || e[r + 2] !== e[r + 2 - t])
    return 0;
  var n = r, a = Math.min(e.length, r + 258);
  for (r += 3; r < a && e[r] === e[r - t]; )
    r++;
  return r - n;
}
function lE(e, r) {
  return (e[r] << 8 | e[r + 1]) + (e[r + 2] << 4) & 65535;
}
function Sz(e, r, t, n, a, i, o, c, s) {
  or.U.lhst[256]++;
  var u = Ste(), l = u[0], f = u[1], d = u[2], m = u[3], p = u[4], v = u[5], h = u[6], y = u[7], C = (s + 3 & 7 ? 8 - (s + 3 & 7) : 0) + 32 + (o << 3), S = n + vh(or.U.fltree, or.U.lhst) + vh(or.U.fdtree, or.U.dhst), b = n + vh(or.U.ltree, or.U.lhst) + vh(or.U.dtree, or.U.dhst);
  b += 14 + 3 * v + vh(or.U.itree, or.U.ihst) + (or.U.ihst[16] * 2 + or.U.ihst[17] * 3 + or.U.ihst[18] * 7);
  for (var g = 0; g < 286; g++)
    or.U.lhst[g] = 0;
  for (var g = 0; g < 30; g++)
    or.U.dhst[g] = 0;
  for (var g = 0; g < 19; g++)
    or.U.ihst[g] = 0;
  var _ = C < S && C < b ? 0 : S < b ? 1 : 2;
  if (X_(c, s, e), X_(c, s + 1, _), s += 3, _ === 0) {
    for (; s & 7; )
      s++;
    s = Cz(a, i, o, c, s);
  } else {
    var A = void 0, M = void 0;
    if (_ === 1)
      A = or.U.fltree, M = or.U.fdtree;
    else if (_ === 2) {
      (0, or.makeCodes)(or.U.ltree, l), (0, or.revCodes)(or.U.ltree, l), (0, or.makeCodes)(or.U.dtree, f), (0, or.revCodes)(or.U.dtree, f), (0, or.makeCodes)(or.U.itree, d), (0, or.revCodes)(or.U.itree, d), A = or.U.ltree, M = or.U.dtree, qf(c, s, m - 257), s += 5, qf(c, s, p - 1), s += 5, qf(c, s, v - 4), s += 4;
      for (var P = 0; P < v; P++)
        qf(c, s + P * 3, or.U.itree[(or.U.ordr[P] << 1) + 1]);
      s += 3 * v, s = J6(h, or.U.itree, c, s), s = J6(y, or.U.itree, c, s);
    } else
      (0, vte.assertUnreachable)(_);
    for (var T = i, x = 0; x < t; x += 2) {
      for (var w = r[x], E = w >>> 23, I = T + (w & (1 << 23) - 1); T < I; )
        s = O1(a[T++], A, c, s);
      if (E !== 0) {
        var B = r[x + 1], D = B >> 16, N = B >> 8 & 255, O = B & 255;
        s = O1(257 + N, A, c, s), qf(c, s, E - or.U.of0[N]), s += or.U.exb[N], s = O1(O, M, c, s), X_(c, s, D - or.U.df0[O]), s += or.U.dxb[O], T += E;
      }
    }
    s = O1(256, A, c, s);
  }
  return s;
}
function Cz(e, r, t, n, a) {
  var i = a >>> 3;
  return n[i] = t, n[i + 1] = t >>> 8, n[i + 2] = 255 - n[i], n[i + 3] = 255 - n[i + 1], i += 4, n.set(new Uint8Array(e.buffer, r, t), i), a + (t + 4 << 3);
}
function Ste() {
  for (var e = (0, kx._hufTree)(or.U.lhst, or.U.ltree, 15), r = (0, kx._hufTree)(or.U.dhst, or.U.dtree, 15), t = [], n = eI(or.U.ltree, t), a = [], i = eI(or.U.dtree, a), o = 0; o < t.length; o += 2)
    or.U.ihst[t[o]]++;
  for (var o = 0; o < a.length; o += 2)
    or.U.ihst[a[o]]++;
  for (var c = (0, kx._hufTree)(or.U.ihst, or.U.itree, 7), s = 19; s > 4 && or.U.itree[(or.U.ordr[s - 1] << 1) + 1] === 0; )
    s--;
  return [e, r, c, n, i, s, t, a];
}
function vh(e, r) {
  for (var t = 0, n = 0; n < r.length; n++)
    t += r[n] * e[(n << 1) + 1];
  return t;
}
function J6(e, r, t, n) {
  for (var a = 0; a < e.length; a += 2) {
    var i = e[a], o = e[a + 1];
    n = O1(i, r, t, n);
    var c = i === 16 ? 2 : i === 17 ? 3 : 7;
    i > 15 && (qf(t, n, o), n += c);
  }
  return n;
}
function eI(e, r) {
  for (var t = e.length; t !== 2 && e[t - 1] === 0; )
    t -= 2;
  for (var n = 0; n < t; n += 2) {
    var a = e[n + 1], i = n + 3 < t ? e[n + 3] : -1, o = n + 5 < t ? e[n + 5] : -1, c = n === 0 ? -1 : e[n - 1];
    if (a === 0 && i === a && o === a) {
      for (var s = n + 5; s + 2 < t && e[s + 2] === a; )
        s += 2;
      var u = Math.min(s + 1 - n >>> 1, 138);
      u < 11 ? r.push(17, u - 3) : r.push(18, u - 11), n += u * 2 - 2;
    } else if (a === c && i === a && o === a) {
      for (var s = n + 5; s + 2 < t && e[s + 2] === a; )
        s += 2;
      var u = Math.min(s + 1 - n >>> 1, 6);
      r.push(16, u - 3), n += u * 2 - 2;
    } else
      r.push(a, 0);
  }
  return t >>> 1;
}
function rI(e, r) {
  var t = 0;
  return r[t | 16] <= e && (t |= 16), r[t | 8] <= e && (t |= 8), r[t | 4] <= e && (t |= 4), r[t | 2] <= e && (t |= 2), r[t | 1] <= e && (t |= 1), t;
}
function O1(e, r, t, n) {
  return X_(t, n, r[e << 1]), n + r[(e << 1) + 1];
}
function qf(e, r, t) {
  t = t << (r & 7);
  var n = r >>> 3;
  e[n] |= t, e[n + 1] |= t >>> 8;
}
function X_(e, r, t) {
  t = t << (r & 7);
  var n = r >>> 3;
  e[n] |= t, e[n + 1] |= t >>> 8, e[n + 2] |= t >>> 16;
}
Object.defineProperty(Ba, "__esModule", { value: !0 });
Ba.zip = Ba.Zip = Ba.deflate = Ba.ungzip = Ba.inflate = Ba.inflateRaw = Ba.unzip = Ba.Unzip = void 0;
var Co = Te, it = ra, cE = Tv, Cte = oS, Az = uS, xz = Kr;
function Ate(e, r) {
  return r === void 0 && (r = !1), xz.Task.create("Unzip", function(t) {
    return Tz(t, e, r);
  });
}
Ba.Unzip = Ate;
function Tz(e, r, t) {
  return t === void 0 && (t = !1), (0, Co.__awaiter)(this, void 0, void 0, function() {
    var n, a, i, o, c, s, u, l, f, d, m, p, v;
    return (0, Co.__generator)(this, function(h) {
      switch (h.label) {
        case 0:
          for (n = /* @__PURE__ */ Object.create(null), a = new Uint8Array(r), i = a.length - 4; (0, it.readUint)(a, i) !== 101010256; )
            i--;
          o = i, o += 4, o += 4, c = (0, it.readUshort)(a, o), o += 2, o += 2, o += 4, s = (0, it.readUint)(a, o), o += 4, o = s, u = 0, h.label = 1;
        case 1:
          return u < c ? (o += 4, o += 4, o += 4, o += 4, o += 4, l = (0, it.readUint)(a, o), o += 4, f = (0, it.readUint)(a, o), o += 4, d = (0, it.readUshort)(a, o), m = (0, it.readUshort)(a, o + 2), p = (0, it.readUshort)(a, o + 4), o += 6, o += 8, v = (0, it.readUint)(a, o), o += 4, o += d + m + p, [4, xte(e, a, v, n, l, f, t)]) : [3, 4];
        case 2:
          h.sent(), h.label = 3;
        case 3:
          return u++, [3, 1];
        case 4:
          return [2, n];
      }
    });
  });
}
Ba.unzip = Tz;
function xte(e, r, t, n, a, i, o) {
  return (0, Co.__awaiter)(this, void 0, void 0, function() {
    var c, s, u, l, f, d;
    return (0, Co.__generator)(this, function(m) {
      switch (m.label) {
        case 0:
          return t += 4, t += 2, t += 2, c = (0, it.readUshort)(r, t), t += 2, t += 4, t += 4, t += 8, s = (0, it.readUshort)(r, t), t += 2, u = (0, it.readUshort)(r, t), t += 2, l = (0, it.readUTF8)(r, t, s), t += s, t += u, o ? (n[l] = { size: i, csize: a }, [
            2
            /*return*/
          ]) : (f = new Uint8Array(r.buffer, t), c !== 0 ? [3, 1] : (n[l] = new Uint8Array(f.buffer.slice(t, t + a)), [3, 4]));
        case 1:
          return c !== 8 ? [3, 3] : (d = new Uint8Array(i), [4, lS(e, f, d)]);
        case 2:
          return m.sent(), n[l] = d, [3, 4];
        case 3:
          throw new Error("unknown compression method: ".concat(c));
        case 4:
          return [
            2
            /*return*/
          ];
      }
    });
  });
}
function lS(e, r, t) {
  return (0, Co.__awaiter)(this, void 0, void 0, function() {
    return (0, Co.__generator)(this, function(n) {
      return [2, (0, Cte._inflate)(e, r, t)];
    });
  });
}
Ba.inflateRaw = lS;
function Tte(e, r, t) {
  return lS(e, new Uint8Array(r.buffer, r.byteOffset + 2, r.length - 6), t);
}
Ba.inflate = Tte;
function Pte(e, r, t) {
  return (0, Co.__awaiter)(this, void 0, void 0, function() {
    var n, a, i, o, o, c, s, u, l, f;
    return (0, Co.__generator)(this, function(d) {
      switch (d.label) {
        case 0:
          if (n = r[3], a = 10, n & 4 && (i = (0, it.readUshort)(r, a), a += i), n & 8) {
            for (o = a; r[o] !== 0; )
              ++o;
            a = o + 1;
          }
          if (n & 16) {
            for (o = a; r[o] !== 0; )
              ++o;
            a = o + 1;
          }
          return n & 1 && (a += 2), c = (0, it.toInt32)((0, it.readUint)(r, r.length - 8)), s = (0, it.readUint)(r, r.length - 4), t === void 0 && (t = new Uint8Array(s)), u = new Uint8Array(r.buffer, r.byteOffset + a, r.length - a - 8), [4, lS(e, u, t)];
        case 1:
          return l = d.sent(), f = (0, cE.crc)(l, 0, l.length), c !== f && console.error("ungzip: checksums don't match"), [2, l];
      }
    });
  });
}
Ba.ungzip = Pte;
function Mte(e, r, t) {
  return (0, Co.__awaiter)(this, void 0, void 0, function() {
    var n, a, i;
    return (0, Co.__generator)(this, function(o) {
      switch (o.label) {
        case 0:
          return t === void 0 && (t = { level: 6 }), n = 0, a = new Uint8Array(50 + Math.floor(r.length * 1.1)), a[n] = 120, a[n + 1] = 156, n += 2, [4, (0, Az._deflateRaw)(e, r, a, n, t.level)];
        case 1:
          return n = o.sent(), i = (0, cE.adler)(r, 0, r.length), a[n + 0] = i >>> 24 & 255, a[n + 1] = i >>> 16 & 255, a[n + 2] = i >>> 8 & 255, a[n + 3] = i >>> 0 & 255, [2, new Uint8Array(a.buffer, 0, n + 4)];
      }
    });
  });
}
Ba.deflate = Mte;
function wte(e, r, t) {
  return (0, Co.__awaiter)(this, void 0, void 0, function() {
    var n, a;
    return (0, Co.__generator)(this, function(i) {
      switch (i.label) {
        case 0:
          return t === void 0 && (t = { level: 6 }), n = new Uint8Array(50 + Math.floor(r.length * 1.1)), [4, (0, Az._deflateRaw)(e, r, n, 0, t.level)];
        case 1:
          return a = i.sent(), [2, new Uint8Array(n.buffer, 0, a)];
      }
    });
  });
}
function Ete(e, r) {
  return r === void 0 && (r = !1), xz.Task.create("Zip", function(t) {
    return Pz(t, e, r);
  });
}
Ba.Zip = Ete;
function Pz(e, r, t) {
  return t === void 0 && (t = !1), (0, Co.__awaiter)(this, void 0, void 0, function() {
    var n, a, i, o, c, S, s, u, l, f, d, m, S, p, v, h, S, b, y, C, S, b, g, _;
    return (0, Co.__generator)(this, function(A) {
      switch (A.label) {
        case 0:
          n = 0, a = {}, i = [];
          for (o in r)
            i.push(o);
          c = 0, A.label = 1;
        case 1:
          return c < i.length ? (S = i[c], s = !Dte(S) && !t, u = r[S], l = (0, cE.crc)(u, 0, u.length), f = a, d = S, _ = {
            cpr: s,
            usize: u.length,
            crc: l
          }, s ? [4, wte(e, u)] : [3, 3]) : [3, 6];
        case 2:
          return m = A.sent(), [3, 4];
        case 3:
          m = u, A.label = 4;
        case 4:
          f[d] = (_.file = m, _), A.label = 5;
        case 5:
          return c++, [3, 1];
        case 6:
          for (S in a)
            n += a[S].file.length + 30 + 46 + 2 * (0, it.sizeUTF8)(S);
          n += 22, p = new Uint8Array(n), v = 0, h = [];
          for (S in a)
            b = a[S], h.push(v), v = tI(p, v, S, b, 0);
          y = 0, C = v;
          for (S in a)
            b = a[S], h.push(v), v = tI(p, v, S, b, 1, h[y++]);
          return g = v - C, (0, it.writeUint)(p, v, 101010256), v += 4, v += 4, (0, it.writeUshort)(p, v, y), v += 2, (0, it.writeUshort)(p, v, y), v += 2, (0, it.writeUint)(p, v, g), v += 4, (0, it.writeUint)(p, v, C), v += 4, v += 2, [2, p.buffer];
      }
    });
  });
}
Ba.zip = Pz;
function Dte(e) {
  var r = e.split(".").pop().toLowerCase();
  return "png,jpg,jpeg,zip".indexOf(r) !== -1;
}
function tI(e, r, t, n, a, i) {
  i === void 0 && (i = 0);
  var o = n.file;
  (0, it.writeUint)(e, r, a === 0 ? 67324752 : 33639248), r += 4, a === 1 && (r += 2), (0, it.writeUshort)(e, r, 20), r += 2, (0, it.writeUshort)(e, r, 0), r += 2, (0, it.writeUshort)(e, r, n.cpr ? 8 : 0), r += 2, (0, it.writeUint)(e, r, 0), r += 4, (0, it.writeUint)(e, r, n.crc), r += 4, (0, it.writeUint)(e, r, o.length), r += 4, (0, it.writeUint)(e, r, n.usize), r += 4, (0, it.writeUshort)(e, r, (0, it.sizeUTF8)(t)), r += 2, (0, it.writeUshort)(e, r, 0), r += 2, a === 1 && (r += 2, r += 2, r += 6, (0, it.writeUint)(e, r, i), r += 4);
  var c = (0, it.writeUTF8)(e, r, t);
  return r += c, a === 0 && (e.set(o, r), r += o.length), r;
}
var Js = {};
Object.defineProperty(Js, "__esModule", { value: !0 });
Js.utf8ByteCount = Js.utf8Read = Js.utf8Write = void 0;
function Ite(e, r, t) {
  for (var n = 0, a = t.length; n < a; n++) {
    var i = t.charCodeAt(n);
    if (i < 128) {
      e[r++] = i >>> 0 & 127 | 0;
      continue;
    }
    if (i < 2048) {
      e[r++] = i >>> 6 & 31 | 192, e[r++] = i >>> 0 & 63 | 128;
      continue;
    }
    if (i < 65536) {
      e[r++] = i >>> 12 & 15 | 224, e[r++] = i >>> 6 & 63 | 128, e[r++] = i >>> 0 & 63 | 128;
      continue;
    }
    if (i < 1114112) {
      e[r++] = i >>> 18 & 7 | 240, e[r++] = i >>> 12 & 63 | 128, e[r++] = i >>> 6 & 63 | 128, e[r++] = i >>> 0 & 63 | 128;
      continue;
    }
    throw new Error("bad codepoint " + i);
  }
}
Js.utf8Write = Ite;
var Bte = function() {
  for (var e = [], r = 0; r < 1024; r++)
    e[r] = String.fromCharCode(r);
  return e;
}();
function Mz(e) {
  throw new Error(e);
}
function Nte(e, r, t) {
  for (var n = Bte, a = void 0, i = 0, o = [], c = 512, s = r, u = r + t; s < u; s++) {
    var l = e[s];
    l & 128 ? (l & 224) === 192 ? o[i++] = n[(l & 15) << 6 | e[++s] & 63] : (l & 240) === 224 ? o[i++] = String.fromCharCode((l & 15) << 12 | (e[++s] & 63) << 6 | (e[++s] & 63) << 0) : (l & 248) === 240 ? o[i++] = String.fromCharCode((l & 7) << 18 | (e[++s] & 63) << 12 | (e[++s] & 63) << 6 | (e[++s] & 63) << 0) : Mz("Invalid byte " + l.toString(16)) : o[i++] = n[l], i === c && (a = a || [], a[a.length] = o.join(""), i = 0);
  }
  return a ? (i > 0 && (a[a.length] = o.slice(0, i).join("")), a.join("")) : o.slice(0, i).join("");
}
var nI = typeof TextDecoder < "u" ? new TextDecoder() : void 0;
function Vte(e, r, t) {
  if (nI) {
    var n = r || t !== e.length ? e.subarray(r, r + t) : e;
    return nI.decode(n);
  } else
    return Nte(e, r, t);
}
Js.utf8Read = Vte;
function Rte(e) {
  for (var r = 0, t = 0, n = e.length; t < n; t++) {
    var a = e.charCodeAt(t);
    if (a < 128) {
      r += 1;
      continue;
    }
    if (a < 2048) {
      r += 2;
      continue;
    }
    if (a < 65536) {
      r += 3;
      continue;
    }
    if (a < 1114112) {
      r += 4;
      continue;
    }
    Mz("bad codepoint " + a);
  }
  return r;
}
Js.utf8ByteCount = Rte;
var aI;
function Ote() {
  return aI || (aI = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.ajaxGetMany = e.ajaxGet = e.readFromFile = e.readUint8ArrayFromFile = e.readStringFromFile = e.DataCompressionMethod = void 0;
    var r = Te, t = Kr, n = Ba, a = Js, i = ty(), o = XMLHttpRequest, c;
    (function(x) {
      x[x.None = 0] = "None", x[x.Gzip = 1] = "Gzip", x[x.Zip = 2] = "Zip";
    })(c = e.DataCompressionMethod || (e.DataCompressionMethod = {}));
    function s(x) {
      return S(x, "string");
    }
    e.readStringFromFile = s;
    function u(x) {
      return S(x, "binary");
    }
    e.readUint8ArrayFromFile = u;
    function l(x, w) {
      return S(x, w);
    }
    e.readFromFile = l;
    function f(x) {
      return typeof x == "string" ? A(x, x, "string") : A(x.title, x.url, x.type || "string", x.body, x.headers);
    }
    e.ajaxGet = f;
    function d(x) {
      if (x instanceof FileReader)
        return x.readyState === FileReader.DONE;
      if (x instanceof XMLHttpRequest)
        return x.readyState === XMLHttpRequest.DONE;
      throw new Error("unknown data type");
    }
    function m(x) {
      return x ? "Failed to download data. Possible reasons: Resource is not available, or CORS is not allowed on the server." : "Failed to open file.";
    }
    function p(x, w, E) {
      return new Promise(function(I, B) {
        if (d(E)) {
          var D = E.error;
          D != null ? B(D ?? m(E instanceof XMLHttpRequest)) : I(E);
          return;
        }
        var N = !1;
        E.onerror = function(O) {
          if (!N) {
            var V = O.target.error;
            B(V ?? m(E instanceof XMLHttpRequest));
          }
        }, E.onprogress = function(O) {
          if (!(!x.shouldUpdate || N))
            try {
              O.lengthComputable ? x.update({
                message: w,
                isIndeterminate: !1,
                current: O.loaded,
                max: O.total
              }) : x.update({
                message: "".concat(w, " ").concat((O.loaded / 1024 / 1024).toFixed(2), " MB"),
                isIndeterminate: !0
              });
            } catch (V) {
              N = !0, B(V);
            }
        }, E.onload = function(O) {
          I(E);
        };
      });
    }
    function v(x) {
      return /\.gz$/i.test(x) ? c.Gzip : /\.zip$/i.test(x) ? c.Zip : c.None;
    }
    var h = /^(__MACOSX|.DS_Store)/;
    function y(x, w, E) {
      return (0, r.__awaiter)(this, void 0, void 0, function() {
        var I, B, D;
        return (0, r.__generator)(this, function(N) {
          switch (N.label) {
            case 0:
              switch (I = E, I) {
                case c.None:
                  return [3, 1];
                case c.Gzip:
                  return [3, 2];
                case c.Zip:
                  return [3, 3];
              }
              return [3, 5];
            case 1:
              return [2, w];
            case 2:
              return [2, (0, n.ungzip)(x, w)];
            case 3:
              return [4, (0, n.unzip)(x, w.buffer)];
            case 4:
              if (B = N.sent(), D = Object.keys(B).filter(function(O) {
                return !h.test(O);
              }), D.length !== 1)
                throw new Error("can only decompress zip files with a single entry");
              return [2, B[D[0]]];
            case 5:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }
    function C(x, w, E, I) {
      return (0, r.__awaiter)(this, void 0, void 0, function() {
        var B, D, N, O;
        return (0, r.__generator)(this, function(V) {
          switch (V.label) {
            case 0:
              if (B = w.result, D = B instanceof ArrayBuffer ? new Uint8Array(B) : B, D === null)
                throw new Error("no data given");
              if (I === c.None) return [3, 4];
              if (!(D instanceof Uint8Array))
                throw new Error("need Uint8Array for decompression");
              return [4, y(x, D, I)];
            case 1:
              return N = V.sent(), E !== "string" ? [3, 3] : [4, x.update({ message: "Decoding text..." })];
            case 2:
              return V.sent(), D = (0, a.utf8Read)(N, 0, N.length), [3, 4];
            case 3:
              D = N, V.label = 4;
            case 4:
              return E === "binary" && D instanceof Uint8Array ? [2, D] : [3, 5];
            case 5:
              return E === "zip" && D instanceof Uint8Array ? [4, (0, n.unzip)(x, D.buffer)] : [3, 7];
            case 6:
              return [2, V.sent()];
            case 7:
              if (E === "string" && typeof D == "string")
                return [2, D];
              if (E === "xml" && typeof D == "string")
                return O = new DOMParser(), [2, O.parseFromString(D, "application/xml")];
              if (E === "json" && typeof D == "string")
                return [2, JSON.parse(D)];
              V.label = 8;
            case 8:
              throw new Error("could not get requested response data '".concat(E, "'"));
          }
        });
      });
    }
    function S(x, w) {
      var E = this, I = void 0;
      return t.Task.create("Read File", function(B) {
        return (0, r.__awaiter)(E, void 0, void 0, function() {
          var D, N;
          return (0, r.__generator)(this, function(O) {
            switch (O.label) {
              case 0:
                return O.trys.push([0, , 5, 6]), I = new FileReader(), D = w === "zip" ? c.None : v(x.name), w === "binary" || w === "zip" || D !== c.None ? I.readAsArrayBuffer(x) : I.readAsText(x), [4, B.update({ message: "Opening file...", canAbort: !0 })];
              case 1:
                return O.sent(), [4, p(B, "Reading...", I)];
              case 2:
                return N = O.sent(), [4, B.update({ message: "Processing file...", canAbort: !1 })];
              case 3:
                return O.sent(), [4, C(B, N, w, D)];
              case 4:
                return [2, O.sent()];
              case 5:
                return I = void 0, [
                  7
                  /*endfinally*/
                ];
              case 6:
                return [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, function() {
        I && I.abort();
      });
    }
    var b = (
      /** @class */
      function() {
        function x() {
        }
        return x.get = function() {
          return this.pool.length ? this.pool.pop() : new o();
        }, x.emptyFunc = function() {
        }, x.deposit = function(w) {
          this.pool.length < this.poolSize && (w.onabort = x.emptyFunc, w.onerror = x.emptyFunc, w.onload = x.emptyFunc, w.onprogress = x.emptyFunc, this.pool.push(w));
        }, x.pool = [], x.poolSize = 15, x;
      }()
    );
    function g(x, w) {
      if (x.status >= 200 && x.status < 400) {
        var E = x.response;
        if (b.deposit(x), (w === "binary" || w === "zip") && E instanceof ArrayBuffer)
          return new Uint8Array(E);
        if (w === "string" && typeof E == "string")
          return E;
        if (w === "xml" && E instanceof XMLDocument)
          return E;
        if (w === "json" && typeof E == "object")
          return E;
        throw new Error("could not get requested response data '".concat(w, "'"));
      } else
        throw b.deposit(x), new Error("Download failed with status code ".concat(x.status));
    }
    function _(x) {
      switch (x) {
        case "json":
          return "json";
        case "xml":
          return "document";
        case "string":
          return "text";
        case "binary":
          return "arraybuffer";
        case "zip":
          return "arraybuffer";
      }
    }
    function A(x, w, E, I, B) {
      var D = this, N = void 0;
      return t.Task.create(x || "Download", function(O) {
        return (0, r.__awaiter)(D, void 0, void 0, function() {
          var V, k, G, L, R, F, U;
          return (0, r.__generator)(this, function(H) {
            switch (H.label) {
              case 0:
                if (N = b.get(), N.open(I ? "post" : "get", w, !0), B)
                  for (V = 0, k = B; V < k.length; V++)
                    G = k[V], L = G[0], R = G[1], N.setRequestHeader(L, R);
                return N.responseType = _(E), N.send(I), [4, O.update({ message: "Waiting for server...", canAbort: !0 })];
              case 1:
                return H.sent(), [4, p(O, "Downloading...", N)];
              case 2:
                return F = H.sent(), N = void 0, [4, O.update({ message: "Parsing response...", canAbort: !1 })];
              case 3:
                return H.sent(), U = g(F, E), [2, U];
            }
          });
        });
      }, function() {
        N && (N.abort(), N = void 0);
      });
    }
    function M(x, w, E, I) {
      return (0, r.__awaiter)(this, void 0, void 0, function() {
        var B, D, N, O, V, k, U, G, L, R, F, U, H;
        return (0, r.__generator)(this, function(q) {
          switch (q.label) {
            case 0:
              return B = E.length, D = new Array(E.length), [4, x.update({ message: "Downloading...", current: 0, max: B })];
            case 1:
              for (q.sent(), N = [], O = [], V = 0, k = Math.min(B, I); V < k; V++)
                U = E[V], N.push(T(V, U.id, w.resolve(i.Asset.getUrlAsset(w, U.url), U.isBinary ? "binary" : "string").runAsChild(x))), O.push(V);
              G = 0, q.label = 2;
            case 2:
              return N.length > 0 ? [4, Promise.race(N)] : [3, 6];
            case 3:
              if (L = q.sent(), R = E[L.index], F = O.indexOf(L.index), G++, L.kind === "error" && !R.canFail)
                throw new Error("".concat(R.url, ": ").concat(L.error));
              return x.shouldUpdate ? [4, x.update({ message: "Downloading...", current: G, max: B })] : [3, 5];
            case 4:
              q.sent(), q.label = 5;
            case 5:
              return D[L.index] = L, N = N.filter(P, F), O = O.filter(P, F), V < B && (U = E[V], H = w.resolve(i.Asset.getUrlAsset(w, U.url), U.isBinary ? "binary" : "string").runAsChild(x), N.push(T(V, U.id, H)), O.push(V), V++), [3, 2];
            case 6:
              return [2, D];
          }
        });
      });
    }
    e.ajaxGetMany = M;
    function P(x, w) {
      return this !== w;
    }
    function T(x, w, E) {
      return (0, r.__awaiter)(this, void 0, void 0, function() {
        var I, B;
        return (0, r.__generator)(this, function(D) {
          switch (D.label) {
            case 0:
              return D.trys.push([0, 2, , 3]), [4, E];
            case 1:
              return I = D.sent(), [2, { kind: "ok", result: I, index: x, id: w }];
            case 2:
              return B = D.sent(), [2, { kind: "error", error: B, index: x, id: w }];
            case 3:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }
  }(Rx)), Rx;
}
var iI;
function ty() {
  if (iI) return lf;
  iI = 1, Object.defineProperty(lf, "__esModule", { value: !0 }), lf.Asset = lf.AssetManager = void 0;
  var e = Te, r = Hg, t = wr(), n = Ote(), a = Kr, i;
  (function(c) {
    function s(v, h) {
      return (0, e.__assign)({ kind: "url", id: r.UUID.create22(), url: v }, h);
    }
    c.Url = s;
    function u(v) {
      return { kind: "file", id: r.UUID.create22(), name: v.name, file: v };
    }
    c.File = u;
    function l(v) {
      return (v == null ? void 0 : v.kind) === "url";
    }
    c.isUrl = l;
    function f(v) {
      return (v == null ? void 0 : v.kind) === "file";
    }
    c.isFile = f;
    function d(v, h, y) {
      return {
        data: v,
        dispose: function() {
          y.release(h);
        }
      };
    }
    c.Wrapper = d;
    function m(v) {
      return typeof v == "string" ? v : v.url;
    }
    c.getUrl = m;
    function p(v, h, y) {
      if (typeof h == "string") {
        var C = v.tryFindUrl(h, y);
        return C || s(h, { body: y });
      }
      return h;
    }
    c.getUrlAsset = p;
  })(i || (i = {})), lf.Asset = i;
  var o = (
    /** @class */
    function() {
      function c() {
        this._assets = /* @__PURE__ */ new Map();
      }
      return Object.defineProperty(c.prototype, "assets", {
        get: function() {
          return (0, t.iterableToArray)(this._assets.values());
        },
        enumerable: !1,
        configurable: !0
      }), c.prototype.tryFindUrl = function(s, u) {
        for (var l = this.assets.values(); ; ) {
          var f = l.next();
          if (f.done)
            return;
          var d = f.value.asset;
          if (i.isUrl(d) && d.url === s && (d.body || "") === (u || ""))
            return d;
        }
      }, c.prototype.set = function(s, u) {
        this._assets.set(s.id, { asset: s, file: u, refCount: 0 });
      }, c.prototype.get = function(s) {
        return this._assets.get(s);
      }, c.prototype.remove = function(s) {
        this._assets.delete(s);
      }, c.prototype.resolve = function(s, u, l) {
        var f = this;
        return l === void 0 && (l = !0), i.isUrl(s) ? a.Task.create("Download ".concat(s.title || s.url), function(d) {
          return (0, e.__awaiter)(f, void 0, void 0, function() {
            var m, p, v, h, y, C, S, b, g;
            return (0, e.__generator)(this, function(_) {
              switch (_.label) {
                case 0:
                  return this._assets.has(s.id) ? (m = this._assets.get(s.id), m.refCount++, v = (p = i).Wrapper, [4, (0, n.readFromFile)(m.file, u).runInContext(d)]) : [3, 2];
                case 1:
                  return [2, v.apply(p, [_.sent(), s, this])];
                case 2:
                  return l ? [3, 4] : (y = (h = i).Wrapper, [4, (0, n.ajaxGet)((0, e.__assign)((0, e.__assign)({}, s), { type: u })).runInContext(d)]);
                case 3:
                  return [2, y.apply(h, [_.sent(), s, this])];
                case 4:
                  return [4, (0, n.ajaxGet)((0, e.__assign)((0, e.__assign)({}, s), { type: "binary" })).runInContext(d)];
                case 5:
                  return C = _.sent(), S = new File([C], "raw-data"), this._assets.set(s.id, { asset: s, file: S, refCount: 1 }), g = (b = i).Wrapper, [4, (0, n.readFromFile)(S, u).runInContext(d)];
                case 6:
                  return [2, g.apply(b, [_.sent(), s, this])];
              }
            });
          });
        }) : a.Task.create("Read ".concat(s.name), function(d) {
          return (0, e.__awaiter)(f, void 0, void 0, function() {
            var m, p, v, h, y;
            return (0, e.__generator)(this, function(C) {
              switch (C.label) {
                case 0:
                  return this._assets.has(s.id) ? (m = this._assets.get(s.id), s.file = m.file, m.refCount++, v = (p = i).Wrapper, [4, (0, n.readFromFile)(m.file, u).runInContext(d)]) : [3, 2];
                case 1:
                  return [2, v.apply(p, [C.sent(), s, this])];
                case 2:
                  if (!(s.file instanceof File))
                    throw new Error("Cannot resolve file asset '".concat(s.name, "' (").concat(s.id, ")"));
                  return l && this._assets.set(s.id, { asset: s, file: s.file, refCount: 1 }), y = (h = i).Wrapper, [4, (0, n.readFromFile)(s.file, u).runInContext(d)];
                case 3:
                  return [2, y.apply(h, [C.sent(), s, this])];
              }
            });
          });
        });
      }, c.prototype.release = function(s) {
        var u = this._assets.get(s.id);
        u && (u.refCount--, u.refCount <= 0 && this._assets.delete(s.id));
      }, c;
    }()
  );
  return lf.AssetManager = o, lf;
}
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ParamDefinition = void 0;
  var r = Te, t = We(), n = Re, a = nn, i = cs, o = _c, c = ty();
  (function(s) {
    s.Essential = { isEssential: !0 };
    function u(ee, ne) {
      return ne && (ne.label && (ee.label = ne.label), ne.description && (ee.description = ne.description), ne.legend && (ee.legend = ne.legend), ne.fieldLabels && (ee.fieldLabels = ne.fieldLabels), ne.isHidden && (ee.isHidden = ne.isHidden), ne.shortLabel && (ee.shortLabel = ne.shortLabel), ne.twoColumns && (ee.twoColumns = ne.twoColumns), ne.isEssential && (ee.isEssential = ne.isEssential), ne.category && (ee.category = ne.category), ne.hideIf && (ee.hideIf = ne.hideIf), ne.help && (ee.help = ne.help)), ee;
    }
    function l(ee) {
      var ne = (0, r.__assign)({}, ee);
      return ne.isOptional = !0, ne;
    }
    s.Optional = l;
    function f(ee, ne) {
      return u({ type: "value", defaultValue: ee }, ne);
    }
    s.Value = f;
    function d(ee, ne, se) {
      return u({ type: "select", defaultValue: re(ee, ne), options: ne, cycle: se == null ? void 0 : se.cycle }, se);
    }
    s.Select = d;
    function m(ee, ne, se) {
      var ce = u({ type: "multi-select", defaultValue: ee, options: ne }, se);
      return se != null && se.emptyValue && (ce.emptyValue = se.emptyValue), ce;
    }
    s.MultiSelect = m;
    function p(ee, ne) {
      return u({ type: "boolean", defaultValue: ee }, ne);
    }
    s.Boolean = p;
    function v(ee, ne) {
      return ee === void 0 && (ee = ""), u({ type: "text", defaultValue: ee }, ne);
    }
    s.Text = v;
    function h(ee, ne) {
      var se = u({ type: "color", defaultValue: ee }, ne);
      return ne != null && ne.isExpanded && (se.isExpanded = ne.isExpanded), se;
    }
    s.Color = h;
    function y(ee, ne) {
      var se;
      if (typeof ee == "string") {
        var ce = (0, o.getColorListFromName)(ee);
        se = { kind: ce.type !== "qualitative" ? "interpolate" : "set", colors: ce.list };
      } else
        se = ee;
      return u({ type: "color-list", presetKind: (ne == null ? void 0 : ne.presetKind) || "all", defaultValue: se, offsets: !!(ne != null && ne.offsets) }, ne);
    }
    s.ColorList = y;
    function C(ee, ne, se) {
      return u(A({ type: "vec3", defaultValue: ee }, ne), se);
    }
    s.Vec3 = C;
    function S(ee, ne) {
      return u({ type: "mat4", defaultValue: ee }, ne);
    }
    s.Mat4 = S;
    function b(ee, ne) {
      var se = typeof ee == "string" ? c.Asset.Url(ee) : c.Asset.Url(ee.url, { body: ee.body }), ce = u({ type: "url", defaultValue: se }, ne);
      return ce;
    }
    s.Url = b;
    function g(ee) {
      var ne = u({ type: "file", defaultValue: null }, ee);
      return ee != null && ee.accept && (ne.accept = ee.accept), ne;
    }
    s.File = g;
    function _(ee) {
      var ne = u({ type: "file-list", defaultValue: null }, ee);
      return ee != null && ee.accept && (ne.accept = ee.accept), ne;
    }
    s.FileList = _;
    function A(ee, ne) {
      return ne && (typeof ne.min < "u" && (ee.min = ne.min), typeof ne.max < "u" && (ee.max = ne.max), typeof ne.step < "u" && (ee.step = ne.step)), ee;
    }
    function M(ee, ne, se) {
      var ce = u(A({ type: "number", defaultValue: ee }, ne), se);
      return se != null && se.immediateUpdate && (ce.immediateUpdate = !0), ce;
    }
    s.Numeric = M;
    function P(ee, ne, se) {
      return u(A({ type: "interval", defaultValue: ee }, ne), se);
    }
    s.Interval = P;
    function T(ee, ne) {
      return u({ type: "line-graph", defaultValue: ee }, ne);
    }
    s.LineGraph = T;
    function x(ee, ne) {
      var se = u({ type: "group", defaultValue: (ne == null ? void 0 : ne.customDefault) || F(ee), params: ee }, ne);
      return ne != null && ne.presets && (se.presets = ne.presets), ne != null && ne.isExpanded && (se.isExpanded = ne.isExpanded), ne != null && ne.isFlat && (se.isFlat = ne.isFlat), ne != null && ne.pivot && (se.pivot = ne.pivot), se;
    }
    s.Group = x;
    function w(ee) {
      return x({}, ee);
    }
    s.EmptyGroup = w;
    function E(ee, ne, se, ce) {
      var de = re(ee, ne);
      return u({
        type: "mapped",
        defaultValue: { name: de, params: se(de).defaultValue },
        select: d(de, ne, ce),
        map: se
      }, ce);
    }
    s.Mapped = E;
    function I(ee, ne, se) {
      var ce = se != null && se.options ? se.options : Object.keys(ne).map(function(me) {
        return [me, ne[me].label || (0, i.stringToWords)(me)];
      }), de = re(ee, ce);
      return u({
        type: "mapped",
        defaultValue: { name: de, params: ne[de].defaultValue },
        select: d(de, ce, se),
        map: function(me) {
          return ne[me];
        }
      }, se);
    }
    s.MappedStatic = I;
    function B(ee, ne, se) {
      return u({ type: "object-list", element: ee, getLabel: ne, ctor: D, defaultValue: (se == null ? void 0 : se.defaultValue) || [] }, se);
    }
    s.ObjectList = B;
    function D() {
      return F(this.element);
    }
    function N() {
      throw new Error("getValue not set. Fix runtime.");
    }
    function O(ee, ne, se) {
      var ce;
      return u({ type: "value-ref", defaultValue: { ref: (ce = se == null ? void 0 : se.defaultRef) !== null && ce !== void 0 ? ce : "", getValue: N }, getOptions: ee, resolveRef: ne }, se);
    }
    s.ValueRef = O;
    function V(ee) {
      var ne;
      return u({ type: "data-ref", defaultValue: { ref: (ne = ee == null ? void 0 : ee.defaultRef) !== null && ne !== void 0 ? ne : "", getValue: N } }, ee);
    }
    s.DataRef = V;
    function k(ee, ne, se) {
      return { type: "converted", defaultValue: ne(se.defaultValue), converted: se, fromValue: ee, toValue: ne };
    }
    s.Converted = k;
    function G(ee, ne, se, ce, de) {
      var me = Object.keys(ne).map(function(he) {
        return [he, he];
      });
      return u({ type: "conditioned", select: d(se(ee), me, de), defaultValue: ee, conditionParams: ne, conditionForValue: se, conditionedValue: ce }, de);
    }
    s.Conditioned = G;
    function L(ee, ne) {
      return u({ type: "script", defaultValue: ee }, ne);
    }
    s.Script = L;
    function R(ee) {
      return 0;
    }
    s.For = R;
    function F(ee) {
      for (var ne = {}, se = 0, ce = Object.keys(ee); se < ce.length; se++) {
        var de = ce[se];
        ee[de].isOptional || (ne[de] = ee[de].defaultValue);
      }
      return ne;
    }
    s.getDefaultValues = F;
    function U(ee, ne) {
      return function() {
        return ee(ne);
      };
    }
    function H(ee, ne, se) {
      if (ne) {
        if (ee.type === "value-ref") {
          var ce = ne;
          ce.ref ? ce.getValue = U(ee.resolveRef, ce.ref) : ce.getValue = function() {
            throw new Error("Unset ref in ValueRef value.");
          };
        } else if (ee.type === "data-ref") {
          var ce = ne;
          ce.ref ? ce.getValue = U(se, ce.ref) : ce.getValue = function() {
            throw new Error("Unset ref in ValueRef value.");
          };
        } else if (ee.type === "group")
          Y(ee.params, ne, se);
        else if (ee.type === "mapped") {
          var ce = ne, de = ee.map(ce.name);
          H(de, ce.params, se);
        } else if (ee.type === "object-list") {
          if (!K(ee.element))
            return;
          for (var me = 0, he = ne; me < he.length; me++) {
            var _e = he[me];
            Y(ee.element, _e, se);
          }
        }
      }
    }
    function q(ee) {
      if (ee.type === "value-ref" || ee.type === "data-ref")
        return !0;
      if (ee.type === "group") {
        if (K(ee.params))
          return !0;
      } else if (ee.type === "mapped")
        for (var ne = 0, se = ee.select.options; ne < se.length; ne++) {
          var ce = se[ne][0];
          if (q(ee.map(ce)))
            return !0;
        }
      else if (ee.type === "object-list")
        return K(ee.element);
      return !1;
    }
    function K(ee) {
      for (var ne = 0, se = Object.keys(ee); ne < se.length; ne++) {
        var ce = se[ne];
        if (q(ee[ce]))
          return !0;
      }
      return !1;
    }
    function Y(ee, ne, se) {
      for (var ce = 0, de = Object.keys(ee); ce < de.length; ce++) {
        var me = de[ce];
        H(ee[me], ne == null ? void 0 : ne[me], se);
      }
    }
    s.resolveRefs = Y;
    function X(ee, ne) {
      for (var se = 0, ce = Object.keys(ee); se < ce.length; se++) {
        var de = ce[se];
        ee[de].isOptional || (ee[de].defaultValue = ne[de]);
      }
    }
    s.setDefaultValues = X;
    function Z(ee) {
      return (0, a.deepClone)(ee);
    }
    s.clone = Z;
    function J(ee, ne) {
    }
    s.validate = J;
    function $(ee, ne, se) {
      if (ne === se)
        return !0;
      if (typeof ne != "object" || typeof se != "object")
        return !1;
      for (var ce = 0, de = Object.keys(ee); ce < de.length; ce++) {
        var me = de[ce];
        if (!Q(ee[me], ne[me], se[me]))
          return !1;
      }
      return !0;
    }
    s.areEqual = $;
    function Q(ee, ne, se) {
      if (ne === se)
        return !0;
      if (ee.type === "group")
        return $(ee.params, ne, se);
      if (ee.type === "mapped") {
        var ce = ne, de = se;
        if (ce.name !== de.name)
          return !1;
        var me = ee.map(ce.name);
        return Q(me, ce.params, de.params);
      } else if (ee.type === "multi-select") {
        var ce = ne, de = se;
        if (ce.length !== de.length)
          return !1;
        if (ce.length < 10) {
          for (var he = 0, _e = ce.length; he < _e; he++)
            if (ce[he] !== de[he] && de.indexOf(ce[he]) < 0)
              return !1;
        } else
          for (var Se = new Set(de), he = 0, _e = ce.length; he < _e; he++)
            if (ce[he] !== de[he] && !Se.has(ce[he]))
              return !1;
        return !0;
      } else {
        if (ee.type === "interval")
          return ne[0] === se[0] && ne[1] === se[1];
        if (ee.type === "line-graph") {
          var ce = ne, de = se;
          if (ce.length !== de.length)
            return !1;
          for (var he = 0, _e = ce.length; he < _e; he++)
            if (!n.Vec2.areEqual(ce[he], de[he]))
              return !1;
          return !0;
        } else {
          if (ee.type === "vec3")
            return n.Vec3.equals(ne, se);
          if (ee.type === "mat4")
            return n.Mat4.areEqual(ne, se, n.EPSILON);
          if (ee.type === "script") {
            var ce = ne, de = se;
            return ce.language === de.language && ce.expression === de.expression;
          } else if (ee.type === "object-list") {
            var ce = ne, de = se, Pe = ce.length;
            if (Pe !== de.length)
              return !1;
            for (var he = 0; he < Pe; he++)
              if (!$(ee.element, ce[he], de[he]))
                return !1;
            return !0;
          } else if (typeof ne == "object" && typeof se == "object")
            return (0, t.shallowEqualObjects)(ne, se);
        }
      }
      return !1;
    }
    s.isParamEqual = Q;
    function W(ee, ne, se) {
      if (ne === void 0)
        return (0, r.__assign)({}, se);
      if (se === void 0)
        return (0, r.__assign)({}, ne);
      for (var ce = /* @__PURE__ */ Object.create(null), de = 0, me = Object.keys(ee); de < me.length; de++) {
        var he = me[de];
        ce[he] = te(ee[he], ne[he], se[he]);
      }
      return ce;
    }
    s.merge = W;
    function te(ee, ne, se) {
      if (ne === void 0)
        return typeof se == "object" && !Array.isArray(se) ? (0, r.__assign)({}, se) : se;
      if (se === void 0)
        return typeof ne == "object" && !Array.isArray(ne) ? (0, r.__assign)({}, ne) : ne;
      if (ee.type === "group")
        return W(ee.params, ne, se);
      if (ee.type === "mapped") {
        var ce = ne, de = se;
        if (ce.name !== de.name)
          return (0, r.__assign)({}, de);
        var me = ee.map(de.name);
        return {
          name: de.name,
          params: te(me, ce.params, de.params)
        };
      } else return ee.type === "value" ? se : typeof ne == "object" && typeof se == "object" ? Array.isArray(se) ? se : (0, r.__assign)((0, r.__assign)({}, ne), se) : se;
    }
    s.mergeParam = te;
    function oe(ee, ne) {
      for (var se = 0, ce = ee.options; se < ce.length; se++) {
        var de = ce[se];
        if (de[0] === ne)
          return !0;
      }
      return !1;
    }
    function z(ee, ne, se) {
      if (ne == null)
        return se ? ee.defaultValue : void 0;
      if (ee.type === "value")
        return ne;
      if (ee.type === "group") {
        for (var ce = /* @__PURE__ */ Object.create(null), de = 0, me = Object.keys(ee.params); de < me.length; de++) {
          var he = me[de], _e = ee.params[he];
          ne[he] === void 0 ? se && (ce[he] = _e.defaultValue) : ce[he] = z(_e, ne[he], se);
        }
        return ce;
      } else if (ee.type === "mapped") {
        var Se = ne;
        if (typeof Se.name != "string")
          return ee.defaultValue;
        if (typeof Se.params > "u")
          return se ? ee.defaultValue : void 0;
        if (!oe(ee.select, Se.name))
          return ee.defaultValue;
        var _e = ee.map(Se.name);
        return {
          name: Se.name,
          params: z(_e, Se.params, se)
        };
      } else {
        if (ee.type === "select")
          return oe(ee, ne) ? ne : ee.defaultValue;
        if (ee.type === "multi-select") {
          if (!Array.isArray(ne))
            return ee.defaultValue;
          var ce = ne.filter(function(De) {
            return oe(this, De);
          }, ee);
          return ne.length > 0 && ce.length === 0 ? ee.defaultValue : ce;
        } else if (ee.type === "object-list")
          return Array.isArray(ne) ? ne.map(function(Pe) {
            return j(ee.element, Pe, se ? "all" : "skip");
          }) : ee.defaultValue;
      }
      return ne;
    }
    function j(ee, ne, se) {
      if (typeof ne != "object" || ne === null)
        return se ? F(ee) : ne;
      for (var ce = /* @__PURE__ */ Object.create(null), de = 0, me = Object.keys(ee); de < me.length; de++) {
        var he = me[de], _e = ee[he];
        ne[he] === void 0 ? se === "all" && (ce[he] = _e.defaultValue) : ce[he] = z(_e, ne[he], se !== "skip");
      }
      return ce;
    }
    s.normalizeParams = j;
    function ae(ee, ne) {
      for (var se = [], ce = 0, de = Object.keys(ee); ce < de.length; ce++) {
        var me = de[ce];
        if (!ne)
          typeof ee[me] == "string" ? se.push([me, ee[me]]) : se.push([me, ne === null ? me : (0, i.stringToWords)(me)]);
        else {
          var he = ne(me, ee[me]);
          se.push(typeof he == "string" ? [me, he] : [me, he[0], he[1]]);
        }
      }
      return se;
    }
    s.objectToOptions = ae;
    function le(ee, ne) {
      for (var se = [], ce = 0, de = ee; ce < de.length; ce++) {
        var me = de[ce];
        ne ? se.push([me, ne(me)]) : se.push([me, ne === null ? me : (0, i.stringToWords)(me)]);
      }
      return se;
    }
    s.arrayToOptions = le;
    function ie(ee, ne) {
      for (var se = 0, ce = ee.options; se < ce.length; se++) {
        var de = ce[se];
        if (de[0] === ne)
          return de[1];
      }
      return "";
    }
    s.optionLabel = ie;
    function re(ee, ne) {
      for (var se = 0, ce = ne; se < ce.length; se++) {
        var de = ce[se];
        if (de[0] === ee)
          return ee;
      }
      return ne.length > 0 ? ne[0][0] : void 0;
    }
  })(e.ParamDefinition || (e.ParamDefinition = {}));
})(Le);
var hr = {};
Object.defineProperty(hr, "__esModule", { value: !0 });
hr.arrayMapUpsert = hr.arrayIsIdentity = hr.arrayEqual = hr.arrayIntersectionSize = hr.arrayAreIntersecting = hr.arraySetRemove = hr.arraySetAdd = hr.arrayRemoveAtInPlace = hr.arrayRemoveInPlace = hr.fillSerial = hr.arrayRms = hr.arrayMean = hr.arraySum = hr.arrayMinMax = hr.arrayMin = hr.arrayMax = void 0;
function Fte(e) {
  for (var r = -1 / 0, t = 0, n = e.length; t < n; ++t)
    e[t] > r && (r = e[t]);
  return r;
}
hr.arrayMax = Fte;
function Lte(e) {
  for (var r = 1 / 0, t = 0, n = e.length; t < n; ++t)
    e[t] < r && (r = e[t]);
  return r;
}
hr.arrayMin = Lte;
function kte(e) {
  for (var r = 1 / 0, t = -1 / 0, n = 0, a = e.length; n < a; ++n)
    e[n] < r && (r = e[n]), e[n] > t && (t = e[n]);
  return [r, t];
}
hr.arrayMinMax = kte;
function wz(e, r, t) {
  r === void 0 && (r = 1), t === void 0 && (t = 0);
  for (var n = e.length, a = 0, i = t; i < n; i += r)
    a += e[i];
  return a;
}
hr.arraySum = wz;
function Ute(e, r, t) {
  return r === void 0 && (r = 1), t === void 0 && (t = 0), wz(e, r, t) / (e.length / r);
}
hr.arrayMean = Ute;
function zte(e) {
  for (var r = e.length, t = 0, n = 0; n < r; ++n) {
    var a = e[n];
    t += a * a;
  }
  return Math.sqrt(t / r);
}
hr.arrayRms = zte;
function Gte(e, r) {
  for (var t = 0, n = r ? Math.min(r, e.length) : e.length; t < n; ++t)
    e[t] = t;
  return e;
}
hr.fillSerial = Gte;
function qte(e, r) {
  for (var t = 0, n = !1, a = e.length; t < a; t++)
    if (e[t] === r) {
      n = !0;
      break;
    }
  return n ? (Ez(e, t), !0) : !1;
}
hr.arrayRemoveInPlace = qte;
function Ez(e, r) {
  for (var t = r, n = e.length - 1; t < n; t++)
    e[t] = e[t + 1];
  e.pop();
}
hr.arrayRemoveAtInPlace = Ez;
function Hte(e, r) {
  return e.indexOf(r) >= 0 ? !1 : (e.push(r), !0);
}
hr.arraySetAdd = Hte;
function jte(e, r) {
  var t = e.indexOf(r);
  if (t < 0)
    return !1;
  for (var n = t, a = e.length - 1; n < a; n++)
    e[n] = e[n + 1];
  return e.pop(), !0;
}
hr.arraySetRemove = jte;
function $te(e, r) {
  for (var t = 0, n = e.length; t < n; ++t)
    if (r.includes(e[t]))
      return !0;
  return !1;
}
hr.arrayAreIntersecting = $te;
function Kte(e, r) {
  for (var t = 0, n = 0, a = e.length; n < a; ++n)
    r.includes(e[n]) && (t += 1);
  return t;
}
hr.arrayIntersectionSize = Kte;
function Wte(e, r) {
  if (!e || e.length === 0)
    return !r || r.length === 0;
  if (!r)
    return !1;
  var t = e.length;
  if (t !== r.length)
    return !1;
  for (var n = 0; n < t; n++)
    if (e[n] !== r[n])
      return !1;
  return !0;
}
hr.arrayEqual = Wte;
function Xte(e) {
  for (var r = 0, t = e.length; r < t; r++)
    if (e[r] !== r)
      return !1;
  return !0;
}
hr.arrayIsIdentity = Xte;
function Yte(e, r, t) {
  for (var n = 0, a = e.length; n < a; ++n)
    if (e[n][0] === r) {
      e[n][1] = t;
      return;
    }
  e.push([r, t]);
}
hr.arrayMapUpsert = Yte;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Renderer = e.RendererParams = void 0;
  var r = ri, t = Re, n = Tr(), a = We(), i = Le, o = kn, c = hr, s = Zr;
  e.RendererParams = {
    backgroundColor: i.ParamDefinition.Color((0, n.Color)(0), {
      description: "Background color of the 3D canvas"
    }),
    pickingAlphaThreshold: i.ParamDefinition.Numeric(0.3, { min: 0, max: 1, step: 0.01 }, {
      description: "The minimum opacity value needed for an object to be pickable."
    }),
    interiorDarkening: i.ParamDefinition.Numeric(0.5, { min: 0, max: 1, step: 0.01 }),
    interiorColorFlag: i.ParamDefinition.Boolean(!0, { label: "Use Interior Color" }),
    interiorColor: i.ParamDefinition.Color(n.Color.fromNormalizedRgb(0.3, 0.3, 0.3)),
    highlightColor: i.ParamDefinition.Color(n.Color.fromNormalizedRgb(1, 0.4, 0.6)),
    selectColor: i.ParamDefinition.Color(n.Color.fromNormalizedRgb(0.2, 1, 0.1)),
    highlightStrength: i.ParamDefinition.Numeric(0.3, { min: 0, max: 1, step: 0.1 }),
    selectStrength: i.ParamDefinition.Numeric(0.3, { min: 0, max: 1, step: 0.1 }),
    markerPriority: i.ParamDefinition.Select(1, [
      [1, "Highlight"],
      [2, "Select"]
    ]),
    xrayEdgeFalloff: i.ParamDefinition.Numeric(1, { min: 0, max: 3, step: 0.1 }),
    light: i.ParamDefinition.ObjectList({
      inclination: i.ParamDefinition.Numeric(180, { min: 0, max: 180, step: 1 }),
      azimuth: i.ParamDefinition.Numeric(0, { min: 0, max: 360, step: 1 }),
      color: i.ParamDefinition.Color(n.Color.fromNormalizedRgb(1, 1, 1)),
      intensity: i.ParamDefinition.Numeric(0.6, { min: 0, max: 1, step: 0.01 })
    }, function(m) {
      return n.Color.toHexString(m.color);
    }, {
      defaultValue: [
        {
          inclination: 180,
          azimuth: 0,
          color: n.Color.fromNormalizedRgb(1, 1, 1),
          intensity: 0.6
        }
      ]
    }),
    ambientColor: i.ParamDefinition.Color(n.Color.fromNormalizedRgb(1, 1, 1)),
    ambientIntensity: i.ParamDefinition.Numeric(0.45, { min: 0, max: 1, step: 0.01 }),
    invalidColor: i.ParamDefinition.Color((0, n.Color)(16410214)),
    invalidStrength: i.ParamDefinition.Numeric(0.2, { min: 0, max: 1, step: 0.1 })
  };
  var u = (0, t.Vec3)(), l = (0, t.Vec3)();
  function f(m, p) {
    for (var v = p || {
      direction: new Array(15).fill(0),
      color: new Array(15).fill(0)
    }, h = v.direction, y = v.color, C = 0, S = m.length; C < S; ++C) {
      var b = m[C];
      t.Vec3.directionFromSpherical(u, (0, o.degToRad)(b.inclination), (0, o.degToRad)(b.azimuth), 1), t.Vec3.toArray(u, h, C * 3), t.Vec3.scale(l, n.Color.toVec3Normalized(l, b.color), b.intensity), t.Vec3.toArray(l, y, C * 3);
    }
    return { count: m.length, direction: h, color: y };
  }
  var d;
  (function(m) {
    function p(v, h) {
      h === void 0 && (h = {});
      var y = v.gl, C = v.state, S = v.stats, b = i.ParamDefinition.merge(e.RendererParams, i.ParamDefinition.getDefaultValues(e.RendererParams), h), g = f(b.light), _ = (0, r.Viewport)(), A = t.Vec2.create(y.drawingBufferWidth, y.drawingBufferHeight), M = n.Color.toVec3Normalized((0, t.Vec3)(), b.backgroundColor), P = !1, T = v.resources.texture("image-depth", "depth", "ushort", "nearest"), x = [["tDepth", T]], w = (0, t.Mat4)(), E = (0, t.Mat4)(), I = (0, t.Mat4)(), B = (0, t.Mat4)(), D = (0, t.Mat4)(), N = (0, t.Mat4)(), O = (0, t.Mat4)(), V = (0, t.Vec3)(), k = (0, t.Vec2)(), G = (0, t.Vec3)();
      t.Vec3.scale(G, n.Color.toArrayNormalized(b.ambientColor, G, 0), b.ambientIntensity);
      var L = {
        uModel: a.ValueCell.create(t.Mat4.identity()),
        uView: a.ValueCell.create(w),
        uInvView: a.ValueCell.create(E),
        uModelView: a.ValueCell.create(I),
        uInvModelView: a.ValueCell.create(B),
        uInvProjection: a.ValueCell.create(D),
        uProjection: a.ValueCell.create((0, t.Mat4)()),
        uModelViewProjection: a.ValueCell.create(N),
        uInvModelViewProjection: a.ValueCell.create(O),
        uIsOrtho: a.ValueCell.create(1),
        uViewOffset: a.ValueCell.create(k),
        uPixelRatio: a.ValueCell.create(v.pixelRatio),
        uViewport: a.ValueCell.create(r.Viewport.toVec4((0, t.Vec4)(), _)),
        uDrawingBufferSize: a.ValueCell.create(A),
        uCameraPosition: a.ValueCell.create((0, t.Vec3)()),
        uCameraDir: a.ValueCell.create(V),
        uNear: a.ValueCell.create(1),
        uFar: a.ValueCell.create(1e4),
        uFogNear: a.ValueCell.create(1),
        uFogFar: a.ValueCell.create(1e4),
        uFogColor: a.ValueCell.create(M),
        uRenderWboit: a.ValueCell.create(!1),
        uMarkingDepthTest: a.ValueCell.create(!1),
        uPickType: a.ValueCell.create(
          0
          /* None */
        ),
        uMarkingType: a.ValueCell.create(
          0
          /* None */
        ),
        uTransparentBackground: a.ValueCell.create(!1),
        uLightDirection: a.ValueCell.create(g.direction),
        uLightColor: a.ValueCell.create(g.color),
        uAmbientColor: a.ValueCell.create(G),
        uPickingAlphaThreshold: a.ValueCell.create(b.pickingAlphaThreshold),
        uInteriorDarkening: a.ValueCell.create(b.interiorDarkening),
        uInteriorColorFlag: a.ValueCell.create(b.interiorColorFlag),
        uInteriorColor: a.ValueCell.create(n.Color.toVec3Normalized((0, t.Vec3)(), b.interiorColor)),
        uHighlightColor: a.ValueCell.create(n.Color.toVec3Normalized((0, t.Vec3)(), b.highlightColor)),
        uSelectColor: a.ValueCell.create(n.Color.toVec3Normalized((0, t.Vec3)(), b.selectColor)),
        uHighlightStrength: a.ValueCell.create(b.highlightStrength),
        uSelectStrength: a.ValueCell.create(b.selectStrength),
        uMarkerPriority: a.ValueCell.create(b.markerPriority),
        uXrayEdgeFalloff: a.ValueCell.create(b.xrayEdgeFalloff),
        uInvalidColor: a.ValueCell.create(n.Color.toVec3Normalized((0, t.Vec3)(), b.invalidColor)),
        uInvalidStrength: a.ValueCell.create(b.invalidStrength)
      }, R = Object.entries(L), F = !0, U = function(j, ae) {
        if (!(j.state.disposed || !j.state.visible || !j.state.pickable && ae === "pick")) {
          var le = !1;
          j.values.dLightCount.ref.value !== g.count && (a.ValueCell.update(j.values.dLightCount, g.count), le = !0), le && j.update();
          var ie = j.getProgram(ae);
          if (C.currentProgramId !== ie.id && (F = !0, ie.use()), F && (ie.setUniforms(R), F = !1), j.values.dGeometryType.ref.value === "directVolume") {
            if (ae !== "colorWboit" && ae !== "colorBlended")
              return;
            C.disable(y.CULL_FACE), C.frontFace(y.CCW), ae === "colorBlended" && (C.disable(y.DEPTH_TEST), C.depthMask(!1));
          } else
            j.values.uDoubleSided ? j.values.uDoubleSided.ref.value || j.values.hasReflection.ref.value ? C.disable(y.CULL_FACE) : C.enable(y.CULL_FACE) : C.disable(y.CULL_FACE), j.values.dFlipSided && j.values.dFlipSided.ref.value ? (C.frontFace(y.CW), C.cullFace(y.FRONT)) : (C.frontFace(y.CCW), C.cullFace(y.BACK));
          j.render(ae, x);
        }
      }, H = function(j) {
        a.ValueCell.update(L.uView, j.view), a.ValueCell.update(L.uInvView, t.Mat4.invert(E, j.view)), a.ValueCell.update(L.uProjection, j.projection), a.ValueCell.update(L.uInvProjection, t.Mat4.invert(D, j.projection)), a.ValueCell.updateIfChanged(L.uIsOrtho, j.state.mode === "orthographic" ? 1 : 0), a.ValueCell.update(L.uViewOffset, j.viewOffset.enabled ? t.Vec2.set(k, j.viewOffset.offsetX * 16, j.viewOffset.offsetY * 16) : t.Vec2.set(k, 0, 0)), a.ValueCell.update(L.uCameraPosition, j.state.position), a.ValueCell.update(L.uCameraDir, t.Vec3.normalize(V, t.Vec3.sub(V, j.state.target, j.state.position))), a.ValueCell.updateIfChanged(L.uFar, j.far), a.ValueCell.updateIfChanged(L.uNear, j.near), a.ValueCell.updateIfChanged(L.uFogFar, j.fogFar), a.ValueCell.updateIfChanged(L.uFogNear, j.fogNear), a.ValueCell.updateIfChanged(L.uTransparentBackground, P);
      }, q = function(j, ae, le, ie, re) {
        (0, c.arrayMapUpsert)(x, "tDepth", le || T), a.ValueCell.update(L.uModel, j.view), a.ValueCell.update(L.uModelView, t.Mat4.mul(I, j.view, ae.view)), a.ValueCell.update(L.uInvModelView, t.Mat4.invert(B, I)), a.ValueCell.update(L.uModelViewProjection, t.Mat4.mul(N, I, ae.projection)), a.ValueCell.update(L.uInvModelViewProjection, t.Mat4.invert(O, N)), a.ValueCell.updateIfChanged(L.uRenderWboit, ie), a.ValueCell.updateIfChanged(L.uMarkingDepthTest, re), C.enable(y.SCISSOR_TEST), C.colorMask(!0, !0, !0, !0);
        var ee = _.x, ne = _.y, se = _.width, ce = _.height;
        y.viewport(ee, ne, se, ce), y.scissor(ee, ne, se, ce), F = !0, C.currentRenderItemId = -1;
      }, K = function(j, ae, le, ie, re) {
        C.disable(y.BLEND), C.enable(y.DEPTH_TEST), C.depthMask(!0), q(j, ae, ie, !1, !1), a.ValueCell.updateIfChanged(L.uPickType, re);
        for (var ee = j.renderables, ne = 0, se = ee.length; ne < se; ++ne)
          ee[ne].state.colorOnly || U(ee[ne], le);
      }, Y = function(j, ae, le) {
        C.disable(y.BLEND), C.enable(y.DEPTH_TEST), C.depthMask(!0), q(j, ae, le, !1, !1);
        for (var ie = j.renderables, re = 0, ee = ie.length; re < ee; ++re)
          U(ie[re], "depth");
      }, X = function(j, ae, le) {
        C.disable(y.BLEND), C.enable(y.DEPTH_TEST), C.depthMask(!0), q(j, ae, le, !1, !1), a.ValueCell.updateIfChanged(
          L.uMarkingType,
          1
          /* Depth */
        );
        for (var ie = j.renderables, re = 0, ee = ie.length; re < ee; ++re) {
          var ne = ie[re];
          ne.values.markerAverage.ref.value !== 1 && U(ie[re], "marking");
        }
      }, Z = function(j, ae, le) {
        C.disable(y.BLEND), C.enable(y.DEPTH_TEST), C.depthMask(!0), q(j, ae, le, !1, !!le), a.ValueCell.updateIfChanged(
          L.uMarkingType,
          2
          /* Mask */
        );
        for (var ie = j.renderables, re = 0, ee = ie.length; re < ee; ++re) {
          var ne = ie[re];
          ne.values.markerAverage.ref.value > 0 && U(ie[re], "marking");
        }
      }, J = function(j, ae, le) {
        $(j, ae, le), Q(j, ae, le);
      }, $ = function(j, ae, le) {
        C.disable(y.BLEND), C.enable(y.DEPTH_TEST), C.depthMask(!0), q(j, ae, le, !1, !1);
        for (var ie = j.renderables, re = 0, ee = ie.length; re < ee; ++re) {
          var ne = ie[re];
          ne.state.opaque && U(ne, "colorBlended");
        }
      }, Q = function(j, ae, le) {
        C.enable(y.DEPTH_TEST), q(j, ae, le, !1, !1);
        var ie = j.renderables;
        P ? C.blendFunc(y.ONE, y.ONE_MINUS_SRC_ALPHA) : C.blendFuncSeparate(y.SRC_ALPHA, y.ONE_MINUS_SRC_ALPHA, y.ONE, y.ONE_MINUS_SRC_ALPHA), C.enable(y.BLEND), C.depthMask(!0);
        for (var re = 0, ee = ie.length; re < ee; ++re) {
          var ne = ie[re];
          !ne.state.opaque && ne.state.writeDepth && U(ne, "colorBlended");
        }
        C.depthMask(!1);
        for (var re = 0, ee = ie.length; re < ee; ++re) {
          var ne = ie[re];
          !ne.state.opaque && !ne.state.writeDepth && U(ne, "colorBlended");
        }
      }, W = function(j, ae, le) {
        var ie;
        C.blendFunc(y.ONE, y.ONE_MINUS_SRC_ALPHA), C.enable(y.BLEND), q(j, ae, le, !1, !1);
        for (var re = j.renderables, ee = 0, ne = re.length; ee < ne; ++ee) {
          var se = re[ee], ce = (0, s.clamp)(se.values.alpha.ref.value * se.state.alphaFactor, 0, 1);
          ce === 1 && se.values.transparencyAverage.ref.value !== 1 && !(!((ie = se.values.dXrayShaded) === null || ie === void 0) && ie.ref.value) && U(se, "colorBlended");
        }
      }, te = function(j, ae, le) {
        var ie;
        C.blendFunc(y.ONE, y.ONE_MINUS_SRC_ALPHA), C.enable(y.BLEND), q(j, ae, le, !1, !1);
        for (var re = j.renderables, ee = 0, ne = re.length; ee < ne; ++ee) {
          var se = re[ee], ce = (0, s.clamp)(se.values.alpha.ref.value * se.state.alphaFactor, 0, 1);
          (ce < 1 || se.values.transparencyAverage.ref.value > 0 || !((ie = se.values.dXrayShaded) === null || ie === void 0) && ie.ref.value) && U(se, "colorBlended");
        }
      }, oe = function(j, ae, le) {
        var ie, re;
        C.disable(y.BLEND), C.enable(y.DEPTH_TEST), C.depthMask(!0), q(j, ae, le, !1, !1);
        for (var ee = j.renderables, ne = 0, se = ee.length; ne < se; ++ne) {
          var ce = ee[ne], de = (0, s.clamp)(ce.values.alpha.ref.value * ce.state.alphaFactor, 0, 1);
          de === 1 && ce.values.transparencyAverage.ref.value !== 1 && ce.values.dGeometryType.ref.value !== "directVolume" && ((ie = ce.values.dPointStyle) === null || ie === void 0 ? void 0 : ie.ref.value) !== "fuzzy" && !(!((re = ce.values.dXrayShaded) === null || re === void 0) && re.ref.value) && U(ce, "colorWboit");
        }
      }, z = function(j, ae, le) {
        var ie, re;
        q(j, ae, le, !0, !1);
        for (var ee = j.renderables, ne = 0, se = ee.length; ne < se; ++ne) {
          var ce = ee[ne], de = (0, s.clamp)(ce.values.alpha.ref.value * ce.state.alphaFactor, 0, 1);
          (de < 1 || ce.values.transparencyAverage.ref.value > 0 || ce.values.dGeometryType.ref.value === "directVolume" || ((ie = ce.values.dPointStyle) === null || ie === void 0 ? void 0 : ie.ref.value) === "fuzzy" || ce.values.uBackgroundColor || !((re = ce.values.dXrayShaded) === null || re === void 0) && re.ref.value) && U(ce, "colorWboit");
        }
      };
      return {
        clear: function(j, ae) {
          C.enable(y.SCISSOR_TEST), C.enable(y.DEPTH_TEST), C.colorMask(!0, !0, !0, !0), C.depthMask(!0), P && !ae ? C.clearColor(0, 0, 0, 0) : j ? C.clearColor(M[0], M[1], M[2], 1) : C.clearColor(1, 1, 1, 1), y.clear(y.COLOR_BUFFER_BIT | y.DEPTH_BUFFER_BIT);
        },
        clearDepth: function() {
          C.enable(y.SCISSOR_TEST), C.enable(y.DEPTH_TEST), C.depthMask(!0), y.clear(y.DEPTH_BUFFER_BIT);
        },
        update: H,
        renderPick: K,
        renderDepth: Y,
        renderMarkingDepth: X,
        renderMarkingMask: Z,
        renderBlended: J,
        renderBlendedOpaque: $,
        renderBlendedTransparent: Q,
        renderBlendedVolumeOpaque: W,
        renderBlendedVolumeTransparent: te,
        renderWboitOpaque: oe,
        renderWboitTransparent: z,
        setProps: function(j) {
          j.backgroundColor !== void 0 && j.backgroundColor !== b.backgroundColor && (b.backgroundColor = j.backgroundColor, n.Color.toVec3Normalized(M, b.backgroundColor), a.ValueCell.update(L.uFogColor, t.Vec3.copy(L.uFogColor.ref.value, M))), j.pickingAlphaThreshold !== void 0 && j.pickingAlphaThreshold !== b.pickingAlphaThreshold && (b.pickingAlphaThreshold = j.pickingAlphaThreshold, a.ValueCell.update(L.uPickingAlphaThreshold, b.pickingAlphaThreshold)), j.interiorDarkening !== void 0 && j.interiorDarkening !== b.interiorDarkening && (b.interiorDarkening = j.interiorDarkening, a.ValueCell.update(L.uInteriorDarkening, b.interiorDarkening)), j.interiorColorFlag !== void 0 && j.interiorColorFlag !== b.interiorColorFlag && (b.interiorColorFlag = j.interiorColorFlag, a.ValueCell.update(L.uInteriorColorFlag, b.interiorColorFlag)), j.interiorColor !== void 0 && j.interiorColor !== b.interiorColor && (b.interiorColor = j.interiorColor, a.ValueCell.update(L.uInteriorColor, n.Color.toVec3Normalized(L.uInteriorColor.ref.value, b.interiorColor))), j.highlightColor !== void 0 && j.highlightColor !== b.highlightColor && (b.highlightColor = j.highlightColor, a.ValueCell.update(L.uHighlightColor, n.Color.toVec3Normalized(L.uHighlightColor.ref.value, b.highlightColor))), j.selectColor !== void 0 && j.selectColor !== b.selectColor && (b.selectColor = j.selectColor, a.ValueCell.update(L.uSelectColor, n.Color.toVec3Normalized(L.uSelectColor.ref.value, b.selectColor))), j.highlightStrength !== void 0 && j.highlightStrength !== b.highlightStrength && (b.highlightStrength = j.highlightStrength, a.ValueCell.update(L.uHighlightStrength, b.highlightStrength)), j.selectStrength !== void 0 && j.selectStrength !== b.selectStrength && (b.selectStrength = j.selectStrength, a.ValueCell.update(L.uSelectStrength, b.selectStrength)), j.markerPriority !== void 0 && j.markerPriority !== b.markerPriority && (b.markerPriority = j.markerPriority, a.ValueCell.update(L.uMarkerPriority, b.markerPriority)), j.xrayEdgeFalloff !== void 0 && j.xrayEdgeFalloff !== b.xrayEdgeFalloff && (b.xrayEdgeFalloff = j.xrayEdgeFalloff, a.ValueCell.update(L.uXrayEdgeFalloff, b.xrayEdgeFalloff)), j.light !== void 0 && !(0, a.deepEqual)(j.light, b.light) && (b.light = j.light, Object.assign(g, f(j.light, g)), a.ValueCell.update(L.uLightDirection, g.direction), a.ValueCell.update(L.uLightColor, g.color)), j.ambientColor !== void 0 && j.ambientColor !== b.ambientColor && (b.ambientColor = j.ambientColor, t.Vec3.scale(G, n.Color.toArrayNormalized(b.ambientColor, G, 0), b.ambientIntensity), a.ValueCell.update(L.uAmbientColor, G)), j.ambientIntensity !== void 0 && j.ambientIntensity !== b.ambientIntensity && (b.ambientIntensity = j.ambientIntensity, t.Vec3.scale(G, n.Color.toArrayNormalized(b.ambientColor, G, 0), b.ambientIntensity), a.ValueCell.update(L.uAmbientColor, G)), j.invalidColor !== void 0 && j.invalidColor !== b.invalidColor && (b.invalidColor = j.invalidColor, a.ValueCell.update(L.uInvalidColor, n.Color.toVec3Normalized(L.uInvalidColor.ref.value, b.invalidColor))), j.invalidStrength !== void 0 && j.invalidStrength !== b.invalidStrength && (b.invalidStrength = j.invalidStrength, a.ValueCell.update(L.uInvalidStrength, b.invalidStrength));
        },
        setViewport: function(j, ae, le, ie) {
          y.viewport(j, ae, le, ie), y.scissor(j, ae, le, ie), (j !== _.x || ae !== _.y || le !== _.width || ie !== _.height) && (r.Viewport.set(_, j, ae, le, ie), a.ValueCell.update(L.uViewport, t.Vec4.set(L.uViewport.ref.value, j, ae, le, ie)));
        },
        setTransparentBackground: function(j) {
          P = j;
        },
        setDrawingBufferSize: function(j, ae) {
          (j !== A[0] || ae !== A[1]) && a.ValueCell.update(L.uDrawingBufferSize, t.Vec2.set(A, j, ae));
        },
        setPixelRatio: function(j) {
          a.ValueCell.update(L.uPixelRatio, j);
        },
        props: b,
        get stats() {
          return {
            programCount: v.stats.resourceCounts.program,
            shaderCount: v.stats.resourceCounts.shader,
            attributeCount: v.stats.resourceCounts.attribute,
            elementsCount: v.stats.resourceCounts.elements,
            framebufferCount: v.stats.resourceCounts.framebuffer,
            renderbufferCount: v.stats.resourceCounts.renderbuffer,
            textureCount: v.stats.resourceCounts.texture,
            vertexArrayCount: v.stats.resourceCounts.vertexArray,
            drawCount: S.drawCount,
            instanceCount: S.instanceCount,
            instancedDrawCount: S.instancedDrawCount
          };
        },
        dispose: function() {
        }
      };
    }
    m.create = p;
  })(d || (d = {})), e.Renderer = d;
})(vz);
var Dz = {}, ny = {};
Object.defineProperty(ny, "__esModule", { value: !0 });
ny.Binding = void 0;
var iM = ey, oI = cs;
function Cg(e, r, t) {
  return r === void 0 && (r = ""), t === void 0 && (t = ""), Cg.create(e, r, t);
}
ny.Binding = Cg;
(function(e) {
  function r(c, s, u) {
    return s === void 0 && (s = ""), u === void 0 && (u = ""), { triggers: c, action: s, description: u };
  }
  e.create = r, e.Empty = { triggers: [], action: "", description: "" };
  function t(c) {
    return c.triggers.length === 0 || c.triggers.every(function(s) {
      return s.buttons === void 0 && s.modifiers === void 0;
    });
  }
  e.isEmpty = t;
  function n(c, s, u) {
    return c.triggers.some(function(l) {
      return o.match(l, s, u);
    });
  }
  e.match = n;
  function a(c) {
    return c.triggers.map(o.format).join(" or ");
  }
  e.formatTriggers = a;
  function i(c, s) {
    s === void 0 && (s = "");
    var u = c.description || (0, oI.stringToWords)(s);
    return (0, oI.interpolate)(u, { triggers: "<i>" + a(c) + "</i>" });
  }
  e.format = i;
  function o(c, s) {
    return o.create(c, s);
  }
  e.Trigger = o, function(c) {
    function s(f, d) {
      return { buttons: f, modifiers: d };
    }
    c.create = s, c.Empty = {};
    function u(f, d, m) {
      var p = f.buttons, v = f.modifiers;
      return p !== void 0 && (p === d || iM.ButtonsType.has(p, d)) && (!v || iM.ModifiersKeys.areEqual(v, m));
    }
    c.match = u;
    function l(f) {
      var d = [], m = Qte(f.buttons);
      m && d.push(m);
      var p = Zte(f.modifiers);
      return p && d.push(p), d.join(" + ");
    }
    c.format = l;
  }(o = e.Trigger || (e.Trigger = {}));
})(Cg || (Cg = {}));
ny.Binding = Cg;
var Qy = iM.ButtonsType;
function Qte(e) {
  var r = [];
  return e === void 0 ? r.push("any mouse button") : e === 0 ? r.push("mouse hover") : (Qy.has(
    e,
    1
    /* Primary */
  ) && r.push("left mouse button"), Qy.has(
    e,
    2
    /* Secondary */
  ) && r.push("right mouse button"), Qy.has(
    e,
    4
    /* Auxilary */
  ) && r.push("wheel/middle mouse button"), Qy.has(
    e,
    8
    /* Forth */
  ) && r.push("three fingers")), r.join(" + ");
}
function Zte(e, r) {
  var t = [];
  return e && (e.alt && t.push("alt key"), e.control && t.push("control key"), e.meta && t.push("meta/command key"), e.shift && t.push("shift key")), t.join(" + ");
}
var Ti = {};
Object.defineProperty(Ti, "__esModule", { value: !0 });
Ti.RxEventHelper = void 0;
var uI = cl, oM;
(function(e) {
  function r() {
    var t = new Jte(), n = function() {
      return t.create();
    };
    return n.dispose = function() {
      return t.dispose();
    }, n.behavior = function(a) {
      return t.behavior(a);
    }, n;
  }
  e.create = r;
})(oM || (oM = {}));
Ti.RxEventHelper = oM;
var Jte = (
  /** @class */
  function() {
    function e() {
      this._eventList = [], this._disposed = !1;
    }
    return e.prototype.create = function() {
      var r = new uI.Subject();
      return this._eventList.push(r), r;
    }, e.prototype.behavior = function(r) {
      var t = new uI.BehaviorSubject(r);
      return this._eventList.push(t), t;
    }, e.prototype.dispose = function() {
      if (!this._disposed) {
        for (var r = 0, t = this._eventList; r < t.length; r++) {
          var n = t[r];
          n.complete();
        }
        this._disposed = !0;
      }
    }, e;
  }()
);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.TrackballControls = e.TrackballControlsParams = e.DefaultTrackballBindings = void 0;
  var r = Te, t = Re, n = ri, a = ey, i = Le, o = kn, c = ny, s = Ti;
  a.ButtonsType;
  var u = a.ModifiersKeys, l = c.Binding.Trigger;
  e.DefaultTrackballBindings = {
    dragRotate: (0, c.Binding)([l(1, u.create())], "Rotate", "Drag using ${triggers}"),
    dragRotateZ: (0, c.Binding)([l(1, u.create({ shift: !0 }))], "Rotate around z-axis", "Drag using ${triggers}"),
    dragPan: (0, c.Binding)([l(2, u.create()), l(1, u.create({ control: !0 }))], "Pan", "Drag using ${triggers}"),
    dragZoom: c.Binding.Empty,
    dragFocus: (0, c.Binding)([l(8, u.create())], "Focus", "Drag using ${triggers}"),
    dragFocusZoom: (0, c.Binding)([l(4, u.create())], "Focus and zoom", "Drag using ${triggers}"),
    scrollZoom: (0, c.Binding)([l(4, u.create())], "Zoom", "Scroll using ${triggers}"),
    scrollFocus: (0, c.Binding)([l(4, u.create({ shift: !0 }))], "Clip", "Scroll using ${triggers}"),
    scrollFocusZoom: c.Binding.Empty
  }, e.TrackballControlsParams = {
    noScroll: i.ParamDefinition.Boolean(!0, { isHidden: !0 }),
    rotateSpeed: i.ParamDefinition.Numeric(5, { min: 1, max: 10, step: 1 }),
    zoomSpeed: i.ParamDefinition.Numeric(7, { min: 1, max: 15, step: 1 }),
    panSpeed: i.ParamDefinition.Numeric(1, { min: 0.1, max: 5, step: 0.1 }),
    animate: i.ParamDefinition.MappedStatic("off", {
      off: i.ParamDefinition.EmptyGroup(),
      spin: i.ParamDefinition.Group({
        speed: i.ParamDefinition.Numeric(1, { min: -20, max: 20, step: 1 })
      }, { description: "Spin the 3D scene around the x-axis in view space" }),
      rock: i.ParamDefinition.Group({
        speed: i.ParamDefinition.Numeric(0.3, { min: -5, max: 5, step: 0.1 }),
        angle: i.ParamDefinition.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: i.ParamDefinition.Boolean(!0, { isHidden: !0 }),
    dynamicDampingFactor: i.ParamDefinition.Numeric(0.2, {}, { isHidden: !0 }),
    minDistance: i.ParamDefinition.Numeric(0.01, {}, { isHidden: !0 }),
    maxDistance: i.ParamDefinition.Numeric(1e150, {}, { isHidden: !0 }),
    gestureScaleFactor: i.ParamDefinition.Numeric(1, {}, { isHidden: !0 }),
    maxWheelDelta: i.ParamDefinition.Numeric(0.02, {}, { isHidden: !0 }),
    bindings: i.ParamDefinition.Value(e.DefaultTrackballBindings, { isHidden: !0 }),
    /**
     * minDistance = minDistanceFactor * boundingSphere.radius + minDistancePadding
     * maxDistance = max(maxDistanceFactor * boundingSphere.radius, maxDistanceMin)
     */
    autoAdjustMinMaxDistance: i.ParamDefinition.MappedStatic("on", {
      off: i.ParamDefinition.EmptyGroup(),
      on: i.ParamDefinition.Group({
        minDistanceFactor: i.ParamDefinition.Numeric(0),
        minDistancePadding: i.ParamDefinition.Numeric(5),
        maxDistanceFactor: i.ParamDefinition.Numeric(10),
        maxDistanceMin: i.ParamDefinition.Numeric(20)
      })
    }, { isHidden: !0 })
  };
  var f;
  (function(d) {
    function m(p, v, h) {
      h === void 0 && (h = {});
      var y = s.RxEventHelper.create(), C = (0, r.__assign)((0, r.__assign)({}, i.ParamDefinition.getDefaultValues(e.TrackballControlsParams)), h), S = n.Viewport.clone(v.viewport), b = !1, g = y.behavior(!1), _ = y.behavior([]), A = y.behavior(!1), M = p.drag.subscribe(ue), P = p.interactionEnd.subscribe(pe), T = p.wheel.subscribe(Ae), x = p.pinch.subscribe(ye), w = p.gesture.subscribe(be), E = !1, I = (0, t.Vec3)(), B = (0, t.Vec3)(), D = (0, t.Vec2)(), N = (0, t.Vec2)(), O = (0, t.Vec3)(), V = 0, k = (0, t.Vec2)(), G = (0, t.Vec2)(), L = 0, R = (0, t.Vec2)(), F = (0, t.Vec2)(), U = (0, t.Vec2)(), H = (0, t.Vec2)(), q = (0, t.Vec2)(), K = (0, t.Vec2)(), Y = t.Vec3.clone(v.target), X = t.Vec3.clone(v.position), Z = t.Vec3.clone(v.up), J = (0, t.Vec2)();
      function $(Fe, He) {
        return t.Vec2.set(J, (Fe - S.x) / S.width, (He - S.y) / S.height);
      }
      var Q = (0, t.Vec2)();
      function W(Fe, He) {
        return t.Vec2.set(
          Q,
          (Fe - S.width * 0.5 - S.x) / (S.width * 0.5),
          (S.height + 2 * (S.y - He)) / S.width
          // screen.width intentional
        );
      }
      function te() {
        var Fe = p.width / p.height;
        return C.rotateSpeed * p.pixelRatio * Fe;
      }
      var oe = (0, t.Vec3)(), z = (0, t.Quat)(), j = (0, t.Vec3)(), ae = (0, t.Vec3)(), le = (0, t.Vec3)(), ie = (0, t.Vec3)();
      function re() {
        var Fe = N[0] - D[0], He = N[1] - D[1];
        t.Vec3.set(ie, Fe, He, 0);
        var Be = t.Vec3.magnitude(ie) * te();
        Be ? (t.Vec3.sub(B, v.position, v.target), t.Vec3.normalize(j, B), t.Vec3.normalize(ae, v.up), t.Vec3.normalize(le, t.Vec3.cross(le, ae, j)), t.Vec3.setMagnitude(ae, ae, He), t.Vec3.setMagnitude(le, le, Fe), t.Vec3.add(ie, ae, le), t.Vec3.normalize(oe, t.Vec3.cross(oe, ie, B)), t.Quat.setAxisAngle(z, oe, Be), t.Vec3.transformQuat(B, B, z), t.Vec3.transformQuat(v.up, v.up, z), t.Vec3.copy(O, oe), V = Be) : !C.staticMoving && V && (V *= Math.sqrt(1 - C.dynamicDampingFactor), t.Vec3.sub(B, v.position, v.target), t.Quat.setAxisAngle(z, O, V), t.Vec3.transformQuat(B, B, z), t.Vec3.transformQuat(v.up, v.up, z)), t.Vec2.copy(D, N);
      }
      var ee = (0, t.Quat)();
      function ne() {
        var Fe = G[0] - k[0], He = G[1] - k[1], Be = C.rotateSpeed * (-Fe + He) * -0.05;
        Be ? (t.Vec3.sub(B, v.position, v.target), t.Quat.setAxisAngle(ee, B, Be), t.Vec3.transformQuat(v.up, v.up, ee), L = Be) : !C.staticMoving && L && (L *= Math.sqrt(1 - C.dynamicDampingFactor), t.Vec3.sub(B, v.position, v.target), t.Quat.setAxisAngle(ee, B, L), t.Vec3.transformQuat(v.up, v.up, ee)), t.Vec2.copy(k, G);
      }
      function se() {
        var Fe = 1 + (F[1] - R[1]) * C.zoomSpeed;
        Fe !== 1 && Fe > 0 && t.Vec3.scale(B, B, Fe), C.staticMoving ? t.Vec2.copy(R, F) : R[1] += (F[1] - R[1]) * C.dynamicDampingFactor;
      }
      function ce() {
        var Fe = (H[1] - U[1]) * C.zoomSpeed;
        if (Fe !== 0) {
          var He = Math.max(1, v.state.radius + v.state.radius * Fe);
          v.setState({ radius: He });
        }
        C.staticMoving ? t.Vec2.copy(U, H) : U[1] += (H[1] - U[1]) * C.dynamicDampingFactor;
      }
      var de = (0, t.Vec2)(), me = (0, t.Vec3)(), he = (0, t.Vec3)();
      function _e() {
        if (t.Vec2.sub(de, t.Vec2.copy(de, K), q), t.Vec2.squaredMagnitude(de)) {
          var Fe = p.pixelRatio * C.panSpeed;
          de[0] *= 1 / v.zoom * v.viewport.width * Fe, de[1] *= 1 / v.zoom * v.viewport.height * Fe, t.Vec3.cross(he, t.Vec3.copy(he, B), v.up), t.Vec3.setMagnitude(he, he, de[0]), t.Vec3.setMagnitude(me, v.up, de[1]), t.Vec3.add(he, he, me), t.Vec3.add(v.position, v.position, he), t.Vec3.add(v.target, v.target, he), C.staticMoving ? t.Vec2.copy(q, K) : (t.Vec2.sub(de, K, q), t.Vec2.scale(de, de, C.dynamicDampingFactor), t.Vec2.add(q, q, de));
        }
      }
      function Se() {
        var Fe = Math.min(Math.max(v.state.radiusMax * 1e3, 0.01), C.maxDistance);
        t.Vec3.squaredMagnitude(B) > Fe * Fe && (t.Vec3.setMagnitude(B, B, Fe), t.Vec3.add(v.position, v.target, B), t.Vec2.copy(R, F), t.Vec2.copy(U, H)), t.Vec3.squaredMagnitude(B) < C.minDistance * C.minDistance && (t.Vec3.setMagnitude(B, B, C.minDistance), t.Vec3.add(v.position, v.target, B), t.Vec2.copy(R, F), t.Vec2.copy(U, H));
      }
      function Pe(Fe, He) {
        return Fe *= p.pixelRatio, He *= p.pixelRatio, Fe > S.x + S.width || p.height - He > S.y + S.height || Fe < S.x || p.height - He < S.y;
      }
      var De = -1;
      function Ee(Fe) {
        De !== Fe && (De > 0 && (C.animate.name === "spin" ? xe(Fe - De) : C.animate.name === "rock" && Ne(Fe - De)), t.Vec3.sub(B, v.position, v.target), re(), ne(), se(), ce(), _e(), t.Vec3.add(v.position, v.target, B), Se(), t.Vec3.squaredDistance(I, v.position) > t.EPSILON && t.Vec3.copy(I, v.position), De = Fe);
      }
      function Me() {
        t.Vec3.copy(v.target, Y), t.Vec3.copy(v.position, X), t.Vec3.copy(v.up, Z), t.Vec3.sub(B, v.position, v.target), t.Vec3.copy(I, v.position);
      }
      function ue(Fe) {
        var He = Fe.x, Be = Fe.y, Ye = Fe.pageX, cr = Fe.pageY, Ar = Fe.buttons, Lr = Fe.modifiers, It = Fe.isStart, en = Pe(He, Be);
        if (!(g.value && _.value.includes("drag") && (A.value || Ar !== 1)) && !(It && en) && !(!It && !E)) {
          E = !0, Oe();
          var Sn = c.Binding.match(C.bindings.dragRotate, Ar, Lr), Wn = c.Binding.match(C.bindings.dragRotateZ, Ar, Lr), oa = c.Binding.match(C.bindings.dragPan, Ar, Lr), La = c.Binding.match(C.bindings.dragZoom, Ar, Lr), ci = c.Binding.match(C.bindings.dragFocus, Ar, Lr), Do = c.Binding.match(C.bindings.dragFocusZoom, Ar, Lr);
          if (W(Ye, cr), $(Ye, cr), It && (Sn && (t.Vec2.copy(N, Q), t.Vec2.copy(D, N)), Wn && (t.Vec2.copy(G, Q), t.Vec2.copy(k, G)), (La || Do) && (t.Vec2.copy(R, J), t.Vec2.copy(F, R)), ci && (t.Vec2.copy(U, J), t.Vec2.copy(H, U)), oa && (t.Vec2.copy(q, J), t.Vec2.copy(K, q))), Sn && t.Vec2.copy(N, Q), Wn && t.Vec2.copy(G, Q), (La || Do) && t.Vec2.copy(F, J), ci && t.Vec2.copy(H, J), Do) {
            var nu = t.Vec3.distance(v.state.position, v.state.target);
            v.setState({ radius: nu / 5 });
          }
          oa && t.Vec2.copy(K, J);
        }
      }
      function pe() {
        E = !1;
      }
      function Ae(Fe) {
        var He = Fe.x, Be = Fe.y, Ye = Fe.spinX, cr = Fe.spinY, Ar = Fe.dz, Lr = Fe.buttons, It = Fe.modifiers;
        if (!Pe(He, Be)) {
          var en = (0, o.absMax)(Ye * 0.075, cr * 0.075, Ar * 1e-4);
          en < -C.maxWheelDelta ? en = -C.maxWheelDelta : en > C.maxWheelDelta && (en = C.maxWheelDelta), c.Binding.match(C.bindings.scrollZoom, Lr, It) && (F[1] += en), c.Binding.match(C.bindings.scrollFocus, Lr, It) && (H[1] += en);
        }
      }
      function ye(Fe) {
        var He = Fe.fractionDelta, Be = Fe.buttons, Ye = Fe.modifiers;
        c.Binding.match(C.bindings.scrollZoom, Be, Ye) && (E = !0, F[1] += C.gestureScaleFactor * He);
      }
      function be(Fe) {
        var He = Fe.deltaScale;
        E = !0, F[1] += C.gestureScaleFactor * He;
      }
      function fe() {
        b || (b = !0, M.unsubscribe(), T.unsubscribe(), x.unsubscribe(), w.unsubscribe(), P.unsubscribe());
      }
      var ge = t.Vec2.create(5e-3, 0);
      function xe(Fe) {
        if (!(C.animate.name !== "spin" || C.animate.params.speed === 0 || E)) {
          var He = C.animate.params.speed / 1e3;
          ge[0] = 60 * Math.min(Math.abs(Fe), 1e3 / 8) / 1e3 * He, t.Vec2.add(N, D, ge);
        }
      }
      var we = 0, Ve = t.Vec2.create(5e-3, 0);
      function Ne(Fe) {
        if (!(C.animate.name !== "rock" || C.animate.params.speed === 0 || E)) {
          var He = Fe / 1e3 * C.animate.params.speed, Be = (0, o.degToRad)(C.animate.params.angle) / te(), Ye = Math.sin(we * Math.PI * 2) * Be, cr = Math.sin((we + He) * Math.PI * 2) * Be;
          Ve[0] = cr - Ye, t.Vec2.add(N, D, Ve), we += He, we >= 1 && (we = 0);
        }
      }
      function Oe() {
        we = 0;
      }
      function ze(Fe) {
        De = -1, Ee(Fe);
      }
      function ke(Fe) {
        g.next(Fe);
      }
      function je(Fe) {
        _.next(Fe);
      }
      function Xe(Fe) {
        A.next(Fe);
      }
      return {
        viewport: S,
        get isAnimating() {
          return C.animate.name !== "off";
        },
        get props() {
          return C;
        },
        setProps: function(Fe) {
          var He;
          ((He = Fe.animate) === null || He === void 0 ? void 0 : He.name) === "rock" && C.animate.name !== "rock" && Oe(), Object.assign(C, Fe);
        },
        get isEditing() {
          return g.value;
        },
        get disabledInteraction() {
          return _.value;
        },
        get isLockCamera() {
          return A.value;
        },
        start: ze,
        update: Ee,
        reset: Me,
        dispose: fe,
        setEditState: ke,
        setLockCameraState: Xe,
        setDisabledInteractionState: je
      };
    }
    d.create = m;
  })(f || (f = {})), e.TrackballControls = f;
})(Dz);
var Io = {}, Wr = {}, cf = {}, Cn = {}, cS = {};
Object.defineProperty(cS, "__esModule", { value: !0 });
cS.apply_fog = void 0;
cS.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;
}
`;
var dS = {};
Object.defineProperty(dS, "__esModule", { value: !0 });
dS.apply_interior_color = void 0;
dS.apply_interior_color = `
if (interior) {
    if (uInteriorColorFlag) {
        gl_FragColor.rgb = uInteriorColor;
    } else {
        gl_FragColor.rgb *= 1.0 - uInteriorDarkening;
    }
}
`;
var fS = {};
Object.defineProperty(fS, "__esModule", { value: !0 });
fS.apply_light_color = void 0;
fS.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
`;
var mS = {};
Object.defineProperty(mS, "__esModule", { value: !0 });
mS.apply_marker_color = void 0;
mS.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
    }
}
`;
var vS = {};
Object.defineProperty(vS, "__esModule", { value: !0 });
vS.assign_clipping_varying = void 0;
vS.assign_clipping_varying = `
#if dClipObjectCount != 0 && defined(dClipping)
    vClipping = readFromTexture(tClipping, aInstance * float(uGroupCount) + group, uClippingTexDim).a;
#endif
`;
var pS = {};
Object.defineProperty(pS, "__esModule", { value: !0 });
pS.assign_color_varying = void 0;
pS.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
`;
var hS = {};
Object.defineProperty(hS, "__esModule", { value: !0 });
hS.assign_group = void 0;
hS.assign_group = `
#ifdef dGeometryType_textureMesh
    float group = unpackRGBToInt(readFromTexture(tGroup, VertexID, uGeoTexDim).rgb);
#else
    float group = aGroup;
#endif
`;
var gS = {};
Object.defineProperty(gS, "__esModule", { value: !0 });
gS.assign_marker_varying = void 0;
gS.assign_marker_varying = `
#if defined(dRenderVariant_color) || defined(dRenderVariant_marking)
    vMarker = readFromTexture(tMarker, aInstance * float(uGroupCount) + group, uMarkerTexDim).a;
#endif
`;
var yS = {};
Object.defineProperty(yS, "__esModule", { value: !0 });
yS.assign_material_color = void 0;
yS.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
`;
var _S = {};
Object.defineProperty(_S, "__esModule", { value: !0 });
_S.assign_position = void 0;
_S.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;
`;
var bS = {};
Object.defineProperty(bS, "__esModule", { value: !0 });
bS.assign_size = void 0;
bS.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;
`;
var SS = {};
Object.defineProperty(SS, "__esModule", { value: !0 });
SS.check_picking_alpha = void 0;
SS.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
`;
var CS = {};
Object.defineProperty(CS, "__esModule", { value: !0 });
CS.clip_instance = void 0;
CS.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
`;
var AS = {};
Object.defineProperty(AS, "__esModule", { value: !0 });
AS.clip_pixel = void 0;
AS.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
`;
var xS = {};
Object.defineProperty(xS, "__esModule", { value: !0 });
xS.color_frag_params = void 0;
xS.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
`;
var TS = {};
Object.defineProperty(TS, "__esModule", { value: !0 });
TS.color_vert_params = void 0;
TS.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
`;
var PS = {};
Object.defineProperty(PS, "__esModule", { value: !0 });
PS.common_clip = void 0;
PS.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
`;
var MS = {};
Object.defineProperty(MS, "__esModule", { value: !0 });
MS.common_frag_params = void 0;
MS.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;
}
`;
var wS = {};
Object.defineProperty(wS, "__esModule", { value: !0 });
wS.common_vert_params = void 0;
wS.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
`;
var ES = {};
Object.defineProperty(ES, "__esModule", { value: !0 });
ES.common = void 0;
ES.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
`;
var DS = {};
Object.defineProperty(DS, "__esModule", { value: !0 });
DS.float_to_rgba = void 0;
DS.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)
        );
    }
`;
var IS = {};
Object.defineProperty(IS, "__esModule", { value: !0 });
IS.light_frag_params = void 0;
IS.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;
}
`;
var BS = {};
Object.defineProperty(BS, "__esModule", { value: !0 });
BS.matrix_scale = void 0;
BS.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]);
}
`;
var NS = {};
Object.defineProperty(NS, "__esModule", { value: !0 });
NS.normal_frag_params = void 0;
NS.normal_frag_params = `
varying vec3 vNormal;
`;
var VS = {};
Object.defineProperty(VS, "__esModule", { value: !0 });
VS.read_from_texture = void 0;
VS.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);
}
`;
var RS = {};
Object.defineProperty(RS, "__esModule", { value: !0 });
RS.rgba_to_float = void 0;
RS.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);
    }
`;
var OS = {};
Object.defineProperty(OS, "__esModule", { value: !0 });
OS.size_vert_params = void 0;
OS.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;
`;
var FS = {};
Object.defineProperty(FS, "__esModule", { value: !0 });
FS.texture3d_from_1d_trilinear = void 0;
FS.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);
}
`;
var LS = {};
Object.defineProperty(LS, "__esModule", { value: !0 });
LS.texture3d_from_2d_linear = void 0;
LS.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);
}
`;
var kS = {};
Object.defineProperty(kS, "__esModule", { value: !0 });
kS.texture3d_from_2d_nearest = void 0;
kS.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);
}
`;
var US = {};
Object.defineProperty(US, "__esModule", { value: !0 });
US.wboit_write = void 0;
US.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
`;
var zS = {};
Object.defineProperty(zS, "__esModule", { value: !0 });
zS.points_vert = void 0;
zS.points_vert = `
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
}
`;
var GS = {};
Object.defineProperty(GS, "__esModule", { value: !0 });
GS.points_frag = void 0;
GS.points_frag = `
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
}
`;
var qS = {};
Object.defineProperty(qS, "__esModule", { value: !0 });
qS.spheres_vert = void 0;
qS.spheres_vert = `
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
}
`;
var HS = {};
Object.defineProperty(HS, "__esModule", { value: !0 });
HS.spheres_frag = void 0;
HS.spheres_frag = `
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
}
`;
var jS = {};
Object.defineProperty(jS, "__esModule", { value: !0 });
jS.cylinders_vert = void 0;
jS.cylinders_vert = `
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
}
`;
var $S = {};
Object.defineProperty($S, "__esModule", { value: !0 });
$S.cylinders_frag = void 0;
$S.cylinders_frag = `
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
}
`;
var KS = {};
Object.defineProperty(KS, "__esModule", { value: !0 });
KS.text_vert = void 0;
KS.text_vert = `
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
}
`;
var WS = {};
Object.defineProperty(WS, "__esModule", { value: !0 });
WS.text_frag = void 0;
WS.text_frag = `
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
}
`;
var XS = {};
Object.defineProperty(XS, "__esModule", { value: !0 });
XS.lines_vert = void 0;
XS.lines_vert = `
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
}
`;
var YS = {};
Object.defineProperty(YS, "__esModule", { value: !0 });
YS.lines_frag = void 0;
YS.lines_frag = `
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
}
`;
var QS = {};
Object.defineProperty(QS, "__esModule", { value: !0 });
QS.mesh_vert = void 0;
QS.mesh_vert = `
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;
}
`;
var ZS = {};
Object.defineProperty(ZS, "__esModule", { value: !0 });
ZS.mesh_frag = void 0;
ZS.mesh_frag = `
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
}
`;
var JS = {};
Object.defineProperty(JS, "__esModule", { value: !0 });
JS.directVolume_vert = void 0;
JS.directVolume_vert = `
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;
}
`;
var eC = {};
Object.defineProperty(eC, "__esModule", { value: !0 });
eC.directVolume_frag = void 0;
eC.directVolume_frag = `
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
}
`;
var rC = {};
Object.defineProperty(rC, "__esModule", { value: !0 });
rC.image_vert = void 0;
rC.image_vert = `
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;
}
`;
var tC = {};
Object.defineProperty(tC, "__esModule", { value: !0 });
tC.image_frag = void 0;
tC.image_frag = `
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
}
`;
var sI;
function Bn() {
  if (sI) return Cn;
  sI = 1, Object.defineProperty(Cn, "__esModule", { value: !0 }), Cn.addShaderDefines = Cn.ImageShaderCode = Cn.DirectVolumeShaderCode = Cn.MeshShaderCode = Cn.LinesShaderCode = Cn.TextShaderCode = Cn.CylindersShaderCode = Cn.SpheresShaderCode = Cn.PointsShaderCode = Cn.ShaderCode = void 0;
  var e = Ra, r = vs(), t = (0, e.idFactory)(), n = cS, a = dS, i = fS, o = mS, c = vS, s = pS, u = hS, l = gS, f = yS, d = _S, m = bS, p = SS, v = CS, h = AS, y = xS, C = TS, S = PS, b = MS, g = wS, _ = ES, A = DS, M = IS, P = BS, T = NS, x = VS, w = RS, E = OS, I = FS, B = LS, D = kS, N = US, O = {
    apply_fog: n.apply_fog,
    apply_interior_color: a.apply_interior_color,
    apply_light_color: i.apply_light_color,
    apply_marker_color: o.apply_marker_color,
    assign_clipping_varying: c.assign_clipping_varying,
    assign_color_varying: s.assign_color_varying,
    assign_group: u.assign_group,
    assign_marker_varying: l.assign_marker_varying,
    assign_material_color: f.assign_material_color,
    assign_position: d.assign_position,
    assign_size: m.assign_size,
    check_picking_alpha: p.check_picking_alpha,
    clip_instance: v.clip_instance,
    clip_pixel: h.clip_pixel,
    color_frag_params: y.color_frag_params,
    color_vert_params: C.color_vert_params,
    common_clip: S.common_clip,
    common_frag_params: b.common_frag_params,
    common_vert_params: g.common_vert_params,
    common: _.common,
    float_to_rgba: A.float_to_rgba,
    light_frag_params: M.light_frag_params,
    matrix_scale: P.matrix_scale,
    normal_frag_params: T.normal_frag_params,
    read_from_texture: x.read_from_texture,
    rgba_to_float: w.rgba_to_float,
    size_vert_params: E.size_vert_params,
    texture3d_from_1d_trilinear: I.texture3d_from_1d_trilinear,
    texture3d_from_2d_linear: B.texture3d_from_2d_linear,
    texture3d_from_2d_nearest: D.texture3d_from_2d_nearest,
    wboit_write: N.wboit_write
  }, V = /^(?!\/\/)\s*#include\s+(\S+)/gm, k = /#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, G = /[ \t]*\/\/.*\n/g, L = /[ \t]*\/\*[\s\S]*?\*\//g, R = /\n{2,}/g;
  function F(Me) {
    return Me.replace(V, function(ue, pe) {
      var Ae = O[pe];
      if (!Ae)
        throw new Error("empty chunk, '".concat(pe, "'"));
      return Ae;
    }).trim().replace(G, `
`).replace(L, `
`).replace(R, `
`);
  }
  function U(Me) {
    return Me.replace(k, H);
  }
  function H(Me, ue, pe, Ae) {
    for (var ye = "", be = parseInt(ue); be < parseInt(pe); ++be)
      ye += Ae.replace(/\[\s*i\s*\]/g, "[".concat(be, "]")).replace(/UNROLLED_LOOP_INDEX/g, "".concat(be));
    return ye;
  }
  function q(Me, ue) {
    return ue.dLightCount && (Me = Me.replace(/dLightCount/g, "".concat(ue.dLightCount.ref.value))), ue.dClipObjectCount && (Me = Me.replace(/dClipObjectCount/g, "".concat(ue.dClipObjectCount.ref.value))), Me;
  }
  function K(Me, ue) {
    return U(q(Me, ue));
  }
  function Y(Me, ue, pe, Ae, ye, be) {
    return Ae === void 0 && (Ae = {}), ye === void 0 && (ye = {}), { id: t(), name: Me, vert: F(ue), frag: F(pe), extensions: Ae, outTypes: ye, ignoreDefine: be };
  }
  Cn.ShaderCode = Y;
  function X(Me, ue, pe) {
    var Ae;
    if (ue.startsWith("color")) {
      if (Me === "dLightCount")
        return !!(!((Ae = pe.dIgnoreLight) === null || Ae === void 0) && Ae.ref.value);
    } else
      return [
        "dColorType",
        "dUsePalette",
        "dLightCount",
        "dOverpaintType",
        "dOverpaint",
        "dSubstanceType",
        "dSubstance"
      ].includes(Me);
    return !1;
  }
  function Z(Me, ue, pe) {
    return Me === "dLightCount" ? !0 : X(Me, ue, pe);
  }
  var J = zS, $ = GS;
  Cn.PointsShaderCode = Y("points", J.points_vert, $.points_frag, { drawBuffers: "optional" }, {}, Z);
  var Q = qS, W = HS;
  Cn.SpheresShaderCode = Y("spheres", Q.spheres_vert, W.spheres_frag, { fragDepth: "required", drawBuffers: "optional" }, {}, X);
  var te = jS, oe = $S;
  Cn.CylindersShaderCode = Y("cylinders", te.cylinders_vert, oe.cylinders_frag, { fragDepth: "required", drawBuffers: "optional" }, {}, X);
  var z = KS, j = WS;
  Cn.TextShaderCode = Y("text", z.text_vert, j.text_frag, { drawBuffers: "optional" }, {}, Z);
  var ae = XS, le = YS;
  Cn.LinesShaderCode = Y("lines", ae.lines_vert, le.lines_frag, { drawBuffers: "optional" }, {}, Z);
  var ie = QS, re = ZS;
  Cn.MeshShaderCode = Y("mesh", ie.mesh_vert, re.mesh_frag, { drawBuffers: "optional" }, {}, X);
  var ee = JS, ne = eC;
  Cn.DirectVolumeShaderCode = Y("direct-volume", ee.directVolume_vert, ne.directVolume_frag, { fragDepth: "optional", drawBuffers: "optional" }, {}, X);
  var se = rC, ce = tC, de = Ft;
  Cn.ImageShaderCode = Y("image", se.image_vert, ce.image_frag, { drawBuffers: "optional" }, {}, Z);
  function me(Me, ue) {
    var pe;
    if (Me === void 0)
      return "";
    var Ae = ((pe = Me.dRenderVariant) === null || pe === void 0 ? void 0 : pe.ref.value) || "", ye = [];
    for (var be in Me)
      if (!(ue != null && ue(be, Ae, Me))) {
        var fe = Me[be], ge = fe.ref.value;
        ge !== void 0 && (typeof ge == "string" ? ye.push("#define ".concat(be, "_").concat(ge)) : typeof ge == "number" ? ye.push("#define ".concat(be, " ").concat(ge)) : typeof ge == "boolean" ? ge && ye.push("#define ".concat(be)) : (0, de.assertUnreachable)(ge));
      }
    return ye.join(`
`) + `
`;
  }
  function he(Me, ue) {
    var pe = [
      "#extension GL_OES_standard_derivatives : enable"
    ];
    if (ue.fragDepth) {
      if (Me.fragDepth)
        pe.push("#extension GL_EXT_frag_depth : enable"), pe.push("#define enabledFragDepth");
      else if (ue.fragDepth === "required")
        throw new Error("required 'GL_EXT_frag_depth' extension not available");
    }
    if (ue.drawBuffers) {
      if (Me.drawBuffers)
        pe.push("#extension GL_EXT_draw_buffers : require"), pe.push("#define requiredDrawBuffers"), pe.push("#define gl_FragColor gl_FragData[0]");
      else if (ue.drawBuffers === "required")
        throw new Error("required 'GL_EXT_draw_buffers' extension not available");
    }
    if (ue.shaderTextureLod) {
      if (Me.shaderTextureLod)
        pe.push("#extension GL_EXT_shader_texture_lod : enable"), pe.push("#define enabledShaderTextureLod");
      else if (ue.shaderTextureLod === "required")
        throw new Error("required 'GL_EXT_shader_texture_lod' extension not available");
    }
    return Me.depthTexture && pe.push("#define depthTextureSupport"), pe.join(`
`) + `
`;
  }
  var _e = `#version 300 es
#define attribute in
#define varying out
#define texture2D texture
`, Se = `
#define varying in
#define texture2D texture
#define texture2DLodEXT textureLod

#define gl_FragColor out_FragData0
#define gl_FragDepthEXT gl_FragDepth

#define depthTextureSupport
`;
  function Pe(Me, ue, pe, Ae) {
    var ye = [
      "#version 300 es",
      "layout(location = 0) out highp ".concat(Ae[0] || "vec4", " out_FragData0;")
    ];
    if (pe.fragDepth && ye.push("#define enabledFragDepth"), pe.drawBuffers) {
      ye.push("#define requiredDrawBuffers");
      for (var be = Me.getParameter(Me.MAX_DRAW_BUFFERS), fe = 1, ge = be; fe < ge; ++fe)
        ye.push("layout(location = ".concat(fe, ") out highp ").concat(Ae[fe] || "vec4", " out_FragData").concat(fe, ";"));
    }
    return pe.shaderTextureLod && ye.push("#define enabledShaderTextureLod"), ye.push(Se), ye.join(`
`) + `
`;
  }
  function De(Me) {
    return Me.replace(/gl_FragData\[([0-9]+)\]/g, "out_FragData$1");
  }
  function Ee(Me, ue, pe, Ae) {
    var ye = me(pe, Ae.ignoreDefine), be = me(pe, Ae.ignoreDefine), fe = (0, r.isWebGL2)(Me) ? _e : "", ge = (0, r.isWebGL2)(Me) ? Pe(Me, ue, Ae.extensions, Ae.outTypes) : he(ue, Ae.extensions), xe = (0, r.isWebGL2)(Me) ? De(Ae.frag) : Ae.frag;
    return {
      id: t(),
      name: Ae.name,
      vert: "".concat(fe).concat(ye).concat(K(Ae.vert, pe)),
      frag: "".concat(ge).concat(be).concat(K(xe, pe)),
      extensions: Ae.extensions,
      outTypes: Ae.outTypes
    };
  }
  return Cn.addShaderDefines = Ee, Cn;
}
var Ko = {};
Object.defineProperty(Ko, "__esModule", { value: !0 });
Ko.cloneUniformValues = Ko.isUniformValueScalar = Ko.getUniformGlslType = Ko.getUniformSetters = Ko.getUniformType = void 0;
var ene = We(), rne = nn;
function tne(e, r) {
  switch (r) {
    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(r, "'"));
  }
}
Ko.getUniformType = tne;
function nne(e, r, t) {
  e.uniform1f(r, t);
}
function ane(e, r, t) {
  e.uniform1fv(r, t);
}
function ine(e, r, t) {
  e.uniform1i(r, t);
}
function one(e, r, t) {
  e.uniform1iv(r, t);
}
function une(e, r, t) {
  e.uniform2fv(r, t);
}
function sne(e, r, t) {
  e.uniform3fv(r, t);
}
function lne(e, r, t) {
  e.uniform4fv(r, t);
}
function cne(e, r, t) {
  e.uniformMatrix3fv(r, !1, t);
}
function dne(e, r, t) {
  e.uniformMatrix4fv(r, !1, t);
}
function lI(e) {
  switch (e) {
    case "f":
      return nne;
    case "f[]":
      return ane;
    case "i":
    case "t":
    case "b":
      return ine;
    case "i[]":
    case "t[]":
    case "b[]":
      return one;
    case "v2":
    case "v2[]":
      return une;
    case "v3":
    case "v3[]":
      return sne;
    case "v4":
    case "v4[]":
      return lne;
    case "m3":
    case "m3[]":
      return cne;
    case "m4":
    case "m4[]":
      return dne;
  }
}
function fne(e) {
  var r = {};
  return Object.keys(e).forEach(function(t) {
    var n = e[t];
    n.type === "uniform" ? r[t] = lI(n.kind) : n.type === "texture" && (r[t] = lI("t"));
  }), r;
}
Ko.getUniformSetters = fne;
function mne(e) {
  switch (e) {
    case "f":
      return "float";
    case "i":
      return "int";
    case "t":
      return "sampler2D";
    case "b":
      return "bool";
    case "v2":
      return "vec2";
    case "v3":
      return "vec3";
    case "v4":
      return "vec4";
    case "m3":
      return "mat3";
    case "m4":
      return "mat4";
  }
  throw new Error("".concat(e, " has no primitive GLSL type."));
}
Ko.getUniformGlslType = mne;
function vne(e) {
  switch (e) {
    case "f":
    case "i":
    case "b":
      return !0;
    default:
      return !1;
  }
}
Ko.isUniformValueScalar = vne;
function pne(e) {
  var r = {};
  return Object.keys(e).forEach(function(t) {
    r[t] = ene.ValueCell.create((0, rne.deepClone)(e[t].ref.value));
  }), r;
}
Ko.cloneUniformValues = pne;
var Na = {};
Object.defineProperty(Na, "__esModule", { value: !0 });
Na.createElementsBuffer = Na.createAttributeBuffers = Na.createAttributeBuffer = Na.getAttribType = Na.getBufferType = Na.getDataType = Na.getUsageHint = void 0;
var Sb = Te, hne = Ra, gne = Ft, yne = (0, hne.idFactory)();
function Iz(e, r) {
  switch (r) {
    case "static":
      return e.STATIC_DRAW;
    case "dynamic":
      return e.DYNAMIC_DRAW;
    case "stream":
      return e.STREAM_DRAW;
  }
}
Na.getUsageHint = Iz;
function _ne(e, r) {
  switch (r) {
    case "uint8":
      return e.UNSIGNED_BYTE;
    case "int8":
      return e.BYTE;
    case "uint16":
      return e.UNSIGNED_SHORT;
    case "int16":
      return e.SHORT;
    case "uint32":
      return e.UNSIGNED_INT;
    case "int32":
      return e.INT;
    case "float32":
      return e.FLOAT;
  }
}
Na.getDataType = _ne;
function bne(e, r) {
  if (r instanceof Uint8Array)
    return e.UNSIGNED_BYTE;
  if (r instanceof Int8Array)
    return e.BYTE;
  if (r instanceof Uint16Array)
    return e.UNSIGNED_SHORT;
  if (r instanceof Int16Array)
    return e.SHORT;
  if (r instanceof Uint32Array)
    return e.UNSIGNED_INT;
  if (r instanceof Int32Array)
    return e.INT;
  if (r instanceof Float32Array)
    return e.FLOAT;
  (0, gne.assertUnreachable)(r);
}
function Bz(e, r) {
  switch (r) {
    case "attribute":
      return e.ARRAY_BUFFER;
    case "elements":
      return e.ELEMENT_ARRAY_BUFFER;
    case "uniform":
      return e.UNIFORM_BUFFER;
  }
}
Na.getBufferType = Bz;
function cI(e) {
  var r = e.createBuffer();
  if (r === null)
    throw new Error("Could not create WebGL buffer");
  return r;
}
function Nz(e, r, t, n) {
  var a = cI(e), i = Iz(e, t), o = Bz(e, n), c = bne(e, r), s = r.BYTES_PER_ELEMENT, u = r.length;
  function l(d) {
    e.bindBuffer(o, a), e.bufferData(o, d, i);
  }
  l(r);
  var f = !1;
  return {
    id: yne(),
    _usageHint: i,
    _bufferType: o,
    _dataType: c,
    _bpe: s,
    length: u,
    getBuffer: function() {
      return a;
    },
    updateData: l,
    updateSubData: function(d, m, p) {
      e.bindBuffer(o, a), p - m === d.length ? e.bufferSubData(o, 0, d) : e.bufferSubData(o, m * s, d.subarray(m, m + p));
    },
    reset: function() {
      a = cI(e), l(r);
    },
    destroy: function() {
      f || (e.deleteBuffer(a), f = !0);
    }
  };
}
function Sne(e, r, t) {
  switch (r) {
    case "int32":
      switch (t) {
        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 (t) {
        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;
      }
      break;
  }
  throw new Error("unknown attribute type for kind '".concat(r, "' and itemSize '").concat(t, "'"));
}
Na.getAttribType = Sne;
function Cne(e, r, t, n, a, i, o) {
  o === void 0 && (o = "dynamic");
  var c = t.instancedArrays, s = Nz(e, n, o, "attribute"), u = s._bufferType, l = s._dataType, f = s._bpe;
  return (0, Sb.__assign)((0, Sb.__assign)({}, s), { bind: function(d) {
    if (e.bindBuffer(u, s.getBuffer()), a === 16)
      for (var m = 0; m < 4; ++m)
        r.enableVertexAttrib(d + m), e.vertexAttribPointer(d + m, 4, l, !1, 4 * 4 * f, m * 4 * f), c.vertexAttribDivisor(d + m, i);
    else
      r.enableVertexAttrib(d), e.vertexAttribPointer(d, a, l, !1, 0, 0), c.vertexAttribDivisor(d, i);
  } });
}
Na.createAttributeBuffer = Cne;
function Ane(e, r, t) {
  var n = [];
  return Object.keys(r).forEach(function(a) {
    var i = r[a];
    i.type === "attribute" && (n[n.length] = [
      a,
      e.resources.attribute(t[a].ref.value, i.itemSize, i.divisor)
    ]);
  }), n;
}
Na.createAttributeBuffers = Ane;
function xne(e, r, t) {
  t === void 0 && (t = "static");
  var n = Nz(e, r, t, "elements");
  return (0, Sb.__assign)((0, Sb.__assign)({}, n), { bind: function() {
    e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, n.getBuffer());
  } });
}
Na.createElementsBuffer = xne;
var dI;
function Vz() {
  if (dI) return cf;
  dI = 1, Object.defineProperty(cf, "__esModule", { value: !0 }), cf.createProgram = cf.getProgram = void 0;
  var e = Bn(), r = Ko, t = Na, n = Ra, a = Zt, i = (0, n.idFactory)();
  function o(d, m, p) {
    var v = {};
    return Object.keys(p).forEach(function(h) {
      var y = p[h];
      if (y.type === "attribute") {
        var C = d.getAttribLocation(m, h);
        v[h] = C;
      } else if (y.type === "uniform" || y.type === "texture") {
        var C = d.getUniformLocation(m, h);
        v[h] = C;
      }
    }), v;
  }
  function c(d, m, p) {
    for (var v = d.getProgramParameter(m, d.ACTIVE_ATTRIBUTES), h = 0; h < v; ++h) {
      var y = d.getActiveAttrib(m, h);
      if (y) {
        var C = y.name, S = y.type;
        if (C.startsWith("__activeAttribute") || C === "gl_InstanceID" || C === "gl_VertexID")
          continue;
        var b = p[C];
        if (b === void 0)
          throw new Error("missing 'uniform' or 'texture' with name '".concat(C, "' in schema"));
        if (b.type !== "attribute")
          throw new Error("'".concat(C, "' must be of type 'attribute' but is '").concat(b.type, "'"));
        var g = (0, t.getAttribType)(d, b.kind, b.itemSize);
        if (g !== S)
          throw new Error("unexpected attribute type for ".concat(C));
      }
    }
  }
  function s(d, m, p) {
    for (var v = d.getProgramParameter(m, d.ACTIVE_UNIFORMS), h = 0; h < v; ++h) {
      var y = d.getActiveUniform(m, h);
      if (y) {
        var C = y.name, S = y.type;
        if (C.startsWith("__activeUniform"))
          continue;
        var b = C.replace(/[[0-9]+\]$/, ""), g = p[b];
        if (g === void 0)
          throw new Error("missing 'uniform' or 'texture' with name '".concat(C, "' in schema"));
        if (g.type === "uniform") {
          var _ = (0, r.getUniformType)(d, g.kind);
          if (_ !== S)
            throw new Error("unexpected uniform type for ".concat(C));
        } else if (g.type === "texture") {
          if (g.kind === "image-float32" || g.kind === "image-uint8") {
            if (S !== d.SAMPLER_2D)
              throw new Error("unexpected sampler type for '".concat(C, "'"));
          } else if ((g.kind === "volume-float32" || g.kind === "volume-uint8") && S !== d.SAMPLER_3D)
            throw new Error("unexpected sampler type for '".concat(C, "'"));
        } else
          throw new Error("'".concat(C, "' must be of type 'uniform' or 'texture' but is '").concat(g.type, "'"));
      }
    }
  }
  function u(d, m) {
    if (!d.getProgramParameter(m, d.LINK_STATUS))
      throw new Error(`Could not compile WebGL program. 

`.concat(d.getProgramInfoLog(m)));
  }
  function l(d) {
    var m = d.createProgram();
    if (m === null)
      throw new Error("Could not create WebGL program");
    return m;
  }
  cf.getProgram = l;
  function f(d, m, p, v, h) {
    var y = h.defineValues, C = h.shaderCode, S = h.schema, b = l(d), g = i(), _ = (0, e.addShaderDefines)(d, p, y, C), A = v("vert", _.vert), M = v("frag", _.frag), P, T;
    function x() {
      A.attach(b), M.attach(b), d.linkProgram(b), a.isDebugMode && u(d, b), P = o(d, b, S), T = (0, r.getUniformSetters)(S), a.isDebugMode && (c(d, b, S), s(d, b, S));
    }
    x();
    var w = !1;
    return {
      id: g,
      use: function() {
        m.currentProgramId = g, d.useProgram(b);
      },
      setUniforms: function(E) {
        for (var I = 0, B = E.length; I < B; ++I) {
          var D = E[I], N = D[0], O = D[1];
          if (O) {
            var V = P[N];
            V !== null && T[N](d, V, O.ref.value);
          }
        }
      },
      bindAttributes: function(E) {
        m.clearVertexAttribsState();
        for (var I = 0, B = E.length; I < B; ++I) {
          var D = E[I], N = D[0], O = D[1], V = P[N];
          V !== -1 && O.bind(V);
        }
        m.disableUnusedVertexAttribs();
      },
      bindTextures: function(E, I) {
        for (var B = 0, D = E.length; B < D; ++B) {
          var N = E[B], O = N[0], V = N[1], k = P[O];
          k != null && (V.bind(B + I), T[O](d, k, B + I));
        }
      },
      reset: function() {
        b = l(d), x();
      },
      destroy: function() {
        w || (A.destroy(), M.destroy(), d.deleteProgram(b), w = !0);
      }
    };
  }
  return cf.createProgram = f, cf;
}
var s0 = {};
Object.defineProperty(s0, "__esModule", { value: !0 });
s0.createShader = s0.getShader = void 0;
var Tne = Ra, Pne = Zt, Mne = (0, Tne.idFactory)();
function wne(e) {
  for (var r = e.split(`
`), t = 0; t < r.length; ++t)
    r[t] = t + 1 + ": " + r[t];
  return r.join(`
`);
}
function uM(e, r) {
  var t = r.type, n = r.source, a = e.createShader(t === "vert" ? e.VERTEX_SHADER : e.FRAGMENT_SHADER);
  if (a === null)
    throw new Error("Error creating ".concat(t, " shader"));
  if (e.shaderSource(a, n), e.compileShader(a), Pne.isDebugMode && e.getShaderParameter(a, e.COMPILE_STATUS) === !1)
    throw console.warn("'".concat(t, "' shader info log '").concat(e.getShaderInfoLog(a), `'
`).concat(wne(n))), new Error("Error compiling ".concat(t, " shader"));
  return a;
}
s0.getShader = uM;
function Ene(e, r) {
  var t = uM(e, r);
  return {
    id: Mne(),
    attach: function(n) {
      e.attachShader(n, t);
    },
    reset: function() {
      t = uM(e, r);
    },
    destroy: function() {
      e.deleteShader(t);
    }
  };
}
s0.createShader = Ene;
var fI;
function vs() {
  if (fI) return Wr;
  fI = 1, Object.defineProperty(Wr, "__esModule", { value: !0 }), Wr.testColorBuffer = Wr.getSRGB = Wr.getDepthTexture = Wr.getShaderTextureLod = Wr.getDrawBuffers = Wr.getColorBufferHalfFloat = Wr.getColorBufferFloat = Wr.getFragDepth = Wr.getBlendMinMax = Wr.getTextureHalfFloatLinear = Wr.getTextureHalfFloat = Wr.getTextureFloatLinear = Wr.getTextureFloat = Wr.getVertexArrayObject = Wr.getElementIndexUint = Wr.getStandardDerivatives = Wr.getInstancedArrays = Wr.isWebGL2 = Wr.isWebGL = void 0;
  var e = Zt, r = dE(), t = Vz(), n = s0;
  function a(T) {
    return typeof WebGLRenderingContext < "u" && T instanceof WebGLRenderingContext;
  }
  Wr.isWebGL = a;
  function i(T) {
    return typeof WebGL2RenderingContext < "u" && T instanceof WebGL2RenderingContext;
  }
  Wr.isWebGL2 = i;
  function o(T) {
    if (i(T))
      return {
        drawArraysInstanced: T.drawArraysInstanced.bind(T),
        drawElementsInstanced: T.drawElementsInstanced.bind(T),
        vertexAttribDivisor: T.vertexAttribDivisor.bind(T),
        VERTEX_ATTRIB_ARRAY_DIVISOR: T.VERTEX_ATTRIB_ARRAY_DIVISOR
      };
    var x = T.getExtension("ANGLE_instanced_arrays");
    return x === null ? null : {
      drawArraysInstanced: x.drawArraysInstancedANGLE.bind(x),
      drawElementsInstanced: x.drawElementsInstancedANGLE.bind(x),
      vertexAttribDivisor: x.vertexAttribDivisorANGLE.bind(x),
      VERTEX_ATTRIB_ARRAY_DIVISOR: x.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE
    };
  }
  Wr.getInstancedArrays = o;
  function c(T) {
    if (i(T))
      return {
        FRAGMENT_SHADER_DERIVATIVE_HINT: T.FRAGMENT_SHADER_DERIVATIVE_HINT
      };
    var x = T.getExtension("OES_standard_derivatives");
    return x === null ? null : {
      FRAGMENT_SHADER_DERIVATIVE_HINT: x.FRAGMENT_SHADER_DERIVATIVE_HINT_OES
    };
  }
  Wr.getStandardDerivatives = c;
  function s(T) {
    return i(T) ? {} : T.getExtension("OES_element_index_uint");
  }
  Wr.getElementIndexUint = s;
  function u(T) {
    if (i(T))
      return {
        VERTEX_ARRAY_BINDING: T.VERTEX_ARRAY_BINDING,
        bindVertexArray: T.bindVertexArray.bind(T),
        createVertexArray: T.createVertexArray.bind(T),
        deleteVertexArray: T.deleteVertexArray.bind(T),
        isVertexArray: T.isVertexArray.bind(T)
      };
    var x = T.getExtension("OES_vertex_array_object");
    return x === null ? null : {
      VERTEX_ARRAY_BINDING: x.VERTEX_ARRAY_BINDING_OES,
      bindVertexArray: x.bindVertexArrayOES.bind(x),
      createVertexArray: x.createVertexArrayOES.bind(x),
      deleteVertexArray: x.deleteVertexArrayOES.bind(x),
      isVertexArray: x.isVertexArrayOES.bind(x)
    };
  }
  Wr.getVertexArrayObject = u;
  function l(T) {
    return i(T) ? {} : T.getExtension("OES_texture_float");
  }
  Wr.getTextureFloat = l;
  function f(T) {
    return T.getExtension("OES_texture_float_linear");
  }
  Wr.getTextureFloatLinear = f;
  function d(T) {
    if (i(T))
      return { HALF_FLOAT: T.HALF_FLOAT };
    var x = T.getExtension("OES_texture_half_float");
    return x === null ? null : { HALF_FLOAT: x.HALF_FLOAT_OES };
  }
  Wr.getTextureHalfFloat = d;
  function m(T) {
    return T.getExtension("OES_texture_half_float_linear");
  }
  Wr.getTextureHalfFloatLinear = m;
  function p(T) {
    if (i(T))
      return { MIN: T.MIN, MAX: T.MAX };
    var x = T.getExtension("EXT_blend_minmax");
    return x === null ? null : { MIN: x.MIN_EXT, MAX: x.MAX_EXT };
  }
  Wr.getBlendMinMax = p;
  function v(T) {
    return i(T) ? {} : T.getExtension("EXT_frag_depth");
  }
  Wr.getFragDepth = v;
  function h(T) {
    if (i(T))
      return T.getExtension("EXT_color_buffer_float") === null ? null : (T.getExtension("EXT_float_blend"), { RGBA32F: T.RGBA32F });
    var x = T.getExtension("WEBGL_color_buffer_float");
    return x === null ? (T.getExtension("OES_texture_float"), P(T, T.FLOAT) ? { RGBA32F: 34836 } : null) : (T.getExtension("EXT_float_blend"), { RGBA32F: x.RGBA32F_EXT });
  }
  Wr.getColorBufferFloat = h;
  function y(T) {
    if (i(T))
      return T.getExtension("EXT_color_buffer_half_float") === null ? null : (T.getExtension("EXT_float_blend"), { RGBA16F: T.RGBA16F });
    var x = T.getExtension("EXT_color_buffer_half_float");
    return x === null ? (T.getExtension("OES_texture_half_float"), P(T, 36193) ? { RGBA16F: 34842 } : null) : (T.getExtension("EXT_float_blend"), { RGBA16F: x.RGBA16F_EXT });
  }
  Wr.getColorBufferHalfFloat = y;
  function C(T) {
    if (i(T))
      return {
        drawBuffers: T.drawBuffers.bind(T),
        COLOR_ATTACHMENT0: T.COLOR_ATTACHMENT0,
        COLOR_ATTACHMENT1: T.COLOR_ATTACHMENT1,
        COLOR_ATTACHMENT2: T.COLOR_ATTACHMENT2,
        COLOR_ATTACHMENT3: T.COLOR_ATTACHMENT3,
        COLOR_ATTACHMENT4: T.COLOR_ATTACHMENT4,
        COLOR_ATTACHMENT5: T.COLOR_ATTACHMENT5,
        COLOR_ATTACHMENT6: T.COLOR_ATTACHMENT6,
        COLOR_ATTACHMENT7: T.COLOR_ATTACHMENT7,
        DRAW_BUFFER0: T.DRAW_BUFFER0,
        DRAW_BUFFER1: T.DRAW_BUFFER1,
        DRAW_BUFFER2: T.DRAW_BUFFER2,
        DRAW_BUFFER3: T.DRAW_BUFFER3,
        DRAW_BUFFER4: T.DRAW_BUFFER4,
        DRAW_BUFFER5: T.DRAW_BUFFER5,
        DRAW_BUFFER6: T.DRAW_BUFFER6,
        DRAW_BUFFER7: T.DRAW_BUFFER7,
        MAX_COLOR_ATTACHMENTS: T.MAX_COLOR_ATTACHMENTS,
        MAX_DRAW_BUFFERS: T.MAX_DRAW_BUFFERS
      };
    var x = T.getExtension("WEBGL_draw_buffers");
    return x === null ? null : {
      drawBuffers: x.drawBuffersWEBGL.bind(x),
      COLOR_ATTACHMENT0: x.COLOR_ATTACHMENT0_WEBGL,
      COLOR_ATTACHMENT1: x.COLOR_ATTACHMENT1_WEBGL,
      COLOR_ATTACHMENT2: x.COLOR_ATTACHMENT2_WEBGL,
      COLOR_ATTACHMENT3: x.COLOR_ATTACHMENT3_WEBGL,
      COLOR_ATTACHMENT4: x.COLOR_ATTACHMENT4_WEBGL,
      COLOR_ATTACHMENT5: x.COLOR_ATTACHMENT5_WEBGL,
      COLOR_ATTACHMENT6: x.COLOR_ATTACHMENT6_WEBGL,
      COLOR_ATTACHMENT7: x.COLOR_ATTACHMENT7_WEBGL,
      DRAW_BUFFER0: x.DRAW_BUFFER0_WEBGL,
      DRAW_BUFFER1: x.DRAW_BUFFER1_WEBGL,
      DRAW_BUFFER2: x.DRAW_BUFFER2_WEBGL,
      DRAW_BUFFER3: x.DRAW_BUFFER3_WEBGL,
      DRAW_BUFFER4: x.DRAW_BUFFER4_WEBGL,
      DRAW_BUFFER5: x.DRAW_BUFFER5_WEBGL,
      DRAW_BUFFER6: x.DRAW_BUFFER6_WEBGL,
      DRAW_BUFFER7: x.DRAW_BUFFER7_WEBGL,
      MAX_COLOR_ATTACHMENTS: x.MAX_COLOR_ATTACHMENTS_WEBGL,
      MAX_DRAW_BUFFERS: x.MAX_DRAW_BUFFERS_WEBGL
    };
  }
  Wr.getDrawBuffers = C;
  function S(T) {
    return i(T) ? {} : T.getExtension("EXT_shader_texture_lod");
  }
  Wr.getShaderTextureLod = S;
  function b(T) {
    if (i(T))
      return {
        UNSIGNED_INT_24_8: T.UNSIGNED_INT_24_8
      };
    var x = T.getExtension("WEBGL_depth_texture");
    return x === null ? null : {
      UNSIGNED_INT_24_8: x.UNSIGNED_INT_24_8_WEBGL
    };
  }
  Wr.getDepthTexture = b;
  function g(T) {
    if (i(T))
      return {
        FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: T.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING,
        SRGB8_ALPHA8: T.SRGB8_ALPHA8,
        SRGB8: T.SRGB8,
        SRGB: T.SRGB
      };
    var x = T.getExtension("EXT_sRGB");
    return x === null ? null : {
      FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: x.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT,
      SRGB8_ALPHA8: x.SRGB8_ALPHA8_EXT,
      SRGB8: x.SRGB_ALPHA_EXT,
      SRGB: x.SRGB_EXT
    };
  }
  Wr.getSRGB = g;
  var _ = `
attribute vec4 aPosition;

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

void main() {
    gl_FragColor = texture2D(uTexture, vec2(0.5, 0.5)) * uColor;
}`, M = new Float32Array([
    -1,
    -1,
    1,
    -1,
    -1,
    1,
    -1,
    1,
    1,
    -1,
    1,
    1
  ]);
  function P(T, x) {
    var w = (0, n.getShader)(T, {
      type: "vert",
      source: _
    }), E = (0, n.getShader)(T, {
      type: "frag",
      source: A
    });
    if (!w || !E)
      return !1;
    var I = (0, t.getProgram)(T);
    T.attachShader(I, w), T.attachShader(I, E), T.linkProgram(I), T.useProgram(I);
    var B = T.getAttribLocation(I, "aPosition"), D = T.getUniformLocation(I, "uColor");
    if (!D)
      return e.isDebugMode && console.log("error getting 'uColor' uniform location"), !1;
    var N = T.createBuffer();
    T.bindBuffer(T.ARRAY_BUFFER, N), T.bufferData(T.ARRAY_BUFFER, M, T.STATIC_DRAW), T.enableVertexAttribArray(B), T.vertexAttribPointer(B, 2, T.FLOAT, !1, 0, 0);
    var O = T.createTexture(), V = new Uint8Array([255, 255, 255, 255]);
    T.bindTexture(T.TEXTURE_2D, O), T.texImage2D(T.TEXTURE_2D, 0, T.RGBA, 1, 1, 0, T.RGBA, T.UNSIGNED_BYTE, V);
    var k = T.createTexture();
    T.bindTexture(T.TEXTURE_2D, k), T.texImage2D(T.TEXTURE_2D, 0, T.RGBA, 1, 1, 0, T.RGBA, x, null), T.texParameteri(T.TEXTURE_2D, T.TEXTURE_MIN_FILTER, T.NEAREST), T.texParameteri(T.TEXTURE_2D, T.TEXTURE_MAG_FILTER, T.NEAREST);
    var G = T.createFramebuffer();
    T.bindFramebuffer(T.FRAMEBUFFER, G), T.framebufferTexture2D(T.FRAMEBUFFER, T.COLOR_ATTACHMENT0, T.TEXTURE_2D, k, 0);
    var L = T.checkFramebufferStatus(T.FRAMEBUFFER);
    if (L !== T.FRAMEBUFFER_COMPLETE)
      return e.isDebugMode && console.log("error creating framebuffer for '".concat(x, "'")), !1;
    T.bindTexture(T.TEXTURE_2D, O), T.uniform4fv(D, [0, 10, 20, 1]), T.drawArrays(T.TRIANGLES, 0, 6), T.bindTexture(T.TEXTURE_2D, k), T.bindFramebuffer(T.FRAMEBUFFER, null), T.clearColor(1, 0, 0, 1), T.clear(T.COLOR_BUFFER_BIT), T.uniform4fv(D, [0, 1 / 10, 1 / 20, 1]), T.drawArrays(T.TRIANGLES, 0, 6);
    var R = new Uint8Array(4);
    if (T.readPixels(0, 0, 1, 1, T.RGBA, T.UNSIGNED_BYTE, R), R[0] !== 0 || R[1] < 248 || R[2] < 248 || R[3] < 254)
      return e.isDebugMode && console.log("not able to actually render to '".concat(x, "' texture")), !1;
    if (x === T.FLOAT) {
      T.bindFramebuffer(T.FRAMEBUFFER, G);
      var F = new Float32Array(4);
      T.readPixels(0, 0, 1, 1, T.RGBA, T.FLOAT, F);
      var U = T.getError();
      if (U)
        return e.isDebugMode && console.log("error reading float pixels: '".concat((0, r.getErrorDescription)(T, U), "'")), !1;
    }
    return !0;
  }
  return Wr.testColorBuffer = P, Wr;
}
var xl = {}, mI;
function ay() {
  if (mI) return xl;
  mI = 1, Object.defineProperty(xl, "__esModule", { value: !0 }), xl.createNullFramebuffer = xl.createFramebuffer = xl.checkFramebufferStatus = void 0;
  var e = Ra, r = vs(), t = (0, e.idFactory)();
  function n(s, u) {
    switch (u) {
      case s.FRAMEBUFFER_COMPLETE:
        return "complete";
      case s.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
        return "incomplete attachment";
      case s.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
        return "incomplete missing attachment";
      case s.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
        return "incomplete dimensions";
      case s.FRAMEBUFFER_UNSUPPORTED:
        return "unsupported";
    }
    if ((0, r.isWebGL2)(s))
      switch (u) {
        case s.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
          return "incomplete multisample";
        case s.RENDERBUFFER_SAMPLES:
          return "renderbuffer samples";
      }
    return "unknown error";
  }
  function a(s) {
    var u = s.checkFramebufferStatus(s.FRAMEBUFFER);
    if (u !== s.FRAMEBUFFER_COMPLETE) {
      var l = n(s, u);
      throw new Error("Framebuffer status: ".concat(l));
    }
  }
  xl.checkFramebufferStatus = a;
  function i(s) {
    var u = s.createFramebuffer();
    if (u === null)
      throw new Error("Could not create WebGL framebuffer");
    return u;
  }
  function o(s) {
    var u = i(s), l = !1;
    return {
      id: t(),
      bind: function() {
        return s.bindFramebuffer(s.FRAMEBUFFER, u);
      },
      reset: function() {
        u = i(s);
      },
      destroy: function() {
        l || (s.deleteFramebuffer(u), l = !0);
      }
    };
  }
  xl.createFramebuffer = o;
  function c() {
    return {
      id: t(),
      bind: function() {
      },
      reset: function() {
      },
      destroy: function() {
      }
    };
  }
  return xl.createNullFramebuffer = c, xl;
}
var ph = {}, vI;
function Dne() {
  if (vI) return ph;
  vI = 1, Object.defineProperty(ph, "__esModule", { value: !0 }), ph.createExtensions = void 0;
  var e = vs(), r = Zt;
  function t(n) {
    var a = (0, e.getInstancedArrays)(n);
    if (a === null)
      throw new Error('Could not find support for "instanced_arrays"');
    var i = (0, e.getElementIndexUint)(n);
    if (i === null)
      throw new Error('Could not find support for "element_index_uint"');
    var o = (0, e.getStandardDerivatives)(n);
    if (o === null)
      throw new Error('Could not find support for "standard_derivatives"');
    var c = (0, e.getTextureFloat)(n);
    r.isDebugMode && c === null && console.log('Could not find support for "texture_float"');
    var s = (0, e.getTextureFloatLinear)(n);
    r.isDebugMode && s === null && console.log('Could not find support for "texture_float_linear"');
    var u = (0, e.getTextureHalfFloat)(n);
    r.isDebugMode && u === null && console.log('Could not find support for "texture_half_float"');
    var l = (0, e.getTextureHalfFloatLinear)(n);
    r.isDebugMode && l === null && console.log('Could not find support for "texture_half_float_linear"');
    var f = (0, e.getDepthTexture)(n);
    r.isDebugMode && f === null && console.log('Could not find support for "depth_texture"');
    var d = (0, e.getBlendMinMax)(n);
    r.isDebugMode && d === null && console.log('Could not find support for "blend_minmax"');
    var m = (0, e.getVertexArrayObject)(n);
    r.isDebugMode && m === null && console.log('Could not find support for "vertex_array_object"');
    var p = (0, e.getFragDepth)(n);
    r.isDebugMode && p === null && console.log('Could not find support for "frag_depth"');
    var v = (0, e.getColorBufferFloat)(n);
    r.isDebugMode && v === null && console.log('Could not find support for "color_buffer_float"');
    var h = (0, e.getColorBufferHalfFloat)(n);
    r.isDebugMode && h === null && console.log('Could not find support for "color_buffer_half_float"');
    var y = (0, e.getDrawBuffers)(n);
    r.isDebugMode && y === null && console.log('Could not find support for "draw_buffers"');
    var C = (0, e.getShaderTextureLod)(n);
    r.isDebugMode && C === null && console.log('Could not find support for "shader_texture_lod"');
    var S = (0, e.getSRGB)(n);
    return r.isDebugMode && S === null && console.log('Could not find support for "sRGB"'), {
      instancedArrays: a,
      standardDerivatives: o,
      textureFloat: c,
      textureFloatLinear: s,
      textureHalfFloat: u,
      textureHalfFloatLinear: l,
      elementIndexUint: i,
      depthTexture: f,
      blendMinMax: d,
      vertexArrayObject: m,
      fragDepth: p,
      colorBufferFloat: v,
      colorBufferHalfFloat: h,
      drawBuffers: y,
      shaderTextureLod: C,
      sRGB: S
    };
  }
  return ph.createExtensions = t, ph;
}
var nC = {};
Object.defineProperty(nC, "__esModule", { value: !0 });
nC.createState = void 0;
function Ine(e) {
  var r = {}, t = e.getParameter(e.FRONT_FACE), n = e.getParameter(e.CULL_FACE_MODE), a = e.getParameter(e.DEPTH_WRITEMASK), i = e.getParameter(e.COLOR_WRITEMASK), o = e.getParameter(e.COLOR_CLEAR_VALUE), c = e.getParameter(e.BLEND_SRC_RGB), s = e.getParameter(e.BLEND_DST_RGB), u = e.getParameter(e.BLEND_SRC_ALPHA), l = e.getParameter(e.BLEND_DST_ALPHA), f = e.getParameter(e.BLEND_EQUATION_RGB), d = e.getParameter(e.BLEND_EQUATION_ALPHA), m = e.getParameter(e.MAX_VERTEX_ATTRIBS), p = [], v = function() {
    for (var h = 0; h < m; ++h)
      p[h] = 0;
  };
  return v(), {
    currentProgramId: -1,
    currentMaterialId: -1,
    currentRenderItemId: -1,
    enable: function(h) {
      r[h] !== !0 && (e.enable(h), r[h] = !0);
    },
    disable: function(h) {
      r[h] !== !1 && (e.disable(h), r[h] = !1);
    },
    frontFace: function(h) {
      h !== t && (e.frontFace(h), t = h);
    },
    cullFace: function(h) {
      h !== n && (e.cullFace(h), n = h);
    },
    depthMask: function(h) {
      h !== a && (e.depthMask(h), a = h);
    },
    colorMask: function(h, y, C, S) {
      (h !== i[0] || y !== i[1] || C !== i[2] || S !== i[3]) && (e.colorMask(h, y, C, S), i[0] = h, i[1] = y, i[2] = C, i[3] = S);
    },
    clearColor: function(h, y, C, S) {
      (h !== o[0] || y !== o[1] || C !== o[2] || S !== o[3]) && (e.clearColor(h, y, C, S), o[0] = h, o[1] = y, o[2] = C, o[3] = S);
    },
    blendFunc: function(h, y) {
      (h !== c || y !== s || h !== u || y !== l) && (e.blendFunc(h, y), c = h, s = y, u = h, l = y);
    },
    blendFuncSeparate: function(h, y, C, S) {
      (h !== c || y !== s || C !== u || S !== l) && (e.blendFuncSeparate(h, y, C, S), c = h, s = y, u = C, l = S);
    },
    blendEquation: function(h) {
      (h !== f || h !== d) && (e.blendEquation(h), f = h, d = h);
    },
    blendEquationSeparate: function(h, y) {
      (h !== f || y !== d) && (e.blendEquationSeparate(h, y), f = h, d = y);
    },
    enableVertexAttrib: function(h) {
      e.enableVertexAttribArray(h), p[h] = 1;
    },
    clearVertexAttribsState: v,
    disableUnusedVertexAttribs: function() {
      for (var h = 0; h < m; ++h)
        p[h] === 0 && e.disableVertexAttribArray(h);
    },
    reset: function() {
      r = {}, t = e.getParameter(e.FRONT_FACE), n = e.getParameter(e.CULL_FACE_MODE), a = e.getParameter(e.DEPTH_WRITEMASK), i = e.getParameter(e.COLOR_WRITEMASK), o = e.getParameter(e.COLOR_CLEAR_VALUE), c = e.getParameter(e.BLEND_SRC_RGB), s = e.getParameter(e.BLEND_DST_RGB), u = e.getParameter(e.BLEND_SRC_ALPHA), l = e.getParameter(e.BLEND_DST_ALPHA), f = e.getParameter(e.BLEND_EQUATION_RGB), d = e.getParameter(e.BLEND_EQUATION_ALPHA), m = e.getParameter(e.MAX_VERTEX_ATTRIBS), p.length = 0;
      for (var h = 0; h < m; ++h)
        p[h] = 0;
    }
  };
}
nC.createState = Ine;
var iy = {};
Object.defineProperty(iy, "__esModule", { value: !0 });
iy.PixelData = void 0;
var sM;
(function(e) {
  function r(a, i, o) {
    return { array: a, width: i, height: o };
  }
  e.create = r;
  function t(a) {
    for (var i = a.array, o = a.width, c = a.height, s = o * 4, u = 0, l = c / 2; u < l; ++u)
      for (var f = 0, d = s; f < d; ++f) {
        var m = u * s + f, p = (c - u - 1) * s + f, v = i[m];
        i[m] = i[p], i[p] = v;
      }
    return a;
  }
  e.flipY = t;
  function n(a) {
    for (var i = a.array, o = i instanceof Uint8Array ? 255 : 1, c = 0, s = i.length; c < s; c += 4) {
      var u = i[c + 3] / o;
      u !== 0 ? (i[c] /= u, i[c + 1] /= u, i[c + 2] /= u) : (i[c] = 0, i[c + 1] = 0, i[c + 2] = 0);
    }
    return a;
  }
  e.divideByAlpha = n;
})(sM || (sM = {}));
iy.PixelData = sM;
var hh = {}, vd = {};
Object.defineProperty(vd, "__esModule", { value: !0 });
vd.createReferenceCache = vd.createReferenceItem = vd.createReference = void 0;
function Rz(e, r) {
  return r === void 0 && (r = 0), { value: e, usageCount: r };
}
vd.createReference = Rz;
function Oz(e) {
  return {
    free: function() {
      e.usageCount -= 1;
    },
    value: e.value
  };
}
vd.createReferenceItem = Oz;
function Bne(e, r, t) {
  var n = /* @__PURE__ */ new Map();
  return {
    get: function(a) {
      var i = e(a), o = n.get(i);
      return o || (o = Rz(r(a)), n.set(i, o)), o.usageCount += 1, Oz(o);
    },
    clear: function() {
      n.forEach(function(a, i) {
        a.usageCount <= 0 && (a.usageCount < 0 && console.warn("Reference usageCount below zero."), t(a.value), n.delete(i));
      });
    },
    get count() {
      return n.size;
    },
    dispose: function() {
      n.forEach(function(a) {
        return t(a.value);
      }), n.clear();
    }
  };
}
vd.createReferenceCache = Bne;
var Tl = {}, pI;
function Nne() {
  if (pI) return Tl;
  pI = 1, Object.defineProperty(Tl, "__esModule", { value: !0 }), Tl.createRenderbuffer = Tl.getAttachment = Tl.getFormat = void 0;
  var e = Ra, r = vs(), t = ay(), n = Zt, a = (0, e.idFactory)();
  function i(u, l) {
    switch (l) {
      case "depth16":
        return u.DEPTH_COMPONENT16;
      case "stencil8":
        return u.STENCIL_INDEX8;
      case "rgba4":
        return u.RGBA4;
      case "depth-stencil":
        return u.DEPTH_STENCIL;
      case "depth32f":
        if ((0, r.isWebGL2)(u))
          return u.DEPTH_COMPONENT32F;
        throw new Error("WebGL2 needed for `depth32f` renderbuffer format");
    }
  }
  Tl.getFormat = i;
  function o(u, l) {
    switch (l) {
      case "depth":
        return u.DEPTH_ATTACHMENT;
      case "stencil":
        return u.STENCIL_ATTACHMENT;
      case "depth-stencil":
        return u.DEPTH_STENCIL_ATTACHMENT;
      case "color0":
        return u.COLOR_ATTACHMENT0;
    }
  }
  Tl.getAttachment = o;
  function c(u) {
    var l = u.createRenderbuffer();
    if (l === null)
      throw new Error("Could not create WebGL renderbuffer");
    return l;
  }
  function s(u, l, f, d, m) {
    var p = c(u), v = function() {
      return u.bindRenderbuffer(u.RENDERBUFFER, p);
    }, h = i(u, l), y = o(u, f);
    function C() {
      v(), u.renderbufferStorage(u.RENDERBUFFER, h, d, m);
    }
    C();
    var S = !1;
    return {
      id: a(),
      bind: v,
      attachFramebuffer: function(b) {
        b.bind(), v(), u.framebufferRenderbuffer(u.FRAMEBUFFER, y, u.RENDERBUFFER, p), n.isDebugMode && (0, t.checkFramebufferStatus)(u);
      },
      setSize: function(b, g) {
        d = b, m = g, C();
      },
      reset: function() {
        p = c(u), C();
      },
      destroy: function() {
        S || (u.deleteRenderbuffer(p), S = !0);
      }
    };
  }
  return Tl.createRenderbuffer = s, Tl;
}
var An = {}, hI;
function ps() {
  if (hI) return An;
  hI = 1, Object.defineProperty(An, "__esModule", { value: !0 }), An.createNullTexture = An.loadImageTexture = An.createTextures = An.createTexture = An.getAttachment = An.getFilter = An.getType = An.getInternalFormat = An.getFormat = An.getTarget = void 0;
  var e = We(), r = Ra, t = vs(), n = (0, r.idFactory)();
  function a(g, _) {
    switch (_) {
      case "image-uint8":
        return g.TEXTURE_2D;
      case "image-float32":
        return g.TEXTURE_2D;
      case "image-float16":
        return g.TEXTURE_2D;
      case "image-depth":
        return g.TEXTURE_2D;
    }
    if ((0, t.isWebGL2)(g))
      switch (_) {
        case "image-int32":
          return g.TEXTURE_2D;
        case "volume-uint8":
          return g.TEXTURE_3D;
        case "volume-float32":
          return g.TEXTURE_3D;
        case "volume-float16":
          return g.TEXTURE_3D;
      }
    throw new Error("unknown texture kind '".concat(_, "'"));
  }
  An.getTarget = a;
  function i(g, _, A) {
    switch (_) {
      case "alpha":
        return (0, t.isWebGL2)(g) && A === "float" ? g.RED : (0, t.isWebGL2)(g) && A === "int" ? g.RED_INTEGER : g.ALPHA;
      case "rgb":
        return (0, t.isWebGL2)(g) && A === "int" ? g.RGB_INTEGER : g.RGB;
      case "rgba":
        return (0, t.isWebGL2)(g) && A === "int" ? g.RGBA_INTEGER : g.RGBA;
      case "depth":
        return g.DEPTH_COMPONENT;
    }
  }
  An.getFormat = i;
  function o(g, _, A) {
    if ((0, t.isWebGL2)(g))
      switch (_) {
        case "alpha":
          switch (A) {
            case "ubyte":
              return g.ALPHA;
            case "float":
              return g.R32F;
            case "fp16":
              return g.R16F;
            case "int":
              return g.R32I;
          }
        case "rgb":
          switch (A) {
            case "ubyte":
              return g.RGB;
            case "float":
              return g.RGB32F;
            case "fp16":
              return g.RGB16F;
            case "int":
              return g.RGB32I;
          }
        case "rgba":
          switch (A) {
            case "ubyte":
              return g.RGBA;
            case "float":
              return g.RGBA32F;
            case "fp16":
              return g.RGBA16F;
            case "int":
              return g.RGBA32I;
          }
        case "depth":
          switch (A) {
            case "ushort":
              return g.DEPTH_COMPONENT16;
            case "float":
              return g.DEPTH_COMPONENT32F;
          }
      }
    return i(g, _, A);
  }
  An.getInternalFormat = o;
  function c(g, _, A, M, P) {
    var T = s(g) * u(_);
    return T * A * M * (P || 1);
  }
  function s(g) {
    switch (g) {
      case "alpha":
        return 1;
      case "rgb":
        return 3;
      case "rgba":
        return 4;
      case "depth":
        return 4;
    }
  }
  function u(g) {
    switch (g) {
      case "ubyte":
        return 1;
      case "ushort":
        return 2;
      case "float":
        return 4;
      case "fp16":
        return 2;
      case "int":
        return 4;
    }
  }
  function l(g, _, A) {
    switch (A) {
      case "ubyte":
        return g.UNSIGNED_BYTE;
      case "ushort":
        return g.UNSIGNED_SHORT;
      case "float":
        return g.FLOAT;
      case "fp16":
        if (_.textureHalfFloat)
          return _.textureHalfFloat.HALF_FLOAT;
        throw new Error('extension "texture_half_float" unavailable');
      case "int":
        if ((0, t.isWebGL2)(g))
          return g.INT;
        throw new Error('texture type "int" requires webgl2');
    }
  }
  An.getType = l;
  function f(g, _) {
    switch (_) {
      case "nearest":
        return g.NEAREST;
      case "linear":
        return g.LINEAR;
    }
  }
  An.getFilter = f;
  function d(g, _, A) {
    switch (A) {
      case "depth":
        return g.DEPTH_ATTACHMENT;
      case "stencil":
        return g.STENCIL_ATTACHMENT;
      case "color0":
      case 0:
        return g.COLOR_ATTACHMENT0;
    }
    if (_.drawBuffers)
      switch (A) {
        case "color1":
        case 1:
          return _.drawBuffers.COLOR_ATTACHMENT1;
        case "color2":
        case 2:
          return _.drawBuffers.COLOR_ATTACHMENT2;
        case "color3":
        case 3:
          return _.drawBuffers.COLOR_ATTACHMENT3;
        case "color4":
        case 4:
          return _.drawBuffers.COLOR_ATTACHMENT4;
        case "color5":
        case 5:
          return _.drawBuffers.COLOR_ATTACHMENT5;
        case "color6":
        case 6:
          return _.drawBuffers.COLOR_ATTACHMENT6;
        case "color7":
        case 7:
          return _.drawBuffers.COLOR_ATTACHMENT7;
      }
    throw new Error("unknown texture attachment");
  }
  An.getAttachment = d;
  function m(g) {
    return typeof HTMLImageElement < "u" && g instanceof HTMLImageElement;
  }
  function p(g, _, A) {
    return _ === A.TEXTURE_2D;
  }
  function v(g, _, A) {
    return _ === A.TEXTURE_3D;
  }
  function h(g) {
    var _ = g.createTexture();
    if (_ === null)
      throw new Error("Could not create WebGL texture");
    return _;
  }
  function y(g, _, A, M, P, T) {
    var x = n(), w = h(g);
    if (A.endsWith("float32") && P !== "float" || A.endsWith("float16") && P !== "fp16" || A.endsWith("uint8") && P !== "ubyte" || A.endsWith("int32") && P !== "int" || A.endsWith("depth") && P !== "ushort" && P !== "float")
      throw new Error("texture kind '".concat(A, "' and type '").concat(P, "' are incompatible"));
    var E = a(g, A), I = f(g, T), B = i(g, M, P), D = o(g, M, P), N = l(g, _, P);
    function O() {
      g.bindTexture(E, w), g.texParameteri(E, g.TEXTURE_MAG_FILTER, I), g.texParameteri(E, g.TEXTURE_MIN_FILTER, I), g.texParameteri(E, g.TEXTURE_WRAP_S, g.CLAMP_TO_EDGE), g.texParameteri(E, g.TEXTURE_WRAP_T, g.CLAMP_TO_EDGE), g.bindTexture(E, null);
    }
    O();
    var V = 0, k = 0, G = 0, L, R = !1;
    function F(q, K, Y) {
      if (q === 0 || K === 0 || (0, t.isWebGL2)(g) && E === g.TEXTURE_3D && Y === 0)
        throw new Error("empty textures are not allowed");
      if (!(V === q && k === K && G === (Y || 0)))
        if (V = q, k = K, G = Y || 0, g.bindTexture(E, w), E === g.TEXTURE_2D)
          g.texImage2D(E, 0, D, V, k, 0, B, N, null);
        else if ((0, t.isWebGL2)(g) && E === g.TEXTURE_3D && G !== void 0)
          g.texImage3D(E, 0, D, V, k, G, 0, B, N, null);
        else
          throw new Error("unknown texture target");
    }
    F(1, 1, (0, t.isWebGL2)(g) && E === g.TEXTURE_3D ? 1 : 0);
    function U(q, K) {
      if (K === void 0 && (K = !1), q.width === 0 || q.height === 0 || !m(q) && (0, t.isWebGL2)(g) && v(q, E, g) && q.depth === 0)
        throw new Error("empty textures are not allowed");
      if (g.bindTexture(E, w), g.pixelStorei(g.UNPACK_ALIGNMENT, 1), g.pixelStorei(g.UNPACK_COLORSPACE_CONVERSION_WEBGL, g.NONE), g.pixelStorei(g.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), m(q))
        V = q.width, k = q.height, g.pixelStorei(g.UNPACK_FLIP_Y_WEBGL, !1), g.bindTexture(g.TEXTURE_2D, w), g.texImage2D(g.TEXTURE_2D, 0, D, B, N, q);
      else if (p(q, E, g)) {
        var Y = q.filter ? f(g, q.filter) : I;
        g.texParameteri(E, g.TEXTURE_MAG_FILTER, Y), g.texParameteri(E, g.TEXTURE_MIN_FILTER, Y), g.pixelStorei(g.UNPACK_FLIP_Y_WEBGL, !!q.flipY), K ? g.texSubImage2D(E, 0, 0, 0, q.width, q.height, B, N, q.array) : (V = q.width, k = q.height, g.texImage2D(E, 0, D, V, k, 0, B, N, q.array));
      } else if ((0, t.isWebGL2)(g) && v(q, E, g))
        g.pixelStorei(g.UNPACK_FLIP_Y_WEBGL, !1), K ? g.texSubImage3D(E, 0, 0, 0, 0, q.width, q.height, q.depth, B, N, q.array) : (V = q.width, k = q.height, G = q.depth, g.texImage3D(E, 0, D, V, k, G, 0, B, N, q.array));
      else
        throw new Error("unknown texture target");
      g.bindTexture(E, null), L = q;
    }
    function H(q, K, Y) {
      if (q.bind(), E === g.TEXTURE_2D)
        g.framebufferTexture2D(g.FRAMEBUFFER, d(g, _, K), g.TEXTURE_2D, w, 0);
      else if ((0, t.isWebGL2)(g) && E === g.TEXTURE_3D) {
        if (Y === void 0)
          throw new Error("need `layer` to attach 3D texture");
        g.framebufferTextureLayer(g.FRAMEBUFFER, d(g, _, K), w, 0, Y);
      } else
        throw new Error("unknown/unsupported texture target");
    }
    return {
      id: x,
      target: E,
      format: B,
      internalFormat: D,
      type: N,
      filter: I,
      getWidth: function() {
        return V;
      },
      getHeight: function() {
        return k;
      },
      getDepth: function() {
        return G;
      },
      getByteCount: function() {
        return c(M, P, V, k, G);
      },
      define: F,
      load: U,
      bind: function(q) {
        g.activeTexture(g.TEXTURE0 + q), g.bindTexture(E, w);
      },
      unbind: function(q) {
        g.activeTexture(g.TEXTURE0 + q), g.bindTexture(E, null);
      },
      attachFramebuffer: H,
      detachFramebuffer: function(q, K) {
        if (q.bind(), E === g.TEXTURE_2D)
          g.framebufferTexture2D(g.FRAMEBUFFER, d(g, _, K), g.TEXTURE_2D, null, 0);
        else if ((0, t.isWebGL2)(g) && E === g.TEXTURE_3D)
          g.framebufferTextureLayer(g.FRAMEBUFFER, d(g, _, K), null, 0, 0);
        else
          throw new Error("unknown texture target");
      },
      reset: function() {
        w = h(g), O();
        var q = [V, k, G], K = q[0], Y = q[1], X = q[2];
        V = 0, k = 0, G = 0, F(K, Y, X), L && U(L);
      },
      destroy: function() {
        R || (g.deleteTexture(w), R = !0);
      }
    };
  }
  An.createTexture = y;
  function C(g, _, A) {
    var M = g.resources, P = [];
    return Object.keys(_).forEach(function(T) {
      var x = _[T];
      if (x.type === "texture") {
        var w = A[T];
        if (w)
          if (x.kind === "texture")
            P[P.length] = [T, w.ref.value];
          else {
            var E = M.texture(x.kind, x.format, x.dataType, x.filter);
            E.load(w.ref.value), P[P.length] = [T, E];
          }
      }
    }), P;
  }
  An.createTextures = C;
  function S(g, _, A) {
    var M = new Image();
    M.onload = function() {
      A.load(M), e.ValueCell.update(_, A);
    }, M.src = g;
  }
  An.loadImageTexture = S;
  function b(g) {
    var _, A = (_ = g == null ? void 0 : g.TEXTURE_2D) !== null && _ !== void 0 ? _ : 3553;
    return {
      id: n(),
      target: A,
      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(M) {
        g && (g.activeTexture(g.TEXTURE0 + M), g.bindTexture(A, null));
      },
      unbind: function(M) {
        g && (g.activeTexture(g.TEXTURE0 + M), g.bindTexture(A, null));
      },
      attachFramebuffer: function() {
      },
      detachFramebuffer: function() {
      },
      reset: function() {
      },
      destroy: function() {
      }
    };
  }
  return An.createNullTexture = b, An;
}
var aC = {};
Object.defineProperty(aC, "__esModule", { value: !0 });
aC.createVertexArray = void 0;
var Vne = Ra, Rne = (0, Vne.idFactory)();
function gI(e) {
  var r = e.vertexArrayObject;
  if (!r)
    throw new Error("VertexArrayObject not supported");
  var t = r.createVertexArray();
  if (!t)
    throw new Error("Could not create WebGL vertex array");
  return t;
}
function yI(e) {
  var r = e.vertexArrayObject;
  if (r === null)
    throw new Error("VertexArrayObject not supported");
  return r;
}
function One(e, r, t, n, a) {
  var i = Rne(), o = gI(r), c = yI(r);
  function s() {
    c.bindVertexArray(o), a && a.bind(), t.bindAttributes(n), c.bindVertexArray(null);
  }
  s();
  var u = !1;
  return {
    id: i,
    bind: function() {
      c.bindVertexArray(o);
    },
    update: s,
    reset: function() {
      o = gI(r), c = yI(r), s();
    },
    destroy: function() {
      u || (a && (c.bindVertexArray(o), e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, null)), c.deleteVertexArray(o), u = !0);
    }
  };
}
aC.createVertexArray = One;
var _I;
function Fne() {
  if (_I) return hh;
  _I = 1, Object.defineProperty(hh, "__esModule", { value: !0 }), hh.createResources = void 0;
  var e = Te, r = Vz(), t = s0, n = ay(), a = Na, i = vd, o = wr(), c = Nne(), s = ps(), u = aC;
  function l(m) {
    return typeof m == "boolean" ? m ? 1 : 0 : typeof m == "number" ? m * 1e4 : (0, o.hashString)(m);
  }
  function f(m) {
    var p = (0, e.__assign)((0, e.__assign)({}, m.value), { destroy: function() {
      m.free();
    } });
    return p;
  }
  function d(m, p, v, h) {
    var y = {
      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 C(_, A) {
      return y[_].add(A), v.resourceCounts[_] += 1, (0, e.__assign)((0, e.__assign)({}, A), { destroy: function() {
        A.destroy(), y[_].delete(A), v.resourceCounts[_] -= 1;
      } });
    }
    var S = (0, i.createReferenceCache)(function(_) {
      return JSON.stringify(_);
    }, function(_) {
      return C("shader", (0, t.createShader)(m, _));
    }, function(_) {
      _.destroy();
    });
    function b(_, A) {
      return f(S.get({ type: _, source: A }));
    }
    var g = (0, i.createReferenceCache)(function(_) {
      var A, M = [_.shaderCode.id], P = ((A = _.defineValues.dRenderVariant) === null || A === void 0 ? void 0 : A.ref.value) || "";
      return Object.keys(_.defineValues).forEach(function(T) {
        var x, w;
        !((w = (x = _.shaderCode).ignoreDefine) === null || w === void 0) && w.call(x, T, P, _.defineValues) || M.push((0, o.hashString)(T), l(_.defineValues[T].ref.value));
      }), (0, o.hashFnv32a)(M).toString();
    }, function(_) {
      return C("program", (0, r.createProgram)(m, p, h, b, _));
    }, function(_) {
      _.destroy();
    });
    return {
      attribute: function(_, A, M, P) {
        return C("attribute", (0, a.createAttributeBuffer)(m, p, h, _, A, M, P));
      },
      elements: function(_, A) {
        return C("elements", (0, a.createElementsBuffer)(m, _, A));
      },
      framebuffer: function() {
        return C("framebuffer", (0, n.createFramebuffer)(m));
      },
      program: function(_, A, M) {
        return f(g.get({ defineValues: _, shaderCode: A, schema: M }));
      },
      renderbuffer: function(_, A, M, P) {
        return C("renderbuffer", (0, c.createRenderbuffer)(m, _, A, M, P));
      },
      shader: b,
      texture: function(_, A, M, P) {
        return C("texture", (0, s.createTexture)(m, h, _, A, M, P));
      },
      vertexArray: function(_, A, M) {
        return C("vertexArray", (0, u.createVertexArray)(m, h, _, A, M));
      },
      getByteCounts: function() {
        var _ = 0;
        y.texture.forEach(function(P) {
          _ += P.getByteCount();
        });
        var A = 0;
        y.attribute.forEach(function(P) {
          A += P.length * 4;
        });
        var M = 0;
        return y.elements.forEach(function(P) {
          M += P.length * 4;
        }), { texture: _, attribute: A, elements: M };
      },
      reset: function() {
        y.attribute.forEach(function(_) {
          return _.reset();
        }), y.elements.forEach(function(_) {
          return _.reset();
        }), y.framebuffer.forEach(function(_) {
          return _.reset();
        }), y.renderbuffer.forEach(function(_) {
          return _.reset();
        }), y.shader.forEach(function(_) {
          return _.reset();
        }), y.program.forEach(function(_) {
          return _.reset();
        }), y.vertexArray.forEach(function(_) {
          return _.reset();
        }), y.texture.forEach(function(_) {
          return _.reset();
        });
      },
      destroy: function() {
        y.attribute.forEach(function(_) {
          return _.destroy();
        }), y.elements.forEach(function(_) {
          return _.destroy();
        }), y.framebuffer.forEach(function(_) {
          return _.destroy();
        }), y.renderbuffer.forEach(function(_) {
          return _.destroy();
        }), y.shader.forEach(function(_) {
          return _.destroy();
        }), y.program.forEach(function(_) {
          return _.destroy();
        }), y.vertexArray.forEach(function(_) {
          return _.destroy();
        }), y.texture.forEach(function(_) {
          return _.destroy();
        }), S.clear(), g.clear();
      }
    };
  }
  return hh.createResources = d, hh;
}
var df = {}, bI;
function Fz() {
  if (bI) return df;
  bI = 1, Object.defineProperty(df, "__esModule", { value: !0 }), df.createNullRenderTarget = df.createRenderTarget = void 0;
  var e = Ra, r = ps(), t = ay(), n = vs(), a = (0, e.idFactory)();
  function i(c, s, u, l, f, d, m) {
    f === void 0 && (f = !0), d === void 0 && (d = "uint8"), m === void 0 && (m = "nearest");
    var p = s.framebuffer(), v = d === "fp16" ? s.texture("image-float16", "rgba", "fp16", m) : d === "float32" ? s.texture("image-float32", "rgba", "float", m) : s.texture("image-uint8", "rgba", "ubyte", m), h = f ? (0, n.isWebGL2)(c) ? s.renderbuffer("depth32f", "depth", u, l) : s.renderbuffer("depth16", "depth", u, l) : null;
    function y() {
      v.define(u, l), v.attachFramebuffer(p, "color0"), h && h.attachFramebuffer(p);
    }
    y();
    var C = !1;
    return {
      id: a(),
      texture: v,
      framebuffer: p,
      getWidth: function() {
        return u;
      },
      getHeight: function() {
        return l;
      },
      bind: function() {
        p.bind();
      },
      setSize: function(S, b) {
        u === S && l === b || (u = S, l = b, v.define(u, l), h && h.setSize(u, l));
      },
      reset: function() {
        y();
      },
      destroy: function() {
        C || (v.destroy(), p.destroy(), h && h.destroy(), C = !0);
      }
    };
  }
  df.createRenderTarget = i;
  function o(c) {
    return {
      id: a(),
      texture: (0, r.createNullTexture)(c),
      framebuffer: (0, t.createNullFramebuffer)(),
      getWidth: function() {
        return 0;
      },
      getHeight: function() {
        return 0;
      },
      bind: function() {
        c.bindFramebuffer(c.FRAMEBUFFER, null);
      },
      setSize: function() {
      },
      reset: function() {
      },
      destroy: function() {
      }
    };
  }
  return df.createNullRenderTarget = o, df;
}
var SI;
function dE() {
  if (SI) return Io;
  SI = 1, Object.defineProperty(Io, "__esModule", { value: !0 }), Io.createContext = Io.readPixels = Io.checkError = Io.getErrorDescription = Io.getGLContext = void 0;
  var e = Te, r = vs(), t = ay(), n = Kr, a = Zt, i = Dne(), o = nC, c = iy, s = Fne(), u = Fz(), l = cl, f = Eu;
  function d(x, w) {
    function E(B) {
      try {
        return x.getContext(B, w);
      } catch {
        return null;
      }
    }
    var I = (w != null && w.preferWebGl1 ? null : E("webgl2")) || E("webgl") || E("experimental-webgl");
    return a.isDebugMode && console.log("isWebgl2: ".concat((0, r.isWebGL2)(I))), I;
  }
  Io.getGLContext = d;
  function m(x, w) {
    switch (w) {
      case x.NO_ERROR:
        return "no error";
      case x.INVALID_ENUM:
        return "invalid enum";
      case x.INVALID_VALUE:
        return "invalid value";
      case x.INVALID_OPERATION:
        return "invalid operation";
      case x.INVALID_FRAMEBUFFER_OPERATION:
        return "invalid framebuffer operation";
      case x.OUT_OF_MEMORY:
        return "out of memory";
      case x.CONTEXT_LOST_WEBGL:
        return "context lost";
    }
    return "unknown error";
  }
  Io.getErrorDescription = m;
  function p(x) {
    var w = x.getError();
    if (w !== x.NO_ERROR)
      throw new Error("WebGL error: '".concat(m(x, w), "'"));
  }
  Io.checkError = p;
  function v(x) {
    for (var w = x.getParameter(x.MAX_TEXTURE_IMAGE_UNITS), E = 0; E < w; ++E)
      x.activeTexture(x.TEXTURE0 + E), x.bindTexture(x.TEXTURE_2D, null), x.bindTexture(x.TEXTURE_CUBE_MAP, null), (0, r.isWebGL2)(x) && (x.bindTexture(x.TEXTURE_2D_ARRAY, null), x.bindTexture(x.TEXTURE_3D, null));
    var I = x.createBuffer();
    x.bindBuffer(x.ARRAY_BUFFER, I);
    for (var B = x.getParameter(x.MAX_VERTEX_ATTRIBS), E = 0; E < B; ++E)
      x.vertexAttribPointer(E, 1, x.FLOAT, !1, 0, 0);
    x.bindBuffer(x.ARRAY_BUFFER, null), x.bindBuffer(x.ELEMENT_ARRAY_BUFFER, null), x.bindRenderbuffer(x.RENDERBUFFER, null), h(x);
  }
  function h(x) {
    x.bindFramebuffer(x.FRAMEBUFFER, null);
  }
  var y = new Uint8Array(1 * 4);
  function C(x, w, E) {
    x.getSyncParameter(w, x.SYNC_STATUS) === x.SIGNALED ? (x.deleteSync(w), E()) : n.Scheduler.setImmediate(C, x, w, E);
  }
  function S(x, w) {
    var E = x.fenceSync(x.SYNC_GPU_COMMANDS_COMPLETE, 0);
    E ? n.Scheduler.setImmediate(C, x, E, w) : (console.warn("Could not create a WebGLSync object"), x.readPixels(0, 0, 1, 1, x.RGBA, x.UNSIGNED_BYTE, y), w());
  }
  var b = !1;
  function g(x) {
    return new Promise(function(w) {
      (0, r.isWebGL2)(x) ? S(x, w) : (b || (console.info("Sync object not supported in WebGL"), b = !0), _(x), w());
    });
  }
  function _(x) {
    x.bindFramebuffer(x.FRAMEBUFFER, null), x.readPixels(0, 0, 1, 1, x.RGBA, x.UNSIGNED_BYTE, y);
  }
  function A(x, w, E, I, B, D) {
    if (a.isDebugMode && (0, t.checkFramebufferStatus)(x), D instanceof Uint8Array)
      x.readPixels(w, E, I, B, x.RGBA, x.UNSIGNED_BYTE, D);
    else if (D instanceof Float32Array)
      x.readPixels(w, E, I, B, x.RGBA, x.FLOAT, D);
    else if (D instanceof Int32Array && (0, r.isWebGL2)(x))
      x.readPixels(w, E, I, B, x.RGBA_INTEGER, x.INT, D);
    else
      throw new Error("unsupported readPixels buffer type");
    a.isDebugMode && p(x);
  }
  Io.readPixels = A;
  function M(x) {
    var w = x.drawingBufferWidth, E = x.drawingBufferHeight, I = new Uint8Array(w * E * 4);
    return h(x), x.viewport(0, 0, w, E), A(x, 0, 0, w, E, I), c.PixelData.flipY(c.PixelData.create(I, w, E));
  }
  function P() {
    return {
      resourceCounts: {
        attribute: 0,
        elements: 0,
        framebuffer: 0,
        program: 0,
        renderbuffer: 0,
        shader: 0,
        texture: 0,
        vertexArray: 0
      },
      drawCount: 0,
      instanceCount: 0,
      instancedDrawCount: 0
    };
  }
  function T(x, w) {
    var E = this;
    w === void 0 && (w = {});
    var I = (0, i.createExtensions)(x), B = (0, o.createState)(x), D = P(), N = (0, s.createResources)(x, B, D, I), O = {
      maxTextureSize: x.getParameter(x.MAX_TEXTURE_SIZE),
      max3dTextureSize: (0, r.isWebGL2)(x) ? x.getParameter(x.MAX_3D_TEXTURE_SIZE) : 0,
      maxRenderbufferSize: x.getParameter(x.MAX_RENDERBUFFER_SIZE),
      maxDrawBuffers: I.drawBuffers ? x.getParameter(I.drawBuffers.MAX_DRAW_BUFFERS) : 0,
      maxTextureImageUnits: x.getParameter(x.MAX_TEXTURE_IMAGE_UNITS),
      maxVertexTextureImageUnits: x.getParameter(x.MAX_VERTEX_TEXTURE_IMAGE_UNITS)
    };
    if (O.maxVertexTextureImageUnits < 8)
      throw new Error('Need "MAX_VERTEX_TEXTURE_IMAGE_UNITS" >= 8');
    var V = !1, k = new l.BehaviorSubject(0), G;
    if ((0, r.isWebGL2)(x)) {
      var L = x.createBuffer(), R = void 0, F = void 0, U = !1, H = function() {
        x.bindBuffer(x.PIXEL_PACK_BUFFER, L), x.getBufferSubData(x.PIXEL_PACK_BUFFER, 0, R), x.bindBuffer(x.PIXEL_PACK_BUFFER, null), U = !1, F(), F = void 0, R = void 0;
      };
      G = function(K, Y, X, Z, J) {
        return new Promise(function($, Q) {
          if (U) {
            Q("Can not call multiple readPixelsAsync at the same time");
            return;
          }
          U = !0, x.bindBuffer(x.PIXEL_PACK_BUFFER, L), x.bufferData(x.PIXEL_PACK_BUFFER, X * Z * 4, x.STREAM_READ), x.readPixels(K, Y, X, Z, x.RGBA, x.UNSIGNED_BYTE, 0), x.bindBuffer(x.PIXEL_PACK_BUFFER, null), F = $, R = J, S(x, H);
        });
      };
    } else
      G = function(K, Y, X, Z, J) {
        return (0, e.__awaiter)(E, void 0, void 0, function() {
          return (0, e.__generator)(this, function($) {
            return A(x, K, Y, X, Z, J), [
              2
              /*return*/
            ];
          });
        });
      };
    var q = /* @__PURE__ */ new Set();
    return {
      gl: x,
      isWebGL2: (0, r.isWebGL2)(x),
      get pixelRatio() {
        var K = typeof window < "u" && window.devicePixelRatio || 1;
        return K * (w.pixelScale || 1);
      },
      extensions: I,
      state: B,
      stats: D,
      resources: N,
      get maxTextureSize() {
        return O.maxTextureSize;
      },
      get max3dTextureSize() {
        return O.max3dTextureSize;
      },
      get maxRenderbufferSize() {
        return O.maxRenderbufferSize;
      },
      get maxDrawBuffers() {
        return O.maxDrawBuffers;
      },
      get maxTextureImageUnits() {
        return O.maxTextureImageUnits;
      },
      namedComputeRenderables: /* @__PURE__ */ Object.create(null),
      namedFramebuffers: /* @__PURE__ */ Object.create(null),
      namedTextures: /* @__PURE__ */ Object.create(null),
      get isContextLost() {
        return V || x.isContextLost();
      },
      contextRestored: k,
      setContextLost: function() {
        V = !0;
      },
      handleContextRestored: function(K) {
        Object.assign(I, (0, i.createExtensions)(x)), B.reset(), B.currentMaterialId = -1, B.currentProgramId = -1, B.currentRenderItemId = -1, N.reset(), q.forEach(function(Y) {
          return Y.reset();
        }), K == null || K(), V = !1, k.next((0, f.now)());
      },
      createRenderTarget: function(K, Y, X, Z, J) {
        var $ = (0, u.createRenderTarget)(x, N, K, Y, X, Z, J);
        return q.add($), (0, e.__assign)((0, e.__assign)({}, $), { destroy: function() {
          $.destroy(), q.delete($);
        } });
      },
      unbindFramebuffer: function() {
        return h(x);
      },
      readPixels: function(K, Y, X, Z, J) {
        A(x, K, Y, X, Z, J);
      },
      readPixelsAsync: G,
      waitForGpuCommandsComplete: function() {
        return g(x);
      },
      waitForGpuCommandsCompleteSync: function() {
        return _(x);
      },
      getDrawingBufferPixelData: function() {
        return M(x);
      },
      clear: function(K, Y, X, Z) {
        h(x), B.enable(x.SCISSOR_TEST), B.depthMask(!0), B.colorMask(!0, !0, !0, !0), B.clearColor(K, Y, X, Z), x.viewport(0, 0, x.drawingBufferWidth, x.drawingBufferHeight), x.scissor(0, 0, x.drawingBufferWidth, x.drawingBufferHeight), x.clear(x.COLOR_BUFFER_BIT | x.DEPTH_BUFFER_BIT);
      },
      destroy: function(K) {
        var Y, X;
        N.destroy(), v(x), K != null && K.doNotForceWebGLContextLoss || ((Y = x.getExtension("WEBGL_lose_context")) === null || Y === void 0 || Y.loseContext(), (X = x.getExtension("STACKGL_destroy_context")) === null || X === void 0 || X.destroy());
      }
    };
  }
  return Io.createContext = T, Io;
}
var Wt = {}, ff = {}, Lz = {}, Ux = {}, iC = {}, Pv = {};
Object.defineProperty(Pv, "__esModule", { value: !0 });
Pv.Coordinates = Pv.Time = void 0;
var Zy = We(), Jy = mr();
function Lne(e, r) {
  return { value: e, unit: r };
}
Pv.Time = Lne;
var lM;
(function(e) {
  function r(s, u, l) {
    var f = !!s[0].cell, d = !!s[0].velocities, m = !!s[0].forces;
    return {
      id: Zy.UUID.create22(),
      frames: s,
      hasCell: f,
      hasVelocities: d,
      hasForces: m,
      deltaTime: u,
      timeOffset: l
    };
  }
  e.create = r;
  function t(s, u, l) {
    var f = s.x, d = s.y, m = s.z;
    return s.xyzOrdering.frozen ? l ? s.xyzOrdering.isIdentity ? (f = o(f, l), d = o(d, l), m = o(m, l)) : (0, Zy.arrayEqual)(s.xyzOrdering.index, l) || (f = i(f, s.xyzOrdering.index, l), d = i(d, s.xyzOrdering.index, l), m = i(m, s.xyzOrdering.index, l)) : s.xyzOrdering.isIdentity || (f = c(f, s.xyzOrdering.index), d = c(d, s.xyzOrdering.index), m = c(m, s.xyzOrdering.index)) : l && (s.xyzOrdering.isIdentity ? (s.xyzOrdering.isIdentity = !1, s.xyzOrdering.index = l, a(f, l), a(d, l), a(m, l)) : (0, Zy.arrayEqual)(s.xyzOrdering.index, l) || (f = i(f, s.xyzOrdering.index, l), d = i(d, s.xyzOrdering.index, l), m = i(m, s.xyzOrdering.index, l))), s.xyzOrdering.frozen = !0, {
      id: Zy.UUID.create22(),
      atomId: u,
      occupancy: Jy.Column.ofConst(1, s.elementCount, Jy.Column.Schema.int),
      B_iso_or_equiv: Jy.Column.ofConst(0, s.elementCount, Jy.Column.Schema.float),
      xyzDefined: !0,
      x: f,
      y: d,
      z: m
    };
  }
  e.getAtomicConformation = t;
  var n = [0.123];
  function a(s, u) {
    for (var l = n, f = 0, d = s.length; f < d; f++)
      l[f] = s[u[f]];
    for (var f = 0, d = s.length; f < d; f++)
      s[f] = l[f];
  }
  function i(s, u, l) {
    for (var f = new Float32Array(s.length), d = 0, m = s.length; d < m; d++)
      f[d] = s[u[l[d]]];
    return f;
  }
  function o(s, u) {
    for (var l = new Float32Array(s.length), f = 0, d = s.length; f < d; f++)
      l[f] = s[u[f]];
    return l;
  }
  function c(s, u) {
    for (var l = new Float32Array(s.length), f = 0, d = s.length; f < d; f++)
      l[u[f]] = s[f];
    return l;
  }
})(lM || (lM = {}));
Pv.Coordinates = lM;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 });
  var r = Te;
  (0, r.__exportStar)(Pv, e);
})(iC);
var kz = {}, oC = {};
Object.defineProperty(oC, "__esModule", { value: !0 });
oC.Topology = void 0;
var kne = We(), cM;
(function(e) {
  function r(t, n, a, i) {
    return {
      id: kne.UUID.create22(),
      label: t,
      basic: n,
      sourceData: i,
      bonds: a
    };
  }
  e.create = r;
})(cM || (cM = {}));
oC.Topology = cM;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 });
  var r = Te;
  (0, r.__exportStar)(oC, e);
})(kz);
var zx = {}, Gx = {}, In = {};
Object.defineProperty(In, "__esModule", { value: !0 });
In.CustomProperties = In.CustomPropertyDescriptor = void 0;
var Une = We();
function Cb(e) {
  return e;
}
In.CustomPropertyDescriptor = Cb;
(function(e) {
  function r(t) {
    return t.__key || (t.__key = Une.UUID.create22()), t.__key;
  }
  e.getUUID = r;
})(Cb || (Cb = {}));
In.CustomPropertyDescriptor = Cb;
var zne = (
  /** @class */
  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(r) {
      this._set.has(r) || (this._list.push(r), this._set.add(r));
    }, e.prototype.reference = function(r, t) {
      var n = this._refs.get(r) || 0;
      n += t ? 1 : -1, this._refs.set(r, Math.max(n, 0));
    }, e.prototype.hasReference = function(r) {
      return (this._refs.get(r) || 0) > 0;
    }, e.prototype.has = function(r) {
      return this._set.has(r);
    }, e.prototype.assets = function(r, t) {
      var n = this._assets.get(r);
      if (n)
        for (var a = 0, i = n; a < i.length; a++) {
          var o = i[a];
          o.dispose();
        }
      t ? this._assets.set(r, t) : this._assets.delete(r);
    }, e.prototype.dispose = function() {
      this._assets.forEach(function(r) {
        for (var t = 0, n = r; t < n.length; t++) {
          var a = n[t];
          a.dispose();
        }
      });
    }, e;
  }()
);
In.CustomProperties = zne;
var Mv = {};
Object.defineProperty(Mv, "__esModule", { value: !0 });
Mv.getAsymIdCount = Mv.calcModelCenter = void 0;
var Gne = Re, iu = hr;
function qne(e, r) {
  var t = [], n = [], a = [];
  e.x.length && (t.push.apply(t, (0, iu.arrayMinMax)(e.x)), n.push.apply(n, (0, iu.arrayMinMax)(e.y)), a.push.apply(a, (0, iu.arrayMinMax)(e.z))), r && (r.spheres.x.length && (t.push.apply(t, (0, iu.arrayMinMax)(r.spheres.x)), n.push.apply(n, (0, iu.arrayMinMax)(r.spheres.y)), a.push.apply(a, (0, iu.arrayMinMax)(r.spheres.z))), r.gaussians.x.length && (t.push.apply(t, (0, iu.arrayMinMax)(r.gaussians.x)), n.push.apply(n, (0, iu.arrayMinMax)(r.gaussians.y)), a.push.apply(a, (0, iu.arrayMinMax)(r.gaussians.z))));
  var i = (0, iu.arrayMinMax)(t), o = i[0], c = i[1], s = (0, iu.arrayMinMax)(n), u = s[0], l = s[1], f = (0, iu.arrayMinMax)(a), d = f[0], m = f[1], p = o + (c - o) / 2, v = u + (l - u) / 2, h = d + (m - d) / 2;
  return Gne.Vec3.create(p, v, h);
}
Mv.calcModelCenter = qne;
function Hne(e) {
  var r = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
  return e.properties.structAsymMap.forEach(function(n, a) {
    var i = n.auth_id;
    r.add(i), t.add(a);
  }), { auth: r.size, label: t.size };
}
Mv.getAsymIdCount = Hne;
var Cc = {}, dl = {}, Uz = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.IntAdjacencyGraph = void 0;
  var r = wr(), t = Qe();
  (function(a) {
    function i(v, h) {
      if (v === h)
        return !0;
      if (v.vertexCount !== h.vertexCount || v.edgeCount !== h.edgeCount)
        return !1;
      for (var y = v.a, C = v.b, S = v.offset, b = h.a, g = h.b, _ = h.offset, A = 0, M = v.a.length; A < M; A++)
        if (y[A] !== b[A])
          return !1;
      for (var A = 0, M = v.b.length; A < M; A++)
        if (C[A] !== g[A])
          return !1;
      for (var A = 0, M = v.offset.length; A < M; A++)
        if (S[A] !== _[A])
          return !1;
      for (var P = 0, T = Object.keys(v.edgeProps); P < T.length; P++) {
        var x = T[P], w = v.edgeProps[x], E = h.edgeProps[x];
        if (!E)
          return !1;
        for (var A = 0, M = w.length; A < M; A++)
          if (w[A] !== E[A])
            return !1;
      }
      return !0;
    }
    a.areEqual = i;
    var o = (
      /** @class */
      function() {
        function v(h, y, C, S, b, g) {
          this.offset = h, this.a = y, this.b = C, this.edgeCount = S, this.props = g, this.vertexCount = h.length - 1, this.edgeProps = b || {};
        }
        return v.prototype.getEdgeIndex = function(h, y) {
          var C, S;
          h < y ? (C = h, S = y) : (C = y, S = h);
          for (var b = this.offset[C], g = this.offset[C + 1]; b < g; b++)
            if (this.b[b] === S)
              return b;
          return -1;
        }, v.prototype.getDirectedEdgeIndex = function(h, y) {
          for (var C = this.offset[h], S = this.offset[h + 1]; C < S; C++)
            if (this.b[C] === y)
              return C;
          return -1;
        }, v.prototype.getVertexEdgeCount = function(h) {
          return this.offset[h + 1] - this.offset[h];
        }, v;
      }()
    );
    function c(v, h, y, C, S, b) {
      return new o(v, h, y, C, S, b);
    }
    a.create = c;
    var s = (
      /** @class */
      function() {
        function v(h, y, C) {
          this.vertexCount = h, this.xs = y, this.ys = C, this.current = 0, this.curA = 0, this.curB = 0, this.edgeCount = y.length, this.offsets = new Int32Array(this.vertexCount + 1), this.bucketFill = new Int32Array(this.vertexCount);
          for (var S = new Int32Array(this.vertexCount), b = 0, g = this.xs.length; b < g; b++)
            S[this.xs[b]]++;
          for (var b = 0, g = this.ys.length; b < g; b++)
            S[this.ys[b]]++;
          for (var _ = 0, b = 0; b < this.vertexCount; b++)
            this.offsets[b] = _, _ += S[b];
          this.offsets[this.vertexCount] = _, this.slotCount = _, this.a = new Int32Array(_), this.b = new Int32Array(_);
        }
        return v.prototype.createGraph = function(h, y) {
          return c(this.offsets, this.a, this.b, this.edgeCount, h, y);
        }, v.prototype.addNextEdge = function() {
          var h = this.xs[this.current], y = this.ys[this.current], C = this.offsets[h] + this.bucketFill[h], S = this.offsets[y] + this.bucketFill[y];
          this.a[C] = h, this.b[C] = y, this.bucketFill[h]++, this.a[S] = y, this.b[S] = h, this.bucketFill[y]++, this.current++, this.curA = C, this.curB = S;
        }, v.prototype.addAllEdges = function() {
          for (var h = 0; h < this.edgeCount; h++)
            this.addNextEdge();
        }, v.prototype.assignProperty = function(h, y) {
          h[this.curA] = y, h[this.curB] = y;
        }, v;
      }()
    );
    a.EdgeBuilder = s;
    var u = (
      /** @class */
      function() {
        function v(h, y, C) {
          this.vertexCount = h, this.xs = y, this.ys = C, this.current = 0, this.curA = 0, this.edgeCount = y.length, this.offsets = new Int32Array(this.vertexCount + 1), this.bucketFill = new Int32Array(this.vertexCount);
          for (var S = new Int32Array(this.vertexCount), b = 0, g = this.xs.length; b < g; b++)
            S[this.xs[b]]++;
          for (var _ = 0, b = 0; b < this.vertexCount; b++)
            this.offsets[b] = _, _ += S[b];
          this.offsets[this.vertexCount] = _, this.slotCount = _, this.a = new Int32Array(_), this.b = new Int32Array(_);
        }
        return v.prototype.createGraph = function(h) {
          return c(this.offsets, this.a, this.b, this.edgeCount, h);
        }, v.prototype.addNextEdge = function() {
          var h = this.xs[this.current], y = this.ys[this.current], C = this.offsets[h] + this.bucketFill[h];
          this.a[C] = h, this.b[C] = y, this.bucketFill[h]++, this.current++, this.curA = C;
        }, v.prototype.addAllEdges = function() {
          for (var h = 0; h < this.edgeCount; h++)
            this.addNextEdge();
        }, v.prototype.assignProperty = function(h, y) {
          h[this.curA] = y;
        }, v;
      }()
    );
    a.DirectedEdgeBuilder = u;
    var l = (
      /** @class */
      function() {
        function v(h) {
          this.vertexCount = h, this.xs = [], this.ys = [], this.included = /* @__PURE__ */ new Set();
        }
        return v.prototype.addEdge = function(h, y) {
          var C = h, S = y;
          h > y && (C = y, S = h);
          var b = (0, r.cantorPairing)(C, S);
          return this.included.has(b) ? !1 : (this.included.add(b), this.xs[this.xs.length] = C, this.ys[this.ys.length] = S, !0);
        }, v.prototype.getGraph = function() {
          return f(this.vertexCount, this.xs, this.ys);
        }, v.prototype.getEdgeBuiler = function() {
          return new s(this.vertexCount, this.xs, this.ys);
        }, v;
      }()
    );
    a.UniqueEdgeBuilder = l;
    function f(v, h, y) {
      var C = new a.EdgeBuilder(v, h, y);
      return C.addAllEdges(), C.createGraph({});
    }
    a.fromVertexPairs = f;
    function d(v, h) {
      for (var y = v.b, C = v.offset, S = v.vertexCount, b = v.edgeProps, g = new Int32Array(S), _ = 0, A = h.length; _ < A; _++)
        g[h[_]] = _ + 1;
      for (var M = 0, _ = 0; _ < S; _++)
        if (g[_] !== 0)
          for (var P = C[_], T = C[_ + 1]; P < T; P++)
            y[P] > _ && g[y[P]] !== 0 && M++;
      for (var x = new Int32Array(h.length + 1), w = new Int32Array(2 * M), E = new Int32Array(2 * M), I = new Int32Array(2 * M), B = 0, D = 0, _ = 0; _ < S; _++)
        if (g[_] !== 0) {
          for (var N = g[_] - 1, P = C[_], T = C[_ + 1]; P < T; P++) {
            var O = g[y[P]];
            O !== 0 && (E[B] = N, I[B] = O - 1, w[B] = P, B++);
          }
          x[++D] = B;
        }
      for (var V = {}, k = 0, G = Object.keys(b); k < G.length; k++) {
        var L = G[k];
        V[L] = (0, r.arrayPickIndices)(b[L], w);
      }
      return c(x, E, I, M, V);
    }
    a.induceByVertices = d;
    function m(v) {
      var h = v.vertexCount;
      if (h === 0)
        return { componentCount: 0, componentIndex: new Int32Array(0) };
      if (v.edgeCount === 0) {
        for (var y = new Int32Array(h), C = 0, S = h; C < S; C++)
          y[C] = C;
        return { componentCount: h, componentIndex: y };
      }
      for (var b = new Int32Array(h), C = 0, S = h; C < S; C++)
        b[C] = -1;
      var g = 0;
      b[0] = g;
      var _ = v.offset, A = v.b, M = [0], P = (0, t.LinkedIndex)(h);
      for (P.remove(0); M.length > 0; ) {
        for (var T = M.pop(), x = b[T], w = _[T], E = _[T + 1]; w < E; w++) {
          var I = A[w];
          P.has(I) && (P.remove(I), M.push(I), b[I] = x);
        }
        M.length === 0 && P.head >= 0 && (M.push(P.head), b[P.head] = ++g, P.remove(P.head));
      }
      return { componentCount: h, componentIndex: b };
    }
    a.connectedComponents = m;
    function p(v, h, y, C) {
      if (t.SortedArray.areIntersecting(h, y))
        return !0;
      if (C < 1)
        return !1;
      for (var S = /* @__PURE__ */ new Set(), b = 0, g = h.length; b < g; ++b)
        S.add(h[b]);
      return n(v, h, y, C, S);
    }
    a.areVertexSetsConnected = p;
  })(e.IntAdjacencyGraph || (e.IntAdjacencyGraph = {}));
  function n(a, i, o, c, s) {
    for (var u = a.b, l = a.offset, f = [], d = 0, m = i.length; d < m; ++d)
      for (var p = i[d], v = l[p], h = l[p + 1]; v < h; ++v) {
        var y = u[v];
        if (!s.has(y)) {
          if (t.SortedArray.has(o, y))
            return !0;
          s.add(y), f[f.length] = y;
        }
      }
    return c > 1 ? n(a, f, o, c - 1, s) : !1;
  }
})(Uz);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 });
  var r = Te;
  (0, r.__exportStar)(Uz, e);
})(dl);
var hs = {};
Object.defineProperty(hs, "__esModule", { value: !0 });
hs.FormatPropertyProvider = void 0;
var jne = (
  /** @class */
  function() {
    function e() {
      this.map = /* @__PURE__ */ new Map(), this.applicable = /* @__PURE__ */ new Map();
    }
    return e.prototype.add = function(r, t, n) {
      this.map.set(r, t), n && this.applicable.set(r, n);
    }, e.prototype.remove = function(r) {
      this.map.delete(r), this.applicable.delete(r);
    }, e.prototype.get = function(r) {
      return this.map.get(r);
    }, e.prototype.isApplicable = function(r) {
      var t = this.applicable.get(r.sourceData.kind);
      return t ? t(r) : !0;
    }, e;
  }()
), dM;
(function(e) {
  function r(t, n) {
    var a = t.name, i = new jne();
    return {
      descriptor: t,
      formatRegistry: i,
      isApplicable: function(o) {
        return i.isApplicable(o);
      },
      get: function(o) {
        var c = n != null && n.asDynamic ? o._dynamicPropertyData : o._staticPropertyData;
        if (c[a])
          return c[a];
        if (!o.customProperties.has(t)) {
          var s = i.get(o.sourceData.kind);
          if (s)
            return c[a] = s(o), o.customProperties.add(t), c[a];
        }
      },
      set: function(o, c) {
        n != null && n.asDynamic ? o._dynamicPropertyData[a] = c : o._staticPropertyData[a] = c;
      },
      delete: function(o) {
        n != null && n.asDynamic ? delete o._dynamicPropertyData[a] : delete o._staticPropertyData[a];
      }
    };
  }
  e.create = r;
})(dM || (dM = {}));
hs.FormatPropertyProvider = dM;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.IndexPairBonds = void 0;
  var r = Te, t = dl, n = hs;
  function a(i, o, c, s) {
    for (var u = new t.IntAdjacencyGraph.EdgeBuilder(s, i, o), l = new Int32Array(u.slotCount), f = new Int8Array(u.slotCount), d = new Array(u.slotCount), m = new Array(u.slotCount), p = 0, v = u.edgeCount; p < v; p++)
      u.addNextEdge(), u.assignProperty(l, c.key ? c.key[p] : -1), u.assignProperty(f, c.order ? c.order[p] : 1), u.assignProperty(d, c.distance ? c.distance[p] : -1), u.assignProperty(
        m,
        c.flag ? c.flag[p] : 1
        /* Covalent */
      );
    return u.createGraph({ key: l, order: f, distance: d, flag: m });
  }
  (function(i) {
    i.Descriptor = {
      name: "index_pair_bonds"
    }, i.Provider = n.FormatPropertyProvider.create(i.Descriptor, { asDynamic: !0 }), i.DefaultProps = {
      /**
       * If negative, test using element-based threshold, otherwise distance in Angstrom.
       *
       * This option exists to handle bonds in periodic cells. For systems that are
       * made from beads (as opposed to atomic elements), set to a specific distance.
       *
       * Note that `Data` has a `distance` field which allows specifying a distance
       * for each bond individually which takes precedence over this option.
       */
      maxDistance: -1
    };
    function o(c, s) {
      s === void 0 && (s = {});
      var u = (0, r.__assign)((0, r.__assign)({}, i.DefaultProps), s), l = c.pairs, f = c.count, d = l.indexA.toArray(), m = l.indexB.toArray(), p = l.key && l.key.toArray(), v = l.order && l.order.toArray(), h = l.distance && l.distance.toArray(), y = l.flag && l.flag.toArray();
      return {
        bonds: a(d, m, { key: p, order: v, distance: h, flag: y }, f),
        maxDistance: u.maxDistance
      };
    }
    i.fromData = o;
  })(e.IndexPairBonds || (e.IndexPairBonds = {}));
})(Cc);
var gh = {}, yh = {}, uC = {}, oy = {}, Hi = {};
Object.defineProperty(Hi, "__esModule", { value: !0 });
Hi.areTokensEmpty = Hi.areValuesEqualProvider = Hi.TokenColumn = Hi.TokenColumnProvider = void 0;
var $ne = mr(), CI = Qa;
function Kne(e) {
  return function(r) {
    return zz(e, r);
  };
}
Hi.TokenColumnProvider = Kne;
function zz(e, r) {
  var t = e.data, n = e.indices, a = e.count, i = r.valueType, o = i === "str" ? function(c) {
    return t.substring(n[2 * c], n[2 * c + 1]);
  } : i === "int" ? function(c) {
    return (0, CI.parseInt)(t, n[2 * c], n[2 * c + 1]) || 0;
  } : function(c) {
    return (0, CI.parseFloat)(t, n[2 * c], n[2 * c + 1]) || 0;
  };
  return {
    schema: r,
    __array: void 0,
    isDefined: !0,
    rowCount: a,
    value: o,
    valueKind: function(c) {
      return 0;
    },
    toArray: function(c) {
      return $ne.ColumnHelpers.createAndFillArray(a, o, c);
    },
    areValuesEqual: Gz(e)
  };
}
Hi.TokenColumn = zz;
function Gz(e) {
  var r = e.data, t = e.indices;
  return function(n, a) {
    var i = t[2 * n], o = t[2 * a], c = t[2 * n + 1] - i;
    if (c !== t[2 * a + 1] - o)
      return !1;
    for (var s = 0; s < c; s++)
      if (r.charCodeAt(s + i) !== r.charCodeAt(s + o))
        return !1;
    return !0;
  };
}
Hi.areValuesEqualProvider = Gz;
function Wne(e) {
  for (var r = e.count, t = e.indices, n = 0; n < r; ++n)
    if (t[2 * n] !== t[2 * n + 1])
      return !1;
  return !0;
}
Hi.areTokensEmpty = Wne;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.getCifFieldType = e.getTensor = e.tensorFieldNameGetter = e.CifField = e.CifCategory = e.CifSaveFrame = e.CifBlock = e.CifFile = void 0;
  var r = Te, t = mr(), n = Qa, a = Hi;
  function i(m, p) {
    return { name: p, blocks: m };
  }
  e.CifFile = i;
  function o(m, p, v, h) {
    return h === void 0 && (h = []), {
      categoryNames: m,
      header: v,
      categories: p,
      saveFrames: h,
      getField: function(y) {
        var C = y.split("."), S = C[0], b = C[1];
        return p[S].getField(b || "");
      }
    };
  }
  e.CifBlock = o;
  function c(m, p, v) {
    return { categoryNames: m, header: v, categories: p };
  }
  e.CifSaveFrame = c;
  function s(m, p, v, h) {
    return { rowCount: p, name: m, fieldNames: (0, r.__spreadArray)([], v, !0), getField: function(y) {
      return h[y];
    } };
  }
  e.CifCategory = s, function(m) {
    function p(y) {
      return { rowCount: 0, name: y, fieldNames: [], getField: function(C) {
      } };
    }
    m.empty = p;
    function v(y, C) {
      var S = Object.keys(C);
      return {
        rowCount: S.length > 0 ? C[S[0]].rowCount : 0,
        name: y,
        fieldNames: S,
        getField: function(b) {
          return C[b];
        }
      };
    }
    m.ofFields = v;
    function h(y, C) {
      for (var S = {}, b = 0, g = C._columns; b < g.length; b++) {
        var _ = g[b];
        S[_] = u.ofColumn(C[_]);
      }
      return v(y, S);
    }
    m.ofTable = h;
  }(s = e.CifCategory || (e.CifCategory = {}));
  var u;
  (function(m) {
    function p(b) {
      return v([b]);
    }
    m.ofString = p;
    function v(b) {
      var g = b.length, _ = function(T) {
        var x = b[T];
        return !x || x === "." || x === "?" ? "" : x;
      }, A = function(T) {
        var x = b[T];
        return (0, n.parseInt)(x, 0, x.length) || 0;
      }, M = function(T) {
        var x = b[T];
        return (0, n.parseFloat)(x, 0, x.length) || 0;
      }, P = function(T) {
        var x = b[T], w = x.length;
        if (w > 1)
          return 0;
        if (w === 0)
          return 1;
        var E = x.charCodeAt(0);
        return E === 46 ? 1 : E === 63 ? 2 : 0;
      };
      return {
        __array: void 0,
        binaryEncoding: void 0,
        isDefined: !0,
        rowCount: g,
        str: _,
        int: A,
        float: M,
        valueKind: P,
        areValuesEqual: function(T, x) {
          return b[T] === b[x];
        },
        toStringArray: function(T) {
          return T ? t.ColumnHelpers.createAndFillArray(g, _, T) : b;
        },
        toIntArray: function(T) {
          return t.ColumnHelpers.createAndFillArray(g, A, T);
        },
        toFloatArray: function(T) {
          return t.ColumnHelpers.createAndFillArray(g, M, T);
        }
      };
    }
    m.ofStrings = v;
    function h(b) {
      var g = b.length, _ = function(T) {
        return "" + b[T];
      }, A = function(T) {
        return b[T];
      }, M = function(T) {
        return 0;
      }, P = function(T) {
        return !T || T.array && b instanceof T.array ? b : t.ColumnHelpers.createAndFillArray(g, A, T);
      };
      return {
        __array: void 0,
        binaryEncoding: void 0,
        isDefined: !0,
        rowCount: g,
        str: _,
        int: A,
        float: A,
        valueKind: M,
        areValuesEqual: function(T, x) {
          return b[T] === b[x];
        },
        toStringArray: function(T) {
          return t.ColumnHelpers.createAndFillArray(g, _, T);
        },
        toIntArray: P,
        toFloatArray: P
      };
    }
    m.ofNumbers = h;
    function y(b) {
      var g = b.data, _ = b.indices, A = b.count, M = function(w) {
        var E = g.substring(_[2 * w], _[2 * w + 1]);
        return E === "." || E === "?" ? "" : E;
      }, P = function(w) {
        return (0, n.parseInt)(g, _[2 * w], _[2 * w + 1]) || 0;
      }, T = function(w) {
        return (0, n.parseFloat)(g, _[2 * w], _[2 * w + 1]) || 0;
      }, x = function(w) {
        var E = _[2 * w], I = _[2 * w + 1] - E;
        if (I > 1)
          return 0;
        if (I === 0)
          return 1;
        var B = g.charCodeAt(E);
        return B === 46 ? 1 : B === 63 ? 2 : 0;
      };
      return {
        __array: void 0,
        binaryEncoding: void 0,
        isDefined: !0,
        rowCount: A,
        str: M,
        int: P,
        float: T,
        valueKind: x,
        areValuesEqual: (0, a.areValuesEqualProvider)(b),
        toStringArray: function(w) {
          return t.ColumnHelpers.createAndFillArray(A, M, w);
        },
        toIntArray: function(w) {
          return t.ColumnHelpers.createAndFillArray(A, P, w);
        },
        toFloatArray: function(w) {
          return t.ColumnHelpers.createAndFillArray(A, T, w);
        }
      };
    }
    m.ofTokens = y;
    function C(b) {
      var g = b.rowCount, _ = b.valueKind, A = b.areValuesEqual, M = b.isDefined, P, T, x;
      switch (b.schema.valueType) {
        case "float":
        case "int":
          P = function(E) {
            return "" + b.value(E);
          }, T = b.value, x = b.value;
          break;
        case "str":
          P = b.value, T = function(E) {
            var I = b.value(E);
            return (0, n.parseInt)(I, 0, I.length) || 0;
          }, x = function(E) {
            var I = b.value(E);
            return (0, n.parseFloat)(I, 0, I.length) || 0;
          };
          break;
        case "list":
          var w = b.schema.separator;
          P = function(E) {
            return b.value(E).join(w);
          }, T = function(E) {
            return NaN;
          }, x = function(E) {
            return NaN;
          };
          break;
        default:
          throw new Error("unsupported valueType '".concat(b.schema.valueType, "'"));
      }
      return {
        __array: void 0,
        binaryEncoding: void 0,
        isDefined: M,
        rowCount: g,
        str: P,
        int: T,
        float: x,
        valueKind: _,
        areValuesEqual: A,
        toStringArray: function(E) {
          return t.ColumnHelpers.createAndFillArray(g, P, E);
        },
        toIntArray: function(E) {
          return t.ColumnHelpers.createAndFillArray(g, T, E);
        },
        toFloatArray: function(E) {
          return t.ColumnHelpers.createAndFillArray(g, x, E);
        }
      };
    }
    m.ofColumn = C;
    function S(b, g) {
      return C(t.Column.Undefined(b, g));
    }
    m.ofUndefined = S;
  })(u = e.CifField || (e.CifField = {}));
  function l(m, p, v, h) {
    var y = v ? 0 : 1;
    switch (p) {
      case 1:
        return h === "brackets" ? function(C) {
          return "".concat(m, "[").concat(C + y, "]");
        } : function(C) {
          return "".concat(m, "_").concat(C + y);
        };
      case 2:
        return h === "brackets" ? function(C, S) {
          return "".concat(m, "[").concat(C + y, "][").concat(S + y, "]");
        } : function(C, S) {
          return "".concat(m, "_").concat(C + y).concat(S + y);
        };
      case 3:
        return h === "brackets" ? function(C, S, b) {
          return "".concat(m, "[").concat(C + y, "][").concat(S + y, "][").concat(b + y, "]");
        } : function(C, S, b) {
          return "".concat(m, "_").concat(C + y).concat(S + y).concat(b + y);
        };
      default:
        throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.");
    }
  }
  e.tensorFieldNameGetter = l;
  function f(m, p, v, h) {
    var y = p.create();
    if (p.rank === 1)
      for (var C = p.dimensions[0], S = 0; S < C; S++) {
        var b = m.getField(h(S));
        p.set(y, S, b ? b.float(v) : 0);
      }
    else if (p.rank === 2)
      for (var C = p.dimensions[0], g = p.dimensions[1], S = 0; S < C; S++)
        for (var _ = 0; _ < g; _++) {
          var b = m.getField(h(S, _));
          p.set(y, S, _, b ? b.float(v) : 0);
        }
    else if (p.rank === 3)
      for (var A = p.dimensions[0], M = p.dimensions[1], P = p.dimensions[2], S = 0; S < A; S++)
        for (var _ = 0; _ < M; _++)
          for (var T = 0; T < P; T++) {
            var b = m.getField(h(S, _, T));
            p.set(y, S, _, T, b ? b.float(v) : 0);
          }
    else
      throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.");
    return y;
  }
  e.getTensor = f;
  function d(m) {
    for (var p = 0, v = !1, h = 0, y = 0, C = m.rowCount; y < C; y++) {
      var S = m.valueKind(y);
      if (S !== 0) {
        h++;
        continue;
      }
      var b = (0, n.getNumberType)(m.str(y));
      if (b !== 0)
        if (b === 1)
          p++;
        else {
          v = !0;
          break;
        }
    }
    return v || h === m.rowCount ? t.Column.Schema.str : p > 0 ? t.Column.Schema.float : t.Column.Schema.int;
  }
  e.getCifFieldType = d;
})(oy);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.toTable = e.toDatabase = e.toDatabaseCollection = e.FieldPath = void 0;
  var r = Te, t = mr(), n = Re, a = We(), i = (0, r.__importStar)(oy), o;
  (function(S) {
    function b(A) {
      return A.replace(".", "_").replace(/\[/, "_").replace(/(\[|\])/g, "");
    }
    S.canonical = b;
    function g(A, M) {
      return b(A) === b(M);
    }
    S.equal = g;
    function _(A, M, P) {
      P === void 0 && (P = !1);
      var T = "".concat(A).concat(M ? ".".concat(M) : "");
      return P ? b(T) : T;
    }
    S.create = _;
  })(o = e.FieldPath || (e.FieldPath = {}));
  function c(S, b, g) {
    for (var _ = {}, A = 0, M = b.blocks; A < M.length; A++) {
      var P = M[A];
      _[P.header] = s(S, P, g);
    }
    return _;
  }
  e.toDatabaseCollection = c;
  function s(S, b, g) {
    return v(S, b, g);
  }
  e.toDatabase = s;
  function u(S, b) {
    return new p(b, S, !0);
  }
  e.toTable = u;
  function l(S) {
    switch (S.valueType) {
      case "str":
        return function(b, g, _) {
          return f(S, b, b.str, b.toStringArray);
        };
      case "int":
        return function(b, g, _) {
          return f(S, b, b.int, b.toIntArray);
        };
      case "float":
        return function(b, g, _) {
          return f(S, b, b.float, b.toFloatArray);
        };
      case "list":
        throw new Error("Use createListColumn instead.");
      case "tensor":
        throw new Error("Use createTensorColumn instead.");
    }
  }
  function f(S, b, g, _) {
    return {
      schema: S,
      __array: b.__array,
      isDefined: b.isDefined,
      rowCount: b.rowCount,
      value: g,
      valueKind: b.valueKind,
      areValuesEqual: b.areValuesEqual,
      toArray: _
    };
  }
  function d(S, b, g) {
    var _ = S.separator, A = S.itemParse, M = b.getField(g), P = M ? function(x) {
      return M.str(x).split(_).map(function(w) {
        return A(w.trim());
      }).filter(function(w) {
        return !!w;
      });
    } : function(x) {
      return [];
    }, T = function(x) {
      return t.ColumnHelpers.createAndFillArray(b.rowCount, P, x);
    };
    return {
      schema: S,
      __array: void 0,
      isDefined: !!M,
      rowCount: b.rowCount,
      value: P,
      valueKind: M ? M.valueKind : function() {
        return 1;
      },
      areValuesEqual: function(x, w) {
        return (0, a.arrayEqual)(P(x), P(w));
      },
      toArray: T
    };
  }
  function m(S, b, g) {
    var _ = S.space, A = b.fieldNames.includes("".concat(g, "[0]")) || b.fieldNames.includes("".concat(g, "[0][0]")) || b.fieldNames.includes("".concat(g, "[0][0][0]")), M = A ? 0 : 1, P = b.fieldNames.includes("".concat(g, "_1")) || b.fieldNames.includes("".concat(g, "_11")) || b.fieldNames.includes("".concat(g, "_111")) ? "underscore" : "brackets", T = i.tensorFieldNameGetter(g, _.rank, A, P), x = b.getField(T(M, M, M)) || t.Column.Undefined(b.rowCount, S), w = function(I) {
      return i.getTensor(b, _, I, T);
    }, E = function(I) {
      return t.ColumnHelpers.createAndFillArray(b.rowCount, w, I);
    };
    return {
      schema: S,
      __array: void 0,
      isDefined: x.isDefined,
      rowCount: b.rowCount,
      value: w,
      valueKind: x.valueKind,
      areValuesEqual: function(I, B) {
        return n.Tensor.areEqualExact(w(I), w(B));
      },
      toArray: E
    };
  }
  var p = (
    /** @class */
    /* @__PURE__ */ function() {
      function S(b, g, _) {
        this._isDefined = _;
        var A = Object.keys(g);
        this._rowCount = b.rowCount, this._columns = A, this._schema = g;
        for (var M = /* @__PURE__ */ Object.create(null), P = function(I) {
          Object.defineProperty(T, I, {
            get: function() {
              if (M[I])
                return M[I];
              var B = g[I];
              if (B.valueType === "list")
                M[I] = d(B, b, I);
              else if (B.valueType === "tensor")
                M[I] = m(B, b, I);
              else {
                var D = l(B), N = b.getField(I);
                M[I] = N ? D(N, b, I) : t.Column.Undefined(b.rowCount, B);
              }
              return M[I];
            },
            enumerable: !0,
            configurable: !1
          });
        }, T = this, x = 0, w = A; x < w.length; x++) {
          var E = w[x];
          P(E);
        }
      }
      return S;
    }()
  );
  function v(S, b, g) {
    for (var _ = /* @__PURE__ */ Object.create(null), A = 0, M = Object.keys(S); A < M.length; A++) {
      var P = M[A];
      _[P] = C(P, S[P], b, g);
    }
    return t.Database.ofTables(b.header, S, _);
  }
  function h(S) {
    for (var b = /* @__PURE__ */ Object.create(null), g = 0, _ = Object.keys(S.categories); g < _.length; g++)
      for (var A = _[g], M = 0, P = S.categories[A].fieldNames; M < P.length; M++) {
        var T = P[M], x = o.create(A, T, !0);
        b[x] = S.categories[A].getField(T);
      }
    return b;
  }
  function y(S, b, g, _) {
    var A = o.create(b, S), M = o.canonical(A);
    if (M in g)
      return g[M];
    if (_ && A in _)
      for (var P = 0, T = _[A]; P < T.length; P++) {
        var x = T[P], w = o.canonical(x);
        if (w in g)
          return g[w];
      }
  }
  function C(S, b, g, _) {
    var A = g.categories[S];
    if (_) {
      for (var M = h(g), P = /* @__PURE__ */ Object.create(null), T = [], x = 0, w = 0, E = Object.keys(b); w < E.length; w++) {
        var I = E[w], B = y(I, S, M, _);
        B && (P[I] = B, T.push(I), x = B.rowCount);
      }
      A = {
        rowCount: x,
        name: S,
        fieldNames: (0, r.__spreadArray)([], T, !0),
        getField: function(D) {
          return P[D];
        }
      };
    }
    return new p(A || i.CifCategory.empty(S), b, !!A);
  }
})(uC);
var qx = {}, mf = {}, AI;
function Xne() {
  if (AI) return mf;
  AI = 1, Object.defineProperty(mf, "__esModule", { value: !0 }), mf.fillGridDim = mf.getRegularGrid3dDelta = void 0;
  var e = Re, r = nr();
  function t(a) {
    var i = a.box, o = a.dimensions;
    return e.Vec3.div((0, e.Vec3)(), r.Box3D.size((0, e.Vec3)(), i), e.Vec3.subScalar((0, e.Vec3)(), o, 1));
  }
  mf.getRegularGrid3dDelta = t;
  function n(a, i, o) {
    for (var c = new Float32Array(a), s = 0; s < c.length; s++)
      c[s] = i + o * s;
    return c;
  }
  return mf.fillGridDim = n, mf;
}
var E0 = {};
Object.defineProperty(E0, "__esModule", { value: !0 });
E0.SymmetryOperator = void 0;
var Hx = Zr, Yne = We(), xI = x0, Qr = bc, vf = hp, Y_ = Yo, fM;
(function(e) {
  e.DefaultName = "1_555", e.Default = r(e.DefaultName, Qr.Mat4.identity()), e.RotationTranslationEpsilon = 5e-3;
  function r(v, h, y) {
    var C = y || {}, S = C.assembly, b = C.ncsId, g = C.hkl, _ = C.spgrOp, A = g ? Y_.Vec3.clone(g) : (0, Y_.Vec3)();
    _ = (0, Yne.defaults)(_, -1), b = b || -1;
    var M = Qr.Mat4.isIdentity(h), P = n(y, M);
    return M ? { name: v, assembly: S, matrix: h, inverse: Qr.Mat4.identity(), isIdentity: !0, hkl: A, spgrOp: _, ncsId: b, suffix: P } : (Qr.Mat4.isRotationAndTranslation(h, e.RotationTranslationEpsilon) || console.warn("Symmetry operator (".concat(v, ") should be a composition of rotation and translation.")), { name: v, assembly: S, matrix: h, inverse: Qr.Mat4.invert((0, Qr.Mat4)(), h), isIdentity: !1, hkl: A, spgrOp: _, ncsId: b, suffix: P });
  }
  e.create = r;
  function t(v) {
    return !!v && !!v.matrix && !!v.inverse && typeof v.name == "string";
  }
  function n(v, h) {
    if (!v)
      return "";
    if (v.assembly)
      return t(v) ? v.suffix : h ? "" : "_".concat(v.assembly.operId);
    if (typeof v.spgrOp < "u" && typeof v.hkl < "u" && v.spgrOp !== -1) {
      var y = v.hkl, C = y[0], S = y[1], b = y[2];
      return "-".concat(v.spgrOp + 1, "_").concat(5 + C).concat(5 + S).concat(5 + b);
    }
    return v.ncsId !== -1 ? "_".concat(v.ncsId) : "";
  }
  function a(v, h) {
    for (var y = Qr.Mat4.identity(), C = 0; C < 3; C++)
      for (var S = 0; S < 3; S++)
        Qr.Mat4.setValue(y, C, S, xI.Mat3.getValue(v, C, S));
    return Qr.Mat4.setTranslation(y, h), Qr.Mat4.isRotationAndTranslation(y, e.RotationTranslationEpsilon);
  }
  e.checkIfRotationAndTranslation = a;
  function i(v, h, y, C) {
    for (var S = Qr.Mat4.identity(), b = 0; b < 3; b++)
      for (var g = 0; g < 3; g++)
        Qr.Mat4.setValue(S, b, g, xI.Mat3.getValue(h, b, g));
    return Qr.Mat4.setTranslation(S, y), r(v, S, { ncsId: C });
  }
  e.ofRotationAndOffset = i;
  var o = vf.Quat.identity(), c = (0, vf.Quat)(), s = (0, vf.Quat)(), u = (0, Y_.Vec3)();
  function l(v, h, y) {
    var C = h.inverse;
    if (h.isIdentity)
      return Qr.Mat4.copy(v, C);
    var S = 1 - y;
    Qr.Mat4.getRotation(c, C), vf.Quat.slerp(c, o, c, S);
    var b = vf.Quat.getAxisAngle(u, c);
    return Qr.Mat4.fromRotation(v, b, u), Qr.Mat4.setValue(v, 0, 3, S * Qr.Mat4.getValue(C, 0, 3)), Qr.Mat4.setValue(v, 1, 3, S * Qr.Mat4.getValue(C, 1, 3)), Qr.Mat4.setValue(v, 2, 3, S * Qr.Mat4.getValue(C, 2, 3)), v;
  }
  e.lerpFromIdentity = l;
  function f(v, h, y, C) {
    if (Math.abs(C) <= 1e-5)
      return Qr.Mat4.copy(v, h);
    if (Math.abs(C - 1) <= 1e-5)
      return Qr.Mat4.copy(v, y);
    Qr.Mat4.getRotation(c, h), Qr.Mat4.getRotation(s, y), vf.Quat.slerp(s, c, s, C);
    var S = vf.Quat.getAxisAngle(u, s);
    return Qr.Mat4.fromRotation(v, S, u), Qr.Mat4.setValue(v, 0, 3, (0, Hx.lerp)(Qr.Mat4.getValue(h, 0, 3), Qr.Mat4.getValue(y, 0, 3), C)), Qr.Mat4.setValue(v, 1, 3, (0, Hx.lerp)(Qr.Mat4.getValue(h, 1, 3), Qr.Mat4.getValue(y, 1, 3), C)), Qr.Mat4.setValue(v, 2, 3, (0, Hx.lerp)(Qr.Mat4.getValue(h, 2, 3), Qr.Mat4.getValue(y, 2, 3), C)), v;
  }
  e.slerp = f;
  function d(v, h) {
    var y = Qr.Mat4.mul((0, Qr.Mat4)(), h.matrix, v.matrix);
    return r(h.name, y, h);
  }
  e.compose = d;
  function m(v, h, y) {
    var C = e.createCoordinateMapper(e.Default, h), S = v.isIdentity ? C : e.createCoordinateMapper(v, h), b = Zne(v, h), g = b.x, _ = b.y, A = b.z;
    return { operator: v, coordinates: h, invariantPosition: C, position: S, x: g, y: _, z: A, r: y || Qne };
  }
  e.createMapping = m;
  function p(v, h) {
    return v.isIdentity ? tae(h) : nae(v, h);
  }
  e.createCoordinateMapper = p;
})(fM || (fM = {}));
E0.SymmetryOperator = fM;
function Qne(e) {
  return 0;
}
function Zne(e, r) {
  return e.isIdentity ? { x: jx(r.x), y: jx(r.y), z: jx(r.z) } : { x: Jne(e, r), y: eae(e, r), z: rae(e, r) };
}
function jx(e) {
  return function(t) {
    return e[t];
  };
}
function sC(e) {
  return e[3] === 0 && e[7] === 0 && e[11] === 0 && e[15] === 1;
}
function Jne(e, r) {
  var t = e.matrix, n = r.x, a = r.y, i = r.z, o = t[0], c = t[4], s = t[8], u = t[12];
  return sC(t) ? function(f) {
    return o * n[f] + c * a[f] + s * i[f] + u;
  } : function(f) {
    var d = n[f], m = a[f], p = i[f], v = t[3] * d + t[7] * m + t[11] * p + t[15] || 1;
    return (o * d + c * m + s * p + u) / v;
  };
}
function eae(e, r) {
  var t = e.matrix, n = r.x, a = r.y, i = r.z, o = t[1], c = t[5], s = t[9], u = t[13];
  return sC(t) ? function(f) {
    return o * n[f] + c * a[f] + s * i[f] + u;
  } : function(f) {
    var d = n[f], m = a[f], p = i[f], v = t[3] * d + t[7] * m + t[11] * p + t[15] || 1;
    return (o * d + c * m + s * p + u) / v;
  };
}
function rae(e, r) {
  var t = e.matrix, n = r.x, a = r.y, i = r.z, o = t[2], c = t[6], s = t[10], u = t[14];
  return sC(t) ? function(f) {
    return o * n[f] + c * a[f] + s * i[f] + u;
  } : function(f) {
    var d = n[f], m = a[f], p = i[f], v = t[3] * d + t[7] * m + t[11] * p + t[15] || 1;
    return (o * d + c * m + s * p + u) / v;
  };
}
function tae(e) {
  var r = e.x, t = e.y, n = e.z;
  return function(i, o) {
    return o[0] = r[i], o[1] = t[i], o[2] = n[i], o;
  };
}
function nae(e, r) {
  var t = e.matrix, n = r.x, a = r.y, i = r.z;
  return sC(t) ? function(c, s) {
    var u = n[c], l = a[c], f = i[c];
    return s[0] = t[0] * u + t[4] * l + t[8] * f + t[12], s[1] = t[1] * u + t[5] * l + t[9] * f + t[13], s[2] = t[2] * u + t[6] * l + t[10] * f + t[14], s;
  } : function(c, s) {
    return s[0] = n[c], s[1] = a[c], s[2] = i[c], Y_.Vec3.transformMat4(s, s, t), s;
  };
}
var pf = {}, qz = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.getSpacegroupIndex = e.SpacegroupNumber = e.SpacegroupName = e.getSpacegroupNumberFromIndex = e.getSpacegroupIndexFromNumber = e.SpacegroupNameToIndexMap = e.GroupData = e.OperatorData = e.TransformData = void 0, e.TransformData = [
    [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]
  ], e.OperatorData = [
    [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]
  ], e.GroupData = [
    [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],
    // X,Y,Z
    // -X+1/2,Y+1/2,-Z+1/2
    // -X,-Y,-Z
    // X+1/2,-Y+1/2,Z+1/2
    [0, 5, 1, 8],
    // X,Y,Z
    // -X+1/2,Y+1/2,-Z
    // -X,-Y,-Z
    // X+1/2,-Y+1/2,Z
    [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]
  ], e.SpacegroupNameToIndexMap = {
    "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 r(a) {
    switch (a) {
      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 i = 0;
    return a > 146 && ++i, a > 148 && ++i, a > 155 && ++i, a > 160 && ++i, a > 161 && ++i, a > 166 && ++i, a > 167 && ++i, a - 1 + i;
  }
  e.getSpacegroupIndexFromNumber = r;
  function t(a) {
    if (a < 146)
      return a + 1;
    if (a === 146)
      return 1146;
    if (a < 149)
      return a + 1 - 1;
    if (a === 149)
      return 1148;
    if (a < 157)
      return a + 1 - 2;
    if (a === 157)
      return 1155;
    if (a < 163)
      return a + 1 - 3;
    if (a === 163)
      return 1160;
    if (a < 165)
      return a + 1 - 4;
    if (a === 165)
      return 1161;
    if (a < 171)
      return a + 1 - 5;
    if (a === 171)
      return 1166;
    if (a < 173)
      return a + 1 - 6;
    if (a === 173)
      return 1167;
    if (a < 237)
      return a + 1 - 7;
    if (a === 237)
      return 1003;
    if (a === 238)
      return 1004;
    if (a === 239)
      return 1005;
    if (a === 240)
      return 2005;
    if (a === 241)
      return 3005;
    if (a === 242)
      return 4005;
    if (a === 243)
      return 5005;
    if (a === 244)
      return 1006;
    if (a === 245)
      return 1007;
    if (a === 246)
      return 1008;
    if (a === 247)
      return 1009;
    if (a === 248)
      return 1010;
    if (a === 249)
      return 1011;
    if (a === 250)
      return 1012;
    if (a === 251)
      return 1013;
    if (a === 252)
      return 1014;
    if (a === 253)
      return 2014;
    if (a === 254)
      return 3014;
    if (a === 255)
      return 1015;
    if (a === 256)
      return 1017;
    if (a === 257)
      return 2017;
    if (a === 258)
      return 1018;
    if (a === 259)
      return 2018;
    if (a === 260)
      return 3018;
    if (a === 261)
      return 1020;
    if (a === 262)
      return 1021;
    if (a === 263)
      return 1022;
    if (a === 264)
      return 1023;
    if (a === 265)
      return 1059;
    if (a === 266)
      return 1094;
    if (a === 267)
      return 1197;
    throw new Error("unknown spacegroup index '".concat(a, "'"));
  }
  e.getSpacegroupNumberFromIndex = t, e.SpacegroupName = function() {
    for (var a = /* @__PURE__ */ Object.create(null), i = 0, o = Object.keys(e.SpacegroupNameToIndexMap); i < o.length; i++) {
      var c = o[i];
      a[e.SpacegroupNameToIndexMap[c]] = c;
    }
    return a;
  }(), e.SpacegroupNumber = function() {
    for (var a = /* @__PURE__ */ Object.create(null), i = 0, o = Object.keys(e.SpacegroupNameToIndexMap); i < o.length; i++) {
      var c = o[i], s = e.SpacegroupNameToIndexMap[c];
      a[s] = t(s);
    }
    return a;
  }();
  function n(a) {
    var i = typeof a == "number" ? r(a) : e.SpacegroupNameToIndexMap[a];
    return typeof i > "u" || typeof e.SpacegroupName[i] > "u" ? -1 : i;
  }
  e.getSpacegroupIndex = n;
})(qz);
var TI;
function aae() {
  if (TI) return pf;
  TI = 1, Object.defineProperty(pf, "__esModule", { value: !0 }), pf.SpacegroupCell = pf.Spacegroup = void 0;
  var e = Re, r = qz, t = nr(), n;
  (function(i) {
    i.Zero = c("P 1", e.Vec3.create(1, 1, 1), e.Vec3.create(Math.PI / 2, Math.PI / 2, Math.PI / 2));
    function o(u) {
      return u ? u.index === 0 && u.size[0] === 1 && u.size[1] === 1 && u.size[1] === 1 : !0;
    }
    i.isZero = o;
    function c(u, l, f) {
      var d = (0, r.getSpacegroupIndex)(u);
      if (d < 0)
        return console.warn("Unknown spacegroup '".concat(u, "', returning a 'P 1' with cellsize [1, 1, 1]")), i.Zero;
      var m = l[0] * l[1] * l[2], p = f[0], v = f[1], h = f[2], y = l[0], C = l[1], S = l[2], b = Math.cos(v), g = (Math.cos(p) - Math.cos(v) * Math.cos(h)) / Math.sin(h), _ = Math.sqrt(1 - b * b - g * g), A = [y, 0, 0], M = [Math.cos(h) * C, Math.sin(h) * C, 0], P = [b * S, g * S, _ * S], T = e.Mat4.ofRows([
        [A[0], M[0], P[0], 0],
        [0, M[1], P[1], 0],
        [0, 0, P[2], 0],
        [0, 0, 0, 1]
      ]), x = e.Mat4.invert(e.Mat4.zero(), T);
      return { index: d, size: l, volume: m, anglesInRadians: f, toFractional: x, fromFractional: T };
    }
    i.create = c;
    function s(u, l, f, d, m, p) {
      var v = (0, r.getSpacegroupIndex)(u);
      return v < 0 ? (console.warn("Unknown spacegroup '".concat(u, "', returning a 'P 1' with cellsize [1, 1, 1]")), i.Zero) : { index: v, size: l, volume: d, anglesInRadians: f, toFractional: m, fromFractional: p };
    }
    i.createMaterial = s;
  })(n || (n = {})), pf.SpacegroupCell = n;
  var a;
  return function(i) {
    i.ZeroP1 = o(n.Zero);
    function o(g) {
      var _ = r.GroupData[g.index].map(function(P) {
        return h(r.OperatorData[P]);
      }), A = r.SpacegroupName[g.index], M = r.SpacegroupNumber[g.index];
      return { name: A, num: M, cell: g, operators: _ };
    }
    i.create = o;
    var c = (0, e.Vec3)(), s = (0, e.Mat4)();
    function u(g, _, A, M, P, T) {
      return e.Vec3.set(c, A, M, P), e.Mat4.fromTranslation(s, c), e.Mat4.mul(T, e.Mat4.mul(T, e.Mat4.mul(T, g.cell.fromFractional, s), g.operators[_]), g.cell.toFractional);
    }
    i.setOperatorMatrix = u;
    function l(g, _, A, M, P) {
      var T = u(g, _, A, M, P, e.Mat4.zero());
      return t.SymmetryOperator.create("".concat(_ + 1, "_").concat(5 + A).concat(5 + M).concat(5 + P), T, { hkl: e.Vec3.create(A, M, P), spgrOp: _ });
    }
    i.getSymmetryOperator = l;
    var f = (0, e.Vec3)(), d = (0, e.Vec3)(), m = (0, e.Vec3)(), p = (0, e.Vec3)();
    function v(g, _, A, M, P, T) {
      var x = e.Mat4.zero();
      e.Vec3.set(c, A, M, P), e.Vec3.floor(f, T), e.Mat4.copy(x, g.operators[_]), e.Vec3.floor(d, e.Vec3.transformMat4(d, T, x)), e.Mat4.getTranslation(p, x), e.Vec3.sub(p, p, d), e.Vec3.add(p, p, f), e.Vec3.add(p, p, c), e.Mat4.setTranslation(x, p), e.Mat4.mul(x, g.cell.fromFractional, x), e.Mat4.mul(x, x, g.cell.toFractional), e.Vec3.sub(m, d, f);
      var w = A - m[0], E = M - m[1], I = P - m[2];
      return t.SymmetryOperator.create("".concat(_ + 1, "_").concat(5 + w).concat(5 + E).concat(5 + I), x, { hkl: e.Vec3.create(w, E, I), spgrOp: _ });
    }
    i.getSymmetryOperatorRef = v;
    function h(g) {
      var _ = r.TransformData[g[0]], A = r.TransformData[g[1]], M = r.TransformData[g[2]];
      return e.Mat4.ofRows([_, A, M, [0, 0, 0, 1]]);
    }
    function y(g) {
      return [
        b(C(g[0], g[4], g[8]), S(g[12])),
        b(C(g[1], g[5], g[9]), S(g[13])),
        b(C(g[2], g[6], g[10]), S(g[14]))
      ].join(",");
    }
    i.getOperatorXyz = y;
    function C(g, _, A) {
      var M = [];
      if (g > 0 ? M.push("+X") : g < 0 && M.push("-X"), _ > 0 ? M.push("+Y") : _ < 0 && M.push("-Y"), A > 0 ? M.push("+Z") : A < 0 && M.push("-Z"), M.length === 1)
        return M[0].charAt(0) === "+" ? M[0].substr(1) : M[0];
      if (M.length === 2) {
        var P = M[0].charAt(0), T = M[1].charAt(0);
        if (P === "+")
          return "".concat(M[0].substr(1)).concat(M[1]);
        if (T === "+")
          return "".concat(M[1].substr(1)).concat(M[0]);
      }
      throw new Error("unknown rotation '".concat(M, "', ").concat(g, " ").concat(_, " ").concat(A));
    }
    function S(g) {
      switch (g) {
        case 1 / 2:
          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 b(g, _) {
      return _ === "" ? g : g.length > 2 ? "".concat(g, "+").concat(_) : g.charAt(0) === "-" ? "".concat(_).concat(g) : "".concat(_, "+").concat(g);
    }
  }(a || (a = {})), pf.Spacegroup = a, pf;
}
var fE = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Result = void 0, function(r) {
    function t(o, c, s) {
      o.squaredDistances[o.count] = s, o.indices[o.count++] = c;
    }
    r.add = t;
    function n(o) {
      o.count = 0;
    }
    r.reset = n;
    function a() {
      return { count: 0, indices: [], squaredDistances: [] };
    }
    r.create = a;
    function i(o, c) {
      for (var s = 0; s < c.count; ++s)
        o.indices[s] = c.indices[s], o.squaredDistances[s] = c.squaredDistances[s];
      return o.count = c.count, o;
    }
    r.copy = i;
  }(e.Result || (e.Result = {}));
})(fE);
var _h = {}, um = {}, sm = {}, bp = {};
Object.defineProperty(bp, "__esModule", { value: !0 });
bp.Axes3D = void 0;
var Yt = Re;
function Ag() {
  return Ag.empty();
}
bp.Axes3D = Ag;
(function(e) {
  function r(d, m, p, v) {
    return { origin: d, dirA: m, dirB: p, dirC: v };
  }
  e.create = r;
  function t() {
    return { origin: (0, Yt.Vec3)(), dirA: (0, Yt.Vec3)(), dirB: (0, Yt.Vec3)(), dirC: (0, Yt.Vec3)() };
  }
  e.empty = t;
  function n(d, m) {
    return Yt.Vec3.copy(d.origin, m.origin), Yt.Vec3.copy(d.dirA, m.dirA), Yt.Vec3.copy(d.dirB, m.dirB), Yt.Vec3.copy(d.dirC, m.dirC), d;
  }
  e.copy = n;
  function a(d) {
    return n(t(), d);
  }
  e.clone = a;
  function i(d, m) {
    return Yt.Vec3.set(d, Yt.Vec3.magnitude(m.dirA) * 2, Yt.Vec3.magnitude(m.dirB) * 2, Yt.Vec3.magnitude(m.dirC) * 2);
  }
  e.size = i;
  var o = (0, Yt.Vec3)();
  function c(d) {
    return i(o, d), o[0] * o[1] * o[2];
  }
  e.volume = c;
  function s(d, m) {
    return Yt.Vec3.copy(d.origin, m.origin), Yt.Vec3.normalize(d.dirA, m.dirA), Yt.Vec3.normalize(d.dirB, m.dirB), Yt.Vec3.normalize(d.dirC, m.dirC), d;
  }
  e.normalize = s;
  var u = (0, Yt.Mat3)();
  function l(d, m, p) {
    Yt.Vec3.transformMat4(d.origin, m.origin, p);
    var v = Yt.Mat3.directionTransform(u, p);
    return Yt.Vec3.transformMat3(d.dirA, m.dirA, v), Yt.Vec3.transformMat3(d.dirB, m.dirB, v), Yt.Vec3.transformMat3(d.dirC, m.dirC, v), d;
  }
  e.transform = l;
  function f(d, m, p) {
    return Yt.Vec3.scale(d.dirA, m.dirA, p), Yt.Vec3.scale(d.dirB, m.dirB, p), Yt.Vec3.scale(d.dirC, m.dirC, p), d;
  }
  e.scale = f;
})(Ag || (Ag = {}));
bp.Axes3D = Ag;
var bh = {}, uy = {};
Object.defineProperty(uy, "__esModule", { value: !0 });
uy.Matrix = void 0;
var mM;
(function(e) {
  function r(d, m, p) {
    p === void 0 && (p = Float32Array);
    var v = d * m;
    return { data: new p(v), size: v, cols: d, rows: m };
  }
  e.create = r;
  function t(d, m, p) {
    return d.data[d.rows * p + m];
  }
  e.get = t;
  function n(d, m, p, v) {
    return d.data[d.rows * p + m] = v, d;
  }
  e.set = n;
  function a(d, m, p, v) {
    return d.data[d.rows * p + m] += v, d;
  }
  e.add = a;
  function i(d) {
    return d.data.fill(0), d;
  }
  e.makeZero = i;
  function o(d) {
    return { data: d.data.slice(), size: d.size, cols: d.cols, rows: d.rows };
  }
  e.clone = o;
  function c(d, m, p) {
    return { data: d, size: m * p, cols: m, rows: p };
  }
  e.fromArray = c;
  function s(d, m) {
    if (d.cols !== m.rows || d.rows !== m.cols)
      throw new Error("transpose: matrix dimensions incompatible");
    if (d.data === m.data)
      throw new Error("transpose: matrices share memory");
    for (var p = m.rows, v = m.cols, h = m.data, y = d.data, C = 0, S = 0, b = 0; C < p; b += 1, S += v, ++C)
      for (var g = b, _ = 0; _ < v; g += p, _++)
        y[g] = h[S + _];
    return d;
  }
  e.transpose = s;
  function u(d, m, p) {
    for (var v = m.cols, h = m.rows, y = p.rows, C = m.data, S = p.data, b = d.data, g = 0, _ = 0, A = 0; g < h; _ += v, g++)
      for (var M = 0, P = 0; P < y; A++, P++) {
        for (var T = 0, x = _, w = 0; w < v; x++, M++, w++)
          T += C[x] * S[M];
        b[A] = T;
      }
    return d;
  }
  e.multiplyABt = u;
  function l(d) {
    for (var m = d.rows, p = d.cols, v = d.data, h = new Array(p), y = 0; y < p; ++y)
      h[y] = 0;
    for (var C = 0, S = 0; C < m; ++C)
      for (var y = 0; y < p; ++y, ++S)
        h[y] += v[S];
    for (var y = 0; y < p; ++y)
      h[y] /= m;
    return h;
  }
  e.meanRows = l;
  function f(d, m) {
    for (var p = d.rows, v = d.cols, h = d.data, y = 0, C = 0; y < p; ++y)
      for (var S = 0; S < v; ++S, ++C)
        h[C] -= m[S];
    return d;
  }
  e.subRows = f;
})(mM || (mM = {}));
uy.Matrix = mM;
var $s = {};
Object.defineProperty($s, "__esModule", { value: !0 });
$s.svd = $s.JacobiSVDImpl = $s.hypot = $s.swap = void 0;
var Vc = uy;
function Q_(e, r, t, n) {
  n = e[r], e[r] = e[t], e[t] = n;
}
$s.swap = Q_;
function Hz(e, r) {
  return e = Math.abs(e), r = Math.abs(r), e > r ? (r /= e, e * Math.sqrt(1 + r * r)) : r > 0 ? (e /= r, r * Math.sqrt(1 + e * e)) : 0;
}
$s.hypot = Hz;
var iae = 1192092896e-16, oae = 1e-37;
function jz(e, r, t, n, a, i, o, c) {
  for (var s = iae * 2, u = oae, l = 0, f = 0, d = 0, m = 0, p = Math.max(i, 30), v = 0, h = 0, y = 0, C = 0, S = 0, b = 0, g = 0, _ = 0, A = 0, M = 0, P = 0, T = 0, x = 0, w = 0, E = 0, I = 0, B = 0, D = 4660, N = 0, O = 0, V = 0, k = new Float64Array(o << 3); l < o; l++) {
    for (d = 0, P = 0; d < i; d++)
      _ = e[l * r + d], P += _ * _;
    if (k[l] = P, n) {
      for (d = 0; d < o; d++)
        n[l * a + d] = 0;
      n[l * a + l] = 1;
    }
  }
  for (; m < p; m++) {
    for (S = 0, l = 0; l < o - 1; l++)
      for (f = l + 1; f < o; f++) {
        for (v = l * r | 0, h = f * r | 0, E = k[l], I = 0, B = k[f], d = 2, I += e[v] * e[h], I += e[v + 1] * e[h + 1]; d < i; d++)
          I += e[v + d] * e[h + d];
        if (!(Math.abs(I) <= s * Math.sqrt(E * B))) {
          for (I *= 2, T = E - B, x = Hz(I, T), T < 0 ? (w = (x - T) * 0.5, g = Math.sqrt(w / x), b = I / (x * g * 2)) : (b = Math.sqrt((x + T) / (x * 2)), g = I / (x * b * 2)), E = 0, B = 0, d = 2, A = b * e[v] + g * e[h], M = -g * e[v] + b * e[h], e[v] = A, e[h] = M, E += A * A, B += M * M, A = b * e[v + 1] + g * e[h + 1], M = -g * e[v + 1] + b * e[h + 1], e[v + 1] = A, e[h + 1] = M, E += A * A, B += M * M; d < i; d++)
            A = b * e[v + d] + g * e[h + d], M = -g * e[v + d] + b * e[h + d], e[v + d] = A, e[h + d] = M, E += A * A, B += M * M;
          if (k[l] = E, k[f] = B, S = 1, n)
            for (y = l * a | 0, C = f * a | 0, d = 2, A = b * n[y] + g * n[C], M = -g * n[y] + b * n[C], n[y] = A, n[C] = M, A = b * n[y + 1] + g * n[C + 1], M = -g * n[y + 1] + b * n[C + 1], n[y + 1] = A, n[C + 1] = M; d < o; d++)
              A = b * n[y + d] + g * n[C + d], M = -g * n[y + d] + b * n[C + d], n[y + d] = A, n[C + d] = M;
        }
      }
    if (S === 0)
      break;
  }
  for (l = 0; l < o; l++) {
    for (d = 0, P = 0; d < i; d++)
      _ = e[l * r + d], P += _ * _;
    k[l] = Math.sqrt(P);
  }
  for (l = 0; l < o - 1; l++) {
    for (f = l, d = l + 1; d < o; d++)
      k[f] < k[d] && (f = d);
    if (l !== f && (Q_(k, l, f, P), n)) {
      for (d = 0; d < i; d++)
        Q_(e, l * r + d, f * r + d, _);
      for (d = 0; d < o; d++)
        Q_(n, l * a + d, f * a + d, _);
    }
  }
  for (l = 0; l < o; l++)
    t[l] = k[l];
  if (n)
    for (l = 0; l < c; l++) {
      for (P = l < o ? k[l] : 0; P <= u; ) {
        for (O = 1 / i, d = 0; d < i; d++)
          D = D * 214013 + 2531011, N = D >> 16 & 32767 & 256 ? O : -O, e[l * r + d] = N;
        for (m = 0; m < 2; m++)
          for (f = 0; f < l; f++) {
            for (P = 0, d = 0; d < i; d++)
              P += e[l * r + d] * e[f * r + d];
            for (V = 0, d = 0; d < i; d++)
              _ = e[l * r + d] - P * e[f * r + d], e[l * r + d] = _, V += Math.abs(_);
            for (V = V ? 1 / V : 0, d = 0; d < i; d++)
              e[l * r + d] *= V;
          }
        for (P = 0, d = 0; d < i; d++)
          _ = e[l * r + d], P += _ * _;
        P = Math.sqrt(P);
      }
      for (g = 1 / P, d = 0; d < i; d++)
        e[l * r + d] *= g;
    }
}
$s.JacobiSVDImpl = jz;
function uae(e, r, t, n) {
  var a = 0, i = 0, o = e.rows, c = e.cols, s = o, u = c;
  s < u && (a = 1, i = s, s = u, u = i);
  var l = Vc.Matrix.create(s, s), f = Vc.Matrix.create(1, u), d = Vc.Matrix.create(u, u);
  if (a === 0)
    Vc.Matrix.transpose(l, e);
  else {
    for (i = 0; i < c * o; i++)
      l.data[i] = e.data[i];
    for (; i < u * s; i++)
      l.data[i] = 0;
  }
  if (jz(l.data, s, f.data, d.data, u, s, u, s), r) {
    for (i = 0; i < u; i++)
      r.data[i] = f.data[i];
    for (; i < c; i++)
      r.data[i] = 0;
  }
  a === 0 ? (t && Vc.Matrix.transpose(t, l), n && Vc.Matrix.transpose(n, d)) : (t && Vc.Matrix.transpose(t, d), n && Vc.Matrix.transpose(n, l));
}
$s.svd = uae;
var PI;
function sy() {
  if (PI) return bh;
  PI = 1, Object.defineProperty(bh, "__esModule", { value: !0 }), bh.PrincipalAxes = void 0;
  var e = uy, r = Yo, t = $s, n = nr(), a;
  return function(i) {
    function o(m) {
      var p = c(m), v = d(m, p);
      return { momentsAxes: p, boxAxes: v };
    }
    i.ofPositions = o;
    function c(m) {
      if (m.length === 3)
        return n.Axes3D.create(r.Vec3.fromArray((0, r.Vec3)(), m, 0), r.Vec3.create(1, 0, 0), r.Vec3.create(0, 1, 0), r.Vec3.create(0, 1, 0));
      var p = e.Matrix.fromArray(m, 3, m.length / 3), v = p.rows, h = v / 3, y = e.Matrix.create(3, 3), C = e.Matrix.create(1, 3), S = e.Matrix.create(3, 3), b = e.Matrix.create(3, 3), g = e.Matrix.meanRows(p), _ = e.Matrix.subRows(e.Matrix.clone(p), g), A = e.Matrix.transpose(e.Matrix.create(v, 3), _);
      e.Matrix.multiplyABt(y, A, A), (0, t.svd)(y, C, S, b);
      var M = r.Vec3.create(g[0], g[1], g[2]), P = r.Vec3.create(S.data[0], S.data[3], S.data[6]), T = r.Vec3.create(S.data[1], S.data[4], S.data[7]), x = r.Vec3.create(S.data[2], S.data[5], S.data[8]);
      return r.Vec3.scale(P, P, Math.sqrt(C.data[0] / h)), r.Vec3.scale(T, T, Math.sqrt(C.data[1] / h)), r.Vec3.scale(x, x, Math.sqrt(C.data[2] / h)), n.Axes3D.create(M, P, T, x);
    }
    i.calculateMomentsAxes = c;
    var s = (0, r.Vec3)(), u = (0, r.Vec3)(), l = (0, r.Vec3)(), f = (0, r.Vec3)();
    function d(m, p) {
      if (m.length === 3)
        return n.Axes3D.clone(p);
      for (var v = -1 / 0, h = -1 / 0, y = -1 / 0, C = -1 / 0, S = -1 / 0, b = -1 / 0, g = (0, r.Vec3)(), _ = (0, r.Vec3)(), A = p.origin, M = r.Vec3.normalize(u, p.dirA), P = r.Vec3.normalize(l, p.dirB), T = r.Vec3.normalize(f, p.dirC), x = 0, w = m.length; x < w; x += 3) {
        r.Vec3.projectPointOnVector(g, r.Vec3.fromArray(g, m, x), M, A);
        var E = r.Vec3.dot(M, r.Vec3.normalize(_, r.Vec3.sub(_, g, A))), I = r.Vec3.distance(g, A);
        E > 0 ? I > v && (v = I) : I > h && (h = I), r.Vec3.projectPointOnVector(g, r.Vec3.fromArray(g, m, x), P, A);
        var B = r.Vec3.dot(P, r.Vec3.normalize(_, r.Vec3.sub(_, g, A))), D = r.Vec3.distance(g, A);
        B > 0 ? D > y && (y = D) : D > C && (C = D), r.Vec3.projectPointOnVector(g, r.Vec3.fromArray(g, m, x), T, A);
        var N = r.Vec3.dot(T, r.Vec3.normalize(_, r.Vec3.sub(_, g, A))), O = r.Vec3.distance(g, A);
        N > 0 ? O > S && (S = O) : O > b && (b = O);
      }
      var V = r.Vec3.setMagnitude((0, r.Vec3)(), M, (v + h) / 2), k = r.Vec3.setMagnitude((0, r.Vec3)(), P, (y + C) / 2), G = r.Vec3.setMagnitude((0, r.Vec3)(), T, (S + b) / 2), L = (0, r.Vec3)(), R = function(F, U, H) {
        r.Vec3.copy(s, A), r.Vec3.scaleAndAdd(s, s, M, F), r.Vec3.scaleAndAdd(s, s, P, U), r.Vec3.scaleAndAdd(s, s, T, H), r.Vec3.add(L, L, s);
      };
      return R(v, y, S), R(v, y, -b), R(v, -C, -b), R(v, -C, S), R(-h, -C, -b), R(-h, -C, S), R(-h, y, S), R(-h, y, -b), r.Vec3.scale(L, L, 1 / 8), n.Axes3D.create(L, V, k, G);
    }
    i.calculateBoxAxes = d;
  }(a || (a = {})), bh.PrincipalAxes = a, bh;
}
var MI;
function lC() {
  if (MI) return sm;
  MI = 1, Object.defineProperty(sm, "__esModule", { value: !0 }), sm.Sphere3D = void 0;
  var e = Te, r = Re, t = Qe(), n = bp, a = sy();
  function i() {
    return i.zero();
  }
  return sm.Sphere3D = i, function(o) {
    function c(N) {
      return N.extrema !== void 0;
    }
    o.hasExtrema = c;
    function s(N, O) {
      return { center: N, radius: O };
    }
    o.create = s;
    function u() {
      return { center: (0, r.Vec3)(), radius: 0 };
    }
    o.zero = u;
    function l(N) {
      var O = s(r.Vec3.clone(N.center), N.radius);
      return c(N) && (O.extrema = N.extrema.map(function(V) {
        return r.Vec3.clone(V);
      })), O;
    }
    o.clone = l;
    function f(N, O, V) {
      return r.Vec3.copy(N.center, O), N.radius = V, N;
    }
    o.set = f;
    function d(N, O) {
      return r.Vec3.copy(N.center, O.center), N.radius = O.radius, c(O) && m(N, O.extrema.map(function(V) {
        return r.Vec3.clone(V);
      })), N;
    }
    o.copy = d;
    function m(N, O) {
      var V;
      return N.extrema !== void 0 ? (N.extrema.length = 0, (V = N.extrema).push.apply(V, O)) : N.extrema = O, N;
    }
    o.setExtrema = m;
    function p(N) {
      for (var O = N.x, V = N.y, k = N.z, G = N.indices, L = 0, R = 0, F = 0, U = 0, H = t.OrderedSet.size(G), q = 0; q < H; q++) {
        var K = t.OrderedSet.getAt(G, q);
        L += O[K], R += V[K], F += k[K];
      }
      H > 0 && (L /= H, R /= H, F /= H);
      for (var q = 0; q < H; q++) {
        var K = t.OrderedSet.getAt(G, q), Y = O[K] - L, X = V[K] - R, Z = k[K] - F, J = Y * Y + X * X + Z * Z;
        J > U && (U = J);
      }
      return { center: r.Vec3.create(L, R, F), radius: Math.sqrt(U) };
    }
    o.computeBounding = p;
    function v(N, O, V) {
      return r.Vec3.transformMat4(N.center, O.center, V), N.radius = O.radius * r.Mat4.getMaxScaleOnAxis(V), c(O) && m(N, O.extrema.map(function(k) {
        return r.Vec3.transformMat4((0, r.Vec3)(), k, V);
      })), N;
    }
    o.transform = v;
    function h(N, O, V) {
      return r.Vec3.add(N.center, O.center, V), c(O) && m(N, O.extrema.map(function(k) {
        return r.Vec3.add((0, r.Vec3)(), k, V);
      })), N;
    }
    o.translate = h;
    function y(N, O, V) {
      r.Vec3.toArray(N.center, O, V), O[V + 3] = N.radius;
    }
    o.toArray = y;
    function C(N, O, V) {
      return r.Vec3.fromArray(N.center, O, V), N.radius = O[V + 3], N;
    }
    o.fromArray = C;
    function S(N, O) {
      return r.Vec3.scale(N.center, r.Vec3.add(N.center, O.max, O.min), 0.5), N.radius = r.Vec3.distance(N.center, O.max), o.setExtrema(N, [
        r.Vec3.create(O.min[0], O.min[1], O.min[2]),
        r.Vec3.create(O.max[0], O.max[1], O.max[2]),
        r.Vec3.create(O.max[0], O.min[1], O.min[2]),
        r.Vec3.create(O.min[0], O.max[1], O.max[2]),
        r.Vec3.create(O.min[0], O.min[1], O.max[2]),
        r.Vec3.create(O.max[0], O.min[1], O.max[2]),
        r.Vec3.create(O.max[0], O.max[1], O.min[2]),
        r.Vec3.create(O.min[0], O.max[1], O.min[2])
      ]), N;
    }
    o.fromBox3D = S;
    function b(N, O) {
      return r.Vec3.copy(N.center, O.origin), N.radius = Math.max(r.Vec3.magnitude(O.dirA), r.Vec3.magnitude(O.dirB), r.Vec3.magnitude(O.dirC)), N;
    }
    o.fromAxes3D = b;
    var g = (0, r.Vec3)();
    function _(N, O, V) {
      var k = O[0], G = O[1], L = O[2], R = r.Vec3.create(0, 0, 0);
      r.Vec3.transformMat4(R, R, V);
      var F = r.Vec3.create(k, G, L);
      r.Vec3.transformMat4(F, F, V);
      var U = r.Vec3.create(k, 0, 0);
      r.Vec3.transformMat4(U, U, V);
      var H = r.Vec3.create(0, G, L);
      r.Vec3.transformMat4(H, H, V);
      var q = r.Vec3.create(0, 0, L);
      r.Vec3.transformMat4(q, q, V);
      var K = r.Vec3.create(k, 0, L);
      r.Vec3.transformMat4(K, K, V);
      var Y = r.Vec3.create(k, G, 0);
      r.Vec3.transformMat4(Y, Y, V);
      var X = r.Vec3.create(0, G, 0);
      r.Vec3.transformMat4(X, X, V), r.Vec3.add(g, R, F), r.Vec3.scale(g, g, 0.5);
      var Z = Math.max(r.Vec3.distance(R, F), r.Vec3.distance(U, H));
      return o.set(N, g, Z / 2), o.setExtrema(N, [R, F, U, H, q, K, Y, X]), N;
    }
    o.fromDimensionsAndTransform = _;
    var A = (0, r.Vec3)();
    function M(N, O, V) {
      var k = r.Vec3.distance(O.center, V);
      return k < O.radius ? o.copy(N, O) : (r.Vec3.sub(A, O.center, V), r.Vec3.sub(A, O.center, A), r.Vec3.setMagnitude(A, A, O.radius), r.Vec3.scale(N.center, r.Vec3.add(A, A, V), 0.5), N.radius = r.Vec3.distance(N.center, V), N);
    }
    o.addVec3 = M;
    function P(N, O, V) {
      return r.Vec3.copy(N.center, O.center), N.radius = Math.max(O.radius, r.Vec3.distance(O.center, V.center) + V.radius), c(O) && c(V) && m(N, (0, e.__spreadArray)((0, e.__spreadArray)([], O.extrema.map(function(k) {
        return r.Vec3.clone(k);
      }), !0), V.extrema.map(function(k) {
        return r.Vec3.clone(k);
      }), !0)), N;
    }
    o.expandBySphere = P;
    var T = (0, r.Vec3)();
    function x(N, O, V) {
      var k, G;
      if (r.Vec3.copy(N.center, O.center), N.radius = O.radius + V, O.radius < 1e-12 || ((G = (k = O.extrema) === null || k === void 0 ? void 0 : k.length) !== null && G !== void 0 ? G : 0) <= 1)
        return N.extrema = void 0, N;
      if (c(O)) {
        for (var L = new Float32Array(O.extrema.length * 3), R = 0; R < O.extrema.length; R++)
          r.Vec3.toArray(O.extrema[R], L, R * 3);
        var F = a.PrincipalAxes.calculateMomentsAxes(L);
        n.Axes3D.scale(F, n.Axes3D.normalize(F, F), V), m(N, O.extrema.map(function(U) {
          r.Vec3.normalize(T, r.Vec3.sub(T, U, O.center));
          var H = r.Vec3.clone(U), q = r.Vec3.dot(T, F.dirA) < 0 ? -1 : 1;
          r.Vec3.scaleAndAdd(H, H, F.dirA, q);
          var K = r.Vec3.dot(T, F.dirB) < 0 ? -1 : 1;
          r.Vec3.scaleAndAdd(H, H, F.dirB, K);
          var Y = r.Vec3.dot(T, F.dirC) < 0 ? -1 : 1;
          return r.Vec3.scaleAndAdd(H, H, F.dirC, Y), r.Vec3.distance(N.center, H) > N.radius && (O.extrema.length >= 14 && r.Vec3.normalize(T, r.Vec3.sub(T, H, O.center)), r.Vec3.scaleAndAdd(H, N.center, T, N.radius)), H;
        }));
      }
      return N;
    }
    o.expand = x;
    function w(N, O) {
      return N.radius === O.radius && r.Vec3.exactEquals(N.center, O.center);
    }
    o.exactEquals = w;
    function E(N, O) {
      var V = N.radius, k = O.radius;
      return Math.abs(V - k) <= r.EPSILON * Math.max(1, Math.abs(V), Math.abs(k)) && r.Vec3.equals(N.center, O.center);
    }
    o.equals = E;
    function I(N, O) {
      if (c(O)) {
        for (var V = 0, k = O.extrema; V < k.length; V++) {
          var G = k[V];
          if (r.Vec3.distance(N.center, G) > N.radius)
            return !1;
        }
        return !0;
      } else
        return r.Vec3.distance(N.center, O.center) + O.radius <= N.radius;
    }
    o.includes = I;
    function B(N, O) {
      return r.Vec3.distance(N.center, O.center) <= N.radius + O.radius;
    }
    o.overlaps = B;
    function D(N, O) {
      return r.Vec3.distance(N.center, O.center) - N.radius + O.radius;
    }
    o.distance = D;
  }(i || (i = {})), sm.Sphere3D = i, sm;
}
var wI;
function mE() {
  if (wI) return um;
  wI = 1, Object.defineProperty(um, "__esModule", { value: !0 }), um.Box3D = void 0;
  var e = Re, r = Qe(), t = lC();
  function n() {
    return n.zero();
  }
  return um.Box3D = n, function(a) {
    function i(_, A) {
      return { min: _, max: A };
    }
    a.create = i;
    function o() {
      return { min: (0, e.Vec3)(), max: (0, e.Vec3)() };
    }
    a.zero = o;
    function c(_, A) {
      return e.Vec3.copy(_.min, A.min), e.Vec3.copy(_.max, A.max), _;
    }
    a.copy = c;
    function s(_) {
      return c(o(), _);
    }
    a.clone = s;
    function u(_, A) {
      if (t.Sphere3D.hasExtrema(A) && A.extrema.length >= 14)
        return l(_, A.extrema);
      var M = e.Vec3.create(A.radius, A.radius, A.radius);
      return e.Vec3.sub(_.min, A.center, M), e.Vec3.add(_.max, A.center, M), _;
    }
    a.fromSphere3D = u;
    function l(_, A) {
      a.setEmpty(_);
      for (var M = 0, P = A.length; M < P; M++)
        a.add(_, A[M]);
      return _;
    }
    a.fromVec3Array = l;
    function f(_) {
      for (var A = e.Vec3.create(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), M = e.Vec3.create(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), P = _.x, T = _.y, x = _.z, w = _.indices, E = 0, I = r.OrderedSet.size(w); E < I; E++) {
        var B = r.OrderedSet.getAt(w, E);
        A[0] = Math.min(P[B], A[0]), A[1] = Math.min(T[B], A[1]), A[2] = Math.min(x[B], A[2]), M[0] = Math.max(P[B], M[0]), M[1] = Math.max(T[B], M[1]), M[2] = Math.max(x[B], M[2]);
      }
      return { min: A, max: M };
    }
    a.computeBounding = f;
    function d(_, A) {
      return e.Vec3.sub(_, A.max, A.min);
    }
    a.size = d;
    var m = (0, e.Vec3)();
    function p(_) {
      return d(m, _), m[0] * m[1] * m[2];
    }
    a.volume = p;
    function v(_) {
      return e.Vec3.set(_.min, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), e.Vec3.set(_.max, -Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), _;
    }
    a.setEmpty = v;
    function h(_, A) {
      return e.Vec3.min(_.min, _.min, A), e.Vec3.max(_.max, _.max, A), _;
    }
    a.add = h;
    function y(_, A, M) {
      return e.Vec3.sub(_.min, A.min, M), e.Vec3.add(_.max, A.max, M), _;
    }
    a.expand = y;
    function C(_, A, M) {
      return e.Vec3.scale(_.min, A.min, M), e.Vec3.scale(_.max, A.max, M), _;
    }
    a.scale = C;
    var S = (0, e.Vec3)();
    function b(_, A, M) {
      var P = A.min, T = P[0], x = P[1], w = P[2], E = A.max, I = E[0], B = E[1], D = E[2];
      return v(_), h(_, e.Vec3.transformMat4(S, e.Vec3.set(S, T, x, w), M)), h(_, e.Vec3.transformMat4(S, e.Vec3.set(S, T, x, D), M)), h(_, e.Vec3.transformMat4(S, e.Vec3.set(S, T, B, w), M)), h(_, e.Vec3.transformMat4(S, e.Vec3.set(S, T, B, D), M)), h(_, e.Vec3.transformMat4(S, e.Vec3.set(S, I, x, w), M)), h(_, e.Vec3.transformMat4(S, e.Vec3.set(S, I, x, D), M)), h(_, e.Vec3.transformMat4(S, e.Vec3.set(S, I, B, w), M)), h(_, e.Vec3.transformMat4(S, e.Vec3.set(S, I, B, D), M)), _;
    }
    a.transform = b;
    function g(_, A) {
      return !(A[0] < _.min[0] || A[0] > _.max[0] || A[1] < _.min[1] || A[1] > _.max[1] || A[2] < _.min[2] || A[2] > _.max[2]);
    }
    a.containsVec3 = g;
  }(n || (n = {})), um.Box3D = n, um;
}
var EI;
function sae() {
  if (EI) return _h;
  EI = 1, Object.defineProperty(_h, "__esModule", { value: !0 }), _h.GridLookup3D = void 0;
  var e = fE, r = mE(), t = Re, n = Qe();
  function a(l, f, d) {
    return new i(l, f, d);
  }
  _h.GridLookup3D = a;
  var i = (
    /** @class */
    function() {
      function l(f, d, m) {
        var p = c(f, d, m);
        this.ctx = s(p), this.boundary = { box: p.boundingBox, sphere: p.boundingSphere }, this.buckets = { offset: p.bucketOffset, count: p.bucketCounts, array: p.bucketArray }, this.result = e.Result.create();
      }
      return l.prototype.find = function(f, d, m, p, v) {
        this.ctx.x = f, this.ctx.y = d, this.ctx.z = m, this.ctx.radius = p, this.ctx.isCheck = !1;
        var h = v ?? this.result;
        return u(this.ctx, h), h;
      }, l.prototype.check = function(f, d, m, p) {
        return this.ctx.x = f, this.ctx.y = d, this.ctx.z = m, this.ctx.radius = p, this.ctx.isCheck = !0, u(this.ctx, this.result);
      }, l;
    }()
  );
  function o(l) {
    for (var f = l.expandedBox, d = l.size, m = d[0], p = d[1], v = d[2], h = l.data, y = h.x, C = h.y, S = h.z, b = h.radius, g = h.indices, _ = l.elementCount, A = l.delta, M = m * p * v, P = f.min, T = P[0], x = P[1], w = P[2], E = 0, I = 0, B = new Uint32Array(M), D = new Int32Array(_), N = 0; N < _; N++) {
      var O = n.OrderedSet.getAt(g, N), V = Math.floor((y[O] - T) / A[0]), k = Math.floor((C[O] - x) / A[1]), G = Math.floor((S[O] - w) / A[2]), L = (V * p + k) * v + G;
      (B[L] += 1) === 1 && (I += 1), D[N] = L;
    }
    if (b)
      for (var N = 0; N < _; N++) {
        var O = n.OrderedSet.getAt(g, N);
        b[O] > E && (E = b[O]);
      }
    for (var R = new Int32Array(I), O = 0, F = 0; O < M; O++) {
      var U = B[O];
      U > 0 && (B[O] = F + 1, R[F] = U, F += 1);
    }
    for (var H = new Uint32Array(I), O = 1; O < I; ++O)
      H[O] += H[O - 1] + R[O - 1];
    for (var q = new Int32Array(I), K = new Int32Array(_), O = 0; O < _; O++) {
      var Y = B[D[O]];
      if (Y > 0) {
        var X = Y - 1;
        K[H[X] + q[X]] = O, q[X] += 1;
      }
    }
    return {
      size: l.size,
      bucketArray: K,
      bucketCounts: R,
      bucketOffset: H,
      grid: B,
      delta: A,
      min: l.expandedBox.min,
      data: l.data,
      maxRadius: E,
      expandedBox: l.expandedBox,
      boundingBox: l.boundingBox,
      boundingSphere: l.boundingSphere
    };
  }
  function c(l, f, d) {
    var m = r.Box3D.expand((0, r.Box3D)(), f.box, t.Vec3.create(0.5, 0.5, 0.5)), p = l.indices, v = r.Box3D.size(t.Vec3.zero(), m), h, y, C = n.OrderedSet.size(p), S = typeof d == "number" ? d : 32, b = Array.isArray(d) && d;
    if (b)
      y = [Math.ceil(v[0] / b[0]), Math.ceil(v[1] / b[1]), Math.ceil(v[2] / b[2])], h = b;
    else if (C > 0) {
      var g = Math.ceil(C / S), _ = Math.pow(g / (v[0] * v[1] * v[2]), 1 / 3);
      y = [Math.ceil(v[0] * _), Math.ceil(v[1] * _), Math.ceil(v[2] * _)], h = [v[0] / y[0], v[1] / y[1], v[2] / y[2]];
    } else
      h = v, y = [1, 1, 1];
    var A = {
      x: l.x,
      y: l.y,
      z: l.z,
      indices: p,
      radius: l.radius
    }, M = {
      size: y,
      data: A,
      expandedBox: m,
      boundingBox: f.box,
      boundingSphere: f.sphere,
      elementCount: C,
      delta: h
    };
    return o(M);
  }
  function s(l) {
    return { grid: l, x: 0.1, y: 0.1, z: 0.1, radius: 0.1, isCheck: !1 };
  }
  function u(l, f) {
    var d = l.grid, m = d.min, p = d.size, v = p[0], h = p[1], y = p[2], C = d.bucketOffset, S = d.bucketCounts, b = d.bucketArray, g = d.grid, _ = d.data, A = _.x, M = _.y, P = _.z, T = _.indices, x = _.radius, w = d.delta, E = d.maxRadius, I = l.radius, B = l.isCheck, D = l.x, N = l.y, O = l.z, V = I + E, k = V * V;
    e.Result.reset(f);
    var G = Math.max(0, Math.floor((D - V - m[0]) / w[0])), L = Math.max(0, Math.floor((N - V - m[1]) / w[1])), R = Math.max(0, Math.floor((O - V - m[2]) / w[2])), F = Math.min(v - 1, Math.floor((D + V - m[0]) / w[0])), U = Math.min(h - 1, Math.floor((N + V - m[1]) / w[1])), H = Math.min(y - 1, Math.floor((O + V - m[2]) / w[2]));
    if (G > F || L > U || R > H)
      return !1;
    for (var q = G; q <= F; q++)
      for (var K = L; K <= U; K++)
        for (var Y = R; Y <= H; Y++) {
          var X = g[(q * h + K) * y + Y];
          if (X !== 0)
            for (var Z = X - 1, J = C[Z], $ = S[Z], Q = J + $, W = J; W < Q; W++) {
              var te = n.OrderedSet.getAt(T, b[W]), oe = A[te] - D, z = M[te] - N, j = P[te] - O, ae = oe * oe + z * z + j * j;
              if (ae <= k) {
                if (E > 0 && Math.sqrt(ae) - x[te] > I)
                  continue;
                if (B)
                  return !0;
                e.Result.add(f, b[W], ae);
              }
            }
        }
    return f.count > 0;
  }
  return _h;
}
var DI;
function nr() {
  return DI || (DI = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 });
    var r = Te;
    (0, r.__exportStar)(Xne(), e), (0, r.__exportStar)(E0, e), (0, r.__exportStar)(aae(), e), (0, r.__exportStar)(fE, e), (0, r.__exportStar)(sae(), e), (0, r.__exportStar)(mE(), e), (0, r.__exportStar)(lC(), e), (0, r.__exportStar)(bp, e);
  }(qx)), qx;
}
var Pl = {}, $x = {}, Sh = {}, Kx = {}, Sp = {};
Object.defineProperty(Sp, "__esModule", { value: !0 });
Sp.Location = void 0;
var Wx = Re, vM;
(function(e) {
  function r(d, m, p) {
    return {
      kind: "element-location",
      structure: d,
      unit: m,
      element: p || 0
    };
  }
  e.create = r;
  function t(d) {
    return r(d.structure, d.unit, d.element);
  }
  e.clone = t;
  function n(d, m, p, v) {
    return m && (d.structure = m), p && (d.unit = p), v !== void 0 && (d.element = v), d;
  }
  e.set = n;
  function a(d, m) {
    return d.unit = m.unit, d.element = m.element, d;
  }
  e.copy = a;
  function i(d) {
    return !!d && d.kind === "element-location";
  }
  e.is = i;
  function o(d, m) {
    return d.unit === m.unit && d.element === m.element;
  }
  e.areEqual = o;
  var c = Wx.Vec3.zero(), s = Wx.Vec3.zero();
  function u(d, m) {
    return d.unit.conformation.position(d.element, c), m.unit.conformation.position(m.element, s), Wx.Vec3.distance(c, s);
  }
  e.distance = u;
  function l(d) {
    return d.unit.model.atomicHierarchy.residueAtomSegments.index[d.element];
  }
  e.residueIndex = l;
  function f(d) {
    return d.unit.model.atomicHierarchy.chainAtomSegments.index[d.element];
  }
  e.chainIndex = f;
})(vM || (vM = {}));
Sp.Location = vM;
var Xx = {}, Po = {}, cC = {};
Object.defineProperty(cC, "__esModule", { value: !0 });
cC.HashSet = void 0;
var lae = (
  /** @class */
  function() {
    function e(r, t) {
      this.getHash = r, this.areEqual = t, this.size = 0, this.byHash = /* @__PURE__ */ new Map();
    }
    return e.prototype.add = function(r) {
      var t = this.getHash(r);
      if (this.byHash.has(t)) {
        for (var n = this.byHash.get(t), a = 0, i = n.length; a < i; a++)
          if (this.areEqual(r, n[a]))
            return !1;
        return n[n.length] = r, this.size++, !0;
      } else
        return this.byHash.set(t, [r]), this.size++, !0;
    }, e.prototype.has = function(r) {
      var t = this.getHash(r);
      if (!this.byHash.has(t))
        return !1;
      for (var n = this.byHash.get(t), a = 0, i = n.length; a < i; a++)
        if (this.areEqual(r, n[a]))
          return !0;
      return !1;
    }, e;
  }()
);
function cae(e, r) {
  return new lae(e, r);
}
cC.HashSet = cae;
var dC = {};
Object.defineProperty(dC, "__esModule", { value: !0 });
dC.LinkedList = void 0;
function dae() {
  return new fae();
}
dC.LinkedList = dae;
function II(e) {
  return { previous: null, next: null, inList: !0, value: e };
}
var fae = (
  /** @class */
  function() {
    function e() {
      this.count = 0, this.first = null, this.last = null;
    }
    return e.prototype.addFirst = function(r) {
      var t = II(r);
      return t.inList = !0, this.first && (this.first.previous = t), t.next = this.first, this.first = t, this.count++, this.last || (this.last = t), t;
    }, e.prototype.addLast = function(r) {
      var t = II(r);
      return this.last !== null && (this.last.next = t), t.previous = this.last, this.last = t, this.first === null && (this.first = t), t.inList = !0, this.count++, t;
    }, e.prototype.removeFirst = function() {
      var r = this.first;
      if (r)
        return this.remove(r), r.value;
    }, e.prototype.removeLast = function() {
      var r = this.last;
      if (r)
        return this.remove(r), r.value;
    }, e.prototype.remove = function(r) {
      r.inList && (r.inList = !1, r.previous !== null ? r.previous.next = r.next : (
        /* first == item*/
        r.previous === null && (this.first = r.next)
      ), r.next !== null ? r.next.previous = r.previous : (
        /* last == item*/
        r.next === null && (this.last = r.previous)
      ), r.next = null, r.previous = null, this.count--);
    }, e.prototype.find = function(r) {
      for (var t = this.first; t !== null; ) {
        if (t.value === r)
          return t;
        t = t.next;
      }
    }, e;
  }()
), fC = {};
Object.defineProperty(fC, "__esModule", { value: !0 });
fC.UniqueArray = void 0;
var pM;
(function(e) {
  function r() {
    return { keys: /* @__PURE__ */ new Set(), array: [] };
  }
  e.create = r;
  function t(a, i, o) {
    var c = a.keys, s = a.array;
    return c.has(i) ? !1 : (c.add(i), s[s.length] = o, !0);
  }
  e.add = t;
  function n(a, i) {
    var o = a.keys;
    return o.has(i);
  }
  e.has = n;
})(pM || (pM = {}));
fC.UniqueArray = pM;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 });
  var r = Te;
  (0, r.__exportStar)(cC, e), (0, r.__exportStar)(dC, e), (0, r.__exportStar)(fC, e);
})(Po);
var gs = {}, mC = {}, vE = {}, D0 = {};
Object.defineProperty(D0, "__esModule", { value: !0 });
D0.Type = void 0;
var hM;
(function(e) {
  function r(c, s, u) {
    return { kind: "variable", name: c, type: s, isConstraint: u };
  }
  e.Variable = r;
  function t(c, s, u) {
    return { kind: "value", namespace: c, name: s, parent: u };
  }
  e.Value = t;
  function n(c, s, u, l) {
    return { kind: "container", namespace: c, name: s, child: u, alias: l };
  }
  e.Container = n;
  function a(c) {
    return { kind: "union", types: c };
  }
  e.Union = a;
  function i(c, s, u, l) {
    for (var f = /* @__PURE__ */ Object.create(null), d = 0, m = l; d < m.length; d++) {
      var p = m[d];
      f[p] = !0;
    }
    return { kind: "oneof", namespace: c, name: s, type: u, values: f };
  }
  e.OneOf = i, e.Any = { kind: "any" }, e.AnyValue = { kind: "any-value" }, e.Num = t("", "Number"), e.Str = t("", "String"), e.Bool = i("", "Bool", e.Str, ["true", "false"]);
  function o(c) {
    var s = c.values;
    return Object.keys(s).sort();
  }
  e.oneOfValues = o;
})(hM || (hM = {}));
D0.Type = hM;
var Cp = {}, I0 = {};
Object.defineProperty(I0, "__esModule", { value: !0 });
I0.Expression = void 0;
var gM;
(function(e) {
  function r(s) {
    return { name: s };
  }
  e.Symbol = r;
  function t(s, u) {
    return u ? { head: s, args: u } : { head: s };
  }
  e.Apply = t;
  function n(s) {
    return !!s && Array.isArray(s);
  }
  e.isArgumentsArray = n;
  function a(s) {
    return !!s && !Array.isArray(s);
  }
  e.isArgumentsMap = a;
  function i(s) {
    return !o(s) && !c(s);
  }
  e.isLiteral = i;
  function o(s) {
    return !!s && !!s.head && typeof s == "object";
  }
  e.isApply = o;
  function c(s) {
    return !!s && typeof s.name == "string";
  }
  e.isSymbol = c;
})(gM || (gM = {}));
I0.Expression = gM;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.isSymbol = e.CustomPropSymbol = e.MSymbol = e.Arguments = e.Argument = void 0;
  var r = I0;
  function t(c, s) {
    var u = s || {}, l = u.description, f = l === void 0 ? void 0 : l, d = u.isOptional, m = d === void 0 ? !1 : d, p = u.isRest, v = p === void 0 ? !1 : p, h = u.defaultValue, y = h === void 0 ? void 0 : h;
    return { type: c, isOptional: m, isRest: v, defaultValue: y, description: f };
  }
  e.Argument = t;
  var n;
  (function(c) {
    c.None = s({});
    function s(l) {
      return { kind: "dictionary", map: l, "@type": 0 };
    }
    c.Dictionary = s;
    function u(l, f) {
      var d = (f || {}).nonEmpty, m = d === void 0 ? !1 : d;
      return { kind: "list", type: l, nonEmpty: m, "@type": 0 };
    }
    c.List = u;
  })(n = e.Arguments || (e.Arguments = {}));
  function a(c, s, u, l) {
    var f = function(d) {
      return r.Expression.Apply(r.Expression.Symbol(f.id), d);
    };
    return f.info = { namespace: "", name: c, description: l }, f.id = "", f.args = s, f.type = u, f;
  }
  e.MSymbol = a;
  function i(c, s, u, l) {
    var f = function(d) {
      return r.Expression.Apply(r.Expression.Symbol(f.id), d);
    };
    return f.info = { namespace: c, name: s, description: l }, f.id = "".concat(c, ".").concat(s), f.args = n.None, f.type = u, f;
  }
  e.CustomPropSymbol = i;
  function o(c) {
    var s = c;
    return typeof s == "function" && !!s.info && !!s.args && typeof s.info.namespace == "string" && !!s.type;
  }
  e.isSymbol = o;
})(Cp);
var rs = {};
Object.defineProperty(rs, "__esModule", { value: !0 });
rs.symbolList = rs.normalizeTable = rs.symbol = void 0;
var xg = Cp;
function mae(e, r, t) {
  return (0, xg.MSymbol)("", e, r, t);
}
rs.symbol = mae;
function vae(e) {
  $z("", "", e);
}
rs.normalizeTable = vae;
function pae(e) {
  var r = [];
  return Kz(e, r), r;
}
rs.symbolList = pae;
function BI(e) {
  var r = /([a-z])([A-Z])([a-z]|$)/g;
  return e.replace(r, function(t, n, a, i) {
    return "".concat(n, "-").concat(a.toLocaleLowerCase()).concat(i);
  }).replace(r, function(t, n, a, i) {
    return "".concat(n, "-").concat(a.toLocaleLowerCase()).concat(i);
  });
}
function $z(e, r, t) {
  if ((0, xg.isSymbol)(t)) {
    t.info.namespace = e, t.info.name = t.info.name || BI(r), t.id = "".concat(t.info.namespace, ".").concat(t.info.name);
    return;
  }
  for (var n = "".concat(t["@namespace"] || BI(r)), a = e ? "".concat(e, ".").concat(n) : n, i = 0, o = Object.keys(t); i < o.length; i++) {
    var c = o[i];
    typeof t[c] != "object" && !(0, xg.isSymbol)(t[c]) || $z(a, c, t[c]);
  }
}
function Kz(e, r) {
  if ((0, xg.isSymbol)(e)) {
    r.push(e);
    return;
  }
  for (var t = 0, n = Object.keys(e); t < n.length; t++) {
    var a = n[t];
    typeof e[a] != "object" && !(0, xg.isSymbol)(e[a]) || Kz(e[a], r);
  }
}
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.SymbolMap = e.SymbolList = e.core = e.TTargs = e.Types = void 0;
  var r = D0, t = Cp, n = rs, a;
  (function(y) {
    y.AnyVar = r.Type.Variable("a", r.Type.Any), y.AnyValueVar = r.Type.Variable("a", r.Type.Any), y.ConstrainedVar = r.Type.Variable("a", r.Type.Any, !0), y.Regex = r.Type.Value("Core", "Regex"), y.Set = function(C) {
      return r.Type.Container("Core", "Set", C || y.AnyValueVar);
    }, y.List = function(C) {
      return r.Type.Container("Core", "List", C || y.AnyVar);
    }, y.Fn = function(C, S) {
      return r.Type.Container("Core", "Fn", C || y.AnyVar, S);
    }, y.Flags = function(C, S) {
      return r.Type.Container("Core", "Flags", C, S);
    }, y.BitFlags = y.Flags(r.Type.Num, "BitFlags");
  })(a = e.Types || (e.Types = {}));
  function i(y, C) {
    return (0, n.symbol)(t.Arguments.Dictionary({ 0: (0, t.Argument)(y) }), y, C);
  }
  function o(y, C) {
    return (0, n.symbol)(t.Arguments.List(y, { nonEmpty: !0 }), y, C);
  }
  function c(y, C, S) {
    return (0, n.symbol)(t.Arguments.Dictionary({
      0: (0, t.Argument)(y),
      1: (0, t.Argument)(y)
    }), C, S);
  }
  e.TTargs = t.Arguments.Dictionary({
    0: (0, t.Argument)(r.Type.Num),
    1: (0, t.Argument)(r.Type.Num)
  }), (0, t.Argument)(r.Type.Str);
  var s = {
    "@header": "Types",
    bool: (0, n.symbol)(t.Arguments.Dictionary({ 0: (0, t.Argument)(r.Type.AnyValue) }), r.Type.Bool, "Convert a value to boolean."),
    num: (0, n.symbol)(t.Arguments.Dictionary({ 0: (0, t.Argument)(r.Type.AnyValue) }), r.Type.Num, "Convert a value to number."),
    str: (0, n.symbol)(t.Arguments.Dictionary({ 0: (0, t.Argument)(r.Type.AnyValue) }), r.Type.Str, "Convert a value to string."),
    regex: (0, n.symbol)(t.Arguments.Dictionary({
      0: (0, t.Argument)(r.Type.Str, { description: "Expression" }),
      1: (0, t.Argument)(r.Type.Str, { isOptional: !0, description: "Flags, e.g. 'i' for ignore case" })
    }), a.Regex, "Creates a regular expression from a string using the ECMAscript syntax."),
    list: (0, n.symbol)(t.Arguments.List(a.AnyVar), a.List()),
    set: (0, n.symbol)(t.Arguments.List(a.AnyValueVar), a.Set()),
    bitflags: (0, n.symbol)(t.Arguments.Dictionary({ 0: (0, t.Argument)(r.Type.Num) }), a.BitFlags, "Interpret a number as bitflags."),
    compositeKey: (0, n.symbol)(t.Arguments.List(r.Type.AnyValue), r.Type.AnyValue)
  }, u = {
    "@header": "Logic",
    not: i(r.Type.Bool),
    and: o(r.Type.Bool),
    or: o(r.Type.Bool)
  }, l = {
    "@header": "Control",
    eval: (0, n.symbol)(t.Arguments.Dictionary({ 0: (0, t.Argument)(a.Fn(a.AnyVar)) }), a.AnyVar, "Evaluate a function."),
    fn: (0, n.symbol)(t.Arguments.Dictionary({ 0: (0, t.Argument)(a.AnyVar) }), a.Fn(a.AnyVar), 'Wrap an expression to a "lazy" function.'),
    if: (0, n.symbol)(t.Arguments.Dictionary({
      0: (0, t.Argument)(r.Type.Bool, { description: "Condition" }),
      1: (0, t.Argument)(r.Type.Variable("a", r.Type.Any), { description: "If true" }),
      2: (0, t.Argument)(r.Type.Variable("b", r.Type.Any), { description: "If false" })
    }), r.Type.Union([r.Type.Variable("a", r.Type.Any), r.Type.Variable("b", r.Type.Any)])),
    assoc: (0, n.symbol)(t.Arguments.Dictionary({
      0: (0, t.Argument)(r.Type.Str, { description: "Name" }),
      1: (0, t.Argument)(r.Type.Variable("a", r.Type.Any), { description: "Value to assign" })
    }), r.Type.Variable("a", r.Type.Any))
  }, f = {
    "@header": "Relational",
    eq: c(r.Type.Variable("a", r.Type.AnyValue, !0), r.Type.Bool),
    neq: c(r.Type.Variable("a", r.Type.AnyValue, !0), r.Type.Bool),
    lt: c(r.Type.Num, r.Type.Bool),
    lte: c(r.Type.Num, r.Type.Bool),
    gr: c(r.Type.Num, r.Type.Bool),
    gre: c(r.Type.Num, r.Type.Bool),
    inRange: (0, n.symbol)(t.Arguments.Dictionary({
      0: (0, t.Argument)(r.Type.Num, { description: "Value to test" }),
      1: (0, t.Argument)(r.Type.Num, { description: "Minimum value" }),
      2: (0, t.Argument)(r.Type.Num, { description: "Maximum value" })
    }), r.Type.Bool, "Check if the value of the 1st argument is >= 2nd and <= 3rd.")
  }, d = {
    "@header": "Math",
    add: o(r.Type.Num),
    sub: o(r.Type.Num),
    mult: o(r.Type.Num),
    div: c(r.Type.Num, r.Type.Num),
    pow: c(r.Type.Num, r.Type.Num),
    mod: c(r.Type.Num, r.Type.Num),
    min: o(r.Type.Num),
    max: o(r.Type.Num),
    floor: i(r.Type.Num),
    ceil: i(r.Type.Num),
    roundInt: i(r.Type.Num),
    abs: i(r.Type.Num),
    sqrt: i(r.Type.Num),
    cbrt: i(r.Type.Num),
    sin: i(r.Type.Num),
    cos: i(r.Type.Num),
    tan: i(r.Type.Num),
    asin: i(r.Type.Num),
    acos: i(r.Type.Num),
    atan: i(r.Type.Num),
    sinh: i(r.Type.Num),
    cosh: i(r.Type.Num),
    tanh: i(r.Type.Num),
    exp: i(r.Type.Num),
    log: i(r.Type.Num),
    log10: i(r.Type.Num),
    atan2: c(r.Type.Num, r.Type.Num)
  }, m = {
    "@header": "Strings",
    concat: o(r.Type.Str),
    match: (0, n.symbol)(t.Arguments.Dictionary({ 0: (0, t.Argument)(a.Regex), 1: (0, t.Argument)(r.Type.Str) }), r.Type.Bool)
  }, p = {
    "@header": "Lists",
    getAt: (0, n.symbol)(t.Arguments.Dictionary({ 0: (0, t.Argument)(a.List()), 1: (0, t.Argument)(r.Type.Num) }), a.AnyVar),
    equal: (0, n.symbol)(t.Arguments.Dictionary({ 0: (0, t.Argument)(a.List()), 1: (0, t.Argument)(a.List()) }), r.Type.Bool)
  }, v = {
    "@header": "Sets",
    has: (0, n.symbol)(t.Arguments.Dictionary({ 0: (0, t.Argument)(a.Set(a.ConstrainedVar)), 1: (0, t.Argument)(a.ConstrainedVar) }), r.Type.Bool, "Check if the the 1st argument includes the value of the 2nd."),
    isSubset: (0, n.symbol)(t.Arguments.Dictionary({ 0: (0, t.Argument)(a.Set(a.ConstrainedVar)), 1: (0, t.Argument)(a.Set(a.ConstrainedVar)) }), r.Type.Bool, "Check if the the 1st argument is a subset of the 2nd.")
  }, h = {
    "@header": "Flags",
    hasAny: (0, n.symbol)(t.Arguments.Dictionary({
      0: (0, t.Argument)(a.Flags(a.ConstrainedVar)),
      1: (0, t.Argument)(a.Flags(a.ConstrainedVar))
    }), r.Type.Bool, "Check if the the 1st argument has at least one of the 2nd one's flags."),
    hasAll: (0, n.symbol)(t.Arguments.Dictionary({
      0: (0, t.Argument)(a.Flags(a.ConstrainedVar)),
      1: (0, t.Argument)(a.Flags(a.ConstrainedVar))
    }), r.Type.Bool, "Check if the the 1st argument has all 2nd one's flags.")
  };
  e.core = {
    "@header": "Language Primitives",
    type: s,
    logic: u,
    ctrl: l,
    rel: f,
    math: d,
    str: m,
    list: p,
    set: v,
    flags: h
  }, (0, n.normalizeTable)(e.core), e.SymbolList = (0, n.symbolList)(e.core), e.SymbolMap = function() {
    for (var y = /* @__PURE__ */ Object.create(null), C = 0, S = e.SymbolList; C < S.length; C++) {
      var b = S[C];
      y[b.id] = b;
    }
    return y;
  }();
})(vE);
var vC = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.structureQuery = e.Types = void 0;
  var r = Te, t = D0, n = (0, r.__importStar)(vE), a = Cp, i = rs, o;
  (function(C) {
    C.ElementSymbol = t.Type.Value("Structure", "ElementSymbol"), C.AtomName = t.Type.Value("Structure", "AtomName"), C.BondFlag = t.Type.OneOf("Structure", "BondFlag", t.Type.Str, ["covalent", "metallic", "ion", "hydrogen", "sulfide", "computed", "aromatic"]), C.BondFlags = n.Types.Flags(C.BondFlag, "BondFlags"), C.SecondaryStructureFlag = t.Type.OneOf("Structure", "SecondaryStructureFlag", t.Type.Str, ["alpha", "beta", "3-10", "pi", "sheet", "strand", "helix", "turn", "none"]), C.SecondaryStructureFlags = n.Types.Flags(C.SecondaryStructureFlag, "SecondaryStructureFlag"), C.RingFingerprint = t.Type.Value("Structure", "RingFingerprint"), C.EntityType = t.Type.OneOf("Structure", "EntityType", t.Type.Str, ["polymer", "non-polymer", "water", "branched"]), C.EntitySubtype = t.Type.OneOf("Structure", "EntitySubtype", t.Type.Str, ["other", "polypeptide(D)", "polypeptide(L)", "polydeoxyribonucleotide", "polyribonucleotide", "polydeoxyribonucleotide/polyribonucleotide hybrid", "cyclic-pseudo-peptide", "peptide nucleic acid", "oligosaccharide"]), C.ObjectPrimitive = t.Type.OneOf("Structure", "ObjectPrimitive", t.Type.Str, ["atomistic", "sphere", "gaussian", "other"]), C.ResidueId = t.Type.Value("Structure", "ResidueId"), C.ElementSet = t.Type.Value("Structure", "ElementSet"), C.ElementSelection = t.Type.Value("Structure", "ElementSelection"), C.ElementReference = t.Type.Value("Structure", "ElementReference"), C.ElementSelectionQuery = n.Types.Fn(C.ElementSelection, "ElementSelectionQuery");
  })(o = e.Types || (e.Types = {}));
  var c = {
    "@header": "Types",
    elementSymbol: (0, i.symbol)(a.Arguments.Dictionary({ 0: (0, a.Argument)(t.Type.Str) }), o.ElementSymbol, "Create element symbol representation from a string value."),
    atomName: (0, i.symbol)(a.Arguments.Dictionary({ 0: (0, a.Argument)(t.Type.AnyValue) }), o.AtomName, "Convert a value to an atom name."),
    entityType: (0, i.symbol)(a.Arguments.Dictionary({ 0: (0, a.Argument)(o.EntityType) }), o.EntityType, "Create normalized representation of entity type: ".concat(t.Type.oneOfValues(o.EntityType).join(", "), ".")),
    bondFlags: (0, i.symbol)(a.Arguments.List(o.BondFlag), o.BondFlags, "Create bond flags representation from a list of strings. Allowed flags: ".concat(t.Type.oneOfValues(o.BondFlag).join(", "), ".")),
    ringFingerprint: (0, i.symbol)(a.Arguments.List(o.ElementSymbol, { nonEmpty: !0 }), o.RingFingerprint, "Create ring fingerprint from the supplied atom element list."),
    secondaryStructureFlags: (0, i.symbol)(a.Arguments.List(o.SecondaryStructureFlag), o.SecondaryStructureFlags, "Create secondary structure flags representation from a list of strings. Allowed flags: ".concat(t.Type.oneOfValues(o.SecondaryStructureFlag).join(", "), ".")),
    authResidueId: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(t.Type.Str, { description: "auth_asym_id" }),
      1: (0, a.Argument)(t.Type.Num, { description: "auth_seq_id" }),
      2: (0, a.Argument)(t.Type.Str, { description: "pdbx_PDB_ins_code", isOptional: !0 })
    }), o.ResidueId, 'Residue identifier based on "auth_" annotation.'),
    labelResidueId: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(t.Type.Str, { description: "label_entity_id" }),
      1: (0, a.Argument)(t.Type.Str, { description: "label_asym_id" }),
      2: (0, a.Argument)(t.Type.Num, { description: "label_seq_id" }),
      3: (0, a.Argument)(t.Type.Str, { description: "pdbx_PDB_ins_code", isOptional: !0 })
    }), o.ResidueId, `Residue identifier based on mmCIF's "label_" annotation.`)
  }, s = {
    "@header": "Iteration Slots",
    element: (0, i.symbol)(a.Arguments.None, o.ElementReference, "A reference to the current element."),
    elementSetReduce: (0, i.symbol)(a.Arguments.None, t.Type.Variable("a", t.Type.AnyValue, !0), "Current value of the element set reducer.")
  }, u = {
    "@header": "Generators",
    all: (0, i.symbol)(a.Arguments.None, o.ElementSelectionQuery, "The entire structure."),
    atomGroups: (0, i.symbol)(a.Arguments.Dictionary({
      "entity-test": (0, a.Argument)(t.Type.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom of every entity" }),
      "chain-test": (0, a.Argument)(t.Type.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom of every chain" }),
      "residue-test": (0, a.Argument)(t.Type.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom every residue" }),
      "atom-test": (0, a.Argument)(t.Type.Bool, { isOptional: !0, defaultValue: !0 }),
      "group-by": (0, a.Argument)(t.Type.Any, { isOptional: !0, defaultValue: "atom-key", description: "Group atoms to sets based on this property. Default: each atom has its own set" })
    }), o.ElementSelectionQuery, "Return all atoms for which the tests are satisfied, grouped into sets."),
    bondedAtomicPairs: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(t.Type.Bool, { isOptional: !0, defaultValue: "true for covalent bonds", description: "Test each bond with this predicate. Each bond is visited twice with swapped atom order." })
      // TODO: shoud we support this or just use queryEach to get similar behavior
      // 'group-by': Argument(Type.Any, { isOptional: true, defaultValue: ``, description: 'Group the bonds using the privided value' }),
    }), o.ElementSelectionQuery, "Return all pairs of atoms for which the test is satisfied."),
    rings: (0, i.symbol)(a.Arguments.Dictionary({
      fingerprint: (0, a.Argument)(o.RingFingerprint, { isOptional: !0 }),
      "only-aromatic": (0, a.Argument)(t.Type.Bool, { isOptional: !0, defaultValue: !1 })
    }), o.ElementSelectionQuery, "Return all rings or those with the specified fingerprint and/or only aromatic rings."),
    queryInSelection: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery),
      query: (0, a.Argument)(o.ElementSelectionQuery),
      "in-complement": (0, a.Argument)(t.Type.Bool, { isOptional: !0, defaultValue: !1 })
    }), o.ElementSelectionQuery, "Executes query only on atoms that are in the source selection."),
    empty: (0, i.symbol)(a.Arguments.None, o.ElementSelectionQuery, "Nada.")
  }, l = {
    "@header": "Selection Modifications",
    queryEach: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery),
      query: (0, a.Argument)(o.ElementSelectionQuery)
    }), o.ElementSelectionQuery, "Query every atom set in the input selection separately."),
    intersectBy: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery),
      by: (0, a.Argument)(o.ElementSelectionQuery)
    }), o.ElementSelectionQuery, "Intersect each atom set from the first sequence from atoms in the second one."),
    exceptBy: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery),
      by: (0, a.Argument)(o.ElementSelectionQuery)
    }), o.ElementSelectionQuery, "Remove all atoms from 'selection' that occur in 'by'."),
    unionBy: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery),
      by: (0, a.Argument)(o.ElementSelectionQuery)
    }), o.ElementSelectionQuery, "For each atom set A in the orginal sequence, combine all atoms sets in the target selection that intersect with A."),
    union: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery)
    }), o.ElementSelectionQuery, "Collects all atom sets in the sequence into a single atom set."),
    cluster: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery),
      "min-distance": (0, a.Argument)(t.Type.Num, { isOptional: !0, defaultValue: 0 }),
      "max-distance": (0, a.Argument)(t.Type.Num),
      "min-size": (0, a.Argument)(t.Type.Num, { description: "Minimal number of sets to merge, must be at least 2", isOptional: !0, defaultValue: 2 }),
      "max-size": (0, a.Argument)(t.Type.Num, { description: "Maximal number of sets to merge, if not set, no limit", isOptional: !0 })
    }), o.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: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery),
      radius: (0, a.Argument)(t.Type.Num),
      "atom-radius": (0, a.Argument)(t.Type.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": (0, a.Argument)(t.Type.Bool, { isOptional: !0 })
    }), o.ElementSelectionQuery, "For each atom set in the selection, include all surrouding atoms/residues that are within the specified radius."),
    surroundingLigands: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery),
      radius: (0, a.Argument)(t.Type.Num),
      "include-water": (0, a.Argument)(t.Type.Bool, { isOptional: !0, defaultValue: !0 })
    }), o.ElementSelectionQuery, "Find all ligands components around the source query."),
    includeConnected: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery),
      "bond-test": (0, a.Argument)(t.Type.Bool, { isOptional: !0, defaultValue: "true for covalent bonds" }),
      "layer-count": (0, a.Argument)(t.Type.Num, { isOptional: !0, defaultValue: 1, description: "Number of bonded layers to include." }),
      "fixed-point": (0, a.Argument)(t.Type.Bool, { isOptional: !0, defaultValue: !1, description: "Continue adding layers as long as new connections exist." }),
      "as-whole-residues": (0, a.Argument)(t.Type.Bool, { isOptional: !0 })
    }), o.ElementSelectionQuery, "Pick all atom sets that are connected to the target."),
    wholeResidues: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery)
    }), o.ElementSelectionQuery, "Expand the selection to whole residues."),
    expandProperty: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery),
      property: (0, a.Argument)(t.Type.AnyValue)
    }), o.ElementSelectionQuery, "To each atom set in the selection, add all atoms that have the same property value that was already present in the set.")
  }, f = {
    "@header": "Selection Filters",
    pick: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery),
      test: (0, a.Argument)(t.Type.Bool)
    }), o.ElementSelectionQuery, "Pick all atom sets that satisfy the test."),
    first: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery)
    }), o.ElementSelectionQuery, "Take the 1st atom set in the sequence."),
    withSameAtomProperties: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery),
      source: (0, a.Argument)(o.ElementSelectionQuery),
      property: (0, a.Argument)(t.Type.Any)
    }), o.ElementSelectionQuery, "Pick all atom sets for which the set of given atom properties is a subset of the source properties."),
    intersectedBy: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery),
      by: (0, a.Argument)(o.ElementSelectionQuery)
    }), o.ElementSelectionQuery, "Pick all atom sets that have non-zero intersection with the target."),
    within: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery),
      target: (0, a.Argument)(o.ElementSelectionQuery),
      "min-radius": (0, a.Argument)(t.Type.Num, { isOptional: !0, defaultValue: 0 }),
      "max-radius": (0, a.Argument)(t.Type.Num),
      "atom-radius": (0, a.Argument)(t.Type.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: (0, a.Argument)(t.Type.Bool, { isOptional: !0, defaultValue: !1, description: "If true, pick only atom sets that are further than the specified radius." })
    }), o.ElementSelectionQuery, "Pick all atom sets from selection that have any atom within the radius of any atom from target."),
    isConnectedTo: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery),
      target: (0, a.Argument)(o.ElementSelectionQuery),
      "bond-test": (0, a.Argument)(t.Type.Bool, { isOptional: !0, defaultValue: "true for covalent bonds" }),
      disjunct: (0, a.Argument)(t.Type.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: (0, a.Argument)(t.Type.Bool, { isOptional: !0, defaultValue: !1, description: "If true, return atom sets that are not connected." })
    }), o.ElementSelectionQuery, "Pick all atom sets that are connected to the target.")
  }, d = {
    "@header": "Selection Combinators",
    intersect: (0, i.symbol)(a.Arguments.List(o.ElementSelectionQuery), o.ElementSelectionQuery, "Return all unique atom sets that appear in all of the source selections."),
    merge: (0, i.symbol)(a.Arguments.List(o.ElementSelectionQuery), o.ElementSelectionQuery, "Merges multiple selections into a single one. Only unique atom sets are kept."),
    distanceCluster: (0, i.symbol)(a.Arguments.Dictionary({
      matrix: (0, a.Argument)(n.Types.List(n.Types.List(t.Type.Num)), { description: "Distance matrix, represented as list of rows (num[][])). Lower triangle is min distance, upper triangle is max distance." }),
      selections: (0, a.Argument)(n.Types.List(o.ElementSelectionQuery), { description: "A list of held selections." })
    }), o.ElementSelectionQuery, "Pick combinations of atom sets from the source sequences that are mutually within distances specified by a matrix.")
  }, m = {
    "@header": "Atom Sets",
    atomCount: (0, i.symbol)(a.Arguments.None, t.Type.Num),
    countQuery: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(o.ElementSelectionQuery)
    }), t.Type.Num, "Counts the number of occurences of a specific query inside the current atom set."),
    reduce: (0, i.symbol)(a.Arguments.Dictionary({
      initial: (0, a.Argument)(t.Type.Variable("a", t.Type.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: (0, a.Argument)(t.Type.Variable("a", t.Type.AnyValue, !0), { description: "Expression executed for each atom in the set" })
    }), t.Type.Variable("a", t.Type.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: (0, i.symbol)(a.Arguments.Dictionary({
      0: (0, a.Argument)(n.Types.ConstrainedVar)
    }), n.Types.Set(n.Types.ConstrainedVar), "Returns a set with all values of the given property in the current atom set.")
  }, p = {
    "@header": "Atom Properties",
    core: {
      "@header": "Core Properties",
      elementSymbol: h(o.ElementSymbol),
      vdw: h(t.Type.Num, "Van der Waals radius"),
      mass: h(t.Type.Num, "Atomic weight"),
      atomicNumber: h(t.Type.Num, "Atomic number"),
      x: h(t.Type.Num, "Cartesian X coordinate"),
      y: h(t.Type.Num, "Cartesian Y coordinate"),
      z: h(t.Type.Num, "Cartesian Z coordinate"),
      atomKey: h(t.Type.AnyValue, "Unique value for each atom. Main use case is grouping of atoms."),
      bondCount: (0, i.symbol)(a.Arguments.Dictionary({
        0: (0, a.Argument)(o.ElementReference, { isOptional: !0, defaultValue: "slot.current-atom" }),
        flags: (0, a.Argument)(o.BondFlags, { isOptional: !0, defaultValue: "covalent" })
      }), t.Type.Num, "Number of bonds (by default only covalent bonds are counted)."),
      sourceIndex: h(t.Type.Num, "Index of the atom/element in the input file."),
      operatorName: h(t.Type.Str, "Name of the symmetry operator applied to this element."),
      modelIndex: h(t.Type.Num, "Index of the model in the input file."),
      modelLabel: h(t.Type.Str, "Label/header of the model in the input file.")
    },
    topology: {
      connectedComponentKey: h(t.Type.AnyValue, "Unique value for each connected component.")
    },
    macromolecular: {
      "@header": "Macromolecular Properties (derived from the mmCIF format)",
      authResidueId: h(o.ResidueId, "type.auth-residue-id symbol executed on current atom's residue"),
      labelResidueId: h(o.ResidueId, "type.label-residue-id symbol executed on current atom's residue"),
      residueKey: h(t.Type.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: h(t.Type.AnyValue, "Unique value for each tuple ``(label_entity_id, auth_asym_id)``, main use case is grouping of atoms"),
      entityKey: h(t.Type.AnyValue, "Unique value for each tuple ``label_entity_id``, main use case is grouping of atoms"),
      isHet: h(t.Type.Bool, "Equivalent to atom_site.group_PDB !== ATOM"),
      id: h(t.Type.Num, "_atom_site.id"),
      label_atom_id: h(o.AtomName),
      label_alt_id: h(t.Type.Str),
      label_comp_id: h(t.Type.Str),
      label_asym_id: h(t.Type.Str),
      label_entity_id: h(t.Type.Str),
      label_seq_id: h(t.Type.Num),
      auth_atom_id: h(o.AtomName),
      auth_comp_id: h(t.Type.Str),
      auth_asym_id: h(t.Type.Str),
      auth_seq_id: h(t.Type.Num),
      pdbx_PDB_ins_code: h(t.Type.Str),
      pdbx_formal_charge: h(t.Type.Num),
      occupancy: h(t.Type.Num),
      B_iso_or_equiv: h(t.Type.Num),
      entityType: h(o.EntityType, "Type of the entity as defined in mmCIF (polymer, non-polymer, branched, water)"),
      entitySubtype: h(o.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: h(t.Type.Str, "The PRD ID of the entity."),
      entityDescription: h(n.Types.List(t.Type.Str)),
      objectPrimitive: h(o.ObjectPrimitive, "Type of the primitive object used to model this segment as defined in mmCIF/IHM (atomistic, sphere, gaussian, other)"),
      secondaryStructureKey: h(t.Type.AnyValue, "Unique value for each secondary structure element."),
      secondaryStructureFlags: h(o.SecondaryStructureFlags),
      isModified: h(t.Type.Bool, "True if the atom belongs to modification of a standard residue."),
      modifiedParentName: h(t.Type.Str, "'3-letter' code of the modifed parent residue."),
      isNonStandard: h(t.Type.Bool, "True if this is a non-standard residue."),
      chemCompType: h(t.Type.Str, "Type of the chemical component as defined in mmCIF.")
    }
  }, v = {
    "@header": "Bond Properties",
    flags: y(o.BondFlags),
    order: y(t.Type.Num),
    length: y(t.Type.Num),
    atomA: y(o.ElementReference),
    atomB: y(o.ElementReference)
  };
  function h(C, S) {
    return (0, i.symbol)(a.Arguments.Dictionary({ 0: (0, a.Argument)(o.ElementReference, { isOptional: !0, defaultValue: "slot.current-atom" }) }), C, S);
  }
  function y(C, S) {
    return (0, i.symbol)(a.Arguments.None, C, S);
  }
  e.structureQuery = {
    "@header": "Structure Queries",
    type: c,
    slot: s,
    generator: u,
    modifier: l,
    filter: f,
    combinator: d,
    atomSet: m,
    atomProperty: p,
    bondProperty: v
  };
})(vC);
var pC = {};
Object.defineProperty(pC, "__esModule", { value: !0 });
pC.internal = void 0;
var hae = Te, Ch = D0, NI = (0, hae.__importStar)(vC), hf = Cp, Yx = rs, gae = {
  "@header": "Generators",
  bundleElement: (0, Yx.symbol)(hf.Arguments.Dictionary({
    // TODO: should we use more universal unit keys? (i.e. based on chain and "operator name")
    groupedUnits: (0, hf.Argument)(Ch.Type.Any),
    set: (0, hf.Argument)(Ch.Type.Any),
    ranges: (0, hf.Argument)(Ch.Type.Any)
    // SortedArray<UnitIndex>
  }), Ch.Type.Any),
  bundle: (0, Yx.symbol)(hf.Arguments.Dictionary({
    elements: (0, hf.Argument)(Ch.Type.Any)
    // BundleElement[]
  }), NI.Types.ElementSelectionQuery, "A selection with single structure containing represented by the bundle."),
  // Use with caution as this is not "state saveable"
  // This query should never be used in any State Transform!
  current: (0, Yx.symbol)(hf.Arguments.None, NI.Types.ElementSelectionQuery, "Current selection provided by the query context. Avoid using this in State Transforms.")
};
pC.internal = {
  "@header": "Internal Queries",
  generator: gae
};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.MolScriptSymbolTable = e.SymbolMap = e.SymbolList = void 0;
  var r = vE, t = vC, n = pC, a = rs, i = { core: r.core, structureQuery: t.structureQuery, internal: n.internal };
  e.MolScriptSymbolTable = i, (0, a.normalizeTable)(i), e.SymbolList = (0, a.symbolList)(i), e.SymbolMap = function() {
    for (var o = /* @__PURE__ */ Object.create(null), c = 0, s = e.SymbolList; c < s.length; c++) {
      var u = s[c];
      o[u.id] = u;
    }
    return o;
  }();
})(mC);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.MolScriptBuilder = void 0;
  var r = mC;
  (function(t) {
    t.core = r.MolScriptSymbolTable.core, t.struct = r.MolScriptSymbolTable.structureQuery, t.internal = r.MolScriptSymbolTable.internal;
    function n(b) {
      return t.struct.type.atomName([b]);
    }
    t.atomName = n;
    function a(b) {
      return t.struct.type.elementSymbol([b]);
    }
    t.es = a;
    function i() {
      for (var b = [], g = 0; g < arguments.length; g++)
        b[g] = arguments[g];
      return t.core.type.list(b);
    }
    t.list = i;
    function o() {
      for (var b = [], g = 0; g < arguments.length; g++)
        b[g] = arguments[g];
      return t.core.type.set(b);
    }
    t.set = o;
    function c(b, g) {
      return t.core.type.regex([b, g]);
    }
    t.re = c;
    function s(b) {
      return t.core.ctrl.fn([b]);
    }
    t.fn = s;
    function u(b) {
      return t.core.ctrl.eval([b]);
    }
    t.evaluate = u;
    var l = t.struct.atomProperty.core, f = t.struct.atomProperty.macromolecular, d = t.struct.atomProperty.topology;
    function m(b) {
      return l[b]();
    }
    t.acp = m;
    function p(b) {
      return d[b]();
    }
    t.atp = p;
    function v(b) {
      return f[b]();
    }
    t.ammp = v;
    var h = t.struct.atomSet.propertySet;
    function y(b) {
      return h([m(b)]);
    }
    t.acpSet = y;
    function C(b) {
      return h([p(b)]);
    }
    t.atpSet = C;
    function S(b) {
      return h([v(b)]);
    }
    t.ammpSet = S;
  })(e.MolScriptBuilder || (e.MolScriptBuilder = {}));
})(gs);
var lm = {}, Ah = {}, Qx = {}, Gr = {}, ly = {}, hC = {};
Object.defineProperty(hC, "__esModule", { value: !0 });
hC.SaccharideNames = void 0;
hC.SaccharideNames = /* @__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"]);
(function(e) {
  var r, t;
  Object.defineProperty(e, "__esModule", { value: !0 }), e.SaccharideCompIdMap = e.MonosaccharidesColorTable = e.SaccharidesSnfgMap = e.UnknownSaccharideComponent = e.getSaccharideShape = e.getSaccharideName = e.SaccharideColors = void 0;
  var n = Tr(), a = hC;
  e.SaccharideColors = (0, n.ColorMap)({
    Blue: 37052,
    Green: 42577,
    Yellow: 16765952,
    Orange: 16021792,
    Pink: 16162465,
    Purple: 10830745,
    LightBlue: 9424105,
    Brown: 10582605,
    Red: 15539236,
    Secondary: 15854817
  });
  var i = (r = {}, r[
    0
    /* Hexose */
  ] = "Hexose", r[
    1
    /* HexNAc */
  ] = "HexNAc", r[
    2
    /* Hexosamine */
  ] = "Hexosamine", r[
    3
    /* Hexuronate */
  ] = "Hexuronate", r[
    4
    /* Deoxyhexose */
  ] = "Deoxyhexose", r[
    5
    /* DeoxyhexNAc */
  ] = "DeoxyhexNAc", r[
    6
    /* DiDeoxyhexose */
  ] = "Di-deoxyhexose", r[
    7
    /* Pentose */
  ] = "Pentose", r[
    8
    /* Deoxynonulosonate */
  ] = "Deoxynonulosonate", r[
    9
    /* DiDeoxynonulosonate */
  ] = "Di-deoxynonulosonate", r[
    10
    /* Unknown */
  ] = "Unknown", r[
    11
    /* Assigned */
  ] = "Assigned", r);
  function o(d) {
    return i[d];
  }
  e.getSaccharideName = o;
  var c = (t = {}, t[
    0
    /* Hexose */
  ] = 0, t[
    1
    /* HexNAc */
  ] = 1, t[
    2
    /* Hexosamine */
  ] = 2, t[
    3
    /* Hexuronate */
  ] = 3, t[
    4
    /* Deoxyhexose */
  ] = 4, t[
    5
    /* DeoxyhexNAc */
  ] = 5, t[
    6
    /* DiDeoxyhexose */
  ] = 6, t[
    7
    /* Pentose */
  ] = 7, t[
    8
    /* Deoxynonulosonate */
  ] = 8, t[
    9
    /* DiDeoxynonulosonate */
  ] = 9, t[
    10
    /* Unknown */
  ] = 10, t[
    11
    /* Assigned */
  ] = 11, t);
  function s(d, m) {
    return d === 10 ? m === 4 ? 12 : m === 5 ? 13 : m === 6 ? 14 : m === 7 ? 15 : 10 : c[d];
  }
  e.getSaccharideShape = s, e.UnknownSaccharideComponent = {
    abbr: "Unk",
    name: "Unknown",
    color: e.SaccharideColors.Secondary,
    type: 10
    /* Unknown */
  };
  var u = [
    {
      abbr: "Glc",
      name: "Glucose",
      color: e.SaccharideColors.Blue,
      type: 0
      /* Hexose */
    },
    {
      abbr: "Man",
      name: "Mannose",
      color: e.SaccharideColors.Green,
      type: 0
      /* Hexose */
    },
    {
      abbr: "Gal",
      name: "Galactose",
      color: e.SaccharideColors.Yellow,
      type: 0
      /* Hexose */
    },
    {
      abbr: "Gul",
      name: "Gulose",
      color: e.SaccharideColors.Orange,
      type: 0
      /* Hexose */
    },
    {
      abbr: "Alt",
      name: "Altrose",
      color: e.SaccharideColors.Pink,
      type: 0
      /* Hexose */
    },
    {
      abbr: "All",
      name: "Allose",
      color: e.SaccharideColors.Purple,
      type: 0
      /* Hexose */
    },
    {
      abbr: "Tal",
      name: "Talose",
      color: e.SaccharideColors.LightBlue,
      type: 0
      /* Hexose */
    },
    {
      abbr: "Ido",
      name: "Idose",
      color: e.SaccharideColors.Brown,
      type: 0
      /* Hexose */
    },
    {
      abbr: "GlcNAc",
      name: "N-Acetyl Glucosamine",
      color: e.SaccharideColors.Blue,
      type: 1
      /* HexNAc */
    },
    {
      abbr: "ManNAc",
      name: "N-Acetyl Mannosamine",
      color: e.SaccharideColors.Green,
      type: 1
      /* HexNAc */
    },
    {
      abbr: "GalNAc",
      name: "N-Acetyl Galactosamine",
      color: e.SaccharideColors.Yellow,
      type: 1
      /* HexNAc */
    },
    {
      abbr: "GulNAc",
      name: "N-Acetyl Gulosamine",
      color: e.SaccharideColors.Orange,
      type: 1
      /* HexNAc */
    },
    {
      abbr: "AltNAc",
      name: "N-Acetyl Altrosamine",
      color: e.SaccharideColors.Pink,
      type: 1
      /* HexNAc */
    },
    {
      abbr: "AllNAc",
      name: "N-Acetyl Allosamine",
      color: e.SaccharideColors.Purple,
      type: 1
      /* HexNAc */
    },
    {
      abbr: "TalNAc",
      name: "N-Acetyl Talosamine",
      color: e.SaccharideColors.LightBlue,
      type: 1
      /* HexNAc */
    },
    {
      abbr: "IdoNAc",
      name: "N-Acetyl Idosamine",
      color: e.SaccharideColors.Brown,
      type: 1
      /* HexNAc */
    },
    {
      abbr: "GlcN",
      name: "Glucosamine",
      color: e.SaccharideColors.Blue,
      type: 2
      /* Hexosamine */
    },
    {
      abbr: "ManN",
      name: "Mannosamine",
      color: e.SaccharideColors.Green,
      type: 2
      /* Hexosamine */
    },
    {
      abbr: "GalN",
      name: "Galactosamine",
      color: e.SaccharideColors.Yellow,
      type: 2
      /* Hexosamine */
    },
    {
      abbr: "GulN",
      name: "Gulosamine",
      color: e.SaccharideColors.Orange,
      type: 2
      /* Hexosamine */
    },
    {
      abbr: "AltN",
      name: "Altrosamine",
      color: e.SaccharideColors.Pink,
      type: 2
      /* Hexosamine */
    },
    {
      abbr: "AllN",
      name: "Allosamine",
      color: e.SaccharideColors.Purple,
      type: 2
      /* Hexosamine */
    },
    {
      abbr: "TalN",
      name: "Talosamine",
      color: e.SaccharideColors.LightBlue,
      type: 2
      /* Hexosamine */
    },
    {
      abbr: "IdoN",
      name: "Idosamine",
      color: e.SaccharideColors.Brown,
      type: 2
      /* Hexosamine */
    },
    {
      abbr: "GlcA",
      name: "Glucuronic Acid",
      color: e.SaccharideColors.Blue,
      type: 3
      /* Hexuronate */
    },
    {
      abbr: "ManA",
      name: "Mannuronic Acid",
      color: e.SaccharideColors.Green,
      type: 3
      /* Hexuronate */
    },
    {
      abbr: "GalA",
      name: "Galacturonic Acid",
      color: e.SaccharideColors.Yellow,
      type: 3
      /* Hexuronate */
    },
    {
      abbr: "GulA",
      name: "Guluronic Acid",
      color: e.SaccharideColors.Orange,
      type: 3
      /* Hexuronate */
    },
    {
      abbr: "AltA",
      name: "Altruronic Acid",
      color: e.SaccharideColors.Pink,
      type: 3
      /* Hexuronate */
    },
    {
      abbr: "AllA",
      name: "Alluronic Acid",
      color: e.SaccharideColors.Purple,
      type: 3
      /* Hexuronate */
    },
    {
      abbr: "TalA",
      name: "Taluronic Acid",
      color: e.SaccharideColors.LightBlue,
      type: 3
      /* Hexuronate */
    },
    {
      abbr: "IdoA",
      name: "Iduronic Acid",
      color: e.SaccharideColors.Brown,
      type: 3
      /* Hexuronate */
    },
    {
      abbr: "Qui",
      name: "Quinovose",
      color: e.SaccharideColors.Blue,
      type: 4
      /* Deoxyhexose */
    },
    {
      abbr: "Rha",
      name: "Rhamnose",
      color: e.SaccharideColors.Green,
      type: 4
      /* Deoxyhexose */
    },
    {
      abbr: "6dGul",
      name: "6-Deoxy Gulose",
      color: e.SaccharideColors.Orange,
      type: 4
      /* Deoxyhexose */
    },
    {
      abbr: "6dAlt",
      name: "6-Deoxy Altrose",
      color: e.SaccharideColors.Pink,
      type: 4
      /* Deoxyhexose */
    },
    {
      abbr: "6dTal",
      name: "6-Deoxy Talose",
      color: e.SaccharideColors.LightBlue,
      type: 4
      /* Deoxyhexose */
    },
    {
      abbr: "Fuc",
      name: "Fucose",
      color: e.SaccharideColors.Red,
      type: 4
      /* Deoxyhexose */
    },
    {
      abbr: "QuiNAc",
      name: "N-Acetyl Quinovosamine",
      color: e.SaccharideColors.Blue,
      type: 5
      /* DeoxyhexNAc */
    },
    {
      abbr: "RhaNAc",
      name: "N-Acetyl Rhamnosamine",
      color: e.SaccharideColors.Green,
      type: 5
      /* DeoxyhexNAc */
    },
    {
      abbr: "6dAltNAc",
      name: "N-Acetyl 6-Deoxy Altrosamine",
      color: e.SaccharideColors.Pink,
      type: 5
      /* DeoxyhexNAc */
    },
    {
      abbr: "6dTalNAc",
      name: "N-Acetyl 6-Deoxy Talosamine",
      color: e.SaccharideColors.LightBlue,
      type: 5
      /* DeoxyhexNAc */
    },
    {
      abbr: "FucNAc",
      name: "N-Acetyl Fucosamine",
      color: e.SaccharideColors.Red,
      type: 5
      /* DeoxyhexNAc */
    },
    {
      abbr: "Oli",
      name: "Olivose",
      color: e.SaccharideColors.Blue,
      type: 6
      /* DiDeoxyhexose */
    },
    {
      abbr: "Tyv",
      name: "Tyvelose",
      color: e.SaccharideColors.Green,
      type: 6
      /* DiDeoxyhexose */
    },
    {
      abbr: "Abe",
      name: "Abequose",
      color: e.SaccharideColors.Orange,
      type: 6
      /* DiDeoxyhexose */
    },
    {
      abbr: "Par",
      name: "Paratose",
      color: e.SaccharideColors.Pink,
      type: 6
      /* DiDeoxyhexose */
    },
    {
      abbr: "Dig",
      name: "Digitoxose",
      color: e.SaccharideColors.Purple,
      type: 6
      /* DiDeoxyhexose */
    },
    {
      abbr: "Col",
      name: "Colitose",
      color: e.SaccharideColors.LightBlue,
      type: 6
      /* DiDeoxyhexose */
    },
    {
      abbr: "Ara",
      name: "Arabinose",
      color: e.SaccharideColors.Green,
      type: 7
      /* Pentose */
    },
    {
      abbr: "Lyx",
      name: "Lyxose",
      color: e.SaccharideColors.Yellow,
      type: 7
      /* Pentose */
    },
    {
      abbr: "Xyl",
      name: "Xylose",
      color: e.SaccharideColors.Orange,
      type: 7
      /* Pentose */
    },
    {
      abbr: "Rib",
      name: "Ribose",
      color: e.SaccharideColors.Pink,
      type: 7
      /* Pentose */
    },
    {
      abbr: "Kdn",
      name: "Keto-Deoxy Nonulonic Acid",
      color: e.SaccharideColors.Green,
      type: 8
      /* Deoxynonulosonate */
    },
    {
      abbr: "Neu5Ac",
      name: "N-Acetyl Neuraminic Acid",
      color: e.SaccharideColors.Purple,
      type: 8
      /* Deoxynonulosonate */
    },
    {
      abbr: "Neu5Gc",
      name: "N-Glycolyl Neuraminic Acid",
      color: e.SaccharideColors.LightBlue,
      type: 8
      /* Deoxynonulosonate */
    },
    {
      abbr: "Neu",
      name: "Neuraminic Acid",
      color: e.SaccharideColors.Brown,
      type: 8
      /* Deoxynonulosonate */
    },
    {
      abbr: "Sia",
      name: "Sialic acid",
      color: e.SaccharideColors.Red,
      type: 8
      /* Deoxynonulosonate */
    },
    {
      abbr: "Pse",
      name: "Pseudaminic Acid",
      color: e.SaccharideColors.Green,
      type: 9
      /* DiDeoxynonulosonate */
    },
    {
      abbr: "Leg",
      name: "Legionaminic Acid",
      color: e.SaccharideColors.Yellow,
      type: 9
      /* DiDeoxynonulosonate */
    },
    {
      abbr: "Aci",
      name: "Acinetaminic Acid",
      color: e.SaccharideColors.Pink,
      type: 9
      /* DiDeoxynonulosonate */
    },
    {
      abbr: "4eLeg",
      name: "4-Epilegionaminic Acid",
      color: e.SaccharideColors.LightBlue,
      type: 9
      /* DiDeoxynonulosonate */
    },
    {
      abbr: "Bac",
      name: "Bacillosamine",
      color: e.SaccharideColors.Blue,
      type: 10
      /* Unknown */
    },
    {
      abbr: "LDmanHep",
      name: "L-Glycero-D-Manno Heptose",
      color: e.SaccharideColors.Green,
      type: 10
      /* Unknown */
    },
    {
      abbr: "Kdo",
      name: "Keto-Deoxy Octulonic Acid",
      color: e.SaccharideColors.Yellow,
      type: 10
      /* Unknown */
    },
    {
      abbr: "Dha",
      name: "3-Deoxy Lyxo-Heptulosaric Acid",
      color: e.SaccharideColors.Orange,
      type: 10
      /* Unknown */
    },
    {
      abbr: "DDmanHep",
      name: "D-Glycero-D-Manno-Heptose",
      color: e.SaccharideColors.Pink,
      type: 10
      /* Unknown */
    },
    {
      abbr: "MurNAc",
      name: "N-Acetyl Muramic Acid",
      color: e.SaccharideColors.Purple,
      type: 10
      /* Unknown */
    },
    {
      abbr: "MurNGc",
      name: "N-Glycolyl Muramic Acid",
      color: e.SaccharideColors.LightBlue,
      type: 10
      /* Unknown */
    },
    {
      abbr: "Mur",
      name: "Muramic Acid",
      color: e.SaccharideColors.Brown,
      type: 10
      /* Unknown */
    },
    {
      abbr: "Api",
      name: "Apicose",
      color: e.SaccharideColors.Green,
      type: 11
      /* Assigned */
    },
    {
      abbr: "Fru",
      name: "Fructose",
      color: e.SaccharideColors.Green,
      type: 11
      /* Assigned */
    },
    {
      abbr: "Tag",
      name: "Tagatose",
      color: e.SaccharideColors.Yellow,
      type: 11
      /* Assigned */
    },
    {
      abbr: "Sor",
      name: "Sorbose",
      color: e.SaccharideColors.Orange,
      type: 11
      /* Assigned */
    },
    {
      abbr: "Psi",
      name: "Psicose",
      color: e.SaccharideColors.Pink,
      type: 11
      /* Assigned */
    }
  ];
  e.SaccharidesSnfgMap = function() {
    for (var d = /* @__PURE__ */ new Map(), m = 0, p = u.length; m < p; ++m) {
      var v = u[m];
      d.set(v.abbr, v);
    }
    return d;
  }(), e.MonosaccharidesColorTable = [
    ["Glc-family", e.SaccharideColors.Blue],
    ["Man-family", e.SaccharideColors.Green],
    ["Gal-family", e.SaccharideColors.Yellow],
    ["Gul-family", e.SaccharideColors.Orange],
    ["Alt-family", e.SaccharideColors.Pink],
    ["All-family", e.SaccharideColors.Purple],
    ["Tal-family", e.SaccharideColors.LightBlue],
    ["Ido-family", e.SaccharideColors.Brown],
    ["Fuc-family", e.SaccharideColors.Red],
    ["Generic/Unknown/Secondary", e.SaccharideColors.Secondary]
  ];
  var l = {
    // Hexose
    Glc: [
      "GLC",
      "BGC",
      "Z8T",
      "TRE",
      "MLR"
      // tri-saccharide but homomer
    ],
    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"],
    // HexNAc
    GlcNAc: ["NDG", "NAG", "NGZ"],
    ManNAc: ["BM3", "BM7"],
    GalNAc: ["A2G", "NGA", "YYQ"],
    GulNAc: ["LXB"],
    AltNAc: [],
    AllNAc: ["NAA"],
    TalNAc: [],
    IdoNAc: ["LXZ", "HSQ"],
    // Hexosamine
    GlcN: ["PA1", "GCS"],
    ManN: ["95Z"],
    GalN: ["X6X", "1GN"],
    GulN: [],
    AltN: [],
    AllN: [],
    TalN: [],
    IdoN: [],
    // Hexuronate
    GlcA: ["GCU", "BDP"],
    ManA: ["MAV", "BEM"],
    GalA: ["ADA", "GTR", "GTK"],
    GulA: ["LGU"],
    AltA: [],
    AllA: [],
    TalA: ["X1X", "X0X"],
    IdoA: ["IDR"],
    // Deoxyhexose
    Qui: ["G6D", "YYK"],
    Rha: ["RAM", "RM4", "XXR"],
    "6dGul": ["66O"],
    "6dAlt": [],
    "6dTal": [],
    Fuc: ["FUC", "FUL", "FCA", "FCB", "GYE"],
    // DeoxyhexNAc
    QuiNAc: ["Z9W"],
    RhaNAc: [],
    "6dAltNAc": [],
    "6dTalNAc": [],
    FucNAc: ["49T"],
    // Di-deoxyhexose
    Oli: ["DDA", "RAE", "Z5J"],
    Tyv: ["TYV"],
    Abe: ["ABE"],
    Par: ["PZU"],
    Dig: ["Z3U"],
    Col: [],
    // Pentose
    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"],
    // Deoxynonulosonate
    Kdn: ["KDM", "KDN"],
    Neu5Ac: ["SIA", "SLB"],
    Neu5Gc: ["NGC", "NGE"],
    Neu: [],
    Sia: [],
    // Di-deoxynonulosonate
    Pse: [],
    Leg: [],
    Aci: [],
    "4eLeg": [],
    // Unknown
    Bac: [],
    LDmanHep: ["GMH"],
    Kdo: ["KDO"],
    Dha: [],
    DDmanHep: ["289"],
    MurNAc: ["MUB", "AMU"],
    MurNGc: [],
    Mur: ["1S4", "MUR"],
    // Assigned
    Api: ["XXM"],
    Fru: ["BDF", "Z9N", "FRU", "LFR"],
    Tag: ["T6T"],
    Sor: ["SOE", "UEA"],
    Psi: ["PSV", "SF6", "SF9", "TTV"]
  }, f = {
    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"]
  };
  e.SaccharideCompIdMap = function() {
    for (var d = /* @__PURE__ */ new Map(), m = 0, p = u.length; m < p; ++m) {
      var v = u[m], h = l[v.abbr];
      if (h)
        for (var y = 0, C = h.length; y < C; ++y)
          d.set(h[y], v);
      var S = f[v.abbr];
      if (S)
        for (var y = 0, C = S.length; y < C; ++y)
          d.set(S[y], v);
    }
    return a.SaccharideNames.forEach(function(b) {
      d.has(b) || d.set(b, e.UnknownSaccharideComponent);
    }), d;
  }();
})(ly);
var gC = {};
Object.defineProperty(gC, "__esModule", { value: !0 });
gC.LipidNames = void 0;
gC.LipidNames = /* @__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"]);
var Ap = {};
Object.defineProperty(Ap, "__esModule", { value: !0 });
Ap.IonNames = void 0;
Ap.IonNames = /* @__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"]);
(function(e) {
  var r;
  Object.defineProperty(e, "__esModule", { value: !0 }), e.DefaultResidueHydrophobicity = e.ResidueHydrophobicity = e.BondType = e.DefaultMaxAsa = e.MaxAsa = e.SecondaryStructureType = e.isProtein = e.isNucleic = e.isPolymer = e.getEntitySubtype = e.getEntityType = e.getDefaultChemicalComponent = e.getComponentType = e.getPolymerType = e.getMoleculeType = e.PolymerNames = e.isPyrimidineBase = e.isPurineBase = e.BaseNames = e.PyrimidineBaseNames = e.PurineBaseNames = e.PeptideBaseNames = e.DnaBaseNames = e.RnaBaseNames = e.AminoAcidNames = e.AminoAcidNamesD = e.AminoAcidNamesL = e.WaterNames = e.LipidComponentTypeNames = e.IonComponentTypeNames = e.OtherComponentTypeNames = e.SaccharideComponentTypeNames = e.RNAComponentTypeNames = e.DNAComponentTypeNames = e.ProteinComponentTypeNames = e.OtherProteinComponentTypeNames = e.ProteinTerminusComponentTypeNames = e.BetaProteinComponentTypeNames = e.GammaProteinComponentTypeNames = e.LProteinComponentTypeNames = e.DProteinComponentTypeNames = e.NucleicBackboneAtoms = e.ProteinBackboneAtoms = e.PolymerTypeAtomRoleId = e.getElementFromAtomicNumber = e.ElementSymbol = void 0;
  var t = pp, n = ly, a = ds, i = gC, o = Ap, c = function() {
    for (var _ = /* @__PURE__ */ Object.create(null), A = [], M = 65; M <= 90; M++)
      A[A.length] = String.fromCharCode(M);
    for (var M = 97; M <= 122; M++)
      A[A.length] = String.fromCharCode(M);
    for (var M = 48; M <= 57; M++)
      A[A.length] = String.fromCharCode(M);
    for (var P = 0, T = A; P < T.length; P++) {
      var x = T[P];
      _[x] = x.toUpperCase();
      for (var w = 0, E = A; w < E.length; w++) {
        var I = E[w];
        _[x + I] = (x + I).toUpperCase();
        for (var B = 0, D = A; B < D.length; B++) {
          var N = D[B];
          _[x + I + N] = (x + I + N).toUpperCase();
        }
      }
    }
    return _;
  }();
  function s(_) {
    return c[_] || _.toUpperCase();
  }
  e.ElementSymbol = s;
  var u = 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(_) {
    return [_[0], s(_[1])];
  }));
  function l(_) {
    return u.has(_) ? u.get(_) : s("H");
  }
  e.getElementFromAtomicNumber = l, e.PolymerTypeAtomRoleId = (r = {}, r[
    0
    /* NA */
  ] = {
    trace: /* @__PURE__ */ new Set(),
    directionFrom: /* @__PURE__ */ new Set(),
    directionTo: /* @__PURE__ */ new Set(),
    backboneStart: /* @__PURE__ */ new Set(),
    backboneEnd: /* @__PURE__ */ new Set(),
    coarseBackbone: /* @__PURE__ */ new Set()
  }, r[
    1
    /* Protein */
  ] = {
    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"]),
    // CA1 is used e.g. in GFP chromophores
    // BB is often used for coarse grained models
    coarseBackbone: /* @__PURE__ */ new Set(["CA", "BB", "CA1"])
  }, r[
    2
    /* GammaProtein */
  ] = {
    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"])
  }, r[
    3
    /* BetaProtein */
  ] = {
    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"])
  }, r[
    4
    /* RNA */
  ] = {
    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"])
  }, r[
    5
    /* DNA */
  ] = {
    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"])
  }, r[
    6
    /* PNA */
  ] = {
    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"])
  }, r), e.ProteinBackboneAtoms = /* @__PURE__ */ new Set([
    "CA",
    "C",
    "N",
    "O",
    "O1",
    "O2",
    "OC1",
    "OC2",
    "OT1",
    "OT2",
    "OX1",
    "OXT",
    "H",
    "H1",
    "H2",
    "H3",
    "HA",
    "HN",
    "HXT",
    "BB"
  ]), e.NucleicBackboneAtoms = /* @__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*"
  ]), e.DProteinComponentTypeNames = /* @__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"
  ]), e.LProteinComponentTypeNames = /* @__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"
  ]), e.GammaProteinComponentTypeNames = /* @__PURE__ */ new Set([
    "D-GAMMA-PEPTIDE, C-DELTA LINKING",
    "L-GAMMA-PEPTIDE, C-DELTA LINKING"
  ]), e.BetaProteinComponentTypeNames = /* @__PURE__ */ new Set([
    "D-BETA-PEPTIDE, C-GAMMA LINKING",
    "L-BETA-PEPTIDE, C-GAMMA LINKING"
  ]), e.ProteinTerminusComponentTypeNames = /* @__PURE__ */ new Set([
    "D-PEPTIDE NH3 AMINO TERMINUS",
    "D-PEPTIDE COOH CARBOXY TERMINUS",
    "L-PEPTIDE NH3 AMINO TERMINUS",
    "L-PEPTIDE COOH CARBOXY TERMINUS"
  ]), e.OtherProteinComponentTypeNames = /* @__PURE__ */ new Set([
    "PEPTIDE LINKING",
    "PEPTIDE-LIKE"
  ]), e.ProteinComponentTypeNames = a.SetUtils.unionMany(e.DProteinComponentTypeNames, e.LProteinComponentTypeNames, e.OtherProteinComponentTypeNames), e.DNAComponentTypeNames = /* @__PURE__ */ new Set([
    "DNA LINKING",
    "L-DNA LINKING",
    "DNA OH 5 PRIME TERMINUS",
    "DNA OH 3 PRIME TERMINUS"
  ]), e.RNAComponentTypeNames = /* @__PURE__ */ new Set([
    "RNA LINKING",
    "L-RNA LINKING",
    "RNA OH 5 PRIME TERMINUS",
    "RNA OH 3 PRIME TERMINUS"
  ]), e.SaccharideComponentTypeNames = /* @__PURE__ */ new Set([
    "D-SACCHARIDE, BETA LINKING",
    "L-SACCHARIDE, BETA LINKING",
    "D-SACCHARIDE, ALPHA LINKING",
    "L-SACCHARIDE, ALPHA LINKING",
    "L-SACCHARIDE",
    "D-SACCHARIDE",
    "SACCHARIDE",
    // the following four are marked to be deprecated in the mmCIF dictionary
    "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"
  ]), e.OtherComponentTypeNames = /* @__PURE__ */ new Set(["NON-POLYMER", "OTHER"]), e.IonComponentTypeNames = /* @__PURE__ */ new Set(["ION"]), e.LipidComponentTypeNames = /* @__PURE__ */ new Set(["LIPID"]), e.WaterNames = /* @__PURE__ */ new Set([
    "SOL",
    "WAT",
    "HOH",
    "H2O",
    "W",
    "DOD",
    "D3O",
    "TIP",
    "TIP3",
    "TIP4",
    "SPC"
  ]), e.AminoAcidNamesL = /* @__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",
    // charmm ff
    "HSD",
    "HSE",
    "HSP",
    "LSN",
    "ASPP",
    "GLUP",
    // amber ff
    "HID",
    "HIE",
    "HIP",
    "LYN",
    "ASH",
    "GLH",
    "ACE",
    "NME"
  ]), e.AminoAcidNamesD = /* @__PURE__ */ new Set([
    "DAL",
    "DAR",
    "DSG",
    "DAS",
    "DCY",
    "DGL",
    "DGN",
    "DHI",
    "DIL",
    "DLE",
    "DLY",
    "MED",
    "DPN",
    "DPR",
    "DSN",
    "DTH",
    "DTR",
    "DTY",
    "DVA",
    "DNE"
    // D-NORLEUCINE
    // ???  // D-SELENOCYSTEINE
  ]), e.AminoAcidNames = a.SetUtils.unionMany(e.AminoAcidNamesL, e.AminoAcidNamesD), e.RnaBaseNames = /* @__PURE__ */ new Set([
    "A",
    "C",
    "T",
    "G",
    "I",
    "U",
    "N"
    // unknown RNA base from CCD
  ]), e.DnaBaseNames = /* @__PURE__ */ new Set([
    "DA",
    "DC",
    "DT",
    "DG",
    "DI",
    "DU",
    "DN"
    // unknown DNA base from CCD
  ]), e.PeptideBaseNames = /* @__PURE__ */ new Set(["APN", "CPN", "TPN", "GPN"]), e.PurineBaseNames = /* @__PURE__ */ new Set([
    "A",
    "G",
    "I",
    "DA",
    "DG",
    "DI",
    "APN",
    "GPN"
  ]), e.PyrimidineBaseNames = /* @__PURE__ */ new Set([
    "C",
    "T",
    "U",
    "DC",
    "DT",
    "DU",
    "CPN",
    "TPN"
  ]), e.BaseNames = a.SetUtils.unionMany(e.RnaBaseNames, e.DnaBaseNames, e.PeptideBaseNames);
  var f = function(_) {
    return e.PurineBaseNames.has(_.toUpperCase());
  };
  e.isPurineBase = f;
  var d = function(_) {
    return e.PyrimidineBaseNames.has(_.toUpperCase());
  };
  e.isPyrimidineBase = d, e.PolymerNames = a.SetUtils.unionMany(e.AminoAcidNames, e.BaseNames);
  function m(_, A) {
    return _ = _.toUpperCase(), A = A.toUpperCase(), e.PeptideBaseNames.has(A) ? 8 : e.ProteinComponentTypeNames.has(_) ? 5 : e.RNAComponentTypeNames.has(_) ? 6 : e.DNAComponentTypeNames.has(_) ? 7 : e.SaccharideComponentTypeNames.has(_) ? 9 : e.WaterNames.has(A) ? 2 : o.IonNames.has(A) ? 3 : i.LipidNames.has(A) ? 4 : e.OtherComponentTypeNames.has(_) ? n.SaccharideCompIdMap.has(A) ? 9 : e.AminoAcidNames.has(A) ? 5 : e.RnaBaseNames.has(A) ? 6 : e.DnaBaseNames.has(A) ? 7 : 1 : 0;
  }
  e.getMoleculeType = m;
  function p(_, A) {
    return _ = _.toUpperCase(), A === 5 ? e.GammaProteinComponentTypeNames.has(_) ? 2 : e.BetaProteinComponentTypeNames.has(_) ? 3 : e.ProteinTerminusComponentTypeNames.has(_) ? 0 : 1 : A === 6 ? 4 : A === 7 ? 5 : A === 8 ? 6 : 0;
  }
  e.getPolymerType = p;
  function v(_) {
    return _ = _.toUpperCase(), e.AminoAcidNames.has(_) ? "peptide linking" : e.RnaBaseNames.has(_) ? "RNA linking" : e.DnaBaseNames.has(_) ? "DNA linking" : n.SaccharideCompIdMap.has(_) ? "saccharide" : "other";
  }
  e.getComponentType = v;
  function h(_) {
    return {
      formula: "",
      formula_weight: 0,
      id: _,
      name: _,
      mon_nstd_flag: e.PolymerNames.has(_) ? "y" : "n",
      pdbx_synonyms: [],
      type: v(_)
    };
  }
  e.getDefaultChemicalComponent = h;
  function y(_) {
    return _ = _.toUpperCase(), e.WaterNames.has(_) ? "water" : e.PolymerNames.has(_) ? "polymer" : n.SaccharideCompIdMap.has(_) ? "branched" : "non-polymer";
  }
  e.getEntityType = y;
  function C(_, A) {
    return _ = _.toUpperCase(), A = A.toUpperCase(), e.LProteinComponentTypeNames.has(A) ? "polypeptide(L)" : e.DProteinComponentTypeNames.has(A) ? "polypeptide(D)" : e.RNAComponentTypeNames.has(A) ? "polyribonucleotide" : e.DNAComponentTypeNames.has(A) ? "polydeoxyribonucleotide" : e.SaccharideComponentTypeNames.has(A) || n.SaccharideCompIdMap.has(_) ? "oligosaccharide" : e.PeptideBaseNames.has(_) ? "peptide nucleic acid" : e.AminoAcidNamesL.has(_) ? "polypeptide(L)" : e.AminoAcidNamesD.has(_) ? "polypeptide(D)" : e.RnaBaseNames.has(_) ? "polyribonucleotide" : e.DnaBaseNames.has(_) ? "polydeoxyribonucleotide" : e.IonComponentTypeNames.has(A) || o.IonNames.has(_) ? "ion" : e.LipidComponentTypeNames.has(A) || i.LipidNames.has(_) ? "lipid" : e.OtherProteinComponentTypeNames.has(A) ? "peptide-like" : "other";
  }
  e.getEntitySubtype = C;
  function S(_) {
    return b(_) || g(_);
  }
  e.isPolymer = S;
  function b(_) {
    return _ === 7 || _ === 6 || _ === 8;
  }
  e.isNucleic = b;
  function g(_) {
    return _ === 5;
  }
  e.isProtein = g, function(_) {
    _.is = t.BitFlags.has, _.create = t.BitFlags.create, _.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
      /* Turn3 */
      // type III turn (protein)
    }, _.SecondaryStructurePdb = {
      1: 4162,
      2: 16450,
      3: 32834,
      4: 8258,
      5: 2114,
      6: 4130,
      7: 16418,
      8: 8226,
      9: 1026,
      10: 65538
      /* HelixPolyproline */
      // Polyproline
    }, _.SecondaryStructureStride = {
      H: 4098,
      G: 2050,
      I: 32770,
      E: 8388612,
      B: 4194308,
      T: 16,
      C: 536870912
      /* NA */
      // Coil (none of the above)
    }, _.SecondaryStructureDssp = {
      H: 4098,
      B: 4194308,
      E: 8388612,
      G: 2050,
      I: 32770,
      T: 16,
      S: 8
      /* Bend */
      // bend
    };
  }(e.SecondaryStructureType || (e.SecondaryStructureType = {})), e.MaxAsa = {
    ALA: 121,
    ARG: 265,
    ASN: 187,
    ASP: 187,
    CYS: 148,
    GLU: 214,
    GLN: 214,
    GLY: 97,
    HIS: 216,
    ILE: 195,
    LEU: 191,
    LYS: 230,
    MET: 203,
    PHE: 228,
    PRO: 154,
    SER: 143,
    THR: 163,
    TRP: 264,
    TYR: 255,
    VAL: 165,
    // charmm ff
    HSD: 216,
    HSE: 216,
    HSP: 216,
    // amber ff
    HID: 216,
    HIE: 216,
    HIP: 216,
    ASH: 187,
    GLH: 214
  }, e.DefaultMaxAsa = 121, function(_) {
    _.is = t.BitFlags.has;
    function A(E) {
      return t.BitFlags.create(E);
    }
    _.create = A;
    function M(E) {
      return (E & 1) !== 0;
    }
    _.isCovalent = M;
    function P(E) {
      return E === Math.pow(2, 6) - 1;
    }
    _.isAll = P, _.Names = {
      covalent: 1,
      "metal-coordination": 2,
      "hydrogen-bond": 4,
      disulfide: 8,
      aromatic: 16,
      computed: 32
      /* Computed */
    };
    function T(E) {
      return E in _.Names;
    }
    _.isName = T;
    function x(E) {
      switch (E) {
        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;
      }
    }
    _.fromName = x;
    function w(E) {
      for (var I = 0, B = 0, D = E.length; B < D; ++B)
        I |= x(E[B]);
      return I;
    }
    _.fromNames = w;
  }(e.BondType || (e.BondType = {})), e.ResidueHydrophobicity = {
    // AA  DGwif   DGwoct  Oct-IF
    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.96,  2.33,  1.37 ],
    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],
    // charmm ff
    HSD: [0.17, 0.11, -0.06],
    HSE: [0.17, 0.11, -0.06],
    HSP: [0.96, 2.33, 1.37],
    // amber ff
    HID: [0.17, 0.11, -0.06],
    HIE: [0.17, 0.11, -0.06],
    HIP: [0.96, 2.33, 1.37]
  }, e.DefaultResidueHydrophobicity = [0, 0, 0];
})(Gr);
var Gd = {};
Object.defineProperty(Gd, "__esModule", { value: !0 });
Gd.CentroidHelper = void 0;
var oo = Yo, yae = lC(), Ab = (
  /** @class */
  function() {
    function e() {
      this.count = 0, this.center = (0, oo.Vec3)(), this.radiusSq = 0;
    }
    return e.prototype.reset = function() {
      oo.Vec3.set(this.center, 0, 0, 0), this.radiusSq = 0, this.count = 0;
    }, e.prototype.includeStep = function(r) {
      oo.Vec3.add(this.center, this.center, r), this.count++;
    }, e.prototype.finishedIncludeStep = function() {
      this.count !== 0 && oo.Vec3.scale(this.center, this.center, 1 / this.count);
    }, e.prototype.radiusStep = function(r) {
      var t = oo.Vec3.squaredDistance(r, this.center);
      t > this.radiusSq && (this.radiusSq = t);
    }, e.prototype.radiusSphereStep = function(r, t) {
      var n = oo.Vec3.distance(r, this.center) + t, a = n * n;
      a > this.radiusSq && (this.radiusSq = a);
    }, e.prototype.getSphere = function(r) {
      return r || (r = (0, yae.Sphere3D)()), oo.Vec3.copy(r.center, this.center), r.radius = Math.sqrt(this.radiusSq), r;
    }, e.prototype.getCount = function() {
      return this.count;
    }, e;
  }()
);
Gd.CentroidHelper = Ab;
(function(e) {
  var r = new e(), t = (0, oo.Vec3)(), n = (0, oo.Vec3)();
  function a(c, s) {
    var u = c.x, l = c.y, f = c.z;
    r.reset();
    for (var d = u.length, m = 0; m < d; m++)
      oo.Vec3.set(t, u[m], l[m], f[m]), r.includeStep(t);
    r.finishedIncludeStep();
    for (var m = 0; m < d; m++)
      oo.Vec3.set(t, u[m], l[m], f[m]), r.radiusStep(t);
    return oo.Vec3.copy(s.center, r.center), s.radius = Math.sqrt(r.radiusSq), s;
  }
  e.fromArrays = a;
  function i(c, s, u) {
    r.reset();
    for (var l = 0; l < c; l++)
      s(l, t), r.includeStep(t);
    r.finishedIncludeStep();
    for (var l = 0; l < c; l++)
      s(l, t), r.radiusStep(t);
    return oo.Vec3.copy(u.center, r.center), u.radius = Math.sqrt(r.radiusSq), u;
  }
  e.fromProvider = i;
  function o(c, s, u) {
    r.reset();
    for (var l = 0; l < c; l++)
      s(l, t, n), r.includeStep(t), r.includeStep(n);
    r.finishedIncludeStep();
    for (var l = 0; l < c; l++)
      s(l, t, n), r.radiusStep(t), r.radiusStep(n);
    return oo.Vec3.copy(u.center, r.center), u.radius = Math.sqrt(r.radiusSq), u;
  }
  e.fromPairProvider = o;
})(Ab || (Ab = {}));
Gd.CentroidHelper = Ab;
var Rc = {}, qd = {};
Object.defineProperty(qd, "__esModule", { value: !0 });
qd.InterUnitGraph = void 0;
var VI = Te, e2 = Po, xb = (
  /** @class */
  function() {
    function e(r) {
      this.map = r;
      var t = 0, n = [], a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
      this.map.forEach(function(o) {
        o.forEach(function(c) {
          t += c.edgeCount, c.connectedIndices.forEach(function(s) {
            c.getEdges(s).forEach(function(u) {
              var l = c.unitA, f = c.unitB, d = e.getEdgeKey(s, l, u.indexB, f);
              a.set(d, n.length);
              var m = e.getVertexKey(s, l), p = i.get(m);
              p === void 0 ? i.set(m, [n.length]) : p.push(n.length), n.push((0, VI.__assign)((0, VI.__assign)({}, u), { indexA: s, unitA: l, unitB: f }));
            });
          });
        });
      }), this.edgeCount = t, this.edges = n, this.edgeKeyIndex = a, this.vertexKeyIndex = i;
    }
    return e.prototype.getConnectedUnits = function(r) {
      return this.map.has(r) ? this.map.get(r) : Wz;
    }, e.prototype.getEdgeIndex = function(r, t, n, a) {
      var i = e.getEdgeKey(r, t, n, a), o = this.edgeKeyIndex.get(i);
      return o !== void 0 ? o : -1;
    }, e.prototype.hasEdge = function(r, t, n, a) {
      return this.getEdgeIndex(r, t, n, a) !== -1;
    }, e.prototype.getEdge = function(r, t, n, a) {
      var i = this.getEdgeIndex(r, t, n, a);
      return i !== -1 ? this.edges[i] : void 0;
    }, e.prototype.getEdgeIndices = function(r, t) {
      return this.vertexKeyIndex.get(e.getVertexKey(r, t)) || [];
    }, e;
  }()
);
qd.InterUnitGraph = xb;
(function(e) {
  var r = (
    /** @class */
    function() {
      function o(c, s, u, l, f) {
        this.unitA = c, this.unitB = s, this.edgeCount = u, this.connectedIndices = l, this.edgeMap = f;
      }
      return o.prototype.hasEdges = function(c) {
        return this.edgeMap.has(c);
      }, o.prototype.getEdges = function(c) {
        return this.edgeMap.has(c) ? this.edgeMap.get(c) : Wz;
      }, Object.defineProperty(o.prototype, "areUnitsOrdered", {
        get: function() {
          return this.unitA < this.unitB;
        },
        enumerable: !1,
        configurable: !0
      }), o;
    }()
  );
  e.UnitPairEdges = r;
  function t(o, c, s, u) {
    return "".concat(o, "|").concat(c, "|").concat(s, "|").concat(u);
  }
  e.getEdgeKey = t;
  function n(o, c) {
    return "".concat(o, "|").concat(c);
  }
  e.getVertexKey = n;
  function a(o, c, s) {
    o.has(c) ? o.get(c).push(s) : o.set(c, [s]);
  }
  var i = (
    /** @class */
    function() {
      function o() {
        this.map = /* @__PURE__ */ new Map();
      }
      return o.prototype.startUnitPair = function(c, s) {
        this.uA = c, this.uB = s, this.mapAB = /* @__PURE__ */ new Map(), this.mapBA = /* @__PURE__ */ new Map(), this.linkedA = e2.UniqueArray.create(), this.linkedB = e2.UniqueArray.create(), this.linkCount = 0;
      }, o.prototype.finishUnitPair = function() {
        this.linkCount !== 0 && (a(this.map, this.uA, new r(this.uA, this.uB, this.linkCount, this.linkedA.array, this.mapAB)), a(this.map, this.uB, new r(this.uB, this.uA, this.linkCount, this.linkedB.array, this.mapBA)));
      }, o.prototype.add = function(c, s, u) {
        a(this.mapAB, c, { indexB: s, props: u }), a(this.mapBA, s, { indexB: c, props: u }), e2.UniqueArray.add(this.linkedA, c, c), e2.UniqueArray.add(this.linkedB, s, s), this.linkCount += 1;
      }, o.prototype.getMap = function() {
        return this.map;
      }, o;
    }()
  );
  e.Builder = i;
})(xb || (xb = {}));
qd.InterUnitGraph = xb;
var Wz = [], RI;
function pE() {
  if (RI) return Rc;
  RI = 1, Object.defineProperty(Rc, "__esModule", { value: !0 }), Rc.InterUnitBonds = Rc.IntraUnitBonds = void 0;
  var e = Te, r = dl, t = vl(), n = qd, a;
  (function(o) {
    o.Empty = r.IntAdjacencyGraph.create([], [], [], 0, {
      flags: [],
      order: []
    });
  })(a || (a = {})), Rc.IntraUnitBonds = a;
  var i = (
    /** @class */
    function(o) {
      (0, e.__extends)(c, o);
      function c() {
        return o !== null && o.apply(this, arguments) || this;
      }
      return c.prototype.getBondFromLocation = function(s) {
        return t.Unit.isAtomic(s.aUnit) && t.Unit.isAtomic(s.bUnit) ? this.getEdge(s.aIndex, s.aUnit.id, s.bIndex, s.bUnit.id) : void 0;
      }, c.prototype.getBondIndexFromLocation = function(s) {
        return t.Unit.isAtomic(s.aUnit) && t.Unit.isAtomic(s.bUnit) ? this.getEdgeIndex(s.aIndex, s.aUnit.id, s.bIndex, s.bUnit.id) : -1;
      }, c;
    }(n.InterUnitGraph)
  );
  return Rc.InterUnitBonds = i, function(o) {
    var c = (
      /** @class */
      function(s) {
        (0, e.__extends)(u, s);
        function u() {
          return s !== null && s.apply(this, arguments) || this;
        }
        return u;
      }(n.InterUnitGraph.UnitPairEdges)
    );
    o.UnitPairBonds = c;
  }(i || (i = {})), Rc.InterUnitBonds = i, Rc;
}
var xh = {}, hE = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.isHydrogen = e.getPairingThreshold = e.getElementThreshold = e.getElementPairThreshold = e.getElementIdx = e.MetalsSet = e.DefaultBondComputationProps = e.DefaultBondMaxRadius = void 0, e.DefaultBondMaxRadius = 4, e.DefaultBondComputationProps = {
    forceCompute: !1,
    noCompute: !1,
    maxRadius: e.DefaultBondMaxRadius
  };
  var r = { 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 }, t = { 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 }, n = { 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 }, a = 2.001;
  e.MetalsSet = function() {
    for (var d = ["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"], m = /* @__PURE__ */ new Set(), p = 0, v = d; p < v.length; p++) {
      var h = v[p];
      m.add(r[h]);
    }
    return m;
  }();
  function i(d, m) {
    return d < m ? (d + m) * (d + m + 1) / 2 + m : (d + m) * (d + m + 1) / 2 + d;
  }
  function o(d) {
    var m = r[d];
    return m === void 0 ? -1 : m;
  }
  e.getElementIdx = o;
  function c(d, m) {
    if (d < 0 || m < 0)
      return -1;
    var p = n[i(d, m)];
    return p === void 0 ? -1 : p;
  }
  e.getElementPairThreshold = c;
  function s(d) {
    if (d < 0)
      return a;
    var m = t[d];
    return m === void 0 ? a : m;
  }
  e.getElementThreshold = s;
  function u(d, m, p, v) {
    var h = c(d, m);
    return h > 0 ? h : m < 0 ? p : (p + v) / 1.95;
  }
  e.getPairingThreshold = u;
  var l = r.H;
  function f(d) {
    return d === l;
  }
  e.isHydrogen = f;
})(hE);
var Ed = {};
Object.defineProperty(Ed, "__esModule", { value: !0 });
Ed.getInterBondOrderFromTable = Ed.getIntraBondOrderFromTable = void 0;
var OI = Gr, _ae = /* @__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 bae(e, r, t) {
  var n;
  return n = r < t ? [r, t] : [t, r], r = n[0], t = n[1], OI.AminoAcidNames.has(e) && r === "C" && t === "O" || OI.BaseNames.has(e) && r === "OP1" && t === "P" ? 2 : _ae.get("".concat(e, "|").concat(r, "|").concat(t)) || 1;
}
Ed.getIntraBondOrderFromTable = bae;
var Sae = /* @__PURE__ */ new Map([
  ["LYS|NZ|RET|C15", 2]
  // Schiff base in Rhodopsin and Bacteriorhodopsin
]);
function Cae(e, r, t, n) {
  var a, i;
  return e > t && (a = [t, e], e = a[0], t = a[1], i = [n, r], r = i[0], n = i[1]), Sae.get("".concat(e, "|").concat(r, "|").concat(t, "|").concat(n)) || 1;
}
Ed.getInterBondOrderFromTable = Cae;
var gE = {}, fl = {};
Object.defineProperty(fl, "__esModule", { value: !0 });
fl.mmCIF_Schema = void 0;
var Aae = mr(), Hd = Aae.Column.Schema, ve = Hd.str, Ie = Hd.int, yr = Hd.float, Zx = Hd.coord, $e = Hd.Aliased, Oc = Hd.Matrix, r2 = Hd.Vector, gf = Hd.List;
fl.mmCIF_Schema = {
  /**
   * Data items in the ATOM_SITE category record details about
   * the atom sites in a macromolecular crystal structure, such as
   * the positional coordinates, atomic displacement parameters,
   * magnetic moments and directions.
   *
   * The data items for describing anisotropic atomic
   * displacement factors are only used if the corresponding items
   * are not given in the ATOM_SITE_ANISOTROP category.
   *
   * wwPDB recommends wwPDB-assigned residue number, residue ID,
   * and chain ID, _atom_site.auth_seq_id _atom_site.auth_comp_id, and
   * _atom_site.auth_asym_id, respectively, to be used for publication
   * materials.
   */
  atom_site: {
    /**
     * An alternative identifier for _atom_site.label_asym_id that
     * may be provided by an author in order to match the identification
     * used in the publication that describes the structure.
     */
    auth_asym_id: ve,
    /**
     * An alternative identifier for _atom_site.label_atom_id that
     * may be provided by an author in order to match the identification
     * used in the publication that describes the structure.
     */
    auth_atom_id: ve,
    /**
     * An alternative identifier for _atom_site.label_comp_id that
     * may be provided by an author in order to match the identification
     * used in the publication that describes the structure.
     */
    auth_comp_id: ve,
    /**
     * An alternative identifier for _atom_site.label_seq_id that
     * may be provided by an author in order to match the identification
     * used in the publication that describes the structure.
     *
     * Note that this is not necessarily a number, that the values do
     * not have to be positive, and that the value does not have to
     * correspond to the value of _atom_site.label_seq_id. The value
     * of _atom_site.label_seq_id is required to be a sequential list
     * of positive integers.
     *
     * The author may assign values to _atom_site.auth_seq_id in any
     * desired way. For instance, the values may be used to relate
     * this structure to a numbering scheme in a homologous structure,
     * including sequence gaps or insertion codes. Alternatively, a
     * scheme may be used for a truncated polymer that maintains the
     * numbering scheme of the full length polymer. In all cases, the
     * scheme used here must match the scheme used in the publication
     * that describes the structure.
     */
    auth_seq_id: Ie,
    /**
     * Isotropic atomic displacement parameter, or equivalent isotropic
     * atomic displacement parameter, B~eq~, calculated from the
     * anisotropic displacement parameters.
     *
     * B~eq~ = (1/3) sum~i~[sum~j~(B^ij^ A~i~ A~j~ a*~i~ a*~j~)]
     *
     * A     = the real space cell lengths
     * a*    = the reciprocal space cell lengths
     * B^ij^ = 8 pi^2^ U^ij^
     *
     * Ref: Fischer, R. X. & Tillmanns, E. (1988). Acta Cryst. C44,
     * 775-776.
     *
     * The IUCr Commission on Nomenclature recommends against the use
     * of B for reporting atomic displacement parameters. U, being
     * directly proportional to B, is preferred.
     *
     * Note -
     *
     * The particular type of ADP stored in this item is qualified
     * by item _refine.pdbx_adp_type.
     */
    B_iso_or_equiv: yr,
    /**
     * The x atom-site coordinate in angstroms specified according to
     * a set of orthogonal Cartesian axes related to the cell axes as
     * specified by the description given in
     * _atom_sites.Cartn_transform_axes.
     */
    Cartn_x: Zx,
    /**
     * The y atom-site coordinate in angstroms specified according to
     * a set of orthogonal Cartesian axes related to the cell axes as
     * specified by the description given in
     * _atom_sites.Cartn_transform_axes.
     */
    Cartn_y: Zx,
    /**
     * The z atom-site coordinate in angstroms specified according to
     * a set of orthogonal Cartesian axes related to the cell axes as
     * specified by the description given in
     * _atom_sites.Cartn_transform_axes.
     */
    Cartn_z: Zx,
    /**
     * The group of atoms to which the atom site belongs. This data
     * item is provided for compatibility with the original Protein
     * Data Bank format, and only for that purpose.
     */
    group_PDB: $e(ve),
    /**
     * The value of _atom_site.id must uniquely identify a record in the
     * ATOM_SITE list.
     *
     * Note that this item need not be a number; it can be any unique
     * identifier.
     *
     * This data item was introduced to provide compatibility between
     * small-molecule and macromolecular CIFs. In a small-molecule
     * CIF, _atom_site_label is the identifier for the atom. In a
     * macromolecular CIF, the atom identifier is the aggregate of
     * _atom_site.label_alt_id, _atom_site.label_asym_id,
     * _atom_site.label_atom_id, _atom_site.label_comp_id and
     * _atom_site.label_seq_id. For the two types of files to be
     * compatible, a formal identifier for the category had to be
     * introduced that was independent of the different modes of
     * identifying the atoms. For compatibility with older CIFs,
     * _atom_site_label is aliased to _atom_site.id.
     *
     * In general, this aggregate identifier does not uniquely
     * identify an atom site as for non-polymers _atom_site.label_seq_id
     * is '.'.
     */
    id: Ie,
    /**
     * A place holder to indicate alternate conformation. The alternate conformation
     * can be an entire polymer chain, or several residues or
     * partial residue (several atoms within one residue). If
     * an atom is provided in more than one position, then a
     * non-blank alternate location indicator must be used for
     * each of the atomic positions.
     */
    label_alt_id: ve,
    /**
     * A component of the identifier for this atom site.
     * For further details, see the definition of the STRUCT_ASYM
     * category.
     *
     * This data item is a pointer to _struct_asym.id in the
     * STRUCT_ASYM category.
     */
    label_asym_id: ve,
    /**
     * A component of the identifier for this atom site.
     *
     * This data item is a pointer to _chem_comp_atom.atom_id in the
     * CHEM_COMP_ATOM category.
     */
    label_atom_id: ve,
    /**
     * A component of the identifier for this atom site.
     *
     * This data item is a pointer to _chem_comp.id in the CHEM_COMP
     * category.
     */
    label_comp_id: ve,
    /**
     * This data item is a pointer to _entity.id in the ENTITY category.
     */
    label_entity_id: ve,
    /**
     * This data item is a pointer to _entity_poly_seq.num in the
     * ENTITY_POLY_SEQ category.
     */
    label_seq_id: Ie,
    /**
     * The fraction of the atom type present at this site.
     * The sum of the occupancies of all the atom types at this site
     * may not exceed 1.0 unless it is a dummy site.
     */
    occupancy: yr,
    /**
     * This data item is a pointer to _atom_type.symbol in the
     * ATOM_TYPE category.
     */
    type_symbol: ve,
    /**
     * PDB insertion code.
     */
    pdbx_PDB_ins_code: ve,
    /**
     * PDB model number.
     */
    pdbx_PDB_model_num: Ie,
    /**
     * The net integer charge assigned to this atom. This is the
     * formal charge assignment normally found in chemical diagrams.
     */
    pdbx_formal_charge: Ie,
    /**
     * This data item is an ordinal which identifies distinct chemical components in the atom_site category, both
     * polymeric and non-polymeric.
     */
    pdbx_label_index: Ie,
    /**
     * The name of additional external databases with residue level mapping.
     */
    pdbx_sifts_xref_db_name: ve,
    /**
     * The accession code related to the additional external database entry.
     */
    pdbx_sifts_xref_db_acc: ve,
    /**
     * The sequence position of the external database entry that corresponds
     * to the residue mapping defined by the SIFTS process.
     */
    pdbx_sifts_xref_db_num: ve,
    /**
     * Describes the residue type of the given UniProt match
     */
    pdbx_sifts_xref_db_res: ve,
    /**
     * The model id corresponding to the atom site.
     * This data item is a pointer to _ihm_model_list.model_id
     * in the IHM_MODEL_LIST category.
     */
    ihm_model_id: Ie,
    cdr: Ie,
    em_confidence: ve
  },
  /**
   * Data items in the ATOM_SITE_ANISOTROP category record details
   * about anisotropic displacement parameters.
   * If the ATOM_SITE_ANISOTROP category is used for storing these
   * data, the corresponding ATOM_SITE data items are not used.
   */
  atom_site_anisotrop: {
    /**
     * This data item is a pointer to _atom_site.id in the ATOM_SITE
     * category.
     */
    id: Ie,
    /**
     * This data item is a pointer to _atom_type.symbol in the
     * ATOM_TYPE category.
     */
    type_symbol: ve,
    /**
     * The elements of the standard anisotropic atomic
     * displacement matrix U, which appears in the structure-factor
     * term as:
     *
     * T = exp{-2 pi^2^ sum~i~[sum~j~(U^ij^ h~i~ h~j~ a*~i~ a*~j~)]}
     *
     * h  = the Miller indices
     * a* = the reciprocal space cell lengths
     *
     * These matrix elements may appear with atomic coordinates
     * in the ATOM_SITE category, or they may appear in the separate
     * ATOM_SITE_ANISOTROP category, but they may not appear in both
     * places. Similarly, anisotropic displacements may appear as
     * either B's or U's, but not as both.
     *
     * The unique elements of the real symmetric matrix are
     * entered by row.
     */
    U: Oc(3, 3),
    /**
     * The standard uncertainty (estimated standard deviation)
     * of _atom_site_anisotrop.U.
     */
    U_esd: Oc(3, 3),
    /**
     * Pointer to _atom_site.auth_seq_id
     */
    pdbx_auth_seq_id: ve,
    /**
     * Pointer to _atom_site.auth_asym_id
     */
    pdbx_auth_asym_id: ve,
    /**
     * Pointer to _atom_site.auth_atom_id
     */
    pdbx_auth_atom_id: ve,
    /**
     * Pointer to _atom_site.auth_comp_id
     */
    pdbx_auth_comp_id: ve,
    /**
     * Pointer to _atom_site.label_seq_id
     */
    pdbx_label_seq_id: Ie,
    /**
     * Pointer to _atom_site.label_alt_id.
     */
    pdbx_label_alt_id: ve,
    /**
     * Pointer to _atom_site.label_asym_id
     */
    pdbx_label_asym_id: ve,
    /**
     * Pointer to _atom_site.label_atom_id
     */
    pdbx_label_atom_id: ve,
    /**
     * Pointer to _atom_site.label_comp_id
     */
    pdbx_label_comp_id: ve,
    /**
     * Pointer to _atom_site.pdbx_PDB_ins_code
     */
    pdbx_PDB_ins_code: ve
  },
  /**
   * Data items in the ATOM_SITES category record details about
   * the crystallographic cell and cell transformations, which are
   * common to all atom sites.
   */
  atom_sites: {
    /**
     * This data item is a pointer to _entry.id in the ENTRY category.
     */
    entry_id: ve,
    /**
     * The elements of the 3x3 matrix used to transform Cartesian
     * coordinates in the ATOM_SITE category to fractional coordinates
     * in the same category. The axial alignments of this
     * transformation are described in _atom_sites.Cartn_transform_axes.
     * The 3x1 translation is defined in
     * _atom_sites.fract_transf_vector[].
     *
     * |x'|               |11 12 13| |x|              |1|
     * |y'|~fractional~ = |21 22 23| |y|~Cartesian~ + |2|
     * |z'|               |31 32 33| |z|              |3|
     */
    fract_transf_matrix: Oc(3, 3),
    /**
     * The elements of the three-element vector used to transform
     * Cartesian coordinates in the ATOM_SITE category to fractional
     * coordinates in the same category. The axial alignments of this
     * transformation are described in _atom_sites.Cartn_transform_axes.
     * The 3x3 rotation is defined in
     * _atom_sites.fract_transf_matrix[][].
     *
     * |x'|               |11 12 13| |x|              |1|
     * |y'|~fractional~ = |21 22 23| |y|~Cartesian~ + |2|
     * |z'|               |31 32 33| |z|              |3|
     */
    fract_transf_vector: r2(3)
  },
  /**
   * Data items in the AUDIT_AUTHOR category record details about
   * the author(s) of the data block.
   */
  audit_author: {
    /**
     * The name of an author of this data block. If there are multiple
     * authors, _audit_author.name is looped with _audit_author.address.
     * The family name(s), followed by a comma and including any
     * dynastic components, precedes the first name(s) or initial(s).
     */
    name: ve,
    /**
     * This data item defines the order of the author's name in the
     * list of audit authors.
     */
    pdbx_ordinal: Ie,
    /**
     * The Open Researcher and Contributor ID (ORCID).
     */
    identifier_ORCID: ve
  },
  /**
   * Data items in the AUDIT_CONFORM category describe the
   * dictionary versions against which the data names appearing in
   * the current data block are conformant.
   */
  audit_conform: {
    /**
     * A file name or uniform resource locator (URL) for the
     * dictionary to which the current data block conforms.
     */
    dict_location: ve,
    /**
     * The string identifying the highest-level dictionary defining
     * data names used in this file.
     */
    dict_name: ve,
    /**
     * The version number of the dictionary to which the current
     * data block conforms.
     */
    dict_version: ve
  },
  /**
   * Data items in the CELL category record details about the
   * crystallographic cell parameters.
   */
  cell: {
    /**
     * Unit-cell angle alpha of the reported structure in degrees.
     */
    angle_alpha: yr,
    /**
     * Unit-cell angle beta of the reported structure in degrees.
     */
    angle_beta: yr,
    /**
     * Unit-cell angle gamma of the reported structure in degrees.
     */
    angle_gamma: yr,
    /**
     * This data item is a pointer to _entry.id in the ENTRY category.
     */
    entry_id: ve,
    /**
     * Unit-cell length a corresponding to the structure reported in
     * angstroms.
     */
    length_a: yr,
    /**
     * Unit-cell length b corresponding to the structure reported in
     * angstroms.
     */
    length_b: yr,
    /**
     * Unit-cell length c corresponding to the structure reported in
     * angstroms.
     */
    length_c: yr,
    /**
     * The number of the polymeric chains in a unit cell. In the case
     * of heteropolymers, Z is the number of occurrences of the most
     * populous chain.
     *
     * This data item is provided for compatibility with the original
     * Protein Data Bank format, and only for that purpose.
     */
    Z_PDB: Ie,
    /**
     * To further identify unique axis if necessary.  E.g., P 21 with
     * an unique C axis will have 'C' in this field.
     */
    pdbx_unique_axis: ve
  },
  /**
   * Data items in the CHEM_COMP category give details about each
   * of the chemical components from which the relevant chemical
   * structures can be constructed, such as name, mass or charge.
   *
   * The related categories CHEM_COMP_ATOM, CHEM_COMP_BOND,
   * CHEM_COMP_ANGLE etc. describe the detailed geometry of these
   * chemical components.
   */
  chem_comp: {
    /**
     * The formula for the chemical component. Formulae are written
     * according to the following rules:
     *
     * (1) Only recognized element symbols may be used.
     *
     * (2) Each element symbol is followed by a 'count' number. A count
     * of '1' may be omitted.
     *
     * (3) A space or parenthesis must separate each cluster of
     * (element symbol + count), but in general parentheses are
     * not used.
     *
     * (4) The order of elements depends on whether carbon is
     * present or not. If carbon is present, the order should be:
     * C, then H, then the other elements in alphabetical order
     * of their symbol. If carbon is not present, the elements
     * are listed purely in alphabetic order of their symbol. This
     * is the 'Hill' system used by Chemical Abstracts.
     */
    formula: ve,
    /**
     * Formula mass in daltons of the chemical component.
     */
    formula_weight: yr,
    /**
     * The value of _chem_comp.id must uniquely identify each item in
     * the CHEM_COMP list.
     *
     * For protein polymer entities, this is the three-letter code for
     * the amino acid.
     *
     * For nucleic acid polymer entities, this is the one-letter code
     * for the base.
     */
    id: ve,
    /**
     * 'yes' indicates that this is a 'standard' monomer, 'no'
     * indicates that it is 'nonstandard'. Nonstandard monomers
     * should be described in more detail using the
     * _chem_comp.mon_nstd_parent, _chem_comp.mon_nstd_class and
     * _chem_comp.mon_nstd_details data items.
     */
    mon_nstd_flag: $e(ve),
    /**
     * The full name of the component.
     */
    name: ve,
    /**
     * For standard polymer components, the type of the monomer.
     * Note that monomers that will form polymers are of three types:
     * linking monomers, monomers with some type of N-terminal (or 5')
     * cap and monomers with some type of C-terminal (or 3') cap.
     */
    type: $e(ve),
    /**
     * Synonym list for the component.
     */
    pdbx_synonyms: gf(";", function(e) {
      return e;
    })
  },
  /**
   * Data items in the CHEM_COMP_BOND category record details about
   * the bonds between atoms in a chemical component. Target values
   * may be specified as bond orders, as a distance between the two
   * atoms, or both.
   */
  chem_comp_bond: {
    /**
     * The ID of the first of the two atoms that define the bond.
     *
     * This data item is a pointer to _chem_comp_atom.atom_id in the
     * CHEM_COMP_ATOM category.
     */
    atom_id_1: ve,
    /**
     * The ID of the second of the two atoms that define the bond.
     *
     * This data item is a pointer to _chem_comp_atom.atom_id in the
     * CHEM_COMP_ATOM category.
     */
    atom_id_2: ve,
    /**
     * This data item is a pointer to _chem_comp.id in the CHEM_COMP
     * category.
     */
    comp_id: ve,
    /**
     * The value that should be taken as the target for the chemical
     * bond associated with the specified atoms, expressed as a bond
     * order.
     */
    value_order: $e(ve),
    /**
     * Ordinal index for the component bond list.
     */
    pdbx_ordinal: Ie,
    /**
     * Stereochemical configuration across a double bond.
     */
    pdbx_stereo_config: $e(ve),
    /**
     * A flag indicating an aromatic bond.
     */
    pdbx_aromatic_flag: $e(ve)
  },
  /**
   * Data items in the CITATION category record details about the
   * literature cited as being relevant to the contents of the data
   * block.
   */
  citation: {
    /**
     * The name of the publisher of the citation; relevant
     * for books or book chapters.
     */
    book_publisher: ve,
    /**
     * The country/region of publication; relevant for books
     * and book chapters.
     */
    country: ve,
    /**
     * The value of _citation.id must uniquely identify a record in the
     * CITATION list.
     *
     * The _citation.id 'primary' should be used to indicate the
     * citation that the author(s) consider to be the most pertinent to
     * the contents of the data block.
     *
     * Note that this item need not be a number; it can be any unique
     * identifier.
     */
    id: ve,
    /**
     * Abbreviated name of the cited journal as given in the
     * Chemical Abstracts Service Source Index.
     */
    journal_abbrev: ve,
    /**
     * The American Society for Testing and Materials (ASTM) code
     * assigned to the journal cited (also referred to as the CODEN
     * designator of the Chemical Abstracts Service); relevant for
     * journal articles.
     */
    journal_id_ASTM: ve,
    /**
     * The Cambridge Structural Database (CSD) code assigned to the
     * journal cited; relevant for journal articles. This is also the
     * system used at the Protein Data Bank (PDB).
     */
    journal_id_CSD: ve,
    /**
     * The International Standard Serial Number (ISSN) code assigned to
     * the journal cited; relevant for journal articles.
     */
    journal_id_ISSN: ve,
    /**
     * Volume number of the journal cited; relevant for journal
     * articles.
     */
    journal_volume: ve,
    /**
     * The first page of the citation; relevant for journal
     * articles, books and book chapters.
     */
    page_first: ve,
    /**
     * The last page of the citation; relevant for journal
     * articles, books and book chapters.
     */
    page_last: ve,
    /**
     * The title of the citation; relevant for journal articles, books
     * and book chapters.
     */
    title: ve,
    /**
     * The year of the citation; relevant for journal articles, books
     * and book chapters.
     */
    year: Ie,
    /**
     * Document Object Identifier used by doi.org to uniquely
     * specify bibliographic entry.
     */
    pdbx_database_id_DOI: ve,
    /**
     * Ascession number used by PubMed to categorize a specific
     * bibliographic entry.
     */
    pdbx_database_id_PubMed: Ie
  },
  /**
   * Data items in the CITATION_AUTHOR category record details
   * about the authors associated with the citations in the
   * CITATION list.
   */
  citation_author: {
    /**
     * This data item is a pointer to _citation.id in the CITATION
     * category.
     */
    citation_id: ve,
    /**
     * Name of an author of the citation; relevant for journal
     * articles, books and book chapters.
     *
     * The family name(s), followed by a comma and including any
     * dynastic components, precedes the first name(s) or initial(s).
     */
    name: ve,
    /**
     * This data item defines the order of the author's name in the
     * list of authors of a citation.
     */
    ordinal: Ie
  },
  /**
   * Data items in the DATABASE_2 category record details about the
   * database identifiers of the data block.
   *
   * These data items are assigned by database managers and should
   * only appear in a data block if they originate from that source.
   *
   * The name of this category, DATABASE_2, arose because the
   * category name DATABASE was already in use in the core CIF
   * dictionary, but was used differently from the way it needed
   * to be used in the mmCIF dictionary. Since CIF data names
   * cannot be changed once they have been adopted, a new category
   * had to be created.
   */
  database_2: {
    /**
     * An abbreviation that identifies the database.
     */
    database_id: $e(ve),
    /**
     * The code assigned by the database identified in
     * _database_2.database_id.
     */
    database_code: ve
  },
  /**
   * Data items in the ENTITY category record details (such as
   * chemical composition, name and source) about the molecular
   * entities that are present in the crystallographic structure.
   *
   * Items in the various ENTITY subcategories provide a full
   * chemical description of these molecular entities.
   *
   * Entities are of three types:  polymer, non-polymer and water.
   * Note that the water category includes only water;  ordered
   * solvent such as sulfate ion or acetone would be described as
   * individual non-polymer entities.
   *
   * The ENTITY category is specific to macromolecular CIF
   * applications and replaces the function of the CHEMICAL category
   * in the CIF core.
   *
   * It is important to remember that the ENTITY data are not the
   * result of the crystallographic experiment;  those results are
   * represented by the ATOM_SITE data items. ENTITY data items
   * describe the chemistry of the molecules under investigation
   * and can most usefully be thought of as the ideal groups to which
   * the structure is restrained or constrained during refinement.
   *
   * It is also important to remember that entities do not correspond
   * directly to the enumeration of the contents of the asymmetric
   * unit. Entities are described only once, even in those structures
   * that contain multiple observations of an entity. The
   * STRUCT_ASYM data items, which reference the entity list,
   * describe and label the contents of the asymmetric unit.
   */
  entity: {
    /**
     * A description of special aspects of the entity.
     */
    details: ve,
    /**
     * Formula mass in daltons of the entity.
     */
    formula_weight: yr,
    /**
     * The value of _entity.id must uniquely identify a record in the
     * ENTITY list.
     *
     * Note that this item need not be a number; it can be any unique
     * identifier.
     */
    id: ve,
    /**
     * The method by which the sample for the entity was produced.
     * Entities isolated directly from natural sources (tissues, soil
     * samples etc.) are expected to have further information in the
     * ENTITY_SRC_NAT category. Entities isolated from genetically
     * manipulated sources are expected to have further information in
     * the ENTITY_SRC_GEN category.
     */
    src_method: $e(ve),
    /**
     * Defines the type of the entity.
     *
     * Polymer entities are expected to have corresponding
     * ENTITY_POLY and associated entries.
     *
     * Non-polymer entities are expected to have corresponding
     * CHEM_COMP and associated entries.
     *
     * Water entities are not expected to have corresponding
     * entries in the ENTITY category.
     */
    type: $e(ve),
    /**
     * A description of the entity.
     *
     * Corresponds to the compound name in the PDB format.
     */
    pdbx_description: gf(",", function(e) {
      return e;
    }),
    /**
     * A place holder for the number of molecules of the entity in
     * the entry.
     */
    pdbx_number_of_molecules: Ie,
    /**
     * Details about any entity mutation(s).
     */
    pdbx_mutation: ve,
    /**
     * Entity fragment description(s).
     */
    pdbx_fragment: ve,
    /**
     * Enzyme Commission (EC) number(s)
     */
    pdbx_ec: gf(",", function(e) {
      return e;
    })
  },
  /**
   * Data items in the ENTITY_POLY category record details about the
   * polymer, such as the type of the polymer, the number of
   * monomers and whether it has nonstandard features.
   */
  entity_poly: {
    /**
     * This data item is a pointer to _entity.id in the ENTITY category.
     */
    entity_id: ve,
    /**
     * A flag to indicate whether the polymer contains at least
     * one monomer-to-monomer link different from that implied by
     * _entity_poly.type.
     */
    nstd_linkage: $e(ve),
    /**
     * A flag to indicate whether the polymer contains at least
     * one monomer that is not considered standard.
     */
    nstd_monomer: $e(ve),
    /**
     * The type of the polymer.
     */
    type: $e(ve),
    /**
     * The PDB strand/chain id(s) corresponding to this polymer entity.
     */
    pdbx_strand_id: gf(",", function(e) {
      return e;
    }),
    /**
     * Sequence of protein or nucleic acid polymer in standard one-letter
     * codes of amino acids or nucleotides. Non-standard amino
     * acids/nucleotides are represented by their Chemical
     * Component Dictionary (CCD) codes in
     * parenthesis. Deoxynucleotides are represented by the
     * specially-assigned 2-letter CCD codes in parenthesis,
     * with 'D' prefix added to their ribonucleotide
     * counterparts. For hybrid polymer, each residue is
     * represented by the code of its individual type. A
     * cyclic polymer is represented in linear sequence from
     * the chosen start to end.
     *
     * A for Alanine or Adenosine-5'-monophosphate
     * C for Cysteine or Cytidine-5'-monophosphate
     * D for Aspartic acid
     * E for Glutamic acid
     * F for Phenylalanine
     * G for Glycine or Guanosine-5'-monophosphate
     * H for Histidine
     * I for Isoleucine or Inosinic Acid
     * L for Leucine
     * K for Lysine
     * M for Methionine
     * N for Asparagine  or Unknown ribonucleotide
     * O for Pyrrolysine
     * P for Proline
     * Q for Glutamine
     * R for Arginine
     * S for Serine
     * T for Threonine
     * U for Selenocysteine or Uridine-5'-monophosphate
     * V for Valine
     * W for Tryptophan
     * Y for Tyrosine
     * (DA) for 2'-deoxyadenosine-5'-monophosphate
     * (DC) for 2'-deoxycytidine-5'-monophosphate
     * (DG) for 2'-deoxyguanosine-5'-monophosphate
     * (DT) for Thymidine-5'-monophosphate
     * (MSE) for Selenomethionine
     * (SEP) for Phosphoserine
     * (PTO) for Phosphothreonine
     * (PTR) for Phosphotyrosine
     * (PCA) for Pyroglutamic acid
     * (UNK) for Unknown amino acid
     * (ACE) for Acetylation cap
     * (NH2) for Amidation cap
     */
    pdbx_seq_one_letter_code: ve,
    /**
     * Canonical sequence of protein or nucleic acid polymer in standard
     * one-letter codes of amino acids or nucleotides,
     * corresponding to the sequence in
     * _entity_poly.pdbx_seq_one_letter_code. Non-standard
     * amino acids/nucleotides are represented by the codes of
     * their parents if parent is specified in
     * _chem_comp.mon_nstd_parent_comp_id, or by letter 'X' if
     * parent is not specified. Deoxynucleotides are
     * represented by their canonical one-letter codes of A,
     * C, G, or T.
     */
    pdbx_seq_one_letter_code_can: ve,
    /**
     * For Structural Genomics entries, the sequence's target identifier registered at the TargetTrack database.
     */
    pdbx_target_identifier: ve
  },
  /**
   * Data items in the ENTITY_POLY_SEQ category specify the sequence
   * of monomers in a polymer. Allowance is made for the possibility
   * of microheterogeneity in a sample by allowing a given sequence
   * number to be correlated with more than one monomer ID. The
   * corresponding ATOM_SITE entries should reflect this
   * heterogeneity.
   */
  entity_poly_seq: {
    /**
     * This data item is a pointer to _entity_poly.entity_id in the
     * ENTITY_POLY category.
     */
    entity_id: ve,
    /**
     * A flag to indicate whether this monomer in the polymer is
     * heterogeneous in sequence.
     */
    hetero: $e(ve),
    /**
     * This data item is a pointer to _chem_comp.id in the CHEM_COMP
     * category.
     */
    mon_id: ve,
    /**
     * The value of _entity_poly_seq.num must uniquely and sequentially
     * identify a record in the ENTITY_POLY_SEQ list.
     *
     * Note that this item must be a number and that the sequence
     * numbers must progress in increasing numerical order.
     */
    num: Ie
  },
  /**
   * There is only one item in the ENTRY category, _entry.id. This
   * data item gives a name to this entry and is indirectly a key to
   * the categories (such as CELL, GEOM, EXPTL) that describe
   * information pertinent to the entire data block.
   */
  entry: {
    /**
     * The value of _entry.id identifies the data block.
     *
     * Note that this item need not be a number; it can be any unique
     * identifier.
     */
    id: ve
  },
  /**
   * Data items in the EXPTL category record details about the
   * experimental work prior to the intensity measurements and
   * details about the absorption-correction technique employed.
   */
  exptl: {
    /**
     * This data item is a pointer to _entry.id in the ENTRY category.
     */
    entry_id: ve,
    /**
     * The method used in the experiment.
     */
    method: $e(ve)
  },
  /**
   * Data items in the SOFTWARE category record details about
   * the software used in the structure analysis, which implies
   * any software used in the generation of any data items
   * associated with the structure determination and
   * structure representation.
   *
   * These data items allow computer programs to be referenced
   * in more detail than data items in the COMPUTING category do.
   */
  software: {
    /**
     * The classification of the program according to its
     * major function.
     */
    classification: ve,
    /**
     * The date the software was released.
     */
    date: ve,
    /**
     * Description of the software.
     */
    description: ve,
    /**
     * The name of the software.
     */
    name: ve,
    /**
     * The classification of the software according to the most
     * common types.
     */
    type: $e(ve),
    /**
     * The version of the software.
     */
    version: ve,
    /**
     * An ordinal index for this category
     */
    pdbx_ordinal: Ie
  },
  /**
   * Data items in the STRUCT category record details about the
   * description of the crystallographic structure.
   */
  struct: {
    /**
     * This data item is a pointer to _entry.id in the ENTRY category.
     */
    entry_id: ve,
    /**
     * A title for the data block. The author should attempt to convey
     * the essence of the structure archived in the CIF in the title,
     * and to distinguish this structural result from others.
     */
    title: ve,
    /**
     * An automatically generated descriptor for an NDB structure or
     * the unstructured content of the PDB COMPND record.
     */
    pdbx_descriptor: ve
  },
  /**
   * Data items in the STRUCT_ASYM category record details about the
   * structural elements in the asymmetric unit.
   */
  struct_asym: {
    /**
     * A description of special aspects of this portion of the contents
     * of the asymmetric unit.
     */
    details: ve,
    /**
     * This data item is a pointer to _entity.id in the ENTITY category.
     */
    entity_id: ve,
    /**
     * The value of _struct_asym.id must uniquely identify a record in
     * the STRUCT_ASYM list.
     *
     * Note that this item need not be a number; it can be any unique
     * identifier.
     */
    id: ve,
    /**
     * This data item indicates whether the structural elements are modified.
     */
    pdbx_modified: ve,
    /**
     * A flag indicating that this entity was originally labeled
     * with a blank PDB chain id.
     */
    pdbx_blank_PDB_chainid_flag: $e(ve)
  },
  /**
   * Data items in the STRUCT_CONF category record details about
   * the backbone conformation of a segment of polymer.
   *
   * Data items in the STRUCT_CONF_TYPE category define the
   * criteria used to identify the backbone conformations.
   */
  struct_conf: {
    /**
     * A component of the identifier for the residue at which the
     * conformation segment begins.
     *
     * This data item is a pointer to _atom_site.label_asym_id in the
     * ATOM_SITE category.
     */
    beg_label_asym_id: ve,
    /**
     * A component of the identifier for the residue at which the
     * conformation segment begins.
     *
     * This data item is a pointer to _atom_site.label_comp_id in
     * the ATOM_SITE category.
     */
    beg_label_comp_id: ve,
    /**
     * A component of the identifier for the residue at which the
     * conformation segment begins.
     *
     * This data item is a pointer to _atom_site.label_seq_id in the
     * ATOM_SITE category.
     */
    beg_label_seq_id: Ie,
    /**
     * A component of the identifier for the residue at which the
     * conformation segment begins.
     *
     * This data item is a pointer to _atom_site.auth_asym_id in the
     * ATOM_SITE category.
     */
    beg_auth_asym_id: ve,
    /**
     * A component of the identifier for the residue at which the
     * conformation segment begins.
     *
     * This data item is a pointer to _atom_site.auth_comp_id in
     * the ATOM_SITE category.
     */
    beg_auth_comp_id: ve,
    /**
     * A component of the identifier for the residue at which the
     * conformation segment begins.
     *
     * This data item is a pointer to _atom_site.auth_seq_id in the
     * ATOM_SITE category.
     */
    beg_auth_seq_id: Ie,
    /**
     * This data item is a pointer to _struct_conf_type.id in the
     * STRUCT_CONF_TYPE category.
     */
    conf_type_id: $e(ve),
    /**
     * A description of special aspects of the conformation assignment.
     */
    details: ve,
    /**
     * A component of the identifier for the residue at which the
     * conformation segment ends.
     *
     * This data item is a pointer to _atom_site.label_asym_id in the
     * ATOM_SITE category.
     */
    end_label_asym_id: ve,
    /**
     * A component of the identifier for the residue at which the
     * conformation segment ends.
     *
     * This data item is a pointer to _atom_site.label_comp_id in the
     * ATOM_SITE category.
     */
    end_label_comp_id: ve,
    /**
     * A component of the identifier for the residue at which the
     * conformation segment ends.
     *
     * This data item is a pointer to _atom_site.label_seq_id in the
     * ATOM_SITE category.
     */
    end_label_seq_id: Ie,
    /**
     * A component of the identifier for the residue at which the
     * conformation segment ends.
     *
     * This data item is a pointer to _atom_site.auth_asym_id in the
     * ATOM_SITE category.
     */
    end_auth_asym_id: ve,
    /**
     * A component of the identifier for the residue at which the
     * conformation segment ends.
     *
     * This data item is a pointer to _atom_site.auth_comp_id in the
     * ATOM_SITE category.
     */
    end_auth_comp_id: ve,
    /**
     * A component of the identifier for the residue at which the
     * conformation segment ends.
     *
     * This data item is a pointer to _atom_site.auth_seq_id in the
     * ATOM_SITE category.
     */
    end_auth_seq_id: Ie,
    /**
     * The value of _struct_conf.id must uniquely identify a record in
     * the STRUCT_CONF list.
     *
     * Note that this item need not be a number; it can be any unique
     * identifier.
     */
    id: ve,
    /**
     * A component of the identifier for the residue at which the
     * conformation segment starts.
     */
    pdbx_beg_PDB_ins_code: ve,
    /**
     * A component of the identifier for the residue at which the
     * conformation segment ends.
     */
    pdbx_end_PDB_ins_code: ve,
    /**
     * This item is a place holder for the helix class used in the PDB
     * HELIX record.
     */
    pdbx_PDB_helix_class: ve,
    /**
     * A placeholder for the lengths of the helix of the PDB
     * HELIX record.
     */
    pdbx_PDB_helix_length: Ie,
    /**
     * A placeholder for the helix identifier of the PDB
     * HELIX record.
     */
    pdbx_PDB_helix_id: ve
  },
  /**
   * Data items in the STRUCT_CONN category record details about
   * the connections between portions of the structure. These can be
   * hydrogen bonds, salt bridges, disulfide bridges and so on.
   *
   * The STRUCT_CONN_TYPE records define the criteria used to
   * identify these connections.
   */
  struct_conn: {
    /**
     * This data item is a pointer to _struct_conn_type.id in the
     * STRUCT_CONN_TYPE category.
     */
    conn_type_id: $e(ve),
    /**
     * A description of special aspects of the connection.
     */
    details: ve,
    /**
     * The value of _struct_conn.id must uniquely identify a record in
     * the STRUCT_CONN list.
     *
     * Note that this item need not be a number; it can be any unique
     * identifier.
     */
    id: ve,
    /**
     * A component of the identifier for partner 1 of the structure
     * connection.
     *
     * This data item is a pointer to _atom_site.label_asym_id in the
     * ATOM_SITE category.
     */
    ptnr1_label_asym_id: ve,
    /**
     * A component of the identifier for partner 1 of the structure
     * connection.
     *
     * This data item is a pointer to _chem_comp_atom.atom_id in the
     * CHEM_COMP_ATOM category.
     */
    ptnr1_label_atom_id: ve,
    /**
     * A component of the identifier for partner 1 of the structure
     * connection.
     *
     * This data item is a pointer to _atom_site.label_comp_id in the
     * ATOM_SITE category.
     */
    ptnr1_label_comp_id: ve,
    /**
     * A component of the identifier for partner 1 of the structure
     * connection.
     *
     * This data item is a pointer to _atom_site.label_seq_id in the
     * ATOM_SITE category.
     */
    ptnr1_label_seq_id: Ie,
    /**
     * A component of the identifier for partner 1 of the structure
     * connection.
     *
     * This data item is a pointer to _atom_site.auth_asym_id in the
     * ATOM_SITE category.
     */
    ptnr1_auth_asym_id: ve,
    /**
     * A component of the identifier for partner 1 of the structure
     * connection.
     *
     * This data item is a pointer to _atom_site.auth_comp_id in the
     * ATOM_SITE category.
     */
    ptnr1_auth_comp_id: ve,
    /**
     * A component of the identifier for partner 1 of the structure
     * connection.
     *
     * This data item is a pointer to _atom_site.auth_seq_id in the
     * ATOM_SITE category.
     */
    ptnr1_auth_seq_id: Ie,
    /**
     * Describes the symmetry operation that should be applied to the
     * atom set specified by _struct_conn.ptnr1_label* to generate the
     * first partner in the structure connection.
     */
    ptnr1_symmetry: ve,
    /**
     * A component of the identifier for partner 2 of the structure
     * connection.
     *
     * This data item is a pointer to _atom_site.label_asym_id in the
     * ATOM_SITE category.
     */
    ptnr2_label_asym_id: ve,
    /**
     * A component of the identifier for partner 2 of the structure
     * connection.
     *
     * This data item is a pointer to _chem_comp_atom.atom_id in the
     * CHEM_COMP_ATOM category.
     */
    ptnr2_label_atom_id: ve,
    /**
     * A component of the identifier for partner 2 of the structure
     * connection.
     *
     * This data item is a pointer to _atom_site.label_comp_id in the
     * ATOM_SITE category.
     */
    ptnr2_label_comp_id: ve,
    /**
     * A component of the identifier for partner 2 of the structure
     * connection.
     *
     * This data item is a pointer to _atom_site.label_seq_id in the
     * ATOM_SITE category.
     */
    ptnr2_label_seq_id: Ie,
    /**
     * A component of the identifier for partner 2 of the structure
     * connection.
     *
     * This data item is a pointer to _atom_site.auth_asym_id in the
     * ATOM_SITE category.
     */
    ptnr2_auth_asym_id: ve,
    /**
     * A component of the identifier for partner 2 of the structure
     * connection.
     *
     * This data item is a pointer to _atom_site.auth_comp_id in the
     * ATOM_SITE category.
     */
    ptnr2_auth_comp_id: ve,
    /**
     * A component of the identifier for partner 2 of the structure
     * connection.
     *
     * This data item is a pointer to _atom_site.auth_seq_id in the
     * ATOM_SITE category.
     */
    ptnr2_auth_seq_id: Ie,
    /**
     * Describes the symmetry operation that should be applied to the
     * atom set specified by _struct_conn.ptnr2_label* to generate the
     * second partner in the structure connection.
     */
    ptnr2_symmetry: ve,
    /**
     * A component of the identifier for partner 1 of the structure
     * connection.
     *
     * This data item is a pointer to _atom_site.pdbx_PDB_ins_code in the
     * ATOM_SITE category.
     */
    pdbx_ptnr1_PDB_ins_code: ve,
    /**
     * A component of the identifier for partner 1 of the
     * structure connection. This data item is a pointer to
     * _atom_site.label_alt_id in the ATOM_SITE category.
     */
    pdbx_ptnr1_label_alt_id: ve,
    /**
     * A placeholder for the standard residue name found in
     * the MODRES record of a PDB file.
     */
    pdbx_ptnr1_standard_comp_id: ve,
    /**
     * A component of the identifier for partner 1 of the structure
     * connection.
     *
     * This data item is a pointer to _atom_site.pdbx_PDB_ins_code in the
     * ATOM_SITE category.
     */
    pdbx_ptnr2_PDB_ins_code: ve,
    /**
     * A component of the identifier for partner 2 of the
     * structure connection. This data item is a pointer to
     * _atom_site.label_alt_id in the ATOM_SITE category.
     */
    pdbx_ptnr2_label_alt_id: ve,
    /**
     * A component of the identifier for partner 3 of the
     * structure connection. This data item is a pointer to
     * _atom_site.pdbx_PDB_ins_code in the ATOM_SITE category.
     */
    pdbx_ptnr3_PDB_ins_code: ve,
    /**
     * A component of the identifier for partner 3 of the
     * structure connection. This data item is a pointer to
     * _atom_site.label_alt_id in the ATOM_SITE category.
     */
    pdbx_ptnr3_label_alt_id: ve,
    /**
     * A component of the identifier for partner 3 of the
     * structure connection. This data item is a pointer to
     * _atom_site.label_asym_id in the ATOM_SITE category.
     */
    pdbx_ptnr3_label_asym_id: ve,
    /**
     * A component of the identifier for partner 3 of the
     * structure connection. This data item is a pointer to
     * _atom_site.label_atom_id in the ATOM_SITE category.
     */
    pdbx_ptnr3_label_atom_id: ve,
    /**
     * A component of the identifier for partner 3 of the
     * structure connection. This data item is a pointer to
     * _atom_site.label_comp_id in the ATOM_SITE category.
     */
    pdbx_ptnr3_label_comp_id: ve,
    /**
     * A component of the identifier for partner 1 of the
     * structure connection. This data item is a pointer to
     * _atom_site.label_seq_id in the ATOM_SITE category.
     */
    pdbx_ptnr3_label_seq_id: Ie,
    /**
     * A placeholder for the PDB id in the case the category
     * is used to hold the information of the MODRES record of
     * a PDB file.
     */
    pdbx_PDB_id: ve,
    /**
     * Distance value for this contact.
     */
    pdbx_dist_value: yr,
    /**
     * The chemical bond order associated with the specified atoms in
     * this contact.
     */
    pdbx_value_order: $e(ve)
  },
  /**
   * Data items in the STRUCT_CONN_TYPE category record details
   * about the criteria used to identify interactions between
   * portions of the structure.
   */
  struct_conn_type: {
    /**
     * The criteria used to define the interaction.
     */
    criteria: ve,
    /**
     * The chemical or structural type of the interaction.
     */
    id: $e(ve),
    /**
     * A reference that specifies the criteria used to define the
     * interaction.
     */
    reference: ve
  },
  /**
   * Data items in the STRUCT_KEYWORDS category specify keywords
   * that describe the chemical structure in this entry.
   */
  struct_keywords: {
    /**
     * This data item is a pointer to _entry.id in the ENTRY category.
     */
    entry_id: ve,
    /**
     * Keywords describing this structure.
     */
    text: gf(",", function(e) {
      return e;
    }),
    /**
     * Terms characterizing the macromolecular structure.
     */
    pdbx_keywords: ve
  },
  /**
   * Data items in the STRUCT_NCS_OPER category describe the
   * noncrystallographic symmetry operations.
   *
   * Each operator is specified as a matrix and a subsequent
   * translation vector. Operators need not represent proper
   * rotations.
   */
  struct_ncs_oper: {
    /**
     * A code to indicate whether this operator describes a
     * relationship between coordinates all of which are given in the
     * data block (in which case the value of code is 'given'), or
     * whether the operator is used to generate new coordinates from
     * those that are given in the data block (in which case the value
     * of code is 'generate').
     */
    code: $e(ve),
    /**
     * A description of special aspects of the noncrystallographic
     * symmetry operator.
     */
    details: ve,
    /**
     * The value of _struct_ncs_oper.id must uniquely identify a
     * record in the STRUCT_NCS_OPER list.
     *
     * Note that for PDB _struct_ncs_oper.id must be a number.
     */
    id: Ie,
    /**
     * The elements of the 3x3 matrix component of a
     * noncrystallographic symmetry operation.
     */
    matrix: Oc(3, 3),
    /**
     * The elements of the three-element vector component of a
     * noncrystallographic symmetry operation.
     */
    vector: r2(3)
  },
  /**
   * Data items in the STRUCT_SHEET_RANGE category record details
   * about the residue ranges that form a beta-sheet. Residues are
   * included in a range if they made beta-sheet-type hydrogen-bonding
   * interactions with at least one adjacent strand and if there are
   * at least two residues in the range.
   */
  struct_sheet_range: {
    /**
     * A component of the identifier for the residue at which the
     * beta-sheet range begins.
     *
     * This data item is a pointer to _struct_asym.id in the
     * STRUCT_ASYM category.
     */
    beg_label_asym_id: ve,
    /**
     * A component of the identifier for the residue at which the
     * beta-sheet range begins.
     *
     * This data item is a pointer to _chem_comp.id in the CHEM_COMP
     * category.
     */
    beg_label_comp_id: ve,
    /**
     * A component of the identifier for the residue at which the
     * beta-sheet range begins.
     *
     * This data item is a pointer to _atom_site.label_seq_id in the
     * ATOM_SITE category.
     */
    beg_label_seq_id: Ie,
    /**
     * A component of the identifier for the residue at which the
     * beta-sheet range ends.
     *
     * This data item is a pointer to _struct_asym.id in the
     * STRUCT_ASYM category.
     */
    end_label_asym_id: ve,
    /**
     * A component of the identifier for the residue at which the
     * beta-sheet range ends.
     *
     * This data item is a pointer to _chem_comp.id in the CHEM_COMP
     * category.
     */
    end_label_comp_id: ve,
    /**
     * A component of the identifier for the residue at which the
     * beta-sheet range ends.
     *
     * This data item is a pointer to _atom_site.label_seq_id in the
     * ATOM_SITE category.
     */
    end_label_seq_id: Ie,
    /**
     * A component of the identifier for the residue at which the
     * beta-sheet range begins.
     *
     * This data item is a pointer to _atom_site.auth_asym_id in the
     * ATOM_SITE category.
     */
    beg_auth_asym_id: ve,
    /**
     * A component of the identifier for the residue at which the
     * beta-sheet range begins.
     *
     * This data item is a pointer to _atom_site.auth_comp_id in
     * the ATOM_SITE category.
     */
    beg_auth_comp_id: ve,
    /**
     * A component of the identifier for the residue at which the
     * beta-sheet range begins.
     *
     * This data item is a pointer to _atom_site.auth_seq_id in the
     * ATOM_SITE category.
     */
    beg_auth_seq_id: Ie,
    /**
     * A component of the identifier for the residue at which the
     * beta-sheet range ends.
     *
     * This data item is a pointer to _atom_site.auth_asym_id in the
     * ATOM_SITE category.
     */
    end_auth_asym_id: ve,
    /**
     * A component of the identifier for the residue at which the
     * beta-sheet range ends.
     *
     * This data item is a pointer to _atom_site.auth_comp_id in the
     * ATOM_SITE category.
     */
    end_auth_comp_id: ve,
    /**
     * A component of the identifier for the residue at which the
     * beta-sheet range ends.
     *
     * This data item is a pointer to _atom_site.auth_seq_id in the
     * ATOM_SITE category.
     */
    end_auth_seq_id: Ie,
    /**
     * The value of _struct_sheet_range.id must uniquely identify a
     * range in a given sheet in the STRUCT_SHEET_RANGE list.
     *
     * Note that this item need not be a number; it can be any unique
     * identifier.
     */
    id: ve,
    /**
     * This data item is a pointer to _struct_sheet.id in the
     * STRUCT_SHEET category.
     */
    sheet_id: ve,
    /**
     * A component of the identifier for the residue at which the
     * beta sheet range begins.  Insertion code.
     */
    pdbx_beg_PDB_ins_code: ve,
    /**
     * A component of the identifier for the residue at which the
     * beta sheet range ends. Insertion code.
     */
    pdbx_end_PDB_ins_code: ve
  },
  /**
   * Data items in the STRUCT_SITE category record details about
   * portions of the structure that contribute to structurally
   * relevant sites (e.g. active sites, substrate-binding subsites,
   * metal-coordination sites).
   */
  struct_site: {
    /**
     * A description of special aspects of the site.
     */
    details: ve,
    /**
     * The value of _struct_site.id must uniquely identify a record in
     * the STRUCT_SITE list.
     *
     * Note that this item need not be a number; it can be any unique
     * identifier.
     */
    id: ve,
    /**
     * Number of residues in the site.
     */
    pdbx_num_residues: Ie,
    /**
     * Source of evidence supporting the assignment of this site.
     */
    pdbx_evidence_code: ve,
    /**
     * A component of the identifier for the ligand in the site.
     *
     * This data item is a pointer to _atom_site.auth_asym_id in the
     * ATOM_SITE category.
     */
    pdbx_auth_asym_id: ve,
    /**
     * A component of the identifier for the ligand in the site.
     *
     * This data item is a pointer to _atom_site.auth_comp_id in the
     * ATOM_SITE category.
     */
    pdbx_auth_comp_id: ve,
    /**
     * A component of the identifier for the ligand in the site.
     *
     * This data item is a pointer to _atom_site.auth_seq_id in the
     * ATOM_SITE category.
     */
    pdbx_auth_seq_id: ve,
    /**
     * PDB insertion code for the ligand in the site.
     */
    pdbx_auth_ins_code: ve
  },
  /**
   * Data items in the STRUCT_SITE_GEN category record details about
   * the generation of portions of the structure that contribute to
   * structurally relevant sites.
   */
  struct_site_gen: {
    /**
     * A description of special aspects of the symmetry generation of
     * this portion of the structural site.
     */
    details: ve,
    /**
     * The value of _struct_site_gen.id must uniquely identify a record
     * in the STRUCT_SITE_GEN list.
     *
     * Note that this item need not be a number; it can be any unique
     * identifier.
     */
    id: ve,
    /**
     * A component of the identifier for participants in the site.
     *
     * This data item is a pointer to _atom_sites_alt.id in the
     * ATOM_SITES_ALT category.
     */
    label_alt_id: ve,
    /**
     * A component of the identifier for participants in the site.
     *
     * This data item is a pointer to _atom_site.label_asym_id in the
     * ATOM_SITE category.
     */
    label_asym_id: ve,
    /**
     * A component of the identifier for participants in the site.
     *
     * This data item is a pointer to _chem_comp_atom.atom_id in the
     * CHEM_COMP_ATOM category.
     */
    label_atom_id: ve,
    /**
     * A component of the identifier for participants in the site.
     *
     * This data item is a pointer to _atom_site.label_comp_id in the
     * ATOM_SITE category.
     */
    label_comp_id: ve,
    /**
     * A component of the identifier for participants in the site.
     *
     * This data item is a pointer to _atom_site.label_seq_id in the
     * ATOM_SITE category.
     */
    label_seq_id: Ie,
    /**
     * A component of the identifier for participants in the site.
     *
     * This data item is a pointer to _atom_site.auth_asym_id in the
     * ATOM_SITE category.
     */
    auth_asym_id: ve,
    /**
     * A component of the identifier for participants in the site.
     *
     * This data item is a pointer to _atom_site.auth_comp_id in the
     * ATOM_SITE category.
     */
    auth_comp_id: ve,
    /**
     * A component of the identifier for participants in the site.
     *
     * This data item is a pointer to _atom_site.auth_seq_id in the
     * ATOM_SITE category.
     */
    auth_seq_id: ve,
    /**
     * This data item is a pointer to _struct_site.id in the STRUCT_SITE
     * category.
     */
    site_id: ve,
    /**
     * Describes the symmetry operation that should be applied to the
     * atom set specified by _struct_site_gen.label* to generate a
     * portion of the site.
     */
    symmetry: ve,
    /**
     * PDB insertion code.
     */
    pdbx_auth_ins_code: ve,
    /**
     * Number of residues in the site.
     */
    pdbx_num_res: Ie
  },
  /**
   * Data items in the SYMMETRY category record details about the
   * space-group symmetry.
   */
  symmetry: {
    /**
     * This data item is a pointer to _entry.id in the ENTRY category.
     */
    entry_id: ve,
    /**
     * The cell settings for this space-group symmetry.
     */
    cell_setting: $e(ve),
    /**
     * Space-group number from International Tables for Crystallography
     * Vol. A (2002).
     */
    Int_Tables_number: Ie,
    /**
     * Space-group symbol as described by Hall (1981). This symbol
     * gives the space-group setting explicitly. Leave spaces between
     * the separate components of the symbol.
     *
     * Ref: Hall, S. R. (1981). Acta Cryst. A37, 517-525; erratum
     * (1981) A37, 921.
     */
    space_group_name_Hall: ve,
    /**
     * Hermann-Mauguin space-group symbol. Note that the
     * Hermann-Mauguin symbol does not necessarily contain complete
     * information about the symmetry and the space-group origin. If
     * used, always supply the FULL symbol from International Tables
     * for Crystallography Vol. A (2002) and indicate the origin and
     * the setting if it is not implicit. If there is any doubt that
     * the equivalent positions can be uniquely deduced from this
     * symbol, specify the  _symmetry_equiv.pos_as_xyz or
     * _symmetry.space_group_name_Hall  data items as well. Leave
     * spaces between symbols referring to
     * different axes.
     */
    "space_group_name_H-M": ve
  },
  /**
   * These are internal RCSB records to keep track of data processing
   * and status of the entry.
   */
  pdbx_database_status: {
    /**
     * Code for status of file.
     */
    status_code: $e(ve),
    /**
     * Code for status of structure factor file.
     */
    status_code_sf: $e(ve),
    /**
     * Code for status of NMR constraints file.
     */
    status_code_mr: $e(ve),
    /**
     * The value of _pdbx_database_status.entry_id identifies the data block.
     */
    entry_id: ve,
    /**
     * The date of initial deposition.  (The first message for
     * deposition has been received.)
     */
    recvd_initial_deposition_date: ve,
    /**
     * This code indicates whether the entry belongs to
     * Structural Genomics Project.
     */
    SG_entry: $e(ve),
    /**
     * The site where the file was deposited.
     */
    deposit_site: $e(ve),
    /**
     * The site where the file was deposited.
     */
    process_site: $e(ve),
    /**
     * Code for status of chemical shift data file.
     */
    status_code_cs: $e(ve),
    /**
     * The methods development category in which this
     * entry has been placed.
     */
    methods_development_category: $e(ve),
    /**
     * A flag indicating that the entry is compatible with the PDB format.
     *
     * A value of 'N' indicates that the no PDB format data file is
     * corresponding to this entry is available in the PDB archive.
     */
    pdb_format_compatible: $e(ve)
  },
  /**
   * The PDBX_NONPOLY_SCHEME category provides residue level nomenclature
   * mapping for non-polymer entities.
   */
  pdbx_nonpoly_scheme: {
    /**
     * Pointer to _atom_site.label_asym_id.
     */
    asym_id: ve,
    /**
     * Pointer to _atom_site.label_entity_id.
     */
    entity_id: ve,
    /**
     * Pointer to _atom_site.label_comp_id.
     */
    mon_id: ve,
    /**
     * PDB strand/chain id.
     */
    pdb_strand_id: ve,
    /**
     * NDB/RCSB residue number.
     */
    ndb_seq_num: ve,
    /**
     * PDB residue number.
     */
    pdb_seq_num: ve,
    /**
     * Author provided residue numbering.   This value may differ from the PDB residue
     * number and may not correspond to residue numbering within the coordinate records.
     */
    auth_seq_num: ve,
    /**
     * PDB residue identifier.
     */
    pdb_mon_id: ve,
    /**
     * Author provided residue identifier.   This value may differ from the PDB residue
     * identifier and may not correspond to residue identification within the coordinate records.
     */
    auth_mon_id: ve,
    /**
     * PDB insertion code.
     */
    pdb_ins_code: ve
  },
  /**
   * Data items in PDBX_DATABASE_RELATED contain references to entries
   * that are related to the this entry.
   */
  pdbx_database_related: {
    /**
     * The name of the database containing the related entry.
     */
    db_name: ve,
    /**
     * A description of the related entry.
     */
    details: ve,
    /**
     * The identifying code in the related database.
     */
    db_id: ve,
    /**
     * The identifying content type of the related entry.
     */
    content_type: $e(ve)
  },
  /**
   * The PDBX_ENTITY_NONPOLY category provides a mapping between
   * entity and the nonpolymer component
   */
  pdbx_entity_nonpoly: {
    /**
     * This data item is a pointer to _entity.id in the ENTITY category.
     */
    entity_id: ve,
    /**
     * This data item is a pointer to _chem_comp.id in the CHEM_COMP category.
     */
    comp_id: ve,
    /**
     * A name for the non-polymer entity
     */
    name: ve
  },
  /**
   * PDBX_CHEM_COMP_SYNONYMS holds chemical name and synonym correspondences.
   */
  pdbx_chem_comp_synonyms: {
    /**
     * The synonym of this particular chemical component.
     */
    name: ve,
    /**
     * The chemical component for which this synonym applies.
     */
    comp_id: ve,
    /**
     * The provenance of this synonym.
     */
    provenance: $e(ve)
  },
  /**
   * Data items in the CHEM_COMP_IDENTIFIER category provide
   * identifiers for chemical components.
   */
  pdbx_chem_comp_identifier: {
    /**
     * This data item is a pointer to _chem_comp.id in the CHEM_COMP
     * category.
     */
    comp_id: ve,
    /**
     * This data item contains the identifier value for this
     * component.
     */
    identifier: ve,
    /**
     * This data item contains the identifier type.
     */
    type: $e(ve),
    /**
     * This data item contains the name of the program
     * or library used to compute the identifier.
     */
    program: ve,
    /**
     * This data item contains the version of the program
     * or library used to compute the identifier.
     */
    program_version: ve
  },
  /**
   * Data items in the PDBX_UNOBS_OR_ZERO_OCC_RESIDUES category list the
   * residues within the entry that are not observed or have zero occupancy.
   */
  pdbx_unobs_or_zero_occ_residues: {
    /**
     * The value of _pdbx_unobs_or_zero_occ_residues.id must uniquely identify
     * each item in the PDBX_UNOBS_OR_ZERO_OCC_RESIDUES list.
     *
     * This is an integer serial number.
     */
    id: Ie,
    /**
     * The value of polymer flag indicates whether the unobserved or
     * zero occupancy residue is part of a polymer chain or not
     */
    polymer_flag: $e(ve),
    /**
     * The value of occupancy flag indicates whether the residue
     * is unobserved (= 1) or the coordinates have an occupancy of zero (=0)
     */
    occupancy_flag: $e(Ie),
    /**
     * Part of the identifier for the unobserved or zero occupancy residue.
     *
     * This data item is a pointer to _atom_site.pdbx_PDB_model_num in the
     * ATOM_SITE category.
     */
    PDB_model_num: Ie,
    /**
     * Part of the identifier for the unobserved or zero occupancy residue.
     *
     * This data item is a pointer to _atom_site.auth_asym_id in the
     * ATOM_SITE category.
     */
    auth_asym_id: ve,
    /**
     * Part of the identifier for the unobserved or zero occupancy residue.
     *
     * This data item is a pointer to _atom_site.auth_comp_id in the
     * ATOM_SITE category.
     */
    auth_comp_id: ve,
    /**
     * Part of the identifier for the unobserved or zero occupancy residue.
     *
     * This data item is a pointer to _atom_site.auth_seq_id in the
     * ATOM_SITE category.
     */
    auth_seq_id: ve,
    /**
     * Part of the identifier for the unobserved or zero occupancy residue.
     *
     * This data item is a pointer to _atom_site.pdbx_PDB_ins_code in the
     * ATOM_SITE category.
     */
    PDB_ins_code: ve,
    /**
     * Part of the identifier for the unobserved or zero occupancy residue.
     *
     * This data item is a pointer to _atom_site.label_asym_id in the
     * ATOM_SITE category.
     */
    label_asym_id: ve,
    /**
     * Part of the identifier for the unobserved or zero occupancy residue.
     *
     * This data item is a pointer to _atom_site.label_comp_id in the
     * ATOM_SITE category.
     */
    label_comp_id: ve,
    /**
     * Part of the identifier for the unobserved or zero occupancy residue.
     *
     * This data item is a pointer to _atom_site.label_seq_id in the
     * ATOM_SITE category.
     */
    label_seq_id: Ie
  },
  /**
   * Data items in the PDBX_STRUCT_MOD_RESIDUE category list the
   * modified polymer components in the entry and provide some
   * details describing the nature of the modification.
   */
  pdbx_struct_mod_residue: {
    /**
     * The value of _pdbx_struct_mod_residue.id must uniquely identify
     * each item in the PDBX_STRUCT_MOD_RESIDUE list.
     *
     * This is an integer serial number.
     */
    id: Ie,
    /**
     * Part of the identifier for the modified polymer component.
     *
     * This data item is a pointer to _atom_site.auth_asym_id in the
     * ATOM_SITE category.
     */
    auth_asym_id: ve,
    /**
     * Part of the identifier for the modified polymer component.
     *
     * This data item is a pointer to _atom_site.auth_comp_id in the
     * ATOM_SITE category.
     */
    auth_comp_id: ve,
    /**
     * Part of the identifier for the modified polymer component.
     *
     * This data item is a pointer to _atom_site.auth_seq_id in the
     * ATOM_SITE category.
     */
    auth_seq_id: Ie,
    /**
     * Part of the identifier for the modified polymer component.
     *
     * This data item is a pointer to _atom_site.pdbx_PDB_ins_code in the
     * ATOM_SITE category.
     */
    PDB_ins_code: ve,
    /**
     * Part of the identifier for the modified polymer component.
     *
     * This data item is a pointer to _atom_site.label_asym_id in the
     * ATOM_SITE category.
     */
    label_asym_id: ve,
    /**
     * Part of the identifier for the modified polymer component.
     *
     * This data item is a pointer to _atom_site.label_comp_id in the
     * ATOM_SITE category.
     */
    label_comp_id: ve,
    /**
     * Part of the identifier for the unobserved or zero occupancy residue.
     *
     * This data item is a pointer to _atom_site.label_seq_id in the
     * ATOM_SITE category.
     */
    label_seq_id: Ie,
    /**
     * The parent component identifier for this modified polymer component.
     */
    parent_comp_id: ve,
    /**
     * Details of the modification for this polymer component.
     */
    details: ve
  },
  /**
   * Data items in the PDBX_STRUCT_OPER_LIST category describe
   * Cartesian rotation and translation operations required to
   * generate or transform the coordinates deposited with this entry.
   */
  pdbx_struct_oper_list: {
    /**
     * This identifier code must uniquely identify a
     * record in the PDBX_STRUCT_OPER_LIST list.
     */
    id: ve,
    /**
     * A code to indicate the type of operator.
     */
    type: $e(ve),
    /**
     * A descriptive name for the transformation operation.
     */
    name: ve,
    /**
     * The symmetry operation corresponding to the transformation operation.
     */
    symmetry_operation: ve,
    /**
     * The elements of the 3x3 matrix component of the
     * transformation operation.
     */
    matrix: Oc(3, 3),
    /**
     * The elements of the three-element vector component of the
     * transformation operation.
     */
    vector: r2(3)
  },
  /**
   * Data items in the PDBX_STRUCT_ASSEMBLY category record details about
   * the structural elements that form macromolecular assemblies.
   */
  pdbx_struct_assembly: {
    /**
     * Provides details of the method used to determine or
     * compute the assembly.
     */
    method_details: ve,
    /**
     * Provides the details of the oligomeric state of the assembly.
     */
    oligomeric_details: ve,
    /**
     * The number of polymer molecules in the assembly.
     */
    oligomeric_count: Ie,
    /**
     * A description of special aspects of the macromolecular assembly.
     *
     * In the PDB, 'representative helical assembly', 'complete point assembly',
     * 'complete icosahedral assembly', 'software_defined_assembly', 'author_defined_assembly',
     * and 'author_and_software_defined_assembly' are considered "biologically relevant assemblies.
     */
    details: ve,
    /**
     * The value of _pdbx_struct_assembly.id must uniquely identify a record in
     * the PDBX_STRUCT_ASSEMBLY list.
     */
    id: ve
  },
  /**
   * Data items in the PDBX_STRUCT_ASSEMBLY_GEN category record details about
   * the generation of each macromolecular assemblies. The PDBX_STRUCT_ASSEMBLY_GEN
   * data items provide the specifications of the components that
   * constitute that assembly in terms of cartesian transformations.
   */
  pdbx_struct_assembly_gen: {
    /**
     * This data item is a pointer to _struct_asym.id in
     * the STRUCT_ASYM category.
     *
     * This item may be expressed as a comma separated list of identifiers.
     */
    asym_id_list: gf(",", function(e) {
      return e;
    }),
    /**
     * This data item is a pointer to _pdbx_struct_assembly.id in the
     * PDBX_STRUCT_ASSEMBLY category.
     */
    assembly_id: ve,
    /**
     * Identifies the operation of collection of operations
     * from category PDBX_STRUCT_OPER_LIST.
     *
     * Operation expressions may have the forms:
     *
     * (1)        the single operation 1
     * (1,2,5)    the operations 1, 2, 5
     * (1-4)      the operations 1,2,3 and 4
     * (1,2)(3,4) the combinations of operations
     * 3 and 4 followed by 1 and 2 (i.e.
     * the cartesian product of parenthetical
     * groups applied from right to left)
     */
    oper_expression: ve
  },
  /**
   * Data items in the PDBX_REFERENCE_ENTITY_LIST category record
   * the list of entities within each reference molecule.
   */
  pdbx_reference_entity_list: {
    /**
     * The value of _pdbx_reference_entity_list.prd_id is a reference
     * _pdbx_reference_molecule.prd_id in the PDBX_REFERENCE_MOLECULE category.
     */
    prd_id: ve,
    /**
     * The value of _pdbx_reference_entity_list.ref_entity_id is a unique identifier
     * the a constituent entity within this reference molecule.
     */
    ref_entity_id: ve,
    /**
     * Defines the polymer characteristic of the entity.
     */
    type: $e(ve),
    /**
     * Additional details about this entity.
     */
    details: ve,
    /**
     * The component number of this entity within the molecule.
     */
    component_id: Ie
  },
  /**
   * Data items in the PDBX_REFERENCE_ENTITY_LINK category give details about
   * the linkages between entities within reference molecules.
   */
  pdbx_reference_entity_link: {
    /**
     * The value of _pdbx_reference_entity_link.link_id uniquely identifies
     * linkages between entities with a molecule.
     */
    link_id: Ie,
    /**
     * The value of _pdbx_reference_entity_link.prd_id is a reference
     * _pdbx_reference_entity_list.prd_id in the PDBX_REFERENCE_ENTITY_LIST category.
     */
    prd_id: ve,
    /**
     * A description of special aspects of a linkage between
     * chemical components in the structure.
     */
    details: ve,
    /**
     * The reference entity id of the first of the two entities joined by the
     * linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_list.ref_entity_id
     * in the PDBX_REFERENCE_ENTITY_LIST category.
     */
    ref_entity_id_1: ve,
    /**
     * The reference entity id of the second of the two entities joined by the
     * linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_list.ref_entity_id
     * in the PDBX_REFERENCE_ENTITY_LIST category.
     */
    ref_entity_id_2: ve,
    /**
     * For a polymer entity, the sequence number in the first of
     * the two entities containing the linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_poly_seq.num
     * in the PDBX_REFERENCE_ENTITY_POLY_SEQ category.
     */
    entity_seq_num_1: Ie,
    /**
     * For a polymer entity, the sequence number in the second of
     * the two entities containing the linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_poly_seq.num
     * in the PDBX_REFERENCE_ENTITY_POLY_SEQ category.
     */
    entity_seq_num_2: Ie,
    /**
     * The component identifier in the first of the two entities containing the linkage.
     *
     * For polymer entities, this data item is a pointer to _pdbx_reference_entity_poly_seq.mon_id
     * in the PDBX_REFERENCE_ENTITY_POLY_SEQ category.
     *
     * For non-polymer entities, this data item is a pointer to
     * _pdbx_reference_entity_nonpoly.chem_comp_id in the
     * PDBX_REFERENCE_ENTITY_NONPOLY category.
     */
    comp_id_1: ve,
    /**
     * The component identifier in the second of the two entities containing the linkage.
     *
     * For polymer entities, this data item is a pointer to _pdbx_reference_entity_poly_seq.mon_id
     * in the PDBX_REFERENCE_ENTITY_POLY_SEQ category.
     *
     * For non-polymer entities, this data item is a pointer to
     * _pdbx_reference_entity_nonpoly.chem_comp_id in the
     * PDBX_REFERENCE_ENTITY_NONPOLY category.
     */
    comp_id_2: ve,
    /**
     * The atom identifier/name in the first of the two entities containing the linkage.
     */
    atom_id_1: ve,
    /**
     * The atom identifier/name in the second of the two entities containing the linkage.
     */
    atom_id_2: ve,
    /**
     * The bond order target for the chemical linkage.
     */
    value_order: $e(ve),
    /**
     * The entity component identifier for the first of two entities containing the linkage.
     */
    component_1: Ie,
    /**
     * The entity component identifier for the second of two entities containing the linkage.
     */
    component_2: Ie,
    /**
     * A code indicating the entity types involved in the linkage.
     */
    link_class: $e(ve)
  },
  /**
   * Data items in the PDBX_REFERENCE_ENTITY_POLY_LINK category give details about
   * polymer linkages including both standard and non-standard linkages between
   * polymer componnents.
   */
  pdbx_reference_entity_poly_link: {
    /**
     * The value of _pdbx_reference_entity_poly_link.link_id uniquely identifies
     * a linkage within a polymer entity.
     */
    link_id: Ie,
    /**
     * The value of _pdbx_reference_entity_poly_link.prd_id is a reference
     * _pdbx_reference_entity_list.prd_id in the PDBX_REFERENCE_ENTITY_POLY category.
     */
    prd_id: ve,
    /**
     * The reference entity id of the polymer entity containing the linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_poly.ref_entity_id
     * in the PDBX_REFERENCE_ENTITY_POLY category.
     */
    ref_entity_id: ve,
    /**
     * The entity component identifier entity containing the linkage.
     */
    component_id: Ie,
    /**
     * For a polymer entity, the sequence number in the first of
     * the two components making the linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_poly_seq.num
     * in the PDBX_REFERENCE_ENTITY_POLY_SEQ category.
     */
    entity_seq_num_1: Ie,
    /**
     * For a polymer entity, the sequence number in the second of
     * the two components making the linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_poly_seq.num
     * in the PDBX_REFERENCE_ENTITY_POLY_SEQ category.
     */
    entity_seq_num_2: Ie,
    /**
     * The component identifier in the first of the two components making the
     * linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_poly_seq.mon_id
     * in the PDBX_REFERENCE_ENTITY_POLY_SEQ category.
     */
    comp_id_1: ve,
    /**
     * The component identifier in the second of the two components making the
     * linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_poly_seq.mon_id
     * in the PDBX_REFERENCE_ENTITY_POLY_SEQ category.
     */
    comp_id_2: ve,
    /**
     * The atom identifier/name in the first of the two components making
     * the linkage.
     */
    atom_id_1: ve,
    /**
     * The atom identifier/name in the second of the two components making
     * the linkage.
     */
    atom_id_2: ve,
    /**
     * The bond order target for the non-standard linkage.
     */
    value_order: $e(ve)
  },
  /**
   * Data items in the PDBX_MOLECULE category identify reference molecules
   * within a PDB entry.
   */
  pdbx_molecule: {
    /**
     * The value of _pdbx_molecule.prd_id is the PDB accession code for this
     * reference molecule.
     */
    prd_id: ve,
    /**
     * The value of _pdbx_molecule.instance_id is identifies a particular molecule
     * in the molecule list.
     */
    instance_id: Ie,
    /**
     * A reference to _struct_asym.id in the STRUCT_ASYM category.
     */
    asym_id: ve
  },
  /**
   * Data items in the PDBX_MOLECULE_FEATURES category record features of molecules
   * within a PDB entry.
   */
  pdbx_molecule_features: {
    /**
     * The value of _pdbx_molecule_features.prd_id is the accession code for this
     * reference molecule.
     */
    prd_id: ve,
    /**
     * Broadly defines the function of the molecule.
     */
    class: $e(ve),
    /**
     * Defines the structural classification of the molecule.
     */
    type: $e(ve),
    /**
     * A name of the molecule.
     */
    name: ve,
    /**
     * Additional details describing the molecule.
     */
    details: ve
  },
  /**
   * Data items in the ENTITY_SRC_NAT category record details of
   * the source from which the entity was obtained in cases
   * where the entity was isolated directly from a natural tissue.
   */
  entity_src_nat: {
    /**
     * This data item is a pointer to _entity.id in the ENTITY category.
     */
    entity_id: ve,
    /**
     * Scientific name of the organism of the natural source.
     */
    pdbx_organism_scientific: ve,
    /**
     * The plasmid containing the gene.
     */
    pdbx_plasmid_name: ve,
    /**
     * This data item is an ordinal identifier for entity_src_nat data records.
     */
    pdbx_src_id: Ie,
    /**
     * The beginning polymer sequence position for the polymer section corresponding
     * to this source.
     *
     * A reference to the sequence position in the entity_poly category.
     */
    pdbx_beg_seq_num: Ie,
    /**
     * The ending polymer sequence position for the polymer section corresponding
     * to this source.
     *
     * A reference to the sequence position in the entity_poly category.
     */
    pdbx_end_seq_num: Ie
  },
  /**
   * Data items in the ENTITY_SRC_GEN category record details of
   * the source from which the entity was obtained in cases
   * where the source was genetically manipulated.  The
   * following are treated separately:  items pertaining to the tissue
   * from which the gene was obtained, items pertaining to the host
   * organism for gene expression and items pertaining to the actual
   * producing organism (plasmid).
   */
  entity_src_gen: {
    /**
     * This data item is a pointer to _entity.id in the ENTITY category.
     */
    entity_id: ve,
    /**
     * Identifies the gene.
     */
    pdbx_gene_src_gene: gf(",", function(e) {
      return e;
    }),
    /**
     * Scientific name of the organism.
     */
    pdbx_gene_src_scientific_name: ve,
    /**
     * The name of the plasmid that produced the entity in the host
     * organism. Where full details of the protein production are available
     * it would be expected that this item would be derived from
     * _pdbx_construct.name of the construct pointed to from
     * _entity_src_gen_express.plasmid_id.
     */
    plasmid_name: ve,
    /**
     * This data item is an ordinal identifier for entity_src_gen data records.
     */
    pdbx_src_id: Ie,
    /**
     * The beginning polymer sequence position for the polymer section corresponding
     * to this source.
     *
     * A reference to the sequence position in the entity_poly category.
     */
    pdbx_beg_seq_num: Ie,
    /**
     * The ending polymer sequence position for the polymer section corresponding
     * to this source.
     *
     * A reference to the sequence position in the entity_poly category.
     */
    pdbx_end_seq_num: Ie
  },
  /**
   * The data items in category PDBX_ENTITY_SRC_SYN record the source details
   * about chemically synthesized molecules.
   */
  pdbx_entity_src_syn: {
    /**
     * The scientific name of the organism from which the sequence of
     * the synthetic entity was derived.
     */
    organism_scientific: ve,
    /**
     * This data item is a pointer to _entity.id in the ENTITY category.
     */
    entity_id: ve,
    /**
     * This data item is an ordinal identifier for pdbx_entity_src_syn data records.
     */
    pdbx_src_id: Ie,
    /**
     * The beginning polymer sequence position for the polymer section corresponding
     * to this source.
     *
     * A reference to the sequence position in the entity_poly category.
     */
    pdbx_beg_seq_num: Ie,
    /**
     * The ending polymer sequence position for the polymer section corresponding
     * to this source.
     *
     * A reference to the sequence position in the entity_poly category.
     */
    pdbx_end_seq_num: Ie
  },
  /**
   * Data items in the PDBX_ENTITY_BRANCH_DESCRIPTOR category provide
   * string descriptors of entity chemical structure.
   */
  pdbx_entity_branch_descriptor: {
    /**
     * This data item is a pointer to _entity_poly.entity_id in the ENTITY
     * category.
     */
    entity_id: ve,
    /**
     * This data item contains the descriptor value for this
     * entity.
     */
    descriptor: ve,
    /**
     * This data item contains the descriptor type.
     */
    type: $e(ve),
    /**
     * This data item contains the name of the program
     * or library used to compute the descriptor.
     */
    program: ve,
    /**
     * This data item contains the version of the program
     * or library used to compute the descriptor.
     */
    program_version: ve,
    /**
     * Ordinal index for this category.
     */
    ordinal: Ie
  },
  /**
   * Data items in the pdbx_entity_instance_feature category records
   * special features of selected entity instances.
   */
  pdbx_entity_instance_feature: {
    /**
     * Special structural details about this entity instance.
     */
    details: ve,
    /**
     * A feature type associated with entity instance.
     */
    feature_type: $e(ve),
    /**
     * Author instance identifier (formerly PDB Chain ID)
     */
    auth_asym_id: ve,
    /**
     * Instance identifier for this entity.
     */
    asym_id: ve,
    /**
     * Author provided residue number.
     */
    auth_seq_num: ve,
    /**
     * Position in the sequence.
     */
    seq_num: Ie,
    /**
     * Chemical component identifier
     */
    comp_id: ve,
    /**
     * The author provided chemical component identifier
     */
    auth_comp_id: ve,
    /**
     * An ordinal index for this category
     */
    ordinal: Ie
  },
  /**
   * Data items in the PDBX_ENTITY_BRANCH_LIST category specify the list
   * of monomers in a branched entity.  Allowance is made for the possibility
   * of microheterogeneity in a sample by allowing a given sequence
   * number to be correlated with more than one monomer ID. The
   * corresponding ATOM_SITE entries should reflect this
   * heterogeneity.
   */
  pdbx_entity_branch_list: {
    /**
     * This data item is a pointer to _entity.id in the ENTITY category.
     */
    entity_id: ve,
    /**
     * A flag to indicate whether this monomer in the entity is
     * heterogeneous in sequence.
     */
    hetero: $e(ve),
    /**
     * This data item is a pointer to _chem_comp.id in the CHEM_COMP
     * category.
     */
    comp_id: ve,
    /**
     * The value pair  _pdbx_entity_branch_list.num and _pdbx_entity_branch_list.comp_id
     * must uniquely identify a record in the PDBX_ENTITY_BRANCH_LIST list.
     */
    num: Ie
  },
  /**
   * Data items in the PDBX_ENTITY_BRANCH_LINK category give details about
   * the linkages between components within a branched entity.
   */
  pdbx_entity_branch_link: {
    /**
     * The value of _pdbx_entity_branch_link.link_id uniquely identifies
     * linkages within the branched entity.
     */
    link_id: Ie,
    /**
     * A description of special aspects of this linkage.
     */
    details: ve,
    /**
     * The entity id for this branched entity.
     *
     * This data item is a pointer to _pdbx_entity_branch_list.entity_id
     * in the PDBX_ENTITY_BRANCH_LIST category.
     */
    entity_id: ve,
    /**
     * The component number for the first component making the linkage.
     *
     * This data item is a pointer to _pdbx_entity_branch_list.num
     * in the PDBX_ENTITY_BRANCH_LIST category.
     */
    entity_branch_list_num_1: Ie,
    /**
     * The component number for the second component making the linkage.
     *
     * This data item is a pointer to _pdbx_entity_branch_list.num
     * in the PDBX_ENTITY_BRANCH_LIST category.
     */
    entity_branch_list_num_2: Ie,
    /**
     * The component identifier for the first component making the linkage.
     *
     * This data item is a pointer to _pdbx_entity_branch_list.comp_id
     * in the PDBX_ENTITY_BRANCH_LIST category.
     */
    comp_id_1: ve,
    /**
     * The component identifier for the second component making the linkage.
     *
     * This data item is a pointer to _pdbx_entity_branch_list.comp_id
     * in the PDBX_ENTITY_BRANCH_LIST category.
     */
    comp_id_2: ve,
    /**
     * The atom identifier/name for the first atom making the linkage.
     */
    atom_id_1: ve,
    /**
     * The leaving atom identifier/name bonded to the first atom making the linkage.
     */
    leaving_atom_id_1: ve,
    /**
     * The chiral configuration of the first atom making the linkage.
     */
    atom_stereo_config_1: $e(ve),
    /**
     * The atom identifier/name for the second atom making the linkage.
     */
    atom_id_2: ve,
    /**
     * The leaving atom identifier/name bonded to the second atom making the linkage.
     */
    leaving_atom_id_2: ve,
    /**
     * The chiral configuration of the second atom making the linkage.
     */
    atom_stereo_config_2: $e(ve),
    /**
     * The bond order target for the chemical linkage.
     */
    value_order: $e(ve)
  },
  /**
   * Data items in the PDBX_ENTITY_BRANCH category specify the list
   * of branched entities and the type.
   */
  pdbx_entity_branch: {
    /**
     * The entity id for this branched entity.
     *
     * This data item is a pointer to _entity.id
     */
    entity_id: ve,
    /**
     * The type of this branched oligosaccharide.
     */
    type: $e(ve)
  },
  /**
   * The PDBX_BRANCH_SCHEME category provides residue level nomenclature
   * mapping for branch chain entities.
   */
  pdbx_branch_scheme: {
    /**
     * This data item is a pointer to _entity.id in the ENTITY category.
     */
    entity_id: ve,
    /**
     * A flag to indicate whether this monomer in the entity is
     * heterogeneous in sequence.
     */
    hetero: $e(ve),
    /**
     * Pointer to _atom_site.label_asym_id.
     */
    asym_id: ve,
    /**
     * This data item is a pointer to _atom_site.label_comp_id in the
     * PDBX_ENTITY_BRANCH_LIST category.
     */
    mon_id: ve,
    /**
     * This data item is a pointer to _pdbx_entity_branch_list.num in the
     * PDBX_ENTITY_BRANCH_LIST category.
     */
    num: Ie,
    /**
     * This data item is a pointer to _atom_site.auth_asym_id in the
     * ATOM_SITE category.
     */
    pdb_asym_id: ve,
    /**
     * This data item is a pointer to _atom_site.auth_seq_id in the
     * ATOM_SITE category.
     */
    pdb_seq_num: ve,
    /**
     * This data item is a pointer to _atom_site.auth_comp_id in the
     * ATOM_SITE category.
     */
    pdb_mon_id: ve,
    /**
     * This data item is a pointer to _atom_site.pdbx_auth_asym_id in the
     * ATOM_SITE category.
     */
    auth_asym_id: ve,
    /**
     * This data item is a pointer to _atom_site.pdbx_auth_seq_id in the
     * ATOM_SITE category.
     */
    auth_seq_num: ve,
    /**
     * This data item is a pointer to _atom_site.pdbx_auth_comp_id in the
     * ATOM_SITE category.
     */
    auth_mon_id: ve
  },
  /**
   * PDBX_CHEM_COMP_RELATED describes the relationship between two chemical components.
   */
  pdbx_chem_comp_related: {
    /**
     * The chemical component for which this relationship applies.
     */
    comp_id: ve,
    /**
     * The related chemical component for which this chemical component is based.
     */
    related_comp_id: ve,
    /**
     * Describes the type of relationship
     */
    relationship_type: $e(ve),
    /**
     * Describes the type of relationship
     */
    details: ve
  },
  /**
   * Data items in the IHM_STARTING_MODEL_DETAILS category records the
   * details about structural models used as starting inputs in
   * the integrative model building process.
   */
  ihm_starting_model_details: {
    /**
     * A unique identifier for the starting structural model.
     */
    starting_model_id: ve,
    /**
     * A unique identifier for the distinct molecular entities.
     * This data item is a pointer to _entity.id in the ENTITY category.
     */
    entity_id: ve,
    /**
     * A text description of the molecular entity
     */
    entity_description: ve,
    /**
     * An asym/strand identifier for the entity molecule.
     * This data item is a pointer to _struct_asym.id in the
     * STRUCT_ASYM category.
     */
    asym_id: ve,
    /**
     * The identifier for the polymeric segment modeled using this starting model.
     * This data item is a pointer to _ihm_entity_poly_segment.id in the
     * IHM_ENTITY_POLY_SEGMENT category.
     */
    entity_poly_segment_id: Ie,
    /**
     * The source of the starting model.
     */
    starting_model_source: $e(ve),
    /**
     * The author assigned chainId/auth_asym_id corresponding to this starting model.
     * This corresponds to the chainId/auth_asym_id of the experimental models in the
     * PDB or comparative models in the Model Archive or the starting models referenced
     * via a DOI. If starting models are included in IHM_STARTING_MODEL_COORD, then
     * this will be the same as _ihm_starting_model_details.asym_id.
     */
    starting_model_auth_asym_id: ve,
    /**
     * The offset in residue numbering between the starting model and the deposited I/H model, if applicable.
     * I/H model residue number = Starting model residue number + offset
     */
    starting_model_sequence_offset: Ie,
    /**
     * Identifier to the starting model (comparative, experimental or integrative)
     * used as input in the integrative modeling.
     * This data item is a pointer to the _ihm_dataset_list.id in the
     * IHM_DATASET_LIST category.
     */
    dataset_list_id: Ie
  },
  /**
   * Data items in the IHM_STARTING_COMPARATIVE_MODELS category records
   * additional details about comparative models used as starting inputs in
   * the integrative model building process.
   */
  ihm_starting_comparative_models: {
    /**
     * A unique identifier for the starting comparative model.
     */
    id: Ie,
    /**
     * The identifier for the starting structural model.
     * This data item is a pointer to _ihm_starting_model_details.starting_model_id
     * in the IHM_STARTING_MODEL_DETAILS category.
     */
    starting_model_id: ve,
    /**
     * The chainId/auth_asym_id corresponding to the starting model.
     */
    starting_model_auth_asym_id: ve,
    /**
     * The starting residue index of the starting model.
     */
    starting_model_seq_id_begin: Ie,
    /**
     * The ending residue index of the starting model.
     */
    starting_model_seq_id_end: Ie,
    /**
     * The chainId/auth_asym_id corresponding to the template.
     */
    template_auth_asym_id: ve,
    /**
     * The starting residue index of the template.
     */
    template_seq_id_begin: Ie,
    /**
     * The ending residue index of the template.
     */
    template_seq_id_end: Ie,
    /**
     * The percentage sequence identity between the template sequence and the comparative model sequence.
     */
    template_sequence_identity: yr,
    /**
     * The denominator used while calculating the sequence identity provided in
     * _ihm_starting_comparative_models.template_sequence_identity.
     */
    template_sequence_identity_denominator: $e(Ie),
    /**
     * The dataset list id corresponding to the template used to obtain the comparative model.
     * This data item is a pointer to _ihm_dataset_list.id in the IHM_DATASET_LIST category.
     */
    template_dataset_list_id: Ie,
    /**
     * The file id corresponding to the sequence alignment of the template sequence and the comparative model sequence.
     * This data item is a pointer to _ihm_external_files.id in the IHM_EXTERNAL_FILES category.
     */
    alignment_file_id: Ie
  },
  /**
   * Data items in the IHM_STARTING_MODEL_SEQ_DIF category provide a
   * mechanism for indicating and annotating point differences
   * between the sequence of the entity or biological unit described
   * in the data block and the sequence of the starting model used in
   * the integrative modeling referenced from a database. The point
   * differences may be due to point mutations introduced in the
   * starting model or the presence of modified amino acid residues.
   */
  ihm_starting_model_seq_dif: {
    /**
     * A unique identifier for the entry.
     */
    id: Ie,
    /**
     * A unique identifier for the distinct molecular entities.
     * This data item is a pointer to _entity_poly_seq.entity_id in the ENTITY_POLY category.
     */
    entity_id: ve,
    /**
     * An asym/strand identifier for the entity molecule.
     * This data item is a pointer to _struct_asym.id in the
     * STRUCT_ASYM category.
     */
    asym_id: ve,
    /**
     * The residue index.
     * This data item is a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category.
     */
    seq_id: Ie,
    /**
     * The component identifier for the residue.
     * This data item is a pointer to _entity_poly_seq.mon_id in the ENTITY_POLY_SEQ category.
     */
    comp_id: ve,
    /**
     * Unique identifier for the starting model record.
     * This data item is a pointer to _ihm_starting_model_details.starting_model_id in the
     * IHM_STARTING_MODEL_DETAILS category.
     */
    starting_model_id: ve,
    /**
     * The asym/strand identifier for the entity molecule of the database starting model.
     */
    db_asym_id: ve,
    /**
     * The corresponding residue index of the database starting model.
     */
    db_seq_id: Ie,
    /**
     * The correspinding component identifier for the residue in the database starting model.
     */
    db_comp_id: ve,
    /**
     * A description of special aspects of the point differences
     * between the sequence of the entity or biological unit described
     * in the data block and that in the starting model referenced
     * from a database.
     */
    details: ve
  },
  /**
   * Data items in the IHM_MODEL_REPRESENTATION category lists the
   * various mono or multi-scale model representations used in the
   * integrative modeling study.
   */
  ihm_model_representation: {
    /**
     * A unique identifier for the model representation.
     */
    id: Ie,
    /**
     * Name/brief description for the model representation.
     */
    name: ve,
    /**
     * Additional details about the model representation.
     */
    details: ve
  },
  /**
   * Data items in the IHM_MODEL_REPRESENTATION_DETAILS category records the
   * details about the architecture and representation of structural
   * models involved in the integrative modeling study.
   */
  ihm_model_representation_details: {
    /**
     * A unique identifier for the category.
     */
    id: Ie,
    /**
     * An identifier that collects or groups together a set of representations.
     * This data item is a pointer to _ihm_model_representation.id in the
     * IHM_MODEL_REPRESENTATION category.
     */
    representation_id: Ie,
    /**
     * The identifier for the polymeric segment in the representation.
     * This data item is a pointer to _ihm_entity_poly_segment.id in the
     * IHM_ENTITY_POLY_SEGMENT category.
     */
    entity_poly_segment_id: Ie,
    /**
     * A unique identifier distinct molecular entities.
     * This data item is a pointer to _entity.id in the
     * ENTITY category.
     */
    entity_id: ve,
    /**
     * A text description of the molecular entity
     */
    entity_description: ve,
    /**
     * An asym/strand identifier for the entity molecule.
     * This data item is a pointer to _struct_asym.id in the
     * STRUCT_ASYM category.
     */
    entity_asym_id: ve,
    /**
     * The primitive object used to model this segment.
     */
    model_object_primitive: $e(ve),
    /**
     * The identifier for the starting structural model.
     * This data item is a pointer to _ihm_starting_model_details.starting_model_id
     * in the IHM_STARTING_MODEL_DETAILS category.
     */
    starting_model_id: ve,
    /**
     * The manner in which the segment is modeled.
     */
    model_mode: $e(ve),
    /**
     * The level of detail at which model primitive objects are applied to the structure.
     */
    model_granularity: $e(ve),
    /**
     * The number of primitive objects used to model a feature in the case of 'by-feature' granularity.
     */
    model_object_count: Ie
  },
  /**
   * Data items in the IHM_STRUCT_ASSEMBLY_DETAILS category records
   * the details of the structural assemblies and used in the
   * integrative modeling.
   */
  ihm_struct_assembly_details: {
    /**
     * A unique identifier for the structural assembly description.
     */
    id: Ie,
    /**
     * An identifier for the structural assembly.
     * This data item will remain the same for all components
     * of an assembly.
     * This data item is a pointer to _ihm_struct_assembly.id
     * in the IHM_STRUCT_ASSEMBLY category.
     */
    assembly_id: Ie,
    /**
     * The parent of this assembly in a hierarchy.
     * This data item is a pointer to _ihm_struct_assembly.id in the
     * IHM_STRUCT_ASSEMBLY category.
     * This data item should point to the assembly id of the immediate
     * parent in a hierarchy.
     * By convention, the full assembly (top of hierarchy) is assigned parent id 0 (zero).
     * In case of assemblies that do not conform to a hierarchy,
     * _ihm_struct_assembly_details.parent_assembly_id is the same as
     * _ihm_struct_assembly_details.assembly_id indicating a self-parent.
     */
    parent_assembly_id: Ie,
    /**
     * A text description of the molecular entity
     */
    entity_description: ve,
    /**
     * A unique identifier for distinct molecular entities.
     * This data item is a pointer to _entity.id in the
     * ENTITY category.
     */
    entity_id: ve,
    /**
     * An asym/strand identifier for the component in the assembly.
     * This data item is a pointer to _struct_asym.id in the
     * STRUCT_ASYM category.
     */
    asym_id: ve,
    /**
     * The identifier for the polymeric segment in the assembly.
     * This data item is a pointer to _ihm_entity_poly_segment.id in the
     * IHM_ENTITY_POLY_SEGMENT category.
     */
    entity_poly_segment_id: Ie
  },
  /**
   * Data items in the IHM_STRUCT_ASSEMBLY category lists
   * all the structural assemblies used in the integrative
   * modeling study.
   */
  ihm_struct_assembly: {
    /**
     * A unique identifier for the structural assembly.
     */
    id: Ie,
    /**
     * A name for the structural assembly.
     */
    name: ve,
    /**
     * Description of the structural assembly.
     */
    description: ve
  },
  /**
   * Data items in the IHM_MODELING_PROTOCOL category lists all
   * modeling protocols used in the integrative modeling study.
   */
  ihm_modeling_protocol: {
    /**
     * A unique identifier for the modeling protocol.
     */
    id: Ie,
    /**
     * Number of independent steps in the modeling protocol.
     */
    num_steps: Ie,
    /**
     * The name for the modeling protocol.
     */
    protocol_name: ve
  },
  /**
   * Data items in the IHM_MODELING_PROTOCOL_DETAILS category records the
   * step-wise details of the integrative modeling workflow.
   */
  ihm_modeling_protocol_details: {
    /**
     * A unique identifier for the modeling protocol/step combination.
     */
    id: Ie,
    /**
     * An index for the modeling protocol carried out.
     * This data item is a pointer to _ihm_modeling_protocol.id in the
     * IHM_MODELING_PROTOCOL category.
     */
    protocol_id: Ie,
    /**
     * An index for a particular step within the modeling protocol.
     */
    step_id: Ie,
    /**
     * An index for the structural assembly being modeled.
     * This is an indicator to whether the whole assembly is modeled
     * or if only a subset of the structural assembly is modeled.
     * This data item is a pointer to _ihm_struct_assembly.id in the
     * IHM_STRUCT_ASSEMBLY category. The IHM_STRUCT_ASSEMBLY category provides the
     * details regarding the different structural assemblies used in the modeling.
     * The default value for this data item is "1", indicating that the entire
     * assembly is being modeled.
     */
    struct_assembly_id: Ie,
    /**
     * An index for the dataset group being used in the modeling protocol.
     * This data item is a pointer to the _ihm_dataset_group.id in the
     * IHM_DATASET_GROUP category.
     */
    dataset_group_id: Ie,
    /**
     * A textual description of the structural assembly being modeled.
     */
    struct_assembly_description: ve,
    /**
     * The name or type of the modeling step.
     */
    step_name: ve,
    /**
     * Description of the method involved in the modeling step.
     */
    step_method: ve,
    /**
     * The number of models in the beginning of the step.
     */
    num_models_begin: Ie,
    /**
     * The number of models at the end of the step.
     */
    num_models_end: Ie,
    /**
     * A flag to indicate if the modeling is multi scale.
     */
    multi_scale_flag: $e(ve),
    /**
     * A flag to indicate if the modeling is multi state.
     */
    multi_state_flag: $e(ve),
    /**
     * A flag to indicate if the modeling involves an ensemble ordered by time or other order.
     */
    ordered_flag: $e(ve),
    /**
     * The file id corresponding to the script used in the modeling protocol step.
     * This data item is a pointer to _ihm_external_files.id in the IHM_EXTERNAL_FILES category.
     */
    script_file_id: Ie,
    /**
     * Identifier to the software used in the modeling protocol step.
     * This data item is a pointer to the _software.pdbx_ordinal in the
     * SOFTWARE category.
     */
    software_id: Ie
  },
  /**
   * Data items in the IHM_MULTI_STATE_MODELING category records the
   * details of the multi-state modeling protocol, if applicable.
   */
  ihm_multi_state_modeling: {
    /**
     * A unique identifier for a particular state in the multi-state modeling.
     */
    state_id: Ie,
    /**
     * An identifier for a collections of states in the multi-state modeling.
     * This data item can be used when structural models belong to diffent
     * multi-state modeling types.
     */
    state_group_id: Ie,
    /**
     * A fraction representing the population of the particular state.
     */
    population_fraction: yr,
    /**
     * The standard deviation of the population fraction.
     */
    population_fraction_sd: yr,
    /**
     * The type that the multiple states being modeled belong to.
     */
    state_type: ve,
    /**
     * A descriptive name for the state.
     */
    state_name: ve,
    /**
     * The type of multi-state modeling experiment carried out.
     */
    experiment_type: $e(ve),
    /**
     * Additional textual details of the multi-state modeling, if required.
     */
    details: ve
  },
  /**
   * Data items in the IHM_MODELING_POST_PROCESS category records
   * the details of the post processing of the models/results of
   * the modeling protocol.
   */
  ihm_modeling_post_process: {
    /**
     * A unique identifier for the post modeling analysis/step combination.
     */
    id: Ie,
    /**
     * An identifier for the modeling protocol, whose post modeling analysis
     * is being carried out.
     * This data item is a pointer to the _ihm_modeling_protocol.id
     * in the IHM_MODELING_PROTOCOL category.
     */
    protocol_id: Ie,
    /**
     * An identifier for the post modeling analysis. This data item accounts for
     * multiple post-modeling analyses that can be carried out.
     */
    analysis_id: Ie,
    /**
     * In a multi-step process, this identifier denotes the particular
     * step in the post modeling analysis.
     */
    step_id: Ie,
    /**
     * The type of post modeling analysis being carried out.
     */
    type: $e(ve),
    /**
     * The parameter/feature used in the post modeling analysis.
     */
    feature: $e(ve),
    /**
     * The number of models at the beginning of the post processing step.
     */
    num_models_begin: Ie,
    /**
     * The number of models the the end of the post processing step.
     */
    num_models_end: Ie
  },
  /**
   * Data items in the IHM_ENSEMBLE_INFO category records the
   * details of the model clusters or ensembles obtained after
   * sampling.
   */
  ihm_ensemble_info: {
    /**
     * A unique id for the ensemble.
     */
    ensemble_id: Ie,
    /**
     * An optional name for the cluster or ensemble for better description.
     */
    ensemble_name: ve,
    /**
     * An identifier for the post modeling analyses carried out.
     * This data item is a pointer to _ihm_modeling_post_process.id in
     * the IHM_MODELING_POST_PROCESS category.
     */
    post_process_id: Ie,
    /**
     * An identifier for the cluster or group of models being deposited.
     * This data item is a pointer to the _ihm_model_group.id
     * in the IHM_MODEL_GROUP category.
     */
    model_group_id: Ie,
    /**
     * The clustering method used to obtain the ensemble, if applicable.
     */
    ensemble_clustering_method: $e(ve),
    /**
     * The parameter/feature used for clustering the models, if applicable.
     */
    ensemble_clustering_feature: $e(ve),
    /**
     * The number of models in the current ensemble being described.
     */
    num_ensemble_models: Ie,
    /**
     * The number of models from the current ensemble that is deposited.
     */
    num_ensemble_models_deposited: Ie,
    /**
     * The precision of each cluster or ensemble is calculated as dRMSD, which
     * is the average C-alpha distance root mean square deviation (dRMSD)
     * between the individual models in the cluster and the cluster centroid.
     * The cluster centroid is defined as the model with the minimal sum of
     * dRMSDs to the other models in the cluster or ensemble.
     */
    ensemble_precision_value: yr,
    /**
     * A reference to the external file containing the structural models
     * in the ensemble. The number of models in the external file should
     * correspond to the number of models in the ensemble. This data item
     * is a pointer to _ihm_external_files.id in the IHM_EXTERNAL_FILES
     * category.
     * It is recommended that the large ensemble files be stored as separate
     * zip files within the same DOI. It is also recommended that large sphere
     * model ensembles be in binary format, which facilitates faster access.
     * Currently, a binary dump of co-ordinates in dcd format is suggested.
     * The topology can be inferred from the IHM_SPHERE_OBJ_SITE and the
     * ATOM_SITE categories in the corresponding mmCIF file.
     */
    ensemble_file_id: Ie
  },
  /**
   * Data items in the IHM_MODEL_LIST category record the
   * details of the models being deposited.
   */
  ihm_model_list: {
    /**
     * A unique identifier for the structural model being deposited.
     */
    model_id: Ie,
    /**
     * A decsriptive name for the model.
     */
    model_name: ve,
    /**
     * An identifier to the structure assembly corresponding to the model.
     * This data item is a pointer to the _ihm_struct_assembly.id
     * in the IHM_STRUCT_ASSEMBLY category.
     */
    assembly_id: Ie,
    /**
     * An identifier to the modeling protocol that produced the model.
     * This data item is a pointer to the _ihm_modeling_protocol.id
     * in the IHM_MODELING_PROTOCOL category.
     */
    protocol_id: Ie,
    /**
     * An identifier to the multi-scale model representation id of the model.
     * This data item is a pointer to the _ihm_model_representation.id
     * in the IHM_MODEL_REPRESENTATION category.
     */
    representation_id: Ie
  },
  /**
   * IHM_MODEL_GROUP category defines collections or groups of integrative
   * structural models.
   */
  ihm_model_group: {
    /**
     * A unique identifier for a collection or group of structural models.
     * This data item can be used to group models into structural clusters
     * or using other criteria based on experimental data or other
     * relationships such as those belonging to the same state or time stamp.
     * An ensemble of models and its representative can either be grouped together
     * or can be separate groups in the ihm_model_group table. The choice between
     * the two options should be decided based on how the modeling was carried out
     * and how the representative was chosen. If the representative is a member of
     * the ensemble (i.e., best scoring model), then it is recommended that the
     * representative and the ensemble belong to the same model group. If the
     * representative is calculated from the ensemble (i.e., centroid), then it is
     * recommended that the representative be separated into a different group.
     */
    id: Ie,
    /**
     * A name for the collection of models.
     */
    name: ve,
    /**
     * Additional details about the collection of models.
     */
    details: ve
  },
  /**
   * IHM_MODEL_GROUP_LINK category provides the list of models present in
   * a particular model group.
   */
  ihm_model_group_link: {
    /**
     * An identifier for the structural model.
     * This data item is a pointer to _ihm_model_list.model_id in the
     * IHM_MODEL_LIST category.
     */
    model_id: Ie,
    /**
     * An identifier for the structural model group.
     * This data item is a pointer to _ihm_model_group.id in the
     * IHM_MODEL_GROUP category.
     */
    group_id: Ie
  },
  /**
   * Data items in the IHM_MODEL_REPRESENTATIVE category record the
   * details of the representative model in an ensemble or cluster.
   */
  ihm_model_representative: {
    /**
     * A unique identifier for the representative of the model group.
     */
    id: Ie,
    /**
     * The model group identifier corresponding to the representative model.
     * This data item is a pointer to _ihm_model_group.id in the
     * IHM_MODEL_GROUP category.
     */
    model_group_id: Ie,
    /**
     * The model identifier corresponding to the representative model.
     * This data item is a pointer to _ihm_model_list.model_id in the
     * IHM_MODEL_LIST category.
     */
    model_id: Ie,
    /**
     * The selection criteria based on which the representative is chosen.
     */
    selection_criteria: $e(ve)
  },
  /**
   * Category holds the list of all datasets used in the IHM modeling.
   * These can be datasets archived in other related databases such as
   * BMRB, EMDB, EMPIAR, SASBDB, PRIDE etc., or can be hosted in other
   * places such as the authors website, github etc. These datasets are
   * elaborated in detail in the IHM_DATASET_RELATED_DB_REFERENCE and/or
   * the IHM_DATASET_EXTERNAL_REFERENCE categories. This category
   * holds the list of all datasets used.
   */
  ihm_dataset_list: {
    /**
     * A unique identifier for the dataset.
     */
    id: Ie,
    /**
     * The type of data held in the dataset.
     */
    data_type: $e(ve),
    /**
     * A flag that indicates whether the dataset is archived in
     * an IHM related database or elsewhere.
     */
    database_hosted: $e(ve)
  },
  /**
   * Category to define groups or collections of input datasets.
   */
  ihm_dataset_group: {
    /**
     * A unique identifier for the dataset group.
     */
    id: Ie,
    /**
     * A name for the dataset group.
     */
    name: ve,
    /**
     * The application / utilization of the dataset group in modeling.
     */
    application: $e(ve),
    /**
     * Additional details regarding the dataset group.
     */
    details: ve
  },
  /**
   * IHM_DATASET_GROUP_LINK category provides the list of datasets present in
   * a particular group.
   */
  ihm_dataset_group_link: {
    /**
     * An identifier for the dataset.
     * This data item is a pointer to _ihm_dataset_list.id in the
     * IHM_DATASET_LIST category.
     */
    dataset_list_id: Ie,
    /**
     * An identifier for the dataset group.
     * This data item is a pointer to _ihm_dataset_group.id in the
     * IHM_DATASET_GROUP category.
     */
    group_id: Ie
  },
  /**
   * Category holds information about related datasets, where one is derived from the other.
   */
  ihm_related_datasets: {
    /**
     * The dataset list id corresponding to the derived dataset.
     * This data item is a pointer to _ihm_dataset_list.id in the
     * IHM_DATASET_LIST category.
     */
    dataset_list_id_derived: Ie,
    /**
     * The primary dataset list id from which the corresponding derived dataset is obtained.
     * This data item is a pointer to _ihm_dataset_list.id in the
     * IHM_DATASET_LIST category.
     */
    dataset_list_id_primary: Ie
  },
  /**
   * Category holds information related to data sources for the entry.
   * These can be datasets archived in other related databases such as
   * BMRB, EMDB, EMPIAR, SASBDB, PRIDE etc.
   */
  ihm_dataset_related_db_reference: {
    /**
     * A unique identifier for the related database entry.
     */
    id: Ie,
    /**
     * Identifier to the dataset list used in the IHM modeling.
     * This data item is a pointer to the _ihm_dataset_list.id in the
     * IHM_DATASET_LIST category.
     */
    dataset_list_id: Ie,
    /**
     * The name of the database containing the dataset entry.
     */
    db_name: $e(ve),
    /**
     * The accession code for the database entry.
     */
    accession_code: ve,
    /**
     * Version of the database entry, if the database allows versioning.
     */
    version: ve,
    /**
     * Details regarding the dataset entry.
     */
    details: ve
  },
  /**
   * Category holds links to other external data sources for the I/H model entry.
   * Input datasets held in other databases such as EMDB, BMRB, SASBDB etc.
   * are referenced in the IHM_DATASET_RELATED_DB_REFERENCE category.
   * This data category, along with IHM_EXTERNAL_FILES category, holds information
   * regarding other non-database external data sources, such as  DOIs (digital
   * object identifiers) or supplementary files stored locally. The DOIs can either
   * lead to the external data file(s) directly (as in case of DOIs provided by the PDB)
   * or might lead to an HTML landing page (as provided by Zenodo). In the latter case,
   * additional URL (Uniform Resource Locator) information is required to retrieve
   * the external data file(s).
   */
  ihm_external_reference_info: {
    /**
     * A unique identifier for the external reference.
     */
    reference_id: Ie,
    /**
     * The name of the reference provider.
     */
    reference_provider: ve,
    /**
     * The type of external reference.
     * Currently, only Digital Object Identifiers (DOIs) and supplementary files
     * stored locally are supported.
     */
    reference_type: $e(ve),
    /**
     * The external reference or the Digital Object Identifier (DOI).
     * This field is not relevant for local files.
     */
    reference: ve,
    /**
     * The type of object that the external reference points to, usually
     * a single file or an archive.
     */
    refers_to: $e(ve),
    /**
     * The Uniform Resource Locator (URL) corresponding to the external reference (DOI).
     * This URL should link to the corresponding downloadable file or archive and is provided
     * to enable automated software to download the referenced file or archive.
     */
    associated_url: ve
  },
  /**
   * Category provides details regarding external files. The IHM_EXTERNAL_REFERENCE_INFO
   * category captures the top-level details regarding external data sources.
   * This category captures the specific details regarding externally stored files
   * related to the particular I/H model entry.
   */
  ihm_external_files: {
    /**
     * A unique identifier for each external file.
     */
    id: Ie,
    /**
     * A pointer to the source of the external file - either DOI or locally stored.
     * This data item is a pointer to _ihm_external_reference_info.reference_id in the
     * IHM_EXTERNAL_REFERENCE_INFO category.
     */
    reference_id: Ie,
    /**
     * The relative path (including filename) for each external file.
     * Absolute paths (starting with "/") are not permitted.
     * This is required for identifying individual files from within
     * a tar-zipped archive file or for identifying supplementary local
     * files organized within a directory structure.
     * This data item assumes a POSIX-like directory structure or file path.
     */
    file_path: ve,
    /**
     * The type of content in the file.
     */
    content_type: $e(ve),
    /**
     * Storage size of the external file in bytes.
     */
    file_size_bytes: yr,
    /**
     * Additional textual details regarding the external file.
     */
    details: ve
  },
  /**
   * Category provides additional details regarding input data hosted externally
   * at other resources.
   */
  ihm_dataset_external_reference: {
    /**
     * A unique identifier for the external data.
     */
    id: Ie,
    /**
     * Identifier to the dataset list used in the I/H modeling.
     * This data item is a pointer to the _ihm_dataset_list.id in the
     * IHM_DATASET_LIST category.
     */
    dataset_list_id: Ie,
    /**
     * The file id corresponding to this external data file.
     * This data item is a pointer to _ihm_external_files.id
     * in the IHM_EXTERNAL_FILES category.
     */
    file_id: Ie
  },
  /**
   * Data items in the IHM_LOCALIZATION_DENSITY_FILES category records the
   * details of files that provide information regarding localization densities
   * of ensembles. These may be stored externally as local files or linked via
   * DOI and can be in any accepted format that provides volume information
   * (CCP4, MRC, etc.).
   */
  ihm_localization_density_files: {
    /**
     * A unique identifier.
     */
    id: Ie,
    /**
     * The file id for the externally stored localization density file.
     * This data item is a pointer to _ihm_external_files.id
     * in the IHM_EXTERNAL_FILES category.
     */
    file_id: Ie,
    /**
     * The ensemble identifier for the ensemble, for which the localization density is provided.
     * This data item is a pointer to _ihm_ensemble_info.ensemble_id in the IHM_ENSEMBLE_INFO category.
     */
    ensemble_id: Ie,
    /**
     * The entity identifier corresponding to this localization density.
     * This data item is a pointer to _entity.id in the ENTITY category.
     */
    entity_id: ve,
    /**
     * The identifier for the polymeric segment corresponding to this
     * localization density.
     * This data item is a pointer to _ihm_entity_poly_segment.id in the
     * IHM_ENTITY_POLY_SEGMENT category.
     */
    entity_poly_segment_id: Ie,
    /**
     * An asym/strand identifier corresponding to this localization density.
     * This data item is a pointer to _struct_asym.id in the STRUCT_ASYM category.
     */
    asym_id: ve
  },
  /**
   * Data items in the IHM_PREDICTED_CONTACT_RESTRAINT category records the
   * list of predicted contacts used in the integrative modeling experiment.
   * This has been adapted from the widely used CASP RR format
   * (http://www.predictioncenter.org/casp8/index.cgi?page=format#RR).
   * These contacts may be derived from various computational tools.
   * The software information can be provided in the SOFTWARE category.
   */
  ihm_predicted_contact_restraint: {
    /**
     * A unique identifier for the predicted contact restraint.
     */
    id: Ie,
    /**
     * An identifier to group the predicted contacts.
     */
    group_id: Ie,
    /**
     * The entity identifier for the first monomer partner in the predicted contact.
     * This data item is a pointer to _entity_poly_seq.entity_id in the ENTITY_POLY_SEQ category.
     */
    entity_id_1: ve,
    /**
     * The entity identifier for the second monomer partner in the predicted contact.
     * This data item is a pointer to _entity_poly_seq.entity_id in the ENTITY_POLY_SEQ category.
     */
    entity_id_2: ve,
    /**
     * An asym/strand identifier for the first monomer partner in the predicted contact.
     * This data item is a pointer to _struct_asym.id in the
     * STRUCT_ASYM category.
     */
    asym_id_1: ve,
    /**
     * An asym/strand identifier for the second monomer partner in the predicted contact.
     * This data item is a pointer to _struct_asym.id in the
     * STRUCT_ASYM category.
     */
    asym_id_2: ve,
    /**
     * The component identifier for the first monomer partner in the predicted contact.
     * This data item is a pointer to _entity_poly_seq.mon_id in the ENTITY_POLY_SEQ category.
     */
    comp_id_1: ve,
    /**
     * The component identifier for the second monomer partner in the predicted contact.
     * This data item is a pointer to _entity_poly_seq.mon_id in the ENTITY_POLY_SEQ category.
     */
    comp_id_2: ve,
    /**
     * The sequence index for the first monomer partner in the predicted contact.
     * This data item is a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category.
     */
    seq_id_1: Ie,
    /**
     * The sequence index for the second monomer partner in the predicted contact.
     * This data item is a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category.
     */
    seq_id_2: Ie,
    /**
     * If _ihm_predicted_contact_restraint.model_granularity is by-residue, then indicate the atom
     * used to represent the first monomer partner in three-dimension. Default is the C-alpha atom.
     */
    rep_atom_1: $e(ve),
    /**
     * If _ihm_predicted_contact_restraint.model_granularity is by-residue, then indicate the atom
     * used to represent the second monomer partner in three-dimension. Default is the C-alpha atom.
     */
    rep_atom_2: $e(ve),
    /**
     * The lower limit to the distance threshold applied to this predicted contact restraint
     * in the integrative modeling task.
     */
    distance_lower_limit: yr,
    /**
     * The upper limit to the distance threshold applied to this predicted contact restraint
     * in the integrative modeling task.
     */
    distance_upper_limit: yr,
    /**
     * The real number that indicates the probability that the predicted distance restraint
     * is correct. This number should fall between 0.0 and 1.0.
     */
    probability: yr,
    /**
     * The type of distance restraint applied.
     */
    restraint_type: $e(ve),
    /**
     * The granularity of the predicted contact as applied to the multi-scale model.
     */
    model_granularity: $e(ve),
    /**
     * Identifier to the predicted contacts dataset.
     * This data item is a pointer to the _ihm_dataset_list.id in the
     * IHM_DATASET_LIST category.
     */
    dataset_list_id: Ie,
    /**
     * Identifier to the software used to obtain the predicted contacts dataset.
     * This data item is a pointer to the _software.pdbx_ordinal in the
     * SOFTWARE category.
     */
    software_id: Ie
  },
  /**
   * Data items in the IHM_CROSS_LINK_LIST category records the
   * list of spatial restraints derived from chemical crosslinking
   * experiment.
   */
  ihm_cross_link_list: {
    /**
     * A unique identifier for the cross link restraint.
     */
    id: Ie,
    /**
     * An identifier for a set of ambiguous crosslink restraints.
     * Handles experimental uncertainties in the identities of
     * crosslinked residues.
     */
    group_id: Ie,
    /**
     * A text description of molecular entity 1.
     */
    entity_description_1: ve,
    /**
     * A text description of molecular entity 2.
     */
    entity_description_2: ve,
    /**
     * The entity identifier for the first monomer partner in the cross link
     * This data item is a pointer to _entity_poly_seq.entity_id in the ENTITY_POLY_SEQ category.
     */
    entity_id_1: ve,
    /**
     * The entity identifier for the second monomer partner in the cross link
     *
     * This data item is a pointer to _entity_poly_seq.entity_id in the ENTITY_POLY_SEQ category.
     */
    entity_id_2: ve,
    /**
     * The component identifier for the first monomer partner in the cross link.
     *
     * This data item is a pointer to _entity_poly_seq.mon_id in the ENTITY_POLY_SEQ category.
     */
    comp_id_1: ve,
    /**
     * The component identifier for the second monomer partner in the cross link.
     *
     * This data item is a pointer to _entity_poly_seq.mon_id in the ENTITY_POLY_SEQ category.
     */
    comp_id_2: ve,
    /**
     * The sequence index for the first monomer partner in the cross link.
     *
     * This data item is a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category.
     */
    seq_id_1: Ie,
    /**
     * The sequence index for the second monomer partner in the cross link.
     *
     * This data item is a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category.
     */
    seq_id_2: Ie,
    /**
     * The type of crosslinker used.
     */
    linker_type: $e(ve),
    /**
     * Identifier to the crosslinking dataset.
     * This data item is a pointer to the _ihm_dataset_list.id in the
     * IHM_DATASET_LIST category.
     */
    dataset_list_id: Ie
  },
  /**
   * Data items in the IHM_CROSS_LINK_RESTRAINT category enumerates the
   * implementation details of the chemical crosslinking restraints in
   * the integrative modeling. This category holds the details of how
   * the experimentally derived crosslinks are applied in the modeling.
   */
  ihm_cross_link_restraint: {
    /**
     * A unique identifier for the cross link record.
     */
    id: Ie,
    /**
     * An identifier for a set of ambiguous cross-links.
     * Handles implementation uncertainties related to multiple copies of subunit.
     * This data item is a pointer to _ihm_cross_link_list.id in the
     * IHM_CROSS_LINK_LIST category.
     */
    group_id: Ie,
    /**
     * The entity identifier for the first monomer partner in the cross link
     *
     * This data item is a pointer to _entity_poly_seq.entity_id in the ENTITY_POLY_SEQ category
     * and the _ihm_cross_link_restraint.entity_id_1 in the IHM_CROSS_LINK_RESTRAINT category.
     */
    entity_id_1: ve,
    /**
     * The entity identifier for the second monomer partner in the cross link
     *
     * This data item is a pointer to _entity_poly_seq.entity_id in the ENTITY_POLY_SEQ category
     * and the _ihm_cross_link_restraint.entity_id_2 in the IHM_CROSS_LINK_RESTRAINT category.
     */
    entity_id_2: ve,
    /**
     * An asym/strand identifier for the first monomer partner in the cross-link.
     *
     * This data item is a pointer to _struct_asym.id in the
     * STRUCT_ASYM category.
     */
    asym_id_1: ve,
    /**
     * An asym/strand identifier for the second monomer partner in the cross-link.
     *
     * This data item is a pointer to _struct_asym.id in the
     * STRUCT_ASYM category.
     */
    asym_id_2: ve,
    /**
     * The component identifier for the first monomer partner in the cross link.
     *
     * This data item is a pointer to _entity_poly_seq.mon_id in the ENTITY_POLY_SEQ category
     * and the _ihm_cross_link_restraint.comp_id_1 in the IHM_CROSS_LINK_RESTRAINT category.
     */
    comp_id_1: ve,
    /**
     * The component identifier for the second monomer partner in the cross link.
     *
     * This data item is a pointer to _entity_poly_seq.mon_id in the ENTITY_POLY_SEQ category
     * and the _ihm_cross_link_restraint.comp_id_2 in the IHM_CROSS_LINK_RESTRAINT category.
     */
    comp_id_2: ve,
    /**
     * The sequence index for the first monomer partner in the cross link.
     *
     * This data item is a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category
     * and the _ihm_cross_link_restraint.seq_id_1 in the IHM_CROSS_LINK_RESTRAINT category.
     */
    seq_id_1: Ie,
    /**
     * The sequence index for the second monomer partner in the cross link.
     *
     * This data item is a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category
     * and the _ihm_cross_link_restraint.seq_id_2 in the IHM_CROSS_LINK_RESTRAINT category.
     */
    seq_id_2: Ie,
    /**
     * The atom identifier for the first monomer partner in the cross link.
     * This data item is a pointer to _chem_comp_atom.atom_id in the
     * CHEM_COMP_ATOM category.
     */
    atom_id_1: ve,
    /**
     * The atom identifier for the second monomer partner in the cross link.
     * This data item is a pointer to _chem_comp_atom.atom_id in the
     * CHEM_COMP_ATOM category.
     */
    atom_id_2: ve,
    /**
     * The type of the cross link restraint applied.
     */
    restraint_type: $e(ve),
    /**
     * The cross link conditionality.
     */
    conditional_crosslink_flag: $e(ve),
    /**
     * The coarse-graining information for the crosslink implementation.
     */
    model_granularity: $e(ve),
    /**
     * The distance threshold applied to this crosslink in the integrative modeling task.
     */
    distance_threshold: yr,
    /**
     * The uncertainty in the crosslinking experimental data;
     * may be approximated to the false positive rate.
     */
    psi: yr,
    /**
     * The uncertainty in the position of residue 1 in the crosslink
     * arising due to the multi-scale nature of the model represention.
     */
    sigma_1: yr,
    /**
     * The uncertainty in the position of residue 2 in the crosslink
     * arising due to the multi-scale nature of the model represention.
     */
    sigma_2: yr
  },
  /**
   * Data items in the IHM_CROSS_LINK_RESULT_PARAMETERS category records the
   * results of the crosslinking restraint parameters in the IHM modeling.
   */
  ihm_cross_link_result_parameters: {
    /**
     * A unique identifier for the restraint/model combination.
     */
    id: Ie,
    /**
     * An identifier for the crosslink restraint between a pair of residues.
     * This data item is a pointer to _ihm_cross_link_restraint.id in the
     * IHM_CROSS_LINK_RESTRAINT category.
     */
    restraint_id: Ie,
    /**
     * The model number corresponding to the cross link result presented.
     * This data item is a pointer to _ihm_model_list.model_id in the
     * IHM_MODEL_LIST category.
     */
    model_id: Ie,
    /**
     * The uncertainty in the crosslinking experimental data;
     * May be approximated to the false positive rate.
     */
    psi: yr,
    /**
     * The uncertainty in the position of residue 1 in the crosslink
     * arising due to the multi-scale nature of the model represention.
     */
    sigma_1: yr,
    /**
     * The uncertainty in the position of residue 2 in the crosslink
     * arising due to the multi-scale nature of the model represention.
     */
    sigma_2: yr
  },
  /**
   * Data items in the IHM_2DEM_CLASS_AVERAGE_RESTRAINT category records the
   * details of the 2DEM class averages used in the IHM modeling.
   */
  ihm_2dem_class_average_restraint: {
    /**
     * A unique identifier for the 2dem class average.
     */
    id: Ie,
    /**
     * Identifier to the 2dem class average dataset.
     * This data item is a pointer to the _ihm_dataset_list.id in the
     * IHM_DATASET_LIST category.
     */
    dataset_list_id: Ie,
    /**
     * The number of raw micrographs used to obtain the class average.
     */
    number_raw_micrographs: Ie,
    /**
     * Pixel size width of the 2dem class average image.
     * While fitting the model to the image, _ihm_2dem_class_average_restraint.pixel_size_width
     * is used along with _ihm_2dem_class_average_restraint.pixel_size_height to scale the image.
     */
    pixel_size_width: yr,
    /**
     * Pixel size height of the 2dem class average image.
     * While fitting the model to the image, _ihm_2dem_class_average_restraint.pixel_size_height
     * is used along with _ihm_2dem_class_average_restraint.pixel_size_width to scale the image.
     */
    pixel_size_height: yr,
    /**
     * Resolution of the 2dem class average.
     */
    image_resolution: yr,
    /**
     * A flag that indicates whether or not the 2DEM class average image is segmented i.e.,
     * whether the whole image is used or only a portion of it is used (by masking
     * or by other means) as restraint in the modeling.
     */
    image_segment_flag: $e(ve),
    /**
     * Number of 2D projections of the model used in the fitting.
     */
    number_of_projections: Ie,
    /**
     * An indicator to whether the whole assembly that is modeled is fit into the image
     * or if only a subset of the structural assembly is fit into the image.
     * This data item is a pointer to _ihm_struct_assembly.id in the
     * IHM_STRUCT_ASSEMBLY category. The IHM_STRUCT_ASSEMBLY category provides the
     * details regarding the different structural assemblies used in the modeling.
     * The default value for this data item is "1" indicating that the entire assembly
     * being modeled is fit into the EM data.
     */
    struct_assembly_id: Ie,
    /**
     * Details of how the 2DEM restraint is applied in the modeling algorithm.
     */
    details: ve
  },
  /**
   * Data items in the IHM_2DEM_CLASS_AVERAGE_FITTING category records the
   * details of the fitting of the model to the 2DEM class averages
   * used in the IHM modeling. The following conventions are recommended
   * while generating the rotation matrix and translation vector for
   * transformation.
   *
   * - The model is rotated and translated to fit to the 2DEM image.
   * - The 2DEM image should be in the XY plane.
   * - The lower left image corner (image pixel index 0,0) should be at x,y,z = (0,0,0).
   * - The 2D image is scaled by the _ihm_2dem_class_average_restraint.pixel_size_width
   * and _ihm_2dem_class_average_restraint.pixel_size_height from the
   * IHM_2DEM_CLASS_AVERAGE_RESTRAINT table.
   * - The transformation is applied after the scaling and hence the translation vector
   * should account for the scaling.
   * - There are no specifications for Z translations i.e., how far the image should be
   * from the model while projecting. It may be set to zero.
   */
  ihm_2dem_class_average_fitting: {
    /**
     * A unique identifier for the 2dem class average fitting data.
     */
    id: Ie,
    /**
     * Identifier to the 2dem class average restraint.
     * This data item is a pointer to the _ihm_2dem_class_average_restraint.id in the
     * IHM_2DEM_CLASS_AVERAGE_RESTRAINT category.
     */
    restraint_id: Ie,
    /**
     * The model number corresponding to the 2DEM fitting result presented.
     * This data item is a pointer to _ihm_model_list.model_id in the
     * IHM_MODEL_LIST category.
     */
    model_id: Ie,
    /**
     * The cross correlation coefficient corresponding to the model to image fitting.
     */
    cross_correlation_coefficient: yr,
    /**
     * Data item  of the rotation matrix used in the fitting of the model to the image.
     */
    rot_matrix: Oc(3, 3),
    /**
     * Data item  of the tranlation vector used in the fitting of the model to the image.
     */
    tr_vector: r2(3)
  },
  /**
   * Data items in the IHM_3DEM_RESTRAINT category records the
   * details of the 3DEM maps used as restraints in the
   * IHM modeling.
   */
  ihm_3dem_restraint: {
    /**
     * A unique identifier for the 3DEM restraint description.
     */
    id: Ie,
    /**
     * Identifier to the 3DEM map used.
     * This data item is a pointer to the _ihm_dataset_list.id in the
     * IHM_DATASET_LIST category.
     */
    dataset_list_id: Ie,
    /**
     * The model number corresponding to the 3DEM fitting result presented.
     * This data item is a pointer to _ihm_model_list.model_id in the
     * IHM_MODEL_LIST category.
     */
    model_id: Ie,
    /**
     * An indicator to whether the whole assembly that is modeled is fit into the 3DEM map
     * or if only a subset of the structural assembly is fit into the map.
     * This data item is a pointer to _ihm_struct_assembly.id in the
     * IHM_STRUCT_ASSEMBLY category. The IHM_STRUCT_ASSEMBLY category provides the
     * details regarding the different structural assemblies used in the modeling.
     * The default value for this data item is "1" indicating that the entire assembly
     * being modeled is fit into the EM map.
     */
    struct_assembly_id: Ie,
    /**
     * Method used to fit the model to the 3DEM map.
     */
    fitting_method: ve,
    /**
     * In case of Gaussian mixture models, the number of gaussians
     * is a parameter used to covert the 3DEM maps and models into
     * GMMs. This captures the level of granularity used in
     * representing the maps and/or models as 3D Gaussians.
     */
    number_of_gaussians: Ie,
    /**
     * The cross correlation coefficient corresponding to the model to map fitting.
     */
    cross_correlation_coefficient: yr
  },
  /**
   * Data items in the IHM_SAS_RESTRAINT category records the
   * details of the SAS data used as restraints in the
   * IHM modeling.
   */
  ihm_sas_restraint: {
    /**
     * A unique identifier for the SAS restraint description.
     */
    id: Ie,
    /**
     * Identifier to the SAS data used.
     * This data item is a pointer to the _ihm_dataset_list.id in the
     * IHM_DATASET_LIST category.
     */
    dataset_list_id: Ie,
    /**
     * The model number corresponding to the SAS fitting result presented.
     * This data item is a pointer to _ihm_model_list.model_id in the
     * IHM_MODEL_LIST category.
     */
    model_id: Ie,
    /**
     * An indicator to whether the whole assembly that is modeled is fit into the SAS data
     * or if only a subset of the structural assembly is fit into the data.
     * This data item is a pointer to _ihm_struct_assembly.id in the
     * IHM_STRUCT_ASSEMBLY category. The IHM_STRUCT_ASSEMBLY category provides the
     * details regarding the different structural assemblies used in the modeling.
     * The default value for this data item is "1" indicating that the entire assembly
     * being modeled is fit into the SAS data.
     */
    struct_assembly_id: Ie,
    /**
     * A flag that indicates whether or not the SAS profile is segmented i.e.,
     * whether the whole SAS profile is used or only a portion of it is used
     * (by masking or by other means) as restraint in the modeling.
     */
    profile_segment_flag: $e(ve),
    /**
     * The type of atoms in the model fit to the SAS data.
     */
    fitting_atom_type: ve,
    /**
     * The method used for fitting the model to the SAS data.
     */
    fitting_method: ve,
    /**
     * An indicator to single or multiple state fitting.
     */
    fitting_state: $e(ve),
    /**
     * Radius of gyration obtained from the SAS profile, if used as input restraint.
     */
    radius_of_gyration: yr,
    /**
     * The chi value resulting from fitting the model to the SAS data.
     */
    chi_value: yr,
    /**
     * Additional details regarding the SAS restraint used.
     */
    details: ve
  },
  /**
   * Data items in the IHM_STARTING_MODEL_COORD category records the coordinates
   * for structural templates used as starting inputs in the integrative model
   * building tasks.
   */
  ihm_starting_model_coord: {
    /**
     * A unique identifier for this coordinate position.
     */
    ordinal_id: Ie,
    /**
     * The identifier for the starting structural model.
     * This data item is a pointer to _ihm_starting_model_details.starting_model_id
     * in the IHM_STARTING_MODEL_DETAILS category.
     */
    starting_model_id: ve,
    /**
     * The group of atoms to which the atom site in the starting model belongs. This data
     * item is provided for compatibility with the original Protein Data Bank format,
     * and only for that purpose.
     */
    group_PDB: $e(ve),
    /**
     * The serial number for this coordinate position.
     */
    id: Ie,
    /**
     * The atom type symbol(element symbol) corresponding to this coordinate position.
     */
    type_symbol: ve,
    /**
     * The entity identifier corresponding to this coordinate position.
     * This data item is a pointer to _entity.id in the ENTITY category.
     */
    entity_id: ve,
    /**
     * The atom identifier/name corresponding to this coordinate position.
     * This data item is a pointer to _chem_comp_atom.atom_id in the
     * CHEM_COMP_ATOM category.
     */
    atom_id: ve,
    /**
     * The component identifier corresponding to this coordinate position.
     * This data item is a pointer to _chem_comp.id in the
     * CHEM_COMP category.
     */
    comp_id: ve,
    /**
     * The sequence index corresponding this to coordinate position.
     * This data item is a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category.
     */
    seq_id: Ie,
    /**
     * The asym/strand id corresponding to this coordinate position.
     *
     * This data item is a pointer to _struct_asym.id in the STRUCT_ASYM category.
     */
    asym_id: ve,
    /**
     * The Cartesian X component corresponding to this coordinate position.
     */
    Cartn_x: yr,
    /**
     * The Cartesian Y component corresponding to this coordinate position.
     */
    Cartn_y: yr,
    /**
     * The Cartesian Z component corresponding to this coordinate position.
     */
    Cartn_z: yr,
    /**
     * The isotropic temperature factor corresponding to this coordinate position.
     */
    B_iso_or_equiv: yr
  },
  /**
   * Data items in the IHM_SPHERE_OBJ_SITE category records the details
   * of the spherical objects modeled in the integrative structural model.
   */
  ihm_sphere_obj_site: {
    /**
     * A unique identifier for this pseudo atom / sphere object.
     */
    id: Ie,
    /**
     * The entity identifier corresponding to this sphere object.
     * This data item is a pointer to _entity.id in the ENTITY category.
     */
    entity_id: ve,
    /**
     * The leading sequence index corresponding to this sphere object.
     * This data item is a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category.
     */
    seq_id_begin: Ie,
    /**
     * The trailing sequence index corresponding to this sphere object.
     * This data item is a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category.
     */
    seq_id_end: Ie,
    /**
     * An asym/strand identifier corresponding to this sphere object.
     * This data item is a pointer to _struct_asym.id in the STRUCT_ASYM category.
     */
    asym_id: ve,
    /**
     * The Cartesian X component corresponding to this sphere object.
     */
    Cartn_x: yr,
    /**
     * The Cartesian Y component corresponding to this sphere object.
     */
    Cartn_y: yr,
    /**
     * The Cartesian Z component corresponding to this sphere object.
     */
    Cartn_z: yr,
    /**
     * The radius associated with the primitive sphere object at this position.
     */
    object_radius: yr,
    /**
     * The Root Mean Square Fluctuation (RMSF) observed in the primitive
     * sphere object at this position.
     */
    rmsf: yr,
    /**
     * The model id corresponding to the sphere object.
     * This data item is a pointer to _ihm_model_list.model_id
     * in the IHM_MODEL_LIST category.
     */
    model_id: Ie
  },
  /**
   * Data items in the IHM_GAUSSIAN_OBJ_SITE category records the details
   * of the gaussian objects modeled in the integrative structural model.
   */
  ihm_gaussian_obj_site: {
    /**
     * A unique identifier for this gaussian object in the model.
     */
    id: Ie,
    /**
     * The entity identifier corresponding to this gaussian object.
     * This data item is a pointer to _entity.id in the ENTITY category.
     */
    entity_id: ve,
    /**
     * The leading sequence index corresponding to this gaussian object.
     * This data item is a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category.
     */
    seq_id_begin: Ie,
    /**
     * The trailing sequence index corresponding to this gaussian object.
     * This data item is a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category.
     */
    seq_id_end: Ie,
    /**
     * An asym/strand identifier corresponding to this gaussian object.
     * This data item is a pointer to _struct_asym.id in the STRUCT_ASYM category.
     */
    asym_id: ve,
    /**
     * The mean Cartesian X component corresponding to this gaussian object.
     */
    mean_Cartn_x: yr,
    /**
     * The mean Cartesian Y component corresponding to this gaussian object.
     */
    mean_Cartn_y: yr,
    /**
     * The mean Cartesian Z component corresponding to this gaussian object.
     */
    mean_Cartn_z: yr,
    /**
     * The weight of the gaussian object.
     */
    weight: yr,
    /**
     * Data item  of the covariance matrix representing the Gaussian object.
     */
    covariance_matrix: Oc(3, 3),
    /**
     * The model id corresponding to the gaussian object.
     * This data item is a pointer to _ihm_model_list.model_id
     * in the IHM_MODEL_LIST category.
     */
    model_id: Ie
  },
  /**
   * Data items in the IHM_GAUSSIAN_OBJ_ENSEMBLE category records the details
   * of the gaussian objects representing an ensemble or cluster of models.
   */
  ihm_gaussian_obj_ensemble: {
    /**
     * A unique identifier for this gaussian object.
     */
    id: Ie,
    /**
     * The entity identifier corresponding to this gaussian object.
     * This data item is a pointer to _entity.id in the ENTITY category.
     */
    entity_id: ve,
    /**
     * The leading sequence index corresponding to this gaussian object.
     * This data item is a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category.
     */
    seq_id_begin: Ie,
    /**
     * The trailing sequence index corresponding to this gaussian object.
     * This data item is a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category.
     */
    seq_id_end: Ie,
    /**
     * An asym/strand identifier corresponding to this gaussian object.
     * This data item is a pointer to _struct_asym.id in the STRUCT_ASYM category.
     */
    asym_id: ve,
    /**
     * The mean Cartesian X component corresponding to this gaussian object.
     */
    mean_Cartn_x: yr,
    /**
     * The mean Cartesian Y component corresponding to this gaussian object.
     */
    mean_Cartn_y: yr,
    /**
     * The mean Cartesian Z component corresponding to this gaussian object.
     */
    mean_Cartn_z: yr,
    /**
     * The weight of the gaussian object.
     */
    weight: yr,
    /**
     * Data item  of the covariance matrix representing the Gaussian object.
     */
    covariance_matrix: Oc(3, 3),
    /**
     * The ensemble id corresponding to the gaussian object.
     * This data item is a pointer to _ihm_ensemble_info.ensemble_id
     * in the IHM_ENSEMBLE_INFO category.
     */
    ensemble_id: Ie
  },
  /**
   * IHM_FEATURE_LIST is the high level category that provides defintions
   * to select atoms/residues from polymeric and non-polymeric entities.
   */
  ihm_feature_list: {
    /**
     * A unique identifier for the feature.
     */
    feature_id: Ie,
    /**
     * The type of feature.
     */
    feature_type: $e(ve),
    /**
     * The type of entity.
     */
    entity_type: $e(ve)
  },
  /**
   * Data items in the IHM_POLY_RESIDUE_FEATURE category provides the defintions
   * required to select a specific residue or a set of residues that may or may not be
   * in a contiguous range.
   */
  ihm_poly_residue_feature: {
    /**
     * A unique identifier for the category.
     */
    ordinal_id: Ie,
    /**
     * An identifier for the selected residue / residue range feature.
     * This data item is a pointer to _ihm_feature_list.feature_id in the
     * IHM_FEATURE_LIST category.
     */
    feature_id: Ie,
    /**
     * The entity identifier for residue / residue range.
     * This data item is a pointer to _entity_poly_seq.entity_id in the
     * ENTITY_POLY_SEQ category.
     */
    entity_id: ve,
    /**
     * An asym/strand identifier for the residue / residue range, if applicable.
     * This data item is a pointer to _struct_asym.id in the
     * STRUCT_ASYM category.
     */
    asym_id: ve,
    /**
     * The component identifier of the beginning residue / residue range.
     * This data item is a pointer to _entity_poly_seq.mon_id in the ENTITY_POLY_SEQ category.
     */
    comp_id_begin: ve,
    /**
     * The component identifier of the ending residue / residue range.
     * This data item is a pointer to _entity_poly_seq.mon_id in the ENTITY_POLY_SEQ category.
     */
    comp_id_end: ve,
    /**
     * The sequence index of the beginning residue / residue range.
     * This data item is a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category.
     */
    seq_id_begin: Ie,
    /**
     * The sequence index of the ending residue / residue range.
     * This data item is a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category.
     */
    seq_id_end: Ie
  },
  /**
   * Data items in the IHM_DERIVED_DISTANCE_RESTRAINT category records the
   * list of distance restraints used in the integrative modeling experiment.
   * These distance redistance restraints may be derived from various kinds of experiments.
   */
  ihm_derived_distance_restraint: {
    /**
     * A unique identifier for the derived distance restraint.
     */
    id: Ie,
    /**
     * An identifier to group the distance restraints.
     * This can be the same as the _ihm_derived_distance_restraint.id in case
     * the some of the restraints are not grouped.
     */
    group_id: Ie,
    /**
     * The feature identifier for the first partner in the distance restraint.
     * This data item is a pointer to _ihm_feature_list.feature_id in the
     * IHM_FEATURE_LIST category.
     */
    feature_id_1: Ie,
    /**
     * The feature identifier for the second partner in the distance restraint.
     * This data item is a pointer to _ihm_feature_list.feature_id in the
     * IHM_FEATURE_LIST category.
     */
    feature_id_2: Ie,
    /**
     * If a group of atoms or residues are restrained, this data item defines
     * the conditionality based on which the restraint is applied in the modeling.
     */
    group_conditionality: $e(ve),
    /**
     * The fraction of randomly excluded distance restraints during modeling.
     * In HADDOCK, this is used along with ambiguous interface restraints (AIRs)
     * to account for uncertainties in AIRs.
     */
    random_exclusion_fraction: yr,
    /**
     * The upper limit to the distance threshold applied to this distance restraint
     * in the integrative modeling task.
     */
    distance_upper_limit: yr,
    /**
     * The type of distance restraint applied.
     */
    restraint_type: $e(ve),
    /**
     * Identifier to the input data from which the distance restraint is derived.
     * This data item is a pointer to the _ihm_dataset_list.id in the
     * IHM_DATASET_LIST category.
     * This data item may not be applicable for all cases. For example, in case of
     * ambiguous interface restraints where the interface residues are identified
     * from multiple experiments, the reference to the _ihm_dataset_list.id is
     * handled in the IHM_INTERFACE_RESIDUE_FEATURE category rather than here.
     */
    dataset_list_id: Ie
  },
  /**
   * Data items in the MA_MODEL_LIST category record the
   * details of the models being deposited.
   */
  ma_model_list: {
    /**
     * A unique identifier for the model / model group combination.
     */
    ordinal_id: Ie,
    /**
     * A unique identifier for the structural model being deposited.
     */
    model_id: Ie,
    /**
     * An identifier to group structural models into collections or sets.
     * A cluster of models and its representative can either be grouped together
     * or can be separate groups in the ma_model_list table. The choice between
     * the two options should be decided based on how the modeling was carried out
     * and how the representative was chosen. If the representative is a member of
     * the ensemble (i.e., best scoring model), then it is recommended that the
     * representative and the ensemble belong to the same model group. If the
     * representative is calculated from the ensemble (i.e., centroid), then it is
     * recommended that the representative be separated into a different group.
     * If the models do not need to be grouped into collections, then the
     * _ma_model_list.model_group_id is the same as _ma_model_list.model_id.
     */
    model_group_id: Ie,
    /**
     * A decsriptive name for the model.
     */
    model_name: ve,
    /**
     * A decsriptive name for the model group.
     */
    model_group_name: ve,
    /**
     * The type of model.
     */
    model_type: $e(ve),
    /**
     * The data_id identifier. This data item is a pointer to
     * _ma_data.id in the MA_DATA category.
     */
    data_id: Ie
  },
  /**
   * Data items in the MA_TARGET_ENTITY category record details about
   * the target entities. The details are provided for each entity
   * being modeled.
   */
  ma_target_entity: {
    /**
     * A unique identifier for the distinct molecular entity of the target.
     * This data item is a pointer to _entity.id in the ENTITY category.
     */
    entity_id: ve,
    /**
     * The data_id identifier. This data item is a pointer to
     * _ma_data.id in the MA_DATA category.
     */
    data_id: Ie,
    /**
     * The origin of the target entity.
     */
    origin: $e(ve)
  },
  /**
   * Data items in the MA_TARGET_ENTITY_INSTANCE category record details about
   * the instances of target entities modeled.
   */
  ma_target_entity_instance: {
    /**
     * A unique identifier for the instance of the entity.
     */
    asym_id: ve,
    /**
     * A unique identifier for the distinct molecular entity of the target.
     * This data item is a pointer to _ma_target_entity.entity_id in the
     * MA_TARGET_ENTITY category.
     */
    entity_id: ve,
    /**
     * Additional details about the entity instance.
     */
    details: ve
  },
  /**
   * Data items in the MA_TARGET_REF_DB_DETAILS category record details about
   * the reference databases for the target sequences.
   */
  ma_target_ref_db_details: {
    /**
     * An identifier for the target entity.
     */
    target_entity_id: ve,
    /**
     * The name of the database containing reference information about
     * this entity or biological unit.
     */
    db_name: $e(ve),
    /**
     * The code for this entity or biological unit or for a closely
     * related entity or biological unit in the named database.
     * This can include the version number.
     */
    db_code: ve,
    /**
     * Accession code assigned by the reference database.
     */
    db_accession: ve,
    /**
     * Database code assigned by the reference database for a sequence isoform.   An isoform sequence is an
     * alternative protein sequence that can be generated from the same gene by a single or by a combination of
     * biological events such as: alternative promoter usage, alternative splicing, alternative initiation
     * and ribosomal frameshifting.
     */
    seq_db_isoform: ve,
    /**
     * Beginning index in the chemical sequence from the
     * reference database.
     */
    seq_db_align_begin: ve,
    /**
     * Ending index in the chemical sequence from the
     * reference database.
     */
    seq_db_align_end: ve,
    /**
     * Taxonomy identifier provided by NCBI.
     */
    ncbi_taxonomy_id: ve,
    /**
     * Scientific name of the organism.
     */
    organism_scientific: ve
  },
  /**
   * Data items in the MA_DATA category capture the different kinds of
   * data used in the modeling. These can be multiple sequence
   * alignments, spatial restraints, template structures etc.
   */
  ma_data: {
    /**
     * A unique identifier for the data.
     */
    id: Ie,
    /**
     * The type of data held in the dataset.
     */
    content_type: $e(ve),
    /**
     * Details for other content types.
     */
    content_type_other_details: ve,
    /**
     * An author-given name for the content held in the dataset.
     */
    name: ve
  },
  /**
   * Data items in the MA_SOFTWARE_GROUP category describes the
   * collection of software into groups so that they can be used
   * efficiently in the MA_PROTOCOL_STEP category.
   */
  ma_software_group: {
    /**
     * A unique identifier for the category.
     */
    ordinal_id: Ie,
    /**
     * An identifier for the group entry.
     * If data does not need to be grouped, then _ma_software_group.group_id
     * is the same as _ma_software_group.software_id.
     */
    group_id: Ie,
    /**
     * The identifier for the software.
     * This data item is a pointer to _software.pdbx_ordinal
     * in the SOFTWARE category.
     */
    software_id: Ie
  },
  /**
   * Data items in the MA_QA_METRIC category record the
   * details of the metrics use to assess model quality.
   */
  ma_qa_metric: {
    /**
     * An identifier for the QA metric.
     */
    id: Ie,
    /**
     * Name of the QA metric.
     */
    name: ve,
    /**
     * The type of QA metric.
     */
    type: $e(ve),
    /**
     * The mode of calculation of the QA metric.
     */
    mode: $e(ve),
    /**
     * Identifier to the set of software used to calculate the QA metric.
     * This data item is a pointer to the _ma_software_group.group_id in the
     * MA_SOFTWARE_GROUP category.
     */
    software_group_id: Ie
  },
  /**
   * Data items in the MA_QA_METRIC_GLOBAL category captures the
   * details of the global QA metrics, calculated at the model-level.
   */
  ma_qa_metric_global: {
    /**
     * A unique identifier for the category.
     */
    ordinal_id: Ie,
    /**
     * The identifier for the structural model, for which global QA metric is provided.
     * This data item is a pointer to _ma_model_list.model_id
     * in the MA_MODEL_LIST category.
     */
    model_id: Ie,
    /**
     * The identifier for the QA metric.
     * This data item is a pointer to _ma_qa_metric.id in the
     * MA_QA_METRIC category.
     */
    metric_id: Ie,
    /**
     * The value of the global QA metric.
     */
    metric_value: yr
  },
  /**
   * Data items in the MA_QA_METRIC_LOCAL category captures the
   * details of the local QA metrics, calculated at the residue-level.
   */
  ma_qa_metric_local: {
    /**
     * A unique identifier for the category.
     */
    ordinal_id: Ie,
    /**
     * The identifier for the structural model, for which local QA metric is provided.
     * This data item is a pointer to _ma_model_list.model_id
     * in the MA_MODEL_LIST category.
     */
    model_id: Ie,
    /**
     * The identifier for the asym id of the residue in the
     * structural model, for which local QA metric is provided.
     * This data item is a pointer to _atom_site.label_asym_id
     * in the ATOM_SITE category.
     */
    label_asym_id: ve,
    /**
     * The identifier for the sequence index of the residue
     * in the structural model, for which local QA metric is provided.
     * This data item is a pointer to _atom_site.label_seq_id
     * in the ATOM_SITE category.
     */
    label_seq_id: Ie,
    /**
     * The component identifier for the residue in the
     * structural model, for which local QA metric is provided.
     * This data item is a pointer to _atom_site.label_comp_id
     * in the ATOM_SITE category.
     */
    label_comp_id: ve,
    /**
     * The identifier for the QA metric.
     * This data item is a pointer to _ma_qa_metric.id in the
     * MA_QA_METRIC category.
     */
    metric_id: Ie,
    /**
     * The value of the local QA metric.
     */
    metric_value: yr
  }
};
var Nu = {}, yC = {}, _C = {}, cy = {}, bC = {}, pd = {};
Object.defineProperty(pd, "__esModule", { value: !0 });
pd.uint8ToString = pd.flipByteOrder = pd.IsNativeEndianLittle = void 0;
pd.IsNativeEndianLittle = new Uint16Array(new Uint8Array([18, 52]).buffer)[0] === 13330;
function xae(e, r) {
  for (var t = new ArrayBuffer(e.length), n = new Uint8Array(t), a = 0, i = e.length; a < i; a += r)
    for (var o = 0; o < r; o++)
      n[a + r - o - 1] = e[a + o];
  return t;
}
pd.flipByteOrder = xae;
var Jx = 28672;
function Tae(e) {
  if (e.length > Jx) {
    for (var r = [], t = 0; t < e.length; t += Jx)
      r.push(String.fromCharCode.apply(null, e.subarray(t, t + Jx)));
    return r.join("");
  } else
    return String.fromCharCode.apply(null, e);
}
pd.uint8ToString = Tae;
Object.defineProperty(bC, "__esModule", { value: !0 });
bC.decode = void 0;
var FI = pd, yE = Ft;
function yM(e) {
  for (var r = e.data, t = e.encoding.length - 1; t >= 0; t--)
    r = Pae(r, e.encoding[t]);
  return r;
}
bC.decode = yM;
function Pae(e, r) {
  switch (r.kind) {
    case "ByteArray":
      switch (r.type) {
        case 4:
          return e;
        case 1:
          return Mae(e);
        case 2:
          return wae(e);
        case 5:
          return Eae(e);
        case 3:
          return Dae(e);
        case 6:
          return Iae(e);
        case 32:
          return Bae(e);
        case 33:
          return Nae(e);
        default:
          (0, yE.assertUnreachable)(r.type);
      }
    case "FixedPoint":
      return Vae(e, r);
    case "IntervalQuantization":
      return Rae(e, r);
    case "RunLength":
      return Oae(e, r);
    case "Delta":
      return Fae(e, r);
    case "IntegerPacking":
      return Uae(e, r);
    case "StringArray":
      return zae(e, r);
  }
}
function Xz(e, r) {
  switch (e) {
    case 1:
      return new Int8Array(r);
    case 2:
      return new Int16Array(r);
    case 3:
      return new Int32Array(r);
    case 4:
      return new Uint8Array(r);
    case 5:
      return new Uint16Array(r);
    case 6:
      return new Uint32Array(r);
    default:
      (0, yE.assertUnreachable)(e);
  }
}
function Yz(e, r) {
  switch (e) {
    case 32:
      return new Float32Array(r);
    case 33:
      return new Float64Array(r);
    default:
      (0, yE.assertUnreachable)(e);
  }
}
function Mae(e) {
  return new Int8Array(e.buffer, e.byteOffset);
}
function xp(e, r, t) {
  return FI.IsNativeEndianLittle ? new t(e.buffer) : new t((0, FI.flipByteOrder)(e, r));
}
function wae(e) {
  return xp(e, 2, Int16Array);
}
function Eae(e) {
  return xp(e, 2, Uint16Array);
}
function Dae(e) {
  return xp(e, 4, Int32Array);
}
function Iae(e) {
  return xp(e, 4, Uint32Array);
}
function Bae(e) {
  return xp(e, 4, Float32Array);
}
function Nae(e) {
  return xp(e, 8, Float64Array);
}
function Vae(e, r) {
  for (var t = e.length, n = Yz(r.srcType, t), a = 1 / r.factor, i = 0; i < t; i++)
    n[i] = a * e[i];
  return n;
}
function Rae(e, r) {
  for (var t = e.length, n = Yz(r.srcType, t), a = (r.max - r.min) / (r.numSteps - 1), i = r.min, o = 0; o < t; o++)
    n[o] = i + a * e[o];
  return n;
}
function Oae(e, r) {
  for (var t = Xz(r.srcType, r.srcSize), n = 0, a = 0, i = e.length; a < i; a += 2)
    for (var o = e[a], c = e[a + 1], s = 0; s < c; ++s)
      t[n++] = o;
  return t;
}
function Fae(e, r) {
  var t = e.length, n = Xz(r.srcType, t);
  if (!t)
    return e;
  n[0] = e[0] + (r.origin | 0);
  for (var a = 1; a < t; ++a)
    n[a] = e[a] + n[a - 1];
  return n;
}
function Lae(e, r) {
  for (var t = r.byteCount === 1 ? 127 : 32767, n = -t - 1, a = e.length, i = new Int32Array(r.srcSize), o = 0, c = 0; o < a; ) {
    for (var s = 0, u = e[o]; u === t || u === n; )
      s += u, o++, u = e[o];
    s += u, i[c] = s, o++, c++;
  }
  return i;
}
function kae(e, r) {
  for (var t = r.byteCount === 1 ? 255 : 65535, n = e.length, a = new Int32Array(r.srcSize), i = 0, o = 0; i < n; ) {
    for (var c = 0, s = e[i]; s === t; )
      c += s, i++, s = e[i];
    c += s, a[o] = c, i++, o++;
  }
  return a;
}
function Uae(e, r) {
  return e.length === r.srcSize ? e : r.isUnsigned ? kae(e, r) : Lae(e, r);
}
function zae(e, r) {
  var t = yM({
    encoding: r.offsetEncoding,
    data: r.offsets
  }), n = yM({ encoding: r.dataEncoding, data: e }), a = r.stringData, i = new Array(t.length);
  i[0] = "";
  for (var o = 1, c = t.length; o < c; o++)
    i[o] = a.substring(t[o - 1], t[o]);
  for (var s = 0, u = new Array(n.length), o = 0, c = n.length; o < c; o++)
    u[s++] = i[n[o] + 1];
  return u;
}
var _E = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Encoding = e.VERSION = void 0, e.VERSION = "0.3.0", function(r) {
    function t(a) {
      var i;
      return a instanceof Int8Array ? i = 1 : a instanceof Int16Array ? i = 2 : a instanceof Int32Array ? i = 3 : a instanceof Uint8Array ? i = 4 : a instanceof Uint16Array ? i = 5 : a instanceof Uint32Array ? i = 6 : a instanceof Float32Array ? i = 32 : a instanceof Float64Array ? i = 33 : i = 3, i;
    }
    r.getDataType = t;
    function n(a) {
      if (a instanceof Int8Array || a instanceof Int16Array || a instanceof Int32Array)
        return !0;
      for (var i = 0, o = a.length; i < o; i++)
        if (i < 0)
          return !1;
      return !0;
    }
    r.isSignedIntegerDataType = n;
  }(e.Encoding || (e.Encoding = {}));
})(_E);
var e5 = {}, yf = {}, fa = {};
Object.defineProperty(fa, "__esModule", { value: !0 });
fa.toFixed = fa.toPrecision = fa.getPrecision = fa.isInteger = fa.getArrayDigitCount = fa.integerDigitCount = fa.getMantissaMultiplier = void 0;
function Qz(e, r, t) {
  var n = 1, a;
  for (a = 0; a < r; a++) {
    var i = n * e;
    if (Math.abs(Math.round(i) - i) <= t)
      return a;
    n *= 10;
  }
  return -1;
}
fa.getMantissaMultiplier = Qz;
function Gae(e, r) {
  var t = Math.abs(e);
  return t < r ? 0 : Math.floor(Math.log10(Math.abs(e))) + 1;
}
fa.integerDigitCount = Gae;
function qae(e, r, t) {
  for (var n = 1, a = 0, i = 0, o = e.length; i < o; i++) {
    if (n >= 0) {
      var c = Qz(e[i], r, t);
      c < 0 ? n = -1 : c > n && (n = c);
    }
    var s = Math.abs(e[i]);
    if (s > t) {
      var u = Math.floor(Math.log10(Math.abs(s))) + 1;
      u > a && (a = u);
    }
  }
  return { mantissaDigits: n, integerDigits: a };
}
fa.getArrayDigitCount = qae;
function Hae(e) {
  e = e.trim();
  var r = parseInt(e, 10);
  return isNaN(r) ? !1 : r.toString() === e;
}
fa.isInteger = Hae;
function jae(e) {
  if (!isFinite(e))
    return 0;
  for (var r = 1, t = 0; Math.round(e * r) / r !== e; )
    r *= 10, ++t;
  return t;
}
fa.getPrecision = jae;
function $ae(e, r) {
  return parseFloat(e.toPrecision(r));
}
fa.toPrecision = $ae;
function Kae(e, r) {
  return parseFloat(e.toFixed(r));
}
fa.toFixed = Kae;
var LI;
function bE() {
  if (LI) return yf;
  LI = 1, Object.defineProperty(yf, "__esModule", { value: !0 }), yf.classifyFloatArray = yf.classifyIntArray = void 0;
  var e = Te, r = Zz(), t = fa, n = Ft;
  function a(s) {
    return o.classify(s);
  }
  yf.classifyIntArray = a;
  function i(s) {
    return c.classify(s);
  }
  yf.classifyFloatArray = i;
  var o;
  (function(s) {
    function u(g, _) {
      return g >= 0 ? Math.ceil((g + 1) / _) : Math.ceil((g + 1) / (-_ - 1));
    }
    function l(g) {
      for (var _ = !1, A = 0, M = g.length; A < M; A++)
        if (g[A] < 0) {
          _ = !0;
          break;
        }
      return _ ? { signed: _, limit8: 127, limit16: 32767 } : { signed: _, limit8: 255, limit16: 65535 };
    }
    function f() {
      return { pack8: 0, pack16: 0, count: 0 };
    }
    function d(g, _, A) {
      var M = g.limit8, P = g.limit16;
      _.pack8 += u(A, M), _.pack16 += u(A, P), _.count += 1;
    }
    function m(g, _) {
      g.pack8 += u(_, 127), g.pack16 += u(_, 32767), g.count += 1;
    }
    function p(g) {
      return g.count * 4 < g.pack16 * 2 ? { length: g.count * 4, elem: 4 } : g.pack16 * 2 < g.pack8 ? { length: g.pack16 * 2, elem: 2 } : { length: g.pack8, elem: 1 };
    }
    function v(g, _) {
      for (var A = f(), M = 0, P = g.length; M < P; M++)
        d(_, A, g[M]);
      return (0, e.__assign)((0, e.__assign)({}, p(A)), { kind: "pack" });
    }
    function h(g, _) {
      for (var A = f(), M = g[0], P = 1, T = g.length; P < T; P++)
        m(A, g[P] - M), M = g[P];
      return (0, e.__assign)((0, e.__assign)({}, p(A)), { kind: "delta" });
    }
    function y(g, _) {
      for (var A = f(), M = 1, P = 1, T = g.length; P < T; P++)
        g[P - 1] !== g[P] ? (d(_, A, g[P - 1]), d(_, A, M), M = 1) : M++;
      return d(_, A, g[g.length - 1]), d(_, A, M), (0, e.__assign)((0, e.__assign)({}, p(A)), { kind: "rle" });
    }
    function C(g, _) {
      for (var A = f(), M = 1, P = 0, T = 0, x = 1, w = g.length; x < w; x++) {
        var E = g[x] - P;
        T !== E ? (m(A, T), m(A, M), M = 1) : M++, T = E, P = g[x];
      }
      return m(A, T), m(A, M), (0, e.__assign)((0, e.__assign)({}, p(A)), { kind: "delta-rle" });
    }
    function S(g) {
      var _ = l(g), A = [
        v(g, _),
        y(g, _),
        h(g),
        C(g)
      ];
      return A.sort(function(M, P) {
        return M.length - P.length;
      }), A;
    }
    s.getSize = S;
    function b(g) {
      if (g.length < 2)
        return r.ArrayEncoding.by(r.ArrayEncoding.byteArray);
      var _ = S(g), A = _[0];
      switch (A.kind) {
        case "pack":
          return r.ArrayEncoding.by(r.ArrayEncoding.integerPacking);
        case "rle":
          return r.ArrayEncoding.by(r.ArrayEncoding.runLength).and(r.ArrayEncoding.integerPacking);
        case "delta":
          return r.ArrayEncoding.by(r.ArrayEncoding.delta).and(r.ArrayEncoding.integerPacking);
        case "delta-rle":
          return r.ArrayEncoding.by(r.ArrayEncoding.delta).and(r.ArrayEncoding.runLength).and(r.ArrayEncoding.integerPacking);
        default:
          (0, n.assertUnreachable)(A);
      }
    }
    s.classify = b;
  })(o || (o = {}));
  var c;
  return function(s) {
    var u = 1e-6;
    function l(d) {
      var m = 4, p = (0, t.getArrayDigitCount)(d, m, u), v = p.mantissaDigits, h = p.integerDigits;
      if (v < 0 || v + h > 10)
        return r.ArrayEncoding.by(r.ArrayEncoding.byteArray);
      if (v === 0)
        return o.classify(d);
      for (var y = f(v), C = new Int32Array(d.length), S = 0, b = d.length; S < b; S++)
        C[S] = Math.round(y * d[S]);
      var g = o.getSize(C), _ = g[0], A = r.ArrayEncoding.by(r.ArrayEncoding.fixedPoint(y));
      switch (_.kind) {
        case "pack":
          return A.and(r.ArrayEncoding.integerPacking);
        case "rle":
          return A.and(r.ArrayEncoding.runLength).and(r.ArrayEncoding.integerPacking);
        case "delta":
          return A.and(r.ArrayEncoding.delta).and(r.ArrayEncoding.integerPacking);
        case "delta-rle":
          return A.and(r.ArrayEncoding.delta).and(r.ArrayEncoding.runLength).and(r.ArrayEncoding.integerPacking);
        default:
          (0, n.assertUnreachable)(_);
      }
    }
    s.classify = l;
    function f(d) {
      for (var m = 1, p = 0; p < d; p++)
        m *= 10;
      return m;
    }
  }(c || (c = {})), yf;
}
var kI;
function Zz() {
  return kI || (kI = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.ArrayEncoding = e.ArrayEncoder = e.ArrayEncoderImpl = void 0;
    var r = wr(), t = _E, n = bE(), a = (
      /** @class */
      function() {
        function o(c) {
          this.providers = c;
        }
        return o.prototype.and = function(c) {
          return new o(this.providers.concat([c]));
        }, o.prototype.encode = function(c) {
          for (var s = [], u = 0, l = this.providers; u < l.length; u++) {
            var f = l[u], d = f(c);
            if (!d.encodings.length)
              throw new Error("Encodings must be non-empty.");
            c = d.data;
            for (var m = 0, p = d.encodings; m < p.length; m++) {
              var v = p[m];
              s.push(v);
            }
          }
          if (!(c instanceof Uint8Array))
            throw new Error("The encoding must result in a Uint8Array. Fix your encoding chain.");
          return {
            encoding: s,
            data: c
          };
        }, o;
      }()
    );
    e.ArrayEncoderImpl = a, function(o) {
      function c(l) {
        return new a([l]);
      }
      o.by = c;
      function s(l) {
        for (var f = c(u(l[0])), d = 1; d < l.length; d++)
          f = f.and(u(l[d]));
        return f;
      }
      o.fromEncoding = s;
      function u(l) {
        switch (l.kind) {
          case "ByteArray":
            return i.byteArray;
          case "FixedPoint":
            return i.fixedPoint(l.factor);
          case "IntervalQuantization":
            return i.intervalQuantizaiton(l.min, l.max, l.numSteps);
          case "RunLength":
            return i.runLength;
          case "Delta":
            return i.delta;
          case "IntegerPacking":
            return i.integerPacking;
          case "StringArray":
            return i.stringArray;
        }
      }
    }(e.ArrayEncoder || (e.ArrayEncoder = {}));
    var i;
    (function(o) {
      var c, s;
      function u(x) {
        return new a([x]);
      }
      o.by = u;
      function l(x) {
        return {
          encodings: [{
            kind: "ByteArray",
            type: 4
            /* Uint8 */
          }],
          data: x
        };
      }
      function f(x) {
        return {
          encodings: [{
            kind: "ByteArray",
            type: 1
            /* Int8 */
          }],
          data: new Uint8Array(x.buffer, x.byteOffset)
        };
      }
      var d = (c = {}, c[
        2
        /* Int16 */
      ] = function(x, w, E) {
        x.setInt16(2 * w, E, !0);
      }, c[
        5
        /* Uint16 */
      ] = function(x, w, E) {
        x.setUint16(2 * w, E, !0);
      }, c[
        3
        /* Int32 */
      ] = function(x, w, E) {
        x.setInt32(4 * w, E, !0);
      }, c[
        6
        /* Uint32 */
      ] = function(x, w, E) {
        x.setUint32(4 * w, E, !0);
      }, c[
        32
        /* Float32 */
      ] = function(x, w, E) {
        x.setFloat32(4 * w, E, !0);
      }, c[
        33
        /* Float64 */
      ] = function(x, w, E) {
        x.setFloat64(8 * w, E, !0);
      }, c), m = (s = {}, s[
        2
        /* Int16 */
      ] = 2, s[
        5
        /* Uint16 */
      ] = 2, s[
        3
        /* Int32 */
      ] = 4, s[
        6
        /* Uint32 */
      ] = 4, s[
        32
        /* Float32 */
      ] = 4, s[
        33
        /* Float64 */
      ] = 8, s);
      function p(x) {
        var w = t.Encoding.getDataType(x);
        if (w === 1)
          return f(x);
        if (w === 4)
          return l(x);
        for (var E = new Uint8Array(x.length * m[w]), I = d[w], B = new DataView(E.buffer), D = 0, N = x.length; D < N; D++)
          I(B, D, x[D]);
        return {
          encodings: [{ kind: "ByteArray", type: w }],
          data: E
        };
      }
      o.byteArray = p;
      function v(x, w) {
        for (var E = t.Encoding.getDataType(x), I = new Int32Array(x.length), B = 0, D = x.length; B < D; B++)
          I[B] = Math.round(x[B] * w);
        return {
          encodings: [{ kind: "FixedPoint", factor: w, srcType: E }],
          data: I
        };
      }
      function h(x) {
        return function(w) {
          return v(w, x);
        };
      }
      o.fixedPoint = h;
      function y(x, w, E, I, B) {
        var D = t.Encoding.getDataType(x);
        if (!x.length)
          return {
            encodings: [
              { kind: "IntervalQuantization", min: w, max: E, numSteps: I, srcType: D }
            ],
            data: new Int32Array(0)
          };
        if (E < w) {
          var N = w;
          w = E, E = N;
        }
        for (var O = (E - w) / (I - 1), V = new B(x.length), k = 0, G = x.length; k < G; k++) {
          var L = x[k];
          L <= w ? V[k] = 0 : L >= E ? V[k] = I - 1 : V[k] = Math.round((L - w) / O) | 0;
        }
        return {
          encodings: [
            { kind: "IntervalQuantization", min: w, max: E, numSteps: I, srcType: D }
          ],
          data: V
        };
      }
      function C(x, w, E, I) {
        return I === void 0 && (I = Int32Array), function(B) {
          return y(B, x, w, E, I);
        };
      }
      o.intervalQuantizaiton = C;
      function S(x) {
        var w = t.Encoding.getDataType(x);
        if (w === void 0 && (x = new Int32Array(x), w = 3), !x.length)
          return {
            encodings: [{ kind: "RunLength", srcType: w, srcSize: 0 }],
            data: new Int32Array(0)
          };
        for (var E = 2, I = 1, B = x.length; I < B; I++)
          x[I - 1] !== x[I] && (E += 2);
        for (var D = new Int32Array(E), N = 0, O = 1, I = 1, B = x.length; I < B; I++)
          x[I - 1] !== x[I] ? (D[N] = x[I - 1], D[N + 1] = O, O = 1, N += 2) : ++O;
        return D[N] = x[x.length - 1], D[N + 1] = O, {
          encodings: [{ kind: "RunLength", srcType: w, srcSize: x.length }],
          data: D
        };
      }
      o.runLength = S;
      function b(x) {
        if (!t.Encoding.isSignedIntegerDataType(x))
          throw new Error("Only signed integer types can be encoded using delta encoding.");
        var w = t.Encoding.getDataType(x);
        if (w === void 0 && (x = new Int32Array(x), w = 3), !x.length)
          return {
            encodings: [{ kind: "Delta", origin: 0, srcType: w }],
            data: new x.constructor(0)
          };
        var E = new x.constructor(x.length), I = x[0];
        E[0] = x[0];
        for (var B = 1, D = x.length; B < D; B++)
          E[B] = x[B] - x[B - 1];
        return E[0] = 0, {
          encodings: [{ kind: "Delta", origin: I, srcType: w }],
          data: E
        };
      }
      o.delta = b;
      function g(x) {
        for (var w = 0, E = x.length; w < E; w++)
          if (x[w] < 0)
            return !0;
        return !1;
      }
      function _(x, w) {
        for (var E = -w - 1, I = 0, B = 0, D = x.length; B < D; B++) {
          var N = x[B];
          N === 0 ? I += 1 : N > 0 ? (I += Math.ceil(N / w), N % w === 0 && (I += 1)) : (I += Math.ceil(N / E), N % E === 0 && (I += 1));
        }
        return I;
      }
      function A(x) {
        var w = g(x), E = w ? _(x, 127) : _(x, 255), I = w ? _(x, 32767) : _(x, 65535);
        return x.length * 4 < I * 2 ? {
          isSigned: w,
          size: x.length,
          bytesPerElement: 4
        } : I * 2 < E ? {
          isSigned: w,
          size: I,
          bytesPerElement: 2
        } : {
          isSigned: w,
          size: E,
          bytesPerElement: 1
        };
      }
      function M(x, w) {
        for (var E = w.isSigned ? w.bytesPerElement === 1 ? 127 : 32767 : w.bytesPerElement === 1 ? 255 : 65535, I = -E - 1, B = x.length, D = w.isSigned ? w.bytesPerElement === 1 ? new Int8Array(w.size) : new Int16Array(w.size) : w.bytesPerElement === 1 ? new Uint8Array(w.size) : new Uint16Array(w.size), N = 0, O = 0; O < B; O++) {
          var V = x[O];
          if (V >= 0)
            for (; V >= E; )
              D[N] = E, ++N, V -= E;
          else
            for (; V <= I; )
              D[N] = I, ++N, V -= I;
          D[N] = V, ++N;
        }
        var k = p(D);
        return {
          encodings: [
            {
              kind: "IntegerPacking",
              byteCount: w.bytesPerElement,
              isUnsigned: !w.isSigned,
              srcSize: B
            },
            k.encodings[0]
          ],
          data: k.data
        };
      }
      function P(x) {
        var w = A(x);
        return w.bytesPerElement === 4 ? p(x) : M(x, w);
      }
      o.integerPacking = P;
      function T(x) {
        var w = /* @__PURE__ */ Object.create(null), E = [], I = new Int32Array(x.length), B = r.ChunkedArray.create(Int32Array, 1, Math.min(1024, x.length < 32 ? x.length + 1 : Math.round(x.length / 8) + 1));
        r.ChunkedArray.add(B, 0);
        for (var D = 0, N = 0, O = 0, V = x; O < V.length; O++) {
          var k = V[O];
          if (k == null) {
            I[N++] = -1;
            continue;
          }
          var G = w[k];
          G === void 0 && (D += k.length, G = E.length, E[G] = k, w[k] = G, r.ChunkedArray.add(B, D)), I[N++] = G;
        }
        var L = r.ChunkedArray.compact(B), R = (0, n.classifyIntArray)(L), F = R.encode(L), U = (0, n.classifyIntArray)(I), H = U.encode(I);
        return {
          encodings: [
            {
              kind: "StringArray",
              dataEncoding: H.encoding,
              stringData: E.join(""),
              offsetEncoding: F.encoding,
              offsets: F.data
            }
          ],
          data: H.data
        };
      }
      o.stringArray = T;
    })(i = e.ArrayEncoding || (e.ArrayEncoding = {}));
  }(e5)), e5;
}
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.decode = void 0;
  var r = Te, t = bC;
  Object.defineProperty(e, "decode", { enumerable: !0, get: function() {
    return t.decode;
  } }), (0, r.__exportStar)(_E, e), (0, r.__exportStar)(Zz(), e), (0, r.__exportStar)(bE(), e);
})(cy);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Encoder = e.Category = e.Field = void 0;
  var r = Te, t = yp, n = cy, a = Ft;
  (function(d) {
    function m(S, b, g) {
      return {
        name: S,
        type: 0,
        value: b,
        valueKind: g && g.valueKind,
        defaultFormat: g && g.encoder ? { encoder: g.encoder } : void 0,
        shouldInclude: g && g.shouldInclude
      };
    }
    d.str = m;
    function p(S, b, g) {
      return {
        name: S,
        type: 1,
        value: b,
        valueKind: g && g.valueKind,
        defaultFormat: g ? { encoder: g.encoder, typedArray: g.typedArray } : void 0,
        shouldInclude: g && g.shouldInclude
      };
    }
    d.int = p;
    function v(S, b, g) {
      return {
        name: S,
        type: 2,
        value: b,
        valueKind: g && g.valueKind,
        defaultFormat: g ? {
          encoder: g.encoder,
          typedArray: g.typedArray,
          digitCount: typeof g.digitCount < "u" ? g.digitCount : void 0
        } : void 0,
        shouldInclude: g && g.shouldInclude
      };
    }
    d.float = v;
    function h(S) {
      return p(S, function(b, g, _) {
        return _ + 1;
      }, {
        typedArray: Int32Array,
        encoder: n.ArrayEncoding.by(n.ArrayEncoding.delta).and(n.ArrayEncoding.runLength).and(n.ArrayEncoding.integerPacking)
      });
    }
    d.index = h;
    var y = (
      /** @class */
      function() {
        function S() {
          this.fields = [];
        }
        return S.prototype.index = function(b) {
          return this.fields.push(d.index(b)), this;
        }, S.prototype.str = function(b, g, _) {
          return this.fields.push(d.str(b, g, _)), this;
        }, S.prototype.int = function(b, g, _) {
          return this.fields.push(d.int(b, g, _)), this;
        }, S.prototype.vec = function(b, g, _) {
          for (var A = 0; A < g.length; A++)
            this.fields.push(d.int("".concat(b, "[").concat(A + 1, "]"), g[A], _));
          return this;
        }, S.prototype.float = function(b, g, _) {
          return this.fields.push(d.float(b, g, _)), this;
        }, S.prototype.many = function(b) {
          for (var g = 0; g < b.length; g++)
            this.fields.push(b[g]);
          return this;
        }, S.prototype.add = function(b) {
          return this.fields.push(b), this;
        }, S.prototype.getFields = function() {
          return this.fields;
        }, S;
      }()
    );
    d.Builder = y;
    function C() {
      return new y();
    }
    d.build = C;
  })(e.Field || (e.Field = {}));
  var i;
  (function(d) {
    d.Empty = { fields: [], source: [] };
    function m(v) {
      for (var h = [], y = [], C = [], S = [], b = 0, g = v.split(/[\r\n]+/); b < g.length; b++) {
        var _ = g[b];
        if (_ = _.trim(), _.length !== 0) {
          var A = /^!/.test(_);
          A && (_ = _.substr(1));
          var M = _.split(/\./), P = M[1], T = A ? P ? S : y : P ? C : h;
          T[T.length] = _, P && !h.includes(M[0]) && (h[h.length] = M[0]);
        }
      }
      var x = C.map(function(w) {
        return w.split(".")[0];
      });
      return {
        includeCategory: function(w) {
          return y.includes(w) ? !1 : h.length <= 0 || // otherwise include if whitelist contains category
          h.indexOf(w) !== -1;
        },
        includeField: function(w, E) {
          var I = w + "." + E;
          return S.includes(I) ? !1 : !x.includes(w) || // otherwise must be specifically allowed
          C.includes(I);
        }
      };
    }
    d.filterOf = m, d.DefaultFilter = {
      includeCategory: function(v) {
        return !0;
      },
      includeField: function(v, h) {
        return !0;
      }
    }, d.DefaultFormatter = {
      getFormat: function(v, h) {
      }
    };
    function p(v, h) {
      return h ? {
        fields: f(v._schema),
        source: [
          {
            data: v,
            rowCount: h.length,
            keys: function() {
              return t.Iterator.Array(h);
            }
          }
        ]
      } : {
        fields: f(v._schema),
        source: [{ data: v, rowCount: v._rowCount }]
      };
    }
    d.ofTable = p;
  })(i = e.Category || (e.Category = {})), function(d) {
    function m(v, h, y) {
      v.startDataBlock(h);
      for (var C = function(_) {
        v.writeCategory({
          name: _,
          instance: function() {
            return i.ofTable(y[_]);
          }
        });
      }, S = 0, b = y._tableNames; S < b.length; S++) {
        var g = b[S];
        C(g);
      }
    }
    d.writeDatabase = m;
    function p(v, h) {
      for (var y = 0, C = Object.keys(h); y < C.length; y++) {
        var S = C[y];
        m(v, S, h[S]);
      }
    }
    d.writeDatabaseCollection = p;
  }(e.Encoder || (e.Encoder = {}));
  function o(d) {
    return function(m, p) {
      return p[d].value(m);
    };
  }
  function c(d) {
    return function(m, p) {
      return p[d].value(m).join(p[d].schema.separator);
    };
  }
  function s(d) {
    for (var m = [], p = 1; p < arguments.length; p++)
      m[p - 1] = arguments[p];
    return function(v, h) {
      var y;
      return (y = h[d].schema.space).get.apply(y, (0, r.__spreadArray)([h[d].value(v)], m, !1));
    };
  }
  function u(d) {
    return function(m, p) {
      return p[d].valueKind(m);
    };
  }
  function l(d, m) {
    var p = [], v = 2, h = u(d);
    if (m.rank === 1)
      for (var y = m.dimensions[0], C = 0; C < y; C++) {
        var S = "".concat(d, "[").concat(C + 1, "]");
        p.push({
          name: S,
          type: v,
          value: s(d, C),
          valueKind: h
        });
      }
    else if (m.rank === 2)
      for (var y = m.dimensions[0], b = m.dimensions[1], C = 0; C < y; C++)
        for (var g = 0; g < b; g++) {
          var _ = "".concat(d, "[").concat(C + 1, "][").concat(g + 1, "]");
          p.push({
            name: _,
            type: v,
            value: s(d, C, g),
            valueKind: h
          });
        }
    else if (m.rank === 3)
      for (var A = m.dimensions[0], M = m.dimensions[1], P = m.dimensions[2], C = 0; C < A; C++)
        for (var g = 0; g < M; g++)
          for (var T = 0; T < P; T++) {
            var x = "".concat(d, "[").concat(C + 1, "][").concat(g + 1, "][").concat(T + 1, "]");
            p.push({
              name: x,
              type: v,
              value: s(d, C, g, T),
              valueKind: h
            });
          }
    else
      throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.");
    return p;
  }
  function f(d) {
    for (var m = [], p = 0, v = Object.keys(d); p < v.length; p++) {
      var h = v[p], y = d[h];
      y.valueType === "int" ? m.push({
        name: h,
        type: 1,
        value: o(h),
        valueKind: u(h)
      }) : y.valueType === "float" ? m.push({
        name: h,
        type: 2,
        value: o(h),
        valueKind: u(h)
      }) : y.valueType === "str" ? m.push({
        name: h,
        type: 0,
        value: o(h),
        valueKind: u(h)
      }) : y.valueType === "list" ? m.push({
        name: h,
        type: 0,
        value: c(h),
        valueKind: u(h)
      }) : y.valueType === "tensor" ? m.push.apply(m, l(h, y.space)) : (0, a.assertUnreachable)(y.valueType);
    }
    return m;
  }
})(_C);
var ec = {}, Jz = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Generic = e.Util = e.Iterator = e.Int = e.DB = void 0;
  var r = Te, t = (0, r.__importStar)(mr());
  e.DB = t;
  var n = (0, r.__importStar)(Qe());
  e.Int = n;
  var a = yp;
  Object.defineProperty(e, "Iterator", { enumerable: !0, get: function() {
    return a.Iterator;
  } });
  var i = (0, r.__importStar)(wr());
  e.Util = i;
  var o = (0, r.__importStar)(Po);
  e.Generic = o;
})(Jz);
Object.defineProperty(ec, "__esModule", { value: !0 });
ec.getCategoryInstanceData = ec.getIncludedFields = ec.getFieldDigitCount = void 0;
var Wae = Jz;
function Xae(e) {
  return e.defaultFormat && typeof e.defaultFormat.digitCount < "u" ? Math.max(0, Math.min(e.defaultFormat.digitCount, 16)) : 6;
}
ec.getFieldDigitCount = Xae;
function Yae(e) {
  return e.fields.some(function(r) {
    return !!r.shouldInclude;
  }) ? e.fields.filter(function(r) {
    return !r.shouldInclude || e.source.some(function(t) {
      return r.shouldInclude(t.data);
    });
  }) : e.fields;
}
ec.getIncludedFields = Yae;
function Qae(e, r) {
  var t = e.instance(r), n = t.source.filter(function(o) {
    return o.rowCount > 0;
  });
  if (!n.length)
    return { instance: t, rowCount: 0, source: [] };
  var a = n.reduce(function(o, c) {
    return o + c.rowCount;
  }, 0), i = n.map(function(o) {
    return {
      data: o.data,
      keys: function() {
        return o.keys ? o.keys() : Wae.Iterator.Range(0, o.rowCount - 1);
      },
      rowCount: o.rowCount
    };
  });
  return { instance: t, rowCount: a, source: i };
}
ec.getCategoryInstanceData = Qae;
Object.defineProperty(yC, "__esModule", { value: !0 });
yC.TextEncoder = void 0;
var Qt = We(), F1 = _C, SC = ec, Zae = (
  /** @class */
  function() {
    function e() {
      this.builder = Qt.StringBuilder.create(), this.encoded = !1, this.dataBlockCreated = !1, this.filter = F1.Category.DefaultFilter, this.formatter = F1.Category.DefaultFormatter, this.isBinary = !1, this.binaryEncodingProvider = void 0;
    }
    return e.prototype.setFilter = function(r) {
      this.filter = r || F1.Category.DefaultFilter;
    }, e.prototype.isCategoryIncluded = function(r) {
      return this.filter.includeCategory(r);
    }, e.prototype.setFormatter = function(r) {
      this.formatter = r || F1.Category.DefaultFormatter;
    }, e.prototype.startDataBlock = function(r) {
      this.dataBlockCreated = !0, Qt.StringBuilder.write(this.builder, "data_".concat((r || "").replace(/[ \n\t]/g, "").toUpperCase(), `
#
`));
    }, e.prototype.writeCategory = function(r, t, 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(r.name))) {
        var a = (0, SC.getCategoryInstanceData)(r, t), i = a.instance, o = a.rowCount, c = a.source;
        o && (o === 1 ? Jae(r, i, c, this.builder, this.filter, this.formatter) : eie(r, i, c, this.builder, this.filter, this.formatter));
      }
    }, e.prototype.encode = function() {
      this.encoded = !0;
    }, e.prototype.writeTo = function(r) {
      for (var t = Qt.StringBuilder.getChunks(this.builder), n = 0, a = t.length; n < a; n++)
        r.writeString(t[n]);
    }, e.prototype.getSize = function() {
      return Qt.StringBuilder.getSize(this.builder);
    }, e.prototype.getData = function() {
      return Qt.StringBuilder.getString(this.builder);
    }, e;
  }()
);
yC.TextEncoder = Zae;
function eG(e, r, t, n, a, i) {
  var o = n.valueKind, c = o ? o(t, r) : 0;
  if (c !== 0)
    c === 1 ? aie(e) : iie(e);
  else {
    var s = n.value(t, r, i), u = n.type;
    if (u === 0)
      return rie(s) ? (Z_(e, s), !0) : oie(e, s);
    u === 1 ? tie(e, s) : nie(e, s, a);
  }
  return !1;
}
function rG(e, r, t) {
  for (var n = [], a = 0, i = r; a < i.length; a++) {
    var o = i[a], c = t.getFormat(e, o.name);
    c && typeof c.digitCount < "u" ? n[n.length] = o.type === 2 ? Math.pow(10, Math.max(0, Math.min(c.digitCount, 15))) : 0 : n[n.length] = o.type === 2 ? Math.pow(10, (0, SC.getFieldDigitCount)(o)) : 0;
  }
  return n;
}
function Jae(e, r, t, n, a, i) {
  var o = (0, SC.getIncludedFields)(r), c = t[0], s = c.data, u = o.reduce(function(h, y) {
    return a.includeField(e.name, y.name) ? Math.max(h, y.name.length) : 0;
  }, 0);
  if (u !== 0) {
    u += e.name.length + 6;
    for (var l = c.keys(), f = l.move(), d = rG(e.name, r.fields, i), m = 0; m < o.length; m++) {
      var p = o[m];
      if (a.includeField(e.name, p.name)) {
        Qt.StringBuilder.writePadRight(n, "_".concat(e.name, ".").concat(p.name), u);
        var v = eG(n, s, f, p, d[m], 0);
        v || Qt.StringBuilder.newline(n);
      }
    }
    Qt.StringBuilder.write(n, `#
`);
  }
}
function eie(e, r, t, n, a, i) {
  var o = (0, SC.getIncludedFields)(r), c = a === F1.Category.DefaultFilter ? o : o.filter(function(S) {
    return a.includeField(e.name, S.name);
  }), s = c.length;
  if (s !== 0) {
    var u = rG(e.name, c, i);
    UI(n, "loop_");
    for (var l = 0; l < s; l++)
      UI(n, "_".concat(e.name, ".").concat(c[l].name));
    for (var f = 0, d = 0; d < t.length; d++) {
      var m = t[d], p = m.data;
      if (m.rowCount !== 0)
        for (var v = m.keys(); v.hasNext; ) {
          for (var h = v.move(), y = !1, C = 0; C < s; C++)
            y = eG(n, p, h, c[C], u[C], f);
          y || Qt.StringBuilder.newline(n), f++;
        }
    }
    Qt.StringBuilder.write(n, `#
`);
  }
}
function rie(e) {
  return typeof e == "string" && e.indexOf(`
`) >= 0;
}
function UI(e, r) {
  Qt.StringBuilder.write(e, r), Qt.StringBuilder.newline(e);
}
function tie(e, r) {
  Qt.StringBuilder.writeInteger(e, r), Qt.StringBuilder.whitespace1(e);
}
function nie(e, r, t) {
  Qt.StringBuilder.writeFloat(e, r, t), Qt.StringBuilder.whitespace1(e);
}
function aie(e) {
  Qt.StringBuilder.writeSafe(e, ". ");
}
function iie(e) {
  Qt.StringBuilder.writeSafe(e, "? ");
}
function oie(e, r) {
  if (!r)
    return Qt.StringBuilder.writeSafe(e, ". "), !1;
  for (var t = r.charCodeAt(0), n = !1, a = 0, i = !1, o = !1, c = 0, s = r.length - 1; c <= s; c++) {
    var u = r.charCodeAt(c);
    switch (u) {
      case 9:
        n = !0;
        break;
      case 10:
        return Z_(e, r), !0;
      case 32:
        n = !0;
        break;
      case 34:
        if (c && c === s)
          break;
        if (i)
          return Z_(e, r), !0;
        o = !0, n = !0, a = 0;
        break;
      case 39:
        if (c && c === s)
          break;
        if (o)
          return Z_(e, r), !0;
        i = !0, n = !0, a = 1;
        break;
    }
  }
  return !n && (t === 35 || t === 36 || t === 59 || t === 91 || t === 93 || t === 95) && (n = !0), n ? (Qt.StringBuilder.writeSafe(e, a ? '"' : "'"), Qt.StringBuilder.writeSafe(e, r), Qt.StringBuilder.writeSafe(e, a ? '" ' : "' ")) : (Qt.StringBuilder.writeSafe(e, r), Qt.StringBuilder.writeSafe(e, " ")), !1;
}
function Z_(e, r) {
  Qt.StringBuilder.writeSafe(e, `
;` + r), Qt.StringBuilder.writeSafe(e, `
;
`);
}
var CC = {}, AC = {};
Object.defineProperty(AC, "__esModule", { value: !0 });
AC.encodeMsgPack = void 0;
var Hm = Js;
function uie(e) {
  var r = new ArrayBuffer(J_(e)), t = new DataView(r), n = new Uint8Array(r);
  return eb(e, t, n, 0), n;
}
AC.encodeMsgPack = uie;
function J_(e) {
  var r = typeof e;
  if (r === "string") {
    var t = (0, Hm.utf8ByteCount)(e);
    if (t < 32)
      return 1 + t;
    if (t < 256)
      return 2 + t;
    if (t < 65536)
      return 3 + t;
    if (t < 4294967296)
      return 5 + t;
  }
  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 (r === "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 (r === "boolean" || e === null || e === void 0)
    return 1;
  if (r === "object") {
    var a, i = 0;
    if (Array.isArray(e)) {
      a = e.length;
      for (var o = 0; o < a; o++)
        i += J_(e[o]);
    } else {
      var c = Object.keys(e);
      a = c.length;
      for (var o = 0; o < a; o++) {
        var s = c[o];
        i += J_(s) + J_(e[s]);
      }
    }
    if (a < 16)
      return 1 + i;
    if (a < 65536)
      return 3 + i;
    if (a < 4294967296)
      return 5 + i;
    throw new Error("Array or object too long 0x" + a.toString(16));
  }
  throw new Error("Unknown type " + r);
}
function eb(e, r, t, n) {
  var a = typeof e;
  if (a === "string") {
    var i = (0, Hm.utf8ByteCount)(e);
    if (i < 32)
      return r.setUint8(n, i | 160), (0, Hm.utf8Write)(t, n + 1, e), 1 + i;
    if (i < 256)
      return r.setUint8(n, 217), r.setUint8(n + 1, i), (0, Hm.utf8Write)(t, n + 2, e), 2 + i;
    if (i < 65536)
      return r.setUint8(n, 218), r.setUint16(n + 1, i), (0, Hm.utf8Write)(t, n + 3, e), 3 + i;
    if (i < 4294967296)
      return r.setUint8(n, 219), r.setUint32(n + 1, i), (0, Hm.utf8Write)(t, n + 5, e), 5 + i;
  }
  if (e instanceof Uint8Array) {
    var o = e.byteLength, c = new Uint8Array(r.buffer);
    if (o < 256)
      return r.setUint8(n, 196), r.setUint8(n + 1, o), c.set(e, n + 2), 2 + o;
    if (o < 65536)
      return r.setUint8(n, 197), r.setUint16(n + 1, o), c.set(e, n + 3), 3 + o;
    if (o < 4294967296)
      return r.setUint8(n, 198), r.setUint32(n + 1, o), c.set(e, n + 5), 5 + o;
  }
  if (a === "number") {
    if (!isFinite(e))
      throw new Error("Number not finite: " + e);
    if (Math.floor(e) !== e)
      return r.setUint8(n, 203), r.setFloat64(n + 1, e), 9;
    if (e >= 0) {
      if (e < 128)
        return r.setUint8(n, e), 1;
      if (e < 256)
        return r.setUint8(n, 204), r.setUint8(n + 1, e), 2;
      if (e < 65536)
        return r.setUint8(n, 205), r.setUint16(n + 1, e), 3;
      if (e < 4294967296)
        return r.setUint8(n, 206), r.setUint32(n + 1, e), 5;
      throw new Error("Number too big 0x" + e.toString(16));
    }
    if (e >= -32)
      return r.setInt8(n, e), 1;
    if (e >= -128)
      return r.setUint8(n, 208), r.setInt8(n + 1, e), 2;
    if (e >= -32768)
      return r.setUint8(n, 209), r.setInt16(n + 1, e), 3;
    if (e >= -2147483648)
      return r.setUint8(n, 210), r.setInt32(n + 1, e), 5;
    throw new Error("Number too small -0x" + (-e).toString(16).substr(1));
  }
  if (e == null)
    return r.setUint8(n, 192), 1;
  if (a === "boolean")
    return r.setUint8(n, e ? 195 : 194), 1;
  if (a === "object") {
    var s, u = 0, l = Array.isArray(e), f = void 0;
    if (l ? s = e.length : (f = Object.keys(e), s = f.length), s < 16 ? (r.setUint8(n, s | (l ? 144 : 128)), u = 1) : s < 65536 ? (r.setUint8(n, l ? 220 : 222), r.setUint16(n + 1, s), u = 3) : s < 4294967296 && (r.setUint8(n, l ? 221 : 223), r.setUint32(n + 1, s), u = 5), l)
      for (var d = 0; d < s; d++)
        u += eb(e[d], r, t, n + u);
    else
      for (var d = 0, m = f.length; d < m; d++) {
        var p = f[d];
        u += eb(p, r, t, n + u), u += eb(e[p], r, t, n + u);
      }
    return u;
  }
  throw new Error("Unknown type " + a);
}
Object.defineProperty(CC, "__esModule", { value: !0 });
CC.BinaryEncoder = void 0;
var sie = AC, xu = cy, t2 = _C, zI = ec, GI = bE(), lie = (
  /** @class */
  function() {
    function e(r, t, n) {
      this.autoClassify = n, this.dataBlocks = [], this.filter = t2.Category.DefaultFilter, this.formatter = t2.Category.DefaultFormatter, this.isBinary = !0, this.binaryEncodingProvider = void 0, this.binaryEncodingProvider = t, this.data = {
        encoder: r,
        version: xu.VERSION,
        dataBlocks: this.dataBlocks
      };
    }
    return e.prototype.setFilter = function(r) {
      this.filter = r || t2.Category.DefaultFilter;
    }, e.prototype.isCategoryIncluded = function(r) {
      return this.filter.includeCategory(r);
    }, e.prototype.setFormatter = function(r) {
      this.formatter = r || t2.Category.DefaultFormatter;
    }, e.prototype.startDataBlock = function(r) {
      this.dataBlocks.push({
        header: (r || "").replace(/[ \n\t]/g, "").toUpperCase(),
        categories: []
      });
    }, e.prototype.writeCategory = function(r, t, 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(r.name))) {
        var a = (0, zI.getCategoryInstanceData)(r, t), i = a.instance, o = a.rowCount, c = a.source;
        if (o) {
          for (var s = { name: "_" + r.name, columns: [], rowCount: o }, u = (0, zI.getIncludedFields)(i), l = 0, f = u; l < f.length; l++) {
            var d = f[l];
            if (this.filter.includeField(r.name, d.name)) {
              var m = this.formatter.getFormat(r.name, d.name);
              s.columns.push(vie(r.name, d, c, o, m, this.binaryEncodingProvider, this.autoClassify));
            }
          }
          s.columns.length && this.dataBlocks[this.dataBlocks.length - 1].categories.push(s);
        }
      }
    }, e.prototype.encode = function() {
      this.encodedData || (this.encodedData = (0, sie.encodeMsgPack)(this.data), this.data = null, this.dataBlocks = null);
    }, e.prototype.writeTo = function(r) {
      r.writeBinary(this.encodedData);
    }, e.prototype.getData = function() {
      return this.encode(), this.encodedData;
    }, e.prototype.getSize = function() {
      return this.encodedData.length;
    }, e;
  }()
);
CC.BinaryEncoder = lie;
function cie(e, r) {
  return r && r.typedArray ? r.typedArray : e.defaultFormat && e.defaultFormat.typedArray ? e.defaultFormat.typedArray : e.type === 0 ? Array : e.type === 1 ? Int32Array : Float64Array;
}
function die(e) {
  return e === 0 ? xu.ArrayEncoder.by(xu.ArrayEncoding.stringArray) : xu.ArrayEncoder.by(xu.ArrayEncoding.byteArray);
}
function fie(e, r, t, n) {
  return t && t.encoder ? t.encoder : r.defaultFormat && r.defaultFormat.encoder ? r.defaultFormat.encoder : n ? n.get(e, r.name) : void 0;
}
function mie(e, r) {
  return e === 0 ? xu.ArrayEncoder.by(xu.ArrayEncoding.stringArray) : e === 1 ? (0, GI.classifyIntArray)(r) : (0, GI.classifyFloatArray)(r);
}
function vie(e, r, t, n, a, i, o) {
  var c = pie(r, cie(r, a), n, t), s = c.array, u = c.allPresent, l = c.mask, f = fie(e, r, a, i);
  f || (o ? f = mie(r.type, s) : f = die(r.type));
  var d = f.encode(s), m = void 0;
  if (!u) {
    var p = xu.ArrayEncoder.by(xu.ArrayEncoding.runLength).and(xu.ArrayEncoding.byteArray).encode(l);
    p.data.length < l.length ? m = p : m = xu.ArrayEncoder.by(xu.ArrayEncoding.byteArray).encode(l);
  }
  return {
    name: r.name,
    data: d,
    mask: m
  };
}
function pie(e, r, t, n) {
  for (var a = e.type === 0, i = new r(t), o = new Uint8Array(t), c = e.valueKind, s = e.value, u = !0, l = 0, f = 0; f < n.length; f++)
    for (var d = n[f].data, m = n[f].keys(); m.hasNext; ) {
      var p = m.move(), v = c ? c(p, d) : 0;
      if (v !== 0)
        o[l] = v, a && (i[l] = ""), u = !1;
      else {
        var h = s(p, d, l);
        typeof h == "string" && !h ? (o[l] = 1, u = !1) : o[l] = 0, i[l] = h;
      }
      l++;
    }
  return { array: i, allPresent: u, mask: o };
}
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.CifWriter = void 0;
  var r = Te, t = yC, n = CC, a = (0, r.__importStar)(_C), i = cy;
  (function(o) {
    o.Encoder = a.Encoder, o.Category = a.Category, o.Field = a.Field, o.Encoding = i.ArrayEncoding;
    function c(p) {
      var v = p || {}, h = v.binary, y = h === void 0 ? !1 : h, C = v.encoderName, S = C === void 0 ? "mol*" : C;
      return y ? new n.BinaryEncoder(S, p ? p.binaryEncodingPovider : void 0, p ? !!p.binaryAutoClassifyEncoding : !1) : new t.TextEncoder();
    }
    o.createEncoder = c;
    function s() {
      return o.Field.build();
    }
    o.fields = s;
    var u = o.Encoding;
    o.Encodings = {
      deltaRLE: u.by(u.delta).and(u.runLength).and(u.integerPacking),
      fixedPoint2: u.by(u.fixedPoint(100)).and(u.delta).and(u.integerPacking),
      fixedPoint3: u.by(u.fixedPoint(1e3)).and(u.delta).and(u.integerPacking)
    };
    function l(p, v) {
      return { fields: p, source: [v] };
    }
    o.categoryInstance = l;
    function f(p) {
      return {
        get: function(v, h) {
          var y = p.categories[v];
          if (y) {
            var C = y.getField(h);
            return C && C.binaryEncoding ? i.ArrayEncoder.fromEncoding(C.binaryEncoding) : void 0;
          }
        }
      };
    }
    o.createEncodingProviderFromCifFrame = f;
    function d(p) {
      return {
        get: function(v, h) {
          for (var y = 0; y < p.length; y++) {
            var C = p[y];
            if (C.categoryName === v && C.columnName === h)
              return m(C);
          }
        }
      };
    }
    o.createEncodingProviderFromJsonConfig = d;
    function m(p) {
      var v = p.precision;
      if (v !== void 0) {
        var h = Math.pow(10, v), y = u.by(u.fixedPoint(h));
        switch (p.encoding) {
          case "pack":
            return y.and(u.integerPacking);
          case "rle":
            return y.and(u.runLength).and(u.integerPacking);
          case "delta":
            return y.and(u.delta).and(u.integerPacking);
          case "delta-rle":
            return y.and(u.delta).and(u.runLength).and(u.integerPacking);
        }
      } else
        switch (p.encoding) {
          case "pack":
            return u.by(u.integerPacking);
          case "rle":
            return u.by(u.runLength).and(u.integerPacking);
          case "delta":
            return u.by(u.delta).and(u.integerPacking);
          case "delta-rle":
            return u.by(u.delta).and(u.runLength).and(u.integerPacking);
        }
      throw new Error("cannot be reached");
    }
  })(e.CifWriter || (e.CifWriter = {}));
})(Nu);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ComponentBond = void 0;
  var r = fl, t = Nu, n = mr(), a = hs;
  (function(i) {
    i.Descriptor = {
      name: "chem_comp_bond",
      cifExport: {
        prefix: "",
        categories: [
          {
            name: "chem_comp_bond",
            instance: function(u) {
              var l = i.Provider.get(u.firstModel);
              if (!l)
                return t.CifWriter.Category.Empty;
              var f = l.data;
              if (!f)
                return t.CifWriter.Category.Empty;
              for (var d = u.structures[0].uniqueResidueNames, m = f.comp_id, p = f._rowCount, v = [], h = 0; h < p; h++)
                d.has(m.value(h)) && (v[v.length] = h);
              return t.CifWriter.Category.ofTable(f, v);
            }
          }
        ]
      }
    }, i.Provider = a.FormatPropertyProvider.create(i.Descriptor);
    function o(u, l) {
      return n.Table.pick(l, r.mmCIF_Schema.chem_comp_bond, function(f) {
        return u.properties.chemicalComponentMap.has(l.comp_id.value(f));
      });
    }
    i.chemCompBondFromTable = o;
    function c(u) {
      var l = /* @__PURE__ */ new Map();
      function f(x) {
        if (l.has(x))
          return l.get(x);
        var w = new s(x);
        return l.set(x, w), w;
      }
      for (var d = u.comp_id, m = u.atom_id_1, p = u.atom_id_2, v = u.value_order, h = u.pdbx_aromatic_flag, y = u._rowCount, C = f(d.value(0)), S = 0; S < y; S++) {
        var b = d.value(S), g = m.value(S), _ = p.value(S), A = v.value(S), M = h.value(S) === "Y";
        C.id !== b && (C = f(b));
        var P = 1, T = 1;
        switch (M && (P |= 16), A.toLowerCase()) {
          case "delo":
            P |= 16;
            break;
          case "doub":
            T = 2;
            break;
          case "trip":
            T = 3;
            break;
          case "quad":
            T = 4;
            break;
        }
        C.add(g, _, T, P);
      }
      return l;
    }
    i.getEntriesFromChemCompBond = c;
    var s = (
      /** @class */
      function() {
        function u(l) {
          this.id = l, this.map = /* @__PURE__ */ new Map();
        }
        return u.prototype.add = function(l, f, d, m, p) {
          p === void 0 && (p = !0);
          var v = this.map.get(l);
          if (v !== void 0) {
            var h = v.get(f);
            h === void 0 && v.set(f, { order: d, flags: m });
          } else {
            var y = /* @__PURE__ */ new Map();
            y.set(f, { order: d, flags: m }), this.map.set(l, y);
          }
          p && this.add(f, l, d, m, !1);
        }, u;
      }()
    );
    i.Entry = s;
  })(e.ComponentBond || (e.ComponentBond = {}));
})(gE);
var xC = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.StructConn = void 0;
  var r = Qe(), t = Nu, n = Ed, a = hs;
  (function(i) {
    i.Descriptor = {
      name: "struct_conn",
      cifExport: {
        prefix: "",
        categories: [{
          name: "struct_conn",
          instance: function(l) {
            var f = i.Provider.get(l.firstModel);
            if (!f || f.entries.length === 0)
              return t.CifWriter.Category.Empty;
            for (var d = l.structures[0], m = [], p = 0, v = f.entries; p < v.length; p++) {
              var h = v[p];
              c(d, h.partnerA.atomIndex) && c(d, h.partnerB.atomIndex) && (m[m.length] = h.rowIndex);
            }
            return t.CifWriter.Category.ofTable(f.data, m);
          }
        }]
      }
    }, i.Provider = a.FormatPropertyProvider.create(i.Descriptor);
    function o(l) {
      var f = i.Provider.get(l);
      return !!f && f.data.id.rowCount / l.atomicConformation.atomId.rowCount > 0.95;
    }
    i.isExhaustive = o;
    function c(l, f) {
      for (var d = l.units, m = 0, p = d.length; m < p; m++)
        if (r.SortedArray.indexOf(d[m].elements, f) >= 0)
          return !0;
      return !1;
    }
    function s(l) {
      for (var f = /* @__PURE__ */ new Map(), d = 0, m = l; d < m.length; d++) {
        var p = m[d], v = p.partnerA.atomIndex, h = p.partnerB.atomIndex;
        f.has(v) ? f.get(v).push(p) : f.set(v, [p]), f.has(h) ? f.get(h).push(p) : f.set(h, [p]);
      }
      return f;
    }
    i.getAtomIndexFromEntries = s;
    function u(l, f) {
      for (var d = l.conn_type_id, m = l.pdbx_dist_value, p = l.pdbx_value_order, v = {
        label_asym_id: l.ptnr1_label_asym_id,
        label_seq_id: l.ptnr1_label_seq_id,
        auth_seq_id: l.ptnr1_auth_seq_id,
        label_atom_id: l.ptnr1_label_atom_id,
        label_alt_id: l.pdbx_ptnr1_label_alt_id,
        ins_code: l.pdbx_ptnr1_PDB_ins_code,
        symmetry: l.ptnr1_symmetry
      }, h = {
        label_asym_id: l.ptnr2_label_asym_id,
        label_seq_id: l.ptnr2_label_seq_id,
        auth_seq_id: l.ptnr2_auth_seq_id,
        label_atom_id: l.ptnr2_label_atom_id,
        label_alt_id: l.pdbx_ptnr2_label_alt_id,
        ins_code: l.pdbx_ptnr2_PDB_ins_code,
        symmetry: l.ptnr2_symmetry
      }, y = function(T, x) {
        if (x.label_asym_id.valueKind(T) === 0) {
          var w = x.label_asym_id.value(T), E = f.atomicHierarchy.index.findEntity(w);
          if (!(E < 0)) {
            var I = f.atomicHierarchy.index.findResidue(f.entities.data.id.value(E), w, x.auth_seq_id.value(T), x.ins_code.value(T));
            if (!(I < 0)) {
              var B = x.label_atom_id.value(T);
              if (B) {
                var D = f.atomicHierarchy.index.findAtomOnResidue(I, B, x.label_alt_id.value(T));
                if (!(D < 0))
                  return { residueIndex: I, atomIndex: D, symmetry: x.symmetry.value(T) };
              }
            }
          }
        }
      }, C = [], S = 0; S < l._rowCount; S++) {
        var b = y(S, v), g = y(S, h);
        if (!(b === void 0 || g === void 0)) {
          var _ = d.value(S), A = (p.value(S) || "").toLowerCase(), M = 0, P = 1;
          switch (A) {
            case "sing":
              P = 1;
              break;
            case "doub":
              P = 2;
              break;
            case "trip":
              P = 3;
              break;
            case "quad":
              P = 4;
              break;
            default:
              P = (0, n.getInterBondOrderFromTable)(l.ptnr1_label_comp_id.value(S), l.ptnr1_label_atom_id.value(S), l.ptnr2_label_comp_id.value(S), l.ptnr2_label_atom_id.value(S));
          }
          switch (_) {
            case "covale":
              M = 1;
              break;
            case "disulf":
              M = 9;
              break;
            case "hydrog":
              M = 4;
              break;
            case "metalc":
              M = 2;
              break;
          }
          C.push({
            rowIndex: S,
            flags: M,
            order: P,
            distance: m.value(S),
            partnerA: b,
            partnerB: g
          });
        }
      }
      return C;
    }
    i.getEntriesFromStructConn = u;
  })(e.StructConn || (e.StructConn = {}));
})(xC);
var qI;
function hie() {
  if (qI) return xh;
  qI = 1, Object.defineProperty(xh, "__esModule", { value: !0 }), xh.computeIntraUnitBonds = void 0;
  var e = Te, r = pE(), t = dl, n = hE, a = Qe(), i = Ed, o = Cc, c = gE, s = xC, u = Re, l = Ci, f = o4();
  function d(g, _, A, M, P, T) {
    for (var x = new t.IntAdjacencyGraph.EdgeBuilder(P, g, _), w = new Uint16Array(x.slotCount), E = new Int8Array(x.slotCount), I = 0, B = x.edgeCount; I < B; I++)
      x.addNextEdge(), x.assignProperty(w, M[I]), x.assignProperty(E, A[I]);
    return x.createGraph({ flags: w, order: E }, { canRemap: T });
  }
  var m = (0, u.Vec3)(), p = (0, u.Vec3)();
  function v(g, _, A) {
    return g.conformation.position(_, m), g.conformation.position(A, p), u.Vec3.distance(m, p);
  }
  var h = /* @__PURE__ */ new Set();
  function y(g) {
    for (var _ = o.IndexPairBonds.Provider.get(g.model), A = g.elements, M = g.model.atomicHierarchy.atoms.type_symbol, P = g.elements.length, T = _.bonds, x = T.offset, w = T.b, E = T.edgeProps, I = E.order, B = E.distance, D = E.flag, N = g.model.atomicHierarchy.atomSourceIndex, O = f.Model.getInvertedAtomSourceIndex(g.model).invertedIndex, V = [], k = [], G = [], L = [], R = 0; R < P; R++)
      for (var F = A[R], U = (0, n.getElementIdx)(M.value(F)), H = (0, n.isHydrogen)(U), q = N.value(F), K = x[q], Y = x[q + 1]; K < Y; ++K) {
        var X = O[w[K]];
        if (!(F >= X)) {
          var Z = a.SortedArray.indexOf(g.elements, X);
          if (!(Z < 0)) {
            var J = (0, n.getElementIdx)(M.value(X)), $ = B[K], Q = v(g, F, X), W = !1;
            g.model.sourceData.kind === "mol" || g.model.sourceData.kind === "sdf" || g.model.sourceData.kind === "mol2" ? W = !0 : $ >= 0 ? W = (0, l.equalEps)(Q, $, 0.3) : U === -1 || J === -1 ? W = !0 : H && (0, n.isHydrogen)(J) && (W = !1), W && (V[V.length] = R, k[k.length] = Z, L[L.length] = I[K], G[G.length] = D[K]);
          }
        }
      }
    return d(V, k, L, G, P, !1);
  }
  function C(g, _) {
    for (var A = _.maxRadius, M = g.model.atomicConformation, P = M.x, T = M.y, x = M.z, w = g.elements.length, E = g.elements, I = g.residueIndex, B = g.chainIndex, D = g.model.atomicHierarchy.atoms, N = D.type_symbol, O = D.label_atom_id, V = D.label_alt_id, k = D.label_comp_id, G = g.model.atomicHierarchy.residues.label_seq_id, L = g.model.atomicHierarchy.index, R = g.model.sequence.byEntityKey, F = g.lookup3d, U = s.StructConn.Provider.get(g.model), H = c.ComponentBond.Provider.get(g.model), q = s.StructConn.isExhaustive(g.model), K = [], Y = [], X = [], Z = [], J = -1, $ = void 0, Q = !0, W = !0, te = !0, oe = h, z = 0; z < w; z++) {
      var j = E[z], ae = N.value(j);
      Q && ae !== "H" && ae !== "O" && (Q = !1);
      var le = _.forceCompute ? void 0 : U && U.byAtomIndex.get(j), ie = !1;
      if (le)
        for (var re = 0, ee = le; re < ee.length; re++) {
          var ne = ee[re], se = ne.partnerA, ce = ne.partnerB;
          if (se.symmetry === ce.symmetry) {
            var de = se.atomIndex === j ? ce : se, me = a.SortedArray.indexOf(g.elements, de.atomIndex);
            me < 0 || E[me] < j || (K[K.length] = z, Y[Y.length] = me, X[X.length] = ne.flags, Z[Z.length] = ne.order, ie || oe.clear(), ie = !0, oe.add(me));
          }
        }
      if (!q) {
        var he = I[j], _e = G.value(he), Se = k.value(j);
        if (!_.forceCompute && he !== J)
          if (H && H.entries.has(Se)) {
            var Pe = R[L.getEntityFromChain(B[j])];
            Pe && Pe.sequence.microHet.has(_e) ? $ = void 0 : $ = H.entries.get(Se).map;
          } else
            $ = void 0;
        J = he;
        for (var De = (0, n.getElementIdx)(ae), Ee = O.value(j), Me = $ ? $.get(Ee) : void 0, ue = F.find(P[j], T[j], x[j], A), pe = ue.indices, Ae = ue.count, ye = ue.squaredDistances, be = (0, n.isHydrogen)(De), fe = (0, n.getElementThreshold)(De), ge = V.value(j), xe = n.MetalsSet.has(De), we = 0; we < Ae; we++) {
          var me = pe[we];
          if (!(ie && oe.has(me))) {
            var Ve = E[me];
            if (!(Ve <= j)) {
              var Ne = V.value(Ve);
              if (!(ge && Ne && ge !== Ne)) {
                var Oe = (0, n.getElementIdx)(N.value(Ve)), ze = (0, n.isHydrogen)(Oe);
                if (!(be && ze)) {
                  var ke = (xe || n.MetalsSet.has(Oe)) && !(be || ze);
                  if (!ke) {
                    var je = I[Ve];
                    if (he === je && Me) {
                      var Xe = Me.get(O.value(Ve));
                      if (Xe) {
                        K[K.length] = z, Y[Y.length] = me, Z[Z.length] = Xe.order;
                        var Fe = Xe.flags;
                        ke && (Fe | 1 && (Fe ^= 1), Fe |= 2), X[X.length] = Fe;
                      }
                      continue;
                    }
                    var He = Math.sqrt(ye[we]);
                    if (He !== 0) {
                      var Be = (0, n.getPairingThreshold)(De, Oe, fe, (0, n.getElementThreshold)(Oe));
                      if (He <= Be) {
                        K[K.length] = z, Y[Y.length] = me, Z[Z.length] = (0, i.getIntraBondOrderFromTable)(Se, Ee, O.value(Ve)), X[X.length] = (ke ? 2 : 1) | 32;
                        var Ye = G.value(je);
                        _e === Ye && (W = !1), Math.abs(_e - Ye) > 1 && (te = !1);
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    var cr = Q || W && te;
    return d(K, Y, Z, X, w, cr);
  }
  function S(g) {
    var _ = o.IndexPairBonds.Provider.get(g.model);
    if (!_)
      return d([], [], [], [], 0, !1);
    var A = Array.from(_.bonds.a || []), M = Array.from(_.bonds.b || []), P = Array.from(_.bonds.edgeProps.order || []), T = Array.from(_.bonds.edgeProps.flag || []), x = _.bonds.vertexCount;
    return d(A, M, P, T, x, !1);
  }
  function b(g, _) {
    var A = (0, e.__assign)((0, e.__assign)({}, n.DefaultBondComputationProps), _);
    return A.noCompute || f.Model.isCoarseGrained(g.model) ? r.IntraUnitBonds.Empty : f.Model.isMaterial(g.model) ? S(g) : !A.forceCompute && o.IndexPairBonds.Provider.get(g.model) ? y(g) : C(g, A);
  }
  return xh.computeIntraUnitBonds = b, xh;
}
var Th = {}, HI;
function gie() {
  if (HI) return Th;
  HI = 1, Object.defineProperty(Th, "__esModule", { value: !0 }), Th.computeInterUnitBonds = void 0;
  var e = Te, r = gn(), t = vl(), n = hE, a = pE(), i = Qe(), o = Re, c = Ed, s = Cc, u = qd, l = xC, f = Ci, d = O0(), m = (0, o.Vec3)(), p = (0, o.Vec3)();
  function v(A, M, P, T) {
    return A.conformation.position(M, m), P.conformation.position(T, p), o.Vec3.distance(m, p);
  }
  var h = (0, o.Mat4)(), y = (0, o.Vec3)();
  function C(A, M, P, T) {
    var x = P.maxRadius, w = A.elements, E = A.residueIndex, I = A.model.atomicConformation, B = I.x, D = I.y, N = I.z, O = M.elements, V = M.residueIndex, k = A.elements.length, G = A.model.atomicHierarchy.atoms, L = G.type_symbol, R = G.label_alt_id, F = G.label_atom_id, U = G.label_comp_id, H = M.model.atomicHierarchy.atoms, q = H.type_symbol, K = H.label_alt_id, Y = H.label_atom_id, X = H.label_comp_id, Z = A.model.atomicHierarchy.residues.auth_seq_id, J = M.model.atomicHierarchy.residues.auth_seq_id, $ = A.model.atomicConformation.occupancy, Q = M.model.atomicConformation.occupancy, W = $.isDefined && Q.isDefined, te = A.model === M.model && l.StructConn.Provider.get(A.model), oe = !P.forceCompute && A.model === M.model && s.IndexPairBonds.Provider.get(A.model), z = A.model.atomicHierarchy.atomSourceIndex, j = (oe ? d.Model.getInvertedAtomSourceIndex(M.model) : { invertedIndex: void 0 }).invertedIndex, ae = A.model === M.model && l.StructConn.isExhaustive(A.model), le = o.Mat4.mul(h, M.conformation.operator.inverse, A.conformation.operator.matrix), ie = !o.Mat4.isIdentity(le), re = M.boundary.sphere, ee = re.center, ne = re.radius, se = (ne + x) * (ne + x);
    T.startUnitPair(A.id, M.id);
    for (var ce = 0; ce < k; ce++) {
      var de = w[ce];
      if (o.Vec3.set(y, B[de], D[de], N[de]), ie && o.Vec3.transformMat4(y, y, le), !(o.Vec3.squaredDistance(y, ee) > se)) {
        if (!P.forceCompute && oe) {
          for (var me = oe.maxDistance, he = oe.bonds, _e = he.offset, Se = he.b, Pe = he.edgeProps, De = Pe.order, Ee = Pe.distance, Me = Pe.flag, ue = z.value(de), pe = _e[ue], Ae = _e[ue + 1]; pe < Ae; ++pe) {
            var ye = j[Se[pe]], be = i.SortedArray.indexOf(M.elements, ye);
            if (!(be < 0)) {
              var fe = (0, n.getElementIdx)(L.value(de)), ge = (0, n.getElementIdx)(L.value(ye)), xe = Ee[pe], we = v(A, de, M, ye), Ve = !1;
              if (xe >= 0)
                Ve = (0, f.equalEps)(we, xe, 0.3);
              else if (me >= 0)
                Ve = we < me;
              else {
                var Ne = (0, n.getPairingThreshold)(fe, ge, (0, n.getElementThreshold)(fe), (0, n.getElementThreshold)(ge));
                Ve = we < Ne, (0, n.isHydrogen)(fe) && (0, n.isHydrogen)(ge) && (Ve = !1);
              }
              Ve && T.add(ce, be, { order: De[pe], flag: Me[pe] });
            }
          }
          continue;
        }
        var Oe = P.forceCompute ? void 0 : te && te.byAtomIndex.get(de);
        if (Oe && Oe.length) {
          for (var ze = !1, ke = 0, je = Oe; ke < je.length; ke++) {
            var Xe = je[ke], Fe = Xe.partnerA, He = Xe.partnerB, Be = Fe.atomIndex === de ? He : Fe, be = i.SortedArray.indexOf(M.elements, Be.atomIndex);
            be < 0 || v(A, de, M, Be.atomIndex) > x || (T.add(ce, be, { order: Xe.order, flag: Xe.flags }), ze = !0);
          }
          if (ze)
            continue;
        }
        if (!ae) {
          var Ye = $.value(de), cr = M.lookup3d, Ar = cr.find(y[0], y[1], y[2], x), Lr = Ar.indices, It = Ar.count, en = Ar.squaredDistances;
          if (It !== 0)
            for (var Sn = (0, n.getElementIdx)(L.value(de)), Wn = (0, n.isHydrogen)(Sn), oa = (0, n.getElementThreshold)(Sn), La = R.value(de), ci = n.MetalsSet.has(Sn), Do = F.value(de), nu = U.value(E[de]), Di = 0; Di < It; Di++) {
              var be = Lr[Di], ye = O[be], xa = K.value(ye);
              if (!(La && xa && La !== xa) && !(W && Q.value(ye) < 1 && Ye < 1 && Z.value(de) === J.value(ye))) {
                var ge = (0, n.getElementIdx)(q.value(ye)), Yr = (0, n.isHydrogen)(ge);
                if (!(Wn && Yr)) {
                  var rn = (ci || n.MetalsSet.has(ge)) && !(Wn || Yr);
                  if (!rn) {
                    var we = Math.sqrt(en[Di]);
                    if (we !== 0) {
                      var Ne = (0, n.getPairingThreshold)(Sn, ge, oa, (0, n.getElementThreshold)(ge));
                      if (we <= Ne) {
                        var Ps = Y.value(ye), Ge = X.value(V[ye]);
                        T.add(ce, be, {
                          order: (0, c.getInterBondOrderFromTable)(nu, Ge, Do, Ps),
                          flag: (rn ? 2 : 1) | 32
                          /* Computed */
                        });
                      }
                    }
                  }
                }
              }
            }
        }
      }
    }
    T.finishUnitPair();
  }
  var S = (0, e.__assign)((0, e.__assign)({}, n.DefaultBondComputationProps), { ignoreWater: !0, ignoreIon: !0 });
  function b(A, M) {
    var P = new u.InterUnitGraph.Builder(), T = A.models.some(function(x) {
      return s.IndexPairBonds.Provider.get(x);
    });
    return M.noCompute || A.isCoarseGrained && !T ? new a.InterUnitBonds(P.getMap()) : (r.Structure.eachUnitPair(A, function(x, w) {
      C(x, w, M, P);
    }, {
      maxRadius: M.maxRadius,
      validUnit: function(x) {
        return t.Unit.isAtomic(x);
      },
      validUnitPair: function(x, w) {
        return M.validUnitPair(A, x, w);
      }
    }), new a.InterUnitBonds(P.getMap()));
  }
  function g(A, M) {
    var P = (0, e.__assign)((0, e.__assign)({}, S), M);
    return b(A, (0, e.__assign)((0, e.__assign)({}, P), { validUnitPair: M && M.validUnitPair || function(T, x, w) {
      var E = x.model.atomicHierarchy.derived.residue.moleculeType, I = w.model.atomicHierarchy.derived.residue.moleculeType, B = (!t.Unit.isAtomic(x) || E[x.residueIndex[x.elements[0]]] !== 2) && (!t.Unit.isAtomic(w) || I[w.residueIndex[w.elements[0]]] !== 2), D = x.model === w.model, N = !t.Unit.isAtomic(x) || E[x.residueIndex[x.elements[0]]] !== 3 || D && _(x), O = !t.Unit.isAtomic(w) || I[w.residueIndex[w.elements[0]]] !== 3 || D && _(w), V = N && O;
      return r.Structure.validUnitPair(T, x, w) && (B || !P.ignoreWater) && (V || !P.ignoreIon);
    } }));
  }
  Th.computeInterUnitBonds = g;
  function _(A) {
    if (!t.Unit.isAtomic(A))
      return !1;
    var M = A.elements, P = l.StructConn.Provider.get(A.model);
    if (P) {
      for (var T = 0, x = M.length; T < x; T++)
        if (P.byAtomIndex.get(M[T]))
          return !0;
    }
    return !1;
  }
  return Th;
}
var jI;
function TC() {
  return jI || (jI = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.Bond = void 0;
    var r = Te, t = ia(), n = Gr, a = Qe(), i = Gd;
    (0, r.__exportStar)(pE(), e), (0, r.__exportStar)(hie(), e), (0, r.__exportStar)(gie(), e);
    var o;
    (function(c) {
      function s(A, M, P, T, x, w) {
        return {
          kind: "bond-location",
          aStructure: A,
          aUnit: M,
          aIndex: P,
          bStructure: T,
          bUnit: x,
          bIndex: w
        };
      }
      c.Location = s;
      function u(A) {
        return !!A && A.kind === "bond-location";
      }
      c.isLocation = u;
      function l(A, M) {
        return A.aStructure.label === M.aStructure.label && A.bStructure.label === M.bStructure.label && A.aIndex === M.aIndex && A.bIndex === M.bIndex && A.aUnit.id === M.aUnit.id && A.bUnit.id === M.bUnit.id;
      }
      c.areLocationsEqual = l;
      function f(A, M) {
        return { kind: "bond-loci", structure: A, bonds: M };
      }
      c.Loci = f;
      function d(A) {
        return !!A && A.kind === "bond-loci";
      }
      c.isLoci = d;
      function m(A, M) {
        if (A.structure !== M.structure || A.bonds.length !== M.bonds.length)
          return !1;
        for (var P = 0, T = A.bonds.length; P < T; ++P)
          if (!l(A.bonds[P], M.bonds[P]))
            return !1;
        return !0;
      }
      c.areLociEqual = m;
      function p(A) {
        return A.bonds.length === 0;
      }
      c.isLociEmpty = p;
      function v(A, M) {
        if (M === A.structure)
          return A;
        var P = [];
        return A.bonds.forEach(function(T) {
          var x = M.unitMap.get(T.aUnit.id);
          if (x) {
            var w = M.unitMap.get(T.bUnit.id);
            if (w) {
              var E = T.aUnit.elements[T.aIndex], I = a.SortedArray.indexOf(x.elements, E);
              if (I !== -1) {
                var B = T.bUnit.elements[T.bIndex], D = a.SortedArray.indexOf(w.elements, B);
                D !== -1 && P.push(s(A.structure, x, I, A.structure, w, D));
              }
            }
          }
        }), f(M, P);
      }
      c.remapLoci = v;
      function h(A) {
        for (var M = [], P = /* @__PURE__ */ new Map(), T = 0, x = A.bonds; T < x.length; T++) {
          var w = x[T], E = w.aIndex, I = w.aUnit, B = w.bIndex, D = w.bUnit;
          I === D ? P.has(I.id) ? P.get(I.id).push(E, B) : P.set(I.id, [E, B]) : (P.has(I.id) ? P.get(I.id).push(E) : P.set(I.id, [E]), P.has(D.id) ? P.get(D.id).push(B) : P.set(D.id, [B]));
        }
        return P.forEach(function(N, O) {
          M.push({
            unit: A.structure.unitMap.get(O),
            indices: a.SortedArray.deduplicate(a.SortedArray.ofUnsortedArray(N))
          });
        }), t.StructureElement.Loci(A.structure, M);
      }
      c.toStructureElementLoci = h;
      function y(A) {
        var M = A.bonds[0], P = M.aUnit, T = M.aIndex;
        return t.StructureElement.Loci(A.structure, [{ unit: P, indices: a.OrderedSet.ofSingleton(T) }]);
      }
      c.toFirstStructureElementLoci = y;
      function C(A, M) {
        if (M.aUnit === M.bUnit) {
          var P = M.aUnit.bonds, T = P.getEdgeIndex(M.aIndex, M.bIndex);
          return T < 0 ? n.BondType.create(
            0
            /* None */
          ) : n.BondType.create(P.edgeProps.flags[T]);
        } else {
          var x = A.interUnitBonds.getBondFromLocation(M);
          return x ? n.BondType.create(x.props.flag) : n.BondType.create(
            0
            /* None */
          );
        }
      }
      c.getType = C;
      function S(A, M) {
        if (M.aUnit === M.bUnit) {
          var P = M.aUnit.bonds, T = P.getEdgeIndex(M.aIndex, M.bIndex);
          return T < 0 ? 0 : P.edgeProps.order[T];
        } else {
          var x = A.interUnitBonds.getBondFromLocation(M);
          return x ? x.props.order : 0;
        }
      }
      c.getOrder = S;
      function b(A) {
        for (var M = 0, P = 0, T = A.units.length; P < T; ++P) {
          var x = A.units[P];
          t.Unit.isAtomic(x) && (M += x.bonds.edgeCount);
        }
        return M;
      }
      c.getIntraUnitBondCount = b;
      var g = (
        /** @class */
        function() {
          function A() {
            this.current = {}, this.hasNext = !1;
          }
          return A.prototype.move = function() {
            return this.advance(), this.current;
          }, A.prototype.setElement = function(M, P, T) {
            this.structure = M, this.unit = P, this.index = T, this.interBondIndices = M.interUnitBonds.getEdgeIndices(T, P.id), this.interBondCount = this.interBondIndices.length, this.interBondIndex = 0, this.intraBondEnd = P.bonds.offset[T + 1], this.intraBondIndex = P.bonds.offset[T], 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) {
              var M = this.structure.interUnitBonds.edges[this.interBondIndex];
              this.current.otherUnit = this.structure.unitMap.get(M.unitA !== this.unit.id ? M.unitA : M.unitB), this.current.otherIndex = M.indexA !== this.index ? M.indexA : M.indexB, this.current.type = M.props.flag, this.current.order = M.props.order, this.interBondIndex += 1;
            } else {
              this.hasNext = !1;
              return;
            }
            this.hasNext = this.interBondIndex < this.interBondCount || this.intraBondIndex < this.intraBondEnd;
          }, A;
        }()
      );
      c.ElementBondIterator = g;
      function _(A, M) {
        return i.CentroidHelper.fromPairProvider(A.bonds.length, function(P, T, x) {
          var w = A.bonds[P], E = w.aUnit, I = w.aIndex, B = w.bUnit, D = w.bIndex;
          E.conformation.position(E.elements[I], T), B.conformation.position(B.elements[D], x);
        }, M);
      }
      c.getBoundingSphere = _;
    })(o || (o = {})), e.Bond = o;
  }(Qx)), Qx;
}
var fc = {}, hd = {};
Object.defineProperty(hd, "__esModule", { value: !0 });
hd.createIndex = hd.getFingerprint = hd.computeRings = void 0;
var q1 = Qe(), $I = dl, yie = Gr, _ie = wr(), KI = hr;
function bie(e) {
  for (var r = Cie(e), t = Sie(e, r), n = q1.Segmentation.transientSegments(e.model.atomicHierarchy.residueAtomSegments, e.elements); n.hasNext; ) {
    var a = n.move();
    Aie(t, a.start, a.end);
  }
  return t.rings;
}
hd.computeRings = bie;
function Sie(e, r) {
  return {
    startVertex: 0,
    endVertex: 0,
    count: 0,
    isRingAtom: new Int32Array(r),
    marked: new Int32Array(r),
    queue: new Int32Array(r),
    pred: new Int32Array(r),
    depth: new Int32Array(r),
    left: new Int32Array(
      5
      /* MaxDepth */
    ),
    right: new Int32Array(
      5
      /* MaxDepth */
    ),
    color: new Int32Array(r),
    currentColor: 0,
    currentAltLoc: "",
    hasAltLoc: !1,
    rings: [],
    currentRings: [],
    unit: e,
    bonds: e.bonds,
    altLoc: e.model.atomicHierarchy.atoms.label_alt_id
  };
}
function WI(e) {
  e.count = e.endVertex - e.startVertex;
  for (var r = e.isRingAtom, t = e.pred, n = e.color, a = e.depth, i = e.marked, o = 0; o < e.count; o++)
    r[o] = 0, t[o] = -1, i[o] = -1, n[o] = 0, a[o] = 0;
  e.currentColor = 0, e.currentAltLoc = "", e.hasAltLoc = !1;
}
function XI(e) {
  for (var r = e.depth, t = 0; t < e.count; t++)
    r[t] = e.count + 1;
}
function Cie(e) {
  for (var r = q1.Segmentation.transientSegments(e.model.atomicHierarchy.residueAtomSegments, e.elements), t = 0; r.hasNext; ) {
    var n = r.move();
    t = Math.max(t, n.end - n.start);
  }
  return t;
}
function YI(e, r) {
  var t = e.bonds.offset, n = e.startVertex + r, a = t[n], i = t[n + 1], o = i - a;
  return !(o <= 1 || e.isRingAtom[r] && o === 2);
}
function Aie(e, r, t) {
  if (e.startVertex = r, e.endVertex = t, !(e.endVertex - e.startVertex < 3)) {
    e.currentRings = [];
    for (var n = e.unit.elements, a = [], i = e.startVertex; i < e.endVertex; i++) {
      var o = e.altLoc.value(n[i]);
      (0, KI.arraySetAdd)(a, o);
    }
    (0, KI.arraySetRemove)(a, "");
    var c = 1;
    if (a.length === 0) {
      WI(e);
      for (var i = 0; i < e.count; i++)
        YI(e, i) && (XI(e), c = QI(e, i, c));
    } else
      for (var s = 0; s < a.length; s++) {
        WI(e), e.hasAltLoc = !0, e.currentAltLoc = a[s];
        for (var i = 0; i < e.count; i++)
          if (YI(e, i)) {
            var o = e.altLoc.value(n[e.startVertex + i]);
            o && o !== e.currentAltLoc || (XI(e), c = QI(e, i, c));
          }
      }
    for (var i = 0, u = e.currentRings.length; i < u; i++)
      e.rings.push(e.currentRings[i]);
  }
}
function xie(e, r, t, n) {
  if (t < r)
    return !1;
  for (var a = e.pred, i = e.color, o = e.left, c = e.right, s = ++e.currentColor, u = r, l = 0; l < 5 && (i[u] = s, u = a[u], !(u < 0)); l++)
    ;
  var f = 0, d = 0, m = !1, p = 0;
  u = t;
  for (var l = 0; l < 5; l++) {
    if (i[u] === s) {
      p = u, m = !0;
      break;
    }
    if (c[d++] = u, u = a[u], u < 0)
      break;
  }
  if (!m)
    return !1;
  u = r;
  for (var l = 0; l < 5 && (o[f++] = u, !(p === u || (u = a[u], u < 0))); l++)
    ;
  var v = f + d;
  if (v < 3)
    return !1;
  for (var h = new Int32Array(v), y = 0, l = 0; l < f; l++)
    h[y++] = e.startVertex + o[l], n[o[l]] = 1;
  for (var l = d - 1; l >= 0; l--)
    h[y++] = e.startVertex + c[l], n[c[l]] = 1;
  (0, _ie.sortArray)(h);
  for (var C = 0, S = e.currentRings.length; C < S; C++) {
    var b = e.currentRings[C];
    if (h.length === b.length) {
      if (q1.SortedArray.areEqual(h, b))
        return !1;
    } else if (h.length > b.length && q1.SortedArray.isSubset(h, b))
      return !1;
  }
  return e.currentRings.push(q1.SortedArray.ofSortedArray(h)), !0;
}
function QI(e, r, t) {
  var n = e.bonds, a = e.startVertex, i = e.endVertex, o = e.isRingAtom, c = e.marked, s = e.queue, u = e.pred, l = e.depth, f = e.unit.elements, d = n.b, m = n.edgeProps.flags, p = n.offset;
  c[r] = t, l[r] = 0, s[0] = r;
  for (var v = 0, h = 1; v < h; )
    for (var y = s[v++], C = l[y], S = a + y, b = p[S], g = p[S + 1], _ = b; _ < g; _++) {
      var A = d[_];
      if (!(A < a || A >= i || !yie.BondType.isCovalent(m[_]))) {
        if (e.hasAltLoc) {
          var M = e.altLoc.value(f[A]);
          if (M && e.currentAltLoc !== M)
            continue;
        }
        var P = A - a;
        if (c[P] === t) {
          if (u[P] !== y && u[y] !== P && xie(e, y, P, o))
            return t + 1;
          continue;
        }
        var T = Math.min(l[P], C + 1);
        T > 5 || (l[P] = T, c[P] = t, s[h++] = P, u[P] = y);
      }
    }
  return t + 1;
}
function Tie(e) {
  for (var r = e.length, t = new Array(r), n = 0; n < r; n++)
    t[n] = e[r - n - 1];
  for (var a = ZI(e), i = ZI(t), o = !1, n = 0; n < r; n++) {
    var c = e[(n + a) % r], s = t[(n + i) % r];
    if (c !== s) {
      o = c < s;
      break;
    }
  }
  return o ? JI(e, a) : JI(t, i);
}
hd.getFingerprint = Tie;
function ZI(e) {
  for (var r = e.length, t = new Int32Array(r * 2), n = 0; n < t.length; n++)
    t[n] = -1;
  for (var a = "", i = "", o = 0, c = 1; c < t.length; c++) {
    for (var n = t[c - o - 1]; n !== -1 && (a = e[c % r], i = e[(o + n + 1) % r], a !== i); )
      a < i && (o = c - n - 1), n = t[n];
    n === -1 ? (a = e[c % r], i = e[(o + n + 1) % r], a !== i ? (a < i && (o = c), t[c - o] = -1) : t[c - o] = n + 1) : t[c - o] = n + 1;
  }
  return o;
}
function JI(e, r) {
  var t = e.length, n = [], a;
  for (a = 0; a < t - 1; a++)
    n.push(e[(a + r) % t]), n.push("-");
  return n.push(e[(a + r) % t]), n.join("");
}
function Pie(e, r) {
  for (var t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), a = 0, i = e.length; a < i; a++)
    for (var o = e[a], c = 0, s = o.length; c < s; c++) {
      var u = o[c];
      t.has(u) ? t.get(u).push(a) : t.set(u, [a]);
    }
  for (var l = 0, f = r.length; l < f; l++)
    for (var a = r[l], o = e[a], c = 0, s = o.length; c < s; c++) {
      var u = o[c];
      n.has(u) ? n.get(u).push(a) : n.set(u, [a]);
    }
  for (var d = new $I.IntAdjacencyGraph.UniqueEdgeBuilder(e.length), a = 0, i = e.length; a < i; a++)
    for (var o = e[a], c = 0, s = o.length; c < s; c++) {
      var u = o[c], m = t.get(u);
      if (m.length !== 1)
        for (var p = 0, v = m.length; p < v; p++) {
          var h = m[p];
          a >= h || d.addEdge(a, h);
        }
    }
  for (var y = $I.IntAdjacencyGraph.connectedComponents(d.getGraph()), C = y.componentIndex, S = [], c = 0; c < y.componentCount; c++)
    S[c] = [];
  for (var a = 0, i = e.length; a < i; a++)
    S[C[a]].push(a);
  return {
    elementRingIndices: t,
    elementAromaticRingIndices: n,
    ringComponentIndex: C,
    ringComponents: S
  };
}
hd.createIndex = Pie;
var Za = {};
Object.defineProperty(Za, "__esModule", { value: !0 });
Za.getPositions = Za.getAtomIdForAtomRole = Za.getAtomicMoleculeType = Za.getElementMoleculeType = Za.getCoarseBegCompId = void 0;
var tG = Gr, nG = Re;
function aG(e, r) {
  var t = e.coarseElements.entityKey[r], n = e.model.sequence.byEntityKey[t].sequence, a = e.coarseElements.seq_id_begin.value(r);
  return n.compId.value(a - 1);
}
Za.getCoarseBegCompId = aG;
function Mie(e, r) {
  switch (e.kind) {
    case 0:
      return e.model.atomicHierarchy.derived.residue.moleculeType[e.residueIndex[r]];
    case 1:
    case 2:
      var t = aG(e, r), n = e.model.properties.chemicalComponentMap.get(t);
      if (n)
        return (0, tG.getMoleculeType)(n.type, t);
  }
  return 0;
}
Za.getElementMoleculeType = Mie;
function wie(e, r) {
  return e.atomicHierarchy.derived.residue.moleculeType[r];
}
Za.getAtomicMoleculeType = wie;
var Eie = /* @__PURE__ */ new Set();
function Die(e, r) {
  var t = tG.PolymerTypeAtomRoleId[e];
  if (t !== void 0) {
    var n = t[r];
    if (n !== void 0)
      return n;
  }
  return Eie;
}
Za.getAtomIdForAtomRole = Die;
var e8 = nG.Vec3.zero();
function Iie(e, r) {
  for (var t = e.conformation.position, n = new Float32Array(r.length * 3), a = e.elements, i = 0, o = r.length; i < o; ++i)
    t(a[r[i]], e8), nG.Vec3.toArray(e8, n, i * 3);
  return n;
}
Za.getPositions = Iie;
Object.defineProperty(fc, "__esModule", { value: !0 });
fc.UnitRings = fc.UnitRing = void 0;
var SE = hd, Bie = Qe(), Nie = Gr, Vie = Za, Rie = sy(), Oie = Re, Tb = (
  /** @class */
  function() {
    function e(r, t) {
      this.unit = t, this.all = r;
    }
    return Object.defineProperty(e.prototype, "index", {
      get: function() {
        return this._index ? this._index : (this._index = (0, SE.createIndex)(this.all, this.aromaticRings), this._index);
      },
      enumerable: !1,
      configurable: !0
    }), Object.defineProperty(e.prototype, "byFingerprint", {
      get: function() {
        return this._byFingerprint ? this._byFingerprint : (this._byFingerprint = Fie(this.unit, this.all), this._byFingerprint);
      },
      enumerable: !1,
      configurable: !0
    }), Object.defineProperty(e.prototype, "elementRingIndices", {
      /** Maps atom index inside a Unit to ring indices (an atom can be part of more than one ring) */
      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", {
      /** Maps UnitRings.Index to index to ringComponents */
      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 : (this._aromaticRings = Uie(this.unit, this.all), this._aromaticRings);
      },
      enumerable: !1,
      configurable: !0
    }), e;
  }()
);
fc.UnitRings = Tb;
var Tg;
(function(e) {
  function r(c, s) {
    for (var u = c.elements, l = c.model.atomicHierarchy.atoms.type_symbol, f = [], d = 0, m = s.length; d < m; d++)
      f[f.length] = l.value(u[s[d]]);
    return t(f);
  }
  e.fingerprint = r;
  function t(c) {
    return (0, SE.getFingerprint)(c);
  }
  e.elementFingerprint = t;
  var n = /* @__PURE__ */ new Set([
    "B",
    "C",
    "N",
    "O",
    "SI",
    "P",
    "S",
    "GE",
    "AS",
    "SN",
    "SB",
    "BI"
    /* BI */
  ]), a = 0.05;
  function i(c, s) {
    var u = c.elements, l = c.bonds, f = l.b, d = l.offset, m = l.edgeProps.flags, p = c.model.atomicHierarchy.atoms, v = p.type_symbol, h = p.label_comp_id;
    if (h.value(c.elements[s[0]]) === "PRO")
      return !1;
    for (var y = 0, C = !1, S = 0, b = s.length; S < b; ++S) {
      var g = s[S];
      !C && n.has(v.value(u[g])) && (C = !0);
      for (var _ = d[g], A = d[g + 1]; _ < A; ++_)
        Nie.BondType.is(16, m[_]) && Bie.SortedArray.has(s, f[_]) && (y += 1);
    }
    if (y === 2 * s.length)
      return !0;
    if (!C || s.length < 5)
      return !1;
    var M = Rie.PrincipalAxes.calculateMomentsAxes((0, Vie.getPositions)(c, s));
    return Oie.Vec3.magnitude(M.dirC) < a;
  }
  e.isAromatic = i;
  function o(c, s) {
    for (var u = c.model.atomicHierarchy.atoms.label_alt_id, l = c.elements, f = 0, d = s.length; f < d; ++f) {
      var m = l[s[f]], p = u.value(m);
      if (p)
        return p;
    }
    return "";
  }
  e.getAltId = o;
})(Tg || (Tg = {}));
fc.UnitRing = Tg;
(function(e) {
  function r(n) {
    var a = (0, SE.computeRings)(n);
    return new e(a, n);
  }
  e.create = r;
  function t(n, a) {
    for (var i = /* @__PURE__ */ new Map(), o = 0, c = a.length; o < c; o++) {
      var s = a[o];
      kie(n, s, i);
    }
    return i;
  }
  e.byFingerprintAndResidue = t;
})(Tb || (Tb = {}));
fc.UnitRings = Tb;
function Fie(e, r) {
  for (var t = /* @__PURE__ */ new Map(), n = 0, a = 0, i = r.length; a < i; a++) {
    var o = r[a], c = Tg.fingerprint(e, o);
    t.has(c) ? t.get(c).push(n) : t.set(c, [n]), n++;
  }
  return t;
}
function Lie(e, r) {
  for (var t = e.elements, n = e.model.atomicHierarchy.residueAtomSegments.index, a = n[t[r[0]]], i = 1, o = r.length; i < o; i++)
    if (a !== n[t[r[i]]])
      return -1;
  return a;
}
function kie(e, r, t) {
  var n = e.byFingerprint.get(r);
  if (n)
    for (var a = 0, i = n.length; a < i; a++) {
      var o = n[a], c = Lie(e.unit, e.all[o]);
      c >= 0 && (t.has(c) ? t.get(c).push(o) : t.set(c, [o]));
    }
}
function Uie(e, r) {
  for (var t = [], n = 0, a = r.length; n < a; ++n)
    Tg.isAromatic(e, r[n]) && t.push(n);
  return t;
}
var Ii = {}, Qo = {};
Object.defineProperty(Qo, "__esModule", { value: !0 });
Qo.SortedRanges = void 0;
var _f = Qe(), _M;
(function(e) {
  function r(b) {
    return _f.SortedArray.ofSortedArray(b);
  }
  e.ofSortedRanges = r;
  function t(b) {
    return b[0];
  }
  e.start = t;
  function n(b) {
    return b[b.length - 1] + 1;
  }
  e.end = n;
  function a(b) {
    return b[0];
  }
  e.min = a;
  function i(b) {
    return b[b.length - 1];
  }
  e.max = i;
  function o(b) {
    for (var g = 0, _ = 0, A = b.length; _ < A; _ += 2)
      g += b[_ + 1] - b[_] + 1;
    return g;
  }
  e.size = o;
  function c(b) {
    return b.length / 2;
  }
  e.count = c;
  function s(b, g) {
    return b[g * 2];
  }
  e.startAt = s;
  function u(b, g) {
    return b[g * 2 + 1] + 1;
  }
  e.endAt = u;
  function l(b, g) {
    return b[g * 2];
  }
  e.minAt = l;
  function f(b, g) {
    return b[g * 2 + 1];
  }
  e.maxAt = f;
  function d(b, g) {
    if (b.length !== g.length)
      return !1;
    for (var _ = 0, A = b.length; _ < A; ++_)
      if (b[_] !== g[_])
        return !1;
    return !0;
  }
  e.areEqual = d;
  function m(b, g) {
    for (var _ = 0, A = 0, M = b.length; A < M; A += 2)
      for (var P = b[A], T = b[A + 1]; P <= T; ++P)
        g(P, _), ++_;
  }
  e.forEach = m;
  function p(b, g) {
    return h(b, g) !== -1;
  }
  e.has = p;
  function v(b, g, _) {
    return y(b, g, _) !== -1;
  }
  e.hasFrom = v;
  function h(b, g) {
    return y(b, g, 0);
  }
  e.firstIntersectionIndex = h;
  function y(b, g, _) {
    if (l(b, _) > _f.OrderedSet.max(g) || i(b) < _f.OrderedSet.min(g))
      return -1;
    for (var A = _, M = c(b); A < M; ++A) {
      var P = _f.Interval.ofRange(l(b, A), f(b, A));
      if (_f.OrderedSet.areIntersecting(P, g))
        return A;
    }
    return -1;
  }
  e.firstIntersectionIndexFrom = y;
  function C(b, g) {
    return new S(b, g);
  }
  e.transientSegments = C;
  var S = (
    /** @class */
    function() {
      function b(g, _) {
        this.ranges = g, this.set = _, this.value = { index: 0, start: 0, end: 0 }, this.curIndex = 0, this.hasNext = !1, this.curIndex = h(g, _), this.hasNext = this.curIndex !== -1;
      }
      return b.prototype.updateValue = function() {
        this.value.index = this.curIndex, this.value.start = _f.OrderedSet.findPredecessorIndex(this.set, s(this.ranges, this.curIndex)), this.value.end = _f.OrderedSet.findPredecessorIndex(this.set, u(this.ranges, this.curIndex));
      }, b.prototype.move = function() {
        return this.hasNext && (this.updateValue(), this.curIndex = y(this.ranges, this.set, this.curIndex + 1), this.hasNext = this.curIndex !== -1), this.value;
      }, b;
    }()
  );
  e.Iterator = S;
})(_M || (_M = {}));
Qo.SortedRanges = _M;
var r8;
function zie() {
  if (r8) return Ii;
  r8 = 1, Object.defineProperty(Ii, "__esModule", { value: !0 }), Ii.getProteinElements = Ii.getNucleotideElements = Ii.getCoarseGapElements = Ii.getAtomicGapElements = Ii.getCoarsePolymerElements = Ii.getAtomicPolymerElements = void 0;
  var e = Je(), r = Qe(), t = Qo, n = Gr;
  function a(l) {
    for (var f = [], d = l.elements, m = l.model, p = l.model.atomicHierarchy.residueAtomSegments, v = m.atomicHierarchy.derived.residue.traceElementIndex, h = t.SortedRanges.transientSegments(l.model.atomicRanges.polymerRanges, d), y = r.Segmentation.transientSegments(p, d); h.hasNext; ) {
      var C = h.move();
      for (y.setSegment(C); y.hasNext; ) {
        var S = y.move(), b = S.start, g = S.end, _ = S.index;
        if (r.OrderedSet.areIntersecting(r.Interval.ofRange(d[b], d[g - 1]), d)) {
          var A = v[_];
          f.push(A === -1 ? p.offsets[_] : A);
        }
      }
    }
    return r.SortedArray.ofSortedArray(f);
  }
  Ii.getAtomicPolymerElements = a;
  function i(l) {
    for (var f = [], d = l.elements, m = l.model, p = m.coarseHierarchy, v = p.spheres, h = p.gaussians, y = e.Unit.isSpheres(l) ? v.polymerRanges : h.polymerRanges, C = t.SortedRanges.transientSegments(y, d); C.hasNext; )
      for (var S = C.move(), b = S.start, g = S.end, _ = b; _ < g; ++_)
        f.push(d[_]);
    return r.SortedArray.ofSortedArray(f);
  }
  Ii.getCoarsePolymerElements = i;
  function o(l) {
    for (var f = [], d = l.elements, m = l.model, p = l.residueIndex, v = l.model.atomicHierarchy.residueAtomSegments, h = m.atomicHierarchy.derived.residue.traceElementIndex, y = t.SortedRanges.transientSegments(l.model.atomicRanges.gapRanges, l.elements); y.hasNext; ) {
      var C = y.move(), S = p[d[C.start]], b = p[d[C.end - 1]], g = h[S], _ = h[b];
      f.push(g === -1 ? v.offsets[S] : g), f.push(_ === -1 ? v.offsets[b] : _);
    }
    return r.SortedArray.ofSortedArray(f);
  }
  Ii.getAtomicGapElements = o;
  function c(l) {
    for (var f = [], d = l.elements, m = l.model, p = m.coarseHierarchy, v = p.spheres, h = p.gaussians, y = e.Unit.isSpheres(l) ? v.gapRanges : h.gapRanges, C = t.SortedRanges.transientSegments(y, d); C.hasNext; ) {
      var S = C.move(), b = S.start, g = S.end;
      f.push(d[b], d[g - 1]);
    }
    return r.SortedArray.ofSortedArray(f);
  }
  Ii.getCoarseGapElements = c;
  function s(l) {
    for (var f = [], d = l.elements, m = l.model, p = m.atomicHierarchy, v = p.chainAtomSegments, h = p.residueAtomSegments, y = m.atomicHierarchy.derived.residue, C = y.moleculeType, S = y.traceElementIndex, b = r.Segmentation.transientSegments(v, d), g = r.Segmentation.transientSegments(h, d); b.hasNext; )
      for (g.setSegment(b.move()); g.hasNext; ) {
        var _ = g.move().index;
        if ((0, n.isNucleic)(C[_])) {
          var A = S[_];
          f.push(A === -1 ? h.offsets[_] : A);
        }
      }
    return r.SortedArray.ofSortedArray(f);
  }
  Ii.getNucleotideElements = s;
  function u(l) {
    for (var f = [], d = l.elements, m = l.model, p = m.atomicHierarchy, v = p.chainAtomSegments, h = p.residueAtomSegments, y = m.atomicHierarchy.derived.residue, C = y.moleculeType, S = y.traceElementIndex, b = r.Segmentation.transientSegments(v, d), g = r.Segmentation.transientSegments(h, d); b.hasNext; )
      for (g.setSegment(b.move()); g.hasNext; ) {
        var _ = g.move().index;
        if ((0, n.isProtein)(C[_])) {
          var A = S[_];
          f.push(A === -1 ? h.offsets[_] : A);
        }
      }
    return r.SortedArray.ofSortedArray(f);
  }
  return Ii.getProteinElements = u, Ii;
}
var wv = {};
Object.defineProperty(wv, "__esModule", { value: !0 });
wv.getPrincipalAxes = wv.toPositionsArray = void 0;
var Gie = sy(), iG = Re, t8 = iG.Vec3.zero();
function oG(e) {
  for (var r = e.conformation.invariantPosition, t = e.elements, n = new Float32Array(t.length * 3), a = 0, i = t.length; a < i; a++)
    r(t[a], t8), iG.Vec3.toArray(t8, n, a * 3);
  return n;
}
wv.toPositionsArray = oG;
function qie(e) {
  var r = oG(e);
  return Gie.PrincipalAxes.ofPositions(r);
}
wv.getPrincipalAxes = qie;
var B0 = {}, ys = {};
Object.defineProperty(ys, "__esModule", { value: !0 });
ys.BoundaryHelper = void 0;
var zo = Te, Ls = Yo, Hie = Gd, r5 = nr(), n8 = mE(), jie = (
  /** @class */
  function() {
    function e(r) {
      this.minDist = [], this.maxDist = [], this.extrema = [], this.centroidHelper = new Hie.CentroidHelper(), this.dir = $ie(r), this.reset();
    }
    return e.prototype.computeExtrema = function(r, t) {
      var n = Ls.Vec3.dot(this.dir[r], t);
      n < this.minDist[r] && (this.minDist[r] = n, Ls.Vec3.copy(this.extrema[r * 2], t)), n > this.maxDist[r] && (this.maxDist[r] = n, Ls.Vec3.copy(this.extrema[r * 2 + 1], t));
    }, e.prototype.computeSphereExtrema = function(r, t, n) {
      var a = Ls.Vec3.dot(this.dir[r], t);
      a - n < this.minDist[r] && (this.minDist[r] = a - n, Ls.Vec3.scaleAndSub(this.extrema[r * 2], t, this.dir[r], n)), a + n > this.maxDist[r] && (this.maxDist[r] = a + n, Ls.Vec3.scaleAndAdd(this.extrema[r * 2 + 1], t, this.dir[r], n));
    }, e.prototype.includeSphere = function(r) {
      if (r5.Sphere3D.hasExtrema(r) && r.extrema.length > 1)
        for (var t = 0, n = r.extrema; t < n.length; t++) {
          var a = n[t];
          this.includePosition(a);
        }
      else
        this.includePositionRadius(r.center, r.radius);
    }, e.prototype.includePosition = function(r) {
      for (var t = 0, n = this.dir.length; t < n; ++t)
        this.computeExtrema(t, r);
    }, e.prototype.includePositionRadius = function(r, t) {
      for (var n = 0, a = this.dir.length; n < a; ++n)
        this.computeSphereExtrema(n, r, t);
    }, e.prototype.finishedIncludeStep = function() {
      for (var r = 0; r < this.extrema.length; r++)
        this.centroidHelper.includeStep(this.extrema[r]);
      this.centroidHelper.finishedIncludeStep();
    }, e.prototype.radiusSphere = function(r) {
      if (r5.Sphere3D.hasExtrema(r) && r.extrema.length > 1)
        for (var t = 0, n = r.extrema; t < n.length; t++) {
          var a = n[t];
          this.radiusPosition(a);
        }
      else
        this.radiusPositionRadius(r.center, r.radius);
    }, e.prototype.radiusPosition = function(r) {
      this.centroidHelper.radiusStep(r);
    }, e.prototype.radiusPositionRadius = function(r, t) {
      this.centroidHelper.radiusSphereStep(r, t);
    }, e.prototype.getSphere = function(r) {
      return r5.Sphere3D.setExtrema(this.centroidHelper.getSphere(r), (0, zo.__spreadArray)([], this.extrema, !0));
    }, e.prototype.getBox = function(r) {
      return n8.Box3D.fromVec3Array(r || (0, n8.Box3D)(), this.extrema);
    }, e.prototype.reset = function() {
      for (var r = 0, t = this.dir.length; r < t; ++r)
        this.minDist[r] = 1 / 0, this.maxDist[r] = -1 / 0, this.extrema[r * 2] = (0, Ls.Vec3)(), this.extrema[r * 2 + 1] = (0, Ls.Vec3)();
      this.centroidHelper.reset();
    }, e;
  }()
);
ys.BoundaryHelper = jie;
function $ie(e) {
  var r;
  switch (e) {
    case "6":
      r = (0, zo.__spreadArray)([], n2, !0);
      break;
    case "14":
      r = (0, zo.__spreadArray)((0, zo.__spreadArray)([], n2, !0), t5, !0);
      break;
    case "26":
      r = (0, zo.__spreadArray)((0, zo.__spreadArray)((0, zo.__spreadArray)([], n2, !0), t5, !0), a8, !0);
      break;
    case "98":
      r = (0, zo.__spreadArray)((0, zo.__spreadArray)((0, zo.__spreadArray)((0, zo.__spreadArray)((0, zo.__spreadArray)((0, zo.__spreadArray)([], n2, !0), t5, !0), a8, !0), Kie, !0), Wie, !0), Xie, !0);
      break;
  }
  return r.map(function(t) {
    var n = Ls.Vec3.create(t[0], t[1], t[2]);
    return Ls.Vec3.normalize(n, n);
  });
}
var n2 = [
  [1, 0, 0],
  [0, 1, 0],
  [0, 0, 1]
], t5 = [
  [1, 1, 1],
  [-1, 1, 1],
  [-1, -1, 1],
  [1, -1, 1]
], a8 = [
  [1, 1, 0],
  [1, -1, 0],
  [1, 0, 1],
  [1, 0, -1],
  [0, 1, 1],
  [0, 1, -1]
], Kie = [
  [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]
], Wie = [
  [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]
], Xie = [
  [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]
];
Object.defineProperty(B0, "__esModule", { value: !0 });
B0.getBoundary = void 0;
var CE = Re, a2 = Qe(), uG = ys, Ph = nr(), i8 = CE.Vec3.set, Yie = new uG.BoundaryHelper("14"), Qie = new uG.BoundaryHelper("98");
function Zie(e) {
  return e > 1e4 ? Yie : Qie;
}
var i2 = (0, CE.Vec3)();
function Jie(e) {
  var r = e.x, t = e.y, n = e.z, a = e.radius, i = e.indices, o = a2.OrderedSet.size(i);
  if (o > 25e4) {
    var c = Ph.Box3D.computeBounding(e);
    return { box: c, sphere: Ph.Sphere3D.fromBox3D((0, Ph.Sphere3D)(), c) };
  }
  var s = Zie(o);
  s.reset();
  for (var u = 0; u < o; u++) {
    var l = a2.OrderedSet.getAt(i, u);
    i8(i2, r[l], t[l], n[l]), s.includePositionRadius(i2, a && a[l] || 0);
  }
  s.finishedIncludeStep();
  for (var u = 0; u < o; u++) {
    var l = a2.OrderedSet.getAt(i, u);
    i8(i2, r[l], t[l], n[l]), s.radiusPositionRadius(i2, a && a[l] || 0);
  }
  var f = s.getSphere();
  if (!a && Ph.Sphere3D.hasExtrema(f) && o <= f.extrema.length) {
    for (var d = [], u = 0; u < o; u++) {
      var l = a2.OrderedSet.getAt(i, u);
      d.push(CE.Vec3.create(r[l], t[l], n[l]));
    }
    Ph.Sphere3D.setExtrema(f, d);
  }
  return { box: s.getBox(), sphere: f };
}
B0.getBoundary = Jie;
var PC = {};
Object.defineProperty(PC, "__esModule", { value: !0 });
PC.ElementSetIntraBondCache = void 0;
var o2 = Qe(), eoe = (
  /** @class */
  function() {
    function e() {
      this.data = /* @__PURE__ */ new Map();
    }
    return e.prototype.get = function(r) {
      var t = o2.SortedArray.hashCode(r);
      if (this.data.has(t))
        for (var n = 0, a = this.data.get(t); n < a.length; n++) {
          var i = a[n], o = i[0], c = i[1];
          if (o2.SortedArray.areEqual(r, o))
            return c;
        }
    }, e.prototype.set = function(r, t) {
      var n = o2.SortedArray.hashCode(r);
      if (this.data.has(n)) {
        for (var a = this.data.get(n), i = 0, o = a; i < o.length; i++) {
          var c = o[i];
          if (o2.SortedArray.areEqual(r, c[0])) {
            c[1] = t;
            return;
          }
        }
        a.push([r, t]);
      } else
        this.data.set(n, [[r, t]]);
    }, e.get = function(r) {
      return r._dynamicPropertyData.ElementSetIntraBondCache || (r._dynamicPropertyData.ElementSetIntraBondCache = new e()), r._dynamicPropertyData.ElementSetIntraBondCache;
    }, e;
  }()
);
PC.ElementSetIntraBondCache = eoe;
var Mh = {}, wh = {}, n5 = {}, o8;
function sG() {
  return o8 || (o8 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.Symmetry = e.Assembly = void 0;
    var r = wr(), t = nr(), n = ml(), a = kn, i = (
      /** @class */
      function() {
        function c(s, u, l) {
          this.operatorsProvider = l, this.id = s, this.details = u;
        }
        return Object.defineProperty(c.prototype, "operatorGroups", {
          get: function() {
            return this._operators ? this._operators : (this._operators = this.operatorsProvider(), this._operators);
          },
          enumerable: !1,
          configurable: !0
        }), c;
      }()
    );
    e.Assembly = i, function(c) {
      function s(u, l, f) {
        return new c(u, l, f);
      }
      c.create = s;
    }(i = e.Assembly || (e.Assembly = {})), e.Assembly = i;
    var o;
    (function(c) {
      c.Default = { assemblies: [], spacegroup: t.Spacegroup.ZeroP1, isNonStandardCrystalFrame: !1 };
      function s(l, f) {
        var d = f.toLocaleLowerCase(), m = n.ModelSymmetry.Provider.get(l);
        return m ? (0, r.arrayFind)(m.assemblies, function(p) {
          return p.id.toLowerCase() === d;
        }) : void 0;
      }
      c.findAssembly = s;
      function u(l) {
        var f = l.spacegroup, d = f.cell, m = f.name, p = f.num, v = d.size, h = d.anglesInRadians, y = v[0].toFixed(2), C = v[1].toFixed(2), S = v[2].toFixed(2), b = (0, a.radToDeg)(h[0]).toFixed(2), g = (0, a.radToDeg)(h[1]).toFixed(2), _ = (0, a.radToDeg)(h[2]).toFixed(2), A = [];
        return A.push("Unit Cell <b>".concat(m, "</b> #").concat(p)), A.push("".concat(y, "×").concat(C, "×").concat(S, " Å")), A.push("α=".concat(b, "° β=").concat(g, "° γ=").concat(_, "°")), A.join(" | ");
      }
      c.getUnitcellLabel = u;
    })(o || (o = {})), e.Symmetry = o;
  }(n5)), n5;
}
var u8;
function roe() {
  if (u8) return wh;
  u8 = 1, Object.defineProperty(wh, "__esModule", { value: !0 }), wh.createAssemblies = void 0;
  var e = Re, r = E0, t = sG(), n = Je(), a = Je();
  function i(m, p, v) {
    if (!m._rowCount)
      return [];
    for (var h = s(v), y = [], C = 0; C < m._rowCount; C++)
      y[y.length] = o(m, p, C, h);
    return y;
  }
  wh.createAssemblies = i;
  function o(m, p, v, h) {
    for (var y = m.id.value(v), C = m.details.value(v), S = [], b = p.assembly_id, g = p.oper_expression, _ = p.asym_id_list, A = 0, M = p._rowCount; A < M; A++)
      b.value(A) === y && (S[S.length] = {
        assemblyId: y,
        expression: g.value(A),
        asymIds: _.value(A)
      });
    return t.Assembly.create(y, C, c(S, h));
  }
  function c(m, p) {
    return function() {
      for (var v = [], h = 0, y = 0; y < m.length; y++) {
        var C = m[y], S = d(C.expression), b = u(S), g = f(p, b, h, C.assemblyId), _ = n.Queries.generators.atoms({ chainTest: n.Queries.pred.and(n.Queries.pred.eq(function(A) {
          return a.StructureProperties.unit.operator_name(A.element);
        }, r.SymmetryOperator.DefaultName), n.Queries.pred.inSet(function(A) {
          return a.StructureProperties.chain.label_asym_id(A.element);
        }, C.asymIds)) });
        v[v.length] = { selector: _, operators: g }, h += g.length;
      }
      return v;
    };
  }
  function s(m) {
    for (var p = m.id, v = m.matrix, h = m.vector, y = m._schema, C = /* @__PURE__ */ new Map(), S = 0, b = m._rowCount; S < b; S++) {
      var g = e.Tensor.toMat4((0, e.Mat4)(), y.matrix.space, v.value(S)), _ = e.Tensor.toVec3((0, e.Vec3)(), y.vector.space, h.value(S));
      e.Mat4.setTranslation(g, _), e.Mat4.setValue(g, 3, 3, 1), C.set(p.value(S), g);
    }
    return C;
  }
  function u(m) {
    for (var p = [], v = [], h = 0; h < m.length; h++)
      v[h] = "";
    return l(m, p, m.length - 1, v), p;
  }
  function l(m, p, v, h) {
    if (v < 0) {
      p[p.length] = h.slice(0);
      return;
    }
    for (var y = m[v], C = y.length, S = 0; S < C; S++)
      h[v] = y[S], l(m, p, v - 1, h);
  }
  function f(m, p, v, h) {
    for (var y = [], C = v, S = 0, b = p; S < b.length; S++) {
      for (var g = b[S], _ = e.Mat4.identity(), A = 0; A < g.length; A++)
        e.Mat4.mul(_, _, m.get(g[A]));
      C++, y[y.length] = r.SymmetryOperator.create("ASM_".concat(C), _, { assembly: { id: h, operId: C, operList: g } });
    }
    return y;
  }
  function d(m) {
    for (var p = /\(?([^\(\)]+)\)?]*/g, v = [], h = [], y; y = p.exec(m); )
      v[v.length] = y[1];
    return v.forEach(function(C) {
      var S = [];
      C.split(",").forEach(function(b) {
        var g = b.indexOf("-");
        if (g > 0)
          for (var _ = parseInt(b.substring(0, g)), A = parseInt(b.substr(g + 1)), M = _; M <= A; M++)
            S[S.length] = M.toString();
        else
          S[S.length] = b.trim();
      }), h[h.length] = S;
    }), h;
  }
  return wh;
}
var s8;
function ml() {
  if (s8) return Mh;
  s8 = 1, Object.defineProperty(Mh, "__esModule", { value: !0 }), Mh.ModelSymmetry = void 0;
  var e = fl, r = nr(), t = Re, n = roe(), a = hs, i;
  (function(l) {
    l.Descriptor = {
      name: "model_symmetry"
    }, l.Provider = a.FormatPropertyProvider.create(l.Descriptor);
    function f(m) {
      var p = (0, n.createAssemblies)(m.pdbx_struct_assembly, m.pdbx_struct_assembly_gen, m.pdbx_struct_oper_list), v = s(m.symmetry, m.cell), h = o(m.atom_sites);
      return {
        assemblies: p,
        spacegroup: v,
        isNonStandardCrystalFrame: h,
        ncsOperators: u(m.struct_ncs_oper)
      };
    }
    l.fromData = f;
    function d(m, p) {
      var v = r.SpacegroupCell.create("P 1", m, p), h = r.Spacegroup.create(v);
      return { assemblies: [], spacegroup: h, isNonStandardCrystalFrame: !1 };
    }
    l.fromCell = d;
  })(i || (i = {})), Mh.ModelSymmetry = i;
  function o(l, f) {
    return l._rowCount === 0, !1;
  }
  function c(l) {
    var f = l.Int_Tables_number.value(0), d = l["space_group_name_H-M"].value(0);
    return l.Int_Tables_number.isDefined ? l["space_group_name_H-M"].isDefined ? d : f : d;
  }
  function s(l, f) {
    if (l._rowCount === 0 || f._rowCount === 0)
      return r.Spacegroup.ZeroP1;
    var d = f.length_a.value(0), m = f.length_b.value(0), p = f.length_c.value(0);
    if (d === 0 || m === 0 || p === 0)
      return r.Spacegroup.ZeroP1;
    var v = f.angle_alpha.value(0), h = f.angle_beta.value(0), y = f.angle_gamma.value(0);
    if (v === 0 || h === 0 || y === 0)
      return r.Spacegroup.ZeroP1;
    var C = c(l), S = r.SpacegroupCell.create(C, t.Vec3.create(d, m, p), t.Vec3.scale((0, t.Vec3)(), t.Vec3.create(v, h, y), Math.PI / 180));
    return r.Spacegroup.create(S);
  }
  function u(l) {
    if (l._rowCount !== 0) {
      for (var f = l.id, d = l.matrix, m = l.vector, p = e.mmCIF_Schema.struct_ncs_oper.matrix.space, v = e.mmCIF_Schema.struct_ncs_oper.vector.space, h = [], y = 0; y < l._rowCount; y++) {
        var C = t.Tensor.toMat3((0, t.Mat3)(), p, d.value(y)), S = t.Tensor.toVec3((0, t.Vec3)(), v, m.value(y));
        if (r.SymmetryOperator.checkIfRotationAndTranslation(C, S) && !(l.code.value(y) === "given" && !t.Mat3.isIdentity(C) && !t.Vec3.isZero(S))) {
          var b = f.value(y);
          h[h.length] = r.SymmetryOperator.ofRotationAndOffset("ncs_".concat(b), C, S, b);
        }
      }
      return h;
    }
  }
  return Mh;
}
var MC = {};
Object.defineProperty(MC, "__esModule", { value: !0 });
MC.getResonance = void 0;
var toe = Wg(), l8 = wr(), noe = Gr;
function aoe(e) {
  return {
    delocalizedTriplets: ioe(e)
  };
}
MC.getResonance = aoe;
function ioe(e) {
  var r = e.bonds, t = r.b, n = r.edgeProps, a = r.offset;
  n.order;
  for (var i = n.flags, o = e.rings.elementAromaticRingIndices, c = [], s = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), l = function(S, b, g) {
    var _ = c.length;
    c.push(toe.SortedArray.ofUnsortedArray([S, b, g])), s.set((0, l8.sortedCantorPairing)(S, b), g), u.has(S) ? u.get(S).push(_) : u.set(S, [_]);
  }, f = 0; f < e.elements.length; f++)
    if (!o.has(f)) {
      var d = a[f + 1] - a[f] + 1;
      if (!(d < 2)) {
        for (var m = [], p = a[f], v = a[f + 1]; p < v; p++) {
          var h = i[p];
          noe.BondType.is(
            h,
            16
            /* Aromatic */
          ) && m.push(t[p]);
        }
        if (m.length >= 2) {
          l(f, m[0], m[1]);
          for (var y = 1, C = m.length; y < C; y++)
            l(f, m[y], m[0]);
        }
      }
    }
  return {
    getThirdElement: function(S, b) {
      return s.get((0, l8.sortedCantorPairing)(S, b));
    },
    getTripletIndices: function(S) {
      return u.get(S);
    },
    triplets: c
  };
}
var c8;
function vl() {
  if (c8) return Ah;
  c8 = 1, Object.defineProperty(Ah, "__esModule", { value: !0 }), Ah.Unit = void 0;
  var e = Te, r = E0, t = O0(), n = nr(), a = TC(), i = We(), o = fc, c = Qe(), s = wr(), u = zie(), l = wv, f = B0, d = Re, m = Cc, p = PC, v = ml(), h = MC, y;
  return function(C) {
    function S($) {
      return $.kind === 0;
    }
    C.isAtomic = S;
    function b($) {
      return $.kind === 1 || $.kind === 2;
    }
    C.isCoarse = b;
    function g($) {
      return $.kind === 1;
    }
    C.isSpheres = g;
    function _($) {
      return $.kind === 2;
    }
    C.isGaussians = _;
    function A($, Q, W, te, oe, z, j, ae, le) {
      switch (oe) {
        case 0:
          return new D($, Q, W, te, z, ae, r.SymmetryOperator.createMapping(j, z.atomicConformation, void 0), le ?? N());
        case 1:
          return R($, Q, W, te, z, 1, ae, r.SymmetryOperator.createMapping(j, z.coarseConformation.spheres, I(z)), le ?? k());
        case 2:
          return R($, Q, W, te, z, 2, ae, r.SymmetryOperator.createMapping(j, z.coarseConformation.gaussians, B()), le ?? k());
      }
    }
    C.create = A;
    function M($) {
      for (var Q = c.IntMap.Mutable(), W = 0, te = $.length; W < te; W++)
        Q.set($[W].id, W);
      return Q;
    }
    function P($) {
      for (var Q = [], W = 0, te = $.length; W < te; W++)
        Q.push($[W].id);
      return (0, s.hashFnv32a)(Q);
    }
    function T($) {
      var Q = {};
      return {
        elements: $[0].elements,
        units: $,
        get unitIndexMap() {
          return Q.unitIndexMap || (Q.unitIndexMap = M($)), Q.unitIndexMap;
        },
        hashCode: w($[0]),
        transformHash: P($)
      };
    }
    C.SymmetryGroup = T, function($) {
      function Q(te, oe) {
        return te.hashCode !== oe.hashCode ? !1 : c.SortedArray.areEqual(te.elements, oe.elements);
      }
      $.areInvariantElementsEqual = Q;
      function W(te) {
        for (var oe = c.IntMap.Mutable(), z = 0, j = te.length; z < j; ++z)
          for (var ae = te[z], le = 0, ie = ae.units.length; le < ie; ++le)
            oe.set(ae.units[le].id, z);
        return oe;
      }
      $.getUnitSymmetryGroupsIndexMap = W;
    }(T = C.SymmetryGroup || (C.SymmetryGroup = {}));
    function x($) {
      return C.isAtomic($) ? $.model.atomicConformation.id : $.model.coarseConformation.id;
    }
    C.conformationId = x;
    function w($) {
      return (0, s.hash2)($.invariantId, c.SortedArray.hashCode($.elements));
    }
    C.hashUnit = w, function($) {
      $.is = i.BitFlags.has, $.create = i.BitFlags.create;
    }(C.Traits || (C.Traits = {}));
    function E() {
      return {};
    }
    function I($) {
      var Q = $.coarseConformation.spheres.radius;
      return function(W) {
        return Q[W];
      };
    }
    function B($) {
      return function(Q) {
        return 0;
      };
    }
    var D = (
      /** @class */
      function() {
        function $(Q, W, te, oe, z, j, ae, le) {
          this.kind = 0, this.objectPrimitive = "atomistic", this.id = Q, this.invariantId = W, this.chainGroupId = te, this.traits = oe, this.model = z, this.elements = j, this.conformation = ae, this.residueIndex = z.atomicHierarchy.residueAtomSegments.index, this.chainIndex = z.atomicHierarchy.chainAtomSegments.index, this.props = le;
        }
        return $.prototype.getChild = function(Q) {
          return Q.length === this.elements.length ? this : new $(this.id, this.invariantId, this.chainGroupId, this.traits, this.model, Q, this.conformation, N());
        }, $.prototype.applyOperator = function(Q, W, te) {
          te === void 0 && (te = !1);
          var oe = te ? W : r.SymmetryOperator.compose(this.conformation.operator, W);
          return new $(Q, this.invariantId, this.chainGroupId, this.traits, this.model, this.elements, r.SymmetryOperator.createMapping(oe, this.model.atomicConformation, this.conformation.r), this.props);
        }, $.prototype.remapModel = function(Q, W, te) {
          var oe, z;
          te || (te = (0, e.__assign)((0, e.__assign)({}, this.props), { bonds: W && !(!((z = (oe = this.props.bonds) === null || oe === void 0 ? void 0 : oe.props) === null || z === void 0) && z.canRemap) ? void 0 : q(this, this.props.bonds, Q, W) }), C.isSameConformation(this, Q) || (te.boundary = void 0, te.lookup3d = void 0, te.principalAxes = void 0));
          var j = this.conformation.operator, ae = v.ModelSymmetry.Provider.get(Q);
          if (j.spgrOp !== -1 && ae && ae !== v.ModelSymmetry.Provider.get(this.model)) {
            var le = j.hkl, ie = le[0], re = le[1], ee = le[2], ne = ae.spacegroup.cell.toFractional, se = d.Vec3.transformMat4((0, d.Vec3)(), t.Model.getCenter(Q), ne);
            j = n.Spacegroup.getSymmetryOperatorRef(ae.spacegroup, j.spgrOp, ie, re, ee, se);
          }
          var ce = this.model.atomicConformation !== Q.atomicConformation || j !== this.conformation.operator ? r.SymmetryOperator.createMapping(j, Q.atomicConformation) : this.conformation;
          return new $(this.id, this.invariantId, this.chainGroupId, this.traits, Q, this.elements, ce, te);
        }, Object.defineProperty($.prototype, "boundary", {
          get: function() {
            if (this.props.boundary)
              return this.props.boundary;
            var Q = this.model.atomicConformation, W = Q.x, te = Q.y, oe = Q.z;
            return this.props.boundary = (0, f.getBoundary)({ x: W, y: te, z: oe, indices: this.elements }), this.props.boundary;
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty($.prototype, "lookup3d", {
          get: function() {
            if (this.props.lookup3d)
              return this.props.lookup3d;
            var Q = this.model.atomicConformation, W = Q.x, te = Q.y, oe = Q.z;
            return this.props.lookup3d = (0, n.GridLookup3D)({ x: W, y: te, z: oe, indices: this.elements }, this.boundary), this.props.lookup3d;
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty($.prototype, "principalAxes", {
          get: function() {
            return this.props.principalAxes ? this.props.principalAxes : (this.props.principalAxes = (0, l.getPrincipalAxes)(this), this.props.principalAxes);
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty($.prototype, "bonds", {
          get: function() {
            if (this.props.bonds)
              return this.props.bonds;
            var Q = p.ElementSetIntraBondCache.get(this.model), W = Q.get(this.elements);
            return W || (W = (0, a.computeIntraUnitBonds)(this), Q.set(this.elements, W)), this.props.bonds = W, this.props.bonds;
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty($.prototype, "rings", {
          get: function() {
            return this.props.rings ? this.props.rings : (this.props.rings = o.UnitRings.create(this), this.props.rings);
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty($.prototype, "resonance", {
          get: function() {
            return this.props.resonance ? this.props.resonance : (this.props.resonance = (0, h.getResonance)(this), this.props.resonance);
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty($.prototype, "polymerElements", {
          get: function() {
            return this.props.polymerElements ? this.props.polymerElements : (this.props.polymerElements = (0, u.getAtomicPolymerElements)(this), this.props.polymerElements);
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty($.prototype, "gapElements", {
          get: function() {
            return this.props.gapElements ? this.props.gapElements : (this.props.gapElements = (0, u.getAtomicGapElements)(this), this.props.gapElements);
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty($.prototype, "nucleotideElements", {
          get: function() {
            return this.props.nucleotideElements ? this.props.nucleotideElements : (this.props.nucleotideElements = (0, u.getNucleotideElements)(this), this.props.nucleotideElements);
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty($.prototype, "proteinElements", {
          get: function() {
            return this.props.proteinElements ? this.props.proteinElements : (this.props.proteinElements = (0, u.getProteinElements)(this), this.props.proteinElements);
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty($.prototype, "residueCount", {
          get: function() {
            if (this.props.residueCount !== void 0)
              return this.props.residueCount;
            for (var Q = 0, W = c.Segmentation.transientSegments(this.model.atomicHierarchy.residueAtomSegments, this.elements); W.hasNext; )
              W.move(), Q += 1;
            return this.props.residueCount = Q, this.props.residueCount;
          },
          enumerable: !1,
          configurable: !0
        }), $.prototype.getResidueIndex = function(Q) {
          return this.residueIndex[this.elements[Q]];
        }, $;
      }()
    );
    C.Atomic = D;
    function N() {
      return E();
    }
    var O = (
      /** @class */
      function() {
        function $(Q, W, te, oe, z, j, ae, le, ie) {
          this.kind = j, this.objectPrimitive = j === 1 ? "sphere" : "gaussian", this.id = Q, this.invariantId = W, this.chainGroupId = te, this.traits = oe, this.model = z, this.elements = ae, this.conformation = le, this.coarseElements = j === 1 ? z.coarseHierarchy.spheres : z.coarseHierarchy.gaussians, this.coarseConformation = j === 1 ? z.coarseConformation.spheres : z.coarseConformation.gaussians, this.props = ie;
        }
        return $.prototype.getChild = function(Q) {
          return Q.length === this.elements.length ? this : R(this.id, this.invariantId, this.chainGroupId, this.traits, this.model, this.kind, Q, this.conformation, k());
        }, $.prototype.applyOperator = function(Q, W, te) {
          te === void 0 && (te = !1);
          var oe = te ? W : r.SymmetryOperator.compose(this.conformation.operator, W);
          return R(Q, this.invariantId, this.chainGroupId, this.traits, this.model, this.kind, this.elements, r.SymmetryOperator.createMapping(oe, this.getCoarseConformation(), this.conformation.r), this.props);
        }, $.prototype.remapModel = function(Q, W, te) {
          var oe = this.getCoarseConformation(), z = V(this.kind, Q);
          te || (te = (0, e.__assign)({}, this.props), C.isSameConformation(this, Q) || (te.boundary = void 0, te.lookup3d = void 0, te.principalAxes = void 0));
          var j = oe !== z ? r.SymmetryOperator.createMapping(this.conformation.operator, z) : this.conformation;
          return new $(this.id, this.invariantId, this.chainGroupId, this.traits, Q, this.kind, this.elements, j, te);
        }, Object.defineProperty($.prototype, "boundary", {
          get: function() {
            if (this.props.boundary)
              return this.props.boundary;
            var Q = this.getCoarseConformation(), W = Q.x, te = Q.y, oe = Q.z;
            return this.props.boundary = (0, f.getBoundary)({ x: W, y: te, z: oe, indices: this.elements }), this.props.boundary;
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty($.prototype, "lookup3d", {
          get: function() {
            if (this.props.lookup3d)
              return this.props.lookup3d;
            var Q = this.getCoarseConformation(), W = Q.x, te = Q.y, oe = Q.z;
            return this.props.lookup3d = (0, n.GridLookup3D)({ x: W, y: te, z: oe, indices: this.elements }, this.boundary), this.props.lookup3d;
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty($.prototype, "principalAxes", {
          get: function() {
            return this.props.principalAxes ? this.props.principalAxes : (this.props.principalAxes = (0, l.getPrincipalAxes)(this), this.props.principalAxes);
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty($.prototype, "polymerElements", {
          get: function() {
            return this.props.polymerElements ? this.props.polymerElements : (this.props.polymerElements = (0, u.getCoarsePolymerElements)(this), this.props.polymerElements);
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty($.prototype, "gapElements", {
          get: function() {
            return this.props.gapElements ? this.props.gapElements : (this.props.gapElements = (0, u.getCoarseGapElements)(this), this.props.gapElements);
          },
          enumerable: !1,
          configurable: !0
        }), $.prototype.getCoarseConformation = function() {
          return V(this.kind, this.model);
        }, $;
      }()
    );
    function V($, Q) {
      return $ === 1 ? Q.coarseConformation.spheres : Q.coarseConformation.gaussians;
    }
    function k() {
      return E();
    }
    var G = (
      /** @class */
      function($) {
        (0, e.__extends)(Q, $);
        function Q() {
          return $ !== null && $.apply(this, arguments) || this;
        }
        return Q;
      }(O)
    );
    C.Spheres = G;
    var L = (
      /** @class */
      function($) {
        (0, e.__extends)(Q, $);
        function Q() {
          return $ !== null && $.apply(this, arguments) || this;
        }
        return Q;
      }(O)
    );
    C.Gaussians = L;
    function R($, Q, W, te, oe, z, j, ae, le) {
      return new O($, Q, W, te, oe, z, j, ae, le);
    }
    function F($, Q) {
      return $.chainGroupId === Q.chainGroupId && $.conformation.operator.name === Q.conformation.operator.name;
    }
    C.areSameChainOperatorGroup = F;
    function U($, Q) {
      return d.Mat4.areEqual($.conformation.operator.matrix, Q.conformation.operator.matrix, 1e-6);
    }
    C.areOperatorsEqual = U;
    function H($, Q) {
      return c.SortedArray.areEqual($.elements, Q.elements) ? K($, Q.model) : !1;
    }
    C.areConformationsEqual = H;
    function q($, Q, W, te) {
      var oe;
      if (Q) {
        if ($.model.atomicConformation.id === W.atomicConformation.id)
          return Q;
        var z = m.IndexPairBonds.Provider.get($.model);
        if (z) {
          var j = m.IndexPairBonds.Provider.get(W);
          return !j || z === j ? Q : void 0;
        }
        return !((oe = Q.props) === null || oe === void 0) && oe.canRemap || !te || K($, W) ? Q : void 0;
      }
    }
    function K($, Q) {
      var W = t.Model.CoordinatesHistory.get(t.Model.getRoot(Q));
      if (W)
        return W.areEqual($.elements, $.kind, Q);
      for (var te = $.elements, oe = $.conformation.coordinates, z = oe.x, j = oe.y, ae = oe.z, le = Y($.kind, Q), ie = le.x, re = le.y, ee = le.z, ne = 0, se = te.length; ne < se; ne++) {
        var ce = te[ne];
        if (z[ce] !== ie[ce] || j[ce] !== re[ce] || ae[ce] !== ee[ce])
          return !1;
      }
      return !0;
    }
    C.isSameConformation = K;
    function Y($, Q) {
      return $ === 0 ? Q.atomicConformation : $ === 1 ? Q.coarseConformation.spheres : Q.coarseConformation.gaussians;
    }
    C.getModelConformationOfKind = Y;
    function X($) {
      return Y($.kind, $.model);
    }
    C.getConformation = X;
    function Z($, Q) {
      return $ === 0 ? Q.atomicHierarchy : $ === 1 ? Q.coarseHierarchy.spheres : Q.coarseHierarchy.gaussians;
    }
    C.getModelHierarchyOfKind = Z;
    function J($) {
      return Z($.kind, $.model);
    }
    C.getHierarchy = J;
  }(y || (y = {})), Ah.Unit = y, Ah;
}
var a5 = {}, d8;
function lG() {
  return d8 || (d8 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.StructureLookup3D = e.StructureLookup3DResultContext = e.StructureResult = void 0;
    var r = nr(), t = Re, n = Qe(), a = Mp(), i;
    (function(s) {
      function u(d, m, p, v) {
        d.indices[d.count] = p, d.units[d.count] = m, d.squaredDistances[d.count] = v, d.count++;
      }
      s.add = u;
      function l() {
        return { count: 0, indices: [], units: [], squaredDistances: [] };
      }
      s.create = l;
      function f(d, m) {
        for (var p = 0; p < m.count; ++p)
          d.indices[p] = m.indices[p], d.units[p] = m.units[p], d.squaredDistances[p] = m.squaredDistances[p];
        return d.count = m.count, d;
      }
      s.copy = f;
    })(i = e.StructureResult || (e.StructureResult = {}));
    function o() {
      return { result: i.create(), closeUnitsResult: r.Result.create(), unitGroupResult: r.Result.create() };
    }
    e.StructureLookup3DResultContext = o;
    var c = (
      /** @class */
      function() {
        function s(u) {
          this.structure = u, this.pivot = (0, t.Vec3)(), this.findContext = o();
          for (var l = u.units, f = u.boundary, d = l.length, m = new Float32Array(d), p = new Float32Array(d), v = new Float32Array(d), h = new Float32Array(d), y = (0, t.Vec3)(), C = 0; C < d; C++) {
            var S = l[C], b = S.boundary.sphere;
            t.Vec3.transformMat4(y, b.center, S.conformation.operator.matrix), m[C] = y[0], p[C] = y[1], v[C] = y[2], h[C] = b.radius;
          }
          var g = { x: m, y: p, z: v, radius: h, indices: n.OrderedSet.ofBounds(0, d) };
          this.unitLookup = (0, r.GridLookup3D)(g, f);
        }
        return s.prototype.findUnitIndices = function(u, l, f, d) {
          return this.unitLookup.find(u, l, f, d);
        }, s.prototype.find = function(u, l, f, d, m) {
          return this._find(u, l, f, d, m ?? this.findContext);
        }, s.prototype._find = function(u, l, f, d, m) {
          r.Result.reset(m.result);
          var p = this.structure.units, v = this.unitLookup.find(u, l, f, d, m.closeUnitsResult);
          if (v.count === 0)
            return m.result;
          for (var h = 0, y = v.count; h < y; h++) {
            var C = p[v.indices[h]];
            t.Vec3.set(this.pivot, u, l, f), C.conformation.operator.isIdentity || t.Vec3.transformMat4(this.pivot, this.pivot, C.conformation.operator.inverse);
            for (var S = C.lookup3d, b = S.find(this.pivot[0], this.pivot[1], this.pivot[2], d, m.unitGroupResult), g = 0, _ = b.count; g < _; g++)
              i.add(m.result, C, b.indices[g], b.squaredDistances[g]);
          }
          return m.result;
        }, s.prototype.findIntoBuilder = function(u, l, f, d, m) {
          var p = this.structure.units, v = this.unitLookup.find(u, l, f, d);
          if (v.count !== 0)
            for (var h = 0, y = v.count; h < y; h++) {
              var C = p[v.indices[h]];
              t.Vec3.set(this.pivot, u, l, f), C.conformation.operator.isIdentity || t.Vec3.transformMat4(this.pivot, this.pivot, C.conformation.operator.inverse);
              var S = C.lookup3d, b = S.find(this.pivot[0], this.pivot[1], this.pivot[2], d);
              if (b.count !== 0) {
                var g = C.elements;
                m.beginUnit(C.id);
                for (var _ = 0, A = b.count; _ < A; _++)
                  m.addElement(g[b.indices[_]]);
                m.commitUnit();
              }
            }
        }, s.prototype.findIntoBuilderIf = function(u, l, f, d, m, p) {
          var v = this.structure.units, h = this.unitLookup.find(u, l, f, d);
          if (h.count !== 0)
            for (var y = a.StructureElement.Location.create(this.structure), C = 0, S = h.count; C < S; C++) {
              var b = v[h.indices[C]];
              t.Vec3.set(this.pivot, u, l, f), b.conformation.operator.isIdentity || t.Vec3.transformMat4(this.pivot, this.pivot, b.conformation.operator.inverse);
              var g = b.lookup3d, _ = g.find(this.pivot[0], this.pivot[1], this.pivot[2], d);
              if (_.count !== 0) {
                var A = b.elements;
                y.unit = b, m.beginUnit(b.id);
                for (var M = 0, P = _.count; M < P; M++)
                  y.element = A[_.indices[M]], p(y) && m.addElement(y.element);
                m.commitUnit();
              }
            }
        }, s.prototype.findIntoBuilderWithRadius = function(u, l, f, d, m, p, v, h) {
          var y = this.structure.units, C = this.unitLookup.find(u, l, f, p);
          if (C.count !== 0)
            for (var S = a.StructureElement.Location.create(this.structure), b = d + m + p, g = 0, _ = C.count; g < _; g++) {
              var A = y[C.indices[g]];
              t.Vec3.set(this.pivot, u, l, f), A.conformation.operator.isIdentity || t.Vec3.transformMat4(this.pivot, this.pivot, A.conformation.operator.inverse);
              var M = A.lookup3d, P = M.find(this.pivot[0], this.pivot[1], this.pivot[2], b);
              if (P.count !== 0) {
                var T = A.elements;
                S.unit = A, h.beginUnit(A.id);
                for (var x = 0, w = P.count; x < w; x++) {
                  S.element = T[P.indices[x]];
                  var E = v(S);
                  Math.sqrt(P.squaredDistances[x]) - d - E > p || h.addElement(T[P.indices[x]]);
                }
                h.commitUnit();
              }
            }
        }, s.prototype.check = function(u, l, f, d) {
          var m = this.structure.units, p = this.unitLookup.find(u, l, f, d);
          if (p.count === 0)
            return !1;
          for (var v = 0, h = p.count; v < h; v++) {
            var y = m[p.indices[v]];
            t.Vec3.set(this.pivot, u, l, f), y.conformation.operator.isIdentity || t.Vec3.transformMat4(this.pivot, this.pivot, y.conformation.operator.inverse);
            var C = y.lookup3d;
            if (C.check(this.pivot[0], this.pivot[1], this.pivot[2], d))
              return !0;
          }
          return !1;
        }, Object.defineProperty(s.prototype, "boundary", {
          get: function() {
            return this.structure.boundary;
          },
          enumerable: !1,
          configurable: !0
        }), s;
      }()
    );
    e.StructureLookup3D = c;
  }(a5)), a5;
}
var Eh = {}, Dh = {}, i5 = {}, Ih = {}, Bo = {}, f8;
function dy() {
  if (f8) return Bo;
  f8 = 1, Object.defineProperty(Bo, "__esModule", { value: !0 }), Bo.structureSubtract = Bo.structureIntersect = Bo.structureAreIntersecting = Bo.structureAreEqual = Bo.structureUnion = void 0;
  var e = ia(), r = Qe();
  function t(s, u) {
    if (u.length === 0)
      return e.Structure.Empty;
    if (u.length === 1)
      return u[0];
    for (var l = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Set(), d = 0, m = u; d < m.length; d++)
      for (var p = m[d].units, v = 0, h = p.length; v < h; v++) {
        var y = p[v];
        if (l.has(y.id)) {
          if (f.has(y.id))
            continue;
          var C = r.SortedArray.union(l.get(y.id), y.elements);
          l.set(y.id, C), C.length === s.unitMap.get(y.id).elements.length && f.add(y.id);
        } else
          l.set(y.id, y.elements), y.elements.length === s.unitMap.get(y.id).elements.length && f.add(y.id);
      }
    var S = s.subsetBuilder(!0);
    return l.forEach(n, S), S.getStructure();
  }
  Bo.structureUnion = t;
  function n(s, u) {
    this.setUnit(u, s);
  }
  function a(s, u) {
    if (s === u)
      return !0;
    if (s.units.length !== u.units.length)
      return !1;
    for (var l = s.units, f = u.unitMap, d = 0, m = l.length; d < m; d++) {
      var p = l[d];
      if (!f.has(p.id))
        return !1;
      var v = f.get(p.id);
      if (!r.SortedArray.areEqual(p.elements, v.elements))
        return !1;
    }
    return !0;
  }
  Bo.structureAreEqual = a;
  function i(s, u) {
    if (s === u)
      return !0;
    var l, f;
    s.units.length < u.units.length ? (l = s, f = u) : (l = u, f = s);
    for (var d = l.units, m = f.unitMap, p = 0, v = d.length; p < v; p++) {
      var h = d[p];
      if (m.has(h.id)) {
        var y = m.get(h.id);
        if (r.SortedArray.areIntersecting(h.elements, y.elements))
          return !0;
      }
    }
    return !1;
  }
  Bo.structureAreIntersecting = i;
  function o(s, u) {
    if (s === u)
      return s;
    if (!i(s, u))
      return e.Structure.Empty;
    var l, f;
    s.units.length < u.units.length ? (l = s, f = u) : (l = u, f = s);
    for (var d = l.units, m = f.unitMap, p = [], v = 0, h = d.length; v < h; v++) {
      var y = d[v];
      if (m.has(y.id)) {
        var C = m.get(y.id);
        if (r.SortedArray.areIntersecting(y.elements, C.elements)) {
          var S = r.SortedArray.intersect(y.elements, C.elements);
          p[p.length] = y.getChild(S);
        }
      }
    }
    return e.Structure.create(p, { parent: s.parent || u.parent });
  }
  Bo.structureIntersect = o;
  function c(s, u) {
    if (s === u)
      return e.Structure.Empty;
    if (!i(s, u))
      return s;
    for (var l = s.units, f = u.unitMap, d = [], m = 0, p = l.length; m < p; m++) {
      var v = l[m];
      if (!f.has(v.id)) {
        d[d.length] = v;
        continue;
      }
      var h = f.get(v.id), y = r.SortedArray.subtract(v.elements, h.elements);
      y.length > 0 && (d[d.length] = v.getChild(y));
    }
    return e.Structure.create(d, { parent: s.parent || u.parent });
  }
  return Bo.structureSubtract = c, Bo;
}
var m8;
function jd() {
  if (m8) return Ih;
  m8 = 1, Object.defineProperty(Ih, "__esModule", { value: !0 }), Ih.StructureSelection = void 0;
  var e = Po, r = ia(), t = dy(), n = Qe(), a;
  return function(i) {
    function o(_, A) {
      return { kind: "singletons", source: _, structure: A };
    }
    i.Singletons = o;
    function c(_, A) {
      return { kind: "sequence", source: _, structures: A };
    }
    i.Sequence = c;
    function s(_) {
      return o(_, r.Structure.Empty);
    }
    i.Empty = s;
    function u(_) {
      return _.kind === "singletons";
    }
    i.isSingleton = u;
    function l(_) {
      return u(_) ? _.structure.units.length === 0 : _.structures.length === 0;
    }
    i.isEmpty = l;
    function f(_) {
      return u(_) ? _.structure.elementCount : _.structures.length;
    }
    i.structureCount = f;
    function d(_) {
      return l(_) ? r.Structure.Empty : u(_) ? _.structure : (0, t.structureUnion)(_.source, _.structures);
    }
    i.unionStructure = d;
    function m(_) {
      for (var A = [], M = _.source.unitMap, P = 0, T = d(_).units; P < T.length; P++) {
        var x = T[P];
        x === M.get(x.id) ? A[A.length] = {
          unit: x,
          indices: n.OrderedSet.ofBounds(0, x.elements.length)
        } : A[A.length] = {
          unit: x,
          indices: n.OrderedSet.ofSortedArray(n.SortedArray.indicesOf(M.get(x.id).elements, x.elements))
        };
      }
      return r.StructureElement.Loci(_.source, A);
    }
    i.toLociWithCurrentUnits = m;
    function p(_) {
      for (var A = [], M = _.source.unitMap, P = 0, T = d(_).units; P < T.length; P++) {
        var x = T[P];
        if (M.has(x.id)) {
          var w = M.get(x.id);
          w === x ? A[A.length] = {
            unit: w,
            indices: n.OrderedSet.ofBounds(0, w.elements.length)
          } : A[A.length] = {
            unit: w,
            indices: n.OrderedSet.ofSortedArray(n.SortedArray.indicesOf(w.elements, x.elements))
          };
        }
      }
      return r.StructureElement.Loci(_.source, A);
    }
    i.toLociWithSourceUnits = p;
    function v(_, A, M) {
      var P = A.length;
      return P === 0 ? s(_) : M ? o(_, (0, t.structureUnion)(_, A)) : c(_, A);
    }
    var h = (
      /** @class */
      function() {
        function _(A) {
          this.source = A, this.structures = [], this.allSingletons = !0;
        }
        return _.prototype.add = function(A) {
          var M = A.elementCount;
          M !== 0 && (this.structures[this.structures.length] = A, M !== 1 && (this.allSingletons = !1));
        }, _.prototype.getSelection = function() {
          return v(this.source, this.structures, this.allSingletons);
        }, _;
      }()
    ), y = (
      /** @class */
      function() {
        function _(A) {
          this.structure = A, this.structures = [], this.allSingletons = !0, this.uniqueSets = (0, e.HashSet)(r.Structure.hashCode, r.Structure.areUnitIdsAndIndicesEqual);
        }
        return _.prototype.add = function(A) {
          var M = A.elementCount;
          M === 0 || !this.uniqueSets.add(A) || (this.structures[this.structures.length] = A, M !== 1 && (this.allSingletons = !1));
        }, _.prototype.getSelection = function() {
          return v(this.structure, this.structures, this.allSingletons);
        }, _;
      }()
    );
    function C(_) {
      return new h(_);
    }
    i.LinearBuilder = C;
    function S(_) {
      return new y(_);
    }
    i.UniqueBuilder = S;
    function b(_, A) {
      var M = 0;
      if (i.isSingleton(_))
        for (var P = 0, T = _.structure.units; P < T.length; P++)
          for (var x = T[P], w = x.elements, E = 0, I = w.length; E < I; E++) {
            var B = r.Structure.create([x.getChild(n.SortedArray.ofSingleton(w[E]))], { parent: _.source });
            A(B, M++);
          }
      else
        for (var D = 0, N = _.structures; D < N.length; D++) {
          var B = N[D];
          A(B, M++);
        }
    }
    i.forEach = b;
    function g(_, A) {
      return u(_) ? o(A, _.structure) : c(A, _.structures);
    }
    i.withInputStructure = g;
  }(a || (a = {})), Ih.StructureSelection = a, Ih;
}
var Bh = {}, Nh = {}, Ua = {}, o5 = {}, v8;
function AE() {
  return v8 || (v8 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.Bundle = void 0;
    var r = Qe(), t = gn(), n = wr(), a = Qo, i = eu(), o = gs, c = EE();
    (function(s) {
      s.Empty = { hash: -1, elements: [] };
      function u(C, S) {
        return f(c.StructureSelection.toLociWithSourceUnits(c.StructureSelection.Singletons(C, S)));
      }
      s.fromSubStructure = u;
      function l(C) {
        return f(c.StructureSelection.toLociWithSourceUnits(C));
      }
      s.fromSelection = l;
      function f(C) {
        for (var S = [], b = 0, g = C.elements; b < g.length; b++) {
          var _ = g[b], A = _.unit, M = _.indices;
          if (r.OrderedSet.size(M) !== 0) {
            var P = [], T = [];
            if (r.OrderedSet.isInterval(M))
              r.OrderedSet.size(M) === 1 ? T.push(r.Interval.min(M)) : P.push(r.Interval.min(M), r.Interval.max(M));
            else
              for (var x = 0, w = M.length; x < w; ) {
                var E = x;
                for (x++; x < w && M[x - 1] + 1 === M[x]; )
                  x++;
                var I = x;
                if (I - E > 2)
                  P.push(M[E], M[I - 1]);
                else
                  for (var B = E; B < I; B++)
                    T[T.length] = M[B];
              }
            S.push({
              unit: A,
              set: r.SortedArray.ofSortedArray(T),
              ranges: a.SortedRanges.ofSortedRanges(P)
            });
          }
        }
        for (var D = /* @__PURE__ */ new Map(), x = 0, N = S.length; x < N; ++x) {
          var _ = S[x], O = (0, n.hash2)((0, n.hashFnv32a)(_.ranges), (0, n.hashFnv32a)(_.set));
          if (D.has(O)) {
            var V = D.get(O).groupedUnits;
            V.has(_.unit.invariantId) ? V.get(_.unit.invariantId).push(_.unit.id) : V.set(_.unit.invariantId, [_.unit.id]);
          } else {
            var V = /* @__PURE__ */ new Map();
            V.set(_.unit.invariantId, [_.unit.id]), D.set(O, { groupedUnits: V, set: _.set, ranges: _.ranges });
          }
        }
        var k = [];
        return D.forEach(function(G) {
          var L = [];
          G.groupedUnits.forEach(function(R) {
            return L.push(r.SortedArray.ofUnsortedArray(R));
          }), L.sort(function(R, F) {
            return R[0] - F[0];
          }), k.push({ groupedUnits: L, set: G.set, ranges: G.ranges });
        }), { hash: C.structure.hashCode, elements: k };
      }
      s.fromLoci = f;
      function d(C, S) {
        for (var b = [], g = 0, _ = C.length; g < _; ++g) {
          var A = C[g];
          S.unitMap.has(A) && b.push(S.unitMap.get(A));
        }
        return b;
      }
      function m(C, S) {
        C.hash !== -1 && (C.hash, S.hashCode);
        for (var b = [], g = 0, _ = C.elements; g < _.length; g++)
          for (var A = _[g], M = function(w) {
            var E = d(w, S);
            if (E.length === 0)
              return "continue";
            var I = void 0;
            if (A.ranges.length === 0)
              I = A.set;
            else if (A.set.length === 0)
              if (A.ranges.length === 2)
                I = r.Interval.ofRange(A.ranges[0], A.ranges[1]);
              else {
                var B = new Int32Array(a.SortedRanges.size(A.ranges));
                a.SortedRanges.forEach(A.ranges, function(G, L) {
                  return B[L] = G;
                }), I = r.SortedArray.ofSortedArray(B);
              }
            else {
              var D = a.SortedRanges.size(A.ranges), N = new Int32Array(A.set.length + D);
              a.SortedRanges.forEach(A.ranges, function(G, L) {
                return N[L] = G;
              }), N.set(A.set, D), I = r.SortedArray.ofUnsortedArray(N);
            }
            for (var O = 0, V = E; O < V.length; O++) {
              var k = V[O];
              b.push({ unit: k, indices: I });
            }
          }, P = 0, T = A.groupedUnits; P < T.length; P++) {
            var x = T[P];
            M(x);
          }
        return (0, i.Loci)(S, b);
      }
      s.toLoci = m;
      function p(C, S) {
        C.hash !== -1 && (C.hash, S.hashCode);
        for (var b = [], g = 0, _ = C.elements; g < _.length; g++)
          for (var A = _[g], M = function(w) {
            var E = d(w, S);
            if (E.length === 0)
              return "continue";
            var I = E[0].elements, B = a.SortedRanges.size(A.ranges), D = A.set.length, N = new Int32Array(D + B), O = void 0;
            if (B === 0) {
              for (var V = 0, k = D; V < k; ++V)
                N[V] = I[A.set[V]];
              O = r.SortedArray.ofSortedArray(N);
            } else if (D === 0)
              a.SortedRanges.forEach(A.ranges, function(F, U) {
                return N[U] = I[F];
              }), O = r.SortedArray.ofSortedArray(N);
            else if (r.SortedArray.min(A.set) > a.SortedRanges.max(A.ranges)) {
              a.SortedRanges.forEach(A.ranges, function(F, U) {
                return N[U] = I[F];
              });
              for (var V = 0, k = D; V < k; ++V)
                N[V + B] = I[A.set[V]];
              O = r.SortedArray.ofSortedArray(N);
            } else if (a.SortedRanges.min(A.ranges) > r.SortedArray.max(A.set)) {
              for (var V = 0, k = D; V < k; ++V)
                N[V] = I[A.set[V]];
              a.SortedRanges.forEach(A.ranges, function(F, U) {
                return N[U + D] = I[F];
              }), O = r.SortedArray.ofSortedArray(N);
            } else {
              a.SortedRanges.forEach(A.ranges, function(F, U) {
                return N[U] = I[F];
              });
              for (var V = 0, k = D; V < k; ++V)
                N[V + B] = I[A.set[V]];
              O = r.SortedArray.ofUnsortedArray(N);
            }
            for (var G = 0, L = E; G < L.length; G++) {
              var R = L[G];
              b.push(R.getChild(O));
            }
          }, P = 0, T = A.groupedUnits; P < T.length; P++) {
            var x = T[P];
            M(x);
          }
        return t.Structure.create(b, { parent: S });
      }
      s.toStructure = p;
      function v(C) {
        return o.MolScriptBuilder.internal.generator.bundleElement({
          groupedUnits: o.MolScriptBuilder.core.type.list(C.groupedUnits.map(function(S) {
            return o.MolScriptBuilder.core.type.list(S);
          })),
          ranges: o.MolScriptBuilder.core.type.list(C.ranges),
          set: o.MolScriptBuilder.core.type.list(C.set)
        });
      }
      function h(C) {
        return o.MolScriptBuilder.internal.generator.bundle({
          elements: o.MolScriptBuilder.core.type.list(C.elements.map(v))
        });
      }
      s.toExpression = h;
      function y(C, S) {
        if (C.elements.length !== S.elements.length)
          return !1;
        for (var b = 0, g = C.elements.length; b < g; ++b) {
          var _ = C.elements[b], A = S.elements[b];
          if (_.groupedUnits.length !== A.groupedUnits.length)
            return !1;
          for (var M = 0, P = A.groupedUnits.length; M < P; ++M)
            if (!r.SortedArray.areEqual(_.groupedUnits[M], A.groupedUnits[M]))
              return !1;
          if (!r.SortedArray.areEqual(_.set, A.set) || !a.SortedRanges.areEqual(_.ranges, A.ranges))
            return !1;
        }
        return !0;
      }
      s.areEqual = y;
    })(e.Bundle || (e.Bundle = {}));
  }(o5)), o5;
}
var p8;
function xE() {
  if (p8) return Ua;
  p8 = 1, Object.defineProperty(Ua, "__esModule", { value: !0 }), Ua.bundleGenerator = Ua.bundleElementImpl = Ua.spheres = Ua.atomicHet = Ua.water = Ua.atomicSequence = Ua.defaultBondTest = void 0;
  var e = Qe(), r = Mp(), t = ia(), n = gn(), a = jd(), i = Gr, o = AE();
  function c(p) {
    return i.BondType.isCovalent(p.atomicBond.type);
  }
  Ua.defaultBondTest = c;
  function s() {
    return function(v) {
      for (var h = v.inputStructure, y = r.StructureElement.Location.create(h), C = [], S = 0, b = h.units; S < b.length; S++) {
        var g = b[S];
        if (g.kind === 0) {
          y.unit = g;
          var _ = g.elements;
          if (y.element = _[0], t.StructureProperties.entity.type(y) === "polymer") {
            for (var A = e.Segmentation.transientSegments(g.model.atomicHierarchy.residueAtomSegments, _), M = 0; A.hasNext; )
              M++, A.move();
            M < 8 || C.push(g);
          }
        }
      }
      return a.StructureSelection.Singletons(h, n.Structure.create(C, { parent: h }));
    };
  }
  Ua.atomicSequence = s;
  function u() {
    return function(v) {
      for (var h = v.inputStructure, y = r.StructureElement.Location.create(h), C = [], S = 0, b = h.units; S < b.length; S++) {
        var g = b[S];
        if (g.kind === 0) {
          y.unit = g;
          var _ = g.elements;
          y.element = _[0], t.StructureProperties.entity.type(y) === "water" && C.push(g);
        }
      }
      return a.StructureSelection.Singletons(h, n.Structure.create(C, { parent: h }));
    };
  }
  Ua.water = u;
  function l() {
    return function(v) {
      for (var h = v.inputStructure, y = r.StructureElement.Location.create(h), C = [], S = 0, b = h.units; S < b.length; S++) {
        var g = b[S];
        if (g.kind === 0) {
          y.unit = g;
          var _ = g.elements;
          if (y.element = _[0], t.StructureProperties.entity.type(y) !== "water") {
            if (t.StructureProperties.entity.type(y) === "polymer") {
              for (var A = e.Segmentation.transientSegments(g.model.atomicHierarchy.residueAtomSegments, _), M = 0; A.hasNext; )
                M++, A.move();
              if (M >= 8)
                continue;
            }
            C.push(g);
          }
        }
      }
      return a.StructureSelection.Singletons(h, n.Structure.create(C, { parent: h }));
    };
  }
  Ua.atomicHet = l;
  function f() {
    return function(v) {
      for (var h = v.inputStructure, y = [], C = 0, S = h.units; C < S.length; C++) {
        var b = S[C];
        b.kind === 1 && y.push(b);
      }
      return a.StructureSelection.Singletons(h, n.Structure.create(y, { parent: h }));
    };
  }
  Ua.spheres = f;
  function d(p, v, h) {
    return {
      groupedUnits: p,
      ranges: v,
      set: h
    };
  }
  Ua.bundleElementImpl = d;
  function m(p) {
    return function(h) {
      var y = {
        hash: h.inputStructure.hashCode,
        elements: p
      };
      return a.StructureSelection.Sequence(h.inputStructure, [o.Bundle.toStructure(y, h.inputStructure)]);
    };
  }
  return Ua.bundleGenerator = m, Ua;
}
var h8;
function cG() {
  if (h8) return Nh;
  h8 = 1, Object.defineProperty(Nh, "__esModule", { value: !0 }), Nh.QueryContext = void 0;
  var e = ia(), r = Eu, t = xE(), n = (
    /** @class */
    function() {
      function i(o, c) {
        this.currentElementStack = [], this.currentAtomicBondStack = [], this.currentStructureStack = [], this.inputStructureStack = [], this.timeCreated = (0, r.now)(), this.element = e.StructureElement.Location.create(void 0), this.currentStructure = void 0, this.atomicBond = new a(), this.currentSelection = void 0, this.inputStructure = o, this.timeoutMs = c && c.timeoutMs || 0, this.currentSelection = c && c.currentSelection;
      }
      return i.prototype.pushCurrentElement = function() {
        return this.currentElementStack[this.currentElementStack.length] = this.element, this.element = e.StructureElement.Location.create(void 0), this.element;
      }, i.prototype.popCurrentElement = function() {
        this.element = this.currentElementStack.pop();
      }, i.prototype.pushCurrentBond = function() {
        return this.atomicBond && this.currentAtomicBondStack.push(this.atomicBond), this.atomicBond = new a(), this.atomicBond;
      }, i.prototype.popCurrentBond = function() {
        this.currentAtomicBondStack.length > 0 ? this.atomicBond = this.currentAtomicBondStack.pop() : this.atomicBond = void 0;
      }, i.prototype.pushCurrentStructure = function() {
        this.currentStructure && this.currentStructureStack.push(this.currentStructure);
      }, i.prototype.popCurrentStructure = function() {
        this.currentStructureStack.length ? this.currentStructure = this.currentStructureStack.pop() : this.currentStructure = void 0;
      }, i.prototype.pushInputStructure = function(o) {
        this.inputStructureStack.push(this.inputStructure), this.inputStructure = o;
      }, i.prototype.popInputStructure = function() {
        if (this.inputStructureStack.length === 0)
          throw new Error("Must push before pop.");
        this.inputStructure = this.inputStructureStack.pop();
      }, i.prototype.throwIfTimedOut = function() {
        if (this.timeoutMs !== 0 && (0, r.now)() - this.timeCreated > this.timeoutMs)
          throw new Error("The query took too long to execute (> ".concat(this.timeoutMs / 1e3, "s)."));
      }, i.prototype.tryGetCurrentSelection = function() {
        if (!this.currentSelection)
          throw new Error("The current selection is not assigned.");
        return this.currentSelection;
      }, i;
    }()
  );
  Nh.QueryContext = n;
  var a = (
    /** @class */
    function() {
      function i() {
        this.a = e.StructureElement.Location.create(void 0), this.aIndex = 0, this.b = e.StructureElement.Location.create(void 0), this.bIndex = 0, this.type = 0, this.order = 0, this.testFn = t.defaultBondTest;
      }
      return i.prototype.setStructure = function(o) {
        this.a.structure = o, this.b.structure = o;
      }, i.prototype.setTestFn = function(o) {
        this.testFn = o || t.defaultBondTest;
      }, i.prototype.test = function(o, c) {
        return this.testFn(o) ? !0 : c ? (this.swap(), this.testFn(o)) : !1;
      }, i.prototype.swap = function() {
        var o = this.aIndex;
        this.aIndex = this.bIndex, this.bIndex = o;
        var c = this.a.unit;
        this.a.unit = this.b.unit, this.b.unit = c;
        var s = this.a.element;
        this.a.element = this.b.element, this.b.element = s;
      }, Object.defineProperty(i.prototype, "length", {
        get: function() {
          return e.StructureElement.Location.distance(this.a, this.b);
        },
        enumerable: !1,
        configurable: !0
      }), i;
    }()
  );
  return Nh;
}
var g8;
function ooe() {
  if (g8) return Bh;
  g8 = 1, Object.defineProperty(Bh, "__esModule", { value: !0 }), Bh.StructureQuery = void 0;
  var e = cG(), r;
  return function(t) {
    function n(a, i, o) {
      return a(new e.QueryContext(i, o));
    }
    t.run = n;
  }(r || (r = {})), Bh.StructureQuery = r, Bh;
}
var u5 = {}, bf = {}, y8;
function dG() {
  if (y8) return bf;
  y8 = 1, Object.defineProperty(bf, "__esModule", { value: !0 }), bf.LinearGroupingBuilder = bf.UniqueStructuresBuilder = void 0;
  var e = ia(), r = jd(), t = Po, n = dy(), a = (
    /** @class */
    function() {
      function o(c) {
        this.source = c, this.set = (0, t.HashSet)(e.Structure.hashCode, e.Structure.areUnitIdsAndIndicesEqual), this.structures = [], this.allSingletons = !0;
      }
      return o.prototype.add = function(c) {
        c.elementCount && (c.elementCount !== 1 && (this.allSingletons = !1), this.set.add(c) && (this.structures[this.structures.length] = c));
      }, o.prototype.getSelection = function() {
        return this.allSingletons ? r.StructureSelection.Singletons(this.source, (0, n.structureUnion)(this.source, this.structures)) : r.StructureSelection.Sequence(this.source, this.structures);
      }, o;
    }()
  );
  bf.UniqueStructuresBuilder = a;
  var i = (
    /** @class */
    function() {
      function o(c) {
        this.source = c, this.builders = [], this.builderMap = /* @__PURE__ */ new Map();
      }
      return o.prototype.add = function(c, s, u) {
        var l = this.builderMap.get(c);
        l || (l = this.source.subsetBuilder(!0), this.builders[this.builders.length] = l, this.builderMap.set(c, l)), l.addToUnit(s, u);
      }, o.prototype.allSingletons = function() {
        for (var c = 0, s = this.builders.length; c < s; c++)
          if (this.builders[c].elementCount > 1)
            return !1;
        return !0;
      }, o.prototype.singletonSelection = function() {
        for (var c = this.source.subsetBuilder(!0), s = e.StructureElement.Location.create(this.source), u = 0, l = this.builders.length; u < l; u++)
          this.builders[u].setSingletonLocation(s), c.addToUnit(s.unit.id, s.element);
        return r.StructureSelection.Singletons(this.source, c.getStructure());
      }, o.prototype.fullSelection = function() {
        for (var c = new Array(this.builders.length), s = 0, u = this.builders.length; s < u; s++)
          c[s] = this.builders[s].getStructure();
        return r.StructureSelection.Sequence(this.source, c);
      }, o.prototype.getSelection = function() {
        var c = this.builders.length;
        return c === 0 ? r.StructureSelection.Empty(this.source) : this.allSingletons() ? this.singletonSelection() : this.fullSelection();
      }, o;
    }()
  );
  return bf.LinearGroupingBuilder = i, bf;
}
var _8;
function fG() {
  return _8 || (_8 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.bondedAtomicPairs = e.querySelection = e.rings = e.atoms = e.chains = e.residues = e.all = e.none = void 0;
    var r = Te, t = Po, n = Qe(), a = ia(), i = gn(), o = jd(), c = dG(), s = dy(), u = function(A) {
      return o.StructureSelection.Sequence(A.inputStructure, []);
    };
    e.none = u;
    var l = function(A) {
      return o.StructureSelection.Singletons(A.inputStructure, A.inputStructure);
    };
    e.all = l;
    function f(A) {
      return v((0, r.__assign)((0, r.__assign)({}, A), { groupBy: function(M) {
        return a.StructureProperties.residue.key(M.element);
      } }));
    }
    e.residues = f;
    function d(A) {
      return v((0, r.__assign)((0, r.__assign)({}, A), { groupBy: function(M) {
        return a.StructureProperties.chain.key(M.element);
      } }));
    }
    e.chains = d;
    function m(A) {
      return !0;
    }
    function p(A) {
      return 0;
    }
    function v(A) {
      if (!A || !A.atomTest && !A.residueTest && !A.chainTest && !A.entityTest && !A.unitTest && !A.groupBy)
        return e.all;
      if (A.atomTest && !A.residueTest && !A.chainTest && !A.entityTest && !A.unitTest && !A.groupBy)
        return h(A.atomTest);
      var M = {
        unitTest: A.unitTest || m,
        entityTest: A.entityTest || m,
        chainTest: A.chainTest || m,
        residueTest: A.residueTest || m,
        atomTest: A.atomTest || m,
        groupBy: A.groupBy || p
      };
      return A.groupBy ? C(M) : y(M);
    }
    e.atoms = v;
    function h(A) {
      return function(P) {
        var T = P.inputStructure, x = T.units, w = P.pushCurrentElement(), E = T.subsetBuilder(!0);
        w.structure = T;
        for (var I = 0, B = x; I < B.length; I++) {
          var D = B[I];
          w.unit = D;
          var N = D.elements;
          E.beginUnit(D.id);
          for (var O = 0, V = N.length; O < V; O++)
            w.element = N[O], A(P) && E.addElement(w.element);
          E.commitUnit(), P.throwIfTimedOut();
        }
        return P.popCurrentElement(), o.StructureSelection.Singletons(T, E.getStructure());
      };
    }
    function y(A) {
      var M = A.unitTest, P = A.entityTest, T = A.chainTest, x = A.residueTest, w = A.atomTest;
      return function(I) {
        var B = I.inputStructure, D = B.units, N = I.pushCurrentElement(), O = B.subsetBuilder(!0), V = x === m && w === m, k = w === m;
        N.structure = B;
        for (var G = 0, L = D; G < L.length; G++) {
          var R = L[G];
          if (N.unit = R, !!M(I)) {
            var F = R.elements, U = R.model;
            if (O.beginUnit(R.id), R.kind === 0)
              for (var H = n.Segmentation.transientSegments(R.model.atomicHierarchy.chainAtomSegments, F), q = n.Segmentation.transientSegments(R.model.atomicHierarchy.residueAtomSegments, F); H.hasNext; ) {
                var K = H.move();
                if (N.element = F[K.start], !(!P(I) || !T(I))) {
                  if (V) {
                    O.addElementRange(F, K.start, K.end);
                    continue;
                  }
                  for (q.setSegment(K); q.hasNext; ) {
                    var Y = q.move();
                    if (N.element = F[Y.start], !!x(I)) {
                      if (k) {
                        O.addElementRange(F, Y.start, Y.end);
                        continue;
                      }
                      for (var X = Y.start, Z = Y.end; X < Z; X++)
                        N.element = F[X], w(I) && O.addElement(N.element);
                    }
                  }
                }
              }
            else
              for (var J = U.coarseHierarchy.spheres.chainElementSegments, H = n.Segmentation.transientSegments(J, F); H.hasNext; ) {
                var K = H.move();
                if (N.element = F[K.start], !(!P(I) || !T(I))) {
                  if (V) {
                    O.addElementRange(F, K.start, K.end);
                    continue;
                  }
                  for (var X = K.start, Z = K.end; X < Z; X++)
                    N.element = F[X], x(I) && O.addElement(N.element);
                }
              }
            O.commitUnit(), I.throwIfTimedOut();
          }
        }
        return I.popCurrentElement(), o.StructureSelection.Singletons(B, O.getStructure());
      };
    }
    function C(A) {
      var M = A.unitTest, P = A.entityTest, T = A.chainTest, x = A.residueTest, w = A.atomTest, E = A.groupBy;
      return function(B) {
        var D = B.inputStructure, N = D.units, O = B.pushCurrentElement(), V = new c.LinearGroupingBuilder(D);
        O.structure = D;
        for (var k = 0, G = N; k < G.length; k++) {
          var L = G[k];
          if (O.unit = L, !!M(B)) {
            var R = L.elements, F = L.model;
            if (L.kind === 0)
              for (var U = n.Segmentation.transientSegments(F.atomicHierarchy.chainAtomSegments, R), H = n.Segmentation.transientSegments(F.atomicHierarchy.residueAtomSegments, R); U.hasNext; ) {
                var q = U.move();
                if (O.element = R[q.start], !(!P(B) || !T(B)))
                  for (H.setSegment(q); H.hasNext; ) {
                    var K = H.move();
                    if (O.element = R[K.start], !!x(B))
                      for (var Y = K.start, X = K.end; Y < X; Y++)
                        O.element = R[Y], w(B) && V.add(E(B), L.id, O.element);
                  }
              }
            else
              for (var Z = F.coarseHierarchy.spheres.chainElementSegments, U = n.Segmentation.transientSegments(Z, R); U.hasNext; ) {
                var q = U.move();
                if (O.element = R[q.start], !(!P(B) || !T(B)))
                  for (var Y = q.start, X = q.end; Y < X; Y++)
                    O.element = R[Y], x(B) && V.add(E(B), L.id, O.element);
              }
            B.throwIfTimedOut();
          }
        }
        return B.popCurrentElement(), V.getSelection();
      };
    }
    function S(A, M, P) {
      for (var T = new Int32Array(M.length), x = 0, w = M.length; x < w; x++)
        T[x] = A.elements[M[x]];
      return i.Structure.create([A.getChild(n.SortedArray.ofSortedArray(T))], { parent: P });
    }
    function b(A, M) {
      return function(T) {
        var x = T.inputStructure.units, w = o.StructureSelection.LinearBuilder(T.inputStructure);
        if (!A || A.length === 0)
          for (var E = 0, I = x; E < I.length; E++) {
            var B = I[E];
            if (a.Unit.isAtomic(B))
              if (M)
                for (var D = 0, N = B.rings.aromaticRings; D < N.length; D++) {
                  var O = N[D];
                  w.add(S(B, B.rings.all[O], T.inputStructure));
                }
              else
                for (var V = 0, k = B.rings.all; V < k.length; V++) {
                  var O = k[V];
                  w.add(S(B, O, T.inputStructure));
                }
          }
        else {
          for (var G = t.UniqueArray.create(), L = 0; L < A.length; L++)
            t.UniqueArray.add(G, A[L], A[L]);
          for (var R = 0, F = x; R < F.length; R++) {
            var B = F[R];
            if (a.Unit.isAtomic(B))
              for (var U = B.rings, H = 0, q = G.array; H < q.length; H++) {
                var K = q[H];
                if (U.byFingerprint.has(K))
                  for (var Y = 0, X = U.byFingerprint.get(K); Y < X.length; Y++) {
                    var O = X[Y];
                    M && !U.aromaticRings.includes(O) || w.add(S(B, U.all[O], T.inputStructure));
                  }
              }
          }
        }
        return w.getSelection();
      };
    }
    e.rings = b;
    function g(A, M, P) {
      return P === void 0 && (P = !1), function(x) {
        var w = A(x);
        if (o.StructureSelection.structureCount(w) === 0)
          return w;
        var E = P ? (0, s.structureSubtract)(x.inputStructure, o.StructureSelection.unionStructure(w)) : o.StructureSelection.unionStructure(w);
        if (E.elementCount === 0)
          return o.StructureSelection.Empty(x.inputStructure);
        x.throwIfTimedOut(), x.pushInputStructure(E);
        var I = M(x);
        return x.popInputStructure(), o.StructureSelection.withInputStructure(I, x.inputStructure);
      };
    }
    e.querySelection = g;
    function _(A) {
      return function(P) {
        var T = P.inputStructure, x = T.interUnitBonds, w = o.StructureSelection.UniqueBuilder(P.inputStructure);
        P.pushCurrentBond();
        var E = P.atomicBond;
        E.setTestFn(A), E.setStructure(T);
        for (var I = 0, B = T.units; I < B.length; I++) {
          var D = B[I];
          if (D.kind === 0) {
            var N = D.bonds, O = N.offset, V = N.b, k = N.edgeProps, G = k.flags, L = k.order;
            E.a.unit = D, E.b.unit = D;
            for (var R = 0, F = D.elements.length; R < F; R++) {
              E.aIndex = R, E.a.element = D.elements[R];
              for (var U = O[R], H = O[R + 1]; U < H; U++)
                if (E.bIndex = V[U], E.b.element = D.elements[V[U]], E.type = G[U], E.order = L[U], E.test(P, !1)) {
                  var q = T.subsetBuilder(!1);
                  q.beginUnit(D.id), q.addElement(E.a.element), q.addElement(E.b.element), q.commitUnit(), w.add(q.getStructure());
                }
            }
          }
        }
        for (var K = 0, Y = x.edges; K < Y.length; K++) {
          var X = Y[K];
          if (E.a.unit = T.unitMap.get(X.unitA), E.a.element = E.a.unit.elements[X.indexA], E.aIndex = X.indexA, E.b.unit = T.unitMap.get(X.unitA), E.b.element = E.b.unit.elements[X.indexB], E.bIndex = X.indexB, E.order = X.props.order, E.type = X.props.flag, E.test(P, !1)) {
            var q = T.subsetBuilder(!1);
            q.addToUnit(E.a.unit.id, E.a.element), q.addToUnit(E.b.unit.id, E.b.element), w.add(q.getStructure());
          }
        }
        return P.popCurrentBond(), w.getSelection();
      };
    }
    e.bondedAtomicPairs = _;
  }(u5)), u5;
}
var Un = {}, Vh = {}, b8;
function uoe() {
  if (b8) return Vh;
  b8 = 1, Object.defineProperty(Vh, "__esModule", { value: !0 }), Vh.StructureUniqueSubsetBuilder = void 0;
  var e = Qe(), r = wr(), t = WC(), n = gn(), a = Po, i = (
    /** @class */
    function() {
      function o(c) {
        this.parent = c, this.ids = [], this.unitMap = e.IntMap.Mutable(), this.parentId = -1, this.currentUnit = a.UniqueArray.create(), this.elementCount = 0;
      }
      return o.prototype.addToUnit = function(c, s) {
        var u = this.unitMap.get(c);
        if (u)
          a.UniqueArray.add(u, s, s) && this.elementCount++;
        else {
          var l = a.UniqueArray.create();
          a.UniqueArray.add(l, s, s), this.unitMap.set(c, l), this.ids[this.ids.length] = c, this.elementCount++;
        }
      }, o.prototype.has = function(c, s) {
        var u = this.unitMap.get(c);
        return u ? a.UniqueArray.has(u, s) : !1;
      }, o.prototype.beginUnit = function(c) {
        this.parentId = c, this.unitMap.has(c) ? this.currentUnit = this.unitMap.get(c) : this.currentUnit = this.currentUnit.array.length > 0 ? a.UniqueArray.create() : this.currentUnit;
      }, o.prototype.addElement = function(c) {
        a.UniqueArray.add(this.currentUnit, c, c) && this.elementCount++;
      }, o.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);
      }, o.prototype.getStructure = function() {
        if (this.isEmpty)
          return n.Structure.Empty;
        var c = [];
        (0, r.sortArray)(this.ids);
        for (var s = t.StructureSymmetry.UnitEquivalenceBuilder(), u = 0, l = this.ids.length; u < l; u++) {
          var f = this.ids[u], d = this.parent.unitMap.get(f), m = this.unitMap.get(f).array, p = m.length;
          if (m.length === d.elements.length) {
            c[c.length] = d, s.add(d.id, d);
            continue;
          }
          p > 1 && (0, r.sortArray)(m);
          var v = d.getChild(e.SortedArray.ofSortedArray(m)), h = s.add(v.id, v);
          v !== h && (v = h.applyOperator(v.id, v.conformation.operator, !0)), c[c.length] = v;
        }
        return n.Structure.create(c, { parent: this.parent });
      }, Object.defineProperty(o.prototype, "isEmpty", {
        get: function() {
          return this.elementCount === 0;
        },
        enumerable: !1,
        configurable: !0
      }), o;
    }()
  );
  return Vh.StructureUniqueSubsetBuilder = i, Vh;
}
var Sf = {}, Vu = {}, wC = {}, Pi = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.TokenBuilder = e.trimStr = e.Tokenizer = void 0;
  var r = Te, t = Kr;
  function n(o) {
    return {
      data: o,
      position: 0,
      length: o.length,
      lineNumber: 1,
      tokenStart: 0,
      tokenEnd: 0
    };
  }
  e.Tokenizer = n, function(o) {
    function c(M) {
      return M.data.substring(M.tokenStart, M.tokenEnd);
    }
    o.getTokenString = c;
    function s(M) {
      M.position = 0, M.lineNumber = 1, M.tokenStart = 0, M.tokenEnd = 0;
    }
    o.reset = s;
    function u(M) {
      for (var P = M.data; M.position < M.length; )
        switch (P.charCodeAt(M.position)) {
          case 10:
            return M.tokenEnd = M.position, ++M.position, ++M.lineNumber, !0;
          case 13:
            return M.tokenEnd = M.position, ++M.position, ++M.lineNumber, P.charCodeAt(M.position) === 10 && ++M.position, !0;
          default:
            ++M.position;
            break;
        }
      return M.tokenEnd = M.position, M.tokenStart !== M.tokenEnd;
    }
    o.eatLine = u;
    function l(M) {
      M.tokenStart = M.position;
    }
    o.markStart = l;
    function f(M) {
      return M.tokenStart = M.position, u(M);
    }
    o.markLine = f;
    function d(M) {
      return f(M), c(M);
    }
    o.readLine = d;
    function m(M) {
      f(M);
      var P = M.position;
      return A(M, M.tokenStart, M.tokenEnd), M.position = P, c(M);
    }
    o.readLineTrim = m;
    function p(M, P, T) {
      for (var x = 0, w = 0; w < P; w++) {
        if (!f(M))
          return x;
        i.addUnchecked(T, M.tokenStart, M.tokenEnd), x++;
      }
      return x;
    }
    function v(M, P) {
      var T = i.create(M.data, P * 2);
      return p(M, P, T), T;
    }
    o.markLines = v;
    function h(M, P) {
      for (var T = [], x = 0; x < P; x++)
        T.push(o.readLine(M));
      return T;
    }
    o.readLines = h;
    function y(M, P, T, x) {
      return x === void 0 && (x = 1e5), (0, r.__awaiter)(this, void 0, void 0, function() {
        var w, E, I;
        return (0, r.__generator)(this, function(B) {
          switch (B.label) {
            case 0:
              return w = M.length, E = i.create(M.data, P * 2), I = 0, [4, (0, t.chunkedSubtask)(T, x, M, function(D, N) {
                var O = Math.min(P - I, D);
                return p(N, O, E), I += O, O;
              }, function(D, N) {
                return D.update({ message: "Parsing...", current: N.position, max: w });
              })];
            case 1:
              return B.sent(), [2, E];
          }
        });
      });
    }
    o.readLinesAsync = y;
    function C(M) {
      for (var P = o(M), T = i.create(P.data, Math.max(M.length / 80, 2)); f(P); )
        i.add(T, P.tokenStart, P.tokenEnd);
      return T;
    }
    o.readAllLines = C;
    function S(M, P, T) {
      for (var x = 0, w = 0; w < P; w++) {
        if (!f(M))
          return x;
        i.add(T, M.tokenStart, M.tokenEnd), x++;
      }
      return x;
    }
    function b(M, P, T) {
      return T === void 0 && (T = 1e5), (0, r.__awaiter)(this, void 0, void 0, function() {
        var x, w;
        return (0, r.__generator)(this, function(E) {
          switch (E.label) {
            case 0:
              return x = o(M), w = i.create(x.data, Math.max(M.length / 80, 2)), [4, (0, t.chunkedSubtask)(P, T, x, function(I, B) {
                return S(B, I, w), B.position < B.length ? I : 0;
              }, function(I, B) {
                return I.update({ message: "Parsing...", current: B.position, max: length });
              })];
            case 1:
              return E.sent(), [2, w];
          }
        });
      });
    }
    o.readAllLinesAsync = b;
    function g(M) {
      for (; M.position < M.length; )
        switch (M.data.charCodeAt(M.position)) {
          case 9:
          case 10:
          case 13:
          case 32:
            M.tokenEnd = M.position;
            return;
          default:
            ++M.position;
            break;
        }
      M.tokenEnd = M.position;
    }
    o.eatValue = g;
    function _(M) {
      for (var P = -1; M.position < M.length; ) {
        var T = M.data.charCodeAt(M.position);
        switch (T) {
          case 9:
          case 32:
            P = T, ++M.position;
            break;
          case 10:
            P !== 13 && ++M.lineNumber, P = T, ++M.position;
            break;
          case 13:
            P = T, ++M.position, ++M.lineNumber;
            break;
          default:
            return P;
        }
      }
      return P;
    }
    o.skipWhitespace = _;
    function A(M, P, T) {
      for (var x = M.data, w = P, E = T - 1, I = x.charCodeAt(w); (I === 9 || I === 32) && w <= E; )
        I = x.charCodeAt(++w);
      for (I = x.charCodeAt(E); (I === 9 || I === 32) && E >= w; )
        I = x.charCodeAt(--E);
      return M.tokenStart = w, M.tokenEnd = E + 1, M.position = T, M;
    }
    o.trim = A;
  }(n || (n = {})), e.Tokenizer = n;
  function a(o, c, s) {
    for (var u = c, l = s - 1, f = o.charCodeAt(u); (f === 9 || f === 32) && u <= l; )
      f = o.charCodeAt(++u);
    for (f = o.charCodeAt(l); (f === 9 || f === 32) && l >= u; )
      f = o.charCodeAt(--l);
    return o.substring(u, l + 1);
  }
  e.trimStr = a;
  var i;
  (function(o) {
    function c(d) {
      var m = new Uint32Array(1.61 * d.indices.length | 0);
      m.set(d.indices), d.indices = m, d.indicesLenMinus2 = m.length - 2 | 0;
    }
    function s(d, m, p) {
      var v = d;
      v.offset > v.indicesLenMinus2 && c(v), v.indices[v.offset++] = m, v.indices[v.offset++] = p, d.count++;
    }
    o.add = s;
    function u(d, m) {
      s(d, m.tokenStart, m.tokenEnd);
    }
    o.addToken = u;
    function l(d, m, p) {
      d.indices[d.offset++] = m, d.indices[d.offset++] = p, d.count++;
    }
    o.addUnchecked = l;
    function f(d, m) {
      return m = Math.max(10, m), {
        data: d,
        indicesLenMinus2: m - 2 | 0,
        count: 0,
        offset: 0,
        indices: new Uint32Array(m)
      };
    }
    o.create = f;
  })(i = e.TokenBuilder || (e.TokenBuilder = {}));
})(Pi);
var Mi = {};
Object.defineProperty(Mi, "__esModule", { value: !0 });
Mi.ReaderResult = void 0;
var bM;
(function(e) {
  function r(i, o) {
    return o === void 0 && (o = -1), new n(i, o);
  }
  e.error = r;
  function t(i, o) {
    return o === void 0 && (o = []), new a(i, o);
  }
  e.success = t;
  var n = (
    /** @class */
    function() {
      function i(o, c) {
        this.message = o, this.line = c, this.isError = !0;
      }
      return i.prototype.toString = function() {
        return this.line >= 0 ? "[Line ".concat(this.line, "] ").concat(this.message) : this.message;
      }, i;
    }()
  );
  e.Error = n;
  var a = (
    /** @class */
    /* @__PURE__ */ function() {
      function i(o, c) {
        this.result = o, this.warnings = c, this.isError = !1;
      }
      return i;
    }()
  );
  e.Success = a;
})(bM || (bM = {}));
Mi.ReaderResult = bM;
Object.defineProperty(wC, "__esModule", { value: !0 });
wC.parseCifText = void 0;
var l0 = Te, Dd = (0, l0.__importStar)(oy), TE = Pi, mG = Mi, vG = Kr;
function S8(e) {
  for (; e.position < e.length; )
    switch (e.data.charCodeAt(e.position)) {
      case 9:
      case 10:
      case 13:
      case 32:
        e.tokenEnd = e.position;
        return;
      default:
        ++e.position;
        break;
    }
  e.tokenEnd = e.position;
}
function soe(e, r) {
  var t, n;
  for (++e.position; e.position < e.length; )
    if (n = e.data.charCodeAt(e.position), n === r)
      switch (t = e.data.charCodeAt(e.position + 1), t) {
        case 9:
        case 10:
        case 13:
        case 32:
          e.tokenStart++, e.tokenEnd = e.position, e.isEscaped = !0, ++e.position;
          return;
        default:
          if (t === void 0) {
            e.tokenStart++, e.tokenEnd = e.position, e.isEscaped = !0, ++e.position;
            return;
          }
          ++e.position;
          break;
      }
    else {
      if (n === 10 || n === 13) {
        e.tokenEnd = e.position;
        return;
      }
      ++e.position;
    }
  e.tokenEnd = e.position;
}
function loe(e) {
  for (e.position += 3; e.position < e.length; ) {
    if (e.data.charCodeAt(e.position) === 39 && pG(e)) {
      e.tokenStart += 3, e.tokenEnd = e.position, e.isEscaped = !0, e.position += 3;
      return;
    }
    ++e.position;
  }
  e.tokenEnd = e.position;
}
function coe(e) {
  for (var r = 59, t = e.position + 1, n; t < e.length; )
    if (n = e.data.charCodeAt(t), n === 59 && (r === 10 || r === 13)) {
      for (e.position = t + 1, e.tokenStart++, t--, n = e.data.charCodeAt(t); n === 10 || n === 13; )
        t--, n = e.data.charCodeAt(t);
      e.tokenEnd = t + 1, e.isEscaped = !0;
      return;
    } else
      (n === 13 || n === 10 && r !== 13) && e.lineNumber++, r = n, ++t;
  return e.position = t, r;
}
function doe(e) {
  for (; e.position < e.length; )
    switch (e.data.charCodeAt(e.position)) {
      case 93:
        ++e.position, e.tokenEnd = e.position, e.isImportGet = !1;
        return;
      default:
        ++e.position;
        break;
    }
}
function foe(e) {
  for (; e.position < e.length; ) {
    var r = e.data.charCodeAt(e.position);
    if (r === 10 || r === 13)
      return;
    ++e.position;
  }
}
function moe(e) {
  for (var r = 10; e.position < e.length; ) {
    var t = e.data.charCodeAt(e.position);
    switch (t) {
      case 9:
      case 32:
        r = t, ++e.position;
        break;
      case 10:
        r !== 13 && ++e.lineNumber, r = t, ++e.position;
        break;
      case 13:
        r = t, ++e.position, ++e.lineNumber;
        break;
      default:
        return r;
    }
  }
  return r;
}
function pG(e) {
  return !(e.length - e.position < 2 || e.data.charCodeAt(e.position + 1) !== 39 || e.data.charCodeAt(e.position + 2) !== 39);
}
function voe(e) {
  var r = e.data.charCodeAt(e.tokenStart);
  return !(r !== 68 && r !== 100 || (r = e.data.charCodeAt(e.tokenStart + 1), r !== 65 && r !== 97) || (r = e.data.charCodeAt(e.tokenStart + 2), r !== 84 && r !== 116) || (r = e.data.charCodeAt(e.tokenStart + 3), r !== 65 && r !== 97));
}
function poe(e) {
  var r = e.data.charCodeAt(e.tokenStart);
  return !(r !== 83 && r !== 115 || (r = e.data.charCodeAt(e.tokenStart + 1), r !== 65 && r !== 97) || (r = e.data.charCodeAt(e.tokenStart + 2), r !== 86 && r !== 118) || (r = e.data.charCodeAt(e.tokenStart + 3), r !== 69 && r !== 101));
}
function hoe(e) {
  if (e.tokenEnd - e.tokenStart !== 5)
    return !1;
  var r = e.data.charCodeAt(e.tokenStart);
  return !(r !== 76 && r !== 108 || (r = e.data.charCodeAt(e.tokenStart + 1), r !== 79 && r !== 111) || (r = e.data.charCodeAt(e.tokenStart + 2), r !== 79 && r !== 111) || (r = e.data.charCodeAt(e.tokenStart + 3), r !== 80 && r !== 112));
}
function goe(e) {
  return !(e.tokenEnd - e.tokenStart !== 11 || e.data.charCodeAt(e.tokenStart + 1) !== 105 || e.data.charCodeAt(e.tokenStart + 2) !== 109 || e.data.charCodeAt(e.tokenStart + 3) !== 112 || e.data.charCodeAt(e.tokenStart + 4) !== 111 || e.data.charCodeAt(e.tokenStart + 5) !== 114 || e.data.charCodeAt(e.tokenStart + 6) !== 116 || e.data.charCodeAt(e.tokenStart + 7) !== 46 || e.data.charCodeAt(e.tokenStart + 8) !== 103 || e.data.charCodeAt(e.tokenStart + 9) !== 101 || e.data.charCodeAt(e.tokenStart + 10) !== 116);
}
function yoe(e, r, t) {
  var n, a = t - r, i = e.tokenStart - r, o = e.tokenEnd - e.tokenStart;
  if (o < a)
    return !1;
  for (n = r; n < t; ++n)
    if (e.data.charCodeAt(n) !== e.data.charCodeAt(n + i))
      return !1;
  return a === o || e.data.charCodeAt(n + i) === 46;
}
function hG(e) {
  var r;
  for (r = e.tokenStart; r < e.tokenEnd; ++r)
    if (e.data.charCodeAt(r) === 46)
      return r;
  return r;
}
function gG(e, r) {
  return e.data.substring(e.tokenStart, r);
}
function _oe(e) {
  var r;
  for (r = e.tokenStart; r < e.tokenEnd; ++r)
    if (e.data.charCodeAt(r) === 46)
      return !1;
  return !0;
}
function SM(e) {
  return e.data.substring(e.tokenStart, e.tokenEnd);
}
function C8(e) {
  var r = moe(e);
  if (e.position >= e.length) {
    e.tokenType = 6;
    return;
  }
  e.tokenStart = e.position, e.tokenEnd = e.position, e.isEscaped = !1;
  var t = e.data.charCodeAt(e.position);
  switch (t) {
    case 35:
      foe(e), e.tokenType = 5;
      break;
    case 39:
      if (pG(e)) {
        loe(e), e.tokenType = 3;
        break;
      }
    case 34:
      soe(e, t), e.tokenType = 3;
      break;
    case 59:
      r === 10 || r === 13 ? coe(e) : S8(e), e.tokenType = 3;
      break;
    default:
      e.isImportGet ? doe(e) : S8(e), e.isEscaped ? e.tokenType = 3 : e.data.charCodeAt(e.tokenStart) === 95 ? (e.inSaveFrame && goe(e) && (e.isImportGet = !0), e.tokenType = 4) : e.tokenEnd - e.tokenStart >= 5 && e.data.charCodeAt(e.tokenStart + 4) === 95 ? voe(e) ? e.tokenType = 0 : poe(e) ? e.tokenType = 1 : hoe(e) ? e.tokenType = 2 : e.tokenType = 3 : e.tokenType = 3;
      break;
  }
}
function gd(e) {
  for (C8(e); e.tokenType === 5; )
    C8(e);
}
function boe(e, r) {
  return {
    data: e,
    length: e.length,
    position: 0,
    tokenStart: 0,
    tokenEnd: 0,
    tokenType: 6,
    lineNumber: 1,
    isEscaped: !1,
    isImportGet: !1,
    inSaveFrame: !1,
    runtimeCtx: r
  };
}
function u2() {
  return { categoryNames: [], categoryData: /* @__PURE__ */ Object.create(null) };
}
function PE(e, r) {
  for (var t = /* @__PURE__ */ Object.create(null), n = 0, a = e; n < a.length; n++) {
    var i = a[n], o = r[i];
    t[i] = Dd.CifCategory(o.name, o.rowCount, o.fieldNames, o.fields);
  }
  return t;
}
function A8(e, r, t) {
  return Dd.CifBlock(e.categoryNames, PE(e.categoryNames, e.categoryData), r, t);
}
function Soe(e, r) {
  return Dd.CifBlock(e.categoryNames, PE(e.categoryNames, e.categoryData), r);
}
function CM(e, r, t, n, a) {
  var i;
  if (r in e.categoryData) {
    var o = e.categoryData[r];
    (i = o.fieldNames).push.apply(i, n), Object.assign(o.fields, a);
  } else
    e.categoryData[r] = { name: r, rowCount: t, fieldNames: n, fields: a }, e.categoryNames.push(r);
}
function Coe(e, r) {
  for (var t = e.tokenStart, n = hG(e), a = gG(e, n), i = /* @__PURE__ */ Object.create(null), o = [], c = !0; c; ) {
    if (e.tokenType !== 4 || !yoe(e, t, n)) {
      c = !1;
      break;
    }
    var s = SM(e).substring(a.length + 1);
    if (gd(e), e.tokenType !== 3)
      return {
        hasError: !0,
        errorLine: e.lineNumber,
        errorMessage: "Expected value."
      };
    i[s] = Dd.CifField.ofTokens({ data: e.data, indices: [e.tokenStart, e.tokenEnd], count: 1 }), o[o.length] = s, gd(e);
  }
  return CM(r, a.substr(1), 1, o, i), {
    hasError: !1,
    errorLine: 0,
    errorMessage: ""
  };
}
function Aoe(e, r) {
  for (var t = r.tokenizer, n = r.tokens, a = r.fieldCount, i = r.tokenCount, o = 0; t.tokenType === 3 && o < e; )
    TE.TokenBuilder.add(n[i++ % a], t.tokenStart, t.tokenEnd), gd(t), o++;
  return r.tokenCount = i, o;
}
function xoe(e, r) {
  return e.update({ message: "Parsing...", current: r.tokenizer.position, max: r.tokenizer.data.length });
}
function Toe(e, r) {
  return (0, l0.__awaiter)(this, void 0, void 0, function() {
    var t, n, a, i, o, c, s, d, u, l, d, f, f, d;
    return (0, l0.__generator)(this, function(m) {
      switch (m.label) {
        case 0:
          for (t = e.lineNumber, gd(e), n = gG(e, hG(e)), a = _oe(e), i = []; e.tokenType === 4; )
            i[i.length] = a ? SM(e) : SM(e).substring(n.length + 1), gd(e);
          for (o = n === "_atom_site" ? e.data.length / 100 | 0 : 32, c = [], s = i.length, d = 0; d < s; d++)
            c[d] = TE.TokenBuilder.create(e.data, o);
          return u = {
            fieldCount: s,
            tokenCount: 0,
            tokenizer: e,
            tokens: c
          }, [4, (0, vG.chunkedSubtask)(e.runtimeCtx, 1e6, u, Aoe, xoe)];
        case 1:
          if (m.sent(), u.tokenCount % s !== 0)
            return [2, {
              hasError: !0,
              errorLine: e.lineNumber,
              errorMessage: "The number of values for loop starting at line ".concat(t, " is not a multiple of the number of columns.")
            }];
          if (l = u.tokenCount / s | 0, a)
            for (d = 0; d < s; d++)
              f = { "": Dd.CifField.ofTokens(c[d]) }, CM(r, i[d].substr(1), l, [""], f);
          else {
            for (f = /* @__PURE__ */ Object.create(null), d = 0; d < s; d++)
              f[i[d]] = Dd.CifField.ofTokens(c[d]);
            CM(r, n.substr(1), l, i, f);
          }
          return [2, {
            hasError: !1,
            errorLine: 0,
            errorMessage: ""
          }];
      }
    });
  });
}
function cm(e, r) {
  return mG.ReaderResult.error(r, e);
}
function Poe(e) {
  return mG.ReaderResult.success(e);
}
function Moe(e, r) {
  return (0, l0.__awaiter)(this, void 0, void 0, function() {
    var t, n, a, i, o, c, s, u, l, f, f;
    return (0, l0.__generator)(this, function(d) {
      switch (d.label) {
        case 0:
          t = [], n = boe(e, r), a = "", i = u2(), o = [], c = u2(), s = Dd.CifSaveFrame(c.categoryNames, PE(c.categoryNames, c.categoryData), ""), u = "", r.update({ message: "Parsing...", current: 0, max: e.length }), gd(n), d.label = 1;
        case 1:
          return n.tokenType === 6 ? [3, 7] : (l = n.tokenType, l !== 0 ? [3, 2] : n.inSaveFrame ? [2, cm(n.lineNumber, "Unexpected data block inside a save frame.")] : (i.categoryNames.length > 0 && t.push(A8(i, a, o)), a = e.substring(n.tokenStart + 5, n.tokenEnd), i = u2(), o = [], gd(n), [3, 6]));
        case 2:
          if (l !== 1) return [3, 3];
          if (n.tokenEnd - n.tokenStart === 5)
            c.categoryNames.length > 0 && (o[o.length] = Soe(c, u)), n.inSaveFrame = !1;
          else {
            if (n.inSaveFrame)
              return [2, cm(n.lineNumber, "Save frames cannot be nested.")];
            n.inSaveFrame = !0, u = e.substring(n.tokenStart + 5, n.tokenEnd), c = u2();
          }
          return gd(n), [3, 6];
        case 3:
          return l !== 2 ? [3, 5] : [4, Toe(n, n.inSaveFrame ? c : i)];
        case 4:
          return f = d.sent(), f.hasError ? [2, cm(f.errorLine, f.errorMessage)] : [3, 6];
        case 5:
          if (l === 4) {
            if (f = Coe(n, n.inSaveFrame ? c : i), f.hasError)
              return [2, cm(f.errorLine, f.errorMessage)];
          } else
            return console.log(n.tokenType, TE.Tokenizer.getTokenString(n)), [2, cm(n.lineNumber, "Unexpected token. Expected data_, loop_, or data name.")];
          d.label = 6;
        case 6:
          return [3, 1];
        case 7:
          return n.inSaveFrame ? [2, cm(n.lineNumber, "Unfinished save frame (".concat(s.header, ")."))] : ((i.categoryNames.length > 0 || o.length > 0) && t.push(A8(i, a, o)), [2, Poe(Dd.CifFile(t))]);
      }
    });
  });
}
function woe(e) {
  var r = this;
  return vG.Task.create("Parse CIF", function(t) {
    return (0, l0.__awaiter)(r, void 0, void 0, function() {
      return (0, l0.__generator)(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, Moe(e, t)];
          case 1:
            return [2, n.sent()];
        }
      });
    });
  });
}
wC.parseCifText = woe;
var EC = {}, DC = {};
Object.defineProperty(DC, "__esModule", { value: !0 });
DC.Field = void 0;
var dm = mr(), x8 = cy, T8 = Qa;
function Eoe(e) {
  var r = e.mask ? (0, x8.decode)(e.mask) : void 0, t = (0, x8.decode)(e.data), n = dm.ColumnHelpers.isTypedArray(t), a = n ? r ? function(u) {
    return r[u] === 0 ? "" + t[u] : "";
  } : function(u) {
    return "" + t[u];
  } : r ? function(u) {
    return r[u] === 0 ? t[u] : "";
  } : function(u) {
    return t[u];
  }, i = n ? function(u) {
    return t[u];
  } : function(u) {
    var l = t[u];
    return (0, T8.parseInt)(l, 0, l.length);
  }, o = n ? function(u) {
    return t[u];
  } : function(u) {
    var l = t[u];
    return (0, T8.parseFloat)(l, 0, l.length);
  }, c = r ? function(u) {
    return r[u];
  } : function(u) {
    return 0;
  }, s = t.length;
  return {
    __array: t,
    binaryEncoding: e.data.encoding,
    isDefined: !0,
    rowCount: s,
    str: a,
    int: i,
    float: o,
    valueKind: c,
    areValuesEqual: function(u, l) {
      return t[u] === t[l];
    },
    toStringArray: function(u) {
      return dm.ColumnHelpers.createAndFillArray(s, a, u);
    },
    toIntArray: n ? function(u) {
      return dm.ColumnHelpers.typedArrayWindow(t, u);
    } : function(u) {
      return dm.ColumnHelpers.createAndFillArray(s, i, u);
    },
    toFloatArray: n ? function(u) {
      return dm.ColumnHelpers.typedArrayWindow(t, u);
    } : function(u) {
      return dm.ColumnHelpers.createAndFillArray(s, o, u);
    }
  };
}
DC.Field = Eoe;
var IC = {};
Object.defineProperty(IC, "__esModule", { value: !0 });
IC.decodeMsgPack = void 0;
var Doe = Js;
function Ioe(e) {
  return Pb({ buffer: e, offset: 0, dataView: new DataView(e.buffer) });
}
IC.decodeMsgPack = Ioe;
function s5(e, r) {
  for (var t = {}, n = 0; n < r; n++) {
    var a = Pb(e);
    t[a] = Pb(e);
  }
  return t;
}
function l5(e, r) {
  for (var t = new Uint8Array(r), n = e.offset, a = 0; a < r; a++)
    t[a] = e.buffer[a + n];
  return e.offset += r, t;
}
function s2(e, r) {
  var t = (0, Doe.utf8Read)(e.buffer, e.offset, r);
  return e.offset += r, t;
}
function c5(e, r) {
  for (var t = new Array(r), n = 0; n < r; n++)
    t[n] = Pb(e);
  return t;
}
function Pb(e) {
  var r = e.buffer[e.offset], t, n;
  if (!(r & 128))
    return e.offset++, r;
  if ((r & 240) === 128)
    return n = r & 15, e.offset++, s5(e, n);
  if ((r & 240) === 144)
    return n = r & 15, e.offset++, c5(e, n);
  if ((r & 224) === 160)
    return n = r & 31, e.offset++, s2(e, n);
  if ((r & 224) === 224)
    return t = e.dataView.getInt8(e.offset), e.offset++, t;
  switch (r) {
    case 192:
      return e.offset++, null;
    case 194:
      return e.offset++, !1;
    case 195:
      return e.offset++, !0;
    case 196:
      return n = e.dataView.getUint8(e.offset + 1), e.offset += 2, l5(e, n);
    case 197:
      return n = e.dataView.getUint16(e.offset + 1), e.offset += 3, l5(e, n);
    case 198:
      return n = e.dataView.getUint32(e.offset + 1), e.offset += 5, l5(e, n);
    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 n = e.dataView.getUint8(e.offset + 1), e.offset += 2, s2(e, n);
    case 218:
      return n = e.dataView.getUint16(e.offset + 1), e.offset += 3, s2(e, n);
    case 219:
      return n = e.dataView.getUint32(e.offset + 1), e.offset += 5, s2(e, n);
    case 220:
      return n = e.dataView.getUint16(e.offset + 1), e.offset += 3, c5(e, n);
    case 221:
      return n = e.dataView.getUint32(e.offset + 1), e.offset += 5, c5(e, n);
    case 222:
      return n = e.dataView.getUint16(e.offset + 1), e.offset += 3, s5(e, n);
    case 223:
      return n = e.dataView.getUint32(e.offset + 1), e.offset += 5, s5(e, n);
  }
  throw new Error("Unknown type 0x" + r.toString(16));
}
Object.defineProperty(EC, "__esModule", { value: !0 });
EC.parseCifBinary = void 0;
var AM = Te, P8 = (0, AM.__importStar)(oy), Boe = DC, d5 = Mi, Noe = IC, Voe = Kr;
function Roe(e, r) {
  for (var t = 0; t < 2; t++)
    if (e[t] > r[t])
      return !1;
  return !0;
}
function Ooe(e) {
  for (var r = /* @__PURE__ */ Object.create(null), t = /* @__PURE__ */ Object.create(null), n = 0, a = e.columns; n < a.length; n++) {
    var i = a[n];
    r[i.name] = i;
  }
  return {
    rowCount: e.rowCount,
    name: e.name.substr(1),
    fieldNames: e.columns.map(function(o) {
      return o.name;
    }),
    getField: function(o) {
      var c = r[o];
      if (c)
        return t[o] || (t[o] = (0, Boe.Field)(c)), t[o];
    }
  };
}
function Foe(e) {
  var r = this;
  return Voe.Task.create("Parse BinaryCIF", function(t) {
    return (0, AM.__awaiter)(r, void 0, void 0, function() {
      var n, a, i;
      return (0, AM.__generator)(this, function(o) {
        n = [0, 3];
        try {
          return a = (0, Noe.decodeMsgPack)(e), Roe(n, a.version.match(/(\d)\.(\d)\.\d/).slice(1).map(function(c) {
            return +c;
          })) ? (i = P8.CifFile(a.dataBlocks.map(function(c) {
            for (var s = /* @__PURE__ */ Object.create(null), u = 0, l = c.categories; u < l.length; u++) {
              var f = l[u];
              s[f.name.substr(1)] = Ooe(f);
            }
            return P8.CifBlock(c.categories.map(function(d) {
              return d.name.substr(1);
            }), s, c.header);
          })), [2, d5.ReaderResult.success(i)]) : [2, d5.ReaderResult.error("Unsupported format version. Current ".concat(a.version, ", required ").concat(n.join("."), "."))];
        } catch (c) {
          return [2, d5.ReaderResult.error("" + c)];
        }
        return [
          2
          /*return*/
        ];
      });
    });
  });
}
EC.parseCifBinary = Foe;
var BC = {};
Object.defineProperty(BC, "__esModule", { value: !0 });
BC.CCD_Schema = void 0;
var Loe = mr(), Tp = Loe.Column.Schema, qr = Tp.str, koe = Tp.float, M8 = Tp.List, No = Tp.Aliased, Rh = Tp.int, fm = Tp.coord;
BC.CCD_Schema = {
  /**
   * Data items in the CHEM_COMP category give details about each
   * of the chemical components from which the relevant chemical
   * structures can be constructed, such as name, mass or charge.
   *
   * The related categories CHEM_COMP_ATOM, CHEM_COMP_BOND,
   * CHEM_COMP_ANGLE etc. describe the detailed geometry of these
   * chemical components.
   */
  chem_comp: {
    /**
     * The formula for the chemical component. Formulae are written
     * according to the following rules:
     *
     * (1) Only recognized element symbols may be used.
     *
     * (2) Each element symbol is followed by a 'count' number. A count
     * of '1' may be omitted.
     *
     * (3) A space or parenthesis must separate each cluster of
     * (element symbol + count), but in general parentheses are
     * not used.
     *
     * (4) The order of elements depends on whether carbon is
     * present or not. If carbon is present, the order should be:
     * C, then H, then the other elements in alphabetical order
     * of their symbol. If carbon is not present, the elements
     * are listed purely in alphabetic order of their symbol. This
     * is the 'Hill' system used by Chemical Abstracts.
     */
    formula: qr,
    /**
     * Formula mass in daltons of the chemical component.
     */
    formula_weight: koe,
    /**
     * The value of _chem_comp.id must uniquely identify each item in
     * the CHEM_COMP list.
     *
     * For protein polymer entities, this is the three-letter code for
     * the amino acid.
     *
     * For nucleic acid polymer entities, this is the one-letter code
     * for the base.
     */
    id: qr,
    /**
     * The identifier for the parent component of the nonstandard
     * component. May be be a comma separated list if this component
     * is derived from multiple components.
     *
     * Items in this indirectly point to _chem_comp.id in
     * the CHEM_COMP category.
     */
    mon_nstd_parent_comp_id: M8(",", function(e) {
      return e;
    }),
    /**
     * The full name of the component.
     */
    name: qr,
    /**
     * For standard polymer components, the one-letter code for
     * the component.   For non-standard polymer components, the
     * one-letter code for parent component if this exists;
     * otherwise, the one-letter code should be given as 'X'.
     *
     * Components that derived from multiple parents components
     * are described by a sequence of one-letter-codes.
     */
    one_letter_code: qr,
    /**
     * For standard polymer components, the common three-letter code for
     * the component.   Non-standard polymer components and non-polymer
     * components are also assigned three-letter-codes.
     *
     * For ambiguous polymer components three-letter code should
     * be given as 'UNK'.  Ambiguous ions are assigned the code 'UNX'.
     * Ambiguous non-polymer components are assigned the code 'UNL'.
     */
    three_letter_code: qr,
    /**
     * For standard polymer components, the type of the monomer.
     * Note that monomers that will form polymers are of three types:
     * linking monomers, monomers with some type of N-terminal (or 5')
     * cap and monomers with some type of C-terminal (or 3') cap.
     */
    type: No(qr),
    /**
     * Synonym list for the component.
     */
    pdbx_synonyms: M8(";", function(e) {
      return e;
    }),
    /**
     * A preliminary classification used by PDB.
     */
    pdbx_type: qr,
    /**
     * A preliminary classification used by PDB to indicate
     * that the chemistry of this component while described
     * as clearly as possible is still ambiguous.  Software
     * tools may not be able to process this component
     * definition.
     */
    pdbx_ambiguous_flag: qr,
    /**
     * Identifies the _chem_comp.id of the component that
     * has replaced this component.
     */
    pdbx_replaced_by: qr,
    /**
     * Identifies the _chem_comp.id's of the components
     * which have been replaced by this component.
     * Multiple id codes should be separated by commas.
     */
    pdbx_replaces: qr,
    /**
     * The net integer charge assigned to this component. This is the
     * formal charge assignment normally found in chemical diagrams.
     */
    pdbx_formal_charge: Rh,
    /**
     * This data item provides additional details about the model coordinates
     * in the component definition.
     */
    pdbx_model_coordinates_details: qr,
    /**
     * This data item identifies the PDB database code from which the heavy
     * atom model coordinates were obtained.
     */
    pdbx_model_coordinates_db_code: qr,
    /**
     * This data item identifies the source of the ideal coordinates in the
     * component definition.
     */
    pdbx_ideal_coordinates_details: qr,
    /**
     * This data item identifies if ideal coordinates are missing in this definition.
     */
    pdbx_ideal_coordinates_missing_flag: No(qr),
    /**
     * This data item identifies if model coordinates are missing in this definition.
     */
    pdbx_model_coordinates_missing_flag: No(qr),
    /**
     * Date component was added to database.
     */
    pdbx_initial_date: qr,
    /**
     * Date component was last modified.
     */
    pdbx_modified_date: qr,
    /**
     * This data item holds the current release status for the component.
     */
    pdbx_release_status: No(qr),
    /**
     * This data item identifies the deposition site that processed
     * this chemical component defintion.
     */
    pdbx_processing_site: No(qr)
  },
  /**
   * Data items in the CHEM_COMP_ATOM category record details about
   * the atoms in a chemical component. Specifying the atomic
   * coordinates for the components in this category is an
   * alternative to specifying the structure of the component
   * via bonds, angles, planes etc. in the appropriate
   * CHEM_COMP subcategories.
   */
  chem_comp_atom: {
    /**
     * An alternative identifier for the atom. This data item would be
     * used in cases where alternative nomenclatures exist for labelling
     * atoms in a group.
     */
    alt_atom_id: qr,
    /**
     * The value of _chem_comp_atom.atom_id must uniquely identify
     * each atom in each monomer in the CHEM_COMP_ATOM list.
     *
     * The atom identifiers need not be unique over all atoms in the
     * data block; they need only be unique for each atom in a
     * component.
     *
     * Note that this item need not be a number; it can be any unique
     * identifier.
     */
    atom_id: qr,
    /**
     * The net integer charge assigned to this atom. This is the
     * formal charge assignment normally found in chemical diagrams.
     */
    charge: Rh,
    /**
     * The x component of the coordinates for this atom in this
     * component specified as orthogonal angstroms. The choice of
     * reference axis frame for the coordinates is arbitrary.
     *
     * The set of coordinates input for the entity here is intended to
     * correspond to the atomic model used to generate restraints for
     * structure refinement, not to atom sites in the ATOM_SITE
     * list.
     */
    model_Cartn_x: fm,
    /**
     * The y component of the coordinates for this atom in this
     * component specified as orthogonal angstroms. The choice of
     * reference axis frame for the coordinates is arbitrary.
     *
     * The set of coordinates input for the entity here is intended to
     * correspond to the atomic model used to generate restraints for
     * structure refinement, not to atom sites in the ATOM_SITE
     * list.
     */
    model_Cartn_y: fm,
    /**
     * The z component of the coordinates for this atom in this
     * component specified as orthogonal angstroms. The choice of
     * reference axis frame for the coordinates is arbitrary.
     *
     * The set of coordinates input for the entity here is intended to
     * correspond to the atomic model used to generate restraints for
     * structure refinement, not to atom sites in the ATOM_SITE
     * list.
     */
    model_Cartn_z: fm,
    /**
     * This data item is a pointer to _chem_comp.id in the CHEM_COMP
     * category.
     */
    comp_id: qr,
    /**
     * The code used to identify the atom species representing
     * this atom type. Normally this code is the element
     * symbol.
     */
    type_symbol: qr,
    /**
     * Atom name alignment offset in PDB atom field.
     */
    pdbx_align: Rh,
    /**
     * Ordinal index for the component atom list.
     */
    pdbx_ordinal: Rh,
    /**
     * An alternative x component of the coordinates for this atom in this
     * component specified as orthogonal angstroms.
     */
    pdbx_model_Cartn_x_ideal: fm,
    /**
     * An alternative y component of the coordinates for this atom in this
     * component specified as orthogonal angstroms.
     */
    pdbx_model_Cartn_y_ideal: fm,
    /**
     * An alternative z component of the coordinates for this atom in this
     * component specified as orthogonal angstroms.
     */
    pdbx_model_Cartn_z_ideal: fm,
    /**
     * The chiral configuration of the atom that is a chiral center.
     */
    pdbx_stereo_config: No(qr),
    /**
     * A flag indicating an aromatic atom.
     */
    pdbx_aromatic_flag: No(qr),
    /**
     * A flag indicating a leaving atom.
     */
    pdbx_leaving_atom_flag: No(qr)
  },
  /**
   * Data items in the CHEM_COMP_BOND category record details about
   * the bonds between atoms in a chemical component. Target values
   * may be specified as bond orders, as a distance between the two
   * atoms, or both.
   */
  chem_comp_bond: {
    /**
     * The ID of the first of the two atoms that define the bond.
     *
     * This data item is a pointer to _chem_comp_atom.atom_id in the
     * CHEM_COMP_ATOM category.
     */
    atom_id_1: qr,
    /**
     * The ID of the second of the two atoms that define the bond.
     *
     * This data item is a pointer to _chem_comp_atom.atom_id in the
     * CHEM_COMP_ATOM category.
     */
    atom_id_2: qr,
    /**
     * This data item is a pointer to _chem_comp.id in the CHEM_COMP
     * category.
     */
    comp_id: qr,
    /**
     * The value that should be taken as the target for the chemical
     * bond associated with the specified atoms, expressed as a bond
     * order.
     */
    value_order: No(qr),
    /**
     * Ordinal index for the component bond list.
     */
    pdbx_ordinal: Rh,
    /**
     * Stereochemical configuration across a double bond.
     */
    pdbx_stereo_config: No(qr),
    /**
     * A flag indicating an aromatic bond.
     */
    pdbx_aromatic_flag: No(qr)
  },
  /**
   * Data items in the CHEM_COMP_DESCRIPTOR category provide
   * string descriptors of component chemical structure.
   */
  pdbx_chem_comp_descriptor: {
    /**
     * This data item is a pointer to _chem_comp.id in the CHEM_COMP
     * category.
     */
    comp_id: qr,
    /**
     * This data item contains the descriptor value for this
     * component.
     */
    descriptor: qr,
    /**
     * This data item contains the descriptor type.
     */
    type: No(qr),
    /**
     * This data item contains the name of the program
     * or library used to compute the descriptor.
     */
    program: qr,
    /**
     * This data item contains the version of the program
     * or library used to compute the descriptor.
     */
    program_version: qr
  },
  /**
   * Data items in the CHEM_COMP_IDENTIFIER category provide
   * identifiers for chemical components.
   */
  pdbx_chem_comp_identifier: {
    /**
     * This data item is a pointer to _chem_comp.id in the CHEM_COMP
     * category.
     */
    comp_id: qr,
    /**
     * This data item contains the identifier value for this
     * component.
     */
    identifier: qr,
    /**
     * This data item contains the identifier type.
     */
    type: No(qr),
    /**
     * This data item contains the name of the program
     * or library used to compute the identifier.
     */
    program: qr,
    /**
     * This data item contains the version of the program
     * or library used to compute the identifier.
     */
    program_version: qr
  }
};
var NC = {};
Object.defineProperty(NC, "__esModule", { value: !0 });
NC.BIRD_Schema = void 0;
var Uoe = mr(), VC = Uoe.Column.Schema, ir = VC.str, zoe = VC.float, Bi = VC.Aliased, ou = VC.int;
NC.BIRD_Schema = {
  /**
   * Data items in the PDBX_REFERENCE_MOLECULE category record
   * reference information about small polymer molecules.
   */
  pdbx_reference_molecule: {
    /**
     * The value of _pdbx_reference_molecule.prd_id is the unique identifier
     * for the reference molecule in this family.
     *
     * By convention this ID uniquely identifies the reference molecule in
     * in the PDB reference dictionary.
     *
     * The ID has the template form PRD_dddddd (e.g. PRD_000001)
     */
    prd_id: ir,
    /**
     * Formula mass in daltons of the entity.
     */
    formula_weight: zoe,
    /**
     * The formula for the reference entity. Formulae are written
     * according to the rules:
     *
     * 1. Only recognised element symbols may be used.
     *
     * 2. Each element symbol is followed by a 'count' number. A count
     * of '1' may be omitted.
     *
     * 3. A space or parenthesis must separate each element symbol and
     * its count, but in general parentheses are not used.
     *
     * 4. The order of elements depends on whether or not carbon is
     * present. If carbon is present, the order should be: C, then
     * H, then the other elements in alphabetical order of their
     * symbol. If carbon is not present, the elements are listed
     * purely in alphabetic order of their symbol. This is the
     * 'Hill' system used by Chemical Abstracts.
     */
    formula: ir,
    /**
     * Defines the structural classification of the entity.
     */
    type: Bi(ir),
    /**
     * Evidence for the assignment of _pdbx_reference_molecule.type
     */
    type_evidence_code: ir,
    /**
     * Broadly defines the function of the entity.
     */
    class: Bi(ir),
    /**
     * Evidence for the assignment of _pdbx_reference_molecule.class
     */
    class_evidence_code: ir,
    /**
     * A name of the entity.
     */
    name: ir,
    /**
     * Defines how this entity is represented in PDB data files.
     */
    represent_as: Bi(ir),
    /**
     * For entities represented as single molecules, the identifier
     * corresponding to the chemical definition for the molecule.
     */
    chem_comp_id: ir,
    /**
     * Special details about this molecule.
     */
    compound_details: ir,
    /**
     * Description of this molecule.
     */
    description: ir,
    /**
     * The PDB accession code for the entry containing a representative example of this molecule.
     */
    representative_PDB_id_code: ir,
    /**
     * Defines the current PDB release status for this molecule definition.
     */
    release_status: Bi(ir),
    /**
     * Assigns the identifier for the reference molecule which have been replaced
     * by this reference molecule.
     * Multiple molecule identifier codes should be separated by commas.
     */
    replaces: ir,
    /**
     * Assigns the identifier of the reference molecule that has replaced this molecule.
     */
    replaced_by: ir
  },
  /**
   * Data items in the PDBX_REFERENCE_ENTITY_LIST category record
   * the list of entities within each reference molecule.
   */
  pdbx_reference_entity_list: {
    /**
     * The value of _pdbx_reference_entity_list.prd_id is a reference
     * _pdbx_reference_molecule.prd_id in the PDBX_REFERENCE_MOLECULE category.
     */
    prd_id: ir,
    /**
     * The value of _pdbx_reference_entity_list.ref_entity_id is a unique identifier
     * the a constituent entity within this reference molecule.
     */
    ref_entity_id: ir,
    /**
     * Defines the polymer characteristic of the entity.
     */
    type: Bi(ir),
    /**
     * Additional details about this entity.
     */
    details: ir,
    /**
     * The component number of this entity within the molecule.
     */
    component_id: ou
  },
  /**
   * Data items in the PDBX_REFERENCE_ENTITY_NONPOLY category record
   * the list of entities within each reference molecule.
   */
  pdbx_reference_entity_nonpoly: {
    /**
     * The value of _pdbx_reference_entity_nonpoly.prd_id is a reference
     * _pdbx_reference_entity_list.prd_id in the PDBX_REFERENCE_ENTITY_LIST category.
     */
    prd_id: ir,
    /**
     * The value of _pdbx_reference_entity_nonpoly.ref_entity_id is a reference
     * to _pdbx_reference_entity_list.ref_entity_id in PDBX_REFERENCE_ENTITY_LIST category.
     */
    ref_entity_id: ir,
    /**
     * A name of the non-polymer entity.
     */
    name: ir,
    /**
     * For non-polymer entities, the identifier corresponding
     * to the chemical definition for the molecule.
     */
    chem_comp_id: ir
  },
  /**
   * Data items in the PDBX_REFERENCE_ENTITY_LINK category give details about
   * the linkages between entities within reference molecules.
   */
  pdbx_reference_entity_link: {
    /**
     * The value of _pdbx_reference_entity_link.link_id uniquely identifies
     * linkages between entities with a molecule.
     */
    link_id: ou,
    /**
     * The value of _pdbx_reference_entity_link.prd_id is a reference
     * _pdbx_reference_entity_list.prd_id in the PDBX_REFERENCE_ENTITY_LIST category.
     */
    prd_id: ir,
    /**
     * A description of special aspects of a linkage between
     * chemical components in the structure.
     */
    details: ir,
    /**
     * The reference entity id of the first of the two entities joined by the
     * linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_list.ref_entity_id
     * in the PDBX_REFERENCE_ENTITY_LIST category.
     */
    ref_entity_id_1: ir,
    /**
     * The reference entity id of the second of the two entities joined by the
     * linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_list.ref_entity_id
     * in the PDBX_REFERENCE_ENTITY_LIST category.
     */
    ref_entity_id_2: ir,
    /**
     * For a polymer entity, the sequence number in the first of
     * the two entities containing the linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_poly_seq.num
     * in the PDBX_REFERENCE_ENTITY_POLY_SEQ category.
     */
    entity_seq_num_1: ou,
    /**
     * For a polymer entity, the sequence number in the second of
     * the two entities containing the linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_poly_seq.num
     * in the PDBX_REFERENCE_ENTITY_POLY_SEQ category.
     */
    entity_seq_num_2: ou,
    /**
     * The component identifier in the first of the two entities containing the linkage.
     *
     * For polymer entities, this data item is a pointer to _pdbx_reference_entity_poly_seq.mon_id
     * in the PDBX_REFERENCE_ENTITY_POLY_SEQ category.
     *
     * For non-polymer entities, this data item is a pointer to
     * _pdbx_reference_entity_nonpoly.chem_comp_id in the
     * PDBX_REFERENCE_ENTITY_NONPOLY category.
     */
    comp_id_1: ir,
    /**
     * The component identifier in the second of the two entities containing the linkage.
     *
     * For polymer entities, this data item is a pointer to _pdbx_reference_entity_poly_seq.mon_id
     * in the PDBX_REFERENCE_ENTITY_POLY_SEQ category.
     *
     * For non-polymer entities, this data item is a pointer to
     * _pdbx_reference_entity_nonpoly.chem_comp_id in the
     * PDBX_REFERENCE_ENTITY_NONPOLY category.
     */
    comp_id_2: ir,
    /**
     * The atom identifier/name in the first of the two entities containing the linkage.
     */
    atom_id_1: ir,
    /**
     * The atom identifier/name in the second of the two entities containing the linkage.
     */
    atom_id_2: ir,
    /**
     * The bond order target for the chemical linkage.
     */
    value_order: Bi(ir),
    /**
     * The entity component identifier for the first of two entities containing the linkage.
     */
    component_1: ou,
    /**
     * The entity component identifier for the second of two entities containing the linkage.
     */
    component_2: ou,
    /**
     * A code indicating the entity types involved in the linkage.
     */
    link_class: Bi(ir)
  },
  /**
   * Data items in the PDBX_REFERENCE_ENTITY_POLY_LINK category give details about
   * polymer linkages including both standard and non-standard linkages between
   * polymer componnents.
   */
  pdbx_reference_entity_poly_link: {
    /**
     * The value of _pdbx_reference_entity_poly_link.link_id uniquely identifies
     * a linkage within a polymer entity.
     */
    link_id: ou,
    /**
     * The value of _pdbx_reference_entity_poly_link.prd_id is a reference
     * _pdbx_reference_entity_list.prd_id in the PDBX_REFERENCE_ENTITY_POLY category.
     */
    prd_id: ir,
    /**
     * The reference entity id of the polymer entity containing the linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_poly.ref_entity_id
     * in the PDBX_REFERENCE_ENTITY_POLY category.
     */
    ref_entity_id: ir,
    /**
     * The entity component identifier entity containing the linkage.
     */
    component_id: ou,
    /**
     * For a polymer entity, the sequence number in the first of
     * the two components making the linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_poly_seq.num
     * in the PDBX_REFERENCE_ENTITY_POLY_SEQ category.
     */
    entity_seq_num_1: ou,
    /**
     * For a polymer entity, the sequence number in the second of
     * the two components making the linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_poly_seq.num
     * in the PDBX_REFERENCE_ENTITY_POLY_SEQ category.
     */
    entity_seq_num_2: ou,
    /**
     * The component identifier in the first of the two components making the
     * linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_poly_seq.mon_id
     * in the PDBX_REFERENCE_ENTITY_POLY_SEQ category.
     */
    comp_id_1: ir,
    /**
     * The component identifier in the second of the two components making the
     * linkage.
     *
     * This data item is a pointer to _pdbx_reference_entity_poly_seq.mon_id
     * in the PDBX_REFERENCE_ENTITY_POLY_SEQ category.
     */
    comp_id_2: ir,
    /**
     * The atom identifier/name in the first of the two components making
     * the linkage.
     */
    atom_id_1: ir,
    /**
     * The atom identifier/name in the second of the two components making
     * the linkage.
     */
    atom_id_2: ir,
    /**
     * The bond order target for the non-standard linkage.
     */
    value_order: Bi(ir)
  },
  /**
   * Data items in the PDBX_REFERENCE_ENTITY_POLY category record details about
   * the polymer, such as the type of the polymer, the number of
   * monomers and whether it has nonstandard features.
   */
  pdbx_reference_entity_poly: {
    /**
     * The value of _pdbx_reference_entity_poly.prd_id is a reference
     * _pdbx_reference_entity_list.prd_id in the  PDBX_REFERENCE_ENTITY_LIST category.
     */
    prd_id: ir,
    /**
     * The value of _pdbx_reference_entity_poly.ref_entity_id is a reference
     * to _pdbx_reference_entity_list.ref_entity_id in PDBX_REFERENCE_ENTITY_LIST category.
     */
    ref_entity_id: ir,
    /**
     * The type of the polymer.
     */
    type: Bi(ir),
    /**
     * The database code for this source information
     */
    db_code: ir,
    /**
     * The database name for this source information
     */
    db_name: ir
  },
  /**
   * Data items in the PDBX_REFERENCE_ENTITY_POLY_SEQ category specify the sequence
   * of monomers in a polymer.
   */
  pdbx_reference_entity_poly_seq: {
    /**
     * The value of _pdbx_reference_entity_poly_seq.prd_id is a reference
     * _pdbx_reference_entity_poly.prd_id in the  PDBX_REFERENCE_ENTITY_POLY category.
     */
    prd_id: ir,
    /**
     * The value of _pdbx_reference_entity_poly_seq.ref_entity_id is a reference
     * to _pdbx_reference_entity_poly.ref_entity_id in PDBX_REFERENCE_ENTITY_POLY category.
     */
    ref_entity_id: ir,
    /**
     * This data item is the chemical component identifier of monomer.
     */
    mon_id: ir,
    /**
     * This data item is the chemical component identifier for the parent component corresponding to this monomer.
     */
    parent_mon_id: ir,
    /**
     * The value of _pdbx_reference_entity_poly_seq.num must uniquely and sequentially
     * identify a record in the PDBX_REFERENCE_ENTITY_POLY_SEQ list.
     *
     * This value is conforms to author numbering conventions and does not map directly
     * to the numbering conventions used for _entity_poly_seq.num.
     */
    num: ou,
    /**
     * A flag to indicate that this monomer is observed in the instance example.
     */
    observed: Bi(ir),
    /**
     * A flag to indicate that sequence heterogeneity at this monomer position.
     */
    hetero: Bi(ir)
  },
  /**
   * Additional features associated with the reference entity.
   */
  pdbx_reference_entity_sequence: {
    /**
     * The value of _pdbx_reference_entity_sequence.prd_id is a reference
     * _pdbx_reference_entity_list.prd_id in the  PDBX_REFERENCE_ENTITY_LIST category.
     */
    prd_id: ir,
    /**
     * The value of _pdbx_reference_entity_sequence.ref_entity_id is a reference
     * to _pdbx_reference_entity_list.ref_entity_id in PDBX_REFERENCE_ENTITY_LIST category.
     */
    ref_entity_id: ir,
    /**
     * The monomer type for the sequence.
     */
    type: Bi(ir),
    /**
     * A flag to indicate a non-ribosomal entity.
     */
    NRP_flag: Bi(ir),
    /**
     * The one-letter-code sequence for this entity.  Non-standard monomers are represented as 'X'.
     */
    one_letter_codes: ir
  },
  /**
   * Data items in the PDBX_REFERENCE_ENTITY_SRC_NAT category record
   * details of the source from which the entity was obtained.
   */
  pdbx_reference_entity_src_nat: {
    /**
     * The value of _pdbx_reference_entity_src_nat.prd_id is a reference
     * _pdbx_reference_entity_list.prd_id in the  PDBX_REFERENCE_ENTITY_LIST category.
     */
    prd_id: ir,
    /**
     * The value of _pdbx_reference_entity_src_nat.ref_entity_id is a reference
     * to _pdbx_reference_entity_list.ref_entity_id in PDBX_REFERENCE_ENTITY_LIST category.
     */
    ref_entity_id: ir,
    /**
     * The value of _pdbx_reference_entity_src_nat.ordinal distinguishes
     * source details for this entity.
     */
    ordinal: ou,
    /**
     * The scientific name of the organism from which the entity was isolated.
     */
    organism_scientific: ir,
    /**
     * The NCBI TaxId of the organism from which the entity was isolated.
     */
    taxid: ir,
    /**
     * The database code for this source information
     */
    db_code: ir,
    /**
     * The database name for this source information
     */
    db_name: ir
  },
  /**
   * Data items in the PDBX_PRD_AUDIT category records
   * the status and tracking information for this molecule.
   */
  pdbx_prd_audit: {
    /**
     * This data item is a pointer to _pdbx_reference_molecule.prd_id in the
     * pdbx_reference_molecule category.
     */
    prd_id: ir,
    /**
     * The date associated with this audit record.
     */
    date: ir,
    /**
     * An identifier for the wwPDB site creating or modifying the molecule.
     */
    processing_site: Bi(ir),
    /**
     * The action associated with this audit record.
     */
    action_type: Bi(ir)
  }
};
var RC = {};
Object.defineProperty(RC, "__esModule", { value: !0 });
RC.dic_Schema = void 0;
var Goe = mr(), yG = Goe.Column.Schema, Fn = yG.str, qoe = yG.float, Hoe = {
  id: Fn,
  description: Fn
}, joe = {
  title: Fn,
  datablock_id: Fn,
  version: Fn
}, $oe = {
  version: Fn,
  update: Fn,
  revision: Fn
}, Koe = {
  id: Fn,
  description: Fn
}, Woe = {
  id: Fn,
  parent_id: Fn,
  description: Fn
}, Xoe = {
  code: Fn,
  primitive_code: Fn,
  construct: Fn,
  detail: Fn
}, Yoe = {
  code: Fn,
  detail: Fn
}, Qoe = {
  from_code: Fn,
  to_code: Fn,
  operator: Fn,
  factor: qoe
};
RC.dic_Schema = {
  datablock: Hoe,
  dictionary: joe,
  dictionary_history: $oe,
  sub_category: Koe,
  category_group_list: Woe,
  item_type_list: Xoe,
  item_units_list: Yoe,
  item_units_conversion: Qoe
};
var Ev = {};
Object.defineProperty(Ev, "__esModule", { value: !0 });
Ev.DensityServer_Data_Schema = Ev.DensityServer_Header_Schema = void 0;
var Zoe = mr(), fy = Zoe.Column.Schema, Fs = fy.str, l2 = fy.int, Ml = fy.float, c2 = fy.Aliased, Qc = fy.Vector;
Ev.DensityServer_Header_Schema = {
  density_server_result: {
    server_version: Fs,
    datetime_utc: Fs,
    guid: Fs,
    is_empty: c2(Fs),
    has_error: c2(Fs),
    error: Fs,
    query_source_id: Fs,
    query_type: c2(Fs),
    query_box_type: c2(Fs),
    query_box_a: Qc(3),
    query_box_b: Qc(3)
  }
};
Ev.DensityServer_Data_Schema = {
  volume_data_3d_info: {
    name: Fs,
    // zero indexed axis order of the data
    axis_order: Qc(3, l2),
    // Origin in fractional coords
    origin: Qc(3),
    // Dimension in fractional coords
    dimensions: Qc(3),
    sample_rate: l2,
    // number of samples along each axis
    sample_count: Qc(3, l2),
    spacegroup_number: l2,
    spacegroup_cell_size: Qc(3),
    // angles in degrees
    spacegroup_cell_angles: Qc(3),
    mean_source: Ml,
    mean_sampled: Ml,
    sigma_source: Ml,
    sigma_sampled: Ml,
    min_source: Ml,
    min_sampled: Ml,
    max_source: Ml,
    max_sampled: Ml
  },
  volume_data_3d: {
    values: Ml
  }
};
var Dv = {};
Object.defineProperty(Dv, "__esModule", { value: !0 });
Dv.CifCore_Aliases = Dv.CifCore_Schema = void 0;
var Joe = mr(), OC = Joe.Column.Schema, ln = OC.float, f5 = OC.int, _t = OC.str, eue = OC.Matrix;
Dv.CifCore_Schema = {
  /**
   * The CATEGORY of data items used to describe the parameters of
   * the crystal unit cell and their measurement.
   */
  cell: {
    /**
     * The angle between the bounding cell axes.
     */
    angle_alpha: ln,
    /**
     * The angle between the bounding cell axes.
     */
    angle_beta: ln,
    /**
     * The angle between the bounding cell axes.
     */
    angle_gamma: ln,
    /**
     * The number of the formula units in the unit cell as specified
     * by _chemical_formula.structural, _chemical_formula.moiety or
     * _chemical_formula.sum.
     */
    formula_units_z: f5,
    /**
     * The length of each cell axis.
     */
    length_a: ln,
    /**
     * The length of each cell axis.
     */
    length_b: ln,
    /**
     * The length of each cell axis.
     */
    length_c: ln,
    /**
     * Volume of the crystal unit cell.
     */
    volume: ln
  },
  /**
   * The CATEGORY of data items which describe the composition and
   * chemical properties of the compound under study. The formula data
   * items must be consistent with the density, unit-cell and Z values.
   */
  chemical: {
    /**
     * The temperature at which a crystalline solid changes to a liquid.
     */
    melting_point: ln,
    /**
     * Trivial name by which the compound is commonly known.
     */
    name_common: _t,
    /**
     * IUPAC or Chemical Abstracts full name of compound.
     */
    name_systematic: _t
  },
  /**
   * The CATEGORY of data items which specify the composition and chemical
   * properties of the compound. The formula data items must agree
   * with those that specify the density, unit-cell and Z values.
   *
   * The following rules apply to the construction of the data items
   * _chemical_formula.analytical, *.structural and *.sum. For the
   * data item *.moiety the formula construction is broken up into
   * residues or moieties, i.e. groups of atoms that form a molecular
   * unit or molecular ion. The  rules given below apply within each
   * moiety but different requirements apply to the way that moieties
   * are connected (see _chemical_formula.moiety).
   *
   * 1. Only recognized element symbols may be used.
   *
   * 2. Each element symbol is followed by a 'count' number. A count of
   * '1' may be omitted.
   *
   * 3. A space or parenthesis must separate each cluster of (element
   * symbol + count).
   *
   * 4. Where a group of elements is enclosed in parentheses, the
   * multiplier for the group must follow the closing parentheses.
   * That is, all element and group multipliers are assumed to be
   * printed as subscripted numbers. [An exception to this rule
   * exists for *.moiety formulae where pre- and post-multipliers
   * are permitted for molecular units].
   *
   * 5. Unless the elements are ordered in a manner that corresponds to
   * their chemical structure, as in _chemical_formula.structural,
   * the order of the elements within any group or moiety
   * depends on whether or not carbon is present. If carbon is
   * present, the order should be: C, then H, then the other
   * elements in alphabetical order of their symbol. If carbon is
   * not present, the elements are listed purely in alphabetic order
   * of their symbol. This is the 'Hill' system used by Chemical
   * Abstracts. This ordering is used in _chemical_formula.moiety
   * and _chemical_formula.sum.
   *
   * _chemical_formula.IUPAC      '[Mo (C O)4 (C18 H33 P)2]'
   * _chemical_formula.moiety     'C40 H66 Mo O4 P2'
   * _chemical_formula.structural '((C O)4 (P (C6 H11)3)2)Mo'
   * _chemical_formula.sum         'C40 H66 Mo O4 P2'
   * _chemical_formula.weight      768.81
   */
  chemical_formula: {
    /**
     * Formula with each discrete bonded residue or ion shown as a
     * separate moiety. See above CHEMICAL_FORMULA for rules
     * for writing chemical formulae. In addition to the general
     * formulae requirements, the following rules apply:
     * 1. Moieties are separated by commas ','.
     * 2. The order of elements within a moiety follows general rule
     * 5 in CHEMICAL_FORMULA.
     * 3. Parentheses are not used within moieties but may surround
     * a moiety. Parentheses may not be nested.
     * 4. Charges should be placed at the end of the moiety. The
     * Singlege '+' or '-' may be preceded by a numerical multiplier
     * and should be separated from the last (element symbol +
     * count) by a space. Pre- or post-multipliers may be used for
     * individual moieties.
     */
    moiety: _t,
    /**
     * Chemical formulae in which all discrete bonded residues and ions are
     * summed over the constituent elements, following the ordering given
     * in rule 5 of the CATEGORY description. Parentheses normally not used.
     */
    sum: _t,
    /**
     * Mass corresponding to the formulae _chemical_formula.structural,
     * *_IUPAC, *_moiety or *_sum and, together with the Z value and cell
     * parameters yield the density given as _exptl_crystal.density_diffrn.
     */
    weight: ln
  },
  /**
   * The CATEGORY of data items used to specify space group
   * information about the crystal used in the diffraction measurements.
   *
   * Space-group types are identified by their number as listed in
   * International Tables for Crystallography Volume A, or by their
   * Schoenflies symbol. Specific settings of the space groups can
   * be identified by their Hall symbol, by specifying their
   * symmetry operations or generators, or by giving the
   * transformation that relates the specific setting to the
   * reference setting based on International Tables Volume A and
   * stored in this dictionary.
   *
   * The commonly used Hermann-Mauguin symbol determines the
   * space-group type uniquely but several different Hermann-Mauguin
   * symbols may refer to the same space-group type. A
   * Hermann-Mauguin symbol contains information on the choice of
   * the basis, but not on the choice of origin.
   *
   * Ref: International Tables for Crystallography (2002). Volume A,
   * Space-group symmetry, edited by Th. Hahn, 5th ed.
   * Dordrecht: Kluwer Academic Publishers.
   */
  space_group: {
    /**
     * The name of the system of geometric crystal classes of space
     * groups (crystal system) to which the space group belongs.
     * Note that rhombohedral space groups belong to the
     * trigonal system.
     */
    crystal_system: _t,
    /**
     * The number as assigned in International Tables for Crystallography
     * Vol. A, specifying the proper affine class (i.e. the orientation
     * preserving affine class) of space groups (crystallographic space
     * group type) to which the space group belongs. This number defines
     * the space group type but not the coordinate system expressed.
     */
    it_number: f5,
    /**
     * The full international Hermann-Mauguin space-group symbol as
     * defined in Section 2.2.3 and given as the second item of the
     * second line of each of the space-group tables of Part 7 of
     * International Tables for Crystallography Volume A (2002).
     *
     * Each component of the space-group name is separated by a
     * space or an underscore character. The use of a space is
     * strongly recommended.  The underscore is only retained
     * because it was used in old CIFs. It should not be used in
     * new CIFs.
     *
     * Subscripts should appear without special symbols. Bars should
     * be given as negative signs before the numbers to which they
     * apply. The commonly used Hermann-Mauguin symbol determines the
     * space-group type uniquely but a given space-group type may
     * be described by more than one Hermann-Mauguin symbol. The
     * space-group type is best described using
     * _space_group.IT_number or _space_group.name_Schoenflies. The
     * full international Hermann-Mauguin symbol contains information
     * about the choice of basis for monoclinic and orthorhombic
     * space groups but does not give information about the choice
     * of origin. To define the setting uniquely use
     * _space_group.name_Hall, or list the symmetry operations
     * or generators.
     *
     * Ref: International Tables for Crystallography (2002). Volume A,
     * Space-group symmetry, edited by Th. Hahn, 5th ed.
     * Dordrecht: Kluwer Academic Publishers.
     */
    "name_h-m_full": _t
  },
  /**
   * The CATEGORY of data items used to describe symmetry equivalent sites
   * in the crystal unit cell.
   */
  space_group_symop: {
    /**
     * A parsable string giving one of the symmetry operations of the
     * space group in algebraic form.  If W is a matrix representation
     * of the rotational part of the symmetry operation defined by the
     * positions and signs of x, y and z, and w is a column of
     * translations defined by fractions, an equivalent position
     * X' is generated from a given position X by the equation
     *
     * X' = WX + w
     *
     * (Note: X is used to represent bold_italics_x in International
     * Tables for Crystallography Vol. A, Part 5)
     *
     * When a list of symmetry operations is given, it must contain
     * a complete set of coordinate representatives which generates
     * all the operations of the space group by the addition of
     * all primitive translations of the space group. Such
     * representatives are to be found as the coordinates of
     * the general-equivalent position in International Tables for
     * Crystallography Vol. A (2002), to which it is necessary to
     * add any centring translations shown above the
     * general-equivalent position.
     *
     * That is to say, it is necessary to list explicitly all the
     * symmetry operations required to generate all the atoms in
     * the unit cell defined by the setting used.
     */
    operation_xyz: _t
  },
  /**
   * The CATEGORY of data items used to specify the geometry bonds in the
   * structural model as derived from the atomic sites.
   */
  geom_bond: {
    /**
     * This label is a unique identifier for a particular site in the
     * asymmetric unit of the crystal unit cell.
     */
    atom_site_label_1: _t,
    /**
     * This label is a unique identifier for a particular site in the
     * asymmetric unit of the crystal unit cell.
     */
    atom_site_label_2: _t,
    /**
     * Intramolecular bond distance between the sites identified
     * by _geom_bond.id
     */
    distance: ln,
    /**
     * This code signals whether the angle is referred to in a
     * publication or should be placed in a table of significant angles.
     */
    publ_flag: _t,
    /**
     * The set of data items which specify the symmetry operation codes
     * which must be applied to the atom sites involved in the geometry angle.
     *
     * The symmetry code of each atom site as the symmetry-equivalent position
     * number 'n' and the cell translation number 'pqr'. These numbers are
     * combined to form the code 'n pqr' or n_pqr.
     *
     * The character string n_pqr is composed as follows:
     *
     * n refers to the symmetry operation that is applied to the
     * coordinates stored in _atom_site.fract_xyz. It must match a
     * number given in _symmetry_equiv.pos_site_id.
     *
     * p, q and r refer to the translations that are subsequently
     * applied to the symmetry transformed coordinates to generate
     * the atom used in calculating the angle. These translations
     * (x,y,z) are related to (p,q,r) by the relations
     * p = 5 + x
     * q = 5 + y
     * r = 5 + z
     */
    site_symmetry_1: _t,
    /**
     * The set of data items which specify the symmetry operation codes
     * which must be applied to the atom sites involved in the geometry angle.
     *
     * The symmetry code of each atom site as the symmetry-equivalent position
     * number 'n' and the cell translation number 'pqr'. These numbers are
     * combined to form the code 'n pqr' or n_pqr.
     *
     * The character string n_pqr is composed as follows:
     *
     * n refers to the symmetry operation that is applied to the
     * coordinates stored in _atom_site.fract_xyz. It must match a
     * number given in _symmetry_equiv.pos_site_id.
     *
     * p, q and r refer to the translations that are subsequently
     * applied to the symmetry transformed coordinates to generate
     * the atom used in calculating the angle. These translations
     * (x,y,z) are related to (p,q,r) by the relations
     * p = 5 + x
     * q = 5 + y
     * r = 5 + z
     */
    site_symmetry_2: _t,
    /**
     * Bond valence calculated from the bond distance.
     */
    valence: ln
  },
  /**
   * The CATEGORY of data items used to record details about the
   * creation and subsequent updating of the data block.
   */
  audit: {
    /**
     * The digital object identifier (DOI) registered to identify
     * the data set publication represented by the current
     * data block. This can be used as a unique identifier for
     * the data block so long as the code used is a valid DOI
     * (i.e. begins with a valid publisher prefix assigned by a
     * Registration Agency and a suffix guaranteed to be unique
     * by the publisher) and has had its metadata deposited
     * with a DOI Registration Agency.
     *
     * A DOI is a unique character string identifying any
     * object of intellectual property. It provides a
     * persistent identifier for an object on a digital network
     * and permits the association of related current data in a
     * structured extensible way. A DOI is an implementation
     * of the Internet concepts of Uniform Resource Name and
     * Universal Resource Locator managed according to the
     * specifications of the International DOI Foundation
     * (see http://www.doi.org).
     */
    block_doi: _t
  },
  /**
   * The CATEGORY of data items recording database deposition. These data items
   * are assigned by database managers and should only appear in a CIF if they
   * originate from that source.
   */
  database_code: {
    /**
     * Code assigned by the Crystallography Open Database (COD).
     */
    cod: _t,
    /**
     * Code assigned by the Cambridge Structural Database.
     */
    csd: _t,
    /**
     * Deposition numbers assigned by the Cambridge Crystallographic
     * Data Centre (CCDC) to files containing structural information
     * archived by the CCDC.
     */
    depnum_ccdc_archive: _t,
    /**
     * Deposition numbers assigned by the Fachinformationszentrum
     * Karlsruhe (FIZ) to files containing structural information
     * archived by the Cambridge Crystallographic Data Centre (CCDC).
     */
    depnum_ccdc_fiz: _t,
    /**
     * Code assigned by the Inorganic Crystal Structure Database.
     */
    icsd: _t,
    /**
     * Code assigned in the Metals Data File.
     */
    mdf: _t,
    /**
     * Code assigned by the NBS (NIST) Crystal Data Database.
     */
    nbs: _t
  },
  /**
   * The CATEGORY of data items used to describe atom site information
   * used in crystallographic structure studies.
   */
  atom_site: {
    /**
     * Code for type of atomic displacement parameters used for the site.
     */
    adp_type: _t,
    /**
     * A standard code to signal if the site coordinates have been
     * determined from the intensities or calculated from the geometry
     * of surrounding sites, or have been assigned dummy coordinates.
     */
    calc_flag: _t,
    /**
     * A code which identifies a cluster of atoms that show long range
     * positional disorder but are locally ordered. Within each such
     * cluster of atoms, _atom_site.disorder_group is used to identify
     * the sites that are simultaneously occupied. This field is only
     * needed if there is more than one cluster of disordered atoms
     * showing independent local order.
     */
    disorder_assembly: _t,
    /**
     * A code that identifies a group of positionally disordered atom
     * sites that are locally simultaneously occupied. Atoms that are
     * positionally disordered over two or more sites (e.g. the H
     * atoms of a methyl group that exists in two orientations) can
     * be assigned to two or more groups. Sites belonging to the same
     * group are simultaneously occupied, but those belonging to
     * different groups are not. A minus prefix (e.g. "-1") is used to
     * indicate sites disordered about a special position.
     */
    disorder_group: _t,
    /**
     * Atom site coordinates as fractions of the cell length values.
     */
    fract_x: ln,
    /**
     * Atom site coordinates as fractions of the cell length values.
     */
    fract_y: ln,
    /**
     * Atom site coordinates as fractions of the cell length values.
     */
    fract_z: ln,
    /**
     * This label is a unique identifier for a particular site in the
     * asymmetric unit of the crystal unit cell. It is made up of
     * components, _atom_site.label_component_0 to *_6, which may be
     * specified as separate data items. Component 0 usually matches one
     * of the specified _atom_type.symbol codes. This is not mandatory
     * if an _atom_site.type_symbol item is included in the atom site
     * list. The _atom_site.type_symbol always takes precedence over
     * an _atom_site.label in the identification of the atom type. The
     * label components 1 to 6 are optional, and normally only
     * components 0 and 1 are used. Note that components 0 and 1 are
     * concatenated, while all other components, if specified, are
     * separated by an underline character. Underline separators are
     * only used if higher-order components exist. If an intermediate
     * component is not used it may be omitted provided the underline
     * separators are inserted. For example the label 'C233__ggg' is
     * acceptable and represents the components C, 233, '', and ggg.
     * Each label may have a different number of components.
     */
    label: _t,
    /**
     * The fraction of the atom type present at this site.
     * The sum of the occupancies of all the atom types at this site
     * may not significantly exceed 1.0 unless it is a dummy site. The
     * value must lie in the 99.97% Gaussian confidence interval
     * -3u =< x =< 1 + 3u. The _enumeration.range of 0.0:1.0 is thus
     * correctly interpreted as meaning (0.0 - 3u) =< x =< (1.0 + 3u).
     */
    occupancy: ln,
    /**
     * A concatenated series of single-letter codes which indicate the
     * refinement restraints or constraints applied to this site. This
     * item should not be used. It has been replaced by
     * _atom_site.refinement_flags_posn, _ADP and _occupancy. It is
     * retained in this dictionary only to provide compatibility with
     * legacy CIFs.
     */
    refinement_flags: _t,
    /**
     * The number of different sites that are generated by the
     * application of the space-group symmetry to the coordinates
     * given for this site. It is equal to the multiplicity given
     * for this Wyckoff site in International Tables for Cryst.
     * Vol. A (2002). It is equal to the multiplicity of the general
     * position divided by the order of the site symmetry given in
     * _atom_site.site_symmetry_order.
     */
    site_symmetry_multiplicity: f5,
    /**
     * A code to identify the atom specie(s) occupying this site.
     * This code must match a corresponding _atom_type.symbol. The
     * specification of this code is optional if component_0 of the
     * _atom_site.label is used for this purpose. See _atom_type.symbol.
     */
    type_symbol: _t,
    /**
     * Isotropic atomic displacement parameter, or equivalent isotropic
     * atomic  displacement parameter, U(equiv), in angstroms squared,
     * calculated from anisotropic atomic displacement  parameters.
     *
     * U(equiv) = (1/3) sum~i~[sum~j~(U^ij^ a*~i~ a*~j~ a~i~.a~j~)]
     *
     * a  = the real-space cell vectors
     * a* = the reciprocal-space cell lengths
     * Ref: Fischer, R. X. & Tillmanns, E. (1988). Acta Cryst. C44, 775-776.
     */
    u_iso_or_equiv: ln
  },
  /**
   * The CATEGORY of data items used to describe the anisotropic
   * thermal parameters of the atomic sites in a crystal structure.
   */
  atom_site_aniso: {
    /**
     * Anisotropic atomic displacement parameters are usually looped in
     * a separate list. If this is the case, this code must match the
     * _atom_site.label of the associated atom in the atom coordinate
     * list and conform with the same rules described in _atom_site.label.
     */
    label: _t,
    /**
     * These are the standard anisotropic atomic displacement
     * components in angstroms squared which appear in the
     * structure factor term:
     *
     * T = exp{-2pi^2^ sum~i~ [sum~j~ (U^ij^ h~i~ h~j~ a*~i~ a*~j~) ] }
     *
     * h = the Miller indices
     * a* = the reciprocal-space cell lengths
     *
     * The unique elements of the real symmetric matrix are entered by row.
     */
    u_11: ln,
    /**
     * These are the standard anisotropic atomic displacement
     * components in angstroms squared which appear in the
     * structure factor term:
     *
     * T = exp{-2pi^2^ sum~i~ [sum~j~ (U^ij^ h~i~ h~j~ a*~i~ a*~j~) ] }
     *
     * h = the Miller indices
     * a* = the reciprocal-space cell lengths
     *
     * The unique elements of the real symmetric matrix are entered by row.
     */
    u: eue(3, 3),
    /**
     * These are the standard anisotropic atomic displacement
     * components in angstroms squared which appear in the
     * structure factor term:
     *
     * T = exp{-2pi^2^ sum~i~ [sum~j~ (U^ij^ h~i~ h~j~ a*~i~ a*~j~) ] }
     *
     * h = the Miller indices
     * a* = the reciprocal-space cell lengths
     *
     * The unique elements of the real symmetric matrix are entered by row.
     */
    u_12: ln,
    /**
     * These are the standard anisotropic atomic displacement
     * components in angstroms squared which appear in the
     * structure factor term:
     *
     * T = exp{-2pi^2^ sum~i~ [sum~j~ (U^ij^ h~i~ h~j~ a*~i~ a*~j~) ] }
     *
     * h = the Miller indices
     * a* = the reciprocal-space cell lengths
     *
     * The unique elements of the real symmetric matrix are entered by row.
     */
    u_13: ln,
    /**
     * These are the standard anisotropic atomic displacement
     * components in angstroms squared which appear in the
     * structure factor term:
     *
     * T = exp{-2pi^2^ sum~i~ [sum~j~ (U^ij^ h~i~ h~j~ a*~i~ a*~j~) ] }
     *
     * h = the Miller indices
     * a* = the reciprocal-space cell lengths
     *
     * The unique elements of the real symmetric matrix are entered by row.
     */
    u_22: ln,
    /**
     * These are the standard anisotropic atomic displacement
     * components in angstroms squared which appear in the
     * structure factor term:
     *
     * T = exp{-2pi^2^ sum~i~ [sum~j~ (U^ij^ h~i~ h~j~ a*~i~ a*~j~) ] }
     *
     * h = the Miller indices
     * a* = the reciprocal-space cell lengths
     *
     * The unique elements of the real symmetric matrix are entered by row.
     */
    u_23: ln,
    /**
     * These are the standard anisotropic atomic displacement
     * components in angstroms squared which appear in the
     * structure factor term:
     *
     * T = exp{-2pi^2^ sum~i~ [sum~j~ (U^ij^ h~i~ h~j~ a*~i~ a*~j~) ] }
     *
     * h = the Miller indices
     * a* = the reciprocal-space cell lengths
     *
     * The unique elements of the real symmetric matrix are entered by row.
     */
    u_33: ln
  },
  /**
   * The CATEGORY of data items used to describe atomic type information
   * used in crystallographic structure studies.
   */
  atom_type: {
    /**
     * A description of the atom(s) designated by this atom type. In
     * most cases this will be the element name and oxidation state of
     * a single atom  species. For disordered or nonstoichiometric
     * structures it will describe a combination of atom species.
     */
    description: _t,
    /**
     * The identity of the atom specie(s) representing this atom type.
     * Normally this code is the element symbol followed by the charge
     * if there is one. The symbol may be composed of any character except
     * an underline or a blank, with the proviso that digits designate an
     * oxidation state and must be followed by a + or - character.
     */
    symbol: _t
  },
  /**
   * The CATEGORY of data items used to describe atomic scattering
   * information used in crystallographic structure studies.
   */
  atom_type_scat: {
    /**
     * The imaginary component of the anomalous dispersion scattering factors
     * for this atom type and radiation by _diffrn_radiation_wavelength.value
     */
    dispersion_imag: ln,
    /**
     * The real component of the anomalous dispersion scattering factors
     * for this atom type and radiation by _diffrn_radiation_wavelength.value
     */
    dispersion_real: ln,
    /**
     * Reference to source of scattering factors used for this atom type.
     */
    source: _t
  }
};
Dv.CifCore_Aliases = {
  "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"
  ]
};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.CIF = void 0;
  var r = Te, t = wC, n = EC, a = uC, i = fl, o = BC, c = NC, s = RC, u = Ev, l = Dv;
  e.CIF = {
    parse: function(f) {
      return typeof f == "string" ? (0, t.parseCifText)(f) : (0, n.parseCifBinary)(f);
    },
    parseText: t.parseCifText,
    parseBinary: n.parseCifBinary,
    toDatabaseCollection: a.toDatabaseCollection,
    toDatabase: a.toDatabase,
    schema: {
      mmCIF: function(f) {
        return (0, a.toDatabase)(i.mmCIF_Schema, f);
      },
      CCD: function(f) {
        return (0, a.toDatabase)(o.CCD_Schema, f);
      },
      BIRD: function(f) {
        return (0, a.toDatabase)(c.BIRD_Schema, f);
      },
      dic: function(f) {
        return (0, a.toDatabase)(s.dic_Schema, f);
      },
      cifCore: function(f) {
        return (0, a.toDatabase)(l.CifCore_Schema, f, l.CifCore_Aliases);
      },
      densityServer: function(f) {
        return (0, a.toDatabase)(u.DensityServer_Data_Schema, f);
      }
    }
  }, (0, r.__exportStar)(oy, e);
})(Vu);
var Pp = {}, _s = {}, _G = {};
Object.defineProperty(_G, "__esModule", { value: !0 });
var ME = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.AtomicHierarchy = e.AtomicIndex = e.ChainsSchema = e.ResiduesSchema = e.AtomsSchema = void 0;
  var r = mr(), t = fl;
  e.AtomsSchema = {
    /**
     * The chemical element of this atom site.
     * For mmCIF files, this points to atom_type.symbol in the ATOM_TYPE category.
     */
    type_symbol: r.Column.Schema.Aliased(t.mmCIF_Schema.atom_site.type_symbol),
    /**
     * A component of the identifier for this atom site.
     * This is a standardized name for the atom within its residue.
     * For mmCIF files, this points to chem_comp_atom.atom_id in the CHEM_COMP_ATOM category.
     */
    label_atom_id: t.mmCIF_Schema.atom_site.label_atom_id,
    /**
     * An alternative identifier for label_atom_id that may be provided by an author
     * in order to match the identification used in the publication that describes the structure.
     */
    auth_atom_id: t.mmCIF_Schema.atom_site.auth_atom_id,
    /**
     * A component of the identifier for this atom site.
     * Identifies an alternative conformation for this atom site.
     */
    label_alt_id: t.mmCIF_Schema.atom_site.label_alt_id,
    /**
     * A component of the identifier for this atom site.
     * For mmCIF files, this points to chem_comp.id in the CHEM_COMP category.
     */
    label_comp_id: t.mmCIF_Schema.atom_site.label_comp_id,
    /**
     * An alternative identifier for atom_site.label_comp_id that may be provided by an author
     * in order to match the identification used in the publication that describes the structure.
     */
    auth_comp_id: t.mmCIF_Schema.atom_site.auth_comp_id,
    /**
     * The net integer charge assigned to this atom.
     * This is the formal charge assignment normally found in chemical diagrams.
     */
    pdbx_formal_charge: t.mmCIF_Schema.atom_site.pdbx_formal_charge,
    // id, occupancy and B_iso_or_equiv are part of conformation
    cdr: t.mmCIF_Schema.atom_site.cdr,
    B_iso_or_equiv: t.mmCIF_Schema.atom_site.B_iso_or_equiv,
    em_confidence: t.mmCIF_Schema.atom_site.em_confidence
  }, e.ResiduesSchema = {
    /**
     * The group of atoms to which the atom site belongs. This data item is provided for
     * compatibility with the original Protein Data Bank format, and only for that purpose.
     */
    group_PDB: t.mmCIF_Schema.atom_site.group_PDB,
    /**
     * For mmCIF files, this points to entity_poly_seq.num in the ENTITY_POLY_SEQ category.
     */
    label_seq_id: t.mmCIF_Schema.atom_site.label_seq_id,
    /**
     * An alternative identifier for atom_site.label_seq_id that may be provided by an author
     * in order to match the identification used in the publication that describes the structure.
     */
    auth_seq_id: t.mmCIF_Schema.atom_site.auth_seq_id,
    /**
     * PDB insertion code.
     */
    pdbx_PDB_ins_code: t.mmCIF_Schema.atom_site.pdbx_PDB_ins_code
    // comp_id is part of atoms because of microheterogeneity
  }, e.ChainsSchema = {
    /**
     * A component of the identifier for this atom site.
     * For mmCIF files, this points to struct_asym.id in the STRUCT_ASYM category.
     */
    label_asym_id: t.mmCIF_Schema.atom_site.label_asym_id,
    /**
     * An alternative identifier for atomsite.label_asym_id that may be provided by an author
     * in order to match the identification used in the publication that describes the structure.
     */
    auth_asym_id: t.mmCIF_Schema.atom_site.auth_asym_id,
    /**
     * For mmCIF files, this points to _entity.id in the ENTITY category.
     */
    label_entity_id: t.mmCIF_Schema.atom_site.label_entity_id
  }, function(n) {
    function a() {
      return { label_entity_id: "", label_asym_id: "", auth_seq_id: 0, pdbx_PDB_ins_code: void 0 };
    }
    n.EmptyResidueKey = a;
  }(e.AtomicIndex || (e.AtomicIndex = {})), function(n) {
    function a(c, s) {
      return c.residueAtomSegments.index[c.chainAtomSegments.offsets[s]];
    }
    n.chainStartResidueIndex = a;
    function i(c, s) {
      return c.residueAtomSegments.index[c.chainAtomSegments.offsets[s + 1] - 1] + 1;
    }
    n.chainEndResidueIndexExcl = i;
    function o(c, s) {
      return i(c, s) - a(c, s);
    }
    n.chainResidueCount = o;
  }(e.AtomicHierarchy || (e.AtomicHierarchy = {}));
})(ME);
var wE = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.AtomNumber = e.AtomWeight = e.VdwRadius = e.DefaultAtomNumber = e.DefaultAtomWeight = e.DefaultVdwRadius = e.ElementAtomWeights = e.ElementVdwRadii = e.AtomicNumbers = void 0, e.AtomicNumbers = {
    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
  }, e.ElementVdwRadii = {
    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
  }, e.ElementAtomWeights = {
    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
  }, e.DefaultVdwRadius = 1.7, e.DefaultAtomWeight = 10.81, e.DefaultAtomNumber = 0;
  function r(a) {
    var i = e.AtomicNumbers[a];
    return i === void 0 ? e.DefaultVdwRadius : e.ElementVdwRadii[i];
  }
  e.VdwRadius = r;
  function t(a) {
    var i = e.AtomicNumbers[a];
    return i === void 0 ? e.DefaultAtomWeight : e.ElementAtomWeights[i];
  }
  e.AtomWeight = t;
  function n(a) {
    var i = e.AtomicNumbers[a];
    return i === void 0 ? e.DefaultAtomNumber : i;
  }
  e.AtomNumber = n;
})(wE);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 });
  var r = Te;
  (0, r.__exportStar)(_G, e), (0, r.__exportStar)(ME, e), (0, r.__exportStar)(wE, e);
})(_s);
var my = {};
Object.defineProperty(my, "__esModule", { value: !0 });
my.SecondaryStructure = void 0;
function rue(e, r, t, n) {
  return { type: e, key: r, elements: t, getIndex: n };
}
my.SecondaryStructure = rue;
Object.defineProperty(Pp, "__esModule", { value: !0 });
Pp.ModelSecondaryStructure = void 0;
var rb = Gr, w8 = _s, tue = my, nue = hs, xM;
(function(e) {
  e.Descriptor = {
    name: "model_secondary_structure"
  }, e.Provider = nue.FormatPropertyProvider.create(e.Descriptor);
  function r(t, n, a) {
    var i = /* @__PURE__ */ new Map(), o = [{ kind: "none" }], c = aue(t, n);
    iue(t, c, i, o), oue(n, c, i, t._rowCount, o);
    var s = a.residues._rowCount, u = function(f) {
      return f;
    }, l = {
      type: new Int32Array(s),
      key: new Int32Array(s),
      elements: o
    };
    return i.size > 0 && sue(a, c, i, l), (0, tue.SecondaryStructure)(l.type, l.key, l.elements, u);
  }
  e.fromStruct = r;
})(xM || (xM = {}));
Pp.ModelSecondaryStructure = xM;
function aue(e, r) {
  if (e._rowCount > 0) {
    if (e.beg_label_seq_id.valueKind(0) !== 0 || e.end_label_seq_id.valueKind(0) !== 0)
      return "auth";
  } else if (r && (r.beg_label_seq_id.valueKind(0) !== 0 || r.end_label_seq_id.valueKind(0) !== 0))
    return "auth";
  return "label";
}
function iue(e, r, t, n) {
  if (e._rowCount)
    for (var a = e.beg_label_asym_id, i = e.beg_label_seq_id, o = e.beg_auth_seq_id, c = e.pdbx_beg_PDB_ins_code, s = e.end_label_seq_id, u = e.end_auth_seq_id, l = e.pdbx_end_PDB_ins_code, f = e.pdbx_PDB_helix_class, d = e.conf_type_id, m = e.details, p = r === "label" ? i : o, v = r === "label" ? s : u, h = 0, y = e._rowCount; h < y; h++) {
      var C = rb.SecondaryStructureType.create(
        f.valueKind(h) === 0 ? rb.SecondaryStructureType.SecondaryStructurePdb[f.value(h)] : d.valueKind(h) === 0 ? rb.SecondaryStructureType.SecondaryStructureMmcif[d.value(h)] : 536870912
        /* NA */
      ), S = {
        kind: "helix",
        flags: C,
        type_id: d.valueKind(h) === 0 ? d.value(h) : "HELIX_P",
        helix_class: f.value(h),
        details: m.valueKind(h) === 0 ? m.value(h) : void 0
      }, b = {
        startSeqId: p.value(h),
        startInsCode: c.value(h),
        endSeqId: v.value(h),
        endInsCode: l.value(h),
        type: C,
        key: n.length
      };
      n[n.length] = S;
      var g = a.value(h);
      if (t.has(g)) {
        var _ = t.get(g);
        _.has(b.startSeqId) ? _.get(b.startSeqId).push(b) : _.set(b.startSeqId, [b]);
      } else
        t.set(g, /* @__PURE__ */ new Map([[b.startSeqId, [b]]]));
    }
}
function oue(e, r, t, n, a) {
  if (e._rowCount)
    for (var i = e.beg_label_asym_id, o = e.beg_label_seq_id, c = e.beg_auth_seq_id, s = e.pdbx_beg_PDB_ins_code, u = e.end_label_seq_id, l = e.end_auth_seq_id, f = e.pdbx_end_PDB_ins_code, d = e.sheet_id, m = r === "label" ? o : c, p = r === "label" ? u : l, v = /* @__PURE__ */ new Map(), h = n + 1, y = 0, C = e._rowCount; y < C; y++) {
      var S = d.value(y), b = void 0;
      v.has(S) ? b = v.get(S) : (b = h++, v.set(S, b));
      var g = rb.SecondaryStructureType.create(
        8388612
        /* BetaSheet */
      ), _ = {
        kind: "sheet",
        flags: g,
        sheet_id: S,
        symmetry: void 0
      }, A = {
        startSeqId: m.value(y),
        startInsCode: s.value(y),
        endSeqId: p.value(y),
        endInsCode: f.value(y),
        type: g,
        key: a.length
      };
      a[a.length] = _;
      var M = i.value(y);
      if (t.has(M)) {
        var P = t.get(M);
        P.has(A.startSeqId) ? P.get(A.startSeqId).push(A) : P.set(A.startSeqId, [A]);
      } else
        t.set(M, /* @__PURE__ */ new Map([[A.startSeqId, [A]]]));
    }
}
function uue(e, r, t, n, a, i) {
  for (var o = e.residues, c = o.auth_seq_id, s = o.label_seq_id, u = o.pdbx_PDB_ins_code, l = t.endSeqId, f = t.endInsCode, d = t.key, m = t.type, p = r === "label" ? s : c, v = n; v < a; ) {
    var h = p.value(v);
    if (i.type[v] = m, i.key[v] = d, h > l || h === l && u.value(v) === f)
      break;
    v++;
  }
}
function sue(e, r, t, n) {
  for (var a = e.chainAtomSegments.count, i = e.chains.label_asym_id, o = e.residues, c = o.auth_seq_id, s = o.label_seq_id, u = o.pdbx_PDB_ins_code, l = r === "label" ? s : c, f = 0; f < a; f++) {
    var d = w8.AtomicHierarchy.chainStartResidueIndex(e, f), m = w8.AtomicHierarchy.chainEndResidueIndexExcl(e, f), p = i.value(f);
    if (t.has(p))
      for (var v = t.get(p), h = d; h < m; h++) {
        var y = l.value(h);
        if (v.has(y))
          for (var C = v.get(y), S = 0, b = C; S < b.length; S++) {
            var g = b[S], _ = u.value(h);
            g.startInsCode === _ && uue(e, r, g, h, m, n);
          }
      }
  }
}
var Oh = {}, E8;
function bG() {
  if (E8) return Oh;
  E8 = 1, Object.defineProperty(Oh, "__esModule", { value: !0 }), Oh.AtomSiteAnisotrop = void 0;
  var e = fl, r = Nu, t = hs, n = Jo(), a = {
    U: e.mmCIF_Schema.atom_site_anisotrop.U,
    U_esd: e.mmCIF_Schema.atom_site_anisotrop.U_esd
  }, i;
  return function(o) {
    o.Schema = a, o.Descriptor = {
      name: "atom_site_anisotrop",
      cifExport: {
        prefix: "",
        categories: [{
          name: "atom_site_anisotrop",
          instance: function(u) {
            var l = o.Provider.get(u.firstModel);
            return !l || !n.MmcifFormat.is(u.firstModel.sourceData) ? r.CifWriter.Category.Empty : r.CifWriter.Category.ofTable(u.firstModel.sourceData.data.db.atom_site_anisotrop);
          }
        }]
      }
    }, o.Provider = t.FormatPropertyProvider.create(o.Descriptor);
    function c(u, l) {
      var f = new Int32Array(u.rowCount);
      f.fill(-1);
      for (var d = 0, m = u.rowCount; d < m; d++)
        f[u.value(d)] = d;
      var p = new Int32Array(u.rowCount);
      p.fill(-1);
      for (var d = 0, m = l.rowCount; d < m; ++d) {
        var v = f[l.value(d)];
        v !== -1 && (p[v] = d);
      }
      return p;
    }
    o.getElementToAnsiotrop = c;
    function s(u, l) {
      for (var f = {}, d = 0, m = u.rowCount; d < m; d++)
        f[u.value(d)] = d;
      var p = new Int32Array(u.rowCount);
      p.fill(-1);
      for (var d = 0, m = l.rowCount; d < m; ++d) {
        var v = f[l.value(d)];
        v !== void 0 && (p[v] = d);
      }
      return p;
    }
    o.getElementToAnsiotropFromLabel = s;
  }(i || (i = {})), Oh.AtomSiteAnisotrop = i, Oh;
}
var m5 = {}, D8;
function lue() {
  return D8 || (D8 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.GlobalModelTransformInfo = void 0;
    var r = hs, t = In, n = mr(), a = Nu, i = Jo(), o = uC;
    (function(c) {
      var s, u = "molstar_global_model_transform_info";
      c.Schema = (s = {}, s[u] = {
        matrix: n.Column.Schema.Matrix(4, 4, n.Column.Schema.float)
      }, s), c.Descriptor = (0, t.CustomPropertyDescriptor)({
        name: u,
        cifExport: {
          categories: [{
            name: u,
            instance: function(v) {
              var h = f(v.firstModel);
              if (!h)
                return a.CifWriter.Category.Empty;
              var y = n.Table.ofRows(c.Schema.molstar_global_model_transform_info, [{ matrix: h }]);
              return a.CifWriter.Category.ofTable(y);
            }
          }],
          prefix: "molstar"
        }
      }), c.Provider = r.FormatPropertyProvider.create(c.Descriptor);
      function l(v, h) {
        v.customProperties.has(c.Descriptor) || v.customProperties.add(c.Descriptor), c.Provider.set(v, h);
      }
      c.attach = l;
      function f(v) {
        return c.Provider.get(v);
      }
      c.get = f;
      function d(v) {
        if (i.MmcifFormat.is(v.sourceData)) {
          var h = v.sourceData.data.frame.categories[u];
          if (h) {
            var y = (0, o.toTable)(c.Schema[u], h);
            if (y._rowCount !== 0)
              return y.matrix.value(0);
          }
        }
      }
      c.fromMmCif = d;
      function m(v) {
        if (!i.MmcifFormat.is(v.sourceData))
          return !1;
        var h = v.sourceData.data.frame.categories[u];
        return !!h && h.rowCount > 0;
      }
      c.hasData = m;
      function p(v, h) {
        v.writeCategory({
          name: u,
          instance: function() {
            var y = n.Table.ofRows(c.Schema.molstar_global_model_transform_info, [{ matrix: h }]);
            return a.CifWriter.Category.ofTable(y);
          }
        });
      }
      c.writeMmCif = p;
    })(e.GlobalModelTransformInfo || (e.GlobalModelTransformInfo = {}));
  }(m5)), m5;
}
var Zo = {}, yd = {};
Object.defineProperty(yd, "__esModule", { value: !0 });
yd.mmCIF_chemComp_schema = yd.mmCIF_chemCompBond_schema = yd.mmCIF_residueId_schema = void 0;
var Mb = Te, ks = fl, TM = mr();
yd.mmCIF_residueId_schema = {
  label_comp_id: ks.mmCIF_Schema.atom_site.label_comp_id,
  label_seq_id: ks.mmCIF_Schema.atom_site.label_seq_id,
  pdbx_PDB_ins_code: ks.mmCIF_Schema.atom_site.pdbx_PDB_ins_code,
  label_asym_id: ks.mmCIF_Schema.atom_site.label_asym_id,
  label_entity_id: ks.mmCIF_Schema.atom_site.label_entity_id,
  auth_comp_id: ks.mmCIF_Schema.atom_site.auth_atom_id,
  auth_seq_id: ks.mmCIF_Schema.atom_site.auth_seq_id,
  auth_asym_id: ks.mmCIF_Schema.atom_site.auth_asym_id
};
yd.mmCIF_chemCompBond_schema = (0, Mb.__assign)((0, Mb.__assign)({}, ks.mmCIF_Schema.chem_comp_bond), {
  /** Indicates if the bond entry was taken from the protonation variant dictionary */
  molstar_protonation_variant: TM.Column.Schema.Str()
});
yd.mmCIF_chemComp_schema = (0, Mb.__assign)((0, Mb.__assign)({}, ks.mmCIF_Schema.chem_comp), { type: TM.Column.Schema.Aliased(TM.Column.Schema.str) });
var c0 = {};
Object.defineProperty(c0, "__esModule", { value: !0 });
c0.getNormalizedAtomSite = c0.getModelGroupName = void 0;
var PM = mr();
function cue(e, r) {
  var t = r.ihm_model_group, n = r.ihm_model_group_link, a = PM.Table.pickRow(n, function(o) {
    return n.model_id.value(o) === e;
  });
  if (a) {
    var i = PM.Table.pickRow(t, function(o) {
      return t.id.value(o) === a.group_id;
    });
    if (i)
      return i.name;
  }
  return "";
}
c0.getModelGroupName = cue;
function I8(e) {
  for (var r = 0, t = e.rowCount; r < t; r++)
    if (e.valueKind(r) === 0)
      return !0;
  return !1;
}
function d2(e, r, t) {
  (!e[r].isDefined || !I8(e[r])) && (e[r] = e[t]), (!e[t].isDefined || !I8(e[t])) && (e[t] = e[r]);
}
function due(e) {
  var r = PM.Table.ofColumns(e._schema, e);
  return d2(r, "label_atom_id", "auth_atom_id"), d2(r, "label_comp_id", "auth_comp_id"), d2(r, "label_seq_id", "auth_seq_id"), d2(r, "label_asym_id", "auth_asym_id"), r;
}
c0.getNormalizedAtomSite = due;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.createBasic = e.BasicSchema = void 0;
  var r = fl, t = mr(), n = yd, a = c0;
  e.BasicSchema = {
    entry: r.mmCIF_Schema.entry,
    struct: r.mmCIF_Schema.struct,
    struct_asym: r.mmCIF_Schema.struct_asym,
    ihm_model_list: r.mmCIF_Schema.ihm_model_list,
    ihm_model_group: r.mmCIF_Schema.ihm_model_group,
    ihm_model_group_link: r.mmCIF_Schema.ihm_model_group_link,
    entity: r.mmCIF_Schema.entity,
    entity_poly: r.mmCIF_Schema.entity_poly,
    entity_poly_seq: r.mmCIF_Schema.entity_poly_seq,
    pdbx_entity_branch: r.mmCIF_Schema.pdbx_entity_branch,
    chem_comp: n.mmCIF_chemComp_schema,
    pdbx_chem_comp_identifier: r.mmCIF_Schema.pdbx_chem_comp_identifier,
    atom_site: r.mmCIF_Schema.atom_site,
    ihm_sphere_obj_site: r.mmCIF_Schema.ihm_sphere_obj_site,
    ihm_gaussian_obj_site: r.mmCIF_Schema.ihm_gaussian_obj_site,
    pdbx_unobs_or_zero_occ_residues: r.mmCIF_Schema.pdbx_unobs_or_zero_occ_residues,
    pdbx_molecule: r.mmCIF_Schema.pdbx_molecule
  };
  function i(o, c) {
    c === void 0 && (c = !1);
    for (var s = /* @__PURE__ */ Object.create(null), u = 0, l = Object.keys(e.BasicSchema); u < l.length; u++) {
      var f = l[u];
      f in o ? s[f] = o[f] : s[f] = t.Table.ofUndefinedColumns(e.BasicSchema[f], 0);
    }
    return c && (s.atom_site = (0, a.getNormalizedAtomSite)(s.atom_site)), s;
  }
  e.createBasic = i;
})(Zo);
var B8;
function Jo() {
  if (B8) return Sf;
  B8 = 1, Object.defineProperty(Sf, "__esModule", { value: !0 }), Sf.trajectoryFromMmCIF = Sf.MmcifFormat = void 0;
  var e = Kr, r = Vu, t = xc(), n = ml(), a = Pp, i = mr(), o = bG(), c = gE, s = xC, u = lue(), l = Zo;
  function f(S) {
    if (y.is(S.sourceData))
      return n.ModelSymmetry.fromData(S.sourceData.data.db);
  }
  n.ModelSymmetry.Provider.formatRegistry.add("mmCIF", f);
  function d(S) {
    if (y.is(S.sourceData)) {
      var b = S.sourceData.data.db, g = b.struct_conf, _ = b.struct_sheet_range;
      return a.ModelSecondaryStructure.fromStruct(g, _, S.atomicHierarchy);
    }
  }
  a.ModelSecondaryStructure.Provider.formatRegistry.add("mmCIF", d);
  function m(S) {
    if (y.is(S.sourceData)) {
      var b = S.sourceData.data.db.atom_site_anisotrop, g = i.Table.ofColumns(o.AtomSiteAnisotrop.Schema, b), _ = o.AtomSiteAnisotrop.getElementToAnsiotrop(S.atomicConformation.atomId, b.id);
      return { data: g, elementToAnsiotrop: _ };
    }
  }
  function p(S) {
    return y.is(S.sourceData) ? S.sourceData.data.db.atom_site_anisotrop.U.isDefined : !1;
  }
  o.AtomSiteAnisotrop.Provider.formatRegistry.add("mmCIF", m, p);
  function v(S) {
    if (y.is(S.sourceData)) {
      var b = S.sourceData.data.db.chem_comp_bond;
      if (b._rowCount !== 0)
        return {
          data: b,
          entries: c.ComponentBond.getEntriesFromChemCompBond(b)
        };
    }
  }
  c.ComponentBond.Provider.formatRegistry.add("mmCIF", v);
  function h(S) {
    if (y.is(S.sourceData)) {
      var b = S.sourceData.data.db.struct_conn;
      if (b._rowCount !== 0) {
        var g = s.StructConn.getEntriesFromStructConn(b, S);
        return {
          data: b,
          byAtomIndex: s.StructConn.getAtomIndexFromEntries(g),
          entries: g
        };
      }
    }
  }
  s.StructConn.Provider.formatRegistry.add("mmCIF", h), u.GlobalModelTransformInfo.Provider.formatRegistry.add("mmCIF", u.GlobalModelTransformInfo.fromMmCif, u.GlobalModelTransformInfo.hasData);
  var y;
  (function(S) {
    function b(_) {
      return (_ == null ? void 0 : _.kind) === "mmCIF";
    }
    S.is = b;
    function g(_, A, M) {
      return A || (A = r.CIF.schema.mmCIF(_)), { kind: "mmCIF", name: A._name, data: { db: A, frame: _, source: M } };
    }
    S.fromFrame = g;
  })(y || (y = {})), Sf.MmcifFormat = y;
  function C(S) {
    var b = y.fromFrame(S), g = (0, l.createBasic)(b.data.db, !0);
    return e.Task.create("Create mmCIF Model", function(_) {
      return (0, t.createModels)(g, b, _);
    });
  }
  return Sf.trajectoryFromMmCIF = C, Sf;
}
var Fh = {}, Lh = {}, v5 = {}, Iv = {}, FC = {};
Object.defineProperty(FC, "__esModule", { value: !0 });
FC.assignBends = void 0;
var uu = Re, fue = kn;
function mue(e) {
  var r = e.unit, t = e.flags, n = e.proteinInfo, a = r.conformation.position, i = r.model.atomicHierarchy.derived.residue.traceElementIndex, o = n.residueIndices, c = n.nIndices, s = o.length, u = function(x, w) {
    return x === -1 ? uu.Vec3.setNaN(w) : a(x, w);
  }, l = (0, uu.Vec3)(), f = (0, uu.Vec3)(), d = (0, uu.Vec3)(), m = (0, uu.Vec3)(), p = (0, uu.Vec3)(), v = (0, uu.Vec3)(), h = (0, uu.Vec3)();
  e: for (var y = 2; y < s - 2; y++) {
    for (var C = 0; C < 4; C++) {
      var S = y + C - 2;
      if (u(i[S], m), u(c[S + 1], p), uu.Vec3.squaredDistance(m, p) > 6.25)
        continue e;
    }
    var b = o[y - 2], g = o[y], _ = o[y + 2], A = i[b], M = i[g], P = i[_];
    u(A, l), u(M, f), u(P, d), uu.Vec3.sub(v, l, f), uu.Vec3.sub(h, f, d);
    var T = (0, fue.radToDeg)(uu.Vec3.angle(v, h));
    T && T > 70 && (t[y] |= 32);
  }
}
FC.assignBends = mue;
var LC = {};
Object.defineProperty(LC, "__esModule", { value: !0 });
LC.calcUnitBackboneHbonds = void 0;
var vue = dl, no = Re, pue = 9, f2 = -27.888, hue = -0.5, N8 = -9.9;
function gue(e, r, t, n) {
  var a = no.Vec3.distance(e, n), i = no.Vec3.distance(r, n), o = no.Vec3.distance(r, t), c = no.Vec3.distance(e, t), s = f2 / a - f2 / i, u = f2 / o - f2 / c, l = s + u;
  return l < N8 ? N8 : l;
}
function yue(e, r, t) {
  for (var n = r.residueIndices, a = r.cIndices, i = r.hIndices, o = r.nIndices, c = r.oIndices, s = e.model.atomicHierarchy.index, u = e.conformation.invariantPosition, l = e.model.atomicHierarchy.derived.residue.traceElementIndex, f = n.length, d = [], m = [], p = [], v = (0, no.Vec3)(), h = (0, no.Vec3)(), y = (0, no.Vec3)(), C = (0, no.Vec3)(), S = (0, no.Vec3)(), b = (0, no.Vec3)(), g = (0, no.Vec3)(), _ = 0, A = n.length; _ < A; ++_) {
    var M = _, P = n[_], T = c[M], x = a[M], w = l[P];
    if (!(T === -1 || x === -1) && s.findAtomOnResidue(P, "OXT") === -1) {
      u(T, v), u(x, h), u(w, y);
      for (var E = t.find(y[0], y[1], y[2], pue), I = E.indices, B = E.count, D = 0; D < B; ++D) {
        var N = I[D];
        if (!(N === M || N - 1 === M || N + 1 === M)) {
          var O = o[N];
          if (O !== -1) {
            u(O, C);
            var V = i[N];
            if (V === -1) {
              if (N === 0)
                continue;
              var k = N - 1, G = c[k], L = a[k];
              if (G === -1 || L === -1)
                continue;
              u(G, g), u(L, b), no.Vec3.sub(S, b, g);
              var R = no.Vec3.distance(g, b);
              no.Vec3.scaleAndAdd(S, C, S, 1 / R);
            } else
              u(V, S);
            var F = gue(v, h, C, S);
            F > hue || (d[d.length] = M, m[m.length] = N, p[p.length] = F);
          }
        }
      }
    }
  }
  return _ue(f, d, m, p);
}
LC.calcUnitBackboneHbonds = yue;
function _ue(e, r, t, n) {
  for (var a = new vue.IntAdjacencyGraph.DirectedEdgeBuilder(e, r, t), i = new Float32Array(a.slotCount), o = 0, c = a.edgeCount; o < c; o++)
    a.addNextEdge(), a.assignProperty(i, n[o]);
  return a.createGraph({ energies: n });
}
var mc = {};
Object.defineProperty(mc, "__esModule", { value: !0 });
mc.Bridge = mc.DSSPType = void 0;
var V8 = We(), MM;
(function(e) {
  e.is = V8.BitFlags.has, e.create = V8.BitFlags.create;
})(MM || (MM = {}));
mc.DSSPType = MM;
var bue = (
  /** @class */
  /* @__PURE__ */ function() {
    function e(r, t, n) {
      this.partner1 = Math.min(r, t), this.partner2 = Math.max(r, t), this.type = n;
    }
    return e;
  }()
);
mc.Bridge = bue;
var kC = {};
Object.defineProperty(kC, "__esModule", { value: !0 });
kC.assignTurns = void 0;
function Sue(e) {
  for (var r = e.proteinInfo, t = e.hbonds, n = e.flags, a = [
    1024,
    2048,
    4096,
    128,
    256,
    512
    /* T5 */
  ], i = 0; i < 3; i++)
    for (var o = 0, c = r.residueIndices.length - 1; o < c; ++o)
      if (t.getDirectedEdgeIndex(o, o + i + 3) !== -1)
        if (n[o] |= a[i + 3] | a[i], e.params.oldDefinition)
          for (var s = 1; s < i + 3; ++s)
            n[o + s] |= a[i + 3] | 64;
        else
          for (var s = 0; s <= i + 3; ++s)
            n[o + s] |= a[i + 3] | 64;
}
kC.assignTurns = Sue;
var UC = {};
Object.defineProperty(UC, "__esModule", { value: !0 });
UC.assignHelices = void 0;
var ua = mc;
function Cue(e) {
  for (var r = e.proteinInfo, t = e.flags, n = r.residueIndices.length, a = [
    1024,
    2048,
    4096,
    128,
    256,
    512
    /* T5 */
  ], i = [
    0,
    0,
    0,
    8,
    1,
    16
    /* I */
  ], o = e.params.oldOrdering ? [4, 3, 5] : [3, 4, 5], c = 0; c < o.length; c++)
    for (var s = o[c], u = 1, l = n - s; u < l; u++) {
      var f = ua.DSSPType.create(t[u]), d = ua.DSSPType.create(t[u - 1]), m = ua.DSSPType.create(t[u + 1]);
      if (e.params.oldOrdering) {
        if (s === 3 && (ua.DSSPType.is(
          f,
          1
          /* H */
        ) || ua.DSSPType.is(
          m,
          1
          /* H */
        )) || // for 3-10 yield to alpha helix
        s === 5 && (ua.DSSPType.is(
          f,
          1
          /* H */
        ) || ua.DSSPType.is(
          f,
          8
          /* G */
        ) || ua.DSSPType.is(
          m,
          1
          /* H */
        ) || ua.DSSPType.is(
          m,
          8
          /* G */
        )))
          continue;
      } else if (s === 4 && (ua.DSSPType.is(
        f,
        8
        /* G */
      ) || ua.DSSPType.is(
        m,
        8
        /* G */
      )) || // for alpha helix yield to 3-10
      s === 5 && (ua.DSSPType.is(
        f,
        1
        /* H */
      ) || ua.DSSPType.is(
        f,
        8
        /* G */
      ) || ua.DSSPType.is(
        m,
        1
        /* H */
      ) || ua.DSSPType.is(
        m,
        8
        /* G */
      )))
        continue;
      if (ua.DSSPType.is(f, a[s]) && ua.DSSPType.is(f, a[s - 3]) && // check fI for turn start of proper type
      ua.DSSPType.is(d, a[s]) && ua.DSSPType.is(d, a[s - 3]))
        if (e.params.oldDefinition)
          for (var p = 0; p < s; p++)
            t[u + p] |= i[s];
        else
          for (var p = -1; p <= s; p++)
            t[u + p] |= i[s];
    }
}
UC.assignHelices = Cue;
var zC = {};
Object.defineProperty(zC, "__esModule", { value: !0 });
zC.assignLadders = void 0;
function Aue(e, r) {
  if (r.type !== e.type || r.partner1 !== e.firstEnd + 1)
    return !1;
  if (r.type === 0) {
    if (r.partner2 === e.secondEnd + 1)
      return !0;
  } else if (r.partner2 === e.secondStart - 1)
    return !0;
  return !1;
}
function xue(e, r) {
  return e.type === r.type && r.firstStart - e.firstEnd < 6 && e.firstStart < r.firstStart && r.nextLadder === 0 ? e.type === 0 ? R8(e, r) : R8(r, e) : !1;
}
function R8(e, r) {
  return r.secondStart - e.secondEnd > 0 && (r.secondStart - e.secondEnd < 6 && r.firstStart - e.firstEnd < 3 || r.secondStart - e.secondEnd < 3);
}
function Tue(e) {
  for (var r = e.bridges, t = e.ladders, n = 0; n < r.length; n++) {
    for (var a = r[n], i = !1, o = 0; o < t.length; o++) {
      var c = t[o];
      Aue(c, a) && (i = !0, c.firstEnd++, a.type === 0 ? c.secondEnd++ : c.secondStart--);
    }
    i || (t[t.length] = {
      previousLadder: 0,
      nextLadder: 0,
      firstStart: a.partner1,
      firstEnd: a.partner1,
      secondStart: a.partner2,
      secondEnd: a.partner2,
      type: a.type
    });
  }
  for (var s = 0; s < t.length; s++)
    for (var u = t[s], l = s; l < t.length; l++) {
      var f = t[l];
      xue(u, f) && (u.nextLadder = l, f.previousLadder = s);
    }
}
zC.assignLadders = Tue;
var GC = {};
Object.defineProperty(GC, "__esModule", { value: !0 });
GC.assignBridges = void 0;
var m2 = mc;
function Pue(e) {
  for (var r = e.proteinInfo, t = e.hbonds, n = e.flags, a = e.bridges, i = t.offset, o = t.b, c, s, u = 0, l = r.residueIndices.length; u < l; ++u)
    for (var f = i[u], d = i[u + 1]; f < d; f++) {
      var m = o[f];
      u > m || (c = u + 1, s = m, c !== s && t.getDirectedEdgeIndex(s, c + 1) !== -1 && (n[c] |= 2, n[s] |= 2, a[a.length] = new m2.Bridge(
        c,
        s,
        0
        /* PARALLEL */
      )), c = u, s = m - 1, c !== s && t.getDirectedEdgeIndex(s - 1, c) !== -1 && (n[c] |= 2, n[s] |= 2, a[a.length] = new m2.Bridge(
        s,
        c,
        0
        /* PARALLEL */
      )), c = u, s = m, c !== s && t.getDirectedEdgeIndex(s, c) !== -1 && (n[c] |= 2, n[s] |= 2, a[a.length] = new m2.Bridge(
        s,
        c,
        1
        /* ANTI_PARALLEL */
      )), c = u + 1, s = m - 1, c !== s && t.getDirectedEdgeIndex(s - 1, c + 1) !== -1 && (n[c] |= 2, n[s] |= 2, a[a.length] = new m2.Bridge(
        s,
        c,
        1
        /* ANTI_PARALLEL */
      )));
    }
  a.sort(function(p, v) {
    return p.partner1 > v.partner1 ? 1 : p.partner1 < v.partner1 ? -1 : 0;
  });
}
GC.assignBridges = Pue;
var qC = {};
Object.defineProperty(qC, "__esModule", { value: !0 });
qC.assignSheets = void 0;
var H1 = mc;
function O8(e) {
  return H1.DSSPType.is(
    e,
    8
    /* G */
  ) || H1.DSSPType.is(
    e,
    1
    /* H */
  ) || H1.DSSPType.is(
    e,
    16
    /* I */
  );
}
function Mue(e) {
  for (var r = e.ladders, t = e.flags, n = 0; n < r.length; n++) {
    for (var a = r[n], i = a.firstStart; i <= a.firstEnd; i++) {
      var o = a.firstStart - i, c = a.secondStart - o;
      a.firstStart !== a.firstEnd ? (t[i] |= 4, t[c] |= 4) : (!O8(t[i]) && H1.DSSPType.is(
        t[i],
        4
        /* E */
      ) && (t[i] |= 2), !O8(t[c]) && H1.DSSPType.is(
        t[c],
        4
        /* E */
      ) && (t[c] |= 2));
    }
    if (a.nextLadder !== 0) {
      for (var s = r[a.nextLadder], i = a.firstStart; i <= s.firstEnd; i++)
        t[i] |= 4;
      if (a.type === 0)
        for (var i = a.secondStart; i <= s.secondEnd; i++)
          t[i] |= 4;
      else
        for (var i = s.secondEnd; i <= a.secondStart; i++)
          t[i] |= 4;
    }
  }
}
qC.assignSheets = Mue;
var HC = {};
Object.defineProperty(HC, "__esModule", { value: !0 });
HC.calculateUnitDihedralAngles = void 0;
var su = Re, F8 = kn;
function wue(e, r) {
  var t = r.cIndices, n = r.nIndices, a = r.residueIndices, i = e.conformation.position, o = e.model.atomicHierarchy.index, c = e.model.atomicHierarchy.derived.residue.traceElementIndex, s = a.length, u = function(_, A) {
    return _ === -1 ? su.Vec3.setNaN(A) : i(_, A);
  }, l = (0, su.Vec3)(), f = (0, su.Vec3)(), d = (0, su.Vec3)(), m = (0, su.Vec3)(), p = (0, su.Vec3)(), v = (0, su.Vec3)(), h = (0, su.Vec3)(), y = (0, su.Vec3)(), C = (0, su.Vec3)();
  if (s === 0)
    return { phi: new Float32Array(0), psi: new Float32Array(0) };
  var S = new Float32Array(s - 1), b = new Float32Array(s - 1);
  u(-1, l), u(-1, f), u(-1, d), u(t[0], m), u(c[a[0]], p), u(n[0], v), u(t[1], h), u(c[a[1]], y), u(n[1], C);
  for (var g = 0; g < s - 1; ++g)
    o.findAtomOnResidue(a[g], "OXT") === -1 && (S[g] = (0, F8.radToDeg)(su.Vec3.dihedralAngle(l, v, p, m)), b[g] = (0, F8.radToDeg)(su.Vec3.dihedralAngle(v, p, m, C)), l = m, f = p, d = v, m = h, p = y, v = C, u(t[g + 1], h), u(c[a[g + 1]], y), u(n[g + 1], C));
  return { phi: S, psi: b };
}
HC.calculateUnitDihedralAngles = wue;
var jC = {};
Object.defineProperty(jC, "__esModule", { value: !0 });
jC.calcUnitProteinTraceLookup3D = void 0;
var Eue = nr(), Due = Qe(), Iue = B0;
function Bue(e, r) {
  for (var t = e.model.atomicConformation, n = t.x, a = t.y, i = t.z, o = e.model.atomicHierarchy.derived.residue.traceElementIndex, c = new Uint32Array(r.length), s = 0, u = r.length; s < u; ++s)
    c[s] = o[r[s]];
  var l = { x: n, y: a, z: i, indices: Due.SortedArray.ofSortedArray(c) };
  return (0, Eue.GridLookup3D)(l, (0, Iue.getBoundary)(l));
}
jC.calcUnitProteinTraceLookup3D = Bue;
var $C = {};
Object.defineProperty($C, "__esModule", { value: !0 });
$C.getUnitProteinInfo = void 0;
var Nue = Qe();
function Vue(e) {
  for (var r = e.model.atomicHierarchy.index, t = e.proteinElements, n = e.residueIndex, a = t.length, i = new Uint32Array(a), o = new Int32Array(a), c = new Int32Array(a), s = new Int32Array(a), u = new Int32Array(a), l = 0; l < a; ++l) {
    var f = n[t[l]];
    i[l] = f, o[l] = r.findAtomOnResidue(f, "C"), c[l] = r.findAtomOnResidue(f, "H"), s[l] = r.findAtomOnResidue(f, "O"), u[l] = r.findAtomOnResidue(f, "N");
  }
  return {
    residueIndices: Nue.SortedArray.ofSortedArray(i),
    cIndices: o,
    hIndices: c,
    oIndices: s,
    nIndices: u
  };
}
$C.getUnitProteinInfo = Vue;
Object.defineProperty(Iv, "__esModule", { value: !0 });
Iv.computeUnitDSSP = Iv.DSSPComputationParams = void 0;
var L8 = Te, Rue = my, jn = Gr, k8 = Le, Oue = FC, Fue = LC, wt = mc, Lue = kC, kue = UC, Uue = zC, zue = GC, Gue = qC, que = HC, Hue = jC, jue = $C, $ue = Qe();
Iv.DSSPComputationParams = {
  oldDefinition: k8.ParamDefinition.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: k8.ParamDefinition.Boolean(!0, { description: "Alpha-helices are preferred over 3-10 helices" })
};
function Kue(e, r) {
  return (0, L8.__awaiter)(this, void 0, void 0, function() {
    var t, n, a, i, o, c, s, u, l, f, d, m, p, v, h, y, C, S, b, g, _;
    return (0, L8.__generator)(this, function(A) {
      for (t = (0, jue.getUnitProteinInfo)(e), n = t.residueIndices, a = (0, Hue.calcUnitProteinTraceLookup3D)(e, n), i = (0, Fue.calcUnitBackboneHbonds)(e, t, a), o = n.length, c = new Uint32Array(o), s = (0, que.calculateUnitDihedralAngles)(e, t), u = [], l = [], f = r.oldDefinition ? Yue : Zue, d = r.oldOrdering ? Que : Jue, m = {
        params: r,
        getResidueFlag: f,
        getFlagName: d,
        unit: e,
        proteinInfo: t,
        flags: c,
        hbonds: i,
        torsionAngles: s,
        ladders: u,
        bridges: l
      }, (0, Lue.assignTurns)(m), (0, kue.assignHelices)(m), (0, Oue.assignBends)(m), (0, zue.assignBridges)(m), (0, Uue.assignLadders)(m), (0, Gue.assignSheets)(m), p = ese(c, f), v = new Uint32Array(o), h = [], y = [], C = function(M) {
        return $ue.SortedArray.indexOf(n, M);
      }, S = 0, b = n.length; S < b; ++S)
        g = p[S], v[S] = g, _ = f(c[S]), (y.length === 0 || _ !== y[y.length - 1].flags) && (y[y.length] = Wue(Xue(g), c[S], f)), h[S] = y.length - 1;
      return [2, (0, Rue.SecondaryStructure)(v, h, y, C)];
    });
  });
}
Iv.computeUnitDSSP = Kue;
function Wue(e, r, t) {
  return e === "helix" ? {
    kind: "helix",
    flags: t(r)
  } : e === "sheet" ? {
    kind: "sheet",
    flags: t(r)
  } : e === "turn" || e === "bend" ? {
    kind: "turn",
    flags: t(r)
  } : {
    kind: "none"
  };
}
function Xue(e) {
  return e === jn.SecondaryStructureType.SecondaryStructureDssp.H || e === jn.SecondaryStructureType.SecondaryStructureDssp.G || e === jn.SecondaryStructureType.SecondaryStructureDssp.I ? "helix" : e === jn.SecondaryStructureType.SecondaryStructureDssp.B || e === jn.SecondaryStructureType.SecondaryStructureDssp.E ? "sheet" : e === jn.SecondaryStructureType.SecondaryStructureDssp.T ? "turn" : e === jn.SecondaryStructureType.SecondaryStructureDssp.S ? "bend" : "none";
}
function Yue(e) {
  return wt.DSSPType.is(
    e,
    1
    /* H */
  ) ? jn.SecondaryStructureType.SecondaryStructureDssp.H : wt.DSSPType.is(
    e,
    4
    /* E */
  ) ? jn.SecondaryStructureType.SecondaryStructureDssp.E : wt.DSSPType.is(
    e,
    2
    /* B */
  ) ? jn.SecondaryStructureType.SecondaryStructureDssp.B : wt.DSSPType.is(
    e,
    8
    /* G */
  ) ? jn.SecondaryStructureType.SecondaryStructureDssp.G : wt.DSSPType.is(
    e,
    16
    /* I */
  ) ? jn.SecondaryStructureType.SecondaryStructureDssp.I : wt.DSSPType.is(
    e,
    64
    /* T */
  ) ? jn.SecondaryStructureType.SecondaryStructureDssp.T : wt.DSSPType.is(
    e,
    32
    /* S */
  ) ? jn.SecondaryStructureType.SecondaryStructureDssp.S : 0;
}
function Que(e) {
  return wt.DSSPType.is(
    e,
    1
    /* H */
  ) ? "H" : wt.DSSPType.is(
    e,
    4
    /* E */
  ) ? "E" : wt.DSSPType.is(
    e,
    2
    /* B */
  ) ? "B" : wt.DSSPType.is(
    e,
    8
    /* G */
  ) ? "G" : wt.DSSPType.is(
    e,
    16
    /* I */
  ) ? "I" : wt.DSSPType.is(
    e,
    64
    /* T */
  ) ? "T" : wt.DSSPType.is(
    e,
    32
    /* S */
  ) ? "S" : "-";
}
function Zue(e) {
  return wt.DSSPType.is(
    e,
    16
    /* I */
  ) ? jn.SecondaryStructureType.SecondaryStructureDssp.I : wt.DSSPType.is(
    e,
    1
    /* H */
  ) ? jn.SecondaryStructureType.SecondaryStructureDssp.H : wt.DSSPType.is(
    e,
    4
    /* E */
  ) ? jn.SecondaryStructureType.SecondaryStructureDssp.E : wt.DSSPType.is(
    e,
    2
    /* B */
  ) ? jn.SecondaryStructureType.SecondaryStructureDssp.B : wt.DSSPType.is(
    e,
    8
    /* G */
  ) ? jn.SecondaryStructureType.SecondaryStructureDssp.G : wt.DSSPType.is(
    e,
    64
    /* T */
  ) ? jn.SecondaryStructureType.SecondaryStructureDssp.T : wt.DSSPType.is(
    e,
    32
    /* S */
  ) ? jn.SecondaryStructureType.SecondaryStructureDssp.S : 0;
}
function Jue(e) {
  return wt.DSSPType.is(
    e,
    16
    /* I */
  ) ? "I" : wt.DSSPType.is(
    e,
    1
    /* H */
  ) ? "H" : wt.DSSPType.is(
    e,
    4
    /* E */
  ) ? "E" : wt.DSSPType.is(
    e,
    2
    /* B */
  ) ? "B" : wt.DSSPType.is(
    e,
    8
    /* G */
  ) ? "G" : wt.DSSPType.is(
    e,
    64
    /* T */
  ) ? "T" : wt.DSSPType.is(
    e,
    32
    /* S */
  ) ? "S" : "-";
}
function ese(e, r) {
  for (var t = new Uint32Array(e.length), n = 0, a = e.length; n < a; ++n) {
    var i = wt.DSSPType.create(e[n]);
    t[n] = r(i);
  }
  return t;
}
var N0 = {};
Object.defineProperty(N0, "__esModule", { value: !0 });
N0.CustomStructureProperty = void 0;
var Cf = Te, Es = Le, U8 = We(), rse = In, tse = cs, wM;
(function(e) {
  function r(n) {
    var a = this, i = n.descriptor.name, o = n.type === "root" ? "inheritedPropertyData" : "currentPropertyData", c = function(u) {
      return i in u[o] || (u[o][i] = {
        props: (0, Cf.__assign)({}, Es.ParamDefinition.getDefaultValues(n.getParams(u))),
        data: U8.ValueBox.create(void 0)
      }), u[o][i];
    }, s = function(u, l, f) {
      var d = c(u);
      u[o][i] = {
        props: l,
        data: U8.ValueBox.withValue(d.data, f)
      };
    };
    return {
      label: n.label,
      descriptor: n.descriptor,
      isHidden: n.isHidden,
      getParams: function(u) {
        var l = Es.ParamDefinition.clone(n.getParams(u));
        return Es.ParamDefinition.setDefaultValues(l, c(u).props), l;
      },
      defaultParams: n.defaultParams,
      isApplicable: n.isApplicable,
      attach: function(u, l, f, d) {
        return f === void 0 && (f = {}), (0, Cf.__awaiter)(a, void 0, void 0, function() {
          var m, p, v, h, y, C;
          return (0, Cf.__generator)(this, function(S) {
            switch (S.label) {
              case 0:
                return d && l.customPropertyDescriptors.reference(n.descriptor, !0), n.type === "root" && (l = l.root), m = c(l.root).props, p = c(l), v = Es.ParamDefinition.merge(n.defaultParams, m, f), p.data.value && Es.ParamDefinition.areEqual(n.defaultParams, p.props, v) ? [
                  2
                  /*return*/
                ] : [4, n.obtain(u, l, v)];
              case 1:
                return h = S.sent(), y = h.value, C = h.assets, l.customPropertyDescriptors.add(n.descriptor), l.customPropertyDescriptors.assets(n.descriptor, C), s(l, v, y), [
                  2
                  /*return*/
                ];
            }
          });
        });
      },
      ref: function(u, l) {
        return u.customPropertyDescriptors.reference(n.descriptor, l);
      },
      get: function(u) {
        return c(u).data;
      },
      set: function(u, l, f) {
        l === void 0 && (l = {}), n.type === "root" && (u = u.root);
        var d = c(u), m = Es.ParamDefinition.merge(n.defaultParams, d.props, l);
        Es.ParamDefinition.areEqual(n.defaultParams, d.props, m) || (s(u, m, f), u.customPropertyDescriptors.assets(n.descriptor));
      },
      props: function(u) {
        return c(u).props;
      }
    };
  }
  e.createProvider = r;
  function t(n, a, i) {
    var o = this, c = { value: Es.ParamDefinition.Value(i, { isHidden: !0 }) };
    return r({
      label: (0, tse.stringToWords)(n),
      descriptor: (0, rse.CustomPropertyDescriptor)({ name: n }),
      isHidden: !0,
      type: a,
      defaultParams: c,
      getParams: function() {
        return { value: Es.ParamDefinition.Value(i, { isHidden: !0 }) };
      },
      isApplicable: function() {
        return !0;
      },
      obtain: function(s, u, l) {
        return (0, Cf.__awaiter)(o, void 0, void 0, function() {
          return (0, Cf.__generator)(this, function(f) {
            return [2, (0, Cf.__assign)((0, Cf.__assign)({}, Es.ParamDefinition.getDefaultValues(c)), l)];
          });
        });
      }
    });
  }
  e.createSimple = t;
})(wM || (wM = {}));
N0.CustomStructureProperty = wM;
var z8;
function Ac() {
  return z8 || (z8 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.SecondaryStructureProvider = e.SecondaryStructureParams = void 0;
    var r = Te, t = Iv, n = Le, a = ia(), i = N0, o = Pp, c = In, s = O0();
    function u(d) {
      var m = "model";
      if (d) {
        m = "model";
        for (var p = 0, v = d.models.length; p < v; ++p) {
          var h = d.models[p];
          if (!(s.Model.isFromPdbArchive(h) || s.Model.hasSecondaryStructure(h))) {
            m = "dssp";
            break;
          }
        }
      }
      return {
        type: n.ParamDefinition.MappedStatic(m, {
          model: n.ParamDefinition.EmptyGroup({ label: "Model" }),
          dssp: n.ParamDefinition.Group(t.DSSPComputationParams, { label: "DSSP", isFlat: !0 })
        }, { options: [["model", "Model"], ["dssp", "DSSP"]] })
      };
    }
    e.SecondaryStructureParams = u(), e.SecondaryStructureProvider = i.CustomStructureProperty.createProvider({
      label: "Secondary Structure",
      descriptor: (0, c.CustomPropertyDescriptor)({
        name: "molstar_computed_secondary_structure"
        // TODO `cifExport` and `symbol`
      }),
      type: "root",
      defaultParams: e.SecondaryStructureParams,
      getParams: u,
      isApplicable: function(d) {
        return !0;
      },
      obtain: function(d, m, p) {
        return (0, r.__awaiter)(void 0, void 0, void 0, function() {
          var v, h, y, C;
          return (0, r.__generator)(this, function(S) {
            switch (S.label) {
              case 0:
                switch (v = (0, r.__assign)((0, r.__assign)({}, n.ParamDefinition.getDefaultValues(e.SecondaryStructureParams)), p), h = v.type.name, h) {
                  case "dssp":
                    return [3, 1];
                  case "model":
                    return [3, 3];
                }
                return [3, 5];
              case 1:
                return y = {}, [4, l(m, v.type.params)];
              case 2:
                return [2, (y.value = S.sent(), y)];
              case 3:
                return C = {}, [4, f(m)];
              case 4:
                return [2, (C.value = S.sent(), C)];
              case 5:
                return [
                  2
                  /*return*/
                ];
            }
          });
        });
      }
    });
    function l(d, m) {
      return (0, r.__awaiter)(this, void 0, void 0, function() {
        var p, v, h, y, C;
        return (0, r.__generator)(this, function(S) {
          switch (S.label) {
            case 0:
              p = /* @__PURE__ */ new Map(), v = 0, h = d.unitSymmetryGroups.length, S.label = 1;
            case 1:
              return v < h ? (y = d.unitSymmetryGroups[v].units[0], a.Unit.isAtomic(y) && !s.Model.isCoarseGrained(y.model) ? [4, (0, t.computeUnitDSSP)(y, m)] : [3, 3]) : [3, 4];
            case 2:
              C = S.sent(), p.set(y.invariantId, C), S.label = 3;
            case 3:
              return ++v, [3, 1];
            case 4:
              return [2, p];
          }
        });
      });
    }
    function f(d) {
      return (0, r.__awaiter)(this, void 0, void 0, function() {
        var m, p, v, h, y, y;
        return (0, r.__generator)(this, function(C) {
          switch (C.label) {
            case 0:
              m = /* @__PURE__ */ new Map(), p = 0, v = d.unitSymmetryGroups.length, C.label = 1;
            case 1:
              return p < v ? (h = d.unitSymmetryGroups[p].units[0], a.Unit.isAtomic(h) ? s.Model.isFromPdbArchive(h.model) || s.Model.hasSecondaryStructure(h.model) ? [3, 3] : [4, (0, t.computeUnitDSSP)(h, {
                oldDefinition: !0,
                oldOrdering: !0
              })] : [3, 4]) : [3, 5];
            case 2:
              return y = C.sent(), m.set(h.invariantId, y), [3, 4];
            case 3:
              y = o.ModelSecondaryStructure.Provider.get(h.model), y && m.set(h.invariantId, y), C.label = 4;
            case 4:
              return ++p, [3, 1];
            case 5:
              return [2, m];
          }
        });
      });
    }
  }(v5)), v5;
}
var G8;
function V0() {
  if (G8) return Lh;
  G8 = 1, Object.defineProperty(Lh, "__esModule", { value: !0 }), Lh.StructureProperties = void 0;
  var e = vl(), r = _s, t = Ac(), n = nr();
  function a(g) {
    return g;
  }
  var i = {
    true: function(g) {
      return !0;
    },
    false: function(g) {
      return !1;
    },
    zero: function(g) {
      return 0;
    }
  };
  function o() {
    throw new Error("Property only available for atomic models.");
  }
  function c(g) {
    throw g ? new Error("Property only available for coarse models (".concat(g, ").")) : new Error("Property only available for coarse models.");
  }
  var s = {
    key: function(g) {
      return g.element;
    },
    // Conformation
    x: function(g) {
      return g.unit.conformation.x(g.element);
    },
    y: function(g) {
      return g.unit.conformation.y(g.element);
    },
    z: function(g) {
      return g.unit.conformation.z(g.element);
    },
    id: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicConformation.atomId.value(g.element) : o();
    },
    occupancy: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicConformation.occupancy.value(g.element) : o();
    },
    B_iso_or_equiv: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicConformation.B_iso_or_equiv.value(g.element) : o();
    },
    sourceIndex: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicHierarchy.atomSourceIndex.value(g.element) : g.element;
    },
    // Hierarchy
    type_symbol: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicHierarchy.atoms.type_symbol.value(g.element) : o();
    },
    label_atom_id: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicHierarchy.atoms.label_atom_id.value(g.element) : o();
    },
    auth_atom_id: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicHierarchy.atoms.auth_atom_id.value(g.element) : o();
    },
    label_alt_id: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicHierarchy.atoms.label_alt_id.value(g.element) : o();
    },
    label_comp_id: u,
    auth_comp_id: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicHierarchy.atoms.auth_comp_id.value(g.element) : o();
    },
    pdbx_formal_charge: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicHierarchy.atoms.pdbx_formal_charge.value(g.element) : o();
    },
    // Derived
    vdw_radius: function(g) {
      return e.Unit.isAtomic(g.unit) ? (0, r.VdwRadius)(g.unit.model.atomicHierarchy.atoms.type_symbol.value(g.element)) : o();
    },
    cdr: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicHierarchy.atoms.cdr.value(g.element) : o();
    },
    em_confidence: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicHierarchy.atoms.em_confidence.value(g.element) : o();
    }
  };
  function u(g) {
    return e.Unit.isAtomic(g.unit) || o(), g.unit.model.atomicHierarchy.atoms.label_comp_id.value(g.element);
  }
  function l(g) {
    return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicHierarchy.residues.label_seq_id.value(g.unit.residueIndex[g.element]) : o();
  }
  function f(g) {
    e.Unit.isAtomic(g.unit) || o();
    var _ = g.unit.model.sequence.byEntityKey[h(g)];
    return _ && _.sequence.microHet.has(l(g));
  }
  function d(g) {
    e.Unit.isAtomic(g.unit) || o();
    var _ = g.unit.model.sequence.byEntityKey[h(g)];
    return _ ? _.sequence.microHet.get(l(g)) || [u(g)] : [u(g)];
  }
  var m = {
    key: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.residueIndex[g.element] : o();
    },
    group_PDB: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicHierarchy.residues.group_PDB.value(g.unit.residueIndex[g.element]) : o();
    },
    label_seq_id: l,
    auth_seq_id: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicHierarchy.residues.auth_seq_id.value(g.unit.residueIndex[g.element]) : o();
    },
    pdbx_PDB_ins_code: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(g.unit.residueIndex[g.element]) : o();
    },
    // Properties
    isNonStandard: function(g) {
      return e.Unit.isAtomic(g.unit) ? d(g).some(function(_) {
        return g.unit.model.properties.chemicalComponentMap.get(_).mon_nstd_flag[0] === "n";
      }) : o();
    },
    hasMicroheterogeneity: f,
    microheterogeneityCompIds: d,
    secondary_structure_type: function(g) {
      var _;
      e.Unit.isAtomic(g.unit) || o();
      var A = (_ = t.SecondaryStructureProvider.get(g.structure).value) === null || _ === void 0 ? void 0 : _.get(g.unit.invariantId);
      return A ? A.type[A.getIndex(g.unit.residueIndex[g.element])] : 536870912;
    },
    secondary_structure_key: function(g) {
      var _;
      e.Unit.isAtomic(g.unit) || o();
      var A = (_ = t.SecondaryStructureProvider.get(g.structure).value) === null || _ === void 0 ? void 0 : _.get(g.unit.invariantId);
      return A ? A.key[A.getIndex(g.unit.residueIndex[g.element])] : -1;
    },
    chem_comp_type: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.properties.chemicalComponentMap.get(u(g)).type : o();
    }
  }, p = {
    key: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.chainIndex[g.element] : o();
    },
    label_asym_id: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicHierarchy.chains.label_asym_id.value(g.unit.chainIndex[g.element]) : o();
    },
    auth_asym_id: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicHierarchy.chains.auth_asym_id.value(g.unit.chainIndex[g.element]) : o();
    },
    label_entity_id: function(g) {
      return e.Unit.isAtomic(g.unit) ? g.unit.model.atomicHierarchy.chains.label_entity_id.value(g.unit.chainIndex[g.element]) : o();
    }
  }, v = {
    key: s.key,
    entityKey: function(g) {
      return e.Unit.isCoarse(g.unit) ? g.unit.coarseElements.entityKey[g.element] : c();
    },
    x: s.x,
    y: s.y,
    z: s.z,
    asym_id: function(g) {
      return e.Unit.isCoarse(g.unit) ? g.unit.coarseElements.asym_id.value(g.element) : c();
    },
    entity_id: function(g) {
      return e.Unit.isCoarse(g.unit) ? g.unit.coarseElements.entity_id.value(g.element) : c();
    },
    seq_id_begin: function(g) {
      return e.Unit.isCoarse(g.unit) ? g.unit.coarseElements.seq_id_begin.value(g.element) : c();
    },
    seq_id_end: function(g) {
      return e.Unit.isCoarse(g.unit) ? g.unit.coarseElements.seq_id_end.value(g.element) : c();
    },
    sphere_radius: function(g) {
      return e.Unit.isSpheres(g.unit) ? g.unit.coarseConformation.radius[g.element] : c("spheres");
    },
    sphere_rmsf: function(g) {
      return e.Unit.isSpheres(g.unit) ? g.unit.coarseConformation.rmsf[g.element] : c("spheres");
    },
    gaussian_weight: function(g) {
      return e.Unit.isGaussians(g.unit) ? g.unit.coarseConformation.weight[g.element] : c("gaussians");
    },
    gaussian_covariance_matrix: function(g) {
      return e.Unit.isGaussians(g.unit) ? g.unit.coarseConformation.covariance_matrix[g.element] : c("gaussians");
    }
  };
  function h(g) {
    switch (g.unit.kind) {
      case 0:
        return g.unit.model.atomicHierarchy.index.getEntityFromChain(g.unit.chainIndex[g.element]);
      case 1:
        return g.unit.model.coarseHierarchy.spheres.entityKey[g.element];
      case 2:
        return g.unit.model.coarseHierarchy.gaussians.entityKey[g.element];
    }
  }
  var y = {
    key: h,
    id: function(g) {
      return g.unit.model.entities.data.id.value(h(g));
    },
    type: function(g) {
      return g.unit.model.entities.data.type.value(h(g));
    },
    src_method: function(g) {
      return g.unit.model.entities.data.src_method.value(h(g));
    },
    pdbx_description: function(g) {
      return g.unit.model.entities.data.pdbx_description.value(h(g));
    },
    formula_weight: function(g) {
      return g.unit.model.entities.data.formula_weight.value(h(g));
    },
    pdbx_number_of_molecules: function(g) {
      return g.unit.model.entities.data.pdbx_number_of_molecules.value(h(g));
    },
    details: function(g) {
      return g.unit.model.entities.data.details.value(h(g));
    },
    pdbx_mutation: function(g) {
      return g.unit.model.entities.data.pdbx_mutation.value(h(g));
    },
    pdbx_fragment: function(g) {
      return g.unit.model.entities.data.pdbx_fragment.value(h(g));
    },
    pdbx_ec: function(g) {
      return g.unit.model.entities.data.pdbx_ec.value(h(g));
    },
    subtype: function(g) {
      return g.unit.model.entities.subtype.value(h(g));
    },
    prd_id: function(g) {
      var _, A;
      return (A = (_ = g.unit.model.entities.prd_id) === null || _ === void 0 ? void 0 : _.value(h(g))) !== null && A !== void 0 ? A : "";
    }
  }, C = [], S = {
    id: function(g) {
      return g.unit.id;
    },
    chainGroupId: function(g) {
      return g.unit.chainGroupId;
    },
    multiChain: function(g) {
      return e.Unit.Traits.is(
        g.unit.traits,
        1
        /* MultiChain */
      );
    },
    object_primitive: function(g) {
      return g.unit.objectPrimitive;
    },
    operator_name: function(g) {
      return g.unit.conformation.operator.name;
    },
    model_index: function(g) {
      return g.unit.model.modelNum;
    },
    model_label: function(g) {
      return g.unit.model.label;
    },
    model_entry_id: function(g) {
      return g.unit.model.entryId;
    },
    hkl: function(g) {
      return g.unit.conformation.operator.hkl;
    },
    spgrOp: function(g) {
      return g.unit.conformation.operator.spgrOp;
    },
    model_num: function(g) {
      return g.unit.model.modelNum;
    },
    pdbx_struct_assembly_id: function(g) {
      var _;
      return ((_ = g.unit.conformation.operator.assembly) === null || _ === void 0 ? void 0 : _.id) || n.SymmetryOperator.DefaultName;
    },
    pdbx_struct_oper_list_ids: function(g) {
      var _;
      return ((_ = g.unit.conformation.operator.assembly) === null || _ === void 0 ? void 0 : _.operList) || C;
    },
    struct_ncs_oper_id: function(g) {
      return g.unit.conformation.operator.ncsId;
    }
  }, b = {
    constant: i,
    atom: s,
    residue: m,
    chain: p,
    entity: y,
    unit: S,
    coarse: v
  };
  return Lh.StructureProperties = b, Lh;
}
var q8;
function nse() {
  if (q8) return Fh;
  q8 = 1, Object.defineProperty(Fh, "__esModule", { value: !0 }), Fh.ResidueSet = void 0;
  var e = V0(), r = (
    /** @class */
    function() {
      function s(u) {
        var l;
        this.index = /* @__PURE__ */ new Map(), this.checkOperator = !1, this.checkOperator = (l = u == null ? void 0 : u.checkOperator) !== null && l !== void 0 ? l : !1;
      }
      return s.prototype.add = function(u) {
        var l = this.index.get(u.label_asym_id);
        l || (l = /* @__PURE__ */ new Map(), this.index.set(u.label_asym_id, l));
        var f = l.get(u.label_seq_id);
        f || (f = [], l.set(u.label_seq_id, f));
        var d = this._find(u, f);
        return d ? !1 : (f.push(u), !0);
      }, s.prototype.hasLabelAsymId = function(u) {
        return this.index.has(u);
      }, s.prototype.has = function(u) {
        var l, f, d = t(u);
        if (this.index.has(d)) {
          var m = this.index.get(d), p = n(u);
          if (m.has(p))
            for (var v = m.get(p), h = a(u), y = i(u), C = o(u), S = (l = c(u)) !== null && l !== void 0 ? l : "1_555", b = 0, g = v; b < g.length; b++) {
              var _ = g[b];
              if (!(_.label_comp_id !== h || _.label_alt_id !== y || _.ins_code !== C) && !(this.checkOperator && ((f = _.operator_name) !== null && f !== void 0 ? f : "1_555") !== S))
                return _;
            }
        }
      }, s.getLabel = function(u, l) {
        var f;
        return l === void 0 && (l = !1), "".concat(u.label_asym_id, " ").concat(u.label_comp_id, " ").concat(u.label_seq_id, ":").concat(u.ins_code, ":").concat(u.label_alt_id).concat(l ? " " + ((f = u.operator_name) !== null && f !== void 0 ? f : "1_555") : "");
      }, s.getEntryFromLocation = function(u) {
        var l;
        return {
          label_asym_id: t(u),
          label_comp_id: a(u),
          label_seq_id: n(u),
          label_alt_id: i(u),
          ins_code: o(u),
          operator_name: (l = c(u)) !== null && l !== void 0 ? l : "1_555"
        };
      }, s.prototype._find = function(u, l) {
        for (var f, d, m = 0, p = l; m < p.length; m++) {
          var v = p[m];
          if (!(v.label_comp_id !== u.label_comp_id || v.label_alt_id !== u.label_alt_id || v.ins_code !== u.ins_code) && !(this.checkOperator && ((f = v.operator_name) !== null && f !== void 0 ? f : "1_555") !== ((d = u.operator_name) !== null && d !== void 0 ? d : "1_555")))
            return !0;
        }
        return !1;
      }, s;
    }()
  );
  Fh.ResidueSet = r;
  var t = e.StructureProperties.chain.label_asym_id, n = e.StructureProperties.residue.label_seq_id, a = e.StructureProperties.atom.label_comp_id, i = e.StructureProperties.atom.label_alt_id, o = e.StructureProperties.residue.pdbx_PDB_ins_code, c = e.StructureProperties.unit.operator_name;
  return Fh;
}
var H8;
function ase() {
  if (H8) return Un;
  H8 = 1, Object.defineProperty(Un, "__esModule", { value: !0 }), Un.surroundingLigands = Un.includeConnected = Un.expandProperty = Un.union = Un.exceptBy = Un.intersectBy = Un.querySelection = Un.includeSurroundings = Un.wholeResidues = void 0;
  var e = Te, r = Qe(), t = jd(), n = dG(), a = uoe(), i = dy(), o = Po, c = Mp(), s = Jo(), u = nse(), l = V0(), f = hr;
  function d(N, O, V) {
    for (var k = O.subsetBuilder(!0), G = 0, L = V.units; G < L.length; G++) {
      var R = L[G];
      if (R.kind !== 0) {
        k.setUnit(R.id, R.elements);
        continue;
      }
      var F = R.model.atomicHierarchy.residueAtomSegments, U = O.unitMap.get(R.id).elements, H = R.elements;
      k.beginUnit(R.id);
      for (var q = r.Segmentation.transientSegments(F, H); q.hasNext; )
        for (var K = q.move().index, Y = F.offsets[K], X = F.offsets[K + 1]; Y < X; Y++)
          r.SortedArray.has(U, Y) && k.addElement(Y);
      k.commitUnit(), N.throwIfTimedOut();
    }
    return k.getStructure();
  }
  function m(N) {
    return function(V) {
      var k = N(V);
      if (t.StructureSelection.isSingleton(k))
        return t.StructureSelection.Singletons(V.inputStructure, d(V, V.inputStructure, k.structure));
      for (var G = new n.UniqueStructuresBuilder(V.inputStructure), L = 0, R = k.structures; L < R.length; L++) {
        var F = R[L];
        G.add(d(V, V.inputStructure, F));
      }
      return G.getSelection();
    };
  }
  Un.wholeResidues = m;
  function p(N, O, V, k) {
    for (var G = new a.StructureUniqueSubsetBuilder(O), L = O.lookup3d, R = k.radius, F = 0, U = V.units; F < U.length; F++) {
      for (var H = U[F], q = H.conformation, K = q.x, Y = q.y, X = q.z, Z = H.elements, J = 0, $ = Z.length; J < $; J++) {
        var Q = Z[J];
        L.findIntoBuilder(K(Q), Y(Q), X(Q), R, G);
      }
      N.throwIfTimedOut();
    }
    return k.wholeResidues ? d(N, O, G.getStructure()) : G.getStructure();
  }
  function v(N, O, V, k) {
    var G = new a.StructureUniqueSubsetBuilder(O), L = O.lookup3d, R = k.elementRadius, F = k.elementRadiusClosure, U = k.sourceMaxRadius, H = k.radius;
    N.pushCurrentElement(), N.element.structure = V;
    for (var q = 0, K = V.units; q < K.length; q++) {
      var Y = K[q];
      N.element.unit = Y;
      for (var X = Y.conformation, Z = X.x, J = X.y, $ = X.z, Q = Y.elements, W = 0, te = Q.length; W < te; W++) {
        var oe = Q[W];
        N.element.element = oe;
        var z = R(N);
        L.findIntoBuilderWithRadius(Z(oe), J(oe), $(oe), z, U, H, F, G);
      }
      N.throwIfTimedOut();
    }
    return N.popCurrentElement(), k.wholeResidues ? d(N, O, G.getStructure()) : G.getStructure();
  }
  function h(N, O) {
    return function(V) {
      return N.element.structure = V.structure, N.element.unit = V.unit, N.element.element = V.element, O(N);
    };
  }
  function y(N, O) {
    var V = 0;
    N.element.structure = N.inputStructure;
    for (var k = 0, G = N.inputStructure.units; k < G.length; k++) {
      var L = G[k];
      N.element.unit = L;
      for (var R = L.elements, F = 0, U = R.length; F < U; F++) {
        var H = R[F];
        N.element.element = H;
        var q = O(N);
        q > V && (V = q);
      }
    }
    return N.throwIfTimedOut(), V;
  }
  function C(N, O) {
    return function(k) {
      var G = N(k);
      if (O.elementRadius) {
        var L = (0, e.__assign)((0, e.__assign)({}, O), { elementRadius: O.elementRadius, elementRadiusClosure: h(k, O.elementRadius), sourceMaxRadius: y(k, O.elementRadius) });
        if (t.StructureSelection.isSingleton(G)) {
          var R = v(k, k.inputStructure, G.structure, L), F = t.StructureSelection.Singletons(k.inputStructure, R);
          return F;
        } else {
          for (var U = new n.UniqueStructuresBuilder(k.inputStructure), H = 0, q = G.structures; H < q.length; H++) {
            var K = q[H];
            U.add(v(k, k.inputStructure, K, L));
          }
          return U.getSelection();
        }
      }
      if (t.StructureSelection.isSingleton(G)) {
        var R = p(k, k.inputStructure, G.structure, O), F = t.StructureSelection.Singletons(k.inputStructure, R);
        return F;
      } else {
        for (var U = new n.UniqueStructuresBuilder(k.inputStructure), Y = 0, X = G.structures; Y < X.length; Y++) {
          var K = X[Y];
          U.add(p(k, k.inputStructure, K, O));
        }
        return U.getSelection();
      }
    };
  }
  Un.includeSurroundings = C;
  function S(N, O) {
    return function(k) {
      var G = N(k);
      if (t.StructureSelection.structureCount(G) === 0)
        return G;
      var L = t.StructureSelection.UniqueBuilder(k.inputStructure), R = function(F) {
        return L.add(F);
      };
      return t.StructureSelection.forEach(G, function(F, U) {
        k.pushInputStructure(F), t.StructureSelection.forEach(O(k), R), k.popInputStructure(), U % 10 === 0 && k.throwIfTimedOut();
      }), L.getSelection();
    };
  }
  Un.querySelection = S;
  function b(N, O) {
    return function(k) {
      var G = N(k);
      if (t.StructureSelection.structureCount(G) === 0)
        return G;
      var L = O(k);
      if (t.StructureSelection.structureCount(L) === 0)
        return t.StructureSelection.Empty(k.inputStructure);
      var R = t.StructureSelection.unionStructure(L), F = t.StructureSelection.UniqueBuilder(k.inputStructure);
      return t.StructureSelection.forEach(G, function(U, H) {
        var q = (0, i.structureIntersect)(R, U);
        q.elementCount !== 0 && F.add(q), H % 50 === 0 && k.throwIfTimedOut();
      }), F.getSelection();
    };
  }
  Un.intersectBy = b;
  function g(N, O) {
    return function(k) {
      var G = N(k);
      if (t.StructureSelection.structureCount(G) === 0)
        return G;
      var L = O(k);
      if (t.StructureSelection.structureCount(L) === 0)
        return G;
      var R = t.StructureSelection.unionStructure(L), F = t.StructureSelection.UniqueBuilder(k.inputStructure);
      return t.StructureSelection.forEach(G, function(U, H) {
        var q = (0, i.structureSubtract)(U, R);
        q.elementCount !== 0 && F.add(q), H % 50 === 0 && k.throwIfTimedOut();
      }), F.getSelection();
    };
  }
  Un.exceptBy = g;
  function _(N) {
    return function(V) {
      var k = t.StructureSelection.LinearBuilder(V.inputStructure);
      return k.add(t.StructureSelection.unionStructure(N(V))), k.getSelection();
    };
  }
  Un.union = _;
  function A(N, O) {
    return function(k) {
      var G = N(k), L = /* @__PURE__ */ new Map(), R = [];
      k.pushCurrentElement(), t.StructureSelection.forEach(G, function(z, j) {
        k.element.structure = z;
        for (var ae = 0, le = z.units; ae < le.length; ae++) {
          var ie = le[ae];
          k.element.unit = ie;
          for (var re = ie.elements, ee = 0, ne = re.length; ee < ne; ee++) {
            k.element.element = re[ee];
            var se = O(k), ce = void 0;
            L.has(se) ? ce = L.get(se) : (ce = o.UniqueArray.create(), L.set(se, ce)), o.UniqueArray.add(ce, j, j);
          }
        }
        R[j] = k.inputStructure.subsetBuilder(!0), j % 10 === 0 && k.throwIfTimedOut();
      }), k.element.structure = k.inputStructure;
      for (var F = 0, U = k.inputStructure.units; F < U.length; F++) {
        var H = U[F];
        k.element.unit = H;
        for (var q = H.elements, K = 0, Y = q.length; K < Y; K++) {
          k.element.element = q[K];
          var X = O(k);
          if (L.has(X))
            for (var Z = L.get(X).array, J = 0, $ = Z.length; J < $; J++)
              R[Z[J]].addToUnit(H.id, q[K]);
        }
      }
      k.popCurrentElement();
      for (var Q = t.StructureSelection.UniqueBuilder(k.inputStructure), W = 0, te = R; W < te.length; W++) {
        var oe = te[W];
        Q.add(oe.getStructure());
      }
      return Q.getSelection();
    };
  }
  Un.expandProperty = A;
  function M(N) {
    var O = N.query, V = N.layerCount, k = N.wholeResidues, G = N.bondTest, L = N.fixedPoint, R = Math.max(V, 0);
    return function(U) {
      var H = t.StructureSelection.UniqueBuilder(U.inputStructure), q = O(U);
      return U.pushCurrentBond(), U.atomicBond.setTestFn(G), t.StructureSelection.forEach(q, function(K, Y) {
        var X = K;
        if (L)
          for (; ; ) {
            var Z = X.elementCount;
            if (X = P(U, k, X), X.elementCount === Z)
              break;
          }
        else
          for (var J = 0; J < R; J++)
            X = P(U, k, X);
        H.add(X), Y % 10 === 0 && U.throwIfTimedOut();
      }), U.popCurrentBond(), H.getSelection();
    };
  }
  Un.includeConnected = M;
  function P(N, O, V) {
    var k = T(N, V);
    return O ? d(N, N.inputStructure, k) : k;
  }
  function T(N, O) {
    for (var V = N.inputStructure, k = V.interUnitBonds, G = new a.StructureUniqueSubsetBuilder(V), L = N.atomicBond, R = 0, F = O.units; R < F.length; R++) {
      var U = F[R];
      if (U.kind !== 0) {
        G.beginUnit(U.id);
        for (var H = 0, q = U.elements.length; H < q; H++)
          G.addElement(U.elements[H]);
        G.commitUnit();
        continue;
      }
      var K = V.unitMap.get(U.id), Y = K.bonds, X = Y.offset, Z = Y.b, J = Y.edgeProps, $ = J.flags, Q = J.order;
      L.setStructure(V), L.a.unit = K, L.b.unit = K;
      for (var H = 0, q = U.elements.length; H < q; H++) {
        G.addToUnit(U.id, U.elements[H]);
        for (var W = r.SortedArray.indexOf(K.elements, U.elements[H]), te = X[W], oe = X[W + 1]; te < oe; te++) {
          var z = Z[te], j = K.elements[z];
          r.SortedArray.has(U.elements, j) || G.has(U.id, j) || (L.aIndex = W, L.a.element = U.elements[H], L.bIndex = z, L.b.element = j, L.type = $[te], L.order = Q[te], L.test(N, !0) && G.addToUnit(U.id, j));
        }
      }
      for (var ae = 0, le = k.getConnectedUnits(K.id); ae < le.length; ae++)
        for (var ie = le[ae], re = O.unitMap.get(ie.unitB), ee = V.unitMap.get(ie.unitB), ne = 0, se = ie.connectedIndices; ne < se.length; ne++) {
          var ce = se[ne];
          if (r.SortedArray.has(U.elements, K.elements[ce]))
            for (var de = 0, me = ie.getEdges(ce); de < me.length; de++) {
              var he = me[de], j = ee.elements[he.indexB];
              re && r.SortedArray.has(re.elements, j) || G.has(ie.unitB, j) || (L.a.unit = K, L.aIndex = ce, L.a.element = K.elements[ce], L.b.unit = ee, L.bIndex = he.indexB, L.b.element = j, L.type = he.props.flag, L.order = he.props.order, L.test(N, !0) && G.addToUnit(ie.unitB, j));
            }
        }
    }
    return G.getStructure();
  }
  function x(N) {
    var O = N.query, V = N.radius, k = N.includeWater;
    return function(L) {
      for (var R = t.StructureSelection.unionStructure(O(L)), F = d(L, L.inputStructure, p(L, L.inputStructure, R, { radius: V })), U = I(L.inputStructure), H = B(L.inputStructure), q = c.StructureElement.Location.create(F), K = /* @__PURE__ */ new Map(), Y = new u.ResidueSet({ checkOperator: !0 }), X = 0, Z = F.units; X < Z.length; X++) {
        var J = Z[X];
        if (J.kind === 0) {
          q.unit = J;
          for (var $ = J.elements, Q = r.Segmentation.transientSegments(J.model.atomicHierarchy.chainAtomSegments, $), W = r.Segmentation.transientSegments(J.model.atomicHierarchy.residueAtomSegments, $); Q.hasNext; ) {
            var te = Q.move();
            q.element = $[te.start];
            var oe = l.StructureProperties.chain.label_asym_id(q), z = l.StructureProperties.unit.operator_name(q);
            if (U.has(oe)) {
              K.has(oe) ? (0, f.arraySetAdd)(K.get(oe), z) : K.set(oe, [z]);
              continue;
            }
            var j = l.StructureProperties.entity.type(q);
            if (!(j === "water" || j === "polymer"))
              for (W.setSegment(te); W.hasNext; ) {
                var ae = W.move();
                q.element = $[ae.start], H.addComponent(u.ResidueSet.getEntryFromLocation(q), Y);
              }
          }
          L.throwIfTimedOut();
        }
      }
      for (var le = L.inputStructure.subsetBuilder(!0), ie = 0, re = L.inputStructure.units; ie < re.length; ie++) {
        var J = re[ie];
        if (J.kind === 0) {
          q.unit = J;
          var $ = J.elements, Q = r.Segmentation.transientSegments(J.model.atomicHierarchy.chainAtomSegments, $), W = r.Segmentation.transientSegments(J.model.atomicHierarchy.residueAtomSegments, $);
          for (le.beginUnit(J.id); Q.hasNext; ) {
            var te = Q.move();
            q.element = $[te.start];
            var oe = l.StructureProperties.chain.label_asym_id(q), z = l.StructureProperties.unit.operator_name(q);
            if (K.has(oe) && K.get(oe).indexOf(z) >= 0) {
              le.addElementRange($, te.start, te.end);
              continue;
            }
            if (Y.hasLabelAsymId(oe))
              for (W.setSegment(te); W.hasNext; ) {
                var ae = W.move();
                q.element = $[ae.start], Y.has(q) && le.addElementRange($, ae.start, ae.end);
              }
          }
          le.commitUnit(), L.throwIfTimedOut();
        }
      }
      var ee = (0, i.structureUnion)(L.inputStructure, [le.getStructure(), R]);
      if (k) {
        for (var ne = new a.StructureUniqueSubsetBuilder(L.inputStructure), se = L.inputStructure.lookup3d, ce = 0, de = ee.units; ce < de.length; ce++) {
          for (var J = de[ce], me = J.conformation, he = me.x, _e = me.y, Se = me.z, $ = J.elements, Pe = 0, De = $.length; Pe < De; Pe++) {
            var Ee = $[Pe];
            se.findIntoBuilderIf(he(Ee), _e(Ee), Se(Ee), V, ne, E), ne.addToUnit(J.id, Ee);
          }
          L.throwIfTimedOut();
        }
        return t.StructureSelection.Sequence(L.inputStructure, [ne.getStructure()]);
      } else
        return t.StructureSelection.Sequence(L.inputStructure, [ee]);
    };
  }
  Un.surroundingLigands = x;
  var w = l.StructureProperties.entity.type;
  function E(N) {
    return w(N) === "water";
  }
  function I(N) {
    var O = N.models[0], V = /* @__PURE__ */ new Set();
    if (!s.MmcifFormat.is(O.sourceData))
      return V;
    for (var k = O.sourceData.data.db.pdbx_molecule, G = k._rowCount, L = k.asym_id, R = 0; R < G; R++)
      V.add(L.value(R));
    return V;
  }
  function B(N) {
    var O, V, k = N.models[0], G = new D();
    if (!s.MmcifFormat.is(k.sourceData))
      return G;
    for (var L = k.sourceData.data.db.struct_conn, R = L.conn_type_id, F = L.ptnr1_label_asym_id, U = L.ptnr1_label_comp_id, H = L.ptnr1_label_seq_id, q = L.ptnr1_symmetry, K = L.pdbx_ptnr1_label_alt_id, Y = L.pdbx_ptnr1_PDB_ins_code, X = L.ptnr2_label_asym_id, Z = L.ptnr2_label_comp_id, J = L.ptnr2_label_seq_id, $ = L.ptnr2_symmetry, Q = L.pdbx_ptnr2_label_alt_id, W = L.pdbx_ptnr2_PDB_ins_code, te = 0; te < L._rowCount; te++) {
      var oe = R.value(te);
      if (!(oe !== "covale" && oe !== "metalc")) {
        var z = {
          label_asym_id: F.value(te),
          label_comp_id: U.value(te),
          label_seq_id: H.value(te),
          label_alt_id: K.value(te),
          ins_code: Y.value(te),
          operator_name: (O = q.value(te)) !== null && O !== void 0 ? O : "1_555"
        }, j = {
          label_asym_id: X.value(te),
          label_comp_id: Z.value(te),
          label_seq_id: J.value(te),
          label_alt_id: Q.value(te),
          ins_code: W.value(te),
          operator_name: (V = $.value(te)) !== null && V !== void 0 ? V : "1_555"
        };
        G.addEdge(z, j);
      }
    }
    return G;
  }
  var D = (
    /** @class */
    function() {
      function N() {
        this.vertices = /* @__PURE__ */ new Map(), this.edges = /* @__PURE__ */ new Map();
      }
      return N.prototype.addVertex = function(O, V) {
        this.vertices.has(V) || (this.vertices.set(V, O), this.edges.set(V, []));
      }, N.prototype.addEdge = function(O, V) {
        var k = u.ResidueSet.getLabel(O), G = u.ResidueSet.getLabel(V);
        this.addVertex(O, k), this.addVertex(V, G), (0, f.arraySetAdd)(this.edges.get(k), G), (0, f.arraySetAdd)(this.edges.get(G), k);
      }, N.prototype.addComponent = function(O, V) {
        var k = u.ResidueSet.getLabel(O);
        if (!this.vertices.has(k)) {
          V.add(O);
          return;
        }
        var G = /* @__PURE__ */ new Set(), L = /* @__PURE__ */ new Set(), R = [k];
        for (L.add(k), V.add(O); R.length > 0; ) {
          var F = R.pop();
          G.add(F);
          for (var U = this.vertices.get(F), H = 0, q = this.edges.get(F); H < q.length; H++) {
            var K = q[H];
            if (!G.has(K) && (R.push(K), !L.has(K))) {
              L.add(K);
              var Y = this.vertices.get(K);
              U.operator_name === Y.operator_name ? V.add((0, e.__assign)((0, e.__assign)({}, Y), { operator_name: O.operator_name })) : V.add(Y);
            }
          }
        }
      }, N;
    }()
  );
  return Un;
}
var za = {}, Bv = {};
Object.defineProperty(Bv, "__esModule", { value: !0 });
Bv.checkStructureMaxRadiusDistance = Bv.checkStructureMinMaxDistance = void 0;
var cv = Re;
function ise(e, r, t, n, a, i) {
  return r.elementCount === 0 || t.elementCount === 0 ? !0 : r.elementCount <= t.elementCount ? wb.check(e, r, t, n, a, i) : wb.check(e, t, r, n, a, i);
}
Bv.checkStructureMinMaxDistance = ise;
function ose(e, r, t, n, a) {
  return r.elementCount === 0 || t.elementCount === 0 ? !0 : r.elementCount <= t.elementCount ? Eb.check(e, r, t, n, a) : Eb.check(e, t, r, n, a);
}
Bv.checkStructureMaxRadiusDistance = ose;
var wb;
(function(e) {
  var r = cv.Vec3.zero();
  function t(o, c, s, u, l, f, d) {
    var m = c.elements, p = c.conformation.position, v = r;
    o.element.unit = c;
    for (var h = !1, y = 0, C = m.length; y < C; y++) {
      var S = m[y];
      o.element.element = S;
      var b = Math.max(0, cv.Vec3.distance(s, p(S, v)) - u - d(o));
      if (b < l)
        return 0;
      b < f && (h = !0);
    }
    return h ? 1 : 2;
  }
  function n(o, c, s, u, l, f, d) {
    for (var m = c.units, p = !1, v = 0, h = m.length; v < h; v++) {
      var y = t(o, m[v], s, u, l, f, d);
      if (y === 0)
        return 0;
      y === 1 && (p = !0);
    }
    return p ? 1 : 2;
  }
  e.toPoint = n;
  var a = cv.Vec3.zero();
  function i(o, c, s, u, l, f) {
    if (c.elementCount === 0 || s.elementCount === 0)
      return 0;
    var d = c.units, m = !1;
    o.element.structure = c;
    for (var p = 0, v = d.length; p < v; p++) {
      var h = d[p], y = h.elements, C = h.conformation.position;
      o.element.unit = h;
      for (var S = 0, b = y.length; S < b; S++) {
        var g = y[S];
        o.element.element = g;
        var _ = n(o, s, C(g, a), f(o), u, l, f);
        if (_ === 0)
          return 0;
        _ === 1 && (m = !0);
      }
    }
    return m;
  }
  e.check = i;
})(wb || (wb = {}));
var Eb;
(function(e) {
  var r = cv.Vec3.zero();
  function t(o, c, s, u, l, f) {
    var d = c.elements, m = c.conformation.position, p = r;
    o.element.unit = c;
    for (var v = 0, h = d.length; v < h; v++) {
      var y = d[v];
      if (o.element.element = y, Math.max(0, cv.Vec3.distance(s, m(y, p)) - u - f(o)) <= l)
        return !0;
    }
    return !1;
  }
  function n(o, c, s, u, l, f) {
    for (var d = c.units, m = 0, p = d.length; m < p; m++)
      if (t(o, d[m], s, u, l, f))
        return !0;
    return !1;
  }
  e.toPoint = n;
  var a = cv.Vec3.zero();
  function i(o, c, s, u, l) {
    if (c.elementCount === 0 || s.elementCount === 0)
      return 0;
    var f = c.units;
    o.element.structure = c;
    for (var d = 0, m = f.length; d < m; d++) {
      var p = f[d];
      o.element.unit = p;
      for (var v = p.elements, h = p.conformation.position, y = 0, C = v.length; y < C; y++) {
        var S = v[y];
        if (o.element.element = S, n(o, s, h(S, a), l(o), u, l))
          return !0;
      }
    }
    return !1;
  }
  e.check = i;
})(Eb || (Eb = {}));
var j8;
function use() {
  if (j8) return za;
  j8 = 1, Object.defineProperty(za, "__esModule", { value: !0 }), za.isConnectedTo = za.within = za.areIntersectedBy = za.withSameAtomProperties = za.getCurrentStructureProperties = za.first = za.pick = void 0;
  var e = ds, r = ia(), t = jd(), n = dy(), a = Re, i = Bv, o = gn(), c = Qe();
  function s(b, g) {
    return function(_) {
      var A = b(_), M = t.StructureSelection.LinearBuilder(_.inputStructure);
      return _.pushCurrentElement(), t.StructureSelection.forEach(A, function(P, T) {
        _.currentStructure = P, g(_) && M.add(P), T % 100 && _.throwIfTimedOut();
      }), _.popCurrentStructure(), M.getSelection();
    };
  }
  za.pick = s;
  function u(b) {
    return function(g) {
      var _ = b(g), A = t.StructureSelection.LinearBuilder(g.inputStructure);
      if (_.kind === "singletons") {
        if (_.structure.elementCount > 0) {
          var M = _.structure.units[0], P = o.Structure.create([M.getChild(c.SortedArray.ofSingleton(M.elements[0]))], { parent: g.inputStructure });
          A.add(P);
        }
      } else
        _.structures.length > 0 && A.add(_.structures[0]);
      return A.getSelection();
    };
  }
  za.first = u;
  function l(b, g, _) {
    var A = b.currentStructure.units, M = b.pushCurrentElement();
    M.structure = b.currentStructure;
    for (var P = 0, T = A; P < T.length; P++) {
      var x = T[P];
      M.unit = x;
      var w = x.elements, E = void 0;
      if (r.Unit.isAtomic(x) ? E = g.atomic : E = g.coarse, !!E) {
        for (var I = 0, B = w.length; I < B; I++)
          M.element = w[I], _.add(E(b));
        b.throwIfTimedOut();
      }
    }
    return b.popCurrentElement(), _;
  }
  za.getCurrentStructureProperties = l;
  function f(b, g, _) {
    var A = /* @__PURE__ */ new Set(), M = g(b);
    return b.pushCurrentElement(), t.StructureSelection.forEach(M, function(P, T) {
      b.currentStructure = P, l(b, _, A), T % 10 && b.throwIfTimedOut();
    }), b.popCurrentElement(), A;
  }
  function d(b, g, _) {
    return function(A) {
      var M = b(A), P = f(A, g, _), T = t.StructureSelection.LinearBuilder(A.inputStructure);
      return A.pushCurrentStructure(), t.StructureSelection.forEach(M, function(x, w) {
        A.currentStructure = x;
        var E = l(A, _, /* @__PURE__ */ new Set());
        e.SetUtils.isSuperset(E, P) && T.add(x), w % 10 && A.throwIfTimedOut();
      }), A.popCurrentStructure(), T.getSelection();
    };
  }
  za.withSameAtomProperties = d;
  function m(b, g) {
    return function(_) {
      var A = t.StructureSelection.unionStructure(g(_)), M = t.StructureSelection.LinearBuilder(_.inputStructure);
      return t.StructureSelection.forEach(b(_), function(P, T) {
        (0, n.structureAreIntersecting)(A, P) && M.add(P), T % 10 && _.throwIfTimedOut();
      }), M.getSelection();
    };
  }
  za.areIntersectedBy = m;
  function p(b) {
    return function(g) {
      var _ = {
        queryCtx: g,
        selection: b.query(g),
        target: b.target(g),
        maxRadius: b.maxRadius,
        minRadius: b.minRadius ? Math.max(0, b.minRadius) : 0,
        elementRadius: b.elementRadius,
        invert: !!b.invert
      };
      return _.minRadius === 0 && typeof b.minRadius > "u" ? v(_) : _.minRadius === 0 ? h(_) : y(_);
    };
  }
  za.within = p;
  function v(b) {
    var g = b.queryCtx, _ = b.selection, A = b.target, M = b.maxRadius, P = b.invert, T = t.StructureSelection.unionStructure(A).lookup3d, x = t.StructureSelection.LinearBuilder(g.inputStructure), w = a.Vec3.zero();
    return t.StructureSelection.forEach(_, function(E, I) {
      for (var B = E.units, D = !1, N = 0, O = B.length; N < O; N++) {
        for (var V = B[N], k = V.elements, G = V.conformation, L = G.position, R = G.r, F = 0, U = k.length; F < U; F++) {
          var H = k[F];
          if (L(H, w), T.check(w[0], w[1], w[2], M + R(H))) {
            D = !0;
            break;
          }
        }
        if (D)
          break;
      }
      P && (D = !D), D && x.add(E), I % 10 === 0 && g.throwIfTimedOut();
    }), x.getSelection();
  }
  function h(b) {
    var g = b.queryCtx, _ = b.selection, A = b.target, M = b.maxRadius, P = b.invert, T = b.elementRadius, x = t.StructureSelection.unionStructure(A), w = t.StructureSelection.LinearBuilder(g.inputStructure);
    return g.pushCurrentElement(), t.StructureSelection.forEach(_, function(E, I) {
      var B = (0, i.checkStructureMaxRadiusDistance)(g, x, E, M, T);
      P && (B = !B), B && w.add(E), I % 10 === 0 && g.throwIfTimedOut();
    }), g.popCurrentElement(), w.getSelection();
  }
  function y(b) {
    var g = b.queryCtx, _ = b.selection, A = b.target, M = b.minRadius, P = b.maxRadius, T = b.invert, x = b.elementRadius, w = t.StructureSelection.unionStructure(A), E = t.StructureSelection.LinearBuilder(g.inputStructure);
    return g.pushCurrentElement(), t.StructureSelection.forEach(_, function(I, B) {
      var D = (0, i.checkStructureMinMaxDistance)(g, w, I, M, P, x);
      T && (D = !D), D && E.add(I), B % 10 === 0 && g.throwIfTimedOut();
    }), g.popCurrentElement(), E.getSelection();
  }
  function C(b, g) {
    var _ = b.queryCtx, A = b.input, M = b.target, P = b.disjunct, T = _.atomicBond, x = A.interUnitBonds;
    T.setStructure(A);
    for (var w = 0, E = g.units; w < E.length; w++) {
      var I = E[w];
      if (r.Unit.isAtomic(I))
        for (var B = A.unitMap.get(I.id), D = B.bonds, N = D.offset, O = D.b, V = D.edgeProps, k = V.flags, G = V.order, L = x.getConnectedUnits(I.id), R = L.length, F = I.elements, U = B.elements, H = 0, q = F.length; H < q; H++) {
          var K = c.SortedArray.indexOf(U, F[H]);
          T.a.unit = B, T.b.unit = B;
          for (var Y = N[K], X = N[K + 1]; Y < X; Y++)
            if (T.b.element = B.elements[O[Y]], !(P && c.SortedArray.has(I.elements, T.b.element)) && M.hasElement(T.b) && (T.aIndex = K, T.a.element = F[H], T.bIndex = O[Y], T.type = k[Y], T.order = G[Y], T.test(_, !0)))
              return !0;
          for (var Z = 0; Z < R; Z++)
            for (var J = L[Z], $ = A.unitMap.get(J.unitB), Q = $.elements, W = J.getEdges(K), te = 0, oe = W.length; te < oe; te++) {
              var z = W[te];
              if (T.b.unit = $, T.b.element = Q[z.indexB], !!M.hasElement(T.b) && !(P && g.hasElement(T.b)) && (T.a.unit = B, T.aIndex = K, T.a.element = F[H], T.bIndex = z.indexB, T.type = z.props.flag, T.order = z.props.order, T.test(_, !0)))
                return !0;
            }
        }
    }
    return !1;
  }
  function S(b) {
    var g = b.query, _ = b.target, A = b.disjunct, M = b.invert, P = b.bondTest;
    return function(T) {
      var x = _(T);
      if (t.StructureSelection.isEmpty(x))
        return x;
      var w = g(T);
      if (t.StructureSelection.isEmpty(w))
        return w;
      var E = {
        queryCtx: T,
        input: T.inputStructure,
        disjunct: A,
        target: t.StructureSelection.unionStructure(x)
      }, I = t.StructureSelection.LinearBuilder(T.inputStructure);
      return T.pushCurrentBond(), T.atomicBond.setTestFn(P), t.StructureSelection.forEach(w, function(B, D) {
        (C(E, B) || M) && I.add(B), D % 5 === 0 && T.throwIfTimedOut();
      }), T.popCurrentBond(), I.getSelection();
    };
  }
  return za.isConnectedTo = S, za;
}
var Af = {}, $8;
function sse() {
  if ($8) return Af;
  $8 = 1, Object.defineProperty(Af, "__esModule", { value: !0 }), Af.intersect = Af.merge = void 0;
  var e = jd(), r = fG(), t = Po, n = ia();
  function a(o) {
    return o.length === 0 ? r.none : o.length === 1 ? o[0] : function(c) {
      for (var s = e.StructureSelection.UniqueBuilder(c.inputStructure), u = function(f) {
        e.StructureSelection.forEach(o[f](c), function(d, m) {
          s.add(d), f % 100 && c.throwIfTimedOut();
        });
      }, l = 0; l < o.length; l++)
        u(l);
      return s.getSelection();
    };
  }
  Af.merge = a;
  function i(o) {
    return o.length === 0 ? r.none : o.length === 1 ? o[0] : function(c) {
      for (var s = [], u = 0; u < o.length; u++)
        s.push(o[u](c));
      for (var l = 0, f = e.StructureSelection.structureCount(s[0]), u = 1; u < s.length; u++) {
        var d = e.StructureSelection.structureCount(s[u]);
        d < f && (l = u, f = d);
      }
      c.throwIfTimedOut();
      var m = (0, t.HashSet)(function(h) {
        return h.hashCode;
      }, n.Structure.areUnitIdsAndIndicesEqual);
      e.StructureSelection.forEach(s[l], function(h) {
        return m.add(h);
      });
      for (var p = e.StructureSelection.UniqueBuilder(c.inputStructure), v = 0; v < s.length; v++)
        v !== l && (e.StructureSelection.forEach(s[v], function(h) {
          m.has(h) && p.add(h);
        }), c.throwIfTimedOut());
      return p.getSelection();
    };
  }
  return Af.intersect = i, Af;
}
var KC = {};
Object.defineProperty(KC, "__esModule", { value: !0 });
KC.Predicates = void 0;
var EM;
(function(e) {
  function r(d) {
    return !!d && !!d.has;
  }
  function t(d, m) {
    return function(p) {
      return d(p) === m;
    };
  }
  e.eq = t;
  function n(d, m) {
    return function(p) {
      return d(p) < m;
    };
  }
  e.lt = n;
  function a(d, m) {
    return function(p) {
      return d(p) <= m;
    };
  }
  e.lte = a;
  function i(d, m) {
    return function(p) {
      return d(p) > m;
    };
  }
  e.gt = i;
  function o(d, m) {
    return function(p) {
      return d(p) >= m;
    };
  }
  e.gte = o;
  function c(d) {
    return !0;
  }
  function s(d) {
    return !1;
  }
  function u(d, m) {
    if (r(m))
      return function(h) {
        return m.has(d(h));
      };
    if (m.length === 0)
      return s;
    for (var p = /* @__PURE__ */ new Set(), v = 0; v < m.length; v++)
      p.add(m[v]);
    return function(h) {
      return p.has(d(h));
    };
  }
  e.inSet = u;
  function l() {
    for (var d = [], m = 0; m < arguments.length; m++)
      d[m] = arguments[m];
    switch (d.length) {
      case 0:
        return c;
      case 1:
        return d[0];
      case 2: {
        var p = d[0], v = d[1];
        return function(V) {
          return p(V) && v(V);
        };
      }
      case 3: {
        var h = d[0], y = d[1], C = d[2];
        return function(V) {
          return h(V) && y(V) && C(V);
        };
      }
      case 4: {
        var S = d[0], b = d[1], g = d[2], _ = d[3];
        return function(V) {
          return S(V) && b(V) && g(V) && _(V);
        };
      }
      case 5: {
        var A = d[0], M = d[1], P = d[2], T = d[3], x = d[4];
        return function(V) {
          return A(V) && M(V) && P(V) && T(V) && x(V);
        };
      }
      case 6: {
        var w = d[0], E = d[1], I = d[2], B = d[3], D = d[4], N = d[5];
        return function(V) {
          return w(V) && E(V) && I(V) && B(V) && D(V) && N(V);
        };
      }
      default: {
        var O = d.length;
        return function(V) {
          for (var k = 0; k < O; k++)
            if (!d[k])
              return !1;
          return !0;
        };
      }
    }
  }
  e.and = l;
  function f() {
    for (var d = [], m = 0; m < arguments.length; m++)
      d[m] = arguments[m];
    switch (d.length) {
      case 0:
        return s;
      case 1:
        return d[0];
      case 2: {
        var p = d[0], v = d[1];
        return function(V) {
          return p(V) || v(V);
        };
      }
      case 3: {
        var h = d[0], y = d[1], C = d[2];
        return function(V) {
          return h(V) || y(V) || C(V);
        };
      }
      case 4: {
        var S = d[0], b = d[1], g = d[2], _ = d[3];
        return function(V) {
          return S(V) || b(V) || g(V) || _(V);
        };
      }
      case 5: {
        var A = d[0], M = d[1], P = d[2], T = d[3], x = d[4];
        return function(V) {
          return A(V) || M(V) || P(V) || T(V) || x(V);
        };
      }
      case 6: {
        var w = d[0], E = d[1], I = d[2], B = d[3], D = d[4], N = d[5];
        return function(V) {
          return w(V) || E(V) || I(V) || B(V) || D(V) || N(V);
        };
      }
      default: {
        var O = d.length;
        return function(V) {
          for (var k = 0; k < O; k++)
            if (d[k])
              return !0;
          return !1;
        };
      }
    }
  }
  e.or = f;
})(EM || (EM = {}));
KC.Predicates = EM;
var K8;
function EE() {
  return K8 || (K8 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.StructureQuery = e.StructureSelection = e.Queries = void 0;
    var r = Te, t = jd();
    Object.defineProperty(e, "StructureSelection", { enumerable: !0, get: function() {
      return t.StructureSelection;
    } });
    var n = ooe();
    Object.defineProperty(e, "StructureQuery", { enumerable: !0, get: function() {
      return n.StructureQuery;
    } }), (0, r.__exportStar)(cG(), e);
    var a = (0, r.__importStar)(fG()), i = (0, r.__importStar)(ase()), o = (0, r.__importStar)(use()), c = (0, r.__importStar)(sse()), s = (0, r.__importStar)(xE()), u = KC;
    e.Queries = {
      generators: a,
      filters: o,
      modifiers: i,
      combinators: c,
      pred: u.Predicates,
      internal: s
    };
  }(i5)), i5;
}
var W8;
function WC() {
  if (W8) return Dh;
  W8 = 1, Object.defineProperty(Dh, "__esModule", { value: !0 }), Dh.StructureSymmetry = void 0;
  var e = Te, r = Qe(), t = wr(), n = nr(), a = Re, i = Kr, o = O0(), c = EE(), s = gn(), u = vl(), l = ml(), f = V0(), d;
  (function(g) {
    function _(B, D) {
      var N = this;
      return i.Task.create("Build Assembly", function(O) {
        return (0, e.__awaiter)(N, void 0, void 0, function() {
          var V, k, G, L, R, F, U, H, q, K, Y, X, Z, J, $, Q;
          return (0, e.__generator)(this, function(W) {
            if (V = B.models, V.length !== 1)
              throw new Error("Can only build assemblies from structures based on 1 model.");
            if (k = o.Symmetry.findAssembly(V[0], D), !k)
              throw new Error("Assembly '".concat(D, "' is not defined."));
            for (G = n.SymmetryOperator.create(k.id, a.Mat4.identity(), { assembly: { id: k.id, operId: 0, operList: [] } }), L = s.Structure.Builder({
              coordinateSystem: G,
              label: B.label,
              dynamicBonds: B.dynamicBonds
            }), R = new c.QueryContext(B), F = 0, U = k.operatorGroups; F < U.length; F++)
              if (H = U[F], q = H.selector(R), c.StructureSelection.structureCount(q) !== 0)
                for (K = c.StructureSelection.unionStructure(q).units, Y = 0, X = H.operators; Y < X.length; Y++)
                  for (Z = X[Y], J = 0, $ = K; J < $.length; J++)
                    Q = $[J], L.addWithOperator(Q, Z);
            return [2, L.getStructure()];
          });
        });
      });
    }
    g.buildAssembly = _;
    function A(B, D, N) {
      var O = this;
      return i.Task.create("Build Symmetry Assembly", function(V) {
        return (0, e.__awaiter)(O, void 0, void 0, function() {
          var k, G, L, R, F, U, H, q, K, Y, X, Z, J, $, Q, W, te, oe, z, j, ae, le, ie, re, ee;
          return (0, e.__generator)(this, function(ne) {
            if (k = B.models, k.length !== 1)
              throw new Error("Can only build symmetry assemblies from structures based on 1 model.");
            for (G = (0, a.Vec3)(), L = s.Structure.Builder({
              label: B.label,
              representativeModel: k[0],
              dynamicBonds: B.dynamicBonds
            }), R = new c.QueryContext(B), F = 0, U = D; F < U.length; F++)
              if (H = U[F], q = m(H.asymIds), K = q(R), c.StructureSelection.structureCount(K) !== 0)
                for (Y = c.StructureSelection.unionStructure(K).units, X = 0, Z = H.operators; X < Z.length; X++)
                  for (J = Z[X], $ = J.index, Q = J.shift, W = Q[0], te = Q[1], oe = Q[2], z = p(N, $, W, te, oe, G), j = 0, ae = Y; j < ae.length; j++)
                    for (le = ae[j], ie = 0, re = z; ie < re.length; ie++)
                      ee = re[ie], L.addWithOperator(le, ee);
            return [2, L.getStructure()];
          });
        });
      });
    }
    g.buildSymmetryAssembly = A;
    function M(B, D) {
      return i.Task.create("Find Symmetry Mates", function(N) {
        return b(N, B, D);
      });
    }
    g.builderSymmetryMates = M;
    function P(B, D, N) {
      return i.Task.create("Build Symmetry", function(O) {
        return S(O, B, D, N);
      });
    }
    g.buildSymmetryRange = P;
    function T(B) {
      return i.Task.create("Build NCS", function(D) {
        return C(D, B);
      });
    }
    g.buildNcs = T;
    function x(B, D) {
      return B.invariantId === D.invariantId && B.model.id === D.model.id && r.SortedArray.areEqual(B.elements, D.elements);
    }
    g.areUnitsEquivalent = x;
    function w() {
      return (0, t.EquivalenceClasses)(u.Unit.hashUnit, x);
    }
    g.UnitEquivalenceBuilder = w;
    function E(B) {
      for (var D = w(), N = 0, O = B.units; N < O.length; N++) {
        var V = O[N];
        D.add(V.id, V);
      }
      for (var k = [], G = 0, L = D.groups; G < L.length; G++) {
        var R = L[G];
        k.push(u.Unit.SymmetryGroup(R.map(function(F) {
          return B.unitMap.get(F);
        })));
      }
      return k;
    }
    g.computeTransformGroups = E;
    function I(B, D) {
      if (B.length !== D.length)
        return !1;
      for (var N = 0, O = B.length; N < O; ++N) {
        var V = B[N].units, k = D[N].units;
        if (V.length !== k.length || B[N].hashCode !== D[N].hashCode)
          return !1;
        for (var G = 0, L = V.length; G < L; G++)
          if (V[G].conformation !== k[G].conformation)
            return !1;
      }
      return !0;
    }
    g.areTransformGroupsEquivalent = I;
  })(d || (d = {})), Dh.StructureSymmetry = d;
  function m(g) {
    return c.Queries.generators.atoms({ chainTest: c.Queries.pred.and(c.Queries.pred.eq(function(_) {
      return f.StructureProperties.unit.operator_name(_.element);
    }, n.SymmetryOperator.DefaultName), c.Queries.pred.inSet(function(_) {
      return f.StructureProperties.chain.label_asym_id(_.element);
    }, g)) });
  }
  function p(g, _, A, M, P, T) {
    var x = g.spacegroup, w = g.ncsOperators, E = [], I = x.cell.toFractional, B = a.Vec3.transformMat4((0, a.Vec3)(), T, I), D = n.Spacegroup.getSymmetryOperatorRef(x, _, A, M, P, B);
    if (w && w.length)
      for (var N = 0, O = w.length; N < O; ++N) {
        var V = w[N], k = a.Mat4.mul((0, a.Mat4)(), D.matrix, V.matrix), G = n.SymmetryOperator.create("".concat(D.name, " ").concat(V.name), k, {
          assembly: D.assembly,
          ncsId: V.ncsId,
          hkl: D.hkl,
          spgrOp: D.spgrOp
        });
        E.push(G);
      }
    else
      E.push(D);
    return E;
  }
  function v(g, _, A, M) {
    var P = g.spacegroup, T = g.ncsOperators, x = T && T.length || 0, w = [];
    !x && _[0] <= 0 && A[0] >= 0 && _[1] <= 0 && A[1] >= 0 && _[2] <= 0 && A[2] >= 0 && (w[0] = n.Spacegroup.getSymmetryOperator(P, 0, 0, 0, 0));
    for (var E = 0; E < P.operators.length; E++)
      for (var I = _[0]; I <= A[0]; I++)
        for (var B = _[1]; B <= A[1]; B++)
          for (var D = _[2]; D <= A[2]; D++)
            !x && E === 0 && I === 0 && B === 0 && D === 0 || w.push.apply(w, p(g, E, I, B, D, M));
    return w;
  }
  function h(g, _) {
    return g._operators_333 && a.Vec3.equals(_, g._operators_333.ref) || (g._operators_333 = {
      ref: a.Vec3.clone(_),
      operators: v(g, a.Vec3.create(-3, -3, -3), a.Vec3.create(3, 3, 3), _)
    }), g._operators_333.operators;
  }
  function y(g, _) {
    for (var A = s.Structure.Builder({
      label: g.label,
      dynamicBonds: g.dynamicBonds
    }), M = g.units, P = 0, T = _; P < T.length; P++)
      for (var x = T[P], w = 0, E = M; w < E.length; w++) {
        var I = E[w];
        A.addWithOperator(I, x);
      }
    return A.getStructure();
  }
  function C(g, _) {
    return (0, e.__awaiter)(this, void 0, void 0, function() {
      var A, M, P;
      return (0, e.__generator)(this, function(T) {
        if (A = _.models, A.length !== 1)
          throw new Error("Can only build NCS from structures based on 1 model.");
        return M = l.ModelSymmetry.Provider.get(A[0]), M ? (P = M.ncsOperators, !P || !P.length ? [2, _] : [2, y(_, P)]) : [2, _];
      });
    });
  }
  function S(g, _, A, M) {
    return (0, e.__awaiter)(this, void 0, void 0, function() {
      var P, T, x, w, E;
      return (0, e.__generator)(this, function(I) {
        if (P = _.models, P.length !== 1)
          throw new Error("Can only build symmetries from structures based on 1 model.");
        return T = l.ModelSymmetry.Provider.get(P[0]), T ? (x = T.spacegroup, n.SpacegroupCell.isZero(x.cell) ? [2, _] : (w = o.Model.getCenter(P[0]), E = v(T, A, M, w), [2, y(_, E)])) : [2, _];
      });
    });
  }
  function b(g, _, A) {
    return (0, e.__awaiter)(this, void 0, void 0, function() {
      function M(Z, J) {
        return "".concat(Z.invariantId, "|").concat(J.name);
      }
      var P, T, x, w, E, I, B, D, N, O, V, k, G, L, R, F, U, H, q, K, Y, X;
      return (0, e.__generator)(this, function(Z) {
        switch (Z.label) {
          case 0:
            if (P = _.models, P.length !== 1)
              throw new Error("Can only build symmetries from structures based on 1 model.");
            return T = l.ModelSymmetry.Provider.get(P[0]), T ? (x = T.spacegroup, n.SpacegroupCell.isZero(x.cell) ? [2, _] : g.shouldUpdate ? [4, g.update("Initialing...")] : [3, 2]) : [2, _];
          case 1:
            Z.sent(), Z.label = 2;
          case 2:
            w = o.Model.getCenter(P[0]), E = h(T, w), I = _.lookup3d, B = /* @__PURE__ */ new Set(), D = s.Structure.Builder({
              label: _.label,
              dynamicBonds: _.dynamicBonds
            }), N = _.units, O = a.Vec3.zero(), V = 0, k = E, Z.label = 3;
          case 3:
            if (!(V < k.length)) return [3, 6];
            for (G = k[V], L = 0, R = N; L < R.length; L++)
              for (F = R[L], U = F.lookup3d.boundary.sphere, a.Vec3.transformMat4(O, U.center, G.matrix), H = I.findUnitIndices(O[0], O[1], O[2], U.radius + A), q = 0, K = H.count; q < K; q++)
                Y = N[H.indices[q]], Y.lookup3d.check(O[0], O[1], O[2], U.radius + A) && (X = M(F, G), B.has(X) || (D.addWithOperator(F, G), B.add(X)));
            return g.shouldUpdate ? [4, g.update("Building symmetry...")] : [3, 5];
          case 4:
            Z.sent(), Z.label = 5;
          case 5:
            return V++, [3, 3];
          case 6:
            return [2, D.getStructure()];
        }
      });
    });
  }
  return Dh;
}
var X8;
function lse() {
  if (X8) return Eh;
  X8 = 1, Object.defineProperty(Eh, "__esModule", { value: !0 }), Eh.StructureSubsetBuilder = void 0;
  var e = Qe(), r = wr(), t = WC(), n = gn(), a = (
    /** @class */
    function() {
      function i(o, c) {
        this.parent = o, this.isSorted = c, this.ids = [], this.unitMap = e.IntMap.Mutable(), this.parentId = -1, this.currentUnit = [], this.elementCount = 0;
      }
      return i.prototype.addToUnit = function(o, c) {
        var s = this.unitMap.get(o);
        s ? s[s.length] = c : (this.unitMap.set(o, [c]), this.ids[this.ids.length] = o), this.elementCount++;
      }, i.prototype.beginUnit = function(o) {
        this.parentId = o, this.currentUnit = this.currentUnit.length > 0 ? [] : this.currentUnit;
      }, i.prototype.addElement = function(o) {
        this.currentUnit[this.currentUnit.length] = o, this.elementCount++;
      }, i.prototype.addElementRange = function(o, c, s) {
        for (var u = c; u < s; u++)
          this.currentUnit[this.currentUnit.length] = o[u], this.elementCount++;
      }, i.prototype.commitUnit = function() {
        this.currentUnit.length !== 0 && (this.ids[this.ids.length] = this.parentId, this.unitMap.set(this.parentId, this.currentUnit), this.parentId = -1);
      }, i.prototype.setUnit = function(o, c) {
        this.ids[this.ids.length] = o, this.unitMap.set(o, c), this.elementCount += c.length;
      }, i.prototype._getStructure = function(o) {
        if (this.isEmpty)
          return n.Structure.Empty;
        var c = [];
        (0, r.sortArray)(this.ids);
        for (var s = t.StructureSymmetry.UnitEquivalenceBuilder(), u = 0, l = this.ids.length; u < l; u++) {
          var f = this.ids[u], d = this.parent.unitMap.get(f), m = this.unitMap.get(f), p = !1;
          o && (this.isSorted || (0, r.sortArray)(m), m = e.SortedArray.deduplicate(e.SortedArray.ofSortedArray(this.currentUnit)), p = !0);
          var v = m.length;
          if (m.length === d.elements.length) {
            c[c.length] = d, s.add(d.id, d);
            continue;
          }
          !this.isSorted && !p && v > 1 && (0, r.sortArray)(m);
          var h = d.getChild(e.SortedArray.ofSortedArray(m)), y = s.add(h.id, h);
          h !== y && (h = y.applyOperator(h.id, h.conformation.operator, !0)), c[c.length] = h;
        }
        return n.Structure.create(c, { parent: this.parent });
      }, i.prototype.getStructure = function() {
        return this._getStructure(!1);
      }, i.prototype.getStructureDeduplicate = function() {
        return this._getStructure(!0);
      }, i.prototype.setSingletonLocation = function(o) {
        var c = this.ids[0];
        o.unit = this.parent.unitMap.get(c), o.element = this.unitMap.get(c)[0];
      }, Object.defineProperty(i.prototype, "isEmpty", {
        get: function() {
          return this.elementCount === 0;
        },
        enumerable: !1,
        configurable: !0
      }), i;
    }()
  );
  return Eh.StructureSubsetBuilder = a, Eh;
}
var kh = {}, Nv = {};
Object.defineProperty(Nv, "__esModule", { value: !0 });
Nv.combinations = Nv.CombinationIterator = void 0;
function Y8(e, r) {
  for (var t = 1; r--; )
    t *= e--;
  return t;
}
function cse(e, r) {
  return r > e ? 0 : Y8(e, r) / Y8(r, r);
}
function dse(e) {
  var r = e & -e, t = e + r, n = t & -t, a = (n / r >> 1) - 1;
  return t | a;
}
var SG = (
  /** @class */
  function() {
    function e(r, t) {
      this.array = r, this.hasNext = !1, this.index = (1 << t) - 1, this.size = cse(r.length, t), this.maxIndex = 1 << r.length, this.value = new Array(t), this.hasNext = t > 0 && t <= r.length;
    }
    return e.prototype.move = function() {
      if (this.hasNext) {
        for (var r = 0, t = 0, n = this.index; n; n >>>= 1, r++)
          n & 1 && (this.value[t++] = this.array[r]);
        this.index = dse(this.index), this.hasNext = this.index < this.maxIndex;
      }
      return this.value;
    }, e;
  }()
);
Nv.CombinationIterator = SG;
function fse(e, r) {
  for (var t = [], n = new SG(e, r); n.hasNext; )
    t.push(n.move().slice());
  return t;
}
Nv.combinations = fse;
var XC = {};
Object.defineProperty(XC, "__esModule", { value: !0 });
XC.EmptyCarbohydrates = void 0;
var xf = [];
XC.EmptyCarbohydrates = {
  links: xf,
  terminalLinks: xf,
  elements: xf,
  partialElements: xf,
  getElementIndices: function() {
    return xf;
  },
  getLinkIndices: function() {
    return xf;
  },
  getTerminalLinkIndices: function() {
    return xf;
  }
};
var Q8;
function mse() {
  if (Q8) return kh;
  Q8 = 1, Object.defineProperty(kh, "__esModule", { value: !0 }), kh.computeCarbohydrates = void 0;
  var e = Te, r = Qe(), t = Nv, n = dl, a = Re, i = sy(), o = hr, c = Gr, s = Za, u = vl(), l = XC, f = fc, d = wr(), m = (0, c.ElementSymbol)("C"), p = (0, c.ElementSymbol)("O"), v = [
    f.UnitRing.elementFingerprint([m, m, m, p]),
    f.UnitRing.elementFingerprint([m, m, m, m, p]),
    f.UnitRing.elementFingerprint([m, m, m, m, m, p]),
    f.UnitRing.elementFingerprint([m, m, m, m, m, m, p])
  ];
  function h(M, P) {
    for (var T = -1, x = -1, w = -1, E = -1, I = M.elements, B = M.model.atomicHierarchy.atoms, D = B.type_symbol, N = B.label_atom_id, O = M.bonds, V = O.b, k = O.offset, G = 0, L = P.length; G < L; ++G) {
      var R = I[P[G]];
      if (D.value(R) === m) {
        for (var F = 0, U = 0, H = k[P[G]], q = k[P[G] + 1]; H < q; ++H) {
          var K = I[V[H]], Y = D.value(K);
          Y === p ? ++F : Y === m && ++U;
        }
        if (F === 2) {
          T = R;
          break;
        } else F === 1 && U === 1 ? x = R : N.value(R).startsWith("C1") ? w = R : E = R;
      }
    }
    return T !== -1 ? T : x !== -1 ? x : w !== -1 ? w : E !== -1 ? E : I[P[0]];
  }
  function y(M, P) {
    var T = M.elements, x = M.model.atomicHierarchy.atoms.label_alt_id;
    return x.value(T[P]);
  }
  function C(M, P, T, x) {
    var w = P.conformation.position;
    return a.Vec3.normalize(M, a.Vec3.sub(M, x, w(T, M))), M;
  }
  function S(M, P) {
    var T = M.elements, x = M.model.atomicHierarchy.atoms.label_atom_id;
    return x.value(T[P]);
  }
  function b(M, P) {
    if (!(!P || !P.length)) {
      for (var T = M.unit, x = M.all, w = /* @__PURE__ */ new Set(), E = (0, t.combinations)((0, o.fillSerial)(new Array(P.length)), 2), I = 0, B = E.length; I < B; ++I) {
        var D = E[I], N = x[P[D[0]]], O = x[P[D[1]]];
        r.SortedArray.areIntersecting(N, O) && f.UnitRing.getAltId(T, N) === f.UnitRing.getAltId(T, O) && (w.add(P[D[0]]), w.add(P[D[1]]));
      }
      if (w.size) {
        for (var V = [], I = 0, B = P.length; I < B; ++I)
          w.has(P[I]) || V.push(P[I]);
        return V;
      } else
        return P;
    }
  }
  function g(M, P) {
    return P.properties.saccharideComponentMap.get(M);
  }
  function _(M) {
    if (M.models.reduce(function(ue, pe) {
      return ue + pe.properties.saccharideComponentMap.size;
    }, 0) === 0)
      return l.EmptyCarbohydrates;
    var P = [], T = [], x = [], w = [], E = /* @__PURE__ */ new Map();
    function I(ue, pe, Ae) {
      return "".concat(ue, "|").concat(pe, "|").concat(Ae);
    }
    function B(ue, pe) {
      E.has(ue) ? E.get(ue).push(pe) : E.set(ue, [pe]);
    }
    function D(ue, pe) {
      a.Vec3.sub(x[ue].geometry.direction, x[pe].geometry.center, x[ue].geometry.center), a.Vec3.normalize(x[ue].geometry.direction, x[ue].geometry.direction);
    }
    var N = a.Vec3.zero();
    function O(ue, pe, Ae) {
      var ye = Ae.conformation.position, be = x[ue].geometry;
      a.Vec3.sub(be.direction, ye(Ae.elements[pe], N), be.center), a.Vec3.normalize(be.direction, be.direction);
    }
    for (var V = 0, k = M.units.length; V < k; ++V) {
      var G = M.units[V];
      if (u.Unit.isAtomic(G))
        for (var L = G.model, R = G.rings, F = L.atomicHierarchy, U = F.chainAtomSegments, H = F.residueAtomSegments, q = F.atoms, K = q.label_comp_id, Y = r.Segmentation.transientSegments(U, G.elements), X = r.Segmentation.transientSegments(H, G.elements), Z = void 0; Y.hasNext; )
          for (X.setSegment(Y.move()); X.hasNext; ) {
            var J = X.move().index, $ = g(K.value(H.offsets[J]), L);
            if ($) {
              Z || (Z = f.UnitRings.byFingerprintAndResidue(R, v));
              var Q = b(R, Z.get(J));
              if (!Q || !Q.length) {
                w.push({ unit: G, residueIndex: J, component: $ });
                continue;
              }
              for (var W = [], te = 0, oe = Q.length; te < oe; ++te) {
                var z = R.all[Q[te]], j = h(G, z), ae = i.PrincipalAxes.calculateMomentsAxes((0, s.getPositions)(G, z)), le = a.Vec3.copy(a.Vec3.zero(), ae.origin), ie = a.Vec3.copy(a.Vec3.zero(), ae.dirC), re = C(a.Vec3.zero(), G, j, le);
                a.Vec3.orthogonalize(re, ie, re);
                var ee = f.UnitRing.getAltId(G, z), ne = x.length;
                W.push(ne), B(I(J, G.id, ee), ne), ee && B(I(J, G.id, ""), ne), x.push({
                  geometry: { center: le, normal: ie, direction: re },
                  component: $,
                  ringIndex: Q[te],
                  altId: ee,
                  unit: G,
                  residueIndex: J
                });
              }
              for (var se = (0, t.combinations)((0, o.fillSerial)(new Array(Q.length)), 2), te = 0, oe = se.length; te < oe; ++te) {
                var ce = se[te], de = R.all[Q[ce[0]]], me = R.all[Q[ce[1]]];
                if (n.IntAdjacencyGraph.areVertexSetsConnected(G.bonds, de, me, 3)) {
                  var he = W[ce[0]], _e = W[ce[1]];
                  x[he].altId === x[_e].altId && (D(he, _e), D(_e, he), P.push({ carbohydrateIndexA: he, carbohydrateIndexB: _e }), P.push({ carbohydrateIndexA: _e, carbohydrateIndexB: he }));
                }
              }
            }
          }
    }
    function Se(ue, pe) {
      return E.get(I(ue.getResidueIndex(pe), ue.id, y(ue, pe))) || [];
    }
    for (var V = 0, k = x.length; V < k; ++V)
      for (var Pe = x[V], G = Pe.unit, te = V + 1; te < k; ++te) {
        var De = x[te];
        if (!(G !== De.unit || Pe.residueIndex === De.residueIndex)) {
          var Ee = G.rings.all[Pe.ringIndex], Me = G.rings.all[De.ringIndex];
          n.IntAdjacencyGraph.areVertexSetsConnected(G.bonds, Ee, Me, 3) && (D(V, te), D(te, V), P.push({ carbohydrateIndexA: V, carbohydrateIndexB: te }), P.push({ carbohydrateIndexA: te, carbohydrateIndexB: V }));
        }
      }
    for (var V = 0, k = M.units.length; V < k; ++V) {
      var G = M.units[V];
      u.Unit.isAtomic(G) && M.interUnitBonds.getConnectedUnits(G.id).forEach(function(ye) {
        ye.connectedIndices.forEach(function(be) {
          ye.getEdges(be).forEach(function(fe) {
            var ge = fe.props, xe = fe.indexB;
            if (c.BondType.isCovalent(ge.flag)) {
              var we = M.unitMap.get(ye.unitA), Ve = M.unitMap.get(ye.unitB), Ne = Se(we, be), Oe = Se(Ve, xe);
              if (Ne.length > 0 && Oe.length > 0)
                for (var ze = Ne.length, ke = Oe.length, je = 0, Xe = Math.max(ze, ke); je < Xe; ++je) {
                  var Fe = Ne[Math.min(je, ze - 1)], He = Oe[Math.min(je, ke - 1)], Be = S(we, be);
                  (Be.startsWith("O1") || Be.startsWith("C1")) && D(Fe, He), P.push({
                    carbohydrateIndexA: Fe,
                    carbohydrateIndexB: He
                  });
                }
              else if (Oe.length === 0)
                for (var Ye = 0, cr = Ne; Ye < cr.length; Ye++) {
                  var Fe = cr[Ye], Be = S(we, be);
                  (Be.startsWith("O1") || Be.startsWith("C1")) && O(Fe, xe, Ve), T.push({
                    carbohydrateIndex: Fe,
                    elementIndex: xe,
                    elementUnit: Ve,
                    fromCarbohydrate: !0
                  });
                }
              else if (Ne.length === 0)
                for (var Ar = 0, Lr = Oe; Ar < Lr.length; Ar++) {
                  var He = Lr[Ar];
                  T.push({
                    carbohydrateIndex: He,
                    elementIndex: be,
                    elementUnit: we,
                    fromCarbohydrate: !1
                  });
                }
            }
          });
        });
      });
    }
    return (0, e.__assign)({ links: P, terminalLinks: T, elements: x, partialElements: w }, A(x, P, T));
  }
  kh.computeCarbohydrates = _;
  function A(M, P, T) {
    function x(oe, z) {
      return (0, d.cantorPairing)(oe.id, z);
    }
    function w(oe, z, j) {
      var ae = [], le = oe.get(x(z, j));
      if (le !== void 0)
        for (var ie = 0, re = le; ie < re.length; ie++) {
          var ee = re[ie];
          (0, o.arraySetAdd)(ae, ee);
        }
      return ae;
    }
    for (var E = /* @__PURE__ */ new Map(), I = 0, B = M.length; I < B; ++I)
      for (var D = M[I], N = D.unit, O = D.ringIndex, V = N.rings.all[O], k = 0, G = V.length; k < G; ++k) {
        var L = x(N, N.elements[V[k]]), R = E.get(L);
        R === void 0 ? E.set(L, [I]) : R.push(I);
      }
    function F(oe, z) {
      return w(E, oe, z);
    }
    for (var U = /* @__PURE__ */ new Map(), I = 0, B = P.length; I < B; ++I)
      for (var H = P[I], q = M[H.carbohydrateIndexA], N = q.unit, O = q.ringIndex, V = N.rings.all[O], k = 0, G = V.length; k < G; ++k) {
        var L = x(N, N.elements[V[k]]), R = U.get(L);
        R === void 0 ? U.set(L, [I]) : R.push(I);
      }
    function K(oe, z) {
      return w(U, oe, z);
    }
    for (var Y = /* @__PURE__ */ new Map(), I = 0, B = T.length; I < B; ++I) {
      var X = T[I], Z = X.fromCarbohydrate, J = X.carbohydrateIndex, $ = X.elementUnit, Q = X.elementIndex;
      if (Z)
        for (var W = M[J], N = W.unit, O = W.ringIndex, V = N.rings.all[O], k = 0, G = V.length; k < G; ++k) {
          var L = x(N, N.elements[V[k]]), R = Y.get(L);
          R === void 0 ? Y.set(L, [I]) : R.push(I);
        }
      else {
        var L = x($, $.elements[Q]), R = Y.get(L);
        R === void 0 ? Y.set(L, [I]) : R.push(I);
      }
    }
    function te(oe, z) {
      return w(Y, oe, z);
    }
    return { getElementIndices: F, getLinkIndices: K, getTerminalLinkIndices: te };
  }
  return kh;
}
var YC = {};
Object.defineProperty(YC, "__esModule", { value: !0 });
YC.computeStructureBoundary = void 0;
var DM = nr(), CG = ys, v2 = (0, DM.Sphere3D)(), vse = new CG.BoundaryHelper("14"), pse = new CG.BoundaryHelper("98");
function hse(e) {
  return e > 500 ? vse : pse;
}
function gse(e) {
  var r = e.units, t = hse(r.length);
  t.reset();
  for (var n = 0, a = r.length; n < a; n++) {
    var i = r[n], o = i.boundary, c = i.conformation.operator;
    c.isIdentity ? t.includeSphere(o.sphere) : (DM.Sphere3D.transform(v2, o.sphere, c.matrix), t.includeSphere(v2));
  }
  t.finishedIncludeStep();
  for (var n = 0, a = r.length; n < a; n++) {
    var i = r[n], o = i.boundary, c = i.conformation.operator;
    c.isIdentity ? t.radiusSphere(o.sphere) : (DM.Sphere3D.transform(v2, o.sphere, c.matrix), t.radiusSphere(v2));
  }
  return { box: t.getBox(), sphere: t.getSphere() };
}
YC.computeStructureBoundary = gse;
var Z8;
function gn() {
  if (Z8) return lm;
  Z8 = 1, Object.defineProperty(lm, "__esModule", { value: !0 }), lm.Structure = void 0;
  var e = Te, r = Qe(), t = Po, n = E0, a = O0(), i = wr(), o = Mp(), c = vl(), s = lG(), u = lse(), l = TC(), f = WC(), d = V0(), m = mse(), p = Re, v = Ra;
  nr();
  var h = In, y = _s, C = jd(), S = N0, b = Kr, g = YC, _ = (
    /** @class */
    function() {
      function V(k, G, L, R, F) {
        this.units = k, this.unitMap = G, this.unitIndexMap = L, this.state = R, this._child = F == null ? void 0 : F.child, this._target = F == null ? void 0 : F.target, this._proxy = void 0;
      }
      return V.prototype.subsetBuilder = function(k) {
        return new u.StructureSubsetBuilder(this, k);
      }, Object.defineProperty(V.prototype, "elementCount", {
        /** Count of all elements in the structure, i.e. the sum of the elements in the units */
        get: function() {
          return this.state.elementCount;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "bondCount", {
        /** Count of all bonds (intra- and inter-unit) in the structure */
        get: function() {
          return this.state.bondCount === -1 && (this.state.bondCount = this.interUnitBonds.edgeCount + l.Bond.getIntraUnitBondCount(this)), this.state.bondCount;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "hasCustomProperties", {
        get: function() {
          return !!this.state.customProps && this.state.customProps.all.length > 0;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "customPropertyDescriptors", {
        get: function() {
          return this.state.customProps || (this.state.customProps = new h.CustomProperties()), this.state.customProps;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "currentPropertyData", {
        /**
         * Property data unique to this instance of the structure.
         */
        get: function() {
          return this.state.propertyData || (this.state.propertyData = /* @__PURE__ */ Object.create(null)), this.state.propertyData;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "inheritedPropertyData", {
        /**
         * Property data of the parent structure if it exists, currentPropertyData otherwise.
         */
        get: function() {
          return this.parent ? this.parent.currentPropertyData : this.currentPropertyData;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "polymerResidueCount", {
        /** Count of all polymer residues in the structure */
        get: function() {
          return this.state.polymerResidueCount === -1 && (this.state.polymerResidueCount = I(this)), this.state.polymerResidueCount;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "polymerGapCount", {
        /** Count of all polymer gaps in the structure */
        get: function() {
          return this.state.polymerGapCount === -1 && (this.state.polymerGapCount = B(this)), this.state.polymerGapCount;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "polymerUnitCount", {
        get: function() {
          return this.state.polymerUnitCount === -1 && (this.state.polymerUnitCount = D(this)), this.state.polymerUnitCount;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "uniqueElementCount", {
        get: function() {
          return this.state.uniqueElementCount === -1 && (this.state.uniqueElementCount = E(this)), this.state.uniqueElementCount;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "atomicResidueCount", {
        get: function() {
          return this.state.atomicResidueCount === -1 && (this.state.atomicResidueCount = N(this)), this.state.atomicResidueCount;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "isCoarseGrained", {
        /**
         * True if any model the structure is based on is coarse grained.
         * @see Model.isCoarseGrained
         */
        get: function() {
          return this.models.some(function(k) {
            return a.Model.isCoarseGrained(k);
          });
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "isEmpty", {
        get: function() {
          return this.units.length === 0;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "hashCode", {
        get: function() {
          return this.state.hashCode !== -1 ? this.state.hashCode : this.computeHash();
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "transformHash", {
        /** Hash based on all unit.id values in the structure, reflecting the units transformation */
        get: function() {
          return this.state.transformHash !== -1 ? this.state.transformHash : (this.state.transformHash = (0, i.hashFnv32a)(this.units.map(function(k) {
            return k.id;
          })), this.state.transformHash);
        },
        enumerable: !1,
        configurable: !0
      }), V.prototype.computeHash = function() {
        for (var k = 23, G = 0, L = this.units.length; G < L; G++) {
          var R = this.units[G];
          k = 31 * k + R.id | 0, k = 31 * k + r.SortedArray.hashCode(R.elements) | 0;
        }
        return k = 31 * k + this.elementCount | 0, k = (0, i.hash1)(k), k === -1 && (k = 0), this.state.hashCode = k, k;
      }, V.prototype.elementLocations = function() {
        return new V.ElementLocationIterator(this);
      }, Object.defineProperty(V.prototype, "root", {
        /** The parent or itself in case this is the root */
        get: function() {
          var k;
          return (k = this.state.parent) !== null && k !== void 0 ? k : this;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "parent", {
        /** The root/top-most parent or `undefined` in case this is the root */
        get: function() {
          return this.state.parent;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "coordinateSystem", {
        /**
         * Conformation transformation that was applied to every unit of this structure.
         *
         * Coordinate system applies to the *current* structure only.
         * A parent structure can have a different coordinate system and thefore it has to be composed "manualy"
         * by the consumer.
         */
        get: function() {
          return this.state.coordinateSystem;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "label", {
        get: function() {
          return this.state.label;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "boundary", {
        get: function() {
          return this.state.boundary ? this.state.boundary : (this.state.boundary = (0, g.computeStructureBoundary)(this), this.state.boundary);
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "lookup3d", {
        get: function() {
          return this.state.lookup3d ? this.state.lookup3d : (this.state.lookup3d = new s.StructureLookup3D(this), this.state.lookup3d);
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "interUnitBonds", {
        get: function() {
          return this.state.interUnitBonds ? 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 l.InterUnitBonds(/* @__PURE__ */ new Map()) : this.state.interUnitBonds = (0, l.computeInterUnitBonds)(this, {
            ignoreWater: !this.dynamicBonds,
            ignoreIon: !this.dynamicBonds
          }), this.state.interUnitBonds);
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "dynamicBonds", {
        get: function() {
          return this.state.dynamicBonds;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "unitSymmetryGroups", {
        get: function() {
          return this.state.unitSymmetryGroups ? this.state.unitSymmetryGroups : (this.state.unitSymmetryGroups = f.StructureSymmetry.computeTransformGroups(this), this.state.unitSymmetryGroups);
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "unitSymmetryGroupsIndexMap", {
        /** Maps unit.id to index of SymmetryGroup in unitSymmetryGroups array */
        get: function() {
          return this.state.unitSymmetryGroupsIndexMap ? this.state.unitSymmetryGroupsIndexMap : (this.state.unitSymmetryGroupsIndexMap = c.Unit.SymmetryGroup.getUnitSymmetryGroupsIndexMap(this.unitSymmetryGroups), this.state.unitSymmetryGroupsIndexMap);
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "carbohydrates", {
        get: function() {
          return this.state.carbohydrates ? this.state.carbohydrates : (this.state.carbohydrates = (0, m.computeCarbohydrates)(this), this.state.carbohydrates);
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "models", {
        get: function() {
          return this.state.models ? this.state.models : (this.state.models = M(this), this.state.models);
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "uniqueResidueNames", {
        get: function() {
          return this.state.uniqueResidueNames || (this.state.uniqueResidueNames = P(this));
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "uniqueElementSymbols", {
        get: function() {
          return this.state.uniqueElementSymbols || (this.state.uniqueElementSymbols = T(this));
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "entityIndices", {
        get: function() {
          return this.state.entityIndices || (this.state.entityIndices = x(this));
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "uniqueAtomicResidueIndices", {
        get: function() {
          return this.state.uniqueAtomicResidueIndices || (this.state.uniqueAtomicResidueIndices = w(this));
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "isAtomic", {
        /** Contains only atomic units */
        get: function() {
          for (var k = 0, G = this.units; k < G.length; k++) {
            var L = G[k];
            if (!c.Unit.isAtomic(L))
              return !1;
          }
          return !0;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "hasAtomic", {
        /** Contains some atomic units */
        get: function() {
          for (var k = 0, G = this.units; k < G.length; k++) {
            var L = G[k];
            if (c.Unit.isAtomic(L))
              return !0;
          }
          return !1;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "isCoarse", {
        /** Contains only coarse units */
        get: function() {
          for (var k = 0, G = this.units; k < G.length; k++) {
            var L = G[k];
            if (!c.Unit.isCoarse(L))
              return !1;
          }
          return !0;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "hasCoarse", {
        /** Contains some coarse units */
        get: function() {
          for (var k = 0, G = this.units; k < G.length; k++) {
            var L = G[k];
            if (c.Unit.isCoarse(L))
              return !0;
          }
          return !1;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "serialMapping", {
        /**
         * Provides mapping for serial element indices accross all units.
         *
         * Note that this is especially costly for structures with many units that are grouped
         * into few symmetry groups. Use only when needed and prefer `StructureElement`
         * to address elements in a structure.
         */
        get: function() {
          return this.state.serialMapping || (this.state.serialMapping = O(this));
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "model", {
        /**
         * If the structure is based on a single model or has a master-/representative-model, return it.
         * Otherwise throw an exception.
         */
        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 k = this.models;
          if (k.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 = k[0], this.state.model;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "masterModel", {
        /** The master-model, other models can have bonds to it  */
        get: function() {
          return this.state.masterModel;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "representativeModel", {
        /** A representative model, e.g. the first model of a trajectory */
        get: function() {
          return this.state.representativeModel;
        },
        enumerable: !1,
        configurable: !0
      }), V.prototype.hasElement = function(k) {
        return this.unitMap.has(k.unit.id) ? r.SortedArray.has(this.unitMap.get(k.unit.id).elements, k.element) : !1;
      }, V.prototype.getModelIndex = function(k) {
        return this.models.indexOf(k);
      }, V.prototype.remapModel = function(k) {
        for (var G = this.state, L = G.dynamicBonds, R = G.interUnitBonds, F = G.parent, U = [], H = 0, q = this.unitSymmetryGroups; H < q.length; H++) {
          var K = q[H], Y = K.units[0].remapModel(k, L);
          U.push(Y);
          for (var X = 1, Z = K.units.length; X < Z; ++X) {
            var J = K.units[X];
            U.push(J.remapModel(k, L, Y.props));
          }
        }
        return V.create(U, {
          parent: F == null ? void 0 : F.remapModel(k),
          label: this.label,
          interUnitBonds: L ? void 0 : R,
          dynamicBonds: L
        });
      }, V.prototype.asParent = function() {
        if (this._proxy)
          return this._proxy;
        if (this.parent) {
          var k = this.parent.coordinateSystem.isIdentity ? this.parent : V.transform(this.parent, this.parent.coordinateSystem.inverse), G = this.coordinateSystem.isIdentity ? k : V.transform(k, this.coordinateSystem.matrix);
          this._proxy = new V(G.units, G.unitMap, G.unitIndexMap, (0, e.__assign)((0, e.__assign)({}, G.state), { dynamicBonds: this.dynamicBonds }), { child: this, target: this.parent });
        } else
          this._proxy = this;
        return this._proxy;
      }, Object.defineProperty(V.prototype, "child", {
        get: function() {
          return this._child;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(V.prototype, "target", {
        /** Get the proxy target. Usefull for equality checks. */
        get: function() {
          var k;
          return (k = this._target) !== null && k !== void 0 ? k : this;
        },
        enumerable: !1,
        configurable: !0
      }), V;
    }()
  );
  lm.Structure = _;
  function A(V, k, G) {
    return V[k].id - V[G].id;
  }
  function M(V) {
    for (var k = V.units, G = t.UniqueArray.create(), L = 0, R = k; L < R.length; L++) {
      var F = R[L];
      t.UniqueArray.add(G, F.model.id, F.model);
    }
    return G.array;
  }
  function P(V) {
    for (var k = d.StructureProperties.residue.microheterogeneityCompIds, G = /* @__PURE__ */ new Set(), L = o.StructureElement.Location.create(V), R = 0, F = V.unitSymmetryGroups; R < F.length; R++) {
      var U = F[R], H = U.units[0];
      if (c.Unit.isAtomic(H)) {
        var q = r.Segmentation.transientSegments(H.model.atomicHierarchy.residueAtomSegments, H.elements);
        for (L.unit = H; q.hasNext; ) {
          var K = q.move();
          L.element = H.elements[K.start];
          for (var Y = k(L), X = 0, Z = Y; X < Z.length; X++) {
            var J = Z[X];
            G.add(J);
          }
        }
      }
    }
    return G;
  }
  function T(V) {
    for (var k = d.StructureProperties.atom.type_symbol, G = /* @__PURE__ */ new Set(), L = o.StructureElement.Location.create(V), R = 0, F = V.unitSymmetryGroups; R < F.length; R++) {
      var U = F[R], H = U.units[0];
      if (c.Unit.isAtomic(H)) {
        L.unit = H;
        for (var q = 0, K = H.elements.length; q < K; ++q)
          L.element = H.elements[q], G.add(k(L));
      }
    }
    return G;
  }
  function x(V) {
    for (var k = V.units, G = o.StructureElement.Location.create(V), L = t.UniqueArray.create(), R = 0, F = k; R < F.length; R++) {
      var U = F[R], H = U.kind === 0 ? d.StructureProperties.entity.key : d.StructureProperties.coarse.entityKey;
      G.unit = U;
      for (var q = U.elements, K = r.Segmentation.transientSegments(U.model.atomicHierarchy.chainAtomSegments, q); K.hasNext; ) {
        var Y = K.move();
        G.element = q[Y.start];
        var X = H(G);
        t.UniqueArray.add(L, X, X);
      }
    }
    return (0, i.sortArray)(L.array), L.array;
  }
  function w(V) {
    for (var k = /* @__PURE__ */ new Map(), G = [], L = V.unitSymmetryGroups, R = 0, F = L; R < F.length; R++) {
      var U = F[R], H = U.units[0];
      if (c.Unit.isAtomic(H)) {
        var q = void 0;
        k.has(H.model.id) ? q = k.get(H.model.id) : (q = t.UniqueArray.create(), G.push(H.model.id), k.set(H.model.id, q));
        for (var K = r.Segmentation.transientSegments(H.model.atomicHierarchy.residueAtomSegments, H.elements); K.hasNext; ) {
          var Y = K.move();
          t.UniqueArray.add(q, Y.index, Y.index);
        }
      }
    }
    for (var X = /* @__PURE__ */ new Map(), Z = 0, J = G; Z < J.length; Z++) {
      var $ = J[Z], Q = k.get($).array;
      (0, i.sortArray)(Q), X.set($, Q);
    }
    return X;
  }
  function E(V) {
    for (var k = V.unitSymmetryGroups, G = 0, L = 0, R = k.length; L < R; L++)
      G += k[L].elements.length;
    return G;
  }
  function I(V) {
    for (var k = V.units, G = 0, L = 0, R = k.length; L < R; L++)
      G += k[L].polymerElements.length;
    return G;
  }
  function B(V) {
    for (var k = V.units, G = 0, L = 0, R = k.length; L < R; L++)
      G += k[L].gapElements.length / 2;
    return G;
  }
  function D(V) {
    for (var k = V.units, G = 0, L = 0, R = k.length; L < R; L++)
      k[L].polymerElements.length > 0 && (G += 1);
    return G;
  }
  function N(V) {
    for (var k = V.units, G = 0, L = 0, R = k.length; L < R; L++) {
      var F = k[L];
      if (c.Unit.isAtomic(F))
        for (var U = F.elements, H = F.residueIndex, q = -1, K = -1, Y = 0, X = U.length; Y < X; ++Y)
          q = H[U[Y]], q !== K && (G += 1, K = q);
    }
    return G;
  }
  function O(V) {
    for (var k = V.units, G = V.elementCount, L = V.unitIndexMap, R = new Uint32Array(k.length), F = new Uint32Array(G), U = new Uint32Array(G), H = 0, q = 0, K = k.length; H < K; ++H) {
      R[H] = q;
      for (var Y = k[H].elements, X = 0, Z = Y.length; X < Z; ++X) {
        var J = q + X;
        F[J] = H, U[J] = Y[X];
      }
      q += Y.length;
    }
    return {
      cumulativeUnitElementCount: R,
      unitIndices: F,
      elementIndices: U,
      getSerialIndex: function($, Q) {
        return R[L.get($.id)] + r.OrderedSet.indexOf($.elements, Q);
      }
    };
  }
  return function(V) {
    V.Empty = q([]);
    function k(ye) {
      return { kind: "structure-loci", structure: ye };
    }
    V.Loci = k;
    function G(ye) {
      for (var be = [], fe = 0, ge = ye.units; fe < ge.length; fe++) {
        var xe = ge[fe];
        be.push({
          unit: xe,
          indices: r.Interval.ofBounds(0, xe.elements.length)
        });
      }
      return o.StructureElement.Loci(ye, be);
    }
    V.toStructureElementLoci = G;
    function L(ye, be) {
      return C.StructureSelection.toLociWithSourceUnits(C.StructureSelection.Singletons(ye, be));
    }
    V.toSubStructureElementLoci = L;
    function R(ye) {
      return !!ye && ye.kind === "structure-loci";
    }
    V.isLoci = R;
    function F(ye, be) {
      return ye.structure === be.structure;
    }
    V.areLociEqual = F;
    function U(ye) {
      return ye.structure.isEmpty;
    }
    V.isLociEmpty = U;
    function H(ye, be) {
      return be === ye.structure ? ye : k(be);
    }
    V.remapLoci = H;
    function q(ye, be) {
      be === void 0 && (be = {});
      for (var fe = r.IntMap.Mutable(), ge = r.IntMap.Mutable(), xe = 0, we = !0, Ve = ye.length > 0 ? ye[0].id : 0, Ne = 0, Oe = ye.length; Ne < Oe; Ne++) {
        var ze = ye[Ne];
        fe.set(ze.id, ze), xe += ze.elements.length, ze.id < Ve && (we = !1), Ve = ze.id;
      }
      we || (0, i.sort)(ye, 0, ye.length, A, i.arraySwap);
      for (var Ne = 0, Oe = ye.length; Ne < Oe; Ne++)
        ge.set(ye[Ne].id, Ne);
      var ke = {
        hashCode: -1,
        transformHash: -1,
        elementCount: xe,
        bondCount: -1,
        uniqueElementCount: -1,
        atomicResidueCount: -1,
        polymerResidueCount: -1,
        polymerGapCount: -1,
        polymerUnitCount: -1,
        dynamicBonds: !1,
        coordinateSystem: n.SymmetryOperator.Default,
        label: ""
      };
      return be.parent && (ke.parent = be.parent.parent || be.parent), be.interUnitBonds && (ke.interUnitBonds = be.interUnitBonds), be.dynamicBonds ? ke.dynamicBonds = be.dynamicBonds : be.parent && (ke.dynamicBonds = be.parent.dynamicBonds), be.coordinateSystem ? ke.coordinateSystem = be.coordinateSystem : be.parent && (ke.coordinateSystem = be.parent.coordinateSystem), be.label ? ke.label = be.label : be.parent && (ke.label = be.parent.label), be.masterModel ? ke.masterModel = be.masterModel : be.parent && (ke.masterModel = be.parent.masterModel), be.representativeModel ? ke.representativeModel = be.representativeModel : be.parent && (ke.representativeModel = be.parent.representativeModel), new V(ye, fe, ge, ke);
    }
    V.create = q;
    function K(ye, be) {
      return (0, e.__awaiter)(this, void 0, void 0, function() {
        var fe, ge, xe, we, Ve, Ne, Oe, ze, ke, je, Xe, Fe, He;
        return (0, e.__generator)(this, function(Be) {
          switch (Be.label) {
            case 0:
              if (ye.frameCount === 0)
                return [2, V.Empty];
              fe = [], ge = void 0, xe = 0, we = 0, Ve = ye.frameCount, Be.label = 1;
            case 1:
              return we < Ve ? [4, b.Task.resolveInContext(ye.getFrameAtIndex(we), be)] : [3, 4];
            case 2:
              for (Ne = Be.sent(), ge || (ge = Ne), Oe = Y(Ne), ze = 0, ke = Oe.units.length; ze < ke; ++ze)
                je = Oe.units[ze], Xe = je.invariantId + xe, Fe = je.chainGroupId + xe, He = c.Unit.create(fe.length, Xe, Fe, je.traits, je.kind, je.model, je.conformation.operator, je.elements), fe.push(He);
              xe = fe.length, Be.label = 3;
            case 3:
              return ++we, [3, 1];
            case 4:
              return [2, q(fe, { representativeModel: ge, label: ge.label })];
          }
        });
      });
    }
    V.ofTrajectory = K;
    function Y(ye, be) {
      be === void 0 && (be = {});
      for (var fe = ye.atomicHierarchy.chainAtomSegments, ge = ye.atomicHierarchy.index, xe = ye.atomicHierarchy.chains.auth_asym_id, we = ye.atomicChainOperatorMappinng, Ve = new $((0, e.__assign)({ label: ye.label }, be)), Ne = 0; Ne < fe.count; Ne++) {
        var Oe = we.get(Ne) || n.SymmetryOperator.Default, ze = fe.offsets[Ne];
        y.AtomicHierarchy.chainResidueCount(ye.atomicHierarchy, Ne), fe.offsets[Ne + 1] - fe.offsets[Ne];
        var ke = !1;
        if (X(ye, Ne))
          for (; Ne + 1 < fe.count && X(ye, Ne + 1); ) {
            var je = we.get(Ne), Xe = we.get(Ne + 1);
            if (je !== Xe)
              break;
            ke = !0, Ne++;
          }
        else
          for (; Ne + 1 < fe.count && fe.offsets[Ne + 1] - fe.offsets[Ne] === 1 && fe.offsets[Ne + 2] - fe.offsets[Ne + 1] === 1; ) {
            var Fe = ge.getEntityFromChain(Ne), He = ge.getEntityFromChain(Ne + 1);
            if (Fe !== He)
              break;
            var Be = xe.value(Ne), Ye = xe.value(Ne + 1);
            if (Be !== Ye)
              break;
            var je = we.get(Ne), Xe = we.get(Ne + 1);
            if (je !== Xe)
              break;
            ke = !0, Ne++;
          }
        var cr = r.SortedArray.ofBounds(ze, fe.offsets[Ne + 1]);
        Ve.addUnit(
          0,
          ye,
          Oe,
          cr,
          ke ? 1 : 0
          /* None */
        );
      }
      var Ar = ye.coarseHierarchy;
      return Ar.isDefined && (Ar.spheres.count > 0 && Z(
        Ve,
        ye,
        ye.coarseHierarchy.spheres,
        1
        /* Spheres */
      ), Ar.gaussians.count > 0 && Z(
        Ve,
        ye,
        ye.coarseHierarchy.gaussians,
        2
        /* Gaussians */
      )), Ve.getStructure();
    }
    V.ofModel = Y;
    function X(ye, be) {
      var fe = ye.atomicHierarchy.index.getEntityFromChain(be);
      return ye.entities.data.type.value(fe) === "water";
    }
    function Z(ye, be, fe, ge) {
      for (var xe = fe.chainElementSegments, we = 0; we < xe.count; we++) {
        var Ve = r.SortedArray.ofBounds(xe.offsets[we], xe.offsets[we + 1]);
        ye.addUnit(
          ge,
          be,
          n.SymmetryOperator.Default,
          Ve,
          0
          /* None */
        );
      }
    }
    function J(ye, be) {
      if (p.Mat4.isIdentity(be))
        return ye;
      if (!p.Mat4.isRotationAndTranslation(be, n.SymmetryOperator.RotationTranslationEpsilon))
        throw new Error("Only rotation/translation combination can be applied.");
      for (var fe = [], ge = 0, xe = ye.units; ge < xe.length; ge++) {
        var we = xe[ge], Ve = we.conformation.operator, Ne = n.SymmetryOperator.create(Ve.name, be, Ve);
        fe.push(we.applyOperator(we.id, Ne));
      }
      var Oe = ye.coordinateSystem, ze = n.SymmetryOperator.compose(n.SymmetryOperator.create(Oe.name, be, Oe), Oe);
      return q(fe, { parent: ye, coordinateSystem: ze });
    }
    V.transform = J;
    var $ = (
      /** @class */
      function() {
        function ye(be) {
          be === void 0 && (be = {}), this.props = be, this.units = [], this.invariantId = (0, v.idFactory)(), this.chainGroupId = -1, this.inChainGroup = !1, this.p = (0, p.Vec3)(), this.singleElementUnits = /* @__PURE__ */ new Map();
        }
        return ye.prototype.beginChainGroup = function() {
          this.chainGroupId++, this.inChainGroup = !0;
        }, ye.prototype.endChainGroup = function() {
          this.inChainGroup = !1;
        }, ye.prototype.addUnit = function(be, fe, ge, xe, we, Ve) {
          Ve === void 0 && (Ve = this.invariantId());
          var Ne = this.inChainGroup ? this.chainGroupId : ++this.chainGroupId, Oe = c.Unit.create(Ve, Ve, Ne, we, be, fe, ge, xe);
          return this.add(Oe);
        }, ye.prototype.add = function(be) {
          if (be.elements.length === 1) {
            be.conformation.position(be.elements[0], this.p);
            var fe = [be.invariantId, this.p[0], this.p[1], this.p[2]].join("|");
            if (this.singleElementUnits.has(fe))
              return this.singleElementUnits.get(fe);
            this.singleElementUnits.set(fe, be);
          }
          return this.units.push(be), be;
        }, ye.prototype.addWithOperator = function(be, fe, ge) {
          return ge === void 0 && (ge = !1), this.add(be.applyOperator(this.units.length, fe, ge));
        }, ye.prototype.getStructure = function() {
          return q(this.units, this.props);
        }, Object.defineProperty(ye.prototype, "isEmpty", {
          get: function() {
            return this.units.length === 0;
          },
          enumerable: !1,
          configurable: !0
        }), ye;
      }()
    );
    V.StructureBuilder = $;
    function Q(ye) {
      return ye === void 0 && (ye = {}), new $(ye);
    }
    V.Builder = Q;
    function W(ye) {
      return ye.hashCode;
    }
    V.hashCode = W;
    function te(ye) {
      return (0, i.hashString)(ye.units.map(function(be) {
        return c.Unit.conformationId(be);
      }).join("|"));
    }
    V.conformationHash = te;
    function oe(ye, be) {
      if (ye === be)
        return !0;
      if (ye.elementCount !== be.elementCount)
        return !1;
      var fe = ye.units.length;
      if (fe !== be.units.length)
        return !1;
      for (var ge = 0; ge < fe; ge++)
        if (ye.units[ge].id !== be.units[ge].id)
          return !1;
      return !0;
    }
    V.areUnitIdsEqual = oe;
    function z(ye, be) {
      if (!oe(ye, be))
        return !1;
      for (var fe = 0, ge = ye.units.length; fe < ge; fe++)
        if (!r.SortedArray.areEqual(ye.units[fe].elements, be.units[fe].elements))
          return !1;
      return !0;
    }
    V.areUnitIdsAndIndicesEqual = z;
    function j(ye, be) {
      if (ye.hashCode !== be.hashCode)
        return !1;
      var fe = ye.models.length;
      if (fe !== be.models.length)
        return !1;
      for (var ge = 0; ge < fe; ge++)
        if (!a.Model.areHierarchiesEqual(ye.models[ge], be.models[ge]))
          return !1;
      return !0;
    }
    V.areHierarchiesEqual = j;
    function ae(ye, be) {
      return ye === be || ye.hashCode === be.hashCode && f.StructureSymmetry.areTransformGroupsEquivalent(ye.unitSymmetryGroups, be.unitSymmetryGroups);
    }
    V.areEquivalent = ae;
    function le(ye, be) {
      return ae(ye.root, be.root);
    }
    V.areRootsEquivalent = le;
    function ie(ye, be) {
      return ye.root === be.root;
    }
    V.areRootsEqual = ie;
    var re = (
      /** @class */
      function() {
        function ye(be) {
          this.structure = be, this.unitIndex = 0, this.maxIdx = 0, this.idx = -1, this.current = o.StructureElement.Location.create(be), this.hasNext = be.elementCount > 0, this.hasNext && (this.elements = be.units[0].elements, this.maxIdx = this.elements.length - 1, this.current.unit = be.units[0]);
        }
        return ye.prototype.move = function() {
          return this.advance(), this.current.element = this.elements[this.idx], this.current;
        }, ye.prototype.advance = function() {
          if (this.idx < this.maxIdx) {
            this.idx++, this.idx === this.maxIdx && (this.hasNext = this.unitIndex + 1 < this.structure.units.length);
            return;
          }
          if (this.idx = 0, this.unitIndex++, this.unitIndex >= this.structure.units.length) {
            this.hasNext = !1;
            return;
          }
          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);
        }, ye;
      }()
    );
    V.ElementLocationIterator = re;
    var ee = (0, p.Vec3)();
    function ne(ye, be, fe) {
      for (var ge = ye.elements, xe = ye.conformation, we = xe.position, Ve = xe.r, Ne = ee, Oe = Number.MAX_VALUE, ze = 0, ke = ge.length; ze < ke; ze++) {
        var je = ge[ze], Xe = p.Vec3.distance(be, we(je, Ne)) - fe - Ve(je);
        Xe < Oe && (Oe = Xe);
      }
      return Oe;
    }
    function se(ye, be, fe) {
      for (var ge = ye.units, xe = Number.MAX_VALUE, we = 0, Ve = ge.length; we < Ve; we++) {
        var Ne = ge[we], Oe = ne(Ne, be, fe);
        Oe < xe && (xe = Oe);
      }
      return xe;
    }
    V.minDistanceToPoint = se;
    var ce = (0, p.Vec3)();
    function de(ye, be) {
      if (ye.elementCount === 0 || be.elementCount === 0)
        return 0;
      for (var fe = ye.units, ge = Number.MAX_VALUE, xe = 0, we = fe.length; xe < we; xe++)
        for (var Ve = fe[xe], Ne = Ve.elements, Oe = Ve.conformation, ze = Oe.position, ke = Oe.r, je = 0, Xe = Ne.length; je < Xe; je++) {
          var Fe = Ne[je], He = se(be, ze(Fe, ce), ke(Fe));
          He < ge && (ge = He);
        }
      return ge;
    }
    V.distance = de;
    function me(ye) {
      return ye.elementCount === 1 ? "1 element" : "".concat(ye.elementCount, " elements");
    }
    V.elementDescription = me;
    function he(ye, be, fe) {
      return !0;
    }
    V.validUnitPair = he;
    function _e(ye, be, fe) {
      var ge = fe.maxRadius, xe = fe.validUnit, we = fe.validUnitPair;
      if (ye.units.some(function(Be) {
        return xe(Be);
      }))
        for (var Ve = ye.lookup3d, Ne = (0, p.Vec3)(), Oe = 0, ze = ye.units; Oe < ze.length; Oe++) {
          var ke = ze[Oe];
          if (xe(ke)) {
            var je = ke.boundary.sphere;
            p.Vec3.transformMat4(Ne, je.center, ke.conformation.operator.matrix);
            for (var Xe = Ve.findUnitIndices(Ne[0], Ne[1], Ne[2], je.radius + ge + 9999), Fe = 0; Fe < Xe.count; Fe++) {
              var He = ye.units[Xe.indices[Fe]];
              !xe(He) || ke.id >= He.id || !we(ke, He) || (He.elements.length >= ke.elements.length ? be(ke, He) : be(He, ke));
            }
          }
        }
    }
    V.eachUnitPair = _e;
    function Se(ye, be) {
      for (var fe = be.chain, ge = be.residue, xe = be.atom, we = o.StructureElement.Location.create(ye), Ve = 0, Ne = ye.units; Ve < Ne.length; Ve++) {
        var Oe = Ne[Ve];
        if (Oe.kind === 0) {
          we.unit = Oe;
          for (var ze = Oe.elements, ke = r.Segmentation.transientSegments(Oe.model.atomicHierarchy.chainAtomSegments, ze), je = r.Segmentation.transientSegments(Oe.model.atomicHierarchy.residueAtomSegments, ze); ke.hasNext; ) {
            var Xe = ke.move();
            if (fe && (we.element = ze[Xe.start], fe(we)), !(!ge && !xe))
              for (je.setSegment(Xe); je.hasNext; ) {
                var Fe = je.move();
                if (ge && (we.element = ze[Fe.start], ge(we)), !!xe)
                  for (var He = Fe.start, Be = Fe.end; He < Be; He++)
                    we.element = ze[He], xe(we);
              }
          }
        }
      }
    }
    V.eachAtomicHierarchyElement = Se, V.DefaultSizeThresholds = {
      /** Must be lower to be small */
      smallResidueCount: 10,
      /** Must be lower to be medium */
      mediumResidueCount: 5e3,
      /** Must be lower to be large (big ribosomes like 4UG0 should still be `large`) */
      largeResidueCount: 3e4,
      /**
       * Structures above `largeResidueCount` are consider huge when they have
       * a `highSymmetryUnitCount` or gigantic when not
       */
      highSymmetryUnitCount: 10,
      /** Fiber-like structure are consider small when below this */
      fiberResidueCount: 15
    };
    function Pe(ye) {
      return ye.unitSymmetryGroups.filter(function(be) {
        return be.units[0].polymerElements.length > 0;
      });
    }
    function De(ye, be) {
      var fe = Pe(ye);
      return fe.length === 1 && fe[0].units.length > 2 && fe[0].units[0].polymerElements.length < be.fiberResidueCount;
    }
    function Ee(ye, be) {
      var fe = Pe(ye);
      return fe.length >= 1 && fe[0].units.length > be.highSymmetryUnitCount;
    }
    var Me;
    (function(ye) {
      ye[ye.Small = 0] = "Small", ye[ye.Medium = 1] = "Medium", ye[ye.Large = 2] = "Large", ye[ye.Huge = 3] = "Huge", ye[ye.Gigantic = 4] = "Gigantic";
    })(Me = V.Size || (V.Size = {}));
    function ue(ye, be, fe) {
      be === void 0 && (be = {}), fe === void 0 && (fe = 1);
      var ge = (0, e.__assign)((0, e.__assign)({}, V.DefaultSizeThresholds), be);
      return ye.polymerResidueCount >= ge.largeResidueCount * fe ? Ee(ye, ge) ? Me.Huge : Me.Gigantic : De(ye, ge) || ye.polymerResidueCount < ge.smallResidueCount * fe ? Me.Small : ye.polymerResidueCount < ge.mediumResidueCount * fe ? Me.Medium : Me.Large;
    }
    V.getSize = ue, V.Index = S.CustomStructureProperty.createSimple("index", "root");
    var pe = "__PrincipalAxes__";
    function Ae(ye) {
      if (ye.currentPropertyData[pe])
        return ye.currentPropertyData[pe];
      var be = o.StructureElement.Loci.getPrincipalAxes(V.toStructureElementLoci(ye));
      return ye.currentPropertyData[pe] = be, be;
    }
    V.getPrincipalAxes = Ae;
  }(_ || (_ = {})), lm.Structure = _, lm;
}
var J8;
function eu() {
  return J8 || (J8 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.Loci = void 0;
    var r = Po, t = Qe(), n = Re, a = gs, i = gn(), o = vl(), c = wr(), s = Sp, u = sy(), l = V0(), f = ys, d = qw(), m = d.IntTuple.diff;
    function p(v, h) {
      return { kind: "element-loci", structure: v, elements: h };
    }
    e.Loci = p, function(v) {
      function h(ie) {
        return !!ie && ie.kind === "element-loci";
      }
      v.is = h;
      function y(ie, re) {
        if (ie.structure !== re.structure || ie.elements.length !== re.elements.length)
          return !1;
        for (var ee = 0, ne = ie.elements.length; ee < ne; ++ee) {
          var se = ie.elements[ee], ce = re.elements[ee];
          if (se.unit.id !== ce.unit.id || !t.OrderedSet.areEqual(se.indices, ce.indices))
            return !1;
        }
        return !0;
      }
      v.areEqual = y;
      function C(ie) {
        for (var re = 0, ee = ie.elements; re < ee.length; re++) {
          var ne = ee[re];
          if (t.OrderedSet.size(ne.indices) > 0)
            return !1;
        }
        return !0;
      }
      v.isEmpty = C;
      function S(ie) {
        return b(ie) === ie.structure.elementCount;
      }
      v.isWholeStructure = S;
      function b(ie) {
        for (var re = 0, ee = 0, ne = ie.elements; ee < ne.length; ee++) {
          var se = ne[ee].indices;
          typeof se == "number" ? re += m(se) : re += se.length;
        }
        return re;
      }
      v.size = b;
      function g(ie) {
        return v(ie, ie.units.map(function(re) {
          return {
            unit: re,
            indices: t.OrderedSet.ofBounds(0, re.elements.length)
          };
        }));
      }
      v.all = g;
      function _(ie) {
        return v(ie, []);
      }
      v.none = _;
      function A(ie, re) {
        if (!C(ie)) {
          var ee = ie.elements[0].unit, ne = ee.elements[t.OrderedSet.getAt(ie.elements[0].indices, 0)];
          return re ? (re.structure = ie.structure, re.unit = ie.elements[0].unit, re.element = ne, re) : s.Location.create(ie.structure, ee, ne);
        }
      }
      v.getFirstLocation = A;
      function M(ie) {
        return C(ie) ? ie : v(ie.structure, [{
          unit: ie.elements[0].unit,
          indices: t.OrderedSet.ofSingleton(t.OrderedSet.start(ie.elements[0].indices))
        }]);
      }
      v.firstElement = M;
      function P(ie) {
        return C(ie) ? ie : V(M(ie));
      }
      v.firstResidue = P;
      function T(ie) {
        return C(ie) ? ie : F(M(ie));
      }
      v.firstChain = T;
      function x(ie) {
        for (var re = [], ee = function(de) {
          var me = de.unit, he = de.indices, _e = new Int32Array(t.OrderedSet.size(he));
          t.OrderedSet.forEach(he, function(Se, Pe) {
            return _e[Pe] = me.elements[Se];
          }), re.push(me.getChild(t.SortedArray.ofSortedArray(_e)));
        }, ne = 0, se = ie.elements; ne < se.length; ne++) {
          var ce = se[ne];
          ee(ce);
        }
        return i.Structure.create(re, { parent: ie.structure.parent });
      }
      v.toStructure = x;
      function w(ie, re) {
        if (re === ie.structure)
          return ie;
        var ee = [];
        return ie.elements.forEach(function(ne) {
          if (re.unitMap.has(ne.unit.id)) {
            var se = re.unitMap.get(ne.unit.id), ce = t.OrderedSet.indexedIntersect(ne.indices, ne.unit.elements, se.elements);
            t.OrderedSet.size(ce) > 0 && ee.push({ unit: se, indices: ce });
          }
        }), v(re, ee);
      }
      v.remap = w;
      function E(ie, re) {
        if (ie.elements.length > re.elements.length)
          return E(re, ie);
        if (v.isEmpty(ie))
          return re;
        for (var ee = /* @__PURE__ */ new Map(), ne = 0, se = ie.elements; ne < se.length; ne++) {
          var ce = se[ne];
          ee.set(ce.unit.id, ce.indices);
        }
        for (var de = [], me = 0, he = re.elements; me < he.length; me++) {
          var ce = he[me];
          ee.has(ce.unit.id) ? (de[de.length] = { unit: ce.unit, indices: t.OrderedSet.union(ee.get(ce.unit.id), ce.indices) }, ee.delete(ce.unit.id)) : de[de.length] = ce;
        }
        return ee.forEach(function(_e, Se) {
          de[de.length] = { unit: ie.structure.unitMap.get(Se), indices: _e };
        }), v(ie.structure, de);
      }
      v.union = E;
      function I(ie, re) {
        for (var ee = /* @__PURE__ */ new Map(), ne = 0, se = re.elements; ne < se.length; ne++) {
          var ce = se[ne];
          ee.set(ce.unit.id, ce.indices);
        }
        for (var de = [], me = 0, he = ie.elements; me < he.length; me++) {
          var ce = he[me];
          if (ee.has(ce.unit.id)) {
            var _e = t.OrderedSet.subtract(ce.indices, ee.get(ce.unit.id));
            if (t.OrderedSet.size(_e) === 0)
              continue;
            de[de.length] = { unit: ce.unit, indices: _e };
          } else
            de[de.length] = ce;
        }
        return v(ie.structure, de);
      }
      v.subtract = I;
      function B(ie, re) {
        for (var ee = /* @__PURE__ */ new Map(), ne = 0, se = ie.elements; ne < se.length; ne++) {
          var ce = se[ne];
          ee.set(ce.unit.id, ce.indices);
        }
        for (var de = [], me = 0, he = re.elements; me < he.length; me++) {
          var ce = he[me];
          if (ee.has(ce.unit.id)) {
            var _e = t.OrderedSet.intersect(ee.get(ce.unit.id), ce.indices);
            t.OrderedSet.size(_e) !== 0 && (de[de.length] = { unit: ce.unit, indices: _e });
          }
        }
        return v(ie.structure, de);
      }
      v.intersect = B;
      function D(ie, re) {
        if (ie.elements.length > re.elements.length)
          return D(re, ie);
        if (v.isEmpty(ie))
          return v.isEmpty(re);
        for (var ee = /* @__PURE__ */ new Map(), ne = 0, se = ie.elements; ne < se.length; ne++) {
          var ce = se[ne];
          ee.set(ce.unit.id, ce.indices);
        }
        for (var de = 0, me = re.elements; de < me.length; de++) {
          var ce = me[de];
          if (ee.has(ce.unit.id) && t.OrderedSet.areIntersecting(ee.get(ce.unit.id), ce.indices))
            return !0;
        }
        return !1;
      }
      v.areIntersecting = D;
      function N(ie, re) {
        if (v.isEmpty(ie))
          return v.isEmpty(re);
        for (var ee = /* @__PURE__ */ new Map(), ne = 0, se = ie.elements; ne < se.length; ne++) {
          var ce = se[ne];
          ee.set(ce.unit.id, ce.indices);
        }
        for (var de = !1, me = 0, he = re.elements; me < he.length; me++) {
          var ce = he[me];
          if (ee.has(ce.unit.id))
            if (t.OrderedSet.isSubset(ee.get(ce.unit.id), ce.indices))
              de = !0;
            else
              return !1;
        }
        return de;
      }
      v.isSubset = N;
      function O(ie) {
        return ie.length > 3 && t.SortedArray.isRange(ie) ? t.Interval.ofRange(ie[0], ie[ie.length - 1]) : t.SortedArray.ofSortedArray(ie);
      }
      function V(ie, re) {
        for (var ee = [], ne = /* @__PURE__ */ new Set(), se = 0, ce = ie.elements; se < ce.length; se++) {
          var de = ce[se];
          if (G(de)) {
            ee[ee.length] = de;
            continue;
          }
          if (de.unit.kind === 0) {
            for (var me = de.unit.elements, he = de.unit.model.atomicHierarchy, _e = de.unit.model.atomicHierarchy.atoms.label_alt_id, Se = he.residueAtomSegments, Pe = Se.index, De = Se.offsets, Ee = [], Me = de.indices, ue = t.OrderedSet.size(Me), pe = 0; pe < ue; ) {
              ne.clear();
              var Ae = me[t.OrderedSet.getAt(Me, pe)], ye = Pe[Ae];
              for (ne.add(_e.value(Ae)), pe++; pe < ue; ) {
                var be = me[t.OrderedSet.getAt(Me, pe)];
                if (Pe[be] !== ye)
                  break;
                ne.add(_e.value(be)), pe++;
              }
              for (var fe = ne.has(""), ge = De[ye], xe = De[ye + 1]; ge < xe; ge++) {
                var we = t.OrderedSet.indexOf(me, ge);
                if (we >= 0) {
                  var Ve = _e.value(ge);
                  (!re || fe || !Ve || ne.has(Ve)) && (Ee[Ee.length] = we);
                }
              }
            }
            ee[ee.length] = { unit: de.unit, indices: O(Ee) };
          } else
            ee[ee.length] = de;
        }
        return v(ie.structure, ee);
      }
      v.extendToWholeResidues = V;
      function k(ie) {
        switch (ie.kind) {
          case 0:
            return ie.model.atomicHierarchy.chainAtomSegments;
          case 1:
            return ie.model.coarseHierarchy.spheres.chainElementSegments;
          case 2:
            return ie.model.coarseHierarchy.gaussians.chainElementSegments;
        }
      }
      function G(ie) {
        return ie.unit.elements.length === t.OrderedSet.size(ie.indices);
      }
      function L(ie, re, ee) {
        for (var ne = k(ie).index, se = ie.elements, ce = 0, de = 0, me = se.length; de < me; de++) {
          var he = se[de], _e = ne[he];
          re.has(_e) && ce++;
        }
        if (ce === ie.elements.length) {
          ee[ee.length] = { unit: ie, indices: t.Interval.ofBounds(0, ce) };
          return;
        }
        var Se = new Int32Array(ce);
        ce = 0;
        for (var de = 0, me = se.length; de < me; de++) {
          var he = se[de], _e = ne[he];
          re.has(_e) && (Se[ce++] = de);
        }
        Se.length > 0 && (ee[ee.length] = { unit: ie, indices: O(Se) });
      }
      function R(ie, re, ee, ne, se) {
        for (var ce = k(ie.elements[0].unit).index, de = /* @__PURE__ */ new Set(), me = re; me < ee; me++)
          for (var he = ie.elements[me], _e = he.indices, Se = he.unit.elements, Pe = 0, De = t.OrderedSet.size(_e); Pe < De; Pe++)
            de.add(ce[Se[t.OrderedSet.getAt(_e, Pe)]]);
        if (ne)
          for (var Ee = ie.elements[0].unit, Me = 0, ue = ie.structure.units; Me < ue.length; Me++) {
            var pe = ue[Me];
            o.Unit.areSameChainOperatorGroup(pe, Ee) && L(pe, de, se);
          }
        else
          for (var me = re; me < ee; me++)
            L(ie.elements[me].unit, de, se);
      }
      function F(ie) {
        for (var re = [], ee = 0, ne = ie.elements.length; ee < ne; ee++) {
          var se = ie.elements[ee];
          if (o.Unit.Traits.is(
            se.unit.traits,
            2
            /* Partitioned */
          )) {
            for (var ce = ee; ee < ne && o.Unit.areSameChainOperatorGroup(ie.elements[ee].unit, se.unit); )
              ee++;
            var de = ee;
            ee--, R(ie, ce, de, !0, re);
          } else
            G(se) ? re[re.length] = se : R(ie, ee, ee + 1, !1, re);
        }
        return v(ie.structure, re);
      }
      v.extendToWholeChains = F;
      function U(ie) {
        return "".concat(ie.unit.model.id, "|").concat(l.StructureProperties.entity.id(ie));
      }
      function H(ie) {
        for (var re = [], ee = s.Location.create(ie.structure), ne = /* @__PURE__ */ new Set(), se = ie.structure.units, ce = 0, de = ie.elements.length; ce < de; ce++) {
          var me = ie.elements[ce];
          ee.unit = me.unit, ee.element = me.unit.elements[0], ne.add(U(ee));
        }
        for (var ce = 0, he = se.length; ce < he; ++ce) {
          var _e = se[ce];
          if (ee.unit = _e, ee.element = _e.elements[0], ne.has(U(ee))) {
            var Se = t.OrderedSet.ofBounds(0, _e.elements.length);
            re[re.length] = { unit: _e, indices: Se };
          }
        }
        return v(ie.structure, re);
      }
      v.extendToWholeEntities = H;
      function q(ie) {
        for (var re = [], ee = /* @__PURE__ */ new Set(), ne = ie.structure.units, se = 0, ce = ie.elements.length; se < ce; se++) {
          var de = ie.elements[se];
          ee.add(de.unit.model.id);
        }
        for (var se = 0, me = ne.length; se < me; ++se) {
          var he = ne[se];
          if (ee.has(he.model.id)) {
            var _e = t.OrderedSet.ofBounds(0, he.elements.length);
            re[re.length] = { unit: he, indices: _e };
          }
        }
        return v(ie.structure, re);
      }
      v.extendToWholeModels = q;
      function K(ie, re) {
        for (var ee = [], ne = 0, se = t.OrderedSet.size(re); ne < se; ++ne)
          ee.push(ie[t.OrderedSet.getAt(re, ne)]);
        return t.SortedArray.ofSortedArray(ee);
      }
      function Y(ie, re) {
        return t.SortedArray.isRange(ie) && t.SortedArray.areEqual(ie, re) ? t.Interval.ofLength(ie.length) : O(t.SortedArray.indicesOf(ie, re));
      }
      function X(ie) {
        for (var re = [], ee = /* @__PURE__ */ new Map(), ne = 0, se = ie.elements.length; ne < se; ne++) {
          var ce = ie.elements[ne], de = ce.unit.model, me = K(ce.unit.elements, ce.indices);
          ee.has(de) ? ee.set(de, t.SortedArray.union(me, ee.get(de))) : ee.set(de, me);
        }
        for (var ne = 0, he = ie.structure.units.length; ne < he; ++ne) {
          var _e = ie.structure.units[ne], me = ee.get(_e.model);
          if (me) {
            var Se = Y(_e.elements, me);
            t.OrderedSet.size(Se) && (re[re.length] = { unit: _e, indices: Se });
          }
        }
        return v(ie.structure, re);
      }
      v.extendToAllInstances = X;
      function Z(ie) {
        for (var re = [], ee = /* @__PURE__ */ new Set(), ne = ie.structure.units, se = 0, ce = ie.elements.length; se < ce; se++) {
          var de = ie.elements[se];
          ee.add(de.unit.conformation.operator.name);
        }
        for (var se = 0, me = ne.length; se < me; ++se) {
          var he = ne[se];
          if (ee.has(he.conformation.operator.name)) {
            var _e = t.OrderedSet.ofBounds(0, he.elements.length);
            re[re.length] = { unit: he, indices: _e };
          }
        }
        return v(ie.structure, re);
      }
      v.extendToWholeOperators = Z;
      var J = new f.BoundaryHelper("98"), $ = (0, n.Vec3)();
      function Q(ie, re) {
        J.reset();
        for (var ee = 0, ne = ie.elements; ee < ne.length; ee++)
          for (var se = ne[ee], ce = se.indices, de = se.unit.conformation.position, me = se.unit.conformation.r, he = se.unit.elements, _e = 0, Se = t.OrderedSet.size(ce); _e < Se; _e++) {
            var Pe = he[t.OrderedSet.getAt(ce, _e)];
            de(Pe, $), re && n.Vec3.transformMat4($, $, re), J.includePositionRadius($, me(Pe));
          }
        J.finishedIncludeStep();
        for (var De = 0, Ee = ie.elements; De < Ee.length; De++)
          for (var se = Ee[De], ce = se.indices, de = se.unit.conformation.position, me = se.unit.conformation.r, he = se.unit.elements, _e = 0, Se = t.OrderedSet.size(ce); _e < Se; _e++) {
            var Pe = he[t.OrderedSet.getAt(ce, _e)];
            de(Pe, $), re && n.Vec3.transformMat4($, $, re), J.radiusPositionRadius($, me(Pe));
          }
        return { box: J.getBox(), sphere: J.getSphere() };
      }
      v.getBoundary = Q;
      var W = (0, n.Vec3)();
      function te(ie, re, ee) {
        ee === void 0 && (ee = 0);
        for (var ne = ee, se = 0, ce = ie.elements; se < ce.length; se++) {
          for (var de = ce[se], me = de.indices, he = de.unit.conformation.position, _e = de.unit.elements, Se = t.OrderedSet.size(me), Pe = 0; Pe < Se; Pe++) {
            var De = _e[t.OrderedSet.getAt(me, Pe)];
            he(De, W), n.Vec3.toArray(W, re, ne + Pe * 3);
          }
          ne += Se * 3;
        }
        return re;
      }
      v.toPositionsArray = te;
      function oe(ie) {
        var re = b(ie), ee = te(ie, new Float32Array(3 * re));
        return u.PrincipalAxes.ofPositions(ee);
      }
      v.getPrincipalAxes = oe;
      function z(ie) {
        var re = 0;
        ie.forEach(function(se) {
          re += b(se);
        });
        var ee = new Float32Array(3 * re), ne = 0;
        return ie.forEach(function(se) {
          te(se, ee, ne), ne += b(se) * 3;
        }), u.PrincipalAxes.ofPositions(ee);
      }
      v.getPrincipalAxesMany = z;
      function j(ie, re) {
        return o.Unit.isAtomic(ie) ? ie.model.atomicHierarchy.atomSourceIndex.value(re) : re;
      }
      function ae(ie) {
        var re;
        if (v.isEmpty(ie))
          return a.MolScriptBuilder.struct.generator.empty();
        for (var ee = ie.structure.models, ne = /* @__PURE__ */ new Map(), se = 0, ce = ie.elements; se < ce.length; se++) {
          var de = ce[se], me = de.indices, he = de.unit.elements, _e = de.unit.conformation.operator.name, Se = void 0;
          ne.has(_e) ? Se = ne.get(_e).xs : (Se = r.UniqueArray.create(), ne.set(_e, { modelLabel: de.unit.model.label, modelIndex: de.unit.model.modelNum, xs: Se }));
          for (var Pe = 0, De = t.OrderedSet.size(me); Pe < De; Pe++) {
            var Ee = j(de.unit, he[t.OrderedSet.getAt(me, Pe)]);
            r.UniqueArray.add(Se, Ee, Ee);
          }
        }
        for (var Me = [], ue = ne.keys(); ; ) {
          var pe = ue.next();
          if (pe.done)
            break;
          var de = ne.get(pe.value);
          Me.push(le(pe.value, de.xs.array, ee.length > 1, de.modelLabel, de.modelIndex));
        }
        for (var Ae = /* @__PURE__ */ new Map(), Pe = 0, ye = Me.length; Pe < ye; ++Pe) {
          var be = Me[Pe], fe = (0, c.hash2)((0, c.hashFnv32a)(be.atom.ranges), (0, c.hashFnv32a)(be.atom.set)), _e = "".concat(fe, "|").concat(be.entity ? be.entity.modelLabel + be.entity.modelIndex : "");
          Ae.has(_e) ? (re = Ae.get(_e).chain.opName).push.apply(re, be.chain.opName) : Ae.set(_e, be);
        }
        var ge = [];
        return Ae.forEach(function(xe) {
          var we = xe.atom, Ve = we.ranges, Ne = we.set, Oe = xe.chain.opName, ze = a.MolScriptBuilder.struct.atomProperty.core.operatorName(), ke = a.MolScriptBuilder.struct.atomProperty.core.sourceIndex(), je = [];
          Ne.length > 0 && (je[je.length] = a.MolScriptBuilder.core.set.has([a.MolScriptBuilder.core.type.set(Ne), ke]));
          for (var Xe = 0, Fe = Ve.length / 2; Xe < Fe; Xe++)
            je[je.length] = a.MolScriptBuilder.core.rel.inRange([ke, Ve[2 * Xe], Ve[2 * Xe + 1]]);
          if (xe.entity) {
            var He = xe.entity, Be = He.modelLabel, Ye = He.modelIndex;
            ge.push(a.MolScriptBuilder.struct.generator.atomGroups({
              "atom-test": je.length > 1 ? a.MolScriptBuilder.core.logic.or(je) : je[0],
              "chain-test": Oe.length > 1 ? a.MolScriptBuilder.core.set.has([a.MolScriptBuilder.core.type.set(Oe), ze]) : a.MolScriptBuilder.core.rel.eq([ze, Oe[0]]),
              "entity-test": a.MolScriptBuilder.core.logic.and([
                a.MolScriptBuilder.core.rel.eq([a.MolScriptBuilder.struct.atomProperty.core.modelLabel(), Be]),
                a.MolScriptBuilder.core.rel.eq([a.MolScriptBuilder.struct.atomProperty.core.modelIndex(), Ye])
              ])
            }));
          } else
            ge.push(a.MolScriptBuilder.struct.generator.atomGroups({
              "atom-test": je.length > 1 ? a.MolScriptBuilder.core.logic.or(je) : je[0],
              "chain-test": Oe.length > 1 ? a.MolScriptBuilder.core.set.has([a.MolScriptBuilder.core.type.set(Oe), ze]) : a.MolScriptBuilder.core.rel.eq([ze, Oe[0]])
            }));
        }), a.MolScriptBuilder.struct.modifier.union([
          ge.length === 1 ? ge[0] : a.MolScriptBuilder.struct.combinator.merge(ge.map(function(xe) {
            return a.MolScriptBuilder.struct.modifier.union([xe]);
          }))
        ]);
      }
      v.toExpression = ae;
      function le(ie, re, ee, ne, se) {
        (0, c.sortArray)(re);
        for (var ce = [], de = [], me = 0, he = re.length; me < he; ) {
          var _e = me;
          for (me++; me < he && re[me - 1] + 1 === re[me]; )
            me++;
          var Se = me;
          if (Se - _e > 12)
            ce[ce.length] = re[_e], ce[ce.length] = re[Se - 1];
          else
            for (var Pe = _e; Pe < Se; Pe++)
              de[de.length] = re[Pe];
        }
        return ee ? {
          atom: { set: de, ranges: ce },
          chain: { opName: [ie] },
          entity: { modelLabel: ne, modelIndex: se }
        } : {
          atom: { set: de, ranges: ce },
          chain: { opName: [ie] }
        };
      }
    }(p = e.Loci || (e.Loci = {}));
  }(Xx)), Xx;
}
var p5 = {}, e7;
function yse() {
  return e7 || (e7 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.Stats = void 0;
    var r = Qe(), t = vl(), n = eu(), a = Sp;
    (function(i) {
      function o() {
        return {
          elementCount: 0,
          conformationCount: 0,
          residueCount: 0,
          chainCount: 0,
          unitCount: 0,
          structureCount: 0,
          firstElementLoc: a.Location.create(void 0),
          firstConformationLoc: a.Location.create(void 0),
          firstResidueLoc: a.Location.create(void 0),
          firstChainLoc: a.Location.create(void 0),
          firstUnitLoc: a.Location.create(void 0),
          firstStructureLoc: a.Location.create(void 0)
        };
      }
      i.create = o;
      function c(m, p, v) {
        var h = m.get(p) || 0;
        m.set(p, h + v);
      }
      function s(m, p, v) {
        var h = v.indices, y = v.unit, C = y.elements, S = r.OrderedSet.size(h), b = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
        if (S > 0 && a.Location.set(m.firstElementLoc, p, y, C[r.OrderedSet.start(h)]), S === C.length)
          m.unitCount += 1, m.unitCount === 1 && a.Location.set(m.firstUnitLoc, p, y, C[r.OrderedSet.start(h)]);
        else if (S === 1) {
          if (t.Unit.Traits.is(
            y.traits,
            1
            /* MultiChain */
          ))
            return;
          m.elementCount += 1, m.elementCount === 1 && a.Location.set(m.firstElementLoc, p, y, C[r.OrderedSet.start(h)]);
        } else if (t.Unit.isAtomic(y))
          for (var _ = y.model.atomicHierarchy.residueAtomSegments, A = _.index, M = _.offsets, P = y.model.atomicHierarchy.atoms.label_alt_id, T = 0, x = function() {
            b.clear();
            var w = 0, E = C[r.OrderedSet.getAt(h, T)], I = A[E];
            for (c(b, P.value(E), 1), ++T, ++w; T < S; ) {
              var B = C[r.OrderedSet.getAt(h, T)];
              if (A[B] !== I)
                break;
              c(b, P.value(B), 1), ++T, ++w;
            }
            if (M[I + 1] - M[I] === w)
              m.residueCount += 1, m.residueCount === 1 && a.Location.set(m.firstResidueLoc, p, y, M[I]);
            else {
              g.clear();
              for (var D = M[I], N = M[I + 1]; D < N; ++D)
                c(g, P.value(D), 1);
              g.get("") === b.get("") && b.forEach(function(O, V) {
                if (g.get(V) === O) {
                  if (V !== "" && (m.conformationCount += 1, m.conformationCount === 1)) {
                    for (var k = M[I], G = M[I + 1]; k < G; ++k)
                      if (V === P.value(k)) {
                        a.Location.set(m.firstConformationLoc, p, y, k);
                        break;
                      }
                  }
                  w -= O;
                }
              }), m.elementCount += w;
            }
          }; T < S; )
            x();
        else
          m.elementCount += S, m.elementCount === 1 && a.Location.set(m.firstElementLoc, p, y, C[r.OrderedSet.start(h)]);
      }
      function u(m, p, v) {
        var h = v.indices, y = v.unit, C = r.OrderedSet.size(h);
        if (C !== 0) {
          var S = y.elements;
          if (!t.Unit.Traits.is(
            y.traits,
            1
            /* MultiChain */
          )) {
            C === S.length && (m.chainCount += 1, m.chainCount === 1 && a.Location.set(m.firstChainLoc, p, y, S[r.OrderedSet.start(h)]));
            return;
          }
          var b = t.Unit.isAtomic(y) ? y.model.atomicHierarchy.chainAtomSegments : t.Unit.isSpheres(y) ? y.model.coarseHierarchy.spheres.chainElementSegments : t.Unit.isGaussians(y) ? y.model.coarseHierarchy.gaussians.chainElementSegments : void 0;
          if (!b) {
            console.warn("StructureElement loci stats: unknown unit type");
            return;
          }
          for (var g = b.index, _ = b.offsets, A = 0; A < C; ) {
            var M = 0, P = S[r.OrderedSet.getAt(h, A)], T = g[P];
            for (++A, ++M; A < C; ) {
              var x = S[r.OrderedSet.getAt(h, A)];
              if (g[x] !== T)
                break;
              ++A, ++M;
            }
            _[T + 1] - _[T] === M ? (m.chainCount += 1, m.chainCount === 1 && a.Location.set(m.firstChainLoc, p, y, _[T])) : C === 1 && (m.elementCount += 1, m.elementCount === 1 && a.Location.set(m.firstElementLoc, p, y, P));
          }
        }
      }
      function l(m, p, v, h, y) {
        var C = v[h], S = t.Unit.isAtomic(C.unit) ? C.unit.model.atomicHierarchy.chainAtomSegments : t.Unit.isSpheres(C.unit) ? C.unit.model.coarseHierarchy.spheres.chainElementSegments : t.Unit.isGaussians(C.unit) ? C.unit.model.coarseHierarchy.gaussians.chainElementSegments : void 0;
        if (!S) {
          console.warn("StructureElement loci stats: unknown unit type");
          return;
        }
        for (var b = S.index, g = S.offsets, _ = /* @__PURE__ */ new Map(), A = h; A < y; A++) {
          C = v[A];
          var M = C.indices, P = C.unit, T = r.OrderedSet.size(M);
          if (T !== 0) {
            var x = P.elements;
            if (!t.Unit.Traits.is(
              P.traits,
              1
              /* MultiChain */
            )) {
              var w = x[r.OrderedSet.start(M)];
              c(_, b[w], x.length);
              continue;
            }
            for (var E = 0; E < T; ) {
              var I = 0, w = x[r.OrderedSet.getAt(M, E)], B = b[w];
              for (++E, ++I; E < T; ) {
                var D = x[r.OrderedSet.getAt(M, E)];
                if (b[D] !== B)
                  break;
                ++E, ++I;
              }
              c(_, B, I);
            }
          }
        }
        var N = -1;
        if (_.forEach(function(O, V) {
          g[V + 1] - g[V] === O && (m.chainCount += 1, m.chainCount === 1 && (N = V));
        }), !(N < 0))
          for (var A = h; A < y; A++) {
            C = v[A];
            var M = C.indices, P = C.unit, T = r.OrderedSet.size(M);
            if (T !== 0)
              for (var x = P.elements, E = 0; E < T; ) {
                var w = x[r.OrderedSet.getAt(M, E)], B = b[w];
                if (B === N) {
                  a.Location.set(m.firstChainLoc, p, P, w);
                  return;
                }
              }
          }
      }
      function f(m) {
        var p = o();
        if (n.Loci.isEmpty(m))
          return p;
        var v = !1;
        if (n.Loci.isWholeStructure(m)) {
          if (p.structureCount += 1, p.structureCount === 1) {
            var h = m.elements[0], y = h.unit, C = h.indices;
            a.Location.set(p.firstStructureLoc, m.structure, y, y.elements[r.OrderedSet.min(C)]);
          }
        } else
          for (var S = 0, b = m.elements; S < b.length; S++) {
            var g = b[S];
            s(p, m.structure, g), t.Unit.Traits.is(
              g.unit.traits,
              2
              /* Partitioned */
            ) ? v = !0 : u(p, m.structure, g);
          }
        if (v)
          for (var _ = 0, A = m.elements.length; _ < A; _++) {
            var g = m.elements[_];
            if (t.Unit.Traits.is(
              g.unit.traits,
              2
              /* Partitioned */
            )) {
              for (var M = _; _ < A && t.Unit.areSameChainOperatorGroup(m.elements[_].unit, g.unit); )
                _++;
              var P = _;
              _--, P - M === 1 ? u(p, m.structure, g) : l(p, m.structure, m.elements, M, P);
            }
          }
        return p;
      }
      i.ofLoci = f;
      function d(m, p, v) {
        return p.elementCount === 1 && v.elementCount === 0 ? a.Location.copy(m.firstElementLoc, p.firstElementLoc) : p.elementCount === 0 && v.elementCount === 1 && a.Location.copy(m.firstElementLoc, v.firstElementLoc), p.conformationCount === 1 && v.conformationCount === 0 ? a.Location.copy(m.firstConformationLoc, p.firstConformationLoc) : p.conformationCount === 0 && v.conformationCount === 1 && a.Location.copy(m.firstConformationLoc, v.firstConformationLoc), p.residueCount === 1 && v.residueCount === 0 ? a.Location.copy(m.firstResidueLoc, p.firstResidueLoc) : p.residueCount === 0 && v.residueCount === 1 && a.Location.copy(m.firstResidueLoc, v.firstResidueLoc), p.chainCount === 1 && v.chainCount === 0 ? a.Location.copy(m.firstChainLoc, p.firstChainLoc) : p.chainCount === 0 && v.chainCount === 1 && a.Location.copy(m.firstChainLoc, v.firstChainLoc), p.unitCount === 1 && v.unitCount === 0 ? a.Location.copy(m.firstUnitLoc, p.firstUnitLoc) : p.unitCount === 0 && v.unitCount === 1 && a.Location.copy(m.firstUnitLoc, v.firstUnitLoc), p.structureCount === 1 && v.structureCount === 0 ? a.Location.copy(m.firstStructureLoc, p.firstStructureLoc) : p.structureCount === 0 && v.structureCount === 1 && a.Location.copy(m.firstStructureLoc, v.firstStructureLoc), m.elementCount = p.elementCount + v.elementCount, m.conformationCount = p.conformationCount + v.conformationCount, m.residueCount = p.residueCount + v.residueCount, m.chainCount = p.chainCount + v.chainCount, m.unitCount = p.unitCount + v.unitCount, m.structureCount = p.structureCount + v.structureCount, m;
      }
      i.add = d;
    })(e.Stats || (e.Stats = {}));
  }(p5)), p5;
}
var Ni = {}, r7;
function _se() {
  if (r7) return Ni;
  r7 = 1, Object.defineProperty(Ni, "__esModule", { value: !0 }), Ni.entityIndex = Ni.chainIndex = Ni.residueIndex = Ni.coarseProperty = Ni.atomicProperty = Ni.property = void 0;
  var e = vl(), r = V0();
  function t(u) {
    return u;
  }
  Ni.property = t;
  function n(u) {
    throw new Error("Property only available for ".concat(u, " models."));
  }
  function a(u) {
    return function(l) {
      return e.Unit.isAtomic(l.unit) ? u(l) : n("atomic");
    };
  }
  Ni.atomicProperty = a;
  function i(u) {
    return function(l) {
      return e.Unit.isCoarse(l.unit) ? u(l) : n("coarse");
    };
  }
  Ni.coarseProperty = i;
  function o(u) {
    return e.Unit.isAtomic(u.unit) ? u.unit.residueIndex[u.element] : -1;
  }
  Ni.residueIndex = o;
  function c(u) {
    return e.Unit.isAtomic(u.unit) ? u.unit.chainIndex[u.element] : -1;
  }
  Ni.chainIndex = c;
  function s(u) {
    return r.StructureProperties.entity.key(u);
  }
  return Ni.entityIndex = s, Ni;
}
var t7;
function bse() {
  return t7 || (t7 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 });
    var r = Te;
    (0, r.__exportStar)(Sp, e), (0, r.__exportStar)(eu(), e), (0, r.__exportStar)(AE(), e), (0, r.__exportStar)(yse(), e), (0, r.__exportStar)(_se(), e);
  }(Kx)), Kx;
}
var n7;
function Mp() {
  if (n7) return Sh;
  n7 = 1, Object.defineProperty(Sh, "__esModule", { value: !0 }), Sh.StructureElement = void 0;
  var e = Te, r = (0, e.__importStar)(bse());
  return Sh.StructureElement = r, Sh;
}
var h5 = {}, Vo = {}, Uh = {}, wp = {};
Object.defineProperty(wp, "__esModule", { value: !0 });
wp.CustomModelProperty = void 0;
var zh = Te, wl = Le, a7 = We(), Sse = In, Cse = cs, IM;
(function(e) {
  function r(n) {
    var a = this, i = n.descriptor.name, o = n.type === "static" ? "_staticPropertyData" : "_dynamicPropertyData", c = function(u) {
      return i in u[o] || (u[o][i] = {
        props: (0, zh.__assign)({}, wl.ParamDefinition.getDefaultValues(n.getParams(u))),
        data: a7.ValueBox.create(void 0)
      }), u[o][i];
    }, s = function(u, l, f) {
      var d = c(u);
      u[o][i] = {
        props: l,
        data: a7.ValueBox.withValue(d.data, f)
      };
    };
    return {
      label: n.label,
      descriptor: n.descriptor,
      isHidden: n.isHidden,
      getParams: function(u) {
        var l = wl.ParamDefinition.clone(n.getParams(u));
        return wl.ParamDefinition.setDefaultValues(l, c(u).props), l;
      },
      defaultParams: n.defaultParams,
      isApplicable: n.isApplicable,
      attach: function(u, l, f, d) {
        return f === void 0 && (f = {}), (0, zh.__awaiter)(a, void 0, void 0, function() {
          var m, p, v, h, y;
          return (0, zh.__generator)(this, function(C) {
            switch (C.label) {
              case 0:
                return d && l.customProperties.reference(n.descriptor, !0), m = c(l), p = wl.ParamDefinition.merge(n.defaultParams, m.props, f), m.data.value && wl.ParamDefinition.areEqual(n.defaultParams, m.props, p) ? [
                  2
                  /*return*/
                ] : [4, n.obtain(u, l, p)];
              case 1:
                return v = C.sent(), h = v.value, y = v.assets, l.customProperties.add(n.descriptor), l.customProperties.assets(n.descriptor, y), s(l, p, h), [
                  2
                  /*return*/
                ];
            }
          });
        });
      },
      ref: function(u, l) {
        return u.customProperties.reference(n.descriptor, l);
      },
      get: function(u) {
        var l;
        return (l = c(u)) === null || l === void 0 ? void 0 : l.data;
      },
      set: function(u, l) {
        l === void 0 && (l = {});
        var f = c(u), d = wl.ParamDefinition.merge(n.defaultParams, f.props, l);
        wl.ParamDefinition.areEqual(n.defaultParams, f.props, d) || (s(u, d, void 0), u.customProperties.assets(n.descriptor));
      },
      props: function(u) {
        return c(u).props;
      }
    };
  }
  e.createProvider = r;
  function t(n, a, i) {
    var o = this, c = { value: wl.ParamDefinition.Value(i, { isHidden: !0 }) };
    return r({
      label: (0, Cse.stringToWords)(n),
      descriptor: (0, Sse.CustomPropertyDescriptor)({ name: n }),
      isHidden: !0,
      type: a,
      defaultParams: c,
      getParams: function() {
        return { value: wl.ParamDefinition.Value(i, { isHidden: !0 }) };
      },
      isApplicable: function() {
        return !0;
      },
      obtain: function(s, u, l) {
        return (0, zh.__awaiter)(o, void 0, void 0, function() {
          var f;
          return (0, zh.__generator)(this, function(d) {
            return [2, { value: (f = l.value) !== null && f !== void 0 ? f : i }];
          });
        });
      }
    });
  }
  e.createSimple = t;
})(IM || (IM = {}));
wp.CustomModelProperty = IM;
var i7;
function Ase() {
  if (i7) return Uh;
  i7 = 1, Object.defineProperty(Uh, "__esModule", { value: !0 }), Uh.SIFTSMapping = void 0;
  var e = Te, r = Jo(), t = In, n = wp, a;
  return function(i) {
    var o = this;
    i.Provider = n.CustomModelProperty.createProvider({
      label: "SIFTS Mapping",
      descriptor: (0, t.CustomPropertyDescriptor)({
        name: "sifts_sequence_mapping"
      }),
      type: "static",
      defaultParams: {},
      getParams: function() {
        return {};
      },
      isApplicable: function(f) {
        return c(f);
      },
      obtain: function(f, d) {
        return (0, e.__awaiter)(o, void 0, void 0, function() {
          return (0, e.__generator)(this, function(m) {
            return [2, { value: l(d) }];
          });
        });
      }
    });
    function c(f) {
      if (!r.MmcifFormat.is(f.sourceData))
        return !1;
      var d = f.sourceData.data.db.atom_site, m = d.pdbx_sifts_xref_db_name, p = d.pdbx_sifts_xref_db_acc, v = d.pdbx_sifts_xref_db_num, h = d.pdbx_sifts_xref_db_res;
      return m.isDefined && p.isDefined && v.isDefined && h.isDefined;
    }
    i.isAvailable = c;
    function s(f) {
      var d = f.unit.model, m = i.Provider.get(d).value;
      if (!m)
        return "";
      var p = f.unit.elements[f.element], v = d.atomicHierarchy.residueAtomSegments.index[p];
      return m.accession[v];
    }
    i.getKey = s;
    function u(f) {
      var d = f.unit.model, m = i.Provider.get(d).value;
      if (m) {
        var p = f.unit.elements[f.element], v = d.atomicHierarchy.residueAtomSegments.index[p], h = m.dbName[v];
        if (h)
          return "".concat(h, " ").concat(m.accession[v], " ").concat(m.num[v], " ").concat(m.residue[v]);
      }
    }
    i.getLabel = u;
    function l(f) {
      if (r.MmcifFormat.is(f.sourceData)) {
        var d = f.sourceData.data.db.atom_site, m = d.pdbx_sifts_xref_db_name, p = d.pdbx_sifts_xref_db_acc, v = d.pdbx_sifts_xref_db_num, h = d.pdbx_sifts_xref_db_res;
        if (!(!m.isDefined || !p.isDefined || !v.isDefined || !h.isDefined)) {
          for (var y = f.atomicHierarchy.atomSourceIndex, C = f.atomicHierarchy.residueAtomSegments, S = C.count, b = C.offsets, g = new Array(S), _ = new Array(S), A = new Array(S), M = new Array(S), P = 0; P < S; P++) {
            var T = y.value(b[P]);
            if (m.valueKind(T) !== 0) {
              g[P] = "", _[P] = "", A[P] = "", M[P] = "";
              continue;
            }
            g[P] = m.value(T), _[P] = p.value(T), A[P] = v.value(T), M[P] = h.value(T);
          }
          return { dbName: g, accession: _, num: A, residue: M };
        }
      }
    }
  }(a || (a = {})), Uh.SIFTSMapping = a, Uh;
}
var o7;
function AG() {
  if (o7) return Vo;
  o7 = 1, Object.defineProperty(Vo, "__esModule", { value: !0 }), Vo.atomIdFields = Vo.entityIdFields = Vo.chainIdFields = Vo.residueIdFields = Vo._atom_site = void 0;
  var e = Nu, r = Jo(), t = Ase(), n = ia(), a = e.CifWriter.Field, i = e.CifWriter.Encodings;
  function o(S) {
    var b = n.StructureProperties.chain.label_asym_id(S), g = S.unit.conformation.operator.suffix;
    return g ? b + g : b;
  }
  function c(S) {
    var b = n.StructureProperties.chain.auth_asym_id(S), g = S.unit.conformation.operator.suffix;
    return g ? b + g : b;
  }
  var s = {
    shouldInclude: function(S) {
      var b;
      return !!(!((b = S.atom_site) === null || b === void 0) && b.pdbx_label_index.isDefined);
    },
    value: function(S, b) {
      var g = b.sourceIndex.value(S.element);
      return b.atom_site.pdbx_label_index.value(g);
    }
  }, u = {
    shouldInclude: function(S) {
      return t.SIFTSMapping.isAvailable(S.structure.models[0]);
    },
    pdbx_sifts_xref_db_name: {
      value: function(S, b) {
        var g = b.sourceIndex.value(S.element);
        return b.atom_site.pdbx_sifts_xref_db_name.value(g);
      },
      valueKind: function(S, b) {
        var g = b.sourceIndex.value(S.element);
        return b.atom_site.pdbx_sifts_xref_db_name.valueKind(g);
      }
    },
    pdbx_sifts_xref_db_acc: {
      value: function(S, b) {
        var g = b.sourceIndex.value(S.element);
        return b.atom_site.pdbx_sifts_xref_db_acc.value(g);
      },
      valueKind: function(S, b) {
        var g = b.sourceIndex.value(S.element);
        return b.atom_site.pdbx_sifts_xref_db_acc.valueKind(g);
      }
    },
    pdbx_sifts_xref_db_num: {
      value: function(S, b) {
        var g = b.sourceIndex.value(S.element);
        return b.atom_site.pdbx_sifts_xref_db_num.value(g);
      },
      valueKind: function(S, b) {
        var g = b.sourceIndex.value(S.element);
        return b.atom_site.pdbx_sifts_xref_db_num.valueKind(g);
      }
    },
    pdbx_sifts_xref_db_res: {
      value: function(S, b) {
        var g = b.sourceIndex.value(S.element);
        return b.atom_site.pdbx_sifts_xref_db_res.value(g);
      },
      valueKind: function(S, b) {
        var g = b.sourceIndex.value(S.element);
        return b.atom_site.pdbx_sifts_xref_db_res.valueKind(g);
      }
    }
  }, l = function() {
    return e.CifWriter.fields().str("group_PDB", n.StructureProperties.residue.group_PDB).index("id").str("type_symbol", n.StructureProperties.atom.type_symbol).str("label_atom_id", n.StructureProperties.atom.label_atom_id).str("label_comp_id", n.StructureProperties.atom.label_comp_id).int("label_seq_id", n.StructureProperties.residue.label_seq_id, {
      encoder: i.deltaRLE,
      valueKind: function(S, b) {
        var g = S.unit.model;
        return g.atomicHierarchy.residues.label_seq_id.valueKind(g.atomicHierarchy.residueAtomSegments.index[S.element]);
      }
    }).str("label_alt_id", n.StructureProperties.atom.label_alt_id).str("pdbx_PDB_ins_code", n.StructureProperties.residue.pdbx_PDB_ins_code).str("label_asym_id", o).str("label_entity_id", n.StructureProperties.chain.label_entity_id).float("Cartn_x", n.StructureProperties.atom.x, { digitCount: 3, encoder: i.fixedPoint3 }).float("Cartn_y", n.StructureProperties.atom.y, { digitCount: 3, encoder: i.fixedPoint3 }).float("Cartn_z", n.StructureProperties.atom.z, { digitCount: 3, encoder: i.fixedPoint3 }).float("occupancy", n.StructureProperties.atom.occupancy, {
      digitCount: 2,
      encoder: i.fixedPoint2
    }).float("B_iso_or_equiv", n.StructureProperties.atom.B_iso_or_equiv, {
      digitCount: 2,
      encoder: i.fixedPoint2
    }).int("pdbx_formal_charge", n.StructureProperties.atom.pdbx_formal_charge, {
      encoder: i.deltaRLE,
      valueKind: function(S, b) {
        return S.unit.model.atomicHierarchy.atoms.pdbx_formal_charge.valueKind(S.element);
      }
    }).str("auth_atom_id", n.StructureProperties.atom.auth_atom_id).str("auth_comp_id", n.StructureProperties.atom.auth_comp_id).int("auth_seq_id", n.StructureProperties.residue.auth_seq_id, { encoder: i.deltaRLE }).str("auth_asym_id", c).int("pdbx_PDB_model_num", n.StructureProperties.unit.model_num, { encoder: i.deltaRLE }).int("pdbx_label_index", s.value, {
      shouldInclude: s.shouldInclude
    }).str("pdbx_sifts_xref_db_name", u.pdbx_sifts_xref_db_name.value, {
      shouldInclude: u.shouldInclude,
      valueKind: u.pdbx_sifts_xref_db_name.valueKind
    }).str("pdbx_sifts_xref_db_acc", u.pdbx_sifts_xref_db_acc.value, {
      shouldInclude: u.shouldInclude,
      valueKind: u.pdbx_sifts_xref_db_acc.valueKind
    }).str("pdbx_sifts_xref_db_num", u.pdbx_sifts_xref_db_num.value, {
      shouldInclude: u.shouldInclude,
      valueKind: u.pdbx_sifts_xref_db_num.valueKind
    }).str("pdbx_sifts_xref_db_res", u.pdbx_sifts_xref_db_res.value, {
      shouldInclude: u.shouldInclude,
      valueKind: u.pdbx_sifts_xref_db_res.valueKind
    }).getFields();
  };
  Vo._atom_site = {
    name: "atom_site",
    instance: function(S) {
      var b = S.structures;
      return {
        fields: l(),
        source: b.map(function(g) {
          return {
            data: {
              structure: g,
              sourceIndex: g.model.atomicHierarchy.atomSourceIndex,
              atom_site: r.MmcifFormat.is(g.model.sourceData) ? g.model.sourceData.data.db.atom_site : void 0
            },
            rowCount: g.elementCount,
            keys: function() {
              return g.elementLocations();
            }
          };
        })
      };
    }
  };
  function f(S, b) {
    return S ? "".concat(S, "_").concat(b) : b;
  }
  function d(S) {
    return S ? "pdbx_".concat(S, "_PDB_ins_code") : "pdbx_PDB_ins_code";
  }
  function m(S, b) {
    return function(g, _) {
      return b(S(g, _));
    };
  }
  function p(S, b, g) {
    g && g.includeModelNum && S.int("pdbx_PDB_model_num", m(b, n.StructureProperties.unit.model_num));
  }
  function v(S, b) {
    var g = b && b.prefix, _ = e.CifWriter.fields().str(f(g, "label_comp_id"), m(S, n.StructureProperties.atom.label_comp_id)).int(f(g, "label_seq_id"), m(S, n.StructureProperties.residue.label_seq_id), {
      encoder: i.deltaRLE,
      valueKind: function(A, M) {
        var P = S(A, M), T = P.unit.model;
        return T.atomicHierarchy.residues.label_seq_id.valueKind(T.atomicHierarchy.residueAtomSegments.index[P.element]);
      }
    }).str(d(g), m(S, n.StructureProperties.residue.pdbx_PDB_ins_code)).str(f(g, "label_asym_id"), m(S, n.StructureProperties.chain.label_asym_id)).str(f(g, "label_entity_id"), m(S, n.StructureProperties.chain.label_entity_id)).str(f(g, "auth_comp_id"), m(S, n.StructureProperties.atom.auth_comp_id)).int(f(g, "auth_seq_id"), m(S, n.StructureProperties.residue.auth_seq_id), { encoder: i.deltaRLE }).str(f(g, "auth_asym_id"), m(S, n.StructureProperties.chain.auth_asym_id));
    return p(_, S, b), _.getFields();
  }
  Vo.residueIdFields = v;
  function h(S, b) {
    var g = b && b.prefix, _ = a.build().str(f(g, "label_asym_id"), m(S, n.StructureProperties.chain.label_asym_id)).str(f(g, "label_entity_id"), m(S, n.StructureProperties.chain.label_entity_id)).str(f(g, "auth_asym_id"), m(S, n.StructureProperties.chain.auth_asym_id));
    return p(_, S, b), _.getFields();
  }
  Vo.chainIdFields = h;
  function y(S, b) {
    var g = b && b.prefix, _ = a.build().str(f(g, "label_entity_id"), m(S, n.StructureProperties.chain.label_entity_id));
    return p(_, S, b), _.getFields();
  }
  Vo.entityIdFields = y;
  function C(S, b) {
    var g = b && b.prefix, _ = e.CifWriter.fields().str(f(g, "label_atom_id"), m(S, n.StructureProperties.atom.label_atom_id)).str(f(g, "label_comp_id"), m(S, n.StructureProperties.atom.label_comp_id)).int(f(g, "label_seq_id"), m(S, n.StructureProperties.residue.label_seq_id), {
      encoder: i.deltaRLE,
      valueKind: function(A, M) {
        var P = S(A, M), T = P.unit.model;
        return T.atomicHierarchy.residues.label_seq_id.valueKind(T.atomicHierarchy.residueAtomSegments.index[P.element]);
      }
    }).str(f(g, "label_alt_id"), m(S, n.StructureProperties.atom.label_alt_id)).str(d(g), m(S, n.StructureProperties.residue.pdbx_PDB_ins_code)).str(f(g, "label_asym_id"), m(S, n.StructureProperties.chain.label_asym_id)).str(f(g, "label_entity_id"), m(S, n.StructureProperties.chain.label_entity_id)).str(f(g, "auth_atom_id"), m(S, n.StructureProperties.atom.auth_atom_id)).str(f(g, "auth_comp_id"), m(S, n.StructureProperties.atom.auth_comp_id)).int(f(g, "auth_seq_id"), m(S, n.StructureProperties.residue.auth_seq_id), { encoder: i.deltaRLE }).str(f(g, "auth_asym_id"), m(S, n.StructureProperties.chain.auth_asym_id));
    return p(_, S, b), _.getFields();
  }
  return Vo.atomIdFields = C, Vo;
}
var Tf = {}, u7;
function xse() {
  if (u7) return Tf;
  u7 = 1, Object.defineProperty(Tf, "__esModule", { value: !0 }), Tf._struct_sheet_range = Tf._struct_conf = void 0;
  var e = Te, r = Qe(), t = Nu, n = ia(), a = t.CifWriter.Field, i = AG(), o = Pp;
  Tf._struct_conf = {
    name: "struct_conf",
    instance: function(f) {
      var d = l(f, "helix");
      return {
        fields: s(),
        source: [{ data: d, rowCount: d.length }]
      };
    }
  }, Tf._struct_sheet_range = {
    name: "struct_sheet_range",
    instance: function(f) {
      var d = l(f, "sheet").sort(c);
      return {
        fields: u(),
        source: [{ data: d, rowCount: d.length }]
      };
    }
  };
  function c(f, d) {
    var m = f.element, p = d.element;
    return m.sheet_id < p.sheet_id ? -1 : m.sheet_id === p.sheet_id ? f.start.element - d.start.element : 1;
  }
  var s = function() {
    return (0, e.__spreadArray)((0, e.__spreadArray)((0, e.__spreadArray)([
      a.str("conf_type_id", function(f, d) {
        return d[f].element.type_id;
      }),
      a.str("id", function(f, d, m) {
        return "".concat(d[f].element.type_id).concat(m + 1);
      })
    ], (0, i.residueIdFields)(function(f, d) {
      return d[f].start;
    }, { prefix: "beg" }), !0), (0, i.residueIdFields)(function(f, d) {
      return d[f].end;
    }, { prefix: "end" }), !0), [
      a.str("pdbx_PDB_helix_class", function(f, d) {
        return d[f].element.helix_class;
      }),
      a.str("details", function(f, d) {
        return d[f].element.details || "";
      }, {
        valueKind: function(f, d) {
          return d[f].element.details ? 0 : 2;
        }
      }),
      a.int("pdbx_PDB_helix_length", function(f, d) {
        return d[f].length;
      })
    ], !1);
  }, u = function() {
    return (0, e.__spreadArray)((0, e.__spreadArray)((0, e.__spreadArray)([
      a.str("sheet_id", function(f, d) {
        return d[f].element.sheet_id;
      }),
      a.index("id")
    ], (0, i.residueIdFields)(function(f, d) {
      return d[f].start;
    }, { prefix: "beg" }), !0), (0, i.residueIdFields)(function(f, d) {
      return d[f].end;
    }, { prefix: "end" }), !0), [
      a.str("symmetry", function(f, d) {
        return "";
      }, { valueKind: function(f, d) {
        return 2;
      } })
    ], !1);
  };
  function l(f, d) {
    var m = o.ModelSecondaryStructure.Provider.get(f.firstModel);
    if (!m)
      return [];
    for (var p = m.key, v = m.elements, h = [], y = f.structures[0], C = 0, S = y.unitSymmetryGroups; C < S.length; C++) {
      var b = S[C].units, g = b[0];
      if (n.Unit.isAtomic(g))
        for (var _ = g.model.atomicHierarchy.residueAtomSegments, A = r.Segmentation.transientSegments(_, g.elements), M = void 0, P = !0; A.hasNext; ) {
          P && (M = A.move());
          var T = M.index, x = p[T], w = v[x];
          if (w.kind !== d) {
            P = !0;
            continue;
          }
          for (var E = T; A.hasNext; )
            if (E = M.index, M = A.move(), x !== p[M.index]) {
              P = !1, h[h.length] = {
                start: n.StructureElement.Location.create(y, g, _.offsets[T]),
                end: n.StructureElement.Location.create(y, g, _.offsets[E]),
                length: E - T + 1,
                element: w
              };
              break;
            }
        }
    }
    return h;
  }
  return Tf;
}
var Fu = {}, Vi = {}, s7;
function DE() {
  if (s7) return Vi;
  s7 = 1, Object.defineProperty(Vi, "__esModule", { value: !0 }), Vi.copy_source_mmCifCategory = Vi.copy_mmCif_category = Vi.getUniqueEntityIndicesFromStructures = Vi.getUniqueEntityIdsFromStructures = Vi.getUniqueResidueNamesFromStructures = Vi.getModelMmCifCategory = void 0;
  var e = ds, r = Po, t = wr(), n = Nu, a = Jo(), i = Vu;
  function o(m, p) {
    if (a.MmcifFormat.is(m.sourceData))
      return m.sourceData.data.db[p];
  }
  Vi.getModelMmCifCategory = o;
  function c(m) {
    return e.SetUtils.unionMany.apply(e.SetUtils, m.map(function(p) {
      return p.uniqueResidueNames;
    }));
  }
  Vi.getUniqueResidueNamesFromStructures = c;
  function s(m) {
    if (m.length === 0)
      return /* @__PURE__ */ new Set();
    var p = m[0].model.entities.data.id;
    return new Set(u(m).map(function(v) {
      return p.value(v);
    }));
  }
  Vi.getUniqueEntityIdsFromStructures = s;
  function u(m) {
    if (m.length === 0)
      return [];
    if (m.length === 1)
      return m[0].entityIndices;
    for (var p = r.UniqueArray.create(), v = 0, h = m; v < h.length; v++)
      for (var y = h[v], C = 0, S = y.entityIndices; C < S.length; C++) {
        var b = S[C];
        r.UniqueArray.add(p, b, b);
      }
    return (0, t.sortArray)(p.array), p.array;
  }
  Vi.getUniqueEntityIndicesFromStructures = u;
  function l(m, p) {
    return {
      name: m,
      instance: function(v) {
        var h = v.structures;
        if (p && !p(h[0]))
          return n.CifWriter.Category.Empty;
        var y = h[0].model;
        if (!a.MmcifFormat.is(y.sourceData))
          return n.CifWriter.Category.Empty;
        var C = y.sourceData.data.db[m];
        return !C || !C._rowCount ? n.CifWriter.Category.Empty : n.CifWriter.Category.ofTable(C);
      }
    };
  }
  Vi.copy_mmCif_category = l;
  function f(m, p, v) {
    if (a.MmcifFormat.is(p.firstModel.sourceData)) {
      var h = n.CifWriter.fields();
      if (m.isBinary)
        for (var y = 0, C = v.fieldNames; y < C.length; y++) {
          var S = C[y], b = d(S, v.getField(S));
          h.add(b);
        }
      else
        for (var g = function(P) {
          var T = v.getField(P);
          h.str(P, function(x) {
            return T.str(x);
          });
        }, _ = 0, A = v.fieldNames; _ < A.length; _++) {
          var S = A[_];
          g(S);
        }
      var M = h.getFields();
      return {
        name: v.name,
        instance: function() {
          return { fields: M, source: [{ data: void 0, rowCount: v.rowCount }] };
        }
      };
    }
  }
  Vi.copy_source_mmCifCategory = f;
  function d(m, p) {
    var v = (0, i.getCifFieldType)(p);
    return v["@type"] === "str" ? { name: m, type: 0, value: p.str, valueKind: p.valueKind } : v["@type"] === "float" ? n.CifWriter.Field.float(m, p.float, { valueKind: p.valueKind, typedArray: Float64Array }) : n.CifWriter.Field.int(m, p.int, { valueKind: p.valueKind, typedArray: Int32Array });
  }
  return Vi;
}
var l7;
function Tse() {
  if (l7) return Fu;
  l7 = 1, Object.defineProperty(Fu, "__esModule", { value: !0 }), Fu._pdbx_nonpoly_scheme = Fu._pdbx_chem_comp_identifier = Fu._chem_comp_bond = Fu._chem_comp = void 0;
  var e = mr(), r = Nu, t = DE(), n = r.CifWriter.Category;
  return Fu._chem_comp = {
    name: "chem_comp",
    instance: function(a) {
      a.firstModel;
      var i = a.structures, o = a.cache, c = (0, t.getModelMmCifCategory)(i[0].model, "chem_comp");
      if (!c)
        return n.Empty;
      var s = c.id, u = o.uniqueResidueNames || (o.uniqueResidueNames = (0, t.getUniqueResidueNamesFromStructures)(i)), l = e.Column.indicesOf(s, function(f) {
        return u.has(f);
      });
      return n.ofTable(c, l);
    }
  }, Fu._chem_comp_bond = {
    name: "chem_comp_bond",
    instance: function(a) {
      a.firstModel;
      var i = a.structures, o = a.cache, c = (0, t.getModelMmCifCategory)(i[0].model, "chem_comp_bond");
      if (!c)
        return n.Empty;
      var s = c.comp_id, u = o.uniqueResidueNames || (o.uniqueResidueNames = (0, t.getUniqueResidueNamesFromStructures)(i)), l = e.Column.indicesOf(s, function(f) {
        return u.has(f);
      });
      return n.ofTable(c, l);
    }
  }, Fu._pdbx_chem_comp_identifier = {
    name: "pdbx_chem_comp_identifier",
    instance: function(a) {
      var i = a.firstModel, o = a.structures, c = a.cache, s = (0, t.getModelMmCifCategory)(i, "pdbx_chem_comp_identifier");
      if (!s)
        return n.Empty;
      var u = s.comp_id, l = c.uniqueResidueNames || (c.uniqueResidueNames = (0, t.getUniqueResidueNamesFromStructures)(o)), f = e.Column.indicesOf(u, function(d) {
        return l.has(d);
      });
      return n.ofTable(s, f);
    }
  }, Fu._pdbx_nonpoly_scheme = {
    name: "pdbx_nonpoly_scheme",
    instance: function(a) {
      var i = a.firstModel;
      a.structures, a.cache;
      var o = (0, t.getModelMmCifCategory)(i, "pdbx_nonpoly_scheme");
      return o ? n.ofTable(o) : n.Empty;
    }
  }, Fu;
}
var El = {}, c7;
function Pse() {
  if (c7) return El;
  c7 = 1, Object.defineProperty(El, "__esModule", { value: !0 }), El._entity_poly_seq = El._entity_poly = El._struct_asym = void 0;
  var e = mr(), r = Nu, t = DE(), n = r.CifWriter.Category;
  El._struct_asym = a("struct_asym"), El._entity_poly = a("entity_poly"), El._entity_poly_seq = a("entity_poly_seq");
  function a(o) {
    return {
      name: o,
      instance: function(c) {
        var s = c.structures, u = c.cache;
        return i(s, o, u);
      }
    };
  }
  function i(o, c, s) {
    var u = (0, t.getModelMmCifCategory)(o[0].model, c);
    if (!u)
      return n.Empty;
    var l = u.entity_id, f = s.uniqueEntityIds || (s.uniqueEntityIds = (0, t.getUniqueEntityIdsFromStructures)(o)), d = e.Column.indicesOf(l, function(m) {
      return f.has(m);
    });
    return n.ofTable(u, d);
  }
  return El;
}
var d7;
function Mse() {
  return d7 || (d7 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.to_mmCIF = e.encode_mmCIF_categories = e.mmCIF_Export_Filters = e.CifExportContext = void 0;
    var r = Nu, t = AG(), n = r.CifWriter.Category, a = xse(), i = Tse(), o = DE(), c = Pse(), s = In, u = xG(), l = Jo(), f;
    (function(_) {
      function A(M) {
        var P = Array.isArray(M) ? M : [M];
        return {
          structures: P,
          firstModel: P[0].model,
          cache: /* @__PURE__ */ Object.create(null)
        };
      }
      _.create = A;
    })(f = e.CifExportContext || (e.CifExportContext = {}));
    var d = {
      name: "entity",
      instance: function(_) {
        var A = _.structures, M = (0, o.getUniqueEntityIndicesFromStructures)(A);
        return n.ofTable(A[0].model.entities.data, M);
      }
    };
    function m(_) {
      return _.units.every(function(A) {
        return A.conformation.operator.isIdentity;
      });
    }
    function p(_) {
      return m(_) && _.units.every(function(A) {
        return !A.conformation.operator.assembly && !A.conformation.operator.suffix;
      });
    }
    var v = [
      // Basics
      (0, o.copy_mmCif_category)("entry"),
      (0, o.copy_mmCif_category)("exptl"),
      d,
      // Symmetry
      (0, o.copy_mmCif_category)("cell", m),
      (0, o.copy_mmCif_category)("symmetry", m),
      // Assemblies
      (0, o.copy_mmCif_category)("pdbx_struct_assembly", p),
      (0, o.copy_mmCif_category)("pdbx_struct_assembly_gen", p),
      (0, o.copy_mmCif_category)("pdbx_struct_oper_list", p),
      // Secondary structure
      a._struct_conf,
      a._struct_sheet_range,
      // Sequence
      c._struct_asym,
      c._entity_poly,
      c._entity_poly_seq,
      // Branch
      (0, o.copy_mmCif_category)("pdbx_entity_branch"),
      (0, o.copy_mmCif_category)("pdbx_entity_branch_link"),
      (0, o.copy_mmCif_category)("pdbx_branch_scheme"),
      // Struct conn
      (0, o.copy_mmCif_category)("struct_conn"),
      // Misc
      i._chem_comp,
      i._chem_comp_bond,
      i._pdbx_chem_comp_identifier,
      (0, o.copy_mmCif_category)("atom_sites"),
      i._pdbx_nonpoly_scheme,
      // Atoms
      t._atom_site
    ], h;
    (function(_) {
      _.AtomSitePositionsFieldNames = /* @__PURE__ */ new Set(["id", "Cartn_x", "Cartn_y", "Cartn_z"]);
    })(h || (h = {})), e.mmCIF_Export_Filters = {
      onlyPositions: {
        includeCategory: function(_) {
          return _ === "atom_site";
        },
        includeField: function(_, A) {
          return h.AtomSitePositionsFieldNames.has(A);
        }
      }
    };
    function y(_, A, M) {
      var P;
      if (!_.cifExport || _.cifExport.categories.length === 0)
        return [];
      var T = _.cifExport.prefix, x = _.cifExport.categories, w = A;
      if (_.cifExport.context) {
        var E = s.CustomPropertyDescriptor.getUUID(_);
        A.cache[E + "__ctx"] ? w = A.cache[E + "__ctx"] : (w = _.cifExport.context(A) || A, A.cache[E + "__ctx"] = w);
      }
      for (var I = [], B = 0, D = x; B < D.length; B++) {
        var N = D[B];
        if (!(!((P = M == null ? void 0 : M.skipCategoryNames) === null || P === void 0) && P.has(N.name))) {
          if (N.name.indexOf(T) !== 0)
            throw new Error("Custom category '".concat(N.name, "' name must start with prefix '").concat(T, ".'"));
          I.push([N, w]);
        }
      }
      return I;
    }
    function C(_, A, M) {
      var P = Array.isArray(A) ? A[0] : A, T = P.models;
      if (T.length !== 1)
        throw new Error("Can't export stucture composed from multiple models.");
      var x = (M == null ? void 0 : M.exportCtx) || f.create(A);
      M != null && M.copyAllCategories && l.MmcifFormat.is(T[0].sourceData) ? b(_, x, M) : S(_, x, M);
    }
    e.encode_mmCIF_categories = C;
    function S(_, A, M) {
      for (var P, T = 0, x = v; T < x.length; T++) {
        var w = x[T];
        M != null && M.skipCategoryNames && (M != null && M.skipCategoryNames.has(w.name)) || _.writeCategory(w, A);
      }
      if (!(!((P = M == null ? void 0 : M.skipCategoryNames) === null || P === void 0) && P.has("atom_site")) && _.isCategoryIncluded("atom_site")) {
        var E = (0, u.atom_site_operator_mapping)(A);
        E && _.writeCategory(E[0], E[1], E[2]);
      }
      for (var I = M || {}, B = 0, D = A.firstModel.customProperties.all; B < D.length; B++)
        for (var N = D[B], O = 0, V = y(N, A, I); O < V.length; O++) {
          var k = V[O], w = k[0], G = k[1];
          _.writeCategory(w, G);
        }
      if (M != null && M.customProperties)
        for (var L = 0, R = M == null ? void 0 : M.customProperties; L < R.length; L++)
          for (var N = R[L], F = 0, U = y(N, A, I); F < U.length; F++) {
            var H = U[F], w = H[0], G = H[1];
            _.writeCategory(w, G);
          }
      for (var q = 0, K = A.structures; q < K.length; q++) {
        var Y = K[q];
        if (Y.hasCustomProperties)
          for (var X = 0, Z = Y.customPropertyDescriptors.all; X < Z.length; X++)
            for (var N = Z[X], J = 0, $ = y(N, A, I); J < $.length; J++) {
              var Q = $[J], w = Q[0], G = Q[1];
              _.writeCategory(w, G);
            }
      }
    }
    function b(_, A, M) {
      for (var P = /* @__PURE__ */ new Map(), T = 0, x = v; T < x.length; T++) {
        var w = x[T];
        P.set(w.name, [w, A]);
      }
      var E = (0, u.atom_site_operator_mapping)(A);
      E && P.set(E[0].name, E);
      for (var I = M || {}, B = 0, D = A.firstModel.customProperties.all; B < D.length; B++)
        for (var N = D[B], O = 0, V = y(N, A, I); O < V.length; O++) {
          var k = V[O];
          P.set(k[0].name, k);
        }
      if (M != null && M.customProperties)
        for (var G = 0, L = M == null ? void 0 : M.customProperties; G < L.length; G++)
          for (var N = L[G], R = 0, F = y(N, A, I); R < F.length; R++) {
            var k = F[R];
            P.set(k[0].name, k);
          }
      for (var U = 0, H = A.structures; U < H.length; U++) {
        var q = H[U];
        if (q.hasCustomProperties)
          for (var K = 0, Y = q.customPropertyDescriptors.all; K < Y.length; K++)
            for (var N = Y[K], X = 0, Z = y(N, A); X < Z.length; X++) {
              var k = Z[X];
              P.set(k[0].name, k);
            }
      }
      for (var J = /* @__PURE__ */ new Set(), $ = A.firstModel.sourceData.data, Q = 0, W = $.frame.categoryNames; Q < W.length; Q++) {
        var te = W[Q];
        if (J.add(te), P.has(te)) {
          var k = P.get(te);
          _.writeCategory(k[0], k[1], k[2]);
        } else if ($.db[te]) {
          var w = (0, o.copy_mmCif_category)(te);
          _.writeCategory(w, A);
        } else {
          var w = (0, o.copy_source_mmCifCategory)(_, A, $.frame.categories[te]);
          w && _.writeCategory(w);
        }
      }
      P.forEach(function(oe, z) {
        J.has(z) || _.writeCategory(oe[0], oe[1], oe[2]);
      });
    }
    function g(_, A, M, P) {
      M === void 0 && (M = !1);
      var T = r.CifWriter.createEncoder({ binary: M });
      return T.startDataBlock(_), C(T, A, P), T.getData();
    }
    e.to_mmCIF = g;
  }(h5)), h5;
}
var f7;
function ia() {
  return f7 || (f7 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.StructureProperties = e.StructureSymmetry = e.Unit = e.Structure = e.Bond = e.StructureElement = void 0;
    var r = Te, t = Mp();
    Object.defineProperty(e, "StructureElement", { enumerable: !0, get: function() {
      return t.StructureElement;
    } });
    var n = gn();
    Object.defineProperty(e, "Structure", { enumerable: !0, get: function() {
      return n.Structure;
    } });
    var a = vl();
    Object.defineProperty(e, "Unit", { enumerable: !0, get: function() {
      return a.Unit;
    } });
    var i = WC();
    Object.defineProperty(e, "StructureSymmetry", { enumerable: !0, get: function() {
      return i.StructureSymmetry;
    } });
    var o = TC();
    Object.defineProperty(e, "Bond", { enumerable: !0, get: function() {
      return o.Bond;
    } });
    var c = V0();
    Object.defineProperty(e, "StructureProperties", { enumerable: !0, get: function() {
      return c.StructureProperties;
    } }), (0, r.__exportStar)(fc, e), (0, r.__exportStar)(Mse(), e);
  }($x)), $x;
}
var m7;
function xG() {
  if (m7) return Pl;
  m7 = 1, Object.defineProperty(Pl, "__esModule", { value: !0 }), Pl.AtomSiteOperatorMappingSchema = Pl.AtomSiteOperatorMappingCategoryName = Pl.atom_site_operator_mapping = void 0;
  var e = ia(), r = Qe(), t = Nu, n = mr();
  function a(l) {
    var f = u(l);
    if (f.length !== 0)
      return [s, f, { ignoreFilter: !0 }];
  }
  Pl.atom_site_operator_mapping = a, Pl.AtomSiteOperatorMappingCategoryName = "molstar_atom_site_operator_mapping", Pl.AtomSiteOperatorMappingSchema = {
    molstar_atom_site_operator_mapping: {
      label_asym_id: n.Column.Schema.Str(),
      auth_asym_id: n.Column.Schema.Str(),
      operator_name: n.Column.Schema.Str(),
      suffix: n.Column.Schema.Str(),
      // assembly
      assembly_id: n.Column.Schema.Str(),
      assembly_operator_id: n.Column.Schema.Int(),
      // symmetry
      symmetry_operator_index: n.Column.Schema.Int(),
      symmetry_hkl: n.Column.Schema.Vector(3),
      // NCS
      ncs_id: n.Column.Schema.Int()
    }
  };
  var i = function(l, f) {
    return typeof f[l].operator.assembly > "u" ? 1 : 0;
  }, o = function(l, f) {
    return f[l].operator.spgrOp === -1 ? 1 : 0;
  }, c = t.CifWriter.fields().str("label_asym_id", function(l, f) {
    return f[l].label_asym_id;
  }).str("auth_asym_id", function(l, f) {
    return f[l].auth_asym_id;
  }).str("operator_name", function(l, f) {
    return f[l].operator.name;
  }).str("suffix", function(l, f) {
    return f[l].operator.suffix;
  }).str("assembly_id", function(l, f) {
    var d;
    return ((d = f[l].operator.assembly) === null || d === void 0 ? void 0 : d.id) || "";
  }, { valueKind: i }).int("assembly_operator_id", function(l, f) {
    var d;
    return ((d = f[l].operator.assembly) === null || d === void 0 ? void 0 : d.operId) || 0;
  }, { valueKind: i }).int("symmetry_operator_index", function(l, f) {
    return f[l].operator.spgrOp;
  }, { valueKind: o }).vec("symmetry_hkl", [function(l, f) {
    return f[l].operator.hkl[0];
  }, function(l, f) {
    return f[l].operator.hkl[1];
  }, function(l, f) {
    return f[l].operator.hkl[2];
  }], { valueKind: o }).int("ncs_id", function(l, f) {
    return f[l].operator.ncsId;
  }, { valueKind: o }).getFields(), s = {
    name: "molstar_atom_site_operator_mapping",
    instance: function(l) {
      return { fields: c, source: [{ data: l, rowCount: l.length }] };
    }
  };
  function u(l) {
    for (var f = /* @__PURE__ */ new Set(), d = [], m = 0, p = l.structures; m < p.length; m++)
      for (var v = p[m], h = e.StructureElement.Location.create(v), y = 0, C = v.units; y < C.length; y++) {
        var S = C[y], b = S.conformation.operator;
        if (!(!b.suffix || S.kind !== 0)) {
          h.unit = S;
          for (var g = S.elements, _ = r.Segmentation.transientSegments(S.model.atomicHierarchy.chainAtomSegments, g); _.hasNext; ) {
            var A = _.move();
            h.element = g[A.start];
            var M = e.StructureProperties.chain.label_asym_id(h), P = "".concat(M).concat(b.suffix);
            if (!f.has(P)) {
              f.add(P);
              var T = e.StructureProperties.chain.label_asym_id(h);
              d.push({ label_asym_id: M, auth_asym_id: T, operator: b });
            }
          }
        }
      }
    return d;
  }
  return Pl;
}
var QC = {};
Object.defineProperty(QC, "__esModule", { value: !0 });
QC.getAtomicDerivedData = void 0;
var wse = _s, Gh = Gr, p2 = Za, Ese = Zt;
function Dse(e, r, t, n) {
  for (var a = e.atoms, i = a.label_comp_id, o = a.type_symbol, c = a._rowCount, s = e.residues._rowCount, u = r.residueAtomSegments.offsets, l = new Uint8Array(c), f = 0; f < c; ++f)
    l[f] = (0, wse.AtomNumber)(o.value(f));
  for (var d = new Int32Array(s), m = new Int32Array(s), p = new Int32Array(s), v = new Uint8Array(s), h = new Uint8Array(s), y = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), f = 0; f < s; ++f) {
    var S = i.value(u[f]), b = n, g = void 0, _ = void 0;
    if (y.has(S))
      g = y.get(S), _ = C.get(S);
    else {
      var A = void 0;
      b.has(S) ? A = b.get(S).type : (Ese.isProductionMode || console.info("chemComp not found", S), A = (0, Gh.getComponentType)(S)), g = (0, Gh.getMoleculeType)(A, S), _ = (0, Gh.getPolymerType)(A, g), y.set(S, g), C.set(S, _);
    }
    v[f] = g, h[f] = _;
    var M = (0, p2.getAtomIdForAtomRole)(_, "trace"), P = t.findAtomsOnResidue(f, M);
    if (P === -1) {
      var T = (0, p2.getAtomIdForAtomRole)(_, "coarseBackbone");
      P = t.findAtomsOnResidue(f, T), P === -1 && (0, Gh.isPolymer)(g) && (P = t.findElementOnResidue(f, (0, Gh.ElementSymbol)("C")));
    }
    d[f] = P;
    var x = (0, p2.getAtomIdForAtomRole)(_, "directionFrom");
    m[f] = t.findAtomsOnResidue(f, x);
    var w = (0, p2.getAtomIdForAtomRole)(_, "directionTo");
    p[f] = t.findAtomsOnResidue(f, w);
  }
  return {
    atom: {
      atomicNumber: l
    },
    residue: {
      traceElementIndex: d,
      directionFromElementIndex: m,
      directionToElementIndex: p,
      moleculeType: v,
      polymerType: h
    }
  };
}
QC.getAtomicDerivedData = Dse;
var ZC = {};
Object.defineProperty(ZC, "__esModule", { value: !0 });
ZC.getAtomicIndex = void 0;
var j1 = Qe(), BM = ME, g5 = wr();
function $1(e, r) {
  return r ? r.length === 1 ? (0, g5.cantorPairing)(r.charCodeAt(0), e) : r.length === 2 ? (0, g5.cantorPairing)(r.charCodeAt(0), (0, g5.cantorPairing)(r.charCodeAt(1), e)) : "".concat(e, " ").concat(r) : e;
}
function Ise(e, r, t, n) {
  if (e.has(r)) {
    var a = e.get(r);
    a.has(t) || a.set(t, n);
  } else {
    var a = /* @__PURE__ */ new Map();
    e.set(r, a), a.set(t, n);
  }
}
function Bse(e) {
  throw new Error("Missing entity entry for entity id '".concat(e, "'."));
}
function Nse(e, r, t) {
  return {
    entities: e,
    segments: t,
    label_seq_id: j1.SortedArray.ofSortedArray(r.residues.label_seq_id.toArray({ array: Int32Array })),
    label_atom_id: r.atoms.label_atom_id,
    auth_atom_id: r.atoms.auth_atom_id,
    label_alt_id: r.atoms.label_alt_id,
    type_symbol: r.atoms.type_symbol,
    chain_index_entity_index: new Int32Array(r.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()
  };
}
var qh = BM.AtomicIndex.EmptyResidueKey(), Vse = (
  /** @class */
  function() {
    function e(r) {
      this.map = r, this.entityIndex = r.entities.getEntityIndex, this.residueOffsets = this.map.segments.residueAtomSegments.offsets;
    }
    return e.prototype.getEntityFromChain = function(r) {
      return this.map.chain_index_entity_index[r];
    }, e.prototype.findEntity = function(r) {
      var t = this.map.label_asym_id.get(r);
      return t !== void 0 ? t : -1;
    }, e.prototype.findChainLabel = function(r) {
      var t = this.entityIndex(r.label_entity_id);
      if (t < 0 || !this.map.entity_index_label_asym_id.has(t))
        return -1;
      var n = this.map.entity_index_label_asym_id.get(t);
      return n && n.has(r.label_asym_id) ? n.get(r.label_asym_id) : -1;
    }, e.prototype.findChainAuth = function(r) {
      if (!this.map.auth_asym_id_auth_seq_id.has(r.auth_asym_id))
        return -1;
      var t = this.map.auth_asym_id_auth_seq_id.get(r.auth_asym_id);
      return t.has(r.auth_seq_id) ? t.get(r.auth_seq_id) : -1;
    }, e.prototype.findResidue = function(r, t, n, a) {
      var i;
      arguments.length === 1 ? i = r : (qh.label_entity_id = r, qh.label_asym_id = t, qh.auth_seq_id = n, qh.pdbx_PDB_ins_code = a, i = qh);
      var o = this.findChainLabel(i);
      if (o < 0)
        return -1;
      var c = this.map.chain_index_auth_seq_id.get(o), s = $1(i.auth_seq_id, i.pdbx_PDB_ins_code || "");
      return c.has(s) ? c.get(s) : -1;
    }, e.prototype.findResidueAuth = function(r) {
      var t = this.findChainAuth(r);
      if (t < 0)
        return -1;
      var n = this.map.chain_index_auth_seq_id.get(t), a = $1(r.auth_seq_id, r.pdbx_PDB_ins_code || "");
      return n.has(a) ? n.get(a) : -1;
    }, e.prototype.findResidueInsertion = function(r) {
      var t = this.findChainLabel(r);
      if (t < 0)
        return -1;
      var n = this.map.chain_index_label_seq_id.get(t), a = $1(r.label_seq_id, r.pdbx_PDB_ins_code || "");
      if (n.has(a))
        return n.get(a);
      var i = j1.SortedArray.findPredecessorIndex(this.map.label_seq_id, r.label_seq_id), o = BM.AtomicHierarchy.chainStartResidueIndex(this.map.segments, t);
      if (i < o)
        return o;
      var c = BM.AtomicHierarchy.chainEndResidueIndexExcl(this.map.segments, t) - 1;
      return i >= c ? c : i;
    }, e.prototype.findAtom = function(r) {
      var t = this.findResidue(r);
      return t < 0 ? -1 : typeof r.label_alt_id > "u" ? y5(this.residueOffsets[t], this.residueOffsets[t + 1], this.map.label_atom_id, r.label_atom_id) : _5(this.residueOffsets[t], this.residueOffsets[t + 1], this.map.label_atom_id, this.map.label_alt_id, r.label_atom_id, r.label_alt_id);
    }, e.prototype.findAtomAuth = function(r) {
      var t = this.findResidueAuth(r);
      return t < 0 ? -1 : typeof r.label_alt_id > "u" ? y5(this.residueOffsets[t], this.residueOffsets[t + 1], this.map.auth_atom_id, r.auth_atom_id) : _5(this.residueOffsets[t], this.residueOffsets[t + 1], this.map.auth_atom_id, this.map.label_alt_id, r.auth_atom_id, r.label_alt_id);
    }, e.prototype.findAtomOnResidue = function(r, t, n) {
      return typeof n > "u" ? y5(this.residueOffsets[r], this.residueOffsets[r + 1], this.map.label_atom_id, t) : _5(this.residueOffsets[r], this.residueOffsets[r + 1], this.map.label_atom_id, this.map.label_alt_id, t, n);
    }, e.prototype.findAtomsOnResidue = function(r, t) {
      return Rse(this.residueOffsets[r], this.residueOffsets[r + 1], this.map.label_atom_id, t);
    }, e.prototype.findElementOnResidue = function(r, t) {
      return Ose(this.residueOffsets[r], this.residueOffsets[r + 1], this.map.type_symbol, t);
    }, e;
  }()
);
function y5(e, r, t, n) {
  for (var a = e; a < r; a++)
    if (t.value(a) === n)
      return a;
  return -1;
}
function Rse(e, r, t, n) {
  for (var a = e; a < r; a++)
    if (n.has(t.value(a)))
      return a;
  return -1;
}
function _5(e, r, t, n, a, i) {
  for (var o = e; o < r; o++)
    if (t.value(o) === a && n.value(o) === i)
      return o;
  return -1;
}
function Ose(e, r, t, n) {
  for (var a = e; a < r; a++)
    if (t.value(a) === n)
      return a;
  return -1;
}
function Fse(e, r, t) {
  for (var n = Nse(r, e, t), a = e.residues, i = a.label_seq_id, o = a.auth_seq_id, c = a.pdbx_PDB_ins_code, s = e.chains, u = s.label_entity_id, l = s.label_asym_id, f = s.auth_asym_id, d = j1.Interval.ofBounds(0, e.atoms._rowCount), m = j1.Segmentation.transientSegments(t.chainAtomSegments, d); m.hasNext; ) {
    var p = m.move(), v = p.index, h = r.getEntityIndex(u.value(v));
    h < 0 && Bse(u.value(v)), n.chain_index_entity_index[v] = h;
    var y = f.value(v), C = n.auth_asym_id_auth_seq_id.get(y);
    C || (C = /* @__PURE__ */ new Map(), n.auth_asym_id_auth_seq_id.set(y, C));
    var S = l.value(v);
    n.label_asym_id.has(S) || n.label_asym_id.set(S, h), Ise(n.entity_index_label_asym_id, h, S, v);
    var b = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
    n.chain_index_label_seq_id.set(v, b), n.chain_index_auth_seq_id.set(v, g);
    for (var _ = j1.Segmentation.transientSegments(t.residueAtomSegments, d, p); _.hasNext; ) {
      var A = _.move(), M = A.index, P = o.value(M), T = c.value(M);
      b.set($1(i.value(M), T), M), g.set($1(P, T), M), C.set(P, v);
    }
  }
  return new Vse(n);
}
ZC.getAtomicIndex = Fse;
var v7;
function Lse() {
  if (v7) return yh;
  v7 = 1, Object.defineProperty(yh, "__esModule", { value: !0 }), yh.getAtomicHierarchyAndConformation = void 0;
  var e = Te, r = mr(), t = Qe(), n = uC, a = nr(), i = Re, o = xG(), c = _s, s = QC, u = ZC, l = Gr, f = We(), d = Jo();
  function m(b) {
    if (b._rowCount === 0)
      return { residues: [], chains: [] };
    for (var g = 0, _ = b._rowCount, A = [g], M = [g], P = b.label_entity_id, T = b.label_asym_id, x = b.label_seq_id, w = b.auth_seq_id, E = b.pdbx_PDB_ins_code, I = g + 1; I < _; I++) {
      var B = !P.areValuesEqual(I - 1, I) || !T.areValuesEqual(I - 1, I), D = B || !x.areValuesEqual(I - 1, I) || !w.areValuesEqual(I - 1, I) || !E.areValuesEqual(I - 1, I);
      D && (A[A.length] = I), B && (M[M.length] = I);
    }
    return { residues: A, chains: M };
  }
  function p(b, g, _) {
    var A = r.Table.ofColumns(c.AtomsSchema, {
      type_symbol: r.Column.ofArray({
        array: r.Column.mapToArray(b.type_symbol, l.ElementSymbol),
        schema: r.Column.Schema.Aliased(r.Column.Schema.str)
      }),
      label_atom_id: b.label_atom_id,
      auth_atom_id: b.auth_atom_id,
      label_alt_id: b.label_alt_id,
      label_comp_id: b.label_comp_id,
      auth_comp_id: b.auth_comp_id,
      pdbx_formal_charge: b.pdbx_formal_charge,
      cdr: b.cdr,
      B_iso_or_equiv: b.B_iso_or_equiv,
      em_confidence: b.em_confidence
    }), M = r.Table.view(b, c.ResiduesSchema, _.residues), P = r.Table.view(b, c.ChainsSchema, _.chains);
    if (!M.label_seq_id.isDefined) {
      for (var T = new Int32Array(M.label_seq_id.rowCount), x = _.residues, w = _.chains, E = 0, I = 0, B = 0, D = T.length; B < D; ++B)
        x[B] >= w[E + 1] && (E += 1, I = 0), T[B] = ++I;
      M.label_seq_id = r.Column.ofIntArray(T);
    }
    return r.Table.columnToArray(M, "label_seq_id", Int32Array), r.Table.columnToArray(M, "auth_seq_id", Int32Array), { atoms: A, residues: M, chains: P, atomSourceIndex: g };
  }
  function v(b) {
    return {
      id: f.UUID.create22(),
      atomId: b.id,
      occupancy: b.occupancy.isDefined ? b.occupancy : r.Column.ofConst(1, b._rowCount, r.Column.Schema.float),
      B_iso_or_equiv: b.B_iso_or_equiv,
      xyzDefined: b.Cartn_x.isDefined && b.Cartn_y.isDefined && b.Cartn_z.isDefined,
      x: b.Cartn_x.toArray({ array: Float32Array }),
      y: b.Cartn_y.toArray({ array: Float32Array }),
      z: b.Cartn_z.toArray({ array: Float32Array })
    };
  }
  function h(b, g) {
    return r.Table.areEqual(b.chains, g.chains) && r.Table.areEqual(b.residues, g.residues) && r.Table.areEqual(b.atoms, g.atoms);
  }
  function y(b, g) {
    var _ = /* @__PURE__ */ new Map();
    if (!d.MmcifFormat.is(g))
      return _;
    var A = (0, n.toDatabase)(o.AtomSiteOperatorMappingSchema, g.data.frame).molstar_atom_site_operator_mapping;
    if (A._rowCount === 0)
      return _;
    for (var M = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Map(), T = 0; T < A._rowCount; T++) {
      var x = A.assembly_operator_id.valueKind(T) === 0 ? {
        id: A.assembly_id.value(T),
        operList: [],
        operId: A.assembly_operator_id.value(T)
      } : void 0, w = a.SymmetryOperator.create(A.operator_name.value(T), i.Mat4.identity(), {
        assembly: x,
        spgrOp: A.symmetry_operator_index.valueKind(T) === 0 ? A.symmetry_operator_index.value(T) : void 0,
        hkl: i.Vec3.ofArray(A.symmetry_hkl.value(T)),
        ncsId: A.ncs_id.value(T)
      }), E = A.suffix.value(T), I = A.label_asym_id.value(T);
      M.set("".concat(I).concat(E), { name: I, operator: w });
      var B = A.auth_asym_id.value(T);
      P.set("".concat(B).concat(E), B);
    }
    for (var D = b.chains, N = D.label_asym_id, O = D.auth_asym_id, V = new Array(N.rowCount), k = new Array(N.rowCount), T = 0; T < N.rowCount; T++) {
      var I = N.value(T), B = O.value(T);
      if (!M.has(I)) {
        V[T] = I, k[T] = B;
        continue;
      }
      var G = M.get(I), L = G.name, w = G.operator;
      _.set(T, w), V[T] = L, k[T] = P.get(B) || B;
    }
    return b.chains.label_asym_id = r.Column.ofArray({
      array: V,
      valueKind: b.chains.label_asym_id.valueKind,
      schema: b.chains.label_asym_id.schema
    }), b.chains.auth_asym_id = r.Column.ofArray({
      array: k,
      valueKind: b.chains.auth_asym_id.valueKind,
      schema: b.chains.auth_asym_id.schema
    }), _;
  }
  function C(b, g, _, A, M, P) {
    var T = m(b), x = p(b, g, T), w = y(x, M);
    if (P && h(P.atomicHierarchy, x))
      return {
        sameAsPrevious: !0,
        hierarchy: P.atomicHierarchy,
        chainOperatorMapping: w
      };
    var E = {
      residueAtomSegments: t.Segmentation.ofOffsets(T.residues, t.Interval.ofBounds(0, b._rowCount)),
      chainAtomSegments: t.Segmentation.ofOffsets(T.chains, t.Interval.ofBounds(0, b._rowCount))
    }, I = (0, u.getAtomicIndex)(x, _, E), B = (0, s.getAtomicDerivedData)(x, E, I, A), D = (0, e.__assign)((0, e.__assign)((0, e.__assign)({}, x), E), { index: I, derived: B });
    return { sameAsPrevious: !1, hierarchy: D, chainOperatorMapping: w };
  }
  function S(b, g, _, A, M, P) {
    var T = C(b, g, _, A, M, P), x = T.sameAsPrevious, w = T.hierarchy, E = T.chainOperatorMapping, I = v(b);
    return { sameAsPrevious: x, hierarchy: w, conformation: I, chainOperatorMapping: E };
  }
  return yh.getAtomicHierarchyAndConformation = S, yh;
}
var TG = {}, PG = {}, MG = {};
Object.defineProperty(MG, "__esModule", { value: !0 });
var wG = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.CoarseHierarchy = void 0;
  var r = mr(), t = Qe(), n = Qo, a = {
    chainKey: [],
    entityKey: [],
    findSequenceKey: function() {
      return -1;
    },
    findChainKey: function() {
      return -1;
    },
    getEntityFromChain: function() {
      return -1;
    },
    count: 0,
    entity_id: r.Column.Undefined(0, r.Column.Schema.str),
    asym_id: r.Column.Undefined(0, r.Column.Schema.str),
    seq_id_begin: r.Column.Undefined(0, r.Column.Schema.int),
    seq_id_end: r.Column.Undefined(0, r.Column.Schema.int),
    chainElementSegments: t.Segmentation.create([]),
    polymerRanges: n.SortedRanges.ofSortedRanges([]),
    gapRanges: n.SortedRanges.ofSortedRanges([])
  };
  (function(i) {
    i.Empty = {
      isDefined: !1,
      spheres: a,
      gaussians: a
    };
  })(e.CoarseHierarchy || (e.CoarseHierarchy = {}));
})(wG);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 });
  var r = Te;
  (0, r.__exportStar)(MG, e), (0, r.__exportStar)(wG, e);
})(PG);
var JC = {};
Object.defineProperty(JC, "__esModule", { value: !0 });
JC.getCoarseKeys = void 0;
var EG = Qo, kse = Qe();
function Use(e, r, t) {
  if (e.has(r))
    return e.get(r);
  var n = t.index++;
  return e.set(r, n), n;
}
function zse(e, r) {
  if (e.has(r))
    return e.get(r);
  var t = /* @__PURE__ */ new Map();
  return e.set(r, t), t;
}
function Gse(e, r, t) {
  var n = e.getEntityIndex, a = function(o, c) {
    var s = n(o);
    if (s < 0)
      return -1;
    var u = r.get(s);
    return u.has(c) ? u.get(c) : -1;
  }, i = function(o, c, s) {
    var u = n(o);
    if (u < 0)
      return -1;
    var l = r.get(u);
    if (l === void 0)
      return -1;
    var f = l.get(c);
    if (f === void 0)
      return -1;
    var d = t.get(f), m = d.elementIndices, p = d.seqRanges, v = EG.SortedRanges.firstIntersectionIndex(p, kse.OrderedSet.ofSingleton(s));
    return v !== -1 ? m[v] : -1;
  };
  return { findChainKey: a, findSequenceKey: i };
}
function qse(e) {
  throw new Error("Missing entity entry for entity id '".concat(e, "'."));
}
function Hse(e, r) {
  for (var t = e.entity_id, n = e.asym_id, a = e.seq_id_begin, i = e.seq_id_end, o = e.count, c = e.chainElementSegments, s = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), l = { index: 0 }, f = new Int32Array(o), d = new Int32Array(o), m = new Int32Array(c.count), p = 0; p < o; p++)
    d[p] = r.getEntityIndex(t.value(p)), d[p] < 0 && qse(t.value(p));
  for (var v = 0; v < c.count; v++) {
    var h = c.offsets[v], y = c.offsets[v + 1], C = d[h];
    m[v] = C;
    for (var S = zse(u, C), b = Use(S, n.value(h), l), p = h; p < y; p++)
      f[p] = b;
    for (var g = [], _ = [], p = h; p < y; p++) {
      var A = a.value(p), M = i.value(p);
      g.push(p), _.push(A, M);
    }
    var P = {
      elementIndices: g,
      seqRanges: EG.SortedRanges.ofSortedRanges(_)
    };
    s.set(b, P);
  }
  var T = Gse(r, u, s), x = T.findChainKey, w = T.findSequenceKey, E = function(I) {
    return m[I];
  };
  return {
    chainKey: f,
    entityKey: d,
    findSequenceKey: w,
    findChainKey: x,
    getEntityFromChain: E
  };
}
JC.getCoarseKeys = Hse;
var e4 = {};
Object.defineProperty(e4, "__esModule", { value: !0 });
e4.getCoarseRanges = void 0;
var p7 = Qe(), h7 = Qo;
function jse(e, r) {
  for (var t = [], n = [], a = p7.Segmentation.transientSegments(e.chainElementSegments, p7.Interval.ofBounds(0, e.count)), i = e.seq_id_begin, o = e.seq_id_end; a.hasNext; )
    for (var c = a.move(), s = c.start, u = c.end, l = -1, f = -1, d = s; d < u; ++d) {
      var m = o.value(d);
      d === s ? (l = d, f = o.value(d)) : i.value(d) - f > 1 && (t.push(l, d - 1), n.push(d - 1, d), l = d), d === u - 1 && t.push(l, d), f = m;
    }
  return {
    polymerRanges: h7.SortedRanges.ofSortedRanges(t),
    gapRanges: h7.SortedRanges.ofSortedRanges(n)
  };
}
e4.getCoarseRanges = jse;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.getCoarse = e.EmptyCoarse = void 0;
  var r = Te, t = PG, n = JC, a = We(), i = Qe(), o = Re, c = e4, s = Zo;
  e.EmptyCoarse = {
    hierarchy: t.CoarseHierarchy.Empty,
    conformation: void 0
  };
  function u(p, v) {
    var h = p.ihm_sphere_obj_site, y = p.ihm_gaussian_obj_site;
    if (h._rowCount === 0 && y._rowCount === 0)
      return e.EmptyCoarse;
    var C = m(h), S = l(h), b = (0, n.getCoarseKeys)(C, p.entities), g = (0, c.getCoarseRanges)(C, v), _ = m(y), A = f(y), M = (0, n.getCoarseKeys)(_, p.entities), P = (0, c.getCoarseRanges)(_, v);
    return {
      hierarchy: {
        isDefined: !0,
        spheres: (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, C), b), g),
        gaussians: (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, _), M), P)
      },
      conformation: {
        id: a.UUID.create22(),
        spheres: S,
        gaussians: A
      }
    };
  }
  e.getCoarse = u;
  function l(p) {
    return {
      x: p.Cartn_x.toArray({ array: Float32Array }),
      y: p.Cartn_y.toArray({ array: Float32Array }),
      z: p.Cartn_z.toArray({ array: Float32Array }),
      radius: p.object_radius.toArray({ array: Float32Array }),
      rmsf: p.rmsf.toArray({ array: Float32Array })
    };
  }
  function f(p) {
    for (var v = s.BasicSchema.ihm_gaussian_obj_site.covariance_matrix.space, h = [], y = p.covariance_matrix, C = 0, S = y.rowCount; C < S; C++)
      h[C] = o.Tensor.toMat3((0, o.Mat3)(), v, y.value(C));
    return {
      x: p.mean_Cartn_x.toArray({ array: Float32Array }),
      y: p.mean_Cartn_y.toArray({ array: Float32Array }),
      z: p.mean_Cartn_z.toArray({ array: Float32Array }),
      weight: p.weight.toArray({ array: Float32Array }),
      covariance_matrix: h
    };
  }
  function d(p, v, h) {
    for (var y = [0], C = 1, S = p.rowCount; C < S; C++) {
      var b = !p.areValuesEqual(C - 1, C);
      b && (y[y.length] = C);
    }
    return {
      chainElementSegments: i.Segmentation.ofOffsets(y, i.Interval.ofBounds(0, p.rowCount))
    };
  }
  function m(p) {
    var v = p.entity_id, h = p.seq_id_begin, y = p.seq_id_end, C = p.asym_id;
    return (0, r.__assign)({ count: v.rowCount, entity_id: v, asym_id: C, seq_id_begin: h, seq_id_end: y }, d(C));
  }
})(TG);
var r4 = {}, vy = {}, IE = {}, t4 = {}, _d = {};
Object.defineProperty(_d, "__esModule", { value: !0 });
_d.getDnaOneLetterCode = _d.getRnaOneLetterCode = _d.getProteinOneLetterCode = void 0;
var $se = {
  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",
  // charmm ff
  HSD: "H",
  HSE: "H",
  HSP: "H",
  LSN: "K",
  ASPP: "D",
  GLUP: "E",
  // amber ff
  HID: "H",
  HIE: "H",
  HIP: "H",
  LYN: "K",
  ASH: "D",
  GLH: "E",
  ACE: "ACE",
  NME: "NME"
}, Kse = {
  DA: "A",
  DC: "C",
  DG: "G",
  DT: "T",
  DU: "U"
}, Wse = {
  A: "A",
  C: "C",
  G: "G",
  T: "T",
  U: "U"
};
function Xse(e) {
  var r = $se[e];
  return r || "X";
}
_d.getProteinOneLetterCode = Xse;
function Yse(e) {
  var r = Wse[e];
  return r || "X";
}
_d.getRnaOneLetterCode = Yse;
function Qse(e) {
  var r = Kse[e];
  return r || "X";
}
_d.getDnaOneLetterCode = Qse;
Object.defineProperty(t4, "__esModule", { value: !0 });
t4.Sequence = void 0;
var mm = _d, lu = mr(), Zse = Ft, NM;
(function(e) {
  function r(s) {
    var u = s.code.toArray();
    return (u instanceof Array ? u : Array.from(u)).join("");
  }
  e.getSequenceString = r;
  function t(s) {
    for (var u = 0, l = Math.min(s.rowCount, 10); u < l; u++) {
      var f = s.value(u) || "";
      if ((0, mm.getProteinOneLetterCode)(f) !== "X")
        return "protein";
      if ((0, mm.getRnaOneLetterCode)(f) !== "X")
        return "RNA";
      if ((0, mm.getDnaOneLetterCode)(f) !== "X")
        return "DNA";
    }
    return "generic";
  }
  function n(s, u) {
    var l;
    switch (s) {
      case "protein":
        l = mm.getProteinOneLetterCode;
        break;
      case "DNA":
        l = mm.getDnaOneLetterCode;
        break;
      case "RNA":
        l = mm.getRnaOneLetterCode;
        break;
      case "generic":
        l = function() {
          return "X";
        };
        break;
      default:
        (0, Zse.assertUnreachable)(s);
    }
    return l;
  }
  function a(s, u) {
    if (u.rowCount === 0)
      throw new Error("cannot be empty");
    var l = t(s);
    return new i(l, s, u);
  }
  e.ofResidueNames = a;
  var i = (
    /** @class */
    function() {
      function s(u, l, f) {
        this.kind = u, this.microHet = /* @__PURE__ */ new Map();
        for (var d = n(u), m = [], p = [], v = [], h = /* @__PURE__ */ new Map(), y = 0, C = /* @__PURE__ */ new Map(), S = 0, b = f.rowCount; S < b; ++S) {
          var g = f.value(S);
          if (C.has(g))
            h.has(g) ? h.get(g).push(l.value(S)) : h.set(g, [
              p[C.get(g)],
              l.value(S)
            ]);
          else {
            C.set(g, y);
            var _ = l.value(S);
            p[y] = _, v[y] = g, m[y] = d(_), y += 1;
          }
        }
        for (var A = [], S = 0, b = y; S < b; ++S) {
          var M = h.get(v[S]);
          if (M) {
            var P = M.map(function(w) {
              var E = d(w);
              return E === "X" ? w : E;
            });
            A[S] = "(".concat(P.join("|"), ")");
          } else
            A[S] = m[S] === "X" ? p[S] : m[S];
        }
        this.length = y, this.code = lu.Column.ofStringArray(m), this.compId = lu.Column.ofStringArray(p), this.seqId = lu.Column.ofIntArray(v), this.label = lu.Column.ofStringArray(A), this.microHet = h, this.indexMap = C;
      }
      return s.prototype.index = function(u) {
        return this.indexMap.get(u);
      }, s;
    }()
  );
  function o(s, u) {
    var l = "generic";
    return new c(l, s, u);
  }
  e.ofSequenceRanges = o;
  var c = (
    /** @class */
    function() {
      function s(u, l, f) {
        this.kind = u, this.seqIdStart = l, this.seqIdEnd = f, this.microHet = /* @__PURE__ */ new Map();
        for (var d = 0, m = Number.MAX_SAFE_INTEGER, p = 0, v = this.seqIdStart.rowCount; p < v; p++) {
          var h = this.seqIdStart.value(p), y = this.seqIdEnd.value(p);
          h < m && (m = h), d < y && (d = y);
        }
        var C = d - m + 1;
        this.code = lu.Column.ofConst("X", C, lu.Column.Schema.str), this.label = lu.Column.ofConst("", C, lu.Column.Schema.str), this.seqId = lu.Column.ofLambda({
          value: function(S) {
            return S + m + 1;
          },
          rowCount: C,
          schema: lu.Column.Schema.int
        }), this.compId = lu.Column.ofConst("", C, lu.Column.Schema.str), this.length = C, this.minSeqId = m;
      }
      return s.prototype.index = function(u) {
        return u - this.minSeqId;
      }, s;
    }()
  );
})(NM || (NM = {}));
t4.Sequence = NM;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 });
  var r = Te;
  (0, r.__exportStar)(t4, e);
})(IE);
Object.defineProperty(vy, "__esModule", { value: !0 });
vy.StructureSequence = void 0;
var h2 = mr(), g7 = IE, VM;
(function(e) {
  var r = { byEntityKey: {}, sequences: [] };
  function t() {
    for (var c = [], s = 0; s < arguments.length; s++)
      c[s] = arguments[s];
    for (var u = [], l = {}, f = 0, d = c.length; f < d; ++f)
      u.push.apply(u, c[f].sequences), Object.assign(l, c[f].byEntityKey);
    return { sequences: u, byEntityKey: l };
  }
  function n(c, s, u) {
    var l = a(c, s), f = u.isDefined ? i(c, u) : r;
    return t(l, f);
  }
  e.fromHierarchy = n;
  function a(c, s) {
    var u = s.atoms.label_comp_id, l = s.residues.label_seq_id, f = s.chainAtomSegments, d = s.residueAtomSegments, m = f.count, p = f.offsets, v = {}, h = [];
    if (m === 1 && p[0] === 0 && p[1] === 0)
      return { byEntityKey: v, sequences: h };
    for (var y = 0, C = s.chains._rowCount; y < C; y++) {
      var S = s.index.getEntityFromChain(y);
      if (!(v[S] !== void 0 || c.data.type.value(S) !== "polymer")) {
        var b = y;
        for (y++; y < C && S === s.index.getEntityFromChain(y) && c.data.type.value(S) !== "polymer"; )
          y++;
        y--;
        for (var g = d.index[p[b]], _ = d.index[p[y + 1] - 1] + 1, A = h2.Column.window(l, g, _), M = [], P = g; P < _; ++P)
          M.push(u.value(d.offsets[P]));
        var T = h2.Column.ofStringArray(M);
        v[S] = {
          entityId: c.data.id.value(S),
          sequence: g7.Sequence.ofResidueNames(T, A)
        }, h.push(v[S]);
      }
    }
    return { byEntityKey: v, sequences: h };
  }
  e.fromAtomicHierarchy = a;
  function i(c, s) {
    var u = o(c, s.spheres), l = o(c, s.gaussians);
    return t(u, l);
  }
  e.fromCoarseHierarchy = i;
  function o(c, s) {
    var u = s.chainElementSegments, l = s.seq_id_begin, f = s.seq_id_end, d = u.count, m = u.offsets, p = {}, v = [];
    if (d === 1 && m[0] === 0 && m[1] === 0)
      return { byEntityKey: p, sequences: v };
    for (var h = 0, y = d; h < y; h++) {
      var C = s.getEntityFromChain(h);
      if (p[C] === void 0) {
        var S = h;
        for (h++; h < y && C === s.getEntityFromChain(h); )
          h++;
        h--;
        var b = m[S], g = m[h + 1] - 1, _ = h2.Column.window(l, b, g), A = h2.Column.window(f, b, g);
        p[C] = {
          entityId: c.data.id.value(C),
          sequence: g7.Sequence.ofSequenceRanges(_, A)
        }, v.push(p[C]);
      }
    }
    return { byEntityKey: p, sequences: v };
  }
  e.fromCoarseElements = o;
})(VM || (VM = {}));
vy.StructureSequence = VM;
Object.defineProperty(r4, "__esModule", { value: !0 });
r4.getSequence = void 0;
var Jse = vy, y7 = mr(), ele = IE;
function rle(e, r, t, n) {
  if (!e.entity_poly_seq || !e.entity_poly_seq._rowCount)
    return Jse.StructureSequence.fromHierarchy(r, t, n);
  for (var a = e.entity_poly_seq, i = a.entity_id, o = a.num, c = a.mon_id, s = {}, u = [], l = i.rowCount, f = 0; f < l; ) {
    for (var d = f; f < l - 1 && i.areValuesEqual(f, f + 1); )
      f++;
    f++;
    var m = i.value(d), p = y7.Column.window(c, d, f), v = y7.Column.window(o, d, f), h = r.getEntityIndex(m);
    s[h] = {
      entityId: m,
      sequence: ele.Sequence.ofResidueNames(p, v)
    }, u.push(s[h]);
  }
  return { byEntityKey: s, sequences: u };
}
r4.getSequence = rle;
var n4 = {};
Object.defineProperty(n4, "__esModule", { value: !0 });
n4.sortAtomSite = void 0;
var _7 = Te, g2 = wr(), b5 = mr(), tle = hr;
function nle(e, r, t, n) {
  return (0, _7.__awaiter)(this, void 0, void 0, function() {
    var a, i, o, c, s, u, l, f, d, m, p;
    return (0, _7.__generator)(this, function(v) {
      switch (v.label) {
        case 0:
          return a = (0, g2.createRangeArray)(t, n - 1), i = r.label_entity_id, o = r.label_asym_id, c = r.label_seq_id, s = (0, g2.makeBuckets)(a, i.value), e.shouldUpdate ? [4, e.update()] : [3, 2];
        case 1:
          v.sent(), v.label = 2;
        case 2:
          u = 0, l = s.length - 1, v.label = 3;
        case 3:
          if (!(u < l)) return [3, 10];
          f = (0, g2.makeBuckets)(a, o.value, {
            start: s[u],
            end: s[u + 1]
          }), d = 0, m = f.length - 1, v.label = 4;
        case 4:
          return d < m ? (p = f[d], c.valueKind(p) !== 0 ? [3, 6] : ((0, g2.makeBuckets)(a, c.value, {
            sort: !0,
            start: p,
            end: f[d + 1]
          }), e.shouldUpdate ? [4, e.update()] : [3, 6])) : [3, 7];
        case 5:
          v.sent(), v.label = 6;
        case 6:
          return d++, [3, 4];
        case 7:
          return e.shouldUpdate ? [4, e.update()] : [3, 9];
        case 8:
          v.sent(), v.label = 9;
        case 9:
          return u++, [3, 3];
        case 10:
          return (0, tle.arrayIsIdentity)(a) && a.length === r._rowCount ? [2, { atom_site: r, sourceIndex: b5.Column.ofIntArray(a) }] : [2, {
            atom_site: b5.Table.view(r, r._schema, a),
            sourceIndex: b5.Column.ofIntArray(a)
          }];
      }
    });
  });
}
n4.sortAtomSite = nle;
var a4 = {};
Object.defineProperty(a4, "__esModule", { value: !0 });
a4.getAtomicRanges = void 0;
var y2 = Qe(), b7 = Qo, ale = Gr, _2 = Za, S5 = Re;
function S7(e, r, t, n, a) {
  var i = a.residue, o = i.polymerType, c = i.traceElementIndex, s = i.directionFromElementIndex, u = i.directionToElementIndex, l = o[e], f = o[r];
  if (l === 0 || f === 0 || c[e] === -1 || c[r] === -1)
    return !1;
  var d = n.findAtomsOnResidue(e, (0, _2.getAtomIdForAtomRole)(l, "backboneStart")), m = n.findAtomsOnResidue(r, (0, _2.getAtomIdForAtomRole)(f, "backboneEnd"));
  (d === -1 || m === -1) && (d = n.findAtomsOnResidue(e, (0, _2.getAtomIdForAtomRole)(l, "coarseBackbone")), m = n.findAtomsOnResidue(r, (0, _2.getAtomIdForAtomRole)(f, "coarseBackbone")));
  var p = t.x, v = t.y, h = t.z, y = S5.Vec3.create(p[d], v[d], h[d]), C = S5.Vec3.create(p[m], v[m], h[m]), S = s[e] === -1 || u[e] === -1 || s[r] === -1 || u[r] === -1;
  return S5.Vec3.distance(y, C) < (S ? 10 : 3);
}
function ile(e, r, t, n) {
  for (var a = [], i = [], o = /* @__PURE__ */ new Map(), c = y2.Segmentation.transientSegments(e.chainAtomSegments, y2.Interval.ofBounds(0, e.atoms._rowCount)), s = y2.Segmentation.transientSegments(e.residueAtomSegments, y2.Interval.ofBounds(0, e.atoms._rowCount)), u = e.index, l = e.derived, f = e.residues.label_seq_id, d = e.chains.label_entity_id, m = l.residue, p = m.moleculeType, v = m.traceElementIndex, h, y, C, S; c.hasNext; ) {
    var b = c.move();
    s.setSegment(b), h = -1, y = -1, C = -1, S = -1;
    var g = r.getEntityIndex(d.value(b.index)), _ = n.byEntityKey[g], A = _ ? _.sequence.seqId.value(_.sequence.seqId.rowCount - 1) : -1, M = e.residueAtomSegments.index[b.start], P = e.residueAtomSegments.index[b.end - 1], T = f.value(M), x = f.value(P);
    for (T === 1 && x === A && t.xyzDefined && S7(M, P, t, u, l) && (o.set(M, P), o.set(P, M)); s.hasNext; ) {
      var w = s.move(), E = w.index, I = f.value(E);
      if ((0, ale.isPolymer)(p[E]) && v[E] !== -1)
        if (S !== -1)
          if (I !== h + 1)
            a.push(S, C - 1), i.push(y, w.end - 1), S = w.start;
          else if (!s.hasNext)
            a.push(S, w.end - 1);
          else {
            var B = e.residueAtomSegments.index[w.start], D = e.residueAtomSegments.index[C - 1];
            t.xyzDefined && !S7(B, D, t, e.index, l) && (a.push(S, C - 1), i.push(y, w.end - 1), S = w.start);
          }
        else
          S = w.start;
      else
        S !== -1 && (a.push(S, C - 1), S = -1);
      y = w.start, C = w.end, h = I;
    }
  }
  return {
    polymerRanges: b7.SortedRanges.ofSortedRanges(a),
    gapRanges: b7.SortedRanges.ofSortedRanges(i),
    cyclicPolymerMap: o
  };
}
a4.getAtomicRanges = ile;
var Ks = {}, d0 = {};
Object.defineProperty(d0, "__esModule", { value: !0 });
d0.memoize1 = d0.memoizeLatest = void 0;
function ole(e) {
  var r = void 0, t = void 0;
  return function() {
    for (var n = [], a = 0; a < arguments.length; a++)
      n[a] = arguments[a];
    if (!r || r.length !== n.length)
      return r = n, t = e.apply(void 0, n), t;
    for (var i = 0, o = n.length; i < o; i++)
      if (n[i] !== r[i])
        return r = n, t = e.apply(void 0, n), t;
    return t;
  };
}
d0.memoizeLatest = ole;
function ule(e) {
  var r = /* @__PURE__ */ new Map();
  return function(t) {
    if (r.has(t))
      return r.get(t);
    var n = e(t);
    return r.set(t, n), n;
  };
}
d0.memoize1 = ule;
Object.defineProperty(Ks, "__esModule", { value: !0 });
Ks.getStructAsymMap = Ks.getSaccharideComponentMap = Ks.getChemicalComponentMap = Ks.getMissingResidues = void 0;
var sle = mr(), DG = Gr, Hh = ly, lle = d0;
function cle(e) {
  for (var r = /* @__PURE__ */ new Map(), t = function(c, s, u) {
    return "".concat(c, "|").concat(s, "|").concat(u);
  }, n = e.pdbx_unobs_or_zero_occ_residues, a = 0, i = n._rowCount; a < i; ++a) {
    var o = t(n.PDB_model_num.value(a), n.label_asym_id.value(a), n.label_seq_id.value(a));
    r.set(o, { polymer_flag: n.polymer_flag.value(a), occupancy_flag: n.occupancy_flag.value(a) });
  }
  return {
    has: function(c, s, u) {
      return r.has(t(c, s, u));
    },
    get: function(c, s, u) {
      return r.get(t(c, s, u));
    },
    size: r.size
  };
}
Ks.getMissingResidues = cle;
function dle(e) {
  var r = /* @__PURE__ */ new Map();
  if (e.chem_comp._rowCount > 0)
    for (var t = e.chem_comp.id, n = 0, a = t.rowCount; n < a; ++n)
      r.set(t.value(n), sle.Table.getRow(e.chem_comp, n));
  else {
    var i = IG(e);
    i.forEach(function(o) {
      r.set(o, (0, DG.getDefaultChemicalComponent)(o));
    });
  }
  return r;
}
Ks.getChemicalComponentMap = dle;
function fle(e) {
  var r = /* @__PURE__ */ new Map();
  if (e.pdbx_chem_comp_identifier._rowCount > 0) {
    for (var t = e.pdbx_chem_comp_identifier, n = t.comp_id, a = t.type, i = t.identifier, o = 0, c = n.rowCount; o < c; ++o)
      if (a.value(o) === "SNFG CARBOHYDRATE SYMBOL" || a.value(o) === "SNFG CARB SYMBOL") {
        var s = i.value(o), u = Hh.SaccharidesSnfgMap.get(s);
        u ? r.set(n.value(o), u) : console.warn("Unknown SNFG name '".concat(s, "'"));
      }
  }
  if (e.chem_comp._rowCount > 0)
    for (var l = e.chem_comp, f = l.id, a = l.type, o = 0, c = f.rowCount; o < c; ++o) {
      var d = f.value(o);
      if (!r.has(d)) {
        var m = a.value(o);
        Hh.SaccharideCompIdMap.has(d) ? r.set(d, Hh.SaccharideCompIdMap.get(d)) : (0, DG.getMoleculeType)(m, d) === 9 && r.set(d, Hh.UnknownSaccharideComponent);
      }
    }
  else {
    var p = IG(e);
    Hh.SaccharideCompIdMap.forEach(function(v, h) {
      !r.has(h) && p.has(h) && r.set(h, v);
    });
  }
  return r;
}
Ks.getSaccharideComponentMap = fle;
var IG = (0, lle.memoize1)(function(e) {
  for (var r = /* @__PURE__ */ new Set(), t = e.atom_site, n = t.label_comp_id, a = t.auth_comp_id, i = n.isDefined ? n : a, o = 0, c = i.rowCount; o < c; ++o)
    r.add(i.value(o));
  return r;
});
function mle(e, r) {
  for (var t = /* @__PURE__ */ new Map(), n = e.chains, a = n.auth_asym_id, i = n.label_asym_id, o = n.label_entity_id, c = 0, s = e.chains._rowCount; c < s; c++) {
    var u = i.value(c);
    t.set(u, { id: u, auth_id: a.value(c), entity_id: o.value(c) });
  }
  if (r != null && r.struct_asym._rowCount)
    for (var l = r.struct_asym, u = l.id, f = l.entity_id, c = 0, d = u.rowCount; c < d; ++c) {
      var m = u.value(c);
      t.has(m) || t.set(m, {
        id: m,
        auth_id: "",
        entity_id: f.value(c)
      });
    }
  return t;
}
Ks.getStructAsymMap = mle;
var Vv = {}, i4 = {};
Object.defineProperty(i4, "__esModule", { value: !0 });
i4.EntitySubtype = void 0;
var C7 = mr();
i4.EntitySubtype = C7.Column.Schema.Aliased(C7.Column.Schema.Str(""));
Object.defineProperty(Vv, "__esModule", { value: !0 });
Vv.getEntitiesWithPRD = Vv.getEntityData = void 0;
var A7 = Te, Hf = mr(), vle = i4, x7 = Gr, C5 = Zo;
function ple(e) {
  var r;
  if (e.entity.id.isDefined)
    r = e.entity;
  else {
    for (var t = /* @__PURE__ */ new Set(), n = [], a = [], i = e.atom_site, o = i.label_entity_id, c = i.label_comp_id, s = 0, u = e.atom_site._rowCount; s < u; s++) {
      var l = o.value(s);
      t.has(l) || (n.push(l), a.push((0, x7.getEntityType)(c.value(s))), t.add(l));
    }
    for (var f = e.ihm_sphere_obj_site.entity_id, s = 0, u = e.ihm_sphere_obj_site._rowCount; s < u; s++) {
      var l = f.value(s);
      t.has(l) || (n.push(l), a.push("polymer"), t.add(l));
    }
    for (var d = e.ihm_gaussian_obj_site.entity_id, s = 0, u = e.ihm_gaussian_obj_site._rowCount; s < u; s++) {
      var l = d.value(s);
      t.has(l) || (n.push(l), a.push("polymer"), t.add(l));
    }
    r = Hf.Table.ofPartialColumns(C5.BasicSchema.entity, {
      id: Hf.Column.ofArray({ array: n, schema: C5.BasicSchema.entity.id }),
      type: Hf.Column.ofArray({ array: a, schema: C5.BasicSchema.entity.type })
    }, n.length);
  }
  var m = Hf.Column.createIndexer(r.id), p = new Array(r._rowCount);
  p.fill("other");
  var v = /* @__PURE__ */ new Set(), h = !1;
  if (e.entity_poly && e.entity_poly.type.isDefined)
    for (var y = e.entity_poly, C = y.entity_id, S = y.type, b = y._rowCount, s = 0; s < b; ++s) {
      var l = C.value(s);
      p[m(l)] = S.value(s), v.add(l);
    }
  else
    h = !0;
  if (e.pdbx_entity_branch && e.pdbx_entity_branch.entity_id.isDefined)
    for (var g = e.pdbx_entity_branch, C = g.entity_id, S = g.type, b = g._rowCount, s = 0; s < b; ++s) {
      var l = C.value(s);
      p[m(l)] = S.value(s), v.add(l);
    }
  else
    h = !0;
  if (v.size < p.length && (h = !0), h) {
    var _ = /* @__PURE__ */ new Map();
    if (e.chem_comp)
      for (var A = e.chem_comp, M = A.id, S = A.type, s = 0, u = e.chem_comp._rowCount; s < u; s++)
        _.set(M.value(s), S.value(s));
    if (e.atom_site)
      for (var P = e.atom_site, o = P.label_entity_id, c = P.label_comp_id, s = 0, u = e.atom_site._rowCount; s < u; s++) {
        var l = o.value(s);
        if (!v.has(l)) {
          var T = c.value(s), x = _.get(T) || "";
          p[m(l)] = (0, x7.getEntitySubtype)(T, x), v.add(l);
        }
      }
  }
  var w = Hf.Column.ofArray({
    array: p,
    schema: vle.EntitySubtype
  });
  return {
    data: r,
    subtype: w,
    getEntityIndex: m
  };
}
Vv.getEntityData = ple;
function hle(e, r, t) {
  var n;
  if (!e.pdbx_molecule || !e.pdbx_molecule.prd_id.isDefined)
    return r;
  var a = new Array(r.data._rowCount);
  a.fill("");
  for (var i = e.pdbx_molecule, o = i.asym_id, c = i.prd_id, s = i._rowCount, u = 0; u < s; ++u) {
    var l = o.value(u), f = (n = t.get(l)) === null || n === void 0 ? void 0 : n.entity_id;
    f !== void 0 && (a[r.getEntityIndex(f)] = c.value(u));
  }
  var d = Hf.Column.ofArray({
    array: a,
    schema: Hf.Column.Schema.str
  });
  return (0, A7.__assign)((0, A7.__assign)({}, r), { prd_id: d });
}
Vv.getEntitiesWithPRD = hle;
var R0 = {};
Object.defineProperty(R0, "__esModule", { value: !0 });
R0.ArrayTrajectory = void 0;
var gle = (
  /** @class */
  function() {
    function e(r) {
      this.frames = r, this.frameCount = r.length, this.representative = r[0], this.duration = r.length;
    }
    return e.prototype.getFrameAtIndex = function(r) {
      return this.frames[r];
    }, e;
  }()
);
R0.ArrayTrajectory = gle;
var T7;
function xc() {
  if (T7) return gh;
  T7 = 1, Object.defineProperty(gh, "__esModule", { value: !0 }), gh.createModels = void 0;
  var e = Te, r = mr(), t = We(), n = o4(), a = In, i = Lse(), o = TG, c = r4, s = n4, u = a4, l = Ks, f = Vv, d = c0, m = R0;
  function p(_, A, M) {
    return (0, e.__awaiter)(this, void 0, void 0, function() {
      var P, T, x, w;
      return (0, e.__generator)(this, function(E) {
        switch (E.label) {
          case 0:
            return P = v(_), _.ihm_model_list._rowCount > 0 ? [4, g(M, _, P, A)] : [3, 2];
          case 1:
            return x = E.sent(), [3, 4];
          case 2:
            return [4, S(M, _, P, A)];
          case 3:
            x = E.sent(), E.label = 4;
          case 4:
            for (T = x, w = 0; w < T.length; w++)
              n.Model.TrajectoryInfo.set(T[w], { index: w, size: T.length });
            return [2, new m.ArrayTrajectory(T)];
        }
      });
    });
  }
  gh.createModels = p;
  function v(_, A) {
    return {
      missingResidues: (0, l.getMissingResidues)(_),
      chemicalComponentMap: (0, l.getChemicalComponentMap)(_),
      saccharideComponentMap: (0, l.getSaccharideComponentMap)(_)
    };
  }
  function h(_, A, M, P, T, x, w) {
    var E = (0, i.getAtomicHierarchyAndConformation)(A, M, P, T.chemicalComponentMap, x, w), I = A.pdbx_PDB_model_num.value(0);
    if (w && E.sameAsPrevious)
      return (0, e.__assign)((0, e.__assign)({}, w), { id: t.UUID.create22(), modelNum: I, atomicConformation: E.conformation, _dynamicPropertyData: /* @__PURE__ */ Object.create(null) });
    var B = o.EmptyCoarse, D = (0, c.getSequence)(_, P, E.hierarchy, B.hierarchy), N = (0, u.getAtomicRanges)(E.hierarchy, P, E.conformation, D), O = (0, l.getStructAsymMap)(E.hierarchy), V = _.entry.id.valueKind(0) === 0 ? _.entry.id.value(0) : x.name, k = [];
    return V && k.push(V), _.struct.title.valueKind(0) === 0 && k.push(_.struct.title.value(0)), {
      id: t.UUID.create22(),
      entryId: V,
      label: k.join(" | "),
      entry: V,
      sourceData: x,
      modelNum: I,
      parent: void 0,
      entities: (0, f.getEntitiesWithPRD)(_, P, O),
      sequence: D,
      atomicHierarchy: E.hierarchy,
      atomicConformation: E.conformation,
      atomicRanges: N,
      atomicChainOperatorMappinng: E.chainOperatorMapping,
      coarseHierarchy: B.hierarchy,
      coarseConformation: B.conformation,
      properties: (0, e.__assign)((0, e.__assign)({}, T), { structAsymMap: O }),
      customProperties: new a.CustomProperties(),
      _staticPropertyData: /* @__PURE__ */ Object.create(null),
      _dynamicPropertyData: /* @__PURE__ */ Object.create(null)
    };
  }
  function y(_, A, M, P) {
    var T = (0, i.getAtomicHierarchyAndConformation)(A.atom_site, A.atom_site_sourceIndex, A.entities, M.chemicalComponentMap, P), x = (0, o.getCoarse)(A, M.chemicalComponentMap), w = (0, c.getSequence)(_, A.entities, T.hierarchy, x.hierarchy), E = (0, u.getAtomicRanges)(T.hierarchy, A.entities, T.conformation, w), I = _.entry.id.valueKind(0) === 0 ? _.entry.id.value(0) : P.name, B = [];
    I && B.push(I), _.struct.title.valueKind(0) === 0 && B.push(_.struct.title.value(0)), A.model_name && B.push(A.model_name), A.model_group_name && B.push(A.model_group_name);
    var D = (0, l.getStructAsymMap)(T.hierarchy, _);
    return {
      id: t.UUID.create22(),
      entryId: I,
      label: B.join(" | "),
      entry: I,
      sourceData: P,
      modelNum: A.model_id,
      parent: void 0,
      entities: (0, f.getEntitiesWithPRD)(_, A.entities, D),
      sequence: w,
      atomicHierarchy: T.hierarchy,
      atomicConformation: T.conformation,
      atomicRanges: E,
      atomicChainOperatorMappinng: T.chainOperatorMapping,
      coarseHierarchy: x.hierarchy,
      coarseConformation: x.conformation,
      properties: (0, e.__assign)((0, e.__assign)({}, M), { structAsymMap: D }),
      customProperties: new a.CustomProperties(),
      _staticPropertyData: /* @__PURE__ */ Object.create(null),
      _dynamicPropertyData: /* @__PURE__ */ Object.create(null)
    };
  }
  function C(_, A) {
    var M = _.rowCount;
    if (!_.isDefined)
      return M;
    for (var P = A + 1; P < M && _.areValuesEqual(A, P); )
      P++;
    return P;
  }
  function S(_, A, M, P) {
    return (0, e.__awaiter)(this, void 0, void 0, function() {
      var T, x, w, E, I, B, D, N, O;
      return (0, e.__generator)(this, function(V) {
        switch (V.label) {
          case 0:
            if (T = [], !A.atom_site) return [3, 3];
            x = A.atom_site.id.rowCount, w = (0, f.getEntityData)(A), E = 0, V.label = 1;
          case 1:
            return E < x ? (I = C(A.atom_site.pdbx_PDB_model_num, E), [4, (0, s.sortAtomSite)(_, A.atom_site, E, I)]) : [3, 3];
          case 2:
            return B = V.sent(), D = B.atom_site, N = B.sourceIndex, O = h(A, D, N, w, M, P, T.length > 0 ? T[T.length - 1] : void 0), T.push(O), E = I, [3, 1];
          case 3:
            return [2, T];
        }
      });
    });
  }
  function b(_, A) {
    for (var M = /* @__PURE__ */ new Map(), P = _._rowCount, T = 0; T < P; ) {
      var x = C(A, T), w = A.value(T);
      M.set(w, {
        table: r.Table.window(_, _._schema, T, x),
        start: T,
        end: x
      }), T = x;
    }
    return M;
  }
  function g(_, A, M, P) {
    return (0, e.__awaiter)(this, void 0, void 0, function() {
      var T, x, w, E, I, B, D, N, O, V, k, G, L, R, F, U, H, q, K;
      return (0, e.__generator)(this, function(Y) {
        switch (Y.label) {
          case 0:
            if (T = (0, f.getEntityData)(A), x = A.atom_site.ihm_model_id.isDefined ? A.atom_site.ihm_model_id : A.atom_site.pdbx_PDB_model_num, w = b(A.atom_site, x), E = b(A.ihm_sphere_obj_site, A.ihm_sphere_obj_site.model_id), I = b(A.ihm_gaussian_obj_site, A.ihm_gaussian_obj_site.model_id), B = [], !A.ihm_model_list) return [3, 6];
            D = A.ihm_model_list, N = D.model_id, O = D.model_name, V = 0, Y.label = 1;
          case 1:
            return V < A.ihm_model_list._rowCount ? (k = N.value(V), G = void 0, L = void 0, w.has(k) ? (R = w.get(k), [4, (0, s.sortAtomSite)(_, A.atom_site, R.start, R.end)]) : [3, 3]) : [3, 6];
          case 2:
            return F = Y.sent(), U = F.atom_site, H = F.sourceIndex, G = U, L = H, [3, 4];
          case 3:
            G = r.Table.window(A.atom_site, A.atom_site._schema, 0, 0), L = r.Column.ofIntArray([]), Y.label = 4;
          case 4:
            q = {
              model_id: k,
              model_name: O.value(V),
              model_group_name: (0, d.getModelGroupName)(k, A),
              entities: T,
              atom_site: G,
              atom_site_sourceIndex: L,
              ihm_sphere_obj_site: E.has(k) ? E.get(k).table : r.Table.window(A.ihm_sphere_obj_site, A.ihm_sphere_obj_site._schema, 0, 0),
              ihm_gaussian_obj_site: I.has(k) ? I.get(k).table : r.Table.window(A.ihm_gaussian_obj_site, A.ihm_gaussian_obj_site._schema, 0, 0)
            }, K = y(A, q, M, P), B.push(K), Y.label = 5;
          case 5:
            return V++, [3, 1];
          case 6:
            return [2, B];
        }
      });
    });
  }
  return gh;
}
var P7;
function o4() {
  return P7 || (P7 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.Model = void 0;
    var r = Te, t = We(), n = In, a = Mv, i = Re, o = iC, c = Kr, s = Cc, u = xc(), l = Jo(), f = ml(), d = mr(), m = wp, p = R0;
    (function(v) {
      function h($, Q) {
        for (var W = [], te = Q.frames, oe = $.atomicHierarchy.atomSourceIndex, z = d.Column.isIdentity(oe), j = z ? void 0 : oe.toArray({ array: Int32Array }), ae = I($), le = 0, ie = te.length; le < ie; ++le) {
          var re = te[le], ee = (0, r.__assign)((0, r.__assign)({}, $), {
            id: t.UUID.create22(),
            modelNum: le,
            atomicConformation: o.Coordinates.getAtomicConformation(re, $.atomicConformation.atomId, j),
            // TODO: add support for supplying sphere and gaussian coordinates in addition to atomic coordinates?
            // coarseConformation: coarse.conformation,
            customProperties: new n.CustomProperties(),
            _staticPropertyData: /* @__PURE__ */ Object.create(null),
            _dynamicPropertyData: /* @__PURE__ */ Object.create(null)
          });
          if (re.cell) {
            var ne = f.ModelSymmetry.fromCell(re.cell.size, re.cell.anglesInRadians);
            f.ModelSymmetry.Provider.set(ee, ne);
          }
          v.TrajectoryInfo.set(ee, { index: le, size: te.length }), v.CoarseGrained.set(ee, ae), W.push(ee);
        }
        return { trajectory: W, srcIndexArray: j };
      }
      function y($, Q) {
        return new p.ArrayTrajectory(h($, Q).trajectory);
      }
      v.trajectoryFromModelAndCoordinates = y;
      function C($, Q) {
        var W = this;
        return c.Task.create("Create Trajectory", function(te) {
          return (0, r.__awaiter)(W, void 0, void 0, function() {
            var oe, z, j, ae, le, ie, re, ee, ne, se;
            return (0, r.__generator)(this, function(ce) {
              switch (ce.label) {
                case 0:
                  return [4, (0, u.createModels)($.basic, $.sourceData, te)];
                case 1:
                  if (oe = ce.sent(), oe.frameCount === 0)
                    throw new Error("found no model");
                  for (z = oe.representative, j = h(z, Q).trajectory, ae = {
                    pairs: $.bonds,
                    count: z.atomicHierarchy.atoms._rowCount
                  }, le = s.IndexPairBonds.fromData(ae), ie = I(z), re = 0, ee = 0, ne = j; ee < ne.length; ee++)
                    se = ne[ee], s.IndexPairBonds.Provider.set(se, le), v.TrajectoryInfo.set(se, { index: re++, size: j.length }), v.CoarseGrained.set(se, ie);
                  return [2, new p.ArrayTrajectory(j)];
              }
            });
          });
        });
      }
      v.trajectoryFromTopologyAndCoordinates = C;
      var S = "__Center__";
      function b($) {
        if ($._dynamicPropertyData[S])
          return $._dynamicPropertyData[S];
        var Q = (0, a.calcModelCenter)($.atomicConformation, $.coarseConformation);
        return $._dynamicPropertyData[S] = Q, Q;
      }
      v.getCenter = b;
      function g($) {
        for (var Q = new Int32Array($.rowCount), W = !1, te = 0, oe = $.rowCount; te < oe; te++) {
          var z = $.value(te);
          z !== te && (W = !1), Q[z] = te;
        }
        return {
          isIdentity: W,
          invertedIndex: Q
        };
      }
      var _ = "__InvertedAtomSrcIndex__";
      function A($) {
        if ($._staticPropertyData[_])
          return $._staticPropertyData[_];
        var Q = g($.atomicHierarchy.atomSourceIndex);
        return $._staticPropertyData[_] = Q, Q;
      }
      v.getInvertedAtomSourceIndex = A;
      var M = "__TrajectoryInfo__";
      v.TrajectoryInfo = {
        get: function($) {
          return $._dynamicPropertyData[M] || { index: 0, size: 1 };
        },
        set: function($, Q) {
          return $._dynamicPropertyData[M] = Q;
        }
      };
      var P = "__AsymIdCount__";
      v.AsymIdCount = {
        get: function($) {
          if ($._dynamicPropertyData[P])
            return $._dynamicPropertyData[P];
          var Q = (0, a.getAsymIdCount)($);
          return $._dynamicPropertyData[P] = Q, Q;
        }
      }, v.AsymIdOffset = m.CustomModelProperty.createSimple("asym_id_offset", "static"), v.Index = m.CustomModelProperty.createSimple("index", "static");
      function T($) {
        return $.parent || $;
      }
      v.getRoot = T;
      function x($, Q) {
        return $.atomicHierarchy === Q.atomicHierarchy && $.coarseHierarchy === Q.coarseHierarchy;
      }
      v.areHierarchiesEqual = x;
      var w = "__CoordinatesHistory__";
      v.CoordinatesHistory = {
        get: function($) {
          return $._staticPropertyData[w];
        },
        set: function($, Q) {
          return $._staticPropertyData[w] = Q;
        }
      };
      var E = "__CoarseGrained__";
      v.CoarseGrained = {
        get: function($) {
          return $._staticPropertyData[E];
        },
        set: function($, Q) {
          return $._staticPropertyData[E] = Q;
        }
      };
      function I($) {
        var Q = v.CoarseGrained.get($);
        if (Q === void 0) {
          for (var W = 0, te = $.atomicHierarchy.derived.residue.polymerType, oe = 0; oe < te.length; ++oe)
            te[oe] !== 0 && (W += 1);
          for (var z = !1, j = !1, ae = $.atomicHierarchy.atoms, le = ae.label_atom_id, ie = ae._rowCount, oe = 0; oe < ie; ++oe) {
            var re = le.value(oe);
            if (!z && re === "BB" && (z = !0), !j && re === "SC1" && (j = !0), z && j)
              break;
          }
          Q = z && j || (W && ie ? ie / W < 3 : !1), v.CoarseGrained.set($, Q);
        }
        return Q;
      }
      v.isCoarseGrained = I;
      function B($) {
        var Q, W;
        return !!(!((W = (Q = $.sourceData) === null || Q === void 0 ? void 0 : Q.data) === null || W === void 0) && W.isMaterial);
      }
      v.isMaterial = B;
      function D($) {
        var Q, W, te, oe = (Q = $.sourceData) === null || Q === void 0 ? void 0 : Q.data;
        return oe != null && oe.isMaterial ? !1 : !!(!((te = (W = oe == null ? void 0 : oe.molecules) === null || W === void 0 ? void 0 : W[0]) === null || te === void 0) && te.cell);
      }
      v.isMaterialCrystal = D;
      function N($) {
        return $.properties.saccharideComponentMap.size > 0;
      }
      v.hasCarbohydrate = N;
      function O($) {
        for (var Q = $.entities.subtype, W = 0, te = Q.rowCount; W < te; ++W)
          if (Q.value(W).startsWith("polypeptide"))
            return !0;
        return !1;
      }
      v.hasProtein = O;
      function V($) {
        for (var Q = $.entities.subtype, W = 0, te = Q.rowCount; W < te; ++W) {
          var oe = Q.value(W);
          if (oe.endsWith("ribonucleotide hybrid") || oe.endsWith("ribonucleotide"))
            return !0;
        }
        return !1;
      }
      v.hasNucleic = V;
      function k($) {
        if (!l.MmcifFormat.is($.sourceData))
          return !1;
        for (var Q = $.sourceData.data.db, W = 0, te = Q.database_2.database_id.rowCount; W < te; ++W)
          if (Q.database_2.database_id.value(W) === "PDB")
            return !0;
        return !1;
      }
      v.isFromPdbArchive = k;
      function G($) {
        return l.MmcifFormat.is($.sourceData) ? (
          // 4 character PDB id
          $.entryId.match(/^[1-9][a-z0-9]{3,3}$/i) !== null || // long PDB id
          $.entryId.match(/^pdb_[0-9]{4,4}[1-9][a-z0-9]{3,3}$/i) !== null
        ) : !1;
      }
      v.hasPdbId = G;
      function L($) {
        if (!l.MmcifFormat.is($.sourceData))
          return !1;
        var Q = $.sourceData.data.db;
        return Q.struct_conf.id.isDefined || Q.struct_sheet_range.id.isDefined;
      }
      v.hasSecondaryStructure = L;
      var R = i.Vec3.create(1.5707963, 1.5707963, 1.5707963), F = i.Vec3.create(1, 1, 1);
      function U($) {
        var Q, W = (Q = f.ModelSymmetry.Provider.get($)) === null || Q === void 0 ? void 0 : Q.spacegroup;
        return !!W && !(W.num === 1 && i.Vec3.equals(W.cell.anglesInRadians, R) && i.Vec3.equals(W.cell.size, F));
      }
      v.hasCrystalSymmetry = U;
      function H($) {
        if (!l.MmcifFormat.is($.sourceData))
          return !1;
        for (var Q = $.sourceData.data.db, W = 0; W < Q.exptl.method.rowCount; W++) {
          var te = Q.exptl.method.value(W).toUpperCase();
          if (te.indexOf("DIFFRACTION") >= 0)
            return !0;
        }
        return !1;
      }
      v.isFromXray = H;
      function q($) {
        if (!l.MmcifFormat.is($.sourceData))
          return !1;
        for (var Q = $.sourceData.data.db, W = 0; W < Q.exptl.method.rowCount; W++) {
          var te = Q.exptl.method.value(W).toUpperCase();
          if (te.indexOf("MICROSCOPY") >= 0)
            return !0;
        }
        return !1;
      }
      v.isFromEm = q;
      function K($) {
        if (!l.MmcifFormat.is($.sourceData))
          return !1;
        for (var Q = $.sourceData.data.db, W = 0; W < Q.exptl.method.rowCount; W++) {
          var te = Q.exptl.method.value(W).toUpperCase();
          if (te.indexOf("NMR") >= 0)
            return !0;
        }
        return !1;
      }
      v.isFromNmr = K;
      function Y($) {
        if (!l.MmcifFormat.is($.sourceData) || !H($))
          return !1;
        var Q = $.sourceData.data.db, W = Q.pdbx_database_status.status_code_sf;
        return W.isDefined && W.value(0) === "REL";
      }
      v.hasXrayMap = Y;
      function X($) {
        if (!l.MmcifFormat.is($.sourceData))
          return !1;
        for (var Q = $.sourceData.data.db, W = Q.pdbx_database_related, te = W.db_name, oe = W.content_type, z = 0, j = Q.pdbx_database_related._rowCount; z < j; ++z)
          if (te.value(z).toUpperCase() === "EMDB" && oe.value(z) === "associated EM volume")
            return !0;
        return !1;
      }
      v.hasEmMap = X;
      function Z($) {
        return l.MmcifFormat.is($.sourceData) ? Y($) || X($) : !1;
      }
      v.hasDensityMap = Z;
      function J($) {
        if (!l.MmcifFormat.is($.sourceData))
          return !1;
        var Q = $.sourceData.data.db;
        return Z($) || // check if from pdb archive but missing relevant meta data
        G($) && (!Q.exptl.method.isDefined || H($) && (!Q.pdbx_database_status.status_code_sf.isDefined || Q.pdbx_database_status.status_code_sf.valueKind(0) === 2) || q($) && !Q.pdbx_database_related.db_name.isDefined);
      }
      v.probablyHasDensityMap = J;
    })(e.Model || (e.Model = {}));
  }(Gx)), Gx;
}
var A5 = {}, M7;
function yle() {
  return M7 || (M7 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.IndexedCustomProperty = void 0;
    var r = ia(), t = Qe(), n = We();
    (function(s) {
      function u(S, b, g) {
        if (!b)
          return { rowCount: 0 };
        if (g && g[b.id])
          return g[b.id];
        var _ = b.getElements(S), A = { data: _, rowCount: _.elements.length };
        return g && (g[b.id] = A), A;
      }
      s.getCifDataSource = u;
      function l(S) {
        return new o(S);
      }
      s.fromAtomMap = l;
      function f(S) {
        return new o(a(S));
      }
      s.fromAtomArray = f;
      var d = function(S) {
        return S.atomicHierarchy.residueAtomSegments;
      };
      function m(S) {
        return new i(
          "residue",
          S,
          d,
          0
          /* Atomic */
        );
      }
      s.fromResidueMap = m;
      function p(S) {
        return new i(
          "residue",
          a(S),
          d,
          0
          /* Atomic */
        );
      }
      s.fromResidueArray = p;
      var v = function(S) {
        return S.atomicHierarchy.chainAtomSegments;
      };
      function h(S) {
        return new i(
          "chain",
          S,
          v,
          0
          /* Atomic */
        );
      }
      s.fromChainMap = h;
      function y(S) {
        return new i(
          "chain",
          a(S),
          v,
          0
          /* Atomic */
        );
      }
      s.fromChainArray = y;
      function C(S) {
        return new c(S);
      }
      s.fromEntityMap = C;
    })(e.IndexedCustomProperty || (e.IndexedCustomProperty = {}));
    function a(s) {
      for (var u = /* @__PURE__ */ new Map(), l = 0, f = s.length; l < f; l++)
        u.set(l, s[l]);
      return u;
    }
    var i = (
      /** @class */
      function() {
        function s(u, l, f, d) {
          this.level = u, this.map = l, this.segmentGetter = f, this.id = n.UUID.create22(), this.kind = d;
        }
        return s.prototype.has = function(u) {
          return this.map.has(u);
        }, s.prototype.get = function(u) {
          return this.map.get(u);
        }, s.prototype.getStructureElements = function(u) {
          var l = u.models;
          if (l.length !== 1)
            throw new Error("Only works on structures with a single model.");
          for (var f = /* @__PURE__ */ new Set(), d = u.unitSymmetryGroups, m = [], p = this.segmentGetter(l[0]), v = 0, h = d; v < h.length; v++) {
            var y = h[v], C = y.units[0];
            if (C.kind === this.kind)
              for (var S = t.Segmentation.transientSegments(p, C.elements); S.hasNext; ) {
                var b = S.move();
                !this.has(b.index) || f.has(b.index) || (f.add(b.index), m[m.length] = r.StructureElement.Location.create(u, C, C.elements[b.start]));
              }
          }
          return m.sort(function(g, _) {
            return g.element - _.element;
          }), m;
        }, s.prototype.getElements = function(u) {
          var l = this, f = this.segmentGetter(u.model).index, d = this.getStructureElements(u);
          return { elements: d, property: function(m) {
            return l.get(f[d[m].element]);
          } };
        }, s;
      }()
    ), o = (
      /** @class */
      function() {
        function s(u) {
          this.map = u, this.id = n.UUID.create22(), this.level = "atom", this.kind = 0;
        }
        return s.prototype.has = function(u) {
          return this.map.has(u);
        }, s.prototype.get = function(u) {
          return this.map.get(u);
        }, s.prototype.getStructureElements = function(u) {
          var l = u.models;
          if (l.length !== 1)
            throw new Error("Only works on structures with a single model.");
          for (var f = /* @__PURE__ */ new Set(), d = u.unitSymmetryGroups, m = [], p = 0, v = d; p < v.length; p++) {
            var h = v[p], y = h.units[0];
            if (y.kind === this.kind)
              for (var C = y.elements, S = 0, b = C.length; S < b; S++) {
                var g = C[S];
                !this.has(g) || f.has(g) || (f.add(C[S]), m[m.length] = r.StructureElement.Location.create(u, y, g));
              }
          }
          return m.sort(function(_, A) {
            return _.element - A.element;
          }), m;
        }, s.prototype.getElements = function(u) {
          var l = this, f = this.getStructureElements(u);
          return { elements: f, property: function(d) {
            return l.get(f[d].element);
          } };
        }, s;
      }()
    ), c = (
      /** @class */
      function() {
        function s(u) {
          this.map = u, this.id = n.UUID.create22(), this.level = "entity", this.kind = 0;
        }
        return s.prototype.has = function(u) {
          return this.map.has(u);
        }, s.prototype.get = function(u) {
          return this.map.get(u);
        }, s.prototype.getStructureElements = function(u) {
          var l = u.models;
          if (l.length !== 1)
            throw new Error("Only works on structures with a single model.");
          for (var f = l[0].atomicHierarchy.index, d = /* @__PURE__ */ new Set(), m = u.unitSymmetryGroups, p = [], v = l[0].atomicHierarchy.chainAtomSegments, h = 0, y = m; h < y.length; h++) {
            var C = y[h], S = C.units[0];
            if (S.kind === this.kind)
              for (var b = t.Segmentation.transientSegments(v, S.elements); b.hasNext; ) {
                var g = b.move(), _ = f.getEntityFromChain(g.index);
                !this.has(_) || d.has(_) || (d.add(_), p[p.length] = r.StructureElement.Location.create(u, S, S.elements[g.start]));
              }
          }
          return p.sort(function(A, M) {
            return A.element - M.element;
          }), p;
        }, s.prototype.getElements = function(u) {
          var l = this, f = this.getStructureElements(u), d = u.model.atomicHierarchy.chainAtomSegments.index, m = u.model.atomicHierarchy.index;
          return { elements: f, property: function(p) {
            return l.get(m.getEntityFromChain(d[f[p].element]));
          } };
        }, s;
      }()
    );
  }(A5)), A5;
}
var BG = {};
Object.defineProperty(BG, "__esModule", { value: !0 });
var w7;
function O0() {
  return w7 || (w7 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.StructureSequence = e.Symmetry = e.Types = e.Model = void 0;
    var r = Te, t = o4();
    Object.defineProperty(e, "Model", { enumerable: !0, get: function() {
      return t.Model;
    } });
    var n = (0, r.__importStar)(Gr);
    e.Types = n;
    var a = sG();
    Object.defineProperty(e, "Symmetry", { enumerable: !0, get: function() {
      return a.Symmetry;
    } });
    var i = vy;
    Object.defineProperty(e, "StructureSequence", { enumerable: !0, get: function() {
      return i.StructureSequence;
    } }), (0, r.__exportStar)(yle(), e), (0, r.__exportStar)(BG, e);
  }(zx)), zx;
}
var E7;
function Je() {
  return E7 || (E7 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 });
    var r = Te;
    (0, r.__exportStar)(iC, e), (0, r.__exportStar)(kz, e), (0, r.__exportStar)(O0(), e), (0, r.__exportStar)(ia(), e), (0, r.__exportStar)(EE(), e), (0, r.__exportStar)(R0, e);
  }(Ux)), Ux;
}
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.CarbohydrateSymbolColorThemeProvider = e.CarbohydrateSymbolColorTheme = e.getCarbohydrateSymbolColorThemeParams = e.CarbohydrateSymbolColorThemeParams = void 0;
  var r = Je(), t = ly, n = Tr(), a = Le, i = ti, o = (0, n.Color)(13421772), c = "Assigns colors according to the Symbol Nomenclature for Glycans (SNFG).";
  e.CarbohydrateSymbolColorThemeParams = {};
  function s(l) {
    return e.CarbohydrateSymbolColorThemeParams;
  }
  e.getCarbohydrateSymbolColorThemeParams = s;
  function u(l, f) {
    var d;
    if (l.structure) {
      var m = l.structure.carbohydrates, p = m.elements, v = m.getElementIndices, h = function(y, C) {
        if (!r.Unit.isAtomic(y))
          return o;
        var S = v(y, C);
        return S.length > 0 ? p[S[0]].component.color : o;
      };
      d = function(y, C) {
        return C ? t.SaccharideColors.Secondary : r.StructureElement.Location.is(y) ? h(y.unit, y.element) : r.Bond.isLocation(y) ? h(y.aUnit, y.aUnit.elements[y.aIndex]) : o;
      };
    } else
      d = function() {
        return o;
      };
    return {
      factory: u,
      granularity: "group",
      color: d,
      props: f,
      description: c,
      legend: (0, i.TableLegend)(t.MonosaccharidesColorTable)
    };
  }
  e.CarbohydrateSymbolColorTheme = u, e.CarbohydrateSymbolColorThemeProvider = {
    name: "carbohydrate-symbol",
    label: "Carbohydrate Symbol",
    category: "Residue Property",
    factory: u,
    getParams: s,
    defaultValues: a.ParamDefinition.getDefaultValues(e.CarbohydrateSymbolColorThemeParams),
    isApplicable: function(l) {
      return !!l.structure && l.structure.models.some(function(f) {
        return r.Model.hasCarbohydrate(f);
      });
    }
  };
})(Lz);
var py = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.UniformColorThemeProvider = e.UniformColorTheme = e.getUniformColorThemeParams = e.UniformColorThemeParams = void 0;
  var r = Tr(), t = Le, n = ti, a = We(), i = (0, r.Color)(14539007), o = "Gives everything the same, uniform color.";
  e.UniformColorThemeParams = {
    value: t.ParamDefinition.Color(i)
  };
  function c(u) {
    return e.UniformColorThemeParams;
  }
  e.getUniformColorThemeParams = c;
  function s(u, l) {
    var f = (0, a.defaults)(l.value, i);
    return {
      factory: s,
      granularity: "uniform",
      color: function() {
        return f;
      },
      props: l,
      description: o,
      legend: (0, n.TableLegend)([["uniform", f]])
    };
  }
  e.UniformColorTheme = s, e.UniformColorThemeProvider = {
    name: "uniform",
    label: "Uniform",
    category: "Miscellaneous",
    factory: s,
    getParams: c,
    defaultValues: t.ParamDefinition.getDefaultValues(e.UniformColorThemeParams),
    isApplicable: function(u) {
      return !0;
    }
  };
})(py);
var Pf = {}, jh = {}, BE = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.UniformSizeThemeProvider = e.UniformSizeTheme = e.getUniformSizeThemeParams = e.UniformSizeThemeParams = void 0;
  var r = Le, t = "Gives everything the same, uniform size.";
  e.UniformSizeThemeParams = {
    value: r.ParamDefinition.Numeric(1, { min: 0, max: 20, step: 0.1 })
  };
  function n(i) {
    return e.UniformSizeThemeParams;
  }
  e.getUniformSizeThemeParams = n;
  function a(i, o) {
    var c = o.value;
    return {
      factory: a,
      granularity: "uniform",
      size: function() {
        return c;
      },
      props: o,
      description: t
    };
  }
  e.UniformSizeTheme = a, e.UniformSizeThemeProvider = {
    name: "uniform",
    label: "Uniform",
    category: "",
    factory: a,
    getParams: n,
    defaultValues: r.ParamDefinition.getDefaultValues(e.UniformSizeThemeParams),
    isApplicable: function(i) {
      return !0;
    }
  };
})(BE);
var NG = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.PhysicalSizeThemeProvider = e.PhysicalSizeTheme = e.getPhysicalRadius = e.getPhysicalSizeThemeParams = e.PhysicalSizeThemeParams = void 0;
  var r = Je(), t = _s, n = Le, a = 1, i = "Assigns a physical size, i.e. vdW radius for atoms or given radius for coarse spheres.";
  e.PhysicalSizeThemeParams = {
    scale: n.ParamDefinition.Numeric(1, { min: 0.1, max: 5, step: 0.1 })
  };
  function o(u) {
    return e.PhysicalSizeThemeParams;
  }
  e.getPhysicalSizeThemeParams = o;
  function c(u, l) {
    return r.Unit.isAtomic(u) ? (0, t.VdwRadius)(u.model.atomicHierarchy.atoms.type_symbol.value(l)) : r.Unit.isSpheres(u) ? u.model.coarseConformation.spheres.radius[l] : 0;
  }
  e.getPhysicalRadius = c;
  function s(u, l) {
    var f = l.scale === void 0 ? 1 : l.scale;
    function d(m) {
      var p;
      return r.StructureElement.Location.is(m) ? p = f * c(m.unit, m.element) : r.Bond.isLocation(m) ? p = f * Math.min(c(m.aUnit, m.aUnit.elements[m.aIndex]), c(m.bUnit, m.bUnit.elements[m.bIndex])) : p = f * a, p;
    }
    return {
      factory: s,
      granularity: "group",
      size: d,
      props: l,
      description: i
    };
  }
  e.PhysicalSizeTheme = s, e.PhysicalSizeThemeProvider = {
    name: "physical",
    label: "Physical",
    category: "",
    factory: s,
    getParams: o,
    defaultValues: n.ParamDefinition.getDefaultValues(e.PhysicalSizeThemeParams),
    isApplicable: function(u) {
      return !!u.structure;
    }
  };
})(NG);
var x5 = {}, T5 = {}, P5 = {}, M5 = {}, w5 = {}, On = {};
Object.defineProperty(On, "__esModule", { value: !0 });
On.createGroupMapping = On.computeVertexNormals = On.computeIndexedVertexNormals = On.appplyRadius = On.transformDirectionArray = On.transformPositionArray = On.normalizeVec3Array = void 0;
var Ot = Re, _le = hr;
function NE(e, r) {
  for (var t = 0, n = r * 3; t < n; t += 3) {
    var a = e[t], i = e[t + 1], o = e[t + 2], c = 1 / Math.sqrt(a * a + i * i + o * o);
    e[t] = a * c, e[t + 1] = i * c, e[t + 2] = o * c;
  }
  return e;
}
On.normalizeVec3Array = NE;
var lo = (0, Ot.Vec3)();
function ble(e, r, t, n) {
  for (var a = 0, i = n * 3; a < i; a += 3)
    Ot.Vec3.fromArray(lo, r, t + a), Ot.Vec3.transformMat4(lo, lo, e), Ot.Vec3.toArray(lo, r, t + a);
}
On.transformPositionArray = ble;
function Sle(e, r, t, n) {
  for (var a = 0, i = n * 3; a < i; a += 3)
    Ot.Vec3.fromArray(lo, r, t + a), Ot.Vec3.transformMat3(lo, lo, e), Ot.Vec3.toArray(lo, r, t + a);
}
On.transformDirectionArray = Sle;
function Cle(e, r) {
  for (var t = 0, n = e.length; t < n; t += 3)
    Ot.Vec3.fromArray(lo, e, t), Ot.Vec3.normalize(lo, lo), Ot.Vec3.scale(lo, lo, r), Ot.Vec3.toArray(lo, e, t);
}
On.appplyRadius = Cle;
var Db = (0, Ot.Vec3)(), dv = (0, Ot.Vec3)(), Ib = (0, Ot.Vec3)(), mn = (0, Ot.Vec3)(), Bb = (0, Ot.Vec3)();
function Ale(e, r, t, n, a) {
  for (var i = 0, o = a * 3; i < o; i += 3) {
    var c = r[i] * 3, s = r[i + 1] * 3, u = r[i + 2] * 3;
    Ot.Vec3.fromArray(Db, e, c), Ot.Vec3.fromArray(dv, e, s), Ot.Vec3.fromArray(Ib, e, u), Ot.Vec3.sub(mn, Ib, dv), Ot.Vec3.sub(Bb, Db, dv), Ot.Vec3.cross(mn, mn, Bb), t[c] += mn[0], t[c + 1] += mn[1], t[c + 2] += mn[2], t[s] += mn[0], t[s + 1] += mn[1], t[s + 2] += mn[2], t[u] += mn[0], t[u + 1] += mn[1], t[u + 2] += mn[2];
  }
  return NE(t, n);
}
On.computeIndexedVertexNormals = Ale;
function xle(e, r, t) {
  for (var n = 0, a = t * 3; n < a; n += 9)
    Ot.Vec3.fromArray(Db, e, n), Ot.Vec3.fromArray(dv, e, n + 3), Ot.Vec3.fromArray(Ib, e, n + 6), Ot.Vec3.sub(mn, Ib, dv), Ot.Vec3.sub(Bb, Db, dv), Ot.Vec3.cross(mn, mn, Bb), r[n] = mn[0], r[n + 1] = mn[1], r[n + 2] = mn[2], r[n + 3] = mn[0], r[n + 4] = mn[1], r[n + 5] = mn[2], r[n + 6] = mn[0], r[n + 7] = mn[1], r[n + 8] = mn[2];
  return NE(r, t);
}
On.computeVertexNormals = xle;
function Tle(e, r, t) {
  t === void 0 && (t = 1);
  for (var n = (0, _le.arrayMax)(e), a = new Int32Array(n + 2), i = new Int32Array(r), o = new Int32Array(r), c = 0, s = r * t; c < s; c += t)
    ++o[e[c]];
  for (var u = 0, c = 0; c < r; c++)
    a[c] = u, u += o[c];
  a[r] = u;
  for (var l = new Int32Array(u), c = 0, s = r * t; c < s; c += t) {
    var f = e[c], d = a[f] + i[f];
    l[d] = c, ++i[f];
  }
  return { indices: l, offsets: a };
}
On.createGroupMapping = Tle;
var na = {}, ut = {};
Object.defineProperty(ut, "__esModule", { value: !0 });
ut.calculateBoundingSphere = ut.calculateTransformBoundingSphere = ut.calculateInvariantBoundingSphere = ut.printImageData = ut.printTextureImage = ut.createTextureImage = ut.calculateTextureInfo = void 0;
var D7 = Te, Pg = nr(), Su = Re, VG = ys;
function RG(e, r) {
  e = Math.max(e, 2);
  var t = Math.sqrt(e), n = Math.ceil(t);
  n = n + (r - n % r) % r;
  var a = n > 0 ? Math.ceil(e / n) : 0;
  return { width: n, height: a, length: n * a * r };
}
ut.calculateTextureInfo = RG;
function Ple(e, r, t, n) {
  var a = RG(e, r), i = a.length, o = a.width, c = a.height;
  return n = n && n.length >= i ? n : new t(i), { array: n, width: o, height: c };
}
ut.createTextureImage = Ple;
var Mle = {
  scale: 1,
  pixelated: !1,
  id: "molstar.debug.image"
};
function wle(e, r) {
  r === void 0 && (r = {});
  var t = e.array, n = e.width, a = e.height, i = t.length / (n * a), o = new Uint8ClampedArray(n * a * 4);
  if (i === 1)
    for (var c = 0; c < a; ++c)
      for (var s = 0; s < n; ++s)
        o[(c * n + s) * 4 + 3] = t[c * n + s];
  else i === 4 ? o.set(t) : console.warn("itemSize '".concat(i, "' not supported"));
  return OG(new ImageData(o, n, a), r);
}
ut.printTextureImage = wle;
var I7, B7, Dl;
function OG(e, r) {
  r === void 0 && (r = {});
  var t = (0, D7.__assign)((0, D7.__assign)({}, Mle), r), n = I7 || document.createElement("canvas");
  I7 = n, n.width = e.width, n.height = e.height;
  var a = B7 || n.getContext("2d");
  if (B7 = a, !a)
    throw new Error("Could not create canvas 2d context");
  a.putImageData(e, 0, 0), Dl || (Dl = document.createElement("div"), Dl.style.position = "absolute", Dl.style.bottom = "0px", Dl.style.right = "0px", Dl.style.border = "solid orange", Dl.style.pointerEvents = "none", document.body.appendChild(Dl)), n.toBlob(function(i) {
    var o = URL.createObjectURL(i), c = document.getElementById(t.id), s = c || document.createElement("img");
    s.id = t.id, s.src = o, s.style.width = e.width * t.scale + "px", s.style.height = e.height * t.scale + "px", t.pixelated && (s.style.imageRendering = "pixelated"), s.style.position = "relative", s.style.border = "solid grey", s.style.pointerEvents = "none", c || Dl.appendChild(s);
  }, "image/png");
}
ut.printImageData = OG;
var hu = (0, Su.Vec3)(), Ele = new VG.BoundaryHelper("14"), Dle = new VG.BoundaryHelper("98");
function FG(e) {
  return e > 1e5 ? Ele : Dle;
}
function LG(e, r, t) {
  var n = t * 3, a = FG(r);
  a.reset();
  for (var i = 0, o = r * 3; i < o; i += n)
    Su.Vec3.fromArray(hu, e, i), a.includePosition(hu);
  a.finishedIncludeStep();
  for (var i = 0, o = r * 3; i < o; i += n)
    Su.Vec3.fromArray(hu, e, i), a.radiusPosition(hu);
  var c = a.getSphere();
  if (r <= 98) {
    for (var s = [], i = 0, o = r * 3; i < o; i += n)
      s.push(Su.Vec3.fromArray((0, Su.Vec3)(), e, i));
    Pg.Sphere3D.setExtrema(c, s);
  }
  return c;
}
ut.calculateInvariantBoundingSphere = LG;
var E5 = (0, Su.Mat4)();
function kG(e, r, t) {
  if (t === 1) {
    Su.Mat4.fromArray(E5, r, 0);
    var n = Pg.Sphere3D.clone(e);
    return Su.Mat4.isIdentity(E5) ? n : Pg.Sphere3D.transform(n, n, E5);
  }
  var a = FG(t);
  a.reset();
  var i = e.center, o = e.radius, c = e.extrema;
  if (c && t < 50) {
    for (var s = 0, u = t; s < u; ++s)
      for (var l = 0, f = c; l < f.length; l++) {
        var d = f[l];
        Su.Vec3.transformMat4Offset(hu, d, r, 0, 0, s * 16), a.includePosition(hu);
      }
    a.finishedIncludeStep();
    for (var s = 0, u = t; s < u; ++s)
      for (var m = 0, p = c; m < p.length; m++) {
        var d = p[m];
        Su.Vec3.transformMat4Offset(hu, d, r, 0, 0, s * 16), a.radiusPosition(hu);
      }
  } else {
    for (var s = 0, u = t; s < u; ++s)
      Su.Vec3.transformMat4Offset(hu, i, r, 0, 0, s * 16), a.includePositionRadius(hu, o);
    a.finishedIncludeStep();
    for (var s = 0, u = t; s < u; ++s)
      Su.Vec3.transformMat4Offset(hu, i, r, 0, 0, s * 16), a.radiusPositionRadius(hu, o);
  }
  return a.getSphere();
}
ut.calculateTransformBoundingSphere = kG;
function Ile(e, r, t, n, a, i) {
  a === void 0 && (a = 0), i === void 0 && (i = 1);
  var o = LG(e, r, i), c = kG(o, t, n);
  return Pg.Sphere3D.expand(c, c, a), Pg.Sphere3D.expand(o, o, a), { boundingSphere: c, invariantBoundingSphere: o };
}
ut.calculateBoundingSphere = Ile;
Object.defineProperty(na, "__esModule", { value: !0 });
na.createEmptyMarkers = na.createMarkers = na.getMarkersAverage = void 0;
var Jn = We(), Nb = Re, Ble = ut, ai = new Uint8Array(772);
ai[1] = 1;
ai[2] = 1;
ai[3] = 1;
ai[256] = 1;
ai[512] = 1;
ai[768] = 1;
ai[257] = 2;
ai[513] = 2;
ai[769] = 2;
ai[258] = 2;
ai[514] = 2;
ai[770] = 2;
ai[259] = 2;
ai[515] = 2;
ai[771] = 2;
function UG(e, r) {
  if (r === 0)
    return 0;
  var t = new Uint32Array(e.buffer, 0, e.buffer.byteLength >> 2), n = r - 4 >> 2, a = 4 * n, i = 0;
  if (n < 0)
    for (var o = 0; o < r; ++o)
      i += e[o] && 1;
  else {
    for (var o = 0; o < n; ++o) {
      var c = t[o];
      i += ai[c & 65535] + ai[c >> 16];
    }
    for (var o = a; o < r; ++o)
      i += e[o] && 1;
  }
  return i / r;
}
na.getMarkersAverage = UG;
function Nle(e, r) {
  var t = (0, Ble.createTextureImage)(Math.max(1, e), 1, Uint8Array, r && r.tMarker.ref.value.array), n = UG(t.array, e), a = n === 0 ? 0 : -1;
  return r ? (Jn.ValueCell.updateIfChanged(r.uMarker, 0), Jn.ValueCell.update(r.tMarker, t), Jn.ValueCell.update(r.uMarkerTexDim, Nb.Vec2.create(t.width, t.height)), Jn.ValueCell.updateIfChanged(r.markerAverage, n), Jn.ValueCell.updateIfChanged(r.markerStatus, a), r) : {
    uMarker: Jn.ValueCell.create(0),
    tMarker: Jn.ValueCell.create(t),
    uMarkerTexDim: Jn.ValueCell.create(Nb.Vec2.create(t.width, t.height)),
    markerAverage: Jn.ValueCell.create(n),
    markerStatus: Jn.ValueCell.create(a)
  };
}
na.createMarkers = Nle;
var N7 = { array: new Uint8Array(1), width: 1, height: 1 };
function Vle(e) {
  return e ? (Jn.ValueCell.updateIfChanged(e.uMarker, 0), Jn.ValueCell.update(e.tMarker, N7), Jn.ValueCell.update(e.uMarkerTexDim, Nb.Vec2.create(1, 1)), Jn.ValueCell.updateIfChanged(e.markerAverage, 0), Jn.ValueCell.updateIfChanged(e.markerStatus, 0), e) : {
    uMarker: Jn.ValueCell.create(0),
    tMarker: Jn.ValueCell.create(N7),
    uMarkerTexDim: Jn.ValueCell.create(Nb.Vec2.create(1, 1)),
    markerAverage: Jn.ValueCell.create(0),
    markerStatus: Jn.ValueCell.create(0)
  };
}
na.createEmptyMarkers = Vle;
var on = {}, Ja = {};
Object.defineProperty(Ja, "__esModule", { value: !0 });
Ja.isDataLocation = Ja.DataLocation = Ja.isNullLocation = Ja.NullLocation = void 0;
Ja.NullLocation = { kind: "null-location" };
function Rle(e) {
  return !!e && e.kind === "null-location";
}
Ja.isNullLocation = Rle;
function Ole(e, r, t) {
  return { kind: "data-location", tag: e, data: r, element: t };
}
Ja.DataLocation = Ole;
function Fle(e) {
  return !!e && e.kind === "data-location";
}
Ja.isDataLocation = Fle;
Object.defineProperty(on, "__esModule", { value: !0 });
on.isPositionLocation = on.PositionLocation = on.LocationIterator = void 0;
var V7 = Re, R7 = Ja;
function Lle(e, r, t, n, a, i) {
  if (a === void 0 && (a = !1), i === void 0 && (i = function() {
    return !1;
  }), e % t !== 0)
    throw new Error("incompatible groupCount and stride");
  var o = {
    location: R7.NullLocation,
    index: 0,
    groupIndex: 0,
    instanceIndex: 0,
    isSecondary: !1
  }, c = o.groupIndex < e, s = !1, u = 0, l = 0, f = !1;
  return {
    get hasNext() {
      return c;
    },
    get isNextNewInstance() {
      return s;
    },
    groupCount: e,
    instanceCount: r,
    count: e * r,
    stride: t,
    nonInstanceable: a,
    move: function() {
      return c && (o.groupIndex = u, o.instanceIndex = l, o.index = l * e + u, o.location = n(u, f ? -1 : l), o.isSecondary = i(u, f ? -1 : l), u += t, u === e ? (++l, s = !0, l < r && (u = 0)) : s = !1, c = u < e), o;
    },
    reset: function() {
      o.location = R7.NullLocation, o.index = 0, o.groupIndex = 0, o.instanceIndex = 0, o.isSecondary = !1, c = o.groupIndex < e, s = !1, u = 0, l = 0, f = !1;
    },
    skipInstance: function() {
      c && o.instanceIndex === l && (++l, u = 0, c = l < r);
    },
    voidInstances: function() {
      f = !0;
    }
  };
}
on.LocationIterator = Lle;
function kle(e) {
  return { kind: "position-location", position: e ? V7.Vec3.clone(e) : (0, V7.Vec3)() };
}
on.PositionLocation = kle;
function Ule(e) {
  return !!e && e.kind === "position-location";
}
on.isPositionLocation = Ule;
var Lu = {}, O7;
function ru() {
  if (O7) return Lu;
  O7 = 1, Object.defineProperty(Lu, "__esModule", { value: !0 }), Lu.createGridColor = Lu.createTextureColor = Lu.createValueColor = Lu.createColors = void 0;
  var e = We(), r = ut, t = Tr(), n = Re, a = Ja, i = Kd(), o = ps();
  function c(b, g, _, A) {
    var M = s(b, g, _, A);
    return _.palette ? (e.ValueCell.updateIfChanged(M.dUsePalette, !0), u(_.palette, M.tPalette)) : e.ValueCell.updateIfChanged(M.dUsePalette, !1), M;
  }
  Lu.createColors = c;
  function s(b, g, _, A) {
    switch (i.Geometry.getGranularity(b, _.granularity)) {
      case "uniform":
        return f(b, _.color, A);
      case "instance":
        return m(b, _.color, A);
      case "group":
        return p(b, _.color, A);
      case "groupInstance":
        return v(b, _.color, A);
      case "vertex":
        return h(g, _.color, A);
      case "vertexInstance":
        return y(g, _.color, A);
      case "volume":
        return C(_.grid, "volume", A);
      case "volumeInstance":
        return C(_.grid, "volumeInstance", A);
      case "direct":
        return S(A);
    }
  }
  function u(b, g) {
    var _ = !0, A = g.ref.value;
    if (b.colors.length !== A.width || A.filter !== b.filter)
      _ = !1;
    else
      for (var M = A.array, P = 0, T = 0, x = b.colors; T < x.length; T++) {
        var w = x[T], E = t.Color.toRgb(w), I = E[0], B = E[1], D = E[2];
        if (M[P++] !== I || M[P++] !== B || M[P++] !== D) {
          _ = !1;
          break;
        }
      }
    if (!_) {
      for (var N = new Uint8Array(b.colors.length * 3), O = 0, V = 0, k = b.colors; V < k.length; V++) {
        var w = k[V], G = t.Color.toRgb(w), I = G[0], B = G[1], D = G[2];
        N[O++] = I, N[O++] = B, N[O++] = D;
      }
      e.ValueCell.update(g, {
        array: N,
        height: 1,
        width: b.colors.length,
        filter: b.filter
      });
    }
  }
  function l(b, g) {
    return g ? (e.ValueCell.update(g.uColor, t.Color.toVec3Normalized(g.uColor.ref.value, b)), e.ValueCell.updateIfChanged(g.dColorType, "uniform"), g) : {
      uColor: e.ValueCell.create(t.Color.toVec3Normalized((0, n.Vec3)(), b)),
      tColor: e.ValueCell.create({
        array: new Uint8Array(3),
        width: 1,
        height: 1
      }),
      tColorGrid: e.ValueCell.create((0, o.createNullTexture)()),
      tPalette: e.ValueCell.create({
        array: new Uint8Array(3),
        width: 1,
        height: 1
      }),
      uColorTexDim: e.ValueCell.create(n.Vec2.create(1, 1)),
      uColorGridDim: e.ValueCell.create(n.Vec3.create(1, 1, 1)),
      uColorGridTransform: e.ValueCell.create(n.Vec4.create(0, 0, 0, 1)),
      dColorType: e.ValueCell.create("uniform"),
      dUsePalette: e.ValueCell.create(!1)
    };
  }
  Lu.createValueColor = l;
  function f(b, g, _) {
    return l(g(a.NullLocation, !1), _);
  }
  function d(b, g, _) {
    return _ ? (e.ValueCell.update(_.tColor, b), e.ValueCell.update(_.uColorTexDim, n.Vec2.create(b.width, b.height)), e.ValueCell.updateIfChanged(_.dColorType, g), _) : {
      uColor: e.ValueCell.create((0, n.Vec3)()),
      tColor: e.ValueCell.create(b),
      tColorGrid: e.ValueCell.create((0, o.createNullTexture)()),
      tPalette: e.ValueCell.create({
        array: new Uint8Array(3),
        width: 1,
        height: 1
      }),
      uColorTexDim: e.ValueCell.create(n.Vec2.create(b.width, b.height)),
      uColorGridDim: e.ValueCell.create(n.Vec3.create(1, 1, 1)),
      uColorGridTransform: e.ValueCell.create(n.Vec4.create(0, 0, 0, 1)),
      dColorType: e.ValueCell.create(g),
      dUsePalette: e.ValueCell.create(!1)
    };
  }
  Lu.createTextureColor = d;
  function m(b, g, _) {
    var A = b.instanceCount, M = (0, r.createTextureImage)(Math.max(1, A), 3, Uint8Array, _ && _.tColor.ref.value.array);
    for (b.reset(); b.hasNext; ) {
      var P = b.move(), T = P.location, x = P.isSecondary, w = P.instanceIndex;
      t.Color.toArray(g(T, x), M.array, w * 3), b.skipInstance();
    }
    return d(M, "instance", _);
  }
  function p(b, g, _) {
    var A = b.groupCount, M = (0, r.createTextureImage)(Math.max(1, A), 3, Uint8Array, _ && _.tColor.ref.value.array);
    for (b.reset(); b.hasNext && !b.isNextNewInstance; ) {
      var P = b.move(), T = P.location, x = P.isSecondary, w = P.groupIndex;
      t.Color.toArray(g(T, x), M.array, w * 3);
    }
    return d(M, "group", _);
  }
  function v(b, g, _) {
    var A = b.groupCount, M = b.instanceCount, P = M * A, T = (0, r.createTextureImage)(Math.max(1, P), 3, Uint8Array, _ && _.tColor.ref.value.array);
    for (b.reset(); b.hasNext; ) {
      var x = b.move(), w = x.location, E = x.isSecondary, I = x.index;
      t.Color.toArray(g(w, E), T.array, I * 3);
    }
    return d(T, "groupInstance", _);
  }
  function h(b, g, _) {
    var A = b.groupCount, M = b.stride, P = (0, r.createTextureImage)(Math.max(1, A), 3, Uint8Array, _ && _.tColor.ref.value.array);
    for (b.reset(), b.voidInstances(); b.hasNext && !b.isNextNewInstance; )
      for (var T = b.move(), x = T.location, w = T.isSecondary, E = T.groupIndex, I = g(x, w), B = 0; B < M; ++B)
        t.Color.toArray(I, P.array, (E + B) * 3);
    return d(P, "vertex", _);
  }
  function y(b, g, _) {
    var A = b.groupCount, M = b.instanceCount, P = b.stride, T = M * A, x = (0, r.createTextureImage)(Math.max(1, T), 3, Uint8Array, _ && _.tColor.ref.value.array);
    for (b.reset(); b.hasNext; )
      for (var w = b.move(), E = w.location, I = w.isSecondary, B = w.index, D = g(E, I), N = 0; N < P; ++N)
        t.Color.toArray(D, x.array, (B + N) * 3);
    return d(x, "vertexInstance", _);
  }
  function C(b, g, _) {
    var A = b.colors, M = b.dimension, P = b.transform, T = A.getWidth(), x = A.getHeight();
    return _ ? (e.ValueCell.update(_.tColorGrid, A), e.ValueCell.update(_.uColorTexDim, n.Vec2.create(T, x)), e.ValueCell.update(_.uColorGridDim, n.Vec3.clone(M)), e.ValueCell.update(_.uColorGridTransform, n.Vec4.clone(P)), e.ValueCell.updateIfChanged(_.dColorType, g), _) : {
      uColor: e.ValueCell.create((0, n.Vec3)()),
      tColor: e.ValueCell.create({
        array: new Uint8Array(3),
        width: 1,
        height: 1
      }),
      tColorGrid: e.ValueCell.create(A),
      tPalette: e.ValueCell.create({
        array: new Uint8Array(3),
        width: 1,
        height: 1
      }),
      uColorTexDim: e.ValueCell.create(n.Vec2.create(T, x)),
      uColorGridDim: e.ValueCell.create(n.Vec3.clone(M)),
      uColorGridTransform: e.ValueCell.create(n.Vec4.clone(P)),
      dColorType: e.ValueCell.create(g),
      dUsePalette: e.ValueCell.create(!1)
    };
  }
  Lu.createGridColor = C;
  function S(b) {
    return b ? (e.ValueCell.updateIfChanged(b.dColorType, "direct"), b) : {
      uColor: e.ValueCell.create((0, n.Vec3)()),
      tColor: e.ValueCell.create({
        array: new Uint8Array(3),
        width: 1,
        height: 1
      }),
      tColorGrid: e.ValueCell.create((0, o.createNullTexture)()),
      tPalette: e.ValueCell.create({
        array: new Uint8Array(3),
        width: 1,
        height: 1
      }),
      uColorTexDim: e.ValueCell.create(n.Vec2.create(1, 1)),
      uColorGridDim: e.ValueCell.create(n.Vec3.create(1, 1, 1)),
      uColorGridTransform: e.ValueCell.create(n.Vec4.create(0, 0, 0, 1)),
      dColorType: e.ValueCell.create("direct"),
      dUsePalette: e.ValueCell.create(!1)
    };
  }
  return Lu;
}
var Xt = {}, ji = {};
Object.defineProperty(ji, "__esModule", { value: !0 });
ji.updateTransformData = ji.fillIdentityTransform = ji.createIdentityTransform = ji.createTransform = void 0;
var ja = We(), el = Re, F7 = hr, L7 = (0, el.Mat3)(), zle = (0, el.Mat4)();
function Gle(e, r) {
  for (var t = 0; t < r; t++)
    if (el.Mat3.fromMat4(L7, el.Mat4.fromArray(zle, e, t * 16)), el.Mat3.determinant(L7) < 0)
      return !0;
  return !1;
}
function zG(e, r, t) {
  var n = Gle(e, r);
  if (t) {
    ja.ValueCell.update(t.matrix, t.matrix.ref.value);
    var a = t.transform.ref.value.length >= r * 16 ? t.transform.ref.value : new Float32Array(r * 16);
    a.set(e), ja.ValueCell.update(t.transform, a), ja.ValueCell.updateIfChanged(t.uInstanceCount, r), ja.ValueCell.updateIfChanged(t.instanceCount, r);
    var i = t.aTransform.ref.value.length >= r * 16 ? t.aTransform.ref.value : new Float32Array(r * 16);
    ja.ValueCell.update(t.aTransform, i);
    var o = t.extraTransform.ref.value.length >= r * 16 ? t.extraTransform.ref.value : new Float32Array(r * 16);
    ja.ValueCell.update(t.extraTransform, RM(o, r));
    var c = t.aInstance.ref.value.length >= r ? t.aInstance.ref.value : new Float32Array(r);
    ja.ValueCell.update(t.aInstance, (0, F7.fillSerial)(c, r)), ja.ValueCell.update(t.hasReflection, n);
  } else
    t = {
      aTransform: ja.ValueCell.create(new Float32Array(r * 16)),
      matrix: ja.ValueCell.create(el.Mat4.identity()),
      transform: ja.ValueCell.create(new Float32Array(e)),
      extraTransform: ja.ValueCell.create(RM(new Float32Array(r * 16), r)),
      uInstanceCount: ja.ValueCell.create(r),
      instanceCount: ja.ValueCell.create(r),
      aInstance: ja.ValueCell.create((0, F7.fillSerial)(new Float32Array(r))),
      hasReflection: ja.ValueCell.create(n)
    };
  return GG(t), t;
}
ji.createTransform = zG;
var VE = new Float32Array(16);
el.Mat4.toArray(el.Mat4.identity(), VE, 0);
function qle(e) {
  return zG(new Float32Array(VE), 1, e);
}
ji.createIdentityTransform = qle;
function RM(e, r) {
  for (var t = 0; t < r; t++)
    e.set(VE, t * 16);
  return e;
}
ji.fillIdentityTransform = RM;
function GG(e) {
  for (var r = e.aTransform.ref.value, t = e.instanceCount.ref.value, n = e.matrix.ref.value, a = e.transform.ref.value, i = e.extraTransform.ref.value, o = 0; o < t; o++) {
    var c = o * 16;
    el.Mat4.mulOffset(r, i, a, c, c, c), el.Mat4.mulOffset(r, n, r, c, 0, c);
  }
  ja.ValueCell.update(e.aTransform, r);
}
ji.updateTransformData = GG;
var Oa = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ColorNamesValueMap = e.ColorNames = void 0;
  var r = Iu();
  e.ColorNames = (0, r.ColorMap)({
    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
  }), e.ColorNamesValueMap = function() {
    var t = /* @__PURE__ */ new Map();
    return Object.keys(e.ColorNames).forEach(function(n) {
      t.set(e.ColorNames[n], n);
    }), t;
  }();
})(Oa);
var u4 = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Material = void 0;
  var r = Te, t = Le;
  function n(a) {
    return (0, r.__assign)((0, r.__assign)({}, n.Zero), a);
  }
  e.Material = n, function(a) {
    a.Zero = { metalness: 0, roughness: 0, bumpiness: 0 };
    function i(s, u, l) {
      return u[l] = s.metalness * 255, u[l + 1] = s.roughness * 255, u[l + 2] = s.bumpiness * 255, u;
    }
    a.toArray = i;
    function o(s) {
      var u = s.metalness, l = s.roughness, f = s.bumpiness;
      return "M ".concat(u.toFixed(2), " | R ").concat(l.toFixed(2), " | B ").concat(f.toFixed(2));
    }
    a.toString = o;
    function c(s) {
      return t.ParamDefinition.Group({
        metalness: t.ParamDefinition.Numeric(0, { min: 0, max: 1, step: 0.01 }),
        roughness: t.ParamDefinition.Numeric(1, { min: 0, max: 1, step: 0.01 }),
        bumpiness: t.ParamDefinition.Numeric(0, { min: 0, max: 1, step: 0.01 })
      }, (0, r.__assign)((0, r.__assign)({}, s), { 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"]
      ] }));
    }
    a.getParam = c;
  }(n = e.Material || (e.Material = {}));
})(u4);
var qG = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Clip = void 0;
  var r = Re, t = kn, n = Le, a = cs;
  function i() {
  }
  e.Clip = i, function(o) {
    o.Type = {
      none: 0,
      plane: 1,
      sphere: 2,
      cube: 3,
      cylinder: 4,
      infiniteCone: 5
    }, o.Params = {
      variant: n.ParamDefinition.Select("pixel", n.ParamDefinition.arrayToOptions(["instance", "pixel"])),
      objects: n.ParamDefinition.ObjectList({
        type: n.ParamDefinition.Select("plane", n.ParamDefinition.objectToOptions(o.Type, function(p) {
          return (0, a.stringToWords)(p);
        })),
        invert: n.ParamDefinition.Boolean(!1),
        position: n.ParamDefinition.Vec3((0, r.Vec3)()),
        rotation: n.ParamDefinition.Group({
          axis: n.ParamDefinition.Vec3(r.Vec3.create(1, 0, 0)),
          angle: n.ParamDefinition.Numeric(0, { min: -180, max: 180, step: 1 }, { description: "Angle in Degrees" })
        }, { isExpanded: !0 }),
        scale: n.ParamDefinition.Vec3(r.Vec3.create(1, 1, 1))
      }, function(p) {
        return (0, a.stringToWords)(p.type);
      })
    };
    function c() {
      return {
        count: 0,
        type: new Array(5).fill(1),
        invert: new Array(5).fill(!1),
        position: new Array(5 * 3).fill(0),
        rotation: new Array(5 * 4).fill(0),
        scale: new Array(5 * 3).fill(1)
      };
    }
    var s = (0, r.Quat)(), u = (0, r.Quat)(), l = (0, r.Vec3)(), f = (0, r.Vec3)();
    function d(p, v) {
      for (var h = (v == null ? void 0 : v.objects) || c(), y = h.type, C = h.invert, S = h.position, b = h.rotation, g = h.scale, _ = 0, A = p.objects.length; _ < A; ++_) {
        var M = p.objects[_];
        y[_] = o.Type[M.type], C[_] = M.invert, r.Vec3.toArray(M.position, S, _ * 3), r.Quat.toArray(r.Quat.setAxisAngle(s, M.rotation.axis, (0, t.degToRad)(M.rotation.angle)), b, _ * 4), r.Vec3.toArray(M.scale, g, _ * 3);
      }
      return {
        variant: p.variant,
        objects: { count: p.objects.length, type: y, invert: C, position: S, rotation: b, scale: g }
      };
    }
    o.getClip = d;
    function m(p, v) {
      if (p.variant !== v.variant || p.objects.count !== v.objects.count)
        return !1;
      for (var h = p.objects, y = v.objects, C = 0, S = h.count; C < S; ++C)
        if (h.invert[C] !== y.invert[C] || h.type[C] !== y.type[C] || (r.Vec3.fromArray(l, h.position, C * 3), r.Vec3.fromArray(f, y.position, C * 3), !r.Vec3.equals(l, f)) || (r.Vec3.fromArray(l, h.scale, C * 3), r.Vec3.fromArray(f, y.scale, C * 3), !r.Vec3.equals(l, f)) || (r.Quat.fromArray(s, h.rotation, C * 4), r.Quat.fromArray(u, y.rotation, C * 4), !r.Quat.equals(s, u)))
          return !1;
      return !0;
    }
    o.areEqual = m;
  }(i = e.Clip || (e.Clip = {}));
})(qG);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.BaseGeometry = e.getColorSmoothingProps = e.hasColorSmoothingProp = e.ColorSmoothingParams = e.VisualQualityOptions = e.VisualQualityNames = e.VisualQualityInfo = void 0;
  var r = We(), t = on, n = Le, a = ji, i = Oa, o = Ja, c = py, s = BE, u = Zr, l = u4, f = qG;
  e.VisualQualityInfo = {
    custom: {},
    auto: {},
    highest: {},
    higher: {},
    high: {},
    medium: {},
    low: {},
    lower: {},
    lowest: {}
  }, e.VisualQualityNames = Object.keys(e.VisualQualityInfo), e.VisualQualityOptions = n.ParamDefinition.arrayToOptions(e.VisualQualityNames), e.ColorSmoothingParams = {
    smoothColors: n.ParamDefinition.MappedStatic("auto", {
      auto: n.ParamDefinition.Group({}),
      on: n.ParamDefinition.Group({
        resolutionFactor: n.ParamDefinition.Numeric(2, { min: 0.5, max: 6, step: 0.1 }),
        sampleStride: n.ParamDefinition.Numeric(3, { min: 1, max: 12, step: 1 })
      }),
      off: n.ParamDefinition.Group({})
    })
  };
  function d(p) {
    return !!p.smoothColors;
  }
  e.hasColorSmoothingProp = d;
  function m(p, v, h) {
    if ((p.name === "on" || p.name === "auto" && v) && h && h < 3) {
      var y = 3;
      return p.name === "on" ? (h *= p.params.resolutionFactor, y = p.params.sampleStride) : (h *= 2 - (0, u.smoothstep)(0, 1.1, h), h = Math.max(0.5, h), h > 1.2 && (y = 2)), { resolution: h, stride: y };
    }
  }
  e.getColorSmoothingProps = m, function(p) {
    p.MaterialCategory = { category: "Material" }, p.ShadingCategory = { category: "Shading" }, p.CustomQualityParamInfo = {
      category: "Custom Quality",
      hideIf: function(b) {
        return typeof b.quality < "u" && b.quality !== "custom";
      }
    }, p.Params = {
      alpha: n.ParamDefinition.Numeric(1, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }),
      quality: n.ParamDefinition.Select("auto", e.VisualQualityOptions, { isEssential: !0, description: "Visual/rendering quality of the representation." }),
      material: l.Material.getParam(),
      clip: n.ParamDefinition.Group(f.Clip.Params)
    };
    function v(b, g, _) {
      b === void 0 && (b = i.ColorNames.grey), g === void 0 && (g = 1), _ || (_ = (0, a.createIdentityTransform)());
      var A = (0, t.LocationIterator)(1, _.instanceCount.ref.value, 1, function() {
        return o.NullLocation;
      }, !1, function() {
        return !1;
      }), M = {
        color: (0, c.UniformColorTheme)({}, { value: b }),
        size: (0, s.UniformSizeTheme)({}, { value: g })
      };
      return { transform: _, locationIterator: A, theme: M };
    }
    p.createSimple = v;
    function h(b, g) {
      var _ = f.Clip.getClip(b.clip);
      return {
        alpha: r.ValueCell.create(b.alpha),
        uAlpha: r.ValueCell.create(b.alpha),
        uVertexCount: r.ValueCell.create(g.vertexCount),
        uGroupCount: r.ValueCell.create(g.groupCount),
        drawCount: r.ValueCell.create(g.drawCount),
        uMetalness: r.ValueCell.create(b.material.metalness),
        uRoughness: r.ValueCell.create(b.material.roughness),
        uBumpiness: r.ValueCell.create(b.material.bumpiness),
        dLightCount: r.ValueCell.create(1),
        dClipObjectCount: r.ValueCell.create(_.objects.count),
        dClipVariant: r.ValueCell.create(_.variant),
        uClipObjectType: r.ValueCell.create(_.objects.type),
        uClipObjectInvert: r.ValueCell.create(_.objects.invert),
        uClipObjectPosition: r.ValueCell.create(_.objects.position),
        uClipObjectRotation: r.ValueCell.create(_.objects.rotation),
        uClipObjectScale: r.ValueCell.create(_.objects.scale)
      };
    }
    p.createValues = h;
    function y(b, g) {
      r.ValueCell.updateIfChanged(b.alpha, g.alpha), r.ValueCell.updateIfChanged(b.uMetalness, g.material.metalness), r.ValueCell.updateIfChanged(b.uRoughness, g.material.roughness), r.ValueCell.updateIfChanged(b.uBumpiness, g.material.bumpiness);
      var _ = f.Clip.getClip(g.clip);
      r.ValueCell.update(b.dClipObjectCount, _.objects.count), r.ValueCell.update(b.dClipVariant, _.variant), r.ValueCell.update(b.uClipObjectType, _.objects.type), r.ValueCell.update(b.uClipObjectInvert, _.objects.invert), r.ValueCell.update(b.uClipObjectPosition, _.objects.position), r.ValueCell.update(b.uClipObjectRotation, _.objects.rotation), r.ValueCell.update(b.uClipObjectScale, _.objects.scale);
    }
    p.updateValues = y;
    function C(b) {
      b === void 0 && (b = {});
      var g = b.alpha === void 0 ? !0 : b.alpha === 1;
      return {
        disposed: !1,
        visible: !0,
        alphaFactor: 1,
        pickable: !0,
        colorOnly: !1,
        opaque: g,
        writeDepth: g
      };
    }
    p.createRenderableState = C;
    function S(b, g) {
      b.opaque = g.alpha * b.alphaFactor >= 1, b.writeDepth = b.opaque;
    }
    p.updateRenderableState = S;
  }(e.BaseGeometry || (e.BaseGeometry = {}));
})(Xt);
var pa = {};
Object.defineProperty(pa, "__esModule", { value: !0 });
pa.createEmptyOverpaint = pa.createOverpaint = pa.clearOverpaint = pa.applyOverpaintColor = void 0;
var la = Jl, od = Re, Hle = ut, jle = Tr(), HG = ps();
function $le(e, r, t, n) {
  for (var a = r; a < t; ++a)
    jle.Color.toArray(n, e, a * 4), e[a * 4 + 3] = 255;
  return !0;
}
pa.applyOverpaintColor = $le;
function Kle(e, r, t) {
  return e.fill(0, r * 4, t * 4), !0;
}
pa.clearOverpaint = Kle;
function Wle(e, r) {
  var t = (0, Hle.createTextureImage)(Math.max(1, e), 4, Uint8Array, r && r.tOverpaint.ref.value.array);
  return r ? (la.ValueCell.update(r.tOverpaint, t), la.ValueCell.update(r.uOverpaintTexDim, od.Vec2.create(t.width, t.height)), la.ValueCell.updateIfChanged(r.dOverpaint, e > 0), r) : {
    tOverpaint: la.ValueCell.create(t),
    uOverpaintTexDim: la.ValueCell.create(od.Vec2.create(t.width, t.height)),
    dOverpaint: la.ValueCell.create(e > 0),
    tOverpaintGrid: la.ValueCell.create((0, HG.createNullTexture)()),
    uOverpaintGridDim: la.ValueCell.create(od.Vec3.create(1, 1, 1)),
    uOverpaintGridTransform: la.ValueCell.create(od.Vec4.create(0, 0, 0, 1)),
    dOverpaintType: la.ValueCell.create("groupInstance")
  };
}
pa.createOverpaint = Wle;
var k7 = { array: new Uint8Array(4), width: 1, height: 1 };
function Xle(e) {
  return e ? (la.ValueCell.update(e.tOverpaint, k7), la.ValueCell.update(e.uOverpaintTexDim, od.Vec2.create(1, 1)), e) : {
    tOverpaint: la.ValueCell.create(k7),
    uOverpaintTexDim: la.ValueCell.create(od.Vec2.create(1, 1)),
    dOverpaint: la.ValueCell.create(!1),
    tOverpaintGrid: la.ValueCell.create((0, HG.createNullTexture)()),
    uOverpaintGridDim: la.ValueCell.create(od.Vec3.create(1, 1, 1)),
    uOverpaintGridTransform: la.ValueCell.create(od.Vec4.create(0, 0, 0, 1)),
    dOverpaintType: la.ValueCell.create("groupInstance")
  };
}
pa.createEmptyOverpaint = Xle;
var $n = {};
Object.defineProperty($n, "__esModule", { value: !0 });
$n.createEmptyTransparency = $n.createTransparency = $n.clearTransparency = $n.getTransparencyAverage = $n.applyTransparencyValue = void 0;
var Rn = We(), ud = Re, Yle = ut, jG = ps();
function Qle(e, r, t, n) {
  for (var a = r; a < t; ++a)
    e[a] = n * 255;
  return !0;
}
$n.applyTransparencyValue = Qle;
function $G(e, r) {
  for (var t = 0, n = 0; n < r; ++n)
    t += e[n];
  return t / (255 * r);
}
$n.getTransparencyAverage = $G;
function Zle(e, r, t) {
  e.fill(0, r, t);
}
$n.clearTransparency = Zle;
function Jle(e, r) {
  var t = (0, Yle.createTextureImage)(Math.max(1, e), 1, Uint8Array, r && r.tTransparency.ref.value.array);
  return r ? (Rn.ValueCell.update(r.tTransparency, t), Rn.ValueCell.update(r.uTransparencyTexDim, ud.Vec2.create(t.width, t.height)), Rn.ValueCell.updateIfChanged(r.dTransparency, e > 0), Rn.ValueCell.updateIfChanged(r.transparencyAverage, $G(t.array, e)), r) : {
    tTransparency: Rn.ValueCell.create(t),
    uTransparencyTexDim: Rn.ValueCell.create(ud.Vec2.create(t.width, t.height)),
    dTransparency: Rn.ValueCell.create(e > 0),
    transparencyAverage: Rn.ValueCell.create(0),
    tTransparencyGrid: Rn.ValueCell.create((0, jG.createNullTexture)()),
    uTransparencyGridDim: Rn.ValueCell.create(ud.Vec3.create(1, 1, 1)),
    uTransparencyGridTransform: Rn.ValueCell.create(ud.Vec4.create(0, 0, 0, 1)),
    dTransparencyType: Rn.ValueCell.create("groupInstance")
  };
}
$n.createTransparency = Jle;
var U7 = {
  array: new Uint8Array(1),
  width: 1,
  height: 1
};
function ece(e) {
  return e ? (Rn.ValueCell.update(e.tTransparency, U7), Rn.ValueCell.update(e.uTransparencyTexDim, ud.Vec2.create(1, 1)), e) : {
    tTransparency: Rn.ValueCell.create(U7),
    uTransparencyTexDim: Rn.ValueCell.create(ud.Vec2.create(1, 1)),
    dTransparency: Rn.ValueCell.create(!1),
    transparencyAverage: Rn.ValueCell.create(0),
    tTransparencyGrid: Rn.ValueCell.create((0, jG.createNullTexture)()),
    uTransparencyGridDim: Rn.ValueCell.create(ud.Vec3.create(1, 1, 1)),
    uTransparencyGridTransform: Rn.ValueCell.create(ud.Vec4.create(0, 0, 0, 1)),
    dTransparencyType: Rn.ValueCell.create("groupInstance")
  };
}
$n.createEmptyTransparency = ece;
var ha = {};
Object.defineProperty(ha, "__esModule", { value: !0 });
ha.createEmptyClipping = ha.createClipping = ha.clearClipping = ha.applyClippingGroups = void 0;
var Cu = We(), Vb = Re, rce = ut;
function tce(e, r, t, n) {
  return e.fill(n, r, t), !0;
}
ha.applyClippingGroups = tce;
function nce(e, r, t) {
  e.fill(0, r, t);
}
ha.clearClipping = nce;
function ace(e, r) {
  var t = (0, rce.createTextureImage)(Math.max(1, e), 1, Uint8Array, r && r.tClipping.ref.value.array);
  return r ? (Cu.ValueCell.update(r.tClipping, t), Cu.ValueCell.update(r.uClippingTexDim, Vb.Vec2.create(t.width, t.height)), Cu.ValueCell.updateIfChanged(r.dClipping, e > 0), r) : {
    tClipping: Cu.ValueCell.create(t),
    uClippingTexDim: Cu.ValueCell.create(Vb.Vec2.create(t.width, t.height)),
    dClipping: Cu.ValueCell.create(e > 0)
  };
}
ha.createClipping = ace;
var z7 = { array: new Uint8Array(1), width: 1, height: 1 };
function ice(e) {
  return e ? (Cu.ValueCell.update(e.tClipping, z7), Cu.ValueCell.update(e.uClippingTexDim, Vb.Vec2.create(1, 1)), Cu.ValueCell.updateIfChanged(e.dClipping, !1), e) : {
    tClipping: Cu.ValueCell.create(z7),
    uClippingTexDim: Cu.ValueCell.create(Vb.Vec2.create(1, 1)),
    dClipping: Cu.ValueCell.create(!1)
  };
}
ha.createEmptyClipping = ice;
var ga = {};
Object.defineProperty(ga, "__esModule", { value: !0 });
ga.createEmptySubstance = ga.createSubstance = ga.clearSubstance = ga.applySubstanceMaterial = void 0;
var ca = We(), sd = Re, oce = ut, KG = ps(), uce = u4;
function sce(e, r, t, n) {
  for (var a = r; a < t; ++a)
    uce.Material.toArray(n, e, a * 4), e[a * 4 + 3] = 255;
  return !0;
}
ga.applySubstanceMaterial = sce;
function lce(e, r, t) {
  return e.fill(0, r * 4, t * 4), !0;
}
ga.clearSubstance = lce;
function cce(e, r) {
  var t = (0, oce.createTextureImage)(Math.max(1, e), 4, Uint8Array, r && r.tSubstance.ref.value.array);
  return r ? (ca.ValueCell.update(r.tSubstance, t), ca.ValueCell.update(r.uSubstanceTexDim, sd.Vec2.create(t.width, t.height)), ca.ValueCell.updateIfChanged(r.dSubstance, e > 0), r) : {
    tSubstance: ca.ValueCell.create(t),
    uSubstanceTexDim: ca.ValueCell.create(sd.Vec2.create(t.width, t.height)),
    dSubstance: ca.ValueCell.create(e > 0),
    tSubstanceGrid: ca.ValueCell.create((0, KG.createNullTexture)()),
    uSubstanceGridDim: ca.ValueCell.create(sd.Vec3.create(1, 1, 1)),
    uSubstanceGridTransform: ca.ValueCell.create(sd.Vec4.create(0, 0, 0, 1)),
    dSubstanceType: ca.ValueCell.create("groupInstance")
  };
}
ga.createSubstance = cce;
var G7 = { array: new Uint8Array(4), width: 1, height: 1 };
function dce(e) {
  return e ? (ca.ValueCell.update(e.tSubstance, G7), ca.ValueCell.update(e.uSubstanceTexDim, sd.Vec2.create(1, 1)), e) : {
    tSubstance: ca.ValueCell.create(G7),
    uSubstanceTexDim: ca.ValueCell.create(sd.Vec2.create(1, 1)),
    dSubstance: ca.ValueCell.create(!1),
    tSubstanceGrid: ca.ValueCell.create((0, KG.createNullTexture)()),
    uSubstanceGridDim: ca.ValueCell.create(sd.Vec3.create(1, 1, 1)),
    uSubstanceGridTransform: ca.ValueCell.create(sd.Vec4.create(0, 0, 0, 1)),
    dSubstanceType: ca.ValueCell.create("groupInstance")
  };
}
ga.createEmptySubstance = dce;
var q7;
function Dt() {
  return q7 || (q7 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.Mesh = void 0;
    var r = Te, t = We(), n = Re, a = nr(), i = On, o = na, c = on, s = ru(), u = wr(), l = Le, f = ut, d = Xt, m = pa, p = $n, v = ha, h = hr, y = kn, C = ga;
    (function(S) {
      function b(X, Z, J, $, Q, W, te) {
        return te ? M(X, Z, J, $, Q, W, te) : A(X, Z, J, $, Q, W);
      }
      S.create = b;
      function g(X) {
        var Z = X ? X.vertexBuffer.ref.value : new Float32Array(0), J = X ? X.indexBuffer.ref.value : new Uint32Array(0), $ = X ? X.normalBuffer.ref.value : new Float32Array(0), Q = X ? X.groupBuffer.ref.value : new Float32Array(0);
        return b(Z, J, $, Q, 0, 0, X);
      }
      S.createEmpty = g;
      function _(X) {
        return (0, u.hashFnv32a)([
          X.vertexCount,
          X.triangleCount,
          X.vertexBuffer.ref.version,
          X.indexBuffer.ref.version,
          X.normalBuffer.ref.version,
          X.groupBuffer.ref.version
        ]);
      }
      function A(X, Z, J, $, Q, W) {
        var te = (0, a.Sphere3D)(), oe, z = -1, j = -1, ae = {
          kind: "mesh",
          vertexCount: Q,
          triangleCount: W,
          vertexBuffer: t.ValueCell.create(X),
          indexBuffer: t.ValueCell.create(Z),
          normalBuffer: t.ValueCell.create(J),
          groupBuffer: t.ValueCell.create($),
          get boundingSphere() {
            var le = _(ae);
            if (le !== z) {
              var ie = (0, f.calculateInvariantBoundingSphere)(ae.vertexBuffer.ref.value, ae.vertexCount, 1);
              a.Sphere3D.copy(te, ie), z = le;
            }
            return te;
          },
          get groupMapping() {
            return ae.groupBuffer.ref.version !== j && (oe = (0, i.createGroupMapping)(ae.groupBuffer.ref.value, ae.vertexCount), j = ae.groupBuffer.ref.version), oe;
          },
          setBoundingSphere: function(le) {
            a.Sphere3D.copy(te, le), z = _(ae);
          },
          meta: {}
        };
        return ae;
      }
      function M(X, Z, J, $, Q, W, te) {
        return te.vertexCount = Q, te.triangleCount = W, t.ValueCell.update(te.vertexBuffer, X), t.ValueCell.update(te.indexBuffer, Z), t.ValueCell.update(te.normalBuffer, J), t.ValueCell.update(te.groupBuffer, $), te;
      }
      function P(X) {
        var Z = X.vertexCount, J = X.triangleCount, $ = X.vertexBuffer.ref.value, Q = X.indexBuffer.ref.value, W = X.normalBuffer.ref.value.length >= Z * 3 ? X.normalBuffer.ref.value : new Float32Array(Z * 3);
        W === X.normalBuffer.ref.value && W.fill(0, 0, Z * 3), (0, i.computeIndexedVertexNormals)($, Q, W, Z, J), t.ValueCell.update(X.normalBuffer, W);
      }
      S.computeNormals = P;
      function T(X, Z) {
        Z === void 0 && (Z = 3);
        for (var J = X.vertexBuffer.ref.value, $ = /* @__PURE__ */ new Map(), Q = function(le, ie) {
          return "".concat(le[0].toFixed(ie), "|").concat(le[1].toFixed(ie), "|").concat(le[2].toFixed(ie));
        }, W = 0, te = (0, n.Vec3)(), oe = 0, z = X.vertexCount; oe < z; ++oe) {
          n.Vec3.fromArray(te, J, oe * 3);
          var j = Q(te, Z), ae = $.get(j);
          ae !== void 0 ? (W += 1, $.set(j, ae + 1)) : $.set(j, 1);
        }
        return W;
      }
      S.checkForDuplicateVertices = T;
      var x = (0, n.Mat3)();
      function w(X, Z) {
        var J = X.vertexBuffer.ref.value;
        if ((0, i.transformPositionArray)(Z, J, 0, X.vertexCount), !n.Mat4.isTranslationAndUniformScaling(Z)) {
          var $ = n.Mat3.directionTransform(x, Z);
          (0, i.transformDirectionArray)($, X.normalBuffer.ref.value, 0, X.vertexCount);
        }
        t.ValueCell.update(X.vertexBuffer, J);
      }
      S.transform = w;
      function E(X) {
        var Z = ("kind" in X ? X.meta : X.meta.ref.value).originalData;
        return Z;
      }
      S.getOriginalData = E;
      function I(X, Z) {
        Z === void 0 && (Z = !0);
        var J = X.indexBuffer, $ = X.vertexBuffer, Q = X.groupBuffer, W = X.normalBuffer, te = X.triangleCount, oe = X.vertexCount, z = J.ref.value, j = $.ref.value, ae = Q.ref.value, le = W.ref.value, ie = u.ChunkedArray.create(Uint32Array, 3, 1024, te), re = u.ChunkedArray.create(Float32Array, 3, 1024, j);
        re.currentIndex = oe * 3, re.elementCount = oe;
        var ee = u.ChunkedArray.create(Float32Array, 3, 1024, le);
        ee.currentIndex = oe * 3, ee.elementCount = oe;
        var ne = u.ChunkedArray.create(Float32Array, 1, 1024, ae);
        ne.currentIndex = oe, ne.elementCount = oe;
        var se = (0, n.Vec3)(), ce = (0, n.Vec3)(), de = (0, n.Vec3)(), me = (0, n.Vec3)(), he = (0, n.Vec3)(), _e = (0, n.Vec3)();
        function Se(Xe) {
          n.Vec3.fromArray(se, j, Xe * 3), n.Vec3.fromArray(me, le, Xe * 3), u.ChunkedArray.add3(re, se[0], se[1], se[2]), u.ChunkedArray.add3(ee, me[0], me[1], me[2]);
        }
        function Pe(Xe, Fe) {
          n.Vec3.fromArray(se, j, Xe * 3), n.Vec3.fromArray(ce, j, Fe * 3), n.Vec3.scale(se, n.Vec3.add(se, se, ce), 0.5), n.Vec3.fromArray(me, le, Xe * 3), n.Vec3.fromArray(he, le, Fe * 3), n.Vec3.scale(me, n.Vec3.add(me, me, he), 0.5), u.ChunkedArray.add3(re, se[0], se[1], se[2]), u.ChunkedArray.add3(ee, me[0], me[1], me[2]);
        }
        function De(Xe, Fe, He) {
          n.Vec3.fromArray(se, j, Xe * 3), n.Vec3.fromArray(ce, j, Fe * 3), n.Vec3.fromArray(de, j, He * 3), n.Vec3.scale(se, n.Vec3.add(se, n.Vec3.add(se, se, ce), de), 1 / 3), n.Vec3.fromArray(me, le, Xe * 3), n.Vec3.fromArray(he, le, Fe * 3), n.Vec3.fromArray(_e, le, He * 3), n.Vec3.scale(me, n.Vec3.add(me, n.Vec3.add(me, me, he), _e), 1 / 3), u.ChunkedArray.add3(re, se[0], se[1], se[2]), u.ChunkedArray.add3(ee, me[0], me[1], me[2]);
        }
        function Ee(Xe, Fe, He, Be, Ye) {
          ++ue, Se(Xe), Pe(Xe, Fe), Pe(Xe, He), u.ChunkedArray.add3(ie, Me, Me + 1, Me + 2);
          for (var cr = 0; cr < 3; ++cr)
            u.ChunkedArray.add(ne, Be);
          Me += 3, ue += 2, Se(Fe), Se(He), Pe(Xe, Fe), Pe(Xe, He), u.ChunkedArray.add3(ie, Me, Me + 1, Me + 3), u.ChunkedArray.add3(ie, Me, Me + 3, Me + 2);
          for (var cr = 0; cr < 4; ++cr)
            u.ChunkedArray.add(ne, Ye);
          Me += 4;
        }
        var Me = oe, ue = 0;
        if (Z)
          for (var pe = 0, Ae = te; pe < Ae; ++pe) {
            var ye = z[pe * 3], be = z[pe * 3 + 1], fe = z[pe * 3 + 2], ge = ae[ye], xe = ae[be], we = ae[fe];
            if (ge === xe && ge === we)
              ++ue, u.ChunkedArray.add3(ie, ye, be, fe);
            else if (ge === xe)
              Ee(fe, ye, be, we, ge);
            else if (ge === we)
              Ee(be, fe, ye, xe, we);
            else if (xe === we)
              Ee(ye, be, fe, ge, xe);
            else {
              ue += 2, Se(ye), Pe(ye, be), Pe(ye, fe), De(ye, be, fe), u.ChunkedArray.add3(ie, Me, Me + 1, Me + 3), u.ChunkedArray.add3(ie, Me, Me + 3, Me + 2);
              for (var Ve = 0; Ve < 4; ++Ve)
                u.ChunkedArray.add(ne, ge);
              Me += 4, ue += 2, Se(be), Pe(be, fe), Pe(be, ye), De(ye, be, fe), u.ChunkedArray.add3(ie, Me, Me + 1, Me + 3), u.ChunkedArray.add3(ie, Me, Me + 3, Me + 2);
              for (var Ve = 0; Ve < 4; ++Ve)
                u.ChunkedArray.add(ne, xe);
              Me += 4, ue += 2, Se(fe), Pe(fe, be), Pe(fe, ye), De(ye, be, fe), u.ChunkedArray.add3(ie, Me + 3, Me + 1, Me), u.ChunkedArray.add3(ie, Me + 2, Me + 3, Me);
              for (var Ve = 0; Ve < 4; ++Ve)
                u.ChunkedArray.add(ne, we);
              Me += 4;
            }
          }
        else
          for (var pe = 0, Ae = te; pe < Ae; ++pe) {
            var ye = z[pe * 3], be = z[pe * 3 + 1], fe = z[pe * 3 + 2], ge = ae[ye], xe = ae[be], we = ae[fe];
            if (ge !== xe || ge !== we) {
              ++ue, Se(ye), Se(be), Se(fe), u.ChunkedArray.add3(ie, Me, Me + 1, Me + 2);
              for (var Ne = xe === we ? xe : ge, Ve = 0; Ve < 3; ++Ve)
                u.ChunkedArray.add(ne, Ne);
              Me += 3;
            } else
              ++ue, u.ChunkedArray.add3(ie, ye, be, fe);
          }
        var Oe = u.ChunkedArray.compact(ie), ze = u.ChunkedArray.compact(re), ke = u.ChunkedArray.compact(ee), je = u.ChunkedArray.compact(ne);
        return X.vertexCount = Me, X.triangleCount = ue, t.ValueCell.update($, ze), t.ValueCell.update(Q, je), t.ValueCell.update(J, Oe), t.ValueCell.update(W, ke), X.meta.originalData = { indexBuffer: z, vertexCount: oe, triangleCount: te }, X;
      }
      S.uniformTriangleGroup = I;
      function B(X) {
        for (var Z = X.vertexCount, J = X.triangleCount, $ = X.indexBuffer.ref.value, Q = [], W = 0; W < Z; ++W)
          Q[W] = [];
        for (var W = 0; W < J; ++W) {
          var te = $[W * 3], oe = $[W * 3 + 1], z = $[W * 3 + 2];
          (0, h.arraySetAdd)(Q[te], oe), (0, h.arraySetAdd)(Q[te], z), (0, h.arraySetAdd)(Q[oe], te), (0, h.arraySetAdd)(Q[oe], z), (0, h.arraySetAdd)(Q[z], te), (0, h.arraySetAdd)(Q[z], oe);
        }
        return Q;
      }
      function D(X) {
        for (var Z = X.triangleCount, J = X.indexBuffer.ref.value, $ = /* @__PURE__ */ new Map(), Q = function(j, ae) {
          var le = (0, u.sortedCantorPairing)(j, ae), ie = $.get(le) || 0;
          $.set(le, ie + 1);
        }, W = 0; W < Z; ++W) {
          var te = J[W * 3], oe = J[W * 3 + 1], z = J[W * 3 + 2];
          Q(te, oe), Q(te, z), Q(oe, z);
        }
        return $;
      }
      function N(X) {
        var Z = /* @__PURE__ */ new Set(), J = [0, 0];
        return X.forEach(function($, Q) {
          $ === 1 && ((0, u.invertCantorPairing)(J, Q), Z.add(J[0]), Z.add(J[1]));
        }), Z;
      }
      function O(X, Z, J) {
        var $ = /* @__PURE__ */ new Map(), Q = function(W, te) {
          $.has(W) ? (0, h.arraySetAdd)($.get(W), te) : $.set(W, [te]);
        };
        return Z.forEach(function(W) {
          for (var te = X[W], oe = 0, z = te; oe < z.length; oe++) {
            var j = z[oe];
            Z.has(j) && J.get((0, u.sortedCantorPairing)(W, j)) === 1 && Q(W, j);
          }
        }), $;
      }
      function V(X, Z) {
        for (var J = X.indexBuffer, $ = X.triangleCount, Q = J.ref.value, W = u.ChunkedArray.create(Uint32Array, 3, 1024, $), te = 0, oe = 0; oe < $; ++oe) {
          var z = Q[oe * 3], j = Q[oe * 3 + 1], ae = Q[oe * 3 + 2];
          Z[z].length === 2 || Z[j].length === 2 || Z[ae].length === 2 || (u.ChunkedArray.add3(W, z, j, ae), te += 1);
        }
        var le = u.ChunkedArray.compact(W);
        return X.triangleCount = te, t.ValueCell.update(J, le), X;
      }
      function k(X, Z, J, $) {
        for (var Q, W = X.vertexBuffer, te = X.indexBuffer, oe = X.normalBuffer, z = X.triangleCount, j = W.ref.value, ae = te.ref.value, le = oe.ref.value, ie = u.ChunkedArray.create(Uint32Array, 3, 1024, z), re = 0, ee = 0; ee < z; ++ee)
          u.ChunkedArray.add3(ie, ae[ee * 3], ae[ee * 3 + 1], ae[ee * 3 + 2]), re += 1;
        var ne = (0, n.Vec3)(), se = (0, n.Vec3)(), ce = (0, n.Vec3)(), de = (0, n.Vec3)(), me = (0, n.Vec3)(), he = (0, n.Vec3)(), _e = (0, n.Vec3)(), Se = (0, n.Vec3)(), Pe = (0, n.Vec3)(), De = (0, n.Vec3)(), Ee = (0, y.degToRad)(120), Me = /* @__PURE__ */ new Set(), ue = Array.from(J.keys()).filter(function(ze) {
          return J.get(ze).length < 2;
        }).map(function(ze) {
          var ke = J.get(ze);
          return n.Vec3.fromArray(ne, j, ze * 3), n.Vec3.fromArray(se, j, ke[0] * 3), n.Vec3.fromArray(ce, j, ke[1] * 3), n.Vec3.sub(me, se, ne), n.Vec3.sub(he, ce, ne), [ze, n.Vec3.angle(me, he)];
        });
        ue.sort(function(ze, ke) {
          var je = ze[1], Xe = ke[1];
          return je - Xe;
        });
        for (var pe = 0, Ae = ue; pe < Ae.length; pe++) {
          var ye = Ae[pe], be = ye[0], fe = ye[1];
          if (!(Me.has(be) || fe > Ee)) {
            var ge = J.get(be);
            if (!(Z[ge[0]].includes(ge[1]) && !(!((Q = J.get(ge[0])) === null || Q === void 0) && Q.includes(ge[1]))) && (n.Vec3.fromArray(ne, j, be * 3), n.Vec3.fromArray(se, j, ge[0] * 3), n.Vec3.fromArray(ce, j, ge[1] * 3), n.Vec3.sub(me, se, ne), n.Vec3.sub(he, ce, ne), n.Vec3.add(Se, me, he), !(n.Vec3.squaredDistance(ne, se) >= $))) {
              for (var xe = !1, we = 0, Ve = Z[be]; we < Ve.length; we++) {
                var Ne = Ve[we];
                if (!ge.includes(Ne) && (n.Vec3.fromArray(de, j, Ne * 3), n.Vec3.sub(_e, de, ne), n.Vec3.dot(Se, _e) < 0)) {
                  xe = !0;
                  break;
                }
              }
              xe && (n.Vec3.fromArray(Pe, le, be * 3), n.Vec3.triangleNormal(De, ne, se, ce), n.Vec3.dot(De, Pe) > 0 ? u.ChunkedArray.add3(ie, be, ge[0], ge[1]) : u.ChunkedArray.add3(ie, ge[1], ge[0], be), Me.add(be), Me.add(ge[0]), Me.add(ge[1]), re += 1);
            }
          }
        }
        var Oe = u.ChunkedArray.compact(ie);
        return X.triangleCount = re, t.ValueCell.update(te, Oe), X;
      }
      function G(X, Z, J) {
        for (var $ = J.iterations, Q = J.lambda, W = (0, n.Vec3)(), te = (0, n.Vec3)(), oe = (0, n.Vec3)(), z = (0, n.Vec3)(), j = -Q, ae = new Float32Array(X.vertexBuffer.ref.value.length), le = function(re) {
          var ee = X.vertexBuffer.ref.value;
          ae.set(ee), Z.forEach(function(se, ce) {
            if (se.length === 2) {
              n.Vec3.fromArray(W, ee, ce * 3), n.Vec3.fromArray(te, ee, se[0] * 3), n.Vec3.fromArray(oe, ee, se[1] * 3);
              var de = 1 / n.Vec3.distance(W, te), me = 1 / n.Vec3.distance(W, oe);
              n.Vec3.scale(te, te, de), n.Vec3.scale(oe, oe, me), n.Vec3.add(z, te, oe), n.Vec3.scale(z, z, 1 / (de + me)), n.Vec3.sub(z, z, W), n.Vec3.scale(z, z, re), n.Vec3.add(z, W, z), n.Vec3.toArray(z, ae, ce * 3);
            }
          });
          var ne = X.vertexBuffer.ref.value;
          t.ValueCell.update(X.vertexBuffer, ae), ae = ne;
        }, ie = 0; ie < $; ++ie)
          le(Q), le(j);
      }
      function L(X, Z) {
        V(X, B(X));
        for (var J = 0; J < 10; ++J) {
          var $ = X.triangleCount, Q = D(X), W = B(X), te = N(Q), oe = O(W, te, Q);
          if (k(X, W, oe, Z.maxNewEdgeLength * Z.maxNewEdgeLength), X.triangleCount === $)
            break;
        }
        var z = D(X), j = B(X), ae = N(z), le = O(j, ae, z);
        return G(X, le, { iterations: Z.iterations, lambda: 0.5 }), X;
      }
      S.smoothEdges = L, S.Params = (0, r.__assign)((0, r.__assign)({}, d.BaseGeometry.Params), { doubleSided: l.ParamDefinition.Boolean(!1, d.BaseGeometry.CustomQualityParamInfo), flipSided: l.ParamDefinition.Boolean(!1, d.BaseGeometry.ShadingCategory), flatShaded: l.ParamDefinition.Boolean(!1, d.BaseGeometry.ShadingCategory), ignoreLight: l.ParamDefinition.Boolean(!1, d.BaseGeometry.ShadingCategory), xrayShaded: l.ParamDefinition.Boolean(!1, d.BaseGeometry.ShadingCategory), bumpFrequency: l.ParamDefinition.Numeric(0, { min: 0, max: 10, step: 0.1 }, d.BaseGeometry.ShadingCategory), bumpAmplitude: l.ParamDefinition.Numeric(1, { min: 0, max: 5, step: 0.1 }, d.BaseGeometry.ShadingCategory) }), S.Utils = {
        Params: S.Params,
        createEmpty: g,
        createValues: F,
        createValuesSimple: U,
        updateValues: H,
        updateBoundingSphere: q,
        createRenderableState: K,
        updateRenderableState: Y,
        createPositionIterator: R
      };
      function R(X, Z) {
        var J = X.vertexCount, $ = Z.instanceCount.ref.value, Q = (0, c.PositionLocation)(), W = Q.position, te = X.vertexBuffer.ref.value, oe = Z.aTransform.ref.value, z = function(j, ae) {
          return ae < 0 ? n.Vec3.fromArray(W, te, j * 3) : n.Vec3.transformMat4Offset(W, te, oe, 0, j * 3, ae * 16), Q;
        };
        return (0, c.LocationIterator)(J, $, 1, z);
      }
      function F(X, Z, J, $, Q) {
        var W = J.instanceCount, te = J.groupCount, oe = R(X, Z), z = (0, s.createColors)(J, oe, $.color), j = (0, o.createMarkers)(W * te), ae = (0, m.createEmptyOverpaint)(), le = (0, p.createEmptyTransparency)(), ie = (0, C.createEmptySubstance)(), re = (0, v.createEmptyClipping)(), ee = { drawCount: X.triangleCount * 3, vertexCount: X.vertexCount, groupCount: te, instanceCount: W }, ne = a.Sphere3D.clone(X.boundingSphere), se = (0, f.calculateTransformBoundingSphere)(ne, Z.aTransform.ref.value, W);
        return (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({ dGeometryType: t.ValueCell.create("mesh"), aPosition: X.vertexBuffer, aNormal: X.normalBuffer, aGroup: X.groupBuffer, elements: X.indexBuffer, boundingSphere: t.ValueCell.create(se), invariantBoundingSphere: t.ValueCell.create(ne), uInvariantBoundingSphere: t.ValueCell.create(n.Vec4.ofSphere(ne)) }, z), j), ae), le), ie), re), Z), d.BaseGeometry.createValues(Q, ee)), { uDoubleSided: t.ValueCell.create(Q.doubleSided), dFlatShaded: t.ValueCell.create(Q.flatShaded), dFlipSided: t.ValueCell.create(Q.flipSided), dIgnoreLight: t.ValueCell.create(Q.ignoreLight), dXrayShaded: t.ValueCell.create(Q.xrayShaded), uBumpFrequency: t.ValueCell.create(Q.bumpFrequency), uBumpAmplitude: t.ValueCell.create(Q.bumpAmplitude), meta: t.ValueCell.create(X.meta) });
      }
      function U(X, Z, J, $, Q) {
        var W = d.BaseGeometry.createSimple(J, $, Q), te = (0, r.__assign)((0, r.__assign)({}, l.ParamDefinition.getDefaultValues(S.Params)), Z);
        return F(X, W.transform, W.locationIterator, W.theme, te);
      }
      function H(X, Z) {
        d.BaseGeometry.updateValues(X, Z), t.ValueCell.updateIfChanged(X.uDoubleSided, Z.doubleSided), t.ValueCell.updateIfChanged(X.dFlatShaded, Z.flatShaded), t.ValueCell.updateIfChanged(X.dFlipSided, Z.flipSided), t.ValueCell.updateIfChanged(X.dIgnoreLight, Z.ignoreLight), t.ValueCell.updateIfChanged(X.dXrayShaded, Z.xrayShaded), t.ValueCell.updateIfChanged(X.uBumpFrequency, Z.bumpFrequency), t.ValueCell.updateIfChanged(X.uBumpAmplitude, Z.bumpAmplitude);
      }
      function q(X, Z) {
        var J = a.Sphere3D.clone(Z.boundingSphere), $ = (0, f.calculateTransformBoundingSphere)(J, X.aTransform.ref.value, X.instanceCount.ref.value);
        a.Sphere3D.equals($, X.boundingSphere.ref.value) || t.ValueCell.update(X.boundingSphere, $), a.Sphere3D.equals(J, X.invariantBoundingSphere.ref.value) || (t.ValueCell.update(X.invariantBoundingSphere, J), t.ValueCell.update(X.uInvariantBoundingSphere, n.Vec4.fromSphere(X.uInvariantBoundingSphere.ref.value, J)));
      }
      function K(X) {
        var Z = d.BaseGeometry.createRenderableState(X);
        return Y(Z, X), Z;
      }
      function Y(X, Z) {
        d.BaseGeometry.updateRenderableState(X, Z), X.opaque = X.opaque && !Z.xrayShaded, X.writeDepth = X.opaque;
      }
    })(e.Mesh || (e.Mesh = {}));
  }(w5)), w5;
}
var D5 = {}, I5 = {}, ts = {};
Object.defineProperty(ts, "__esModule", { value: !0 });
ts.unpackRGBAToDepth = ts.unpackRGBToInt = ts.packIntToRGBArray = void 0;
var fce = Zr, Mg = Re;
function mce(e, r, t) {
  return e = (0, fce.clamp)(Math.round(e), 0, 16777215) + 1, r[t + 2] = e % 256, e = Math.floor(e / 256), r[t + 1] = e % 256, e = Math.floor(e / 256), r[t] = e % 256, r;
}
ts.packIntToRGBArray = mce;
function vce(e, r, t) {
  return Math.floor(e) * 256 * 256 + Math.floor(r) * 256 + Math.floor(t) - 1;
}
ts.unpackRGBToInt = vce;
var b2 = 255 / 256, B5 = Mg.Vec3.create(256 * 256 * 256, 256 * 256, 256), pce = Mg.Vec4.create(b2 / B5[0], b2 / B5[1], b2 / B5[2], b2 / 1), H7 = (0, Mg.Vec4)();
function hce(e, r, t, n) {
  return Mg.Vec4.set(H7, e / 255, r / 255, t / 255, n / 255), Mg.Vec4.dot(H7, pce);
}
ts.unpackRGBAToDepth = hce;
var j7;
function Tc() {
  return j7 || (j7 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.createGroupInstanceSize = e.createGroupSize = e.createInstanceSize = e.createTextureSize = e.createUniformSize = e.createValueSize = e.getMaxSize = e.sizeDataFactor = e.createSizes = void 0;
    var r = Te, t = We(), n = Re, a = ut, i = Ja, o = Kd(), c = ts;
    function s(C, S, b) {
      switch (o.Geometry.getGranularity(C, S.granularity)) {
        case "uniform":
          return m(C, S.size, b);
        case "group":
          return h(C, S.size, b);
        case "groupInstance":
          return y(C, S.size, b);
        case "instance":
          return v(C, S.size, b);
      }
    }
    e.createSizes = s, e.sizeDataFactor = 100;
    function u(C) {
      var S = C.dSizeType.ref.value;
      switch (S) {
        case "uniform":
          return C.uSize.ref.value;
        case "instance":
        case "group":
        case "groupInstance":
          for (var b = 0, g = C.tSize.ref.value.array, _ = 0, A = g.length; _ < A; _ += 3) {
            var M = (0, c.unpackRGBToInt)(g[_], g[_ + 1], g[_ + 2]);
            b < M && (b = M);
          }
          return b / e.sizeDataFactor;
      }
    }
    e.getMaxSize = u;
    var l = { array: new Uint8Array(3), width: 1, height: 1 };
    function f() {
      return {
        tSize: t.ValueCell.create(l),
        uSizeTexDim: t.ValueCell.create(n.Vec2.create(1, 1))
      };
    }
    function d(C, S) {
      return S ? (t.ValueCell.update(S.uSize, C), t.ValueCell.updateIfChanged(S.dSizeType, "uniform"), S) : (0, r.__assign)((0, r.__assign)({ uSize: t.ValueCell.create(C) }, f()), { dSizeType: t.ValueCell.create("uniform") });
    }
    e.createValueSize = d;
    function m(C, S, b) {
      return d(S(i.NullLocation), b);
    }
    e.createUniformSize = m;
    function p(C, S, b) {
      return b ? (t.ValueCell.update(b.tSize, C), t.ValueCell.update(b.uSizeTexDim, n.Vec2.create(C.width, C.height)), t.ValueCell.updateIfChanged(b.dSizeType, S), b) : {
        uSize: t.ValueCell.create(0),
        tSize: t.ValueCell.create(C),
        uSizeTexDim: t.ValueCell.create(n.Vec2.create(C.width, C.height)),
        dSizeType: t.ValueCell.create(S)
      };
    }
    e.createTextureSize = p;
    function v(C, S, b) {
      var g = C.instanceCount, _ = (0, a.createTextureImage)(Math.max(1, g), 3, Uint8Array, b && b.tSize.ref.value.array);
      for (C.reset(); C.hasNext && !C.isNextNewInstance; ) {
        var A = C.move();
        (0, c.packIntToRGBArray)(S(A.location) * e.sizeDataFactor, _.array, A.instanceIndex * 3), C.skipInstance();
      }
      return p(_, "instance", b);
    }
    e.createInstanceSize = v;
    function h(C, S, b) {
      var g = C.groupCount, _ = (0, a.createTextureImage)(Math.max(1, g), 3, Uint8Array, b && b.tSize.ref.value.array);
      for (C.reset(); C.hasNext && !C.isNextNewInstance; ) {
        var A = C.move();
        (0, c.packIntToRGBArray)(S(A.location) * e.sizeDataFactor, _.array, A.groupIndex * 3);
      }
      return p(_, "group", b);
    }
    e.createGroupSize = h;
    function y(C, S, b) {
      var g = C.groupCount, _ = C.instanceCount, A = _ * g, M = (0, a.createTextureImage)(Math.max(1, A), 3, Uint8Array, b && b.tSize.ref.value.array);
      for (C.reset(); C.hasNext; ) {
        var P = C.move();
        (0, c.packIntToRGBArray)(S(P.location) * e.sizeDataFactor, M.array, P.index * 3);
      }
      return p(M, "groupInstance", b);
    }
    e.createGroupInstanceSize = y;
  }(I5)), I5;
}
var $7;
function hy() {
  return $7 || ($7 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.Points = void 0;
    var r = Te, t = We(), n = Re, a = On, i = ru(), o = na, c = Tc(), s = on, u = Le, l = ut, f = nr(), d = Xt, m = pa, p = $n, v = wr(), h = ha, y = ga;
    (function(C) {
      function S(D, N, O, V) {
        return V ? A(D, N, O, V) : _(D, N, O);
      }
      C.create = S;
      function b(D) {
        var N = D ? D.centerBuffer.ref.value : new Float32Array(0), O = D ? D.groupBuffer.ref.value : new Float32Array(0);
        return S(N, O, 0, D);
      }
      C.createEmpty = b;
      function g(D) {
        return (0, v.hashFnv32a)([
          D.pointCount,
          D.centerBuffer.ref.version,
          D.groupBuffer.ref.version
        ]);
      }
      function _(D, N, O) {
        var V = (0, f.Sphere3D)(), k, G = -1, L = -1, R = {
          kind: "points",
          pointCount: O,
          centerBuffer: t.ValueCell.create(D),
          groupBuffer: t.ValueCell.create(N),
          get boundingSphere() {
            var F = g(R);
            if (F !== G) {
              var U = (0, l.calculateInvariantBoundingSphere)(R.centerBuffer.ref.value, R.pointCount, 1);
              f.Sphere3D.copy(V, U), G = F;
            }
            return V;
          },
          get groupMapping() {
            return R.groupBuffer.ref.version !== L && (k = (0, a.createGroupMapping)(R.groupBuffer.ref.value, R.pointCount), L = R.groupBuffer.ref.version), k;
          },
          setBoundingSphere: function(F) {
            f.Sphere3D.copy(V, F), G = g(R);
          }
        };
        return R;
      }
      function A(D, N, O, V) {
        return V.pointCount = O, t.ValueCell.update(V.centerBuffer, D), t.ValueCell.update(V.groupBuffer, N), V;
      }
      function M(D, N) {
        var O = D.centerBuffer.ref.value;
        (0, a.transformPositionArray)(N, O, 0, D.pointCount), t.ValueCell.update(D.centerBuffer, O);
      }
      C.transform = M, C.StyleTypes = {
        square: "Square",
        circle: "Circle",
        fuzzy: "Fuzzy"
      }, C.StyleTypeNames = Object.keys(C.StyleTypes), C.Params = (0, r.__assign)((0, r.__assign)({}, d.BaseGeometry.Params), { sizeFactor: u.ParamDefinition.Numeric(3, { min: 0, max: 10, step: 0.1 }), pointSizeAttenuation: u.ParamDefinition.Boolean(!1), pointStyle: u.ParamDefinition.Select("square", u.ParamDefinition.objectToOptions(C.StyleTypes)) }), C.Utils = {
        Params: C.Params,
        createEmpty: b,
        createValues: T,
        createValuesSimple: x,
        updateValues: w,
        updateBoundingSphere: E,
        createRenderableState: I,
        updateRenderableState: B,
        createPositionIterator: P
      };
      function P(D, N) {
        var O = D.pointCount, V = N.instanceCount.ref.value, k = (0, s.PositionLocation)(), G = k.position, L = D.centerBuffer.ref.value, R = N.aTransform.ref.value, F = function(U, H) {
          return H < 0 ? n.Vec3.fromArray(G, L, U * 3) : n.Vec3.transformMat4Offset(G, L, R, 0, U * 3, H * 16), k;
        };
        return (0, s.LocationIterator)(O, V, 1, F);
      }
      function T(D, N, O, V, k) {
        var G = O.instanceCount, L = O.groupCount, R = P(D, N), F = (0, i.createColors)(O, R, V.color), U = (0, c.createSizes)(O, V.size), H = (0, o.createMarkers)(G * L), q = (0, m.createEmptyOverpaint)(), K = (0, p.createEmptyTransparency)(), Y = (0, y.createEmptySubstance)(), X = (0, h.createEmptyClipping)(), Z = { drawCount: D.pointCount, vertexCount: D.pointCount, groupCount: L, instanceCount: G }, J = f.Sphere3D.clone(D.boundingSphere), $ = (0, l.calculateTransformBoundingSphere)(J, N.aTransform.ref.value, G);
        return (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({ dGeometryType: t.ValueCell.create("points"), aPosition: D.centerBuffer, aGroup: D.groupBuffer, boundingSphere: t.ValueCell.create($), invariantBoundingSphere: t.ValueCell.create(J), uInvariantBoundingSphere: t.ValueCell.create(n.Vec4.ofSphere(J)) }, F), U), H), q), K), Y), X), N), d.BaseGeometry.createValues(k, Z)), { uSizeFactor: t.ValueCell.create(k.sizeFactor), dPointSizeAttenuation: t.ValueCell.create(k.pointSizeAttenuation), dPointStyle: t.ValueCell.create(k.pointStyle) });
      }
      function x(D, N, O, V, k) {
        var G = d.BaseGeometry.createSimple(O, V, k), L = (0, r.__assign)((0, r.__assign)({}, u.ParamDefinition.getDefaultValues(C.Params)), N);
        return T(D, G.transform, G.locationIterator, G.theme, L);
      }
      function w(D, N) {
        d.BaseGeometry.updateValues(D, N), t.ValueCell.updateIfChanged(D.uSizeFactor, N.sizeFactor), t.ValueCell.updateIfChanged(D.dPointSizeAttenuation, N.pointSizeAttenuation), t.ValueCell.updateIfChanged(D.dPointStyle, N.pointStyle);
      }
      function E(D, N) {
        var O = f.Sphere3D.clone(N.boundingSphere), V = (0, l.calculateTransformBoundingSphere)(O, D.aTransform.ref.value, D.instanceCount.ref.value);
        f.Sphere3D.equals(V, D.boundingSphere.ref.value) || t.ValueCell.update(D.boundingSphere, V), f.Sphere3D.equals(O, D.invariantBoundingSphere.ref.value) || (t.ValueCell.update(D.invariantBoundingSphere, O), t.ValueCell.update(D.uInvariantBoundingSphere, n.Vec4.fromSphere(D.uInvariantBoundingSphere.ref.value, O)));
      }
      function I(D) {
        var N = d.BaseGeometry.createRenderableState(D);
        return B(N, D), N;
      }
      function B(D, N) {
        d.BaseGeometry.updateRenderableState(D, N), D.opaque = D.opaque && N.pointStyle !== "fuzzy", D.writeDepth = D.opaque;
      }
    })(e.Points || (e.Points = {}));
  }(D5)), D5;
}
var N5 = {}, RE = {}, s4 = {};
Object.defineProperty(s4, "__esModule", { value: !0 });
s4.edt = void 0;
function gce(e, r, t, n, a, i, o) {
  for (var c = 0; c < r; c++) {
    for (var s = 0; s < t; s++)
      n[s] = e[s * r + c];
    K7(n, a, i, o, t);
    for (var s = 0; s < t; s++)
      e[s * r + c] = a[s];
  }
  for (var s = 0; s < t; s++) {
    for (var c = 0; c < r; c++)
      n[c] = e[s * r + c];
    K7(n, a, i, o, r);
    for (var c = 0; c < r; c++)
      e[s * r + c] = Math.sqrt(a[c]);
  }
}
s4.edt = gce;
function K7(e, r, t, n, a) {
  t[0] = 0, n[0] = Number.MIN_SAFE_INTEGER, n[1] = Number.MAX_SAFE_INTEGER;
  for (var i = 1, o = 0; i < a; i++) {
    for (var c = (e[i] + i * i - (e[t[o]] + t[o] * t[o])) / (2 * i - 2 * t[o]); c <= n[o]; )
      o--, c = (e[i] + i * i - (e[t[o]] + t[o] * t[o])) / (2 * i - 2 * t[o]);
    o++, t[o] = i, n[o] = c, n[o + 1] = Number.MAX_SAFE_INTEGER;
  }
  for (var i = 0, o = 0; i < a; i++) {
    for (; n[o + 1] < i; )
      o++;
    r[i] = (i - t[o]) * (i - t[o]) + e[t[o]];
  }
}
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.FontAtlas = e.FontAtlasParams = e.getFontAtlas = void 0;
  var r = Te, t = Le, n = s4, a = ut, i = {};
  function o(s) {
    var u = JSON.stringify(s);
    return i[u] === void 0 && (i[u] = new c(s)), i[u];
  }
  e.getFontAtlas = o, e.FontAtlasParams = {
    fontFamily: t.ParamDefinition.Select("sans-serif", [["sans-serif", "Sans Serif"], ["monospace", "Monospace"], ["serif", "Serif"], ["cursive", "Cursive"]]),
    fontQuality: t.ParamDefinition.Select(3, [[0, "lower"], [1, "low"], [2, "medium"], [3, "high"], [4, "higher"]]),
    fontStyle: t.ParamDefinition.Select("normal", [["normal", "Normal"], ["italic", "Italic"], ["oblique", "Oblique"]]),
    fontVariant: t.ParamDefinition.Select("normal", [["normal", "Normal"], ["small-caps", "Small Caps"]]),
    fontWeight: t.ParamDefinition.Select("normal", [["normal", "Normal"], ["bold", "Bold"]])
  };
  var c = (
    /** @class */
    function() {
      function s(u) {
        u === void 0 && (u = {}), this.mapped = {}, this.scratchW = 0, this.scratchH = 0, this.currentX = 0, this.currentY = 0, this.cutoff = 0.5;
        var l = (0, r.__assign)((0, r.__assign)({}, t.ParamDefinition.getDefaultValues(e.FontAtlasParams)), u);
        this.props = l;
        var f = 32 * (l.fontQuality + 1);
        this.buffer = f / 8, this.radius = f / 3, this.lineHeight = Math.round(f + 2 * this.buffer + this.radius), this.maxWidth = Math.round(this.lineHeight * 0.75), this.texture = (0, a.createTextureImage)(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(l.fontStyle, " ").concat(l.fontVariant, " ").concat(l.fontWeight, " ").concat(f, "px ").concat(l.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 s.prototype.get = function(u) {
        if (this.mapped[u] === void 0) {
          this.draw(u);
          var l = this.texture, f = l.array, d = l.width, m = l.height, p = this.scratchData;
          if (this.currentX + this.scratchW > d && (this.currentX = 0, this.currentY += this.scratchH), this.currentY + this.scratchH > m)
            return console.warn("canvas to small"), this.placeholder;
          this.mapped[u] = {
            x: this.currentX,
            y: this.currentY,
            w: this.scratchW,
            h: this.scratchH,
            nw: this.scratchW / this.lineHeight,
            nh: this.scratchH / this.lineHeight
          };
          for (var v = 0; v < this.scratchH; ++v)
            for (var h = 0; h < this.scratchW; ++h)
              f[d * (this.currentY + v) + this.currentX + h] = p[v * this.scratchW + h];
          this.currentX += this.scratchW;
        }
        return this.mapped[u];
      }, s.prototype.draw = function(u) {
        var l = this.lineHeight, f = this.scratchContext, d = this.scratchData, m = f.measureText(u), p = Math.min(this.maxWidth, Math.ceil(m.width + 2 * this.buffer)), v = p * l;
        f.clearRect(0, 0, p, l), f.fillText(u, this.buffer, this.middle);
        for (var h = f.getImageData(0, 0, p, l), y = 0; y < v; y++) {
          var C = h.data[y * 4 + 3] / 255;
          this.gridOuter[y] = C === 1 ? 0 : C === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - C), 2), this.gridInner[y] = C === 1 ? Number.MAX_SAFE_INTEGER : C === 0 ? 0 : Math.pow(Math.max(0, C - 0.5), 2);
        }
        (0, n.edt)(this.gridOuter, p, l, this.f, this.d, this.v, this.z), (0, n.edt)(this.gridInner, p, l, this.f, this.d, this.v, this.z);
        for (var y = 0; y < v; y++) {
          var S = this.gridOuter[y] - this.gridInner[y];
          d[y] = Math.max(0, Math.min(255, Math.round(255 - 255 * (S / this.radius + this.cutoff))));
        }
        this.scratchW = p, this.scratchH = l;
      }, s;
    }()
  );
  e.FontAtlas = c;
})(RE);
var W7;
function bs() {
  return W7 || (W7 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.Text = void 0;
    var r = Te, t = Le, n = We(), a = on, i = ru(), o = Tc(), c = na, s = Oa, u = nr(), l = ut, f = Tr(), d = Re, m = RE, p = Zr, v = Xt, h = pa, y = $n, C = wr(), S = On, b = ha, g = ga;
    (function(A) {
      function M(k, G, L, R, F, U, H, q, K) {
        return K ? w(k, G, L, R, F, U, H, q, K) : x(k, G, L, R, F, U, H, q);
      }
      A.create = M;
      function P(k) {
        var G = k ? k.fontTexture.ref.value : (0, l.createTextureImage)(0, 1, Uint8Array), L = k ? k.centerBuffer.ref.value : new Float32Array(0), R = k ? k.mappingBuffer.ref.value : new Float32Array(0), F = k ? k.depthBuffer.ref.value : new Float32Array(0), U = k ? k.indexBuffer.ref.value : new Uint32Array(0), H = k ? k.groupBuffer.ref.value : new Float32Array(0), q = k ? k.tcoordBuffer.ref.value : new Float32Array(0);
        return M(G, L, R, F, U, H, q, 0, k);
      }
      A.createEmpty = P;
      function T(k) {
        return (0, C.hashFnv32a)([
          k.charCount,
          k.fontTexture.ref.version,
          k.centerBuffer.ref.version,
          k.mappingBuffer.ref.version,
          k.depthBuffer.ref.version,
          k.indexBuffer.ref.version,
          k.groupBuffer.ref.version,
          k.tcoordBuffer.ref.version
        ]);
      }
      function x(k, G, L, R, F, U, H, q) {
        var K = (0, u.Sphere3D)(), Y, X = -1, Z = -1, J = {
          kind: "text",
          charCount: q,
          fontTexture: n.ValueCell.create(k),
          centerBuffer: n.ValueCell.create(G),
          mappingBuffer: n.ValueCell.create(L),
          depthBuffer: n.ValueCell.create(R),
          indexBuffer: n.ValueCell.create(F),
          groupBuffer: n.ValueCell.create(U),
          tcoordBuffer: n.ValueCell.create(H),
          get boundingSphere() {
            var $ = T(J);
            if ($ !== X) {
              var Q = (0, l.calculateInvariantBoundingSphere)(J.centerBuffer.ref.value, J.charCount * 4, 4);
              u.Sphere3D.copy(K, Q), X = $;
            }
            return K;
          },
          get groupMapping() {
            return J.groupBuffer.ref.version !== Z && (Y = (0, S.createGroupMapping)(J.groupBuffer.ref.value, J.charCount, 4), Z = J.groupBuffer.ref.version), Y;
          },
          setBoundingSphere: function($) {
            u.Sphere3D.copy(K, $), X = T(J);
          }
        };
        return J;
      }
      function w(k, G, L, R, F, U, H, q, K) {
        return K.charCount = q, n.ValueCell.update(K.fontTexture, k), n.ValueCell.update(K.centerBuffer, G), n.ValueCell.update(K.mappingBuffer, L), n.ValueCell.update(K.depthBuffer, R), n.ValueCell.update(K.indexBuffer, F), n.ValueCell.update(K.groupBuffer, U), n.ValueCell.update(K.tcoordBuffer, H), K;
      }
      A.Params = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, v.BaseGeometry.Params), m.FontAtlasParams), { sizeFactor: t.ParamDefinition.Numeric(1, { min: 0, max: 10, step: 0.1 }), borderWidth: t.ParamDefinition.Numeric(0, { min: 0, max: 0.5, step: 0.01 }), borderColor: t.ParamDefinition.Color(s.ColorNames.grey), offsetX: t.ParamDefinition.Numeric(0, { min: 0, max: 10, step: 0.1 }), offsetY: t.ParamDefinition.Numeric(0, { min: 0, max: 10, step: 0.1 }), offsetZ: t.ParamDefinition.Numeric(0, { min: 0, max: 10, step: 0.1 }), background: t.ParamDefinition.Boolean(!1), backgroundMargin: t.ParamDefinition.Numeric(0.2, { min: 0, max: 1, step: 0.01 }), backgroundColor: t.ParamDefinition.Color(s.ColorNames.grey), backgroundOpacity: t.ParamDefinition.Numeric(1, { min: 0, max: 1, step: 0.01 }), tether: t.ParamDefinition.Boolean(!1), tetherLength: t.ParamDefinition.Numeric(1, { min: 0, max: 5, step: 0.1 }), tetherBaseWidth: t.ParamDefinition.Numeric(0.3, { min: 0, max: 1, step: 0.01 }), attachment: t.ParamDefinition.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"]
      ]) }), A.Utils = {
        Params: A.Params,
        createEmpty: P,
        createValues: I,
        createValuesSimple: B,
        updateValues: D,
        updateBoundingSphere: N,
        createRenderableState: O,
        updateRenderableState: V,
        createPositionIterator: E
      };
      function E(k, G) {
        var L = k.charCount * 4, R = G.instanceCount.ref.value, F = (0, a.PositionLocation)(), U = F.position, H = k.centerBuffer.ref.value, q = G.aTransform.ref.value, K = function(Y, X) {
          return X < 0 ? d.Vec3.fromArray(U, H, Y * 3) : d.Vec3.transformMat4Offset(U, H, q, 0, Y * 3, X * 16), F;
        };
        return (0, a.LocationIterator)(L, R, 4, K);
      }
      function I(k, G, L, R, F) {
        var U = L.instanceCount, H = L.groupCount, q = E(k, G), K = (0, i.createColors)(L, q, R.color), Y = (0, o.createSizes)(L, R.size), X = (0, c.createMarkers)(U * H), Z = (0, h.createEmptyOverpaint)(), J = (0, y.createEmptyTransparency)(), $ = (0, g.createEmptySubstance)(), Q = (0, b.createEmptyClipping)(), W = { drawCount: k.charCount * 2 * 3, vertexCount: k.charCount * 4, groupCount: H, instanceCount: U }, te = _(k.mappingBuffer.ref.value, k.depthBuffer.ref.value, k.charCount, (0, o.getMaxSize)(Y)), oe = u.Sphere3D.expand((0, u.Sphere3D)(), k.boundingSphere, te), z = (0, l.calculateTransformBoundingSphere)(oe, G.aTransform.ref.value, U);
        return (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({ dGeometryType: n.ValueCell.create("text"), aPosition: k.centerBuffer, aMapping: k.mappingBuffer, aDepth: k.depthBuffer, aGroup: k.groupBuffer, elements: k.indexBuffer, boundingSphere: n.ValueCell.create(z), invariantBoundingSphere: n.ValueCell.create(oe), uInvariantBoundingSphere: n.ValueCell.create(d.Vec4.ofSphere(oe)) }, K), Y), X), Z), J), $), Q), G), { aTexCoord: k.tcoordBuffer, tFont: k.fontTexture, padding: n.ValueCell.create(te) }), v.BaseGeometry.createValues(F, W)), { uSizeFactor: n.ValueCell.create(F.sizeFactor), uBorderWidth: n.ValueCell.create((0, p.clamp)(F.borderWidth, 0, 0.5)), uBorderColor: n.ValueCell.create(f.Color.toArrayNormalized(F.borderColor, d.Vec3.zero(), 0)), uOffsetX: n.ValueCell.create(F.offsetX), uOffsetY: n.ValueCell.create(F.offsetY), uOffsetZ: n.ValueCell.create(F.offsetZ), uBackgroundColor: n.ValueCell.create(f.Color.toArrayNormalized(F.backgroundColor, d.Vec3.zero(), 0)), uBackgroundOpacity: n.ValueCell.create(F.backgroundOpacity) });
      }
      function B(k, G, L, R, F) {
        var U = v.BaseGeometry.createSimple(L, R, F), H = (0, r.__assign)((0, r.__assign)({}, t.ParamDefinition.getDefaultValues(A.Params)), G);
        return I(k, U.transform, U.locationIterator, U.theme, H);
      }
      function D(k, G) {
        v.BaseGeometry.updateValues(k, G), n.ValueCell.updateIfChanged(k.uSizeFactor, G.sizeFactor), n.ValueCell.updateIfChanged(k.uBorderWidth, G.borderWidth), f.Color.fromNormalizedArray(k.uBorderColor.ref.value, 0) !== G.borderColor && (f.Color.toArrayNormalized(G.borderColor, k.uBorderColor.ref.value, 0), n.ValueCell.update(k.uBorderColor, k.uBorderColor.ref.value)), n.ValueCell.updateIfChanged(k.uOffsetX, G.offsetX), n.ValueCell.updateIfChanged(k.uOffsetY, G.offsetY), n.ValueCell.updateIfChanged(k.uOffsetZ, G.offsetZ), f.Color.fromNormalizedArray(k.uBackgroundColor.ref.value, 0) !== G.backgroundColor && (f.Color.toArrayNormalized(G.backgroundColor, k.uBackgroundColor.ref.value, 0), n.ValueCell.update(k.uBackgroundColor, k.uBackgroundColor.ref.value)), n.ValueCell.updateIfChanged(k.uBackgroundOpacity, G.backgroundOpacity);
      }
      function N(k, G) {
        var L = _(k.aMapping.ref.value, k.aDepth.ref.value, G.charCount, (0, o.getMaxSize)(k)), R = u.Sphere3D.expand((0, u.Sphere3D)(), G.boundingSphere, L), F = (0, l.calculateTransformBoundingSphere)(R, k.aTransform.ref.value, k.instanceCount.ref.value);
        u.Sphere3D.equals(F, k.boundingSphere.ref.value) || n.ValueCell.update(k.boundingSphere, F), u.Sphere3D.equals(R, k.invariantBoundingSphere.ref.value) || (n.ValueCell.update(k.invariantBoundingSphere, R), n.ValueCell.update(k.uInvariantBoundingSphere, d.Vec4.fromSphere(k.uInvariantBoundingSphere.ref.value, R))), n.ValueCell.update(k.padding, L);
      }
      function O(k) {
        var G = v.BaseGeometry.createRenderableState(k);
        return V(G, k), G;
      }
      function V(k, G) {
        v.BaseGeometry.updateRenderableState(k, G), k.pickable = !1, k.opaque = !1, k.writeDepth = !0;
      }
    })(e.Text || (e.Text = {}));
    function _(A, M, P, T) {
      for (var x = 0, w = 0, E = 0, I = P * 4; E < I; ++E) {
        var B = 2 * E, D = Math.abs(A[B]);
        D > x && (x = D);
        var N = Math.abs(A[B + 1]);
        N > x && (x = N);
        var O = Math.abs(M[E]);
        O > w && (w = O);
      }
      return Math.max(w, T + T * x);
    }
  }(N5)), N5;
}
var V5 = {}, R5 = {}, X7;
function pl() {
  return X7 || (X7 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.LinesBuilder = void 0;
    var r = wr(), t = Fa(), n = Re, a = (0, n.Vec3)(), i = (0, n.Vec3)(), o = (0, n.Vec3)(), c = r.ChunkedArray.add, s = r.ChunkedArray.add3;
    (function(l) {
      function f(d, m, p) {
        d === void 0 && (d = 2048), m === void 0 && (m = 1024);
        var v = r.ChunkedArray.create(Float32Array, 1, m, p ? p.groupBuffer.ref.value : d), h = r.ChunkedArray.create(Float32Array, 3, m, p ? p.startBuffer.ref.value : d), y = r.ChunkedArray.create(Float32Array, 3, m, p ? p.endBuffer.ref.value : d), C = function(g, _, A, M, P, T, x) {
          for (var w = 0; w < 4; ++w)
            s(h, g, _, A), s(y, M, P, T), c(v, x);
        }, S = function(g, _, A) {
          for (var M = 0; M < 4; ++M)
            s(h, g[0], g[1], g[2]), s(y, _[0], _[1], _[2]), c(v, A);
        }, b = function(g, _, A, M) {
          var P = n.Vec3.distance(g, _), T = Math.floor(A / 2), x = 1 / A;
          n.Vec3.sub(o, _, g);
          for (var w = 0; w < T; ++w) {
            var E = x * (w * 2 + 1);
            n.Vec3.setMagnitude(o, o, P * E), n.Vec3.add(a, g, o), n.Vec3.setMagnitude(o, o, P * x * ((w + 1) * 2)), n.Vec3.add(i, g, o), C(a[0], a[1], a[2], i[0], i[1], i[2], M);
          }
        };
        return {
          add: C,
          addVec: S,
          addFixedCountDashes: b,
          addFixedLengthDashes: function(g, _, A, M) {
            var P = n.Vec3.distance(g, _);
            b(g, _, P / A, M);
          },
          addCage: function(g, _, A) {
            for (var M = _.vertices, P = _.edges, T = 0, x = P.length; T < x; T += 2)
              n.Vec3.fromArray(a, M, P[T] * 3), n.Vec3.fromArray(i, M, P[T + 1] * 3), n.Vec3.transformMat4(a, a, g), n.Vec3.transformMat4(i, i, g), C(a[0], a[1], a[2], i[0], i[1], i[2], A);
          },
          getLines: function() {
            var g = v.elementCount / 4, _ = r.ChunkedArray.compact(v, !0), A = r.ChunkedArray.compact(h, !0), M = r.ChunkedArray.compact(y, !0), P = p && g <= p.lineCount ? p.mappingBuffer.ref.value : new Float32Array(g * 8), T = p && g <= p.lineCount ? p.indexBuffer.ref.value : new Uint32Array(g * 6);
            return (!p || g > p.lineCount) && u(g, P, T), t.Lines.create(P, T, _, A, M, g, p);
          }
        };
      }
      l.create = f;
    })(e.LinesBuilder || (e.LinesBuilder = {}));
    function u(l, f, d) {
      for (var m = 0; m < l; ++m) {
        var p = m * 8;
        f[p] = -1, f[p + 1] = -1, f[p + 2] = 1, f[p + 3] = -1, f[p + 4] = -1, f[p + 5] = 1, f[p + 6] = 1, f[p + 7] = 1;
      }
      for (var m = 0; m < l; ++m) {
        var v = m * 4, h = m * 6;
        d[h] = v, d[h + 1] = v + 1, d[h + 2] = v + 2, d[h + 3] = v + 1, d[h + 4] = v + 3, d[h + 5] = v + 2;
      }
    }
  }(R5)), R5;
}
var Y7;
function Fa() {
  return Y7 || (Y7 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.Lines = void 0;
    var r = Te, t = We(), n = Re, a = On, i = ru(), o = na, c = Tc(), s = on, u = pl(), l = Le, f = ut, d = nr(), m = Xt, p = pa, v = $n, h = wr(), y = ha, C = ga;
    (function(S) {
      function b(D, N, O, V, k, G, L) {
        return L ? P(D, N, O, V, k, G, L) : M(D, N, O, V, k, G);
      }
      S.create = b;
      function g(D) {
        var N = D ? D.mappingBuffer.ref.value : new Float32Array(0), O = D ? D.indexBuffer.ref.value : new Uint32Array(0), V = D ? D.groupBuffer.ref.value : new Float32Array(0), k = D ? D.startBuffer.ref.value : new Float32Array(0), G = D ? D.endBuffer.ref.value : new Float32Array(0);
        return b(N, O, V, k, G, 0, D);
      }
      S.createEmpty = g;
      function _(D, N) {
        for (var O = D.vertexBuffer.ref.value, V = D.indexBuffer.ref.value, k = D.groupBuffer.ref.value, G = u.LinesBuilder.create(D.triangleCount * 3, D.triangleCount / 10, N), L = 0, R = D.triangleCount * 3; L < R; L += 3) {
          var F = V[L], U = V[L + 1], H = V[L + 2], q = O[F * 3], K = O[F * 3 + 1], Y = O[F * 3 + 2], X = O[U * 3], Z = O[U * 3 + 1], J = O[U * 3 + 2], $ = O[H * 3], Q = O[H * 3 + 1], W = O[H * 3 + 2];
          G.add(q, K, Y, X, Z, J, k[F]), G.add(q, K, Y, $, Q, W, k[F]), G.add(X, Z, J, $, Q, W, k[U]);
        }
        return G.getLines();
      }
      S.fromMesh = _;
      function A(D) {
        return (0, h.hashFnv32a)([
          D.lineCount,
          D.mappingBuffer.ref.version,
          D.indexBuffer.ref.version,
          D.groupBuffer.ref.version,
          D.startBuffer.ref.version,
          D.endBuffer.ref.version
        ]);
      }
      function M(D, N, O, V, k, G) {
        var L = (0, d.Sphere3D)(), R, F = -1, U = -1, H = {
          kind: "lines",
          lineCount: G,
          mappingBuffer: t.ValueCell.create(D),
          indexBuffer: t.ValueCell.create(N),
          groupBuffer: t.ValueCell.create(O),
          startBuffer: t.ValueCell.create(V),
          endBuffer: t.ValueCell.create(k),
          get boundingSphere() {
            var q = A(H);
            if (q !== F) {
              var K = (0, f.calculateInvariantBoundingSphere)(H.startBuffer.ref.value, H.lineCount * 4, 4), Y = (0, f.calculateInvariantBoundingSphere)(H.endBuffer.ref.value, H.lineCount * 4, 4);
              d.Sphere3D.expandBySphere(L, K, Y), F = q;
            }
            return L;
          },
          get groupMapping() {
            return H.groupBuffer.ref.version !== U && (R = (0, a.createGroupMapping)(H.groupBuffer.ref.value, H.lineCount, 4), U = H.groupBuffer.ref.version), R;
          },
          setBoundingSphere: function(q) {
            d.Sphere3D.copy(L, q), F = A(H);
          }
        };
        return H;
      }
      function P(D, N, O, V, k, G, L) {
        return G > L.lineCount && (t.ValueCell.update(L.mappingBuffer, D), t.ValueCell.update(L.indexBuffer, N)), L.lineCount = G, t.ValueCell.update(L.groupBuffer, O), t.ValueCell.update(L.startBuffer, V), t.ValueCell.update(L.endBuffer, k), L;
      }
      function T(D, N) {
        var O = D.startBuffer.ref.value;
        (0, a.transformPositionArray)(N, O, 0, D.lineCount * 4), t.ValueCell.update(D.startBuffer, O);
        var V = D.endBuffer.ref.value;
        (0, a.transformPositionArray)(N, V, 0, D.lineCount * 4), t.ValueCell.update(D.endBuffer, V);
      }
      S.transform = T, S.Params = (0, r.__assign)((0, r.__assign)({}, m.BaseGeometry.Params), { sizeFactor: l.ParamDefinition.Numeric(2, { min: 0, max: 10, step: 0.1 }), lineSizeAttenuation: l.ParamDefinition.Boolean(!1) }), S.Utils = {
        Params: S.Params,
        createEmpty: g,
        createValues: w,
        createValuesSimple: E,
        updateValues: I,
        updateBoundingSphere: B,
        createRenderableState: m.BaseGeometry.createRenderableState,
        updateRenderableState: m.BaseGeometry.updateRenderableState,
        createPositionIterator: x
      };
      function x(D, N) {
        var O = D.lineCount * 4, V = N.instanceCount.ref.value, k = (0, s.PositionLocation)(), G = k.position, L = D.startBuffer.ref.value, R = D.endBuffer.ref.value, F = N.aTransform.ref.value, U = function(H, q) {
          var K = H % 4 === 0 ? L : R;
          return q < 0 ? n.Vec3.fromArray(G, K, H * 3) : n.Vec3.transformMat4Offset(G, K, F, 0, H * 3, q * 16), k;
        };
        return (0, s.LocationIterator)(O, V, 2, U);
      }
      function w(D, N, O, V, k) {
        var G = O.instanceCount, L = O.groupCount, R = x(D, N), F = (0, i.createColors)(O, R, V.color), U = (0, c.createSizes)(O, V.size), H = (0, o.createMarkers)(G * L), q = (0, p.createEmptyOverpaint)(), K = (0, v.createEmptyTransparency)(), Y = (0, C.createEmptySubstance)(), X = (0, y.createEmptyClipping)(), Z = {
          drawCount: D.lineCount * 2 * 3,
          vertexCount: D.lineCount * 4,
          groupCount: L,
          instanceCount: G
        }, J = d.Sphere3D.clone(D.boundingSphere), $ = (0, f.calculateTransformBoundingSphere)(J, N.aTransform.ref.value, G);
        return (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({ dGeometryType: t.ValueCell.create("lines"), aMapping: D.mappingBuffer, aGroup: D.groupBuffer, aStart: D.startBuffer, aEnd: D.endBuffer, elements: D.indexBuffer, boundingSphere: t.ValueCell.create($), invariantBoundingSphere: t.ValueCell.create(J), uInvariantBoundingSphere: t.ValueCell.create(n.Vec4.ofSphere(J)) }, F), U), H), q), K), Y), X), N), m.BaseGeometry.createValues(k, Z)), { uSizeFactor: t.ValueCell.create(k.sizeFactor), dLineSizeAttenuation: t.ValueCell.create(k.lineSizeAttenuation), uDoubleSided: t.ValueCell.create(!0), dFlipSided: t.ValueCell.create(!1) });
      }
      function E(D, N, O, V, k) {
        var G = m.BaseGeometry.createSimple(O, V, k), L = (0, r.__assign)((0, r.__assign)({}, l.ParamDefinition.getDefaultValues(S.Params)), N);
        return w(D, G.transform, G.locationIterator, G.theme, L);
      }
      function I(D, N) {
        m.BaseGeometry.updateValues(D, N), t.ValueCell.updateIfChanged(D.uSizeFactor, N.sizeFactor), t.ValueCell.updateIfChanged(D.dLineSizeAttenuation, N.lineSizeAttenuation);
      }
      function B(D, N) {
        var O = d.Sphere3D.clone(N.boundingSphere), V = (0, f.calculateTransformBoundingSphere)(O, D.aTransform.ref.value, D.instanceCount.ref.value);
        d.Sphere3D.equals(V, D.boundingSphere.ref.value) || t.ValueCell.update(D.boundingSphere, V), d.Sphere3D.equals(O, D.invariantBoundingSphere.ref.value) || (t.ValueCell.update(D.invariantBoundingSphere, O), t.ValueCell.update(D.uInvariantBoundingSphere, n.Vec4.fromSphere(D.uInvariantBoundingSphere.ref.value, O)));
      }
    })(e.Lines || (e.Lines = {}));
  }(V5)), V5;
}
var O5 = {}, ns = {}, ya = {};
Object.defineProperty(ya, "__esModule", { value: !0 });
ya.transformPrimitive = ya.PrimitiveBuilder = ya.copyPrimitive = ya.createPrimitive = void 0;
var Gt = Re, Q7 = (0, Gt.Vec3)(), Z7 = (0, Gt.Vec3)(), J7 = (0, Gt.Vec3)();
function yce(e, r) {
  for (var t = r.length, n = WG(t / 3), a = 0; a < t; a += 3)
    Gt.Vec3.fromArray(Q7, e, r[a] * 3), Gt.Vec3.fromArray(Z7, e, r[a + 1] * 3), Gt.Vec3.fromArray(J7, e, r[a + 2] * 3), n.add(Q7, Z7, J7);
  return n.getPrimitive();
}
ya.createPrimitive = yce;
function _ce(e) {
  return {
    vertices: new Float32Array(e.vertices),
    normals: new Float32Array(e.normals),
    indices: new Uint32Array(e.indices)
  };
}
ya.copyPrimitive = _ce;
var S2 = (0, Gt.Vec3)();
function WG(e, r) {
  r === void 0 && (r = e * 3);
  var t = new Float32Array(r * 3), n = new Float32Array(r * 3), a = new Uint32Array(e * 3), i = 0, o = 0;
  return {
    add: function(c, s, u) {
      Gt.Vec3.toArray(c, t, i), Gt.Vec3.toArray(s, t, i + 3), Gt.Vec3.toArray(u, t, i + 6), Gt.Vec3.triangleNormal(S2, c, s, u);
      for (var l = 0; l < 3; ++l)
        Gt.Vec3.toArray(S2, n, i + 3 * l), a[o + l] = i / 3 + l;
      i += 9, o += 3;
    },
    addQuad: function(c, s, u, l) {
      Gt.Vec3.toArray(c, t, i), Gt.Vec3.toArray(s, t, i + 3), Gt.Vec3.toArray(u, t, i + 6), Gt.Vec3.toArray(l, t, i + 9), Gt.Vec3.triangleNormal(S2, c, s, u);
      for (var f = 0; f < 4; ++f)
        Gt.Vec3.toArray(S2, n, i + 3 * f);
      var d = i / 3;
      a[o] = d, a[o + 1] = d + 1, a[o + 2] = d + 2, a[o + 3] = d + 2, a[o + 4] = d + 3, a[o + 5] = d, i += 12, o += 6;
    },
    getPrimitive: function() {
      return { vertices: t, normals: n, indices: a };
    }
  };
}
ya.PrimitiveBuilder = WG;
var vm = (0, Gt.Vec3)(), bce = (0, Gt.Mat3)();
function Sce(e, r) {
  for (var t = e.vertices, n = e.normals, a = Gt.Mat3.directionTransform(bce, r), i = 0, o = t.length; i < o; i += 3)
    Gt.Vec3.transformMat4(vm, Gt.Vec3.fromArray(vm, t, i), r), Gt.Vec3.toArray(vm, t, i), Gt.Vec3.transformMat3(vm, Gt.Vec3.fromArray(vm, n, i), a), Gt.Vec3.toArray(vm, n, i);
  return e;
}
ya.transformPrimitive = Sce;
var $d = {};
Object.defineProperty($d, "__esModule", { value: !0 });
$d.polygon = void 0;
function Cce(e, r, t) {
  t === void 0 && (t = -1);
  for (var n = new Float32Array(e * 3), a = t === -1 ? e <= 4 ? Math.sqrt(2) / 2 : 0.6 : t, i = r ? 1 : 0, o = 0, c = e; o < c; ++o) {
    var s = (o * 2 + i) / e * Math.PI;
    n[o * 3] = Math.cos(s) * a, n[o * 3 + 1] = Math.sin(s) * a, n[o * 3 + 2] = 0;
  }
  return n;
}
$d.polygon = Cce;
var wu = {};
Object.defineProperty(wu, "__esModule", { value: !0 });
wu.transformCage = wu.cloneCage = wu.createCage = void 0;
var tb = Re;
function Ace(e, r) {
  return { vertices: e, edges: r };
}
wu.createCage = Ace;
function xce(e) {
  return {
    vertices: new Float32Array(e.vertices),
    edges: new Uint32Array(e.edges)
  };
}
wu.cloneCage = xce;
var F5 = tb.Vec3.zero();
function Tce(e, r) {
  for (var t = e.vertices, n = 0, a = t.length; n < a; n += 3)
    tb.Vec3.transformMat4(F5, tb.Vec3.fromArray(F5, t, n), r), tb.Vec3.toArray(F5, t, n);
  return e;
}
wu.transformCage = Tce;
Object.defineProperty(ns, "__esModule", { value: !0 });
ns.BoxCage = ns.PerforatedBox = ns.Box = void 0;
var gi = Re, Pce = ya, Mce = $d, wce = wu, Il = (0, gi.Vec3)(), Bl = (0, gi.Vec3)(), Nl = (0, gi.Vec3)(), pm = (0, gi.Vec3)(), cn = (0, Mce.polygon)(4, !0);
function XG(e) {
  for (var r = 12, t = e ? 12 * 3 : 6 * 4, n = (0, Pce.PrimitiveBuilder)(r, t), a = 0; a < 4; ++a) {
    var i = (a + 1) % 4;
    gi.Vec3.set(Il, cn[a * 3], cn[a * 3 + 1], -0.5), gi.Vec3.set(Bl, cn[i * 3], cn[i * 3 + 1], -0.5), gi.Vec3.set(Nl, cn[i * 3], cn[i * 3 + 1], 0.5), gi.Vec3.set(pm, cn[a * 3], cn[a * 3 + 1], 0.5), e ? n.add(Il, Bl, Nl) : n.addQuad(Il, Bl, Nl, pm);
  }
  return gi.Vec3.set(Il, cn[0], cn[1], -0.5), gi.Vec3.set(Bl, cn[3], cn[4], -0.5), gi.Vec3.set(Nl, cn[6], cn[7], -0.5), gi.Vec3.set(pm, cn[9], cn[10], -0.5), e ? n.add(Nl, Bl, Il) : n.addQuad(pm, Nl, Bl, Il), gi.Vec3.set(Il, cn[0], cn[1], 0.5), gi.Vec3.set(Bl, cn[3], cn[4], 0.5), gi.Vec3.set(Nl, cn[6], cn[7], 0.5), gi.Vec3.set(pm, cn[9], cn[10], 0.5), e ? n.add(Il, Bl, Nl) : n.addQuad(Il, Bl, Nl, pm), n.getPrimitive();
}
var L5;
function Ece() {
  return L5 || (L5 = XG(!1)), L5;
}
ns.Box = Ece;
var k5;
function Dce() {
  return k5 || (k5 = XG(!0)), k5;
}
ns.PerforatedBox = Dce;
var U5;
function Ice() {
  return U5 || (U5 = (0, wce.createCage)([
    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
    // top base
  ])), U5;
}
ns.BoxCage = Ice;
var bd = {};
Object.defineProperty(bd, "__esModule", { value: !0 });
bd.createTransferFunctionTexture = bd.getControlPointsFromVec2Array = bd.getControlPointsFromString = void 0;
var e9 = Te, Bce = Zr, r9 = We();
function Nce(e) {
  return e.split(/\s*,\s*/).map(function(r) {
    var t = r.split(/\s*:\s*/);
    return { x: parseFloat(t[0]), alpha: parseFloat(t[1]) };
  });
}
bd.getControlPointsFromString = Nce;
function Vce(e) {
  return e.map(function(r) {
    return { x: r[0], alpha: r[1] };
  });
}
bd.getControlPointsFromVec2Array = Vce;
function Rce(e, r) {
  for (var t = (0, e9.__spreadArray)((0, e9.__spreadArray)([
    { x: 0, alpha: 0 },
    { x: 0, alpha: 0 }
  ], e, !0), [
    { x: 1, alpha: 0 },
    { x: 1, alpha: 0 }
  ], !1), n = 256, a = r ? r.ref.value.array : new Uint8Array(n), i = 0, o, c, s, u, l, f, d = e.length + 1, m = 0; m < d; ++m) {
    o = t[m + 1].x, c = t[m + 2].x, s = t[m].alpha, u = t[m + 1].alpha, l = t[m + 2].alpha, f = t[m + 3].alpha;
    for (var p = Math.round((c - o) * n), v = 0; v < p; ++v) {
      var h = v / p;
      a[i] = Math.max(0, (0, Bce.spline)(s, u, l, f, h, 0.5) * 255), ++i;
    }
  }
  var y = { array: a, width: 256, height: 1 };
  return r ? (r9.ValueCell.update(r, y), r) : r9.ValueCell.create(y);
}
bd.createTransferFunctionTexture = Rce;
var F0 = {}, OE = {}, gy = {}, l4 = {};
Object.defineProperty(l4, "__esModule", { value: !0 });
l4.calculateHistogram = void 0;
var Oce = hr;
function Fce(e, r, t) {
  if (t)
    return t9(e, r, t.min, t.max);
  var n = (0, Oce.arrayMinMax)(e), a = n[0], i = n[1];
  return t9(e, r, a, i);
}
l4.calculateHistogram = Fce;
function t9(e, r, t, n) {
  var a = (n - t) / r;
  a === 0 && (a = 1);
  for (var i = new Int32Array(r), o = 0, c = e.length; o < c; o++) {
    var s = Math.floor((e[o] - t) / a);
    s >= r ? s = r - 1 : s < 0 && (s = 0), i[s]++;
  }
  return { min: t, max: n, binWidth: a, counts: i };
}
Object.defineProperty(gy, "__esModule", { value: !0 });
gy.Grid = void 0;
var z5 = nr(), Ga = Re, Lce = l4, OM;
(function(e) {
  e.One = {
    transform: { kind: "matrix", matrix: Ga.Mat4.identity() },
    cells: Ga.Tensor.create(Ga.Tensor.Space([1, 1, 1], [0, 1, 2]), Ga.Tensor.Data1([0])),
    stats: { min: 0, max: 0, mean: 0, sigma: 0 }
  };
  var r = Ga.Mat4.zero(), t = Ga.Mat4.zero();
  function n(s) {
    if (s.transform.kind === "matrix")
      return Ga.Mat4.copy((0, Ga.Mat4)(), s.transform.matrix);
    if (s.transform.kind === "spacegroup") {
      var u = s.cells.space, l = Ga.Mat4.fromScaling(r, Ga.Vec3.div(Ga.Vec3.zero(), z5.Box3D.size(Ga.Vec3.zero(), s.transform.fractionalBox), Ga.Vec3.ofArray(u.dimensions))), f = Ga.Mat4.fromTranslation(t, s.transform.fractionalBox.min);
      return Ga.Mat4.mul3(Ga.Mat4.zero(), s.transform.cell.fromFractional, f, l);
    }
    return Ga.Mat4.identity();
  }
  e.getGridToCartesianTransform = n;
  function a(s, u) {
    return s === u;
  }
  e.areEquivalent = a;
  function i(s) {
    return s.cells.data.length === 0;
  }
  e.isEmpty = i;
  function o(s, u) {
    u || (u = (0, z5.Sphere3D)());
    var l = s.cells.space.dimensions, f = e.getGridToCartesianTransform(s);
    return z5.Sphere3D.fromDimensionsAndTransform(u, l, f);
  }
  e.getBoundingSphere = o;
  function c(s, u) {
    var l = s._historams;
    return l || (l = s._historams = {}), l[u] || (l[u] = (0, Lce.calculateHistogram)(s.cells.data, u, { min: s.stats.min, max: s.stats.max })), l[u];
  }
  e.getHistogram = c;
})(OM || (OM = {}));
gy.Grid = OM;
var Rv = {};
Object.defineProperty(Rv, "__esModule", { value: !0 });
Rv.CubeFormat = Rv.volumeFromCube = void 0;
var n9 = Te, Fc = Re, kce = Kr, C2 = hr, Uce = In;
function zce(e, r) {
  var t = this;
  return kce.Task.create("Create Volume", function() {
    return (0, n9.__awaiter)(t, void 0, void 0, function() {
      var n, a, i, o, c, s, u, l, f, d, m, p, v, h, y, C, S;
      return (0, n9.__generator)(this, function(b) {
        if (n = e.header, a = e.values, i = Fc.Tensor.Space(n.dim, [0, 1, 2], Float64Array), n.dataSetIds.length === 0)
          o = a;
        else
          for (c = n.dim, s = c[0], u = c[1], l = c[2], f = ((r == null ? void 0 : r.dataIndex) || 0) + 1, d = 0, m = 0, o = new Float64Array(s * u * l), p = 0; p < s; p++)
            for (v = 0; v < u; v++)
              for (h = 0; h < l; h++)
                o[d++] = a[m], m += f;
        return y = Fc.Tensor.create(i, Fc.Tensor.Data1(o)), C = Fc.Mat4.fromTranslation((0, Fc.Mat4)(), n.origin), S = Fc.Mat4.fromBasis((0, Fc.Mat4)(), n.basisX, n.basisY, n.basisZ), Fc.Mat4.mul(C, C, S), [2, {
          label: r == null ? void 0 : r.label,
          entryId: r == null ? void 0 : r.entryId,
          grid: {
            transform: { kind: "matrix", matrix: C },
            cells: y,
            stats: {
              min: (0, C2.arrayMin)(o),
              max: (0, C2.arrayMax)(o),
              mean: (0, C2.arrayMean)(o),
              sigma: (0, C2.arrayRms)(o)
            }
          },
          sourceData: Rb.create(e),
          customProperties: new Uce.CustomProperties(),
          _propertyData: /* @__PURE__ */ Object.create(null)
        }];
      });
    });
  });
}
Rv.volumeFromCube = zce;
var Rb;
(function(e) {
  function r(n) {
    return (n == null ? void 0 : n.kind) === "cube";
  }
  e.is = r;
  function t(n) {
    return { kind: "cube", name: n.name, data: n };
  }
  e.create = t;
})(Rb || (Rb = {}));
Rv.CubeFormat = Rb;
var Ov = {};
Object.defineProperty(Ov, "__esModule", { value: !0 });
Ov.DscifFormat = Ov.volumeFromDensityServerData = void 0;
var a9 = Te, Gce = Kr, i9 = nr(), Ro = Re, qce = In;
function Hce(e, r) {
  var t = this;
  return Gce.Task.create("Create Volume", function(n) {
    return (0, a9.__awaiter)(t, void 0, void 0, function() {
      var a, i, o, c, s, u, l, f, d, m;
      return (0, a9.__generator)(this, function(p) {
        return a = e.volume_data_3d_info, i = e.volume_data_3d, o = i9.SpacegroupCell.create(a.spacegroup_number.value(0), Ro.Vec3.ofArray(a.spacegroup_cell_size.value(0)), Ro.Vec3.scale(Ro.Vec3.zero(), Ro.Vec3.ofArray(a.spacegroup_cell_angles.value(0)), Math.PI / 180)), c = a.axis_order.value(0), s = Ro.Tensor.convertToCanonicalAxisIndicesFastToSlow(c), u = s(a.sample_count.value(0)), l = Ro.Tensor.Space(u, Ro.Tensor.invertAxisOrder(c), Float32Array), f = Ro.Tensor.create(l, Ro.Tensor.Data1(i.values.toArray({ array: Float32Array }))), d = Ro.Vec3.ofArray(s(a.origin.value(0))), m = Ro.Vec3.ofArray(s(a.dimensions.value(0))), [2, {
          label: r == null ? void 0 : r.label,
          entryId: r == null ? void 0 : r.entryId,
          grid: {
            transform: { kind: "spacegroup", cell: o, fractionalBox: i9.Box3D.create(d, Ro.Vec3.add(Ro.Vec3.zero(), d, m)) },
            cells: f,
            stats: {
              min: a.min_sampled.value(0),
              max: a.max_sampled.value(0),
              mean: a.mean_sampled.value(0),
              sigma: a.sigma_sampled.value(0)
            }
          },
          sourceData: Ob.create(e),
          customProperties: new qce.CustomProperties(),
          _propertyData: /* @__PURE__ */ Object.create(null)
        }];
      });
    });
  });
}
Ov.volumeFromDensityServerData = Hce;
var Ob;
(function(e) {
  function r(n) {
    return (n == null ? void 0 : n.kind) === "dscif";
  }
  e.is = r;
  function t(n) {
    return { kind: "dscif", name: n._name, data: n };
  }
  e.create = t;
})(Ob || (Ob = {}));
Ov.DscifFormat = Ob;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Volume = void 0;
  var r = gy, t = Qe(), n = nr(), a = Re, i = ys, o = Rv, c = Ci, s = In, u = Le, l = fa, f = Ov;
  (function(d) {
    function m(T) {
      var x, w, E, I;
      return ((I = (E = (w = (x = T == null ? void 0 : T.grid) === null || x === void 0 ? void 0 : x.cells) === null || w === void 0 ? void 0 : w.space) === null || E === void 0 ? void 0 : E.dimensions) === null || I === void 0 ? void 0 : I.length) && (T == null ? void 0 : T.sourceData) && (T == null ? void 0 : T.customProperties) && (T == null ? void 0 : T._propertyData);
    }
    d.is = m;
    var p;
    (function(T) {
      function x(V, k, G) {
        return (0, c.equalEps)(D(V, G).absoluteValue, D(k, G).absoluteValue, G.sigma / 100);
      }
      T.areSame = x;
      function w(V) {
        return { kind: "absolute", absoluteValue: V };
      }
      T.absolute = w;
      function E(V) {
        return { kind: "relative", relativeValue: V };
      }
      T.relative = E;
      function I(V, k) {
        return k * V.sigma + V.mean;
      }
      T.calcAbsolute = I;
      function B(V, k) {
        return V.sigma === 0 ? 0 : (k - V.mean) / V.sigma;
      }
      T.calcRelative = B;
      function D(V, k) {
        return V.kind === "absolute" ? V : { kind: "absolute", absoluteValue: T.calcAbsolute(k, V.relativeValue) };
      }
      T.toAbsolute = D;
      function N(V, k) {
        return V.kind === "relative" ? V : { kind: "relative", relativeValue: T.calcRelative(k, V.absoluteValue) };
      }
      T.toRelative = N;
      function O(V) {
        return V.kind === "relative" ? "".concat(V.relativeValue.toFixed(2), " σ") : "".concat(V.absoluteValue.toPrecision(4));
      }
      T.toString = O;
    })(p = d.IsoValue || (d.IsoValue = {}));
    function v(T, x, w) {
      if (w === "relative")
        return p.relative(x);
      var E = p.absolute(x);
      if (f.DscifFormat.is(T.sourceData)) {
        var I = {
          min: T.sourceData.data.volume_data_3d_info.min_source.value(0),
          max: T.sourceData.data.volume_data_3d_info.max_source.value(0),
          mean: T.sourceData.data.volume_data_3d_info.mean_source.value(0),
          sigma: T.sourceData.data.volume_data_3d_info.sigma_source.value(0)
        };
        return d.IsoValue.toRelative(E, I);
      }
      return E;
    }
    d.adjustedIsoValue = v;
    var h = { min: -1, max: 1, mean: 0, sigma: 0.1 };
    function y(T, x) {
      var w = x || h, E = w.min, I = w.max, B = w.mean, D = w.sigma, N = (E - B) / D, O = (I - B) / D, V = T;
      return T.kind === "absolute" ? T.absoluteValue < E ? V = d.IsoValue.absolute(E) : T.absoluteValue > I && (V = d.IsoValue.absolute(I)) : T.relativeValue < N ? V = d.IsoValue.relative(N) : T.relativeValue > O && (V = d.IsoValue.relative(O)), u.ParamDefinition.Conditioned(V, {
        absolute: u.ParamDefinition.Converted(function(k) {
          return d.IsoValue.toAbsolute(k, r.Grid.One.stats).absoluteValue;
        }, function(k) {
          return d.IsoValue.absolute(k);
        }, u.ParamDefinition.Numeric(B, { min: E, max: I, step: (0, l.toPrecision)(D / 100, 2) })),
        relative: u.ParamDefinition.Converted(function(k) {
          return d.IsoValue.toRelative(k, r.Grid.One.stats).relativeValue;
        }, function(k) {
          return d.IsoValue.relative(k);
        }, u.ParamDefinition.Numeric(Math.min(1, O), { min: N, max: O, step: (0, l.toPrecision)(Math.round((I - E) / D) / 100, 2) }))
      }, function(k) {
        return k.kind === "absolute" ? "absolute" : "relative";
      }, function(k, G) {
        return G === "absolute" ? d.IsoValue.toAbsolute(k, w) : d.IsoValue.toRelative(k, w);
      }, { isEssential: !0 });
    }
    d.createIsoValueParam = y, d.IsoValueParam = y(d.IsoValue.relative(2)), d.One = {
      label: "",
      grid: r.Grid.One,
      sourceData: { kind: "", name: "", data: {} },
      customProperties: new s.CustomProperties(),
      _propertyData: /* @__PURE__ */ Object.create(null)
    };
    function C(T, x) {
      return r.Grid.areEquivalent(T.grid, x.grid);
    }
    d.areEquivalent = C;
    function S(T) {
      return r.Grid.isEmpty(T.grid);
    }
    d.isEmpty = S;
    function b(T) {
      return o.CubeFormat.is(T.sourceData) ? T.sourceData.data.header.orbitals : !1;
    }
    d.isOrbitals = b;
    function g(T) {
      return { kind: "volume-loci", volume: T };
    }
    d.Loci = g;
    function _(T) {
      return !!T && T.kind === "volume-loci";
    }
    d.isLoci = _;
    function A(T, x) {
      return T.volume === x.volume;
    }
    d.areLociEqual = A;
    function M(T) {
      return r.Grid.isEmpty(T.volume.grid);
    }
    d.isLociEmpty = M;
    function P(T, x) {
      return r.Grid.getBoundingSphere(T.grid, x);
    }
    d.getBoundingSphere = P, function(T) {
      function x(D, N) {
        return { kind: "isosurface-loci", volume: D, isoValue: N };
      }
      T.Loci = x;
      function w(D) {
        return !!D && D.kind === "isosurface-loci";
      }
      T.isLoci = w;
      function E(D, N) {
        return D.volume === N.volume && d.IsoValue.areSame(D.isoValue, N.isoValue, D.volume.grid.stats);
      }
      T.areLociEqual = E;
      function I(D) {
        return D.volume.grid.cells.data.length === 0;
      }
      T.isLociEmpty = I;
      function B(D, N, O) {
        return d.getBoundingSphere(D, O);
      }
      T.getBoundingSphere = B;
    }(d.Isosurface || (d.Isosurface = {})), function(T) {
      function x(O, V) {
        return { kind: "cell-loci", volume: O, indices: V };
      }
      T.Loci = x;
      function w(O) {
        return !!O && O.kind === "cell-loci";
      }
      T.isLoci = w;
      function E(O, V) {
        return O.volume === V.volume && t.OrderedSet.areEqual(O.indices, V.indices);
      }
      T.areLociEqual = E;
      function I(O) {
        return t.OrderedSet.size(O.indices) === 0;
      }
      T.isLociEmpty = I;
      var B = new i.BoundaryHelper("98"), D = (0, a.Vec3)();
      function N(O, V, k) {
        B.reset();
        for (var G = r.Grid.getGridToCartesianTransform(O.grid), L = O.grid.cells.space.getCoords, R = 0, F = t.OrderedSet.size(V); R < F; R++) {
          var U = t.OrderedSet.getAt(V, R);
          L(U, D), a.Vec3.transformMat4(D, D, G), B.includePosition(D);
        }
        B.finishedIncludeStep();
        for (var R = 0, F = t.OrderedSet.size(V); R < F; R++) {
          var U = t.OrderedSet.getAt(V, R);
          L(U, D), a.Vec3.transformMat4(D, D, G), B.radiusPosition(D);
        }
        var H = B.getSphere(k);
        return n.Sphere3D.expand(H, H, a.Mat4.getMaxScaleOnAxis(G) * 10);
      }
      T.getBoundingSphere = N;
    }(d.Cell || (d.Cell = {}));
  })(e.Volume || (e.Volume = {}));
})(OE);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 });
  var r = Te;
  (0, r.__exportStar)(OE, e), (0, r.__exportStar)(gy, e);
})(F0);
var o9;
function c4() {
  return o9 || (o9 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.DirectVolume = void 0;
    var r = Te, t = wr(), n = on, a = ut, i = ps(), o = nr(), c = Re, s = We(), u = Le, l = ns, f = Xt, d = ru(), m = na, p = pa, v = $n, h = bd, y = ha, C = F0, S = ga, b = (0, l.Box)();
    (function(_) {
      function A(L, R, F, U, H, q, K, Y, X, Z) {
        return Z ? T(L, R, F, U, H, q, K, Y, X, Z) : P(L, R, F, U, H, q, K, Y, X);
      }
      _.create = A;
      function M(L) {
        return (0, t.hashFnv32a)([
          L.bboxSize.ref.version,
          L.gridDimension.ref.version,
          L.gridTexture.ref.version,
          L.transform.ref.version,
          L.gridStats.ref.version
        ]);
      }
      function P(L, R, F, U, H, q, K, Y, X) {
        var Z = (0, o.Sphere3D)(), J = -1, $ = q.getWidth(), Q = q.getHeight(), W = q.getDepth(), te = {
          kind: "direct-volume",
          gridDimension: s.ValueCell.create(R),
          gridTexture: s.ValueCell.create(q),
          gridTextureDim: s.ValueCell.create(c.Vec3.create($, Q, W)),
          gridStats: s.ValueCell.create(c.Vec4.create(K.min, K.max, K.mean, K.sigma)),
          bboxMin: s.ValueCell.create(L.min),
          bboxMax: s.ValueCell.create(L.max),
          bboxSize: s.ValueCell.create(c.Vec3.sub((0, c.Vec3)(), L.max, L.min)),
          transform: s.ValueCell.create(F),
          cellDim: s.ValueCell.create(H),
          unitToCartn: s.ValueCell.create(U),
          cartnToUnit: s.ValueCell.create(c.Mat4.invert((0, c.Mat4)(), U)),
          get boundingSphere() {
            var oe = M(te);
            if (oe !== J) {
              var z = g(te.gridDimension.ref.value, te.transform.ref.value);
              o.Sphere3D.copy(Z, z), J = oe;
            }
            return Z;
          },
          packedGroup: s.ValueCell.create(Y),
          axisOrder: s.ValueCell.create(X),
          setBoundingSphere: function(oe) {
            o.Sphere3D.copy(Z, oe), J = M(te);
          }
        };
        return te;
      }
      function T(L, R, F, U, H, q, K, Y, X, Z) {
        var J = q.getWidth(), $ = q.getHeight(), Q = q.getDepth();
        return s.ValueCell.update(Z.gridDimension, R), s.ValueCell.update(Z.gridTexture, q), s.ValueCell.update(Z.gridTextureDim, c.Vec3.set(Z.gridTextureDim.ref.value, J, $, Q)), s.ValueCell.update(Z.gridStats, c.Vec4.set(Z.gridStats.ref.value, K.min, K.max, K.mean, K.sigma)), s.ValueCell.update(Z.bboxMin, L.min), s.ValueCell.update(Z.bboxMax, L.max), s.ValueCell.update(Z.bboxSize, c.Vec3.sub(Z.bboxSize.ref.value, L.max, L.min)), s.ValueCell.update(Z.transform, F), s.ValueCell.update(Z.cellDim, H), s.ValueCell.update(Z.unitToCartn, U), s.ValueCell.update(Z.cartnToUnit, c.Mat4.invert((0, c.Mat4)(), U)), s.ValueCell.updateIfChanged(Z.packedGroup, Y), s.ValueCell.updateIfChanged(Z.axisOrder, c.Vec3.fromArray(Z.axisOrder.ref.value, X, 0)), Z;
      }
      function x(L) {
        var R = (0, o.Box3D)(), F = (0, c.Vec3)(), U = c.Mat4.identity(), H = c.Mat4.identity(), q = (0, c.Vec3)(), K = (0, i.createNullTexture)(), Y = C.Grid.One.stats, X = !1, Z = c.Vec3.create(0, 1, 2);
        return A(R, F, U, H, q, K, Y, X, Z, L);
      }
      _.createEmpty = x, _.Params = (0, r.__assign)((0, r.__assign)({}, f.BaseGeometry.Params), { ignoreLight: u.ParamDefinition.Boolean(!1, f.BaseGeometry.ShadingCategory), xrayShaded: u.ParamDefinition.Boolean(!1, f.BaseGeometry.ShadingCategory), controlPoints: u.ParamDefinition.LineGraph([
        c.Vec2.create(0.19, 0),
        c.Vec2.create(0.2, 0.05),
        c.Vec2.create(0.25, 0.05),
        c.Vec2.create(0.26, 0),
        c.Vec2.create(0.79, 0),
        c.Vec2.create(0.8, 0.05),
        c.Vec2.create(0.85, 0.05),
        c.Vec2.create(0.86, 0)
      ], { isEssential: !0 }), stepsPerCell: u.ParamDefinition.Numeric(3, { min: 1, max: 10, step: 1 }), jumpLength: u.ParamDefinition.Numeric(0, { min: 0, max: 20, step: 0.1 }) }), _.Utils = {
        Params: _.Params,
        createEmpty: x,
        createValues: D,
        createValuesSimple: N,
        updateValues: O,
        updateBoundingSphere: V,
        createRenderableState: k,
        updateRenderableState: G,
        createPositionIterator: w
      };
      function w(L, R) {
        var F = L.transform.ref.value, U = L.gridDimension.ref.value, H = U[0], q = U[1], K = U[2], Y = H * q * K, X = R.instanceCount.ref.value, Z = (0, n.PositionLocation)(), J = Z.position, $ = R.aTransform.ref.value, Q = function(W, te) {
          var oe = Math.floor(W / K);
          return J[0] = Math.floor(oe / q), J[1] = oe % q, J[2] = W % K, c.Vec3.transformMat4(J, J, F), te >= 0 && c.Vec3.transformMat4Offset(J, J, $, 0, 0, te * 16), Z;
        };
        return (0, n.LocationIterator)(Y, X, 1, Q);
      }
      function E(L, R) {
        return Math.ceil(c.Vec3.magnitude(L) * R);
      }
      function I(L, R) {
        return Math.min.apply(Math, L) * (1 / R);
      }
      function B(L) {
        return 1 / L;
      }
      function D(L, R, F, U, H) {
        var q = L.gridTexture, K = L.gridTextureDim, Y = L.gridStats, X = L.bboxSize, Z = L.bboxMin, J = L.bboxMax, $ = L.gridDimension, Q = L.transform, W = F.instanceCount, te = F.groupCount, oe = _.Utils.createPositionIterator(L, R), z = (0, d.createColors)(F, oe, U.color), j = (0, m.createMarkers)(W * te), ae = (0, p.createEmptyOverpaint)(), le = (0, v.createEmptyTransparency)(), ie = (0, S.createEmptySubstance)(), re = (0, y.createEmptyClipping)(), ee = $.ref.value, ne = ee[0], se = ee[1], ce = ee[2], de = {
          drawCount: b.indices.length,
          vertexCount: ne * se * ce,
          groupCount: te,
          instanceCount: W
        }, me = o.Sphere3D.clone(L.boundingSphere), he = (0, a.calculateTransformBoundingSphere)(me, R.aTransform.ref.value, W), _e = (0, h.getControlPointsFromVec2Array)(H.controlPoints), Se = (0, h.createTransferFunctionTexture)(_e);
        return (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({ dGeometryType: s.ValueCell.create("directVolume") }, z), j), ae), le), ie), re), R), f.BaseGeometry.createValues(H, de)), { aPosition: s.ValueCell.create(b.vertices), elements: s.ValueCell.create(b.indices), boundingSphere: s.ValueCell.create(he), invariantBoundingSphere: s.ValueCell.create(me), uInvariantBoundingSphere: s.ValueCell.create(c.Vec4.ofSphere(me)), uBboxMin: Z, uBboxMax: J, uBboxSize: X, uMaxSteps: s.ValueCell.create(E($.ref.value, H.stepsPerCell)), uStepScale: s.ValueCell.create(I(L.cellDim.ref.value, H.stepsPerCell)), uJumpLength: s.ValueCell.create(H.jumpLength), uTransform: Q, uGridDim: $, tTransferTex: Se, uTransferScale: s.ValueCell.create(B(H.stepsPerCell)), dGridTexType: s.ValueCell.create(q.ref.value.getDepth() > 0 ? "3d" : "2d"), uGridTexDim: K, tGridTex: q, uGridStats: Y, uCellDim: L.cellDim, uCartnToUnit: L.cartnToUnit, uUnitToCartn: L.unitToCartn, dPackedGroup: L.packedGroup, dAxisOrder: s.ValueCell.create(L.axisOrder.ref.value.join("")), dIgnoreLight: s.ValueCell.create(H.ignoreLight), dXrayShaded: s.ValueCell.create(H.xrayShaded) });
      }
      function N(L, R, F, U, H) {
        var q = f.BaseGeometry.createSimple(F, U, H), K = (0, r.__assign)((0, r.__assign)({}, u.ParamDefinition.getDefaultValues(_.Params)), R);
        return D(L, q.transform, q.locationIterator, q.theme, K);
      }
      function O(L, R) {
        f.BaseGeometry.updateValues(L, R), s.ValueCell.updateIfChanged(L.dIgnoreLight, R.ignoreLight), s.ValueCell.updateIfChanged(L.dXrayShaded, R.xrayShaded);
        var F = (0, h.getControlPointsFromVec2Array)(R.controlPoints);
        (0, h.createTransferFunctionTexture)(F, L.tTransferTex), s.ValueCell.updateIfChanged(L.uMaxSteps, E(L.uGridDim.ref.value, R.stepsPerCell)), s.ValueCell.updateIfChanged(L.uStepScale, I(L.uCellDim.ref.value, R.stepsPerCell)), s.ValueCell.updateIfChanged(L.uTransferScale, B(R.stepsPerCell)), s.ValueCell.updateIfChanged(L.uJumpLength, R.jumpLength);
      }
      function V(L, R) {
        var F = o.Sphere3D.clone(R.boundingSphere), U = (0, a.calculateTransformBoundingSphere)(F, L.aTransform.ref.value, L.instanceCount.ref.value);
        o.Sphere3D.equals(U, L.boundingSphere.ref.value) || s.ValueCell.update(L.boundingSphere, U), o.Sphere3D.equals(F, L.invariantBoundingSphere.ref.value) || (s.ValueCell.update(L.invariantBoundingSphere, F), s.ValueCell.update(L.uInvariantBoundingSphere, c.Vec4.fromSphere(L.uInvariantBoundingSphere.ref.value, F)));
      }
      function k(L) {
        var R = f.BaseGeometry.createRenderableState(L);
        return R.opaque = !1, R.writeDepth = !1, R;
      }
      function G(L, R) {
        f.BaseGeometry.updateRenderableState(L, R), L.opaque = !1, L.writeDepth = !1;
      }
    })(e.DirectVolume || (e.DirectVolume = {}));
    function g(_, A) {
      return o.Sphere3D.fromDimensionsAndTransform((0, o.Sphere3D)(), _, A);
    }
  }(O5)), O5;
}
var G5 = {}, u9;
function Ep() {
  return u9 || (u9 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.Spheres = void 0;
    var r = Te, t = We(), n = Le, a = on, i = ru(), o = na, c = ut, s = nr(), u = Tc(), l = Xt, f = pa, d = $n, m = wr(), p = On, v = ha, h = Re, y = ga;
    (function(C) {
      function S(B, D, N, O, V, k) {
        return k ? A(B, D, N, O, V, k) : _(B, D, N, O, V);
      }
      C.create = S;
      function b(B) {
        var D = B ? B.centerBuffer.ref.value : new Float32Array(0), N = B ? B.mappingBuffer.ref.value : new Float32Array(0), O = B ? B.indexBuffer.ref.value : new Uint32Array(0), V = B ? B.groupBuffer.ref.value : new Float32Array(0);
        return S(D, N, O, V, 0, B);
      }
      C.createEmpty = b;
      function g(B) {
        return (0, m.hashFnv32a)([
          B.sphereCount,
          B.centerBuffer.ref.version,
          B.mappingBuffer.ref.version,
          B.indexBuffer.ref.version,
          B.groupBuffer.ref.version
        ]);
      }
      function _(B, D, N, O, V) {
        var k = (0, s.Sphere3D)(), G, L = -1, R = -1, F = {
          kind: "spheres",
          sphereCount: V,
          centerBuffer: t.ValueCell.create(B),
          mappingBuffer: t.ValueCell.create(D),
          indexBuffer: t.ValueCell.create(N),
          groupBuffer: t.ValueCell.create(O),
          get boundingSphere() {
            var U = g(F);
            if (U !== L) {
              var H = (0, c.calculateInvariantBoundingSphere)(F.centerBuffer.ref.value, F.sphereCount * 4, 4);
              s.Sphere3D.copy(k, H), L = U;
            }
            return k;
          },
          get groupMapping() {
            return F.groupBuffer.ref.version !== R && (G = (0, p.createGroupMapping)(F.groupBuffer.ref.value, F.sphereCount, 4), R = F.groupBuffer.ref.version), G;
          },
          setBoundingSphere: function(U) {
            s.Sphere3D.copy(k, U), L = g(F);
          }
        };
        return F;
      }
      function A(B, D, N, O, V, k) {
        return V > k.sphereCount && (t.ValueCell.update(k.mappingBuffer, D), t.ValueCell.update(k.indexBuffer, N)), k.sphereCount = V, t.ValueCell.update(k.centerBuffer, B), t.ValueCell.update(k.groupBuffer, O), k;
      }
      C.Params = (0, r.__assign)((0, r.__assign)({}, l.BaseGeometry.Params), { sizeFactor: n.ParamDefinition.Numeric(1, { min: 0, max: 10, step: 0.1 }), doubleSided: n.ParamDefinition.Boolean(!1, l.BaseGeometry.CustomQualityParamInfo), ignoreLight: n.ParamDefinition.Boolean(!1, l.BaseGeometry.ShadingCategory), xrayShaded: n.ParamDefinition.Boolean(!1, l.BaseGeometry.ShadingCategory), bumpFrequency: n.ParamDefinition.Numeric(0, { min: 0, max: 10, step: 0.1 }, l.BaseGeometry.ShadingCategory), bumpAmplitude: n.ParamDefinition.Numeric(1, { min: 0, max: 5, step: 0.1 }, l.BaseGeometry.ShadingCategory) }), C.Utils = {
        Params: C.Params,
        createEmpty: b,
        createValues: P,
        createValuesSimple: T,
        updateValues: x,
        updateBoundingSphere: w,
        createRenderableState: E,
        updateRenderableState: I,
        createPositionIterator: M
      };
      function M(B, D) {
        var N = B.sphereCount * 4, O = D.instanceCount.ref.value, V = (0, a.PositionLocation)(), k = V.position, G = B.centerBuffer.ref.value, L = D.aTransform.ref.value, R = function(F, U) {
          return U < 0 ? h.Vec3.fromArray(k, G, F * 3) : h.Vec3.transformMat4Offset(k, G, L, 0, F * 3, U * 16), V;
        };
        return (0, a.LocationIterator)(N, O, 4, R);
      }
      function P(B, D, N, O, V) {
        var k = N.instanceCount, G = N.groupCount, L = M(B, D), R = (0, i.createColors)(N, L, O.color), F = (0, u.createSizes)(N, O.size), U = (0, o.createMarkers)(k * G), H = (0, f.createEmptyOverpaint)(), q = (0, d.createEmptyTransparency)(), K = (0, y.createEmptySubstance)(), Y = (0, v.createEmptyClipping)(), X = {
          drawCount: B.sphereCount * 2 * 3,
          vertexCount: B.sphereCount * 4,
          groupCount: G,
          instanceCount: k
        }, Z = B.boundingSphere.radius ? (0, u.getMaxSize)(F) * V.sizeFactor : 0, J = s.Sphere3D.expand((0, s.Sphere3D)(), B.boundingSphere, Z), $ = (0, c.calculateTransformBoundingSphere)(J, D.aTransform.ref.value, k);
        return (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({ dGeometryType: t.ValueCell.create("spheres"), aPosition: B.centerBuffer, aMapping: B.mappingBuffer, aGroup: B.groupBuffer, elements: B.indexBuffer, boundingSphere: t.ValueCell.create($), invariantBoundingSphere: t.ValueCell.create(J), uInvariantBoundingSphere: t.ValueCell.create(h.Vec4.ofSphere(J)) }, R), F), U), H), q), K), Y), D), { padding: t.ValueCell.create(Z) }), l.BaseGeometry.createValues(V, X)), { uSizeFactor: t.ValueCell.create(V.sizeFactor), uDoubleSided: t.ValueCell.create(V.doubleSided), dIgnoreLight: t.ValueCell.create(V.ignoreLight), dXrayShaded: t.ValueCell.create(V.xrayShaded), uBumpFrequency: t.ValueCell.create(V.bumpFrequency), uBumpAmplitude: t.ValueCell.create(V.bumpAmplitude) });
      }
      function T(B, D, N, O, V) {
        var k = l.BaseGeometry.createSimple(N, O, V), G = (0, r.__assign)((0, r.__assign)({}, n.ParamDefinition.getDefaultValues(C.Params)), D);
        return P(B, k.transform, k.locationIterator, k.theme, G);
      }
      function x(B, D) {
        l.BaseGeometry.updateValues(B, D), t.ValueCell.updateIfChanged(B.uSizeFactor, D.sizeFactor), t.ValueCell.updateIfChanged(B.uDoubleSided, D.doubleSided), t.ValueCell.updateIfChanged(B.dIgnoreLight, D.ignoreLight), t.ValueCell.updateIfChanged(B.dXrayShaded, D.xrayShaded), t.ValueCell.updateIfChanged(B.uBumpFrequency, D.bumpFrequency), t.ValueCell.updateIfChanged(B.uBumpAmplitude, D.bumpAmplitude);
      }
      function w(B, D) {
        var N = D.boundingSphere.radius ? (0, u.getMaxSize)(B) * B.uSizeFactor.ref.value : 0, O = s.Sphere3D.expand((0, s.Sphere3D)(), D.boundingSphere, N), V = (0, c.calculateTransformBoundingSphere)(O, B.aTransform.ref.value, B.instanceCount.ref.value);
        s.Sphere3D.equals(V, B.boundingSphere.ref.value) || t.ValueCell.update(B.boundingSphere, V), s.Sphere3D.equals(O, B.invariantBoundingSphere.ref.value) || (t.ValueCell.update(B.invariantBoundingSphere, O), t.ValueCell.update(B.uInvariantBoundingSphere, h.Vec4.fromSphere(B.uInvariantBoundingSphere.ref.value, O))), t.ValueCell.update(B.padding, N);
      }
      function E(B) {
        var D = l.BaseGeometry.createRenderableState(B);
        return I(D, B), D;
      }
      function I(B, D) {
        l.BaseGeometry.updateRenderableState(B, D), B.opaque = B.opaque && !D.xrayShaded, B.writeDepth = B.opaque;
      }
    })(e.Spheres || (e.Spheres = {}));
  }(G5)), G5;
}
var q5 = {}, s9;
function yy() {
  return s9 || (s9 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.TextureMesh = void 0;
    var r = Te, t = We(), n = nr(), a = Le, i = on, o = ru(), c = na, s = Xt, u = pa, l = $n, f = ut, d = ps(), m = Re, p = ha, v = Ja, h = ga;
    (function(y) {
      var C = (
        /** @class */
        function() {
          function P() {
            this.index = 0, this.textures = [];
          }
          return P.prototype.get = function() {
            return this.textures[this.index];
          }, P.prototype.set = function(T, x, w) {
            this.textures[this.index] = Object.assign(this.textures[this.index] || {}, {
              vertex: T,
              group: x,
              normal: w
            }), this.index = (this.index + 1) % 2;
          }, P.prototype.destroy = function() {
            for (var T = 0, x = this.textures; T < x.length; T++) {
              var w = x[T];
              w.vertex.destroy(), w.group.destroy(), w.normal.destroy();
            }
          }, P;
        }()
      );
      y.DoubleBuffer = C;
      function S(P, T, x, w, E, I, B) {
        var D = x.getWidth(), N = x.getHeight();
        return B ? (B.vertexCount = P, B.groupCount = T, t.ValueCell.update(B.geoTextureDim, m.Vec2.set(B.geoTextureDim.ref.value, D, N)), t.ValueCell.update(B.vertexTexture, x), t.ValueCell.update(B.groupTexture, w), t.ValueCell.update(B.normalTexture, E), B.doubleBuffer.set(x, w, E), n.Sphere3D.copy(B.boundingSphere, I), B) : {
          kind: "texture-mesh",
          vertexCount: P,
          groupCount: T,
          geoTextureDim: t.ValueCell.create(m.Vec2.create(D, N)),
          vertexTexture: t.ValueCell.create(x),
          groupTexture: t.ValueCell.create(w),
          normalTexture: t.ValueCell.create(E),
          doubleBuffer: new C(),
          boundingSphere: n.Sphere3D.clone(I),
          meta: {}
        };
      }
      y.create = S;
      function b(P) {
        var T = P ? P.vertexTexture.ref.value : (0, d.createNullTexture)(), x = P ? P.groupTexture.ref.value : (0, d.createNullTexture)(), w = P ? P.normalTexture.ref.value : (0, d.createNullTexture)(), E = P ? P.boundingSphere : (0, n.Sphere3D)();
        return S(0, 0, T, x, w, E, P);
      }
      y.createEmpty = b, y.Params = (0, r.__assign)((0, r.__assign)({}, s.BaseGeometry.Params), { doubleSided: a.ParamDefinition.Boolean(!1, s.BaseGeometry.CustomQualityParamInfo), flipSided: a.ParamDefinition.Boolean(!1, s.BaseGeometry.ShadingCategory), flatShaded: a.ParamDefinition.Boolean(!1, s.BaseGeometry.ShadingCategory), ignoreLight: a.ParamDefinition.Boolean(!1, s.BaseGeometry.ShadingCategory), xrayShaded: a.ParamDefinition.Boolean(!1, s.BaseGeometry.ShadingCategory), bumpFrequency: a.ParamDefinition.Numeric(0, { min: 0, max: 10, step: 0.1 }, s.BaseGeometry.ShadingCategory), bumpAmplitude: a.ParamDefinition.Numeric(1, { min: 0, max: 5, step: 0.1 }, s.BaseGeometry.ShadingCategory) }), y.Utils = {
        Params: y.Params,
        createEmpty: b,
        createValues: g,
        createValuesSimple: _,
        updateValues: A,
        updateBoundingSphere: M,
        createRenderableState: s.BaseGeometry.createRenderableState,
        updateRenderableState: s.BaseGeometry.updateRenderableState,
        createPositionIterator: function() {
          return (0, i.LocationIterator)(1, 1, 1, function() {
            return v.NullLocation;
          });
        }
      };
      function g(P, T, x, w, E) {
        var I = x.instanceCount, B = x.groupCount, D = y.Utils.createPositionIterator(P, T), N = (0, o.createColors)(x, D, w.color), O = (0, c.createMarkers)(I * B), V = (0, u.createEmptyOverpaint)(), k = (0, l.createEmptyTransparency)(), G = (0, h.createEmptySubstance)(), L = (0, p.createEmptyClipping)(), R = { drawCount: P.vertexCount, vertexCount: P.vertexCount, groupCount: B, instanceCount: I }, F = n.Sphere3D.clone(P.boundingSphere), U = (0, f.calculateTransformBoundingSphere)(F, T.aTransform.ref.value, I);
        return (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({ dGeometryType: t.ValueCell.create("textureMesh"), uGeoTexDim: P.geoTextureDim, tPosition: P.vertexTexture, tGroup: P.groupTexture, tNormal: P.normalTexture, boundingSphere: t.ValueCell.create(U), invariantBoundingSphere: t.ValueCell.create(F), uInvariantBoundingSphere: t.ValueCell.create(m.Vec4.ofSphere(F)) }, N), O), V), k), G), L), T), s.BaseGeometry.createValues(E, R)), { uDoubleSided: t.ValueCell.create(E.doubleSided), dFlatShaded: t.ValueCell.create(E.flatShaded), dFlipSided: t.ValueCell.create(E.flipSided), dIgnoreLight: t.ValueCell.create(E.ignoreLight), dXrayShaded: t.ValueCell.create(E.xrayShaded), uBumpFrequency: t.ValueCell.create(E.bumpFrequency), uBumpAmplitude: t.ValueCell.create(E.bumpAmplitude), meta: t.ValueCell.create(P.meta) });
      }
      function _(P, T, x, w, E) {
        var I = s.BaseGeometry.createSimple(x, w, E), B = (0, r.__assign)((0, r.__assign)({}, a.ParamDefinition.getDefaultValues(y.Params)), T);
        return g(P, I.transform, I.locationIterator, I.theme, B);
      }
      function A(P, T) {
        s.BaseGeometry.updateValues(P, T), t.ValueCell.updateIfChanged(P.uDoubleSided, T.doubleSided), t.ValueCell.updateIfChanged(P.dFlatShaded, T.flatShaded), t.ValueCell.updateIfChanged(P.dFlipSided, T.flipSided), t.ValueCell.updateIfChanged(P.dIgnoreLight, T.ignoreLight), t.ValueCell.updateIfChanged(P.dXrayShaded, T.xrayShaded), t.ValueCell.updateIfChanged(P.uBumpFrequency, T.bumpFrequency), t.ValueCell.updateIfChanged(P.uBumpAmplitude, T.bumpAmplitude);
      }
      function M(P, T) {
        var x = n.Sphere3D.clone(T.boundingSphere), w = (0, f.calculateTransformBoundingSphere)(x, P.aTransform.ref.value, P.instanceCount.ref.value);
        n.Sphere3D.equals(w, P.boundingSphere.ref.value) || t.ValueCell.update(P.boundingSphere, w), n.Sphere3D.equals(x, P.invariantBoundingSphere.ref.value) || (t.ValueCell.update(P.invariantBoundingSphere, x), t.ValueCell.update(P.uInvariantBoundingSphere, m.Vec4.fromSphere(P.uInvariantBoundingSphere.ref.value, x)));
      }
    })(e.TextureMesh || (e.TextureMesh = {}));
  }(q5)), q5;
}
var H5 = {}, Yi = {}, yn = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.BaseSchema = e.ClippingSchema = e.SubstanceSchema = e.TransparencySchema = e.OverpaintSchema = e.MarkerSchema = e.SizeSchema = e.ColorSchema = e.InternalSchema = e.GlobalTextureSchema = e.GlobalUniformSchema = e.ValueSpec = e.DefineSpec = e.ElementsSpec = e.TextureSpec = e.UniformSpec = e.AttributeSpec = e.getValueVersions = e.splitValues = void 0;
  var r = Te;
  function t(l, f) {
    var d = {}, m = {}, p = {}, v = {}, h = {}, y = {};
    return Object.keys(l).forEach(function(C) {
      var S = l[C];
      S.type === "attribute" && (d[C] = f[C]), S.type === "define" && (m[C] = f[C]), S.type === "texture" && f[C] !== void 0 && (p[C] = f[C]), S.type === "uniform" && f[C] !== void 0 && (S.variant === "material" ? h[C] = f[C] : S.variant === "buffered" ? y[C] = f[C] : v[C] = f[C]);
    }), {
      attributeValues: d,
      defineValues: m,
      textureValues: p,
      uniformValues: v,
      materialUniformValues: h,
      bufferedUniformValues: y
    };
  }
  e.splitValues = t;
  function n(l) {
    var f = {};
    return Object.keys(l).forEach(function(d) {
      f[d] = l[d].ref.version;
    }), f;
  }
  e.getValueVersions = n;
  function a(l, f, d) {
    return { type: "attribute", kind: l, itemSize: f, divisor: d };
  }
  e.AttributeSpec = a;
  function i(l, f) {
    return { type: "uniform", kind: l, variant: f };
  }
  e.UniformSpec = i;
  function o(l, f, d, m) {
    return { type: "texture", kind: l, format: f, dataType: d, filter: m };
  }
  e.TextureSpec = o;
  function c(l) {
    return { type: "elements", kind: l };
  }
  e.ElementsSpec = c;
  function s(l, f) {
    return { type: "define", kind: l, options: f };
  }
  e.DefineSpec = s;
  function u(l) {
    return { type: "value", kind: l };
  }
  e.ValueSpec = u, e.GlobalUniformSchema = {
    uModel: i("m4"),
    uView: i("m4"),
    uInvView: i("m4"),
    uModelView: i("m4"),
    uInvModelView: i("m4"),
    uProjection: i("m4"),
    uInvProjection: i("m4"),
    uModelViewProjection: i("m4"),
    uInvModelViewProjection: i("m4"),
    uIsOrtho: i("f"),
    uPixelRatio: i("f"),
    uViewport: i("v4"),
    uViewOffset: i("v2"),
    uDrawingBufferSize: i("v2"),
    uCameraPosition: i("v3"),
    uCameraDir: i("v3"),
    uNear: i("f"),
    uFar: i("f"),
    uFogNear: i("f"),
    uFogFar: i("f"),
    uFogColor: i("v3"),
    uTransparentBackground: i("b"),
    uLightDirection: i("v3[]"),
    uLightColor: i("v3[]"),
    uAmbientColor: i("v3"),
    uPickingAlphaThreshold: i("f"),
    uInteriorDarkening: i("f"),
    uInteriorColorFlag: i("b"),
    uInteriorColor: i("v3"),
    uHighlightColor: i("v3"),
    uSelectColor: i("v3"),
    uHighlightStrength: i("f"),
    uSelectStrength: i("f"),
    uMarkerPriority: i("i"),
    uXrayEdgeFalloff: i("f"),
    uRenderWboit: i("b"),
    uMarkingDepthTest: i("b"),
    uMarkingType: i("i"),
    uPickType: i("i"),
    // hermite 配体错误原子标识
    uInvalidColor: i("v3"),
    uInvalidStrength: i("f")
  }, e.GlobalTextureSchema = {
    tDepth: o("texture", "depth", "ushort", "nearest")
  }, e.InternalSchema = {
    uObjectId: i("i")
  }, e.ColorSchema = {
    // aColor: AttributeSpec('float32', 3, 0), // TODO
    uColor: i("v3", "material"),
    uColorTexDim: i("v2"),
    uColorGridDim: i("v3"),
    uColorGridTransform: i("v4"),
    tColor: o("image-uint8", "rgb", "ubyte", "nearest"),
    tPalette: o("image-uint8", "rgb", "ubyte", "nearest"),
    tColorGrid: o("texture", "rgb", "ubyte", "linear"),
    dColorType: s("string", [
      "uniform",
      "attribute",
      "instance",
      "group",
      "groupInstance",
      "vertex",
      "vertexInstance",
      "volume",
      "volumeInstance",
      "direct"
    ]),
    dUsePalette: s("boolean")
  }, e.SizeSchema = {
    // aSize: AttributeSpec('float32', 1, 0), // TODO
    uSize: i("f", "material"),
    uSizeTexDim: i("v2"),
    tSize: o("image-uint8", "rgb", "ubyte", "nearest"),
    dSizeType: s("string", [
      "uniform",
      "attribute",
      "instance",
      "group",
      "groupInstance"
    ]),
    uSizeFactor: i("f")
  }, e.MarkerSchema = {
    uMarker: i("f"),
    uMarkerTexDim: i("v2"),
    tMarker: o("image-uint8", "alpha", "ubyte", "nearest"),
    markerAverage: u("number"),
    markerStatus: u("number")
  }, e.OverpaintSchema = {
    uOverpaintTexDim: i("v2"),
    tOverpaint: o("image-uint8", "rgba", "ubyte", "nearest"),
    dOverpaint: s("boolean"),
    uOverpaintGridDim: i("v3"),
    uOverpaintGridTransform: i("v4"),
    tOverpaintGrid: o("texture", "rgba", "ubyte", "linear"),
    dOverpaintType: s("string", ["groupInstance", "volumeInstance"])
  }, e.TransparencySchema = {
    uTransparencyTexDim: i("v2"),
    tTransparency: o("image-uint8", "alpha", "ubyte", "nearest"),
    dTransparency: s("boolean"),
    transparencyAverage: u("number"),
    uTransparencyGridDim: i("v3"),
    uTransparencyGridTransform: i("v4"),
    tTransparencyGrid: o("texture", "alpha", "ubyte", "linear"),
    dTransparencyType: s("string", ["groupInstance", "volumeInstance"])
  }, e.SubstanceSchema = {
    uSubstanceTexDim: i("v2"),
    tSubstance: o("image-uint8", "rgba", "ubyte", "nearest"),
    dSubstance: s("boolean"),
    uSubstanceGridDim: i("v3"),
    uSubstanceGridTransform: i("v4"),
    tSubstanceGrid: o("texture", "rgba", "ubyte", "linear"),
    dSubstanceType: s("string", ["groupInstance", "volumeInstance"])
  }, e.ClippingSchema = {
    uClippingTexDim: i("v2"),
    tClipping: o("image-uint8", "alpha", "ubyte", "nearest"),
    dClipping: s("boolean")
  }, e.BaseSchema = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({ dGeometryType: s("string", [
    "cylinders",
    "directVolume",
    "image",
    "lines",
    "mesh",
    "points",
    "spheres",
    "text",
    "textureMesh"
  ]) }, e.ColorSchema), e.MarkerSchema), e.OverpaintSchema), e.TransparencySchema), e.SubstanceSchema), e.ClippingSchema), {
    dLightCount: s("number"),
    dClipObjectCount: s("number"),
    dClipVariant: s("string", ["instance", "pixel"]),
    uClipObjectType: i("i[]"),
    uClipObjectInvert: i("b[]"),
    uClipObjectPosition: i("v3[]"),
    uClipObjectRotation: i("v4[]"),
    uClipObjectScale: i("v3[]"),
    aInstance: a("float32", 1, 1),
    /**
     * final per-instance transform calculated for instance `i` as
     * `aTransform[i] = matrix * transform[i] * extraTransform[i]`
     */
    aTransform: a("float32", 16, 1),
    /**
     * final alpha, calculated as `values.alpha * state.alpha`
     */
    uAlpha: i("f", "material"),
    uMetalness: i("f", "material"),
    uRoughness: i("f", "material"),
    uBumpiness: i("f", "material"),
    uVertexCount: i("i"),
    uInstanceCount: i("i"),
    uGroupCount: i("i"),
    uInvariantBoundingSphere: i("v4"),
    drawCount: u("number"),
    instanceCount: u("number"),
    /** base alpha, see uAlpha  */
    alpha: u("number"),
    /** global transform, see aTransform */
    matrix: u("m4"),
    /** base per-instance transform, see aTransform */
    transform: u("float32"),
    /** additional per-instance transform, see aTransform */
    extraTransform: u("float32"),
    /** denotes reflection in transform */
    hasReflection: u("boolean"),
    /** bounding sphere taking aTransform into account and encompases all instances */
    boundingSphere: u("sphere"),
    /** bounding sphere NOT taking aTransform into account */
    invariantBoundingSphere: u("sphere")
  });
})(yn);
var d4 = {};
Object.defineProperty(d4, "__esModule", { value: !0 });
d4.copy_frag = void 0;
d4.copy_frag = `
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);
}
`;
var Qi = {};
Object.defineProperty(Qi, "__esModule", { value: !0 });
Qi.quad_vert = void 0;
Qi.quad_vert = `
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);
}
`;
var Lt = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.createRenderItem = e.createComputeRenderItem = e.createGraphicsRenderItem = e.ComputeRenderVariants = e.GraphicsRenderVariantsWboit = e.GraphicsRenderVariantsBlended = e.GraphicsRenderVariants = e.getDrawMode = void 0;
  var r = Te, t = Na, n = ps(), a = dE(), i = yn, o = Ra, c = We(), s = ay(), u = Zt, l = hr, f = nn, d = Ko, m = (0, o.idFactory)();
  function p(A, M) {
    var P = A.gl;
    switch (M) {
      case "points":
        return P.POINTS;
      case "lines":
        return P.LINES;
      case "line-strip":
        return P.LINE_STRIP;
      case "line-loop":
        return P.LINE_LOOP;
      case "triangles":
        return P.TRIANGLES;
      case "triangle-strip":
        return P.TRIANGLE_STRIP;
      case "triangle-fan":
        return P.TRIANGLE_FAN;
    }
  }
  e.getDrawMode = p;
  var v = {
    colorBlended: "",
    colorWboit: "",
    pick: "",
    depth: "",
    marking: ""
  };
  e.GraphicsRenderVariants = Object.keys(v), e.GraphicsRenderVariantsBlended = e.GraphicsRenderVariants.filter(function(A) {
    return A !== "colorWboit";
  }), e.GraphicsRenderVariantsWboit = e.GraphicsRenderVariants.filter(function(A) {
    return A !== "colorBlended";
  });
  var h = { compute: "" };
  e.ComputeRenderVariants = Object.keys(h);
  function y(A, M, P, T, x) {
    return P = (0, r.__assign)((0, r.__assign)({}, P), { dRenderVariant: c.ValueCell.create(M) }), x.dRenderVariant === void 0 && Object.defineProperty(x, "dRenderVariant", {
      value: (0, i.DefineSpec)("string")
    }), A.resources.program(P, T, x);
  }
  function C() {
    return {
      attributes: !1,
      defines: !1,
      elements: !1,
      textures: !1
    };
  }
  function S(A) {
    A.attributes = !1, A.defines = !1, A.elements = !1, A.textures = !1;
  }
  function b(A, M, P, T, x, w, E) {
    return _(A, M, P, T, x, w, E);
  }
  e.createGraphicsRenderItem = b;
  function g(A, M, P, T, x, w) {
    return w === void 0 && (w = -1), _(A, M, P, T, x, w, e.ComputeRenderVariants);
  }
  e.createComputeRenderItem = g;
  function _(A, M, P, T, x, w, E) {
    var I = m(), B = A.stats, D = A.state, N = A.resources, O = A.extensions, V = O.instancedArrays, k = O.vertexArrayObject;
    if (x.uVertexCount) {
      var G = x.uVertexCount.ref.value;
      x.aVertex = c.ValueCell.create((0, l.fillSerial)(new Float32Array(G))), T.aVertex = (0, i.AttributeSpec)("float32", 1, 0);
    }
    for (var L = (0, i.splitValues)(T, x), R = L.attributeValues, F = L.defineValues, U = L.textureValues, H = L.uniformValues, q = L.materialUniformValues, K = L.bufferedUniformValues, Y = Object.entries(H), X = Object.entries(q), Z = Object.entries(K), J = Object.entries((0, d.cloneUniformValues)(K)), $ = Object.entries(F), Q = (0, i.getValueVersions)(x), W = p(A, M), te = {}, oe = 0, z = E; oe < z.length; oe++) {
      var j = z[oe];
      te[j] = y(A, j, F, P, T);
    }
    var ae = (0, n.createTextures)(A, T, U), le = (0, t.createAttributeBuffers)(A, T, R), ie, re = x.elements;
    re && re.ref.value && (ie = N.elements(re.ref.value));
    for (var ee = {}, ne = 0, se = E; ne < se.length; ne++) {
      var j = se[ne];
      ee[j] = k ? N.vertexArray(te[j], le, ie) : null;
    }
    var ce = x.drawCount.ref.value, de = x.instanceCount.ref.value;
    B.drawCount += ce, B.instanceCount += de, B.instancedDrawCount += de * ce;
    var me = C(), he = !1, _e = -1;
    return {
      id: I,
      materialId: w,
      getProgram: function(Se) {
        return te[Se];
      },
      render: function(Se, Pe) {
        if (!(ce === 0 || de === 0 || A.isContextLost)) {
          var De = te[Se];
          if (De.id === _e && D.currentRenderItemId === I)
            De.setUniforms(Y), Pe && Pe.length > 0 ? (De.bindTextures(Pe, 0), De.bindTextures(ae, Pe.length)) : De.bindTextures(ae, 0);
          else {
            var Ee = ee[Se];
            (De.id !== D.currentProgramId || De.id !== _e || w === -1 || w !== D.currentMaterialId) && (De.id !== D.currentProgramId && De.use(), De.setUniforms(X), D.currentMaterialId = w, _e = De.id), De.setUniforms(Y), De.setUniforms(J), Pe && Pe.length > 0 ? (De.bindTextures(Pe, 0), De.bindTextures(ae, Pe.length)) : De.bindTextures(ae, 0), Ee ? (Ee.bind(), ie && ie.bind()) : (ie && ie.bind(), De.bindAttributes(le)), D.currentRenderItemId = I;
          }
          if (u.isDebugMode)
            try {
              (0, s.checkFramebufferStatus)(A.gl);
            } catch (Me) {
              throw new Error("Framebuffer error rendering item id ".concat(I, ": '").concat(Me, "'"));
            }
          if (ie ? V.drawElementsInstanced(W, ce, ie._dataType, 0, de) : V.drawArraysInstanced(W, 0, ce, de), u.isDebugMode)
            try {
              (0, a.checkError)(A.gl);
            } catch (Me) {
              throw new Error("Draw error rendering item id ".concat(I, ": '").concat(Me, "'"));
            }
        }
      },
      update: function() {
        if (S(me), x.aVertex) {
          var Se = x.uVertexCount.ref.value;
          x.aVertex.ref.value.length < Se && c.ValueCell.update(x.aVertex, (0, l.fillSerial)(new Float32Array(Se)));
        }
        for (var Pe = 0, De = $.length; Pe < De; ++Pe) {
          var Ee = $[Pe], Me = Ee[0], ue = Ee[1];
          ue.ref.version !== Q[Me] && (me.defines = !0, Q[Me] = ue.ref.version);
        }
        if (me.defines)
          for (var pe = 0, Ae = E; pe < Ae.length; pe++) {
            var Me = Ae[pe];
            te[Me].destroy(), te[Me] = y(A, Me, F, P, T);
          }
        x.drawCount.ref.version !== Q.drawCount && (B.drawCount += x.drawCount.ref.value - ce, B.instancedDrawCount += de * x.drawCount.ref.value - de * ce, ce = x.drawCount.ref.value, Q.drawCount = x.drawCount.ref.version), x.instanceCount.ref.version !== Q.instanceCount && (B.instanceCount += x.instanceCount.ref.value - de, B.instancedDrawCount += x.instanceCount.ref.value * ce - de * ce, de = x.instanceCount.ref.value, Q.instanceCount = x.instanceCount.ref.version);
        for (var Pe = 0, De = le.length; Pe < De; ++Pe) {
          var ye = le[Pe], Me = ye[0], be = ye[1], ue = R[Me];
          if (ue.ref.version !== Q[Me]) {
            if (be.length >= ue.ref.value.length)
              be.updateSubData(ue.ref.value, 0, be.length);
            else {
              be.destroy();
              var fe = T[Me], ge = fe.itemSize, xe = fe.divisor;
              le[Pe][1] = N.attribute(ue.ref.value, ge, xe), me.attributes = !0;
            }
            Q[Me] = ue.ref.version;
          }
        }
        if (ie && x.elements.ref.version !== Q.elements && (ie.length >= x.elements.ref.value.length ? ie.updateSubData(x.elements.ref.value, 0, ie.length) : (ie.destroy(), ie = N.elements(x.elements.ref.value), me.elements = !0), Q.elements = x.elements.ref.version), me.attributes || me.defines || me.elements)
          for (var we = 0, Ve = E; we < Ve.length; we++) {
            var Me = Ve[we], Ne = ee[Me];
            Ne && Ne.destroy(), ee[Me] = k ? N.vertexArray(te[Me], le, ie) : null;
          }
        for (var Pe = 0, De = ae.length; Pe < De; ++Pe) {
          var Oe = ae[Pe], Me = Oe[0], ze = Oe[1], ue = U[Me];
          ue.ref.version !== Q[Me] && (T[Me].kind !== "texture" ? (ze.load(ue.ref.value), me.textures = !0) : ae[Pe][1] = ue.ref.value, Q[Me] = ue.ref.version);
        }
        for (var Pe = 0, De = Z.length; Pe < De; ++Pe) {
          var ke = Z[Pe], Me = ke[0], je = ke[1];
          je.ref.version !== Q[Me] && (c.ValueCell.update(J[Pe][1], (0, f.deepClone)(je.ref.value)), Q[Me] = je.ref.version);
        }
        return me;
      },
      destroy: function() {
        if (!he) {
          for (var Se = 0, Pe = E; Se < Pe.length; Se++) {
            var De = Pe[Se];
            te[De].destroy();
            var Ee = ee[De];
            Ee && Ee.destroy();
          }
          ae.forEach(function(Me) {
            var ue = Me[0], pe = Me[1];
            T[ue].kind !== "texture" && pe.destroy();
          }), le.forEach(function(Me) {
            Me[0];
            var ue = Me[1];
            return ue.destroy();
          }), ie && ie.destroy(), B.drawCount -= ce, B.instanceCount -= de, B.instancedDrawCount -= de * ce, he = !0;
        }
      }
    };
  }
  e.createRenderItem = _;
})(Lt);
var Kt = {};
Object.defineProperty(Kt, "__esModule", { value: !0 });
Kt.createComputeRenderable = Kt.createRenderable = void 0;
var jce = We(), $ce = Ra, Kce = Zr, YG = (0, $ce.idFactory)();
function Wce(e, r, t) {
  return {
    id: YG(),
    materialId: e.materialId,
    values: r,
    state: t,
    render: function(n, a) {
      r.uAlpha && r.alpha && jce.ValueCell.updateIfChanged(r.uAlpha, (0, Kce.clamp)(r.alpha.ref.value * t.alphaFactor, 0, 1)), e.render(n, a);
    },
    getProgram: function(n) {
      return e.getProgram(n);
    },
    update: function() {
      return e.update();
    },
    dispose: function() {
      return e.destroy();
    }
  };
}
Kt.createRenderable = Wce;
function Xce(e, r) {
  return {
    id: YG(),
    values: r,
    render: function() {
      return e.render("compute");
    },
    update: function() {
      return e.update();
    },
    dispose: function() {
      return e.destroy();
    }
  };
}
Kt.createComputeRenderable = Xce;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.readAlphaTexture = e.readTexture = e.getSharedCopyRenderable = e.createCopyRenderable = e.QuadValues = e.QuadSchema = e.QuadPositions = void 0;
  var r = Te, t = ps(), n = We(), a = yn, i = Re, o = Bn(), c = d4, s = Qi, u = Lt, l = Kt;
  e.QuadPositions = new Float32Array([
    1,
    1,
    -1,
    1,
    -1,
    -1,
    -1,
    -1,
    1,
    -1,
    1,
    1
    // Second triangle
  ]), e.QuadSchema = {
    drawCount: (0, a.ValueSpec)("number"),
    instanceCount: (0, a.ValueSpec)("number"),
    aPosition: (0, a.AttributeSpec)("float32", 2, 0),
    uQuadScale: (0, a.UniformSpec)("v2")
  }, e.QuadValues = {
    drawCount: n.ValueCell.create(6),
    instanceCount: n.ValueCell.create(1),
    aPosition: n.ValueCell.create(e.QuadPositions),
    uQuadScale: n.ValueCell.create(i.Vec2.create(1, 1))
  };
  var f = (0, r.__assign)((0, r.__assign)({}, e.QuadSchema), { tColor: (0, a.TextureSpec)("texture", "rgba", "ubyte", "nearest"), uTexSize: (0, a.UniformSpec)("v2") }), d = (0, o.ShaderCode)("copy", s.quad_vert, c.copy_frag);
  function m(b, g) {
    var _ = (0, r.__assign)((0, r.__assign)({}, e.QuadValues), { tColor: n.ValueCell.create(g), uTexSize: n.ValueCell.create(i.Vec2.create(g.getWidth(), g.getHeight())) }), A = (0, r.__assign)({}, f), M = (0, u.createComputeRenderItem)(b, "triangles", d, A, _);
    return (0, l.createComputeRenderable)(M, _);
  }
  e.createCopyRenderable = m;
  var p = "shared-copy";
  function v(b, g) {
    b.namedComputeRenderables[p] || (b.namedComputeRenderables[p] = m(b, (0, t.createNullTexture)()));
    var _ = b.namedComputeRenderables[p];
    return n.ValueCell.update(_.values.tColor, g), n.ValueCell.update(_.values.uTexSize, i.Vec2.set(_.values.uTexSize.ref.value, g.getWidth(), g.getHeight())), _.update(), _;
  }
  e.getSharedCopyRenderable = v;
  var h = "read-texture", y = "read-alpha-texture";
  function C(b, g) {
    var _ = b.gl, A = b.resources;
    if (g.type !== _.UNSIGNED_BYTE)
      throw new Error("unsupported texture type");
    b.namedFramebuffers[h] || (b.namedFramebuffers[h] = A.framebuffer());
    var M = b.namedFramebuffers[h], P = g.getWidth(), T = g.getHeight(), x = new Uint8Array(P * T * 4);
    return M.bind(), g.attachFramebuffer(M, 0), b.readPixels(0, 0, P, T, x), { array: x, width: P, height: T };
  }
  e.readTexture = C;
  function S(b, g) {
    var _ = b.gl, A = b.state, M = b.resources;
    if (g.type !== _.UNSIGNED_BYTE)
      throw new Error("unsupported texture type");
    var P = g.getWidth(), T = g.getHeight(), x = v(b, g);
    A.currentRenderItemId = -1, b.namedFramebuffers[y] || (b.namedFramebuffers[y] = M.framebuffer());
    var w = b.namedFramebuffers[y];
    w.bind(), b.namedTextures[y] || (b.namedTextures[y] = M.texture("image-uint8", "rgba", "ubyte", "linear"));
    var E = b.namedTextures[y];
    E.define(P, T), E.attachFramebuffer(w, 0), A.disable(_.CULL_FACE), A.enable(_.BLEND), A.disable(_.DEPTH_TEST), A.enable(_.SCISSOR_TEST), A.depthMask(!1), A.clearColor(0, 0, 0, 0), A.blendFunc(_.ONE, _.ONE), A.blendEquation(_.FUNC_ADD), _.viewport(0, 0, P, T), _.scissor(0, 0, P, T), _.clear(_.COLOR_BUFFER_BIT), x.render();
    var I = new Uint8Array(P * T * 4);
    return b.readPixels(0, 0, P, T, I), { array: I, width: P, height: T };
  }
  e.readAlphaTexture = S;
})(Yi);
var l9;
function QG() {
  return l9 || (l9 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.Image = e.InterpolationTypeNames = e.InterpolationTypes = void 0;
    var r = Te, t = wr(), n = on, a = ut, i = nr(), o = Re, c = We(), s = Le, u = Xt, l = ru(), f = na, d = pa, m = $n, p = hr, v = ha, h = Ja, y = Yi, C = ga, S = new Uint32Array([
      0,
      1,
      2,
      1,
      3,
      2
    ]), b = new Float32Array([
      0,
      1,
      0,
      0,
      1,
      1,
      1,
      0
    ]);
    e.InterpolationTypes = {
      nearest: "Nearest",
      catmulrom: "Catmulrom (Cubic)",
      mitchell: "Mitchell (Cubic)",
      bspline: "B-Spline (Cubic)"
    }, e.InterpolationTypeNames = Object.keys(e.InterpolationTypes);
    var g;
    (function(A) {
      function M(V, k, G, L) {
        return L ? x(V, k, G, L) : T(V, k, G);
      }
      A.create = M;
      function P(V) {
        return (0, t.hashFnv32a)([
          V.cornerBuffer.ref.version
        ]);
      }
      function T(V, k, G) {
        var L = (0, i.Sphere3D)(), R = -1, F = V.width, U = V.height, H = {
          kind: "image",
          imageTexture: c.ValueCell.create(V),
          imageTextureDim: c.ValueCell.create(o.Vec2.create(F, U)),
          cornerBuffer: c.ValueCell.create(k),
          groupTexture: c.ValueCell.create(G),
          get boundingSphere() {
            var q = P(H);
            if (q !== R) {
              var K = _(H.cornerBuffer.ref.value);
              i.Sphere3D.copy(L, K), R = q;
            }
            return L;
          }
        };
        return H;
      }
      function x(V, k, G, L) {
        var R = V.width, F = V.height;
        return c.ValueCell.update(L.imageTexture, V), c.ValueCell.update(L.imageTextureDim, o.Vec2.set(L.imageTextureDim.ref.value, R, F)), c.ValueCell.update(L.cornerBuffer, k), c.ValueCell.update(L.groupTexture, G), L;
      }
      function w(V) {
        var k = (0, a.createTextureImage)(0, 4, Uint8Array), G = V ? V.cornerBuffer.ref.value : new Float32Array(8 * 3), L = (0, a.createTextureImage)(0, 4, Uint8Array);
        return M(k, G, L, V);
      }
      A.createEmpty = w, A.Params = (0, r.__assign)((0, r.__assign)({}, u.BaseGeometry.Params), { interpolation: s.ParamDefinition.Select("bspline", s.ParamDefinition.objectToOptions(e.InterpolationTypes)) }), A.Utils = {
        Params: A.Params,
        createEmpty: w,
        createValues: E,
        createValuesSimple: I,
        updateValues: B,
        updateBoundingSphere: D,
        createRenderableState: N,
        updateRenderableState: O,
        createPositionIterator: function() {
          return (0, n.LocationIterator)(1, 1, 1, function() {
            return h.NullLocation;
          });
        }
      };
      function E(V, k, G, L, R) {
        var F = G.instanceCount, U = G.groupCount, H = A.Utils.createPositionIterator(V, k), q = (0, l.createColors)(G, H, L.color), K = (0, f.createMarkers)(F * U), Y = (0, d.createEmptyOverpaint)(), X = (0, m.createEmptyTransparency)(), Z = (0, C.createEmptySubstance)(), J = (0, v.createEmptyClipping)(), $ = { drawCount: S.length, vertexCount: y.QuadPositions.length / 3, groupCount: U, instanceCount: F }, Q = i.Sphere3D.clone(V.boundingSphere), W = (0, a.calculateTransformBoundingSphere)(Q, k.aTransform.ref.value, F);
        return (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({ dGeometryType: c.ValueCell.create("image") }, q), K), Y), X), Z), J), k), u.BaseGeometry.createValues(R, $)), {
          aPosition: V.cornerBuffer,
          aUv: c.ValueCell.create(b),
          elements: c.ValueCell.create(S),
          // aGroup is used as a vertex index here, group id is in tGroupTex
          aGroup: c.ValueCell.create((0, p.fillSerial)(new Float32Array(4))),
          boundingSphere: c.ValueCell.create(W),
          invariantBoundingSphere: c.ValueCell.create(Q),
          uInvariantBoundingSphere: c.ValueCell.create(o.Vec4.ofSphere(Q)),
          dInterpolation: c.ValueCell.create(R.interpolation),
          uImageTexDim: V.imageTextureDim,
          tImageTex: V.imageTexture,
          tGroupTex: V.groupTexture
        });
      }
      function I(V, k, G, L, R) {
        var F = u.BaseGeometry.createSimple(G, L, R), U = (0, r.__assign)((0, r.__assign)({}, s.ParamDefinition.getDefaultValues(A.Params)), k);
        return E(V, F.transform, F.locationIterator, F.theme, U);
      }
      function B(V, k) {
        u.BaseGeometry.updateValues(V, k), c.ValueCell.updateIfChanged(V.dInterpolation, k.interpolation);
      }
      function D(V, k) {
        var G = i.Sphere3D.clone(k.boundingSphere), L = (0, a.calculateTransformBoundingSphere)(G, V.aTransform.ref.value, V.instanceCount.ref.value);
        i.Sphere3D.equals(L, V.boundingSphere.ref.value) || c.ValueCell.update(V.boundingSphere, L), i.Sphere3D.equals(G, V.invariantBoundingSphere.ref.value) || (c.ValueCell.update(V.invariantBoundingSphere, G), c.ValueCell.update(V.uInvariantBoundingSphere, o.Vec4.fromSphere(V.uInvariantBoundingSphere.ref.value, G)));
      }
      function N(V) {
        var k = u.BaseGeometry.createRenderableState(V);
        return k.opaque = !1, k;
      }
      function O(V, k) {
        u.BaseGeometry.updateRenderableState(V, k), V.opaque = !1;
      }
    })(g || (g = {})), e.Image = g;
    function _(A) {
      for (var M = (0, o.Vec3)(), P = [], T = 0, x = A.length; T < x; T += 3) {
        var w = o.Vec3.fromArray((0, o.Vec3)(), A, T);
        P.push(w), o.Vec3.add(M, M, w);
      }
      o.Vec3.scale(M, M, 1 / (A.length / 3));
      for (var E = 0, I = 0, B = P; I < B.length; I++) {
        var w = B[I], D = o.Vec3.distance(M, w);
        D > E && (E = D);
      }
      var N = i.Sphere3D.create(M, E);
      return i.Sphere3D.setExtrema(N, P), N;
    }
  }(H5)), H5;
}
var j5 = {}, c9;
function hl() {
  return c9 || (c9 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.Cylinders = void 0;
    var r = Te, t = We(), n = Re, a = On, i = ru(), o = na, c = Tc(), s = on, u = Le, l = ut, f = nr(), d = Xt, m = pa, p = $n, v = wr(), h = ha, y = ga;
    (function(C) {
      function S(D, N, O, V, k, G, L, R, F) {
        return F ? A(D, N, O, V, k, G, L, R, F) : _(D, N, O, V, k, G, L, R);
      }
      C.create = S;
      function b(D) {
        var N = D ? D.mappingBuffer.ref.value : new Float32Array(0), O = D ? D.indexBuffer.ref.value : new Uint32Array(0), V = D ? D.groupBuffer.ref.value : new Float32Array(0), k = D ? D.startBuffer.ref.value : new Float32Array(0), G = D ? D.endBuffer.ref.value : new Float32Array(0), L = D ? D.scaleBuffer.ref.value : new Float32Array(0), R = D ? D.capBuffer.ref.value : new Float32Array(0);
        return S(N, O, V, k, G, L, R, 0, D);
      }
      C.createEmpty = b;
      function g(D) {
        return (0, v.hashFnv32a)([
          D.cylinderCount,
          D.mappingBuffer.ref.version,
          D.indexBuffer.ref.version,
          D.groupBuffer.ref.version,
          D.startBuffer.ref.version,
          D.endBuffer.ref.version,
          D.scaleBuffer.ref.version,
          D.capBuffer.ref.version
        ]);
      }
      function _(D, N, O, V, k, G, L, R) {
        var F = (0, f.Sphere3D)(), U, H = -1, q = -1, K = {
          kind: "cylinders",
          cylinderCount: R,
          mappingBuffer: t.ValueCell.create(D),
          indexBuffer: t.ValueCell.create(N),
          groupBuffer: t.ValueCell.create(O),
          startBuffer: t.ValueCell.create(V),
          endBuffer: t.ValueCell.create(k),
          scaleBuffer: t.ValueCell.create(G),
          capBuffer: t.ValueCell.create(L),
          get boundingSphere() {
            var Y = g(K);
            if (Y !== H) {
              var X = (0, l.calculateInvariantBoundingSphere)(K.startBuffer.ref.value, K.cylinderCount * 6, 6), Z = (0, l.calculateInvariantBoundingSphere)(K.endBuffer.ref.value, K.cylinderCount * 6, 6);
              f.Sphere3D.expandBySphere(F, X, Z), H = Y;
            }
            return F;
          },
          get groupMapping() {
            return K.groupBuffer.ref.version !== q && (U = (0, a.createGroupMapping)(K.groupBuffer.ref.value, K.cylinderCount, 6), q = K.groupBuffer.ref.version), U;
          },
          setBoundingSphere: function(Y) {
            f.Sphere3D.copy(F, Y), H = g(K);
          }
        };
        return K;
      }
      function A(D, N, O, V, k, G, L, R, F) {
        return R > F.cylinderCount && (t.ValueCell.update(F.mappingBuffer, D), t.ValueCell.update(F.indexBuffer, N)), F.cylinderCount = R, t.ValueCell.update(F.groupBuffer, O), t.ValueCell.update(F.startBuffer, V), t.ValueCell.update(F.endBuffer, k), t.ValueCell.update(F.scaleBuffer, G), t.ValueCell.update(F.capBuffer, L), F;
      }
      function M(D, N) {
        var O = D.startBuffer.ref.value;
        (0, a.transformPositionArray)(N, O, 0, D.cylinderCount * 6), t.ValueCell.update(D.startBuffer, O);
        var V = D.endBuffer.ref.value;
        (0, a.transformPositionArray)(N, V, 0, D.cylinderCount * 6), t.ValueCell.update(D.endBuffer, V);
      }
      C.transform = M, C.Params = (0, r.__assign)((0, r.__assign)({}, d.BaseGeometry.Params), { sizeFactor: u.ParamDefinition.Numeric(1, { min: 0, max: 10, step: 0.1 }), sizeAspectRatio: u.ParamDefinition.Numeric(1, { min: 0, max: 3, step: 0.01 }), doubleSided: u.ParamDefinition.Boolean(!1, d.BaseGeometry.CustomQualityParamInfo), ignoreLight: u.ParamDefinition.Boolean(!1, d.BaseGeometry.ShadingCategory), xrayShaded: u.ParamDefinition.Boolean(!1, d.BaseGeometry.ShadingCategory), bumpFrequency: u.ParamDefinition.Numeric(0, { min: 0, max: 10, step: 0.1 }, d.BaseGeometry.ShadingCategory), bumpAmplitude: u.ParamDefinition.Numeric(1, { min: 0, max: 5, step: 0.1 }, d.BaseGeometry.ShadingCategory) }), C.Utils = {
        Params: C.Params,
        createEmpty: b,
        createValues: T,
        createValuesSimple: x,
        updateValues: w,
        updateBoundingSphere: E,
        createRenderableState: I,
        updateRenderableState: B,
        createPositionIterator: P
      };
      function P(D, N) {
        var O = D.cylinderCount * 6, V = N.instanceCount.ref.value, k = (0, s.PositionLocation)(), G = k.position, L = D.startBuffer.ref.value, R = D.endBuffer.ref.value, F = N.aTransform.ref.value, U = function(H, q) {
          var K = H % 6 === 0 ? L : R;
          return q < 0 ? n.Vec3.fromArray(G, K, H * 3) : n.Vec3.transformMat4Offset(G, K, F, 0, H * 3, q * 16), k;
        };
        return (0, s.LocationIterator)(O, V, 2, U);
      }
      function T(D, N, O, V, k) {
        var G = O.instanceCount, L = O.groupCount, R = P(D, N), F = (0, i.createColors)(O, R, V.color), U = (0, c.createSizes)(O, V.size), H = (0, o.createMarkers)(G * L), q = (0, m.createEmptyOverpaint)(), K = (0, p.createEmptyTransparency)(), Y = (0, y.createEmptySubstance)(), X = (0, h.createEmptyClipping)(), Z = { drawCount: D.cylinderCount * 4 * 3, vertexCount: D.cylinderCount * 6, groupCount: L, instanceCount: G }, J = (0, c.getMaxSize)(U) * k.sizeFactor, $ = f.Sphere3D.clone(D.boundingSphere), Q = (0, l.calculateTransformBoundingSphere)($, N.aTransform.ref.value, G);
        return (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({ dGeometryType: t.ValueCell.create("cylinders"), aMapping: D.mappingBuffer, aGroup: D.groupBuffer, aStart: D.startBuffer, aEnd: D.endBuffer, aScale: D.scaleBuffer, aCap: D.capBuffer, elements: D.indexBuffer, boundingSphere: t.ValueCell.create(Q), invariantBoundingSphere: t.ValueCell.create($), uInvariantBoundingSphere: t.ValueCell.create(n.Vec4.ofSphere($)) }, F), U), H), q), K), Y), X), N), { padding: t.ValueCell.create(J) }), d.BaseGeometry.createValues(k, Z)), { uSizeFactor: t.ValueCell.create(k.sizeFactor * k.sizeAspectRatio), uDoubleSided: t.ValueCell.create(k.doubleSided), dIgnoreLight: t.ValueCell.create(k.ignoreLight), dXrayShaded: t.ValueCell.create(k.xrayShaded), uBumpFrequency: t.ValueCell.create(k.bumpFrequency), uBumpAmplitude: t.ValueCell.create(k.bumpAmplitude) });
      }
      function x(D, N, O, V, k) {
        var G = d.BaseGeometry.createSimple(O, V, k), L = (0, r.__assign)((0, r.__assign)({}, u.ParamDefinition.getDefaultValues(C.Params)), N);
        return T(D, G.transform, G.locationIterator, G.theme, L);
      }
      function w(D, N) {
        d.BaseGeometry.updateValues(D, N), t.ValueCell.updateIfChanged(D.uSizeFactor, N.sizeFactor * N.sizeAspectRatio), t.ValueCell.updateIfChanged(D.uDoubleSided, N.doubleSided), t.ValueCell.updateIfChanged(D.dIgnoreLight, N.ignoreLight), t.ValueCell.updateIfChanged(D.dXrayShaded, N.xrayShaded), t.ValueCell.updateIfChanged(D.uBumpFrequency, N.bumpFrequency), t.ValueCell.updateIfChanged(D.uBumpAmplitude, N.bumpAmplitude);
      }
      function E(D, N) {
        var O = f.Sphere3D.clone(N.boundingSphere), V = (0, l.calculateTransformBoundingSphere)(O, D.aTransform.ref.value, D.instanceCount.ref.value);
        f.Sphere3D.equals(V, D.boundingSphere.ref.value) || t.ValueCell.update(D.boundingSphere, V), f.Sphere3D.equals(O, D.invariantBoundingSphere.ref.value) || (t.ValueCell.update(D.invariantBoundingSphere, O), t.ValueCell.update(D.uInvariantBoundingSphere, n.Vec4.fromSphere(D.uInvariantBoundingSphere.ref.value, O)));
      }
      function I(D) {
        var N = d.BaseGeometry.createRenderableState(D);
        return B(N, D), N;
      }
      function B(D, N) {
        d.BaseGeometry.updateRenderableState(D, N), D.opaque = D.opaque && !N.xrayShaded, D.writeDepth = D.opaque;
      }
    })(e.Cylinders || (e.Cylinders = {}));
  }(j5)), j5;
}
var d9;
function Kd() {
  return d9 || (d9 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.Geometry = void 0;
    var r = Dt(), t = hy(), n = bs(), a = Fa(), i = c4(), o = Ep(), c = hr, s = yy(), u = QG(), l = hl();
    (function(f) {
      function d(y) {
        switch (y.kind) {
          case "mesh":
            return y.triangleCount * 3;
          case "points":
            return y.pointCount;
          case "spheres":
            return y.sphereCount * 2 * 3;
          case "cylinders":
            return y.cylinderCount * 4 * 3;
          case "text":
            return y.charCount * 2 * 3;
          case "lines":
            return y.lineCount * 2 * 3;
          case "direct-volume":
            return 12 * 3;
          case "image":
            return 2 * 3;
          case "texture-mesh":
            return y.vertexCount;
        }
      }
      f.getDrawCount = d;
      function m(y) {
        switch (y.kind) {
          case "mesh":
            return y.vertexCount;
          case "points":
            return y.pointCount;
          case "spheres":
            return y.sphereCount * 4;
          case "cylinders":
            return y.cylinderCount * 6;
          case "text":
            return y.charCount * 4;
          case "lines":
            return y.lineCount * 4;
          case "direct-volume":
            var C = y.gridDimension.ref.value, S = C[0], b = C[1], g = C[2];
            return S * b * g;
          case "image":
            return 4;
          case "texture-mesh":
            return y.vertexCount;
        }
      }
      f.getVertexCount = m;
      function p(y) {
        switch (y.kind) {
          case "mesh":
          case "points":
          case "spheres":
          case "cylinders":
          case "text":
          case "lines":
            return d(y) === 0 ? 0 : (0, c.arrayMax)(y.groupBuffer.ref.value) + 1;
          case "direct-volume":
            return 1;
          case "image":
            return (0, c.arrayMax)(y.groupTexture.ref.value.array) + 1;
          case "texture-mesh":
            return y.groupCount;
        }
      }
      f.getGroupCount = p;
      function v(y) {
        switch (y.kind) {
          case "mesh":
            return r.Mesh.Utils;
          case "points":
            return t.Points.Utils;
          case "spheres":
            return o.Spheres.Utils;
          case "cylinders":
            return l.Cylinders.Utils;
          case "text":
            return n.Text.Utils;
          case "lines":
            return a.Lines.Utils;
          case "direct-volume":
            return i.DirectVolume.Utils;
          case "image":
            return u.Image.Utils;
          case "texture-mesh":
            return s.TextureMesh.Utils;
        }
      }
      f.getUtils = v;
      function h(y, C) {
        return C === "instance" && y.nonInstanceable ? "group" : C;
      }
      f.getGranularity = h;
    })(e.Geometry || (e.Geometry = {}));
  }(M5)), M5;
}
var $5 = {}, f9;
function ZG() {
  return f9 || (f9 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.ShapeGroupColorThemeProvider = e.ShapeGroupColorTheme = e.getShapeGroupColorThemeParams = e.ShapeGroupColorThemeParams = void 0;
    var r = Tr(), t = ui(), n = Le, a = (0, r.Color)(13421772), i = "Assigns colors as defined by the shape object.";
    e.ShapeGroupColorThemeParams = {};
    function o(s) {
      return e.ShapeGroupColorThemeParams;
    }
    e.getShapeGroupColorThemeParams = o;
    function c(s, u) {
      return {
        factory: c,
        granularity: "groupInstance",
        color: function(l) {
          return t.ShapeGroup.isLocation(l) ? l.shape.getColor(l.group, l.instance) : a;
        },
        props: u,
        description: i
      };
    }
    e.ShapeGroupColorTheme = c, e.ShapeGroupColorThemeProvider = {
      name: "shape-group",
      label: "Shape Group",
      category: "Miscellaneous",
      factory: c,
      getParams: o,
      defaultValues: n.ParamDefinition.getDefaultValues(e.ShapeGroupColorThemeParams),
      isApplicable: function(s) {
        return !!s.shape;
      }
    };
  }($5)), $5;
}
var Si = {}, JG = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.DirectVolumeRenderable = e.DirectVolumeSchema = void 0;
  var r = Te, t = Kt, n = Lt, a = yn, i = Bn(), o = We();
  e.DirectVolumeSchema = (0, r.__assign)((0, r.__assign)({}, a.BaseSchema), { aPosition: (0, a.AttributeSpec)("float32", 3, 0), elements: (0, a.ElementsSpec)("uint32"), uBboxMin: (0, a.UniformSpec)("v3"), uBboxMax: (0, a.UniformSpec)("v3"), uBboxSize: (0, a.UniformSpec)("v3"), uMaxSteps: (0, a.UniformSpec)("i"), uStepScale: (0, a.UniformSpec)("f"), uJumpLength: (0, a.UniformSpec)("f"), uTransform: (0, a.UniformSpec)("m4"), uGridDim: (0, a.UniformSpec)("v3"), tTransferTex: (0, a.TextureSpec)("image-uint8", "alpha", "ubyte", "linear"), uTransferScale: (0, a.UniformSpec)("f"), dGridTexType: (0, a.DefineSpec)("string", ["2d", "3d"]), uGridTexDim: (0, a.UniformSpec)("v3"), tGridTex: (0, a.TextureSpec)("texture", "rgba", "ubyte", "linear"), uGridStats: (0, a.UniformSpec)("v4"), uCellDim: (0, a.UniformSpec)("v3"), uCartnToUnit: (0, a.UniformSpec)("m4"), uUnitToCartn: (0, a.UniformSpec)("m4"), dPackedGroup: (0, a.DefineSpec)("boolean"), dAxisOrder: (0, a.DefineSpec)("string", ["012", "021", "102", "120", "201", "210"]), dIgnoreLight: (0, a.DefineSpec)("boolean"), dXrayShaded: (0, a.DefineSpec)("boolean") });
  function c(s, u, l, f, d, m) {
    var p = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.GlobalUniformSchema), a.GlobalTextureSchema), a.InternalSchema), e.DirectVolumeSchema);
    s.isWebGL2 || (p.uMaxSteps = (0, a.DefineSpec)("number"));
    var v = {
      uObjectId: o.ValueCell.create(u)
    }, h = i.DirectVolumeShaderCode, y = (0, n.createGraphicsRenderItem)(s, "triangles", h, p, (0, r.__assign)((0, r.__assign)({}, l), v), d, m);
    return (0, t.createRenderable)(y, l, f);
  }
  e.DirectVolumeRenderable = c;
})(JG);
var eq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.MeshRenderable = e.MeshSchema = void 0;
  var r = Te, t = Kt, n = Lt, a = yn, i = Bn(), o = We();
  e.MeshSchema = (0, r.__assign)((0, r.__assign)({}, a.BaseSchema), { aGroup: (0, a.AttributeSpec)("float32", 1, 0), aPosition: (0, a.AttributeSpec)("float32", 3, 0), aNormal: (0, a.AttributeSpec)("float32", 3, 0), elements: (0, a.ElementsSpec)("uint32"), dFlatShaded: (0, a.DefineSpec)("boolean"), uDoubleSided: (0, a.UniformSpec)("b"), dFlipSided: (0, a.DefineSpec)("boolean"), dIgnoreLight: (0, a.DefineSpec)("boolean"), dXrayShaded: (0, a.DefineSpec)("boolean"), uBumpFrequency: (0, a.UniformSpec)("f"), uBumpAmplitude: (0, a.UniformSpec)("f"), meta: (0, a.ValueSpec)("unknown") });
  function c(s, u, l, f, d, m) {
    var p = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.GlobalUniformSchema), a.GlobalTextureSchema), a.InternalSchema), e.MeshSchema), v = {
      uObjectId: o.ValueCell.create(u)
    }, h = i.MeshShaderCode, y = (0, n.createGraphicsRenderItem)(s, "triangles", h, p, (0, r.__assign)((0, r.__assign)({}, l), v), d, m);
    return (0, t.createRenderable)(y, l, f);
  }
  e.MeshRenderable = c;
})(eq);
var rq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.PointsRenderable = e.PointsSchema = void 0;
  var r = Te, t = Kt, n = Lt, a = yn, i = Bn(), o = We();
  e.PointsSchema = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.BaseSchema), a.SizeSchema), { aGroup: (0, a.AttributeSpec)("float32", 1, 0), aPosition: (0, a.AttributeSpec)("float32", 3, 0), dPointSizeAttenuation: (0, a.DefineSpec)("boolean"), dPointStyle: (0, a.DefineSpec)("string", ["square", "circle", "fuzzy"]) });
  function c(s, u, l, f, d, m) {
    var p = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.GlobalUniformSchema), a.GlobalTextureSchema), a.InternalSchema), e.PointsSchema), v = {
      uObjectId: o.ValueCell.create(u)
    }, h = i.PointsShaderCode, y = (0, n.createGraphicsRenderItem)(s, "points", h, p, (0, r.__assign)((0, r.__assign)({}, l), v), d, m);
    return (0, t.createRenderable)(y, l, f);
  }
  e.PointsRenderable = c;
})(rq);
var tq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.LinesRenderable = e.LinesSchema = void 0;
  var r = Te, t = Kt, n = Lt, a = yn, i = We(), o = Bn();
  e.LinesSchema = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.BaseSchema), a.SizeSchema), { aGroup: (0, a.AttributeSpec)("float32", 1, 0), aMapping: (0, a.AttributeSpec)("float32", 2, 0), aStart: (0, a.AttributeSpec)("float32", 3, 0), aEnd: (0, a.AttributeSpec)("float32", 3, 0), elements: (0, a.ElementsSpec)("uint32"), dLineSizeAttenuation: (0, a.DefineSpec)("boolean"), uDoubleSided: (0, a.UniformSpec)("b"), dFlipSided: (0, a.DefineSpec)("boolean") });
  function c(s, u, l, f, d, m) {
    var p = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.GlobalUniformSchema), a.GlobalTextureSchema), a.InternalSchema), e.LinesSchema), v = {
      uObjectId: i.ValueCell.create(u)
    }, h = o.LinesShaderCode, y = (0, n.createGraphicsRenderItem)(s, "triangles", h, p, (0, r.__assign)((0, r.__assign)({}, l), v), d, m);
    return (0, t.createRenderable)(y, l, f);
  }
  e.LinesRenderable = c;
})(tq);
var nq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.SpheresRenderable = e.SpheresSchema = void 0;
  var r = Te, t = Kt, n = Lt, a = yn, i = Bn(), o = We();
  e.SpheresSchema = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.BaseSchema), a.SizeSchema), { aGroup: (0, a.AttributeSpec)("float32", 1, 0), aPosition: (0, a.AttributeSpec)("float32", 3, 0), aMapping: (0, a.AttributeSpec)("float32", 2, 0), elements: (0, a.ElementsSpec)("uint32"), padding: (0, a.ValueSpec)("number"), uDoubleSided: (0, a.UniformSpec)("b"), dIgnoreLight: (0, a.DefineSpec)("boolean"), dXrayShaded: (0, a.DefineSpec)("boolean"), uBumpFrequency: (0, a.UniformSpec)("f"), uBumpAmplitude: (0, a.UniformSpec)("f") });
  function c(s, u, l, f, d, m) {
    var p = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.GlobalUniformSchema), a.GlobalTextureSchema), a.InternalSchema), e.SpheresSchema), v = {
      uObjectId: o.ValueCell.create(u)
    }, h = i.SpheresShaderCode, y = (0, n.createGraphicsRenderItem)(s, "triangles", h, p, (0, r.__assign)((0, r.__assign)({}, l), v), d, m);
    return (0, t.createRenderable)(y, l, f);
  }
  e.SpheresRenderable = c;
})(nq);
var aq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.TextRenderable = e.TextSchema = void 0;
  var r = Te, t = Kt, n = Lt, a = yn, i = Bn(), o = We();
  e.TextSchema = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.BaseSchema), a.SizeSchema), { aGroup: (0, a.AttributeSpec)("float32", 1, 0), aPosition: (0, a.AttributeSpec)("float32", 3, 0), aMapping: (0, a.AttributeSpec)("float32", 2, 0), aDepth: (0, a.AttributeSpec)("float32", 1, 0), elements: (0, a.ElementsSpec)("uint32"), aTexCoord: (0, a.AttributeSpec)("float32", 2, 0), tFont: (0, a.TextureSpec)("image-uint8", "alpha", "ubyte", "linear"), padding: (0, a.ValueSpec)("number"), uBorderWidth: (0, a.UniformSpec)("f"), uBorderColor: (0, a.UniformSpec)("v3"), uOffsetX: (0, a.UniformSpec)("f"), uOffsetY: (0, a.UniformSpec)("f"), uOffsetZ: (0, a.UniformSpec)("f"), uBackgroundColor: (0, a.UniformSpec)("v3"), uBackgroundOpacity: (0, a.UniformSpec)("f") });
  function c(s, u, l, f, d, m) {
    var p = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.GlobalUniformSchema), a.GlobalTextureSchema), a.InternalSchema), e.TextSchema), v = {
      uObjectId: o.ValueCell.create(u)
    }, h = i.TextShaderCode, y = (0, n.createGraphicsRenderItem)(s, "triangles", h, p, (0, r.__assign)((0, r.__assign)({}, l), v), d, m);
    return (0, t.createRenderable)(y, l, f);
  }
  e.TextRenderable = c;
})(aq);
var iq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.TextureMeshRenderable = e.TextureMeshSchema = void 0;
  var r = Te, t = Kt, n = Lt, a = yn, i = Bn(), o = We();
  e.TextureMeshSchema = (0, r.__assign)((0, r.__assign)({}, a.BaseSchema), { uGeoTexDim: (0, a.UniformSpec)("v2", "buffered"), tPosition: (0, a.TextureSpec)("texture", "rgb", "float", "nearest"), tGroup: (0, a.TextureSpec)("texture", "alpha", "float", "nearest"), tNormal: (0, a.TextureSpec)("texture", "rgb", "float", "nearest"), dFlatShaded: (0, a.DefineSpec)("boolean"), uDoubleSided: (0, a.UniformSpec)("b"), dFlipSided: (0, a.DefineSpec)("boolean"), dIgnoreLight: (0, a.DefineSpec)("boolean"), dXrayShaded: (0, a.DefineSpec)("boolean"), uBumpFrequency: (0, a.UniformSpec)("f"), uBumpAmplitude: (0, a.UniformSpec)("f"), meta: (0, a.ValueSpec)("unknown") });
  function c(s, u, l, f, d, m) {
    var p = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.GlobalUniformSchema), a.GlobalTextureSchema), a.InternalSchema), e.TextureMeshSchema), v = {
      uObjectId: o.ValueCell.create(u)
    }, h = i.MeshShaderCode, y = (0, n.createGraphicsRenderItem)(s, "triangles", h, p, (0, r.__assign)((0, r.__assign)({}, l), v), d, m);
    return (0, t.createRenderable)(y, l, f);
  }
  e.TextureMeshRenderable = c;
})(iq);
var oq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ImageRenderable = e.ImageSchema = void 0;
  var r = Te, t = Kt, n = Lt, a = yn, i = Bn(), o = We(), c = QG();
  e.ImageSchema = (0, r.__assign)((0, r.__assign)({}, a.BaseSchema), { aGroup: (0, a.AttributeSpec)("float32", 1, 0), aPosition: (0, a.AttributeSpec)("float32", 3, 0), aUv: (0, a.AttributeSpec)("float32", 2, 0), elements: (0, a.ElementsSpec)("uint32"), uImageTexDim: (0, a.UniformSpec)("v2"), tImageTex: (0, a.TextureSpec)("image-uint8", "rgba", "ubyte", "nearest"), tGroupTex: (0, a.TextureSpec)("image-uint8", "rgba", "ubyte", "nearest"), dInterpolation: (0, a.DefineSpec)("string", c.InterpolationTypeNames) });
  function s(u, l, f, d, m, p) {
    var v = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.GlobalUniformSchema), a.GlobalTextureSchema), a.InternalSchema), e.ImageSchema), h = {
      uObjectId: o.ValueCell.create(l)
    }, y = i.ImageShaderCode, C = (0, n.createGraphicsRenderItem)(u, "triangles", y, v, (0, r.__assign)((0, r.__assign)({}, f), h), m, p);
    return (0, t.createRenderable)(C, f, d);
  }
  e.ImageRenderable = s;
})(oq);
var uq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.CylindersRenderable = e.CylindersSchema = void 0;
  var r = Te, t = Kt, n = Lt, a = yn, i = Bn(), o = We();
  e.CylindersSchema = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.BaseSchema), a.SizeSchema), { aGroup: (0, a.AttributeSpec)("float32", 1, 0), aStart: (0, a.AttributeSpec)("float32", 3, 0), aEnd: (0, a.AttributeSpec)("float32", 3, 0), aMapping: (0, a.AttributeSpec)("float32", 3, 0), aScale: (0, a.AttributeSpec)("float32", 1, 0), aCap: (0, a.AttributeSpec)("float32", 1, 0), elements: (0, a.ElementsSpec)("uint32"), padding: (0, a.ValueSpec)("number"), uDoubleSided: (0, a.UniformSpec)("b"), dIgnoreLight: (0, a.DefineSpec)("boolean"), dXrayShaded: (0, a.DefineSpec)("boolean"), uBumpFrequency: (0, a.UniformSpec)("f"), uBumpAmplitude: (0, a.UniformSpec)("f") });
  function c(s, u, l, f, d, m) {
    var p = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.GlobalUniformSchema), a.GlobalTextureSchema), a.InternalSchema), e.CylindersSchema), v = {
      uObjectId: o.ValueCell.create(u)
    }, h = i.CylindersShaderCode, y = (0, n.createGraphicsRenderItem)(s, "triangles", h, p, (0, r.__assign)((0, r.__assign)({}, l), v), d, m);
    return (0, t.createRenderable)(y, l, f);
  }
  e.CylindersRenderable = c;
})(uq);
Object.defineProperty(Si, "__esModule", { value: !0 });
Si.createRenderable = Si.createRenderObject = Si.getNextMaterialId = void 0;
var sq = Ra, Yce = JG, Qce = eq, Zce = rq, Jce = tq, ede = nq, rde = aq, tde = iq, nde = oq, ade = uq, ide = (0, sq.idFactory)(0, 2147483647);
Si.getNextMaterialId = (0, sq.idFactory)(0, 2147483647);
function ode(e, r, t, n) {
  return {
    id: ide(),
    type: e,
    values: r,
    state: t,
    materialId: n
  };
}
Si.createRenderObject = ode;
function ude(e, r, t) {
  switch (r.type) {
    case "mesh":
      return (0, Qce.MeshRenderable)(e, r.id, r.values, r.state, r.materialId, t);
    case "points":
      return (0, Zce.PointsRenderable)(e, r.id, r.values, r.state, r.materialId, t);
    case "spheres":
      return (0, ede.SpheresRenderable)(e, r.id, r.values, r.state, r.materialId, t);
    case "cylinders":
      return (0, ade.CylindersRenderable)(e, r.id, r.values, r.state, r.materialId, t);
    case "text":
      return (0, rde.TextRenderable)(e, r.id, r.values, r.state, r.materialId, t);
    case "lines":
      return (0, Jce.LinesRenderable)(e, r.id, r.values, r.state, r.materialId, t);
    case "direct-volume":
      return (0, Yce.DirectVolumeRenderable)(e, r.id, r.values, r.state, r.materialId, t);
    case "image":
      return (0, nde.ImageRenderable)(e, r.id, r.values, r.state, r.materialId, t);
    case "texture-mesh":
      return (0, tde.TextureMeshRenderable)(e, r.id, r.values, r.state, r.materialId, t);
  }
  throw new Error("unsupported type");
}
Si.createRenderable = ude;
var m9;
function sde() {
  return m9 || (m9 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.ShapeGroup = e.Shape = void 0;
    var r = We(), t = Qe(), n = Kd(), a = Re, i = nr(), o = Gd, c = lq(), s = ZG(), u = ji, l = Si, f = on;
    (function(m) {
      function p(A, M, P, T, x, w, E) {
        return {
          id: r.UUID.create22(),
          name: A,
          sourceData: M,
          geometry: P,
          transforms: E || [a.Mat4.identity()],
          get groupCount() {
            return n.Geometry.getGroupCount(P);
          },
          getColor: T,
          getSize: x,
          getLabel: w
        };
      }
      m.create = p;
      function v(A) {
        return {
          color: (0, s.ShapeGroupColorTheme)({ shape: A }, {}),
          size: (0, c.ShapeGroupSizeTheme)({ shape: A }, {})
        };
      }
      m.getTheme = v;
      function h(A) {
        var M = A.transforms.length, P = d.Location(A), T = function(x, w) {
          return P.group = x, P.instance = w, P;
        };
        return (0, f.LocationIterator)(A.groupCount, M, 1, T);
      }
      m.groupIterator = h;
      function y(A, M) {
        for (var P = M && M.aTransform.ref.value.length >= A.length * 16 ? M.aTransform.ref.value : new Float32Array(A.length * 16), T = 0, x = A.length; T < x; ++T)
          a.Mat4.toArray(A[T], P, T * 16);
        return (0, u.createTransform)(P, A.length, M);
      }
      m.createTransform = y;
      function C(A, M) {
        var P = m.getTheme(A), T = n.Geometry.getUtils(A.geometry), x = (0, l.getNextMaterialId)(), w = h(A), E = m.createTransform(A.transforms), I = T.createValues(A.geometry, E, w, P, M), B = T.createRenderableState(M);
        return (0, l.createRenderObject)(A.geometry.kind, I, B, x);
      }
      m.createRenderObject = C;
      function S(A) {
        return { kind: "shape-loci", shape: A };
      }
      m.Loci = S;
      function b(A) {
        return !!A && A.kind === "shape-loci";
      }
      m.isLoci = b;
      function g(A, M) {
        return A.shape === M.shape;
      }
      m.areLociEqual = g;
      function _(A) {
        return A.shape.groupCount === 0;
      }
      m.isLociEmpty = _;
    })(e.Shape || (e.Shape = {}));
    var d;
    (function(m) {
      function p(T, x, w) {
        return x === void 0 && (x = 0), w === void 0 && (w = 0), { kind: "group-location", shape: T, group: x, instance: w };
      }
      m.Location = p;
      function v(T) {
        return !!T && T.kind === "group-location";
      }
      m.isLocation = v;
      function h(T, x) {
        return { kind: "group-loci", shape: T, groups: x };
      }
      m.Loci = h;
      function y(T) {
        return !!T && T.kind === "group-loci";
      }
      m.isLoci = y;
      function C(T, x) {
        if (T.shape !== x.shape || T.groups.length !== x.groups.length)
          return !1;
        for (var w = 0, E = T.groups.length; w < E; ++w) {
          var I = T.groups[w], B = I.ids, D = I.instance, N = x.groups[w], O = N.ids, V = N.instance;
          if (D !== V || !t.OrderedSet.areEqual(B, O))
            return !1;
        }
        return !0;
      }
      m.areLociEqual = C;
      function S(T) {
        return b(T) === 0;
      }
      m.isLociEmpty = S;
      function b(T) {
        for (var x = 0, w = 0, E = T.groups; w < E.length; w++) {
          var I = E[w];
          x += t.OrderedSet.size(I.ids);
        }
        return x;
      }
      m.size = b;
      var g = new o.CentroidHelper(), _ = a.Vec3.zero();
      function A(T, x, w, E) {
        for (var I = x.indices, B = x.offsets, D = function(L, R) {
          t.OrderedSet.forEach(L, function(F) {
            for (var U = B[F], H = B[F + 1]; U < H; ++U)
              a.Vec3.fromArray(_, w, I[U] * 3), a.Vec3.transformMat4(_, _, E[R]), g.includeStep(_);
          });
        }, N = 0, O = T; N < O.length; N++) {
          var V = O[N], k = V.ids, G = V.instance;
          D(k, G);
        }
      }
      function M(T, x, w, E) {
        for (var I = x.indices, B = x.offsets, D = function(L, R) {
          t.OrderedSet.forEach(L, function(F) {
            for (var U = B[F], H = B[F + 1]; U < H; ++U)
              a.Vec3.fromArray(_, w, I[U] * 3), a.Vec3.transformMat4(_, _, E[R]), g.radiusStep(_);
          });
        }, N = 0, O = T; N < O.length; N++) {
          var V = O[N], k = V.ids, G = V.instance;
          D(k, G);
        }
      }
      function P(T, x) {
        x || (x = (0, i.Sphere3D)()), g.reset();
        var w = 0, E = T.shape, I = E.geometry, B = E.transforms;
        if (I.kind === "mesh" || I.kind === "points") {
          var D = I.kind === "mesh" ? I.vertexBuffer.ref.value : I.centerBuffer.ref.value;
          A(T.groups, I.groupMapping, D, B), g.finishedIncludeStep(), M(T.groups, I.groupMapping, D, B);
        } else if (I.kind === "lines") {
          var N = I.startBuffer.ref.value, O = I.endBuffer.ref.value;
          A(T.groups, I.groupMapping, N, B), A(T.groups, I.groupMapping, O, B), g.finishedIncludeStep(), M(T.groups, I.groupMapping, N, B), M(T.groups, I.groupMapping, O, B);
        } else if (I.kind === "spheres" || I.kind === "text") {
          var D = I.centerBuffer.ref.value;
          A(T.groups, I.groupMapping, D, B), g.finishedIncludeStep(), M(T.groups, I.groupMapping, D, B);
          for (var V = function(H, q) {
            t.OrderedSet.forEach(H, function(K) {
              var Y = T.shape.getSize(K, q);
              w < Y && (w = Y);
            });
          }, k = 0, G = T.groups; k < G.length; k++) {
            var L = G[k], R = L.ids, F = L.instance;
            V(R, F);
          }
        } else
          return i.Sphere3D.copy(x, I.boundingSphere);
        return a.Vec3.copy(x.center, g.center), x.radius = Math.sqrt(g.radiusSq), i.Sphere3D.expand(x, x, w), x;
      }
      m.getBoundingSphere = P;
    })(d = e.ShapeGroup || (e.ShapeGroup = {}));
  }(P5)), P5;
}
var v9;
function ui() {
  return v9 || (v9 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 });
    var r = Te;
    (0, r.__exportStar)(sde(), e);
  }(T5)), T5;
}
var p9;
function lq() {
  return p9 || (p9 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.ShapeGroupSizeThemeProvider = e.ShapeGroupSizeTheme = e.getShapeGroupSizeThemeParams = e.ShapeGroupSizeThemeParams = void 0;
    var r = ui(), t = Le, n = 1, a = "Assigns sizes as defined by the shape object.";
    e.ShapeGroupSizeThemeParams = {};
    function i(c) {
      return e.ShapeGroupSizeThemeParams;
    }
    e.getShapeGroupSizeThemeParams = i;
    function o(c, s) {
      return {
        factory: o,
        granularity: "groupInstance",
        size: function(u) {
          return r.ShapeGroup.isLocation(u) ? u.shape.getSize(u.group, u.instance) : n;
        },
        props: s,
        description: a
      };
    }
    e.ShapeGroupSizeTheme = o, e.ShapeGroupSizeThemeProvider = {
      name: "shape-group",
      label: "Shape Group",
      category: "",
      factory: o,
      getParams: i,
      defaultValues: t.ParamDefinition.getDefaultValues(e.ShapeGroupSizeThemeParams),
      isApplicable: function(c) {
        return !!c.shape;
      }
    };
  }(x5)), x5;
}
var cq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.UncertaintySizeThemeProvider = e.UncertaintySizeTheme = e.getUncertainty = e.getUncertaintySizeThemeParams = e.UncertaintySizeThemeParams = void 0;
  var r = Je(), t = Le, n = "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.";
  e.UncertaintySizeThemeParams = {
    bfactorFactor: t.ParamDefinition.Numeric(0.1, { min: 0, max: 1, step: 0.01 }),
    rmsfFactor: t.ParamDefinition.Numeric(0.05, { min: 0, max: 1, step: 0.01 }),
    baseSize: t.ParamDefinition.Numeric(0.2, { min: 0, max: 2, step: 0.1 })
  };
  function a(c) {
    return e.UncertaintySizeThemeParams;
  }
  e.getUncertaintySizeThemeParams = a;
  function i(c, s, u) {
    return r.Unit.isAtomic(c) ? c.model.atomicConformation.B_iso_or_equiv.value(s) * u.bfactorFactor : r.Unit.isSpheres(c) ? c.model.coarseConformation.spheres.rmsf[s] * u.rmsfFactor : 0;
  }
  e.getUncertainty = i;
  function o(c, s) {
    function u(l) {
      var f = s.baseSize;
      return r.StructureElement.Location.is(l) ? f += i(l.unit, l.element, s) : r.Bond.isLocation(l) && (f += i(l.aUnit, l.aUnit.elements[l.aIndex], s)), f;
    }
    return {
      factory: o,
      granularity: "group",
      size: u,
      props: s,
      description: n
    };
  }
  e.UncertaintySizeTheme = o, e.UncertaintySizeThemeProvider = {
    name: "uncertainty",
    label: "Uncertainty/Disorder",
    category: "",
    factory: o,
    getParams: a,
    defaultValues: t.ParamDefinition.getDefaultValues(e.UncertaintySizeThemeParams),
    isApplicable: function(c) {
      return !!c.structure && c.structure.models.some(function(s) {
        return s.atomicConformation.B_iso_or_equiv.isDefined || s.coarseHierarchy.isDefined;
      });
    }
  };
})(cq);
var dq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.AquasiteSizeThemeProvider = e.AquasiteSizeTheme = e.getAquasite = e.getAquasiteSizeThemeParams = e.AquasiteSizeThemeParams = void 0;
  var r = Je(), t = Le, n = "Aquasite";
  e.AquasiteSizeThemeParams = {
    hydrogenSize: t.ParamDefinition.Numeric(0.2, { min: 0, max: 10, step: 0.1 }),
    oxygenSize: t.ParamDefinition.Numeric(0.2, { min: 0, max: 10, step: 0.1 }),
    baseSize: t.ParamDefinition.Numeric(0.2, { min: 0, max: 2, step: 0.1 })
  };
  function a(c) {
    return e.AquasiteSizeThemeParams;
  }
  e.getAquasiteSizeThemeParams = a;
  function i(c, s, u) {
    if (r.Unit.isAtomic(c)) {
      var l = c.model.atomicHierarchy.atoms.type_symbol.value(s).toUpperCase();
      return l === "H" ? u.hydrogenSize : l === "O" ? u.oxygenSize : 0;
    } else
      return 0;
  }
  e.getAquasite = i;
  function o(c, s) {
    function u(l) {
      var f = s.baseSize;
      return r.StructureElement.Location.is(l) && (f += i(l.unit, l.element, s)), f;
    }
    return {
      factory: o,
      granularity: "group",
      size: u,
      props: s,
      description: n
    };
  }
  e.AquasiteSizeTheme = o, e.AquasiteSizeThemeProvider = {
    name: "aquasite",
    label: "Aquasite",
    category: "",
    factory: o,
    getParams: a,
    defaultValues: t.ParamDefinition.getDefaultValues(e.AquasiteSizeThemeParams),
    isApplicable: function(c) {
      return !!c.structure && c.structure.models.some(function(s) {
        return s.atomicConformation.B_iso_or_equiv.isDefined || s.coarseHierarchy.isDefined;
      });
    }
  };
})(dq);
var h9;
function _y() {
  if (h9) return jh;
  h9 = 1, Object.defineProperty(jh, "__esModule", { value: !0 }), jh.SizeTheme = void 0;
  var e = BE, r = Pc(), t = NG, n = We(), a = lq(), i = cq, o = dq, c;
  return function(s) {
    s.EmptyFactory = function() {
      return s.Empty;
    }, s.Empty = { factory: s.EmptyFactory, granularity: "uniform", size: function() {
      return 1;
    }, props: {} };
    function u(f, d) {
      return f.factory === d.factory && (0, n.deepEqual)(f.props, d.props);
    }
    s.areEqual = u, s.EmptyProvider = { name: "", label: "", category: "", factory: s.EmptyFactory, getParams: function() {
      return {};
    }, defaultValues: {}, isApplicable: function() {
      return !0;
    } };
    function l() {
      return new r.ThemeRegistry(s.BuiltIn, s.EmptyProvider);
    }
    s.createRegistry = l, s.BuiltIn = {
      physical: t.PhysicalSizeThemeProvider,
      "shape-group": a.ShapeGroupSizeThemeProvider,
      uncertainty: i.UncertaintySizeThemeProvider,
      uniform: e.UniformSizeThemeProvider,
      aquasite: o.AquasiteSizeThemeProvider
    };
  }(c || (c = {})), jh.SizeTheme = c, jh;
}
var g9;
function Pc() {
  if (g9) return Pf;
  g9 = 1, Object.defineProperty(Pf, "__esModule", { value: !0 }), Pf.ThemeRegistry = Pf.Theme = void 0;
  var e = Te, r = Np(), t = _y(), n = Le, a = nn, i;
  (function(s) {
    function u(m, p, v, h) {
      h = h || l();
      var y = v.colorTheme, C = v.sizeTheme;
      return h.color = m.colorThemeRegistry.create(y.name, p, y.params), h.size = m.sizeThemeRegistry.create(C.name, p, C.params), h;
    }
    s.create = u;
    function l() {
      return { color: r.ColorTheme.Empty, size: t.SizeTheme.Empty };
    }
    s.createEmpty = l;
    function f(m, p, v, h) {
      var y, C;
      return (0, e.__awaiter)(this, void 0, void 0, function() {
        return (0, e.__generator)(this, function(S) {
          switch (S.label) {
            case 0:
              return [4, (y = p.colorThemeRegistry.get(h.colorTheme.name).ensureCustomProperties) === null || y === void 0 ? void 0 : y.attach(m, v)];
            case 1:
              return S.sent(), [4, (C = p.sizeThemeRegistry.get(h.sizeTheme.name).ensureCustomProperties) === null || C === void 0 ? void 0 : C.attach(m, v)];
            case 2:
              return S.sent(), [
                2
                /*return*/
              ];
          }
        });
      });
    }
    s.ensureDependencies = f;
    function d(m, p, v) {
      var h, y;
      (h = m.colorThemeRegistry.get(v.colorTheme.name).ensureCustomProperties) === null || h === void 0 || h.detach(p), (y = m.sizeThemeRegistry.get(v.sizeTheme.name).ensureCustomProperties) === null || y === void 0 || y.detach(p);
    }
    s.releaseDependencies = d;
  })(i || (i = {})), Pf.Theme = i;
  function o(s) {
    return s.map(function(u) {
      return [u.name, u.provider.label, u.provider.category];
    });
  }
  var c = (
    /** @class */
    function() {
      function s(u, l) {
        var f = this;
        this.emptyProvider = l, this._list = [], this._map = /* @__PURE__ */ new Map(), this._name = /* @__PURE__ */ new Map(), (0, a.objectForEach)(u, function(d, m) {
          if (d.name !== m)
            throw new Error("Fix build in themes to have matching names. ".concat(d.name, " ").concat(m));
          f.add(d);
        });
      }
      return Object.defineProperty(s.prototype, "default", {
        get: function() {
          return this._list[0];
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(s.prototype, "list", {
        get: function() {
          return this._list;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(s.prototype, "types", {
        get: function() {
          return o(this._list);
        },
        enumerable: !1,
        configurable: !0
      }), s.prototype.sort = function() {
        this._list.sort(function(u, l) {
          return u.provider.category === l.provider.category ? u.provider.label < l.provider.label ? -1 : u.provider.label > l.provider.label ? 1 : 0 : u.provider.category < l.provider.category ? -1 : 1;
        });
      }, s.prototype.add = function(u) {
        if (this._map.has(u.name))
          throw new Error("".concat(u.name, " already registered."));
        var l = u.name;
        this._list.push({ name: l, provider: u }), this._map.set(l, u), this._name.set(u, l), this.sort();
      }, s.prototype.remove = function(u) {
        this._list.splice(this._list.findIndex(function(f) {
          return f.name === u.name;
        }), 1);
        var l = this._map.get(u.name);
        l && (this._map.delete(u.name), this._name.delete(l));
      }, s.prototype.has = function(u) {
        return this._map.has(u.name);
      }, s.prototype.get = function(u) {
        return this._map.get(u) || this.emptyProvider;
      }, s.prototype.getName = function(u) {
        if (!this._name.has(u))
          throw new Error("'".concat(u.label, "' is not a registered theme provider."));
        return this._name.get(u);
      }, s.prototype.create = function(u, l, f) {
        f === void 0 && (f = {});
        var d = this.get(u);
        return d.factory(l, (0, e.__assign)((0, e.__assign)({}, n.ParamDefinition.getDefaultValues(d.getParams(l))), f));
      }, s.prototype.getApplicableList = function(u) {
        return this._list.filter(function(l) {
          return l.provider.isApplicable(u);
        });
      }, s.prototype.getApplicableTypes = function(u) {
        return o(this.getApplicableList(u));
      }, s;
    }()
  );
  return Pf.ThemeRegistry = c, Pf;
}
var L0 = {}, ii = {}, fq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.distinctColors = e.DistinctColorsParams = void 0;
  var r = Te, t = kw(), n = Uw(), a = nn, i = We(), o = hr, c = Le;
  e.DistinctColorsParams = {
    hue: c.ParamDefinition.Interval([1, 360], { min: 0, max: 360, step: 1 }),
    chroma: c.ParamDefinition.Interval([40, 70], { min: 0, max: 100, step: 1 }),
    luminance: c.ParamDefinition.Interval([15, 85], { min: 0, max: 100, step: 1 }),
    clusteringStepCount: c.ParamDefinition.Numeric(50, { min: 10, max: 200, step: 1 }, { isHidden: !0 }),
    minSampleCount: c.ParamDefinition.Numeric(800, { min: 100, max: 5e3, step: 100 }, { isHidden: !0 })
  };
  function s(h, y) {
    return Math.sqrt(Math.pow(Math.abs(h[0] - y[0]), 2) + Math.pow(Math.abs(h[1] - y[1]), 2) + Math.pow(Math.abs(h[2] - y[2]), 2));
  }
  var u = 2, l = [0, 0, 0], f = [0, 0, 0];
  function d(h, y) {
    return t.Lab.toHcl(l, h), t.Lab.fromColor(f, t.Lab.toColor(h)), l[0] >= y.hue[0] && l[0] <= y.hue[1] && l[1] >= y.chroma[0] && l[1] <= y.chroma[1] && l[2] >= y.luminance[0] && l[2] <= y.luminance[1] && f[0] >= h[0] - u && f[0] <= h[0] + u && f[1] >= h[1] - u && f[1] <= h[1] + u && f[2] >= h[2] - u && f[2] <= h[2] + u;
  }
  function m(h) {
    for (var y = h.slice(0), C = [y.shift()]; y.length > 0; ) {
      for (var S = C[C.length - 1], b = 0, g = Number.MIN_SAFE_INTEGER, _ = 0; _ < y.length; ++_) {
        var A = s(S, y[_]);
        A > g && (g = A, b = _);
      }
      C.push(y.splice(b, 1)[0]);
    }
    return C;
  }
  function p(h, y) {
    for (var C = /* @__PURE__ */ new Map(), S = Math.cbrt(h) * 1.001, b = (y.hue[1] - y.hue[0]) / S, g = (y.chroma[1] - y.chroma[0]) / S, _ = (y.luminance[1] - y.luminance[0]) / S, A = y.hue[0]; A <= y.hue[1]; A += b)
      for (var M = y.chroma[0]; M <= y.chroma[1]; M += g)
        for (var P = y.luminance[0]; P <= y.luminance[1]; P += _) {
          var T = t.Lab.fromHcl((0, t.Lab)(), n.Hcl.create(A, M, P));
          d(T, y) && C.set(T.toString(), T);
        }
    return Array.from(C.values());
  }
  function v(h, y) {
    y === void 0 && (y = {});
    var C = (0, r.__assign)((0, r.__assign)({}, c.ParamDefinition.getDefaultValues(e.DistinctColorsParams)), y);
    if (h <= 0)
      return [];
    var S = p(Math.max(C.minSampleCount, h * 5), C);
    if (S.length < h)
      throw new Error("Not enough samples to generate distinct colors, increase sample count.");
    for (var b = [], g = [], _ = Math.floor(S.length / h), A = 0; A < S.length && (b.push(S[A]), g.push([]), !(b.length >= h)); A += _)
      ;
    for (var M = 1; M <= C.clusteringStepCount; ++M) {
      for (var P = (0, a.deepClone)(g), A = 0; A < S.length; ++A) {
        for (var T = Number.MAX_SAFE_INTEGER, x = 0, w = 0; w < b.length; w++) {
          var E = s(S[A], b[w]);
          E < T && (T = E, x = w);
        }
        P[x].push(S[A]);
      }
      for (var I = (0, a.deepClone)(b), A = 0; A < P.length; ++A) {
        for (var B = P[A], D = B.length, N = [], O = [], V = [], k = 0, G = B; k < G.length; k++) {
          var L = G[k];
          N.push(L[0]), O.push(L[1]), V.push(L[2]);
        }
        var R = (0, o.arraySum)(N) / D, F = (0, o.arraySum)(O) / D, U = (0, o.arraySum)(V) / D;
        b[A] = [R, F, U];
      }
      if ((0, i.deepEqual)(I, b))
        break;
    }
    return m(b).map(function(H) {
      return t.Lab.toColor(H);
    });
  }
  e.distinctColors = v;
})(fq);
Object.defineProperty(ii, "__esModule", { value: !0 });
ii.getPalette = ii.getPaletteParams = void 0;
var Xm = Te, lde = ti, jm = Le, mq = fq, y9 = _c, cde = aU(), vq = {
  type: "generate",
  colorList: "red-yellow-blue"
};
function pq(e) {
  e === void 0 && (e = {});
  var r = (0, Xm.__assign)((0, Xm.__assign)({}, vq), e);
  return {
    palette: jm.ParamDefinition.MappedStatic(r.type, {
      colors: jm.ParamDefinition.Group({
        list: jm.ParamDefinition.ColorList(r.colorList)
      }, { isFlat: !0 }),
      generate: jm.ParamDefinition.Group((0, Xm.__assign)((0, Xm.__assign)({}, mq.DistinctColorsParams), { maxCount: jm.ParamDefinition.Numeric(75, { min: 1, max: 250, step: 1 }) }), { isFlat: !0 })
    }, {
      options: [
        ["colors", "Color List"],
        ["generate", "Generate Distinct"]
      ]
    })
  };
}
ii.getPaletteParams = pq;
jm.ParamDefinition.getDefaultValues(pq());
var _9 = {
  valueLabel: function(e) {
    return "".concat(e + 1);
  },
  minLabel: "Start",
  maxLabel: "End"
};
function dde(e, r, t) {
  var n;
  t === void 0 && (t = {});
  var a, i;
  if (r.palette.name === "colors" && r.palette.params.list.kind === "interpolate") {
    var o = r.palette.params.list, c = [0, e - 1], s = (0, Xm.__assign)((0, Xm.__assign)({}, _9), t), u = s.minLabel, l = s.maxLabel, f = o.colors;
    f.length === 0 && (f = (0, y9.getColorListFromName)(vq.colorList).list);
    var d = cde.ColorScale.create({ listOrName: f, domain: c, minLabel: u, maxLabel: l });
    i = d.legend, a = d.color;
  } else {
    var m;
    r.palette.name === "colors" ? (m = r.palette.params.list.colors.map(function(S) {
      return Array.isArray(S) ? S[0] : S;
    }), m.length === 0 && (m = (0, y9.getColorListFromName)("dark-2").list.map(function(S) {
      return Array.isArray(S) ? S[0] : S;
    }))) : (e = Math.min(e, r.palette.params.maxCount), m = (0, mq.distinctColors)(e, r.palette.params));
    for (var p = (n = t.valueLabel) !== null && n !== void 0 ? n : _9.valueLabel, v = m.length, h = [], y = 0; y < e; ++y) {
      var C = y % v;
      h[C] === void 0 ? h[C] = [p(y), m[C]] : h[C][0] += ", ".concat(p(y));
    }
    i = (0, lde.TableLegend)(h), a = function(S) {
      return m[S % v];
    };
  }
  return { color: a, legend: i };
}
ii.getPalette = dde;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ChainIdColorThemeProvider = e.ChainIdColorTheme = e.getChainIdColorThemeParams = e.ChainIdColorThemeParams = void 0;
  var r = Te, t = Je(), n = Tr(), a = Le, i = ii, o = "many-distinct", c = (0, n.Color)(16448250), s = "Gives every chain a color based on its `asym_id` value.";
  e.ChainIdColorThemeParams = (0, r.__assign)({ asymId: a.ParamDefinition.Select("auth", a.ParamDefinition.arrayToOptions(["auth", "label"])) }, (0, i.getPaletteParams)({ type: "colors", colorList: o }));
  function u(v) {
    var h, y = a.ParamDefinition.clone(e.ChainIdColorThemeParams);
    return !((h = v.structure) === null || h === void 0) && h.models.some(function(C) {
      return C.coarseHierarchy.isDefined;
    }) && (y.asymId.defaultValue = "label"), y;
  }
  e.getChainIdColorThemeParams = u;
  function l(v, h) {
    switch (v.kind) {
      case 0:
        return h === "auth" ? t.StructureProperties.chain.auth_asym_id : t.StructureProperties.chain.label_asym_id;
      case 1:
      case 2:
        return t.StructureProperties.coarse.asym_id;
    }
  }
  function f(v, h) {
    var y = l(v.unit, h)(v);
    return v.structure.root.models.length > 1 ? d(v.unit.model, y) : y;
  }
  function d(v, h) {
    return "".concat(h, "|").concat((t.Model.Index.get(v).value || 0) + 1);
  }
  function m(v, h) {
    for (var y = /* @__PURE__ */ new Map(), C = function(_) {
      var A = t.Model.AsymIdOffset.get(_).value, M = (h === "auth" ? A == null ? void 0 : A.auth : A == null ? void 0 : A.label) || 0, P = 0;
      _.properties.structAsymMap.forEach(function(T, x) {
        var w = T.auth_id, E = h === "auth" ? w : x, I = v.models.length > 1 ? d(_, E) : E;
        y.has(I) || (y.set(I, P + M), ++P);
      });
    }, S = 0, b = v.models; S < b.length; S++) {
      var g = b[S];
      C(g);
    }
    return y;
  }
  function p(v, h) {
    var y, C;
    if (v.structure) {
      var S = t.StructureElement.Location.create(v.structure.root), b = m(v.structure.root, h.asymId), g = Array.from(b.keys()), _ = function(M) {
        return g[M];
      }, A = (0, i.getPalette)(b.size, h, { valueLabel: _ });
      C = A.legend, y = function(M) {
        var P = void 0;
        if (t.StructureElement.Location.is(M)) {
          var T = f(M, h.asymId);
          P = b.get(T);
        } else if (t.Bond.isLocation(M)) {
          S.unit = M.aUnit, S.element = M.aUnit.elements[M.aIndex];
          var T = f(S, h.asymId);
          P = b.get(T);
        }
        return P === void 0 ? c : A.color(P);
      };
    } else
      y = function() {
        return c;
      };
    return {
      factory: p,
      granularity: "group",
      color: y,
      props: h,
      description: s,
      legend: C
    };
  }
  e.ChainIdColorTheme = p, e.ChainIdColorThemeProvider = {
    name: "chain-id",
    label: "Chain Id",
    category: "Chain Property",
    factory: p,
    getParams: u,
    defaultValues: a.ParamDefinition.getDefaultValues(e.ChainIdColorThemeParams),
    isApplicable: function(v) {
      return !!v.structure;
    }
  };
})(L0);
var hq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ElementIndexColorThemeProvider = e.ElementIndexColorTheme = e.getElementIndexColorThemeParams = e.ElementIndexColorThemeParams = void 0;
  var r = Te, t = Tr(), n = Je(), a = Qe(), i = Le, o = ii, c = (0, t.Color)(13421772), s = "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.";
  e.ElementIndexColorThemeParams = (0, r.__assign)({}, (0, o.getPaletteParams)({ type: "colors", colorList: "red-yellow-blue" }));
  function u(f) {
    return e.ElementIndexColorThemeParams;
  }
  e.getElementIndexColorThemeParams = u;
  function l(f, d) {
    var m, p;
    if (f.structure) {
      for (var v = f.structure.root.units, h = v.length, y = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), S = 0, b = 0; b < h; ++b)
        y.set(b, S), S += v[b].elements.length, C.set(v[b].id, b);
      var g = (0, o.getPalette)(S, d);
      p = g.legend, m = function(_) {
        if (n.StructureElement.Location.is(_)) {
          var A = C.get(_.unit.id), M = a.OrderedSet.findPredecessorIndex(v[A].elements, _.element);
          return g.color(y.get(A) + M);
        } else if (n.Bond.isLocation(_)) {
          var A = C.get(_.aUnit.id), M = a.OrderedSet.findPredecessorIndex(v[A].elements, _.aUnit.elements[_.aIndex]);
          return g.color(y.get(A) + M);
        }
        return c;
      };
    } else
      m = function() {
        return c;
      };
    return {
      factory: l,
      granularity: "groupInstance",
      preferSmoothing: !0,
      color: m,
      props: d,
      description: s,
      legend: p
    };
  }
  e.ElementIndexColorTheme = l, e.ElementIndexColorThemeProvider = {
    name: "element-index",
    label: "Element Index",
    category: "Atom Property",
    factory: l,
    getParams: u,
    defaultValues: i.ParamDefinition.getDefaultValues(e.ElementIndexColorThemeParams),
    isApplicable: function(f) {
      return !!f.structure;
    }
  };
})(hq);
var gq = {}, Mc = {};
Object.defineProperty(Mc, "__esModule", { value: !0 });
Mc.getColorMapParams = void 0;
var fde = Le, mde = nn;
function vde(e) {
  var r = {};
  return (0, mde.objectForEach)(e, function(t, n) {
    r[n] = fde.ParamDefinition.Color(e[n]);
  }), r;
}
Mc.getColorMapParams = vde;
var Dp = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.OperatorNameColorThemeProvider = e.OperatorNameColorTheme = e.getOperatorNameColorThemeParams = e.OperatorNameColorThemeParams = void 0;
  var r = Te, t = Tr(), n = Je(), a = Le, i = ii, o = "many-distinct", c = (0, t.Color)(13421772), s = "Assigns a color based on the operator name of a transformed chain.";
  e.OperatorNameColorThemeParams = (0, r.__assign)({}, (0, i.getPaletteParams)({ type: "colors", colorList: o }));
  function u(d) {
    var m = a.ParamDefinition.clone(e.OperatorNameColorThemeParams);
    return m;
  }
  e.getOperatorNameColorThemeParams = u;
  function l(d) {
    for (var m = /* @__PURE__ */ new Map(), p = 0, v = d.units.length; p < v; ++p) {
      var h = d.units[p].conformation.operator.name;
      m.has(h) || m.set(h, m.size);
    }
    return m;
  }
  function f(d, m) {
    var p, v;
    if (d.structure) {
      var h = l(d.structure.root), y = Array.from(h.keys()), C = function(b) {
        return y[b];
      }, S = (0, i.getPalette)(h.size, m, {
        valueLabel: C
      });
      v = S.legend, p = function(b) {
        var g = void 0;
        if (n.StructureElement.Location.is(b)) {
          var _ = b.unit.conformation.operator.name;
          g = h.get(_);
        } else if (n.Bond.isLocation(b)) {
          var A = b.aUnit.conformation.operator.name;
          g = h.get(A);
        }
        return g === void 0 ? c : S.color(g);
      };
    } else
      p = function() {
        return c;
      };
    return {
      factory: f,
      granularity: "instance",
      color: p,
      props: m,
      description: s,
      legend: v
    };
  }
  e.OperatorNameColorTheme = f, e.OperatorNameColorThemeProvider = {
    name: "operator-name",
    label: "Operator Name",
    category: "Symmetry",
    factory: f,
    getParams: u,
    defaultValues: a.ParamDefinition.getDefaultValues(e.OperatorNameColorThemeParams),
    isApplicable: function(d) {
      return !!d.structure;
    }
  };
})(Dp);
var Ip = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.EntityIdColorThemeProvider = e.EntityIdColorTheme = e.getEntityIdColorThemeParams = e.EntityIdColorThemeParams = void 0;
  var r = Te, t = Je(), n = Tr(), a = Le, i = ii, o = "many-distinct", c = (0, n.Color)(16448250), s = "Gives every chain a color based on its `label_entity_id` value.";
  e.EntityIdColorThemeParams = (0, r.__assign)({}, (0, i.getPaletteParams)({ type: "colors", colorList: o }));
  function u(p) {
    var v = a.ParamDefinition.clone(e.EntityIdColorThemeParams);
    return v;
  }
  e.getEntityIdColorThemeParams = u;
  function l(p, v) {
    return "".concat(p, "|").concat(v);
  }
  function f(p) {
    for (var v = /* @__PURE__ */ new Map(), h = 0, y = p.models.length; h < y; ++h) {
      for (var C = p.models[h].atomicHierarchy.chains.label_entity_id, S = 0, b = C.rowCount; S < b; ++S) {
        var g = l(C.value(S), h);
        v.has(g) || v.set(g, v.size);
      }
      var _ = p.models[h].coarseHierarchy;
      if (_.isDefined) {
        for (var A = _.spheres.entity_id, S = 0, b = A.rowCount; S < b; ++S) {
          var g = l(A.value(S), h);
          v.has(g) || v.set(g, v.size);
        }
        for (var M = _.gaussians.entity_id, S = 0, b = M.rowCount; S < b; ++S) {
          var g = l(M.value(S), h);
          v.has(g) || v.set(g, v.size);
        }
      }
    }
    return v;
  }
  function d(p) {
    switch (p.unit.kind) {
      case 0:
        return t.StructureProperties.chain.label_entity_id(p);
      case 1:
      case 2:
        return t.StructureProperties.coarse.entity_id(p);
    }
  }
  function m(p, v) {
    var h, y;
    if (p.structure) {
      var C = t.StructureElement.Location.create(p.structure.root), S = f(p.structure.root), b = Array.from(S.keys()), g = function(A) {
        return b[A];
      }, _ = (0, i.getPalette)(S.size, v, { valueLabel: g });
      y = _.legend, h = function(A) {
        var M = void 0;
        if (t.StructureElement.Location.is(A)) {
          var P = d(A), T = A.structure.models.indexOf(A.unit.model), x = l(P, T);
          M = S.get(x);
        } else if (t.Bond.isLocation(A)) {
          C.unit = A.aUnit, C.element = A.aUnit.elements[A.aIndex];
          var P = d(C), T = C.structure.models.indexOf(C.unit.model), x = l(P, T);
          M = S.get(x);
        }
        return M === void 0 ? c : _.color(M);
      };
    } else
      h = function() {
        return c;
      };
    return {
      factory: m,
      granularity: "group",
      color: h,
      props: v,
      description: s,
      legend: y
    };
  }
  e.EntityIdColorTheme = m, e.EntityIdColorThemeProvider = {
    name: "entity-id",
    label: "Entity Id",
    category: "Chain Property",
    factory: m,
    getParams: u,
    defaultValues: a.ParamDefinition.getDefaultValues(e.EntityIdColorThemeParams),
    isApplicable: function(p) {
      return !!p.structure;
    }
  };
})(Ip);
var Bp = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.EntitySourceColorThemeProvider = e.EntitySourceColorTheme = e.getEntitySourceColorThemeParams = e.EntitySourceColorThemeParams = void 0;
  var r = Te, t = Je(), n = Tr(), a = Le, i = ii, o = fa, c = _c, s = Jo(), u = "dark-2", l = (0, n.Color)(16448250), f = "Gives ranges of a polymer chain a color based on the entity source it originates from (e.g. gene, plasmid, organism).";
  e.EntitySourceColorThemeParams = (0, r.__assign)({}, (0, i.getPaletteParams)({ type: "colors", colorList: u }));
  function d(S) {
    var b = a.ParamDefinition.clone(e.EntitySourceColorThemeParams);
    return S.structure && h(S.structure.root.models).srcKeySerialMap.size > c.ColorLists[u].list.length && (b.palette.defaultValue.name = "colors", b.palette.defaultValue.params = (0, r.__assign)((0, r.__assign)({}, b.palette.defaultValue.params), { list: {
      kind: "interpolate",
      colors: (0, c.getColorListFromName)(u).list
    } })), b;
  }
  e.getEntitySourceColorThemeParams = d;
  function m(S, b) {
    return "".concat(S, "|").concat(b);
  }
  function p(S, b, g, _, A, M) {
    return "".concat(S, "|").concat(b, "|").concat(g, "|").concat(M || A || _);
  }
  function v(S, b, g, _, A, M, P, T) {
    for (var x = A.entity_id, w = A.pdbx_src_id, E = A.pdbx_beg_seq_num, I = A.pdbx_end_seq_num, B = 0, D = A._rowCount; B < D; ++B) {
      var N = x.value(B), O = m(g, N), V = void 0;
      if (S.has(O))
        V = S.get(O);
      else {
        var k = _.entities.getEntityIndex(N), G = _.sequence.sequences[k].sequence;
        V = new Int16Array(G.length), S.set(O, V);
      }
      var L = P ? P.value(B) : "", R = T ? T.value(B)[0] : "", F = p(g, N, M.value(B), w.value(B), L, R), U = E.valueKind(B) === 0 ? E.value(B) : 1, H = I.valueKind(B) === 0 ? I.value(B) : V.length, q = void 0;
      b.has(F) ? q = b.get(F) : (q = b.size + 1, b.set(F, q));
      for (var K = U, Y = H; K <= Y; ++K)
        V[K - 1] = q;
    }
  }
  function h(S) {
    for (var b = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), _ = 0, A = S.length; _ < A; ++_) {
      var M = S[_];
      if (s.MmcifFormat.is(M.sourceData)) {
        var P = M.sourceData.data.db, T = P.entity_src_gen, x = P.entity_src_nat, w = P.pdbx_entity_src_syn;
        v(b, g, _, M, T, T.pdbx_gene_src_scientific_name, T.plasmid_name, T.pdbx_gene_src_gene), v(b, g, _, M, x, x.pdbx_organism_scientific, x.pdbx_plasmid_name), v(b, g, _, M, w, w.organism_scientific);
      }
    }
    return { seqToSrcByModelEntity: b, srcKeySerialMap: g };
  }
  function y(S) {
    var b = 0;
    return Array.from(S.keys()).map(function(g) {
      var _ = g.split("|"), A = _[2], M = (0, o.isInteger)(_[3]) ? "Unnamed ".concat(++b) : _[3];
      return "".concat(M).concat(A ? " (".concat(A, ")") : "");
    });
  }
  function C(S, b) {
    var g, _;
    if (S.structure) {
      var A = t.StructureElement.Location.create(S.structure), M = S.structure.root.models, P = h(M), T = P.seqToSrcByModelEntity, x = P.srcKeySerialMap, w = y(x), E = function(D) {
        return w[D];
      }, I = (0, i.getPalette)(x.size, b, { valueLabel: E });
      _ = I.legend;
      var B = function(D) {
        var N = M.indexOf(D.unit.model), O = t.StructureProperties.entity.id(D), V = m(N, O), k = T.get(V);
        if (k) {
          var G = k[t.StructureProperties.residue.label_seq_id(D) - 1] - 1;
          return G === -1 ? l : I.color(G);
        } else
          return l;
      };
      g = function(D) {
        return t.StructureElement.Location.is(D) ? B(D) : t.Bond.isLocation(D) ? (A.unit = D.aUnit, A.element = D.aUnit.elements[D.aIndex], B(A)) : l;
      };
    } else
      g = function() {
        return l;
      };
    return {
      factory: C,
      granularity: "group",
      color: g,
      props: b,
      description: f,
      legend: _
    };
  }
  e.EntitySourceColorTheme = C, e.EntitySourceColorThemeProvider = {
    name: "entity-source",
    label: "Entity Source",
    category: "Chain Property",
    factory: C,
    getParams: d,
    defaultValues: a.ParamDefinition.getDefaultValues(e.EntitySourceColorThemeParams),
    isApplicable: function(S) {
      return !!S.structure;
    }
  };
})(Bp);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ElementSymbolColorThemeProvider = e.ElementSymbolColorTheme = e.elementSymbolColor = e.getElementSymbolColorThemeParams = e.ElementSymbolColorThemeParams = e.ElementSymbolColors = void 0;
  var r = Tr(), t = Je(), n = Le, a = ti, i = Iu(), o = Mc, c = L0, s = Dp, u = Ip, l = Ft, f = Bp, d = py;
  e.ElementSymbolColors = (0, r.ColorMap)({
    // H: 0xFFFFFF,
    // H: 0xF6F8FF,
    H: 13817304,
    D: 16777152,
    T: 16777120,
    HE: 14286847,
    LI: 13402367,
    BE: 12779264,
    B: 16758197,
    C: 9474192,
    // N: 0x3050f8,
    N: 7370475,
    // O: 0xff0d0d,
    O: 15425118,
    // F: 0x90e050,
    F: 2543814,
    NE: 11789301,
    NA: 11230450,
    MG: 9109248,
    AL: 12560038,
    SI: 1578e4,
    // P: 0xff8000,
    P: 15654476,
    // S: 0xffff30,
    S: 15771392,
    // CL: 0x1ff01f,
    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: 0xa62929,
    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
  });
  var m = (0, r.Color)(16777215), p = "Assigns a color to every atom according to its chemical element.";
  e.ElementSymbolColorThemeParams = {
    carbonColor: n.ParamDefinition.MappedStatic("chain-id", {
      "chain-id": n.ParamDefinition.Group(c.ChainIdColorThemeParams),
      "entity-id": n.ParamDefinition.Group(u.EntityIdColorThemeParams),
      "entity-source": n.ParamDefinition.Group(f.EntitySourceColorThemeParams),
      "operator-name": n.ParamDefinition.Group(s.OperatorNameColorThemeParams),
      "element-symbol": n.ParamDefinition.EmptyGroup(),
      uniform: n.ParamDefinition.Group(d.UniformColorThemeParams)
    }, { description: "Use chain-id coloring for carbon atoms." }),
    saturation: n.ParamDefinition.Numeric(0, { min: -6, max: 6, step: 0.1 }),
    lightness: n.ParamDefinition.Numeric(0.2, { min: -6, max: 6, step: 0.1 }),
    colors: n.ParamDefinition.MappedStatic("default", {
      default: n.ParamDefinition.EmptyGroup(),
      custom: n.ParamDefinition.Group((0, o.getColorMapParams)(e.ElementSymbolColors))
    })
  };
  function v(C) {
    return e.ElementSymbolColorThemeParams;
  }
  e.getElementSymbolColorThemeParams = v;
  function h(C, S) {
    var b = C[S];
    return b === void 0 ? m : b;
  }
  e.elementSymbolColor = h;
  function y(C, S) {
    var b = (0, i.getAdjustedColorMap)(S.colors.name === "default" ? e.ElementSymbolColors : S.colors.params, S.saturation, S.lightness), g = S.carbonColor, _ = g.name === "chain-id" ? (0, c.ChainIdColorTheme)(C, g.params).color : g.name === "entity-id" ? (0, u.EntityIdColorTheme)(C, g.params).color : g.name === "entity-source" ? (0, f.EntitySourceColorTheme)(C, g.params).color : g.name === "operator-name" ? (0, s.OperatorNameColorTheme)(C, g.params).color : g.name === "element-symbol" ? void 0 : g.name === "uniform" ? (0, d.UniformColorTheme)(C, g.params).color : (0, l.assertUnreachable)(g);
    function A(T, x) {
      return _ && T === "C" ? _(x, !1) : h(b, T);
    }
    function M(T) {
      if (t.StructureElement.Location.is(T)) {
        if (t.Unit.isAtomic(T.unit)) {
          var x = T.unit.model.atomicHierarchy.atoms.type_symbol;
          return A(x.value(T.element), T);
        }
      } else if (t.Bond.isLocation(T) && t.Unit.isAtomic(T.aUnit)) {
        var x = T.aUnit.model.atomicHierarchy.atoms.type_symbol, w = x.value(T.aUnit.elements[T.aIndex]);
        return A(w, T);
      }
      return m;
    }
    var P = S.carbonColor.name === "operator-name" ? "groupInstance" : "group";
    return {
      factory: y,
      granularity: P,
      preferSmoothing: !0,
      color: M,
      props: S,
      description: p,
      legend: (0, a.TableLegend)(Object.keys(b).map(function(T) {
        return [T, b[T]];
      }))
    };
  }
  e.ElementSymbolColorTheme = y, e.ElementSymbolColorThemeProvider = {
    name: "element-symbol",
    label: "Element Symbol",
    category: "Atom Property",
    factory: y,
    getParams: v,
    defaultValues: n.ParamDefinition.getDefaultValues(e.ElementSymbolColorThemeParams),
    isApplicable: function(C) {
      return !!C.structure;
    }
  };
})(gq);
var FE = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.MoleculeTypeColorThemeProvider = e.MoleculeTypeColorTheme = e.moleculeTypeColor = e.getMoleculeTypeColorThemeParams = e.MoleculeTypeColorThemeParams = e.MoleculeTypeColors = void 0;
  var r = Tr(), t = Je(), n = Za, a = Le, i = ti, o = Iu(), c = Mc;
  e.MoleculeTypeColors = (0, r.ColorMap)({
    water: 3697840,
    ion: 15729279,
    protein: 12496596,
    RNA: 16629894,
    DNA: 12540695,
    PNA: 4367514,
    saccharide: 8374655
  });
  var s = (0, r.Color)(16777113), u = "Assigns a color based on the molecule type of a residue.";
  e.MoleculeTypeColorThemeParams = {
    saturation: a.ParamDefinition.Numeric(0, { min: -6, max: 6, step: 0.1 }),
    lightness: a.ParamDefinition.Numeric(0, { min: -6, max: 6, step: 0.1 }),
    colors: a.ParamDefinition.MappedStatic("default", {
      default: a.ParamDefinition.EmptyGroup(),
      custom: a.ParamDefinition.Group((0, c.getColorMapParams)(e.MoleculeTypeColors))
    })
  };
  function l(m) {
    return e.MoleculeTypeColorThemeParams;
  }
  e.getMoleculeTypeColorThemeParams = l;
  function f(m, p, v) {
    var h = (0, n.getElementMoleculeType)(p, v);
    switch (h) {
      case 2:
        return m.water;
      case 3:
        return m.ion;
      case 5:
        return m.protein;
      case 6:
        return m.RNA;
      case 7:
        return m.DNA;
      case 8:
        return m.PNA;
      case 9:
        return m.saccharide;
    }
    return s;
  }
  e.moleculeTypeColor = f;
  function d(m, p) {
    var v = (0, o.getAdjustedColorMap)(p.colors.name === "default" ? e.MoleculeTypeColors : p.colors.params, p.saturation, p.lightness);
    function h(y) {
      return t.StructureElement.Location.is(y) ? f(v, y.unit, y.element) : t.Bond.isLocation(y) ? f(v, y.aUnit, y.aUnit.elements[y.aIndex]) : s;
    }
    return {
      factory: d,
      granularity: "group",
      color: h,
      props: p,
      description: u,
      legend: (0, i.TableLegend)(Object.keys(v).map(function(y) {
        return [y, v[y]];
      }).concat([["Other/unknown", s]]))
    };
  }
  e.MoleculeTypeColorTheme = d, e.MoleculeTypeColorThemeProvider = {
    name: "molecule-type",
    label: "Molecule Type",
    category: "Residue Property",
    factory: d,
    getParams: l,
    defaultValues: a.ParamDefinition.getDefaultValues(e.MoleculeTypeColorThemeParams),
    isApplicable: function(m) {
      return !!m.structure;
    }
  };
})(FE);
var yq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.PolymerIdColorThemeProvider = e.PolymerIdColorTheme = e.getPolymerIdColorThemeParams = e.PolymerIdColorThemeParams = void 0;
  var r = Te, t = Je(), n = Tr(), a = Le, i = ii, o = Qe(), c = _c, s = "dark-2", u = (0, n.Color)(16448250), l = "Gives every polymer chain a color based on its `asym_id` value.";
  e.PolymerIdColorThemeParams = (0, r.__assign)({}, (0, i.getPaletteParams)({ type: "colors", colorList: s }));
  function f(v) {
    var h = a.ParamDefinition.clone(e.PolymerIdColorThemeParams);
    return v.structure && m(v.structure.root).size > c.ColorLists[s].list.length && (h.palette.defaultValue.name = "colors", h.palette.defaultValue.params = (0, r.__assign)((0, r.__assign)({}, h.palette.defaultValue.params), { list: {
      kind: "interpolate",
      colors: (0, c.getColorListFromName)(s).list
    } })), h;
  }
  e.getPolymerIdColorThemeParams = f;
  function d(v) {
    switch (v.kind) {
      case 0:
        return t.StructureProperties.chain.label_asym_id;
      case 1:
      case 2:
        return t.StructureProperties.coarse.asym_id;
    }
  }
  function m(v) {
    for (var h = /* @__PURE__ */ new Map(), y = 0, C = v.unitSymmetryGroups.length; y < C; ++y) {
      var S = v.unitSymmetryGroups[y].units[0], b = S.model;
      if (t.Unit.isAtomic(S))
        for (var g = b.atomicHierarchy, _ = g.chainAtomSegments, A = g.chains, M = o.Segmentation.transientSegments(_, S.elements); M.hasNext; ) {
          var P = M.move().index, T = A.label_entity_id.value(P), x = b.entities.getEntityIndex(T);
          if (b.entities.data.type.value(x) === "polymer") {
            var w = A.label_asym_id.value(P);
            h.has(w) || h.set(w, h.size);
          }
        }
      else if (t.Unit.isCoarse(S))
        for (var E = t.Unit.isSpheres(S) ? b.coarseHierarchy.spheres : b.coarseHierarchy.gaussians, I = E.chainElementSegments, B = E.asym_id, D = E.entity_id, M = o.Segmentation.transientSegments(I, S.elements); M.hasNext; ) {
          var P = M.move().index, N = I.offsets[P], T = D.value(N), x = b.entities.getEntityIndex(T);
          if (b.entities.data.type.value(x) === "polymer") {
            var w = B.value(N);
            h.has(w) || h.set(w, h.size);
          }
        }
    }
    return h;
  }
  function p(v, h) {
    var y, C;
    if (v.structure) {
      var S = t.StructureElement.Location.create(v.structure), b = m(v.structure.root), g = Array.from(b.keys()), _ = function(M) {
        return g[M];
      }, A = (0, i.getPalette)(b.size, h, {
        valueLabel: _
      });
      C = A.legend, y = function(M) {
        var P = void 0;
        if (t.StructureElement.Location.is(M)) {
          var T = d(M.unit);
          P = b.get(T(M));
        } else if (t.Bond.isLocation(M)) {
          var T = d(M.aUnit);
          S.unit = M.aUnit, S.element = M.aUnit.elements[M.aIndex], P = b.get(T(S));
        }
        return P === void 0 ? u : A.color(P);
      };
    } else
      y = function() {
        return u;
      };
    return {
      factory: p,
      granularity: "group",
      color: y,
      props: h,
      description: l,
      legend: C
    };
  }
  e.PolymerIdColorTheme = p, e.PolymerIdColorThemeProvider = {
    name: "polymer-id",
    label: "Polymer Chain Id",
    category: "Chain Property",
    factory: p,
    getParams: f,
    defaultValues: a.ParamDefinition.getDefaultValues(e.PolymerIdColorThemeParams),
    isApplicable: function(v) {
      return !!v.structure;
    }
  };
})(yq);
var _q = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.PolymerIndexColorThemeProvider = e.PolymerIndexColorTheme = e.getPolymerIndexColorThemeParams = e.PolymerIndexColorThemeParams = void 0;
  var r = Te, t = Tr(), n = Je(), a = Le, i = ii, o = _c, c = "dark-2", s = (0, t.Color)(13421772), u = "Gives every polymer chain instance a unique color based on the position (index) of the polymer in the list of polymers in the structure.";
  e.PolymerIndexColorThemeParams = (0, r.__assign)({}, (0, i.getPaletteParams)({ type: "colors", colorList: c }));
  function l(m) {
    var p = a.ParamDefinition.clone(e.PolymerIndexColorThemeParams);
    return m.structure && f(m.structure.root) > o.ColorLists[c].list.length && (p.palette.defaultValue.name = "colors", p.palette.defaultValue.params = (0, r.__assign)((0, r.__assign)({}, p.palette.defaultValue.params), { list: {
      kind: "interpolate",
      colors: (0, o.getColorListFromName)(c).list
    } })), p;
  }
  e.getPolymerIndexColorThemeParams = l;
  function f(m) {
    for (var p = 0, v = m.units, h = 0, y = v.length; h < y; ++h)
      v[h].polymerElements.length > 0 && ++p;
    return p;
  }
  function d(m, p) {
    var v, h;
    if (m.structure) {
      var y = (0, i.getPalette)(f(m.structure.root), p);
      h = y.legend;
      for (var C = m.structure.root.units, S = /* @__PURE__ */ new Map(), b = 0, g = 0, _ = C.length; b < _; ++b)
        C[b].polymerElements.length > 0 && (S.set(C[b].id, y.color(g)), ++g);
      v = function(A) {
        var M;
        return n.StructureElement.Location.is(A) ? M = S.get(A.unit.id) : n.Bond.isLocation(A) && (M = S.get(A.aUnit.id)), M !== void 0 ? M : s;
      };
    } else
      v = function() {
        return s;
      };
    return {
      factory: d,
      granularity: "instance",
      color: v,
      props: p,
      description: u,
      legend: h
    };
  }
  e.PolymerIndexColorTheme = d, e.PolymerIndexColorThemeProvider = {
    name: "polymer-index",
    label: "Polymer Chain Instance",
    category: "Chain Property",
    factory: d,
    getParams: l,
    defaultValues: a.ParamDefinition.getDefaultValues(e.PolymerIndexColorThemeParams),
    isApplicable: function(m) {
      return !!m.structure;
    }
  };
})(_q);
var bq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ResidueNameColorThemeProvider = e.ResidueNameColorTheme = e.residueNameColor = e.getResidueNameColorThemeParams = e.ResidueNameColorThemeParams = e.ResidueNameColors = void 0;
  var r = Tr(), t = Je(), n = Le, a = ti, i = Iu(), o = Mc;
  e.ResidueNameColors = (0, r.ColorMap)({
    // standard amino acids
    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,
    // rna bases
    A: 14423100,
    G: 3329330,
    I: 10145074,
    C: 16766720,
    T: 4286945,
    U: 4251856,
    // dna bases
    DA: 14423100,
    DG: 3329330,
    DI: 10145074,
    DC: 16766720,
    DT: 4286945,
    DU: 4251856,
    // peptide bases
    APN: 14423100,
    GPN: 3329330,
    CPN: 16766720,
    TPN: 4286945,
    MOL: 0
  });
  var c = (0, r.Color)(16711935), s = "Assigns a color to every residue according to its name.";
  e.ResidueNameColorThemeParams = {
    saturation: n.ParamDefinition.Numeric(0, { min: -6, max: 6, step: 0.1 }),
    lightness: n.ParamDefinition.Numeric(1, { min: -6, max: 6, step: 0.1 }),
    colors: n.ParamDefinition.MappedStatic("default", {
      default: n.ParamDefinition.EmptyGroup(),
      custom: n.ParamDefinition.Group((0, o.getColorMapParams)(e.ResidueNameColors))
    })
  };
  function u(p) {
    return e.ResidueNameColorThemeParams;
  }
  e.getResidueNameColorThemeParams = u;
  function l(p, v) {
    return p.model.atomicHierarchy.atoms.label_comp_id.value(v);
  }
  function f(p, v) {
    var h = p.coarseElements.seq_id_begin.value(v), y = p.coarseElements.seq_id_end.value(v);
    if (h === y) {
      var C = p.coarseElements.entityKey[v], S = p.model.sequence.byEntityKey[C].sequence;
      return S.compId.value(h - 1);
    }
  }
  function d(p, v) {
    var h = p[v];
    return h === void 0 ? c : h;
  }
  e.residueNameColor = d;
  function m(p, v) {
    var h = (0, i.getAdjustedColorMap)(v.colors.name === "default" ? e.ResidueNameColors : v.colors.params, v.saturation, v.lightness);
    function y(C) {
      if (t.StructureElement.Location.is(C))
        if (t.Unit.isAtomic(C.unit)) {
          var S = l(C.unit, C.element);
          return d(h, S);
        } else {
          var S = f(C.unit, C.element);
          if (S)
            return d(h, S);
        }
      else if (t.Bond.isLocation(C))
        if (t.Unit.isAtomic(C.aUnit)) {
          var S = l(C.aUnit, C.aUnit.elements[C.aIndex]);
          return d(h, S);
        } else {
          var S = f(C.aUnit, C.aUnit.elements[C.aIndex]);
          if (S)
            return d(h, S);
        }
      return c;
    }
    return {
      factory: m,
      granularity: "group",
      preferSmoothing: !0,
      color: y,
      props: v,
      description: s,
      legend: (0, a.TableLegend)(Object.keys(h).map(function(C) {
        return [C, h[C]];
      }).concat([["Unknown", c]]))
    };
  }
  e.ResidueNameColorTheme = m, e.ResidueNameColorThemeProvider = {
    name: "residue-name",
    label: "Residue Name",
    category: "Residue Property",
    factory: m,
    getParams: u,
    defaultValues: n.ParamDefinition.getDefaultValues(e.ResidueNameColorThemeParams),
    isApplicable: function(p) {
      return !!p.structure;
    }
  };
})(bq);
var Sq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.SecondaryStructureColorThemeProvider = e.SecondaryStructureColorTheme = e.secondaryStructureColor = e.getSecondaryStructureColorThemeParams = e.SecondaryStructureColorThemeParams = void 0;
  var r = Tr(), t = Je(), n = Gr, a = Za, i = Le, o = ti, c = Ac(), s = Iu(), u = Mc, l = wr(), f = (0, r.ColorMap)({
    alphaHelix: 16711808,
    threeTenHelix: 10485888,
    piHelix: 6291584,
    betaTurn: 6324479,
    betaStrand: 16762880,
    coil: 16777215,
    bend: 6740169,
    turn: 45670,
    dna: 11403518,
    rna: 16580962,
    carbohydrate: 10921722
  }), d = (0, r.Color)(8421504), m = "Assigns a color based on the type of secondary structure and basic molecule type.";
  e.SecondaryStructureColorThemeParams = {
    saturation: i.ParamDefinition.Numeric(-1, { min: -6, max: 6, step: 0.1 }),
    lightness: i.ParamDefinition.Numeric(0, { min: -6, max: 6, step: 0.1 }),
    colors: i.ParamDefinition.MappedStatic("default", {
      default: i.ParamDefinition.EmptyGroup(),
      custom: i.ParamDefinition.Group((0, u.getColorMapParams)(f))
    })
  };
  function p(y) {
    return e.SecondaryStructureColorThemeParams;
  }
  e.getSecondaryStructureColorThemeParams = p;
  function v(y, C, S, b) {
    var g = n.SecondaryStructureType.create(
      0
      /* None */
    );
    if (b && t.Unit.isAtomic(C)) {
      var _ = b.get(C.invariantId);
      _ && (g = _.type[_.getIndex(C.residueIndex[S])]);
    }
    if (n.SecondaryStructureType.is(
      g,
      2
      /* Helix */
    ))
      return n.SecondaryStructureType.is(
        g,
        2048
        /* Helix3Ten */
      ) ? y.threeTenHelix : n.SecondaryStructureType.is(
        g,
        32768
        /* HelixPi */
      ) ? y.piHelix : y.alphaHelix;
    if (n.SecondaryStructureType.is(
      g,
      4
      /* Beta */
    ))
      return y.betaStrand;
    if (n.SecondaryStructureType.is(
      g,
      8
      /* Bend */
    ))
      return y.bend;
    if (n.SecondaryStructureType.is(
      g,
      16
      /* Turn */
    ))
      return y.turn;
    var A = (0, a.getElementMoleculeType)(C, S);
    return A === 7 ? y.dna : A === 6 ? y.rna : A === 9 ? y.carbohydrate : A === 5 ? y.coil : d;
  }
  e.secondaryStructureColor = v;
  function h(y, C) {
    var S = y.structure && c.SecondaryStructureProvider.get(y.structure), b = S ? (0, l.hash2)(S.id, S.version) : -1, g = (0, s.getAdjustedColorMap)(C.colors.name === "default" ? f : C.colors.params, C.saturation, C.lightness);
    function _(A) {
      return t.StructureElement.Location.is(A) ? v(g, A.unit, A.element, S == null ? void 0 : S.value) : t.Bond.isLocation(A) ? v(g, A.aUnit, A.aUnit.elements[A.aIndex], S == null ? void 0 : S.value) : d;
    }
    return {
      factory: h,
      granularity: "group",
      preferSmoothing: !0,
      color: _,
      props: C,
      contextHash: b,
      description: m,
      legend: (0, o.TableLegend)(Object.keys(g).map(function(A) {
        return [A, g[A]];
      }).concat([["Other", d]]))
    };
  }
  e.SecondaryStructureColorTheme = h, e.SecondaryStructureColorThemeProvider = {
    name: "secondary-structure",
    label: "Secondary Structure",
    category: "Residue Property",
    factory: h,
    getParams: p,
    defaultValues: i.ParamDefinition.getDefaultValues(e.SecondaryStructureColorThemeParams),
    isApplicable: function(y) {
      return !!y.structure;
    },
    ensureCustomProperties: {
      attach: function(y, C) {
        return C.structure ? c.SecondaryStructureProvider.attach(y, C.structure, void 0, !0) : Promise.resolve();
      },
      detach: function(y) {
        return y.structure && c.SecondaryStructureProvider.ref(y.structure, !1);
      }
    }
  };
})(Sq);
var Cq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.SequenceIdColorThemeProvider = e.SequenceIdColorTheme = e.getSequenceIdColorThemeParams = e.SequenceIdColorThemeParams = void 0;
  var r = Je(), t = Tr(), n = Le, a = (0, t.Color)(13421772), i = "Gives every polymer residue a color based on its `seq_id` value.";
  e.SequenceIdColorThemeParams = {
    list: n.ParamDefinition.ColorList("turbo", { presetKind: "scale" })
  };
  function o(l) {
    return e.SequenceIdColorThemeParams;
  }
  e.getSequenceIdColorThemeParams = o;
  function c(l, f) {
    var d = l.model;
    switch (l.kind) {
      case 0:
        var m = d.atomicHierarchy.residueAtomSegments.index[f];
        return d.atomicHierarchy.residues.label_seq_id.value(m);
      case 1:
        return Math.round((d.coarseHierarchy.spheres.seq_id_begin.value(f) + d.coarseHierarchy.spheres.seq_id_end.value(f)) / 2);
      case 2:
        return Math.round((d.coarseHierarchy.gaussians.seq_id_begin.value(f) + d.coarseHierarchy.gaussians.seq_id_end.value(f)) / 2);
    }
  }
  function s(l, f) {
    var d = l.model, m = "";
    switch (l.kind) {
      case 0:
        var p = d.atomicHierarchy.chainAtomSegments.index[f];
        m = d.atomicHierarchy.chains.label_entity_id.value(p);
        break;
      case 1:
        m = d.coarseHierarchy.spheres.entity_id.value(f);
        break;
      case 2:
        m = d.coarseHierarchy.gaussians.entity_id.value(f);
        break;
    }
    if (m === "")
      return 0;
    var v = d.entities.getEntityIndex(m);
    if (v === -1)
      return 0;
    var h = d.sequence.byEntityKey[v];
    return h === void 0 ? 0 : h.sequence.length;
  }
  function u(l, f) {
    var d = t.ColorScale.create({
      listOrName: f.list.colors,
      minLabel: "Start",
      maxLabel: "End"
    }), m = function(p) {
      if (r.StructureElement.Location.is(p)) {
        var v = p.unit, h = p.element, y = c(v, h);
        if (y > 0) {
          var C = s(v, h);
          if (C)
            return d.setDomain(0, C - 1), d.color(y);
        }
      } else if (r.Bond.isLocation(p)) {
        var S = p.aUnit, b = p.aIndex, y = c(S, S.elements[b]);
        if (y > 0) {
          var C = s(S, S.elements[b]);
          if (C)
            return d.setDomain(0, C - 1), d.color(y);
        }
      }
      return a;
    };
    return {
      factory: u,
      granularity: "group",
      preferSmoothing: !0,
      color: m,
      props: f,
      description: i,
      legend: d ? d.legend : void 0
    };
  }
  e.SequenceIdColorTheme = u, e.SequenceIdColorThemeProvider = {
    name: "sequence-id",
    label: "Sequence Id",
    category: "Residue Property",
    factory: u,
    getParams: o,
    defaultValues: n.ParamDefinition.getDefaultValues(e.SequenceIdColorThemeParams),
    isApplicable: function(l) {
      return !!l.structure;
    }
  };
})(Cq);
var Aq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.UnitIndexColorThemeProvider = e.UnitIndexColorTheme = e.getUnitIndexColorThemeParams = e.UnitIndexColorThemeParams = void 0;
  var r = Te, t = Tr(), n = Je(), a = Le, i = ii, o = _c, c = "dark-2", s = (0, t.Color)(13421772), u = "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.";
  e.UnitIndexColorThemeParams = (0, r.__assign)({}, (0, i.getPaletteParams)({ type: "colors", colorList: c }));
  function l(d) {
    var m = a.ParamDefinition.clone(e.UnitIndexColorThemeParams);
    return d.structure && d.structure.root.units.length > o.ColorLists[c].list.length && (m.palette.defaultValue.name = "colors", m.palette.defaultValue.params = (0, r.__assign)((0, r.__assign)({}, m.palette.defaultValue.params), { list: {
      kind: "interpolate",
      colors: (0, o.getColorListFromName)(c).list
    } })), m;
  }
  e.getUnitIndexColorThemeParams = l;
  function f(d, m) {
    var p, v;
    if (d.structure) {
      var h = d.structure.root.units, y = (0, i.getPalette)(h.length, m);
      v = y.legend;
      for (var C = /* @__PURE__ */ new Map(), S = 0, b = h.length; S < b; ++S)
        C.set(h[S].id, y.color(S));
      p = function(g) {
        return n.StructureElement.Location.is(g) ? C.get(g.unit.id) : n.Bond.isLocation(g) ? C.get(g.aUnit.id) : s;
      };
    } else
      p = function() {
        return s;
      };
    return {
      factory: f,
      granularity: "instance",
      color: p,
      props: m,
      description: u,
      legend: v
    };
  }
  e.UnitIndexColorTheme = f, e.UnitIndexColorThemeProvider = {
    name: "unit-index",
    label: "Chain Instance",
    category: "Chain Property",
    factory: f,
    getParams: l,
    defaultValues: a.ParamDefinition.getDefaultValues(e.UnitIndexColorThemeParams),
    isApplicable: function(d) {
      return !!d.structure;
    }
  };
})(Aq);
var xq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.UncertaintyColorThemeProvider = e.UncertaintyColorTheme = e.getUncertainty = e.getUncertaintyColorThemeParams = e.UncertaintyColorThemeParams = void 0;
  var r = Tr(), t = Je(), n = Le, a = (0, r.Color)(16777113), i = "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.";
  e.UncertaintyColorThemeParams = {
    domain: n.ParamDefinition.Interval([0, 100]),
    list: n.ParamDefinition.ColorList("red-white-blue", { presetKind: "scale" })
  };
  function o(u) {
    return e.UncertaintyColorThemeParams;
  }
  e.getUncertaintyColorThemeParams = o;
  function c(u, l) {
    return t.Unit.isAtomic(u) ? u.model.atomicConformation.B_iso_or_equiv.value(l) : t.Unit.isSpheres(u) ? u.model.coarseConformation.spheres.rmsf[l] : 0;
  }
  e.getUncertainty = c;
  function s(u, l) {
    var f = r.ColorScale.create({
      reverse: !0,
      domain: l.domain,
      listOrName: l.list.colors
    });
    function d(m) {
      return t.StructureElement.Location.is(m) ? f.color(c(m.unit, m.element)) : t.Bond.isLocation(m) ? f.color(c(m.aUnit, m.aUnit.elements[m.aIndex])) : a;
    }
    return {
      factory: s,
      granularity: "group",
      preferSmoothing: !0,
      color: d,
      props: l,
      description: i,
      legend: f ? f.legend : void 0
    };
  }
  e.UncertaintyColorTheme = s, e.UncertaintyColorThemeProvider = {
    name: "uncertainty",
    label: "Uncertainty/Disorder",
    category: "Atom Property",
    factory: s,
    getParams: o,
    defaultValues: n.ParamDefinition.getDefaultValues(e.UncertaintyColorThemeParams),
    isApplicable: function(u) {
      return !!u.structure && u.structure.models.some(function(l) {
        return l.atomicConformation.B_iso_or_equiv.isDefined || l.coarseHierarchy.isDefined;
      });
    }
  };
})(xq);
var Tq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.IllustrativeColorThemeProvider = e.IllustrativeColorTheme = e.getIllustrativeColorThemeParams = e.IllustrativeColorThemeParams = void 0;
  var r = Tr(), t = Je(), n = Le, a = L0, i = py, o = Ft, c = Ip, s = FE, u = Bp, l = (0, r.Color)(15658734), f = "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).";
  e.IllustrativeColorThemeParams = {
    style: n.ParamDefinition.MappedStatic("entity-id", {
      uniform: n.ParamDefinition.Group(i.UniformColorThemeParams),
      "chain-id": n.ParamDefinition.Group(a.ChainIdColorThemeParams),
      "entity-id": n.ParamDefinition.Group(c.EntityIdColorThemeParams),
      "entity-source": n.ParamDefinition.Group(u.EntitySourceColorThemeParams),
      "molecule-type": n.ParamDefinition.Group(s.MoleculeTypeColorThemeParams)
    }),
    carbonLightness: n.ParamDefinition.Numeric(0.8, { min: -6, max: 6, step: 0.1 })
  };
  function d(p) {
    var v = n.ParamDefinition.clone(e.IllustrativeColorThemeParams);
    return v;
  }
  e.getIllustrativeColorThemeParams = d;
  function m(p, v) {
    var h = v.style.name === "uniform" ? (0, i.UniformColorTheme)(p, v.style.params) : v.style.name === "chain-id" ? (0, a.ChainIdColorTheme)(p, v.style.params) : v.style.name === "entity-id" ? (0, c.EntityIdColorTheme)(p, v.style.params) : v.style.name === "entity-source" ? (0, u.EntitySourceColorTheme)(p, v.style.params) : v.style.name === "molecule-type" ? (0, s.MoleculeTypeColorTheme)(p, v.style.params) : (0, o.assertUnreachable)(v.style), y = h.color, C = h.legend;
    function S(g, _) {
      var A = y(g, !1);
      return _ === "C" ? r.Color.lighten(A, v.carbonLightness) : A;
    }
    function b(g) {
      if (t.StructureElement.Location.is(g) && t.Unit.isAtomic(g.unit)) {
        var _ = g.unit.model.atomicHierarchy.atoms.type_symbol.value(g.element);
        return S(g, _);
      } else if (t.Bond.isLocation(g) && t.Unit.isAtomic(g.aUnit)) {
        var A = g.aUnit.elements[g.aIndex], _ = g.aUnit.model.atomicHierarchy.atoms.type_symbol.value(A);
        return S(g, _);
      }
      return l;
    }
    return {
      factory: m,
      granularity: "group",
      preferSmoothing: !0,
      color: b,
      props: v,
      description: f,
      legend: C
    };
  }
  e.IllustrativeColorTheme = m, e.IllustrativeColorThemeProvider = {
    name: "illustrative",
    label: "Illustrative",
    category: "Miscellaneous",
    factory: m,
    getParams: d,
    defaultValues: n.ParamDefinition.getDefaultValues(e.IllustrativeColorThemeParams),
    isApplicable: function(p) {
      return !!p.structure;
    }
  };
})(Tq);
var Pq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.HydrophobicityColorThemeProvider = e.HydrophobicityColorTheme = e.hydrophobicity = e.getHydrophobicityColorThemeParams = e.HydrophobicityColorThemeParams = void 0;
  var r = Tr(), t = Je(), n = Le, a = Gr, i = '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).';
  e.HydrophobicityColorThemeParams = {
    list: n.ParamDefinition.ColorList("red-yellow-green", { presetKind: "scale" }),
    scale: n.ParamDefinition.Select("DGwif", [
      ["DGwif", "DG water-membrane"],
      ["DGwoct", "DG water-octanol"],
      ["Oct-IF", "DG difference"]
    ])
  };
  function o(d) {
    return e.HydrophobicityColorThemeParams;
  }
  e.getHydrophobicityColorThemeParams = o;
  var c = { DGwif: 0, DGwoct: 1, "Oct-IF": 2 };
  function s(d, m) {
    var p = a.ResidueHydrophobicity[d];
    return p === void 0 ? 0 : p[m];
  }
  e.hydrophobicity = s;
  function u(d, m) {
    return d.model.atomicHierarchy.atoms.label_comp_id.value(m);
  }
  function l(d, m) {
    var p = d.coarseElements.seq_id_begin.value(m), v = d.coarseElements.seq_id_end.value(m);
    if (p === v) {
      var h = d.coarseElements.entityKey[m], y = d.model.sequence.byEntityKey[h].sequence;
      return y.compId.value(p - 1);
    }
  }
  function f(d, m) {
    var p = c[m.scale], v = 1 / 0, h = -1 / 0;
    for (var y in a.ResidueHydrophobicity) {
      var C = a.ResidueHydrophobicity[y][p];
      v = Math.min(v, C), h = Math.max(h, C);
    }
    var S = r.ColorScale.create({
      listOrName: m.list.colors,
      domain: [h, v],
      minLabel: "Hydrophilic",
      maxLabel: "Hydrophobic"
    });
    function b(g) {
      var _;
      return t.StructureElement.Location.is(g) ? t.Unit.isAtomic(g.unit) ? _ = u(g.unit, g.element) : _ = l(g.unit, g.element) : t.Bond.isLocation(g) && (t.Unit.isAtomic(g.aUnit) ? _ = u(g.aUnit, g.aUnit.elements[g.aIndex]) : _ = l(g.aUnit, g.aUnit.elements[g.aIndex])), S.color(_ ? s(_, p) : 0);
    }
    return {
      factory: f,
      granularity: "group",
      preferSmoothing: !0,
      color: b,
      props: m,
      description: i,
      legend: S ? S.legend : void 0
    };
  }
  e.HydrophobicityColorTheme = f, e.HydrophobicityColorThemeProvider = {
    name: "hydrophobicity",
    label: "Hydrophobicity",
    category: "Residue Property",
    factory: f,
    getParams: o,
    defaultValues: n.ParamDefinition.getDefaultValues(e.HydrophobicityColorThemeParams),
    isApplicable: function(d) {
      return !!d.structure;
    }
  };
})(Pq);
var Mq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ModelIndexColorThemeProvider = e.ModelIndexColorTheme = e.getModelIndexColorThemeParams = e.ModelIndexColorThemeParams = void 0;
  var r = Te, t = Tr(), n = Je(), a = Le, i = ii, o = (0, t.Color)(13421772), c = "Gives every model a unique color based on the position (index) of the model in the list of models in the structure.";
  e.ModelIndexColorThemeParams = (0, r.__assign)({}, (0, i.getPaletteParams)({ type: "colors", colorList: "purples" }));
  function s(l) {
    return e.ModelIndexColorThemeParams;
  }
  e.getModelIndexColorThemeParams = s;
  function u(l, f) {
    var d, m, p, v;
    if (l.structure) {
      for (var h = l.structure.root.models, y = 0, C = 0, S = h; C < S.length; C++) {
        var b = S[C];
        y = Math.max(y, ((d = n.Model.TrajectoryInfo.get(b)) === null || d === void 0 ? void 0 : d.size) || 0);
      }
      var g = (0, i.getPalette)(y, f);
      v = g.legend;
      for (var _ = /* @__PURE__ */ new Map(), A = 0, M = h.length; A < M; ++A) {
        var P = ((m = n.Model.TrajectoryInfo.get(h[A])) === null || m === void 0 ? void 0 : m.index) || 0;
        _.set(P, g.color(P));
      }
      p = function(T) {
        return n.StructureElement.Location.is(T) ? _.get(n.Model.TrajectoryInfo.get(T.unit.model).index) : n.Bond.isLocation(T) ? _.get(n.Model.TrajectoryInfo.get(T.aUnit.model).index) : o;
      };
    } else
      p = function() {
        return o;
      };
    return {
      factory: u,
      granularity: "instance",
      color: p,
      props: f,
      description: c,
      legend: v
    };
  }
  e.ModelIndexColorTheme = u, e.ModelIndexColorThemeProvider = {
    name: "model-index",
    label: "Model Index",
    category: "Chain Property",
    factory: u,
    getParams: s,
    defaultValues: a.ParamDefinition.getDefaultValues(e.ModelIndexColorThemeParams),
    isApplicable: function(l) {
      return !!l.structure && l.structure.elementCount > 0 && n.Model.TrajectoryInfo.get(l.structure.models[0]).size > 1;
    }
  };
})(Mq);
var wq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.OccupancyColorThemeProvider = e.OccupancyColorTheme = e.getOccupancy = e.getOccupancyColorThemeParams = e.OccupancyColorThemeParams = void 0;
  var r = Tr(), t = Je(), n = Le, a = (0, r.Color)(13421772), i = "Assigns a color based on the occupancy of an atom.";
  e.OccupancyColorThemeParams = {
    domain: n.ParamDefinition.Interval([0, 1]),
    list: n.ParamDefinition.ColorList("purples", { presetKind: "scale" })
  };
  function o(u) {
    return e.OccupancyColorThemeParams;
  }
  e.getOccupancyColorThemeParams = o;
  function c(u, l) {
    return t.Unit.isAtomic(u) ? u.model.atomicConformation.occupancy.value(l) : 0;
  }
  e.getOccupancy = c;
  function s(u, l) {
    var f = r.ColorScale.create({
      reverse: !1,
      domain: l.domain,
      listOrName: l.list.colors
    });
    function d(m) {
      return t.StructureElement.Location.is(m) ? f.color(c(m.unit, m.element)) : t.Bond.isLocation(m) ? f.color(c(m.aUnit, m.aUnit.elements[m.aIndex])) : a;
    }
    return {
      factory: s,
      granularity: "group",
      preferSmoothing: !0,
      color: d,
      props: l,
      description: i,
      legend: f ? f.legend : void 0
    };
  }
  e.OccupancyColorTheme = s, e.OccupancyColorThemeProvider = {
    name: "occupancy",
    label: "Occupancy",
    category: "Atom Property",
    factory: s,
    getParams: o,
    defaultValues: n.ParamDefinition.getDefaultValues(e.OccupancyColorThemeParams),
    isApplicable: function(u) {
      return !!u.structure && u.structure.models.some(function(l) {
        return l.atomicConformation.occupancy.isDefined;
      });
    }
  };
})(wq);
var Eq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.OperatorHklColorThemeProvider = e.OperatorHklColorTheme = e.getOperatorHklColorThemeParams = e.OperatorHklColorThemeParams = void 0;
  var r = Te, t = Tr(), n = Je(), a = Le, i = ii, o = fa, c = _c, s = "dark-2", u = (0, t.Color)(13421772), l = "Assigns a color based on the operator HKL value of a transformed chain.";
  e.OperatorHklColorThemeParams = (0, r.__assign)({}, (0, i.getPaletteParams)({ type: "colors", colorList: s }));
  function f(C) {
    var S = a.ParamDefinition.clone(e.OperatorHklColorThemeParams);
    return C.structure && h(C.structure.root).map.size > c.ColorLists[s].list.length && (S.palette.defaultValue.name = "colors", S.palette.defaultValue.params = (0, r.__assign)((0, r.__assign)({}, S.palette.defaultValue.params), { list: {
      kind: "interpolate",
      colors: (0, c.getColorListFromName)(s).list
    } })), S;
  }
  e.getOperatorHklColorThemeParams = f;
  var d = 1e4;
  function m(C) {
    return C.map(function(S) {
      return "".concat(S + d).padStart(5, "0");
    }).join("");
  }
  function p(C) {
    var S = (0, o.integerDigitCount)(d, 0), b = parseInt(C.substr(0, S)), g = parseInt(C.substr(S, S)), _ = parseInt(C.substr(S + S, S));
    return [b - d, g - d, _ - d];
  }
  function v(C) {
    return C.map(function(S) {
      return S + 5;
    }).join("");
  }
  function h(C) {
    for (var S = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Set(), g = 0, _ = C.units.length; g < _; ++g) {
      var A = m(C.units[g].conformation.operator.hkl);
      b.add(A);
    }
    var M = Array.from(b.values()).sort();
    M.forEach(function(x) {
      return S.set(x, S.size);
    });
    var P = p(M[0]), T = p(M[M.length - 1]);
    return { min: P, max: T, map: S };
  }
  function y(C, S) {
    var b, g;
    if (C.structure) {
      var _ = h(C.structure.root), A = _.min, M = _.max, P = _.map, T = [];
      P.forEach(function(E, I) {
        var B = E % P.size, D = v(p(I));
        T[B] === void 0 ? T[B] = D : T[B] += ", ".concat(D);
      });
      var x = {
        minLabel: v(A),
        maxLabel: v(M),
        valueLabel: function(E) {
          return T[E];
        }
      }, w = (0, i.getPalette)(P.size, S, x);
      g = w.legend, b = function(E) {
        var I = void 0;
        if (n.StructureElement.Location.is(E)) {
          var B = m(E.unit.conformation.operator.hkl);
          I = P.get(B);
        } else if (n.Bond.isLocation(E)) {
          var B = m(E.aUnit.conformation.operator.hkl);
          I = P.get(B);
        }
        return I === void 0 ? u : w.color(I);
      };
    } else
      b = function() {
        return u;
      };
    return {
      factory: y,
      granularity: "instance",
      color: b,
      props: S,
      description: l,
      legend: g
    };
  }
  e.OperatorHklColorTheme = y, e.OperatorHklColorThemeProvider = {
    name: "operator-hkl",
    label: "Operator HKL",
    category: "Symmetry",
    factory: y,
    getParams: f,
    defaultValues: a.ParamDefinition.getDefaultValues(e.OperatorHklColorThemeParams),
    isApplicable: function(C) {
      return !!C.structure;
    }
  };
})(Eq);
var Dq = {}, Wd = {};
Object.defineProperty(Wd, "__esModule", { value: !0 });
Wd.AtomPartialCharge = void 0;
var pde = hs, FM;
(function(e) {
  e.Descriptor = {
    name: "atom_partial_charge"
  }, e.Provider = pde.FormatPropertyProvider.create(e.Descriptor);
})(FM || (FM = {}));
Wd.AtomPartialCharge = FM;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.PartialChargeColorThemeProvider = e.PartialChargeColorTheme = e.getPartialChargeColorThemeParams = e.PartialChargeColorThemeParams = void 0;
  var r = Tr(), t = Je(), n = Le, a = Wd, i = (0, r.Color)(16777113), o = "Assigns a color based on the partial charge of an atom.";
  e.PartialChargeColorThemeParams = {
    domain: n.ParamDefinition.Interval([-1, 1]),
    list: n.ParamDefinition.ColorList("red-white-blue", { presetKind: "scale" })
  };
  function c(l) {
    return e.PartialChargeColorThemeParams;
  }
  e.getPartialChargeColorThemeParams = c;
  function s(l, f) {
    var d;
    return (d = a.AtomPartialCharge.Provider.get(l.model)) === null || d === void 0 ? void 0 : d.data.value(f);
  }
  function u(l, f) {
    var d = r.ColorScale.create({
      domain: f.domain,
      listOrName: f.list.colors
    });
    function m(p) {
      if (t.StructureElement.Location.is(p)) {
        var v = s(p.unit, p.element);
        return v !== void 0 && !Number.isNaN(v) ? d.color(v) : i;
      } else if (t.Bond.isLocation(p)) {
        var v = s(p.aUnit, p.aUnit.elements[p.aIndex]);
        return v !== void 0 && !Number.isNaN(v) ? d.color(v) : i;
      }
      return i;
    }
    return {
      factory: u,
      granularity: "group",
      preferSmoothing: !0,
      color: m,
      props: f,
      description: o,
      legend: d ? d.legend : void 0
    };
  }
  e.PartialChargeColorTheme = u, e.PartialChargeColorThemeProvider = {
    name: "partial-charge",
    label: "Partial Charge",
    category: "Atom Property",
    factory: u,
    getParams: c,
    defaultValues: n.ParamDefinition.getDefaultValues(e.PartialChargeColorThemeParams),
    isApplicable: function(l) {
      return !!l.structure && l.structure.models.some(function(f) {
        return a.AtomPartialCharge.Provider.get(f) !== void 0;
      });
    }
  };
})(Dq);
var Iq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.AtomIdColorThemeProvider = e.AtomIdColorTheme = e.getAtomIdColorThemeParams = e.AtomIdColorThemeParams = void 0;
  var r = Te, t = Je(), n = Tr(), a = Le, i = ii, o = "many-distinct", c = (0, n.Color)(16448250), s = "Gives every atom a color based on its `label_atom_id` value.";
  e.AtomIdColorThemeParams = (0, r.__assign)({}, (0, i.getPaletteParams)({ type: "colors", colorList: o }));
  function u(d) {
    var m = a.ParamDefinition.clone(e.AtomIdColorThemeParams);
    return m;
  }
  e.getAtomIdColorThemeParams = u;
  function l(d) {
    for (var m = /* @__PURE__ */ new Map(), p = 0, v = d.models; p < v.length; p++)
      for (var h = v[p], y = h.atomicHierarchy.atoms.label_atom_id, C = 0, S = y.rowCount; C < S; ++C) {
        var b = y.value(C);
        m.has(b) || m.set(b, m.size);
      }
    return m;
  }
  function f(d, m) {
    var p, v;
    if (d.structure) {
      var h = t.StructureElement.Location.create(d.structure.root), y = l(d.structure.root), C = Array.from(y.keys()), S = function(g) {
        return C[g];
      }, b = (0, i.getPalette)(y.size, m, { valueLabel: S });
      v = b.legend, p = function(g) {
        var _ = void 0;
        if (t.StructureElement.Location.is(g)) {
          var A = t.StructureProperties.atom.label_atom_id(g);
          _ = y.get(A);
        } else if (t.Bond.isLocation(g)) {
          h.unit = g.aUnit, h.element = g.aUnit.elements[g.aIndex];
          var A = t.StructureProperties.atom.label_atom_id(h);
          _ = y.get(A);
        }
        return _ === void 0 ? c : b.color(_);
      };
    } else
      p = function() {
        return c;
      };
    return {
      factory: f,
      granularity: "group",
      preferSmoothing: !0,
      color: p,
      props: m,
      description: s,
      legend: v
    };
  }
  e.AtomIdColorTheme = f, e.AtomIdColorThemeProvider = {
    name: "atom-id",
    label: "Atom Id",
    category: "Atom Property",
    factory: f,
    getParams: u,
    defaultValues: a.ParamDefinition.getDefaultValues(e.AtomIdColorThemeParams),
    isApplicable: function(d) {
      return !!d.structure;
    }
  };
})(Iq);
var Bq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.VolumeValueColorThemeProvider = e.VolumeValueColorTheme = e.getVolumeValueColorThemeParams = e.VolumeValueColorThemeParams = void 0;
  var r = Tr(), t = Le, n = Oa, a = (0, r.Color)(13421772), i = "Assign color based on the given value of a volume cell.";
  e.VolumeValueColorThemeParams = {
    colorList: t.ParamDefinition.ColorList({
      kind: "interpolate",
      colors: [
        [n.ColorNames.white, 0],
        [n.ColorNames.red, 0.25],
        [n.ColorNames.white, 0.5],
        [n.ColorNames.blue, 0.75],
        [n.ColorNames.white, 1]
      ]
    }, { offsets: !0, isEssential: !0 })
  };
  function o(s) {
    return e.VolumeValueColorThemeParams;
  }
  e.getVolumeValueColorThemeParams = o;
  function c(s, u) {
    for (var l = r.ColorScale.create({
      domain: [0, 1],
      listOrName: u.colorList.colors
    }), f = [], d = 0; d < 256; ++d)
      f[d] = l.color(d / 255);
    var m = { colors: f, filter: "linear" };
    return {
      factory: c,
      granularity: "direct",
      color: function() {
        return a;
      },
      props: u,
      description: i,
      legend: l.legend,
      palette: m
    };
  }
  e.VolumeValueColorTheme = c, e.VolumeValueColorThemeProvider = {
    name: "volume-value",
    label: "Volume Value",
    category: "Miscellaneous",
    factory: c,
    getParams: o,
    defaultValues: t.ParamDefinition.getDefaultValues(e.VolumeValueColorThemeParams),
    isApplicable: function(s) {
      return !!s.volume;
    }
  };
})(Bq);
var Nq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.UniFoldProvider = e.SequenceIdColorTheme = e.getSequenceIdColorThemeParams = e.SequenceIdColorThemeParams = void 0;
  var r = Je(), t = Tr(), n = Le, a = (0, t.Color)(13421772), i = "Fold";
  e.SequenceIdColorThemeParams = {
    list: n.ParamDefinition.ColorList("turbo", { presetKind: "scale" })
  };
  function o(s) {
    return e.SequenceIdColorThemeParams;
  }
  e.getSequenceIdColorThemeParams = o;
  function c(s, u) {
    var l = t.ColorScale.create({
      listOrName: u.list.colors,
      minLabel: "Start",
      maxLabel: "End"
    }), f = function(d) {
      if (r.StructureElement.Location.is(d)) {
        if (r.Unit.isAtomic(d.unit)) {
          var m = d.unit.model.atomicHierarchy.atoms.B_iso_or_equiv, p = m.value(d.element);
          if (p >= 90)
            return t.Color.fromRgb(148, 164, 239);
          if (p < 90 && p >= 70)
            return t.Color.fromRgb(148, 225, 239);
          if (p < 70 && p >= 50)
            return t.Color.fromRgb(240, 193, 145);
          if (p < 50)
            return t.Color.fromRgb(239, 156, 156);
        }
      } else if (r.Bond.isLocation(d) && r.Unit.isAtomic(d.aUnit)) {
        var m = d.aUnit.model.atomicHierarchy.atoms.B_iso_or_equiv, p = m.value(d.aUnit.elements[d.aIndex]);
        if (p >= 90)
          return t.Color.fromRgb(148, 164, 239);
        if (p < 90 && p >= 70)
          return t.Color.fromRgb(148, 225, 239);
        if (p < 70 && p >= 50)
          return t.Color.fromRgb(240, 193, 145);
        if (p < 50)
          return t.Color.fromRgb(239, 156, 156);
      }
      return a;
    };
    return {
      factory: c,
      granularity: "group",
      color: f,
      props: u,
      description: i,
      legend: l ? l.legend : void 0
    };
  }
  e.SequenceIdColorTheme = c, e.UniFoldProvider = {
    name: "uni-fold",
    label: "Uni-Fold",
    category: "Residue Property",
    factory: c,
    getParams: o,
    defaultValues: n.ParamDefinition.getDefaultValues(e.SequenceIdColorThemeParams),
    isApplicable: function(s) {
      return !!s.structure;
    }
  };
})(Nq);
var Vq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.CDRColorThemeProvider = e.CDRColorTheme = e.elementSymbolColor = e.getElementSymbolColorThemeParams = e.ElementSymbolColorThemeParams = e.ElementSymbolColors = void 0;
  var r = Tr(), t = Je(), n = Le, a = ti, i = Iu(), o = Mc, c = L0, s = Dp, u = Ip, l = Bp;
  e.ElementSymbolColors = (0, r.ColorMap)({
    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
  });
  var f = (0, r.Color)(16777215), d = "CDR";
  e.ElementSymbolColorThemeParams = {
    carbonColor: n.ParamDefinition.MappedStatic("chain-id", {
      "chain-id": n.ParamDefinition.Group(c.ChainIdColorThemeParams),
      "entity-id": n.ParamDefinition.Group(u.EntityIdColorThemeParams),
      "entity-source": n.ParamDefinition.Group(l.EntitySourceColorThemeParams),
      "operator-name": n.ParamDefinition.Group(s.OperatorNameColorThemeParams),
      "element-symbol": n.ParamDefinition.EmptyGroup()
    }, { description: "Use chain-id coloring for carbon atoms." }),
    saturation: n.ParamDefinition.Numeric(0, { min: -6, max: 6, step: 0.1 }),
    lightness: n.ParamDefinition.Numeric(0.2, { min: -6, max: 6, step: 0.1 }),
    colors: n.ParamDefinition.MappedStatic("default", {
      default: n.ParamDefinition.EmptyGroup(),
      custom: n.ParamDefinition.Group((0, o.getColorMapParams)(e.ElementSymbolColors))
    })
  };
  function m(h) {
    return e.ElementSymbolColorThemeParams;
  }
  e.getElementSymbolColorThemeParams = m;
  function p(h, y) {
    var C = h[y];
    return C === void 0 ? f : C;
  }
  e.elementSymbolColor = p;
  function v(h, y) {
    var C = (0, i.getAdjustedColorMap)(y.colors.name === "default" ? e.ElementSymbolColors : y.colors.params, y.saturation, y.lightness);
    function S(g) {
      if (t.StructureElement.Location.is(g)) {
        if (t.Unit.isAtomic(g.unit)) {
          var _ = g.unit.model.atomicHierarchy.atoms.cdr, A = g.unit.model.atomicHierarchy.chains.auth_asym_id, M = _.value(g.element), P = A.value(g.unit.chainIndex[g.element]);
          return M !== 0 ? M === 3 && P.toLocaleUpperCase() === "H" ? r.Color.fromRgb(252, 180, 91) : r.Color.fromRgb(153, 154, 235) : P.toLocaleUpperCase() === "L" ? r.Color.fromRgb(145, 225, 192) : P.toLocaleUpperCase() === "H" ? r.Color.fromRgb(148, 223, 247) : (0, r.Color)(16777215);
        }
      } else if (t.Bond.isLocation(g) && t.Unit.isAtomic(g.aUnit)) {
        var _ = g.aUnit.model.atomicHierarchy.atoms.cdr, A = g.aUnit.model.atomicHierarchy.chains.auth_asym_id, M = _.value(g.aUnit.elements[g.aIndex]), P = A.value(g.aUnit.chainIndex[g.aIndex]);
        return M !== 0 ? M === 3 && P.toLocaleUpperCase() === "H" ? r.Color.fromRgb(252, 180, 91) : r.Color.fromRgb(153, 154, 235) : P.toLocaleUpperCase() === "L" ? r.Color.fromRgb(145, 225, 192) : P.toLocaleUpperCase() === "H" ? r.Color.fromRgb(148, 223, 247) : (0, r.Color)(16777215);
      }
      return f;
    }
    var b = y.carbonColor.name === "operator-name" ? "groupInstance" : "group";
    return {
      factory: v,
      granularity: b,
      preferSmoothing: !0,
      color: S,
      props: y,
      description: d,
      legend: (0, a.TableLegend)(Object.keys(C).map(function(g) {
        return [g, C[g]];
      }))
    };
  }
  e.CDRColorTheme = v, e.CDRColorThemeProvider = {
    name: "cdr",
    label: "CDR",
    category: "Atom Property",
    factory: v,
    getParams: m,
    defaultValues: n.ParamDefinition.getDefaultValues(e.ElementSymbolColorThemeParams),
    isApplicable: function(h) {
      return !!h.structure;
    }
  };
})(Vq);
var Rq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.MultiThemeColorThemeProvider = e.MultiThemeColorTheme = e.getMultiThemeColorThemeParams = e.MultiThemeColorThemeParams = void 0;
  var r = Te, t = Je(), n = Tr(), a = Le, i = ii, o = "many-distinct", c = (0, n.Color)(16448250), s = "Structure allows multi theme based on location";
  e.MultiThemeColorThemeParams = (0, r.__assign)({ themes: a.ParamDefinition.Value([]) }, (0, i.getPaletteParams)({ type: "colors", colorList: o }));
  function u(f) {
    var d = a.ParamDefinition.clone(e.MultiThemeColorThemeParams);
    return d;
  }
  e.getMultiThemeColorThemeParams = u;
  function l(f, d) {
    var m, p = d.themes;
    return f.structure ? m = function(v, h) {
      if (t.StructureElement.Location.is(v))
        for (var y = 0; y < p.length; y++) {
          var C = p[y], S = t.StructureElement.Bundle.toStructure(C.bundle, f.structure);
          if (S.hasElement(v))
            return C.colorTheme.color(v, h);
        }
      else if (t.Bond.isLocation(v) && t.Unit.isAtomic(v.aUnit))
        for (var y = 0; y < p.length; y++) {
          var C = p[y], S = t.StructureElement.Bundle.toStructure(C.bundle, f.structure), b = t.StructureElement.Location.create(v.aStructure, v.aUnit, v.aUnit.elements[v.aIndex]);
          if (S.hasElement(b))
            return C.colorTheme.color(v, h);
        }
      return c;
    } : m = function() {
      return c;
    }, {
      factory: l,
      granularity: "group",
      preferSmoothing: !0,
      color: m,
      props: d,
      description: s
    };
  }
  e.MultiThemeColorTheme = l, e.MultiThemeColorThemeProvider = {
    name: "multi-theme",
    label: "Multi Theme",
    category: "Atom Property",
    factory: l,
    getParams: u,
    defaultValues: a.ParamDefinition.getDefaultValues(e.MultiThemeColorThemeParams),
    isApplicable: function(f) {
      return !!f.structure;
    }
  };
})(Rq);
var Oq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.EMColorThemeProvider = e.EMColorTheme = e.elementSymbolColor = e.getElementSymbolColorThemeParams = e.ElementSymbolColorThemeParams = e.ElementSymbolColors = void 0;
  var r = Tr(), t = Je(), n = Le, a = ti, i = Iu(), o = Mc, c = L0, s = Dp, u = Ip, l = Bp;
  e.ElementSymbolColors = (0, r.ColorMap)({
    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
  });
  var f = (0, r.Color)(16777215), d = "EM";
  e.ElementSymbolColorThemeParams = {
    carbonColor: n.ParamDefinition.MappedStatic("chain-id", {
      "chain-id": n.ParamDefinition.Group(c.ChainIdColorThemeParams),
      "entity-id": n.ParamDefinition.Group(u.EntityIdColorThemeParams),
      "entity-source": n.ParamDefinition.Group(l.EntitySourceColorThemeParams),
      "operator-name": n.ParamDefinition.Group(s.OperatorNameColorThemeParams),
      "element-symbol": n.ParamDefinition.EmptyGroup()
    }, { description: "Use chain-id coloring for carbon atoms." }),
    saturation: n.ParamDefinition.Numeric(0, { min: -6, max: 6, step: 0.1 }),
    lightness: n.ParamDefinition.Numeric(0.2, { min: -6, max: 6, step: 0.1 }),
    colors: n.ParamDefinition.MappedStatic("default", {
      default: n.ParamDefinition.EmptyGroup(),
      custom: n.ParamDefinition.Group((0, o.getColorMapParams)(e.ElementSymbolColors))
    })
  };
  function m(h) {
    return e.ElementSymbolColorThemeParams;
  }
  e.getElementSymbolColorThemeParams = m;
  function p(h, y) {
    var C = h[y];
    return C === void 0 ? f : C;
  }
  e.elementSymbolColor = p;
  function v(h, y) {
    var C = (0, i.getAdjustedColorMap)(y.colors.name === "default" ? e.ElementSymbolColors : y.colors.params, y.saturation, y.lightness);
    function S(g) {
      if (t.StructureElement.Location.is(g)) {
        if (t.Unit.isAtomic(g.unit)) {
          var _ = g.unit.model.atomicHierarchy.atoms.em_confidence, A = parseFloat(_.value(g.element));
          switch (!0) {
            case A < -1:
              return r.Color.fromRgb(239, 139, 139);
            case (A >= -1 && A < -0.8):
              return r.Color.fromRgb(239, 151, 139);
            case (A >= -0.8 && A < -0.6):
              return r.Color.fromRgb(239, 167, 138);
            case (A >= -0.6 && A < -0.4):
              return r.Color.fromRgb(239, 190, 136);
            case (A >= -0.4 && A < -0.2):
              return r.Color.fromRgb(239, 214, 136);
            case (A >= -0.2 && A < 0):
              return r.Color.fromRgb(239, 236, 135);
            case (A >= 0 && A < 0.2):
              return r.Color.fromRgb(134, 239, 134);
            case (A >= 0.2 && A < 0.4):
              return r.Color.fromRgb(134, 239, 227);
            case (A >= 0.4 && A < 0.6):
              return r.Color.fromRgb(134, 224, 239);
            case (A >= 0.6 && A < 0.8):
              return r.Color.fromRgb(134, 200, 239);
            case (A >= 0.8 && A <= 1):
              return r.Color.fromRgb(133, 175, 239);
            case A > 1:
              return r.Color.fromRgb(134, 153, 239);
            default:
              return (0, r.Color)(16777215);
          }
        }
      } else if (t.Bond.isLocation(g) && t.Unit.isAtomic(g.aUnit)) {
        var _ = g.aUnit.model.atomicHierarchy.atoms.em_confidence, A = parseFloat(_.value(g.aUnit.elements[g.aIndex]));
        switch (!0) {
          case A < -1:
            return r.Color.fromRgb(239, 139, 139);
          case (A >= -1 && A < -0.8):
            return r.Color.fromRgb(239, 151, 139);
          case (A >= -0.8 && A < -0.6):
            return r.Color.fromRgb(239, 167, 138);
          case (A >= -0.6 && A < -0.4):
            return r.Color.fromRgb(239, 190, 136);
          case (A >= -0.4 && A < -0.2):
            return r.Color.fromRgb(239, 214, 136);
          case (A >= -0.2 && A < 0):
            return r.Color.fromRgb(239, 236, 135);
          case (A >= 0 && A < 0.2):
            return r.Color.fromRgb(134, 239, 134);
          case (A >= 0.2 && A < 0.4):
            return r.Color.fromRgb(134, 239, 227);
          case (A >= 0.4 && A < 0.6):
            return r.Color.fromRgb(134, 224, 239);
          case (A >= 0.6 && A < 0.8):
            return r.Color.fromRgb(134, 200, 239);
          case (A >= 0.8 && A <= 1):
            return r.Color.fromRgb(133, 175, 239);
          case A > 1:
            return r.Color.fromRgb(134, 153, 239);
          default:
            return (0, r.Color)(16777215);
        }
      }
      return f;
    }
    var b = y.carbonColor.name === "operator-name" ? "groupInstance" : "group";
    return {
      factory: v,
      granularity: b,
      preferSmoothing: !0,
      color: S,
      props: y,
      description: d,
      legend: (0, a.TableLegend)(Object.keys(C).map(function(g) {
        return [g, C[g]];
      }))
    };
  }
  e.EMColorTheme = v, e.EMColorThemeProvider = {
    name: "em-confidence",
    label: "EM Confidence",
    category: "Residue Property",
    factory: v,
    getParams: m,
    defaultValues: n.ParamDefinition.getDefaultValues(e.ElementSymbolColorThemeParams),
    isApplicable: function(h) {
      return !!h.structure;
    }
  };
})(Oq);
var Fb = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.MaterialElementSymbolColorThemeProvider = e.MaterialElementSymbolColorTheme = e.elementSymbolColor = e.getMaterialElementSymbolColorThemeParams = e.MaterialElementSymbolColorThemeParams = e.MaterialElementSymbolColors = e.VESTA_COLOR_TABLE = void 0;
  var r = Te, t = Tr(), n = Je(), a = Le, i = ti, o = Iu(), c = L0, s = Dp;
  e.VESTA_COLOR_TABLE = {
    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
  };
  var u = window.materialColors, l = function() {
    Object.keys(u.settings).forEach(function(h) {
      e.VESTA_COLOR_TABLE[h] = u.getColorNumber(h);
    });
  };
  u && (l(), u.setColorsSubject.subscribe(function() {
    l();
  })), e.MaterialElementSymbolColors = (0, t.ColorMap)(e.VESTA_COLOR_TABLE);
  var f = (0, t.Color)(16777215), d = "Assigns a color to every atom according to its chemical element.";
  e.MaterialElementSymbolColorThemeParams = {
    carbonColor: a.ParamDefinition.MappedStatic("chain-id", {
      "chain-id": a.ParamDefinition.Group((0, r.__assign)({}, c.ChainIdColorThemeParams)),
      "operator-name": a.ParamDefinition.Group((0, r.__assign)({}, s.OperatorNameColorThemeParams)),
      "element-symbol": a.ParamDefinition.Group({})
    }, { description: "Use chain-id coloring for carbon atoms." }),
    saturation: a.ParamDefinition.Numeric(0, { min: -6, max: 6, step: 0.1 }),
    lightness: a.ParamDefinition.Numeric(0.2, { min: -6, max: 6, step: 0.1 })
  };
  function m(h) {
    return e.MaterialElementSymbolColorThemeParams;
  }
  e.getMaterialElementSymbolColorThemeParams = m;
  function p(h, y) {
    var C = h[y];
    return C === void 0 ? f : C;
  }
  e.elementSymbolColor = p;
  function v(h, y) {
    var C = (0, o.getAdjustedColorMap)(e.MaterialElementSymbolColors, y.saturation, y.lightness);
    function S(_, A) {
      return p(C, _);
    }
    function b(_) {
      if (n.StructureElement.Location.is(_)) {
        if (n.Unit.isAtomic(_.unit)) {
          var A = _.unit.model.atomicHierarchy.atoms.type_symbol;
          return S(A.value(_.element));
        }
      } else if (n.Bond.isLocation(_) && n.Unit.isAtomic(_.aUnit)) {
        var A = _.aUnit.model.atomicHierarchy.atoms.type_symbol, M = A.value(_.aUnit.elements[_.aIndex]);
        return S(M);
      }
      return f;
    }
    var g = y.carbonColor.name === "operator-name" ? "groupInstance" : "group";
    return {
      factory: v,
      granularity: g,
      preferSmoothing: !0,
      color: b,
      props: y,
      description: d,
      legend: (0, i.TableLegend)(Object.keys(e.MaterialElementSymbolColors).map(function(_) {
        return [_, e.MaterialElementSymbolColors[_]];
      }))
    };
  }
  e.MaterialElementSymbolColorTheme = v, e.MaterialElementSymbolColorThemeProvider = {
    name: "material-element-symbol",
    label: "Material Element Symbol",
    category: "Atom Property",
    factory: v,
    getParams: m,
    defaultValues: a.ParamDefinition.getDefaultValues(e.MaterialElementSymbolColorThemeParams),
    isApplicable: function(h) {
      return !!h.structure;
    }
  };
})(Fb);
var b9;
function Np() {
  if (b9) return ff;
  b9 = 1, Object.defineProperty(ff, "__esModule", { value: !0 }), ff.ColorThemeProvider = ff.ColorTheme = void 0;
  var e = Tr(), r = Lz, t = py, n = We(), a = Pc(), i = L0, o = hq, c = gq, s = FE, u = yq, l = _q, f = bq, d = Sq, m = Cq, p = ZG(), v = Aq, h = xq, y = Bp, C = Tq, S = Pq, b = Mq, g = wq, _ = Dp, A = Eq, M = Dq, P = Iq, T = Ip, x = Bq, w = Nq, E = Vq, I = Rq, B = Oq, D = Fb, N;
  (function(V) {
    V.PaletteScale = (1 << 24) - 1, V.EmptyFactory = function() {
      return V.Empty;
    };
    var k = (0, e.Color)(13421772);
    V.Empty = {
      factory: V.EmptyFactory,
      granularity: "uniform",
      color: function() {
        return k;
      },
      props: {}
    };
    function G(R, F) {
      return R.contextHash === F.contextHash && R.factory === F.factory && (0, n.deepEqual)(R.props, F.props);
    }
    V.areEqual = G, V.EmptyProvider = {
      name: "",
      label: "",
      category: "",
      factory: V.EmptyFactory,
      getParams: function() {
        return {};
      },
      defaultValues: {},
      isApplicable: function() {
        return !0;
      }
    };
    function L() {
      return new a.ThemeRegistry(V.BuiltIn, V.EmptyProvider);
    }
    V.createRegistry = L, V.BuiltIn = {
      "atom-id": P.AtomIdColorThemeProvider,
      "carbohydrate-symbol": r.CarbohydrateSymbolColorThemeProvider,
      "chain-id": i.ChainIdColorThemeProvider,
      "element-index": o.ElementIndexColorThemeProvider,
      "element-symbol": c.ElementSymbolColorThemeProvider,
      "material-element-symbol": D.MaterialElementSymbolColorThemeProvider,
      "entity-id": T.EntityIdColorThemeProvider,
      "entity-source": y.EntitySourceColorThemeProvider,
      hydrophobicity: S.HydrophobicityColorThemeProvider,
      illustrative: C.IllustrativeColorThemeProvider,
      "model-index": b.ModelIndexColorThemeProvider,
      "molecule-type": s.MoleculeTypeColorThemeProvider,
      occupancy: g.OccupancyColorThemeProvider,
      "operator-hkl": A.OperatorHklColorThemeProvider,
      "operator-name": _.OperatorNameColorThemeProvider,
      "partial-charge": M.PartialChargeColorThemeProvider,
      "polymer-id": u.PolymerIdColorThemeProvider,
      "polymer-index": l.PolymerIndexColorThemeProvider,
      "residue-name": f.ResidueNameColorThemeProvider,
      "secondary-structure": d.SecondaryStructureColorThemeProvider,
      "sequence-id": m.SequenceIdColorThemeProvider,
      "shape-group": p.ShapeGroupColorThemeProvider,
      uncertainty: h.UncertaintyColorThemeProvider,
      "unit-index": v.UnitIndexColorThemeProvider,
      uniform: t.UniformColorThemeProvider,
      "volume-value": x.VolumeValueColorThemeProvider,
      "uni-fold": w.UniFoldProvider,
      cdr: E.CDRColorThemeProvider,
      "em-confidence": B.EMColorThemeProvider,
      "multi-theme": I.MultiThemeColorThemeProvider
    };
  })(N || (N = {})), ff.ColorTheme = N;
  function O(V) {
    return V;
  }
  return ff.ColorThemeProvider = O, ff;
}
var _n = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.getPartialMarkerAverage = e.getMarkerInfo = e.applyMarkerAction = e.applyMarkerActionAtPosition = e.setMarkerValue = e.MarkerActions = e.MarkerAction = void 0;
  var r = Qe(), t = pp, n = Ft, a;
  (function(l) {
    l[l.None = 0] = "None", l[l.Highlight = 1] = "Highlight", l[l.RemoveHighlight = 2] = "RemoveHighlight", l[l.Select = 4] = "Select", l[l.Deselect = 8] = "Deselect", l[l.Toggle = 16] = "Toggle", l[l.Clear = 32] = "Clear";
  })(a = e.MarkerAction || (e.MarkerAction = {})), function(l) {
    l.is = t.BitFlags.has, l.All = a.Highlight | a.RemoveHighlight | a.Select | a.Deselect | a.Toggle | a.Clear, l.Highlighting = a.Highlight | a.RemoveHighlight | a.Clear, l.Selecting = a.Select | a.Deselect | a.Toggle | a.Clear;
    function f(d, m) {
      return d === a.Highlight && m === a.RemoveHighlight || d === a.RemoveHighlight && m === a.Highlight || d === a.Select && m === a.Deselect || d === a.Deselect && m === a.Select || d === a.Toggle && m === a.Toggle;
    }
    l.isReverse = f;
  }(e.MarkerActions || (e.MarkerActions = {}));
  function i(l, f, d) {
    l.fill(f, 0, d);
  }
  e.setMarkerValue = i;
  function o(l, f, d) {
    switch (d) {
      case a.Highlight:
        l[f] |= 1;
        break;
      case a.RemoveHighlight:
        l[f] &= -2;
        break;
      case a.Select:
        l[f] |= 2;
        break;
      case a.Deselect:
        l[f] &= -3;
        break;
      case a.Toggle:
        l[f] ^= 2;
        break;
      case a.Clear:
        l[f] = 0;
        break;
    }
  }
  e.applyMarkerActionAtPosition = o;
  function c(l, f, d) {
    if (d === a.None)
      return !1;
    if (r.Interval.is(f)) {
      var m = r.Interval.start(f), p = r.Interval.end(f), v = m + 3 >> 2, h = v + (p - 4 * v >> 2);
      if (h <= v) {
        for (var y = m; y < p; ++y)
          o(l, y, d);
        return !0;
      }
      var C = new Uint32Array(l.buffer, 0, l.buffer.byteLength >> 2), S = m, b = Math.min(4 * v, p), g = Math.max(m, 4 * h), _ = p;
      switch (d) {
        case a.Highlight:
          for (var y = v; y < h; ++y)
            C[y] |= 16843009;
          break;
        case a.RemoveHighlight:
          for (var y = v; y < h; ++y)
            C[y] &= -16843010;
          break;
        case a.Select:
          for (var y = v; y < h; ++y)
            C[y] |= 33686018;
          break;
        case a.Deselect:
          for (var y = v; y < h; ++y)
            C[y] &= -33686019;
          break;
        case a.Toggle:
          for (var y = v; y < h; ++y)
            C[y] ^= 33686018;
          break;
        case a.Clear:
          for (var y = v; y < h; ++y)
            C[y] = 0;
          break;
        default:
          (0, n.assertUnreachable)(d);
      }
      for (var y = S; y < b; ++y)
        o(l, y, d);
      for (var y = g; y < _; ++y)
        o(l, y, d);
    } else
      switch (d) {
        case a.Highlight:
          for (var y = 0, A = f.length; y < A; ++y)
            l[f[y]] |= 1;
          break;
        case a.RemoveHighlight:
          for (var y = 0, A = f.length; y < A; ++y)
            l[f[y]] &= -2;
          break;
        case a.Select:
          for (var y = 0, A = f.length; y < A; ++y)
            l[f[y]] |= 2;
          break;
        case a.Deselect:
          for (var y = 0, A = f.length; y < A; ++y)
            l[f[y]] &= -3;
          break;
        case a.Toggle:
          for (var y = 0, A = f.length; y < A; ++y)
            l[f[y]] ^= 2;
          break;
        case a.Clear:
          for (var y = 0, A = f.length; y < A; ++y)
            l[f[y]] = 0;
          break;
        default:
          (0, n.assertUnreachable)(d);
      }
    return !0;
  }
  e.applyMarkerAction = c;
  function s(l, f) {
    var d = -1, m = -1;
    switch (l) {
      case a.Highlight:
        f === 0 || f === 1 ? (d = 1, m = 1) : f === 2 || f === 3 ? (d = 1, m = 3) : d = 1;
        break;
      case a.RemoveHighlight:
        f === 0 || f === 1 ? (d = 0, m = 0) : (f === 2 || f === 3) && (d = 1, m = 2);
        break;
      case a.Select:
        f === 1 || f === 3 ? (d = 1, m = 3) : f === 0 || f === 2 ? (d = 1, m = 2) : d = 1;
        break;
      case a.Deselect:
        f === 1 || f === 3 ? (d = 1, m = 1) : (f === 0 || f === 2) && (d = 0, m = 0);
        break;
      case a.Toggle:
        f === 1 ? (d = 1, m = 3) : f === 2 ? (d = 0, m = 0) : f === 3 ? (d = 1, m = 1) : f === 0 && (d = 1, m = 2);
        break;
      case a.Clear:
        d = 0, m = 0;
        break;
    }
    return { average: d, status: m };
  }
  e.getMarkerInfo = s;
  function u(l, f) {
    switch (l) {
      case a.Highlight:
        return 0.5;
      case a.RemoveHighlight:
        return f === 0 ? 0 : f === 2 || f === 3 ? 0.5 : -1;
      case a.Select:
        return 0.5;
      case a.Deselect:
        return f === 1 || f === 3 ? 0.5 : f === 0 ? 0 : -1;
      case a.Toggle:
        return f === -1 ? -1 : 0.5;
      case a.Clear:
        return f === -1 ? -1 : f === 0 ? 0 : 0.5;
      case a.None:
        return -1;
      default:
        (0, n.assertUnreachable)(l);
    }
  }
  e.getPartialMarkerAverage = u;
})(_n);
var _r = {};
Object.defineProperty(_r, "__esModule", { value: !0 });
_r.Loci = _r.DataLoci = _r.isDataLociEmpty = _r.areDataLociEqual = _r.isDataLoci = _r.isEmptyLoci = _r.EmptyLoci = _r.isEveryLoci = _r.EveryLoci = void 0;
var bt = Je(), Ds = TC(), Oo = ui(), $h = nr(), S9 = Re, cu = ia(), hde = Le, C9 = We(), gde = ys, A9 = cs, Ta = OE;
_r.EveryLoci = { kind: "every-loci" };
function nb(e) {
  return !!e && e.kind === "every-loci";
}
_r.isEveryLoci = nb;
_r.EmptyLoci = { kind: "empty-loci" };
function ab(e) {
  return !!e && e.kind === "empty-loci";
}
_r.isEmptyLoci = ab;
function ib(e) {
  return !!e && e.kind === "data-loci";
}
_r.isDataLoci = ib;
function Fq(e, r) {
  if (!(0, C9.shallowEqual)(e.data, r.data) || e.tag !== r.tag || e.elements.length !== r.elements.length)
    return !1;
  for (var t = 0, n = e.elements.length; t < n; ++t)
    if (!(0, C9.shallowEqual)(e.elements[t], r.elements[t]))
      return !1;
  return !0;
}
_r.areDataLociEqual = Fq;
function Lq(e) {
  return e.elements.length === 0;
}
_r.isDataLociEmpty = Lq;
function yde(e, r, t, n, a) {
  return { kind: "data-loci", tag: e, data: r, elements: t, getBoundingSphere: n, getLabel: a };
}
_r.DataLoci = yde;
var LM;
(function(e) {
  var r = new gde.BoundaryHelper("98");
  function t(v) {
    var h = v.loci.map(function(_) {
      return c(_);
    }).filter(function(_) {
      return !!_;
    });
    r.reset();
    for (var y = 0, C = h; y < C.length; y++) {
      var S = C[y];
      r.includePositionRadius(S.center, S.radius);
    }
    r.finishedIncludeStep();
    for (var b = 0, g = h; b < g.length; b++) {
      var S = g[b];
      r.radiusPositionRadius(S.center, S.radius);
    }
    return r.getSphere();
  }
  e.getBundleBoundingSphere = t;
  function n(v, h) {
    return nb(v) && nb(h) || ab(v) && ab(h) ? !0 : ib(v) && ib(h) ? Fq(v, h) : cu.Structure.isLoci(v) && cu.Structure.isLoci(h) ? cu.Structure.areLociEqual(v, h) : bt.StructureElement.Loci.is(v) && bt.StructureElement.Loci.is(h) ? bt.StructureElement.Loci.areEqual(v, h) : Ds.Bond.isLoci(v) && Ds.Bond.isLoci(h) ? Ds.Bond.areLociEqual(v, h) : Oo.Shape.isLoci(v) && Oo.Shape.isLoci(h) ? Oo.Shape.areLociEqual(v, h) : Oo.ShapeGroup.isLoci(v) && Oo.ShapeGroup.isLoci(h) ? Oo.ShapeGroup.areLociEqual(v, h) : Ta.Volume.isLoci(v) && Ta.Volume.isLoci(h) ? Ta.Volume.areLociEqual(v, h) : Ta.Volume.Isosurface.isLoci(v) && Ta.Volume.Isosurface.isLoci(h) ? Ta.Volume.Isosurface.areLociEqual(v, h) : Ta.Volume.Cell.isLoci(v) && Ta.Volume.Cell.isLoci(h) ? Ta.Volume.Cell.areLociEqual(v, h) : !1;
  }
  e.areEqual = n;
  function a(v) {
    return !!v && v.kind === "every-loci";
  }
  e.isEvery = a;
  function i(v) {
    return nb(v) ? !1 : ab(v) ? !0 : ib(v) ? Lq(v) : cu.Structure.isLoci(v) ? cu.Structure.isLociEmpty(v) : bt.StructureElement.Loci.is(v) ? bt.StructureElement.Loci.isEmpty(v) : Ds.Bond.isLoci(v) ? Ds.Bond.isLociEmpty(v) : Oo.Shape.isLoci(v) ? Oo.Shape.isLociEmpty(v) : Oo.ShapeGroup.isLoci(v) ? Oo.ShapeGroup.isLociEmpty(v) : Ta.Volume.isLoci(v) ? Ta.Volume.isLociEmpty(v) : Ta.Volume.Isosurface.isLoci(v) ? Ta.Volume.Isosurface.isLociEmpty(v) : Ta.Volume.Cell.isLoci(v) ? Ta.Volume.Cell.isLociEmpty(v) : !1;
  }
  e.isEmpty = i;
  function o(v, h) {
    return h instanceof cu.Structure && (bt.StructureElement.Loci.is(v) ? v = bt.StructureElement.Loci.remap(v, h) : cu.Structure.isLoci(v) ? v = cu.Structure.remapLoci(v, h) : Ds.Bond.isLoci(v) && (v = Ds.Bond.remapLoci(v, h))), v;
  }
  e.remap = o;
  function c(v, h) {
    var y;
    if (!(v.kind === "every-loci" || v.kind === "empty-loci")) {
      if (h || (h = (0, $h.Sphere3D)()), v.kind === "structure-loci")
        return $h.Sphere3D.copy(h, v.structure.boundary.sphere);
      if (v.kind === "element-loci")
        return $h.Sphere3D.copy(h, bt.StructureElement.Loci.getBoundary(v).sphere);
      if (v.kind === "bond-loci")
        return Ds.Bond.getBoundingSphere(v, h);
      if (v.kind === "shape-loci")
        return $h.Sphere3D.copy(h, v.shape.geometry.boundingSphere);
      if (v.kind === "group-loci")
        return Oo.ShapeGroup.getBoundingSphere(v, h);
      if (v.kind === "data-loci")
        return (y = v.getBoundingSphere) === null || y === void 0 ? void 0 : y.call(v, h);
      if (v.kind === "volume-loci")
        return Ta.Volume.getBoundingSphere(v.volume, h);
      if (v.kind === "isosurface-loci")
        return Ta.Volume.Isosurface.getBoundingSphere(v.volume, v.isoValue, h);
      if (v.kind === "cell-loci")
        return Ta.Volume.Cell.getBoundingSphere(v.volume, v.indices, h);
    }
  }
  e.getBoundingSphere = c;
  var s = $h.Sphere3D.zero();
  function u(v, h) {
    var y = c(v, s);
    return y ? S9.Vec3.copy(h || (0, S9.Vec3)(), y.center) : void 0;
  }
  e.getCenter = u;
  function l(v) {
    if (!(v.kind === "every-loci" || v.kind === "empty-loci")) {
      if (v.kind === "structure-loci")
        return bt.StructureElement.Loci.getPrincipalAxes(cu.Structure.toStructureElementLoci(v.structure));
      if (v.kind === "element-loci")
        return bt.StructureElement.Loci.getPrincipalAxes(v);
      if (v.kind === "bond-loci")
        return;
      if (v.kind === "shape-loci")
        return;
      if (v.kind === "group-loci")
        return;
      if (v.kind === "data-loci")
        return;
      if (v.kind === "volume-loci")
        return;
      if (v.kind === "isosurface-loci")
        return;
      if (v.kind === "cell-loci")
        return;
    }
  }
  e.getPrincipalAxes = l;
  var f = {
    element: function(v) {
      return v;
    },
    residue: function(v) {
      return bt.StructureElement.Loci.is(v) ? bt.StructureElement.Loci.extendToWholeResidues(v, !0) : v;
    },
    chain: function(v) {
      return bt.StructureElement.Loci.is(v) ? bt.StructureElement.Loci.extendToWholeChains(v) : v;
    },
    entity: function(v) {
      return bt.StructureElement.Loci.is(v) ? bt.StructureElement.Loci.extendToWholeEntities(v) : v;
    },
    model: function(v) {
      return bt.StructureElement.Loci.is(v) ? bt.StructureElement.Loci.extendToWholeModels(v) : v;
    },
    operator: function(v) {
      return bt.StructureElement.Loci.is(v) ? bt.StructureElement.Loci.extendToWholeOperators(v) : v;
    },
    structure: function(v) {
      return bt.StructureElement.Loci.is(v) ? cu.Structure.toStructureElementLoci(v.structure) : Oo.ShapeGroup.isLoci(v) ? Oo.Shape.Loci(v.shape) : v;
    },
    elementInstances: function(v) {
      return bt.StructureElement.Loci.is(v) ? bt.StructureElement.Loci.extendToAllInstances(v) : v;
    },
    residueInstances: function(v) {
      return bt.StructureElement.Loci.is(v) ? bt.StructureElement.Loci.extendToAllInstances(bt.StructureElement.Loci.extendToWholeResidues(v, !0)) : v;
    },
    chainInstances: function(v) {
      return bt.StructureElement.Loci.is(v) ? bt.StructureElement.Loci.extendToAllInstances(bt.StructureElement.Loci.extendToWholeChains(v)) : v;
    }
  };
  e.GranularityOptions = hde.ParamDefinition.objectToOptions(f, function(v) {
    switch (v) {
      case "element":
        return "Atom/Coarse Element";
      case "elementInstances":
        return ["Atom/Coarse Element Instances", "With Symmetry"];
      case "structure":
        return "Structure/Shape";
      default:
        return v.indexOf("Instances") ? [(0, A9.stringToWords)(v), "With Symmetry"] : (0, A9.stringToWords)(v);
    }
  });
  function d(v) {
    return v.replace("Instances", "");
  }
  e.simpleGranularity = d;
  function m(v, h) {
    return f[h](v);
  }
  e.applyGranularity = m;
  function p(v, h, y) {
    return y === void 0 && (y = !1), (h !== "element" || y) && Ds.Bond.isLoci(v) && (v = Ds.Bond.toStructureElementLoci(v)), cu.Structure.isLoci(v) && (v = cu.Structure.toStructureElementLoci(v.structure)), bt.StructureElement.Loci.is(v) && (v = bt.StructureElement.Loci.remap(v, v.structure.root)), h && (v = m(v, h)), v;
  }
  e.normalize = p;
})(LM || (LM = {}));
_r.Loci = LM;
var k0 = {}, wc = {}, kq = {}, Ws = {};
Object.defineProperty(Ws, "__esModule", { value: !0 });
Ws.aggregate = Ws.pickArgs = Ws.tryGetArg = Ws.getPositionalArgs = void 0;
var x9 = gs;
function _de(e) {
  return Object.keys(e).filter(function(r) {
    return !isNaN(r);
  }).map(function(r) {
    return +r;
  }).sort(function(r, t) {
    return r - t;
  }).map(function(r) {
    return e[r];
  });
}
Ws.getPositionalArgs = _de;
function bde(e, r, t) {
  return e && e[r] !== void 0 ? e[r] : t;
}
Ws.tryGetArg = bde;
function Sde(e) {
  for (var r = [], t = 1; t < arguments.length; t++)
    r[t - 1] = arguments[t];
  for (var n = /* @__PURE__ */ Object.create(null), a = 0, i = 0, o = Object.keys(e); i < o.length; i++) {
    var c = o[i];
    r.indexOf(c) >= 0 && (n[c] = e[c], a++);
  }
  return a ? n : void 0;
}
Ws.pickArgs = Sde;
function Cde(e, r, t) {
  return x9.MolScriptBuilder.struct.atomSet.reduce({
    initial: t !== void 0 ? t : e,
    value: r([x9.MolScriptBuilder.struct.slot.elementSetReduce(), e])
  });
}
Ws.aggregate = Cde;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.transpileMolScript = e.SymbolList = e.SymbolMap = e.NamedArgs = e.Constants = e.MolScriptSymbols = e.SymbolTable = e.isMolScriptSymbol = void 0;
  var r = Te, t = Po, n = I0, a = Cp, i = mC, o = D0, c = vC, s = gs, u = Ws;
  function l(C) {
    for (var S = [], b = 1; b < arguments.length; b++)
      S[b - 1] = arguments[b];
    return { kind: "alias", aliases: S, symbol: C };
  }
  function f(C, S) {
    for (var b = [], g = 2; g < arguments.length; g++)
      b[g - 2] = arguments[g];
    return C.info.namespace = "molscript-macro", C.id = "molscript-macro.".concat(C.info.name), { kind: "macro", symbol: C, translate: S, aliases: (0, r.__spreadArray)([C.info.name], b, !0) };
  }
  function d(C) {
    return C.kind === "alias" || C.kind === "macro";
  }
  e.isMolScriptSymbol = d, e.SymbolTable = [
    [
      "Core symbols",
      l(i.MolScriptSymbolTable.core.type.bool, "bool"),
      l(i.MolScriptSymbolTable.core.type.num, "num"),
      l(i.MolScriptSymbolTable.core.type.str, "str"),
      l(i.MolScriptSymbolTable.core.type.regex, "regex"),
      l(i.MolScriptSymbolTable.core.type.list, "list"),
      l(i.MolScriptSymbolTable.core.type.set, "set"),
      l(i.MolScriptSymbolTable.core.type.compositeKey, "composite-key"),
      l(i.MolScriptSymbolTable.core.logic.not, "not"),
      l(i.MolScriptSymbolTable.core.logic.and, "and"),
      l(i.MolScriptSymbolTable.core.logic.or, "or"),
      l(i.MolScriptSymbolTable.core.ctrl.if, "if"),
      l(i.MolScriptSymbolTable.core.ctrl.fn, "fn"),
      l(i.MolScriptSymbolTable.core.ctrl.eval, "eval"),
      l(i.MolScriptSymbolTable.core.math.add, "add", "+"),
      l(i.MolScriptSymbolTable.core.math.sub, "sub", "-"),
      l(i.MolScriptSymbolTable.core.math.mult, "mult", "*"),
      l(i.MolScriptSymbolTable.core.math.div, "div", "/"),
      l(i.MolScriptSymbolTable.core.math.pow, "pow", "**"),
      l(i.MolScriptSymbolTable.core.math.mod, "mod"),
      l(i.MolScriptSymbolTable.core.math.min, "min"),
      l(i.MolScriptSymbolTable.core.math.max, "max"),
      l(i.MolScriptSymbolTable.core.math.floor, "floor"),
      l(i.MolScriptSymbolTable.core.math.ceil, "ceil"),
      l(i.MolScriptSymbolTable.core.math.roundInt, "round"),
      l(i.MolScriptSymbolTable.core.math.abs, "abs"),
      l(i.MolScriptSymbolTable.core.math.sqrt, "sqrt"),
      l(i.MolScriptSymbolTable.core.math.cbrt, "cbrt"),
      l(i.MolScriptSymbolTable.core.math.sin, "sin"),
      l(i.MolScriptSymbolTable.core.math.cos, "cos"),
      l(i.MolScriptSymbolTable.core.math.tan, "tan"),
      l(i.MolScriptSymbolTable.core.math.asin, "asin"),
      l(i.MolScriptSymbolTable.core.math.acos, "acos"),
      l(i.MolScriptSymbolTable.core.math.atan, "atan"),
      l(i.MolScriptSymbolTable.core.math.sinh, "sinh"),
      l(i.MolScriptSymbolTable.core.math.cosh, "cosh"),
      l(i.MolScriptSymbolTable.core.math.tanh, "tanh"),
      l(i.MolScriptSymbolTable.core.math.exp, "exp"),
      l(i.MolScriptSymbolTable.core.math.log, "log"),
      l(i.MolScriptSymbolTable.core.math.log10, "log10"),
      l(i.MolScriptSymbolTable.core.math.atan2, "atan2"),
      l(i.MolScriptSymbolTable.core.rel.eq, "eq", "="),
      l(i.MolScriptSymbolTable.core.rel.neq, "neq", "!="),
      l(i.MolScriptSymbolTable.core.rel.lt, "lt", "<"),
      l(i.MolScriptSymbolTable.core.rel.lte, "lte", "<="),
      l(i.MolScriptSymbolTable.core.rel.gr, "gr", ">"),
      l(i.MolScriptSymbolTable.core.rel.gre, "gre", ">="),
      l(i.MolScriptSymbolTable.core.rel.inRange, "in-range"),
      l(i.MolScriptSymbolTable.core.str.concat, "concat"),
      l(i.MolScriptSymbolTable.core.str.match, "regex.match"),
      l(i.MolScriptSymbolTable.core.list.getAt, "list.get"),
      l(i.MolScriptSymbolTable.core.set.has, "set.has"),
      l(i.MolScriptSymbolTable.core.set.isSubset, "set.subset")
    ],
    [
      "Structure",
      [
        "Types",
        l(i.MolScriptSymbolTable.structureQuery.type.entityType, "ent-type"),
        l(i.MolScriptSymbolTable.structureQuery.type.authResidueId, "auth-resid"),
        l(i.MolScriptSymbolTable.structureQuery.type.labelResidueId, "label-resid"),
        l(i.MolScriptSymbolTable.structureQuery.type.ringFingerprint, "ringfp"),
        l(i.MolScriptSymbolTable.structureQuery.type.bondFlags, "bond-flags")
      ],
      [
        "Slots",
        l(i.MolScriptSymbolTable.structureQuery.slot.elementSetReduce, "atom.set.reduce.value")
      ],
      [
        "Generators",
        l(i.MolScriptSymbolTable.structureQuery.generator.atomGroups, "sel.atom.atom-groups"),
        l(i.MolScriptSymbolTable.structureQuery.generator.queryInSelection, "sel.atom.query-in-selection"),
        l(i.MolScriptSymbolTable.structureQuery.generator.rings, "sel.atom.rings"),
        l(i.MolScriptSymbolTable.structureQuery.generator.empty, "sel.atom.empty"),
        l(i.MolScriptSymbolTable.structureQuery.generator.all, "sel.atom.all"),
        l(i.MolScriptSymbolTable.structureQuery.generator.bondedAtomicPairs, "sel.atom.bonded-pairs"),
        f((0, a.MSymbol)("sel.atom.atoms", a.Arguments.Dictionary({
          0: (0, a.Argument)(o.Type.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to each atom." })
        }), c.Types.ElementSelection, "A selection of singleton atom sets."), function(C) {
          return s.MolScriptBuilder.struct.generator.atomGroups({ "atom-test": (0, u.tryGetArg)(C, 0, !0) });
        }),
        f((0, a.MSymbol)("sel.atom.res", a.Arguments.Dictionary({
          0: (0, a.Argument)(o.Type.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to the 1st atom of each residue." })
        }), c.Types.ElementSelection, "A selection of atom sets grouped by residue."), function(C) {
          return s.MolScriptBuilder.struct.generator.atomGroups({
            "residue-test": (0, u.tryGetArg)(C, 0, !0),
            "group-by": s.MolScriptBuilder.ammp("residueKey")
          });
        }),
        f((0, a.MSymbol)("sel.atom.chains", a.Arguments.Dictionary({
          0: (0, a.Argument)(o.Type.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to the 1st atom of each chain." })
        }), c.Types.ElementSelection, "A selection of atom sets grouped by chain."), function(C) {
          return s.MolScriptBuilder.struct.generator.atomGroups({
            "chain-test": (0, u.tryGetArg)(C, 0, !0),
            "group-by": s.MolScriptBuilder.ammp("chainKey")
          });
        })
      ],
      [
        "Modifiers",
        l(i.MolScriptSymbolTable.structureQuery.modifier.queryEach, "sel.atom.query-each"),
        l(i.MolScriptSymbolTable.structureQuery.modifier.intersectBy, "sel.atom.intersect-by"),
        l(i.MolScriptSymbolTable.structureQuery.modifier.exceptBy, "sel.atom.except-by"),
        l(i.MolScriptSymbolTable.structureQuery.modifier.unionBy, "sel.atom.union-by"),
        l(i.MolScriptSymbolTable.structureQuery.modifier.union, "sel.atom.union"),
        l(i.MolScriptSymbolTable.structureQuery.modifier.cluster, "sel.atom.cluster"),
        l(i.MolScriptSymbolTable.structureQuery.modifier.includeSurroundings, "sel.atom.include-surroundings"),
        l(i.MolScriptSymbolTable.structureQuery.modifier.surroundingLigands, "sel.atom.surrounding-ligands"),
        l(i.MolScriptSymbolTable.structureQuery.modifier.includeConnected, "sel.atom.include-connected"),
        l(i.MolScriptSymbolTable.structureQuery.modifier.expandProperty, "sel.atom.expand-property")
        // Macro(MSymbol('sel.atom.around', Arguments.Dictionary({
        //     0: Argument(Type.Bool, { isOptional: true, defaultValue: true, description: 'Test applied to the 1st atom of each chain.' })
        // }), Struct.Types.ElementSelection, 'A selection of singleton atom sets with centers within "radius" of the center of any atom in the given selection.'),
        // args => B.struct.modifier.exceptBy({
        //     '0': B.struct.filter.within({
        //         '0': B.struct.generator.atomGroups(), target: M.tryGetArg(args, 0), 'max-radius': M.tryGetArg(args, 'radius')
        //     }),
        //     by: M.tryGetArg(args, 0)
        // }))
      ],
      [
        "Filters",
        l(i.MolScriptSymbolTable.structureQuery.filter.pick, "sel.atom.pick"),
        l(i.MolScriptSymbolTable.structureQuery.filter.first, "sel.atom.first"),
        l(i.MolScriptSymbolTable.structureQuery.filter.withSameAtomProperties, "sel.atom.with-same-atom-properties"),
        l(i.MolScriptSymbolTable.structureQuery.filter.intersectedBy, "sel.atom.intersected-by"),
        l(i.MolScriptSymbolTable.structureQuery.filter.within, "sel.atom.within"),
        l(i.MolScriptSymbolTable.structureQuery.filter.isConnectedTo, "sel.atom.is-connected-to")
      ],
      [
        "Combinators",
        l(i.MolScriptSymbolTable.structureQuery.combinator.intersect, "sel.atom.intersect"),
        l(i.MolScriptSymbolTable.structureQuery.combinator.merge, "sel.atom.merge"),
        l(i.MolScriptSymbolTable.structureQuery.combinator.distanceCluster, "sel.atom.dist-cluster")
      ],
      [
        "Atom Set Properties",
        l(i.MolScriptSymbolTable.structureQuery.atomSet.atomCount, "atom.set.atom-count"),
        l(i.MolScriptSymbolTable.structureQuery.atomSet.countQuery, "atom.set.count-query"),
        l(i.MolScriptSymbolTable.structureQuery.atomSet.reduce, "atom.set.reduce"),
        l(i.MolScriptSymbolTable.structureQuery.atomSet.propertySet, "atom.set.property")
        // Macro(MSymbol('atom.set.max', Arguments.Dictionary({
        //     0: Argument(Type.Num, { description: 'Numeric atom property.'})
        // }), Type.Num, 'Maximum of the given property in the current atom set.'),
        // args => M.aggregate(M.tryGetArg(args, 0), B.core.math.max)),
        // Macro(MSymbol('atom.set.sum', Arguments.Dictionary({
        //     0: Argument(Type.Num, { description: 'Numeric atom property.'})
        // }), Type.Num, 'Sum of the given property in the current atom set.'),
        // args => M.aggregate(M.tryGetArg(args, 0), B.core.math.add, 0)),
        // Macro(MSymbol('atom.set.avg', Arguments.Dictionary({
        //     0: Argument(Type.Num, { description: 'Numeric atom property.'})
        // }), Type.Num, 'Average of the given property in the current atom set.'),
        // args => B.core.math.div([ M.aggregate(M.tryGetArg(args, 0), B.core.math.add, 0), B.struct.atomSet.atomCount() ])),
        // Macro(MSymbol('atom.set.min', Arguments.Dictionary({
        //     0: Argument(Type.Num, { description: 'Numeric atom property.'})
        // }), Type.Num, 'Minimum of the given property in the current atom set.'),
        // args => M.aggregate(M.tryGetArg(args, 0), B.core.math.min))
      ],
      [
        "Atom Properties",
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.core.elementSymbol, "atom.el"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.core.vdw, "atom.vdw"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.core.mass, "atom.mass"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.core.atomicNumber, "atom.atomic-number"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.core.x, "atom.x"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.core.y, "atom.y"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.core.z, "atom.z"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.core.sourceIndex, "atom.src-index"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.core.operatorName, "atom.op-name"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.core.modelIndex, "atom.model-index"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.core.modelLabel, "atom.model-label"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.core.atomKey, "atom.key"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.core.bondCount, "atom.bond-count"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.topology.connectedComponentKey, "atom.key.molecule"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.authResidueId, "atom.auth-resid"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.labelResidueId, "atom.label-resid"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.residueKey, "atom.key.res"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.chainKey, "atom.key.chain"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.entityKey, "atom.key.entity"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.isHet, "atom.is-het"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.id, "atom.id"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.label_atom_id, "atom.label_atom_id"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.label_alt_id, "atom.label_alt_id", "atom.altloc"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.label_comp_id, "atom.label_comp_id"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.label_asym_id, "atom.label_asym_id"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.label_entity_id, "atom.label_entity_id"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.label_seq_id, "atom.label_seq_id"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.auth_atom_id, "atom.auth_atom_id", "atom.name"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.auth_comp_id, "atom.auth_comp_id", "atom.resname"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.auth_asym_id, "atom.auth_asym_id", "atom.chain"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.auth_seq_id, "atom.auth_seq_id", "atom.resno"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.pdbx_PDB_ins_code, "atom.pdbx_PDB_ins_code", "atom.inscode"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.pdbx_formal_charge, "atom.pdbx_formal_charge"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.occupancy, "atom.occupancy"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.B_iso_or_equiv, "atom.B_iso_or_equiv", "atom.bfactor"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.entityType, "atom.entity-type"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.entitySubtype, "atom.entity-subtype"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.entityPrdId, "atom.entity-prd-id"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.entityDescription, "atom.entity-description"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.objectPrimitive, "atom.object-primitive"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.chemCompType, "atom.chem-comp-type"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.secondaryStructureKey, "atom.key.sec-struct"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.isModified, "atom.is-modified"),
        l(i.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.modifiedParentName, "atom.modified-parent")
        // Macro(MSymbol('atom.sec-struct.is', Arguments.List(Struct.Types.SecondaryStructureFlag), Type.Bool,
        //     `Test if the current atom is part of an secondary structure. Optionally specify allowed sec. struct. types: ${Type.oneOfValues(Struct.Types.SecondaryStructureFlag).join(', ')}`),
        // args => B.core.flags.hasAny([B.struct.atomProperty.macromolecular.secondaryStructureFlags(), B.struct.type.secondaryStructureFlags(args)])),
      ],
      [
        "Bond Properties",
        l(i.MolScriptSymbolTable.structureQuery.bondProperty.order, "bond.order"),
        l(i.MolScriptSymbolTable.structureQuery.bondProperty.length, "bond.length"),
        l(i.MolScriptSymbolTable.structureQuery.bondProperty.atomA, "bond.atom-a"),
        l(i.MolScriptSymbolTable.structureQuery.bondProperty.atomB, "bond.atom-b"),
        f((0, a.MSymbol)("bond.is", a.Arguments.List(c.Types.BondFlag), o.Type.Bool, "Test if the current bond has at least one (or all if partial = false) of the specified flags: ".concat(o.Type.oneOfValues(c.Types.BondFlag).join(", "))), function(C) {
          return s.MolScriptBuilder.core.flags.hasAny([s.MolScriptBuilder.struct.bondProperty.flags(), s.MolScriptBuilder.struct.type.bondFlags((0, u.getPositionalArgs)(C))]);
        })
      ]
    ]
  ];
  var m = [];
  function p(C) {
    for (var S = 0, b = C; S < b.length; S++) {
      var g = b[S];
      d(g) ? m.push(g) : g instanceof Array && p(g);
    }
  }
  p(e.SymbolTable);
  var v = function() {
    for (var C = [], S = /* @__PURE__ */ Object.create(null), b = t.UniqueArray.create(), g = t.UniqueArray.create(), _ = 0, A = m; _ < A.length; _++) {
      for (var M = A[_], P = 0, T = M.aliases; P < T.length; P++) {
        var x = T[P];
        if (C.push([x, M]), S[x])
          throw new Error("Alias '".concat(x, "' already in use."));
        S[x] = M;
      }
      var w = M.symbol.args;
      if (w.kind !== "dictionary") {
        w.type.kind === "oneof" && o.Type.oneOfValues(w.type).forEach(function(D) {
          return t.UniqueArray.add(g, D, D);
        });
        continue;
      }
      for (var E = 0, I = Object.keys(w.map); E < I.length; E++) {
        var x = I[E];
        isNaN(x) && t.UniqueArray.add(b, x, x);
        var B = w.map[x];
        B.type.kind === "oneof" && o.Type.oneOfValues(B.type).forEach(function(N) {
          return t.UniqueArray.add(g, N, N);
        });
      }
    }
    return { symbolList: C, symbolMap: S, namedArgs: b.array, constants: g.array };
  }();
  e.MolScriptSymbols = m, e.Constants = v.constants, e.NamedArgs = v.namedArgs, e.SymbolMap = v.symbolMap, e.SymbolList = v.symbolList;
  function h(C) {
    if (n.Expression.isLiteral(C))
      return C;
    if (n.Expression.isSymbol(C)) {
      if (!e.SymbolMap[C.name])
        return C;
      var S = e.SymbolMap[C.name];
      if (S.kind === "alias")
        return n.Expression.Symbol(e.SymbolMap[C.name].symbol.id);
      throw S.translate([]);
    }
    var b = n.Expression.isSymbol(C.head) && !!e.SymbolMap[C.head.name] && e.SymbolMap[C.head.name].kind === "macro", g = b ? C.head : h(C.head), _ = g !== C.head;
    if (!C.args)
      return b ? h(C.head) : _ ? n.Expression.Apply(g) : C;
    var A = !1, M;
    if (n.Expression.isArgumentsArray(C.args)) {
      M = [];
      for (var P = 0, T = C.args.length; P < T; P++) {
        var x = C.args[P], w = h(x);
        x !== w && (A = !0), M[M.length] = w;
      }
      if (A || (M = C.args), !b && !_ && !A)
        return C;
    } else {
      M = {};
      for (var E = 0, I = Object.keys(C.args); E < I.length; E++) {
        var B = I[E], x = C.args[B], w = h(x);
        x !== w && (A = !0), M[B] = w;
      }
      if (!b && !_ && !A)
        return C;
      A || (M = C.args);
    }
    if (b) {
      var D = e.SymbolMap[C.head.name];
      if (D.kind !== "macro")
        return n.Expression.Apply(g, M);
      var N = D.translate(M);
      return N;
    }
    return n.Expression.Apply(g, M);
  }
  function y(C) {
    return h(C);
  }
  e.transpileMolScript = y;
})(kq);
var f4 = {}, Uq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.MonadicParser = void 0;
  var r = Te, t = (
    /** @class */
    function() {
      function m(p) {
        this._ = p;
      }
      return m.prototype.parse = function(p) {
        var v = this.skip(m.eof)._(p, 0);
        return v.status ? { success: !0, value: v.value } : { success: !1, index: c(p, v.furthest), expected: v.expected };
      }, m.prototype.tryParse = function(p) {
        var v = this.parse(p);
        if (v.success)
          return v.value;
        var h = l(p, v), y = new Error(h);
        throw y;
      }, m.prototype.or = function(p) {
        return m.alt(this, p);
      }, m.prototype.trim = function(p) {
        return this.wrap(p, p);
      }, m.prototype.wrap = function(p, v) {
        return n(1, typeof p == "string" ? m.string(p) : p, this, typeof v == "string" ? m.string(v) : v);
      }, m.prototype.thru = function(p) {
        return p(this);
      }, m.prototype.then = function(p) {
        return n(1, this, p);
      }, m.prototype.many = function() {
        var p = this;
        return new m(function(v, h) {
          for (var y = [], C = void 0; ; )
            if (C = o(p._(v, h), C), C.status) {
              if (h === C.index)
                throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");
              h = C.index, y.push(C.value);
            } else
              return o(a(h, y), C);
        });
      }, m.prototype.times = function(p, v) {
        var h = this, y = typeof v > "u" ? p : v;
        return new m(function(C, S) {
          var b = [], g = void 0, _ = void 0, A;
          for (A = 0; A < p; A++)
            if (g = h._(C, S), _ = o(g, _), g.status)
              S = g.index, b.push(g.value);
            else
              return _;
          for (; A < y && (g = h._(C, S), _ = o(g, _), g.status); A += 1)
            S = g.index, b.push(g.value);
          return o(a(S, b), _);
        });
      }, m.prototype.result = function(p) {
        return this.map(function() {
          return p;
        });
      }, m.prototype.atMost = function(p) {
        return this.times(0, p);
      }, m.prototype.atLeast = function(p) {
        return m.seq(this.times(p), this.many()).map(function(v) {
          return (0, r.__spreadArray)((0, r.__spreadArray)([], v[0], !0), v[1], !0);
        });
      }, m.prototype.map = function(p) {
        var v = this;
        return new m(function(h, y) {
          var C = v._(h, y);
          return C.status ? o(a(C.index, p(C.value)), C) : C;
        });
      }, m.prototype.skip = function(p) {
        return n(0, this, p);
      }, m.prototype.mark = function() {
        return m.seq(m.index, this, m.index).map(function(p) {
          return { start: p[0], value: p[1], end: p[2] };
        });
      }, m.prototype.node = function(p) {
        return m.seq(m.index, this, m.index).map(function(v) {
          return { name: p, start: v[0], value: v[1], end: v[2] };
        });
      }, m.prototype.sepBy = function(p) {
        return m.sepBy(this, p);
      }, m.prototype.sepBy1 = function(p) {
        return m.sepBy1(this, p);
      }, m.prototype.lookahead = function(p) {
        return this.skip(m.lookahead(p));
      }, m.prototype.notFollowedBy = function(p) {
        return this.skip(m.notFollowedBy(p));
      }, m.prototype.desc = function(p) {
        var v = this;
        return new m(function(h, y) {
          var C = v._(h, y);
          return C.status || (C.expected = [p]), C;
        });
      }, m.prototype.fallback = function(p) {
        return this.or(m.succeed(p));
      }, m.prototype.ap = function(p) {
        return m.seq(p, this).map(function(v) {
          var h = v[0], y = v[1];
          return h(y);
        });
      }, m.prototype.chain = function(p) {
        var v = this;
        return new m(function(h, y) {
          var C = v._(h, y);
          if (!C.status)
            return C;
          var S = p(C.value);
          return o(S._(h, C.index), C);
        });
      }, m;
    }()
  );
  e.MonadicParser = t, function(m) {
    function p() {
      for (var N = [], O = 0; O < arguments.length; O++)
        N[O] = arguments[O];
      var V = N.length;
      return new m(function(k, G) {
        for (var L, R = new Array(V), F = G, U = 0; U < V; U++) {
          if (L = o(N[U]._(k, F), L), !L.status)
            return L;
          R[U] = L.value, F = L.index;
        }
        return o(a(F, R), L);
      });
    }
    m.seq = p;
    function v() {
      for (var N = [], O = 0; O < arguments.length; O++)
        N[O] = arguments[O];
      var V = N.length;
      return V === 0 ? A("zero alternates") : new m(function(k, G) {
        for (var L, R = 0; R < N.length; R++)
          if (L = o(N[R]._(k, G), L), L.status)
            return L;
        return L;
      });
    }
    m.alt = v;
    function h(N, O) {
      return y(N, O).or(_([]));
    }
    m.sepBy = h;
    function y(N, O) {
      var V = O.then(N).many();
      return p(N, V).map(function(k) {
        return (0, r.__spreadArray)([k[0]], k[1], !0);
      });
    }
    m.sepBy1 = y;
    function C(N) {
      var O = "'".concat(N, "'");
      if (N.length === 1) {
        var V = N.charCodeAt(0);
        return new m(function(k, G) {
          return k.charCodeAt(G) === V ? a(G + 1, N) : i(G, O);
        });
      }
      return new m(function(k, G) {
        var L = G + N.length;
        return k.slice(G, L) === N ? a(L, N) : i(G, O);
      });
    }
    m.string = C;
    function S(N) {
      var O = "" + N;
      return O.slice(O.lastIndexOf("/") + 1);
    }
    function b(N) {
      return RegExp("^(?:" + N.source + ")", S(N));
    }
    function g(N, O) {
      O === void 0 && (O = 0);
      var V = b(N), k = "" + N;
      return new m(function(G, L) {
        var R = V.exec(G.slice(L));
        if (R) {
          if (0 <= O && O <= R.length) {
            var F = R[0], U = R[O];
            return a(L + F.length, U);
          }
          var H = "invalid match group (0 to ".concat(R.length, ") in ").concat(k);
          return i(L, H);
        }
        return i(L, k);
      });
    }
    m.regexp = g;
    function _(N) {
      return new m(function(O, V) {
        return a(V, N);
      });
    }
    m.succeed = _;
    function A(N) {
      return new m(function(O, V) {
        return i(V, N);
      });
    }
    m.fail = A;
    function M(N) {
      if (d(N))
        return new m(function(O, V) {
          var k = N._(O, V);
          return k.status && (k.index = V, k.value = null), k;
        });
      if (typeof N == "string")
        return M(C(N));
      if (N instanceof RegExp)
        return M(g(N));
      throw new Error("not a string, regexp, or parser: " + N);
    }
    m.lookahead = M;
    function P(N) {
      return new m(function(O, V) {
        var k = N._(O, V);
        return k.status ? i(V, 'not "' + O.slice(V, k.index) + '"') : a(V, null);
      });
    }
    m.notFollowedBy = P;
    function T(N) {
      return new m(function(O, V) {
        var k = O.charAt(V);
        return V < O.length && N(k) ? a(V + 1, k) : i(V, "a character " + N);
      });
    }
    m.test = T;
    function x(N) {
      return T(function(O) {
        return N.indexOf(O) >= 0;
      });
    }
    m.oneOf = x;
    function w(N) {
      return T(function(O) {
        return N.indexOf(O) < 0;
      });
    }
    m.noneOf = w;
    function E(N, O) {
      return T(function(V) {
        return N <= V && V <= O;
      }).desc(N + "-" + O);
    }
    m.range = E;
    function I(N) {
      return new m(function(O, V) {
        for (var k = V; k < O.length && N(O.charAt(k)); )
          k++;
        return a(k, O.slice(V, k));
      });
    }
    m.takeWhile = I;
    function B(N) {
      var O = new m(function(V, k) {
        var G = N()._;
        return O._ = G, G(V, k);
      });
      return O;
    }
    m.lazy = B;
    function D() {
      return A("empty");
    }
    m.empty = D, m.index = new m(function(N, O) {
      return a(O, c(N, O));
    }), m.anyChar = new m(function(N, O) {
      return O >= N.length ? i(O, "any character") : a(O + 1, N.charAt(O));
    }), m.all = new m(function(N, O) {
      return a(N.length, N.slice(O));
    }), m.eof = new m(function(N, O) {
      return O < N.length ? i(O, "EOF") : a(O, null);
    }), m.digit = g(/[0-9]/).desc("a digit"), m.digits = g(/[0-9]*/).desc("optional digits"), m.letter = g(/[a-z]/i).desc("a letter"), m.letters = g(/[a-z]*/i).desc("optional letters"), m.optWhitespace = g(/\s*/).desc("optional whitespace"), m.whitespace = g(/\s+/).desc("whitespace"), m.cr = C("\r"), m.lf = C(`
`), m.crlf = C(`\r
`), m.newline = v(m.crlf, m.lf, m.cr).desc("newline"), m.end = v(m.newline, m.eof);
  }(t = e.MonadicParser || (e.MonadicParser = {})), e.MonadicParser = t;
  function n(m) {
    for (var p = [], v = 1; v < arguments.length; v++)
      p[v - 1] = arguments[v];
    var h = p.length;
    return new t(function(y, C) {
      for (var S, b, g = C, _ = 0; _ < h; _++) {
        if (S = o(p[_]._(y, g), S), !S.status)
          return S;
        m === _ && (b = S.value), g = S.index;
      }
      return o(a(g, b), S);
    });
  }
  function a(m, p) {
    return { status: !0, index: m, value: p };
  }
  function i(m, p) {
    return { status: !1, furthest: m, expected: [p] };
  }
  function o(m, p) {
    if (!p || m.status || p.status || m.furthest > p.furthest)
      return m;
    var v = m.furthest === p.furthest ? f(m.expected, p.expected) : p.expected;
    return { status: m.status, furthest: p.furthest, expected: v };
  }
  function c(m, p) {
    var v = m.slice(0, p).split(`
`), h = v.length, y = v[v.length - 1].length + 1;
    return { offset: p, line: h, column: y };
  }
  function s(m) {
    return m.length === 1 ? m[0] : "one of " + m.join(", ");
  }
  function u(m, p) {
    var v = p.index, h = v.offset;
    if (h === m.length)
      return ", got the end of the input";
    var y = h > 0 ? "'..." : "'", C = m.length - h > 12 ? "...'" : "'";
    return " at line ".concat(v.line, " column ").concat(v.column, ", got ").concat(y).concat(m.slice(h, h + 12)).concat(C);
  }
  function l(m, p) {
    return "expected ".concat(s(p.expected)).concat(u(m, p));
  }
  function f(m, p) {
    var v = m.length, h = p.length;
    if (v === 0)
      return p;
    if (h === 0)
      return m;
    for (var y = /* @__PURE__ */ new Set(), C = [], S = 0; S < v; S++)
      y.has(m[S]) || (C[C.length] = m[S], y.add(m[S]));
    for (var S = 0; S < h; S++)
      y.has(p[S]) || (C[C.length] = p[S], y.add(p[S]));
    return C.sort(), C;
  }
  function d(m) {
    return m instanceof t;
  }
})(Uq);
Object.defineProperty(f4, "__esModule", { value: !0 });
f4.parseMolScript = void 0;
var Mf = Uq, T9 = I0, A2 = gs, P9 = Ft;
function Ade(e) {
  return kM.parse(e);
}
f4.parseMolScript = Ade;
var kM;
(function(e) {
  var r;
  (function(b) {
    function g(P) {
      return { kind: "string", value: P };
    }
    b.str = g;
    function _(P) {
      return { kind: "symbol", value: P };
    }
    b.symb = _;
    function A(P, T) {
      return { kind: "list", bracket: P, nodes: T };
    }
    b.list = A;
    function M(P) {
      return { kind: "comment", value: P };
    }
    b.comment = M;
  })(r || (r = {}));
  var t = Mf.MonadicParser.regexp(/[\n\r\s]*/), n = Mf.MonadicParser.lazy(function() {
    return Mf.MonadicParser.alt(a, f, i, o).trim(t);
  }), a = Mf.MonadicParser.takeWhile(function(b) {
    return b !== "`";
  }).trim("`").map(r.str), i = Mf.MonadicParser.regexp(/[^()\[\]{};`,\n\r\s]+/).map(r.symb), o = Mf.MonadicParser.regexp(/\s*;+([^\n\r]*)\n/, 1).map(r.comment), c = n.many(), s = c.wrap("(", ")").map(function(b) {
    return r.list("(", b);
  }), u = c.wrap("[", "]").map(function(b) {
    return r.list("[", b);
  }), l = c.wrap("{", "}").map(function(b) {
    return r.list("{", b);
  }), f = Mf.MonadicParser.alt(s, u, l), d = n.many();
  function m(b) {
    return d.tryParse(b);
  }
  function p(b) {
    switch (b.kind) {
      case "string":
        return b.value;
      case "symbol": {
        var g = b.value;
        if (g.length > 1) {
          var _ = g.charAt(0);
          switch (_) {
            case ".":
              return A2.MolScriptBuilder.atomName(g.substr(1));
            case "_":
              return A2.MolScriptBuilder.struct.type.elementSymbol([g.substr(1)]);
          }
        }
        return g === "true" ? !0 : g === "false" ? !1 : C(g) ? +g : T9.Expression.Symbol(g);
      }
      case "list":
        switch (b.bracket) {
          case "[":
            return A2.MolScriptBuilder.core.type.list(y(b.nodes).map(p));
          case "{":
            return A2.MolScriptBuilder.core.type.set(y(b.nodes).map(p));
          case "(": {
            if (b.nodes[0].kind === "comment")
              throw new Error("Invalid expression");
            var A = p(b.nodes[0]);
            return T9.Expression.Apply(A, v(b.nodes));
          }
          default:
            (0, P9.assertUnreachable)(b.bracket);
        }
      default:
        (0, P9.assertUnreachable)(b);
    }
  }
  function v(b) {
    if (!(b.length <= 1)) {
      if (!h(b)) {
        for (var g = [], _ = 1, A = b.length; _ < A; _++) {
          var M = b[_];
          M.kind !== "comment" && (g[g.length] = p(M));
        }
        return g;
      }
      for (var P = {}, T = !0, x = 0, _ = 1, A = b.length; _ < A; _++) {
        var M = b[_];
        if (M.kind !== "comment")
          if (M.kind === "symbol" && M.value.length > 1 && M.value.charAt(0) === ":") {
            var w = M.value.substr(1);
            for (++_; _ < A && b[_].kind === "comment"; )
              _++;
            if (_ >= A)
              throw new Error("There must be a value foolowed a named arg ':".concat(w, "'."));
            if (b[_].kind === "comment")
              throw new Error("Invalid expression");
            P[w] = p(b[_]), isNaN(+w) && (T = !1);
          } else
            P[x++] = p(M);
      }
      if (T) {
        for (var E = Object.keys(P).map(function(D) {
          return +D;
        }).sort(function(D, N) {
          return D - N;
        }), I = !0, _ = 0, A = E.length; _ < A; _++)
          if (E[_] !== _) {
            I = !1;
            break;
          }
        if (I) {
          for (var B = [], _ = 0, A = E.length; _ < A; _++)
            B[_] = P[_];
          return B;
        }
      }
      return P;
    }
  }
  function h(b) {
    for (var g = 1, _ = b.length; g < _; g++) {
      var A = b[g];
      if (A.kind === "symbol" && A.value.length > 1 && A.value.charAt(0) === ":")
        return !0;
    }
    return !1;
  }
  function y(b) {
    for (var g = !1, _ = 0, A = b.length; _ < A; _++)
      if (b[_].kind === "comment") {
        g = !0;
        break;
      }
    return g ? b.filter(function(M) {
      return M.kind !== "comment";
    }) : b;
  }
  function C(b) {
    return /-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/.test(b) && !isNaN(+b);
  }
  function S(b) {
    for (var g = m(b), _ = [], A = 0, M = g; A < M.length; A++) {
      var P = M[A];
      P.kind !== "comment" && (_[_.length] = p(P));
    }
    return _;
  }
  e.parse = S;
})(kM || (kM = {}));
var by = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.compile = e.QuerySymbolRuntime = e.QueryRuntimeArguments = e.CompiledQueryFn = e.QueryCompiledSymbol = e.QueryCompilerCtx = e.DefaultQueryRuntimeTable = e.QueryRuntimeTable = void 0;
  var r = I0, t = Je(), n = (
    /** @class */
    function() {
      function l() {
        this.map = /* @__PURE__ */ new Map();
      }
      return l.prototype.removeSymbol = function(f) {
        this.map.delete(f.symbol.id);
      }, l.prototype.addSymbol = function(f) {
        this.map.has(f.symbol.id) && console.warn("Symbol '".concat(f.symbol.id, "' already added. Call removeSymbol/removeCustomProps re-adding the symbol.")), this.map.set(f.symbol.id, f);
      }, l.prototype.addCustomProp = function(f) {
        if (f.symbols)
          for (var d = 0, m = Object.keys(f.symbols); d < m.length; d++) {
            var p = m[d];
            this.addSymbol(f.symbols[p]);
          }
      }, l.prototype.removeCustomProp = function(f) {
        if (f.symbols)
          for (var d = 0, m = Object.keys(f.symbols); d < m.length; d++) {
            var p = m[d];
            this.removeSymbol(f.symbols[p]);
          }
      }, l.prototype.getRuntime = function(f) {
        return this.map.get(f);
      }, l;
    }()
  );
  e.QueryRuntimeTable = n, e.DefaultQueryRuntimeTable = new n();
  var a = (
    /** @class */
    /* @__PURE__ */ function() {
      function l(f) {
        this.table = f, this.constQueryContext = new t.QueryContext(t.Structure.Empty);
      }
      return l;
    }()
  );
  e.QueryCompilerCtx = a, function(l) {
    function f(m) {
      return { kind: "const", value: m };
    }
    l.Const = f;
    function d(m) {
      return { kind: "dynamic", runtime: m };
    }
    l.Dynamic = d;
  }(e.QueryCompiledSymbol || (e.QueryCompiledSymbol = {}));
  var i;
  (function(l) {
    function f(m) {
      return { isConst: !0, fn: function(v) {
        return m;
      } };
    }
    l.Const = f;
    function d(m) {
      return { isConst: !1, fn: m };
    }
    l.Dynamic = d;
  })(i = e.CompiledQueryFn || (e.CompiledQueryFn = {})), function(l) {
    function f(d, m, p, v) {
      if (typeof d.length == "number")
        for (var h = 0, y = d.length; h < y; h++)
          p(d[h](m), h, v);
      else
        for (var h = 0, C = 0, S = Object.keys(d); C < S.length; C++) {
          var b = S[C];
          p(d[b](m), h++, v);
        }
      return v;
    }
    l.forEachEval = f;
  }(e.QueryRuntimeArguments || (e.QueryRuntimeArguments = {})), function(l) {
    function f(m, p) {
      return new o(m, p, !0);
    }
    l.Const = f;
    function d(m, p) {
      return new o(m, p, !1);
    }
    l.Dynamic = d;
  }(e.QuerySymbolRuntime || (e.QuerySymbolRuntime = {}));
  var o = (
    /** @class */
    function() {
      function l(f, d, m) {
        this.symbol = f, this.fn = d, this.isConst = m;
      }
      return l.prototype.compile = function(f, d) {
        var m, p = !1;
        if (!d)
          m = void 0, p = !0;
        else if (r.Expression.isArgumentsArray(d)) {
          m = [], p = !0;
          for (var v = 0, h = d; v < h.length; v++) {
            var y = h[v], C = s(f, y);
            p = p && C.isConst, m.push(C.fn);
          }
        } else {
          m = /* @__PURE__ */ Object.create(null), p = !0;
          for (var S = 0, b = Object.keys(d); S < b.length; S++) {
            var g = b[S], C = s(f, d[g]);
            p = p && C.isConst, m[g] = C.fn;
          }
        }
        return this.isConst ? this.isConst && p ? i.Const(this.fn(f.constQueryContext, m)) : i.Dynamic(c(this.fn, m)) : i.Dynamic(c(this.fn, m));
      }, l;
    }()
  );
  function c(l, f) {
    return function(m) {
      return l(m, f);
    };
  }
  function s(l, f) {
    if (r.Expression.isLiteral(f))
      return i.Const(f);
    if (r.Expression.isSymbol(f)) {
      var d = l.table.getRuntime(f.name);
      return d ? d.compile(l) : i.Const(f.name);
    }
    if (!r.Expression.isSymbol(f.head))
      throw new Error("Can only apply symbols.");
    var m = l.table.getRuntime(f.head.name);
    if (!m)
      throw new Error("Symbol '".concat(f.head.name, "' is not implemented."));
    return m.compile(l, f.args);
  }
  function u(l) {
    var f = new a(e.DefaultQueryRuntimeTable);
    return s(f, l).fn;
  }
  e.compile = u;
})(by);
Object.defineProperty(wc, "__esModule", { value: !0 });
wc.Script = void 0;
var xde = kq, Tde = f4, K5 = Je(), M9 = by, Pde = gs;
function Lb(e, r) {
  return { expression: e, language: r };
}
wc.Script = Lb;
(function(e) {
  function r(c) {
    return !!c && typeof c.expression == "string" && !!c.language;
  }
  e.is = r;
  function t(c, s) {
    return c.language === s.language && c.expression === s.expression;
  }
  e.areEqual = t;
  function n(c) {
    switch (c.language) {
      case "mol-script":
        var s = (0, Tde.parseMolScript)(c.expression);
        if (s.length === 0)
          throw new Error("No query");
        return (0, xde.transpileMolScript)(s[0]);
    }
    throw new Error("unsupported script language");
  }
  e.toExpression = n;
  function a(c) {
    var s = n(c);
    return (0, M9.compile)(s);
  }
  e.toQuery = a;
  function i(c, s) {
    var u = a(c), l = u(new K5.QueryContext(s));
    return K5.StructureSelection.toLociWithSourceUnits(l);
  }
  e.toLoci = i;
  function o(c, s, u) {
    var l = typeof c == "function" ? c(Pde.MolScriptBuilder) : c, f = (0, M9.compile)(l);
    return f(new K5.QueryContext(s, u));
  }
  e.getStructureSelection = o;
})(Lb || (Lb = {}));
wc.Script = Lb;
Object.defineProperty(k0, "__esModule", { value: !0 });
k0.Overpaint = void 0;
var Mde = _r, wde = Tr(), Fo = Je(), Ede = wc;
function kb(e) {
  return { layers: e };
}
k0.Overpaint = kb;
(function(e) {
  e.Empty = { layers: [] };
  function r(u, l) {
    if (u.layers.length === 0 && l.layers.length === 0)
      return !0;
    if (u.layers.length !== l.layers.length)
      return !1;
    for (var f = 0, d = u.layers.length; f < d; ++f)
      if (u.layers[f].clear !== l.layers[f].clear || u.layers[f].color !== l.layers[f].color || !Mde.Loci.areEqual(u.layers[f].loci, l.layers[f].loci))
        return !1;
    return !0;
  }
  e.areEqual = r;
  function t(u) {
    return u.layers.length === 0;
  }
  e.isEmpty = t;
  function n(u, l) {
    for (var f = [], d = 0, m = u.layers; d < m.length; d++) {
      var p = m[d], v = p.loci, h = p.color, y = p.clear;
      v = Fo.StructureElement.Loci.remap(v, l), Fo.StructureElement.Loci.isEmpty(v) || f.push({ loci: v, color: h, clear: y });
    }
    return { layers: f };
  }
  e.remap = n;
  function a(u) {
    if (t(u))
      return u;
    for (var l = u.layers[0].loci.structure, f = /* @__PURE__ */ new Map(), d = Fo.StructureElement.Loci.none(l), m = 0, p = u.layers.length; m < p; ++m) {
      var v = u.layers[p - m - 1], h = v.loci, y = v.color, C = v.clear;
      if (h = Fo.StructureElement.Loci.subtract(h, d), d = Fo.StructureElement.Loci.union(h, d), !Fo.StructureElement.Loci.isEmpty(h)) {
        var S = C ? -1 : y;
        f.has(S) && (h = Fo.StructureElement.Loci.union(h, f.get(S))), f.set(S, h);
      }
    }
    var b = [];
    return f.forEach(function(g, _) {
      var A = _ === -1, M = A ? (0, wde.Color)(0) : _;
      b.push({ loci: g, color: M, clear: A });
    }), { layers: b };
  }
  e.merge = a;
  function i(u, l) {
    if (t(u))
      return u;
    for (var f = u.layers[0].loci.structure, d = [], m = 0, p = u.layers; m < p.length; m++) {
      var v = p[m], h = v.loci, y = v.color, C = v.clear, S = Fo.StructureElement.Loci.remap(h, l);
      h = Fo.StructureElement.Loci.remap(S, f), Fo.StructureElement.Loci.isEmpty(h) || d.push({ loci: h, color: y, clear: C });
    }
    return { layers: d };
  }
  e.filter = i;
  function o(u, l) {
    for (var f = [], d = 0, m = u.length; d < m; ++d) {
      var p = u[d], v = p.script, h = p.color, y = p.clear, C = Ede.Script.toLoci(v, l);
      Fo.StructureElement.Loci.isEmpty(C) || f.push({ loci: C, color: h, clear: y });
    }
    return { layers: f };
  }
  e.ofScript = o;
  function c(u, l) {
    for (var f = [], d = 0, m = u.length; d < m; ++d) {
      var p = u[d], v = p.bundle, h = p.color, y = p.clear, C = Fo.StructureElement.Bundle.toLoci(v, l.root);
      f.push({ loci: C, color: h, clear: y });
    }
    return { layers: f };
  }
  e.ofBundle = c;
  function s(u) {
    for (var l = [], f = 0, d = u.layers.length; f < d; ++f) {
      var m = u.layers[f], p = m.loci, v = m.color, h = m.clear, y = Fo.StructureElement.Bundle.fromLoci(p);
      l.push({ bundle: y, color: v, clear: h });
    }
    return { layers: l };
  }
  e.toBundle = s;
})(kb || (kb = {}));
k0.Overpaint = kb;
var U0 = {};
Object.defineProperty(U0, "__esModule", { value: !0 });
U0.Transparency = void 0;
var Dde = _r, Lo = Je(), Ide = wc;
function Ub(e, r) {
  return { kind: e, layers: r };
}
U0.Transparency = Ub;
(function(e) {
  e.Empty = { kind: "empty-loci", layers: [] };
  function r(u, l) {
    if (u.layers.length === 0 && l.layers.length === 0)
      return !0;
    if (u.layers.length !== l.layers.length)
      return !1;
    for (var f = 0, d = u.layers.length; f < d; ++f)
      if (u.layers[f].value !== l.layers[f].value || !Dde.Loci.areEqual(u.layers[f].loci, l.layers[f].loci))
        return !1;
    return !0;
  }
  e.areEqual = r;
  function t(u) {
    return u.layers.length === 0;
  }
  e.isEmpty = t;
  function n(u, l) {
    if (u.kind === "element-loci") {
      for (var f = [], d = 0, m = u.layers; d < m.length; d++) {
        var p = m[d], v = Lo.StructureElement.Loci.remap(p.loci, l);
        Lo.StructureElement.Loci.isEmpty(v) || f.push({ loci: v, value: p.value });
      }
      return { kind: "element-loci", layers: f };
    } else
      return u;
  }
  e.remap = n;
  function a(u) {
    if (t(u))
      return u;
    if (u.kind === "element-loci") {
      for (var l = u.layers[0].loci.structure, f = /* @__PURE__ */ new Map(), d = Lo.StructureElement.Loci.none(l), m = 0, p = u.layers.length; m < p; ++m) {
        var v = u.layers[p - m - 1], h = v.loci, y = v.value;
        h = Lo.StructureElement.Loci.subtract(h, d), d = Lo.StructureElement.Loci.union(h, d), Lo.StructureElement.Loci.isEmpty(h) || (f.has(y) && (h = Lo.StructureElement.Loci.union(h, f.get(y))), f.set(y, h));
      }
      var C = [];
      return f.forEach(function(S, b) {
        C.push({ loci: S, value: b });
      }), { kind: "element-loci", layers: C };
    } else
      return u;
  }
  e.merge = a;
  function i(u, l) {
    if (t(u))
      return u;
    if (u.kind === "element-loci") {
      for (var f = u.layers[0].loci.structure, d = [], m = 0, p = u.layers; m < p.length; m++) {
        var v = p[m], h = v.loci, y = v.value, C = Lo.StructureElement.Loci.remap(h, l);
        h = Lo.StructureElement.Loci.remap(C, f), Lo.StructureElement.Loci.isEmpty(h) || d.push({ loci: h, value: y });
      }
      return { kind: "element-loci", layers: d };
    } else
      return u;
  }
  e.filter = i;
  function o(u, l) {
    for (var f = [], d = 0, m = u.length; d < m; ++d) {
      var p = u[d], v = p.script, h = p.value, y = Ide.Script.toLoci(v, l);
      Lo.StructureElement.Loci.isEmpty(y) || f.push({ loci: y, value: h });
    }
    return { kind: "element-loci", layers: f };
  }
  e.ofScript = o;
  function c(u, l) {
    for (var f = [], d = 0, m = u.length; d < m; ++d) {
      var p = u[d], v = p.bundle, h = p.value, y = Lo.StructureElement.Bundle.toLoci(v, l.root);
      f.push({ loci: y, value: h });
    }
    return { kind: "element-loci", layers: f };
  }
  e.ofBundle = c;
  function s(u) {
    for (var l = [], f = 0, d = u.layers.length; f < d; ++f) {
      var m = u.layers[f], p = m.loci, v = m.value, h = Lo.StructureElement.Bundle.fromLoci(p);
      l.push({ bundle: h, value: v });
    }
    return { kind: "element-loci", layers: l };
  }
  e.toBundle = s;
})(Ub || (Ub = {}));
U0.Transparency = Ub;
var Vp = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.getQualityProps = e.getStructureQuality = e.DefaultQualityThresholds = e.VisualUpdateState = void 0;
  var r = Te, t = We(), n = Je(), a = nr(), i = ml(), o = F0;
  (function(l) {
    function f() {
      return {
        updateTransform: !1,
        updateMatrix: !1,
        updateColor: !1,
        updateSize: !1,
        createGeometry: !1,
        createNew: !1,
        info: {}
      };
    }
    l.create = f;
    function d(m) {
      m.updateTransform = !1, m.updateMatrix = !1, m.updateColor = !1, m.updateSize = !1, m.createGeometry = !1, m.createNew = !1;
    }
    l.reset = d;
  })(e.VisualUpdateState || (e.VisualUpdateState = {})), e.DefaultQualityThresholds = {
    lowestElementCount: 1e6,
    lowerElementCount: 5e5,
    lowElementCount: 1e5,
    mediumElementCount: 2e4,
    highElementCount: 2e3,
    coarseGrainedFactor: 10,
    elementCountFactor: 1
  };
  function c(l, f) {
    f === void 0 && (f = {});
    var d = (0, r.__assign)((0, r.__assign)({}, e.DefaultQualityThresholds), f), m = l.elementCount * d.elementCountFactor;
    return l.isCoarseGrained && (m *= d.coarseGrainedFactor), m > d.lowestElementCount ? "lowest" : m > d.lowerElementCount ? "lower" : m > d.lowElementCount ? "low" : m > d.mediumElementCount ? "medium" : m > d.highElementCount ? "high" : "higher";
  }
  e.getStructureQuality = c;
  function s(l) {
    if (l.root.models.length === 1) {
      var f = i.ModelSymmetry.Provider.get(l.root.model);
      if (f && f.spacegroup.name === "P 1" && !a.SpacegroupCell.isZero(f.spacegroup.cell))
        return f.spacegroup.cell.volume;
    }
    return a.Box3D.volume(l.root.boundary.box);
  }
  function u(l, f) {
    var d = (0, t.defaults)(l.quality, "auto"), m = (0, t.defaults)(l.detail, 1), p = (0, t.defaults)(l.radialSegments, 12), v = (0, t.defaults)(l.linearSegments, 8), h = (0, t.defaults)(l.resolution, 2), y = (0, t.defaults)(l.probePositions, 12), C = (0, t.defaults)(l.doubleSided, !0), S = 0;
    if (d === "auto") {
      if (f instanceof n.Structure)
        d = c(f.root), S = s(f);
      else if (o.Volume.is(f)) {
        var b = f.grid.cells.space.dimensions, g = b[0], _ = b[1], A = b[2];
        S = g * _ * A, d = S < 1e7 ? "medium" : "low";
      }
    }
    switch (d) {
      case "highest":
        m = 3, p = 36, v = 18, h = 0.1, y = 72, C = !0;
        break;
      case "higher":
        m = 3, p = 28, v = 14, h = 0.3, y = 48, C = !0;
        break;
      case "high":
        m = 2, p = 20, v = 10, h = 0.5, y = 36, C = !0;
        break;
      case "medium":
        m = 1, p = 12, v = 8, h = 0.8, y = 24, C = !0;
        break;
      case "low":
        m = 0, p = 8, v = 3, h = 1.3, y = 24, C = !1;
        break;
      case "lower":
        m = 0, p = 4, v = 2, h = 3, y = 12, C = !1;
        break;
      case "lowest":
        m = 0, p = 2, v = 1, h = 8, y = 12, C = !1;
        break;
    }
    return h = Math.max(h, S / 5e8), h = Math.min(h, 20), (l.alpha !== void 0 && l.alpha < 1 || l.xrayShaded) && (C = !1), {
      detail: m,
      radialSegments: p,
      linearSegments: v,
      resolution: h,
      probePositions: y,
      doubleSided: C
    };
  }
  e.getQualityProps = u;
})(Vp);
var gl = {}, Gi = {}, Zu = {};
Object.defineProperty(Zu, "__esModule", { value: !0 });
Zu.createVolumeTexture3d = Zu.createVolumeTexture2d = Zu.getVolumeTexture2dLayout = Zu.eachVolumeLoci = void 0;
var Lc = F0, hm = Qe(), Bde = Ci, il = Yo, Nde = ts, zb = il.Vec3.set, zq = il.Vec3.normalize, Gq = il.Vec3.sub, qq = il.Vec3.addScalar, Gb = il.Vec3.scale, Hq = il.Vec3.toArray;
function Vde(e, r, t, n) {
  var a = !1;
  if (Lc.Volume.isLoci(e)) {
    if (!Lc.Volume.areEquivalent(e.volume, r))
      return !1;
    n(hm.Interval.ofLength(r.grid.cells.data.length)) && (a = !0);
  } else if (Lc.Volume.Isosurface.isLoci(e)) {
    if (!Lc.Volume.areEquivalent(e.volume, r))
      return !1;
    if (t) {
      if (!Lc.Volume.IsoValue.areSame(e.isoValue, t, r.grid.stats))
        return !1;
      n(hm.Interval.ofLength(r.grid.cells.data.length)) && (a = !0);
    } else
      for (var i = r.grid, o = i.stats, c = i.cells.data, s = o.sigma, u = Lc.Volume.IsoValue.toAbsolute(e.isoValue, o).absoluteValue, l = 0, f = c.length; l < f; ++l)
        (0, Bde.equalEps)(u, c[l], s) && n(hm.Interval.ofSingleton(l)) && (a = !0);
  } else if (Lc.Volume.Cell.isLoci(e)) {
    if (!Lc.Volume.areEquivalent(e.volume, r))
      return !1;
    hm.Interval.is(e.indices) ? n(e.indices) && (a = !0) : hm.OrderedSet.forEach(e.indices, function(d) {
      n(hm.Interval.ofSingleton(d)) && (a = !0);
    });
  }
  return a;
}
Zu.eachVolumeLoci = Vde;
function jq(e, r) {
  r === void 0 && (r = 0);
  var t = e[0] * e[1] * e[2], n = Math.sqrt(t), a = Math.pow(2, Math.ceil(Math.log(n) / Math.log(2))), i = e[0] + r, o = e[1] + r, c = 1, s = i;
  return a < i * e[2] ? (s = Math.floor(a / i), c = Math.ceil(e[2] / s), i *= s, o *= c) : i *= e[2], { width: i, height: o, columns: s, rows: c, powerOfTwoSize: o < a ? a : a * 2 };
}
Zu.getVolumeTexture2dLayout = jq;
function Rde(e, r, t) {
  t === void 0 && (t = 0);
  for (var n = e.grid, a = n.cells, i = a.space, o = a.data, c = n.stats, s = c.max, u = c.min, l = i.dimensions, f = i.dataOffset, d = jq(l, t), m = d.width, p = d.height, v = r === "data" ? 1 : 4, h = new Uint8Array(m * p * v), y = { array: h, width: m, height: p }, C = s - u, S = l[0], b = l[1], g = l[2], _ = S + t, A = b + t, M = (0, il.Vec3)(), P = (0, il.Vec3)(), T = S - 1, x = b - 1, w = g - 1, E = 0; E < g; ++E)
    for (var I = 0; I < b; ++I)
      for (var B = 0; B < S; ++B) {
        var D = Math.floor(E * _ % m / _), N = Math.floor(E * _ / m), O = D * _ + B, V = v * (N * A * m + I * m + O), k = f(B, I, E);
        r === "data" ? h[V] = Math.round((o[k] - u) / C * 255) : (r === "groups" ? (0, Nde.packIntToRGBArray)(k, h, V) : (zb(M, o[f(Math.max(0, B - 1), I, E)], o[f(B, Math.max(0, I - 1), E)], o[f(B, I, Math.max(0, E - 1))]), zb(P, o[f(Math.min(T, B + 1), I, E)], o[f(B, Math.min(x, I + 1), E)], o[f(B, I, Math.min(w, E + 1))]), zq(M, Gq(M, M, P)), qq(M, Gb(M, M, 0.5), 0.5), Hq(Gb(M, M, 255), h, V)), h[V + 3] = Math.round((o[k] - u) / C * 255));
      }
  return y;
}
Zu.createVolumeTexture2d = Rde;
function Ode(e) {
  for (var r = e.grid, t = r.cells, n = t.space, a = t.data, i = r.stats, o = i.max, c = i.min, s = n.dimensions, u = s[0], l = s[1], f = s[2], d = n.dataOffset, m = new Uint8Array(u * l * f * 4), p = { array: m, width: u, height: l, depth: f }, v = o - c, h = (0, il.Vec3)(), y = (0, il.Vec3)(), C = u - 1, S = l - 1, b = f - 1, g = 0, _ = 0; _ < f; ++_)
    for (var A = 0; A < l; ++A)
      for (var M = 0; M < u; ++M) {
        var P = d(M, A, _);
        zb(h, a[d(Math.max(0, M - 1), A, _)], a[d(M, Math.max(0, A - 1), _)], a[d(M, A, Math.max(0, _ - 1))]), zb(y, a[d(Math.min(C, M + 1), A, _)], a[d(M, Math.min(S, A + 1), _)], a[d(M, A, Math.min(b, _ + 1))]), zq(h, Gq(h, h, y)), qq(h, Gb(h, h, 0.5), 0.5), Hq(Gb(h, h, 255), m, g), m[g + 3] = Math.round((a[P] - c) / v * 255), g += 4;
      }
  return p;
}
Zu.createVolumeTexture3d = Ode;
Object.defineProperty(Gi, "__esModule", { value: !0 });
Gi.applyMeshSubstanceSmoothing = Gi.applyMeshTransparencySmoothing = Gi.applyMeshOverpaintSmoothing = Gi.applyMeshColorSmoothing = Gi.getTrilinearlyInterpolated = Gi.calcMeshColorSmoothing = void 0;
var Fde = ut, wf = nr(), Ef = Zr, Rt = Re, Lde = Zu, gt = We();
function Sy(e, r, t, n, a) {
  var i = e.colorType, o = e.vertexCount, c = e.groupCount, s = e.positionBuffer, u = e.transformBuffer, l = e.groupBuffer, f = e.itemSize, d = i.endsWith("Instance"), m = wf.Box3D.fromSphere3D((0, wf.Box3D)(), d ? e.boundingSphere : e.invariantBoundingSphere), p = 1 + r, v = wf.Box3D.expand((0, wf.Box3D)(), m, Rt.Vec3.create(p, p, p)), h = 1 / r, y = wf.Box3D.scale((0, wf.Box3D)(), v, h), C = wf.Box3D.size((0, Rt.Vec3)(), y);
  Rt.Vec3.ceil(C, C), Rt.Vec3.add(C, C, Rt.Vec3.create(2, 2, 2));
  var S = v.min, b = C[0], g = C[1], _ = (0, Lde.getVolumeTexture2dLayout)(C), A = _.width, M = _.height, P = new Float32Array(A * M * f), T = new Float32Array(A * M), x = new Uint8Array(A * M * f), w = {
    array: x,
    width: A,
    height: M,
    filter: "linear"
  }, E = d ? e.instanceCount : 1, I = e.colorData.array;
  function B(De, Ee, Me) {
    var ue = Math.floor(Me * b % A / b), pe = Math.floor(Me * b / A), Ae = ue * b + De;
    return f * (pe * g * A + Ee * A + Ae);
  }
  for (var D = 2, N = C[0], O = C[1], V = C[2], k = (0, Rt.Vec3)(), G = 0; G < E; ++G)
    for (var L = 0; L < o; L += t) {
      Rt.Vec3.fromArray(k, s, L * 3), d && Rt.Vec3.transformMat4Offset(k, k, u, 0, 0, G * 16), Rt.Vec3.sub(k, k, S), Rt.Vec3.scale(k, k, h);
      for (var R = k[0], F = k[1], U = k[2], H = Math.floor(R), q = Math.floor(F), K = Math.floor(U), Y = (G * c + l[L]) * f, X = Math.max(0, H - D), Z = Math.max(0, q - D), J = Math.max(0, K - D), $ = Math.min(N, H + D + 2), Q = Math.min(O, q + D + 2), W = Math.min(V, K + D + 2), te = X; te < $; ++te)
        for (var oe = te - R, z = Z; z < Q; ++z)
          for (var j = z - F, ae = J; ae < W; ++ae) {
            var le = ae - U, ie = Math.sqrt(oe * oe + j * j + le * le);
            if (!(ie > D)) {
              for (var re = D - ie, ee = B(te, z, ae), ne = 0; ne < f; ++ne)
                P[ee + ne] += I[Y + ne] * re;
              T[ee / f] += re;
            }
          }
    }
  for (var G = 0, se = T.length; G < se; ++G)
    for (var ce = G * f, de = T[G], ne = 0; ne < f; ++ne)
      x[ce + ne] = Math.round(P[ce + ne] / de);
  var me = Rt.Vec2.create(A, M), he = Rt.Vec4.create(S[0], S[1], S[2], h), _e = d ? "volumeInstance" : "volume";
  if (n) {
    if (!a) {
      var Se = f === 4 ? "rgba" : f === 3 ? "rgb" : "alpha";
      a = n.resources.texture("image-uint8", Se, "ubyte", "linear");
    }
    return a.load(w), {
      kind: "volume",
      texture: a,
      gridTexDim: me,
      gridDim: C,
      gridTransform: he,
      type: _e
    };
  } else {
    var Pe = $q({
      vertexCount: o,
      instanceCount: E,
      transformBuffer: u,
      positionBuffer: s,
      colorType: _e,
      grid: x,
      gridDim: C,
      gridTexDim: me,
      gridTransform: he,
      vertexStride: 3,
      colorStride: f,
      outputStride: f
    });
    return {
      kind: "vertex",
      texture: Pe,
      texDim: Rt.Vec2.create(Pe.width, Pe.height),
      type: d ? "vertexInstance" : "vertex"
    };
  }
}
Gi.calcMeshColorSmoothing = Sy;
function $q(e) {
  var r = e.vertexCount, t = e.positionBuffer, n = e.transformBuffer, a = e.grid, i = e.gridDim, o = e.gridTexDim, c = e.gridTransform, s = e.vertexStride, u = e.colorStride, l = e.itemOffset || 0, f = e.outputStride;
  if (f + l > u)
    throw new Error("outputStride + itemOffset must NOT be larger than colorStride");
  var d = e.colorType.endsWith("Instance"), m = d ? e.instanceCount : 1, p = (0, Fde.createTextureImage)(Math.max(1, m * r), f, Uint8Array), v = p.array, h = i[0], y = i[1], C = o[0], S = Rt.Vec3.fromArray((0, Rt.Vec3)(), c, 0), b = c[3];
  function g(ne, se, ce) {
    var de = Math.floor(ce * h % C / h), me = Math.floor(ce * h / C), he = de * h + ne;
    return u * (me * y * C + se * C + he);
  }
  for (var _ = (0, Rt.Vec3)(), A = (0, Rt.Vec3)(), M = (0, Rt.Vec3)(), P = (0, Rt.Vec3)(), T = 0; T < m; ++T)
    for (var x = 0; x < r; ++x) {
      Rt.Vec3.fromArray(_, t, x * s), d && Rt.Vec3.transformMat4Offset(_, _, n, 0, 0, T * 16), Rt.Vec3.sub(_, _, S), Rt.Vec3.scale(_, _, b), Rt.Vec3.floor(A, _), Rt.Vec3.ceil(M, _), Rt.Vec3.sub(P, _, A), Rt.Vec3.sub(_, M, A), Rt.Vec3.div(P, P, _);
      for (var w = A[0], E = A[1], I = A[2], B = M[0], D = M[1], N = M[2], O = P[0], V = P[1], k = P[2], G = g(w, E, I) + l, L = g(B, E, I) + l, R = g(w, E, N) + l, F = g(B, E, N) + l, U = g(w, D, I) + l, H = g(B, D, I) + l, q = g(w, D, N) + l, K = g(B, D, N) + l, Y = (T * r + x) * f, X = 0; X < f; ++X) {
        var Z = a[G + X], J = a[L + X], $ = a[R + X], Q = a[F + X], W = a[U + X], te = a[H + X], oe = a[q + X], z = a[K + X], j = (0, Ef.lerp)(Z, J, O), ae = (0, Ef.lerp)($, Q, O), le = (0, Ef.lerp)(W, te, O), ie = (0, Ef.lerp)(oe, z, O), re = (0, Ef.lerp)(j, le, V), ee = (0, Ef.lerp)(ae, ie, V);
        v[Y + X] = (0, Ef.lerp)(re, ee, k);
      }
    }
  return p;
}
Gi.getTrilinearlyInterpolated = $q;
function kde(e) {
  return e === "group" || e === "groupInstance";
}
function Ude(e, r, t, n, a) {
  if (kde(e.dColorType.ref.value)) {
    var i = Sy({
      vertexCount: e.uVertexCount.ref.value,
      instanceCount: e.uInstanceCount.ref.value,
      groupCount: e.uGroupCount.ref.value,
      transformBuffer: e.aTransform.ref.value,
      instanceBuffer: e.aInstance.ref.value,
      positionBuffer: e.aPosition.ref.value,
      groupBuffer: e.aGroup.ref.value,
      colorData: e.tColor.ref.value,
      colorType: e.dColorType.ref.value,
      boundingSphere: e.boundingSphere.ref.value,
      invariantBoundingSphere: e.invariantBoundingSphere.ref.value,
      itemSize: 3
    }, r, t, n, a);
    i.kind === "volume" ? (gt.ValueCell.updateIfChanged(e.dColorType, i.type), gt.ValueCell.update(e.tColorGrid, i.texture), gt.ValueCell.update(e.uColorTexDim, i.gridTexDim), gt.ValueCell.update(e.uColorGridDim, i.gridDim), gt.ValueCell.update(e.uColorGridTransform, i.gridTransform)) : i.kind === "vertex" && (gt.ValueCell.updateIfChanged(e.dColorType, i.type), gt.ValueCell.update(e.tColor, i.texture), gt.ValueCell.update(e.uColorTexDim, i.texDim));
  }
}
Gi.applyMeshColorSmoothing = Ude;
function zde(e) {
  return e === "groupInstance";
}
function Gde(e, r, t, n, a) {
  if (zde(e.dOverpaintType.ref.value)) {
    var i = Sy({
      vertexCount: e.uVertexCount.ref.value,
      instanceCount: e.uInstanceCount.ref.value,
      groupCount: e.uGroupCount.ref.value,
      transformBuffer: e.aTransform.ref.value,
      instanceBuffer: e.aInstance.ref.value,
      positionBuffer: e.aPosition.ref.value,
      groupBuffer: e.aGroup.ref.value,
      colorData: e.tOverpaint.ref.value,
      colorType: e.dOverpaintType.ref.value,
      boundingSphere: e.boundingSphere.ref.value,
      invariantBoundingSphere: e.invariantBoundingSphere.ref.value,
      itemSize: 4
    }, r, t, n, a);
    i.kind === "volume" ? (gt.ValueCell.updateIfChanged(e.dOverpaintType, i.type), gt.ValueCell.update(e.tOverpaintGrid, i.texture), gt.ValueCell.update(e.uOverpaintTexDim, i.gridTexDim), gt.ValueCell.update(e.uOverpaintGridDim, i.gridDim), gt.ValueCell.update(e.uOverpaintGridTransform, i.gridTransform)) : i.kind === "vertex" && (gt.ValueCell.updateIfChanged(e.dOverpaintType, i.type), gt.ValueCell.update(e.tOverpaint, i.texture), gt.ValueCell.update(e.uOverpaintTexDim, i.texDim));
  }
}
Gi.applyMeshOverpaintSmoothing = Gde;
function qde(e) {
  return e === "groupInstance";
}
function Hde(e, r, t, n, a) {
  if (qde(e.dTransparencyType.ref.value)) {
    var i = Sy({
      vertexCount: e.uVertexCount.ref.value,
      instanceCount: e.uInstanceCount.ref.value,
      groupCount: e.uGroupCount.ref.value,
      transformBuffer: e.aTransform.ref.value,
      instanceBuffer: e.aInstance.ref.value,
      positionBuffer: e.aPosition.ref.value,
      groupBuffer: e.aGroup.ref.value,
      colorData: e.tTransparency.ref.value,
      colorType: e.dTransparencyType.ref.value,
      boundingSphere: e.boundingSphere.ref.value,
      invariantBoundingSphere: e.invariantBoundingSphere.ref.value,
      itemSize: 1
    }, r, t, n, a);
    i.kind === "volume" ? (gt.ValueCell.updateIfChanged(e.dTransparencyType, i.type), gt.ValueCell.update(e.tTransparencyGrid, i.texture), gt.ValueCell.update(e.uTransparencyTexDim, i.gridTexDim), gt.ValueCell.update(e.uTransparencyGridDim, i.gridDim), gt.ValueCell.update(e.uTransparencyGridTransform, i.gridTransform)) : i.kind === "vertex" && (gt.ValueCell.updateIfChanged(e.dTransparencyType, i.type), gt.ValueCell.update(e.tTransparency, i.texture), gt.ValueCell.update(e.uTransparencyTexDim, i.texDim));
  }
}
Gi.applyMeshTransparencySmoothing = Hde;
function jde(e) {
  return e === "groupInstance";
}
function $de(e, r, t, n, a) {
  if (jde(e.dSubstanceType.ref.value)) {
    var i = Sy({
      vertexCount: e.uVertexCount.ref.value,
      instanceCount: e.uInstanceCount.ref.value,
      groupCount: e.uGroupCount.ref.value,
      transformBuffer: e.aTransform.ref.value,
      instanceBuffer: e.aInstance.ref.value,
      positionBuffer: e.aPosition.ref.value,
      groupBuffer: e.aGroup.ref.value,
      colorData: e.tSubstance.ref.value,
      colorType: e.dSubstanceType.ref.value,
      boundingSphere: e.boundingSphere.ref.value,
      invariantBoundingSphere: e.invariantBoundingSphere.ref.value,
      itemSize: 4
    }, r, t, n, a);
    i.kind === "volume" ? (gt.ValueCell.updateIfChanged(e.dSubstanceType, i.type), gt.ValueCell.update(e.tSubstanceGrid, i.texture), gt.ValueCell.update(e.uSubstanceTexDim, i.gridTexDim), gt.ValueCell.update(e.uSubstanceGridDim, i.gridDim), gt.ValueCell.update(e.uSubstanceGridTransform, i.gridTransform)) : i.kind === "vertex" && (gt.ValueCell.updateIfChanged(e.dSubstanceType, i.type), gt.ValueCell.update(e.tSubstance, i.texture), gt.ValueCell.update(e.uSubstanceTexDim, i.texDim));
  }
}
Gi.applyMeshSubstanceSmoothing = $de;
var Kq = {}, m4 = {};
Object.defineProperty(m4, "__esModule", { value: !0 });
m4.normalize_frag = void 0;
m4.normalize_frag = `
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;
}
`;
var v4 = {};
Object.defineProperty(v4, "__esModule", { value: !0 });
v4.accumulate_frag = void 0;
v4.accumulate_frag = `
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);
}
`;
var p4 = {};
Object.defineProperty(p4, "__esModule", { value: !0 });
p4.accumulate_vert = void 0;
p4.accumulate_vert = `
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
}
`;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.applyTextureMeshSubstanceSmoothing = e.applyTextureMeshTransparencySmoothing = e.applyTextureMeshOverpaintSmoothing = e.applyTextureMeshColorSmoothing = e.calcTextureMeshColorSmoothing = e.ColorNormalizeSchema = e.ColorAccumulateSchema = void 0;
  var r = Te, t = We(), n = Kt, a = Bn(), i = Lt, o = yn, c = Qi, s = m4, u = Yi, l = Re, f = nr(), d = v4, m = p4, p = vs();
  e.ColorAccumulateSchema = {
    drawCount: (0, o.ValueSpec)("number"),
    instanceCount: (0, o.ValueSpec)("number"),
    stride: (0, o.ValueSpec)("number"),
    uTotalCount: (0, o.UniformSpec)("i"),
    uInstanceCount: (0, o.UniformSpec)("i"),
    uGroupCount: (0, o.UniformSpec)("i"),
    aTransform: (0, o.AttributeSpec)("float32", 16, 1),
    aInstance: (0, o.AttributeSpec)("float32", 1, 1),
    aSample: (0, o.AttributeSpec)("float32", 1, 0),
    uGeoTexDim: (0, o.UniformSpec)("v2", "buffered"),
    tPosition: (0, o.TextureSpec)("texture", "rgba", "float", "nearest"),
    tGroup: (0, o.TextureSpec)("texture", "rgba", "float", "nearest"),
    uColorTexDim: (0, o.UniformSpec)("v2"),
    tColor: (0, o.TextureSpec)("texture", "rgba", "ubyte", "nearest"),
    dColorType: (0, o.DefineSpec)("string", ["group", "groupInstance", "vertex", "vertexInstance"]),
    uCurrentSlice: (0, o.UniformSpec)("f"),
    uCurrentX: (0, o.UniformSpec)("f"),
    uCurrentY: (0, o.UniformSpec)("f"),
    uBboxMin: (0, o.UniformSpec)("v3", "material"),
    uBboxSize: (0, o.UniformSpec)("v3", "material"),
    uResolution: (0, o.UniformSpec)("f", "material")
  };
  var v = "color-accumulate", h = "color-count";
  function y(L, R) {
    for (var F = new Float32Array(L), U = 0; U < L; ++U)
      F[U] = U * R;
    return F;
  }
  function C(L, R, F, U, H) {
    if (L.namedComputeRenderables[v]) {
      var q = l.Vec3.sub((0, l.Vec3)(), F.max, F.min), K = L.namedComputeRenderables[v].values, Y = Math.round(R.vertexCount / H);
      (Y > K.drawCount.ref.value || H !== K.stride.ref.value) && t.ValueCell.update(K.aSample, y(Y, H)), t.ValueCell.updateIfChanged(K.drawCount, Y), t.ValueCell.updateIfChanged(K.instanceCount, R.instanceCount), t.ValueCell.updateIfChanged(K.stride, H), t.ValueCell.updateIfChanged(K.uTotalCount, R.vertexCount), t.ValueCell.updateIfChanged(K.uInstanceCount, R.instanceCount), t.ValueCell.updateIfChanged(K.uGroupCount, R.groupCount), t.ValueCell.update(K.aTransform, R.transformBuffer), t.ValueCell.update(K.aInstance, R.instanceBuffer), t.ValueCell.update(K.uGeoTexDim, l.Vec2.set(K.uGeoTexDim.ref.value, R.positionTexture.getWidth(), R.positionTexture.getHeight())), t.ValueCell.update(K.tPosition, R.positionTexture), t.ValueCell.update(K.tGroup, R.groupTexture), t.ValueCell.update(K.uColorTexDim, l.Vec2.set(K.uColorTexDim.ref.value, R.colorData.getWidth(), R.colorData.getHeight())), t.ValueCell.update(K.tColor, R.colorData), t.ValueCell.updateIfChanged(K.dColorType, R.colorType), t.ValueCell.updateIfChanged(K.uCurrentSlice, 0), t.ValueCell.updateIfChanged(K.uCurrentX, 0), t.ValueCell.updateIfChanged(K.uCurrentY, 0), t.ValueCell.update(K.uBboxMin, F.min), t.ValueCell.update(K.uBboxSize, q), t.ValueCell.updateIfChanged(K.uResolution, U), L.namedComputeRenderables[v].update();
    } else
      L.namedComputeRenderables[v] = S(L, R, F, U, H);
    return L.namedComputeRenderables[v];
  }
  function S(L, R, F, U, H) {
    var q = l.Vec3.sub((0, l.Vec3)(), F.max, F.min), K = Math.round(R.vertexCount / H), Y = {
      drawCount: t.ValueCell.create(K),
      instanceCount: t.ValueCell.create(R.instanceCount),
      stride: t.ValueCell.create(H),
      uTotalCount: t.ValueCell.create(R.vertexCount),
      uInstanceCount: t.ValueCell.create(R.instanceCount),
      uGroupCount: t.ValueCell.create(R.groupCount),
      aTransform: t.ValueCell.create(R.transformBuffer),
      aInstance: t.ValueCell.create(R.instanceBuffer),
      aSample: t.ValueCell.create(y(K, H)),
      uGeoTexDim: t.ValueCell.create(l.Vec2.create(R.positionTexture.getWidth(), R.positionTexture.getHeight())),
      tPosition: t.ValueCell.create(R.positionTexture),
      tGroup: t.ValueCell.create(R.groupTexture),
      uColorTexDim: t.ValueCell.create(l.Vec2.create(R.colorData.getWidth(), R.colorData.getHeight())),
      tColor: t.ValueCell.create(R.colorData),
      dColorType: t.ValueCell.create(R.colorType),
      uCurrentSlice: t.ValueCell.create(0),
      uCurrentX: t.ValueCell.create(0),
      uCurrentY: t.ValueCell.create(0),
      uBboxMin: t.ValueCell.create(F.min),
      uBboxSize: t.ValueCell.create(q),
      uResolution: t.ValueCell.create(U)
    }, X = (0, r.__assign)({}, e.ColorAccumulateSchema), Z = (0, a.ShaderCode)("accumulate", m.accumulate_vert, d.accumulate_frag, { drawBuffers: "required" }), J = (0, i.createComputeRenderItem)(L, "points", Z, X, Y);
    return (0, n.createComputeRenderable)(J, Y);
  }
  function b(L) {
    var R = L.gl, F = L.state;
    F.disable(R.CULL_FACE), F.enable(R.BLEND), F.disable(R.DEPTH_TEST), F.enable(R.SCISSOR_TEST), F.depthMask(!1), F.clearColor(0, 0, 0, 0), F.blendFunc(R.ONE, R.ONE), F.blendEquation(R.FUNC_ADD);
  }
  e.ColorNormalizeSchema = (0, r.__assign)((0, r.__assign)({}, u.QuadSchema), { tColor: (0, o.TextureSpec)("texture", "rgba", "float", "nearest"), tCount: (0, o.TextureSpec)("texture", "alpha", "float", "nearest"), uTexSize: (0, o.UniformSpec)("v2") });
  var g = "color-normalize";
  function _(L, R, F) {
    if (L.namedComputeRenderables[g]) {
      var U = L.namedComputeRenderables[g].values;
      t.ValueCell.update(U.tColor, R), t.ValueCell.update(U.tCount, F), t.ValueCell.update(U.uTexSize, l.Vec2.set(U.uTexSize.ref.value, R.getWidth(), R.getHeight())), L.namedComputeRenderables[g].update();
    } else
      L.namedComputeRenderables[g] = A(L, R, F);
    return L.namedComputeRenderables[g];
  }
  function A(L, R, F) {
    var U = (0, r.__assign)((0, r.__assign)({}, u.QuadValues), { tColor: t.ValueCell.create(R), tCount: t.ValueCell.create(F), uTexSize: t.ValueCell.create(l.Vec2.create(R.getWidth(), R.getHeight())) }), H = (0, r.__assign)({}, e.ColorNormalizeSchema), q = (0, a.ShaderCode)("normalize", c.quad_vert, s.normalize_frag), K = (0, i.createComputeRenderItem)(L, "triangles", q, H, U);
    return (0, n.createComputeRenderable)(K, U);
  }
  function M(L) {
    var R = L.gl, F = L.state;
    F.disable(R.CULL_FACE), F.enable(R.BLEND), F.disable(R.DEPTH_TEST), F.enable(R.SCISSOR_TEST), F.depthMask(!1), F.clearColor(0, 0, 0, 0), F.blendFunc(R.ONE, R.ONE), F.blendEquation(R.FUNC_ADD);
  }
  function P(L) {
    var R = L[0] * L[1] * L[2], F = Math.sqrt(R), U = Math.pow(2, Math.ceil(Math.log(F) / Math.log(2))), H = 0, q = L[1], K = 1, Y = L[2];
    return U < L[0] * L[2] ? (Y = Math.floor(U / L[0]), K = Math.ceil(L[2] / Y), H = Y * L[0], q *= K) : H = L[0] * L[2], { texDimX: H, texDimY: q, texRows: K, texCols: Y, powerOfTwoSize: q < U ? U : U * 2 };
  }
  function T(L, R, F, U, H) {
    var q = U.extensions.drawBuffers;
    if (!q)
      throw new Error("need WebGL draw buffers");
    var K = U.gl, Y = U.resources, X = U.state, Z = U.extensions, J = Z.colorBufferHalfFloat, $ = Z.textureHalfFloat, Q = L.colorType.endsWith("Instance"), W = f.Box3D.fromSphere3D((0, f.Box3D)(), Q ? L.boundingSphere : L.invariantBoundingSphere), te = 1 + R, oe = f.Box3D.expand((0, f.Box3D)(), W, l.Vec3.create(te, te, te)), z = 1 / R, j = f.Box3D.scale((0, f.Box3D)(), oe, z), ae = f.Box3D.size((0, l.Vec3)(), j);
    l.Vec3.ceil(ae, ae), l.Vec3.add(ae, ae, l.Vec3.create(2, 2, 2));
    var le = oe.min, ie = ae[0], re = ae[1], ee = ae[2], ne = P(ae), se = ne.texDimX, ce = ne.texDimY, de = ne.texCols;
    U.namedFramebuffers[v] || (U.namedFramebuffers[v] = U.resources.framebuffer());
    var me = U.namedFramebuffers[v];
    (0, p.isWebGL2)(K) ? (U.namedTextures[v] || (U.namedTextures[v] = J && $ ? Y.texture("image-float16", "rgba", "fp16", "nearest") : Y.texture("image-float32", "rgba", "float", "nearest")), U.namedTextures[h] || (U.namedTextures[h] = Y.texture("image-float32", "alpha", "float", "nearest"))) : (U.namedTextures[v] || (U.namedTextures[v] = Y.texture("image-float32", "rgba", "float", "nearest")), U.namedTextures[h] || (U.namedTextures[h] = Y.texture("image-float32", "rgba", "float", "nearest")));
    var he = U.namedTextures[v], _e = U.namedTextures[h];
    he.define(se, ce), _e.define(se, ce), he.attachFramebuffer(me, 0), _e.attachFramebuffer(me, 1);
    var Se = C(U, L, oe, R, F);
    X.currentRenderItemId = -1, me.bind(), q.drawBuffers([
      q.COLOR_ATTACHMENT0,
      q.COLOR_ATTACHMENT1
    ]);
    var Pe = Se.values, De = Pe.uCurrentSlice, Ee = Pe.uCurrentX, Me = Pe.uCurrentY;
    b(U), K.viewport(0, 0, se, ce), K.scissor(0, 0, se, ce), K.clear(K.COLOR_BUFFER_BIT), t.ValueCell.update(Me, 0);
    for (var ue = 0, pe = 0, Ae = 0, ye = 0; ye < ee; ++ye)
      ue >= de && (ue -= de, pe += re, Ae = 0, t.ValueCell.update(Me, pe)), t.ValueCell.update(Ee, Ae), t.ValueCell.update(De, ye), K.viewport(Ae, pe, ie, re), K.scissor(Ae, pe, ie, re), Se.render(), ++ue, Ae += ie;
    he.detachFramebuffer(me, 0), _e.detachFramebuffer(me, 1), q.drawBuffers([K.COLOR_ATTACHMENT0, K.NONE]), H || (H = Y.texture("image-uint8", "rgba", "ubyte", "linear")), H.define(se, ce);
    var be = _(U, he, _e);
    X.currentRenderItemId = -1, M(U), H.attachFramebuffer(me, 0), K.viewport(0, 0, se, ce), K.scissor(0, 0, se, ce), K.clear(K.COLOR_BUFFER_BIT), be.render();
    var fe = l.Vec4.create(le[0], le[1], le[2], z), ge = Q ? "volumeInstance" : "volume";
    return { texture: H, gridDim: ae, gridTexDim: l.Vec2.create(se, ce), gridTransform: fe, type: ge };
  }
  e.calcTextureMeshColorSmoothing = T;
  var x = "color-smoothing-rgb", w = "color-smoothing-rgba", E = "color-smoothing-alpha";
  function I(L) {
    return L === "group" || L === "groupInstance";
  }
  function B(L, R, F, U, H) {
    if (I(L.dColorType.ref.value)) {
      F *= 3, U.namedTextures[x] || (U.namedTextures[x] = U.resources.texture("image-uint8", "rgb", "ubyte", "nearest"));
      var q = U.namedTextures[x];
      q.load(L.tColor.ref.value);
      var K = T({
        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,
        positionTexture: L.tPosition.ref.value,
        groupTexture: L.tGroup.ref.value,
        colorData: q,
        colorType: L.dColorType.ref.value,
        boundingSphere: L.boundingSphere.ref.value,
        invariantBoundingSphere: L.invariantBoundingSphere.ref.value
      }, R, F, U, H);
      t.ValueCell.updateIfChanged(L.dColorType, K.type), t.ValueCell.update(L.tColorGrid, K.texture), t.ValueCell.update(L.uColorTexDim, K.gridTexDim), t.ValueCell.update(L.uColorGridDim, K.gridDim), t.ValueCell.update(L.uColorGridTransform, K.gridTransform);
    }
  }
  e.applyTextureMeshColorSmoothing = B;
  function D(L) {
    return L === "groupInstance";
  }
  function N(L, R, F, U, H) {
    if (D(L.dOverpaintType.ref.value)) {
      F *= 3, U.namedTextures[w] || (U.namedTextures[w] = U.resources.texture("image-uint8", "rgba", "ubyte", "nearest"));
      var q = U.namedTextures[w];
      q.load(L.tOverpaint.ref.value);
      var K = T({
        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,
        positionTexture: L.tPosition.ref.value,
        groupTexture: L.tGroup.ref.value,
        colorData: q,
        colorType: L.dOverpaintType.ref.value,
        boundingSphere: L.boundingSphere.ref.value,
        invariantBoundingSphere: L.invariantBoundingSphere.ref.value
      }, R, F, U, H);
      t.ValueCell.updateIfChanged(L.dOverpaintType, K.type), t.ValueCell.update(L.tOverpaintGrid, K.texture), t.ValueCell.update(L.uOverpaintTexDim, K.gridTexDim), t.ValueCell.update(L.uOverpaintGridDim, K.gridDim), t.ValueCell.update(L.uOverpaintGridTransform, K.gridTransform);
    }
  }
  e.applyTextureMeshOverpaintSmoothing = N;
  function O(L) {
    return L === "groupInstance";
  }
  function V(L, R, F, U, H) {
    if (O(L.dTransparencyType.ref.value)) {
      F *= 3, U.namedTextures[E] || (U.namedTextures[E] = U.resources.texture("image-uint8", "alpha", "ubyte", "nearest"));
      var q = U.namedTextures[E];
      q.load(L.tTransparency.ref.value);
      var K = T({
        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,
        positionTexture: L.tPosition.ref.value,
        groupTexture: L.tGroup.ref.value,
        colorData: q,
        colorType: L.dTransparencyType.ref.value,
        boundingSphere: L.boundingSphere.ref.value,
        invariantBoundingSphere: L.invariantBoundingSphere.ref.value
      }, R, F, U, H);
      t.ValueCell.updateIfChanged(L.dTransparencyType, K.type), t.ValueCell.update(L.tTransparencyGrid, K.texture), t.ValueCell.update(L.uTransparencyTexDim, K.gridTexDim), t.ValueCell.update(L.uTransparencyGridDim, K.gridDim), t.ValueCell.update(L.uTransparencyGridTransform, K.gridTransform);
    }
  }
  e.applyTextureMeshTransparencySmoothing = V;
  function k(L) {
    return L === "groupInstance";
  }
  function G(L, R, F, U, H) {
    if (k(L.dSubstanceType.ref.value)) {
      F *= 3, U.namedTextures[w] || (U.namedTextures[w] = U.resources.texture("image-uint8", "rgba", "ubyte", "nearest"));
      var q = U.namedTextures[w];
      q.load(L.tSubstance.ref.value);
      var K = T({
        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,
        positionTexture: L.tPosition.ref.value,
        groupTexture: L.tGroup.ref.value,
        colorData: q,
        colorType: L.dSubstanceType.ref.value,
        boundingSphere: L.boundingSphere.ref.value,
        invariantBoundingSphere: L.invariantBoundingSphere.ref.value
      }, R, F, U, H);
      t.ValueCell.updateIfChanged(L.dSubstanceType, K.type), t.ValueCell.update(L.tSubstanceGrid, K.texture), t.ValueCell.update(L.uSubstanceTexDim, K.gridTexDim), t.ValueCell.update(L.uSubstanceGridDim, K.gridDim), t.ValueCell.update(L.uSubstanceGridTransform, K.gridTransform);
    }
  }
  e.applyTextureMeshSubstanceSmoothing = G;
})(Kq);
Object.defineProperty(gl, "__esModule", { value: !0 });
gl.Visual = void 0;
var Kh = _r, gm = _n, Kde = Re, w9 = ji, Wde = ut, Yn = We(), x2 = pa, Is = Qe(), T2 = $n, W5 = ha, Xde = na, Vl = Xt, X5 = Gi, Y5 = Kq, P2 = ga, UM;
(function(e) {
  function r(f, d) {
    f && (f.state.visible = d);
  }
  e.setVisibility = r;
  function t(f, d) {
    f && (f.state.alphaFactor = d);
  }
  e.setAlphaFactor = t;
  function n(f, d) {
    f && (f.state.pickable = d);
  }
  e.setPickable = n;
  function a(f, d) {
    f && (f.state.colorOnly = d);
  }
  e.setColorOnly = a;
  function i(f, d, m, p, v) {
    if (!f || (0, Kh.isEmptyLoci)(d))
      return !1;
    var h = f.values, y = h.tMarker, C = h.uMarker, S = h.markerAverage, b = h.markerStatus, g = h.uGroupCount, _ = h.instanceCount, A = g.ref.value * _.ref.value, M = y.ref.value.array, P = b.ref.value;
    if (!(0, Kh.isEveryLoci)(d)) {
      var T = 0;
      if (p(d, function(B) {
        return T += Is.Interval.size(B), !0;
      }, !0), T === 0)
        return !1;
      T === A && (d = Kh.EveryLoci);
    }
    var x = !1, w = -1, E = -1;
    if ((0, Kh.isEveryLoci)(d)) {
      var I = (0, gm.getMarkerInfo)(m, P);
      I.status !== -1 ? (x = P !== I.status, x && (0, gm.setMarkerValue)(M, I.status, A)) : x = (0, gm.applyMarkerAction)(M, Is.Interval.ofLength(A), m), w = I.average, E = I.status;
    } else
      x = p(d, function(B) {
        return (0, gm.applyMarkerAction)(M, B, m);
      }, !0), x && (w = (0, gm.getPartialMarkerAverage)(m, P), v && v.status !== -1 && w === -1 && gm.MarkerActions.isReverse(v.action, m) && Kh.Loci.areEqual(d, v.loci) && (E = v.status, w = E === 0 ? 0 : 0.5));
    return x && (w === -1 && (w = (0, Xde.getMarkersAverage)(M, A), w === 0 && (E = 0)), v && (v.action = m, v.loci = d, v.status = P), Yn.ValueCell.updateIfChanged(C, E), E === -1 && Yn.ValueCell.update(y, y.ref.value), Yn.ValueCell.updateIfChanged(S, w), Yn.ValueCell.updateIfChanged(b, E)), x;
  }
  e.mark = i;
  function o(f, d, m, p, v) {
    if (f) {
      var h = f.values, y = h.tOverpaint, C = h.dOverpaintType, S = h.dOverpaint, b = h.uGroupCount, g = h.instanceCount, _ = b.ref.value * g.ref.value;
      (0, x2.createOverpaint)(d.layers.length ? _ : 0, f.values);
      var A = y.ref.value.array;
      p && (0, x2.clearOverpaint)(A, 0, _);
      for (var M = function(V, k) {
        var G = d.layers[V], L = G.loci, R = G.color, F = G.clear, U = function(H) {
          var q = Is.Interval.start(H), K = Is.Interval.end(H);
          return F ? (0, x2.clearOverpaint)(A, q, K) : (0, x2.applyOverpaintColor)(A, q, K, R);
        };
        m(L, U, !1);
      }, P = 0, T = d.layers.length; P < T; ++P)
        M(P);
      if (Yn.ValueCell.update(y, y.ref.value), Yn.ValueCell.updateIfChanged(C, "groupInstance"), Yn.ValueCell.updateIfChanged(S, d.layers.length > 0), d.layers.length !== 0 && v && (0, Vl.hasColorSmoothingProp)(v.props)) {
        var x = v.geometry, w = v.props, E = v.webgl;
        if (x.kind === "mesh") {
          var I = x.meta, B = I.resolution, D = I.overpaintTexture, N = (0, Vl.getColorSmoothingProps)(w.smoothColors, !0, B);
          N && ((0, X5.applyMeshOverpaintSmoothing)(f.values, N.resolution, N.stride, E, D), x.meta.overpaintTexture = f.values.tOverpaintGrid.ref.value);
        } else if (E && x.kind === "texture-mesh") {
          var O = x.meta, B = O.resolution, D = O.overpaintTexture, N = (0, Vl.getColorSmoothingProps)(w.smoothColors, !0, B);
          N && ((0, Y5.applyTextureMeshOverpaintSmoothing)(f.values, N.resolution, N.stride, E, D), x.meta.overpaintTexture = f.values.tOverpaintGrid.ref.value);
        }
      }
    }
  }
  e.setOverpaint = o;
  function c(f, d, m, p, v) {
    if (f) {
      var h = f.values, y = h.tTransparency, C = h.dTransparencyType, S = h.transparencyAverage, b = h.dTransparency, g = h.uGroupCount, _ = h.instanceCount, A = g.ref.value * _.ref.value;
      (0, T2.createTransparency)(d.layers.length ? A : 0, f.values);
      var M = y.ref.value.array;
      p && (0, T2.clearTransparency)(M, 0, A);
      for (var P = function(k, G) {
        var L = d.layers[k], R = L.loci, F = L.value, U = function(H) {
          var q = Is.Interval.start(H), K = Is.Interval.end(H);
          return (0, T2.applyTransparencyValue)(M, q, K, F);
        };
        m(R, U, !1);
      }, T = 0, x = d.layers.length; T < x; ++T)
        P(T);
      if (Yn.ValueCell.update(y, y.ref.value), Yn.ValueCell.updateIfChanged(S, (0, T2.getTransparencyAverage)(M, A)), Yn.ValueCell.updateIfChanged(C, "groupInstance"), Yn.ValueCell.updateIfChanged(b, d.layers.length > 0), d.layers.length !== 0 && v && (0, Vl.hasColorSmoothingProp)(v.props)) {
        var w = v.geometry, E = v.props, I = v.webgl;
        if (w.kind === "mesh") {
          var B = w.meta, D = B.resolution, N = B.transparencyTexture, O = (0, Vl.getColorSmoothingProps)(E.smoothColors, !0, D);
          O && ((0, X5.applyMeshTransparencySmoothing)(f.values, O.resolution, O.stride, I, N), w.meta.transparencyTexture = f.values.tTransparencyGrid.ref.value);
        } else if (I && w.kind === "texture-mesh") {
          var V = w.meta, D = V.resolution, N = V.transparencyTexture, O = (0, Vl.getColorSmoothingProps)(E.smoothColors, !0, D);
          O && ((0, Y5.applyTextureMeshTransparencySmoothing)(f.values, O.resolution, O.stride, I, N), w.meta.transparencyTexture = f.values.tTransparencyGrid.ref.value);
        }
      }
    }
  }
  e.setTransparency = c;
  function s(f, d, m, p, v) {
    if (f) {
      var h = f.values, y = h.tSubstance, C = h.dSubstanceType, S = h.dSubstance, b = h.uGroupCount, g = h.instanceCount, _ = b.ref.value * g.ref.value;
      (0, P2.createSubstance)(d.layers.length ? _ : 0, f.values);
      var A = y.ref.value.array;
      p && (0, P2.clearSubstance)(A, 0, _);
      for (var M = function(V, k) {
        var G = d.layers[V], L = G.loci, R = G.material, F = G.clear, U = function(H) {
          var q = Is.Interval.start(H), K = Is.Interval.end(H);
          return F ? (0, P2.clearSubstance)(A, q, K) : (0, P2.applySubstanceMaterial)(A, q, K, R);
        };
        m(L, U, !1);
      }, P = 0, T = d.layers.length; P < T; ++P)
        M(P);
      if (Yn.ValueCell.update(y, y.ref.value), Yn.ValueCell.updateIfChanged(C, "groupInstance"), Yn.ValueCell.updateIfChanged(S, d.layers.length > 0), d.layers.length !== 0 && v && (0, Vl.hasColorSmoothingProp)(v.props)) {
        var x = v.geometry, w = v.props, E = v.webgl;
        if (x.kind === "mesh") {
          var I = x.meta, B = I.resolution, D = I.substanceTexture, N = (0, Vl.getColorSmoothingProps)(w.smoothColors, !0, B);
          N && ((0, X5.applyMeshSubstanceSmoothing)(f.values, N.resolution, N.stride, E, D), x.meta.substanceTexture = f.values.tSubstanceGrid.ref.value);
        } else if (E && x.kind === "texture-mesh") {
          var O = x.meta, B = O.resolution, D = O.substanceTexture, N = (0, Vl.getColorSmoothingProps)(w.smoothColors, !0, B);
          N && ((0, Y5.applyTextureMeshSubstanceSmoothing)(f.values, N.resolution, N.stride, E, D), x.meta.substanceTexture = f.values.tSubstanceGrid.ref.value);
        }
      }
    }
  }
  e.setSubstance = s;
  function u(f, d, m, p) {
    if (f) {
      var v = f.values, h = v.tClipping, y = v.dClipping, C = v.uGroupCount, S = v.instanceCount, b = C.ref.value * S.ref.value, g = d.layers;
      (0, W5.createClipping)(g.length ? b : 0, f.values);
      var _ = h.ref.value.array;
      p && (0, W5.clearClipping)(_, 0, b);
      for (var A = function(T, x) {
        var w = d.layers[T], E = w.loci, I = w.groups, B = function(D) {
          var N = Is.Interval.start(D), O = Is.Interval.end(D);
          return (0, W5.applyClippingGroups)(_, N, O, I);
        };
        m(E, B, !1);
      }, M = 0, P = d.layers.length; M < P; ++M)
        A(M);
      Yn.ValueCell.update(h, h.ref.value), Yn.ValueCell.updateIfChanged(y, d.layers.length > 0);
    }
  }
  e.setClipping = u;
  function l(f, d, m) {
    if (!(!f || !d && !m)) {
      var p = f.values;
      d && (Kde.Mat4.copy(p.matrix.ref.value, d), Yn.ValueCell.update(p.matrix, p.matrix.ref.value)), m ? (p.extraTransform.ref.value.set(m), Yn.ValueCell.update(p.extraTransform, p.extraTransform.ref.value)) : m === null && ((0, w9.fillIdentityTransform)(p.extraTransform.ref.value, p.instanceCount.ref.value), Yn.ValueCell.update(p.extraTransform, p.extraTransform.ref.value)), (0, w9.updateTransformData)(p);
      var v = (0, Wde.calculateTransformBoundingSphere)(p.invariantBoundingSphere.ref.value, p.aTransform.ref.value, p.instanceCount.ref.value);
      Yn.ValueCell.update(p.boundingSphere, v);
    }
  }
  e.setTransform = l;
})(UM || (UM = {}));
gl.Visual = UM;
var z0 = {};
Object.defineProperty(z0, "__esModule", { value: !0 });
z0.Clipping = void 0;
var Yde = _r, ko = Je(), Qde = wc, E9 = We();
function qb(e) {
  return { layers: e };
}
z0.Clipping = qb;
(function(e) {
  e.Empty = { layers: [] }, function(u) {
    u.is = E9.BitFlags.has;
    function l(v) {
      return E9.BitFlags.create(v);
    }
    u.create = l, u.Names = {
      one: 1,
      two: 2,
      three: 4,
      four: 8,
      five: 16,
      six: 32
      /* Six */
    };
    function f(v) {
      return v in u.Names;
    }
    u.isName = f;
    function d(v) {
      switch (v) {
        case "one":
          return 1;
        case "two":
          return 2;
        case "three":
          return 4;
        case "four":
          return 8;
        case "five":
          return 16;
        case "six":
          return 32;
      }
    }
    u.fromName = d;
    function m(v) {
      for (var h = 0, y = 0, C = v.length; y < C; ++y)
        h |= d(v[y]);
      return h;
    }
    u.fromNames = m;
    function p(v) {
      var h = [];
      return u.is(
        v,
        1
        /* One */
      ) && h.push("one"), u.is(
        v,
        2
        /* Two */
      ) && h.push("two"), u.is(
        v,
        4
        /* Three */
      ) && h.push("three"), u.is(
        v,
        8
        /* Four */
      ) && h.push("four"), u.is(
        v,
        16
        /* Five */
      ) && h.push("five"), u.is(
        v,
        32
        /* Six */
      ) && h.push("six"), h;
    }
    u.toNames = p;
  }(e.Groups || (e.Groups = {}));
  function r(u, l) {
    if (u.layers.length !== l.layers.length)
      return !1;
    for (var f = 0, d = u.layers.length; f < d; ++f)
      if (u.layers[f].groups !== l.layers[f].groups || !Yde.Loci.areEqual(u.layers[f].loci, l.layers[f].loci))
        return !1;
    return !0;
  }
  e.areEqual = r;
  function t(u) {
    return u.layers.length === 0;
  }
  e.isEmpty = t;
  function n(u, l) {
    for (var f = [], d = 0, m = u.layers; d < m.length; d++) {
      var p = m[d], v = p.loci, h = p.groups;
      v = ko.StructureElement.Loci.remap(v, l), ko.StructureElement.Loci.isEmpty(v) || f.push({ loci: v, groups: h });
    }
    return { layers: f };
  }
  e.remap = n;
  function a(u) {
    if (t(u))
      return u;
    for (var l = u.layers[0].loci.structure, f = /* @__PURE__ */ new Map(), d = ko.StructureElement.Loci.none(l), m = 0, p = u.layers.length; m < p; ++m) {
      var v = u.layers[p - m - 1], h = v.loci, y = v.groups;
      h = ko.StructureElement.Loci.subtract(h, d), d = ko.StructureElement.Loci.union(h, d), ko.StructureElement.Loci.isEmpty(h) || (f.has(y) && (h = ko.StructureElement.Loci.union(h, f.get(y))), f.set(y, h));
    }
    var C = [];
    return f.forEach(function(S, b) {
      C.push({ loci: S, groups: b });
    }), { layers: C };
  }
  e.merge = a;
  function i(u, l) {
    if (t(u))
      return u;
    for (var f = u.layers[0].loci.structure, d = [], m = 0, p = u.layers; m < p.length; m++) {
      var v = p[m], h = v.loci, y = v.groups, C = ko.StructureElement.Loci.remap(h, l);
      h = ko.StructureElement.Loci.remap(C, f), ko.StructureElement.Loci.isEmpty(h) || d.push({ loci: h, groups: y });
    }
    return { layers: d };
  }
  e.filter = i;
  function o(u, l) {
    for (var f = [], d = 0, m = u.length; d < m; ++d) {
      var p = u[d], v = p.script, h = p.groups, y = Qde.Script.toLoci(v, l);
      ko.StructureElement.Loci.isEmpty(y) || f.push({ loci: y, groups: h });
    }
    return { layers: f };
  }
  e.ofScript = o;
  function c(u, l) {
    for (var f = [], d = 0, m = u.length; d < m; ++d) {
      var p = u[d], v = p.bundle, h = p.groups, y = ko.StructureElement.Bundle.toLoci(v, l.root);
      f.push({ loci: y, groups: h });
    }
    return { layers: f };
  }
  e.ofBundle = c;
  function s(u) {
    for (var l = [], f = 0, d = u.layers.length; f < d; ++f) {
      var m = u.layers[f], p = m.loci, v = m.groups, h = ko.StructureElement.Bundle.fromLoci(p);
      l.push({ bundle: h, groups: v });
    }
    return { layers: l };
  }
  e.toBundle = s;
})(qb || (qb = {}));
z0.Clipping = qb;
var G0 = {};
Object.defineProperty(G0, "__esModule", { value: !0 });
G0.Substance = void 0;
var Zde = _r, eo = Je(), Jde = wc, efe = u4, rfe = nn;
function Hb(e) {
  return { layers: e };
}
G0.Substance = Hb;
(function(e) {
  e.Empty = { layers: [] };
  function r(u, l) {
    if (u.layers.length === 0 && l.layers.length === 0)
      return !0;
    if (u.layers.length !== l.layers.length)
      return !1;
    for (var f = 0, d = u.layers.length; f < d; ++f)
      if (u.layers[f].clear !== l.layers[f].clear || !(0, rfe.shallowEqual)(u.layers[f].material, l.layers[f].material) || !Zde.Loci.areEqual(u.layers[f].loci, l.layers[f].loci))
        return !1;
    return !0;
  }
  e.areEqual = r;
  function t(u) {
    return u.layers.length === 0;
  }
  e.isEmpty = t;
  function n(u, l) {
    for (var f = [], d = 0, m = u.layers; d < m.length; d++) {
      var p = m[d], v = p.loci, h = p.material, y = p.clear;
      v = eo.StructureElement.Loci.remap(v, l), eo.StructureElement.Loci.isEmpty(v) || f.push({ loci: v, material: h, clear: y });
    }
    return { layers: f };
  }
  e.remap = n;
  function a(u) {
    if (t(u))
      return u;
    for (var l = u.layers[0].loci.structure, f = void 0, d = /* @__PURE__ */ new Map(), m = eo.StructureElement.Loci.none(l), p = 0, v = u.layers.length; p < v; ++p) {
      var h = u.layers[v - p - 1], y = h.loci, C = h.material, S = h.clear;
      y = eo.StructureElement.Loci.subtract(y, m), m = eo.StructureElement.Loci.union(y, m), eo.StructureElement.Loci.isEmpty(y) || (S ? f = f ? eo.StructureElement.Loci.union(y, f) : y : (d.has(C) && (y = eo.StructureElement.Loci.union(y, d.get(C))), d.set(C, y)));
    }
    var b = [];
    return f && b.push({ loci: f, material: (0, efe.Material)(), clear: !0 }), d.forEach(function(g, _) {
      b.push({ loci: g, material: _, clear: !1 });
    }), { layers: b };
  }
  e.merge = a;
  function i(u, l) {
    if (t(u))
      return u;
    for (var f = u.layers[0].loci.structure, d = [], m = 0, p = u.layers; m < p.length; m++) {
      var v = p[m], h = v.loci, y = v.material, C = v.clear, S = eo.StructureElement.Loci.remap(h, l);
      h = eo.StructureElement.Loci.remap(S, f), eo.StructureElement.Loci.isEmpty(h) || d.push({ loci: h, material: y, clear: C });
    }
    return { layers: d };
  }
  e.filter = i;
  function o(u, l) {
    for (var f = [], d = 0, m = u.length; d < m; ++d) {
      var p = u[d], v = p.script, h = p.material, y = p.clear, C = Jde.Script.toLoci(v, l);
      eo.StructureElement.Loci.isEmpty(C) || f.push({ loci: C, material: h, clear: y });
    }
    return { layers: f };
  }
  e.ofScript = o;
  function c(u, l) {
    for (var f = [], d = 0, m = u.length; d < m; ++d) {
      var p = u[d], v = p.bundle, h = p.material, y = p.clear, C = eo.StructureElement.Bundle.toLoci(v, l.root);
      f.push({ loci: C, material: h, clear: y });
    }
    return { layers: f };
  }
  e.ofBundle = c;
  function s(u) {
    for (var l = [], f = 0, d = u.layers.length; f < d; ++f) {
      var m = u.layers[f], p = m.loci, v = m.material, h = m.clear, y = eo.StructureElement.Bundle.fromLoci(p);
      l.push({ bundle: y, material: v, clear: h });
    }
    return { layers: l };
  }
  e.toBundle = s;
})(Hb || (Hb = {}));
G0.Substance = Hb;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Representation = e.RepresentationRegistry = e.EmptyRepresentationProvider = e.RepresentationProvider = void 0;
  var r = Te, t = Le, n = Np(), a = _y(), i = Pc(), o = cl, c = Kr, s = _n, u = _r, l = k0, f = U0, d = Re, m = Vp, p = Xt, v = gl, h = z0, y = ds, C = wr(), S = G0;
  (function(A) {
    function M(P, T, x) {
      return t.ParamDefinition.getDefaultValues(P.getParams(T, x));
    }
    A.getDetaultParams = M;
  })(e.RepresentationProvider || (e.RepresentationProvider = {})), e.EmptyRepresentationProvider = {
    name: "",
    label: "",
    description: "",
    factory: function() {
      return _.Empty;
    },
    getParams: function() {
      return {};
    },
    defaultValues: {},
    defaultColorTheme: n.ColorTheme.EmptyProvider,
    defaultSizeTheme: a.SizeTheme.EmptyProvider,
    isApplicable: function() {
      return !0;
    }
  };
  function b(A) {
    return A.map(function(M) {
      return [M.name, M.provider.label];
    });
  }
  var g = (
    /** @class */
    function() {
      function A() {
        this._list = [], this._map = /* @__PURE__ */ new Map(), this._name = /* @__PURE__ */ new Map();
      }
      return Object.defineProperty(A.prototype, "default", {
        get: function() {
          return this._list[0];
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(A.prototype, "types", {
        get: function() {
          return b(this._list);
        },
        enumerable: !1,
        configurable: !0
      }), A.prototype.add = function(M) {
        if (this._map.has(M.name))
          throw new Error("".concat(M.name, " already registered."));
        this._list.push({ name: M.name, provider: M }), this._map.set(M.name, M), this._name.set(M, M.name);
      }, A.prototype.getName = function(M) {
        if (!this._name.has(M))
          throw new Error("'".concat(M.label, "' is not a registered represenatation provider."));
        return this._name.get(M);
      }, A.prototype.remove = function(M) {
        var P = M.name;
        this._list.splice(this._list.findIndex(function(x) {
          return x.name === P;
        }), 1);
        var T = this._map.get(P);
        T && (this._map.delete(P), this._name.delete(T));
      }, A.prototype.get = function(M) {
        return this._map.get(M) || e.EmptyRepresentationProvider;
      }, Object.defineProperty(A.prototype, "list", {
        get: function() {
          return this._list;
        },
        enumerable: !1,
        configurable: !0
      }), A.prototype.getApplicableList = function(M) {
        return this._list.filter(function(P) {
          return P.provider.isApplicable(M);
        });
      }, A.prototype.getApplicableTypes = function(M) {
        return b(this.getApplicableList(M));
      }, A;
    }()
  );
  e.RepresentationRegistry = g;
  var _;
  (function(A) {
    (function(E) {
      function I(D, N) {
        return D.repr === N.repr && u.Loci.areEqual(D.loci, N.loci);
      }
      E.areEqual = I;
      function B(D) {
        return u.Loci.isEmpty(D.loci);
      }
      E.isEmpty = B, E.Empty = { loci: u.EmptyLoci };
    })(A.Loci || (A.Loci = {}));
    function M() {
      return {
        visible: !0,
        alphaFactor: 1,
        pickable: !0,
        colorOnly: !1,
        syncManually: !1,
        transform: d.Mat4.identity(),
        overpaint: l.Overpaint.Empty,
        transparency: f.Transparency.Empty,
        substance: S.Substance.Empty,
        clipping: h.Clipping.Empty,
        markerActions: s.MarkerActions.All
      };
    }
    A.createState = M;
    function P(E, I) {
      I.visible !== void 0 && (E.visible = I.visible), I.alphaFactor !== void 0 && (E.alphaFactor = I.alphaFactor), I.pickable !== void 0 && (E.pickable = I.pickable), I.colorOnly !== void 0 && (E.colorOnly = I.colorOnly), I.overpaint !== void 0 && (E.overpaint = I.overpaint), I.transparency !== void 0 && (E.transparency = I.transparency), I.substance !== void 0 && (E.substance = I.substance), I.clipping !== void 0 && (E.clipping = I.clipping), I.syncManually !== void 0 && (E.syncManually = I.syncManually), I.transform !== void 0 && d.Mat4.copy(E.transform, I.transform), I.markerActions !== void 0 && (E.markerActions = I.markerActions);
    }
    A.updateState = P, A.StateBuilder = {
      create: M,
      update: P
    }, A.Empty = {
      label: "",
      groupCount: 0,
      renderObjects: [],
      geometryVersion: -1,
      props: {},
      params: {},
      updated: new o.Subject(),
      state: M(),
      theme: i.Theme.createEmpty(),
      createOrUpdate: function() {
        return c.Task.constant("", void 0);
      },
      setState: function() {
      },
      setTheme: function() {
      },
      getLoci: function() {
        return u.EmptyLoci;
      },
      mark: function() {
        return !1;
      },
      destroy: function() {
      }
    };
    var T = (
      /** @class */
      function() {
        function E() {
          this.curr = /* @__PURE__ */ new Set(), this.next = /* @__PURE__ */ new Set(), this._version = -1;
        }
        return Object.defineProperty(E.prototype, "version", {
          get: function() {
            return this._version;
          },
          enumerable: !1,
          configurable: !0
        }), E.prototype.add = function(I, B) {
          this.next.add((0, C.cantorPairing)(I, B));
        }, E.prototype.snapshot = function() {
          var I;
          y.SetUtils.areEqual(this.curr, this.next) || (this._version += 1), I = [this.next, this.curr], this.curr = I[0], this.next = I[1], this.next.clear();
        }, E;
      }()
    );
    A.GeometryState = T;
    function x(E, I, B, D, N) {
      var O = this, V = 0, k = new o.Subject(), G = new T(), L = D.create(), R = i.Theme.createEmpty(), F, U, H, q = {}, K = Object.keys(N).map(function(Y, X) {
        q[X] = Y;
        var Z = N[Y](I, B);
        return Z.setState(L), Z;
      });
      return {
        label: E,
        updated: k,
        get groupCount() {
          var Y = 0;
          if (U)
            for (var X = U.visuals, Z = 0, J = K.length; Z < J; ++Z)
              (!X || X.includes(q[Z])) && (Y += K[Z].groupCount);
          return Y;
        },
        get renderObjects() {
          var Y = [];
          if (U)
            for (var X = U.visuals, Z = 0, J = K.length; Z < J; ++Z)
              (!X || X.includes(q[Z])) && Y.push.apply(Y, K[Z].renderObjects);
          return Y;
        },
        get geometryVersion() {
          return G.version;
        },
        get props() {
          return U;
        },
        get params() {
          return F;
        },
        createOrUpdate: function(Y, X) {
          Y === void 0 && (Y = {}), X && X !== H && (F = B(I, X), H = X, U || (U = t.ParamDefinition.getDefaultValues(F))), U || (U = {});
          var Z = (0, m.getQualityProps)(Object.assign({}, U || {}, Y || {}), H);
          Object.assign(U, Y || {}, Z || {});
          var J = U.visuals;
          return c.Task.create("Creating or updating '".concat(E, "' representation"), function($) {
            return (0, r.__awaiter)(O, void 0, void 0, function() {
              var Q, W;
              return (0, r.__generator)(this, function(te) {
                switch (te.label) {
                  case 0:
                    Q = 0, W = K.length, te.label = 1;
                  case 1:
                    return Q < W ? !J || J.includes(q[Q]) ? [4, K[Q].createOrUpdate(U, H).runInContext($)] : [3, 3] : [3, 5];
                  case 2:
                    te.sent(), te.label = 3;
                  case 3:
                    G.add(Q, K[Q].geometryVersion), te.label = 4;
                  case 4:
                    return ++Q, [3, 1];
                  case 5:
                    return G.snapshot(), k.next(V++), [
                      2
                      /*return*/
                    ];
                }
              });
            });
          });
        },
        get state() {
          return L;
        },
        get theme() {
          return R;
        },
        getLoci: function(Y) {
          for (var X = U.visuals, Z = 0, J = K.length; Z < J; ++Z)
            if (!X || X.includes(q[Z])) {
              var $ = K[Z].getLoci(Y);
              if (!(0, u.isEmptyLoci)($))
                return $;
            }
          return u.EmptyLoci;
        },
        mark: function(Y, X) {
          for (var Z = !1, J = 0, $ = K.length; J < $; ++J)
            Z = K[J].mark(Y, X) || Z;
          return Z;
        },
        setState: function(Y) {
          D.update(L, Y);
          for (var X = 0, Z = K.length; X < Z; ++X)
            K[X].setState(Y);
          k.next(V++);
        },
        setTheme: function(Y) {
          R = Y;
          for (var X = 0, Z = K.length; X < Z; ++X)
            K[X].setTheme(Y);
        },
        destroy: function() {
          for (var Y = 0, X = K.length; Y < X; ++Y)
            K[Y].destroy();
        }
      };
    }
    A.createMulti = x;
    function w(E, I) {
      var B = this, D = 0, N = new o.Subject(), O = new T(), V = A.createState(), k = i.Theme.createEmpty(), G = t.ParamDefinition.clone(p.BaseGeometry.Params), L = t.ParamDefinition.getDefaultValues(p.BaseGeometry.Params);
      return {
        label: E,
        updated: N,
        get groupCount() {
          return I.values.uGroupCount.ref.value;
        },
        get renderObjects() {
          return [I];
        },
        get geometryVersion() {
          return O.version;
        },
        get props() {
          return L;
        },
        get params() {
          return G;
        },
        createOrUpdate: function(R) {
          R === void 0 && (R = {});
          var F = (0, m.getQualityProps)(Object.assign({}, L, R));
          return Object.assign(L, R, F), c.Task.create("Updating '".concat(E, "' representation"), function(U) {
            return (0, r.__awaiter)(B, void 0, void 0, function() {
              return (0, r.__generator)(this, function(H) {
                return O.add(0, I.id), O.snapshot(), N.next(D++), [
                  2
                  /*return*/
                ];
              });
            });
          });
        },
        get state() {
          return V;
        },
        get theme() {
          return k;
        },
        getLoci: function() {
          return u.EmptyLoci;
        },
        mark: function(R, F) {
          return !1;
        },
        setState: function(R) {
          R.visible !== void 0 && v.Visual.setVisibility(I, R.visible), R.alphaFactor !== void 0 && v.Visual.setAlphaFactor(I, R.alphaFactor), R.pickable !== void 0 && v.Visual.setPickable(I, R.pickable), R.colorOnly !== void 0 && v.Visual.setColorOnly(I, R.colorOnly), R.overpaint, R.transparency, R.substance, R.transform !== void 0 && v.Visual.setTransform(I, R.transform), A.updateState(V, R);
        },
        setTheme: function() {
        },
        destroy: function() {
        }
      };
    }
    A.fromRenderObject = w;
  })(_ || (_ = {})), e.Representation = _;
})(Wt);
var q0 = {}, Wq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Object3D = void 0;
  var r = Re;
  (function(t) {
    function n() {
      return {
        view: r.Mat4.identity(),
        position: r.Vec3.create(0, 0, 0),
        direction: r.Vec3.create(0, 0, -1),
        up: r.Vec3.create(0, 1, 0)
      };
    }
    t.create = n;
    var a = r.Vec3.zero();
    function i(o) {
      r.Vec3.add(a, o.position, o.direction), r.Mat4.lookAt(o.view, o.position, a, o.up);
    }
    t.update = i;
  })(e.Object3D || (e.Object3D = {}));
})(Wq);
var h4 = {};
Object.defineProperty(h4, "__esModule", { value: !0 });
h4.CommitQueue = void 0;
var D9 = Po, tfe = (
  /** @class */
  function() {
    function e() {
      this.removeList = (0, D9.LinkedList)(), this.removeMap = /* @__PURE__ */ new Map(), this.addList = (0, D9.LinkedList)(), 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(r) {
      if (this.removeMap.has(r)) {
        var t = this.removeMap.get(r);
        this.removeMap.delete(r), this.removeList.remove(t);
      }
      if (!this.addMap.has(r)) {
        var n = this.addList.addLast(r);
        this.addMap.set(r, n);
      }
    }, e.prototype.remove = function(r) {
      if (this.addMap.has(r)) {
        var t = this.addMap.get(r);
        this.addMap.delete(r), this.addList.remove(t);
      }
      if (!this.removeMap.has(r)) {
        var n = this.removeList.addLast(r);
        this.removeMap.set(r, n);
      }
    }, e.prototype.tryGetRemove = function() {
      var r = this.removeList.removeFirst();
      return r && this.removeMap.delete(r), r;
    }, e.prototype.tryGetAdd = function() {
      var r = this.addList.removeFirst();
      return r && this.addMap.delete(r), r;
    }, e;
  }()
);
h4.CommitQueue = tfe;
Object.defineProperty(q0, "__esModule", { value: !0 });
q0.Scene = void 0;
var nfe = Si, I9 = Wq, B9 = nr(), afe = h4, Q5 = Eu, Z5 = hr, ife = ys, ofe = wr(), ufe = Lt, Wh = new ife.BoundaryHelper("98");
function N9(e, r, t) {
  Wh.reset();
  for (var n = 0, a = e.length; n < a; ++n)
    if (!(t && !e[n].state.visible)) {
      var i = e[n].values.boundingSphere.ref.value;
      i.radius && Wh.includeSphere(i);
    }
  Wh.finishedIncludeStep();
  for (var n = 0, a = e.length; n < a; ++n)
    if (!(t && !e[n].state.visible)) {
      var o = e[n].values.boundingSphere.ref.value;
      o.radius && Wh.radiusSphere(o);
    }
  return Wh.getSphere(r);
}
function sfe(e, r) {
  var t = (e.getProgram("colorBlended") || e.getProgram("colorWboit")).id, n = (r.getProgram("colorBlended") || e.getProgram("colorWboit")).id, a = e.materialId, i = r.materialId;
  return t !== n ? t - n : a !== i ? a - i : e.id - r.id;
}
var zM;
(function(e) {
  function r(t, n) {
    n === void 0 && (n = ufe.GraphicsRenderVariants);
    var a = /* @__PURE__ */ new Map(), i = [], o = (0, B9.Sphere3D)(), c = (0, B9.Sphere3D)(), s = [], u = [], l = !0, f = !0, d = I9.Object3D.create(), m = d.view, p = d.position, v = d.direction, h = d.up;
    function y(P) {
      if (a.has(P))
        return console.warn("RenderObject with id '".concat(P.id, "' already present")), a.get(P);
      var T = (0, nfe.createRenderable)(t, P, n);
      return i.push(T), P.type === "direct-volume" ? u.push(T) : s.push(T), a.set(P, T), l = !0, f = !0, T;
    }
    function C(P) {
      var T = a.get(P);
      T && (T.dispose(), (0, Z5.arraySetRemove)(i, T), (0, Z5.arraySetRemove)(s, T), (0, Z5.arraySetRemove)(u, T), a.delete(P), l = !0, f = !0);
    }
    var S = 100;
    function b(P) {
      for (var T = (0, Q5.now)(), x = 0; ; ) {
        var w = g.tryGetRemove();
        if (!w)
          break;
        if (C(w), ++x % S === 0 && (0, Q5.now)() - T > P)
          return !1;
      }
      for (; ; ) {
        var w = g.tryGetAdd();
        if (!w)
          break;
        if (y(w), ++x % S === 0 && (0, Q5.now)() - T > P)
          return !1;
      }
      return i.sort(sfe), !0;
    }
    var g = new afe.CommitQueue(), _ = -1;
    function A() {
      for (var P = 23, T = 0, x = i.length; T < x; ++T)
        i[T].state.visible && (P = 31 * P + i[T].id | 0);
      return P = (0, ofe.hash1)(P), P === -1 && (P = 0), P;
    }
    function M() {
      var P = A();
      return P !== _ ? (f = !0, !0) : !1;
    }
    return {
      view: m,
      position: p,
      direction: v,
      up: h,
      renderables: i,
      primitives: { view: m, position: p, direction: v, up: h, renderables: s },
      volumes: { view: m, position: p, direction: v, up: h, renderables: u },
      syncVisibility: M,
      update: function(P, T) {
        var x;
        if (I9.Object3D.update(d), P)
          for (var w = 0, E = P.length; w < E; ++w)
            (x = a.get(P[w])) === null || x === void 0 || x.update();
        else
          for (var w = 0, E = i.length; w < E; ++w)
            i[w].update();
        T ? M() : (l = !0, f = !0);
      },
      add: function(P) {
        return g.add(P);
      },
      remove: function(P) {
        return g.remove(P);
      },
      commit: function(P) {
        return P === void 0 && (P = Number.MAX_VALUE), b(P);
      },
      get needsCommit() {
        return !g.isEmpty;
      },
      has: function(P) {
        return a.has(P);
      },
      clear: function() {
        for (var P = 0, T = i.length; P < T; ++P)
          i[P].dispose();
        i.length = 0, a.clear(), l = !0, f = !0;
      },
      forEach: function(P) {
        a.forEach(P);
      },
      get count() {
        return i.length;
      },
      get boundingSphere() {
        return l && (N9(i, o, !1), l = !1), o;
      },
      get boundingSphereVisible() {
        return f && (N9(i, c, !0), f = !1, _ = A()), c;
      },
      getMarkerAverage: function() {
        if (s.length === 0 && u.length === 0)
          return 0;
        for (var P = 0, T = 0, x = s.length; T < x; ++T)
          P += s[T].values.markerAverage.ref.value;
        for (var T = 0, x = u.length; T < x; ++T)
          P += u[T].values.markerAverage.ref.value;
        return P / (s.length + u.length);
      }
    };
  }
  e.create = r;
})(zM || (zM = {}));
q0.Scene = zM;
var ym = {}, _m = {}, V9;
function lfe() {
  if (V9) return _m;
  V9 = 1, Object.defineProperty(_m, "__esModule", { value: !0 }), _m.CameraTransitionManager = void 0;
  var e = Rp(), r = Re, t = Zr, n = (
    /** @class */
    function() {
      function a(i) {
        this.camera = i, this.t = 0, this.func = a.defaultTransition, this.start = 0, this.inTransition = !1, this.durationMs = 0, this._source = e.Camera.createDefaultSnapshot(), this._target = e.Camera.createDefaultSnapshot(), this._current = e.Camera.createDefaultSnapshot();
      }
      return Object.defineProperty(a.prototype, "source", {
        get: function() {
          return this._source;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(a.prototype, "target", {
        get: function() {
          return this._target;
        },
        enumerable: !1,
        configurable: !0
      }), a.prototype.apply = function(i, o, c) {
        if (o === void 0 && (o = 0), (!this.inTransition || o > 0) && e.Camera.copySnapshot(this._source, this.camera.state), this.inTransition || e.Camera.copySnapshot(this._target, this.camera.state), e.Camera.copySnapshot(this._target, i), 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 && o <= 0 || typeof i.mode < "u" && i.mode !== this.camera.state.mode) {
          this.finish(this._target);
          return;
        }
        this.inTransition = !0, this.func = c || a.defaultTransition, (!this.inTransition || o > 0) && (this.start = this.t, this.durationMs = o);
      }, a.prototype.tick = function(i) {
        this.t = i, this.update();
      }, a.prototype.finish = function(i) {
        e.Camera.copySnapshot(this.camera.state, i), this.inTransition = !1;
      }, a.prototype.update = function() {
        if (this.inTransition) {
          var i = Math.min((this.t - this.start) / this.durationMs, 1);
          if (i === 1) {
            this.finish(this._target);
            return;
          }
          this.func(this._current, i, this._source, this._target), e.Camera.copySnapshot(this.camera.state, this._current);
        }
      }, a;
    }()
  );
  return _m.CameraTransitionManager = n, function(a) {
    var i = r.Quat.identity();
    function o(c, s, u, l) {
      e.Camera.copySnapshot(c, l), r.Quat.slerp(i, r.Quat.Identity, r.Quat.rotationTo(i, u.up, l.up), s), r.Vec3.transformQuat(c.up, u.up, i), r.Vec3.lerp(c.target, u.target, l.target, s), r.Vec3.lerp(c.position, u.position, l.position, s), c.radius = (0, t.lerp)(u.radius, l.radius, s), c.radiusMax = (0, t.lerp)(u.radiusMax, l.radiusMax, s), c.fov = (0, t.lerp)(u.fov, l.fov, s), c.fog = (0, t.lerp)(u.fog, l.fog, s);
    }
    a.defaultTransition = o;
  }(n || (n = {})), _m.CameraTransitionManager = n, _m;
}
var R9;
function Rp() {
  if (R9) return ym;
  R9 = 1, Object.defineProperty(ym, "__esModule", { value: !0 }), ym.Camera = void 0;
  var e = Re, r = ri, t = lfe(), n = cl, a = Ft, i = (0, e.Vec3)(), o = (0, e.Vec3)(), c = (0, e.Vec4)(), s = (
    /** @class */
    function() {
      function d(m, p, v) {
        p === void 0 && (p = r.Viewport.create(0, 0, 128, 128)), v === void 0 && (v = {}), this.view = e.Mat4.identity(), this.projection = e.Mat4.identity(), this.projectionView = e.Mat4.identity(), this.inverseProjectionView = e.Mat4.identity(), this.state = d.createDefaultSnapshot(), this.viewOffset = d.ViewOffset(), this.near = 1, this.far = 1e4, this.fogNear = 5e3, this.fogFar = 1e4, this.zoom = 1, this.transition = new t.CameraTransitionManager(this), this.stateChanged = new n.BehaviorSubject(this.state), this.prevProjection = e.Mat4.identity(), this.prevView = e.Mat4.identity(), this.deltaDirection = (0, e.Vec3)(), this.newPosition = (0, e.Vec3)(), this.viewport = p, this.pixelScale = v.pixelScale || 1, d.copySnapshot(this.state, m);
      }
      return Object.defineProperty(d.prototype, "pixelRatio", {
        get: function() {
          var m = typeof window < "u" ? window.devicePixelRatio : 1;
          return m * this.pixelScale;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(d.prototype, "position", {
        get: function() {
          return this.state.position;
        },
        set: function(m) {
          e.Vec3.copy(this.state.position, m);
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(d.prototype, "up", {
        get: function() {
          return this.state.up;
        },
        set: function(m) {
          e.Vec3.copy(this.state.up, m);
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(d.prototype, "target", {
        get: function() {
          return this.state.target;
        },
        set: function(m) {
          e.Vec3.copy(this.state.target, m);
        },
        enumerable: !1,
        configurable: !0
      }), d.prototype.update = function() {
        var m = this.state;
        if (m.radiusMax === 0)
          return !1;
        var p = 2 * Math.tan(m.fov / 2) * e.Vec3.distance(m.position, m.target);
        switch (this.zoom = this.viewport.height / p, f(this), this.state.mode) {
          case "orthographic":
            u(this);
            break;
          case "perspective":
            l(this);
            break;
          default:
            (0, a.assertUnreachable)(this.state.mode);
        }
        var v = !e.Mat4.areEqual(this.projection, this.prevProjection, e.EPSILON) || !e.Mat4.areEqual(this.view, this.prevView, e.EPSILON);
        if (v) {
          if (e.Mat4.mul(this.projectionView, this.projection, this.view), !e.Mat4.tryInvert(this.inverseProjectionView, this.projectionView))
            return e.Mat4.copy(this.view, this.prevView), e.Mat4.copy(this.projection, this.prevProjection), e.Mat4.mul(this.projectionView, this.projection, this.view), !1;
          e.Mat4.copy(this.prevView, this.view), e.Mat4.copy(this.prevProjection, this.projection);
        }
        return v;
      }, d.prototype.setState = function(m, p) {
        !Number.isNaN(m.radius) && m.radius <= 0.01 || (this.transition.apply(m, p), this.stateChanged.next(m));
      }, d.prototype.getSnapshot = function() {
        return d.copySnapshot(d.createDefaultSnapshot(), this.state);
      }, d.prototype.getTargetDistance = function(m) {
        return d.targetDistance(m, this.state.fov, this.viewport.width, this.viewport.height);
      }, d.prototype.getFocus = function(m, p, v, h) {
        var y = Math.max(p, 0.01), C = this.getTargetDistance(y);
        e.Vec3.sub(this.deltaDirection, this.target, this.position), h && e.Vec3.matchDirection(this.deltaDirection, h, this.deltaDirection), e.Vec3.setMagnitude(this.deltaDirection, this.deltaDirection, C), e.Vec3.sub(this.newPosition, m, this.deltaDirection);
        var S = d.copySnapshot(d.createDefaultSnapshot(), this.state);
        return S.target = e.Vec3.clone(m), S.radius = y, S.position = e.Vec3.clone(this.newPosition), v && e.Vec3.matchDirection(S.up, v, S.up), S;
      }, d.prototype.getInvariantFocus = function(m, p, v, h) {
        var y = Math.max(p, 0.01), C = this.getTargetDistance(y);
        e.Vec3.copy(this.deltaDirection, h), e.Vec3.setMagnitude(this.deltaDirection, this.deltaDirection, C), e.Vec3.sub(this.newPosition, m, this.deltaDirection);
        var S = d.copySnapshot(d.createDefaultSnapshot(), this.state);
        return S.target = e.Vec3.clone(m), S.radius = y, S.position = e.Vec3.clone(this.newPosition), e.Vec3.copy(S.up, v), S;
      }, d.prototype.focus = function(m, p, v, h, y) {
        p > 0 && this.setState(this.getFocus(m, p, h, y), v);
      }, d.prototype.project = function(m, p) {
        return (0, r.cameraProject)(m, p, this.viewport, this.projectionView);
      }, d.prototype.unproject = function(m, p) {
        return (0, r.cameraUnproject)(m, p, this.viewport, this.inverseProjectionView);
      }, d.prototype.getPixelSize = function(m) {
        return this.project(c, m), this.unproject(i, c), c[0] += 1, this.unproject(o, c), e.Vec3.distance(i, o);
      }, d;
    }()
  );
  ym.Camera = s, function(d) {
    function m() {
      return {
        enabled: !1,
        fullWidth: 1,
        fullHeight: 1,
        offsetX: 0,
        offsetY: 0,
        width: 1,
        height: 1
      };
    }
    d.ViewOffset = m;
    function p(b, g, _, A, M, P, T) {
      b.fullWidth = g, b.fullHeight = _, b.offsetX = A, b.offsetY = M, b.width = P, b.height = T;
    }
    d.setViewOffset = p;
    function v(b, g) {
      b.enabled = g.enabled, b.fullWidth = g.fullWidth, b.fullHeight = g.fullHeight, b.offsetX = g.offsetX, b.offsetY = g.offsetY, b.width = g.width, b.height = g.height;
    }
    d.copyViewOffset = v;
    function h(b, g, _, A) {
      var M = Math.max(b, 0.01), P = _ / A, T = A < _ ? 1 : P;
      return Math.abs(M / T / Math.sin(g / 2));
    }
    d.targetDistance = h;
    function y() {
      return {
        mode: "orthographic",
        fov: Math.PI / 4,
        position: e.Vec3.create(0, 0, 100),
        up: e.Vec3.create(0, 1, 0),
        target: e.Vec3.create(0, 0, 0),
        radius: 0,
        radiusMax: 10,
        fog: 50,
        clipFar: !0
      };
    }
    d.createDefaultSnapshot = y;
    function C(b, g) {
      return g && (typeof g.mode < "u" && (b.mode = g.mode), typeof g.fov < "u" && (b.fov = g.fov), typeof g.position < "u" && e.Vec3.copy(b.position, g.position), typeof g.up < "u" && e.Vec3.copy(b.up, g.up), typeof g.target < "u" && e.Vec3.copy(b.target, g.target), typeof g.radius < "u" && (b.radius = g.radius), typeof g.radiusMax < "u" && (b.radiusMax = g.radiusMax), typeof g.fog < "u" && (b.fog = g.fog), typeof g.clipFar < "u" && (b.clipFar = g.clipFar)), b;
    }
    d.copySnapshot = C;
    function S(b, g) {
      return b.mode === g.mode && b.fov === g.fov && b.radius === g.radius && b.radiusMax === g.radiusMax && b.fog === g.fog && b.clipFar === g.clipFar && e.Vec3.exactEquals(b.position, g.position) && e.Vec3.exactEquals(b.up, g.up) && e.Vec3.exactEquals(b.target, g.target);
    }
    d.areSnapshotsEqual = S;
  }(s || (s = {})), ym.Camera = s;
  function u(d) {
    var m = d.viewport, p = d.zoom, v = d.near, h = d.far, y = d.viewOffset, C = -m.width / 2, S = m.width / 2, b = m.height / 2, g = -m.height / 2, _ = (S - C) / (2 * p), A = (b - g) / (2 * p), M = (S + C) / 2, P = (b + g) / 2, T = M - _, x = M + _, w = P + A, E = P - A;
    if (y.enabled) {
      var I = p / (y.width / y.fullWidth), B = p / (y.height / y.fullHeight), D = (S - C) / y.width, N = (b - g) / y.height;
      T += D * (y.offsetX / I), x = T + D * (y.width / I), w -= N * (y.offsetY / B), E = w - N * (y.height / B);
    }
    e.Mat4.ortho(d.projection, T, x, w, E, v, h), e.Mat4.lookAt(d.view, d.position, d.target, d.up);
  }
  function l(d) {
    var m = d.viewport.width / d.viewport.height, p = d.near, v = d.far, h = d.viewOffset, y = p * Math.tan(0.5 * d.state.fov), C = 2 * y, S = m * C, b = -0.5 * S;
    h.enabled && (b += h.offsetX * S / h.fullWidth, y -= h.offsetY * C / h.fullHeight, S *= h.width / h.fullWidth, C *= h.height / h.fullHeight), e.Mat4.perspective(d.projection, b, b + S, y, y - C, p, v), e.Mat4.lookAt(d.view, d.position, d.target, d.up);
  }
  function f(d) {
    var m = d.state, p = m.radius, v = m.radiusMax, h = m.mode, y = m.fog, C = m.clipFar;
    p < 0.01 && (p = 0.01);
    var S = C ? p : v, b = e.Vec3.distance(d.position, d.target), g = b - p, _ = b + S, A = -(50 - y) / 50, M = b - S * A, P = _;
    g = Math.max(Math.min(v, 5), g), _ = Math.max(5, _), g === _ && (_ = g + 0.01), d.near = g, d.far = 2 * _, d.fogNear = M, d.fogFar = P;
  }
  return ym;
}
var LE = {}, J5 = {}, Df = {}, vc = {}, Xq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Polyhedron = e.DefaultPolyhedronProps = void 0;
  var r = Te, t = Re, n = On;
  e.DefaultPolyhedronProps = {
    radius: 1,
    detail: 0
  };
  function a(o, c, s) {
    var u = (0, r.__assign)((0, r.__assign)({}, e.DefaultPolyhedronProps), s), l = u.radius, f = u.detail, d = i(), m = d.vertices, p = d.indices;
    h(f), (0, n.appplyRadius)(m, l);
    var v = new Float32Array(m.length);
    return (0, n.computeIndexedVertexNormals)(m, p, v, m.length / 3, p.length / 3), {
      vertices: new Float32Array(m),
      normals: new Float32Array(v),
      indices: new Uint32Array(p)
    };
    function h(C) {
      for (var S = (0, t.Vec3)(), b = (0, t.Vec3)(), g = (0, t.Vec3)(), _ = 0; _ < c.length; _ += 3)
        t.Vec3.fromArray(S, o, c[_ + 0] * 3), t.Vec3.fromArray(b, o, c[_ + 1] * 3), t.Vec3.fromArray(g, o, c[_ + 2] * 3), y(S, b, g, C);
    }
    function y(C, S, b, g) {
      for (var _ = Math.pow(2, g), A = [], M = 0; M <= _; ++M) {
        A[M] = [];
        var P = (0, t.Vec3)();
        t.Vec3.lerp(P, C, b, M / _);
        var T = (0, t.Vec3)();
        t.Vec3.lerp(T, S, b, M / _);
        for (var x = _ - M, w = 0; w <= x; ++w)
          if (w === 0 && M === _)
            A[M][w] = P;
          else {
            var E = (0, t.Vec3)();
            t.Vec3.lerp(E, P, T, w / x), A[M][w] = E;
          }
      }
      for (var M = 0; M < _; ++M)
        for (var w = 0; w < 2 * (_ - M) - 1; ++w) {
          var I = Math.floor(w / 2);
          w % 2 === 0 ? d.add(A[M][I + 1], A[M + 1][I], A[M][I]) : d.add(A[M][I + 1], A[M + 1][I + 1], A[M + 1][I]);
        }
    }
  }
  e.Polyhedron = a;
  function i() {
    var o = [], c = [], s = /* @__PURE__ */ new Map();
    function u(l) {
      var f = "".concat(l[0].toFixed(5), "|").concat(l[1].toFixed(5), "|").concat(l[2].toFixed(5)), d = s.get(f);
      return d === void 0 && (d = o.length / 3, s.set(f, d), o.push.apply(o, l)), d;
    }
    return {
      vertices: o,
      indices: c,
      add: function(l, f, d) {
        c.push(u(l), u(f), u(d));
      }
    };
  }
})(Xq);
var Fv = {};
Object.defineProperty(Fv, "__esModule", { value: !0 });
Fv.IcosahedronCage = Fv.Icosahedron = void 0;
var cfe = ya, dfe = wu, du = (1 + Math.sqrt(5)) / 2, Yq = [
  -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
], ffe = [
  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
], mfe = [
  0,
  11,
  5,
  11,
  0,
  5,
  1,
  5,
  0,
  1,
  1,
  7,
  0,
  7,
  7,
  10,
  0,
  10,
  10,
  11,
  5,
  9,
  4,
  11,
  2,
  10,
  6,
  7,
  1,
  8,
  3,
  9,
  4,
  9,
  3,
  4,
  2,
  4,
  2,
  3,
  2,
  6,
  3,
  6,
  6,
  8,
  3,
  8,
  8,
  9,
  4,
  5,
  2,
  11,
  6,
  10,
  7,
  8,
  1,
  9
], eT;
function vfe() {
  return eT || (eT = (0, cfe.createPrimitive)(Yq, ffe)), eT;
}
Fv.Icosahedron = vfe;
var pfe = (0, dfe.createCage)(Yq, mfe);
function hfe() {
  return pfe;
}
Fv.IcosahedronCage = hfe;
Object.defineProperty(vc, "__esModule", { value: !0 });
vc.Sphere = vc.sphereVertexCount = void 0;
var gfe = Xq, yfe = Fv, Qq = (0, yfe.Icosahedron)(), _fe = Qq.vertices, bfe = Qq.indices;
function Sfe(e) {
  return 10 * Math.pow(Math.pow(2, e), 2) + 2;
}
vc.sphereVertexCount = Sfe;
function Cfe(e) {
  return (0, gfe.Polyhedron)(_fe, bfe, { detail: e, radius: 1 });
}
vc.Sphere = Cfe;
var O9;
function Xd() {
  if (O9) return Df;
  O9 = 1, Object.defineProperty(Df, "__esModule", { value: !0 }), Df.addSphere = Df.getSphere = void 0;
  var e = Re, r = Ca(), t = vc, n = /* @__PURE__ */ new Map(), a = e.Mat4.identity();
  function i(s, u, l) {
    return e.Mat4.scaleUniformly(s, e.Mat4.fromTranslation(s, u), l);
  }
  function o(s) {
    var u = n.get(s);
    return u === void 0 && (u = (0, t.Sphere)(s), n.set(s, u)), u;
  }
  Df.getSphere = o;
  function c(s, u, l, f) {
    r.MeshBuilder.addPrimitive(s, i(a, u, l), o(f));
  }
  return Df.addSphere = c, Df;
}
var ku = {}, Zq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Cylinder = e.DefaultCylinderProps = void 0;
  var r = Te, t = Re;
  e.DefaultCylinderProps = {
    radiusTop: 1,
    radiusBottom: 1,
    height: 1,
    radialSegments: 8,
    heightSegments: 1,
    topCap: !1,
    bottomCap: !1,
    thetaStart: 0,
    thetaLength: Math.PI * 2
  };
  function n(a) {
    var i = (0, r.__assign)((0, r.__assign)({}, e.DefaultCylinderProps), a), o = i.radiusTop, c = i.radiusBottom, s = i.height, u = i.radialSegments, l = i.heightSegments, f = i.topCap, d = i.bottomCap, m = i.thetaStart, p = i.thetaLength, v = [], h = [], y = [], C = 0, S = [], b = s / 2;
    return g(), f && o > 0 && _(!0), d && c > 0 && _(!1), {
      vertices: new Float32Array(h),
      normals: new Float32Array(y),
      indices: new Uint32Array(v)
    };
    function g() {
      for (var A = t.Vec3.zero(), M = (c - o) / s, P = 0; P <= l; ++P) {
        for (var T = [], x = P / l, w = x * (c - o) + o, E = 0; E <= u; ++E) {
          var I = E / u, B = I * p + m, D = Math.sin(B), N = Math.cos(B);
          h.push(w * D, -x * s + b, w * N), t.Vec3.normalize(A, t.Vec3.set(A, D, M, N)), y.push.apply(y, A), T.push(C++);
        }
        S.push(T);
      }
      for (var E = 0; E < u; ++E)
        for (var P = 0; P < l; ++P) {
          var O = S[P][E], V = S[P + 1][E], k = S[P + 1][E + 1], G = S[P][E + 1];
          v.push(O, V, G), v.push(V, k, G);
        }
    }
    function _(A) {
      for (var M = A === !0 ? o : c, P = A === !0 ? 1 : -1, T = C, x = 1; x <= u; ++x)
        h.push(0, b * P, 0), y.push(0, P, 0), ++C;
      for (var w = C, x = 0; x <= u; ++x) {
        var E = x / u, I = E * p + m, B = Math.cos(I), D = Math.sin(I);
        h.push(M * D, b * P, M * B), y.push(0, P, 0), ++C;
      }
      for (var x = 0; x < u; ++x) {
        var N = T + x, O = w + x;
        A === !0 ? v.push(O, O + 1, N) : v.push(O + 1, O, N);
      }
    }
  }
  e.Cylinder = n;
})(Zq);
var kE = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.HexagonalPrismCage = e.PentagonalPrismCage = e.DiamondPrismCage = e.PrismCage = e.HeptagonalPrism = e.ShiftedHexagonalPrism = e.HexagonalPrism = e.PentagonalPrism = e.DiamondPrism = e.Prism = e.DefaultPrismProps = void 0;
  var r = Te, t = Re, n = ya, a = $d, i = (0, t.Vec3)(), o = (0, t.Vec3)(), c = (0, t.Vec3)(), s = (0, t.Vec3)(), u = (0, t.Vec3)(), l = (0, t.Vec3)();
  e.DefaultPrismProps = {
    height: 1,
    topCap: !0,
    bottomCap: !0
  };
  function f(E, I) {
    var B = E.length / 3;
    if (B < 3)
      throw new Error("need at least 3 points to build a prism");
    var D = (0, r.__assign)((0, r.__assign)({}, e.DefaultPrismProps), I), N = D.height, O = D.topCap, V = D.bottomCap, k = B * 2, G = B * 4, L = (O ? 1 : 0) + (V ? 1 : 0);
    B === 3 ? (k += L, G += L * 3) : B === 4 ? (k += L * 2, G += L * 4) : (k += L * B, G += L * B * 3);
    var R = (0, n.PrimitiveBuilder)(k, G), F = N * 0.5;
    t.Vec3.set(i, 0, 0, -F), t.Vec3.set(o, 0, 0, F);
    for (var U = 0; U < B; ++U) {
      var H = (U + 1) % B;
      t.Vec3.set(c, E[U * 3], E[U * 3 + 1], -F), t.Vec3.set(s, E[H * 3], E[H * 3 + 1], -F), t.Vec3.set(u, E[H * 3], E[H * 3 + 1], F), t.Vec3.set(l, E[U * 3], E[U * 3 + 1], F), R.addQuad(c, s, u, l);
    }
    if (B === 3)
      O && (t.Vec3.set(c, E[0], E[1], -F), t.Vec3.set(s, E[3], E[4], -F), t.Vec3.set(u, E[6], E[7], -F), R.add(u, s, c)), V && (t.Vec3.set(c, E[0], E[1], F), t.Vec3.set(s, E[3], E[4], F), t.Vec3.set(u, E[6], E[7], F), R.add(c, s, u));
    else if (B === 4)
      O && (t.Vec3.set(c, E[0], E[1], -F), t.Vec3.set(s, E[3], E[4], -F), t.Vec3.set(u, E[6], E[7], -F), t.Vec3.set(l, E[9], E[10], -F), R.addQuad(l, u, s, c)), V && (t.Vec3.set(c, E[0], E[1], F), t.Vec3.set(s, E[3], E[4], F), t.Vec3.set(u, E[6], E[7], F), t.Vec3.set(l, E[9], E[10], F), R.addQuad(c, s, u, l));
    else
      for (var U = 0; U < B; ++U) {
        var H = (U + 1) % B;
        O && (t.Vec3.set(c, E[U * 3], E[U * 3 + 1], -F), t.Vec3.set(s, E[H * 3], E[H * 3 + 1], -F), R.add(i, s, c)), V && (t.Vec3.set(c, E[U * 3], E[U * 3 + 1], F), t.Vec3.set(s, E[H * 3], E[H * 3 + 1], F), R.add(c, s, o));
      }
    return R.getPrimitive();
  }
  e.Prism = f;
  var d;
  function m() {
    return d || (d = f((0, a.polygon)(4, !1))), d;
  }
  e.DiamondPrism = m;
  var p;
  function v() {
    return p || (p = f((0, a.polygon)(5, !1))), p;
  }
  e.PentagonalPrism = v;
  var h;
  function y() {
    return h || (h = f((0, a.polygon)(6, !1))), h;
  }
  e.HexagonalPrism = y;
  var C;
  function S() {
    return C || (C = f((0, a.polygon)(6, !0))), C;
  }
  e.ShiftedHexagonalPrism = S;
  var b;
  function g() {
    return b || (b = f((0, a.polygon)(7, !1))), b;
  }
  e.HeptagonalPrism = g;
  function _(E, I) {
    I === void 0 && (I = 1);
    for (var B = E.length / 3, D = [], N = [], O = I * 0.5, V = 0, k = 0; k < B; ++k)
      D.push(E[k * 3], E[k * 3 + 1], -O, E[k * 3], E[k * 3 + 1], O), N.push(V, V + 1), V += 2;
    for (var k = 0; k < B; ++k) {
      var G = (k + 1) % B;
      N.push(k * 2, G * 2, k * 2 + 1, G * 2 + 1);
    }
    return { vertices: D, edges: N };
  }
  e.PrismCage = _;
  var A;
  function M() {
    return A || (A = _((0, a.polygon)(4, !1))), A;
  }
  e.DiamondPrismCage = M;
  var P;
  function T() {
    return P || (P = _((0, a.polygon)(5, !1))), P;
  }
  e.PentagonalPrismCage = T;
  var x;
  function w() {
    return x || (x = _((0, a.polygon)(6, !1))), x;
  }
  e.HexagonalPrismCage = w;
})(kE);
var F9;
function Yd() {
  if (F9) return ku;
  F9 = 1, Object.defineProperty(ku, "__esModule", { value: !0 }), ku.addFixedCountDashedCylinder = ku.addDoubleCylinder = ku.addCylinder = ku.addSimpleCylinder = void 0;
  var e = Re, r = Ca(), t = ya, n = Zq, a = kE, i = $d, o = wr(), c = /* @__PURE__ */ new Map(), s = e.Vec3.create(0, 1, 0), u = (0, e.Vec3)(), l = (0, e.Vec3)(), f = (0, e.Vec3)(), d = (0, e.Mat4)(), m = (0, e.Mat4)(), p = (0, e.Vec3)(), v = (0, e.Vec3)(), h = (0, e.Vec3)();
  function y(P, T, x, w, E) {
    return e.Vec3.setMagnitude(l, x, w / 2), e.Vec3.add(f, T, l), E ? e.Vec3.matchDirection(h, s, l) : e.Vec3.copy(h, s), e.Vec3.set(p, 1, w, 1), e.Vec3.makeRotation(m, h, l), e.Mat4.scale(P, m, p), e.Mat4.setTranslation(P, f);
  }
  var C = new Int32Array(9);
  function S(P) {
    var T, x, w, E, I, B, D, N, O;
    return C[0] = Math.round(1e3 * ((T = P.radiusTop) !== null && T !== void 0 ? T : n.DefaultCylinderProps.radiusTop)), C[1] = Math.round(1e3 * ((x = P.radiusBottom) !== null && x !== void 0 ? x : n.DefaultCylinderProps.radiusBottom)), C[2] = Math.round(1e3 * ((w = P.height) !== null && w !== void 0 ? w : n.DefaultCylinderProps.height)), C[3] = (E = P.radialSegments) !== null && E !== void 0 ? E : n.DefaultCylinderProps.radialSegments, C[4] = (I = P.heightSegments) !== null && I !== void 0 ? I : n.DefaultCylinderProps.heightSegments, C[5] = ((B = P.topCap) !== null && B !== void 0 ? B : n.DefaultCylinderProps.topCap) ? 1 : 0, C[6] = ((D = P.bottomCap) !== null && D !== void 0 ? D : n.DefaultCylinderProps.bottomCap) ? 1 : 0, C[7] = Math.round(1e3 * ((N = P.thetaStart) !== null && N !== void 0 ? N : n.DefaultCylinderProps.thetaStart)), C[8] = Math.round(1e3 * ((O = P.thetaLength) !== null && O !== void 0 ? O : n.DefaultCylinderProps.thetaLength)), (0, o.hashFnv32a)(C);
  }
  function b(P) {
    var T = S(P), x = c.get(T);
    if (x === void 0) {
      if (P.radialSegments && P.radialSegments <= 4) {
        var w = Math.max(3, P.radialSegments), E = (0, a.Prism)((0, i.polygon)(w, !0, P.radiusTop), P);
        x = (0, t.transformPrimitive)(E, e.Mat4.rotX90);
      } else
        x = (0, n.Cylinder)(P);
      c.set(T, x);
    }
    return x;
  }
  function g(P, T, x, w) {
    var E = e.Vec3.distance(T, x);
    e.Vec3.sub(u, x, T), y(d, T, u, E, !1), r.MeshBuilder.addPrimitive(P, d, b(w));
  }
  ku.addSimpleCylinder = g;
  function _(P, T, x, w, E) {
    var I = e.Vec3.distance(T, x) * w;
    e.Vec3.sub(u, x, T), y(d, T, u, I, !0), r.MeshBuilder.addPrimitive(P, d, b(E));
  }
  ku.addCylinder = _;
  function A(P, T, x, w, E, I) {
    var B = e.Vec3.distance(T, x) * w, D = b(I);
    e.Vec3.sub(u, x, T), e.Vec3.add(v, T, E), y(d, v, u, B, !0), r.MeshBuilder.addPrimitive(P, d, D), e.Vec3.sub(v, T, E), y(d, v, u, B, !0), r.MeshBuilder.addPrimitive(P, d, D);
  }
  ku.addDoubleCylinder = A;
  function M(P, T, x, w, E, I) {
    var B = Math.floor(E / 2), D = 1 / E;
    if (w < 1) {
      var N = w / 2 / E;
      w += E % 2 === 1 ? N : -N;
    }
    var O = e.Vec3.distance(T, x) * w, V = b(I);
    e.Vec3.sub(u, x, T);
    for (var k = 0; k < B; ++k) {
      var G = D * (k * 2 + 1);
      e.Vec3.setMagnitude(u, u, O * G), e.Vec3.add(v, T, u), y(d, v, u, O * D, !1), r.MeshBuilder.addPrimitive(P, d, V);
    }
  }
  return ku.addFixedCountDashedCylinder = M, ku;
}
var L9;
function Ca() {
  return L9 || (L9 = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.MeshBuilder = void 0;
    var r = Re, t = wr(), n = Dt(), a = Xd(), i = Yd(), o = (0, r.Vec3)(), c = (0, r.Mat3)(), s = (0, r.Vec3)(), u = (0, r.Vec3)(), l = (0, r.Vec3)(), f = (0, r.Vec3)(), d = r.Vec3.fromArray, m = r.Vec3.triangleNormal, p = r.Vec3.copy, v = r.Vec3.transformMat4, h = r.Vec3.transformMat3, y = r.Mat3.directionTransform, C = t.ChunkedArray.add3, S = t.ChunkedArray.add;
    (function(b) {
      function g(I, B, D) {
        return I === void 0 && (I = 2048), B === void 0 && (B = 1024), {
          currentGroup: -1,
          vertices: t.ChunkedArray.create(Float32Array, 3, B, D ? D.vertexBuffer.ref.value : I),
          normals: t.ChunkedArray.create(Float32Array, 3, B, D ? D.normalBuffer.ref.value : I),
          indices: t.ChunkedArray.create(Uint32Array, 3, B * 3, D ? D.indexBuffer.ref.value : I * 3),
          groups: t.ChunkedArray.create(Float32Array, 1, B, D ? D.groupBuffer.ref.value : I),
          mesh: D
        };
      }
      b.createState = g;
      function _(I, B, D, N) {
        var O = I.vertices, V = I.normals, k = I.indices, G = I.groups, L = I.currentGroup, R = O.elementCount;
        C(O, B[0], B[1], B[2]), C(O, D[0], D[1], D[2]), C(O, N[0], N[1], N[2]), m(o, B, D, N);
        for (var F = 0; F < 3; ++F)
          C(V, o[0], o[1], o[2]), S(G, L);
        C(k, R, R + 1, R + 2);
      }
      b.addTriangle = _;
      function A(I, B, D) {
        d(l, B, D[0] * 3), d(f, B, D[1] * 3);
        for (var N = 2, O = D.length; N < O; N += 2)
          p(s, l), p(u, f), d(l, B, D[N] * 3), d(f, B, D[N + 1] * 3), _(I, s, u, l), _(I, u, f, l);
      }
      b.addTriangleStrip = A;
      function M(I, B, D) {
        d(s, B, D[0] * 3);
        for (var N = 2, O = D.length; N < O; ++N)
          d(u, B, D[N - 1] * 3), d(l, B, D[N] * 3), _(I, s, l, u);
      }
      b.addTriangleFan = M;
      function P(I, B, D) {
        for (var N = D.vertices, O = D.normals, V = D.indices, k = I.vertices, G = I.normals, L = I.indices, R = I.groups, F = I.currentGroup, U = k.elementCount, H = y(c, B), q = 0, K = N.length; q < K; q += 3)
          v(o, d(o, N, q), B), C(k, o[0], o[1], o[2]), h(o, d(o, O, q), H), C(G, o[0], o[1], o[2]), S(R, F);
        for (var q = 0, K = V.length; q < K; q += 3)
          C(L, V[q] + U, V[q + 1] + U, V[q + 2] + U);
      }
      b.addPrimitive = P;
      function T(I, B, D) {
        for (var N = D.vertices, O = D.normals, V = D.indices, k = I.vertices, G = I.normals, L = I.indices, R = I.groups, F = I.currentGroup, U = k.elementCount, H = y(c, B), q = 0, K = N.length; q < K; q += 3)
          v(o, d(o, N, q), B), C(k, o[0], o[1], o[2]), h(o, d(o, O, q), H), C(G, -o[0], -o[1], -o[2]), S(R, F);
        for (var q = 0, K = V.length; q < K; q += 3)
          C(L, V[q + 2] + U, V[q + 1] + U, V[q] + U);
      }
      b.addPrimitiveFlipped = T;
      function x(I, B, D, N, O, V) {
        for (var k = D.vertices, G = D.edges, L = { radiusTop: N, radiusBottom: N, radialSegments: V }, R = 0, F = G.length; R < F; R += 2)
          d(s, k, G[R] * 3), d(u, k, G[R + 1] * 3), v(s, s, B), v(u, u, B), (0, a.addSphere)(I, s, N, O), (0, a.addSphere)(I, u, N, O), (0, i.addCylinder)(I, s, u, 1, L);
      }
      b.addCage = x;
      function w(I, B, D) {
        P(I, B, {
          vertices: D.vertexBuffer.ref.value.subarray(0, D.vertexCount * 3),
          normals: D.normalBuffer.ref.value.subarray(0, D.vertexCount * 3),
          indices: D.indexBuffer.ref.value.subarray(0, D.triangleCount * 3)
        });
      }
      b.addMesh = w;
      function E(I) {
        var B = I.vertices, D = I.normals, N = I.indices, O = I.groups, V = I.mesh, k = t.ChunkedArray.compact(B, !0), G = t.ChunkedArray.compact(N, !0), L = t.ChunkedArray.compact(D, !0), R = t.ChunkedArray.compact(O, !0);
        return n.Mesh.create(k, G, L, R, I.vertices.elementCount, I.indices.elementCount, V);
      }
      b.getMesh = E;
    })(e.MeshBuilder || (e.MeshBuilder = {}));
  }(J5)), J5;
}
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.BoundingSphereHelper = e.DebugHelperParams = void 0;
  var r = Te, t = Si, n = Ca(), a = Xd(), i = Dt(), o = Le, c = q0, s = nr(), u = Oa, l = vc, f = We(), d = Kd(), m = Lt;
  e.DebugHelperParams = {
    sceneBoundingSpheres: o.ParamDefinition.Boolean(!1, { description: "Show full scene bounding spheres." }),
    visibleSceneBoundingSpheres: o.ParamDefinition.Boolean(!1, { description: "Show visible scene bounding spheres." }),
    objectBoundingSpheres: o.ParamDefinition.Boolean(!1, { description: "Show bounding spheres of visible render objects." }),
    instanceBoundingSpheres: o.ParamDefinition.Boolean(!1, { description: "Show bounding spheres of visible instances." })
  };
  var p = (
    /** @class */
    function() {
      function _(A, M, P) {
        this.objectsData = /* @__PURE__ */ new Map(), this.instancesData = /* @__PURE__ */ new Map(), this.scene = c.Scene.create(A, m.GraphicsRenderVariantsBlended), this.parent = M, this._props = (0, r.__assign)((0, r.__assign)({}, o.ParamDefinition.getDefaultValues(e.DebugHelperParams)), P);
      }
      return _.prototype.update = function() {
        var A = this, M = v(this.scene, this.parent.boundingSphere, this.sceneData, u.ColorNames.lightgrey, y);
        M && (this.sceneData = M);
        var P = v(this.scene, this.parent.boundingSphereVisible, this.visibleSceneData, u.ColorNames.black, C);
        P && (this.visibleSceneData = P), this.parent.forEach(function(T, x) {
          var w = A.objectsData.get(x), E = v(A.scene, T.values.boundingSphere.ref.value, w, u.ColorNames.tomato, S);
          E && A.objectsData.set(x, E);
          var I = A.instancesData.get(x), B = v(A.scene, T.values.invariantBoundingSphere.ref.value, I, u.ColorNames.skyblue, b, {
            aTransform: x.values.aTransform,
            matrix: x.values.matrix,
            transform: x.values.transform,
            extraTransform: x.values.extraTransform,
            uInstanceCount: x.values.uInstanceCount,
            instanceCount: x.values.instanceCount,
            aInstance: x.values.aInstance,
            hasReflection: x.values.hasReflection
          });
          B && A.instancesData.set(x, B);
        }), this.objectsData.forEach(function(T, x) {
          A.parent.has(x) || (A.scene.remove(T.renderObject), A.objectsData.delete(x));
        }), this.instancesData.forEach(function(T, x) {
          A.parent.has(x) || (A.scene.remove(T.renderObject), A.instancesData.delete(x));
        }), this.scene.update(void 0, !1), this.scene.commit();
      }, _.prototype.syncVisibility = function() {
        var A = 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(M, P) {
          var T = A.objectsData.get(P);
          T && (T.renderObject.state.visible = P.state.visible && A._props.objectBoundingSpheres);
          var x = A.instancesData.get(P);
          x && (x.renderObject.state.visible = P.state.visible && A._props.instanceBoundingSpheres);
        });
      }, _.prototype.clear = function() {
        this.sceneData = void 0, this.objectsData.clear(), this.scene.clear();
      }, Object.defineProperty(_.prototype, "isEnabled", {
        get: function() {
          return this._props.sceneBoundingSpheres || this._props.visibleSceneBoundingSpheres || this._props.objectBoundingSpheres || this._props.instanceBoundingSpheres;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(_.prototype, "props", {
        get: function() {
          return this._props;
        },
        enumerable: !1,
        configurable: !0
      }), _.prototype.setProps = function(A) {
        Object.assign(this._props, A), this.isEnabled && this.update();
      }, _;
    }()
  );
  e.BoundingSphereHelper = p;
  function v(_, A, M, P, T, x) {
    if (!M || !s.Sphere3D.equals(M.boundingSphere, A)) {
      var w = h(A, M && M.mesh), E = M ? M.renderObject : g(w, P, T, x);
      return M ? f.ValueCell.updateIfChanged(E.values.drawCount, d.Geometry.getDrawCount(w)) : _.add(E), { boundingSphere: s.Sphere3D.clone(A), renderObject: E, mesh: w };
    }
  }
  function h(_, A) {
    var M = 2, P = (0, l.sphereVertexCount)(M), T = n.MeshBuilder.createState(P, P / 2, A);
    if (_.radius && ((0, a.addSphere)(T, _.center, _.radius, M), s.Sphere3D.hasExtrema(_)))
      for (var x = 0, w = _.extrema; x < w.length; x++) {
        var E = w[x];
        (0, a.addSphere)(T, E, 1, 0);
      }
    return n.MeshBuilder.getMesh(T);
  }
  var y = (0, t.getNextMaterialId)(), C = (0, t.getNextMaterialId)(), S = (0, t.getNextMaterialId)(), b = (0, t.getNextMaterialId)();
  function g(_, A, M, P) {
    var T = i.Mesh.Utils.createValuesSimple(_, { alpha: 0.1, doubleSided: !1 }, A, 1, P);
    return (0, t.createRenderObject)("mesh", T, { disposed: !1, visible: !0, alphaFactor: 1, pickable: !1, colorOnly: !1, opaque: !1, writeDepth: !1 }, M);
  }
})(LE);
var Jq = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Canvas3dInteractionHelper = e.Canvas3dInteractionHelperParams = void 0;
  var r = Te, t = Wt, n = ey, a = Ti, i = Re, o = Le, c = Je(), s = (0, i.Vec3)(), u = (0, i.Vec3)(), l = (0, i.Vec3)();
  e.Canvas3dInteractionHelperParams = {
    maxFps: o.ParamDefinition.Numeric(30, { min: 10, max: 60, step: 10 }),
    preferAtomPixelPadding: o.ParamDefinition.Numeric(3, { min: 0, max: 20, step: 1 }, { description: "Number of extra pixels at which to prefer atoms over bonds." })
  };
  var f = (
    /** @class */
    function() {
      function d(m, p, v, h, y) {
        var C = this;
        y === void 0 && (y = {}), this.canvasIdentify = m, this.lociGetter = p, this.input = v, this.camera = h, this.ev = a.RxEventHelper.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 = t.Representation.Loci.Empty, this.prevT = 0, this.inside = !1, this.buttons = n.ButtonsType.create(0), this.button = n.ButtonsType.create(0), this.modifiers = n.ModifiersKeys.None, this.props = (0, r.__assign)((0, r.__assign)({}, o.ParamDefinition.getDefaultValues(e.Canvas3dInteractionHelperParams)), y), v.drag.subscribe(function(S) {
          var b = S.x, g = S.y, _ = S.buttons, A = S.button, M = S.modifiers;
          C.isInteracting = !0, C.drag(b, g, _, A, M);
        }), v.move.subscribe(function(S) {
          var b = S.x, g = S.y, _ = S.inside, A = S.buttons, M = S.button, P = S.modifiers;
          !_ || C.isInteracting || C.move(b, g, A, M, P);
        }), v.leave.subscribe(function() {
          C.leave();
        }), v.click.subscribe(function(S) {
          var b = S.x, g = S.y, _ = S.buttons, A = S.button, M = S.modifiers;
          C.outsideViewport(b, g) || C.click(b, g, _, A, M);
        }), v.interactionEnd.subscribe(function() {
          C.isInteracting = !1;
        }), v.modifiers.subscribe(function(S) {
          C.modify(S);
        });
      }
      return d.prototype.setProps = function(m) {
        Object.assign(this.props, m);
      }, d.prototype.identify = function(m, p) {
        var v = this.startX !== this.endX || this.startY !== this.endY;
        if (m === 2) {
          v && !this.outsideViewport(this.startX, this.startY) && (this.events.drag.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers, pageStart: i.Vec2.create(this.startX, this.startY), pageEnd: i.Vec2.create(this.endX, this.endY) }), this.startX = this.endX, this.startY = this.endY);
          return;
        }
        if (v) {
          var h = this.canvasIdentify(this.endX, this.endY);
          this.id = h == null ? void 0 : h.id, this.position = h == null ? void 0 : h.position, this.startX = this.endX, this.startY = this.endY;
        }
        if (m === 1) {
          var y = this.getLoci(this.id, this.position);
          this.events.click.next({ current: y, buttons: this.buttons, button: this.button, modifiers: this.modifiers, page: i.Vec2.create(this.endX, this.endY), position: this.position }), this.prevLoci = y;
          return;
        }
        if (!(!this.inside || this.currentIdentifyT !== p || !v || this.outsideViewport(this.endX, this.endY))) {
          var C = this.getLoci(this.id, this.position);
          this.events.hover.next({ current: C, buttons: this.buttons, button: this.button, modifiers: this.modifiers, page: i.Vec2.create(this.endX, this.endY), position: this.position }), this.prevLoci = C;
        }
      }, d.prototype.tick = function(m) {
        this.inside && m - this.prevT > 1e3 / this.props.maxFps && (this.prevT = m, this.currentIdentifyT = m, this.identify(this.isInteracting ? 2 : 0, m));
      }, d.prototype.leave = function() {
        this.inside = !1, t.Representation.Loci.isEmpty(this.prevLoci) || (this.prevLoci = t.Representation.Loci.Empty, this.events.hover.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers }));
      }, d.prototype.move = function(m, p, v, h, y) {
        this.inside = !0, this.buttons = v, this.button = h, this.modifiers = y, this.endX = m, this.endY = p;
      }, d.prototype.click = function(m, p, v, h, y) {
        this.endX = m, this.endY = p, this.buttons = v, this.button = h, this.modifiers = y, this.identify(1, 0);
      }, d.prototype.drag = function(m, p, v, h, y) {
        this.endX = m, this.endY = p, this.buttons = v, this.button = h, this.modifiers = y, this.identify(2, 0);
      }, d.prototype.modify = function(m) {
        n.ModifiersKeys.areEqual(m, this.modifiers) || (this.modifiers = m, this.events.hover.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers, page: i.Vec2.create(this.endX, this.endY), position: this.position }));
      }, d.prototype.outsideViewport = function(m, p) {
        var v = this, h = v.input, y = v.camera.viewport;
        return m *= h.pixelRatio, p *= h.pixelRatio, m > y.x + y.width || h.height - p > y.y + y.height || m < y.x || h.height - p < y.y;
      }, d.prototype.getLoci = function(m, p) {
        var v, h = this.lociGetter(m), y = h.repr, C = h.loci;
        if (p && y && c.Bond.isLoci(C) && C.bonds.length === 2) {
          var S = C.bonds[0], b = S.aUnit, g = S.aIndex;
          b.conformation.position(b.elements[g], s), i.Vec3.sub(l, this.camera.state.position, this.camera.state.target), i.Vec3.projectPointOnPlane(u, p, l, s);
          var _ = this.camera.getPixelSize(u), A = y.theme.size.size(C.bonds[0]) * ((v = y.props.sizeFactor) !== null && v !== void 0 ? v : 1);
          if (y.props.lineSizeAttenuation === !1 && (A *= _ / 2), A += this.props.preferAtomPixelPadding * _, i.Vec3.distance(u, s) < A)
            return { repr: y, loci: c.Bond.toFirstStructureElementLoci(C) };
        }
        return { repr: y, loci: C };
      }, d.prototype.dispose = function() {
        this.ev.dispose();
      }, d;
    }()
  );
  e.Canvas3dInteractionHelper = f;
})(Jq);
var rl = {}, g4 = {};
Object.defineProperty(g4, "__esModule", { value: !0 });
g4.outlines_frag = void 0;
g4.outlines_frag = `
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);
}
`;
var y4 = {};
Object.defineProperty(y4, "__esModule", { value: !0 });
y4.ssao_frag = void 0;
y4.ssao_frag = `
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);
}
`;
var _4 = {};
Object.defineProperty(_4, "__esModule", { value: !0 });
_4.ssaoBlur_frag = void 0;
_4.ssaoBlur_frag = `
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);
}
`;
var b4 = {};
Object.defineProperty(b4, "__esModule", { value: !0 });
b4.postprocessing_frag = void 0;
b4.postprocessing_frag = `
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;
}
`;
var Lv = {}, S4 = {};
Object.defineProperty(S4, "__esModule", { value: !0 });
S4.fxaa_frag = void 0;
S4.fxaa_frag = `
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);
}
`;
Object.defineProperty(Lv, "__esModule", { value: !0 });
Lv.FxaaPass = Lv.FxaaParams = void 0;
var K1 = Te, eH = Yi, Afe = Kt, bm = yn, xfe = Bn(), Tfe = Lt, rH = Re, Au = We(), M2 = Le, Pfe = Qi, Mfe = S4;
Lv.FxaaParams = {
  edgeThresholdMin: M2.ParamDefinition.Numeric(0.0312, { min: 0.0312, max: 0.0833, step: 1e-4 }, { description: "Trims the algorithm from processing darks." }),
  edgeThresholdMax: M2.ParamDefinition.Numeric(0.063, { min: 0.063, max: 0.333, step: 1e-3 }, { description: "The minimum amount of local contrast required to apply algorithm." }),
  iterations: M2.ParamDefinition.Numeric(12, { min: 0, max: 16, step: 1 }, { description: "Number of edge exploration steps." }),
  subpixelQuality: M2.ParamDefinition.Numeric(0.3, { min: 0, max: 1, step: 0.01 }, { description: "Choose the amount of sub-pixel aliasing removal." })
};
var wfe = (
  /** @class */
  function() {
    function e(r, t) {
      this.webgl = r, this.renderable = Ife(r, t);
    }
    return e.prototype.updateState = function(r) {
      var t = this.webgl, n = t.gl, a = t.state;
      a.enable(n.SCISSOR_TEST), a.disable(n.BLEND), a.disable(n.DEPTH_TEST), a.depthMask(!1);
      var i = r.x, o = r.y, c = r.width, s = r.height;
      n.viewport(i, o, c, s), n.scissor(i, o, c, s), a.clearColor(0, 0, 0, 1), n.clear(n.COLOR_BUFFER_BIT);
    }, e.prototype.setSize = function(r, t) {
      Au.ValueCell.update(this.renderable.values.uTexSizeInv, rH.Vec2.set(this.renderable.values.uTexSizeInv.ref.value, 1 / r, 1 / t));
    }, e.prototype.update = function(r, t) {
      var n = this.renderable.values, a = t.edgeThresholdMin, i = t.edgeThresholdMax, o = t.iterations, c = t.subpixelQuality, s = !1;
      n.tColor.ref.value !== r && (Au.ValueCell.update(this.renderable.values.tColor, r), s = !0), n.dEdgeThresholdMin.ref.value !== a && (s = !0), Au.ValueCell.updateIfChanged(n.dEdgeThresholdMin, a), n.dEdgeThresholdMax.ref.value !== i && (s = !0), Au.ValueCell.updateIfChanged(n.dEdgeThresholdMax, i), n.dIterations.ref.value !== o && (s = !0), Au.ValueCell.updateIfChanged(n.dIterations, o), n.dSubpixelQuality.ref.value !== c && (s = !0), Au.ValueCell.updateIfChanged(n.dSubpixelQuality, c), s && this.renderable.update();
    }, e.prototype.render = function(r, t) {
      t ? t.bind() : this.webgl.unbindFramebuffer(), this.updateState(r), this.renderable.render();
    }, e;
  }()
);
Lv.FxaaPass = wfe;
var Efe = (0, K1.__assign)((0, K1.__assign)({}, eH.QuadSchema), { tColor: (0, bm.TextureSpec)("texture", "rgba", "ubyte", "linear"), uTexSizeInv: (0, bm.UniformSpec)("v2"), dEdgeThresholdMin: (0, bm.DefineSpec)("number"), dEdgeThresholdMax: (0, bm.DefineSpec)("number"), dIterations: (0, bm.DefineSpec)("number"), dSubpixelQuality: (0, bm.DefineSpec)("number") }), Dfe = (0, xfe.ShaderCode)("fxaa", Pfe.quad_vert, Mfe.fxaa_frag);
function Ife(e, r) {
  var t = r.getWidth(), n = r.getHeight(), a = (0, K1.__assign)((0, K1.__assign)({}, eH.QuadValues), { tColor: Au.ValueCell.create(r), uTexSizeInv: Au.ValueCell.create(rH.Vec2.create(1 / t, 1 / n)), dEdgeThresholdMin: Au.ValueCell.create(0.0312), dEdgeThresholdMax: Au.ValueCell.create(0.125), dIterations: Au.ValueCell.create(12), dSubpixelQuality: Au.ValueCell.create(0.3) }), i = (0, K1.__assign)({}, Efe), o = (0, Tfe.createComputeRenderItem)(e, "triangles", Dfe, i, a);
  return (0, Afe.createComputeRenderable)(o, a);
}
var kv = {}, C4 = {};
Object.defineProperty(C4, "__esModule", { value: !0 });
C4.blend_vert = void 0;
C4.blend_vert = `
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);
}
`;
var A4 = {};
Object.defineProperty(A4, "__esModule", { value: !0 });
A4.blend_frag = void 0;
A4.blend_frag = `
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);
}
`;
var x4 = {};
Object.defineProperty(x4, "__esModule", { value: !0 });
x4.weights_vert = void 0;
x4.weights_vert = `
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);
}
`;
var T4 = {};
Object.defineProperty(T4, "__esModule", { value: !0 });
T4.weights_frag = void 0;
T4.weights_frag = `
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));
}
`;
var P4 = {};
Object.defineProperty(P4, "__esModule", { value: !0 });
P4.edges_vert = void 0;
P4.edges_vert = `
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);
}
`;
var M4 = {};
Object.defineProperty(M4, "__esModule", { value: !0 });
M4.edges_frag = void 0;
M4.edges_frag = `
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);
}
`;
Object.defineProperty(kv, "__esModule", { value: !0 });
kv.SmaaPass = kv.SmaaParams = void 0;
var $i = Te, Op = Yi, UE = Kt, co = yn, zE = Bn(), GE = Lt, w2 = ps(), rc = Re, vn = We(), k9 = Le, Bfe = C4, Nfe = A4, Vfe = x4, Rfe = T4, Ofe = P4, Ffe = M4, rT = ri, Lfe = Zt;
kv.SmaaParams = {
  edgeThreshold: k9.ParamDefinition.Numeric(0.1, { min: 0.05, max: 0.15, step: 0.01 }),
  maxSearchSteps: k9.ParamDefinition.Numeric(16, { min: 0, max: 32, step: 1 })
};
var kfe = (
  /** @class */
  function() {
    function e(r, t) {
      if (this.webgl = r, this._supported = !1, typeof HTMLImageElement > "u") {
        Lfe.isDebugMode && console.log('Missing "HTMLImageElement" required for "SMAA"');
        return;
      }
      var n = t.getWidth(), a = t.getHeight();
      this.edgesTarget = r.createRenderTarget(n, a, !1, "uint8", "linear"), this.weightsTarget = r.createRenderTarget(n, a, !1, "uint8", "linear"), this.edgesRenderable = Gfe(r, t), this.weightsRenderable = jfe(r, this.edgesTarget.texture), this.blendRenderable = Wfe(r, t, this.weightsTarget.texture), this._supported = !0;
    }
    return Object.defineProperty(e.prototype, "supported", {
      get: function() {
        return this._supported;
      },
      enumerable: !1,
      configurable: !0
    }), e.prototype.updateState = function(r) {
      var t = this.webgl, n = t.gl, a = t.state;
      a.enable(n.SCISSOR_TEST), a.disable(n.BLEND), a.disable(n.DEPTH_TEST), a.depthMask(!1);
      var i = r.x, o = r.y, c = r.width, s = r.height;
      n.viewport(i, o, c, s), n.scissor(i, o, c, s), a.clearColor(0, 0, 0, 1), n.clear(n.COLOR_BUFFER_BIT), vn.ValueCell.update(this.edgesRenderable.values.uViewport, rT.Viewport.toVec4(this.edgesRenderable.values.uViewport.ref.value, r)), vn.ValueCell.update(this.weightsRenderable.values.uViewport, rT.Viewport.toVec4(this.weightsRenderable.values.uViewport.ref.value, r)), vn.ValueCell.update(this.blendRenderable.values.uViewport, rT.Viewport.toVec4(this.blendRenderable.values.uViewport.ref.value, r));
    }, e.prototype.setSize = function(r, t) {
      var n = this.edgesTarget.getWidth(), a = this.edgesTarget.getHeight();
      (r !== n || t !== a) && (this.edgesTarget.setSize(r, t), this.weightsTarget.setSize(r, t), vn.ValueCell.update(this.edgesRenderable.values.uTexSizeInv, rc.Vec2.set(this.edgesRenderable.values.uTexSizeInv.ref.value, 1 / r, 1 / t)), vn.ValueCell.update(this.weightsRenderable.values.uTexSizeInv, rc.Vec2.set(this.weightsRenderable.values.uTexSizeInv.ref.value, 1 / r, 1 / t)), vn.ValueCell.update(this.blendRenderable.values.uTexSizeInv, rc.Vec2.set(this.blendRenderable.values.uTexSizeInv.ref.value, 1 / r, 1 / t)));
    }, e.prototype.update = function(r, t) {
      var n = !1;
      this.edgesRenderable.values.tColor.ref.value !== r && (vn.ValueCell.update(this.edgesRenderable.values.tColor, r), n = !0), this.edgesRenderable.values.dEdgeThreshold.ref.value !== t.edgeThreshold && (vn.ValueCell.update(this.edgesRenderable.values.dEdgeThreshold, t.edgeThreshold), n = !0), n && this.edgesRenderable.update(), this.weightsRenderable.values.dMaxSearchSteps.ref.value !== t.maxSearchSteps && (vn.ValueCell.update(this.weightsRenderable.values.dMaxSearchSteps, t.maxSearchSteps), this.weightsRenderable.update()), this.blendRenderable.values.tColor.ref.value !== r && (vn.ValueCell.update(this.blendRenderable.values.tColor, r), this.blendRenderable.update());
    }, e.prototype.render = function(r, t) {
      this.edgesTarget.bind(), this.updateState(r), this.edgesRenderable.render(), this.weightsTarget.bind(), this.updateState(r), this.weightsRenderable.render(), t ? t.bind() : this.webgl.unbindFramebuffer(), this.updateState(r), this.blendRenderable.render();
    }, e;
  }()
);
kv.SmaaPass = kfe;
var Ufe = (0, $i.__assign)((0, $i.__assign)({}, Op.QuadSchema), { tColor: (0, co.TextureSpec)("texture", "rgba", "ubyte", "linear"), uTexSizeInv: (0, co.UniformSpec)("v2"), uViewport: (0, co.UniformSpec)("v4"), dEdgeThreshold: (0, co.DefineSpec)("number") }), zfe = (0, zE.ShaderCode)("smaa-edges", Ofe.edges_vert, Ffe.edges_frag);
function Gfe(e, r) {
  var t = r.getWidth(), n = r.getHeight(), a = (0, $i.__assign)((0, $i.__assign)({}, Op.QuadValues), { tColor: vn.ValueCell.create(r), uTexSizeInv: vn.ValueCell.create(rc.Vec2.create(1 / t, 1 / n)), uViewport: vn.ValueCell.create((0, rc.Vec4)()), dEdgeThreshold: vn.ValueCell.create(0.1) }), i = (0, $i.__assign)({}, Ufe), o = (0, GE.createComputeRenderItem)(e, "triangles", zfe, i, a);
  return (0, UE.createComputeRenderable)(o, a);
}
var qfe = (0, $i.__assign)((0, $i.__assign)({}, Op.QuadSchema), { tEdges: (0, co.TextureSpec)("texture", "rgba", "ubyte", "linear"), tArea: (0, co.TextureSpec)("texture", "rgb", "ubyte", "linear"), tSearch: (0, co.TextureSpec)("texture", "rgba", "ubyte", "nearest"), uTexSizeInv: (0, co.UniformSpec)("v2"), uViewport: (0, co.UniformSpec)("v4"), dMaxSearchSteps: (0, co.DefineSpec)("number") }), Hfe = (0, zE.ShaderCode)("smaa-weights", Vfe.weights_vert, Rfe.weights_frag);
function jfe(e, r) {
  var t = r.getWidth(), n = r.getHeight(), a = (0, w2.createTexture)(e.gl, e.extensions, "image-uint8", "rgb", "ubyte", "linear"), i = (0, w2.createTexture)(e.gl, e.extensions, "image-uint8", "rgba", "ubyte", "nearest"), o = (0, $i.__assign)((0, $i.__assign)({}, Op.QuadValues), { tEdges: vn.ValueCell.create(r), tArea: vn.ValueCell.create(a), tSearch: vn.ValueCell.create(i), uTexSizeInv: vn.ValueCell.create(rc.Vec2.create(1 / t, 1 / n)), uViewport: vn.ValueCell.create((0, rc.Vec4)()), dMaxSearchSteps: vn.ValueCell.create(16) });
  (0, w2.loadImageTexture)(Xfe(), o.tArea, a), (0, w2.loadImageTexture)(Yfe(), o.tSearch, i);
  var c = (0, $i.__assign)({}, qfe), s = (0, GE.createComputeRenderItem)(e, "triangles", Hfe, c, o);
  return (0, UE.createComputeRenderable)(s, o);
}
var $fe = (0, $i.__assign)((0, $i.__assign)({}, Op.QuadSchema), { tColor: (0, co.TextureSpec)("texture", "rgba", "ubyte", "linear"), tWeights: (0, co.TextureSpec)("texture", "rgba", "ubyte", "linear"), uTexSizeInv: (0, co.UniformSpec)("v2"), uViewport: (0, co.UniformSpec)("v4") }), Kfe = (0, zE.ShaderCode)("smaa-blend", Bfe.blend_vert, Nfe.blend_frag);
function Wfe(e, r, t) {
  var n = r.getWidth(), a = r.getHeight(), i = (0, $i.__assign)((0, $i.__assign)({}, Op.QuadValues), { tColor: vn.ValueCell.create(r), tWeights: vn.ValueCell.create(t), uTexSizeInv: vn.ValueCell.create(rc.Vec2.create(1 / n, 1 / a)), uViewport: vn.ValueCell.create((0, rc.Vec4)()) }), o = (0, $i.__assign)({}, $fe), c = (0, GE.createComputeRenderItem)(e, "triangles", Kfe, o, i);
  return (0, UE.createComputeRenderable)(c, i);
}
function Xfe() {
  return "data:image/png;base64, ";
}
function Yfe() {
  return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII=";
}
Object.defineProperty(rl, "__esModule", { value: !0 });
rl.AntialiasingPass = rl.PostprocessingPass = rl.PostprocessingParams = void 0;
var aa = Te, Ec = Yi, Vr = yn, w4 = Bn(), Ke = We(), E4 = Lt, D4 = Kt, Nt = Re, Pa = Le, I4 = Qi, Qfe = g4, Zfe = y4, Jfe = _4, e0e = b4, GM = Tr(), tH = Lv, nH = kv, r0e = (0, aa.__assign)((0, aa.__assign)({}, Ec.QuadSchema), { tDepth: (0, Vr.TextureSpec)("texture", "rgba", "ubyte", "nearest"), uTexSize: (0, Vr.UniformSpec)("v2"), dOrthographic: (0, Vr.DefineSpec)("number"), uNear: (0, Vr.UniformSpec)("f"), uFar: (0, Vr.UniformSpec)("f"), uMaxPossibleViewZDiff: (0, Vr.UniformSpec)("f") });
function t0e(e, r) {
  var t = (0, aa.__assign)((0, aa.__assign)({}, Ec.QuadValues), { tDepth: Ke.ValueCell.create(r), uTexSize: Ke.ValueCell.create(Nt.Vec2.create(r.getWidth(), r.getHeight())), dOrthographic: Ke.ValueCell.create(0), uNear: Ke.ValueCell.create(1), uFar: Ke.ValueCell.create(1e4), uMaxPossibleViewZDiff: Ke.ValueCell.create(0.5) }), n = (0, aa.__assign)({}, r0e), a = (0, w4.ShaderCode)("outlines", I4.quad_vert, Qfe.outlines_frag), i = (0, E4.createComputeRenderItem)(e, "triangles", a, n, t);
  return (0, D4.createComputeRenderable)(i, t);
}
var n0e = (0, aa.__assign)((0, aa.__assign)({}, Ec.QuadSchema), { tDepth: (0, Vr.TextureSpec)("texture", "rgba", "ubyte", "nearest"), uSamples: (0, Vr.UniformSpec)("v3[]"), dNSamples: (0, Vr.DefineSpec)("number"), uProjection: (0, Vr.UniformSpec)("m4"), uInvProjection: (0, Vr.UniformSpec)("m4"), uBounds: (0, Vr.UniformSpec)("v4"), uTexSize: (0, Vr.UniformSpec)("v2"), uRadius: (0, Vr.UniformSpec)("f"), uBias: (0, Vr.UniformSpec)("f") });
function a0e(e, r) {
  var t = (0, aa.__assign)((0, aa.__assign)({}, Ec.QuadValues), { tDepth: Ke.ValueCell.create(r), uSamples: Ke.ValueCell.create([0, 0, 1]), dNSamples: Ke.ValueCell.create(32), uProjection: Ke.ValueCell.create(Nt.Mat4.identity()), uInvProjection: Ke.ValueCell.create(Nt.Mat4.identity()), uBounds: Ke.ValueCell.create((0, Nt.Vec4)()), uTexSize: Ke.ValueCell.create(Nt.Vec2.create(e.gl.drawingBufferWidth, e.gl.drawingBufferHeight)), uRadius: Ke.ValueCell.create(8), uBias: Ke.ValueCell.create(0.025) }), n = (0, aa.__assign)({}, n0e), a = (0, w4.ShaderCode)("ssao", I4.quad_vert, Zfe.ssao_frag), i = (0, E4.createComputeRenderItem)(e, "triangles", a, n, t);
  return (0, D4.createComputeRenderable)(i, t);
}
var i0e = (0, aa.__assign)((0, aa.__assign)({}, Ec.QuadSchema), { tSsaoDepth: (0, Vr.TextureSpec)("texture", "rgba", "ubyte", "nearest"), uTexSize: (0, Vr.UniformSpec)("v2"), uKernel: (0, Vr.UniformSpec)("f[]"), dOcclusionKernelSize: (0, Vr.DefineSpec)("number"), uBlurDirectionX: (0, Vr.UniformSpec)("f"), uBlurDirectionY: (0, Vr.UniformSpec)("f"), uMaxPossibleViewZDiff: (0, Vr.UniformSpec)("f"), uNear: (0, Vr.UniformSpec)("f"), uFar: (0, Vr.UniformSpec)("f"), uBounds: (0, Vr.UniformSpec)("v4"), dOrthographic: (0, Vr.DefineSpec)("number") });
function U9(e, r, t) {
  var n = (0, aa.__assign)((0, aa.__assign)({}, Ec.QuadValues), { tSsaoDepth: Ke.ValueCell.create(r), uTexSize: Ke.ValueCell.create(Nt.Vec2.create(r.getWidth(), r.getHeight())), uKernel: Ke.ValueCell.create([0]), dOcclusionKernelSize: Ke.ValueCell.create(15), uBlurDirectionX: Ke.ValueCell.create(t === "horizontal" ? 1 : 0), uBlurDirectionY: Ke.ValueCell.create(t === "vertical" ? 1 : 0), uMaxPossibleViewZDiff: Ke.ValueCell.create(0.5), uNear: Ke.ValueCell.create(0), uFar: Ke.ValueCell.create(1e4), uBounds: Ke.ValueCell.create((0, Nt.Vec4)()), dOrthographic: Ke.ValueCell.create(0) }), a = (0, aa.__assign)({}, i0e), i = (0, w4.ShaderCode)("ssao_blur", I4.quad_vert, Jfe.ssaoBlur_frag), o = (0, E4.createComputeRenderItem)(e, "triangles", i, a, n);
  return (0, D4.createComputeRenderable)(o, n);
}
function o0e(e) {
  for (var r = e / 3, t = Math.floor((e + 1) / 2), n = [], a = 0; a < t; a++)
    n.push(1 / (Math.sqrt(2 * Math.PI) * r) * Math.exp(-a * a / (2 * r * r)));
  return n;
}
function u0e(e, r) {
  for (var t = [], n = 0; n < r; n++) {
    var a = (n * n + 2 * n + 1) / (r * r);
    a = 0.1 + a * (1 - 0.1), t.push(e[n][0] * a), t.push(e[n][1] * a), t.push(e[n][2] * a);
  }
  return t;
}
var s0e = (0, aa.__assign)((0, aa.__assign)({}, Ec.QuadSchema), { tSsaoDepth: (0, Vr.TextureSpec)("texture", "rgba", "ubyte", "nearest"), tColor: (0, Vr.TextureSpec)("texture", "rgba", "ubyte", "nearest"), tDepth: (0, Vr.TextureSpec)("texture", "rgba", "ubyte", "nearest"), tOutlines: (0, Vr.TextureSpec)("texture", "rgba", "ubyte", "nearest"), uTexSize: (0, Vr.UniformSpec)("v2"), dOrthographic: (0, Vr.DefineSpec)("number"), uNear: (0, Vr.UniformSpec)("f"), uFar: (0, Vr.UniformSpec)("f"), uFogNear: (0, Vr.UniformSpec)("f"), uFogFar: (0, Vr.UniformSpec)("f"), uFogColor: (0, Vr.UniformSpec)("v3"), uOutlineColor: (0, Vr.UniformSpec)("v3"), uTransparentBackground: (0, Vr.UniformSpec)("b"), uMaxPossibleViewZDiff: (0, Vr.UniformSpec)("f"), dOcclusionEnable: (0, Vr.DefineSpec)("boolean"), uOcclusionOffset: (0, Vr.UniformSpec)("v2"), dOutlineEnable: (0, Vr.DefineSpec)("boolean"), dOutlineScale: (0, Vr.DefineSpec)("number"), uOutlineThreshold: (0, Vr.UniformSpec)("f") });
function l0e(e, r, t, n, a) {
  var i = (0, aa.__assign)((0, aa.__assign)({}, Ec.QuadValues), { tSsaoDepth: Ke.ValueCell.create(a), tColor: Ke.ValueCell.create(r), tDepth: Ke.ValueCell.create(t), tOutlines: Ke.ValueCell.create(n), uTexSize: Ke.ValueCell.create(Nt.Vec2.create(r.getWidth(), r.getHeight())), dOrthographic: Ke.ValueCell.create(0), uNear: Ke.ValueCell.create(1), uFar: Ke.ValueCell.create(1e4), uFogNear: Ke.ValueCell.create(1e4), uFogFar: Ke.ValueCell.create(1e4), uFogColor: Ke.ValueCell.create(Nt.Vec3.create(1, 1, 1)), uOutlineColor: Ke.ValueCell.create(Nt.Vec3.create(0, 0, 0)), uTransparentBackground: Ke.ValueCell.create(!1), uMaxPossibleViewZDiff: Ke.ValueCell.create(0.5), dOcclusionEnable: Ke.ValueCell.create(!0), uOcclusionOffset: Ke.ValueCell.create(Nt.Vec2.create(0, 0)), dOutlineEnable: Ke.ValueCell.create(!1), dOutlineScale: Ke.ValueCell.create(1), uOutlineThreshold: Ke.ValueCell.create(0.33) }), o = (0, aa.__assign)({}, s0e), c = (0, w4.ShaderCode)("postprocessing", I4.quad_vert, e0e.postprocessing_frag), s = (0, E4.createComputeRenderItem)(e, "triangles", c, o, i);
  return (0, D4.createComputeRenderable)(s, i);
}
rl.PostprocessingParams = {
  occlusion: Pa.ParamDefinition.MappedStatic("on", {
    on: Pa.ParamDefinition.Group({
      samples: Pa.ParamDefinition.Numeric(32, { min: 1, max: 256, step: 1 }),
      radius: Pa.ParamDefinition.Numeric(5, { min: 0, max: 10, step: 0.1 }, { description: "Final occlusion radius is 2^x" }),
      bias: Pa.ParamDefinition.Numeric(0.8, { min: 0, max: 3, step: 0.1 }),
      blurKernelSize: Pa.ParamDefinition.Numeric(15, { min: 1, max: 25, step: 2 }),
      resolutionScale: Pa.ParamDefinition.Numeric(1, { min: 0.1, max: 1, step: 0.05 }, { description: "Adjust resolution of occlusion calculation" })
    }),
    off: Pa.ParamDefinition.Group({})
  }, { cycle: !0, description: "Darken occluded crevices with the ambient occlusion effect" }),
  outline: Pa.ParamDefinition.MappedStatic("off", {
    on: Pa.ParamDefinition.Group({
      scale: Pa.ParamDefinition.Numeric(1, { min: 1, max: 5, step: 1 }),
      threshold: Pa.ParamDefinition.Numeric(0.33, { min: 0.01, max: 1, step: 0.01 }),
      color: Pa.ParamDefinition.Color((0, GM.Color)(0))
    }),
    off: Pa.ParamDefinition.Group({})
  }, { cycle: !0, description: "Draw outline around 3D objects" }),
  antialiasing: Pa.ParamDefinition.MappedStatic("smaa", {
    fxaa: Pa.ParamDefinition.Group(tH.FxaaParams),
    smaa: Pa.ParamDefinition.Group(nH.SmaaParams),
    off: Pa.ParamDefinition.Group({})
  }, { options: [["fxaa", "FXAA"], ["smaa", "SMAA"], ["off", "Off"]], description: "Smooth pixel edges" })
};
var qM = (
  /** @class */
  function() {
    function e(r, t) {
      this.webgl = r, this.drawPass = t, this.occlusionOffset = [0, 0];
      var n = t.colorTarget, a = t.depthTexture, i = n.getWidth(), o = n.getHeight();
      this.nSamples = 1, this.blurKernelSize = 1, this.downsampleFactor = 1, this.ssaoScale = this.calcSsaoScale(), this.target = r.createRenderTarget(i, o, !1, "uint8", "linear"), this.outlinesTarget = r.createRenderTarget(i, o, !1), this.outlinesRenderable = t0e(r, a), this.randomHemisphereVector = [];
      for (var c = 0; c < 256; c++) {
        var s = (0, Nt.Vec3)();
        s[0] = Math.random() * 2 - 1, s[1] = Math.random() * 2 - 1, s[2] = Math.random(), Nt.Vec3.normalize(s, s), Nt.Vec3.scale(s, s, Math.random()), this.randomHemisphereVector.push(s);
      }
      this.ssaoFramebuffer = r.resources.framebuffer(), this.ssaoBlurFirstPassFramebuffer = r.resources.framebuffer(), this.ssaoBlurSecondPassFramebuffer = r.resources.framebuffer();
      var u = Math.floor(i * this.ssaoScale), l = Math.floor(o * this.ssaoScale);
      this.downsampledDepthTarget = r.createRenderTarget(u, l, !1, "uint8", "linear"), this.downsampleDepthRenderable = (0, Ec.createCopyRenderable)(r, a), this.ssaoDepthTexture = r.resources.texture("image-uint8", "rgba", "ubyte", "linear"), this.ssaoDepthTexture.define(u, l), this.ssaoDepthTexture.attachFramebuffer(this.ssaoFramebuffer, "color0"), this.ssaoDepthBlurProxyTexture = r.resources.texture("image-uint8", "rgba", "ubyte", "linear"), this.ssaoDepthBlurProxyTexture.define(u, l), this.ssaoDepthBlurProxyTexture.attachFramebuffer(this.ssaoBlurFirstPassFramebuffer, "color0"), this.ssaoDepthTexture.attachFramebuffer(this.ssaoBlurSecondPassFramebuffer, "color0"), this.ssaoRenderable = a0e(r, this.downsampleFactor === 1 ? a : this.downsampledDepthTarget.texture), this.ssaoBlurFirstPassRenderable = U9(r, this.ssaoDepthTexture, "horizontal"), this.ssaoBlurSecondPassRenderable = U9(r, this.ssaoDepthBlurProxyTexture, "vertical"), this.renderable = l0e(r, n.texture, a, this.outlinesTarget.texture, this.ssaoDepthTexture);
    }
    return e.isEnabled = function(r) {
      return r.occlusion.name === "on" || r.outline.name === "on";
    }, e.prototype.calcSsaoScale = function() {
      return Math.min(1, 1 / this.webgl.pixelRatio) * this.downsampleFactor;
    }, e.prototype.setSize = function(r, t) {
      var n = this.renderable.values.uTexSize.ref.value, a = n[0], i = n[1], o = this.calcSsaoScale();
      if (r !== a || t !== i || this.ssaoScale !== o) {
        this.ssaoScale = o;
        var c = Math.floor(r * this.ssaoScale), s = Math.floor(t * this.ssaoScale);
        this.target.setSize(r, t), this.outlinesTarget.setSize(r, t), this.downsampledDepthTarget.setSize(c, s), this.ssaoDepthTexture.define(c, s), this.ssaoDepthBlurProxyTexture.define(c, s), Ke.ValueCell.update(this.renderable.values.uTexSize, Nt.Vec2.set(this.renderable.values.uTexSize.ref.value, r, t)), Ke.ValueCell.update(this.outlinesRenderable.values.uTexSize, Nt.Vec2.set(this.outlinesRenderable.values.uTexSize.ref.value, r, t)), Ke.ValueCell.update(this.downsampleDepthRenderable.values.uTexSize, Nt.Vec2.set(this.downsampleDepthRenderable.values.uTexSize.ref.value, c, s)), Ke.ValueCell.update(this.ssaoRenderable.values.uTexSize, Nt.Vec2.set(this.ssaoRenderable.values.uTexSize.ref.value, c, s)), Ke.ValueCell.update(this.ssaoBlurFirstPassRenderable.values.uTexSize, Nt.Vec2.set(this.ssaoBlurFirstPassRenderable.values.uTexSize.ref.value, c, s)), Ke.ValueCell.update(this.ssaoBlurSecondPassRenderable.values.uTexSize, Nt.Vec2.set(this.ssaoBlurSecondPassRenderable.values.uTexSize.ref.value, c, s));
      }
    }, e.prototype.updateState = function(r, t, n, a) {
      var i = !1, o = !1, c = !1, s = r.state.mode === "orthographic" ? 1 : 0, u = a.outline.name === "on", l = a.occlusion.name === "on", f = Nt.Mat4.identity();
      if (Nt.Mat4.invert(f, r.projection), a.occlusion.name === "on") {
        Ke.ValueCell.update(this.ssaoRenderable.values.uProjection, r.projection), Ke.ValueCell.update(this.ssaoRenderable.values.uInvProjection, f);
        var d = this.renderable.values.uTexSize.ref.value, m = d[0], p = d[1], v = this.ssaoRenderable.values.uBounds, h = r.viewport, y = this.ssaoScale;
        if (Nt.Vec4.set(v.ref.value, Math.floor(h.x * y) / (m * y), Math.floor(h.y * y) / (p * y), Math.ceil((h.x + h.width) * y) / (m * y), Math.ceil((h.y + h.height) * y) / (p * y)), Ke.ValueCell.update(v, v.ref.value), Ke.ValueCell.update(this.ssaoBlurFirstPassRenderable.values.uBounds, v.ref.value), Ke.ValueCell.update(this.ssaoBlurSecondPassRenderable.values.uBounds, v.ref.value), Ke.ValueCell.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.uNear, r.near), Ke.ValueCell.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.uNear, r.near), Ke.ValueCell.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.uFar, r.far), Ke.ValueCell.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.uFar, r.far), this.ssaoBlurFirstPassRenderable.values.dOrthographic.ref.value !== s && (c = !0), Ke.ValueCell.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.dOrthographic, s), Ke.ValueCell.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.dOrthographic, s), this.nSamples !== a.occlusion.params.samples && (o = !0, this.nSamples = a.occlusion.params.samples, Ke.ValueCell.update(this.ssaoRenderable.values.uSamples, u0e(this.randomHemisphereVector, this.nSamples)), Ke.ValueCell.updateIfChanged(this.ssaoRenderable.values.dNSamples, this.nSamples)), Ke.ValueCell.updateIfChanged(this.ssaoRenderable.values.uRadius, Math.pow(2, a.occlusion.params.radius)), Ke.ValueCell.updateIfChanged(this.ssaoRenderable.values.uBias, a.occlusion.params.bias), this.blurKernelSize !== a.occlusion.params.blurKernelSize) {
          c = !0, this.blurKernelSize = a.occlusion.params.blurKernelSize;
          var C = o0e(this.blurKernelSize);
          Ke.ValueCell.update(this.ssaoBlurFirstPassRenderable.values.uKernel, C), Ke.ValueCell.update(this.ssaoBlurSecondPassRenderable.values.uKernel, C), Ke.ValueCell.updateIfChanged(this.ssaoBlurFirstPassRenderable.values.dOcclusionKernelSize, this.blurKernelSize), Ke.ValueCell.updateIfChanged(this.ssaoBlurSecondPassRenderable.values.dOcclusionKernelSize, this.blurKernelSize);
        }
        if (this.downsampleFactor !== a.occlusion.params.resolutionScale) {
          o = !0, this.downsampleFactor = a.occlusion.params.resolutionScale, this.ssaoScale = this.calcSsaoScale();
          var S = Math.floor(m * this.ssaoScale), b = Math.floor(p * this.ssaoScale);
          this.downsampledDepthTarget.setSize(S, b), this.ssaoDepthTexture.define(S, b), this.ssaoDepthBlurProxyTexture.define(S, b), this.ssaoScale === 1 ? Ke.ValueCell.update(this.ssaoRenderable.values.tDepth, this.drawPass.depthTexture) : Ke.ValueCell.update(this.ssaoRenderable.values.tDepth, this.downsampledDepthTarget.texture), Ke.ValueCell.update(this.downsampleDepthRenderable.values.uTexSize, Nt.Vec2.set(this.downsampleDepthRenderable.values.uTexSize.ref.value, S, b)), Ke.ValueCell.update(this.ssaoRenderable.values.uTexSize, Nt.Vec2.set(this.ssaoRenderable.values.uTexSize.ref.value, S, b)), Ke.ValueCell.update(this.ssaoBlurFirstPassRenderable.values.uTexSize, Nt.Vec2.set(this.ssaoBlurFirstPassRenderable.values.uTexSize.ref.value, S, b)), Ke.ValueCell.update(this.ssaoBlurSecondPassRenderable.values.uTexSize, Nt.Vec2.set(this.ssaoBlurSecondPassRenderable.values.uTexSize.ref.value, S, b));
        }
      }
      if (a.outline.name === "on") {
        var g = a.outline.params.threshold;
        r.state.mode === "orthographic" && (g /= 5);
        var _ = Math.pow(1e3, g) / 1e3, A = _ * r.state.radiusMax, M = a.outline.params.scale - 1;
        Ke.ValueCell.updateIfChanged(this.outlinesRenderable.values.uNear, r.near), Ke.ValueCell.updateIfChanged(this.outlinesRenderable.values.uFar, r.far), Ke.ValueCell.updateIfChanged(this.outlinesRenderable.values.uMaxPossibleViewZDiff, A), Ke.ValueCell.update(this.renderable.values.uOutlineColor, GM.Color.toVec3Normalized(this.renderable.values.uOutlineColor.ref.value, a.outline.params.color)), Ke.ValueCell.updateIfChanged(this.renderable.values.uMaxPossibleViewZDiff, A), this.renderable.values.dOutlineScale.ref.value !== M && (i = !0), Ke.ValueCell.updateIfChanged(this.renderable.values.dOutlineScale, M);
      }
      Ke.ValueCell.updateIfChanged(this.renderable.values.uFar, r.far), Ke.ValueCell.updateIfChanged(this.renderable.values.uNear, r.near), Ke.ValueCell.updateIfChanged(this.renderable.values.uFogFar, r.fogFar), Ke.ValueCell.updateIfChanged(this.renderable.values.uFogNear, r.fogNear), Ke.ValueCell.update(this.renderable.values.uFogColor, GM.Color.toVec3Normalized(this.renderable.values.uFogColor.ref.value, n)), Ke.ValueCell.updateIfChanged(this.renderable.values.uTransparentBackground, t), this.renderable.values.dOrthographic.ref.value !== s && (i = !0), Ke.ValueCell.updateIfChanged(this.renderable.values.dOrthographic, s), this.renderable.values.dOutlineEnable.ref.value !== u && (i = !0), Ke.ValueCell.updateIfChanged(this.renderable.values.dOutlineEnable, u), this.renderable.values.dOcclusionEnable.ref.value !== l && (i = !0), Ke.ValueCell.updateIfChanged(this.renderable.values.dOcclusionEnable, l), o && this.ssaoRenderable.update(), c && (this.ssaoBlurFirstPassRenderable.update(), this.ssaoBlurSecondPassRenderable.update()), i && this.renderable.update();
      var P = this.webgl, T = P.gl, x = P.state;
      x.enable(T.SCISSOR_TEST), x.disable(T.BLEND), x.disable(T.DEPTH_TEST), x.depthMask(!1);
      var w = r.viewport, E = w.x, I = w.y, B = w.width, D = w.height;
      T.viewport(E, I, B, D), T.scissor(E, I, B, D);
    }, e.prototype.setOcclusionOffset = function(r, t) {
      this.occlusionOffset[0] = r, this.occlusionOffset[1] = t, Ke.ValueCell.update(this.renderable.values.uOcclusionOffset, Nt.Vec2.set(this.renderable.values.uOcclusionOffset.ref.value, r, t));
    }, e.prototype.render = function(r, t, n, a, i) {
      this.updateState(r, n, a, i), i.outline.name === "on" && (this.outlinesTarget.bind(), this.outlinesRenderable.render()), i.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()), t ? this.webgl.unbindFramebuffer() : this.target.bind();
      var o = this.webgl, c = o.gl, s = o.state;
      s.clearColor(0, 0, 0, 1), c.clear(c.COLOR_BUFFER_BIT), this.renderable.render();
    }, e;
  }()
);
rl.PostprocessingPass = qM;
var c0e = (
  /** @class */
  function() {
    function e(r, t) {
      this.drawPass = t;
      var n = t.colorTarget, a = n.getWidth(), i = n.getHeight();
      this.target = r.createRenderTarget(a, i, !1), this.fxaa = new tH.FxaaPass(r, this.target.texture), this.smaa = new nH.SmaaPass(r, this.target.texture);
    }
    return e.isEnabled = function(r) {
      return r.antialiasing.name !== "off";
    }, e.prototype.setSize = function(r, t) {
      var n = this.target.texture.getWidth(), a = this.target.texture.getHeight();
      (r !== n || t !== a) && (this.target.setSize(r, t), this.fxaa.setSize(r, t), this.smaa.supported && this.smaa.setSize(r, t));
    }, e.prototype._renderFxaa = function(r, t, n) {
      if (n.antialiasing.name === "fxaa") {
        var a = qM.isEnabled(n) ? this.drawPass.postprocessing.target.texture : this.drawPass.colorTarget.texture;
        this.fxaa.update(a, n.antialiasing.params), this.fxaa.render(r.viewport, t ? void 0 : this.target);
      }
    }, e.prototype._renderSmaa = function(r, t, n) {
      if (n.antialiasing.name === "smaa") {
        var a = qM.isEnabled(n) ? this.drawPass.postprocessing.target.texture : this.drawPass.colorTarget.texture;
        this.smaa.update(a, n.antialiasing.params), this.smaa.render(r.viewport, t ? void 0 : this.target);
      }
    }, e.prototype.render = function(r, t, n) {
      if (n.antialiasing.name !== "off") {
        if (n.antialiasing.name === "fxaa")
          this._renderFxaa(r, t, n);
        else if (n.antialiasing.name === "smaa") {
          if (!this.smaa.supported)
            throw new Error('SMAA not supported, missing "HTMLImageElement"');
          this._renderSmaa(r, t, n);
        }
      }
    }, e;
  }()
);
rl.AntialiasingPass = c0e;
var tl = {}, B4 = {};
Object.defineProperty(B4, "__esModule", { value: !0 });
B4.compose_frag = void 0;
B4.compose_frag = `
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;
}
`;
Object.defineProperty(tl, "__esModule", { value: !0 });
tl.MultiSampleHelper = tl.MultiSamplePass = tl.MultiSampleParams = void 0;
var W1 = Te, aH = Yi, tT = yn, hi = We(), iH = Re, d0e = Bn(), f0e = Lt, m0e = Kt, z9 = Le, G9 = Rp(), v0e = Qi, p0e = B4, h0e = (0, W1.__assign)((0, W1.__assign)({}, aH.QuadSchema), { tColor: (0, tT.TextureSpec)("texture", "rgba", "ubyte", "nearest"), uTexSize: (0, tT.UniformSpec)("v2"), uWeight: (0, tT.UniformSpec)("f") }), g0e = (0, d0e.ShaderCode)("compose", v0e.quad_vert, p0e.compose_frag);
function y0e(e, r) {
  var t = (0, W1.__assign)((0, W1.__assign)({}, aH.QuadValues), { tColor: hi.ValueCell.create(r), uTexSize: hi.ValueCell.create(iH.Vec2.create(r.getWidth(), r.getHeight())), uWeight: hi.ValueCell.create(1) }), n = (0, W1.__assign)({}, h0e), a = (0, f0e.createComputeRenderItem)(e, "triangles", g0e, n, t);
  return (0, m0e.createComputeRenderable)(a, t);
}
tl.MultiSampleParams = {
  mode: z9.ParamDefinition.Select("temporal", [
    ["off", "Off"],
    ["on", "On"],
    ["temporal", "Temporal"]
  ]),
  sampleLevel: z9.ParamDefinition.Numeric(2, { min: 0, max: 5, step: 1 }, { description: "Take level^2 samples." })
};
var _0e = (
  /** @class */
  function() {
    function e(r, t) {
      this.webgl = r, this.drawPass = t;
      var n = r.extensions, a = n.colorBufferFloat, i = n.textureFloat, o = n.colorBufferHalfFloat, c = n.textureHalfFloat, s = t.colorTarget.getWidth(), u = t.colorTarget.getHeight();
      this.colorTarget = r.createRenderTarget(s, u, !1);
      var l = o && c ? "fp16" : a && i ? "float32" : "uint8";
      this.composeTarget = r.createRenderTarget(s, u, !1, l), this.holdTarget = r.createRenderTarget(s, u, !1), this.compose = y0e(r, t.colorTarget.texture);
    }
    return e.isEnabled = function(r) {
      return r.mode !== "off";
    }, e.prototype.syncSize = function() {
      var r = this.drawPass.colorTarget.getWidth(), t = this.drawPass.colorTarget.getHeight(), n = this.compose.values.uTexSize.ref.value, a = n[0], i = n[1];
      (r !== a || t !== i) && (this.colorTarget.setSize(r, t), this.composeTarget.setSize(r, t), this.holdTarget.setSize(r, t), hi.ValueCell.update(this.compose.values.uTexSize, iH.Vec2.set(this.compose.values.uTexSize.ref.value, r, t)));
    }, e.prototype.render = function(r, t, n, a, i) {
      return n.multiSample.mode === "temporal" && !i ? this.renderTemporalMultiSample(r, t, n, a) : (this.renderMultiSample(t, a, n), -2);
    }, e.prototype.bindOutputTarget = function(r) {
      r ? this.webgl.unbindFramebuffer() : this.colorTarget.bind();
    }, e.prototype.renderMultiSample = function(r, t, n) {
      var a = r.camera, i = this, o = i.compose, c = i.composeTarget, s = i.drawPass, u = i.webgl, l = u.gl, f = u.state, d = HM[Math.max(0, Math.min(n.multiSample.sampleLevel, 5))], m = a.viewport, p = m.x, v = m.y, h = m.width, y = m.height, C = 1 / d.length, S = 1 / 32;
      a.viewOffset.enabled = !0, hi.ValueCell.update(o.values.tColor, s.getColorTarget(n.postprocessing).texture), o.update();
      for (var b = 0; b < d.length; ++b) {
        var g = d[b];
        G9.Camera.setViewOffset(a.viewOffset, h, y, g[0], g[1], h, y), a.update();
        var _ = -0.5 + (b + 0.5) / d.length, A = C + S * _;
        hi.ValueCell.update(o.values.uWeight, A), b === 0 ? s.postprocessing.setOcclusionOffset(0, 0) : s.postprocessing.setOcclusionOffset(g[0] / h, g[1] / y), s.render(r, n, !1), c.bind(), f.enable(l.BLEND), f.blendEquationSeparate(l.FUNC_ADD, l.FUNC_ADD), f.blendFuncSeparate(l.ONE, l.ONE, l.ONE, l.ONE), f.disable(l.DEPTH_TEST), f.depthMask(!1), l.viewport(p, v, h, y), l.scissor(p, v, h, y), b === 0 && (f.clearColor(0, 0, 0, 0), l.clear(l.COLOR_BUFFER_BIT)), o.render();
      }
      s.postprocessing.setOcclusionOffset(0, 0), hi.ValueCell.update(o.values.uWeight, 1), hi.ValueCell.update(o.values.tColor, c.texture), o.update(), this.bindOutputTarget(t), l.viewport(p, v, h, y), l.scissor(p, v, h, y), f.disable(l.BLEND), o.render(), a.viewOffset.enabled = !1, a.update();
    }, e.prototype.renderTemporalMultiSample = function(r, t, n, a) {
      var i = t.camera, o = this, c = o.compose, s = o.composeTarget, u = o.holdTarget, l = o.drawPass, f = o.webgl, d = f.gl, m = f.state, p = HM[Math.max(0, Math.min(n.multiSample.sampleLevel, 5))];
      if (r === -2 || r >= p.length)
        return -2;
      var v = i.viewport, h = v.x, y = v.y, C = v.width, S = v.height, b = 1 / p.length;
      if (r === -1)
        l.render(t, n, !1), hi.ValueCell.update(c.values.uWeight, 1), hi.ValueCell.update(c.values.tColor, l.getColorTarget(n.postprocessing).texture), c.update(), u.bind(), m.disable(d.BLEND), m.disable(d.DEPTH_TEST), m.depthMask(!1), d.viewport(h, y, C, S), d.scissor(h, y, C, S), c.render(), r += 1;
      else {
        i.viewOffset.enabled = !0, hi.ValueCell.update(c.values.tColor, l.getColorTarget(n.postprocessing).texture), hi.ValueCell.update(c.values.uWeight, b), c.update();
        for (var g = Math.pow(2, Math.max(0, n.multiSample.sampleLevel - 2)), _ = 0; _ < g; ++_) {
          var A = p[r];
          if (G9.Camera.setViewOffset(i.viewOffset, C, S, A[0], A[1], C, S), i.update(), r === 0 ? l.postprocessing.setOcclusionOffset(0, 0) : l.postprocessing.setOcclusionOffset(A[0] / C, A[1] / S), l.render(t, n, !1), s.bind(), m.enable(d.BLEND), m.blendEquationSeparate(d.FUNC_ADD, d.FUNC_ADD), m.blendFuncSeparate(d.ONE, d.ONE, d.ONE, d.ONE), m.disable(d.DEPTH_TEST), m.depthMask(!1), d.viewport(h, y, C, S), d.scissor(h, y, C, S), r === 0 && (m.clearColor(0, 0, 0, 0), d.clear(d.COLOR_BUFFER_BIT)), c.render(), r += 1, r >= p.length)
            break;
        }
      }
      l.postprocessing.setOcclusionOffset(0, 0), this.bindOutputTarget(a), d.viewport(h, y, C, S), d.scissor(h, y, C, S);
      var M = r * b;
      return M > 0 && (hi.ValueCell.update(c.values.uWeight, 1), hi.ValueCell.update(c.values.tColor, s.texture), c.update(), m.disable(d.BLEND), c.render()), M < 1 && (hi.ValueCell.update(c.values.uWeight, 1 - M), hi.ValueCell.update(c.values.tColor, u.texture), c.update(), M === 0 ? m.disable(d.BLEND) : m.enable(d.BLEND), c.render()), i.viewOffset.enabled = !1, i.update(), r >= p.length ? -2 : r;
    }, e;
  }()
);
tl.MultiSamplePass = _0e;
var HM = [
  [[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]
  ]
];
HM.forEach(function(e) {
  e.forEach(function(r) {
    r[0] *= 0.0625, r[1] *= 0.0625;
  });
});
var b0e = (
  /** @class */
  function() {
    function e(r) {
      this.multiSamplePass = r, this.sampleIndex = -2;
    }
    return e.prototype.update = function(r, t) {
      return r && (this.sampleIndex = -1), t.mode === "temporal" ? this.sampleIndex !== -2 : !1;
    }, e.prototype.render = function(r, t, n, a) {
      return this.sampleIndex = this.multiSamplePass.render(this.sampleIndex, r, t, n, !!a), this.sampleIndex < 0;
    }, e;
  }()
);
tl.MultiSampleHelper = b0e;
var f0 = {}, N4 = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.StereoCamera = e.DefaultStereoCameraProps = e.StereoCameraParams = void 0;
  var r = Te, t = Re, n = Le, a = Rp(), i = ri;
  e.StereoCameraParams = {
    eyeSeparation: n.ParamDefinition.Numeric(0.064, { min: 0.01, max: 0.5, step: 1e-3 }),
    focus: n.ParamDefinition.Numeric(10, { min: 1, max: 100, step: 0.01 })
  }, e.DefaultStereoCameraProps = n.ParamDefinition.getDefaultValues(e.StereoCameraParams);
  var o = (
    /** @class */
    function() {
      function f(d, m) {
        m === void 0 && (m = {}), this.parent = d, this.left = new c(), this.right = new c(), this.props = (0, r.__assign)((0, r.__assign)({}, e.DefaultStereoCameraProps), m);
      }
      return Object.defineProperty(f.prototype, "viewport", {
        get: function() {
          return this.parent.viewport;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(f.prototype, "viewOffset", {
        get: function() {
          return this.parent.viewOffset;
        },
        enumerable: !1,
        configurable: !0
      }), f.prototype.setProps = function(d) {
        Object.assign(this.props, d);
      }, f.prototype.update = function() {
        this.parent.update(), l(this.parent, this.props, this.left, this.right);
      }, f;
    }()
  );
  e.StereoCamera = o, function(f) {
    function d(m) {
      return "left" in m && "right" in m;
    }
    f.is = d;
  }(o || (o = {})), e.StereoCamera = o;
  var c = (
    /** @class */
    /* @__PURE__ */ function() {
      function f() {
        this.viewport = i.Viewport.create(0, 0, 0, 0), this.view = (0, t.Mat4)(), this.projection = (0, t.Mat4)(), this.projectionView = (0, t.Mat4)(), this.inverseProjectionView = (0, t.Mat4)(), this.state = a.Camera.createDefaultSnapshot(), this.viewOffset = a.Camera.ViewOffset(), this.far = 0, this.near = 0, this.fogFar = 0, this.fogNear = 0;
      }
      return f;
    }()
  ), s = t.Mat4.identity(), u = t.Mat4.identity();
  function l(f, d, m, p) {
    i.Viewport.copy(m.viewport, f.viewport), t.Mat4.copy(m.view, f.view), t.Mat4.copy(m.projection, f.projection), a.Camera.copySnapshot(m.state, f.state), a.Camera.copyViewOffset(m.viewOffset, f.viewOffset), m.far = f.far, m.near = f.near, m.fogFar = f.fogFar, m.fogNear = f.fogNear, i.Viewport.copy(p.viewport, f.viewport), t.Mat4.copy(p.view, f.view), t.Mat4.copy(p.projection, f.projection), a.Camera.copySnapshot(p.state, f.state), a.Camera.copyViewOffset(p.viewOffset, f.viewOffset), p.far = f.far, p.near = f.near, p.fogFar = f.fogFar, p.fogNear = f.fogNear;
    var v = Math.floor(f.viewport.width / 2), h = v / f.viewport.height;
    m.viewport.width = v, p.viewport.x += v, p.viewport.width -= v;
    var y = d.eyeSeparation / 2, C = y * f.near / d.focus, S = f.near * Math.tan(f.state.fov * 0.5), b, g;
    s[12] = -y, u[12] = y, b = -S * h + C, g = S * h + C, m.projection[0] = 2 * f.near / (g - b), m.projection[8] = (g + b) / (g - b), t.Mat4.mul(m.view, m.view, s), t.Mat4.mul(m.projectionView, m.projection, m.view), t.Mat4.invert(m.inverseProjectionView, m.projectionView), b = -S * h - C, g = S * h - C, p.projection[0] = 2 * f.near / (g - b), p.projection[8] = (g + b) / (g - b), t.Mat4.mul(p.view, p.view, u), t.Mat4.mul(p.projectionView, p.projection, p.view), t.Mat4.invert(p.inverseProjectionView, p.projectionView);
  }
})(N4);
Object.defineProperty(f0, "__esModule", { value: !0 });
f0.PickHelper = f0.PickPass = void 0;
var If = Re, S0e = kn, q9 = ts, H9 = N4, E2 = ri, j9 = ri, nT = Math.pow(2, 24) - 2, C0e = (
  /** @class */
  function() {
    function e(r, t, n) {
      this.webgl = r, this.drawPass = t, this.pickBaseScale = n;
      var a = n / r.pixelRatio;
      this.pickWidth = Math.ceil(t.colorTarget.getWidth() * a), this.pickHeight = Math.ceil(t.colorTarget.getHeight() * a), this.objectPickTarget = r.createRenderTarget(this.pickWidth, this.pickHeight), this.instancePickTarget = r.createRenderTarget(this.pickWidth, this.pickHeight), this.groupPickTarget = r.createRenderTarget(this.pickWidth, this.pickHeight), this.depthPickTarget = r.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 r = this.pickBaseScale / this.webgl.pixelRatio, t = Math.ceil(this.drawPass.colorTarget.getWidth() * r), n = Math.ceil(this.drawPass.colorTarget.getHeight() * r);
      (t !== this.pickWidth || n !== this.pickHeight) && (this.pickWidth = t, 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(r, t, n, a, i, o) {
      var c = this.drawPass.depthTexturePrimitives;
      r.clear(!1), r.update(t), r.renderPick(n.primitives, t, i, null, o), r.renderPick(n.volumes, t, i, c, o), r.renderPick(a.handle.scene, t, i, null, o), a.camera.isEnabled && (a.camera.update(t), r.update(a.camera.camera), r.renderPick(a.camera.scene, a.camera.camera, i, null, o));
    }, e.prototype.render = function(r, t, n, a) {
      this.objectPickTarget.bind(), this.renderVariant(
        r,
        t,
        n,
        a,
        "pick",
        1
        /* Object */
      ), this.instancePickTarget.bind(), this.renderVariant(
        r,
        t,
        n,
        a,
        "pick",
        2
        /* Instance */
      ), this.groupPickTarget.bind(), this.renderVariant(
        r,
        t,
        n,
        a,
        "pick",
        3
        /* Group */
      ), this.depthPickTarget.bind(), this.renderVariant(
        r,
        t,
        n,
        a,
        "depth",
        0
        /* None */
      );
    }, e;
  }()
);
f0.PickPass = C0e;
var A0e = (
  /** @class */
  function() {
    function e(r, t, n, a, i, o, c) {
      c === void 0 && (c = 1), this.webgl = r, this.renderer = t, this.scene = n, this.helper = a, this.pickPass = i, this.pickPadding = c, this.dirty = !0, this.viewport = (0, j9.Viewport)(), this.setViewport(o.x, o.y, o.width, o.height);
    }
    return e.prototype.setupBuffers = function() {
      var r = this.pickWidth * this.pickHeight * 4;
      (!this.objectBuffer || this.objectBuffer.length !== r) && (this.objectBuffer = new Uint8Array(r), this.instanceBuffer = new Uint8Array(r), this.groupBuffer = new Uint8Array(r), this.depthBuffer = new Uint8Array(r));
    }, e.prototype.setViewport = function(r, t, n, a) {
      j9.Viewport.set(this.viewport, r, t, n, a), this.pickScale = this.pickPass.pickBaseScale / this.webgl.pixelRatio, this.pickX = Math.ceil(r * this.pickScale), this.pickY = Math.ceil(t * this.pickScale);
      var i = Math.floor(n * this.pickScale), o = Math.floor(a * this.pickScale);
      (i !== this.pickWidth || o !== this.pickHeight) && (this.pickWidth = i, this.pickHeight = o, this.halfPickWidth = Math.floor(this.pickWidth / 2), this.setupBuffers()), this.spiral = (0, S0e.spiral2d)(Math.round(this.pickScale * this.pickPadding));
    }, e.prototype.syncBuffers = function() {
      var r = this, t = r.pickX, n = r.pickY, a = r.pickWidth, i = r.pickHeight;
      this.pickPass.objectPickTarget.bind(), this.webgl.readPixels(t, n, a, i, this.objectBuffer), this.pickPass.instancePickTarget.bind(), this.webgl.readPixels(t, n, a, i, this.instanceBuffer), this.pickPass.groupPickTarget.bind(), this.webgl.readPixels(t, n, a, i, this.groupBuffer), this.pickPass.depthPickTarget.bind(), this.webgl.readPixels(t, n, a, i, this.depthBuffer);
    }, e.prototype.getBufferIdx = function(r, t) {
      return (t * this.pickWidth + r) * 4;
    }, e.prototype.getDepth = function(r, t) {
      var n = this.getBufferIdx(r, t), a = this.depthBuffer;
      return (0, q9.unpackRGBAToDepth)(a[n], a[n + 1], a[n + 2], a[n + 3]);
    }, e.prototype.getId = function(r, t, n) {
      var a = this.getBufferIdx(r, t);
      return (0, q9.unpackRGBToInt)(n[a], n[a + 1], n[a + 2]);
    }, e.prototype.render = function(r) {
      var t = this, n = t.pickX, a = t.pickY, i = t.pickWidth, o = t.pickHeight, c = t.halfPickWidth, s = this, u = s.renderer, l = s.scene, f = s.helper;
      u.setTransparentBackground(!1), u.setDrawingBufferSize(this.pickPass.objectPickTarget.getWidth(), this.pickPass.objectPickTarget.getHeight()), u.setPixelRatio(this.pickScale), H9.StereoCamera.is(r) ? (u.setViewport(n, a, c, o), this.pickPass.render(u, r.left, l, f), u.setViewport(n + c, a, i - c, o), this.pickPass.render(u, r.right, l, f)) : (u.setViewport(n, a, i, o), this.pickPass.render(u, r, l, f)), this.dirty = !1;
    }, e.prototype.identifyInternal = function(r, t, n) {
      var a = this, i = a.webgl, o = a.pickScale;
      if (!i.isContextLost) {
        r *= i.pixelRatio, t *= i.pixelRatio, t = this.pickPass.drawingBufferHeight - t;
        var c = this.viewport;
        if (!(r < c.x || t < c.y || r > c.x + c.width || t > c.y + c.height)) {
          this.dirty && (this.render(n), this.syncBuffers());
          var s = r - c.x, u = t - c.y, l = Math.floor(s * o), f = Math.floor(u * o), d = this.getId(l, f, this.objectBuffer);
          if (!(d === -1 || d === nT)) {
            var m = this.getId(l, f, this.instanceBuffer);
            if (!(m === -1 || m === nT)) {
              var p = this.getId(l, f, this.groupBuffer);
              if (!(p === -1 || p === nT)) {
                var v = this.getDepth(l, f), h = If.Vec3.create(r, c.height - t, v);
                if (H9.StereoCamera.is(n)) {
                  var y = Math.floor(c.width / 2);
                  r > c.x + y ? (h[0] = c.x + (s - y) * 2, (0, E2.cameraUnproject)(h, h, c, n.right.inverseProjectionView)) : (h[0] = c.x + s * 2, (0, E2.cameraUnproject)(h, h, c, n.left.inverseProjectionView));
                } else
                  (0, E2.cameraUnproject)(h, h, c, n.inverseProjectionView);
                return { id: { objectId: d, instanceId: m, groupId: p }, position: h };
              }
            }
          }
        }
      }
    }, e.prototype.identify = function(r, t, n) {
      for (var a = 0, i = this.spiral; a < i.length; a++) {
        var o = i[a], c = this.identifyInternal(r + o[0], t + o[1], n);
        if (c)
          return c;
      }
    }, e.prototype.getPosition = function(r, t, n) {
      var a = this.webgl;
      if (!a.isContextLost) {
        r *= a.pixelRatio, t *= a.pixelRatio, t = this.pickPass.drawingBufferHeight - t;
        var i = this.viewport;
        if (!(r < i.x || t < i.y || r > i.x + i.width || t > i.y + i.height)) {
          this.dirty && (this.render(n), this.syncBuffers());
          var o = 255 / 256, c = If.Vec3.create(256 * 256 * 256, 256 * 256, 256), s = If.Vec4.create(o / c[0], o / c[1], o / c[2], o / 1), u = (0, If.Vec4)();
          If.Vec4.set(u, 128 / 255, 128 / 255, 30 / 255, 60 / 255);
          var l = If.Vec4.dot(u, s) / (n.zoom / 40);
          l > 0.2 && (l = 0.1);
          var f = If.Vec3.create(r, i.height - t, l);
          return (0, E2.cameraUnproject)(f, f, i, n.inverseProjectionView), { position: f };
        }
      }
    }, e;
  }()
);
f0.PickHelper = A0e;
var oH = {}, Cy = {}, V4 = {};
Object.defineProperty(V4, "__esModule", { value: !0 });
V4.depthMerge_frag = void 0;
V4.depthMerge_frag = `
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);
}
`;
var R4 = {}, O4 = {};
Object.defineProperty(O4, "__esModule", { value: !0 });
O4.evaluateWboit_frag = void 0;
O4.evaluateWboit_frag = `
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);
}
`;
Object.defineProperty(R4, "__esModule", { value: !0 });
R4.WboitPass = void 0;
var X1 = Te, uH = Yi, x0e = Kt, aT = yn, T0e = Bn(), P0e = Lt, ob = We(), M0e = Qi, w0e = O4, sH = Re, E0e = Zt, D0e = (0, X1.__assign)((0, X1.__assign)({}, uH.QuadSchema), { tWboitA: (0, aT.TextureSpec)("texture", "rgba", "float", "nearest"), tWboitB: (0, aT.TextureSpec)("texture", "rgba", "float", "nearest"), uTexSize: (0, aT.UniformSpec)("v2") }), I0e = (0, T0e.ShaderCode)("evaluate-wboit", M0e.quad_vert, w0e.evaluateWboit_frag);
function B0e(e, r, t) {
  var n = (0, X1.__assign)((0, X1.__assign)({}, uH.QuadValues), { tWboitA: ob.ValueCell.create(r), tWboitB: ob.ValueCell.create(t), uTexSize: ob.ValueCell.create(sH.Vec2.create(r.getWidth(), r.getHeight())) }), a = (0, X1.__assign)({}, D0e), i = (0, P0e.createComputeRenderItem)(e, "triangles", I0e, a, n);
  return (0, x0e.createComputeRenderable)(i, n);
}
var N0e = (
  /** @class */
  function() {
    function e(r, t, n) {
      if (this.webgl = r, this._supported = !1, !!e.isSupported(r)) {
        var a = r.resources;
        this.textureA = a.texture("image-float32", "rgba", "float", "nearest"), this.textureA.define(t, n), this.textureB = a.texture("image-float32", "rgba", "float", "nearest"), this.textureB.define(t, n), this.renderable = B0e(r, this.textureA, this.textureB), this.framebuffer = a.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 r = this.webgl, t = r.state, n = r.gl;
      this.framebuffer.bind(), t.clearColor(0, 0, 0, 1), n.clear(n.COLOR_BUFFER_BIT), t.disable(n.DEPTH_TEST), t.blendFuncSeparate(n.ONE, n.ONE, n.ZERO, n.ONE_MINUS_SRC_ALPHA), t.enable(n.BLEND);
    }, e.prototype.render = function() {
      var r = this.webgl, t = r.state, n = r.gl;
      t.blendFuncSeparate(n.SRC_ALPHA, n.ONE_MINUS_SRC_ALPHA, n.ONE, n.ONE_MINUS_SRC_ALPHA), t.enable(n.BLEND), this.renderable.update(), this.renderable.render();
    }, e.prototype.setSize = function(r, t) {
      var n = this.renderable.values.uTexSize.ref.value, a = n[0], i = n[1];
      (r !== a || t !== i) && (this.textureA.define(r, t), this.textureB.define(r, t), ob.ValueCell.update(this.renderable.values.uTexSize, sH.Vec2.set(this.renderable.values.uTexSize.ref.value, r, t)));
    }, e.prototype.reset = function() {
      this._supported && this._init();
    }, e.prototype._init = function() {
      var r = this.webgl.extensions.drawBuffers;
      this.framebuffer.bind(), r.drawBuffers([
        r.COLOR_ATTACHMENT0,
        r.COLOR_ATTACHMENT1
      ]), this.textureA.attachFramebuffer(this.framebuffer, "color0"), this.textureB.attachFramebuffer(this.framebuffer, "color1");
    }, e.isSupported = function(r) {
      var t = r.extensions, n = t.drawBuffers, a = t.textureFloat, i = t.colorBufferFloat, o = t.depthTexture;
      if (!a || !i || !o || !n) {
        if (E0e.isDebugMode) {
          var c = [];
          a || c.push("textureFloat"), i || c.push("colorBufferFloat"), o || c.push("depthTexture"), n || c.push("drawBuffers"), console.log('Missing "'.concat(c.join('", "'), '" extensions required for "wboit"'));
        }
        return !1;
      } else
        return !0;
    }, e;
  }()
);
R4.WboitPass = N0e;
var Id = {}, F4 = {};
Object.defineProperty(F4, "__esModule", { value: !0 });
F4.overlay_frag = void 0;
F4.overlay_frag = `
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);
    }
}
`;
var L4 = {};
Object.defineProperty(L4, "__esModule", { value: !0 });
L4.edge_frag = void 0;
L4.edge_frag = `
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);
}
`;
Object.defineProperty(Id, "__esModule", { value: !0 });
Id.MarkingPass = Id.MarkingParams = void 0;
var nl = Te, k4 = Yi, lH = Kt, jl = yn, cH = Bn(), dH = Lt, fv = Re, bi = We(), Sm = Le, fH = Qi, V0e = F4, Ym = Tr(), R0e = L4;
Id.MarkingParams = {
  enabled: Sm.ParamDefinition.Boolean(!0),
  highlightEdgeColor: Sm.ParamDefinition.Color(Ym.Color.darken(Ym.Color.fromNormalizedRgb(1, 0.4, 0.6), 1)),
  selectEdgeColor: Sm.ParamDefinition.Color(Ym.Color.darken(Ym.Color.fromNormalizedRgb(0.2, 1, 0.1), 1)),
  edgeScale: Sm.ParamDefinition.Numeric(1, { min: 1, max: 3, step: 1 }, { description: "Thickness of the edge." }),
  ghostEdgeStrength: Sm.ParamDefinition.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: Sm.ParamDefinition.Numeric(1.5, { min: 0, max: 3, step: 0.1 }, { description: "Factor to multiply the inner edge color with - for added contrast." })
};
var O0e = (
  /** @class */
  function() {
    function e(r, t, n) {
      this.webgl = r, this.depthTarget = r.createRenderTarget(t, n), this.maskTarget = r.createRenderTarget(t, n), this.edgesTarget = r.createRenderTarget(t, n), this.edge = k0e(r, this.maskTarget.texture), this.overlay = G0e(r, this.edgesTarget.texture);
    }
    return e.isEnabled = function(r) {
      return r.enabled;
    }, e.prototype.setEdgeState = function(r) {
      var t = this.webgl, n = t.gl, a = t.state;
      a.enable(n.SCISSOR_TEST), a.enable(n.BLEND), a.blendFunc(n.ONE, n.ONE), a.blendEquation(n.FUNC_ADD), a.disable(n.DEPTH_TEST), a.depthMask(!1);
      var i = r.x, o = r.y, c = r.width, s = r.height;
      n.viewport(i, o, c, s), n.scissor(i, o, c, s), a.clearColor(0, 0, 0, 0), n.clear(n.COLOR_BUFFER_BIT);
    }, e.prototype.setOverlayState = function(r) {
      var t = this.webgl, n = t.gl, a = t.state;
      a.enable(n.SCISSOR_TEST), a.enable(n.BLEND), a.blendFunc(n.SRC_ALPHA, n.ONE_MINUS_SRC_ALPHA), a.blendEquation(n.FUNC_ADD), a.disable(n.DEPTH_TEST), a.depthMask(!1);
      var i = r.x, o = r.y, c = r.width, s = r.height;
      n.viewport(i, o, c, s), n.scissor(i, o, c, s);
    }, e.prototype.setSize = function(r, t) {
      var n = this.depthTarget.getWidth(), a = this.depthTarget.getHeight();
      (r !== n || t !== a) && (this.depthTarget.setSize(r, t), this.maskTarget.setSize(r, t), this.edgesTarget.setSize(r, t), bi.ValueCell.update(this.edge.values.uTexSizeInv, fv.Vec2.set(this.edge.values.uTexSizeInv.ref.value, 1 / r, 1 / t)), bi.ValueCell.update(this.overlay.values.uTexSizeInv, fv.Vec2.set(this.overlay.values.uTexSizeInv.ref.value, 1 / r, 1 / t)));
    }, e.prototype.update = function(r) {
      var t = r.highlightEdgeColor, n = r.selectEdgeColor, a = r.edgeScale, i = r.innerEdgeFactor, o = r.ghostEdgeStrength, c = this.edge.values, s = Math.round(a * this.webgl.pixelRatio);
      c.dEdgeScale.ref.value !== s && (bi.ValueCell.update(c.dEdgeScale, s), this.edge.update());
      var u = this.overlay.values;
      bi.ValueCell.update(u.uHighlightEdgeColor, Ym.Color.toVec3Normalized(u.uHighlightEdgeColor.ref.value, t)), bi.ValueCell.update(u.uSelectEdgeColor, Ym.Color.toVec3Normalized(u.uSelectEdgeColor.ref.value, n)), bi.ValueCell.update(u.uInnerEdgeFactor, i), bi.ValueCell.update(u.uGhostEdgeStrength, o);
    }, e.prototype.render = function(r, t) {
      this.edgesTarget.bind(), this.setEdgeState(r), this.edge.render(), t ? t.bind() : this.webgl.unbindFramebuffer(), this.setOverlayState(r), this.overlay.render();
    }, e;
  }()
);
Id.MarkingPass = O0e;
var F0e = (0, nl.__assign)((0, nl.__assign)({}, k4.QuadSchema), { tMaskTexture: (0, jl.TextureSpec)("texture", "rgba", "ubyte", "linear"), uTexSizeInv: (0, jl.UniformSpec)("v2"), dEdgeScale: (0, jl.DefineSpec)("number") }), L0e = (0, cH.ShaderCode)("edge", fH.quad_vert, R0e.edge_frag);
function k0e(e, r) {
  var t = r.getWidth(), n = r.getHeight(), a = (0, nl.__assign)((0, nl.__assign)({}, k4.QuadValues), { tMaskTexture: bi.ValueCell.create(r), uTexSizeInv: bi.ValueCell.create(fv.Vec2.create(1 / t, 1 / n)), dEdgeScale: bi.ValueCell.create(1) }), i = (0, nl.__assign)({}, F0e), o = (0, dH.createComputeRenderItem)(e, "triangles", L0e, i, a);
  return (0, lH.createComputeRenderable)(o, a);
}
var U0e = (0, nl.__assign)((0, nl.__assign)({}, k4.QuadSchema), { tEdgeTexture: (0, jl.TextureSpec)("texture", "rgba", "ubyte", "linear"), uTexSizeInv: (0, jl.UniformSpec)("v2"), uHighlightEdgeColor: (0, jl.UniformSpec)("v3"), uSelectEdgeColor: (0, jl.UniformSpec)("v3"), uGhostEdgeStrength: (0, jl.UniformSpec)("f"), uInnerEdgeFactor: (0, jl.UniformSpec)("f") }), z0e = (0, cH.ShaderCode)("overlay", fH.quad_vert, V0e.overlay_frag);
function G0e(e, r) {
  var t = r.getWidth(), n = r.getHeight(), a = (0, nl.__assign)((0, nl.__assign)({}, k4.QuadValues), { tEdgeTexture: bi.ValueCell.create(r), uTexSizeInv: bi.ValueCell.create(fv.Vec2.create(1 / t, 1 / n)), uHighlightEdgeColor: bi.ValueCell.create((0, fv.Vec3)()), uSelectEdgeColor: bi.ValueCell.create((0, fv.Vec3)()), uGhostEdgeStrength: bi.ValueCell.create(0), uInnerEdgeFactor: bi.ValueCell.create(0) }), i = (0, nl.__assign)({}, U0e), o = (0, dH.createComputeRenderItem)(e, "triangles", z0e, i, a);
  return (0, lH.createComputeRenderable)(o, a);
}
Object.defineProperty(Cy, "__esModule", { value: !0 });
Cy.DrawPass = void 0;
var Y1 = Te, q0e = Fz(), mH = Yi, D2 = yn, H0e = Kt, j0e = Bn(), $0e = Lt, Wf = We(), ub = Re, K0e = Qi, W0e = V4, X0e = N4, Y0e = R4, Bs = rl, $9 = Id, K9 = Yi, Q0e = (0, Y1.__assign)((0, Y1.__assign)({}, mH.QuadSchema), { tDepthPrimitives: (0, D2.TextureSpec)("texture", "depth", "ushort", "nearest"), tDepthVolumes: (0, D2.TextureSpec)("texture", "depth", "ushort", "nearest"), uTexSize: (0, D2.UniformSpec)("v2"), dPackedDepth: (0, D2.DefineSpec)("boolean") }), Z0e = (0, j0e.ShaderCode)("depth-merge", K0e.quad_vert, W0e.depthMerge_frag);
function J0e(e, r, t, n) {
  var a = (0, Y1.__assign)((0, Y1.__assign)({}, mH.QuadValues), { tDepthPrimitives: Wf.ValueCell.create(r), tDepthVolumes: Wf.ValueCell.create(t), uTexSize: Wf.ValueCell.create(ub.Vec2.create(r.getWidth(), r.getHeight())), dPackedDepth: Wf.ValueCell.create(n) }), i = (0, Y1.__assign)({}, Q0e), o = (0, $0e.createComputeRenderItem)(e, "triangles", Z0e, i, a);
  return (0, H0e.createComputeRenderable)(o, a);
}
var eme = (
  /** @class */
  function() {
    function e(r, t, n, a) {
      this.webgl = r;
      var i = r.extensions, o = r.resources, c = r.isWebGL2;
      this.drawTarget = (0, q0e.createNullRenderTarget)(r.gl), this.colorTarget = r.createRenderTarget(t, n, !0, "uint8", "linear"), this.packedDepth = !i.depthTexture, this.depthTarget = r.createRenderTarget(t, n), this.depthTexture = this.depthTarget.texture, this.depthTargetPrimitives = this.packedDepth ? r.createRenderTarget(t, n) : null, this.depthTargetVolumes = this.packedDepth ? r.createRenderTarget(t, n) : null, this.depthTexturePrimitives = this.depthTargetPrimitives ? this.depthTargetPrimitives.texture : o.texture("image-depth", "depth", c ? "float" : "ushort", "nearest"), this.depthTextureVolumes = this.depthTargetVolumes ? this.depthTargetVolumes.texture : o.texture("image-depth", "depth", c ? "float" : "ushort", "nearest"), this.packedDepth || (this.depthTexturePrimitives.define(t, n), this.depthTextureVolumes.define(t, n)), this.depthMerge = J0e(r, this.depthTexturePrimitives, this.depthTextureVolumes, this.packedDepth), this.wboit = a ? new Y0e.WboitPass(r, t, n) : void 0, this.marking = new $9.MarkingPass(r, t, n), this.postprocessing = new Bs.PostprocessingPass(r, this), this.antialiasing = new Bs.AntialiasingPass(r, this), this.copyFboTarget = (0, K9.createCopyRenderable)(r, this.colorTarget.texture), this.copyFboPostprocessing = (0, K9.createCopyRenderable)(r, this.postprocessing.target.texture);
    }
    return Object.defineProperty(e.prototype, "wboitEnabled", {
      get: function() {
        var r;
        return !!(!((r = this.wboit) === null || r === void 0) && r.supported);
      },
      enumerable: !1,
      configurable: !0
    }), e.prototype.reset = function() {
      var r;
      (r = this.wboit) === null || r === void 0 || r.reset();
    }, e.prototype.setSize = function(r, t) {
      var n, a = this.colorTarget.getWidth(), i = this.colorTarget.getHeight();
      (r !== a || t !== i) && (this.colorTarget.setSize(r, t), this.depthTarget.setSize(r, t), this.depthTargetPrimitives ? this.depthTargetPrimitives.setSize(r, t) : this.depthTexturePrimitives.define(r, t), this.depthTargetVolumes ? this.depthTargetVolumes.setSize(r, t) : this.depthTextureVolumes.define(r, t), Wf.ValueCell.update(this.depthMerge.values.uTexSize, ub.Vec2.set(this.depthMerge.values.uTexSize.ref.value, r, t)), Wf.ValueCell.update(this.copyFboTarget.values.uTexSize, ub.Vec2.set(this.copyFboTarget.values.uTexSize.ref.value, r, t)), Wf.ValueCell.update(this.copyFboPostprocessing.values.uTexSize, ub.Vec2.set(this.copyFboPostprocessing.values.uTexSize.ref.value, r, t)), !((n = this.wboit) === null || n === void 0) && n.supported && this.wboit.setSize(r, t), this.marking.setSize(r, t), this.postprocessing.setSize(r, t), this.antialiasing.setSize(r, t));
    }, e.prototype._depthMerge = function() {
      var r = this.webgl, t = r.state, n = r.gl;
      this.depthMerge.update(), this.depthTarget.bind(), t.disable(n.BLEND), t.disable(n.DEPTH_TEST), t.disable(n.CULL_FACE), t.depthMask(!1), t.clearColor(1, 1, 1, 1), n.clear(n.COLOR_BUFFER_BIT), this.depthMerge.render();
    }, e.prototype._renderWboit = function(r, t, n, a, i) {
      var o;
      if (!(!((o = this.wboit) === null || o === void 0) && o.supported))
        throw new Error("expected wboit to be supported");
      this.colorTarget.bind(), r.clear(!0), this.depthTexturePrimitives.attachFramebuffer(this.colorTarget.framebuffer, "depth"), this.colorTarget.bind(), r.clearDepth(), r.renderWboitOpaque(n.primitives, t, null), this.depthTextureVolumes.attachFramebuffer(this.colorTarget.framebuffer, "depth"), this.colorTarget.bind(), r.clearDepth(), r.renderWboitOpaque(n.volumes, t, this.depthTexturePrimitives), this._depthMerge(), Bs.PostprocessingPass.isEnabled(i) && this.postprocessing.render(t, !1, a, r.props.backgroundColor, i), this.wboit.bind(), r.renderWboitTransparent(n.primitives, t, this.depthTexture), r.renderWboitTransparent(n.volumes, t, this.depthTexture), Bs.PostprocessingPass.isEnabled(i) ? (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(r, t, n, a, i, o) {
      if (a ? this.drawTarget.bind() : (this.colorTarget.bind(), this.packedDepth || this.depthTexturePrimitives.attachFramebuffer(this.colorTarget.framebuffer, "depth")), r.clear(!0), r.renderBlendedOpaque(n.primitives, t, null), !a) {
        this.depthTargetPrimitives && (this.depthTargetPrimitives.bind(), r.clear(!1), r.renderDepth(n.primitives, t, null), this.colorTarget.bind()), this.packedDepth || (this.depthTextureVolumes.attachFramebuffer(this.colorTarget.framebuffer, "depth"), r.clearDepth()), r.renderBlendedVolumeOpaque(n.volumes, t, this.depthTexturePrimitives), this.depthTargetVolumes && (this.depthTargetVolumes.bind(), r.clear(!1), r.renderDepth(n.volumes, t, this.depthTexturePrimitives), this.colorTarget.bind()), this._depthMerge(), this.colorTarget.bind(), Bs.PostprocessingPass.isEnabled(o) && this.postprocessing.render(t, !1, i, r.props.backgroundColor, o), r.renderBlendedVolumeTransparent(n.volumes, t, this.depthTexturePrimitives);
        var c = Bs.PostprocessingPass.isEnabled(o) ? this.postprocessing.target : this.colorTarget;
        this.packedDepth || this.depthTexturePrimitives.attachFramebuffer(c.framebuffer, "depth"), c.bind();
      }
      r.renderBlendedTransparent(n.primitives, t, null);
    }, e.prototype._render = function(r, t, n, a, i, o) {
      var c = n.volumes.renderables.length > 0, s = Bs.PostprocessingPass.isEnabled(o.postprocessing), u = Bs.AntialiasingPass.isEnabled(o.postprocessing), l = $9.MarkingPass.isEnabled(o.marking), f = t.viewport, d = f.x, m = f.y, p = f.width, v = f.height;
      if (r.setViewport(d, m, p, v), r.update(t), o.transparentBackground && !u && i && (this.drawTarget.bind(), r.clear(!1)), this.wboitEnabled ? this._renderWboit(r, t, n, o.transparentBackground, o.postprocessing) : this._renderBlended(r, t, n, !c && !s && !u && i, o.transparentBackground, o.postprocessing), s ? this.postprocessing.target.bind() : !i || c || this.wboitEnabled ? this.colorTarget.bind() : this.drawTarget.bind(), l) {
        var h = n.getMarkerAverage();
        if (h > 0) {
          var y = o.marking.ghostEdgeStrength < 1;
          y && h !== 1 && (this.marking.depthTarget.bind(), r.clear(!1, !0), r.renderMarkingDepth(n.primitives, t, null)), this.marking.maskTarget.bind(), r.clear(!1, !0), r.renderMarkingMask(n.primitives, t, y ? this.marking.depthTarget.texture : null), this.marking.update(o.marking), this.marking.render(t.viewport, s ? this.postprocessing.target : this.colorTarget);
        }
      }
      a.debug.isEnabled && (a.debug.syncVisibility(), r.renderBlended(a.debug.scene, t, null)), a.handle.isEnabled && r.renderBlended(a.handle.scene, t, null), a.camera.isEnabled && (a.camera.update(t), r.update(a.camera.camera), r.renderBlended(a.camera.scene, a.camera.camera, null)), u ? this.antialiasing.render(t, i, o.postprocessing) : i && (this.drawTarget.bind(), this.webgl.state.disable(this.webgl.gl.DEPTH_TEST), s ? this.copyFboPostprocessing.render() : (c || this.wboitEnabled) && this.copyFboTarget.render()), this.webgl.gl.flush();
    }, e.prototype.render = function(r, t, n) {
      var a = r.renderer, i = r.camera, o = r.scene, c = r.helper;
      a.setTransparentBackground(t.transparentBackground), a.setDrawingBufferSize(this.colorTarget.getWidth(), this.colorTarget.getHeight()), a.setPixelRatio(this.webgl.pixelRatio), X0e.StereoCamera.is(i) ? (this._render(a, i.left, o, c, n, t), this._render(a, i.right, o, c, n, t)) : this._render(a, i, o, c, n, t);
    }, e.prototype.getColorTarget = function(r) {
      return Bs.AntialiasingPass.isEnabled(r) ? this.antialiasing.target : Bs.PostprocessingPass.isEnabled(r) ? this.postprocessing.target : this.colorTarget;
    }, e;
  }()
);
Cy.DrawPass = eme;
var Ay = {};
function an(e) {
  for (var r = arguments.length, t = Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++) t[n - 1] = arguments[n];
  if (process.env.NODE_ENV !== "production") {
    var a = lme[e], i = a ? typeof a == "function" ? a.apply(null, t) : a : "unknown error nr: " + e;
    throw Error("[Immer] " + i);
  }
  throw Error("[Immer] minified error nr: " + e + (t.length ? " " + t.map(function(o) {
    return "'" + o + "'";
  }).join(",") : "") + ". Find the full error at: https://bit.ly/3cXEKWf");
}
function ol(e) {
  return !!e && !!e[jr];
}
function ss(e) {
  return !!e && (function(r) {
    if (!r || typeof r != "object") return !1;
    var t = Object.getPrototypeOf(r);
    if (t === null) return !0;
    var n = Object.hasOwnProperty.call(t, "constructor") && t.constructor;
    return n === Object || typeof n == "function" && Function.toString.call(n) === cme;
  }(e) || Array.isArray(e) || !!e[mv] || !!e.constructor[mv] || U4(e) || z4(e));
}
function rme(e) {
  return ol(e) || an(23, e), e[jr].t;
}
function pc(e, r, t) {
  t === void 0 && (t = !1), Bd(e) === 0 ? (t ? Object.keys : vv)(e).forEach(function(n) {
    t && typeof n == "symbol" || r(n, e[n], e);
  }) : e.forEach(function(n, a) {
    return r(a, n, e);
  });
}
function Bd(e) {
  var r = e[jr];
  return r ? r.i > 3 ? r.i - 4 : r.i : Array.isArray(e) ? 1 : U4(e) ? 2 : z4(e) ? 3 : 0;
}
function Sd(e, r) {
  return Bd(e) === 2 ? e.has(r) : Object.prototype.hasOwnProperty.call(e, r);
}
function sb(e, r) {
  return Bd(e) === 2 ? e.get(r) : e[r];
}
function vH(e, r, t) {
  var n = Bd(e);
  n === 2 ? e.set(r, t) : n === 3 ? (e.delete(r), e.add(t)) : e[r] = t;
}
function pH(e, r) {
  return e === r ? e !== 0 || 1 / e == 1 / r : e != e && r != r;
}
function U4(e) {
  return ume && e instanceof Map;
}
function z4(e) {
  return sme && e instanceof Set;
}
function sa(e) {
  return e.o || e.t;
}
function qE(e) {
  if (Array.isArray(e)) return Array.prototype.slice.call(e);
  var r = bH(e);
  delete r[jr];
  for (var t = vv(r), n = 0; n < t.length; n++) {
    var a = t[n], i = r[a];
    i.writable === !1 && (i.writable = !0, i.configurable = !0), (i.get || i.set) && (r[a] = { configurable: !0, writable: !0, enumerable: i.enumerable, value: e[a] });
  }
  return Object.create(Object.getPrototypeOf(e), r);
}
function G4(e, r) {
  return r === void 0 && (r = !1), HE(e) || ol(e) || !ss(e) || (Bd(e) > 1 && (e.set = e.add = e.clear = e.delete = tme), Object.freeze(e), r && pc(e, function(t, n) {
    return G4(n, !0);
  }, !0)), e;
}
function tme() {
  an(2);
}
function HE(e) {
  return e == null || typeof e != "object" || Object.isFrozen(e);
}
function al(e) {
  var r = $M[e];
  return r || an(18, e), r;
}
function jE(e, r) {
  $M[e] || ($M[e] = r);
}
function wg() {
  return process.env.NODE_ENV === "production" || Uv || an(0), Uv;
}
function iT(e, r) {
  r && (al("Patches"), e.u = [], e.s = [], e.v = r);
}
function jb(e) {
  jM(e), e.p.forEach(nme), e.p = null;
}
function jM(e) {
  e === Uv && (Uv = e.l);
}
function W9(e) {
  return Uv = { p: [], l: Uv, h: e, m: !0, _: 0 };
}
function nme(e) {
  var r = e[jr];
  r.i === 0 || r.i === 1 ? r.j() : r.O = !0;
}
function oT(e, r) {
  r._ = r.p.length;
  var t = r.p[0], n = e !== void 0 && e !== t;
  return r.h.g || al("ES5").S(r, e, n), n ? (t[jr].P && (jb(r), an(4)), ss(e) && (e = $b(r, e), r.l || Kb(r, e)), r.u && al("Patches").M(t[jr].t, e, r.u, r.s)) : e = $b(r, t, []), jb(r), r.u && r.v(r.u, r.s), e !== q4 ? e : void 0;
}
function $b(e, r, t) {
  if (HE(r)) return r;
  var n = r[jr];
  if (!n) return pc(r, function(i, o) {
    return X9(e, n, r, i, o, t);
  }, !0), r;
  if (n.A !== e) return r;
  if (!n.P) return Kb(e, n.t, !0), n.t;
  if (!n.I) {
    n.I = !0, n.A._--;
    var a = n.i === 4 || n.i === 5 ? n.o = qE(n.k) : n.o;
    pc(n.i === 3 ? new Set(a) : a, function(i, o) {
      return X9(e, n, a, i, o, t);
    }), Kb(e, a, !1), t && e.u && al("Patches").R(n, t, e.u, e.s);
  }
  return n.o;
}
function X9(e, r, t, n, a, i) {
  if (process.env.NODE_ENV !== "production" && a === t && an(5), ol(a)) {
    var o = $b(e, a, i && r && r.i !== 3 && !Sd(r.D, n) ? i.concat(n) : void 0);
    if (vH(t, n, o), !ol(o)) return;
    e.m = !1;
  }
  if (ss(a) && !HE(a)) {
    if (!e.h.F && e._ < 1) return;
    $b(e, a), r && r.A.l || Kb(e, a);
  }
}
function Kb(e, r, t) {
  t === void 0 && (t = !1), e.h.F && e.m && G4(r, t);
}
function uT(e, r) {
  var t = e[jr];
  return (t ? sa(t) : e)[r];
}
function Y9(e, r) {
  if (r in e) for (var t = Object.getPrototypeOf(e); t; ) {
    var n = Object.getOwnPropertyDescriptor(t, r);
    if (n) return n;
    t = Object.getPrototypeOf(t);
  }
}
function fo(e) {
  e.P || (e.P = !0, e.l && fo(e.l));
}
function sT(e) {
  e.o || (e.o = qE(e.t));
}
function Eg(e, r, t) {
  var n = U4(r) ? al("MapSet").N(r, t) : z4(r) ? al("MapSet").T(r, t) : e.g ? function(a, i) {
    var o = Array.isArray(a), c = { i: o ? 1 : 0, A: i ? i.A : wg(), P: !1, I: !1, D: {}, l: i, t: a, k: null, o: null, j: null, C: !1 }, s = c, u = Dg;
    o && (s = [c], u = L1);
    var l = Proxy.revocable(s, u), f = l.revoke, d = l.proxy;
    return c.k = d, c.j = f, d;
  }(r, t) : al("ES5").J(r, t);
  return (t ? t.A : wg()).p.push(n), n;
}
function hH(e) {
  return ol(e) || an(22, e), function r(t) {
    if (!ss(t)) return t;
    var n, a = t[jr], i = Bd(t);
    if (a) {
      if (!a.P && (a.i < 4 || !al("ES5").K(a))) return a.t;
      a.I = !0, n = Q9(t, i), a.I = !1;
    } else n = Q9(t, i);
    return pc(n, function(o, c) {
      a && sb(a.t, o) === c || vH(n, o, r(c));
    }), i === 3 ? new Set(n) : n;
  }(e);
}
function Q9(e, r) {
  switch (r) {
    case 2:
      return new Map(e);
    case 3:
      return Array.from(e);
  }
  return qE(e);
}
function gH() {
  function e(o, c) {
    var s = i[o];
    return s ? s.enumerable = c : i[o] = s = { configurable: !0, enumerable: c, get: function() {
      var u = this[jr];
      return process.env.NODE_ENV !== "production" && a(u), Dg.get(u, o);
    }, set: function(u) {
      var l = this[jr];
      process.env.NODE_ENV !== "production" && a(l), Dg.set(l, o, u);
    } }, s;
  }
  function r(o) {
    for (var c = o.length - 1; c >= 0; c--) {
      var s = o[c][jr];
      if (!s.P) switch (s.i) {
        case 5:
          n(s) && fo(s);
          break;
        case 4:
          t(s) && fo(s);
      }
    }
  }
  function t(o) {
    for (var c = o.t, s = o.k, u = vv(s), l = u.length - 1; l >= 0; l--) {
      var f = u[l];
      if (f !== jr) {
        var d = c[f];
        if (d === void 0 && !Sd(c, f)) return !0;
        var m = s[f], p = m && m[jr];
        if (p ? p.t !== d : !pH(m, d)) return !0;
      }
    }
    var v = !!c[jr];
    return u.length !== vv(c).length + (v ? 0 : 1);
  }
  function n(o) {
    var c = o.k;
    if (c.length !== o.t.length) return !0;
    var s = Object.getOwnPropertyDescriptor(c, c.length - 1);
    if (s && !s.get) return !0;
    for (var u = 0; u < c.length; u++) if (!c.hasOwnProperty(u)) return !0;
    return !1;
  }
  function a(o) {
    o.O && an(3, JSON.stringify(sa(o)));
  }
  var i = {};
  jE("ES5", { J: function(o, c) {
    var s = Array.isArray(o), u = function(f, d) {
      if (f) {
        for (var m = Array(d.length), p = 0; p < d.length; p++) Object.defineProperty(m, "" + p, e(p, !0));
        return m;
      }
      var v = bH(d);
      delete v[jr];
      for (var h = vv(v), y = 0; y < h.length; y++) {
        var C = h[y];
        v[C] = e(C, f || !!v[C].enumerable);
      }
      return Object.create(Object.getPrototypeOf(d), v);
    }(s, o), l = { i: s ? 5 : 4, A: c ? c.A : wg(), P: !1, I: !1, D: {}, l: c, t: o, k: u, o: null, O: !1, C: !1 };
    return Object.defineProperty(u, jr, { value: l, writable: !0 }), u;
  }, S: function(o, c, s) {
    s ? ol(c) && c[jr].A === o && r(o.p) : (o.u && function u(l) {
      if (l && typeof l == "object") {
        var f = l[jr];
        if (f) {
          var d = f.t, m = f.k, p = f.D, v = f.i;
          if (v === 4) pc(m, function(b) {
            b !== jr && (d[b] !== void 0 || Sd(d, b) ? p[b] || u(m[b]) : (p[b] = !0, fo(f)));
          }), pc(d, function(b) {
            m[b] !== void 0 || Sd(m, b) || (p[b] = !1, fo(f));
          });
          else if (v === 5) {
            if (n(f) && (fo(f), p.length = !0), m.length < d.length) for (var h = m.length; h < d.length; h++) p[h] = !1;
            else for (var y = d.length; y < m.length; y++) p[y] = !0;
            for (var C = Math.min(m.length, d.length), S = 0; S < C; S++) m.hasOwnProperty(S) || (p[S] = !0), p[S] === void 0 && u(m[S]);
          }
        }
      }
    }(o.p[0]), r(o.p));
  }, K: function(o) {
    return o.i === 4 ? t(o) : n(o);
  } });
}
function yH() {
  function e(n) {
    if (!ss(n)) return n;
    if (Array.isArray(n)) return n.map(e);
    if (U4(n)) return new Map(Array.from(n.entries()).map(function(o) {
      return [o[0], e(o[1])];
    }));
    if (z4(n)) return new Set(Array.from(n).map(e));
    var a = Object.create(Object.getPrototypeOf(n));
    for (var i in n) a[i] = e(n[i]);
    return Sd(n, mv) && (a[mv] = n[mv]), a;
  }
  function r(n) {
    return ol(n) ? e(n) : n;
  }
  var t = "add";
  jE("Patches", { $: function(n, a) {
    return a.forEach(function(i) {
      for (var o = i.path, c = i.op, s = n, u = 0; u < o.length - 1; u++) {
        var l = Bd(s), f = "" + o[u];
        l !== 0 && l !== 1 || f !== "__proto__" && f !== "constructor" || an(24), typeof s == "function" && f === "prototype" && an(24), typeof (s = sb(s, f)) != "object" && an(15, o.join("/"));
      }
      var d = Bd(s), m = e(i.value), p = o[o.length - 1];
      switch (c) {
        case "replace":
          switch (d) {
            case 2:
              return s.set(p, m);
            case 3:
              an(16);
            default:
              return s[p] = m;
          }
        case t:
          switch (d) {
            case 1:
              return p === "-" ? s.push(m) : s.splice(p, 0, m);
            case 2:
              return s.set(p, m);
            case 3:
              return s.add(m);
            default:
              return s[p] = m;
          }
        case "remove":
          switch (d) {
            case 1:
              return s.splice(p, 1);
            case 2:
              return s.delete(p);
            case 3:
              return s.delete(i.value);
            default:
              return delete s[p];
          }
        default:
          an(17, c);
      }
    }), n;
  }, R: function(n, a, i, o) {
    switch (n.i) {
      case 0:
      case 4:
      case 2:
        return function(c, s, u, l) {
          var f = c.t, d = c.o;
          pc(c.D, function(m, p) {
            var v = sb(f, m), h = sb(d, m), y = p ? Sd(f, m) ? "replace" : t : "remove";
            if (v !== h || y !== "replace") {
              var C = s.concat(m);
              u.push(y === "remove" ? { op: y, path: C } : { op: y, path: C, value: h }), l.push(y === t ? { op: "remove", path: C } : y === "remove" ? { op: t, path: C, value: r(v) } : { op: "replace", path: C, value: r(v) });
            }
          });
        }(n, a, i, o);
      case 5:
      case 1:
        return function(c, s, u, l) {
          var f = c.t, d = c.D, m = c.o;
          if (m.length < f.length) {
            var p = [m, f];
            f = p[0], m = p[1];
            var v = [l, u];
            u = v[0], l = v[1];
          }
          for (var h = 0; h < f.length; h++) if (d[h] && m[h] !== f[h]) {
            var y = s.concat([h]);
            u.push({ op: "replace", path: y, value: r(m[h]) }), l.push({ op: "replace", path: y, value: r(f[h]) });
          }
          for (var C = f.length; C < m.length; C++) {
            var S = s.concat([C]);
            u.push({ op: t, path: S, value: r(m[C]) });
          }
          f.length < m.length && l.push({ op: "replace", path: s.concat(["length"]), value: f.length });
        }(n, a, i, o);
      case 3:
        return function(c, s, u, l) {
          var f = c.t, d = c.o, m = 0;
          f.forEach(function(p) {
            if (!d.has(p)) {
              var v = s.concat([m]);
              u.push({ op: "remove", path: v, value: p }), l.unshift({ op: t, path: v, value: p });
            }
            m++;
          }), m = 0, d.forEach(function(p) {
            if (!f.has(p)) {
              var v = s.concat([m]);
              u.push({ op: t, path: v, value: p }), l.unshift({ op: "remove", path: v, value: p });
            }
            m++;
          });
        }(n, a, i, o);
    }
  }, M: function(n, a, i, o) {
    i.push({ op: "replace", path: [], value: a === q4 ? void 0 : a }), o.push({ op: "replace", path: [], value: n });
  } });
}
function _H() {
  function e(c, s) {
    function u() {
      this.constructor = c;
    }
    a(c, s), c.prototype = (u.prototype = s.prototype, new u());
  }
  function r(c) {
    c.o || (c.D = /* @__PURE__ */ new Map(), c.o = new Map(c.t));
  }
  function t(c) {
    c.o || (c.o = /* @__PURE__ */ new Set(), c.t.forEach(function(s) {
      if (ss(s)) {
        var u = Eg(c.A.h, s, c);
        c.p.set(s, u), c.o.add(u);
      } else c.o.add(s);
    }));
  }
  function n(c) {
    c.O && an(3, JSON.stringify(sa(c)));
  }
  var a = function(c, s) {
    return (a = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(u, l) {
      u.__proto__ = l;
    } || function(u, l) {
      for (var f in l) l.hasOwnProperty(f) && (u[f] = l[f]);
    })(c, s);
  }, i = function() {
    function c(u, l) {
      return this[jr] = { i: 2, l, A: l ? l.A : wg(), P: !1, I: !1, o: void 0, D: void 0, t: u, k: this, C: !1, O: !1 }, this;
    }
    e(c, Map);
    var s = c.prototype;
    return Object.defineProperty(s, "size", { get: function() {
      return sa(this[jr]).size;
    } }), s.has = function(u) {
      return sa(this[jr]).has(u);
    }, s.set = function(u, l) {
      var f = this[jr];
      return n(f), sa(f).has(u) && sa(f).get(u) === l || (r(f), fo(f), f.D.set(u, !0), f.o.set(u, l), f.D.set(u, !0)), this;
    }, s.delete = function(u) {
      if (!this.has(u)) return !1;
      var l = this[jr];
      return n(l), r(l), fo(l), l.t.has(u) ? l.D.set(u, !1) : l.D.delete(u), l.o.delete(u), !0;
    }, s.clear = function() {
      var u = this[jr];
      n(u), sa(u).size && (r(u), fo(u), u.D = /* @__PURE__ */ new Map(), pc(u.t, function(l) {
        u.D.set(l, !1);
      }), u.o.clear());
    }, s.forEach = function(u, l) {
      var f = this;
      sa(this[jr]).forEach(function(d, m) {
        u.call(l, f.get(m), m, f);
      });
    }, s.get = function(u) {
      var l = this[jr];
      n(l);
      var f = sa(l).get(u);
      if (l.I || !ss(f) || f !== l.t.get(u)) return f;
      var d = Eg(l.A.h, f, l);
      return r(l), l.o.set(u, d), d;
    }, s.keys = function() {
      return sa(this[jr]).keys();
    }, s.values = function() {
      var u, l = this, f = this.keys();
      return (u = {})[I2] = function() {
        return l.values();
      }, u.next = function() {
        var d = f.next();
        return d.done ? d : { done: !1, value: l.get(d.value) };
      }, u;
    }, s.entries = function() {
      var u, l = this, f = this.keys();
      return (u = {})[I2] = function() {
        return l.entries();
      }, u.next = function() {
        var d = f.next();
        if (d.done) return d;
        var m = l.get(d.value);
        return { done: !1, value: [d.value, m] };
      }, u;
    }, s[I2] = function() {
      return this.entries();
    }, c;
  }(), o = function() {
    function c(u, l) {
      return this[jr] = { i: 3, l, A: l ? l.A : wg(), P: !1, I: !1, o: void 0, t: u, k: this, p: /* @__PURE__ */ new Map(), O: !1, C: !1 }, this;
    }
    e(c, Set);
    var s = c.prototype;
    return Object.defineProperty(s, "size", { get: function() {
      return sa(this[jr]).size;
    } }), s.has = function(u) {
      var l = this[jr];
      return n(l), l.o ? !!l.o.has(u) || !(!l.p.has(u) || !l.o.has(l.p.get(u))) : l.t.has(u);
    }, s.add = function(u) {
      var l = this[jr];
      return n(l), this.has(u) || (t(l), fo(l), l.o.add(u)), this;
    }, s.delete = function(u) {
      if (!this.has(u)) return !1;
      var l = this[jr];
      return n(l), t(l), fo(l), l.o.delete(u) || !!l.p.has(u) && l.o.delete(l.p.get(u));
    }, s.clear = function() {
      var u = this[jr];
      n(u), sa(u).size && (t(u), fo(u), u.o.clear());
    }, s.values = function() {
      var u = this[jr];
      return n(u), t(u), u.o.values();
    }, s.entries = function() {
      var u = this[jr];
      return n(u), t(u), u.o.entries();
    }, s.keys = function() {
      return this.values();
    }, s[I2] = function() {
      return this.values();
    }, s.forEach = function(u, l) {
      for (var f = this.values(), d = f.next(); !d.done; ) u.call(l, d.value, d.value, this), d = f.next();
    }, c;
  }();
  jE("MapSet", { N: function(c, s) {
    return new i(c, s);
  }, T: function(c, s) {
    return new o(c, s);
  } });
}
function ame() {
  gH(), _H(), yH();
}
function ime(e) {
  return e;
}
function ome(e) {
  return e;
}
var Z9, Uv, $E = typeof Symbol < "u" && typeof Symbol("x") == "symbol", ume = typeof Map < "u", sme = typeof Set < "u", J9 = typeof Proxy < "u" && Proxy.revocable !== void 0 && typeof Reflect < "u", q4 = $E ? Symbol.for("immer-nothing") : ((Z9 = {})["immer-nothing"] = !0, Z9), mv = $E ? Symbol.for("immer-draftable") : "__$immer_draftable", jr = $E ? Symbol.for("immer-state") : "__$immer_state", I2 = typeof Symbol < "u" && Symbol.iterator || "@@iterator", lme = { 0: "Illegal state", 1: "Immer drafts cannot have computed properties", 2: "This object has been frozen and should not be mutated", 3: function(e) {
  return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + e;
}, 4: "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.", 5: "Immer forbids circular references", 6: "The first or second argument to `produce` must be a function", 7: "The third argument to `produce` must be a function or undefined", 8: "First argument to `createDraft` must be a plain object, an array, or an immerable object", 9: "First argument to `finishDraft` must be a draft returned by `createDraft`", 10: "The given draft is already finalized", 11: "Object.defineProperty() cannot be used on an Immer draft", 12: "Object.setPrototypeOf() cannot be used on an Immer draft", 13: "Immer only supports deleting array indices", 14: "Immer only supports setting array indices and the 'length' property", 15: function(e) {
  return "Cannot apply patch, path doesn't resolve: " + e;
}, 16: 'Sets cannot have "replace" patches.', 17: function(e) {
  return "Unsupported patch operation: " + e;
}, 18: function(e) {
  return "The plugin for '" + e + "' has not been loaded into Immer. To enable the plugin, import and call `enable" + e + "()` when initializing your application.";
}, 20: "Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available", 21: function(e) {
  return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '" + e + "'";
}, 22: function(e) {
  return "'current' expects a draft, got: " + e;
}, 23: function(e) {
  return "'original' expects a draft, got: " + e;
}, 24: "Patching reserved attributes like __proto__, prototype and constructor is not allowed" }, cme = "" + Object.prototype.constructor, vv = typeof Reflect < "u" && Reflect.ownKeys ? Reflect.ownKeys : Object.getOwnPropertySymbols !== void 0 ? function(e) {
  return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e));
} : Object.getOwnPropertyNames, bH = Object.getOwnPropertyDescriptors || function(e) {
  var r = {};
  return vv(e).forEach(function(t) {
    r[t] = Object.getOwnPropertyDescriptor(e, t);
  }), r;
}, $M = {}, Dg = { get: function(e, r) {
  if (r === jr) return e;
  var t = sa(e);
  if (!Sd(t, r)) return function(a, i, o) {
    var c, s = Y9(i, o);
    return s ? "value" in s ? s.value : (c = s.get) === null || c === void 0 ? void 0 : c.call(a.k) : void 0;
  }(e, t, r);
  var n = t[r];
  return e.I || !ss(n) ? n : n === uT(e.t, r) ? (sT(e), e.o[r] = Eg(e.A.h, n, e)) : n;
}, has: function(e, r) {
  return r in sa(e);
}, ownKeys: function(e) {
  return Reflect.ownKeys(sa(e));
}, set: function(e, r, t) {
  var n = Y9(sa(e), r);
  if (n != null && n.set) return n.set.call(e.k, t), !0;
  if (!e.P) {
    var a = uT(sa(e), r), i = a == null ? void 0 : a[jr];
    if (i && i.t === t) return e.o[r] = t, e.D[r] = !1, !0;
    if (pH(t, a) && (t !== void 0 || Sd(e.t, r))) return !0;
    sT(e), fo(e);
  }
  return e.o[r] === t && typeof t != "number" && (t !== void 0 || r in e.o) || (e.o[r] = t, e.D[r] = !0, !0);
}, deleteProperty: function(e, r) {
  return uT(e.t, r) !== void 0 || r in e.t ? (e.D[r] = !1, sT(e), fo(e)) : delete e.D[r], e.o && delete e.o[r], !0;
}, getOwnPropertyDescriptor: function(e, r) {
  var t = sa(e), n = Reflect.getOwnPropertyDescriptor(t, r);
  return n && { writable: !0, configurable: e.i !== 1 || r !== "length", enumerable: n.enumerable, value: t[r] };
}, defineProperty: function() {
  an(11);
}, getPrototypeOf: function(e) {
  return Object.getPrototypeOf(e.t);
}, setPrototypeOf: function() {
  an(12);
} }, L1 = {};
pc(Dg, function(e, r) {
  L1[e] = function() {
    return arguments[0] = arguments[0][0], r.apply(this, arguments);
  };
}), L1.deleteProperty = function(e, r) {
  return process.env.NODE_ENV !== "production" && isNaN(parseInt(r)) && an(13), L1.set.call(this, e, r, void 0);
}, L1.set = function(e, r, t) {
  return process.env.NODE_ENV !== "production" && r !== "length" && isNaN(parseInt(r)) && an(14), Dg.set.call(this, e[0], r, t, e[0]);
};
var SH = function() {
  function e(t) {
    var n = this;
    this.g = J9, this.F = !0, this.produce = function(a, i, o) {
      if (typeof a == "function" && typeof i != "function") {
        var c = i;
        i = a;
        var s = n;
        return function(v) {
          var h = this;
          v === void 0 && (v = c);
          for (var y = arguments.length, C = Array(y > 1 ? y - 1 : 0), S = 1; S < y; S++) C[S - 1] = arguments[S];
          return s.produce(v, function(b) {
            var g;
            return (g = i).call.apply(g, [h, b].concat(C));
          });
        };
      }
      var u;
      if (typeof i != "function" && an(6), o !== void 0 && typeof o != "function" && an(7), ss(a)) {
        var l = W9(n), f = Eg(n, a, void 0), d = !0;
        try {
          u = i(f), d = !1;
        } finally {
          d ? jb(l) : jM(l);
        }
        return typeof Promise < "u" && u instanceof Promise ? u.then(function(v) {
          return iT(l, o), oT(v, l);
        }, function(v) {
          throw jb(l), v;
        }) : (iT(l, o), oT(u, l));
      }
      if (!a || typeof a != "object") {
        if ((u = i(a)) === void 0 && (u = a), u === q4 && (u = void 0), n.F && G4(u, !0), o) {
          var m = [], p = [];
          al("Patches").M(a, u, m, p), o(m, p);
        }
        return u;
      }
      an(21, a);
    }, this.produceWithPatches = function(a, i) {
      if (typeof a == "function") return function(u) {
        for (var l = arguments.length, f = Array(l > 1 ? l - 1 : 0), d = 1; d < l; d++) f[d - 1] = arguments[d];
        return n.produceWithPatches(u, function(m) {
          return a.apply(void 0, [m].concat(f));
        });
      };
      var o, c, s = n.produce(a, i, function(u, l) {
        o = u, c = l;
      });
      return typeof Promise < "u" && s instanceof Promise ? s.then(function(u) {
        return [u, o, c];
      }) : [s, o, c];
    }, typeof (t == null ? void 0 : t.useProxies) == "boolean" && this.setUseProxies(t.useProxies), typeof (t == null ? void 0 : t.autoFreeze) == "boolean" && this.setAutoFreeze(t.autoFreeze);
  }
  var r = e.prototype;
  return r.createDraft = function(t) {
    ss(t) || an(8), ol(t) && (t = hH(t));
    var n = W9(this), a = Eg(this, t, void 0);
    return a[jr].C = !0, jM(n), a;
  }, r.finishDraft = function(t, n) {
    var a = t && t[jr];
    process.env.NODE_ENV !== "production" && (a && a.C || an(9), a.I && an(10));
    var i = a.A;
    return iT(i, n), oT(void 0, i);
  }, r.setAutoFreeze = function(t) {
    this.F = t;
  }, r.setUseProxies = function(t) {
    t && !J9 && an(20), this.g = t;
  }, r.applyPatches = function(t, n) {
    var a;
    for (a = n.length - 1; a >= 0; a--) {
      var i = n[a];
      if (i.path.length === 0 && i.op === "replace") {
        t = i.value;
        break;
      }
    }
    a > -1 && (n = n.slice(a + 1));
    var o = al("Patches").$;
    return ol(t) ? o(t, n) : this.produce(t, function(c) {
      return o(c, n);
    });
  }, e;
}(), Wo = new SH(), eB = Wo.produce, dme = Wo.produceWithPatches.bind(Wo), fme = Wo.setAutoFreeze.bind(Wo), mme = Wo.setUseProxies.bind(Wo), vme = Wo.applyPatches.bind(Wo), pme = Wo.createDraft.bind(Wo), hme = Wo.finishDraft.bind(Wo);
const gme = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Immer: SH,
  applyPatches: vme,
  castDraft: ime,
  castImmutable: ome,
  createDraft: pme,
  current: hH,
  default: eB,
  enableAllPlugins: ame,
  enableES5: gH,
  enableMapSet: _H,
  enablePatches: yH,
  finishDraft: hme,
  freeze: G4,
  immerable: mv,
  isDraft: ol,
  isDraftable: ss,
  nothing: q4,
  original: rme,
  produce: eB,
  produceWithPatches: dme,
  setAutoFreeze: fme,
  setUseProxies: mme
}, Symbol.toStringTag, { value: "Module" })), KE = /* @__PURE__ */ F3(gme);
var H0 = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.TextBuilder = void 0;
  var r = Te, t = Le, n = wr(), a = bs(), i = RE, o = Ft, c = new Uint16Array([0, 1, 2, 1, 3, 2]), s = n.ChunkedArray.add3, u = n.ChunkedArray.add2, l = n.ChunkedArray.add;
  (function(f) {
    function d(m, p, v, h) {
      m === void 0 && (m = {}), p === void 0 && (p = 2048), v === void 0 && (v = 1024), p *= 2, v *= 2;
      var y = n.ChunkedArray.create(Float32Array, 3, v, h ? h.centerBuffer.ref.value : p), C = n.ChunkedArray.create(Float32Array, 2, v, h ? h.mappingBuffer.ref.value : p), S = n.ChunkedArray.create(Float32Array, 1, v, h ? h.depthBuffer.ref.value : p), b = n.ChunkedArray.create(Uint32Array, 3, v, h ? h.indexBuffer.ref.value : p), g = n.ChunkedArray.create(Float32Array, 1, v, h ? h.groupBuffer.ref.value : p), _ = n.ChunkedArray.create(Float32Array, 2, v, h ? h.tcoordBuffer.ref.value : p), A = (0, r.__assign)((0, r.__assign)({}, t.ParamDefinition.getDefaultValues(a.Text.Params)), m), M = A.attachment, P = A.background, T = A.backgroundMargin, x = A.tether, w = A.tetherLength, E = A.tetherBaseWidth, I = (0, i.getFontAtlas)(A), B = 1 / 2.5 * T, D = I.buffer / I.lineHeight, N = function(O, V, k, G, L) {
        s(y, O, V, k), l(S, G), l(g, L);
      };
      return {
        add: function(O, V, k, G, L, R, F) {
          for (var U = 0, H = O.length, q = 0; q < H; ++q) {
            var K = I.get(O[q]);
            U += K.nw - 2 * D;
          }
          var Y = 1 / 1.25, X, Z;
          if (M.startsWith("top") ? X = Y : M.startsWith("middle") ? X = Y / 2 : X = 0, M.endsWith("right") ? Z = U : M.endsWith("center") ? Z = U / 2 : Z = 0, x)
            switch (M) {
              case "bottom-left":
                Z -= w / 2 + B + 0.1, X -= w / 2 + B;
                break;
              case "bottom-center":
                X -= w + B;
                break;
              case "bottom-right":
                Z += w / 2 + B + 0.1, X -= w / 2 + B;
                break;
              case "middle-left":
                Z -= w + B + 0.1;
                break;
              case "middle-center":
                break;
              case "middle-right":
                Z += w + B + 0.1;
                break;
              case "top-left":
                Z -= w / 2 + B + 0.1, X += w / 2 + B;
                break;
              case "top-center":
                X += w + B;
                break;
              case "top-right":
                Z += w / 2 + B + 0.1, X += w / 2 + B;
                break;
            }
          var J = (-Z - B - 0.1) * R, $ = (U - Z + B + 0.1) * R, Q = (Y - X + B) * R, W = (-X - B) * R;
          if (P) {
            u(C, J, Q), u(C, J, W), u(C, $, Q), u(C, $, W);
            for (var te = y.elementCount, oe = 0; oe < 4; ++oe)
              u(_, 10, 10), N(V, k, G, L, F);
            s(b, te + c[0], te + c[1], te + c[2]), s(b, te + c[3], te + c[4], te + c[5]);
          }
          if (x) {
            var z = void 0, j = void 0, ae = void 0, le = void 0, ie = void 0, re = void 0, ee = void 0, ne = void 0, se = w * R, ce = E * R;
            switch (M) {
              case "bottom-left":
                z = J - se / 2, ae = J + ce / 2, ie = J, ee = J, j = W - se / 2, le = W, re = W + ce / 2, ne = W;
                break;
              case "bottom-center":
                z = 0, ae = ce / 2, ie = -ce / 2, ee = 0, j = W - se, le = W, re = W, ne = W;
                break;
              case "bottom-right":
                z = $ + se / 2, ae = $, ie = $ - ce / 2, ee = $, j = W - se / 2, le = W + ce / 2, re = W, ne = W;
                break;
              case "middle-left":
                z = J - se, ae = J, ie = J, ee = J, j = 0, le = -ce / 2, re = ce / 2, ne = 0;
                break;
              case "middle-center":
                z = 0, ae = 0, ie = 0, ee = 0, j = 0, le = 0, re = 0, ne = 0;
                break;
              case "middle-right":
                z = $ + se, ae = $, ie = $, ee = $, j = 0, le = ce / 2, re = -ce / 2, ne = 0;
                break;
              case "top-left":
                z = J - se / 2, ae = J + ce / 2, ie = J, ee = J, j = Q + se / 2, le = Q, re = Q - ce / 2, ne = Q;
                break;
              case "top-center":
                z = 0, ae = ce / 2, ie = -ce / 2, ee = 0, j = Q + se, le = Q, re = Q, ne = Q;
                break;
              case "top-right":
                z = $ + se / 2, ae = $, ie = $ - ce / 2, ee = $, j = Q + se / 2, le = Q - ce / 2, re = Q, ne = Q;
                break;
              default:
                (0, o.assertUnreachable)(M);
            }
            u(C, z, j), u(C, ae, le), u(C, ie, re), u(C, ee, ne);
            for (var te = y.elementCount, oe = 0; oe < 4; ++oe)
              u(_, 10, 10), N(V, k, G, L, F);
            s(b, te, te + 1, te + 3), s(b, te, te + 3, te + 2);
          }
          Z += D, X += D;
          for (var de = 0, q = 0; q < H; ++q) {
            var K = I.get(O[q]), me = (de - Z) * R, he = (de + K.nw - Z) * R, _e = (K.nh - X) * R, Se = -X * R;
            u(C, me, _e), u(C, me, Se), u(C, he, _e), u(C, he, Se);
            var Pe = I.texture.width, De = I.texture.height;
            u(_, K.x / Pe, K.y / De), u(_, K.x / Pe, (K.y + K.h) / De), u(_, (K.x + K.w) / Pe, K.y / De), u(_, (K.x + K.w) / Pe, (K.y + K.h) / De), de += K.nw - 2 * D;
            for (var te = y.elementCount, oe = 0; oe < 4; ++oe)
              N(V, k, G, L, F);
            s(b, te + c[0], te + c[1], te + c[2]), s(b, te + c[3], te + c[4], te + c[5]);
          }
        },
        getText: function() {
          var O = I.texture, V = n.ChunkedArray.compact(y, !0), k = n.ChunkedArray.compact(C, !0), G = n.ChunkedArray.compact(S, !0), L = n.ChunkedArray.compact(b, !0), R = n.ChunkedArray.compact(g, !0), F = n.ChunkedArray.compact(_, !0);
          return a.Text.create(O, V, k, G, L, R, F, b.elementCount / 2, h);
        }
      };
    }
    f.create = d;
  })(e.TextBuilder || (e.TextBuilder = {}));
})(H0);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.isCameraAxesLoci = e.CameraHelperAxis = e.CameraHelper = e.CameraHelperParams = void 0;
  var r = Te, t = (0, r.__importDefault)(KE), n = gp(), a = Yd(), i = Xd(), o = Dt(), c = Ca(), s = bs(), u = H0, l = q0, f = Lt, d = nr(), m = Re, p = _r, v = ui(), h = gl, y = Oa, C = _n, S = Le, b = Ft, g = Rp(), _ = {
    alpha: S.ParamDefinition.Numeric(0.51, { min: 0, max: 1, step: 0.01 }, { isEssential: !0, label: "Opacity" }),
    hideX: S.ParamDefinition.Boolean(!1),
    hideY: S.ParamDefinition.Boolean(!1),
    hideZ: S.ParamDefinition.Boolean(!1),
    colorX: S.ParamDefinition.Color(y.ColorNames.red, { isEssential: !0 }),
    colorY: S.ParamDefinition.Color(y.ColorNames.green, { isEssential: !0 }),
    colorZ: S.ParamDefinition.Color(y.ColorNames.blue, { isEssential: !0 }),
    scale: S.ParamDefinition.Numeric(0.33, { min: 0.1, max: 2, step: 0.1 }, { isEssential: !0 }),
    vecA: S.ParamDefinition.Vec3(m.Vec3.unitX),
    vecB: S.ParamDefinition.Vec3(m.Vec3.unitY),
    vecC: S.ParamDefinition.Vec3(m.Vec3.unitZ),
    location: S.ParamDefinition.Select("bottom-left", S.ParamDefinition.arrayToOptions(["bottom-left", "bottom-right", "top-left", "top-right"])),
    locationOffsetX: S.ParamDefinition.Numeric(0),
    locationOffsetY: S.ParamDefinition.Numeric(0),
    originColor: S.ParamDefinition.Color(y.ColorNames.grey),
    radiusScale: S.ParamDefinition.Numeric(0.075, { min: 0.01, max: 0.3, step: 1e-3 }),
    showPlanes: S.ParamDefinition.Boolean(!1),
    planeColorXY: S.ParamDefinition.Color(y.ColorNames.grey, { label: "Plane Color XY" }),
    planeColorXZ: S.ParamDefinition.Color(y.ColorNames.grey, { label: "Plane Color XZ" }),
    planeColorYZ: S.ParamDefinition.Color(y.ColorNames.grey, { label: "Plane Color YZ" }),
    showLabels: S.ParamDefinition.Boolean(!0),
    labelX: S.ParamDefinition.Text("X"),
    labelY: S.ParamDefinition.Text("Y"),
    labelZ: S.ParamDefinition.Text("Z"),
    labelColorX: S.ParamDefinition.Color(y.ColorNames.grey),
    labelColorY: S.ParamDefinition.Color(y.ColorNames.grey),
    labelColorZ: S.ParamDefinition.Color(y.ColorNames.grey),
    labelOpacity: S.ParamDefinition.Numeric(1, { min: 0, max: 1, step: 0.01 }),
    labelScale: S.ParamDefinition.Numeric(0.15, { min: 0.1, max: 1, step: 0.01 })
  };
  e.CameraHelperParams = {
    axes: S.ParamDefinition.MappedStatic("on", {
      on: S.ParamDefinition.Group(_),
      off: S.ParamDefinition.Group({})
    }, { cycle: !0, description: "Show camera orientation axes" })
  };
  var A = (
    /** @class */
    function() {
      function V(k, G) {
        var L = this;
        G === void 0 && (G = {}), this.webgl = k, this.props = {
          axes: { name: "off", params: {} }
        }, this.pixelRatio = 1, this.eachGroup = function(R, F) {
          if (!x(R))
            return !1;
          var U = !1;
          if (L.meshRenderObject)
            for (var H = L.meshRenderObject.values.uGroupCount.ref.value, q = 0, K = R.elements; q < K.length; q++) {
              var Y = K[q], X = Y.groupId, Z = Y.instanceId, J = Z * H + X;
              F(n.Interval.ofSingleton(J)) && (U = !0);
            }
          if (L.textRenderObject)
            for (var H = L.textRenderObject.values.uGroupCount.ref.value, $ = 0, Q = R.elements; $ < Q.length; $++) {
              var W = Q[$], X = W.groupId, Z = W.instanceId, J = Z * H + X;
              F(n.Interval.ofSingleton(J)) && (U = !0);
            }
          return U;
        }, this.scene = l.Scene.create(k, f.GraphicsRenderVariantsBlended), this.camera = new g.Camera(), m.Vec3.set(this.camera.up, 0, 1, 0), m.Vec3.set(this.camera.target, 0, 0, 0), this.setProps(G);
      }
      return V.prototype.setProps = function(k) {
        var G = this;
        this.props = (0, t.default)(this.props, function(L) {
          if (k.axes !== void 0 && (L.axes.name = k.axes.name, k.axes.name === "on")) {
            G.scene.clear();
            var R = (0, r.__assign)((0, r.__assign)({}, S.ParamDefinition.getDefaultValues(_)), k.axes.params);
            G.pixelRatio = G.webgl.pixelRatio;
            var F = (0, r.__assign)((0, r.__assign)({}, R), { scale: R.scale * G.pixelRatio, labelScale: R.labelScale * G.pixelRatio });
            G.meshRenderObject = B(F), G.scene.add(G.meshRenderObject), F.showLabels ? (G.textRenderObject = O(F), G.scene.add(G.textRenderObject)) : G.textRenderObject = void 0, G.scene.commit(), m.Vec3.set(G.camera.position, 0, 0, F.scale * 200), m.Mat4.lookAt(G.camera.view, G.camera.position, G.camera.target, G.camera.up), L.axes.params = (0, r.__assign)({}, R);
          }
        });
      }, Object.defineProperty(V.prototype, "isEnabled", {
        get: function() {
          return this.props.axes.name === "on";
        },
        enumerable: !1,
        configurable: !0
      }), V.prototype.getLoci = function(k) {
        var G = k.objectId, L = k.groupId, R = k.instanceId;
        return (!this.meshRenderObject || G !== this.meshRenderObject.id) && (!this.textRenderObject || G !== this.textRenderObject.id) || L === M.None ? p.EmptyLoci : T(this, L, R);
      }, V.prototype.mark = function(k, G) {
        return !C.MarkerActions.is(C.MarkerActions.Highlighting, G) || !(0, p.isEveryLoci)(k) && (!x(k) || k.data !== this) ? !1 : h.Visual.mark(this.meshRenderObject, k, G, this.eachGroup) || h.Visual.mark(this.textRenderObject, k, G, this.eachGroup);
      }, V.prototype.update = function(k) {
        if (!(!this.meshRenderObject || this.props.axes.name === "off")) {
          this.pixelRatio !== this.webgl.pixelRatio && this.setProps(this.props), w(this.camera, k.viewport, k.viewOffset), m.Mat4.extractRotation(this.scene.view, k.view);
          var G = this.textRenderObject ? this.textRenderObject.values.boundingSphere.ref.value.radius : this.meshRenderObject.values.boundingSphere.ref.value.radius, L = this.props.axes.params.location, R = this.props.axes.params.locationOffsetX * this.pixelRatio, F = this.props.axes.params.locationOffsetY * this.pixelRatio;
          L === "bottom-left" ? m.Mat4.setTranslation(this.scene.view, m.Vec3.create(-k.viewport.width / 2 + G + R, -k.viewport.height / 2 + G + F, 0)) : L === "bottom-right" ? m.Mat4.setTranslation(this.scene.view, m.Vec3.create(k.viewport.width / 2 - G - R, -k.viewport.height / 2 + G + F, 0)) : L === "top-left" ? m.Mat4.setTranslation(this.scene.view, m.Vec3.create(-k.viewport.width / 2 + G + R, k.viewport.height / 2 - G - F, 0)) : L === "top-right" ? m.Mat4.setTranslation(this.scene.view, m.Vec3.create(k.viewport.width / 2 - G - R, k.viewport.height / 2 - G - F, 0)) : (0, b.assertUnreachable)(L);
        }
      }, V;
    }()
  );
  e.CameraHelper = A;
  var M;
  (function(V) {
    V[V.None = 0] = "None", V[V.X = 1] = "X", V[V.Y = 2] = "Y", V[V.Z = 3] = "Z", V[V.XY = 4] = "XY", V[V.XZ = 5] = "XZ", V[V.YZ = 6] = "YZ", V[V.Origin = 7] = "Origin";
  })(M = e.CameraHelperAxis || (e.CameraHelperAxis = {}));
  function P(V, k) {
    var G = k.props.axes, L = G.name === "on" ? G.params.labelX : "X", R = G.name === "on" ? G.params.labelY : "Y", F = G.name === "on" ? G.params.labelZ : "Z";
    switch (V) {
      case M.X:
        return "".concat(L, " Axis");
      case M.Y:
        return "".concat(R, " Axis");
      case M.Z:
        return "".concat(F, " Axis");
      case M.XY:
        return "".concat(L).concat(R, " Plane");
      case M.XZ:
        return "".concat(L).concat(F, " Plane");
      case M.YZ:
        return "".concat(R).concat(F, " Plane");
      case M.Origin:
        return "Origin";
      default:
        return "Axes";
    }
  }
  function T(V, k, G) {
    return (0, p.DataLoci)("camera-axes", V, [{ groupId: k, instanceId: G }], void 0, function() {
      return P(k, V);
    });
  }
  function x(V) {
    return V.kind === "data-loci" && V.tag === "camera-axes";
  }
  e.isCameraAxesLoci = x;
  function w(V, k, G) {
    var L = V.near, R = V.far, F = -k.width / 2, U = k.width / 2, H = k.height / 2, q = -k.height / 2, K = (U - F) / 2, Y = (H - q) / 2, X = (U + F) / 2, Z = (H + q) / 2, J = X - K, $ = X + K, Q = Z + Y, W = Z - Y;
    if (G.enabled) {
      var te = (U - F) / G.width, oe = (H - q) / G.height;
      J += te * G.offsetX, $ = J + te * G.width, Q -= oe * G.offsetY, W = Q - oe * G.height;
    }
    m.Mat4.ortho(V.projection, J, $, Q, W, L, R);
  }
  function E(V, k) {
    var G = V.vecA, L = V.vecB, R = V.vecC, F = c.MeshBuilder.createState(512, 256, k), U = 100 * V.scale, H = V.radiusScale * U, q = V.showLabels ? 100 * V.labelScale / 3 : 0, K = m.Vec3.sub((0, m.Vec3)(), m.Vec3.scale((0, m.Vec3)(), G, U - q), m.Vec3.scale((0, m.Vec3)(), R, U * 0.5)), Y = m.Vec3.sub((0, m.Vec3)(), m.Vec3.scale((0, m.Vec3)(), L, U - q), m.Vec3.scale((0, m.Vec3)(), R, U * 0.5)), X = m.Vec3.sub((0, m.Vec3)(), m.Vec3.scale((0, m.Vec3)(), R, U - q), m.Vec3.scale((0, m.Vec3)(), R, U * 0.5)), Z = m.Vec3.sub((0, m.Vec3)(), m.Vec3.origin, m.Vec3.scale((0, m.Vec3)(), R, U * 0.5)), J = { radiusTop: H, radiusBottom: H, radialSegments: 32 };
    if (F.currentGroup = M.Origin, (0, i.addSphere)(F, Z, H, 2), V.hideX || (F.currentGroup = M.X, (0, i.addSphere)(F, K, H, 2), (0, a.addCylinder)(F, Z, K, 1, J)), V.hideY || (F.currentGroup = M.Y, (0, i.addSphere)(F, Y, H, 2), (0, a.addCylinder)(F, Z, Y, 1, J)), V.hideZ || (F.currentGroup = M.Z, (0, i.addSphere)(F, X, H, 2), (0, a.addCylinder)(F, Z, X, 1, J)), V.showPlanes) {
      if (m.Vec3.scale(K, K, 0.5), m.Vec3.scale(Y, Y, 0.5), m.Vec3.scale(X, X, 0.5), !V.hideX && !V.hideY) {
        F.currentGroup = M.XY, c.MeshBuilder.addTriangle(F, Z, K, Y), c.MeshBuilder.addTriangle(F, Z, Y, K);
        var $ = m.Vec3.add((0, m.Vec3)(), K, Y);
        c.MeshBuilder.addTriangle(F, $, K, Y), c.MeshBuilder.addTriangle(F, $, Y, K);
      }
      if (!V.hideX && !V.hideZ) {
        F.currentGroup = M.XZ, c.MeshBuilder.addTriangle(F, Z, K, X), c.MeshBuilder.addTriangle(F, Z, X, K);
        var Q = m.Vec3.add((0, m.Vec3)(), K, X);
        c.MeshBuilder.addTriangle(F, Q, K, X), c.MeshBuilder.addTriangle(F, Q, X, K);
      }
      if (!V.hideY && !V.hideZ) {
        F.currentGroup = M.YZ, c.MeshBuilder.addTriangle(F, Z, Y, X), c.MeshBuilder.addTriangle(F, Z, X, Y);
        var W = m.Vec3.add((0, m.Vec3)(), Y, X);
        c.MeshBuilder.addTriangle(F, W, Y, X), c.MeshBuilder.addTriangle(F, W, X, Y);
      }
    }
    return c.MeshBuilder.getMesh(F);
  }
  function I(V, k) {
    var G = 100 * V.scale, L = E(V, void 0);
    L.setBoundingSphere(d.Sphere3D.create(m.Vec3.create(G / 2, G / 2, G / 2), G + G / 4));
    var R = function(F) {
      switch (F) {
        case M.X:
          return V.colorX;
        case M.Y:
          return V.colorY;
        case M.Z:
          return V.colorZ;
        case M.XY:
          return V.planeColorXY;
        case M.XZ:
          return V.planeColorXZ;
        case M.YZ:
          return V.planeColorYZ;
        case M.Origin:
          return V.originColor;
        default:
          return y.ColorNames.grey;
      }
    };
    return v.Shape.create("axes-mesh", {}, L, R, function() {
      return 1;
    }, function() {
      return "";
    });
  }
  function B(V) {
    var k = I(V);
    return v.Shape.createRenderObject(k, (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, S.ParamDefinition.getDefaultValues(o.Mesh.Params)), V), { ignoreLight: !0 }));
  }
  function D(V, k) {
    var G = V.vecA, L = V.vecB, R = V.vecC, F = u.TextBuilder.create(V, 8, 8, k), U = 100 * V.scale, H = m.Vec3.add((0, m.Vec3)(), m.Vec3.scale((0, m.Vec3)(), G, U), m.Vec3.scale((0, m.Vec3)(), R, U * 1.5)), q = m.Vec3.add((0, m.Vec3)(), m.Vec3.scale((0, m.Vec3)(), L, U), m.Vec3.scale((0, m.Vec3)(), R, U * 1.5)), K = m.Vec3.add((0, m.Vec3)(), m.Vec3.scale((0, m.Vec3)(), R, U), m.Vec3.scale((0, m.Vec3)(), R, U * 1.5)), Y = 100 * V.labelScale;
    return V.hideX || F.add(V.labelX, H[0], H[1], H[2], 0, Y, M.X), V.hideY || F.add(V.labelY, q[0], q[1], q[2], 0, Y, M.Y), V.hideZ || F.add(V.labelZ, K[0], K[1], K[2], 0, Y, M.Z), F.getText();
  }
  function N(V, k) {
    var G = 100 * V.scale, L = D(V, void 0);
    L.setBoundingSphere(d.Sphere3D.create(m.Vec3.create(G / 2, G / 2, G / 2), G));
    var R = function(F) {
      switch (F) {
        case M.X:
          return V.labelColorX;
        case M.Y:
          return V.labelColorY;
        case M.Z:
          return V.labelColorZ;
        default:
          return y.ColorNames.grey;
      }
    };
    return v.Shape.create("axes-text", {}, L, R, function() {
      return 1;
    }, function() {
      return "";
    });
  }
  function O(V) {
    var k = N(V);
    return v.Shape.createRenderObject(k, (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, S.ParamDefinition.getDefaultValues(s.Text.Params)), V), { alpha: V.labelOpacity }));
  }
})(Ay);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ImagePass = e.ImageParams = void 0;
  var r = Te, t = Le, n = Cy, a = rl, i = tl, o = Rp(), c = ri, s = iy, u = Ay, l = Id;
  e.ImageParams = {
    transparentBackground: t.ParamDefinition.Boolean(!1),
    multiSample: t.ParamDefinition.Group(i.MultiSampleParams),
    postprocessing: t.ParamDefinition.Group(a.PostprocessingParams),
    marking: t.ParamDefinition.Group(l.MarkingParams),
    cameraHelper: t.ParamDefinition.Group(u.CameraHelperParams)
  };
  var f = (
    /** @class */
    function() {
      function d(m, p, v, h, y, C, S) {
        this.webgl = m, this.renderer = p, this.scene = v, this.camera = h, this._width = 0, this._height = 0, this._camera = new o.Camera(), this.props = (0, r.__assign)((0, r.__assign)({}, t.ParamDefinition.getDefaultValues(e.ImageParams)), S), this.drawPass = new n.DrawPass(m, 128, 128, C), this.multiSamplePass = new i.MultiSamplePass(m, this.drawPass), this.multiSampleHelper = new i.MultiSampleHelper(this.multiSamplePass), this.helper = {
          camera: new u.CameraHelper(m, this.props.cameraHelper),
          debug: y.debug,
          handle: y.handle
        }, this.setSize(1024, 768);
      }
      return Object.defineProperty(d.prototype, "colorTarget", {
        get: function() {
          return this._colorTarget;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(d.prototype, "width", {
        get: function() {
          return this._width;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(d.prototype, "height", {
        get: function() {
          return this._height;
        },
        enumerable: !1,
        configurable: !0
      }), d.prototype.setSize = function(m, p) {
        m === this._width && p === this._height || (this._width = m, this._height = p, this.drawPass.setSize(m, p), this.multiSamplePass.syncSize());
      }, d.prototype.setProps = function(m) {
        m === void 0 && (m = {}), Object.assign(this.props, m), m.cameraHelper && this.helper.camera.setProps(m.cameraHelper);
      }, d.prototype.render = function() {
        o.Camera.copySnapshot(this._camera.state, this.camera.state), c.Viewport.set(this._camera.viewport, 0, 0, this._width, this._height), this._camera.update();
        var m = { renderer: this.renderer, camera: this._camera, scene: this.scene, helper: this.helper };
        i.MultiSamplePass.isEnabled(this.props.multiSample) ? (this.multiSampleHelper.render(m, this.props, !1), this._colorTarget = this.multiSamplePass.colorTarget) : (this.drawPass.render(m, this.props, !1), this._colorTarget = this.drawPass.getColorTarget(this.props.postprocessing));
      }, d.prototype.getImageData = function(m, p, v) {
        var h, y;
        this.setSize(m, p), this.render(), this.colorTarget.bind();
        var C = (h = v == null ? void 0 : v.width) !== null && h !== void 0 ? h : m, S = (y = v == null ? void 0 : v.height) !== null && y !== void 0 ? y : p, b = new Uint8Array(C * S * 4);
        v ? this.webgl.readPixels(v.x, p - v.y - v.height, C, S, b) : this.webgl.readPixels(0, 0, C, S, b);
        var g = s.PixelData.create(b, C, S);
        return s.PixelData.flipY(g), s.PixelData.divideByAlpha(g), new ImageData(new Uint8ClampedArray(b), C, S);
      }, d;
    }()
  );
  e.ImagePass = f;
})(oH);
var WE = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.isHandleLoci = e.HandleGroup = e.HandleHelper = e.HandleHelperParams = void 0;
  var r = Te, t = q0, n = Ca(), a = Re, i = Xd(), o = Dt(), c = Oa, s = Yd(), u = We(), l = nr(), f = Le, d = (0, r.__importDefault)(KE), m = ui(), p = _r, v = _n, h = gl, y = Qe(), C = Lt, S = (0, r.__assign)((0, r.__assign)({}, o.Mesh.Params), { alpha: (0, r.__assign)((0, r.__assign)({}, o.Mesh.Params.alpha), { defaultValue: 1 }), ignoreLight: (0, r.__assign)((0, r.__assign)({}, o.Mesh.Params.ignoreLight), { defaultValue: !0 }), colorX: f.ParamDefinition.Color(c.ColorNames.red, { isEssential: !0 }), colorY: f.ParamDefinition.Color(c.ColorNames.green, { isEssential: !0 }), colorZ: f.ParamDefinition.Color(c.ColorNames.blue, { isEssential: !0 }), scale: f.ParamDefinition.Numeric(0.33, { min: 0.1, max: 2, step: 0.1 }, { isEssential: !0 }) });
  e.HandleHelperParams = {
    handle: f.ParamDefinition.MappedStatic("off", {
      on: f.ParamDefinition.Group(S),
      off: f.ParamDefinition.Group({})
    }, { cycle: !0, description: "Show handle tool" })
  };
  var b = (
    /** @class */
    function() {
      function T(x, w) {
        var E = this;
        w === void 0 && (w = {}), this.webgl = x, this.props = {
          handle: { name: "off", params: {} }
        }, this.pixelRatio = 1, this._transform = (0, a.Mat4)(), this.eachGroup = function(I, B) {
          if (!E.renderObject || !A(I))
            return !1;
          for (var D = !1, N = E.renderObject.values.uGroupCount.ref.value, O = I.elements, V = 0, k = O; V < k.length; V++) {
            var G = k[V], L = G.groupId, R = G.instanceId, F = R * N + L;
            B(y.Interval.ofSingleton(F)) && (D = !0);
          }
          return D;
        }, this.scene = t.Scene.create(x, C.GraphicsRenderVariantsBlended), this.setProps(w);
      }
      return T.prototype.getBoundingSphere = function(x, w) {
        return this.renderObject && (l.Sphere3D.copy(x, this.renderObject.values.invariantBoundingSphere.ref.value), a.Mat4.fromArray(this._transform, this.renderObject.values.aTransform.ref.value, w * 16), l.Sphere3D.transform(x, x, this._transform)), x;
      }, T.prototype.setProps = function(x) {
        var w = this;
        this.props = (0, d.default)(this.props, function(E) {
          if (x.handle !== void 0 && (E.handle.name = x.handle.name, x.handle.name === "on")) {
            w.scene.clear(), w.pixelRatio = w.webgl.pixelRatio;
            var I = (0, r.__assign)((0, r.__assign)({}, x.handle.params), { scale: x.handle.params.scale * w.webgl.pixelRatio });
            w.renderObject = P(I), w.scene.add(w.renderObject), w.scene.commit(), E.handle.params = (0, r.__assign)({}, x.handle.params);
          }
        });
      }, Object.defineProperty(T.prototype, "isEnabled", {
        get: function() {
          return this.props.handle.name === "on";
        },
        enumerable: !1,
        configurable: !0
      }), T.prototype.update = function(x, w, E) {
        this.renderObject && (this.pixelRatio !== this.webgl.pixelRatio && this.setProps(this.props), a.Mat4.setTranslation(this.renderObject.values.aTransform.ref.value, w), a.Mat4.fromMat3(this.renderObject.values.aTransform.ref.value, E), u.ValueCell.update(this.renderObject.values.aTransform, this.renderObject.values.aTransform.ref.value), this.scene.update([this.renderObject], !0));
      }, T.prototype.getLoci = function(x) {
        var w = x.objectId, E = x.groupId, I = x.instanceId;
        return !this.renderObject || w !== this.renderObject.id ? p.EmptyLoci : _(this, E, I);
      }, T.prototype.mark = function(x, w) {
        return !v.MarkerActions.is(v.MarkerActions.Highlighting, w) || !(0, p.isEveryLoci)(x) && (!A(x) || x.data !== this) ? !1 : h.Visual.mark(this.renderObject, x, w, this.eachGroup);
      }, T;
    }()
  );
  e.HandleHelper = b;
  function g(T, x) {
    var w = n.MeshBuilder.createState(512, 256, x), E = 0.05 * T, I = a.Vec3.scale((0, a.Vec3)(), a.Vec3.unitX, T), B = a.Vec3.scale((0, a.Vec3)(), a.Vec3.unitY, T), D = a.Vec3.scale((0, a.Vec3)(), a.Vec3.unitZ, T), N = { radiusTop: E, radiusBottom: E, radialSegments: 32 };
    return w.currentGroup = e.HandleGroup.TranslateScreenXY, (0, i.addSphere)(w, a.Vec3.origin, E * 3, 2), w.currentGroup = e.HandleGroup.TranslateObjectX, (0, i.addSphere)(w, I, E, 2), (0, s.addCylinder)(w, a.Vec3.origin, I, 1, N), w.currentGroup = e.HandleGroup.TranslateObjectY, (0, i.addSphere)(w, B, E, 2), (0, s.addCylinder)(w, a.Vec3.origin, B, 1, N), w.currentGroup = e.HandleGroup.TranslateObjectZ, (0, i.addSphere)(w, D, E, 2), (0, s.addCylinder)(w, a.Vec3.origin, D, 1, N), n.MeshBuilder.getMesh(w);
  }
  e.HandleGroup = {
    None: 0,
    TranslateScreenXY: 1,
    // TranslateScreenZ: 2,
    TranslateObjectX: 3,
    TranslateObjectY: 4,
    TranslateObjectZ: 5
    // TranslateObjectXY: 6,
    // TranslateObjectXZ: 7,
    // TranslateObjectYZ: 8,
    // RotateScreenZ: 9,
    // RotateObjectX: 10,
    // RotateObjectY: 11,
    // RotateObjectZ: 12,
  };
  function _(T, x, w) {
    return (0, p.DataLoci)("handle", T, [{ groupId: x, instanceId: w }], function(E) {
      return T.getBoundingSphere(E, w);
    }, function() {
      return "Handle Helper | Group Id ".concat(x, " | Instance Id ").concat(w);
    });
  }
  function A(T) {
    return T.kind === "data-loci" && T.tag === "handle";
  }
  e.isHandleLoci = A;
  function M(T, x) {
    var w = 10 * T.scale, E = g(w, void 0);
    E.setBoundingSphere(l.Sphere3D.create(a.Vec3.create(w / 2, w / 2, w / 2), w + w / 4));
    var I = function(B) {
      switch (B) {
        case e.HandleGroup.TranslateObjectX:
          return T.colorX;
        case e.HandleGroup.TranslateObjectY:
          return T.colorY;
        case e.HandleGroup.TranslateObjectZ:
          return T.colorZ;
        default:
          return c.ColorNames.grey;
      }
    };
    return m.Shape.create("handle", {}, E, I, function() {
      return 1;
    }, function() {
      return "";
    });
  }
  function P(T) {
    var x = M(T);
    return m.Shape.createRenderObject(x, T);
  }
})(WE);
var CH = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Helper = e.DefaultHelperProps = e.HelperParams = void 0;
  var r = Te, t = Le, n = LE, a = Ay, i = WE;
  e.HelperParams = {
    debug: t.ParamDefinition.Group(n.DebugHelperParams),
    camera: t.ParamDefinition.Group({
      helper: t.ParamDefinition.Group(a.CameraHelperParams)
    }),
    handle: t.ParamDefinition.Group(i.HandleHelperParams)
  }, e.DefaultHelperProps = t.ParamDefinition.getDefaultValues(e.HelperParams);
  var o = (
    /** @class */
    /* @__PURE__ */ function() {
      function c(s, u, l) {
        l === void 0 && (l = {});
        var f = (0, r.__assign)((0, r.__assign)({}, e.DefaultHelperProps), l);
        this.debug = new n.BoundingSphereHelper(s, u, f.debug), this.camera = new a.CameraHelper(s, f.camera.helper), this.handle = new i.HandleHelper(s, f.handle);
      }
      return c;
    }()
  );
  e.Helper = o;
})(CH);
var H4 = {};
Object.defineProperty(H4, "__esModule", { value: !0 });
H4.Passes = void 0;
var yme = Cy, _me = f0, bme = tl, Sme = (
  /** @class */
  function() {
    function e(r, t) {
      t === void 0 && (t = {}), this.webgl = r;
      var n = r.gl;
      this.draw = new yme.DrawPass(r, n.drawingBufferWidth, n.drawingBufferHeight, t.enableWboit || !1), this.pick = new _me.PickPass(r, this.draw, t.pickScale || 0.25), this.multiSample = new bme.MultiSamplePass(r, this.draw);
    }
    return e.prototype.updateSize = function() {
      var r = this.webgl.gl;
      this.draw.setSize(r.drawingBufferWidth, r.drawingBufferHeight), this.pick.syncSize(), this.multiSample.syncSize();
    }, e;
  }()
);
H4.Passes = Sme;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Canvas3D = e.Canvas3DContext = e.DefaultCanvas3DParams = e.Canvas3DParams = void 0;
  var r = Te, t = cl, n = Eu, a = Re, i = ey, o = vz, c = Dz, s = ri, u = dE(), l = Wt, f = q0, d = _r, m = Rp(), p = Le, v = LE, h = ds, y = Jq, C = rl, S = tl, b = f0, g = oH, _ = nr(), A = Zt, M = Ay, P = KE, T = WE, x = N4, w = CH, E = H4, I = We(), B = Id, D = Lt;
  e.Canvas3DParams = {
    camera: p.ParamDefinition.Group({
      mode: p.ParamDefinition.Select("orthographic", p.ParamDefinition.arrayToOptions(["perspective", "orthographic"]), { label: "Camera" }),
      helper: p.ParamDefinition.Group(M.CameraHelperParams, { isFlat: !0 }),
      stereo: p.ParamDefinition.MappedStatic("off", {
        on: p.ParamDefinition.Group(x.StereoCameraParams),
        off: p.ParamDefinition.Group({})
      }, { cycle: !0, hideIf: function(G) {
        return (G == null ? void 0 : G.mode) !== "perspective";
      } }),
      manualReset: p.ParamDefinition.Boolean(!1, { isHidden: !0 })
    }, { pivot: "mode" }),
    cameraFog: p.ParamDefinition.MappedStatic("on", {
      on: p.ParamDefinition.Group({
        intensity: p.ParamDefinition.Numeric(50, { min: 1, max: 100, step: 1 })
      }),
      off: p.ParamDefinition.Group({})
    }, { cycle: !0, description: "Show fog in the distance" }),
    cameraClipping: p.ParamDefinition.Group({
      radius: p.ParamDefinition.Numeric(100, { min: 0, max: 99, step: 1 }, { label: "Clipping", description: "How much of the scene to show." }),
      far: p.ParamDefinition.Boolean(!0, { description: "Hide scene in the distance" })
    }, { pivot: "radius" }),
    viewport: p.ParamDefinition.MappedStatic("canvas", {
      canvas: p.ParamDefinition.Group({}),
      "static-frame": p.ParamDefinition.Group({
        x: p.ParamDefinition.Numeric(0),
        y: p.ParamDefinition.Numeric(0),
        width: p.ParamDefinition.Numeric(128),
        height: p.ParamDefinition.Numeric(128)
      }),
      "relative-frame": p.ParamDefinition.Group({
        x: p.ParamDefinition.Numeric(0.33, { min: 0, max: 1, step: 0.01 }),
        y: p.ParamDefinition.Numeric(0.33, { min: 0, max: 1, step: 0.01 }),
        width: p.ParamDefinition.Numeric(0.5, { min: 0.01, max: 1, step: 0.01 }),
        height: p.ParamDefinition.Numeric(0.5, { min: 0.01, max: 1, step: 0.01 })
      })
    }),
    cameraResetDurationMs: p.ParamDefinition.Numeric(250, { min: 0, max: 1e3, step: 1 }, { description: "The time it takes to reset the camera." }),
    transparentBackground: p.ParamDefinition.Boolean(!1),
    multiSample: p.ParamDefinition.Group(S.MultiSampleParams),
    postprocessing: p.ParamDefinition.Group(C.PostprocessingParams),
    marking: p.ParamDefinition.Group(B.MarkingParams),
    renderer: p.ParamDefinition.Group(o.RendererParams),
    trackball: p.ParamDefinition.Group(c.TrackballControlsParams),
    interaction: p.ParamDefinition.Group(y.Canvas3dInteractionHelperParams),
    debug: p.ParamDefinition.Group(v.DebugHelperParams),
    handle: p.ParamDefinition.Group(T.HandleHelperParams)
  }, e.DefaultCanvas3DParams = p.ParamDefinition.getDefaultValues(e.Canvas3DParams);
  var N;
  (function(G) {
    G.DefaultAttribs = {
      /** true by default to avoid issues with Safari (Jan 2021) */
      antialias: !0,
      /** true to support multiple Canvas3D objects with a single context */
      preserveDrawingBuffer: !0,
      pixelScale: 1,
      pickScale: 0.25,
      /** extra pixels to around target to check in case target is empty */
      pickPadding: 1,
      enableWboit: !0,
      preferWebGl1: !1
    };
    function L(R, F) {
      F === void 0 && (F = {});
      var U = (0, r.__assign)((0, r.__assign)({}, G.DefaultAttribs), F), H = U.antialias, q = U.preserveDrawingBuffer, K = U.pixelScale, Y = U.preferWebGl1, X = (0, u.getGLContext)(R, {
        antialias: H,
        preserveDrawingBuffer: q,
        alpha: !0,
        depth: !0,
        premultipliedAlpha: !0,
        preferWebGl1: Y
      });
      if (X === null)
        throw new Error("Could not create a WebGL rendering context");
      var Z = i.InputObserver.fromElement(R, {
        pixelScale: K,
        preventGestures: !0
      }), J = (0, u.createContext)(X, { pixelScale: K }), $ = new E.Passes(J, F);
      if (A.isDebugMode) {
        var Q = X.getExtension("WEBGL_lose_context");
        Q && R.addEventListener("mousedown", function(z) {
          J.isContextLost || !z.shiftKey || !z.ctrlKey || !z.altKey || (A.isDebugMode && console.log("lose context"), Q.loseContext(), setTimeout(function() {
            J.isContextLost && (A.isDebugMode && console.log("restore context"), Q.restoreContext());
          }, 1e3));
        }, !1);
      }
      var W = new t.BehaviorSubject(0), te = function(z) {
        J.setContextLost(), z && z.preventDefault(), A.isDebugMode && console.log("context lost"), W.next((0, n.now)());
      }, oe = function() {
        J.isContextLost && (J.handleContextRestored(function() {
          $.draw.reset();
        }), A.isDebugMode && console.log("context restored"));
      };
      return R.addEventListener("webglcontextlost", te, !1), R.addEventListener("webglcontextrestored", oe, !1), {
        canvas: R,
        webgl: J,
        input: Z,
        passes: $,
        attribs: U,
        contextLost: W,
        contextRestored: J.contextRestored,
        dispose: function(z) {
          Z.dispose(), R.removeEventListener("webglcontextlost", te, !1), R.removeEventListener("webglcontextrestored", oe, !1), J.destroy(z);
        },
        handleWebglContextLost: te,
        handlewWebglContextRestored: oe
      };
    }
    G.fromCanvas = L;
  })(N || (N = {})), e.Canvas3DContext = N;
  var O = typeof window < "u" ? window.requestAnimationFrame : function(G) {
    return setImmediate(function() {
      return G(Date.now());
    });
  }, V = typeof window < "u" ? window.cancelAnimationFrame : function(G) {
    return clearImmediate(G);
  }, k;
  (function(G) {
    function L(R, F) {
      var U = R.webgl, H = R.input, q = R.passes, K = R.attribs;
      F === void 0 && (F = {});
      var Y = (0, r.__assign)((0, r.__assign)({}, e.DefaultCanvas3DParams), F), X = /* @__PURE__ */ new Map(), Z = /* @__PURE__ */ new Map(), J = new t.BehaviorSubject(0), $ = (0, n.now)(), Q = new t.BehaviorSubject(0), W = new t.BehaviorSubject(0), te = U.gl, oe = U.contextRestored, z = 0, j = 0, ae = 128, le = 128;
      rn();
      var ie = f.Scene.create(U, q.draw.wboitEnabled ? D.GraphicsRenderVariantsWboit : D.GraphicsRenderVariantsBlended), re = new m.Camera({
        position: a.Vec3.create(0, 0, 100),
        mode: Y.camera.mode,
        fog: Y.cameraFog.name === "on" ? Y.cameraFog.params.intensity : 0,
        clipFar: Y.cameraClipping.far
      }, { x: z, y: j, width: ae, height: le }, { pixelScale: K.pixelScale }), ee = new x.StereoCamera(re, Y.camera.stereo.params), ne = c.TrackballControls.create(H, re, Y.trackball), se = o.Renderer.create(U, Y.renderer), ce = new w.Helper(U, ie, Y), de = new b.PickHelper(U, se, ie, ce, q.pick, { x: z, y: j, width: ae, height: le }, K.pickPadding), me = new y.Canvas3dInteractionHelper(He, Me, H, re, Y.interaction), he = new S.MultiSampleHelper(q.multiSample), _e = !1, Se = void 0, Pe = void 0, De = !1, Ee = !0;
      function Me(Ge) {
        var ar = d.EmptyLoci, Er = l.Representation.Empty;
        if (Ge) {
          var Xr = ce.camera.getLoci(Ge);
          if (Xr !== d.EmptyLoci)
            return { loci: Xr, repr: Er };
          ar = ce.handle.getLoci(Ge), X.forEach(function(Ut, ur) {
            var Xn = ur.getLoci(Ge);
            (0, d.isEmptyLoci)(Xn) || ((0, d.isEmptyLoci)(ar) || console.warn("found another loci, this should not happen"), ar = Xn, Er = ur);
          });
        }
        return { loci: ar, repr: Er };
      }
      var ue = [];
      function pe(Ge, ar) {
        ue.push([Ge, ar]);
      }
      function Ae() {
        for (var Ge = !1, ar = 0, Er = ue; ar < Er.length; ar++) {
          var Xr = Er[ar], Ut = Xr[0], ur = Xr[1];
          Ge = ye(Ut, ur) || Ge;
        }
        return ue = [], Ge && (ie.update(void 0, !0), ce.handle.scene.update(void 0, !0), ce.camera.scene.update(void 0, !0)), Ge;
      }
      function ye(Ge, ar) {
        var Er = Ge.repr, Xr = Ge.loci, Ut = !1;
        return Er ? Ut = Er.mark(Xr, ar) : (Ut = ce.handle.mark(Xr, ar), Ut = ce.camera.mark(Xr, ar) || Ut, X.forEach(function(ur, Xn) {
          Ut = Xn.mark(Xr, ar) || Ut;
        })), Ut;
      }
      function be(Ge) {
        if (U.isContextLost)
          return !1;
        var ar = !1;
        if (De && (Yr(!1), De = !1, ar = !0), z > te.drawingBufferWidth || z + ae < 0 || j > te.drawingBufferHeight || j + le < 0)
          return !1;
        var Er = Ae(), Xr = !1;
        ne.update(xe);
        var Ut = re.update(), ur = Ge || Ut || ar || fe;
        fe = !1;
        var Xn = he.update(Er || ur, Y.multiSample);
        if (ur || Xn || Er) {
          var Bc = re;
          Y.camera.stereo.name === "on" && (ee.update(), Bc = ee);
          var Al = { renderer: se, camera: Bc, scene: ie, helper: ce };
          if (S.MultiSamplePass.isEnabled(Y.multiSample)) {
            var nh = !Ut && Er && !ne.isAnimating;
            he.render(Al, Y, !0, nh);
          } else
            q.draw.render(Al, Y, !0);
          de.dirty = de.dirty || ur, Xr = !0;
        }
        return Xr;
      }
      var fe = !1, ge = !1, xe = 0, we = !1;
      function Ve(Ge) {
        we || be(!!(Ge != null && Ge.force)) && Ee && Q.next((0, n.now)() - $);
      }
      function Ne() {
        fe = !0;
      }
      var Oe = 0;
      function ze(Ge, ar) {
        xe = Ge, Ye(ar == null ? void 0 : ar.isSynchronous), re.transition.tick(xe), !(ar != null && ar.manualDraw) && (Ve(), !re.transition.inTransition && !U.isContextLost && me.tick(xe));
      }
      function ke() {
        ze((0, n.now)()), Oe = O(ke);
      }
      function je(Ge) {
        $ = Ge, ne.start(Ge);
      }
      function Xe() {
        we = !1, ne.start((0, n.now)()), Oe === 0 && ke();
      }
      function Fe(Ge) {
        Ge === void 0 && (Ge = !1), we = Ge, V(Oe), Oe = 0;
      }
      function He(Ge, ar) {
        var Er = Y.camera.stereo.name === "on" ? ee : re;
        return U.isContextLost ? void 0 : de.identify(Ge, ar, Er);
      }
      function Be(Ge, ar) {
        var Er = re;
        return U.isContextLost ? void 0 : de.getPosition(Ge, ar, Er);
      }
      function Ye(Ge) {
        Ge === void 0 && (Ge = !1);
        var ar = Sn(Ge);
        ar && (ne.isLockCamera ? (Se = void 0, Pe = void 0, _e = !1) : cr(), ge && (ce.debug.isEnabled && ce.debug.update(), Ve({ force: !0 }), ge = !1), W.next((0, n.now)()));
      }
      function cr() {
        if (!(!_e || ne.isLockCamera)) {
          var Ge = ie.boundingSphereVisible, ar = Ge.center, Er = Ge.radius, Xr = ne.props.autoAdjustMinMaxDistance;
          if (Xr.name === "on") {
            var Ut = Xr.params.minDistanceFactor * Er + Xr.params.minDistancePadding, ur = Math.max(Xr.params.maxDistanceFactor * Er, Xr.params.maxDistanceMin);
            ne.setProps({ minDistance: Ut, maxDistance: ur });
          }
          if (Er > 0) {
            var Xn = Se === void 0 ? Y.cameraResetDurationMs : Se, Bc = re.getFocus(ar, Er), Al = typeof Pe == "function" ? Pe(ie, re) : Pe, nh = Al ? (0, r.__assign)((0, r.__assign)({}, Bc), Al) : Bc;
            re.setState((0, r.__assign)((0, r.__assign)({}, nh), { radiusMax: ie.boundingSphere.radius }), Xn);
          }
          Se = void 0, Pe = void 0, _e = !1;
        }
      }
      var Ar = (0, _.Sphere3D)(), Lr = (0, _.Sphere3D)();
      function It() {
        if (re.state.radiusMax === 0)
          return !0;
        if (re.transition.inTransition || Pe)
          return !1;
        var Ge = !0, ar = !0;
        _.Sphere3D.set(Lr, re.state.target, re.state.radius);
        for (var Er = 0, Xr = ie.renderables; Er < Xr.length; Er++) {
          var Ut = Xr[Er];
          if (Ut.state.visible) {
            var ur = Ut.values.boundingSphere.ref.value;
            if (ur.radius) {
              ar = !1;
              var Xn = a.Vec3.distance(Lr.center, ur.center);
              if ((Xn > Lr.radius || Xn > ur.radius || ur.radius > re.state.radiusMax) && !_.Sphere3D.includes(Ar, ur))
                return !0;
              _.Sphere3D.overlaps(Lr, ur) && (Ge = !1);
            }
          }
        }
        return Ge || !ar && Lr.radius <= 0.1;
      }
      var en = 250;
      function Sn(Ge) {
        return ie.needsCommit ? (_.Sphere3D.copy(Ar, ie.boundingSphereVisible), ie.commit(Ge ? void 0 : en) ? (ce.debug.isEnabled && ce.debug.update(), !Y.camera.manualReset && (J.value === 0 || It()) && (_e = !0), Ar.radius === 0 && (Se = 0), re.setState({ radiusMax: ie.boundingSphere.radius }, 0), J.next(X.size), A.isDebugMode && Wn(), !0) : !1) : !0;
      }
      function Wn() {
        console.table(ie.renderables.map(function(Ut) {
          return {
            drawCount: Ut.values.drawCount.ref.value,
            instanceCount: Ut.values.instanceCount.ref.value,
            materialId: Ut.materialId,
            renderItemId: Ut.id
          };
        })), console.log(U.stats);
        var Ge = U.resources.getByteCounts(), ar = Ge.texture, Er = Ge.attribute, Xr = Ge.elements;
        console.log({
          texture: "".concat((ar / 1024 / 1024).toFixed(3), " MiB"),
          attribute: "".concat((Er / 1024 / 1024).toFixed(3), " MiB"),
          elements: "".concat((Xr / 1024 / 1024).toFixed(3), " MiB")
        });
      }
      function oa(Ge) {
        ci(Ge);
        var ar = X.get(Ge), Er = /* @__PURE__ */ new Set();
        Ge.renderObjects.forEach(function(Xr) {
          return Er.add(Xr);
        }), ar ? h.SetUtils.areEqual(Er, ar) || (Er.forEach(function(Xr) {
          ar.has(Xr) || ie.add(Xr);
        }), ar.forEach(function(Xr) {
          Er.has(Xr) || ie.remove(Xr);
        })) : Ge.renderObjects.forEach(function(Xr) {
          return ie.add(Xr);
        }), X.set(Ge, Er), ie.update(Ge.renderObjects, !1), ge = !0, A.isDebugMode && Wn();
      }
      function La(Ge) {
        Do(Ge);
        var ar = X.get(Ge);
        ar && (ar.forEach(function(Er) {
          return ie.remove(Er);
        }), X.delete(Ge), ge = !0, A.isDebugMode && Wn());
      }
      function ci(Ge) {
        Z.has(Ge) || Z.set(Ge, Ge.updated.subscribe(function(ar) {
          Ge.state.syncManually || oa(Ge);
        }));
      }
      function Do(Ge) {
        var ar = Z.get(Ge);
        ar && (ar.unsubscribe(), Z.delete(Ge));
      }
      function nu() {
        var Ge = ie.boundingSphere.radius > 0 ? 100 - Math.round(re.transition.target.radius / ie.boundingSphere.radius * 100) : 0;
        return {
          camera: {
            mode: re.state.mode,
            helper: (0, r.__assign)({}, ce.camera.props),
            stereo: (0, r.__assign)({}, Y.camera.stereo),
            manualReset: !!Y.camera.manualReset
          },
          cameraFog: re.state.fog > 0 ? { name: "on", params: { intensity: re.state.fog } } : { name: "off", params: {} },
          cameraClipping: { far: re.state.clipFar, radius: Ge },
          cameraResetDurationMs: Y.cameraResetDurationMs,
          transparentBackground: Y.transparentBackground,
          viewport: Y.viewport,
          postprocessing: (0, r.__assign)({}, Y.postprocessing),
          marking: (0, r.__assign)({}, Y.marking),
          multiSample: (0, r.__assign)({}, Y.multiSample),
          renderer: (0, r.__assign)({}, se.props),
          trackball: (0, r.__assign)({}, ne.props),
          interaction: (0, r.__assign)({}, me.props),
          debug: (0, r.__assign)({}, ce.debug.props),
          handle: (0, r.__assign)({}, ce.handle.props)
        };
      }
      var Di = oe.subscribe(function() {
        de.dirty = !0, Ve({ force: !0 }), Ve({ force: !0 });
      }), xa = new t.BehaviorSubject(0);
      function Yr(Ge) {
        Ge === void 0 && (Ge = !0), q.updateSize(), rn(), Ps(), Ge && Ne(), xa.next(+/* @__PURE__ */ new Date());
      }
      return {
        webgl: U,
        scene: ie,
        helper: ce,
        add: oa,
        remove: La,
        commit: Ye,
        controls: ne,
        update: function(Ge, ar) {
          if (Ge) {
            if (!X.has(Ge))
              return;
            ie.update(Ge.renderObjects, !!ar);
          } else
            ie.update(void 0, !!ar);
          ge = !0;
        },
        clear: function() {
          Z.forEach(function(Ge) {
            return Ge.unsubscribe();
          }), Z.clear(), X.clear(), ie.clear(), ce.debug.clear(), Ne(), J.next(X.size);
        },
        syncVisibility: function() {
          re.state.radiusMax === 0 && (_e = !0, Se = 0), ie.syncVisibility() && ce.debug.isEnabled && ce.debug.update(), Ne();
        },
        requestDraw: Ne,
        tick: ze,
        animate: Xe,
        resetTime: je,
        pause: Fe,
        resume: function() {
          we = !1;
        },
        identify: He,
        getPosition: Be,
        mark: pe,
        getLoci: Me,
        handleResize: Yr,
        requestResize: function() {
          De = !0;
        },
        requestCameraReset: function(Ge) {
          Se = Ge == null ? void 0 : Ge.durationMs, Pe = Ge == null ? void 0 : Ge.snapshot, _e = !0;
        },
        camera: re,
        boundingSphere: ie.boundingSphere,
        boundingSphereVisible: ie.boundingSphereVisible,
        get notifyDidDraw() {
          return Ee;
        },
        set notifyDidDraw(Ge) {
          Ee = Ge;
        },
        didDraw: Q,
        commited: W,
        reprCount: J,
        resized: xa,
        setProps: function(Ge, ar) {
          var Er, Xr, Ut;
          ar === void 0 && (ar = !1);
          var ur = typeof Ge == "function" ? (0, P.produce)(nu(), Ge) : Ge, Xn = /* @__PURE__ */ Object.create(null);
          if (ur.camera && ur.camera.mode !== void 0 && ur.camera.mode !== re.state.mode && (Xn.mode = ur.camera.mode), ur.cameraFog !== void 0 && ur.cameraFog.params) {
            var Bc = ur.cameraFog.name === "on" ? ur.cameraFog.params.intensity : 0;
            Bc !== re.state.fog && (Xn.fog = Bc);
          }
          if (ur.cameraClipping !== void 0 && (ur.cameraClipping.far !== void 0 && ur.cameraClipping.far !== re.state.clipFar && (Xn.clipFar = ur.cameraClipping.far), ur.cameraClipping.radius !== void 0)) {
            var Al = ie.boundingSphere.radius / 100 * (100 - ur.cameraClipping.radius);
            Al > 0 && Al !== Xn.radius && (Xn.radius = Math.max(Al, 0.01));
          }
          if (Object.keys(Xn).length > 0 && re.setState(Xn), !((Er = ur.camera) === null || Er === void 0) && Er.helper && ce.camera.setProps(ur.camera.helper), ((Xr = ur.camera) === null || Xr === void 0 ? void 0 : Xr.manualReset) !== void 0 && (Y.camera.manualReset = ur.camera.manualReset), ((Ut = ur.camera) === null || Ut === void 0 ? void 0 : Ut.stereo) !== void 0 && Object.assign(Y.camera.stereo, ur.camera.stereo), ur.cameraResetDurationMs !== void 0 && (Y.cameraResetDurationMs = ur.cameraResetDurationMs), ur.transparentBackground !== void 0 && (Y.transparentBackground = ur.transparentBackground), ur.viewport !== void 0) {
            var nh = Y.viewport === ur.viewport || Y.viewport.name === ur.viewport.name && (0, I.shallowEqual)(Y.viewport.params, ur.viewport.params);
            nh || (Y.viewport = ur.viewport, rn(), Ps());
          }
          ur.postprocessing && Object.assign(Y.postprocessing, ur.postprocessing), ur.marking && Object.assign(Y.marking, ur.marking), ur.multiSample && Object.assign(Y.multiSample, ur.multiSample), ur.renderer && se.setProps(ur.renderer), ur.trackball && ne.setProps(ur.trackball), ur.interaction && me.setProps(ur.interaction), ur.debug && ce.debug.setProps(ur.debug), ur.handle && ce.handle.setProps(ur.handle), Xn.mode === "orthographic" && (Y.camera.stereo.name = "off"), ar || Ne();
        },
        getImagePass: function(Ge) {
          return Ge === void 0 && (Ge = {}), new g.ImagePass(U, se, ie, re, ce, q.draw.wboitEnabled, Ge);
        },
        getRenderObjects: function() {
          var Ge = [];
          return ie.forEach(function(ar, Er) {
            return Ge.push(Er);
          }), Ge;
        },
        get props() {
          return nu();
        },
        get input() {
          return H;
        },
        get stats() {
          return se.stats;
        },
        get interaction() {
          return me.events;
        },
        dispose: function() {
          Di.unsubscribe(), ue = [], ie.clear(), ce.debug.clear(), ne.dispose(), se.dispose(), me.dispose();
        }
      };
      function rn() {
        var Ge = z, ar = j, Er = ae, Xr = le;
        Y.viewport.name === "canvas" ? (z = 0, j = 0, ae = te.drawingBufferWidth, le = te.drawingBufferHeight) : Y.viewport.name === "static-frame" ? (z = Y.viewport.params.x * U.pixelRatio, le = Y.viewport.params.height * U.pixelRatio, j = te.drawingBufferHeight - le - Y.viewport.params.y * U.pixelRatio, ae = Y.viewport.params.width * U.pixelRatio) : Y.viewport.name === "relative-frame" && (z = Math.round(Y.viewport.params.x * te.drawingBufferWidth), le = Math.round(Y.viewport.params.height * te.drawingBufferHeight), j = Math.round(te.drawingBufferHeight - le - Y.viewport.params.y * te.drawingBufferHeight), ae = Math.round(Y.viewport.params.width * te.drawingBufferWidth)), (Ge !== z || ar !== j || Er !== ae || Xr !== le) && (fe = !0);
      }
      function Ps() {
        de.setViewport(z, j, ae, le), se.setViewport(z, j, ae, le), s.Viewport.set(re.viewport, z, j, ae, le), s.Viewport.set(ne.viewport, z, j, ae, le);
      }
    }
    G.create = L;
  })(k || (k = {})), e.Canvas3D = k;
})(iU);
var tc = {};
Object.defineProperty(tc, "__esModule", { value: !0 });
tc.canvasToBlob = tc.resizeCanvas = tc.setCanvasSize = void 0;
var rB = Te;
function AH(e, r, t, n) {
  n === void 0 && (n = 1), e.width = Math.round(window.devicePixelRatio * n * r), e.height = Math.round(window.devicePixelRatio * n * t), Object.assign(e.style, { width: "".concat(r, "px"), height: "".concat(t, "px") });
}
tc.setCanvasSize = AH;
function Cme(e, r, t) {
  t === void 0 && (t = 1);
  var n = window.innerWidth, a = window.innerHeight;
  r !== document.body && (n = r.offsetWidth, a = r.offsetHeight), AH(e, n, a, t);
}
tc.resizeCanvas = Cme;
function Ame(e, r, t, n) {
  for (var a = atob(e.toDataURL(t, n).split(",")[1]), i = a.length, o = i >> 2, c = new Uint8Array(i), s = new Uint32Array(c.buffer, 0, o), u = 0, l = 0; l < o; ++l)
    s[l] = a.charCodeAt(u++) | a.charCodeAt(u++) << 8 | a.charCodeAt(u++) << 16 | a.charCodeAt(u++) << 24;
  for (var f = i & 3; f--; )
    c[u] = a.charCodeAt(u++);
  r(new Blob([c], { type: t || "image/png" }));
}
function xme(e, r, t) {
  return (0, rB.__awaiter)(this, void 0, void 0, function() {
    return (0, rB.__generator)(this, function(n) {
      return [2, new Promise(function(a, i) {
        var o = function(c) {
          c ? a(c) : i("no blob returned");
        };
        HTMLCanvasElement.prototype.toBlob ? e.toBlob(o, r, t) : Ame(e, o, r, t);
      })];
    });
  });
}
tc.canvasToBlob = xme;
var Xh = {}, Jt = {}, Wa = {}, yo = {}, Rr = {};
Object.defineProperty(Rr, "__esModule", { value: !0 });
Rr.eachResidueAtom = Rr.eachBondedAtom = Rr.eachIntraBondedAtom = Rr.eachInterBondedAtom = Rr.connectedTo = Rr.interConnectedTo = Rr.intraConnectedTo = Rr.bondToElementCount = Rr.bondCount = Rr.intraBondCount = Rr.interBondCount = Rr.compId = Rr.altLoc = Rr.atomId = Rr.formalCharge = Rr.typeSymbol = void 0;
var m0 = Gr, Tme = Qe();
function xH(e, r) {
  return e.model.atomicHierarchy.atoms.type_symbol.value(e.elements[r]);
}
Rr.typeSymbol = xH;
function Pme(e, r) {
  return e.model.atomicHierarchy.atoms.pdbx_formal_charge.value(e.elements[r]);
}
Rr.formalCharge = Pme;
function Mme(e, r) {
  return e.model.atomicHierarchy.atoms.label_atom_id.value(e.elements[r]);
}
Rr.atomId = Mme;
function wme(e, r) {
  return e.model.atomicHierarchy.atoms.label_alt_id.value(e.elements[r]);
}
Rr.altLoc = wme;
function Eme(e, r) {
  return e.model.atomicHierarchy.atoms.label_comp_id.value(e.elements[r]);
}
Rr.compId = Eme;
function TH(e, r, t) {
  for (var n = 0, a = e.interUnitBonds.getEdgeIndices(t, r.id), i = 0, o = a.length; i < o; ++i) {
    var c = e.interUnitBonds.edges[a[i]];
    m0.BondType.isCovalent(c.props.flag) && (n += 1);
  }
  return n;
}
Rr.interBondCount = TH;
function PH(e, r) {
  for (var t = 0, n = e.bonds, a = n.offset, i = n.edgeProps.flags, o = a[r], c = a[r + 1]; o < c; ++o)
    m0.BondType.isCovalent(i[o]) && (t += 1);
  return t;
}
Rr.intraBondCount = PH;
function Dme(e, r, t) {
  return TH(e, r, t) + PH(r, t);
}
Rr.bondCount = Dme;
function Ime(e, r, t, n) {
  var a = 0;
  return IH(e, r, t, function(i, o) {
    xH(i, o) === n && (a += 1);
  }), a;
}
Rr.bondToElementCount = Ime;
function MH(e, r, t) {
  var n = e.bonds, a = n.offset, i = n.b, o = n.edgeProps.flags;
  m0.BondType.is;
  for (var c = a[r], s = a[r + 1]; c < s; ++c)
    if (i[c] === t && m0.BondType.isCovalent(o[c]))
      return !0;
  return !1;
}
Rr.intraConnectedTo = MH;
function wH(e, r, t, n, a) {
  var i = e.interUnitBonds.getEdge(t, r.id, a, n.id);
  return i && m0.BondType.isCovalent(i.props.flag);
}
Rr.interConnectedTo = wH;
function Bme(e, r, t, n, a) {
  return r === n ? MH(r, t, a) : wH(e, r, t, n, a);
}
Rr.connectedTo = Bme;
function EH(e, r, t, n) {
  for (var a = e.interUnitBonds.getEdgeIndices(t, r.id), i = 0, o = a.length; i < o; ++i) {
    var c = e.interUnitBonds.edges[a[i]], s = e.unitMap.get(c.unitB);
    m0.BondType.isCovalent(c.props.flag) && n(s, c.indexB);
  }
}
Rr.eachInterBondedAtom = EH;
function DH(e, r, t) {
  for (var n = e.bonds, a = n.offset, i = n.b, o = n.edgeProps.flags, c = a[r], s = a[r + 1]; c < s; ++c)
    m0.BondType.isCovalent(o[c]) && t(e, i[c]);
}
Rr.eachIntraBondedAtom = DH;
function IH(e, r, t, n) {
  EH(e, r, t, n), DH(r, t, n);
}
Rr.eachBondedAtom = IH;
function Nme(e, r, t) {
  for (var n = e.model.atomicHierarchy.residueAtomSegments.offsets, a = e.getResidueIndex(r), i = n[a], o = n[a + 1]; i < o; ++i) {
    var c = Tme.SortedArray.indexOf(e.elements, i);
    c !== -1 && t(c);
  }
}
Rr.eachResidueAtom = Nme;
Object.defineProperty(yo, "__esModule", { value: !0 });
yo.calcPlaneAngle = yo.calcAngles = yo.AtomGeometryAngles = yo.assignGeometry = yo.geometryLabel = void 0;
var B2 = kn, Ui = Re, Qm = Rr;
function Vme(e) {
  switch (e) {
    case 0:
      return "Spherical";
    case 1:
      return "Terminal";
    case 2:
      return "Linear";
    case 3:
      return "Trigonal";
    case 4:
      return "Tetrahedral";
    case 5:
      return "Trigonal Bi-Pyramidal";
    case 6:
      return "Octahedral";
    case 7:
      return "Square Planar";
    case 8:
      return "Unknown";
  }
}
yo.geometryLabel = Vme;
function Rme(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;
  }
}
yo.assignGeometry = Rme;
yo.AtomGeometryAngles = /* @__PURE__ */ new Map([
  [2, (0, B2.degToRad)(180)],
  [3, (0, B2.degToRad)(120)],
  [4, (0, B2.degToRad)(109.4721)],
  [6, (0, B2.degToRad)(90)]
]);
var Wb = (0, Ui.Vec3)(), Xb = (0, Ui.Vec3)(), Xf = (0, Ui.Vec3)(), Yb = (0, Ui.Vec3)(), Zm = (0, Ui.Vec3)();
function Ome(e, r, t, n, a) {
  var i = [];
  return r.conformation.position(r.elements[t], Xf), n.conformation.position(n.elements[a], Yb), Ui.Vec3.sub(Wb, Yb, Xf), (0, Qm.eachBondedAtom)(e, r, t, function(o, c) {
    (0, Qm.typeSymbol)(o, c) !== "H" && (o.conformation.position(o.elements[c], Zm), Ui.Vec3.sub(Xb, Zm, Xf), i.push(Ui.Vec3.angle(Wb, Xb)));
  }), i;
}
yo.calcAngles = Ome;
function Fme(e, r, t, n, a) {
  r.conformation.position(r.elements[t], Xf), n.conformation.position(n.elements[a], Yb), Ui.Vec3.sub(Wb, Yb, Xf);
  var i = [(0, Ui.Vec3)(), (0, Ui.Vec3)()], o = 0, c, s;
  if ((0, Qm.eachBondedAtom)(e, r, t, function(u, l) {
    o > 1 || (0, Qm.typeSymbol)(u, l) !== "H" && (c = u, s = l, u.conformation.position(u.elements[l], Zm), Ui.Vec3.sub(i[o++], Zm, Xf));
  }), o === 1 && c && s && (0, Qm.eachBondedAtom)(e, c, s, function(u, l) {
    o > 1 || u === r && l === t || (0, Qm.typeSymbol)(u, l) !== "H" && (u.conformation.position(u.elements[l], Zm), Ui.Vec3.sub(i[o++], Zm, Xf));
  }), o === 2)
    return Ui.Vec3.cross(Xb, i[0], i[1]), Math.abs(Math.PI / 2 - Ui.Vec3.angle(Xb, Wb));
}
yo.calcPlaneAngle = Fme;
var Ao = {}, Fp = {}, BH = {}, j4 = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.isNonmetal = e.isMetal = e.isActinide = e.isLanthanide = e.isTransitionMetal = e.isHalogen = e.Halogens = e.isMetalloid = e.Metalloids = e.isPostTransitionMetal = e.PostTransitionMetals = e.isNobleGas = e.NobleGases = e.isDiatomicNonmetal = e.DiatomicNonmetals = e.isPolyatomicNonmetal = e.PolyatomicNonmetals = e.isAlkalineEarthMetal = e.AlkalineEarthMetals = e.isAlkaliMetal = e.AlkaliMetals = e.ElementNames = void 0;
  var r = wE;
  e.ElementNames = {
    H: "Hydrogen",
    HE: "Helium",
    LI: "Lithium",
    BE: "Beryllium",
    B: "Boron",
    C: "Carbon",
    N: "Nitrogen",
    O: "Oxygen",
    F: "Fluorine",
    NE: "Neon",
    NA: "Sodium",
    MG: "Magnesium",
    AL: "Aluminum",
    SI: "Silicon",
    P: "Phosphorus",
    S: "Sulfur",
    CL: "Chlorine",
    AR: "Argon",
    K: "Potassium",
    CA: "Calcium",
    SC: "Scandium",
    TI: "Titanium",
    V: "Vanadium",
    CR: "Chromium",
    MN: "Manganese",
    FE: "Iron",
    CO: "Cobalt",
    NI: "Nickel",
    CU: "Copper",
    ZN: "Zinc",
    GA: "Gallium",
    GE: "Germanium",
    AS: "Arsenic",
    SE: "Selenium",
    BR: "Bromine",
    KR: "Krypton",
    RB: "Rubidium",
    SR: "Strontium",
    Y: "Yttrium",
    ZR: "Zirconium",
    NB: "Niobium",
    MO: "Molybdenum",
    TC: "Technetium",
    RU: "Ruthenium",
    RH: "Rhodium",
    PD: "Palladium",
    AG: "Silver",
    CD: "Cadmium",
    IN: "Indium",
    SN: "Tin",
    SB: "Antimony",
    TE: "Tellurium",
    I: "Iodine",
    XE: "Xenon",
    CS: "Cesium",
    BA: "Barium",
    LA: "Lanthanum",
    CE: "Cerium",
    PR: "Praseodymium",
    ND: "Neodymium",
    PM: "Promethium",
    SM: "Samarium",
    EU: "Europium",
    GD: "Gadolinium",
    TB: "Terbium",
    DY: "Dysprosium",
    HO: "Holmium",
    ER: "Erbium",
    TM: "Thulium",
    YB: "Ytterbium",
    LU: "Lutetium",
    HF: "Hafnium",
    TA: "Tantalum",
    W: "Wolfram",
    RE: "Rhenium",
    OS: "Osmium",
    IR: "Iridium",
    PT: "Platinum",
    AU: "Gold",
    HG: "Mercury",
    TL: "Thallium",
    PB: "Lead",
    BI: "Bismuth",
    PO: "Polonium",
    AT: "Astatine",
    RN: "Radon",
    FR: "Francium",
    RA: "Radium",
    AC: "Actinium",
    TH: "Thorium",
    PA: "Protactinium",
    U: "Uranium",
    NP: "Neptunium",
    PU: "Plutonium",
    AM: "Americium",
    CM: "Curium",
    BK: "Berkelium",
    CF: "Californium",
    ES: "Einsteinium",
    FM: "Fermium",
    MD: "Mendelevium",
    NO: "Nobelium",
    LR: "Lawrencium",
    RF: "Rutherfordium",
    DB: "Dubnium",
    SG: "Seaborgium",
    BH: "Bohrium",
    HS: "Hassium",
    MT: "Meitnerium",
    DS: "Darmstadtium",
    RG: "Roentgenium",
    CN: "Copernicium",
    NH: "Nihonium",
    FL: "Flerovium",
    MC: "Moscovium",
    LV: "Livermorium",
    TS: "Tennessine",
    OG: "Oganesson"
  }, e.AlkaliMetals = /* @__PURE__ */ new Set([
    "LI",
    "NA",
    "K",
    "RB",
    "CS",
    "FR"
  ]);
  function t(v) {
    return e.AlkaliMetals.has(v);
  }
  e.isAlkaliMetal = t, e.AlkalineEarthMetals = /* @__PURE__ */ new Set([
    "BE",
    "MG",
    "CA",
    "SR",
    "BA",
    "RA"
  ]);
  function n(v) {
    return e.AlkalineEarthMetals.has(v);
  }
  e.isAlkalineEarthMetal = n, e.PolyatomicNonmetals = /* @__PURE__ */ new Set([
    "C",
    "P",
    "S",
    "SE"
  ]);
  function a(v) {
    return e.PolyatomicNonmetals.has(v);
  }
  e.isPolyatomicNonmetal = a, e.DiatomicNonmetals = /* @__PURE__ */ new Set([
    "H",
    "N",
    "O",
    "F",
    "CL",
    "BR",
    "I"
  ]);
  function i(v) {
    return e.DiatomicNonmetals.has(v);
  }
  e.isDiatomicNonmetal = i, e.NobleGases = /* @__PURE__ */ new Set([
    "HE",
    "NE",
    "AR",
    "KR",
    "XE",
    "RN"
  ]);
  function o(v) {
    return e.NobleGases.has(v);
  }
  e.isNobleGas = o, e.PostTransitionMetals = /* @__PURE__ */ new Set([
    "ZN",
    "GA",
    "CD",
    "IN",
    "SN",
    "HG",
    "TI",
    "PB",
    "BI",
    "PO",
    "CN"
  ]);
  function c(v) {
    return e.PostTransitionMetals.has(v);
  }
  e.isPostTransitionMetal = c, e.Metalloids = /* @__PURE__ */ new Set([
    "B",
    "SI",
    "GE",
    "AS",
    "SB",
    "TE",
    "AT"
  ]);
  function s(v) {
    return e.Metalloids.has(v);
  }
  e.isMetalloid = s, e.Halogens = /* @__PURE__ */ new Set([
    "F",
    "CL",
    "BR",
    "I",
    "AT"
  ]);
  function u(v) {
    return e.Halogens.has(v);
  }
  e.isHalogen = u;
  function l(v) {
    var h = (0, r.AtomNumber)(v);
    return h >= 21 && h <= 29 || h >= 39 && h <= 47 || h >= 72 && h <= 79 || h >= 104 && h <= 108;
  }
  e.isTransitionMetal = l;
  function f(v) {
    var h = (0, r.AtomNumber)(v);
    return h >= 57 && h <= 71;
  }
  e.isLanthanide = f;
  function d(v) {
    var h = (0, r.AtomNumber)(v);
    return h >= 89 && h <= 103;
  }
  e.isActinide = d;
  function m(v) {
    return t(v) || n(v) || f(v) || d(v) || l(v) || c(v);
  }
  e.isMetal = m;
  function p(v) {
    return i(v) || a(v) || o(v);
  }
  e.isNonmetal = p;
})(j4);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.calcValenceModel = e.ValenceModelParams = e.calculateHydrogensCharge = e.explicitValence = void 0;
  var r = Te, t = Je(), n = j4, a = yo, i = Rr, o = Le, c = Zt;
  Qe();
  var s = Gr, u = new t.Bond.ElementBondIterator(), l = new t.Bond.ElementBondIterator();
  function f(C, S, b) {
    var g = (0, i.typeSymbol)(S, b), _ = g === "O" || g === "N";
    if (_ && (0, i.bondCount)(C, S, b) === 4)
      return !1;
    for (u.setElement(C, S, b); u.hasNext; ) {
      var A = u.move();
      if (A.order > 1)
        return !0;
      if (_) {
        var M = (0, i.typeSymbol)(A.otherUnit, A.otherIndex);
        for (l.setElement(C, A.otherUnit, A.otherIndex); l.hasNext; ) {
          var P = l.move();
          if (P.order > 1) {
            if ((M === "P" || M === "S") && (0, i.typeSymbol)(P.otherUnit, P.otherIndex) === "O")
              continue;
            return !0;
          }
        }
      }
    }
    return !1;
  }
  function d(C, S, b) {
    for (var g = 0, _ = S.bonds, A = _.offset, M = _.edgeProps, P = M.flags, T = M.order, x = A[b], w = A[b + 1]; x < w; ++x)
      s.BondType.isCovalent(P[x]) && (g += T[x]);
    return C.interUnitBonds.getEdgeIndices(b, S.id).forEach(function(E) {
      var I = C.interUnitBonds.edges[E];
      s.BondType.isCovalent(I.props.flag) && (g += I.props.order);
    }), g;
  }
  e.explicitValence = d;
  var m = new t.Bond.ElementBondIterator(), p = new t.Bond.ElementBondIterator();
  function v(C, S, b, g) {
    var _ = (0, i.bondToElementCount)(
      C,
      S,
      b,
      "H"
      /* H */
    ), A = (0, i.typeSymbol)(S, b), M = (0, i.formalCharge)(S, b), P = g.assignCharge === "always" || g.assignCharge === "auto" && M === 0, T = !["sdf", "mol"].includes(S.model.sourceData.kind) && (g.assignH === "always" || g.assignH === "auto" && _ === 0), x = (0, i.bondCount)(C, S, b), w = d(C, S, b), E = f(C, S, b), I = w - x > 0, B = 0, D = 8;
    switch (A) {
      case "H":
        P && (x === 0 ? (M = 1, D = 0) : x === 1 && (M = 0, D = 1));
        break;
      case "C":
        P && (M = 0), T && (B = Math.max(0, 4 - w - Math.abs(M))), D = (0, a.assignGeometry)(x + B + Math.max(0, -M));
        break;
      case "N":
        if (P)
          if (!T)
            M = w - 3;
          else if (E && w < 4)
            x - _ === 1 && w - _ === 2 ? M = 1 : M = 0;
          else
            for (m.setElement(C, S, b); m.hasNext; ) {
              var N = m.move(), O = (0, i.typeSymbol)(N.otherUnit, N.otherIndex);
              if (O === "S" || (0, n.isMetal)(O) || s.BondType.is(
                N.type,
                32
                /* Computed */
              )) {
                M = 0;
                break;
              } else
                M = 1;
            }
        T && (B = Math.max(0, 3 - w + M)), E && !I ? D = (0, a.assignGeometry)(x + B - M) : D = (0, a.assignGeometry)(x + B + 1 - M);
        break;
      case "O":
        if (P && (T || (M = w - 2), w === 1)) {
          m.setElement(C, S, b);
          e: for (; m.hasNext; ) {
            var V = m.move();
            for (p.setElement(C, V.otherUnit, V.otherIndex); p.hasNext; ) {
              var k = p.move();
              if (!(k.otherUnit === S && k.otherIndex === b) && (0, i.typeSymbol)(k.otherUnit, k.otherIndex) === "O" && k.order === 2) {
                M = -1;
                break e;
              }
            }
          }
        }
        T && (B = Math.max(0, 2 - w + M)), E && !I ? D = (0, a.assignGeometry)(x + B - M + 1) : D = (0, a.assignGeometry)(x + B - M + 2);
        break;
      case "S":
        P && (T || (w <= 3 && (0, i.bondToElementCount)(
          C,
          S,
          b,
          "O"
          /* O */
        ) === 0 ? M = w - 2 : M = 0)), T && w < 2 && (B = Math.max(0, 2 - w + M)), w <= 3 && (D = (0, a.assignGeometry)(x + B - M + 2));
        break;
      case "F":
      case "CL":
      case "BR":
      case "I":
      case "AT":
        P && (M = w - 1);
        break;
      case "LI":
      case "NA":
      case "K":
      case "RB":
      case "CS":
      case "FR":
        P && (M = 1 - w);
        break;
      case "BE":
      case "MG":
      case "CA":
      case "SR":
      case "BA":
      case "RA":
        P && (M = 2 - w);
        break;
      default:
        c.isDebugMode && console.warn("Requested charge, protonation for an unhandled element", A);
    }
    return [M, B, B + _, D];
  }
  e.calculateHydrogensCharge = v;
  function h(C, S, b) {
    for (var g = S.elements.length, _ = new Int8Array(g), A = new Int8Array(g), M = new Int8Array(g), P = new Int8Array(g), T = 0; T < g; ++T) {
      var x = T, w = v(C, S, x, b), E = w[0], I = w[1], B = w[2], D = w[3];
      _[T] = E, A[T] = I, M[T] = B, P[T] = D;
    }
    return { charge: _, implicitH: A, totalH: M, idealGeometry: P };
  }
  e.ValenceModelParams = {
    assignCharge: o.ParamDefinition.Select("auto", [
      ["always", "always"],
      ["auto", "auto"],
      ["never", "never"]
    ]),
    assignH: o.ParamDefinition.Select("auto", [
      ["always", "always"],
      ["auto", "auto"],
      ["never", "never"]
    ])
  };
  function y(C, S, b) {
    return (0, r.__awaiter)(this, void 0, void 0, function() {
      var g, _, A, M, P, T;
      return (0, r.__generator)(this, function(x) {
        for (g = (0, r.__assign)((0, r.__assign)({}, o.ParamDefinition.getDefaultValues(e.ValenceModelParams)), b), _ = /* @__PURE__ */ new Map(), A = 0, M = S.units.length; A < M; ++A)
          P = S.units[A], t.Unit.isAtomic(P) && (T = h(S, P, g), _.set(P.id, T));
        return [2, _];
      });
    });
  }
  e.calcValenceModel = y;
})(BH);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ValenceModelProvider = e.ValenceModelParams = void 0;
  var r = Te, t = Le, n = BH, a = N0, i = In;
  e.ValenceModelParams = (0, r.__assign)({}, n.ValenceModelParams), e.ValenceModelProvider = a.CustomStructureProperty.createProvider({
    label: "Valence Model",
    descriptor: (0, i.CustomPropertyDescriptor)({
      name: "molstar_computed_valence_model"
      // TODO `cifExport` and `symbol`
    }),
    type: "local",
    defaultParams: e.ValenceModelParams,
    getParams: function(o) {
      return e.ValenceModelParams;
    },
    isApplicable: function(o) {
      return !0;
    },
    obtain: function(o, c, s) {
      return (0, r.__awaiter)(void 0, void 0, void 0, function() {
        var u, l;
        return (0, r.__generator)(this, function(f) {
          switch (f.label) {
            case 0:
              return u = (0, r.__assign)((0, r.__assign)({}, t.ParamDefinition.getDefaultValues(e.ValenceModelParams)), s), l = {}, [4, (0, n.calcValenceModel)(o.runtime, c, u)];
            case 1:
              return [2, (l.value = f.sent(), l)];
          }
        });
      });
    }
  });
})(Fp);
Object.defineProperty(Ao, "__esModule", { value: !0 });
Ao.FeaturesBuilder = Ao.Features = void 0;
var tB = Te, xt = wr(), nB = nr(), aB = Qe(), Lme = Fp, Bf = Re, iB = B0, Qb;
(function(e) {
  function r(f, d, m, p) {
    return Bf.Vec3.set(f, p.x[m], p.y[m], p.z[m]), Bf.Vec3.transformMat4(f, f, d.conformation.operator.matrix), f;
  }
  e.setPosition = r;
  function t(f, d) {
    for (var m = new Int32Array(d + 1), p = new Int32Array(d), v = new Int32Array(d), h = f.members, y = f.count, C = f.offsets, S = 0, b = C[y]; S < b; ++S)
      ++v[h[S]];
    for (var g = 0, S = 0; S < d; S++)
      m[S] = g, g += v[S];
    m[d] = g;
    for (var _ = new Int32Array(g), S = 0; S < y; ++S)
      for (var A = C[S], M = C[S + 1]; A < M; ++A) {
        var P = h[A], T = m[P] + p[P];
        _[T] = S, ++p[P];
      }
    return { indices: _, offsets: m };
  }
  e.createElementsIndex = t;
  function n(f, d) {
    var m, p;
    return (0, tB.__assign)((0, tB.__assign)({}, d), {
      get lookup3d() {
        if (!m) {
          var v = {
            x: d.x,
            y: d.y,
            z: d.z,
            indices: aB.OrderedSet.ofBounds(0, d.count)
          };
          m = (0, nB.GridLookup3D)(v, (0, iB.getBoundary)(v));
        }
        return m;
      },
      get elementsIndex() {
        return p || (p = t(d, f));
      },
      subset: function(v) {
        return a(d, v);
      }
    });
  }
  e.create = n;
  function a(f, d) {
    for (var m, p = f.count, v = f.types, h = [], y = 0; y < p; ++y)
      d.has(v[y]) && h.push(y);
    var C = aB.SortedArray.ofSortedArray(h);
    return {
      indices: C,
      get lookup3d() {
        if (!m) {
          var S = { x: f.x, y: f.y, z: f.z, indices: C };
          m = (0, nB.GridLookup3D)(S, (0, iB.getBoundary)(S));
        }
        return m;
      }
    };
  }
  e.createSubset = a;
  function i(f, d, m) {
    var p = Lme.ValenceModelProvider.get(f).value;
    if (!p || !p.has(d.id))
      throw new Error("valence model required");
    return {
      unit: d,
      types: m.types,
      feature: -1,
      x: m.x,
      y: m.y,
      z: m.z,
      members: m.members,
      offsets: m.offsets,
      idealGeometry: p.get(d.id).idealGeometry
    };
  }
  e.Info = i;
  function o(f, d) {
    return Bf.Vec3.set(f, d.x[d.feature], d.y[d.feature], d.z[d.feature]), Bf.Vec3.transformMat4(f, f, d.unit.conformation.operator.matrix), f;
  }
  e.position = o;
  var c = (0, Bf.Vec3)(), s = (0, Bf.Vec3)();
  function u(f, d) {
    var m = f.members[f.offsets[f.feature]], p = d.members[d.offsets[d.feature]];
    return f.unit.conformation.position(f.unit.elements[m], c), d.unit.conformation.position(d.unit.elements[p], s), Bf.Vec3.distance(c, s);
  }
  e.distance = u;
  function l(f, d) {
    return { types: new Set(f), add: d };
  }
  e.Provider = l;
})(Qb || (Qb = {}));
Ao.Features = Qb;
var KM;
(function(e) {
  function r(t, n, a) {
    t === void 0 && (t = 2048), n === void 0 && (n = 1024);
    var i = xt.ChunkedArray.create(Float32Array, 1, n, a ? a.x : t), o = xt.ChunkedArray.create(Float32Array, 1, n, a ? a.y : t), c = xt.ChunkedArray.create(Float32Array, 1, n, a ? a.z : t), s = xt.ChunkedArray.create(Uint8Array, 1, n, a ? a.types : t), u = xt.ChunkedArray.create(Uint8Array, 1, n, a ? a.groups : t), l = xt.ChunkedArray.create(Uint32Array, 1, n, a ? a.offsets : t), f = xt.ChunkedArray.create(Uint32Array, 1, n, a ? a.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 = f.elementCount, d.count = 0;
      },
      pushMember: function(m, p, v, h) {
        xt.ChunkedArray.add(f, h), d.x += m, d.y += p, d.z += v, d.count += 1;
      },
      finishState: function(m, p) {
        var v = d.count;
        v !== 0 && (xt.ChunkedArray.add(s, m), xt.ChunkedArray.add(u, p), xt.ChunkedArray.add(i, d.x / v), xt.ChunkedArray.add(o, d.y / v), xt.ChunkedArray.add(c, d.z / v), xt.ChunkedArray.add(l, d.offset));
      },
      add: function(m, p, v, h, y, C) {
        xt.ChunkedArray.add(s, m), xt.ChunkedArray.add(u, p), xt.ChunkedArray.add(i, v), xt.ChunkedArray.add(o, h), xt.ChunkedArray.add(c, y), xt.ChunkedArray.add(l, f.elementCount), xt.ChunkedArray.add(f, C);
      },
      getFeatures: function(m) {
        xt.ChunkedArray.add(l, f.elementCount);
        var p = xt.ChunkedArray.compact(i, !0), v = xt.ChunkedArray.compact(o, !0), h = xt.ChunkedArray.compact(c, !0), y = i.elementCount;
        return Qb.create(m, {
          x: p,
          y: v,
          z: h,
          count: y,
          types: xt.ChunkedArray.compact(s, !0),
          groups: xt.ChunkedArray.compact(u, !0),
          offsets: xt.ChunkedArray.compact(l, !0),
          members: xt.ChunkedArray.compact(f, !0)
        });
      }
    };
  }
  e.create = r;
})(KM || (KM = {}));
Ao.FeaturesBuilder = KM;
var Mo = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.featureGroupLabel = e.featureTypeLabel = e.interactionTypeLabel = e.InteractionType = e.InteractionFlag = e.InteractionsInterContacts = e.InteractionsIntraContacts = void 0;
  var r = Te, t = qd, n;
  (function(u) {
    function l(f, d, m) {
      for (var p = new Int32Array(m + 1), v = new Int32Array(m), h = new Int32Array(m), y = d.members, C = d.offsets, S = 0, b = f.edgeCount * 2; S < b; ++S) {
        var g = f.a[S], _ = f.b[S];
        if (!(g > _)) {
          for (var A = C[g], M = C[g + 1]; A < M; ++A)
            ++h[y[A]];
          for (var A = C[_], M = C[_ + 1]; A < M; ++A)
            ++h[y[A]];
        }
      }
      for (var P = 0, S = 0; S < m; S++)
        p[S] = P, P += h[S];
      p[m] = P;
      for (var T = new Int32Array(P), S = 0, b = f.edgeCount * 2; S < b; ++S) {
        var g = f.a[S], _ = f.b[S];
        if (!(g > _)) {
          for (var A = C[g], M = C[g + 1]; A < M; ++A) {
            var x = y[A], w = p[x] + v[x];
            T[w] = S, ++v[x];
          }
          for (var A = C[_], M = C[_ + 1]; A < M; ++A) {
            var x = y[A], w = p[x] + v[x];
            T[w] = S, ++v[x];
          }
        }
      }
      return { indices: T, offsets: p };
    }
    u.createElementsIndex = l;
  })(n || (n = {})), e.InteractionsIntraContacts = n;
  var a = (
    /** @class */
    function(u) {
      (0, r.__extends)(l, u);
      function l(f, d) {
        var m = u.call(this, f) || this;
        m.elementKeyIndex = /* @__PURE__ */ new Map();
        for (var p = 0, v = m.edges.length; p < v; ++p)
          for (var h = m.edges[p], y = h.unitA, C = h.indexA, S = d.get(y), b = S.offsets, g = S.members, _ = b[C], A = b[C + 1]; _ < A; ++_) {
            var M = m.getElementKey(g[_], y), P = m.elementKeyIndex.get(M);
            P === void 0 ? m.elementKeyIndex.set(M, [p]) : P.push(p);
          }
        return m;
      }
      return l.prototype.getContactIndicesForElement = function(f, d) {
        return this.elementKeyIndex.get(this.getElementKey(f, d.id)) || [];
      }, l.prototype.getElementKey = function(f, d) {
        return "".concat(f, "|").concat(d);
      }, l;
    }(t.InterUnitGraph)
  );
  e.InteractionsInterContacts = a, function(u) {
    u[u.None = 0] = "None", u[u.Filtered = 1] = "Filtered";
  }(e.InteractionFlag || (e.InteractionFlag = {}));
  var i;
  (function(u) {
    u[u.Unknown = 0] = "Unknown", u[u.Ionic = 1] = "Ionic", u[u.CationPi = 2] = "CationPi", u[u.PiStacking = 3] = "PiStacking", u[u.HydrogenBond = 4] = "HydrogenBond", u[u.HalogenBond = 5] = "HalogenBond", u[u.Hydrophobic = 6] = "Hydrophobic", u[u.MetalCoordination = 7] = "MetalCoordination", u[u.WeakHydrogenBond = 8] = "WeakHydrogenBond";
  })(i = e.InteractionType || (e.InteractionType = {}));
  function o(u) {
    switch (u) {
      case i.HydrogenBond:
        return "Hydrogen Bond";
      case i.Hydrophobic:
        return "Hydrophobic Contact";
      case i.HalogenBond:
        return "Halogen Bond";
      case i.Ionic:
        return "Salt Bridge";
      case i.MetalCoordination:
        return "Metal Bond";
      case i.CationPi:
        return "Cation-Pi Interaction";
      case i.PiStacking:
        return "Pi Stacking";
      case i.WeakHydrogenBond:
        return "Weak Hydrogen Bond";
      case i.Unknown:
        return "Unknown Interaction";
    }
  }
  e.interactionTypeLabel = o;
  function c(u) {
    switch (u) {
      case 0:
        return "None";
      case 1:
        return "Positive Charge";
      case 2:
        return "Negative Charge";
      case 3:
        return "Aromatic Ring";
      case 4:
        return "Hydrogen Donor";
      case 5:
        return "Hydrogen Acceptor";
      case 6:
        return "Halogen Donor";
      case 7:
        return "Halogen Acceptor";
      case 8:
        return "HydrophobicAtom";
      case 9:
        return "Weak Hydrogen Donor";
      case 10:
        return "Ionic Type Partner";
      case 11:
        return "Dative Bond Partner";
      case 12:
        return "Transition Metal";
      case 13:
        return "Ionic Type Metal";
    }
  }
  e.featureTypeLabel = c;
  function s(u) {
    switch (u) {
      case 0:
        return "None";
      case 1:
        return "Quaternary Amine";
      case 2:
        return "Tertiary Amine";
      case 3:
        return "Sulfonium";
      case 4:
        return "Sulfonic Acid";
      case 5:
        return "Sulfate";
      case 6:
        return "Phosphate";
      case 7:
        return "Halocarbon";
      case 8:
        return "Guanidine";
      case 9:
        return "Acetamidine";
      case 10:
        return "Carboxylate";
    }
  }
  e.featureGroupLabel = s;
})(Mo);
Object.defineProperty(Wa, "__esModule", { value: !0 });
Wa.WeakHydrogenBondsProvider = Wa.HydrogenBondsProvider = Wa.HydrogenAcceptorProvider = Wa.WeakHydrogenDonorProvider = Wa.HydrogenDonorProvider = Wa.DefaultWeakHydrogenBondsParams = Wa.DefaultHydrogenBondsParams = void 0;
var Ig = Te, Gs = Le, kme = yo, XE = Ao, _o = Rr, Ume = Fp, Jm = kn, NH = Mo, zme = Gr, VH = {
  distanceMax: Gs.ParamDefinition.Numeric(2.8, { min: 1, max: 5, step: 0.1 }),
  backbone: Gs.ParamDefinition.Boolean(!0, {
    description: "Include backbone-to-backbone hydrogen bonds"
  }),
  accAngleDevMax: Gs.ParamDefinition.Numeric(90, { min: 0, max: 180, step: 1 }, { description: "Max deviation from ideal acceptor angle" }),
  donAngleDevMax: Gs.ParamDefinition.Numeric(120, { min: 0, max: 180, step: 1 }, { description: "Max deviation from ideal donor angle" }),
  accOutOfPlaneAngleMax: Gs.ParamDefinition.Numeric(90, { min: 0, max: 180, step: 1 }),
  donOutOfPlaneAngleMax: Gs.ParamDefinition.Numeric(45, { min: 0, max: 180, step: 1 })
}, RH = (0, Ig.__assign)((0, Ig.__assign)({}, VH), { water: Gs.ParamDefinition.Boolean(!1, {
  description: "Include water-to-water hydrogen bonds"
}), sulfurDistanceMax: Gs.ParamDefinition.Numeric(3.4, { min: 1, max: 5, step: 0.1 }) });
Wa.DefaultHydrogenBondsParams = Gs.ParamDefinition.getDefaultValues(RH);
var OH = (0, Ig.__assign)({}, VH);
Wa.DefaultWeakHydrogenBondsParams = Gs.ParamDefinition.getDefaultValues(OH);
function Gme(e, r) {
  var t = Ume.ValenceModelProvider.get(e).value;
  if (!t)
    throw Error("expected valence model to be available");
  var n = t.get(r.id);
  if (!n)
    throw Error("expected valence model for unit to be available");
  return n;
}
function qme(e, r, t) {
  for (var n = r.elements, a = r.model.atomicConformation, i = a.x, o = a.y, c = a.z, s = function(f, d) {
    var m = (0, _o.typeSymbol)(r, f), p = !1;
    m === "H" && ((0, _o.eachIntraBondedAtom)(r, f, function(v, h) {
      var y = (0, _o.typeSymbol)(v, h);
      (y === "N" || y === "O" || y === "S") && (p = !0);
    }), p && t.add(4, 0, i[n[f]], o[n[f]], c[n[f]], f));
  }, u = 0, l = n.length; u < l; ++u)
    s(u);
}
function Hme(e, r, t) {
  for (var n = r.elements, a = r.model.atomicConformation, i = a.x, o = a.y, c = a.z, s = function(f, d) {
    var m = (0, _o.typeSymbol)(r, f), p = !1;
    if (m === "H") {
      var v = [];
      if ((0, _o.eachIntraBondedAtom)(r, f, function(y, C) {
        var S = (0, _o.typeSymbol)(y, C);
        S === "C" && (jme(y, C) ? p = !0 : v.push(C));
      }), !p && v.length === 1) {
        var h = 0;
        (0, _o.eachIntraBondedAtom)(r, v[0], function(y, C) {
          var S = (0, _o.typeSymbol)(y, C);
          S === "F" && h++;
        }), h === 2 && (p = !0);
      }
      p && t.add(9, 0, i[n[f]], o[n[f]], c[n[f]], f);
    }
  }, u = 0, l = n.length; u < l; ++u)
    s(u);
}
function jme(e, r) {
  var t = e.rings.elementAromaticRingIndices, n = t.get(r);
  return n !== void 0;
}
function $me(e, r, t) {
  for (var n = Gme(e, r), a = n.charge, i = n.implicitH, o = n.idealGeometry, c = r.elements, s = r.model.atomicConformation, u = s.x, l = s.y, f = s.z, d = function(C) {
    t.add(5, 0, u[c[C]], l[c[C]], f[c[C]], C);
  }, m = 0, p = c.length; m < p; ++m) {
    var v = (0, _o.typeSymbol)(r, m);
    if (v === "O")
      d(m);
    else if (v === "N") {
      if (a[m] < 1) {
        var h = (0, _o.bondCount)(e, r, m) + i[m], y = o[m];
        (y === 4 && h < 4 || y === 3 && h < 3 || y === 2 && h < 2) && d(m);
      }
    } else v === "S" ? (0, _o.formalCharge)(r, m) === -1 && d(m) : v === "F" && d(m);
  }
}
function oB(e, r) {
  return e.model.atomicHierarchy.derived.residue.moleculeType[e.residueIndex[e.elements[r]]] === 2;
}
function uB(e, r) {
  return zme.ProteinBackboneAtoms.has((0, _o.atomId)(e, r));
}
function Kme(e, r, t, n) {
  return uB(e, r) && uB(t, n);
}
function Wme(e, r, t, n) {
  return oB(e, r) && oB(t, n);
}
function Xme(e, r) {
  return e === 5 && r === 4 || e === 4 && r === 5;
}
function Yme(e, r) {
  return e === 9 && r === 5 || e === 5 && r === 9;
}
function FH(e) {
  return {
    includeBackbone: e.backbone,
    maxAccAngleDev: (0, Jm.degToRad)(e.accAngleDevMax),
    maxDonAngleDev: (0, Jm.degToRad)(e.donAngleDevMax),
    maxAccOutOfPlaneAngle: (0, Jm.degToRad)(e.accOutOfPlaneAngleMax),
    maxDonOutOfPlaneAngle: (0, Jm.degToRad)(e.donOutOfPlaneAngleMax)
  };
}
function Qme(e) {
  return (0, Ig.__assign)((0, Ig.__assign)({}, FH(e)), { includeWater: e.water, maxSulfurDistSq: e.sulfurDistanceMax * e.sulfurDistanceMax, maxDistSq: e.distanceMax * e.distanceMax });
}
function LH(e, r, t, n) {
  var a = r.members[r.offsets[r.feature]], i = t.members[t.offsets[t.feature]];
  if (!(!n.includeBackbone && Kme(r.unit, a, t.unit, i))) {
    var o = (0, kme.calcAngles)(e, r.unit, a, t.unit, i);
    if ((0, Jm.radToDeg)(o[0]) >= 120 && (0, Jm.radToDeg)(o[0]) <= 180)
      return !0;
  }
}
function Zme(e, r, t, n, a) {
  var i = r.types[r.feature], o = t.types[t.feature];
  if (Xme(i, o)) {
    var c = o === 5 ? [r, t] : [t, r], s = c[0], u = c[1], l = s.members[s.offsets[s.feature]], f = u.members[u.offsets[u.feature]], d = (0, _o.typeSymbol)(s.unit, l) === "S" || (0, _o.typeSymbol)(u.unit, f) === "S" ? a.maxSulfurDistSq : a.maxDistSq;
    if (!(n > d) && !(!a.includeWater && Wme(s.unit, l, u.unit, f)) && LH(e, s, u, a))
      return NH.InteractionType.HydrogenBond;
  }
}
function Jme(e, r, t, n, a) {
  var i = r.types[r.feature], o = t.types[t.feature];
  if (Yme(i, o)) {
    var c = o === 5 ? [r, t] : [t, r], s = c[0], u = c[1];
    if (LH(e, s, u, a))
      return NH.InteractionType.WeakHydrogenBond;
  }
}
Wa.HydrogenDonorProvider = XE.Features.Provider([
  4
  /* HydrogenDonor */
], qme);
Wa.WeakHydrogenDonorProvider = XE.Features.Provider([
  9
  /* WeakHydrogenDonor */
], Hme);
Wa.HydrogenAcceptorProvider = XE.Features.Provider([
  5
  /* HydrogenAcceptor */
], $me);
Wa.HydrogenBondsProvider = {
  name: "hydrogen-bonds",
  params: RH,
  createTester: function(e) {
    var r = Math.max(e.distanceMax, e.sulfurDistanceMax), t = Qme(e);
    return {
      maxDistance: r,
      requiredFeatures: /* @__PURE__ */ new Set([
        4,
        5
        /* HydrogenAcceptor */
      ]),
      getType: function(n, a, i, o) {
        return Zme(n, a, i, o, t);
      }
    };
  }
};
Wa.WeakHydrogenBondsProvider = {
  name: "weak-hydrogen-bonds",
  params: OH,
  createTester: function(e) {
    var r = FH(e);
    return {
      maxDistance: e.distanceMax,
      requiredFeatures: /* @__PURE__ */ new Set([
        9,
        5
        /* HydrogenAcceptor */
      ]),
      getType: function(t, n, a, i) {
        return Jme(t, n, a, i, r);
      }
    };
  }
};
var Ju = {};
Object.defineProperty(Ju, "__esModule", { value: !0 });
Ju.HalogenBondsProvider = Ju.HalogenAcceptorProvider = Ju.HalogenDonorProvider = Ju.DefaultHalogenBondParams = void 0;
var WM = Le, sB = yo, kH = Ao, lb = Rr, YE = kn, eve = Mo, rve = Fp, UH = {
  distanceMax: WM.ParamDefinition.Numeric(3.5, { min: 1, max: 5, step: 0.1 }),
  // 薛定谔的参数中，donor和acceptor可以分别定义，donor为40（180 - 140），acceptor为60（180 - 120），目前这里取最大值60
  angleMax: WM.ParamDefinition.Numeric(60, { min: 0, max: 60, step: 1 })
};
Ju.DefaultHalogenBondParams = WM.ParamDefinition.getDefaultValues(UH);
var tve = [
  "CL",
  "BR",
  "I",
  "AT"
  /* AT */
];
function nve(e, r) {
  var t = rve.ValenceModelProvider.get(e).value;
  if (!t)
    throw Error("expected valence model to be available");
  var n = t.get(r.id);
  if (!n)
    throw Error("expected valence model for unit to be available");
  return n;
}
function ave(e, r, t) {
  for (var n = r.elements, a = r.model.atomicConformation, i = a.x, o = a.y, c = a.z, s = 0, u = n.length; s < u; ++s) {
    var l = (0, lb.typeSymbol)(r, s);
    tve.includes(l) && t.add(6, 0, i[n[s]], o[n[s]], c[n[s]], s);
  }
}
function ive(e, r, t) {
  for (var n = nve(e, r), a = n.charge, i = n.implicitH, o = n.idealGeometry, c = r.elements, s = r.model.atomicConformation, u = s.x, l = s.y, f = s.z, d = function(A) {
    t.add(7, 0, u[c[A]], l[c[A]], f[c[A]], A);
  }, m = 0, p = c.length; m < p; ++m) {
    var v = (0, lb.typeSymbol)(r, m);
    if (v === "O")
      d(m);
    else if (v === "N") {
      if (a[m] < 1) {
        var h = (0, lb.bondCount)(e, r, m) + i[m], y = o[m];
        (y === 4 && h < 4 || y === 3 && h < 3 || y === 2 && h < 2) && d(m);
      }
    } else v === "S" ? (0, lb.formalCharge)(r, m) === -1 && d(m) : v === "F" && d(m);
  }
  for (var C = 0, S = r.rings.aromaticRings; C < S.length; C++) {
    var b = S[C], g = r.rings.all[b];
    t.startState();
    for (var m = 0, p = g.length; m < p; ++m) {
      var _ = g[m];
      t.pushMember(u[c[_]], l[c[_]], f[c[_]], _);
    }
    t.finishState(
      7,
      0
      /* None */
    );
  }
}
function ove(e, r) {
  return e === 7 && r === 6 || e === 6 && r === 7;
}
var uve = (0, YE.degToRad)(180), sve = (0, YE.degToRad)(120);
function lve(e) {
  return {
    angleMax: (0, YE.degToRad)(e.angleMax)
  };
}
function cve(e, r, t, n) {
  var a = r.types[r.feature], i = t.types[t.feature];
  if (ove(a, i)) {
    var o = a === 6 ? [r, t] : [t, r], c = o[0], s = o[1], u = c.members[c.offsets[c.feature]], l = s.members[s.offsets[s.feature]], f = (0, sB.calcAngles)(e, c.unit, u, s.unit, l);
    if (f.length === 1 && !(uve - f[0] > n.angleMax)) {
      var d = (0, sB.calcAngles)(e, s.unit, l, c.unit, u);
      if (d.length !== 0 && !d.some(function(m) {
        return sve - m > n.angleMax;
      }))
        return eve.InteractionType.HalogenBond;
    }
  }
}
Ju.HalogenDonorProvider = kH.Features.Provider([
  6
  /* HalogenDonor */
], ave);
Ju.HalogenAcceptorProvider = kH.Features.Provider([
  7
  /* HalogenAcceptor */
], ive);
Ju.HalogenBondsProvider = {
  name: "halogen-bonds",
  params: UH,
  createTester: function(e) {
    var r = lve(e);
    return {
      maxDistance: e.distanceMax,
      requiredFeatures: /* @__PURE__ */ new Set([
        6,
        7
        /* HalogenAcceptor */
      ]),
      getType: function(t, n, a) {
        return cve(t, n, a, r);
      }
    };
  }
};
var qn = {};
Object.defineProperty(qn, "__esModule", { value: !0 });
qn.CationPiProvider = qn.PiStackingProvider = qn.IonicProvider = qn.AromaticRingProvider = qn.PositiveChargeProvider = qn.NegativChargeProvider = qn.DefaultCationPiParams = qn.DefaultPiStackingParams = qn.DefaultIonicParams = void 0;
var nc = Le, v0 = Ao, dve = Fp, Bg = kn, Zb = Mo, zH = Qe(), Va = Re, ki = Rr, GH = {
  distanceMax: nc.ParamDefinition.Numeric(5, { min: 0, max: 8, step: 0.1 })
};
qn.DefaultIonicParams = nc.ParamDefinition.getDefaultValues(GH);
var qH = {
  // 薛定谔中face to face是4.4，edge to face是5.5，目前未精确区分，取最大值
  distanceMax: nc.ParamDefinition.Numeric(5.5, { min: 1, max: 8, step: 0.1 }),
  offsetMax: nc.ParamDefinition.Numeric(2, { min: 0, max: 4, step: 0.1 }),
  angleDevMax: nc.ParamDefinition.Numeric(30, { min: 0, max: 180, step: 1 })
};
qn.DefaultPiStackingParams = nc.ParamDefinition.getDefaultValues(qH);
var HH = {
  distanceMax: nc.ParamDefinition.Numeric(6.6, { min: 1, max: 8, step: 0.1 }),
  offsetMax: nc.ParamDefinition.Numeric(2, { min: 0, max: 4, step: 0.1 })
};
qn.DefaultCationPiParams = nc.ParamDefinition.getDefaultValues(HH);
function jH(e, r) {
  var t = dve.ValenceModelProvider.get(e).value;
  if (!t)
    throw Error("expected valence model to be available");
  var n = t.get(r.id);
  if (!n)
    throw Error("expected valence model for unit to be available");
  return n;
}
function fve(e, r, t) {
  for (var n = jH(e, r).charge, a = r.elements, i = r.model.atomicConformation, o = i.x, c = i.y, s = i.z, u = zH.Segmentation.transientSegments(r.model.atomicHierarchy.residueAtomSegments, a); u.hasNext; )
    for (var l = u.move(), f = l.start, d = l.end, m = function(v) {
      if (n[v] > 0)
        t.add(1, 0, o[a[v]], c[a[v]], s[a[v]], v);
      else if ((0, ki.typeSymbol)(r, v) === "N") {
        var h = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Map();
        if ((0, ki.eachIntraBondedAtom)(r, v, function(S, b) {
          (0, ki.typeSymbol)(r, b) === "C" && h.add(b);
        }), h.size)
          h.forEach(function(S) {
            var b = /* @__PURE__ */ new Set();
            (0, ki.eachIntraBondedAtom)(r, S, function(g, _) {
              (0, ki.typeSymbol)(r, _) === "N" ? b.add(_) : h.delete(S);
            }), b.size !== 3 ? h.delete(S) : y.set(S, b);
          });
        else
          return "continue";
        var C = !1;
        if (h.size)
          h.forEach(function(S) {
            var b = r.bonds, g = y.get(S), _ = 0;
            if (g) {
              for (var A = function(T, x) {
                var w = b.a[T], E = b.b[T];
                if (w === S && g.has(E) && b.edgeProps.order[T] === 2) {
                  E === v && (C = !0);
                  var I = !0;
                  (0, ki.eachIntraBondedAtom)(r, E, function(B, D) {
                    D !== S && (0, ki.typeSymbol)(r, D) !== "H" && (I = !1);
                  }), I && g.delete(E), _++;
                }
              }, M = 0, P = b.a.length; M < P; M++)
                A(M);
              _ !== 1 ? h.delete(S) : g.forEach(function(T) {
                var x = !0;
                (0, ki.eachIntraBondedAtom)(r, T, function(w, E) {
                  E !== S && (0, ki.typeSymbol)(r, E) !== "H" && (x = !1);
                }), x && g.delete(T);
              }), g.size > 1 && h.delete(S);
            }
          });
        else
          return "continue";
        h.size && C && t.add(1, 0, o[a[v]], c[a[v]], s[a[v]], v);
      }
    }, p = f; p < d; ++p)
      m(p);
}
function mve(e, r, t) {
  for (var n = jH(e, r).charge, a = r.elements, i = r.model.atomicConformation, o = i.x, c = i.y, s = i.z, u = zH.Segmentation.transientSegments(r.model.atomicHierarchy.residueAtomSegments, a); u.hasNext; )
    for (var l = u.move(), f = l.start, d = l.end, m = function(v) {
      if (n[v] < 0)
        t.add(2, 0, o[a[v]], c[a[v]], s[a[v]], v);
      else if ((0, ki.typeSymbol)(r, v) === "O") {
        var h = -1, y = 0;
        if ((0, ki.eachIntraBondedAtom)(r, v, function(T, x) {
          (0, ki.typeSymbol)(r, x) === "C" && (h = x, y++);
        }), y === 1 && h !== -1) {
          var C = /* @__PURE__ */ new Set(), S = 0;
          if ((0, ki.eachIntraBondedAtom)(r, h, function(T, x) {
            (0, ki.typeSymbol)(r, x) === "O" && C.add(x);
          }), C.size === 2) {
            for (var b = r.bonds, g = !0, _ = 0, A = b.a.length; _ < A; _++) {
              var M = b.a[_], P = b.b[_];
              C.has(P) && M !== h && (0, ki.typeSymbol)(r, M) !== "H" && (S = -100), b.edgeProps.order[_] === 2 && P === v && (g = !1), M === h && C.has(P) && b.edgeProps.order[_] === 2 && S++;
            }
            S === 1 && g && t.add(2, 0, o[a[v]], c[a[v]], s[a[v]], v);
          }
        }
      }
    }, p = f; p < d; ++p)
      m(p);
}
function vve(e, r, t) {
  for (var n = r.elements, a = r.model.atomicConformation, i = a.x, o = a.y, c = a.z, s = 0, u = r.rings.aromaticRings; s < u.length; s++) {
    var l = u[s], f = r.rings.all[l];
    t.startState();
    for (var d = 0, m = f.length; d < m; ++d) {
      var p = f[d];
      t.pushMember(i[n[p]], o[n[p]], c[n[p]], p);
    }
    t.finishState(
      3,
      0
      /* None */
    );
  }
}
function pve(e, r) {
  return e === 2 && r === 1 || e === 1 && r === 2;
}
function hve(e, r) {
  return e === 3 && r === 3;
}
function gve(e, r) {
  return e === 3 && r === 1 || e === 1 && r === 3;
}
var lB = (0, Va.Vec3)(), cB = (0, Va.Vec3)();
function yve(e, r, t) {
  for (var n = e.feature, a = e.offsets, i = e.members, o = r.feature, c = r.offsets, s = r.members, u = a[n], l = a[n + 1]; u < l; ++u) {
    var f = i[u];
    e.unit.conformation.position(e.unit.elements[f], lB);
    for (var d = c[o], m = c[o + 1]; d < m; ++d) {
      var p = s[d];
      if (r.unit.conformation.position(r.unit.elements[p], cB), Va.Vec3.squaredDistance(lB, cB) < t)
        return !0;
    }
  }
  return !1;
}
var zv = (0, Va.Vec3)(), ld = (0, Va.Vec3)(), n0 = (0, Va.Vec3)(), N2 = (0, Va.Vec3)();
function XM(e, r) {
  var t = r.unit, n = r.feature, a = r.offsets, i = r.members, o = t.elements, c = a[n];
  return r.unit.conformation.position(o[i[c]], zv), r.unit.conformation.position(o[i[c + 1]], ld), r.unit.conformation.position(o[i[c + 2]], n0), Va.Vec3.triangleNormal(e, zv, ld, n0);
}
var _ve = function(e, r, t) {
  return v0.Features.position(zv, e), v0.Features.position(ld, r), Va.Vec3.sub(n0, zv, ld), Va.Vec3.projectOnPlane(N2, n0, t), Va.Vec3.add(N2, N2, ld), Va.Vec3.distance(N2, ld);
};
function bve(e) {
  return {
    distanceMaxSq: e.distanceMax * e.distanceMax
  };
}
function Sve(e) {
  return {
    offsetMax: e.offsetMax,
    angleDevMax: (0, Bg.degToRad)(e.angleDevMax)
  };
}
function Cve(e) {
  return {
    offsetMax: e.offsetMax
  };
}
var lT = (0, Bg.degToRad)(180), V2 = (0, Bg.degToRad)(90), Q1 = (0, Va.Vec3)(), cT = (0, Va.Vec3)();
function Ave(e, r, t, n, a) {
  var i = r.types[r.feature], o = t.types[t.feature];
  if (pve(i, o) && yve(r, t, a.distanceMaxSq))
    return Zb.InteractionType.Ionic;
}
function xve(e, r, t, n, a) {
  var i = r.types[r.feature], o = t.types[t.feature];
  if (hve(i, o)) {
    XM(Q1, r), XM(cT, t);
    var c = Va.Vec3.angle(Q1, cT);
    v0.Features.position(zv, r), v0.Features.position(ld, t), Va.Vec3.sub(n0, zv, ld);
    var s = Va.Vec3.angle(Q1, n0), u = Va.Vec3.angle(cT, n0), l = (0, Bg.radToDeg)(s > V2 ? lT - s : s), f = (0, Bg.radToDeg)(u > V2 ? lT - u : u), d = c <= a.angleDevMax || c >= lT - a.angleDevMax ? "parallel" : c <= a.angleDevMax + V2 && c >= V2 - a.angleDevMax ? "t-shaped" : void 0, m = d === "parallel" ? [0, 33] : [0, 30];
    if (d && (l >= m[0] && l <= m[1] || f >= m[0] && f <= m[1]))
      return Zb.InteractionType.PiStacking;
  }
}
function Tve(e, r, t, n, a) {
  var i = r.types[r.feature], o = t.types[t.feature];
  if (gve(i, o)) {
    var c = i === 3 ? [r, t] : [t, r], s = c[0], u = c[1];
    XM(Q1, s);
    var l = _ve(u, s, Q1);
    if (l <= a.offsetMax)
      return Zb.InteractionType.CationPi;
  }
}
qn.NegativChargeProvider = v0.Features.Provider([
  2
  /* NegativeCharge */
], mve);
qn.PositiveChargeProvider = v0.Features.Provider([
  1
  /* PositiveCharge */
], fve);
qn.AromaticRingProvider = v0.Features.Provider([
  3
  /* AromaticRing */
], vve);
qn.IonicProvider = {
  name: "ionic",
  params: GH,
  createTester: function(e) {
    var r = bve(e);
    return {
      maxDistance: e.distanceMax,
      requiredFeatures: /* @__PURE__ */ new Set([
        2,
        1
        /* PositiveCharge */
      ]),
      getType: function(t, n, a, i) {
        return Ave(t, n, a, i, r);
      }
    };
  }
};
qn.PiStackingProvider = {
  name: "pi-stacking",
  params: qH,
  createTester: function(e) {
    var r = Sve(e);
    return {
      maxDistance: e.distanceMax,
      requiredFeatures: /* @__PURE__ */ new Set([
        3
        /* AromaticRing */
      ]),
      getType: function(t, n, a, i) {
        return xve(t, n, a, i, r);
      }
    };
  }
};
qn.CationPiProvider = {
  name: "cation-pi",
  params: HH,
  createTester: function(e) {
    var r = Cve(e);
    return {
      maxDistance: e.distanceMax,
      requiredFeatures: /* @__PURE__ */ new Set([
        3,
        1
        /* PositiveCharge */
      ]),
      getType: function(t, n, a, i) {
        return Tve(t, n, a, i, r);
      }
    };
  }
};
var QE = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.MetalCoordinationProvider = e.MetalBindingProvider = e.MetalProvider = e.DefaultMetalCoordinationParams = e.MetalCoordinationParams = void 0;
  var r = Le, t = Ao, n = Rr, a = j4, i = Mo, o = Gr, c = _s, s = Re;
  e.MetalCoordinationParams = {
    distanceMax: r.ParamDefinition.Numeric(3, { min: 1, max: 5, step: 0.1 })
  }, e.DefaultMetalCoordinationParams = r.ParamDefinition.getDefaultValues(e.MetalCoordinationParams);
  var u = {
    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
    /* Au */
  }, l = [
    "LI",
    "NA",
    "K",
    "RB",
    "CS",
    "MG",
    "CA",
    "SR",
    "BA",
    "AL",
    "GA",
    "IN",
    "TL",
    "SC",
    "SN",
    "PB",
    "BI",
    "SB",
    "HG"
    /* HG */
  ];
  function f(C, S, b) {
    for (var g = S.elements, _ = S.model.atomicConformation, A = _.x, M = _.y, P = _.z, T = 0, x = g.length; T < x; ++T) {
      var w = (0, n.typeSymbol)(S, T), E = 0;
      l.includes(w) ? E = 13 : ((0, a.isTransitionMetal)(w) || w === "ZN" || w === "CD") && (E = 12), E && b.add(E, 0, A[g[T]], M[g[T]], P[g[T]], T);
    }
  }
  function d(C) {
    return !o.ProteinBackboneAtoms.has(C);
  }
  function m(C) {
    return o.ProteinBackboneAtoms.has(C);
  }
  function p(C) {
    return o.NucleicBackboneAtoms.has(C);
  }
  function v(C, S, b) {
    for (var g = S.elements, _ = S.model.atomicConformation, A = _.x, M = _.y, P = _.z, T = 0, x = g.length; T < x; ++T) {
      var w = (0, n.typeSymbol)(S, T), E = (0, n.compId)(S, T), I = (0, n.atomId)(S, T), B = !1, D = !1, N = o.AminoAcidNames.has(E), O = o.BaseNames.has(E);
      !N && !O ? (0, a.isHalogen)(w) || w === "O" || w === "S" ? (B = !0, D = !0) : w === "N" && (B = !0) : N ? w === "O" ? (["ASP", "GLU", "SER", "THR", "TYR", "ASN", "GLN"].includes(E) && d(I) || m(I)) && (B = !0, D = !0) : w === "S" && (E === "CYS" || E === "MET") ? (B = !0, D = !0) : w === "N" && E === "HIS" && d(I) && (B = !0) : O && (w === "O" && p(I) ? (B = !0, D = !0) : ["N3", "N4", "N7"].includes(I) ? B = !0 : ["O2", "O4", "O6"].includes(I) && (B = !0, D = !0)), B && b.add(11, 0, A[g[T]], M[g[T]], P[g[T]], T), D && b.add(10, 0, A[g[T]], M[g[T]], P[g[T]], T);
    }
  }
  function h(C, S) {
    if (C === 12)
      return S === 11 || S === 12;
    if (C === 13)
      return S === 10;
  }
  function y(C, S, b, g) {
    var _ = S.types[S.feature], A = b.types[b.feature];
    if (!(!h(_, A) && !h(A, _))) {
      var M = c.AtomicNumbers[(0, n.typeSymbol)(S.unit, S.members[S.offsets[S.feature]])], P = c.AtomicNumbers[(0, n.typeSymbol)(b.unit, b.members[b.offsets[b.feature]])];
      if (M && P && u[M] && u[P]) {
        var T = u[M] + u[P] + 0.5, x = s.Vec3.create(0, 0, 0), w = s.Vec3.create(0, 0, 0);
        t.Features.position(x, S), t.Features.position(w, b);
        var E = s.Vec3.distance(x, w);
        if (E > T)
          return;
      }
      return i.InteractionType.MetalCoordination;
    }
  }
  e.MetalProvider = t.Features.Provider([
    13,
    12
    /* TransitionMetal */
  ], f), e.MetalBindingProvider = t.Features.Provider([
    10,
    11
    /* DativeBondPartner */
  ], v), e.MetalCoordinationProvider = {
    name: "metal-coordination",
    params: e.MetalCoordinationParams,
    createTester: function(C) {
      return {
        maxDistance: C.distanceMax,
        requiredFeatures: /* @__PURE__ */ new Set([
          13,
          12,
          10,
          11
          /* DativeBondPartner */
        ]),
        getType: function(S, b, g, _) {
          return y(S, b, g);
        }
      };
    }
  };
})(QE);
(function(e) {
  var r, t, n;
  Object.defineProperty(e, "__esModule", { value: !0 }), e.VisualizationMode = e.HydrogenVariant = e.HighlightLabelType = e.ExpandFilterToHierarchyTypes = e.ExpandFilter = e.getDefaultInteractionParams = e.InteractionOptions = e.LociGranularityToGranularity = e.GranularityToLociGranularity = e.Granularity = e.OtherReprType = e.MeasurementType = e.AtomWithBondReprType = e.AtomReprType = e.MolecularReprType = e.Intersection = e.ReprCBasedTheme = e.ThemeC = e.RepresentationType = e.HierarchyType = e.Format = void 0;
  var a = Wa, i = Ju, o = qn, c = QE;
  (function(v) {
    v.Pdb = "pdb", v.Sdf = "sdf", v.Mol = "mol", v.Mol2 = "mol2", v.MMCif = "mmcif", v.Gro = "gro", v.Xtc = "xtc", v.Dump = "dump", v.Xyz = "xyz", v.Cif = "cif", v.MCif = "mcif", v.POSCAR = "poscar", v.Material = "material", v.Pymatgen = "pymatgen";
  })(e.Format || (e.Format = {}));
  var s;
  (function(v) {
    v.Molecular = "Molecular", v.Protein = "Protein", v.Chain = "Chain", v.Residue = "Residue", v.Ligand = "Ligand", v.Solvent = "Solvent", v.Water = "Water", v.Other = "Other", v.Metal = "Metal", v.Ions = "Ions", v.Atom = "Atom";
  })(s = e.HierarchyType || (e.HierarchyType = {}));
  var u;
  (function(v) {
    v.Ribbon = "Ribbon", v.BallAndStick = "BallAndStick", v.Line = "Line", v.Stick = "Stick", v.CPK = "CPK", v.Label = "Label", v.Distance = "Distance", v.Angle = "Angle", v.Dihedral = "Dihedral", v.IntraInteractions = "IntraInteractions", v.BetweenInteractions = "BetweenInteractions", v.Pharmacophore = "Pharmacophore", v.Pocket = "Pocket", v.Surface = "Surface", v.IsoSurface = "IsoSurface", v.RotateArrow = "RotateArrow", v.MappingLine = "MappingLine", v.UnitCell = "UnitCell", v.CustomLines = "CustomLines", v.CustomPlanes = "CustomPlanes", v.Trajectory = "Trajectory";
  })(u = e.RepresentationType || (e.RepresentationType = {}));
  var l;
  (function(v) {
    v.RIBBON = "Ribbon", v.ATOM = "Atom", v.SURFACE = "Surface";
  })(l = e.ThemeC || (e.ThemeC = {})), e.ReprCBasedTheme = (r = {}, r[l.RIBBON] = [u.Ribbon], r[l.ATOM] = [
    u.CPK,
    u.Line,
    u.Stick,
    u.BallAndStick
  ], r[l.SURFACE] = [u.Surface], r), function(v) {
    v[v.Not = 0] = "Not", v[v.Include = 1] = "Include", v[v.BeIncluded = 2] = "BeIncluded", v[v.Cross = 3] = "Cross";
  }(e.Intersection || (e.Intersection = {})), e.MolecularReprType = /* @__PURE__ */ new Set([
    u.Ribbon,
    u.CPK,
    u.Line,
    u.Stick,
    u.BallAndStick,
    u.Surface
  ]), e.AtomReprType = /* @__PURE__ */ new Set([
    u.BallAndStick,
    u.Line,
    u.Stick,
    u.CPK
  ]), e.AtomWithBondReprType = /* @__PURE__ */ new Set([
    u.BallAndStick,
    u.Line,
    u.Stick
  ]), e.MeasurementType = /* @__PURE__ */ new Set([
    u.Label,
    u.Distance,
    u.Angle,
    u.Dihedral
  ]), e.OtherReprType = /* @__PURE__ */ new Set([u.Surface, u.Pharmacophore, u.Pocket]);
  var f;
  (function(v) {
    v.Atom = "Atom", v.Residue = "Residue", v.Chain = "Chain", v.Molecular = "Molecular";
  })(f = e.Granularity || (e.Granularity = {})), e.GranularityToLociGranularity = (t = {}, t[f.Atom] = "element", t[f.Residue] = "residue", t[f.Chain] = "chain", t[f.Molecular] = "entity", t), e.LociGranularityToGranularity = {
    element: f.Atom,
    residue: f.Residue,
    chain: f.Chain,
    entity: f.Molecular
  };
  var d;
  (function(v) {
    v.HydrogenBonds = "hydrogen-bonds", v.WeakHydrogenBonds = "weak-hydrogen-bonds", v.HalogenBonds = "halogen-bonds", v.SaltBridge = "ionic", v.PiPiStacking = "pi-stacking", v.PiCations = "cation-pi", v.MetalBonds = "metal-coordination", v.Hydrophobic = "hydrophobic";
  })(d = e.InteractionOptions || (e.InteractionOptions = {}));
  var m = function(v) {
    var h, y = (h = {}, h[d.HydrogenBonds] = {
      name: "on",
      params: a.DefaultHydrogenBondsParams
    }, h[d.WeakHydrogenBonds] = {
      name: "off",
      params: a.DefaultWeakHydrogenBondsParams
    }, h[d.HalogenBonds] = {
      name: "on",
      params: i.DefaultHalogenBondParams
    }, h[d.SaltBridge] = {
      name: "on",
      params: o.DefaultIonicParams
    }, h[d.PiPiStacking] = {
      name: "on",
      params: o.DefaultPiStackingParams
    }, h[d.PiCations] = {
      name: "on",
      params: o.DefaultCationPiParams
    }, h[d.MetalBonds] = {
      name: "on",
      params: c.DefaultMetalCoordinationParams
    }, h[d.Hydrophobic] = {
      name: "off",
      params: {}
    }, h);
    return v && Object.keys(y).forEach(function(C) {
      y[C].name = v.includes(C) ? "on" : "off";
    }), y;
  };
  e.getDefaultInteractionParams = m;
  var p;
  (function(v) {
    v[v.All = 0] = "All", v[v.Residues = 1] = "Residues", v[v.Water = 2] = "Water", v[v.SolventWithoutWater = 3] = "SolventWithoutWater", v[v.Solvent = 4] = "Solvent";
  })(p = e.ExpandFilter || (e.ExpandFilter = {})), e.ExpandFilterToHierarchyTypes = (n = {}, n[p.All] = [
    s.Protein,
    s.Water,
    s.Ligand,
    s.Solvent
  ], n[p.Residues] = [s.Protein], n[p.Water] = [s.Water], n[p.SolventWithoutWater] = [s.Solvent], n[p.Solvent] = [s.Water, s.Solvent], n), function(v) {
    v.Structure = "Structure", v.Measurement = "Measurement", v.Interaction = "Interaction", v.Bond = "Bond";
  }(e.HighlightLabelType || (e.HighlightLabelType = {})), function(v) {
    v[v.NotHydrogen = -1] = "NotHydrogen", v[v.NonPolar = 0] = "NonPolar", v[v.Polar = 1] = "Polar", v[v.ConnectPolar = 2] = "ConnectPolar", v[v.ConnectNonPolar = 3] = "ConnectNonPolar";
  }(e.HydrogenVariant || (e.HydrogenVariant = {})), function(v) {
    v.Drug = "drug", v.Material = "material";
  }(e.VisualizationMode || (e.VisualizationMode = {}));
})(Jt);
var dT = {}, Lp = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.getInteractionLociInfo = e.getElementLociInfo = e.getElementIdsByLoci = e.getLoci = e.transformLociToElementLoci = void 0;
  var r = Te, t = gn(), n = ia(), a = Qe(), i = eu(), o = Jt, c = Mo, s = function(m) {
    if (m.kind === "element-loci")
      return m;
    if (m.kind === "structure-loci")
      return t.Structure.toStructureElementLoci(m.structure);
    if (m.kind === "shape-loci") {
      var p = m.shape.sourceData, v = [];
      p.infos ? v.push.apply(v, (0, r.__spreadArray)([], p.infos, !0).map(function(y) {
        return y.loci;
      })) : p.pairs ? v.push.apply(v, p.pairs[0].loci) : p.triples ? v.push.apply(v, p.triples[0].loci) : p.quads && v.push.apply(v, p.quads[0].loci);
      var h;
      return v.forEach(function(y) {
        h ? h = i.Loci.union(h, (0, e.transformLociToElementLoci)(y)) : h = (0, e.transformLociToElementLoci)(y);
      }), h;
    }
  };
  e.transformLociToElementLoci = s;
  var u = function(m, p) {
    var v = [], h = new Set(p), y = /* @__PURE__ */ new Set();
    return m.units.forEach(function(C) {
      if (!y.has(C.invariantId)) {
        y.add(C.invariantId);
        var S = [];
        C.elements.forEach(function(b, g) {
          (!p || h.has(b)) && S.push(g);
        }), S.length > 0 && v.push({
          unit: C,
          indices: S
        });
      }
    }), n.StructureElement.Loci(m, v);
  };
  e.getLoci = u;
  var l = function(m) {
    var p = [];
    return m.elements.forEach(function(v) {
      p.push.apply(p, a.OrderedSet.toArray(v.indices).map(function(h) {
        return v.unit.elements[h];
      }).filter(function(h) {
        return h !== void 0;
      }));
    }), p;
  };
  e.getElementIdsByLoci = l;
  var f = function(m, p) {
    var v = n.StructureElement.Stats.ofLoci(m), h;
    v.elementCount > 0 ? h = v.firstElementLoc : v.residueCount > 0 ? h = v.firstResidueLoc : v.chainCount > 0 ? h = v.firstChainLoc : v.unitCount > 0 ? h = v.firstUnitLoc : v.conformationCount > 0 ? h = v.firstConformationLoc : h = v.firstStructureLoc;
    var y = n.StructureProperties.atom.em_confidence(h), C = n.StructureProperties.atom.B_iso_or_equiv(h);
    switch (p) {
      case o.Granularity.Atom:
        return v.elementCount === 1 ? {
          x: n.StructureProperties.atom.x(h),
          y: n.StructureProperties.atom.y(h),
          z: n.StructureProperties.atom.z(h),
          granularity: o.Granularity.Atom,
          atomName: n.StructureProperties.atom.label_atom_id(h),
          atomId: n.StructureProperties.atom.id(h),
          altId: n.StructureProperties.atom.label_alt_id(h),
          residueName: n.StructureProperties.atom.label_comp_id(h),
          residueId: n.StructureProperties.residue.auth_seq_id(h),
          insertCode: n.StructureProperties.residue.pdbx_PDB_ins_code(h),
          chainId: n.StructureProperties.chain.label_asym_id(h),
          emConfidence: y,
          bfactor: C
        } : {
          granularity: o.Granularity.Residue,
          altId: n.StructureProperties.atom.label_alt_id(h),
          residueName: n.StructureProperties.atom.label_comp_id(h),
          residueId: n.StructureProperties.residue.auth_seq_id(h),
          chainId: n.StructureProperties.chain.label_asym_id(h),
          insertCode: n.StructureProperties.residue.pdbx_PDB_ins_code(h),
          emConfidence: y,
          bfactor: C
        };
      case o.Granularity.Residue:
        return {
          granularity: o.Granularity.Residue,
          altId: n.StructureProperties.atom.label_alt_id(h),
          residueName: n.StructureProperties.atom.label_comp_id(h),
          residueId: n.StructureProperties.residue.auth_seq_id(h),
          chainId: n.StructureProperties.chain.label_asym_id(h),
          insertCode: n.StructureProperties.residue.pdbx_PDB_ins_code(h),
          bfactor: C
        };
      case o.Granularity.Chain:
        return {
          granularity: o.Granularity.Chain,
          chainId: n.StructureProperties.chain.label_asym_id(h)
        };
      case o.Granularity.Molecular:
        return {
          granularity: o.Granularity.Molecular
        };
      default:
        return {};
    }
  };
  e.getElementLociInfo = f;
  var d = function(m) {
    var p = m.elements[0], v = p.unitA, h = p.indexA, y = p.unitB, C = p.indexB, S = m.data.interactions, b = S.contacts, g = S.unitsContacts, _ = S.unitsFeatures, A = _.get(v.id), M = A.members, P = A.offsets, T = _.get(y.id), x = T.members, w = T.offsets, E = -1;
    if (v === y) {
      var I = g.get(v.id), B = I.getDirectedEdgeIndex(h, C);
      E = I.edgeProps.type[B];
    } else {
      var B = b.getEdgeIndex(h, v.id, C, y.id);
      E = b.edges[B].props.type;
    }
    var D = n.Bond.Location(m.data.structure, v, M[P[h]], m.data.structure, y, x[w[C]]), N = n.StructureElement.Loci(D.aStructure, [
      { unit: D.aUnit, indices: a.OrderedSet.ofSingleton(D.aIndex) }
    ]), O = n.StructureElement.Loci(D.bStructure, [
      { unit: D.bUnit, indices: a.OrderedSet.ofSingleton(D.bIndex) }
    ]), V = n.StructureElement.Stats.ofLoci(N), k = n.StructureElement.Stats.ofLoci(O), G = V.firstElementLoc, L = k.firstElementLoc, R = {
      chainId: n.StructureProperties.chain.label_asym_id(G),
      residueName: n.StructureProperties.atom.label_comp_id(G),
      residueId: n.StructureProperties.residue.auth_seq_id(G),
      atomName: n.StructureProperties.atom.label_atom_id(G)
    }, F = {
      chainId: n.StructureProperties.chain.label_asym_id(L),
      residueName: n.StructureProperties.atom.label_comp_id(L),
      residueId: n.StructureProperties.residue.auth_seq_id(L),
      atomName: n.StructureProperties.atom.label_atom_id(L)
    };
    return {
      infoA: R,
      infoB: F,
      interactionType: (0, c.interactionTypeLabel)(E)
    };
  };
  e.getInteractionLociInfo = d;
})(Lp);
var ZE = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.checkLineValidate = e.flattenDeep = e.canvasToBlob = e.readAsBlob = e.readAsString = e.readFileAsText = e.fetchUrlAsBlob = e.fetchUrlAsText = void 0;
  var r = Te, t = function(d) {
    return fetch(d).then(function(m) {
      return m.text();
    });
  };
  e.fetchUrlAsText = t;
  var n = function(d) {
    return fetch(d).then(function(m) {
      return m.blob();
    });
  };
  e.fetchUrlAsBlob = n;
  var a = function(d) {
    return new Promise(function(m) {
      var p = new FileReader();
      p.onload = function(v) {
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          return (0, r.__generator)(this, function(h) {
            return m(p.result), [
              2
              /*return*/
            ];
          });
        });
      }, p.readAsText(d);
    });
  };
  e.readFileAsText = a;
  var i = function(d) {
    return (0, r.__awaiter)(void 0, void 0, void 0, function() {
      var m, p;
      return (0, r.__generator)(this, function(v) {
        switch (v.label) {
          case 0:
            return typeof d != "string" ? [3, 4] : d.startsWith("http") || d.startsWith("https") ? [4, (0, e.fetchUrlAsText)(d)] : [3, 2];
          case 1:
            return p = v.sent(), [3, 3];
          case 2:
            p = d, v.label = 3;
          case 3:
            return m = p, [3, 6];
          case 4:
            return [4, (0, e.readFileAsText)(d)];
          case 5:
            m = v.sent(), v.label = 6;
          case 6:
            return [2, m];
        }
      });
    });
  };
  e.readAsString = i;
  var o = function(d) {
    return (0, r.__awaiter)(void 0, void 0, void 0, function() {
      var m, p;
      return (0, r.__generator)(this, function(v) {
        switch (v.label) {
          case 0:
            return typeof d != "string" ? [3, 2] : [4, (0, e.fetchUrlAsBlob)(d)];
          case 1:
            return m = v.sent(), [3, 4];
          case 2:
            return p = Blob.bind, [4, d.arrayBuffer()];
          case 3:
            m = new (p.apply(Blob, [void 0, [v.sent()]]))(), v.label = 4;
          case 4:
            return [2, m];
        }
      });
    });
  };
  e.readAsBlob = o;
  function c(d, m, p) {
    return (0, r.__awaiter)(this, void 0, void 0, function() {
      return (0, r.__generator)(this, function(v) {
        return [2, new Promise(function(h, y) {
          var C = function(x) {
            x ? h(x) : y("no blob returned");
          };
          if (HTMLCanvasElement.prototype.toBlob)
            d.toBlob(C, m, p);
          else {
            for (var S = atob(d.toDataURL(m, p).split(",")[1]), b = S.length, g = b >> 2, _ = new Uint8Array(b), A = new Uint32Array(_.buffer, 0, g), M = 0, P = 0; P < g; ++P)
              A[P] = S.charCodeAt(M++) | S.charCodeAt(M++) << 8 | S.charCodeAt(M++) << 16 | S.charCodeAt(M++) << 24;
            for (var T = b & 3; T--; )
              _[M] = S.charCodeAt(M++);
            C(new Blob([_], { type: m || "image/png" }));
          }
        })];
      });
    });
  }
  e.canvasToBlob = c;
  var s = 1 / 0;
  function u(d, m, p, v, h) {
    var y = -1, C = d.length;
    for (p || (p = Array.isArray), h || (h = []); ++y < C; ) {
      var S = d[y];
      p(S) ? u(S, m - 1, p, v, h) : h[h.length] = S;
    }
    return h;
  }
  function l(d) {
    var m = d == null ? 0 : d.length;
    return m ? u(d, s) : [];
  }
  e.flattenDeep = l;
  var f = function(d, m) {
    for (var p = [], v = 0, h = m.length; v < h; v++) {
      var y = m[v], C = y.start, S = y.end, b = y.regular;
      b.test(d.slice(C, S)) || p.push({
        start: C,
        end: S
      });
    }
    return p;
  };
  e.checkLineValidate = f;
})(ZE);
var fT = {}, kp = {};
Object.defineProperty(kp, "__esModule", { value: !0 });
kp.getStandardTypeSymbol = void 0;
var Pve = function(e) {
  return e.length > 2 || e.length === 0 ? e : "".concat(e[0].toLocaleUpperCase()).concat(e.length === 2 ? e[1].toLocaleLowerCase() : "");
};
kp.getStandardTypeSymbol = Pve;
var mT = {}, xy = {}, Up = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ReprLabelToType = e.molCountLineFormat = e.molBondFormatCheck = e.molAtomLineFormat = e.pdbConectLineFormat = e.pdbAnisouLineFormat = e.pdbAtomLineFormat = e.AcidClassName = e.AcidOverall = e.AcidSpecial = e.AcidNegativelyCharged = e.AcidPositivelyCharged = e.AcidPolarUncharged = e.AcidHydrophobic = e.AcidWithProtonation = e.Acid = e.ResidueAbbrMap = e.residueSubstitutions = void 0;
  var r = Jt;
  e.residueSubstitutions = {
    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"
  }, e.ResidueAbbrMap = {
    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"
  }, e.Acid = /* @__PURE__ */ new Map([
    [
      "Hydrophobic",
      [
        ["Y", "TYR"],
        ["A", "ALA"],
        ["V", "VAL"],
        ["L", "LEU"],
        ["I", "ILE"],
        ["F", "PHE"],
        ["W", "TRP"],
        ["M", "MET"],
        ["C", "CYS"],
        ["P", "PRO"]
      ]
    ],
    [
      "Polar Uncharged",
      [
        ["N", "ASN"],
        ["Q", "GLN"],
        ["S", "SER"],
        ["T", "THR"]
      ]
    ],
    [
      "Positively Charged",
      [
        ["K", "LYS"],
        ["H", "HIS"],
        ["R", "ARG"]
      ]
    ],
    [
      "Negatively Charged",
      [
        ["D", "ASP"],
        ["E", "GLU"]
      ]
    ],
    [
      "Special",
      [
        ["G", "GLY"]
        // ['U', 'Sec'],
      ]
    ]
  ]), e.AcidWithProtonation = /* @__PURE__ */ new Map([
    [
      "Hydrophobic",
      [
        ["Y", "TYR", "0"],
        ["A", "ALA", "0"],
        ["V", "VAL", "0"],
        ["L", "LEU", "0"],
        ["I", "ILE", "0"],
        ["F", "PHE", "0"],
        ["W", "TRP", "0"],
        ["M", "MET", "0"],
        ["C", "CYS", "0"],
        ["P", "PRO", "0"],
        ["H", "HID", "0"],
        ["H", "HIE", "0"]
      ]
    ],
    [
      "Polar Uncharged",
      [
        ["N", "ASN", "0"],
        ["Q", "GLN", "0"],
        ["S", "SER", "0"],
        ["T", "THR", "0"]
      ]
    ],
    [
      "Positively Charged(+1)",
      [
        ["K", "LYS", "1"],
        ["H", "HIP", "1"],
        ["R", "ARG", "1"]
      ]
    ],
    [
      "Negatively Charged(-1)",
      [
        ["D", "ASP", "-1"],
        ["E", "GLU", "-1"]
      ]
    ],
    ["Special", [["G", "GLY", "0"]]],
    [
      "Atypical",
      [
        ["B", "ASH", "0"],
        ["E", "GLH", "0"],
        ["K", "LYN", "0"],
        ["CM", "CYM", "-1", "-1"]
      ]
    ]
  ]), e.AcidHydrophobic = /* @__PURE__ */ new Set(["Y", "A", "V", "L", "I", "F", "W", "M", "C", "P"]), e.AcidPolarUncharged = /* @__PURE__ */ new Set(["N", "Q", "S", "T"]), e.AcidPositivelyCharged = /* @__PURE__ */ new Set(["K", "H", "R"]), e.AcidNegativelyCharged = /* @__PURE__ */ new Set(["D", "E"]), e.AcidSpecial = /* @__PURE__ */ new Set([
    "G"
    // , 'U'
  ]), e.AcidOverall = {
    Y: e.AcidHydrophobic,
    A: e.AcidHydrophobic,
    V: e.AcidHydrophobic,
    L: e.AcidHydrophobic,
    I: e.AcidHydrophobic,
    F: e.AcidHydrophobic,
    W: e.AcidHydrophobic,
    M: e.AcidHydrophobic,
    C: e.AcidHydrophobic,
    P: e.AcidHydrophobic,
    N: e.AcidPolarUncharged,
    Q: e.AcidPolarUncharged,
    S: e.AcidPolarUncharged,
    T: e.AcidPolarUncharged,
    K: e.AcidPositivelyCharged,
    H: e.AcidPositivelyCharged,
    R: e.AcidPositivelyCharged,
    D: e.AcidNegativelyCharged,
    E: e.AcidNegativelyCharged,
    G: e.AcidSpecial
    // U: AcidSpecial,
  }, e.AcidClassName = {
    Y: "acid-hydrophobic",
    A: "acid-hydrophobic",
    V: "acid-hydrophobic",
    L: "acid-hydrophobic",
    I: "acid-hydrophobic",
    F: "acid-hydrophobic",
    W: "acid-hydrophobic",
    M: "acid-hydrophobic",
    C: "acid-hydrophobic",
    P: "acid-hydrophobic",
    N: "acid-polar-uncharged",
    Q: "acid-polar-uncharged",
    S: "acid-polar-uncharged",
    T: "acid-polar-uncharged",
    K: "acid-positively-charged",
    H: "acid-positively-charged",
    R: "acid-positively-charged",
    D: "acid-negatively-charged",
    E: "acid-negatively-charged",
    G: "acid-special",
    U: "acid-special"
  }, e.pdbAtomLineFormat = [
    {
      start: 6,
      end: 11,
      regular: /[\d\s]+/
    },
    // {
    //     start: 11,
    //     end: 12,
    //     regular: /\s/,
    // },
    {
      start: 12,
      end: 16,
      regular: /\s*[A-Z0-9]+\s*/
    },
    {
      start: 16,
      end: 17,
      regular: /[A-Z0-9 ]{1}/
    },
    {
      start: 17,
      end: 20,
      regular: /\s*[A-Z0-9]+\s*/
    },
    // {
    //     start: 20,
    //     end: 21,
    //     regular: /\s/,
    // },
    {
      start: 21,
      end: 22,
      regular: /[A-Za-z0-9 ]{1}/
    },
    {
      start: 22,
      end: 26,
      regular: /\s*[\d-]+\s*/
    },
    {
      start: 26,
      end: 27,
      regular: /[A-Z0-9 ]{1}/
    },
    // {
    //     start: 27,
    //     end: 30,
    //     regular: /\s+/,
    // },
    {
      start: 30,
      end: 38,
      regular: /\s*[\d.-]+\s*/
    },
    {
      start: 38,
      end: 46,
      regular: /\s*[\d.-]+\s*/
    },
    {
      start: 46,
      end: 54,
      regular: /\s*[\d.-]+\s*/
    },
    {
      start: 54,
      end: 60,
      regular: /\s*[\d.-]+\s*/
    }
    // {
    //     start: 60,
    //     end: 66,
    //     regular: /\s*[\d.-]+\s*/,
    // },
    // {
    //     start: 66,
    //     end: 72,
    //     regular: /\s+/,
    // },
    // {
    //     start: 72,
    //     end: 76,
    //     regular: /[\sA-Z0-9\-+]+/,
    // },
    // {
    //     start: 76,
    //     end: 78,
    //     regular: /[\sA-Z0-9\-+]+/,
    // },
    // {
    //     start: 78,
    //     end: 82,
    //     regular: /[\sA-Z0-9\-+]+/,
    // },
    // {
    //     start: 82,
    //     end: 84,
    //     regular: /[\sA-Z0-9\-+]+/,
    // },
    // {
    //     start: 84,
    //     end: 90,
    //     regular: /[\sA-Z0-9\-+]+/,
    // },
  ], e.pdbAnisouLineFormat = [
    {
      start: 6,
      end: 11,
      regular: /[\d\s]+/
    },
    // {
    //     start: 11,
    //     end: 12,
    //     regular: /\s/,
    // },
    {
      start: 12,
      end: 16,
      regular: /\s*[A-Z0-9]+\s*/
    },
    {
      start: 16,
      end: 17,
      regular: /[A-Z0-9 ]{1}/
    },
    {
      start: 17,
      end: 20,
      regular: /\s*[A-Z0-9]+\s*/
    },
    // {
    //     start: 20,
    //     end: 21,
    //     regular: /\s/,
    // },
    {
      start: 21,
      end: 22,
      regular: /[A-Za-z0-9 ]{1}/
    },
    {
      start: 22,
      end: 26,
      regular: /\s*[\d-]+\s*/
    },
    {
      start: 26,
      end: 27,
      regular: /[A-Z0-9 ]{1}/
    },
    // {
    //     start: 27,
    //     end: 28,
    //     regular: /\s+/,
    // },
    {
      start: 28,
      end: 35,
      regular: /\s*[\d.-]+\s*/
    },
    {
      start: 35,
      end: 42,
      regular: /\s*[\d.-]+\s*/
    },
    {
      start: 42,
      end: 49,
      regular: /\s*[\d.-]+\s*/
    },
    {
      start: 49,
      end: 56,
      regular: /\s*[\d.-]+\s*/
    },
    {
      start: 56,
      end: 63,
      regular: /\s*[\d.-]+\s*/
    },
    {
      start: 63,
      end: 70,
      regular: /\s*[\d.-]+\s*/
    }
    // {
    //     start: 70,
    //     end: 76,
    //     regular: /\s+/,
    // },
    // {
    //     start: 76,
    //     end: 78,
    //     regular: /[\sA-Z0-9\-+]+/,
    // },
    // {
    //     start: 78,
    //     end: 80,
    //     regular: /[\sA-Z0-9\-+]+/,
    // },
  ], e.pdbConectLineFormat = [
    {
      start: 6,
      end: 11,
      regular: /[\d\s]+/
    },
    {
      start: 11,
      end: 16,
      regular: /[\d\s]+/
    },
    {
      start: 16,
      end: 21,
      regular: /[\d\s]+/
    },
    {
      start: 21,
      end: 26,
      regular: /[\d\s]+/
    },
    {
      start: 26,
      end: 31,
      regular: /[\d\s]+/
    }
  ], e.molAtomLineFormat = [
    {
      start: 0,
      end: 10,
      regular: /\s*[\d.-]+/
    },
    {
      start: 10,
      end: 20,
      regular: /\s*[\d.-]+/
    },
    {
      start: 20,
      end: 30,
      regular: /\s*[\d.-]+/
    },
    // {
    //     start: 30,
    //     end: 31,
    //     regular: /\s/,
    // },
    {
      start: 31,
      end: 33,
      regular: /[\sA-Za-z]+/
    }
  ], e.molBondFormatCheck = [
    {
      start: 0,
      end: 3,
      regular: /\s*[\d]+/
    },
    {
      start: 3,
      end: 6,
      regular: /\s*[\d]+/
    },
    {
      start: 6,
      end: 9,
      regular: /\s*[\d]+/
    }
    // {
    //     start: 9,
    //     end: 12,
    //     regular: /[\d\s]+/,
    // },
    // {
    //     start: 12,
    //     end: 15,
    //     regular: /[\d\s]+/,
    // },
    // {
    //     start: 15,
    //     end: 18,
    //     regular: /[\d\s]+/,
    // },
  ], e.molCountLineFormat = [
    {
      start: 0,
      end: 3,
      regular: /\s*[\d]+/
    },
    {
      start: 3,
      end: 6,
      regular: /\s*[\d]+/
    }
    // {
    //     start: 6,
    //     end: 9,
    //     regular: /\s*[\d]+/,
    // },
    // {
    //     start: 9,
    //     end: 12,
    //     regular: /[\d\s]+/,
    // },
    // {
    //     start: 12,
    //     end: 15,
    //     regular: /[\d\s]+/,
    // },
    // {
    //     start: 15,
    //     end: 18,
    //     regular: /[\d\s]+/,
    // },
    // {
    //     start: 18,
    //     end: 21,
    //     regular: /[\d\s]+/,
    // },
    // {
    //     start: 21,
    //     end: 24,
    //     regular: /[\d\s]+/,
    // },
    // {
    //     start: 24,
    //     end: 27,
    //     regular: /[\d\s]+/,
    // },
    // {
    //     start: 27,
    //     end: 30,
    //     regular: /[\d\s]+/,
    // },
    // {
    //     start: 30,
    //     end: 33,
    //     regular: /[\d\s]+/,
    // },
    // {
    //     start: 33,
    //     end: 38,
    //     regular: /[\sA-Z0-9+]+/,
    // },
  ], e.ReprLabelToType = {
    Dihedral: r.RepresentationType.Dihedral,
    Distance: r.RepresentationType.Distance,
    Angle: r.RepresentationType.Angle,
    Label: r.RepresentationType.Label,
    "Molecular Surface": r.RepresentationType.Surface,
    "Ball & Stick": r.RepresentationType.BallAndStick,
    Line: r.RepresentationType.Line,
    Stick: r.RepresentationType.Stick,
    Spacefill: r.RepresentationType.CPK,
    Cartoon: r.RepresentationType.Ribbon
  };
})(Up);
Object.defineProperty(xy, "__esModule", { value: !0 });
xy.getSequenceDataOfResidue = void 0;
var Yh = Je(), R2 = Gr, O2 = Up, Mve = Lp, wve = function(e) {
  return R2.SecondaryStructureType.is(e, 2) ? "helix" : R2.SecondaryStructureType.is(e, 4) ? "sheet" : R2.SecondaryStructureType.is(e, 16) ? "turn" : R2.SecondaryStructureType.is(e, 8) ? "bend" : "none";
}, Eve = function(e, r, t) {
  var n = r[0], a = n.residueName, i = n.residueId, o = n.isEutectic, c = r.map(function(d) {
    return d.elementId;
  }), s = (0, Mve.getLoci)(e, c), u = Yh.StructureElement.Stats.ofLoci(s), l;
  u.elementCount > 0 ? l = u.firstElementLoc : u.residueCount > 0 ? l = u.firstResidueLoc : u.chainCount > 0 ? l = u.firstChainLoc : u.unitCount > 0 ? l = u.firstUnitLoc : u.conformationCount > 0 ? l = u.firstConformationLoc : l = u.firstStructureLoc;
  var f = wve(Yh.StructureProperties.residue.secondary_structure_type(l));
  return {
    residueNum: i,
    residueName: a.toUpperCase(),
    standardResidueName: O2.residueSubstitutions[a.toUpperCase()],
    oneLetter: o ? "X" : O2.ResidueAbbrMap[O2.residueSubstitutions[a.toUpperCase()]] || O2.residueSubstitutions[a.toUpperCase()] || "X",
    elementIds: r.map(function(d) {
      return d.elementId;
    }),
    secondaryStructureType: f,
    secondaryStructureTypeInfo: Yh.StructureProperties.residue.secondary_structure_type(l),
    secondaryStructureTypeKey: Yh.StructureProperties.residue.secondary_structure_key(l),
    insCode: Yh.StructureProperties.residue.pdbx_PDB_ins_code(l),
    index: t
  };
};
xy.getSequenceDataOfResidue = Eve;
var dB;
function $H() {
  return dB || (dB = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.getGranularityProps = e.getGranularityUniqueId = e.getSequence = e.getHierarchy = e.setHierarchyData = e.atomHierarchyToAtomData = e.SolventNameSet = e.MetalNameSet = void 0;
    var r = Te, t = Gr, n = Ap, a = Jt, i = xy, o = Hp(), c = [
      "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"
    ], s = [
      "EOH",
      "GOL",
      "DMS",
      "PEG",
      "POL",
      "IOH",
      "DIO",
      "ACN",
      "SBT",
      "1BO",
      "CCN",
      "DMS",
      "GBL",
      "P2K",
      "MPD",
      "PGQ",
      "SEO"
    ];
    e.MetalNameSet = new Set(c), e.SolventNameSet = new Set(s);
    var u = function(v) {
      var h, y;
      return {
        elementId: v.elementId,
        group_PDB: v.groupPDB,
        atom_id: "".concat(v.atomId),
        auth_atom_id: v.atomName,
        label_alt_id: v.altId,
        auth_comp_id: v.residueName,
        auth_asym_id: v.chainId,
        auth_seq_id: "".concat(v.residueId),
        pdbx_PDB_ins_code: v.insertCode,
        x: v.x,
        y: v.y,
        z: v.z,
        occupancy: (h = v.occupancy) !== null && h !== void 0 ? h : "",
        B_iso_or_equiv: "".concat((y = v.bfactor) !== null && y !== void 0 ? y : ""),
        type_symbol: v.typeSymbol,
        charge: v.charge
      };
    };
    e.atomHierarchyToAtomData = u;
    var l = function(v, h, y) {
      y === void 0 && (y = !1);
      var C = y ? "".concat(h.residueId, "_").concat(h.insertCode) : h.residueId;
      v[h.chainId] ? v[h.chainId][C] = (v[h.chainId][C] ? v[h.chainId][C] : []).concat(h) : (v[h.chainId] = {}, v[h.chainId][C] = [h]);
    };
    e.setHierarchyData = l;
    var f = function(v) {
      var h = {}, y = {}, C = {}, S = {}, b = {}, g = {}, _ = {}, A = {}, M = /* @__PURE__ */ new Set(), P = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map();
      v.units.forEach(function(D) {
        var N;
        D.elements.forEach(function(L) {
          var R = (0, o.getAtomHierarchyByUnit)(D, L);
          if (t.WaterNames.has(R.residueName.toUpperCase())) {
            (0, e.setHierarchyData)(y, R);
            return;
          }
          if (e.MetalNameSet.has(R.typeSymbol.toUpperCase())) {
            (0, e.setHierarchyData)(S, R);
            return;
          }
          if (e.SolventNameSet.has(R.residueName.toUpperCase())) {
            (0, e.setHierarchyData)(C, R);
            return;
          }
          if (n.IonNames.has(R.residueName.toUpperCase())) {
            (0, e.setHierarchyData)(b, R);
            return;
          }
          if (R.groupPDB === "ATOM" && !["UNK", "MOL"].includes(R.residueName)) {
            (0, e.setHierarchyData)(h, R, !0), M.add(R.elementId);
            return;
          }
          if (R.groupPDB === "HETATM" || ["UNK", "MOL"].includes(R.residueName)) {
            var F = "".concat(R.chainId, "_").concat(R.residueId);
            P.set(F, P.has(F) ? (0, r.__spreadArray)((0, r.__spreadArray)([], P.get(F), !0), [R], !1) : [R]);
            return;
          }
          (0, e.setHierarchyData)(_, R);
        });
        for (var O = 0, V = D.bonds.a.length; O < V; O++) {
          var k = D.elements[D.bonds.a[O]], G = D.elements[D.bonds.b[O]];
          T.has(k) ? (N = T.get(k)) === null || N === void 0 || N.add(G) : T.set(k, /* @__PURE__ */ new Set([G]));
        }
      }), P.forEach(function(D) {
        var N = !1, O = new Set(D.map(function(V) {
          return V.elementId;
        }));
        O.forEach(function(V) {
          if (T.has(V)) {
            var k = T.get(V);
            k == null || k.forEach(function(G) {
              M.has(G) && (N = !0);
            });
          }
        }), D.forEach(function(V) {
          N ? (Object.assign(V, { isEutectic: !0 }), (0, e.setHierarchyData)(g, V)) : (0, e.setHierarchyData)(_, V);
        });
      });
      var x = {};
      Object.keys(_).forEach(function(D) {
        var N = _[D];
        Object.keys(N).forEach(function(O) {
          var V = N[O], k = V.filter(function(G) {
            return G.typeSymbol !== "H";
          });
          k.length > 10 && k.length < 150 ? (A[D] || (A[D] = {}), A[D][O] = V) : (x[D] || (x[D] = {}), x[D][O] = V);
        });
      });
      var w = {};
      Object.keys(h).forEach(function(D) {
        var N;
        w[D] || (w[D] = []), (N = w[D]).push.apply(N, Object.values(h[D]));
      }), Object.keys(g).forEach(function(D) {
        var N = g[D];
        Object.keys(N).forEach(function(O) {
          var V = N[O];
          x[D] || (x[D] = {}), w[D] || (w[D] = []), w[D].push(V), x[D][O] = V;
        });
      });
      var E = 0, I = {};
      Object.keys(w).forEach(function(D) {
        I[D] = {}, w[D].sort(function(N, O) {
          return N[0].residueId !== O[0].residueId ? N[0].residueId - O[0].residueId : N[0].insertCode.localeCompare(O[0].insertCode);
        }).forEach(function(N) {
          I[N[0].chainId]["".concat(N[0].residueId, "_").concat(N[0].insertCode)] = (0, i.getSequenceDataOfResidue)(v, N, E++);
        });
      });
      var B;
      return B = {
        // structureRef: ref,
        data: {
          polymer: h,
          water: y,
          otherSolvent: C,
          metal: S,
          ion: b,
          ligand: A,
          other: x
        },
        extraData: {
          // label: labelInfo,
          // surface: surfaceInfo,
          sequenceData: I
        }
      }, B;
    };
    e.getHierarchy = f;
    var d = function(v) {
      var h = {}, y = {}, C = {}, S = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
      v.units.forEach(function(T) {
        var x;
        T.elements.forEach(function(D) {
          var N = (0, o.getAtomHierarchyByUnit)(T, D);
          if (!t.WaterNames.has(N.residueName.toUpperCase()) && !e.MetalNameSet.has(N.typeSymbol.toUpperCase()) && !e.SolventNameSet.has(N.residueName.toUpperCase()) && !n.IonNames.has(N.residueName.toUpperCase())) {
            if (N.groupPDB === "ATOM" && !["UNK", "MOL"].includes(N.residueName)) {
              (0, e.setHierarchyData)(h, N, !0), S.add(N.elementId);
              return;
            }
            if (N.groupPDB === "HETATM" || ["UNK", "MOL"].includes(N.residueName)) {
              var O = "".concat(N.chainId, "_").concat(N.residueId);
              b.set(O, b.has(O) ? (0, r.__spreadArray)((0, r.__spreadArray)([], b.get(O), !0), [N], !1) : [N]);
              return;
            }
            (0, e.setHierarchyData)(C, N);
          }
        });
        for (var w = 0, E = T.bonds.a.length; w < E; w++) {
          var I = T.elements[T.bonds.a[w]], B = T.elements[T.bonds.b[w]];
          g.has(I) ? (x = g.get(I)) === null || x === void 0 || x.add(B) : g.set(I, /* @__PURE__ */ new Set([B]));
        }
      }), b.forEach(function(T) {
        var x = !1, w = new Set(T.map(function(E) {
          return E.elementId;
        }));
        w.forEach(function(E) {
          if (g.has(E)) {
            var I = g.get(E);
            I == null || I.forEach(function(B) {
              S.has(B) && (x = !0);
            });
          }
        }), T.forEach(function(E) {
          x ? (Object.assign(E, { isEutectic: !0 }), (0, e.setHierarchyData)(y, E)) : (0, e.setHierarchyData)(C, E);
        });
      });
      var _ = {};
      Object.keys(C).forEach(function(T) {
        var x = C[T];
        Object.keys(x).forEach(function(w) {
          var E = x[w], I = E.filter(function(B) {
            return B.typeSymbol !== "H";
          });
          I.length <= 10 && I.length < 150 && (_[T] || (_[T] = {}), _[T][w] = E);
        });
      });
      var A = {};
      Object.keys(h).forEach(function(T) {
        var x;
        A[T] || (A[T] = []), (x = A[T]).push.apply(x, Object.values(h[T]));
      }), Object.keys(y).forEach(function(T) {
        var x = y[T];
        Object.keys(x).forEach(function(w) {
          var E = x[w];
          _[T] || (_[T] = {}), A[T] || (A[T] = []), A[T].push(E), _[T][w] = E;
        });
      });
      var M = 0, P = {};
      return Object.keys(A).forEach(function(T) {
        P[T] = {}, A[T].sort(function(x, w) {
          return x[0].residueId !== w[0].residueId ? x[0].residueId - w[0].residueId : x[0].insertCode.localeCompare(w[0].insertCode);
        }).forEach(function(x) {
          P[x[0].chainId]["".concat(x[0].residueId, "_").concat(x[0].insertCode)] = (0, i.getSequenceDataOfResidue)(v, x, M++);
        });
      }), P;
    };
    e.getSequence = d;
    var m = function(v, h) {
      switch (h) {
        case a.Granularity.Atom:
          return "".concat(v.elementId);
        case a.Granularity.Residue:
          return "".concat(v.chainId, "_").concat(v.residueName, "_").concat(v.residueId);
        case a.Granularity.Chain:
          return "".concat(v.chainId);
        case a.Granularity.Molecular:
          return "".concat(v.unitId);
      }
      return "";
    };
    e.getGranularityUniqueId = m;
    var p = function(v, h) {
      switch (h) {
        case a.Granularity.Atom:
          return v;
        case a.Granularity.Residue:
          return {
            unitId: v.unitId,
            chainId: v.chainId,
            groupPDB: v.groupPDB,
            residueId: v.residueId,
            residueName: v.residueName
          };
        case a.Granularity.Chain:
          return {
            unitId: v.unitId,
            chainId: v.chainId
          };
        case a.Granularity.Molecular:
          return {
            unitId: v.unitId
          };
      }
      return {};
    };
    e.getGranularityProps = p;
  }(mT)), mT;
}
var Qh = {}, Zh = {}, Ty = {};
Object.defineProperty(Ty, "__esModule", { value: !0 });
Ty.parsePDB = void 0;
var fB = Te, Dve = Kr, Ive = Mi, Bve = Pi;
function Nve(e, r, t) {
  var n = this;
  return t === void 0 && (t = !1), Dve.Task.create("Parse PDB", function(a) {
    return (0, fB.__awaiter)(n, void 0, void 0, function() {
      var i, o, c;
      return (0, fB.__generator)(this, function(s) {
        switch (s.label) {
          case 0:
            return o = (i = Ive.ReaderResult).success, c = {}, [4, Bve.Tokenizer.readAllLinesAsync(e, a)];
          case 1:
            return [2, o.apply(i, [(c.lines = s.sent(), c.id = r, c.isPdbqt = t, c)])];
        }
      });
    });
  });
}
Ty.parsePDB = Nve;
var p0 = {}, $4 = {}, Cd = {};
Object.defineProperty(Cd, "__esModule", { value: !0 });
Cd.parseMtrix = Cd.parseRemark350 = Cd.parseCryst1 = void 0;
var at = Vu, uo = Re;
function Vve(e, r) {
  var t = function(i, o) {
    return (r.substr(i, o) || "").trim();
  }, n = {
    entry_id: at.CifField.ofString(e),
    length_a: at.CifField.ofString(t(6, 9)),
    length_b: at.CifField.ofString(t(15, 9)),
    length_c: at.CifField.ofString(t(24, 9)),
    angle_alpha: at.CifField.ofString(t(33, 7)),
    angle_beta: at.CifField.ofString(t(40, 7)),
    angle_gamma: at.CifField.ofString(t(47, 7)),
    Z_PDB: at.CifField.ofString(t(66, 4)),
    pdbx_unique_axis: at.CifField.ofString("?")
  }, a = {
    entry_id: at.CifField.ofString(e),
    "space_group_name_H-M": at.CifField.ofString(t(55, 11)),
    Int_Tables_number: at.CifField.ofString("?"),
    cell_setting: at.CifField.ofString("?"),
    space_group_name_Hall: at.CifField.ofString("?")
  };
  return [
    at.CifCategory.ofFields("cell", n),
    at.CifCategory.ofFields("symmetry", a)
  ];
}
Cd.parseCryst1 = Vve;
function mB(e, r) {
  return { id: e, details: r, groups: [] };
}
function Rve(e, r, t) {
  for (var n = [], a, i, o, c = 1, s = 1, u = function(F) {
    return e.data.substring(e.indices[2 * F], e.indices[2 * F + 1]);
  }, l = r; l < t; l++) {
    var f = u(l);
    if (f.substr(11, 12) === "BIOMOLECULE:") {
      var d = f.substr(23).trim(), m = "Biomolecule ".concat(d);
      f = u(l + 1), f.substr(11, 30) !== "APPLY THE FOLLOWING TO CHAINS:" && (l++, m = f.substr(11).trim()), a = mB(d, m), n.push(a);
    } else if (f.substr(13, 5) === "BIOMT") {
      var p = f.split(/\s+/), v = parseInt(f[18]) - 1;
      v === 0 && (o = uo.Mat4.identity(), i.operators.push({ id: c++, matrix: o })), uo.Mat4.setValue(o, v, 0, parseFloat(p[4])), uo.Mat4.setValue(o, v, 1, parseFloat(p[5])), uo.Mat4.setValue(o, v, 2, parseFloat(p[6])), uo.Mat4.setValue(o, v, 3, parseFloat(p[7]));
    } else if (f.substr(11, 30) === "APPLY THE FOLLOWING TO CHAINS:" || f.substr(11, 30) === "                   AND CHAINS:") {
      f.substr(11, 5) === "APPLY" && (i = { chains: [], operators: [] }, a.groups.push(i));
      for (var h = f.substr(41, 30).split(","), y = 0, C = h.length; y < C; ++y) {
        var S = h[y].trim();
        S && i.chains.push(S);
      }
    } else if (f.substr(11, 33) === "APPLYING THE FOLLOWING TO CHAINS:") {
      a = mB("".concat(s), "Biomolecule ".concat(s)), n.push(a), s += 1, i = { chains: [], operators: [] }, a.groups.push(i), l++, f = u(l);
      for (var h = f.substr(11, 69).split(","), y = 0, C = h.length; y < C; ++y) {
        var S = h[y].trim();
        S && i.chains.push(S);
      }
    }
  }
  if (n.length === 0)
    return [];
  for (var b = {
    id: at.CifField.ofStrings(n.map(function(F) {
      return F.id;
    })),
    details: at.CifField.ofStrings(n.map(function(F) {
      return F.details;
    }))
  }, g = [], _ = 0, A = n; _ < A.length; _++)
    for (var M = A[_], P = 0, T = M.groups; P < T.length; P++) {
      var x = T[P];
      g.push({
        assembly_id: M.id,
        oper_expression: x.operators.map(function(F) {
          return F.id;
        }).join(","),
        asym_id_list: x.chains.join(",")
      });
    }
  for (var w = {
    assembly_id: at.CifField.ofStrings(g.map(function(F) {
      return F.assembly_id;
    })),
    oper_expression: at.CifField.ofStrings(g.map(function(F) {
      return F.oper_expression;
    })),
    asym_id_list: at.CifField.ofStrings(g.map(function(F) {
      return F.asym_id_list;
    }))
  }, E = [], I = 0, B = n; I < B.length; I++)
    for (var M = B[I], D = 0, N = M.groups; D < N.length; D++)
      for (var O = N[D], V = 0, k = O.operators; V < k.length; V++) {
        for (var G = k[V], v = {
          id: "" + G.id,
          type: "?",
          name: "?",
          symmetry_operation: "?"
        }, l = 0; l < 3; l++) {
          for (var y = 0; y < 3; y++)
            v["matrix[".concat(l + 1, "][").concat(y + 1, "]")] = "" + uo.Mat4.getValue(G.matrix, l, y);
          v["vector[".concat(l + 1, "]")] = "" + uo.Mat4.getValue(G.matrix, l, 3);
        }
        E.push(v);
      }
  for (var L = {
    id: at.CifField.ofStrings(E.map(function(F) {
      return F.id;
    })),
    type: at.CifField.ofStrings(E.map(function(F) {
      return F.type;
    })),
    name: at.CifField.ofStrings(E.map(function(F) {
      return F.name;
    })),
    symmetry_operation: at.CifField.ofStrings(E.map(function(F) {
      return F.symmetry_operation;
    }))
  }, R = function(F) {
    for (var U = function(K) {
      var Y = "matrix[".concat(F + 1, "][").concat(K + 1, "]");
      L[Y] = at.CifField.ofStrings(E.map(function(X) {
        return X[Y];
      }));
    }, H = 0; H < 3; H++)
      U(H);
    var q = "vector[".concat(F + 1, "]");
    L[q] = at.CifField.ofStrings(E.map(function(K) {
      return K[q];
    }));
  }, l = 0; l < 3; l++)
    R(l);
  return [
    at.CifCategory.ofFields("pdbx_struct_assembly", b),
    at.CifCategory.ofFields("pdbx_struct_assembly_gen", w),
    at.CifCategory.ofFields("pdbx_struct_oper_list", L)
  ];
}
Cd.parseRemark350 = Rve;
function Ove(e, r, t) {
  for (var n = [], a, i = function(C) {
    return e.data.substring(e.indices[2 * C], e.indices[2 * C + 1]);
  }, o = r; o < t; o++) {
    var c = i(o), s = c.split(/\s+/), u = parseInt(c[5]) - 1;
    u === 0 && (a = uo.Mat4.identity(), n.push(a)), uo.Mat4.setValue(a, u, 0, parseFloat(s[2])), uo.Mat4.setValue(a, u, 1, parseFloat(s[3])), uo.Mat4.setValue(a, u, 2, parseFloat(s[4])), uo.Mat4.setValue(a, u, 3, parseFloat(s[5]));
  }
  if (n.length === 0)
    return [];
  for (var l = [], f = 1, d = 0, m = n; d < m.length; d++) {
    for (var p = m[d], u = {
      id: "ncsop" + f++,
      code: ".",
      details: "."
    }, o = 0; o < 3; o++) {
      for (var v = 0; v < 3; v++)
        u["matrix[".concat(o + 1, "][").concat(v + 1, "]")] = "" + uo.Mat4.getValue(p, o, v);
      u["vector[".concat(o + 1, "]")] = "" + uo.Mat4.getValue(p, o, 3);
    }
    l.push(u);
  }
  for (var h = {
    id: at.CifField.ofStrings(l.map(function(C) {
      return C.id;
    })),
    code: at.CifField.ofStrings(l.map(function(C) {
      return C.code;
    })),
    details: at.CifField.ofStrings(l.map(function(C) {
      return C.details;
    }))
  }, y = function(C) {
    for (var S = function(_) {
      var A = "matrix[".concat(C + 1, "][").concat(_ + 1, "]");
      h[A] = at.CifField.ofStrings(l.map(function(M) {
        return M[A];
      }));
    }, b = 0; b < 3; b++)
      S(b);
    var g = "vector[".concat(C + 1, "]");
    h[g] = at.CifField.ofStrings(l.map(function(_) {
      return _[g];
    }));
  }, o = 0; o < 3; o++)
    y(o);
  return [at.CifCategory.ofFields("struct_ncs_oper", h)];
}
Cd.parseMtrix = Ove;
var Gv = {};
Object.defineProperty(Gv, "__esModule", { value: !0 });
Gv.parseSheet = Gv.parseHelix = void 0;
var Vt = Vu, vB = mr(), Fve = {
  // CLASS NUMBER
  // TYPE OF  HELIX                     (COLUMNS 39 - 40)
  // --------------------------------------------------------------
  // Right-handed alpha (default)                1
  // Right-handed omega                          2
  // Right-handed pi                             3
  // Right-handed gamma                          4
  // Right-handed 3 - 10                         5
  // Left-handed alpha                           6
  // Left-handed omega                           7
  // Left-handed gamma                           8
  // 2 - 7 ribbon/helix                          9
  // Polyproline                                10
  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"
  // TODO or left-handed???
};
function Lve(e) {
  return Fve[e] || "HELX_P";
}
function kve(e, r, t) {
  for (var n = [], a = function(d) {
    return e.data.substring(e.indices[2 * d], e.indices[2 * d + 1]);
  }, i = r; i < t; i++) {
    var o = a(i);
    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 c = Vt.CifField.ofStrings(n.map(function(d) {
    return d.initChainID;
  })), s = Vt.CifField.ofStrings(n.map(function(d) {
    return d.initResName;
  })), u = Vt.CifField.ofStrings(n.map(function(d) {
    return d.endChainID;
  })), l = Vt.CifField.ofStrings(n.map(function(d) {
    return d.endResName;
  })), f = {
    beg_label_asym_id: c,
    beg_label_comp_id: s,
    beg_label_seq_id: Vt.CifField.ofUndefined(n.length, vB.Column.Schema.int),
    beg_auth_asym_id: c,
    beg_auth_comp_id: s,
    beg_auth_seq_id: Vt.CifField.ofStrings(n.map(function(d) {
      return d.initSeqNum;
    })),
    conf_type_id: Vt.CifField.ofStrings(n.map(function(d) {
      return Lve(d.helixClass);
    })),
    details: Vt.CifField.ofStrings(n.map(function(d) {
      return d.comment;
    })),
    end_label_asym_id: u,
    end_label_comp_id: l,
    end_label_seq_id: Vt.CifField.ofUndefined(n.length, vB.Column.Schema.int),
    end_auth_asym_id: u,
    end_auth_comp_id: l,
    end_auth_seq_id: Vt.CifField.ofStrings(n.map(function(d) {
      return d.endSeqNum;
    })),
    id: Vt.CifField.ofStrings(n.map(function(d) {
      return d.serNum;
    })),
    pdbx_beg_PDB_ins_code: Vt.CifField.ofStrings(n.map(function(d) {
      return d.initICode;
    })),
    pdbx_end_PDB_ins_code: Vt.CifField.ofStrings(n.map(function(d) {
      return d.endICode;
    })),
    pdbx_PDB_helix_class: Vt.CifField.ofStrings(n.map(function(d) {
      return d.helixClass;
    })),
    pdbx_PDB_helix_length: Vt.CifField.ofStrings(n.map(function(d) {
      return d.length;
    })),
    pdbx_PDB_helix_id: Vt.CifField.ofStrings(n.map(function(d) {
      return d.helixID;
    }))
  };
  return Vt.CifCategory.ofFields("struct_conf", f);
}
Gv.parseHelix = kve;
function Uve(e, r, t) {
  for (var n = [], a = function(p) {
    return e.data.substring(e.indices[2 * p], e.indices[2 * p + 1]);
  }, i = r; i < t; i++) {
    var o = a(i);
    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 c = Vt.CifField.ofStrings(n.map(function(p) {
    return p.initChainID;
  })), s = Vt.CifField.ofStrings(n.map(function(p) {
    return p.initResName;
  })), u = Vt.CifField.ofStrings(n.map(function(p) {
    return p.initSeqNum;
  })), l = Vt.CifField.ofStrings(n.map(function(p) {
    return p.endChainID;
  })), f = Vt.CifField.ofStrings(n.map(function(p) {
    return p.endResName;
  })), d = Vt.CifField.ofStrings(n.map(function(p) {
    return p.endSeqNum;
  })), m = {
    beg_label_asym_id: c,
    beg_label_comp_id: s,
    beg_label_seq_id: u,
    beg_auth_asym_id: c,
    beg_auth_comp_id: s,
    beg_auth_seq_id: u,
    end_label_asym_id: l,
    end_label_comp_id: l,
    end_label_seq_id: d,
    end_auth_asym_id: l,
    end_auth_comp_id: f,
    end_auth_seq_id: d,
    id: Vt.CifField.ofStrings(n.map(function(p) {
      return p.strand;
    })),
    sheet_id: Vt.CifField.ofStrings(n.map(function(p) {
      return p.sheetID;
    })),
    pdbx_beg_PDB_ins_code: Vt.CifField.ofStrings(n.map(function(p) {
      return p.initICode;
    })),
    pdbx_end_PDB_ins_code: Vt.CifField.ofStrings(n.map(function(p) {
      return p.endICode;
    }))
  };
  return Vt.CifCategory.ofFields("struct_sheet_range", m);
}
Gv.parseSheet = Uve;
var qv = {};
Object.defineProperty(qv, "__esModule", { value: !0 });
qv.parseHetnam = qv.parseCmpnd = void 0;
var zve = {
  MOL_ID: "",
  MOLECULE: "",
  CHAIN: "",
  FRAGMENT: "",
  SYNONYM: "",
  EC: "",
  ENGINEERED: "",
  MUTATION: "",
  OTHER_DETAILS: ""
};
function Gve(e, r, t) {
  for (var n = function(b) {
    return e.data.substring(e.indices[2 * b], e.indices[2 * b + 1]);
  }, a, i = { chains: [], description: "" }, o = [], c = r; c < t; c++) {
    var s = n(c), u = s.substr(10, 70).trim(), l = u.indexOf(":"), f = u.substring(0, l), d = void 0;
    f in zve ? (a = f, d = u.substring(l + 2)) : d = u, d = d.replace(/;$/, ""), a === "MOL_ID" ? (i = {
      chains: [],
      description: ""
    }, o.push(i)) : a === "MOLECULE" ? (i.description && (i.description += " "), i.description += d) : a === "CHAIN" && Array.prototype.push.apply(i.chains, d.split(/\s*,\s*/));
  }
  for (var m = [], p = 0, v = o; p < v.length; p++)
    for (var h = v[p], y = 0, C = h.chains; y < C.length; y++) {
      var S = C[y];
      m.push({
        description: h.description,
        chains: [S]
      });
    }
  return m;
}
qv.parseCmpnd = Gve;
function qve(e, r, t) {
  for (var n = function(u) {
    return e.data.substring(e.indices[2 * u], e.indices[2 * u + 1]);
  }, a = /* @__PURE__ */ new Map(), i = r; i < t; i++) {
    var o = n(i), c = o.substr(11, 3).trim(), s = o.substr(15).trim();
    a.has(c) ? a.set(c, "".concat(a.get(c), " ").concat(s)) : a.set(c, s);
  }
  return a;
}
qv.parseHetnam = qve;
var yl = {};
Object.defineProperty(yl, "__esModule", { value: !0 });
yl.ComponentBuilder = void 0;
var Jh = mr(), pB = Gr, Hve = ds, jve = Zo, $ve = ly, Kve = [/* @__PURE__ */ new Set(["CA"]), /* @__PURE__ */ new Set(["C"]), /* @__PURE__ */ new Set(["N"])], Wve = [
  /* @__PURE__ */ new Set(["P", "O3'", "O3*"]),
  /* @__PURE__ */ new Set(["C4'", "C4*"]),
  /* @__PURE__ */ new Set(["O2'", "O2*", "F2'", "F2*"])
], Xve = [
  /* @__PURE__ */ new Set(["P", "O3'", "O3*"]),
  /* @__PURE__ */ new Set(["C3'", "C3*"]),
  /* @__PURE__ */ new Set(["O2'", "O2*", "F2'", "F2*"])
], Yve = /* @__PURE__ */ new Set([
  "FMN",
  "NCN",
  "FNS",
  "FMA",
  "ATP",
  "ADP",
  "AMP",
  "GTP",
  "GDP",
  "GMP"
  // Mononucleotides
]), hB = function() {
  var e = /* @__PURE__ */ new Map(), r = [
    { 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" },
    // ADDED BY XUHANG
    { id: "ACE", name: "Acetylgroup", type: "peptide linking" },
    { id: "NME", name: "Methylamine", type: "peptide linking" }
  ];
  return r.forEach(function(t) {
    return e.set(t.id, t);
  }), e;
}(), gB = function() {
  var e = /* @__PURE__ */ new Map(), r = [
    { 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" }
  ];
  return r.forEach(function(t) {
    return e.set(t.id, t);
  }), e;
}(), Qve = (
  /** @class */
  function() {
    function e(r, t) {
      this.seqId = r, this.atomId = t, 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(r) {
      this.comps.set(r.id, r), this.ids.push(r.id), this.names.push(r.name), this.types.push(r.type), this.mon_nstd_flags.push(pB.PolymerNames.has(r.id) ? "y" : "n");
    }, e.prototype.getAtomIds = function(r) {
      for (var t = /* @__PURE__ */ new Set(), n = this.seqId.value(r); r < this.seqId.rowCount; ) {
        var a = this.seqId.value(r);
        if (a !== n)
          break;
        t.add(this.atomId.value(r)), r += 1;
      }
      return t;
    }, e.prototype.hasAtomIds = function(r, t) {
      for (var n = 0, a = t.length; n < a; ++n)
        if (!Hve.SetUtils.areIntersecting(r, t[n]))
          return !1;
      return !0;
    }, e.prototype.getType = function(r) {
      return this.hasAtomIds(r, Kve) ? "peptide linking" : this.hasAtomIds(r, Wve) ? "RNA linking" : this.hasAtomIds(r, Xve) ? "DNA linking" : "other";
    }, e.prototype.has = function(r) {
      return this.comps.has(r);
    }, e.prototype.get = function(r) {
      return this.comps.get(r);
    }, e.prototype.add = function(r, t) {
      if (!this.has(r))
        if (hB.has(r))
          this.set(hB.get(r));
        else if (pB.WaterNames.has(r))
          this.set({ id: r, name: "WATER", type: "non-polymer" });
        else if (Yve.has(r.toUpperCase()))
          this.set({
            id: r,
            name: this.namesMap.get(r) || r,
            type: "non-polymer"
          });
        else if ($ve.SaccharideCompIdMap.has(r.toUpperCase()))
          this.set({
            id: r,
            name: this.namesMap.get(r) || r,
            type: "saccharide"
          });
        else {
          var n = this.getAtomIds(t);
          if (n.size === 1 && gB.has(r))
            this.set(gB.get(r));
          else {
            var a = this.getType(n);
            this.set({
              id: r,
              name: this.namesMap.get(r) || r,
              type: a
            });
          }
        }
      return this.get(r);
    }, e.prototype.getChemCompTable = function() {
      return Jh.Table.ofPartialColumns(jve.BasicSchema.chem_comp, {
        id: Jh.Column.ofStringArray(this.ids),
        name: Jh.Column.ofStringArray(this.names),
        type: Jh.Column.ofStringAliasArray(this.types),
        mon_nstd_flag: Jh.Column.ofStringAliasArray(this.mon_nstd_flags)
      }, this.ids.length);
    }, e.prototype.setNames = function(r) {
      var t = this;
      r.forEach(function(n) {
        return t.namesMap.set(n[0], n[1]);
      });
    }, e;
  }()
);
yl.ComponentBuilder = Qve;
var _l = {};
Object.defineProperty(_l, "__esModule", { value: !0 });
_l.EntityBuilder = void 0;
var Zve = Gr, F2 = mr(), Jve = Zo, epe = (
  /** @class */
  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(r, t) {
      this.count += 1, this.ids.push("".concat(this.count)), this.types.push(r), this.descriptions.push([t]);
    }, e.prototype.getEntityId = function(r, t, n, a) {
      return t === 2 ? (this.waterId === void 0 && (this.set("water", (a == null ? void 0 : a.customName) || "Water"), this.waterId = "".concat(this.count)), this.waterId) : (0, Zve.isPolymer)(t) ? this.compoundsMap.has(n) ? this.compoundsMap.get(n) : (this.chainMap.has(n) || (this.set("polymer", (a == null ? void 0 : a.customName) || "Polymer ".concat(this.chainMap.size + 1)), this.chainMap.set(n, "".concat(this.count))), this.chainMap.get(n)) : (this.heteroMap.has(r) || (this.set("non-polymer", (a == null ? void 0 : a.customName) || this.namesMap.get(r) || r), this.heteroMap.set(r, "".concat(this.count))), this.heteroMap.get(r));
    }, e.prototype.getEntityTable = function() {
      return F2.Table.ofPartialColumns(Jve.BasicSchema.entity, {
        id: F2.Column.ofStringArray(this.ids),
        type: F2.Column.ofStringAliasArray(this.types),
        pdbx_description: F2.Column.ofStringListArray(this.descriptions)
      }, this.count);
    }, e.prototype.setCompounds = function(r) {
      for (var t = 0, n = r.length; t < n; ++t) {
        var a = r[t], i = a.chains, o = a.description;
        this.set("polymer", o);
        for (var c = 0, s = i.length; c < s; ++c)
          this.compoundsMap.set(i[c], "".concat(this.count));
      }
    }, e.prototype.setNames = function(r) {
      var t = this;
      r.forEach(function(n) {
        return t.namesMap.set(n[0], n[1]);
      });
    }, e;
  }()
);
_l.EntityBuilder = epe;
var Ad = {}, ls = {};
Object.defineProperty(ls, "__esModule", { value: !0 });
ls.guessElementSymbolString = ls.guessElementSymbolTokens = void 0;
var e1 = Pi;
function rpe(e, r, t, n) {
  for (var a = t, i = n - 1, o = r.charCodeAt(a); (o === 32 || o >= 48 && o <= 57) && a <= i; )
    o = r.charCodeAt(++a);
  for (o = r.charCodeAt(i); (o === 32 || o >= 48 && o <= 57) && i >= a; )
    o = r.charCodeAt(--i);
  if (++i, a === i || a + 1 === i)
    return e1.TokenBuilder.add(e, a, i);
  if (o = r.charCodeAt(a), a + 2 === i) {
    var c = r.charCodeAt(a + 1);
    if ((o === 78 || o === 110) && (c === 65 || c === 97) || // NA na Na nA
    (o === 67 || o === 99) && (c === 76 || c === 108) || // CL
    (o === 70 || o === 102) && (c === 69 || c === 101) || // FE
    (o === 83 || o === 115) && (c === 73 || c === 105) || // SI
    (o === 66 || o === 98) && (c === 82 || c === 114) || // BR
    (o === 65 || o === 97) && (c === 83 || c === 115))
      return e1.TokenBuilder.add(e, a, a + 2);
  }
  if (o === 67 || o === 99 || // C c
  o === 72 || o === 104 || // H h
  o === 78 || o === 110 || // N n
  o === 79 || o === 111 || // O o
  o === 80 || o === 112 || // P p
  o === 83 || o === 115)
    return e1.TokenBuilder.add(e, a, a + 1);
  e1.TokenBuilder.add(e, a, a);
}
ls.guessElementSymbolTokens = rpe;
var tpe = /* @__PURE__ */ new Set(["NA", "CL", "FE", "SI", "BR", "AS", "LI"]), npe = /* @__PURE__ */ new Set(["C", "H", "N", "O", "P", "S", "F", "B"]), ape = /^[\s\d]+|[\s\d]+$/g;
function ipe(e, r) {
  e = e.replace(ape, "").toUpperCase();
  var t = e.length;
  if (t === 0 || t === 1 || tpe.has(e))
    return e;
  if (t === 3 && r === 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 npe.has(e[0]) ? e[0] : e;
}
ls.guessElementSymbolString = ipe;
Object.defineProperty(Ad, "__esModule", { value: !0 });
Ad.addAtom = Ad.getAtomSite = Ad.getAtomSiteTemplate = void 0;
var Nn = Vu, rt = Pi, yB = ls, _B = mr(), ope = Hi;
function upe(e, r) {
  var t = function() {
    return [];
  }, n = function() {
    return rt.TokenBuilder.create(e, 2 * r);
  };
  return {
    index: 0,
    group_PDB: n(),
    id: t(),
    auth_atom_id: n(),
    label_alt_id: n(),
    auth_comp_id: n(),
    auth_asym_id: n(),
    auth_seq_id: n(),
    pdbx_PDB_ins_code: n(),
    Cartn_x: n(),
    Cartn_y: n(),
    Cartn_z: n(),
    occupancy: n(),
    B_iso_or_equiv: n(),
    type_symbol: n(),
    pdbx_PDB_model_num: t(),
    label_entity_id: t(),
    partial_charge: n(),
    pdbx_formal_charge: n(),
    cdr: n(),
    em_confidence: n()
  };
}
Ad.getAtomSiteTemplate = upe;
function spe(e) {
  var r = Nn.CifField.ofTokens(e.auth_asym_id), t = Nn.CifField.ofTokens(e.auth_atom_id), n = Nn.CifField.ofTokens(e.auth_comp_id);
  return {
    auth_asym_id: r,
    auth_atom_id: t,
    auth_comp_id: n,
    auth_seq_id: Nn.CifField.ofTokens(e.auth_seq_id),
    B_iso_or_equiv: Nn.CifField.ofTokens(e.B_iso_or_equiv),
    Cartn_x: Nn.CifField.ofTokens(e.Cartn_x),
    Cartn_y: Nn.CifField.ofTokens(e.Cartn_y),
    Cartn_z: Nn.CifField.ofTokens(e.Cartn_z),
    group_PDB: Nn.CifField.ofTokens(e.group_PDB),
    id: Nn.CifField.ofStrings(e.id),
    label_alt_id: Nn.CifField.ofTokens(e.label_alt_id),
    label_asym_id: r,
    label_atom_id: t,
    label_comp_id: n,
    label_seq_id: Nn.CifField.ofUndefined(e.index, _B.Column.Schema.int),
    label_entity_id: Nn.CifField.ofStrings(e.label_entity_id),
    occupancy: (0, ope.areTokensEmpty)(e.occupancy) ? Nn.CifField.ofUndefined(e.index, _B.Column.Schema.float) : Nn.CifField.ofTokens(e.occupancy),
    type_symbol: Nn.CifField.ofTokens(e.type_symbol),
    pdbx_PDB_ins_code: Nn.CifField.ofTokens(e.pdbx_PDB_ins_code),
    pdbx_PDB_model_num: Nn.CifField.ofStrings(e.pdbx_PDB_model_num),
    partial_charge: Nn.CifField.ofTokens(e.partial_charge),
    pdbx_formal_charge: Nn.CifField.ofTokens(e.pdbx_formal_charge),
    cdr: Nn.CifField.ofTokens(e.cdr),
    em_confidence: Nn.CifField.ofTokens(e.em_confidence)
  };
}
Ad.getAtomSite = spe;
function lpe(e, r, t, n, a, i) {
  var o = t.data, c = a - n;
  rt.TokenBuilder.addToken(e.group_PDB, rt.Tokenizer.trim(t, n, n + 6)), rt.Tokenizer.trim(t, n + 6, n + 11), e.id[e.index] = t.data.substring(t.tokenStart, t.tokenEnd), rt.TokenBuilder.addToken(e.auth_atom_id, rt.Tokenizer.trim(t, n + 12, n + 16)), o.charCodeAt(n + 16) === 32 ? rt.TokenBuilder.add(e.label_alt_id, 0, 0) : rt.TokenBuilder.add(e.label_alt_id, n + 16, n + 17), rt.TokenBuilder.addToken(e.auth_comp_id, rt.Tokenizer.trim(t, n + 17, n + 20)), rt.TokenBuilder.add(e.auth_asym_id, n + 21, n + 22), rt.TokenBuilder.addToken(e.auth_seq_id, rt.Tokenizer.trim(t, n + 22, n + 26)), o.charCodeAt(n + 26) === 32 ? rt.TokenBuilder.add(e.pdbx_PDB_ins_code, 0, 0) : rt.TokenBuilder.add(e.pdbx_PDB_ins_code, n + 26, n + 27), rt.TokenBuilder.addToken(e.Cartn_x, rt.Tokenizer.trim(t, n + 30, n + 38)), rt.TokenBuilder.addToken(e.Cartn_y, rt.Tokenizer.trim(t, n + 38, n + 46)), rt.TokenBuilder.addToken(e.Cartn_z, rt.Tokenizer.trim(t, n + 46, n + 54)), rt.TokenBuilder.addToken(e.occupancy, rt.Tokenizer.trim(t, n + 54, n + 60)), c >= 66 ? rt.TokenBuilder.addToken(e.B_iso_or_equiv, rt.Tokenizer.trim(t, n + 60, n + 66)) : rt.TokenBuilder.add(e.B_iso_or_equiv, 0, 0), i && rt.TokenBuilder.addToken(e.partial_charge, rt.Tokenizer.trim(t, n + 70, n + 76)), c >= 78 && !i ? (rt.Tokenizer.trim(t, n + 76, n + 78), t.tokenStart < t.tokenEnd ? rt.TokenBuilder.addToken(e.type_symbol, t) : (0, yB.guessElementSymbolTokens)(e.type_symbol, o, n + 12, n + 16)) : (0, yB.guessElementSymbolTokens)(e.type_symbol, o, n + 12, n + 16), c >= 82 && rt.TokenBuilder.addToken(e.pdbx_formal_charge, rt.Tokenizer.trim(t, n + 78, n + 82)), c >= 84 && rt.TokenBuilder.addToken(e.cdr, rt.Tokenizer.trim(t, n + 82, n + 84)), c >= 90 && rt.TokenBuilder.addToken(e.em_confidence, rt.Tokenizer.trim(t, n + 84, n + 90)), e.pdbx_PDB_model_num[e.index] = r, e.index++;
}
Ad.addAtom = lpe;
var xd = {};
Object.defineProperty(xd, "__esModule", { value: !0 });
xd.addAnisotropic = xd.getAnisotropic = xd.getAnisotropicTemplate = void 0;
var ro = Vu, Fi = Pi, bB = ls, Cm = Qa;
function cpe(e, r) {
  var t = function() {
    return [];
  }, n = function() {
    return new Float32Array(r);
  }, a = function() {
    return Fi.TokenBuilder.create(e, 2 * r);
  };
  return {
    index: 0,
    count: r,
    id: t(),
    type_symbol: a(),
    pdbx_label_atom_id: a(),
    pdbx_label_alt_id: a(),
    pdbx_label_comp_id: a(),
    pdbx_label_asym_id: a(),
    pdbx_label_seq_id: a(),
    pdbx_PDB_ins_code: a(),
    "U[1][1]": n(),
    "U[2][2]": n(),
    "U[3][3]": n(),
    "U[1][2]": n(),
    "U[1][3]": n(),
    "U[2][3]": n(),
    pdbx_auth_seq_id: a(),
    pdbx_auth_comp_id: a(),
    pdbx_auth_asym_id: a(),
    pdbx_auth_atom_id: a()
  };
}
xd.getAnisotropicTemplate = cpe;
function dpe(e) {
  var r = ro.CifField.ofTokens(e.pdbx_auth_seq_id), t = ro.CifField.ofTokens(e.pdbx_auth_comp_id), n = ro.CifField.ofTokens(e.pdbx_auth_asym_id), a = ro.CifField.ofTokens(e.pdbx_auth_atom_id), i = {
    id: ro.CifField.ofStrings(e.id),
    type_symbol: ro.CifField.ofTokens(e.type_symbol),
    pdbx_label_atom_id: a,
    pdbx_label_alt_id: ro.CifField.ofTokens(e.pdbx_label_alt_id),
    pdbx_label_comp_id: t,
    pdbx_label_asym_id: n,
    pdbx_label_seq_id: r,
    pdbx_PDB_ins_code: ro.CifField.ofTokens(e.pdbx_PDB_ins_code),
    pdbx_auth_seq_id: r,
    pdbx_auth_comp_id: t,
    pdbx_auth_asym_id: n,
    pdbx_auth_atom_id: a
  };
  return i["U[1][1]"] = ro.CifField.ofNumbers(e["U[1][1]"]), i["U[2][2]"] = ro.CifField.ofNumbers(e["U[2][2]"]), i["U[3][3]"] = ro.CifField.ofNumbers(e["U[3][3]"]), i["U[1][2]"] = ro.CifField.ofNumbers(e["U[1][2]"]), i["U[1][3]"] = ro.CifField.ofNumbers(e["U[1][3]"]), i["U[2][3]"] = ro.CifField.ofNumbers(e["U[2][3]"]), i;
}
xd.getAnisotropic = dpe;
function fpe(e, r, t, n, a) {
  var i = t.data, o = a - n;
  Fi.Tokenizer.trim(t, n + 6, n + 11), e.id[e.index] = i.substring(t.tokenStart, t.tokenEnd), Fi.TokenBuilder.addToken(e.pdbx_auth_atom_id, Fi.Tokenizer.trim(t, n + 12, n + 16)), i.charCodeAt(n + 16) === 32 ? Fi.TokenBuilder.add(e.pdbx_label_alt_id, 0, 0) : Fi.TokenBuilder.add(e.pdbx_label_alt_id, n + 16, n + 17), Fi.TokenBuilder.addToken(e.pdbx_auth_comp_id, Fi.Tokenizer.trim(t, n + 17, n + 20)), Fi.TokenBuilder.add(e.pdbx_auth_asym_id, n + 21, n + 22), Fi.TokenBuilder.addToken(e.pdbx_auth_seq_id, Fi.Tokenizer.trim(t, n + 22, n + 26)), i.charCodeAt(n + 26) === 32 ? Fi.TokenBuilder.add(e.pdbx_PDB_ins_code, 0, 0) : Fi.TokenBuilder.add(e.pdbx_PDB_ins_code, n + 26, n + 27), e["U[1][1]"][e.index] = (0, Cm.parseIntSkipLeadingWhitespace)(i, n + 28, n + 35) / 1e4, e["U[2][2]"][e.index] = (0, Cm.parseIntSkipLeadingWhitespace)(i, n + 35, n + 42) / 1e4, e["U[3][3]"][e.index] = (0, Cm.parseIntSkipLeadingWhitespace)(i, n + 42, n + 49) / 1e4, e["U[1][2]"][e.index] = (0, Cm.parseIntSkipLeadingWhitespace)(i, n + 49, n + 56) / 1e4, e["U[1][3]"][e.index] = (0, Cm.parseIntSkipLeadingWhitespace)(i, n + 56, n + 63) / 1e4, e["U[2][3]"][e.index] = (0, Cm.parseIntSkipLeadingWhitespace)(i, n + 63, n + 70) / 1e4, o >= 78 ? (Fi.Tokenizer.trim(t, n + 76, n + 78), t.tokenStart < t.tokenEnd ? Fi.TokenBuilder.addToken(e.type_symbol, t) : (0, bB.guessElementSymbolTokens)(e.type_symbol, i, n + 12, n + 16)) : (0, bB.guessElementSymbolTokens)(e.type_symbol, i, n + 12, n + 16), e.index++;
}
xd.addAnisotropic = fpe;
var K4 = {};
Object.defineProperty(K4, "__esModule", { value: !0 });
K4.parseConect = void 0;
var Uu = Vu;
function mpe(e, r, t, n) {
  for (var a = {}, i = 0, o = n.id.rowCount; i < o; ++i)
    a[n.id.str(i)] = i;
  for (var c = function(x) {
    return e.data.substring(e.indices[2 * x], e.indices[2 * x + 1]);
  }, s = [], u = [], l = [], f = [], d = [], m = [], p = [], v = [], h = [], y = [], C = [11, 16, 21, 26], S = 1, i = r; i < t; i++) {
    var b = c(i), g = a[parseInt(b.substr(6, 5))], _ = {};
    if (g !== void 0)
      for (var A = 0; A < 4; ++A) {
        var M = parseInt(b.substr(C[A], 5));
        if (!Number.isNaN(M)) {
          var P = a[M];
          P !== void 0 && (g > P || _[P] === void 0 && (s.push("covale".concat(S)), u.push("covale"), l.push(n.label_asym_id.str(g)), d.push(n.auth_seq_id.int(g)), f.push(n.label_seq_id.int(g)), m.push(n.label_atom_id.str(g)), p.push(n.label_asym_id.str(P)), h.push(n.auth_seq_id.int(P)), v.push(n.label_seq_id.int(P)), y.push(n.label_atom_id.str(P)), S += 1));
        }
      }
  }
  var T = {
    id: Uu.CifField.ofStrings(s),
    conn_type_id: Uu.CifField.ofStrings(u),
    ptnr1_label_asym_id: Uu.CifField.ofStrings(l),
    ptnr1_auth_seq_id: Uu.CifField.ofNumbers(d),
    ptnr1_label_seq_id: Uu.CifField.ofNumbers(f),
    ptnr1_label_atom_id: Uu.CifField.ofStrings(m),
    ptnr2_label_asym_id: Uu.CifField.ofStrings(p),
    ptnr2_label_seq_id: Uu.CifField.ofNumbers(v),
    ptnr2_auth_seq_id: Uu.CifField.ofNumbers(h),
    ptnr2_label_atom_id: Uu.CifField.ofStrings(y)
  };
  return Uu.CifCategory.ofFields("struct_conn", T);
}
K4.parseConect = mpe;
Object.defineProperty($4, "__esModule", { value: !0 });
$4.pdbToMmCif = void 0;
var SB = Te, Vn = cs, L2 = Vu, vpe = Pi, vT = Cd, CB = Gv, AB = qv, ppe = yl, hpe = _l, k2 = mr(), gpe = Gr, U2 = Ad, pT = xd, ype = K4, _pe = Zt;
function bpe(e) {
  return (0, SB.__awaiter)(this, void 0, void 0, function() {
    var r, t, n, a, i, o, c, P, h, y, C, s, u, l, f, d, m, p, v, P, h, y, C, S, S, S, S, S, S, S, b, g, _, A, M, P, T, x, w, E, I, B, D, N;
    return (0, SB.__generator)(this, function(O) {
      for (r = e.lines, t = r.data, n = r.indices, a = (0, vpe.Tokenizer)(t), i = !!e.isPdbqt, o = 0, c = 0, P = 0, h = r.count; P < h; P++)
        switch (y = n[2 * P], C = n[2 * P + 1], t[y]) {
          case "A":
            (0, Vn.substringStartsWith)(t, y, C, "ATOM  ") ? o++ : (0, Vn.substringStartsWith)(t, y, C, "ANISOU") && c++;
            break;
          case "H":
            (0, Vn.substringStartsWith)(t, y, C, "HETATM") && o++;
            break;
        }
      for (s = (0, U2.getAtomSiteTemplate)(t, o), u = (0, pT.getAnisotropicTemplate)(t, c), l = new hpe.EntityBuilder(), f = [], d = [], m = 0, p = "", v = void 0, P = 0, h = r.count; P < h; P++)
        switch (y = n[2 * P], C = n[2 * P + 1], t[y]) {
          case "A":
            (0, Vn.substringStartsWith)(t, y, C, "ATOM  ") ? (m || (m++, p = "" + m), (0, U2.addAtom)(s, p, a, y, C, i)) : (0, Vn.substringStartsWith)(t, y, C, "ANISOU") && (0, pT.addAnisotropic)(u, p, a, y, C);
            break;
          case "C":
            if ((0, Vn.substringStartsWith)(t, y, C, "CRYST1"))
              f.push.apply(f, (0, vT.parseCryst1)(e.id || "?", t.substring(y, C)));
            else if ((0, Vn.substringStartsWith)(t, y, C, "CONECT")) {
              for (S = P + 1; y = n[2 * S], C = n[2 * S + 1], !!(0, Vn.substringStartsWith)(t, y, C, "CONECT"); )
                S++;
              v ? _pe.isDebugMode && console.log("only single CONECT block allowed, ignoring others") : v = [P, S], P = S - 1;
            } else if ((0, Vn.substringStartsWith)(t, y, C, "COMPND")) {
              for (S = P + 1; y = n[2 * S], C = n[2 * S + 1], !!(0, Vn.substringStartsWith)(t, y, C, "COMPND"); )
                S++;
              l.setCompounds((0, AB.parseCmpnd)(r, P, S)), P = S - 1;
            }
            break;
          case "H":
            if ((0, Vn.substringStartsWith)(t, y, C, "HETATM"))
              m || (m++, p = "" + m), (0, U2.addAtom)(s, p, a, y, C, i);
            else if ((0, Vn.substringStartsWith)(t, y, C, "HELIX")) {
              for (S = P + 1; y = n[2 * S], C = n[2 * S + 1], !!(0, Vn.substringStartsWith)(t, y, C, "HELIX"); )
                S++;
              f.push((0, CB.parseHelix)(r, P, S)), P = S - 1;
            } else if ((0, Vn.substringStartsWith)(t, y, C, "HETNAM")) {
              for (S = P + 1; y = n[2 * S], C = n[2 * S + 1], !!(0, Vn.substringStartsWith)(t, y, C, "HETNAM"); )
                S++;
              d.push.apply(d, Array.from((0, AB.parseHetnam)(r, P, S).entries())), P = S - 1;
            }
            break;
          case "M":
            if ((0, Vn.substringStartsWith)(t, y, C, "MODEL ") && (m++, p = "" + m), (0, Vn.substringStartsWith)(t, y, C, "MTRIX")) {
              for (S = P + 1; y = n[2 * S], C = n[2 * S + 1], !!(0, Vn.substringStartsWith)(t, y, C, "MTRIX"); )
                S++;
              f.push.apply(f, (0, vT.parseMtrix)(r, P, S)), P = S - 1;
            }
            break;
          case "O":
            break;
          case "R":
            if ((0, Vn.substringStartsWith)(t, y, C, "REMARK 350")) {
              for (S = P + 1; y = n[2 * S], C = n[2 * S + 1], !!(0, Vn.substringStartsWith)(t, y, C, "REMARK 350"); )
                S++;
              f.push.apply(f, (0, vT.parseRemark350)(r, P, S)), P = S - 1;
            }
            break;
          case "S":
            if ((0, Vn.substringStartsWith)(t, y, C, "SHEET")) {
              for (S = P + 1; y = n[2 * S], C = n[2 * S + 1], !!(0, Vn.substringStartsWith)(t, y, C, "SHEET"); )
                S++;
              f.push((0, CB.parseSheet)(r, P, S)), P = S - 1;
            }
            break;
        }
      for (b = k2.Column.ofIntTokens(s.auth_seq_id), g = k2.Column.ofStringTokens(s.auth_atom_id), _ = k2.Column.ofStringTokens(s.auth_comp_id), A = k2.Column.ofStringTokens(s.auth_asym_id), M = new ppe.ComponentBuilder(b, g), M.setNames(d), l.setNames(d), P = 0, T = _.rowCount; P < T; ++P)
        x = _.value(P), w = (0, gpe.getMoleculeType)(M.add(x, P).type, x), s.label_entity_id[P] = l.getEntityId(x, w, A.value(P));
      for (E = (0, U2.getAtomSite)(s), v && f.push((0, ype.parseConect)(r, v[0], v[1], E)), I = {
        entity: L2.CifCategory.ofTable("entity", l.getEntityTable()),
        chem_comp: L2.CifCategory.ofTable("chem_comp", M.getChemCompTable()),
        atom_site: L2.CifCategory.ofFields("atom_site", E),
        atom_site_anisotrop: L2.CifCategory.ofFields("atom_site_anisotrop", (0, pT.getAnisotropic)(u))
      }, B = 0, D = f; B < D.length; B++)
        N = D[B], I[N.name] = N;
      return [2, {
        header: e.id || "PDB",
        categoryNames: Object.keys(I),
        categories: I
      }];
    });
  });
}
$4.pdbToMmCif = bpe;
Object.defineProperty(p0, "__esModule", { value: !0 });
p0.trajectoryFromPDB = p0.PdbFormat = void 0;
var xB = Te, Spe = $4, Cpe = Kr, Ape = Jo(), xpe = xc(), z2 = mr(), Tpe = Wd, Ppe = Zo, Jb;
(function(e) {
  function r(n) {
    return (n == null ? void 0 : n.kind) === "pdb";
  }
  e.is = r;
  function t(n) {
    return { kind: "pdb", name: n.id || "", data: n };
  }
  e.create = t;
})(Jb || (Jb = {}));
p0.PdbFormat = Jb;
function Mpe(e) {
  var r = this;
  return Cpe.Task.create("Parse PDB", function(t) {
    return (0, xB.__awaiter)(r, void 0, void 0, function() {
      var n, a, i, o, c, s, u, l, f, d, m, p;
      return (0, xB.__generator)(this, function(v) {
        switch (v.label) {
          case 0:
            return [4, t.update("Converting to mmCIF")];
          case 1:
            return v.sent(), [4, (0, Spe.pdbToMmCif)(e)];
          case 2:
            return n = v.sent(), a = Ape.MmcifFormat.fromFrame(n, void 0, Jb.create(e)), i = (0, Ppe.createBasic)(a.data.db, !0), [4, (0, xpe.createModels)(i, a, t)];
          case 3:
            return o = v.sent(), c = (p = n.categories.atom_site) === null || p === void 0 ? void 0 : p.getField("partial_charge"), c && o.frameCount === 1 && (s = o.representative, u = s.atomicHierarchy.atomSourceIndex, l = z2.Column.isIdentity(u), f = l ? void 0 : u.toArray({ array: Int32Array }), d = c.toFloatArray(), m = f ? z2.Column.ofFloatArray(z2.Column.mapToArray(u, function(h) {
              return d[h];
            }, Float32Array)) : z2.Column.ofFloatArray(d), Tpe.AtomPartialCharge.Provider.set(s, {
              data: m,
              type: "GASTEIGER"
              // from PDBQT
            })), [2, o];
        }
      });
    });
  });
}
p0.trajectoryFromPDB = Mpe;
var TB;
function wpe() {
  if (TB) return Zh;
  TB = 1, Object.defineProperty(Zh, "__esModule", { value: !0 }), Zh.PdbModel = void 0;
  var e = Te, r = Ty, t = p0, n = gn(), a = sn();
  return Zh.PdbModel = {
    parse: function(i) {
      return (0, e.__awaiter)(this, void 0, void 0, function() {
        var o, c;
        return (0, e.__generator)(this, function(s) {
          switch (s.label) {
            case 0:
              return i.trim() ? [4, (0, r.parsePDB)(i).run()] : [2, [(0, a.createEmptyStructure)()]];
            case 1:
              if (o = s.sent(), o.isError)
                throw o;
              return [4, (0, t.trajectoryFromPDB)(o.result).run()];
            case 2:
              return c = s.sent(), [2, c.frames.map(function(u) {
                return n.Structure.ofModel(u, { dynamicBonds: !0 });
              })];
          }
        });
      });
    }
  }, Zh;
}
var r1 = {}, ma = {};
Object.defineProperty(ma, "__esModule", { value: !0 });
ma.parseMolText = ma.parseMol = ma.handlePropertiesBlock = ma.handleFormalCharges = ma.handleBonds = ma.handleAtoms = ma.formalChargeMapper = void 0;
var PB = Te, Hs = mr(), Epe = Kr, rd = Hi, Dr = Pi, Dpe = Mi;
function Ipe(e) {
  switch (e) {
    case 7:
      return -3;
    case 6:
      return -2;
    case 5:
      return -1;
    case 0:
      return 0;
    case 3:
      return 1;
    case 2:
      return 2;
    case 1:
      return 3;
    case 4:
      return 0;
    default:
      return console.error("Value ".concat(e, " is outside the 0-7 range, defaulting to 0.")), 0;
  }
}
ma.formalChargeMapper = Ipe;
function JE(e, r) {
  for (var t = Dr.TokenBuilder.create(e.data, r * 2), n = Dr.TokenBuilder.create(e.data, r * 2), a = Dr.TokenBuilder.create(e.data, r * 2), i = Dr.TokenBuilder.create(e.data, r * 2), o = Dr.TokenBuilder.create(e.data, r * 2), c = 0; c < r; ++c) {
    Dr.Tokenizer.markLine(e);
    var s = e.tokenStart, u = e.position;
    Dr.Tokenizer.trim(e, s, s + 10), Dr.TokenBuilder.addUnchecked(t, e.tokenStart, e.tokenEnd), Dr.Tokenizer.trim(e, s + 10, s + 20), Dr.TokenBuilder.addUnchecked(n, e.tokenStart, e.tokenEnd), Dr.Tokenizer.trim(e, s + 20, s + 30), Dr.TokenBuilder.addUnchecked(a, e.tokenStart, e.tokenEnd), Dr.Tokenizer.trim(e, s + 31, s + 34), Dr.TokenBuilder.addUnchecked(i, e.tokenStart, e.tokenEnd), Dr.Tokenizer.trim(e, s + 36, s + 39), Dr.TokenBuilder.addUnchecked(o, e.tokenStart, e.tokenEnd), e.position = u;
  }
  return {
    count: r,
    x: (0, rd.TokenColumnProvider)(t)(Hs.Column.Schema.float),
    y: (0, rd.TokenColumnProvider)(n)(Hs.Column.Schema.float),
    z: (0, rd.TokenColumnProvider)(a)(Hs.Column.Schema.float),
    type_symbol: (0, rd.TokenColumnProvider)(i)(Hs.Column.Schema.str),
    formal_charge: (0, rd.TokenColumnProvider)(o)(Hs.Column.Schema.int)
  };
}
ma.handleAtoms = JE;
function eD(e, r) {
  for (var t = Dr.TokenBuilder.create(e.data, r * 2), n = Dr.TokenBuilder.create(e.data, r * 2), a = Dr.TokenBuilder.create(e.data, r * 2), i = 0; i < r; ++i) {
    Dr.Tokenizer.markLine(e);
    var o = e.tokenStart, c = e.position;
    Dr.Tokenizer.trim(e, o, o + 3), Dr.TokenBuilder.addUnchecked(t, e.tokenStart, e.tokenEnd), Dr.Tokenizer.trim(e, o + 3, o + 6), Dr.TokenBuilder.addUnchecked(n, e.tokenStart, e.tokenEnd), Dr.Tokenizer.trim(e, o + 6, o + 9), Dr.TokenBuilder.addUnchecked(a, e.tokenStart, e.tokenEnd), e.position = c;
  }
  return {
    count: r,
    atomIdxA: (0, rd.TokenColumnProvider)(t)(Hs.Column.Schema.int),
    atomIdxB: (0, rd.TokenColumnProvider)(n)(Hs.Column.Schema.int),
    order: (0, rd.TokenColumnProvider)(a)(Hs.Column.Schema.int)
  };
}
ma.handleBonds = eD;
function KH(e, r, t) {
  Dr.Tokenizer.trim(e, r + 6, r + 9);
  for (var n = parseInt(Dr.Tokenizer.getTokenString(e)), a = 0; a < n; ++a) {
    var i = 9 + a * 8;
    Dr.Tokenizer.trim(e, r + i, r + i + 4);
    var o = Dr.Tokenizer.getTokenString(e);
    t.atomIdx.push(+o), Dr.Tokenizer.trim(e, r + i + 4, r + i + 8);
    var c = Dr.Tokenizer.getTokenString(e);
    t.charge.push(+c);
  }
  Dr.Tokenizer.eatLine(e);
}
ma.handleFormalCharges = KH;
function rD(e) {
  for (var r = [], t = [], n = {
    atomIdx: r,
    charge: t
  }; e.position < e.length; ) {
    var a = e.position;
    Dr.Tokenizer.trim(e, a + 3, a + 6);
    var i = Dr.Tokenizer.getTokenString(e);
    if (i === "END")
      break;
    switch (Dr.Tokenizer.eatLine(e), i) {
      case "CHG":
        KH(e, a, n);
        break;
    }
  }
  var o = {
    atomIdx: Hs.Column.ofIntArray(n.atomIdx),
    charge: Hs.Column.ofIntArray(n.charge)
  };
  return o;
}
ma.handlePropertiesBlock = rD;
function Bpe(e) {
  var r = (0, Dr.Tokenizer)(e), t = Dr.Tokenizer.readLine(r).trim(), n = Dr.Tokenizer.readLine(r).trim(), a = Dr.Tokenizer.readLine(r).trim(), i = Dr.Tokenizer.readLine(r), o = +i.substr(0, 3), c = +i.substr(3, 3), s = JE(r, o), u = eD(r, c), l = rD(r), f = {
    title: t,
    program: n,
    comment: a,
    atoms: s,
    bonds: u,
    formalCharges: l
  };
  return Dpe.ReaderResult.success(f);
}
function Npe(e) {
  var r = this;
  return Epe.Task.create("Parse Mol", function() {
    return (0, PB.__awaiter)(r, void 0, void 0, function() {
      return (0, PB.__generator)(this, function(t) {
        return [2, Bpe(e)];
      });
    });
  });
}
ma.parseMol = Npe;
function Vpe(e) {
  var r = (0, Dr.Tokenizer)(e), t = Dr.Tokenizer.readLine(r).trim(), n = Dr.Tokenizer.readLine(r).trim(), a = Dr.Tokenizer.readLine(r).trim(), i = Dr.Tokenizer.readLine(r), o = +i.substr(0, 3), c = +i.substr(3, 3), s = JE(r, o), u = eD(r, c), l = rD(r), f = {
    title: t,
    program: n,
    comment: a,
    atoms: s,
    bonds: u,
    formalCharges: l
  };
  return f;
}
ma.parseMolText = Vpe;
var ac = {};
Object.defineProperty(ac, "__esModule", { value: !0 });
ac.trajectoryFromMol = ac.MolFormat = ac.getMolModels = void 0;
var MB = Te, dn = mr(), Rpe = ma, Ope = Kr, Fpe = xc(), wB = Zo, Lpe = yl, kpe = _l, EB = Cc;
function WH(e, r, t) {
  return (0, MB.__awaiter)(this, void 0, void 0, function() {
    var n, a, i, o, c, s, u, l, f, f, d, m, p, v, h, y, C, S, b;
    return (0, MB.__generator)(this, function(g) {
      switch (g.label) {
        case 0:
          if (n = e.atoms, a = e.bonds, i = e.formalCharges, o = dn.Column.ofConst("MOL", e.atoms.count, dn.Column.Schema.str), c = dn.Column.ofConst("A", e.atoms.count, dn.Column.Schema.str), s = dn.Column.asArrayColumn(n.type_symbol), u = dn.Column.ofConst(1, n.count, dn.Column.Schema.int), l = new Int32Array(e.atoms.count), i.atomIdx.rowCount > 0)
            for (f = 0; f < i.atomIdx.rowCount; f++)
              l[i.atomIdx.value(f) - 1] = i.charge.value(f);
          else
            for (f = 0; f < e.atoms.count; f++)
              l[f] = (0, Rpe.formalChargeMapper)(n.formal_charge.value(f));
          return d = dn.Table.ofPartialColumns(wB.BasicSchema.atom_site, {
            auth_asym_id: c,
            auth_atom_id: s,
            auth_comp_id: o,
            auth_seq_id: u,
            Cartn_x: dn.Column.asArrayColumn(n.x, Float32Array),
            Cartn_y: dn.Column.asArrayColumn(n.y, Float32Array),
            Cartn_z: dn.Column.asArrayColumn(n.z, Float32Array),
            id: dn.Column.range(0, n.count - 1),
            label_asym_id: c,
            label_atom_id: s,
            label_comp_id: o,
            label_seq_id: u,
            label_entity_id: dn.Column.ofConst("1", n.count, dn.Column.Schema.str),
            occupancy: dn.Column.ofConst(1, n.count, dn.Column.Schema.float),
            type_symbol: s,
            pdbx_PDB_model_num: dn.Column.ofConst(1, n.count, dn.Column.Schema.int),
            pdbx_formal_charge: dn.Column.ofIntArray(l)
          }, n.count), m = new kpe.EntityBuilder(), m.setNames([["MOL", "Ligand"]]), m.getEntityId("MOL", 0, "A"), p = new Lpe.ComponentBuilder(u, s), p.setNames([["MOL", "Unknown Molecule"]]), p.add("MOL", 0), v = (0, wB.createBasic)({
            entity: m.getEntityTable(),
            chem_comp: p.getChemCompTable(),
            atom_site: d
          }), [4, (0, Fpe.createModels)(v, r ?? e3.create(e), t)];
        case 1:
          return h = g.sent(), h.frameCount > 0 && (y = dn.Column.ofIntArray(dn.Column.mapToArray(a.atomIdxA, function(_) {
            return _ - 1;
          }, Int32Array)), C = dn.Column.ofIntArray(dn.Column.mapToArray(a.atomIdxB, function(_) {
            return _ - 1;
          }, Int32Array)), S = dn.Column.asArrayColumn(a.order, Int32Array), b = EB.IndexPairBonds.fromData({
            pairs: { indexA: y, indexB: C, order: S },
            count: n.count
          }), EB.IndexPairBonds.Provider.set(h.representative, b)), [2, h];
      }
    });
  });
}
ac.getMolModels = WH;
var e3;
(function(e) {
  function r(n) {
    return (n == null ? void 0 : n.kind) === "mol";
  }
  e.is = r;
  function t(n) {
    return { kind: "mol", name: n.title, data: n };
  }
  e.create = t;
})(e3 || (e3 = {}));
ac.MolFormat = e3;
function Upe(e) {
  return Ope.Task.create("Parse MOL", function(r) {
    return WH(e, void 0, r);
  });
}
ac.trajectoryFromMol = Upe;
var DB;
function zpe() {
  if (DB) return r1;
  DB = 1, Object.defineProperty(r1, "__esModule", { value: !0 }), r1.MolModel = void 0;
  var e = Te, r = gn(), t = ma, n = ac, a = sn();
  return r1.MolModel = {
    parse: function(i) {
      return (0, e.__awaiter)(this, void 0, void 0, function() {
        var o, c;
        return (0, e.__generator)(this, function(s) {
          switch (s.label) {
            case 0:
              return i.trim() ? [4, (0, t.parseMol)(i).run()] : [2, [(0, a.createEmptyStructure)()]];
            case 1:
              if (o = s.sent(), o.isError)
                throw o;
              return [4, (0, n.trajectoryFromMol)(o.result).run()];
            case 2:
              return c = s.sent(), [2, [r.Structure.ofModel(c.representative)]];
          }
        });
      });
    }
  }, r1;
}
var t1 = {}, Hv = {}, Xs = {};
Object.defineProperty(Xs, "__esModule", { value: !0 });
Xs.handleBondsV3 = Xs.handleAtomsV3 = Xs.handleCountsV3 = Xs.isV3 = void 0;
var $u = mr(), En = Pi, Xl = Hi;
function Gpe(e) {
  return e.trim().endsWith("V3000");
}
Xs.isV3 = Gpe;
function qpe(e) {
  var r = En.TokenBuilder.create(e.data, 1), t = En.TokenBuilder.create(e.data, 1);
  return En.Tokenizer.eatLine(e), ic(e), ic(e), ic(e), Yl(e, r), Yl(e, t), En.Tokenizer.eatLine(e), {
    atomCount: (0, Xl.TokenColumnProvider)(r)($u.Column.Schema.int).value(0),
    bondCount: (0, Xl.TokenColumnProvider)(t)($u.Column.Schema.int).value(0)
  };
}
Xs.handleCountsV3 = qpe;
function Hpe(e, r) {
  for (var t = En.TokenBuilder.create(e.data, r * 2), n = En.TokenBuilder.create(e.data, r * 2), a = En.TokenBuilder.create(e.data, r * 2), i = En.TokenBuilder.create(e.data, r * 2), o = 0; o < r; ++o) {
    En.Tokenizer.markLine(e), ic(e), ic(e), ic(e);
    var c = e.position;
    Yl(e, i), Yl(e, t), Yl(e, n), Yl(e, a), e.position = c;
  }
  return En.Tokenizer.eatLine(e), En.Tokenizer.eatLine(e), {
    count: r,
    x: (0, Xl.TokenColumnProvider)(t)($u.Column.Schema.float),
    y: (0, Xl.TokenColumnProvider)(n)($u.Column.Schema.float),
    z: (0, Xl.TokenColumnProvider)(a)($u.Column.Schema.float),
    type_symbol: (0, Xl.TokenColumnProvider)(i)($u.Column.Schema.str),
    /* No support for formal charge parsing in V3000 molfiles at the moment,
    so all charges default to 0.*/
    formal_charge: $u.Column.ofConst(0, r, $u.Column.Schema.int)
  };
}
Xs.handleAtomsV3 = Hpe;
function jpe(e, r) {
  for (var t = En.TokenBuilder.create(e.data, r * 2), n = En.TokenBuilder.create(e.data, r * 2), a = En.TokenBuilder.create(e.data, r * 2), i = 0; i < r; ++i) {
    En.Tokenizer.markLine(e), ic(e), ic(e), ic(e);
    var o = e.position;
    Yl(e, a), Yl(e, t), Yl(e, n), e.position = o;
  }
  return En.Tokenizer.eatLine(e), En.Tokenizer.eatLine(e), {
    count: r,
    atomIdxA: (0, Xl.TokenColumnProvider)(t)($u.Column.Schema.float),
    atomIdxB: (0, Xl.TokenColumnProvider)(n)($u.Column.Schema.float),
    order: (0, Xl.TokenColumnProvider)(a)($u.Column.Schema.float)
  };
}
Xs.handleBondsV3 = jpe;
function ic(e) {
  En.Tokenizer.skipWhitespace(e), En.Tokenizer.eatValue(e);
}
function Yl(e, r) {
  var t = e.position;
  En.Tokenizer.skipWhitespace(e), En.Tokenizer.eatValue(e), En.Tokenizer.trim(e, t, e.position), En.TokenBuilder.addUnchecked(r, e.tokenStart, e.tokenEnd);
}
Object.defineProperty(Hv, "__esModule", { value: !0 });
Hv.parseSdf = Hv.parseInternal = void 0;
var IB = Te, ev = mr(), hT = ma, $pe = Kr, Kpe = Mi, io = Pi, BB = Hi, G2 = Xs, YM = "$$$$";
function Wpe(e) {
  for (var r = io.TokenBuilder.create(e.data, 32), t = io.TokenBuilder.create(e.data, 32); e.position < e.length; ) {
    var n = io.Tokenizer.readLine(e);
    if (n.startsWith(YM))
      break;
    if (n && n.startsWith("> ")) {
      io.TokenBuilder.add(r, e.tokenStart + 2, e.tokenEnd), io.Tokenizer.markLine(e);
      for (var a = e.tokenStart, i = e.tokenEnd, o = !1; e.position < e.length; ) {
        var c = io.Tokenizer.readLine(e);
        if (!c || c.startsWith(YM) || c.startsWith("> ")) {
          io.TokenBuilder.add(t, a, i), o = !0;
          break;
        }
        i = e.tokenEnd;
      }
      o || io.TokenBuilder.add(t, a, i);
    }
  }
  return {
    dataHeader: (0, BB.TokenColumnProvider)(r)(ev.Column.Schema.str),
    data: (0, BB.TokenColumnProvider)(t)(ev.Column.Schema.str)
  };
}
function Xpe(e) {
  return {
    atomCount: +e.substr(0, 3),
    bondCount: +e.substr(3, 3)
  };
}
function Ype(e) {
  var r = io.Tokenizer.readLine(e).trim(), t = io.Tokenizer.readLine(e).trim(), n = io.Tokenizer.readLine(e).trim(), a = io.Tokenizer.readLine(e), i = (0, G2.isV3)(a), o = i ? (0, G2.handleCountsV3)(e) : Xpe(a), c = o.atomCount, s = o.bondCount;
  if (Number.isNaN(c) || Number.isNaN(s)) {
    for (; e.position < e.length; ) {
      var u = io.Tokenizer.readLine(e);
      if (u.startsWith(YM))
        break;
    }
    return;
  }
  var l = {
    atomIdx: ev.Column.ofConst(0, c, ev.Column.Schema.int),
    charge: ev.Column.ofConst(0, c, ev.Column.Schema.int)
  }, f = i ? (0, G2.handleAtomsV3)(e, c) : (0, hT.handleAtoms)(e, c), d = i ? (0, G2.handleBondsV3)(e, s) : (0, hT.handleBonds)(e, s), m = i ? l : (0, hT.handlePropertiesBlock)(e), p = Wpe(e);
  return {
    molFile: { title: r, program: t, comment: n, atoms: f, bonds: d, formalCharges: m },
    dataItems: p
  };
}
function XH(e) {
  for (var r = (0, io.Tokenizer)(e), t = []; r.position < r.length; ) {
    var n = Ype(r);
    n && t.push(n);
  }
  return Kpe.ReaderResult.success({ compounds: t });
}
Hv.parseInternal = XH;
function Qpe(e) {
  var r = this;
  return $pe.Task.create("Parse Sdf", function() {
    return (0, IB.__awaiter)(r, void 0, void 0, function() {
      return (0, IB.__generator)(this, function(t) {
        return [2, XH(e)];
      });
    });
  });
}
Hv.parseSdf = Qpe;
var jv = {};
Object.defineProperty(jv, "__esModule", { value: !0 });
jv.trajectoryFromSdf = jv.SdfFormat = void 0;
var Zpe = Kr, Jpe = ac, r3;
(function(e) {
  function r(n) {
    return (n == null ? void 0 : n.kind) === "sdf";
  }
  e.is = r;
  function t(n) {
    return { kind: "sdf", name: n.molFile.title, data: n };
  }
  e.create = t;
})(r3 || (r3 = {}));
jv.SdfFormat = r3;
function ehe(e) {
  return Zpe.Task.create("Parse SDF", function(r) {
    return (0, Jpe.getMolModels)(e.molFile, r3.create(e), r);
  });
}
jv.trajectoryFromSdf = ehe;
var gT = {}, YH = {};
(function(e) {
  (function() {
    var r = {
      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(c) {
      return a(o(c), arguments);
    }
    function n(c, s) {
      return t.apply(null, [c].concat(s || []));
    }
    function a(c, s) {
      var u = 1, l = c.length, f, d = "", m, p, v, h, y, C, S, b;
      for (m = 0; m < l; m++)
        if (typeof c[m] == "string")
          d += c[m];
        else if (typeof c[m] == "object") {
          if (v = c[m], v.keys)
            for (f = s[u], p = 0; p < v.keys.length; p++) {
              if (f == null)
                throw new Error(t('[sprintf] Cannot access property "%s" of undefined value "%s"', v.keys[p], v.keys[p - 1]));
              f = f[v.keys[p]];
            }
          else v.param_no ? f = s[v.param_no] : f = s[u++];
          if (r.not_type.test(v.type) && r.not_primitive.test(v.type) && f instanceof Function && (f = f()), r.numeric_arg.test(v.type) && typeof f != "number" && isNaN(f))
            throw new TypeError(t("[sprintf] expecting number but found %T", f));
          switch (r.number.test(v.type) && (S = f >= 0), v.type) {
            case "b":
              f = parseInt(f, 10).toString(2);
              break;
            case "c":
              f = String.fromCharCode(parseInt(f, 10));
              break;
            case "d":
            case "i":
              f = parseInt(f, 10);
              break;
            case "j":
              f = JSON.stringify(f, null, v.width ? parseInt(v.width) : 0);
              break;
            case "e":
              f = v.precision ? parseFloat(f).toExponential(v.precision) : parseFloat(f).toExponential();
              break;
            case "f":
              f = v.precision ? parseFloat(f).toFixed(v.precision) : parseFloat(f);
              break;
            case "g":
              f = v.precision ? String(Number(f.toPrecision(v.precision))) : parseFloat(f);
              break;
            case "o":
              f = (parseInt(f, 10) >>> 0).toString(8);
              break;
            case "s":
              f = String(f), f = v.precision ? f.substring(0, v.precision) : f;
              break;
            case "t":
              f = String(!!f), f = v.precision ? f.substring(0, v.precision) : f;
              break;
            case "T":
              f = Object.prototype.toString.call(f).slice(8, -1).toLowerCase(), f = v.precision ? f.substring(0, v.precision) : f;
              break;
            case "u":
              f = parseInt(f, 10) >>> 0;
              break;
            case "v":
              f = f.valueOf(), f = v.precision ? f.substring(0, v.precision) : f;
              break;
            case "x":
              f = (parseInt(f, 10) >>> 0).toString(16);
              break;
            case "X":
              f = (parseInt(f, 10) >>> 0).toString(16).toUpperCase();
              break;
          }
          r.json.test(v.type) ? d += f : (r.number.test(v.type) && (!S || v.sign) ? (b = S ? "+" : "-", f = f.toString().replace(r.sign, "")) : b = "", y = v.pad_char ? v.pad_char === "0" ? "0" : v.pad_char.charAt(1) : " ", C = v.width - (b + f).length, h = v.width && C > 0 ? y.repeat(C) : "", d += v.align ? b + f + h : y === "0" ? b + h + f : h + b + f);
        }
      return d;
    }
    var i = /* @__PURE__ */ Object.create(null);
    function o(c) {
      if (i[c])
        return i[c];
      for (var s = c, u, l = [], f = 0; s; ) {
        if ((u = r.text.exec(s)) !== null)
          l.push(u[0]);
        else if ((u = r.modulo.exec(s)) !== null)
          l.push("%");
        else if ((u = r.placeholder.exec(s)) !== null) {
          if (u[2]) {
            f |= 1;
            var d = [], m = u[2], p = [];
            if ((p = r.key.exec(m)) !== null)
              for (d.push(p[1]); (m = m.substring(p[0].length)) !== ""; )
                if ((p = r.key_access.exec(m)) !== null)
                  d.push(p[1]);
                else if ((p = r.index_access.exec(m)) !== null)
                  d.push(p[1]);
                else
                  throw new SyntaxError("[sprintf] failed to parse named argument key");
            else
              throw new SyntaxError("[sprintf] failed to parse named argument key");
            u[2] = d;
          } else
            f |= 2;
          if (f === 3)
            throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");
          l.push(
            {
              placeholder: u[0],
              param_no: u[1],
              keys: u[2],
              sign: u[3],
              pad_char: u[4],
              align: u[5],
              width: u[6],
              precision: u[7],
              type: u[8]
            }
          );
        } else
          throw new SyntaxError("[sprintf] unexpected placeholder");
        s = s.substring(u[0].length);
      }
      return i[c] = l;
    }
    e.sprintf = t, e.vsprintf = n, typeof window < "u" && (window.sprintf = t, window.vsprintf = n);
  })();
})(YH);
var NB;
function zp() {
  return NB || (NB = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.checkFileFormat = e.molValidate = e.pdbValidate = e.splitSdfContent = e.splitPdbContent = e.splitMolecularContent = e.getMergedStructureContent = e.getDefaultAtomData = e.atomDataToSdf = e.parseToSdf = e.atomDataToPdb = e.parseToPDB = e.getPDBSectionLine = e.MIME = void 0;
    var r = Te, t = YH, n = Wd, a = kp, i = Hp(), o = Jt, c = ZE, s = Up, u;
    (function(x) {
      x.PDB = "chemical/pdb", x.SDF = "chemical/x-mdl-sdf", x.MOL = "chemical/x-mdl-molfile", x.MOL2 = "chemical/x-mol2";
    })(u = e.MIME || (e.MIME = {}));
    var l = [
      "HEADER",
      "SOURCE",
      "AUTHOR",
      "OBSLTE",
      "KEYWDS",
      "REVDAT",
      "TITLE",
      "EXPDTA",
      "SPRSDE",
      "SPLT",
      "NUMMDL",
      "JRNL",
      "CAVEAT",
      "MDLTYP",
      "REMARKS",
      "COMPND"
    ], f = [
      "DBREF",
      "DBREF1",
      "DBREF2",
      "SEQADV",
      "SEQRES",
      "MODRES"
    ], d = ["HET   ", "HETNAM", "HETSYN", "FORMUL"], m = function(x, w) {
      var E = (0, i.getModelByStructure)(x);
      if ((E == null ? void 0 : E.sourceData.kind) === "mmCIF") {
        var I = E.sourceData.data.source.data.lines.data.split(`
`);
        return I.filter(function(B) {
          for (var D = 0, N = w.length; D < N; D++)
            if (B.startsWith(w[D]))
              return !0;
          return !1;
        });
      }
      return [];
    };
    e.getPDBSectionLine = m;
    function p(x, w, E, I) {
      var B, D = [];
      if (((B = x.models[0]) === null || B === void 0 ? void 0 : B.sourceData.kind) === "mmCIF") {
        var N = (0, r.__spreadArray)((0, r.__spreadArray)((0, r.__spreadArray)([], l, !0), f, !0), d, !0);
        D.push.apply(D, (0, e.getPDBSectionLine)(x, N));
      }
      var O = [];
      w ? O.push.apply(O, (0, r.__spreadArray)([], w, !0).sort(function(H, q) {
        return H - q;
      })) : x.units.forEach(function(H) {
        return O.push.apply(O, (0, r.__spreadArray)([], H.elements, !0));
      });
      var V = x.units[0], k = [], G = !1, L = !1;
      if (O.forEach(function(H) {
        var q = {
          elementId: H,
          group_PDB: V.model.atomicHierarchy.residues.group_PDB.value(V.residueIndex[H]),
          atom_id: V.model.atomicConformation.atomId.value(H),
          auth_atom_id: V.model.atomicHierarchy.atoms.auth_atom_id.value(H),
          label_alt_id: V.model.atomicHierarchy.atoms.label_alt_id.value(H),
          auth_comp_id: V.model.atomicHierarchy.atoms.label_comp_id.value(H),
          auth_asym_id: V.model.atomicHierarchy.chains.auth_asym_id.value(V.chainIndex[H]),
          auth_seq_id: V.model.atomicHierarchy.residues.auth_seq_id.value(V.residueIndex[H]),
          pdbx_PDB_ins_code: V.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(V.residueIndex[H]),
          x: V.model.atomicConformation.x[H],
          y: V.model.atomicConformation.y[H],
          z: V.model.atomicConformation.z[H],
          occupancy: V.model.atomicConformation.occupancy.value(H),
          B_iso_or_equiv: V.model.atomicConformation.B_iso_or_equiv.value(H),
          type_symbol: (0, a.getStandardTypeSymbol)(V.model.atomicHierarchy.atoms.type_symbol.value(H)),
          charge: V.model.atomicHierarchy.atoms.pdbx_formal_charge.value(H),
          em_confidence: V.model.atomicHierarchy.atoms.em_confidence.value(H)
        };
        k.push(q), q.em_confidence && (G = !0), q.charge && (L = !0);
      }), I) {
        var R = I(k, []), F = R.editedAtomList, U = R.editedBondList;
        return D.push(v(F, U, E && L, E && G)), D.join(`
`);
      }
      return D.push(v(k, [], E && L, E && G)), D.join(`
`);
    }
    e.parseToPDB = p;
    function v(x, w, E, I) {
      var B = "ATOM  %5d %-4s%1s%3s %1s%4d%1s   %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s".concat(E ? "%4.1f" : "%2s  ").concat(I ? "   %5.2f" : ""), D = "HETATM%5d %-4s%1s%3s %1s%4d%1s   %8.3f%8.3f%8.3f%6.2f%6.2f      %4s%2s".concat(E ? "%4.1f" : "%2s  ").concat(I ? "   %5.2f" : ""), N = "CONECT%5s%5s%5s%5s%5s", O = [], V = [];
      return x.forEach(function(k) {
        var G = k.elementId, L = k.atom_id, R = k.auth_atom_id, F = k.label_alt_id, U = k.auth_comp_id, H = k.auth_asym_id, q = k.auth_seq_id, K = k.pdbx_PDB_ins_code, Y = K === void 0 ? " " : K, X = k.x, Z = k.y, J = k.z, $ = k.occupancy, Q = k.B_iso_or_equiv, W = k.type_symbol, te = k.group_PDB, oe = k.charge, z = k.em_confidence, j = te === "HETATM" ? D : B;
        O.push((0, t.sprintf)(j, L, R, F, U, H, q, Y, X, Z, J, $, Q, " ", W, E ? oe : "  ", I ? z : ""));
        var ae = [];
        if (w && (w.forEach(function(re) {
          if (re.a === G && !ae.includes(re.atom_idB)) {
            for (var ee = 0, ne = re.order; ee < ne; ee++)
              ae.push(re.atom_idB);
            return;
          }
          if (re.b === G && !ae.includes(re.atom_idA))
            for (var ee = 0, ne = re.order; ee < ne; ee++)
              ae.push(re.atom_idA);
        }), ae.length > 0)) {
          for (var le = []; ae.length > 0; ) {
            var ie = ae.shift();
            ie && le.push(ie), le.length === 4 && (V.push((0, t.sprintf)(N, L, le[0], le[1], le[2], le[3])), le = []);
          }
          le.length > 0 && (V.push((0, t.sprintf)(N, L, le[0] || "", le[1] || "", le[2] || "", le[3] || "")), le = []);
        }
      }), (0, r.__spreadArray)((0, r.__spreadArray)([], O, !0), V, !0).join(`
`);
    }
    e.atomDataToPdb = v;
    function h(x, w, E, I, B) {
      var D, N, O, V, k, G;
      B === void 0 && (B = !1);
      var L = [];
      if (w ? L.push.apply(L, (0, r.__spreadArray)([], w, !0).filter(function(re) {
        return re < x.elementCount;
      }).sort(function(re, ee) {
        return re - ee;
      })) : x.units.forEach(function(re) {
        return L.push.apply(L, (0, r.__spreadArray)([], re.elements, !0));
      }), L.length > 999)
        return "";
      if (L.length <= 0) {
        if (I) {
          var R = I([], []), F = R.editedAtomList, U = R.editedBondList, H = (D = x == null ? void 0 : x.state.model) !== null && D !== void 0 ? D : x == null ? void 0 : x.state.models[0], q = (N = H == null ? void 0 : H.sourceData) === null || N === void 0 ? void 0 : N.kind, K = (0, e.atomDataToSdf)(F, U);
          return q === "sdf" || q === "mol" ? (0, r.__spreadArray)((0, r.__spreadArray)([H.entryId], K.split(`
`).slice(1), !0), ["$$$$"], !1).join(`
`) : "".concat(K, `
$$$$`);
        }
        return "";
      }
      var Y = x.units[0], X = [], Z = /* @__PURE__ */ new Map();
      L.forEach(function(re) {
        var ee;
        X.push({
          elementId: re,
          group_PDB: Y.model.atomicHierarchy.residues.group_PDB.value(Y.residueIndex[re]),
          atom_id: Y.model.atomicConformation.atomId.value(re),
          auth_atom_id: Y.model.atomicHierarchy.atoms.label_atom_id.value(re),
          label_alt_id: Y.model.atomicHierarchy.atoms.label_alt_id.value(re),
          auth_comp_id: Y.model.atomicHierarchy.atoms.label_comp_id.value(re),
          auth_asym_id: Y.model.atomicHierarchy.chains.auth_asym_id.value(Y.chainIndex[re]),
          auth_seq_id: Y.model.atomicHierarchy.residues.auth_seq_id.value(Y.residueIndex[re]),
          pdbx_PDB_ins_code: Y.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(Y.residueIndex[re]),
          x: Y.model.atomicConformation.x[re],
          y: Y.model.atomicConformation.y[re],
          z: Y.model.atomicConformation.z[re],
          occupancy: Y.model.atomicConformation.occupancy.value(re),
          B_iso_or_equiv: Y.model.atomicConformation.B_iso_or_equiv.value(re),
          type_symbol: (0, a.getStandardTypeSymbol)(Y.model.atomicHierarchy.atoms.type_symbol.value(re)),
          charge: Y.model.atomicHierarchy.atoms.pdbx_formal_charge.value(re) || ((ee = n.AtomPartialCharge.Provider.get(Y.model)) === null || ee === void 0 ? void 0 : ee.data.value(re)) || 0
        });
      });
      var J = new Set(w), $ = /* @__PURE__ */ new Map();
      if (B && ((O = x.model) === null || O === void 0 ? void 0 : O.sourceData.kind) === "mmCIF")
        for (var Q = function(re, ee) {
          for (var ne = x.units[re], se = function(me, he) {
            var _e = ne.rings.all[ne.rings.aromaticRings[me]], Se = _e.map(function(Pe) {
              return ne.elements[Pe];
            });
            Se.forEach(function(Pe, De) {
              J.has(Pe) && $.set(Pe, new Set((0, r.__spreadArray)((0, r.__spreadArray)([], Se.slice(0, De), !0), Se.slice(De + 1), !0)));
            });
          }, ce = 0, de = ne.rings.aromaticRings.length; ce < de; ce++)
            se(ce);
        }, W = 0, te = x.units.length; W < te; W++)
          Q(W, te);
      x.units.forEach(function(re) {
        for (var ee, ne = 0, se = re.bonds.a.length; ne < se; ne++) {
          var ce = re.elements[re.bonds.a[ne]], de = re.elements[re.bonds.b[ne]];
          if (L.includes(ce) && L.includes(de) && !Z.has("".concat(ce, "_").concat(de)) && !Z.has("".concat(de, "_").concat(ce))) {
            var me = B && $.has(ce) && (!((ee = $.get(ce)) === null || ee === void 0) && ee.has(de)) ? 4 : re.bonds.edgeProps.order[ne];
            Z.set("".concat(ce, "_").concat(de), {
              a: L.indexOf(ce) + 1,
              b: L.indexOf(de) + 1,
              order: me
            });
          }
        }
      });
      var oe = [];
      if (((V = x.model) === null || V === void 0 ? void 0 : V.sourceData.kind) === "sdf" && (!((k = x.state.models) === null || k === void 0) && k.length))
        for (var z = (G = x.state.models[0]) === null || G === void 0 ? void 0 : G.sourceData.data.dataItems, W = 0, j = z.data.rowCount; W < j; W++)
          oe.push("> ".concat(z.dataHeader.value(W), `
`).concat(z.data.value(W)));
      if (I) {
        var ae = I(X, Array.from(Z).map(function(ne) {
          return ne[1];
        })), F = ae.editedAtomList, U = ae.editedBondList, le = (0, e.atomDataToSdf)(F, U);
        return "".concat(le, `
`).concat(oe.join(`

`)).concat(oe.length ? `

` : "", "$$$$");
      }
      var ie = (0, e.atomDataToSdf)(X, Array.from(Z).map(function(re) {
        return re[1];
      }));
      return "".concat(ie, `
`).concat(oe.join(`

`)).concat(oe.length ? `

` : "", "$$$$");
    }
    e.parseToSdf = h;
    var y = function(x) {
      switch (x) {
        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 = function(x, w, E) {
      var I = "%3d%3d  0  0  0  0  0  0  0  0999 V2000", B = "%10.4f%10.4f%10.4f %-2s  0%3d  0  0  0  0  0  0  0  0  0  0", D = "%3s%3s%3s  0  0  0  0", N = [];
      return N.push("".concat(E || "", `

`)), N.push((0, t.sprintf)(I, x.length, w.length)), x.forEach(function(O) {
        var V = O.x, k = O.y, G = O.z, L = O.type_symbol, R = O.charge;
        N.push((0, t.sprintf)(B, V, k, G, L, y(R)));
      }), w.forEach(function(O) {
        var V = O.a, k = O.b, G = O.order;
        N.push((0, t.sprintf)(D, V, k, G));
      }), N.push("M  END"), N.join(`
`);
    };
    e.atomDataToSdf = C;
    var S = function(x, w, E, I) {
      return {
        elementId: -1,
        group_PDB: "HETATM",
        atom_id: x,
        auth_atom_id: w,
        label_alt_id: "",
        auth_comp_id: "UNK",
        auth_asym_id: " ",
        auth_seq_id: "1",
        x: parseFloat(E[0].toFixed(3)),
        y: parseFloat(E[1].toFixed(3)),
        z: parseFloat(E[2].toFixed(3)),
        occupancy: "1",
        B_iso_or_equiv: "0.00",
        type_symbol: w,
        charge: I ?? 0
      };
    };
    e.getDefaultAtomData = S;
    var b = function(x, w) {
      var E = [], I = [], B = 1, D = "sdf", N = [], O = [], V = !1, k = /* @__PURE__ */ new Set(), G = /* @__PURE__ */ new Map(), L = x.sort(function(q) {
        var K;
        return ((K = (0, i.getModelByStructure)(q)) === null || K === void 0 ? void 0 : K.sourceData.kind) === "mmCIF" ? -1 : 1;
      });
      L.forEach(function(q, K) {
        var Y;
        if (q && ((Y = (0, i.getModelByStructure)(q)) === null || Y === void 0 ? void 0 : Y.sourceData.kind) === "mmCIF") {
          var X = Array.from((0, i.getModelByStructure)(q).properties.structAsymMap.keys());
          X.forEach(function(Z) {
            G.set("".concat(K, `
`).concat(Z), Z), k.has(Z) && (V = !0), k.add(Z);
          });
        }
      });
      var R = "", F = 1;
      if (G.size > 35)
        return { format: "pdb", type: u.PDB, content: "" };
      if (V)
        k.clear(), Array.from(G.keys()).forEach(function(q, K) {
          var Y = 65 + K > 90 ? String.fromCharCode(65 + K) : "".concat(K);
          G.set(q, Y), K === G.size - 1 && (R = 65 + K + 1 > 90 ? String.fromCharCode(65 + K + 1) : "".concat(K));
        });
      else {
        for (var U = 65; U < 91 && R === ""; U++) {
          var H = String.fromCharCode(U);
          k.has(H) || (R = H);
        }
        for (var U = 48; U < 58 && R === ""; U++) {
          var H = String.fromCharCode(U);
          k.has(H) || (R = H);
        }
      }
      return L.forEach(function(q, K) {
        var Y;
        if (q)
          if (((Y = (0, i.getModelByStructure)(q)) === null || Y === void 0 ? void 0 : Y.sourceData.kind) === "mmCIF") {
            var X = [], Z = (0, e.getPDBSectionLine)(q, ["HEADER"]);
            X.push.apply(X, Z);
            var J = (0, i.getElementsFromStructure)(q), $ = q.units[0], Q = [];
            J.forEach(function(ae) {
              var le;
              w && (K === w[0].index && ae === w[0].elementId[0] || K === w[1].index && ae === w[1].elementId[0]) && N.push(B);
              var ie = $.model.atomicHierarchy.chains.auth_asym_id.value($.chainIndex[ae]), re = {
                elementId: B,
                atom_id: "".concat(B),
                group_PDB: $.model.atomicHierarchy.residues.group_PDB.value($.residueIndex[ae]),
                auth_atom_id: $.model.atomicHierarchy.atoms.auth_atom_id.value(ae),
                label_alt_id: $.model.atomicHierarchy.atoms.label_alt_id.value(ae),
                auth_comp_id: $.model.atomicHierarchy.atoms.label_comp_id.value(ae),
                auth_asym_id: (le = G.get("".concat(K, `
`).concat(ie))) !== null && le !== void 0 ? le : ie,
                auth_seq_id: $.model.atomicHierarchy.residues.auth_seq_id.value($.residueIndex[ae]),
                pdbx_PDB_ins_code: $.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value($.residueIndex[ae]),
                x: $.model.atomicConformation.x[ae],
                y: $.model.atomicConformation.y[ae],
                z: $.model.atomicConformation.z[ae],
                occupancy: $.model.atomicConformation.occupancy.value(ae),
                B_iso_or_equiv: $.model.atomicConformation.B_iso_or_equiv.value(ae),
                type_symbol: (0, a.getStandardTypeSymbol)($.model.atomicHierarchy.atoms.type_symbol.value(ae)),
                charge: $.model.atomicHierarchy.atoms.pdbx_formal_charge.value(ae)
              };
              Q.push(re), B++;
            });
            var W = /* @__PURE__ */ new Map();
            q.units.forEach(function(ae) {
              for (var le = 0, ie = ae.bonds.a.length; le < ie; le++) {
                var re = ae.elements[ae.bonds.a[le]], ee = ae.elements[ae.bonds.b[le]];
                if (J.includes(re) && J.includes(ee) && !W.has("".concat(re, "_").concat(ee)) && !W.has("".concat(ee, "_").concat(re))) {
                  var ne = ae.bonds.edgeProps.order[le];
                  W.set("".concat(re, "_").concat(ee), {
                    a: Q[J.indexOf(re)].elementId,
                    b: Q[J.indexOf(ee)].elementId,
                    order: ne,
                    atom_idA: Q[J.indexOf(re)].atom_id,
                    atom_idB: Q[J.indexOf(re)].atom_id
                  });
                }
              }
            }), E.push.apply(E, Q), I.push.apply(I, Array.from(W).map(function(ae) {
              return ae[1];
            })), D = "pdb";
          } else {
            var te = (0, i.getElementsFromStructure)(q), oe = q.units[0], z = [], j = /* @__PURE__ */ new Map();
            te.forEach(function(ae) {
              var le;
              w && (K === w[0].index && ae === w[0].elementId[0] || K === w[1].index && ae === w[1].elementId[0]) && N.push(B), z.push({
                elementId: B,
                group_PDB: "HETATM",
                atom_id: "".concat(B),
                auth_atom_id: oe.model.atomicHierarchy.atoms.label_atom_id.value(ae),
                label_alt_id: oe.model.atomicHierarchy.atoms.label_alt_id.value(ae),
                auth_comp_id: oe.model.atomicHierarchy.atoms.label_comp_id.value(ae),
                auth_asym_id: R,
                auth_seq_id: "".concat(F),
                pdbx_PDB_ins_code: oe.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(oe.residueIndex[ae]),
                x: oe.model.atomicConformation.x[ae],
                y: oe.model.atomicConformation.y[ae],
                z: oe.model.atomicConformation.z[ae],
                occupancy: oe.model.atomicConformation.occupancy.value(ae),
                B_iso_or_equiv: oe.model.atomicConformation.B_iso_or_equiv.value(ae),
                type_symbol: (0, a.getStandardTypeSymbol)(oe.model.atomicHierarchy.atoms.type_symbol.value(ae)),
                charge: oe.model.atomicHierarchy.atoms.pdbx_formal_charge.value(ae) || ((le = n.AtomPartialCharge.Provider.get(oe.model)) === null || le === void 0 ? void 0 : le.data.value(ae)) || 0
              }), B++;
            }), q.units.forEach(function(ae) {
              for (var le = 0, ie = ae.bonds.a.length; le < ie; le++) {
                var re = ae.elements[ae.bonds.a[le]], ee = ae.elements[ae.bonds.b[le]];
                if (te.includes(re) && te.includes(ee) && !j.has("".concat(re, "_").concat(ee)) && !j.has("".concat(ee, "_").concat(re))) {
                  var ne = ae.bonds.edgeProps.order[le];
                  j.set("".concat(re, "_").concat(ee), {
                    a: z[te.indexOf(re)].elementId,
                    b: z[te.indexOf(ee)].elementId,
                    order: ne,
                    atom_idA: z[te.indexOf(re)].atom_id,
                    atom_idB: z[te.indexOf(re)].atom_id
                  });
                }
              }
            }), F++, O.push.apply(O, z), I.push.apply(I, Array.from(j).map(function(ae) {
              return ae[1];
            }));
          }
      }), N.length === 2 && I.push({
        a: N[0],
        b: N[1],
        order: 1,
        atom_idA: "".concat(N[0]),
        atom_idB: "".concat(N[1])
      }), E.push.apply(E, O), D === "pdb" ? { format: "pdb", type: u.PDB, content: E.length > 99999 ? "" : v(E, I, !1, !1) } : { format: "sdf", type: u.SDF, content: E.length > 999 || I.length > 999 ? "" : "".concat((0, e.atomDataToSdf)(E, I), `
$$$$`) };
    };
    e.getMergedStructureContent = b;
    var g = function(x, w) {
      switch (w) {
        case o.Format.Pdb:
          return (0, e.splitPdbContent)(x);
        case o.Format.Sdf:
        case o.Format.Mol:
          return (0, e.splitSdfContent)(x);
        default:
          return [x];
      }
    };
    e.splitMolecularContent = g;
    var _ = function(x) {
      var w = x.split(`
`), E = [], I = [[]], B = 0;
      w.forEach(function(O) {
        switch (O[0]) {
          case "A":
            if (O.startsWith("ATOM")) {
              I[B].push(O);
              return;
            }
            if (O.startsWith("AUTHER"))
              return;
            E.push(O);
            break;
          case "C":
            if (O.startsWith("CONECT")) {
              I[B].push(O);
              return;
            }
            E.push(O);
            break;
          case "E":
            if (O.startsWith("ENDMDL")) {
              I[B].length > 0 && (B++, I.push([]));
              return;
            }
            if (O.startsWith("END"))
              return;
            E.push(O);
            break;
          case "H":
            if (O.startsWith("HETATM")) {
              I[B].push(O);
              return;
            }
            E.push(O);
            break;
          case "M":
            if (O.startsWith("MODEL")) {
              I[B].length > 0 && (B++, I.push([]));
              return;
            }
            if (O.startsWith("MASTER"))
              return;
            E.push(O);
            break;
          case "R":
            if (O.startsWith("REVDAT"))
              return;
            E.push(O);
            break;
          case "S":
            if (O.startsWith("SOURCE"))
              return;
            E.push(O);
            break;
          case "T":
            if (O.startsWith("TER")) {
              I[B].push(O);
              return;
            }
            E.push(O);
            break;
          default:
            E.push(O);
        }
      });
      var D = E.join(`
`), N = [];
      return I.forEach(function(O) {
        O.length > 0 && N.push("".concat(D).concat(D ? `
` : "").concat(O.join(`
`)));
      }), N;
    };
    e.splitPdbContent = _;
    var A = function(x) {
      return x.split(/\$\$\$\$\r?\n?/).filter(function(w) {
        return w.trim() !== "";
      });
    };
    e.splitSdfContent = A;
    var M = function(x) {
      var w = x.split(`
`), E = [];
      return w.forEach(function(I, B) {
        switch (I[0]) {
          case "A":
            if (I.startsWith("ATOM")) {
              var D = (0, c.checkLineValidate)(I, s.pdbAtomLineFormat);
              D.length > 0 && E.push({
                index: B,
                info: D
              });
            }
            if (I.startsWith("ANISOU")) {
              var D = (0, c.checkLineValidate)(I, s.pdbAnisouLineFormat);
              D.length > 0 && E.push({
                index: B,
                info: D
              });
            }
            break;
          case "C":
            if (I.startsWith("CONECT")) {
              var D = (0, c.checkLineValidate)(I, s.pdbConectLineFormat);
              D.length > 0 && E.push({
                index: B,
                info: D
              });
            }
            break;
          case "H":
            if (I.startsWith("HETATM")) {
              var D = (0, c.checkLineValidate)(I, s.pdbAtomLineFormat);
              D.length > 0 && E.push({
                index: B,
                info: D
              });
            }
            break;
        }
      }), E;
    };
    e.pdbValidate = M;
    var P = function(x) {
      for (var w = x.split(`
`), E = !0, I = !1, B = [], D = [], N = 0, O = w.length; N < O; N++) {
        var V = w[N];
        if (E) {
          if (B.length < 4) {
            if (B.push(V), B.length === 4) {
              var k = (0, c.checkLineValidate)(V, s.molCountLineFormat);
              k.length > 0 && D.push({
                index: N,
                info: k
              });
            }
          } else if (V.startsWith("M  END"))
            I = !0, E = !1, B = [];
          else if (!V.startsWith("M") && !V.startsWith("V")) {
            if (V.startsWith("G") || V.startsWith("A"))
              N++;
            else if (V.slice(4, 5) !== "T" && V.slice(4, 5) !== "F")
              if (V.length < 34) {
                var k = (0, c.checkLineValidate)(V, s.molBondFormatCheck);
                k.length > 0 && D.push({
                  index: N,
                  info: k
                });
              } else {
                var k = (0, c.checkLineValidate)(V, s.molAtomLineFormat);
                k.length > 0 && D.push({
                  index: N,
                  info: k
                });
              }
          }
        } else V.startsWith("$$$$") && (E = !0, B = []);
      }
      return I || D.push({
        index: 0,
        info: [
          {
            start: 0,
            end: 0
          }
        ]
      }), D;
    };
    e.molValidate = P;
    var T = function(x, w) {
      switch (w) {
        case o.Format.Sdf:
        case o.Format.Mol:
          return (0, e.molValidate)(x);
        default:
          return [];
      }
    };
    e.checkFileFormat = T;
  }(gT)), gT;
}
var VB;
function rhe() {
  if (VB) return t1;
  VB = 1, Object.defineProperty(t1, "__esModule", { value: !0 }), t1.SdfModel = void 0;
  var e = Te, r = gn(), t = Hv, n = jv, a = zp(), i = sn();
  return t1.SdfModel = {
    parse: function(o) {
      return (0, e.__awaiter)(this, void 0, void 0, function() {
        var c, s, u, l, f, d, m, p, v, h, y;
        return (0, e.__generator)(this, function(C) {
          switch (C.label) {
            case 0:
              if (!o.trim())
                return [2, [(0, i.createEmptyStructure)()]];
              c = [], s = (0, a.splitSdfContent)(o), u = 0, l = s, C.label = 1;
            case 1:
              return u < l.length ? (f = l[u], [4, (0, t.parseSdf)(f).run()]) : [3, 7];
            case 2:
              if (d = C.sent(), d.isError)
                throw d;
              m = 0, p = d.result.compounds, C.label = 3;
            case 3:
              return m < p.length ? (v = p[m], [4, (0, n.trajectoryFromSdf)(v).run()]) : [3, 6];
            case 4:
              h = C.sent(), y = r.Structure.ofModel(h.representative), c.push(y), C.label = 5;
            case 5:
              return m++, [3, 3];
            case 6:
              return u++, [3, 1];
            case 7:
              return [2, c];
          }
        });
      });
    }
  }, t1;
}
var W4 = {}, Py = {}, $v = {};
Object.defineProperty($v, "__esModule", { value: !0 });
$v.FixedColumn = $v.FixedColumnProvider = void 0;
var the = mr(), nhe = Pi, RB = Qa;
function ahe(e) {
  return function(r, t, n) {
    return QH(e, r, t, n);
  };
}
$v.FixedColumnProvider = ahe;
function QH(e, r, t, n) {
  var a = e.data, i = e.indices, o = e.count, c = n.valueType, s = c === "str" ? function(u) {
    var l = i[2 * u] + r, f = i[2 * u + 1];
    if (l >= f)
      return "";
    var d = l + t;
    return d > f && (d = f), (0, nhe.trimStr)(a, l, d);
  } : c === "int" ? function(u) {
    var l = i[2 * u] + r;
    return l > i[2 * u + 1] ? 0 : (0, RB.parseIntSkipLeadingWhitespace)(a, l, l + t);
  } : function(u) {
    var l = i[2 * u] + r;
    return l > i[2 * u + 1] ? 0 : (0, RB.parseFloatSkipLeadingWhitespace)(a, l, l + t);
  };
  return {
    schema: n,
    __array: void 0,
    isDefined: !0,
    rowCount: o,
    value: s,
    valueKind: function(u) {
      return 0;
    },
    toArray: function(u) {
      return the.ColumnHelpers.createAndFillArray(o, s, u);
    },
    areValuesEqual: function(u, l) {
      return s(u) === s(l);
    }
  };
}
$v.FixedColumn = QH;
Object.defineProperty(Py, "__esModule", { value: !0 });
Py.parseGRO = void 0;
var Kv = Te, fu = mr(), h0 = Pi, ihe = $v, ohe = Mi, uhe = Kr;
function she() {
  return {
    title: "",
    timeInPs: 0,
    hasVelocities: !1,
    precision: { position: 0, velocity: 0 },
    box: [0, 0, 0]
  };
}
function lhe(e, r) {
  return {
    tokenizer: e,
    header: she(),
    numberOfAtoms: 0,
    runtimeCtx: r
  };
}
function che(e) {
  var r = e.tokenizer, t = e.header, n = h0.Tokenizer.readLine(r);
  n.trim().length === 0 && (n = h0.Tokenizer.readLine(r));
  var a = n.lastIndexOf("t=");
  a >= 0 ? (t.timeInPs = parseFloat(n.substring(a + 2)), t.title = n.substring(0, a).trim(), t.title && t.title[t.title.length - 1] === "," && (t.title = t.title.substring(0, t.title.length - 1))) : t.title = n;
}
function dhe(e) {
  var r = e.tokenizer;
  h0.Tokenizer.markLine(r);
  var t = h0.Tokenizer.getTokenString(r);
  e.numberOfAtoms = parseInt(t);
}
function fhe(e) {
  return (0, Kv.__awaiter)(this, void 0, void 0, function() {
    var r, t, n, a, i, o, c, s, u, l, f, d, m;
    return (0, Kv.__generator)(this, function(p) {
      switch (p.label) {
        case 0:
          return r = e.tokenizer, t = e.numberOfAtoms, [4, h0.Tokenizer.readLinesAsync(r, t, e.runtimeCtx, 1e5)];
        case 1:
          return n = p.sent(), a = r.data.substring(n.indices[0], n.indices[1]).substring(20), i = a.match(/\.\d+/g), o = i.length === 6, e.header.hasVelocities = o, e.header.precision.position = i[0].length - 1, e.header.precision.velocity = o ? i[3].length - 1 : 0, c = 20, s = e.header.precision.position + 5, u = c + 3 * s, l = e.header.precision.velocity + 4, f = (0, ihe.FixedColumnProvider)(n), d = fu.Column.Undefined(e.numberOfAtoms, fu.Column.Schema.float), m = {
            count: e.numberOfAtoms,
            residueNumber: f(0, 5, fu.Column.Schema.int),
            residueName: f(5, 5, fu.Column.Schema.str),
            atomName: f(10, 5, fu.Column.Schema.str),
            atomNumber: f(15, 5, fu.Column.Schema.int),
            x: f(c, s, fu.Column.Schema.float),
            y: f(c + s, s, fu.Column.Schema.float),
            z: f(c + 2 * s, s, fu.Column.Schema.float),
            vx: o ? f(u, l, fu.Column.Schema.float) : d,
            vy: o ? f(u + l, l, fu.Column.Schema.float) : d,
            vz: o ? f(u + 2 * l, l, fu.Column.Schema.float) : d
          }, [2, m];
      }
    });
  });
}
function mhe(e) {
  var r = e.tokenizer, t = h0.Tokenizer.readLine(r).trim().split(/\s+/g);
  e.header.box = [+t[0], +t[1], +t[2]];
}
function vhe(e, r) {
  return (0, Kv.__awaiter)(this, void 0, void 0, function() {
    var t, n, a, i, o;
    return (0, Kv.__generator)(this, function(c) {
      switch (c.label) {
        case 0:
          return t = (0, h0.Tokenizer)(e), [4, r.update({ message: "Parsing...", current: 0, max: e.length })];
        case 1:
          c.sent(), n = [], c.label = 2;
        case 2:
          return t.position < e.length ? (a = lhe(t, r), che(a), dhe(a), [4, fhe(a)]) : [3, 4];
        case 3:
          return i = c.sent(), mhe(a), n.push({ header: a.header, atoms: i }), [3, 2];
        case 4:
          return o = { structures: n }, [2, ohe.ReaderResult.success(o)];
      }
    });
  });
}
function phe(e) {
  var r = this;
  return uhe.Task.create("Parse GRO", function(t) {
    return (0, Kv.__awaiter)(r, void 0, void 0, function() {
      return (0, Kv.__generator)(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, vhe(e, t)];
          case 1:
            return [2, n.sent()];
        }
      });
    });
  });
}
Py.parseGRO = phe;
var g0 = {}, X4 = {};
Object.defineProperty(X4, "__esModule", { value: !0 });
X4.getChainId = void 0;
var hhe = d0, yT = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
function ghe(e) {
  for (var r = yT.length, t = e, n = 0, a = yT[t % r]; t >= r; )
    t = Math.floor(t / r), a += yT[t % r], n += 1;
  return n >= 5 && console.warn("getChainId overflow"), a;
}
X4.getChainId = (0, hhe.memoize1)(ghe);
Object.defineProperty(g0, "__esModule", { value: !0 });
g0.trajectoryFromGRO = g0.GroFormat = void 0;
var OB = Te, yhe = Kr, di = mr(), _he = ls, bhe = Gr, She = yl, Che = X4, Ahe = _l, FB = Zo, xhe = xc(), The = R0;
function Phe(e, r) {
  for (var t = e.atomName, n = e.residueName, a = new Array(e.count), i = new Array(e.count), o = new Uint32Array(e.count), c = new Uint32Array(e.count), s = new Array(e.count), u = new Ahe.EntityBuilder(), l = new She.ComponentBuilder(e.residueNumber, e.atomName), f = "", d = 0, m = "", p = 0, v = 0, h = -1, y = 0, C = e.count; y < C; ++y) {
    var S = e.residueNumber.value(y);
    if (S !== h) {
      var b = e.residueName.value(y), g = (0, bhe.getMoleculeType)(l.add(b, y).type, b);
      (g !== v || S !== h + 1 && !// gro format allows only for 5 character residueNumbers, handle overflow here
      (h === 99999 && S === 0)) && (m = (0, Che.getChainId)(d), d += 1, p = 0), f = u.getEntityId(b, g, m), p += 1, h = S, v = g;
    }
    a[y] = f, i[y] = m, o[y] = p, c[y] = y, s[y] = (0, _he.guessElementSymbolString)(e.atomName.value(y), e.residueName.value(y));
  }
  var _ = di.Column.ofStringArray(i), A = di.Table.ofPartialColumns(FB.BasicSchema.atom_site, {
    auth_asym_id: _,
    auth_atom_id: t,
    auth_comp_id: n,
    auth_seq_id: e.residueNumber,
    Cartn_x: di.Column.ofFloatArray(di.Column.mapToArray(e.x, function(M) {
      return M * 10;
    }, Float32Array)),
    Cartn_y: di.Column.ofFloatArray(di.Column.mapToArray(e.y, function(M) {
      return M * 10;
    }, Float32Array)),
    Cartn_z: di.Column.ofFloatArray(di.Column.mapToArray(e.z, function(M) {
      return M * 10;
    }, Float32Array)),
    id: di.Column.ofIntArray(c),
    label_asym_id: _,
    label_atom_id: t,
    label_comp_id: n,
    label_seq_id: di.Column.ofIntArray(o),
    label_entity_id: di.Column.ofStringArray(a),
    occupancy: di.Column.ofConst(1, e.count, di.Column.Schema.float),
    type_symbol: di.Column.ofStringArray(s),
    pdbx_PDB_model_num: di.Column.ofConst(r, e.count, di.Column.Schema.int)
  }, e.count);
  return (0, FB.createBasic)({
    entity: u.getEntityTable(),
    chem_comp: l.getChemCompTable(),
    atom_site: A
  });
}
var t3;
(function(e) {
  function r(n) {
    return (n == null ? void 0 : n.kind) === "gro";
  }
  e.is = r;
  function t(n) {
    return { kind: "gro", name: n.structures[0].header.title, data: n };
  }
  e.fromGro = t;
})(t3 || (t3 = {}));
g0.GroFormat = t3;
function Mhe(e) {
  var r = this;
  return yhe.Task.create("Parse GRO", function(t) {
    return (0, OB.__awaiter)(r, void 0, void 0, function() {
      var n, a, i, o, c, s;
      return (0, OB.__generator)(this, function(u) {
        switch (u.label) {
          case 0:
            n = t3.fromGro(e), a = [], i = 0, o = e.structures.length, u.label = 1;
          case 1:
            return i < o ? (c = Phe(e.structures[i].atoms, i + 1), [4, (0, xhe.createModels)(c, n, t)]) : [3, 4];
          case 2:
            s = u.sent(), s.frameCount === 1 && a.push(s.representative), u.label = 3;
          case 3:
            return ++i, [3, 1];
          case 4:
            return [2, new The.ArrayTrajectory(a)];
        }
      });
    });
  });
}
g0.trajectoryFromGRO = Mhe;
Object.defineProperty(W4, "__esModule", { value: !0 });
W4.GroModel = void 0;
var LB = Te, whe = Py, Ehe = g0;
W4.GroModel = {
  parse: function(e) {
    return (0, LB.__awaiter)(this, void 0, void 0, function() {
      var r, t;
      return (0, LB.__generator)(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, (0, whe.parseGRO)(e).run()];
          case 1:
            if (r = n.sent(), r.isError)
              throw r;
            return [4, (0, Ehe.trajectoryFromGRO)(r.result).run()];
          case 2:
            return t = n.sent(), [2, t.representative];
        }
      });
    });
  }
};
var Y4 = {}, Q4 = {};
Object.defineProperty(Q4, "__esModule", { value: !0 });
Q4.parseXtc = void 0;
var n3 = Te, Dhe = Kr, kB = Mi, Am = 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
]), _T = 9, to;
(function(e) {
  function r(l) {
    for (var f = 1, d = 0; l >= f && d < 32; )
      d++, f <<= 1;
    return d;
  }
  e.sizeOfInt = r;
  var t = new Uint8Array(32);
  function n(l, f) {
    var d = 1, m = 0;
    t[0] = 1;
    for (var p = 0; p < l; p++) {
      var v = void 0, h = 0;
      for (v = 0; v < d; v++)
        h += t[v] * f[p], t[v] = h & 255, h >>= 8;
      for (; h !== 0; )
        t[v++] = h & 255, h >>= 8;
      d = v;
    }
    var y = 1;
    for (d--; t[d] >= y; )
      m++, y *= 2;
    return m + d * 8;
  }
  e.sizeOfInts = n;
  var a = new ArrayBuffer(8 * 3);
  e.buf = new Int32Array(a);
  var i = new Uint32Array(a);
  function o(l, f, d) {
    for (var m = d, p = (1 << m) - 1, v = i[1], h = i[2], y = e.buf[0], C = 0; m >= 8; )
      h = h << 8 | l[f + y++], C |= h >> v << m - 8, m -= 8;
    return m > 0 && (v < m && (v += 8, h = h << 8 | l[f + y++]), v -= m, C |= h >> v & (1 << m) - 1), C &= p, e.buf[0] = y, e.buf[1] = v, e.buf[2] = h, C;
  }
  e.decodeBits = o;
  function c(l, f) {
    var d = i[2], m = e.buf[0];
    return d = d << 8 | l[f + m], e.buf[0] = m + 1, e.buf[2] = d, d >> i[1] & 255;
  }
  var s = [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];
  function u(l, f, d, m, p) {
    var v = d, h = 0;
    for (s[0] = 0, s[1] = 0, s[2] = 0, s[3] = 0; v > 8; )
      s[h++] = c(l, f), v -= 8;
    v > 0 && (s[h++] = o(l, f, v));
    for (var y = 2; y > 0; y--) {
      for (var C = 0, S = m[y], b = h - 1; b >= 0; b--) {
        C = C << 8 | s[b];
        var g = C / S | 0;
        s[b] = g, C = C - g * S;
      }
      p[y] = C;
    }
    p[0] = s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24;
  }
  e.decodeInts = u;
})(to || (to = {}));
function Ihe() {
  throw new Error("(xdrfile error) Undefined error.");
}
function Bhe(e, r) {
  return (0, n3.__awaiter)(this, void 0, void 0, function() {
    var t, n, a, i, o, c, s, u, l, f, d, m, p, v, h, y, E, E, C, S, b, g, _, A, M, P, T, x, w, E, I, B, D, N, O;
    return (0, n3.__generator)(this, function(V) {
      switch (V.label) {
        case 0:
          t = new DataView(r.buffer, r.byteOffset), n = {
            frames: [],
            boxes: [],
            times: [],
            timeOffset: 0,
            deltaTime: 0
          }, a = n.frames, i = n.boxes, o = n.times, c = [0, 0, 0, 0, 0, 0], s = [0, 0, 0], u = [0, 0, 0], l = [0, 0, 0], f = [0.1, 0.1, 0.1], d = [0.1, 0.1, 0.1], m = 0, p = to.buf, V.label = 1;
        case 1:
          for (v = void 0, h = t.getInt32(m + 4), m += 12, o.push(t.getFloat32(m)), m += 4, y = new Float32Array(9), E = 0; E < 9; ++E)
            y[E] = t.getFloat32(m) * 10, m += 4;
          if (i.push(y), h <= 9)
            for (v = { count: h / 3, x: new Float32Array(h / 3), y: new Float32Array(h / 3), z: new Float32Array(h / 3) }, E = 0; E < h / 3; ++E)
              v.x[E] = t.getFloat32(m), v.y[E] = t.getFloat32(m), v.z[E] = t.getFloat32(m), m += 4;
          else {
            for (p[0] = p[1] = p[2] = 0, s[0] = s[1] = s[2] = 0, l[0] = l[1] = l[2] = 0, u[0] = u[1] = u[2] = 0, f[0] = f[1] = f[2] = 0, d[0] = d[1] = d[2] = 0, v = { count: h, x: new Float32Array(h), y: new Float32Array(h), z: new Float32Array(h) }, C = 0, S = t.getInt32(m), m += 4, b = t.getFloat32(m), m += 4, c[0] = t.getInt32(m), c[1] = t.getInt32(m + 4), c[2] = t.getInt32(m + 8), c[3] = t.getInt32(m + 12), c[4] = t.getInt32(m + 16), c[5] = t.getInt32(m + 20), s[0] = c[3] - c[0] + 1, s[1] = c[4] - c[1] + 1, s[2] = c[5] - c[2] + 1, m += 24, g = void 0, (s[0] | s[1] | s[2]) > 16777215 ? (u[0] = to.sizeOfInt(s[0]), u[1] = to.sizeOfInt(s[1]), u[2] = to.sizeOfInt(s[2]), g = 0) : g = to.sizeOfInts(3, s), _ = t.getInt32(m), m += 4, A = _ - 1, A = _T > A ? _T : A, M = Am[A] / 2 | 0, P = Am[_] / 2 | 0, l[0] = l[1] = l[2] = Am[_], T = Math.ceil(t.getInt32(m) / 4) * 4, m += 4, x = 1 / b, w = 0, E = 0, f[0] = f[1] = f[2] = 0; E < S; ) {
              if (g === 0 ? (f[0] = to.decodeBits(r, m, u[0]), f[1] = to.decodeBits(r, m, u[1]), f[2] = to.decodeBits(r, m, u[2])) : to.decodeInts(r, m, g, s, f), E++, f[0] += c[0], f[1] += c[1], f[2] += c[2], d[0] = f[0], d[1] = f[1], d[2] = f[2], I = to.decodeBits(r, m, 1), B = 0, I === 1 && (w = to.decodeBits(r, m, 5), B = w % 3, w -= B, B--), w > 0)
                for (f[0] = f[1] = f[2] = 0, D = 0; D < w; D += 3)
                  to.decodeInts(r, m, _, l, f), E++, f[0] += d[0] - P, f[1] += d[1] - P, f[2] += d[2] - P, D === 0 ? (N = f[0], f[0] = d[0], d[0] = N, N = f[1], f[1] = d[1], d[1] = N, N = f[2], f[2] = d[2], d[2] = N, v.x[C] = d[0] * x, v.y[C] = d[1] * x, v.z[C] = d[2] * x, C++) : (d[0] = f[0], d[1] = f[1], d[2] = f[2]), v.x[C] = f[0] * x, v.y[C] = f[1] * x, v.z[C] = f[2] * x, C++;
              else
                v.x[C] = f[0] * x, v.y[C] = f[1] * x, v.z[C] = f[2] * x, C++;
              _ += B, B < 0 ? (P = M, _ > _T ? M = Am[_ - 1] / 2 | 0 : M = 0) : B > 0 && (M = P, P = Am[_] / 2 | 0), l[0] = l[1] = l[2] = Am[_], (l[0] === 0 || l[1] === 0 || l[2] === 0) && Ihe();
            }
            m += T;
          }
          for (O = 0; O < h; O++)
            v.x[O] *= 10, v.y[O] *= 10, v.z[O] *= 10;
          return a.push(v), e.shouldUpdate ? [4, e.update({ current: m, max: r.length })] : [3, 3];
        case 2:
          V.sent(), V.label = 3;
        case 3:
          return m >= r.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 Nhe(e) {
  var r = this;
  return Dhe.Task.create("Parse XTC", function(t) {
    return (0, n3.__awaiter)(r, void 0, void 0, function() {
      var n, a;
      return (0, n3.__generator)(this, function(i) {
        switch (i.label) {
          case 0:
            return i.trys.push([0, 2, , 3]), t.update({ canAbort: !0, message: "Parsing trajectory..." }), [4, Bhe(t, e)];
          case 1:
            return n = i.sent(), [2, kB.ReaderResult.success(n)];
          case 2:
            return a = i.sent(), [2, kB.ReaderResult.error("" + a)];
          case 3:
            return [
              2
              /*return*/
            ];
        }
      });
    });
  });
}
Q4.parseXtc = Nhe;
var Z4 = {}, My = {};
Object.defineProperty(My, "__esModule", { value: !0 });
My.Cell = void 0;
var Ns = Re;
function Ng() {
  return Ng.empty();
}
My.Cell = Ng;
(function(e) {
  function r(a, i) {
    return { size: a, anglesInRadians: i };
  }
  e.create = r;
  function t() {
    return r((0, Ns.Vec3)(), (0, Ns.Vec3)());
  }
  e.empty = t;
  function n(a, i, o) {
    var c = Ns.Vec3.magnitude(a), s = Ns.Vec3.magnitude(i), u = Ns.Vec3.magnitude(o), l = Math.acos(Ns.Vec3.dot(i, o) / (s * u)), f = Math.acos(Ns.Vec3.dot(a, o) / (c * u)), d = Math.acos(Ns.Vec3.dot(a, i) / (c * s));
    return c <= 0 || s <= 0 || u <= 0 || l >= Math.PI || f >= Math.PI || d >= Math.PI ? t() : r(Ns.Vec3.create(c, s, u), Ns.Vec3.create(l, f, d));
  }
  e.fromBasis = n;
})(Ng || (Ng = {}));
My.Cell = Ng;
Object.defineProperty(Z4, "__esModule", { value: !0 });
Z4.coordinatesFromXtc = void 0;
var UB = Te, Vhe = Kr, q2 = iC, Rhe = My, xm = Re;
function Ohe(e) {
  var r = this;
  return Vhe.Task.create("Parse XTC", function(t) {
    return (0, UB.__awaiter)(r, void 0, void 0, function() {
      var n, a, i, o, c, s, u, l, f;
      return (0, UB.__generator)(this, function(d) {
        switch (d.label) {
          case 0:
            return [4, t.update("Converting to coordinates")];
          case 1:
            for (d.sent(), n = (0, q2.Time)(e.deltaTime, "step"), a = (0, q2.Time)(e.timeOffset, n.unit), i = [], o = 0, c = e.frames.length; o < c; ++o)
              s = e.boxes[o], u = xm.Vec3.fromArray((0, xm.Vec3)(), s, 0), l = xm.Vec3.fromArray((0, xm.Vec3)(), s, 3), f = xm.Vec3.fromArray((0, xm.Vec3)(), s, 6), i.push({
                elementCount: e.frames[o].count,
                cell: Rhe.Cell.fromBasis(u, l, f),
                x: e.frames[o].x,
                y: e.frames[o].y,
                z: e.frames[o].z,
                xyzOrdering: { isIdentity: !0 },
                time: (0, q2.Time)(a.value + n.value * o, n.unit)
              });
            return [2, q2.Coordinates.create(i, n, a)];
        }
      });
    });
  });
}
Z4.coordinatesFromXtc = Ohe;
Object.defineProperty(Y4, "__esModule", { value: !0 });
Y4.XtcModel = void 0;
var H2 = Te, Fhe = Q4, Lhe = Z4;
Y4.XtcModel = {
  parse: function(e) {
    return (0, H2.__awaiter)(this, void 0, void 0, function() {
      return (0, H2.__generator)(this, function(r) {
        return [2, new Promise(function(t) {
          var n = new FileReader();
          n.onload = function(a) {
            return (0, H2.__awaiter)(this, void 0, void 0, function() {
              var i, o, c;
              return (0, H2.__generator)(this, function(s) {
                switch (s.label) {
                  case 0:
                    return i = new Uint8Array(n.result), [4, (0, Fhe.parseXtc)(i).run()];
                  case 1:
                    if (o = s.sent(), o.isError)
                      throw new Error(o.message);
                    return [4, (0, Lhe.coordinatesFromXtc)(o.result).run()];
                  case 2:
                    return c = s.sent(), t(c), [
                      2
                      /*return*/
                    ];
                }
              });
            });
          }, n.readAsArrayBuffer(e);
        })];
      });
    });
  }
};
var J4 = {}, wy = {}, ul = {};
Object.defineProperty(ul, "__esModule", { value: !0 });
ul.createMaterialCellFromVec = ul.createMaterialCell = void 0;
var Zn = Re;
function khe(e, r, t, n, a, i) {
  var o = e, c = r, s = t, u = Math.cos(n * Math.PI / 180), l = Math.cos(a * Math.PI / 180), f = Math.cos(i * Math.PI / 180), d = Math.sin(n * Math.PI / 180), m = Math.sin(a * Math.PI / 180), p = function() {
    var _ = (u * l - f) / (d * m), A = 1;
    return Math.max(Math.min(_, A), -A);
  }(), v = Math.acos(p), h = Zn.Mat4.ofRows([
    [o * m, -c * d * Math.cos(v), 0, 0],
    [0, c * d * Math.sin(v), 0, 0],
    [o * l, c * u, s, 0],
    [0, 0, 0, 1]
  ]), y = Zn.Mat4.invert(Zn.Mat4.zero(), h), C = Zn.Vec3.create(h[0], h[4], h[8]), S = Zn.Vec3.create(h[1], h[5], h[9]), b = Zn.Vec3.create(h[2], h[6], h[10]), g = Math.abs(Zn.Vec3.dot(C, C)) * t;
  return {
    a: e,
    b: r,
    c: t,
    volume: g,
    alpha: n,
    beta: a,
    gamma: i,
    vecA: C,
    vecB: S,
    vecC: b,
    matrix: h,
    invertMatrix: y
  };
}
ul.createMaterialCell = khe;
function Uhe(e, r, t) {
  var n = Zn.Vec3.create.apply(null, e), a = Zn.Vec3.create.apply(null, r), i = Zn.Vec3.create.apply(null, t), o = n[0], c = n[1], s = n[2], u = a[0], l = a[1], f = a[2], d = i[0], m = i[1], p = i[2], v = Zn.Mat4.ofRows([
    [o, u, d, 0],
    [c, l, m, 0],
    [s, f, p, 0],
    [0, 0, 0, 1]
  ]), h = Zn.Mat4.invert(Zn.Mat4.zero(), v), y = Math.sqrt(Math.abs(Zn.Vec3.dot(n, n))), C = Math.sqrt(Math.abs(Zn.Vec3.dot(a, a))), S = Math.sqrt(Math.abs(Zn.Vec3.dot(i, i))), b = Zn.Vec3.angle(a, i) * (180 / Math.PI), g = Zn.Vec3.angle(n, i) * (180 / Math.PI), _ = Zn.Vec3.angle(n, a) * (180 / Math.PI), A = Math.abs(Zn.Vec3.dot(n, n)) * S;
  return {
    a: y,
    b: C,
    c: S,
    volume: A,
    alpha: b,
    beta: g,
    gamma: _,
    vecA: n,
    vecB: a,
    vecC: i,
    matrix: v,
    invertMatrix: h
  };
}
ul.createMaterialCellFromVec = Uhe;
var Wv = {};
Object.defineProperty(Wv, "__esModule", { value: !0 });
Wv.numberedPeriodicTable = Wv.periodicTable = void 0;
var zB = Te, ZH = {
  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"
  }
};
Wv.periodicTable = ZH;
var JH = [];
Wv.numberedPeriodicTable = JH;
Object.entries(ZH).forEach(function(e) {
  var r = e[0], t = e[1];
  JH[t["Atomic no"]] = (0, zB.__assign)((0, zB.__assign)({}, t), { symbol: r });
});
Object.defineProperty(wy, "__esModule", { value: !0 });
wy.parseDump = void 0;
var QM = Te, kc = mr(), GB = Re, zhe = Kr, $l = Pi, Ghe = ul, qhe = Wv, Hhe = Mi;
function jhe(e, r) {
  var t = r[0], n = r[1], a = r[2], i = r.map(function() {
    return $l.Tokenizer.readLine(e).trim().split(/\s+/g).map(function(P) {
      return Number(P);
    });
  }), o = i[0], c = o[0], s = o[1], u = o[2], l = i[1], f = l[0], d = l[1], m = l[2], p = i[2], v = p[0], h = p[1], y = p[2], C = [
    [c, s],
    [f, d],
    [v, h]
  ], S = [u, m, y], b = [0, S[0], S[1], S[0] + S[1]], g = [0, S[2]], _ = [
    [Math.min.apply(null, b), Math.max.apply(null, b)],
    [Math.min.apply(null, g), Math.max.apply(null, g)],
    [0, 0]
  ];
  C.forEach(function(P, T) {
    P.forEach(function(x, w) {
      C[T][w] = x - _[T][w];
    });
  });
  var A = C.map(function(P) {
    return P[1] - P[0];
  }), M = [
    [A[0], 0, 0],
    [S[0], A[1], 0],
    [S[1], S[2], A[2]]
  ];
  t[0] = M[0][0], t[1] = M[0][1], t[2] = M[0][2], n[0] = M[1][0], n[1] = M[1][1], n[2] = M[1][2], a[0] = M[2][0], a[1] = M[2][1], a[2] = M[2][2];
}
function $he(e, r, t) {
  var n = new Float64Array(r), a = new Float64Array(r), i = new Float64Array(r), o = new Float64Array(r), c = new Float64Array(r), s = [
    ["id", n],
    ["type", a],
    ["x", i],
    ["y", o],
    ["z", c]
  ];
  s.sort(function(d, m) {
    return t.indexOf(d[0]) - t.indexOf(m[0]);
  });
  for (var u = s.map(function(d) {
    var m = d[1];
    return m;
  }), l = function(d) {
    var m = $l.Tokenizer.readLine(e).trim().split(/\s+/g);
    m.forEach(function(p, v) {
      u[v][d] = Number(p);
    });
  }, f = 0; f < r; f++)
    l(f);
  return [n, a, i, o, c];
}
function Khe(e) {
  $l.Tokenizer.readLine(e);
  var r = +$l.Tokenizer.readLine(e);
  $l.Tokenizer.readLine(e);
  var t = +$l.Tokenizer.readLine(e);
  isNaN(t) && (t = 0);
  var n = $l.Tokenizer.readLine(e), a = new Float64Array(3), i = new Float64Array(3), o = new Float64Array(3);
  n.includes("xy xz yz") && jhe(e, [a, i, o]);
  var c = $l.Tokenizer.readLine(e).replace("ITEM: ATOMS", "").split(/\s+/g), s = $he(e, t, c), u = s[0], l = s[1], f = s[2], d = s[3], m = s[4], p = [], v = [];
  l.forEach(function(_) {
    p[_] || (p[_] = qhe.numberedPeriodicTable[_].symbol), v.push(p[_]);
  });
  for (var h = (0, Ghe.createMaterialCellFromVec)(a, i, o), y = new Float64Array(t), C = new Float64Array(t), S = new Float64Array(t), b = 0; b < t; b++) {
    var g = GB.Vec3.create(f[b], d[b], m[b]);
    GB.Vec3.transformMat4(g, g, h.invertMatrix), y[b] = g[0], C[b] = g[1], S[b] = g[2];
  }
  return {
    count: t,
    comment: "",
    x: kc.Column.ofFloatArray(f),
    y: kc.Column.ofFloatArray(d),
    z: kc.Column.ofFloatArray(m),
    type_symbol: kc.Column.ofStringArray(v),
    cell: h,
    timestep: r,
    fractX: kc.Column.ofFloatArray(y),
    fractY: kc.Column.ofFloatArray(C),
    fractZ: kc.Column.ofFloatArray(S),
    id: kc.Column.ofFloatArray(u)
  };
}
function Whe(e) {
  for (var r = (0, $l.Tokenizer)(e), t = []; ; ) {
    var n = Khe(r);
    if (n.count === 0)
      break;
    t.push(n);
  }
  var a = { molecules: t, isMaterial: !0 };
  return Hhe.ReaderResult.success(a);
}
function Xhe(e, r) {
  for (var t = [], n = 0; n < e.length; n++) {
    t[n] = [];
    for (var a = 0; a < r[0].length; a++) {
      for (var i = 0, o = 0; o < e[0].length; o++) {
        var c = +e[n][o], s = +r[o][a];
        i += c * s;
      }
      t[n][a] = i;
    }
  }
  return t;
}
function Yhe(e) {
  var r = e.split(/\r?\n/), t = function(i) {
    var o = i.findIndex(function(U) {
      return U.includes("ITEM: BOX BOUNDS");
    });
    i.splice(o, 1, "ITEM: BOX BOUNDS xy xz yz pp pp pp");
    var c = i.findIndex(function(U) {
      return U.includes("ITEM: ATOMS");
    }), s = i[c].includes("xs") || i[c].includes("xsu"), u = i[o + 1], l = i[o + 2], f = i[o + 3], d = u.split(" ").map(function(U) {
      return +U;
    }), m = d[0], p = d[1], v = d[2], h = v === void 0 ? 0 : v, y = l.split(" ").map(function(U) {
      return +U;
    }), C = y[0], S = y[1], b = y[2], g = b === void 0 ? 0 : b, _ = f.split(" ").map(function(U) {
      return +U;
    }), A = _[0], M = _[1], P = _[2], T = P === void 0 ? 0 : P;
    if (s) {
      var x = p - m - Math.abs(h) - Math.abs(g), w = S - C - Math.abs(T), E = M - A, I = [
        [x, 0, 0],
        [h, w, 0],
        [g, T, E]
      ], B = i.slice(c + 1), D = B.map(function(U) {
        return U.split(" ");
      }), N = D.map(function(U) {
        var H = U[0], q = U[1], K = U[2], Y = U[3], X = U[4], Z = Xhe([[K, Y, X]], I)[0], J = Z[0], $ = Z[1], Q = Z[2];
        return [H, q, J, $, Q];
      }), O = N.map(function(U) {
        return U.join(" ");
      }).join(`
`), V = i.slice(0, o + 4).join(`
`), k = "ITEM: ATOMS id type x y z";
      return [V, k, O].join(`
`);
    } else {
      var G = [m, p, h], L = [C, S, g], R = [A, M, T], F = [G, L, R].map(function(Z) {
        return Z.join(" ");
      });
      i.splice.apply(i, (0, QM.__spreadArray)([o + 1, 3], F, !1));
      var B = i.slice(c + 1), D = B.map(function(Z) {
        return Z.split(" ");
      }), N = D.map(function(Z) {
        var J = Z[0], $ = Z[1], Q = Z[2], W = Z[3], te = Z[4];
        return [J, $, Q, W, te];
      }), O = N.map(function(Z) {
        return Z.join(" ");
      }).join(`
`), k = "ITEM: ATOMS id type x y z", V = i.slice(0, o + 4).join(`
`);
      return [V, k, O].join(`
`);
    }
  }, n = r.reduce(function(i, o) {
    return o.includes("ITEM: TIMESTEP") && i.push([]), i[i.length - 1].push(o), i;
  }, []), a = n.map(t);
  return a.join(`
`);
}
function Qhe(e) {
  var r = this;
  return zhe.Task.create("Parse Mol", function() {
    return (0, QM.__awaiter)(r, void 0, void 0, function() {
      var t;
      return (0, QM.__generator)(this, function(n) {
        return t = Yhe(e), [2, Whe(t)];
      });
    });
  });
}
wy.parseDump = Qhe;
var ej = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 });
  var r = Te;
  (0, r.__exportStar)(ia(), e), (0, r.__exportStar)(_r, e);
})(ej);
var va = {};
Object.defineProperty(va, "__esModule", { value: !0 });
va.sceneToMaterial = va.trajectoryFromMaterial = va.MaterialFormat = va.getMaterialModels = va.getSymmetry = void 0;
var a3 = Te, zt = mr(), Zhe = Kr, Jhe = xc(), qB = Zo, HB = nr(), Yf = Re, e1e = yl, r1e = _l, t1e = ml(), jB = Cc;
function n1e(e) {
  if (!e)
    return "P 1";
  var r = e.it_number.value(0), t = e["name_h-m_full"].value(0).replace("-", " ");
  return e.it_number.isDefined ? (e["name_h-m_full"].isDefined, r) : t;
}
function rj(e) {
  if (e.length) {
    var r = e[0], t = r.cell, n = r.spaceGroup;
    if (t) {
      var a = t.a, i = t.b, o = t.c, c = t.alpha, s = t.beta, u = t.gamma, l = t.matrix, f = t.invertMatrix, d = n1e(n), m = HB.SpacegroupCell.createMaterial(d, Yf.Vec3.create(a, i, o), Yf.Vec3.scale((0, Yf.Vec3)(), Yf.Vec3.create(c, s, u), Math.PI / 180), a * i * o, f, l);
      return {
        spacegroup: HB.Spacegroup.create(m),
        assemblies: [],
        isNonStandardCrystalFrame: !1,
        ncsOperators: []
      };
    }
  }
}
va.getSymmetry = rj;
function tj(e, r) {
  return (0, a3.__awaiter)(this, void 0, void 0, function() {
    var t, n, a, i, o, v, c, s, u, l, f, d, m, p, N, v, h, y, C, S, b, g, _, A, M, P, T, x, w, E, I, B, D, N;
    return (0, a3.__generator)(this, function(O) {
      switch (O.label) {
        case 0:
          for (t = Vg.formatMol(e), n = t.molecules, a = 0, i = 0, o = n; i < o.length; i++)
            v = o[i], a += v.count;
          for (c = new Array(a), s = new Int32Array(a), u = new Float32Array(a), l = new Float32Array(a), f = new Float32Array(a), d = new Int32Array(a), m = rj(n), p = 0, N = 0; N < n.length; N++)
            for (v = n[N], h = 0; h < v.count; h++)
              c[p] = v.type_symbol.value(h), u[p] = v.x.value(h), l[p] = v.y.value(h), f[p] = v.z.value(h), s[p] = h, d[p] = N, p++;
          return y = zt.Column.ofConst("MOL", a, zt.Column.Schema.str), C = zt.Column.ofConst("A", a, zt.Column.Schema.str), S = zt.Column.ofConst(1, a, zt.Column.Schema.int), b = zt.Column.ofStringArray(c), g = zt.Table.ofPartialColumns(qB.BasicSchema.atom_site, {
            auth_asym_id: C,
            auth_atom_id: b,
            auth_comp_id: y,
            auth_seq_id: S,
            Cartn_x: zt.Column.ofFloatArray(u),
            Cartn_y: zt.Column.ofFloatArray(l),
            Cartn_z: zt.Column.ofFloatArray(f),
            id: zt.Column.ofIntArray(s),
            label_asym_id: C,
            label_atom_id: b,
            label_comp_id: y,
            label_seq_id: S,
            label_entity_id: zt.Column.ofConst("1", a, zt.Column.Schema.str),
            occupancy: zt.Column.ofConst(1, a, zt.Column.Schema.float),
            type_symbol: b,
            pdbx_PDB_model_num: zt.Column.ofIntArray(d)
          }, a), _ = new r1e.EntityBuilder(), _.setNames([["MOL", "Ligand"]]), _.getEntityId("MOL", 0, "A"), A = new e1e.ComponentBuilder(S, b), A.setNames([["MOL", "Unknown Molecule"]]), A.add("MOL", 0), M = (0, qB.createBasic)({
            entity: _.getEntityTable(),
            chem_comp: A.getChemCompTable(),
            atom_site: g
          }), [
            4,
            (0, Jhe.createModels)(M, Vg.create(t), r)
            // 设置晶胞信息
          ];
        case 1:
          if (P = O.sent(), P.frameCount > 0 && (T = P.representative, t1e.ModelSymmetry.Provider.set(T, m)), x = n[0], w = x.bonds, w)
            for (E = zt.Column.ofIntArray(w.atomA), I = zt.Column.ofIntArray(w.atomB), B = zt.Column.ofIntArray(new Array(w.count).fill(1)), D = jB.IndexPairBonds.fromData({
              pairs: { indexA: E, indexB: I, order: B },
              count: x.count
            }), N = 0; N < P.frameCount; N++)
              jB.IndexPairBonds.Provider.set(P.getFrameAtIndex(N), D);
          return [2, P];
      }
    });
  });
}
va.getMaterialModels = tj;
var Vg;
(function(e) {
  function r(a) {
    return (a == null ? void 0 : a.kind) === "material";
  }
  e.is = r;
  function t(a) {
    return { kind: "material", name: "material", data: a };
  }
  e.create = t;
  function n(a) {
    var i = a.isMaterial, o = a.molecules;
    if (!i || o.length > 1 || !o[0].cell)
      return a;
    for (var c = o[0], s = c.cell, u = c.x, l = c.y, f = c.z, d = u.rowCount, m = new Float32Array(d), p = new Float32Array(d), v = new Float32Array(d), h = 0; h < d; h++) {
      var y = Yf.Vec3.create(u.value(h), l.value(h), f.value(h)), C = Yf.Vec3.transformMat4(Yf.Vec3.zero(), y, s.invertMatrix);
      m[h] = C[0], p[h] = C[1], v[h] = C[2];
    }
    var S = (0, a3.__assign)((0, a3.__assign)({}, o[0]), { fractX: zt.Column.ofFloatArray(m), fractY: zt.Column.ofFloatArray(p), fractZ: zt.Column.ofFloatArray(v) });
    return {
      isMaterial: !0,
      molecules: [S]
    };
  }
  e.formatMol = n;
})(Vg || (Vg = {}));
va.MaterialFormat = Vg;
function a1e(e) {
  return Zhe.Task.create("Parse Material", function(r) {
    return tj(e, r);
  });
}
va.trajectoryFromMaterial = a1e;
function i1e(e, r) {
  var t = e.length;
  isNaN(t) && (t = 0);
  for (var n = "", a = new Float64Array(t), i = new Float64Array(t), o = new Float64Array(t), c = new Array(t), s = 0; s < t; ++s)
    c[s] = e[s].tooltip.split(" ")[0], a[s] = e[s].positions[0][0], i[s] = e[s].positions[0][1], o[s] = e[s].positions[0][2];
  var u = [], l = {
    count: t,
    comment: n,
    x: zt.Column.ofFloatArray(a),
    y: zt.Column.ofFloatArray(i),
    z: zt.Column.ofFloatArray(o),
    type_symbol: zt.Column.ofStringArray(c),
    cell: r
  };
  u.push(l);
  var f = { molecules: u, isMaterial: !0 };
  return f;
}
va.sceneToMaterial = i1e;
Object.defineProperty(J4, "__esModule", { value: !0 });
J4.DumpModel = void 0;
var $B = Te, o1e = wy, u1e = ej, s1e = va;
J4.DumpModel = {
  parse: function(e) {
    return (0, $B.__awaiter)(this, void 0, void 0, function() {
      var r, t, n;
      return (0, $B.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return [4, (0, o1e.parseDump)(e).run()];
          case 1:
            if (r = a.sent(), r.isError)
              throw r;
            return t = r.result, [4, (0, s1e.trajectoryFromMaterial)(t).run()];
          case 2:
            return n = a.sent(), [2, n.frames.map(function(i) {
              return u1e.Structure.ofModel(i, { dynamicBonds: !0 });
            })];
        }
      });
    });
  }
};
var n1 = {}, y0 = {};
Object.defineProperty(y0, "__esModule", { value: !0 });
y0.parseMaterialXyz = y0.parseXyz = void 0;
var i3 = Te, j2 = mr(), nj = Kr, Z1 = Pi, aj = Mi;
function ij(e) {
  var r = e.position >= e.data.length - 1 ? 0 : +Z1.Tokenizer.readLine(e);
  isNaN(r) && (r = 0);
  for (var t = Z1.Tokenizer.readLine(e), n = new Float64Array(r), a = new Float64Array(r), i = new Float64Array(r), o = new Array(r), c = 0; c < r; ++c) {
    var s = Z1.Tokenizer.readLineTrim(e), u = s.split(/\s+/g);
    o[c] = u[0], n[c] = +u[1], a[c] = +u[2], i[c] = +u[3];
  }
  return {
    count: r,
    comment: t,
    x: j2.Column.ofFloatArray(n),
    y: j2.Column.ofFloatArray(a),
    z: j2.Column.ofFloatArray(i),
    type_symbol: j2.Column.ofStringArray(o)
  };
}
function l1e(e) {
  for (var r = (0, Z1.Tokenizer)(e), t = []; ; ) {
    var n = ij(r);
    if (n.count === 0)
      break;
    t.push(n);
  }
  var a = { molecules: t, isMaterial: !1 };
  return aj.ReaderResult.success(a);
}
function c1e(e) {
  for (var r = (0, Z1.Tokenizer)(e), t = []; ; ) {
    var n = ij(r);
    if (n.count === 0)
      break;
    t.push(n);
  }
  var a = { molecules: t, isMaterial: !0 };
  return aj.ReaderResult.success(a);
}
function d1e(e) {
  var r = this;
  return nj.Task.create("Parse Mol", function() {
    return (0, i3.__awaiter)(r, void 0, void 0, function() {
      return (0, i3.__generator)(this, function(t) {
        return [2, l1e(e)];
      });
    });
  });
}
y0.parseXyz = d1e;
function f1e(e) {
  var r = this;
  return nj.Task.create("Parse Mol", function() {
    return (0, i3.__awaiter)(r, void 0, void 0, function() {
      return (0, i3.__generator)(this, function(t) {
        return [2, c1e(e)];
      });
    });
  });
}
y0.parseMaterialXyz = f1e;
var _0 = {};
Object.defineProperty(_0, "__esModule", { value: !0 });
_0.trajectoryFromXyz = _0.XyzFormat = void 0;
var qa = mr(), m1e = Kr, v1e = xc(), KB = Zo, p1e = yl, h1e = _l;
function g1e(e, r) {
  for (var t = e.molecules, n = 0, a = 0, i = t; a < i.length; a++) {
    var o = i[a];
    n += o.count;
  }
  for (var c = new Array(n), s = new Int32Array(n), u = new Float32Array(n), l = new Float32Array(n), f = new Float32Array(n), d = new Int32Array(n), m = 0, p = 0; p < t.length; p++)
    for (var o = t[p], v = 0; v < o.count; v++)
      c[m] = o.type_symbol.value(v), u[m] = o.x.value(v), l[m] = o.y.value(v), f[m] = o.z.value(v), s[m] = v, d[m] = p, m++;
  var h = qa.Column.ofConst("MOL", n, qa.Column.Schema.str), y = qa.Column.ofConst("A", n, qa.Column.Schema.str), C = qa.Column.ofConst(1, n, qa.Column.Schema.int), S = qa.Column.ofStringArray(c), b = qa.Table.ofPartialColumns(KB.BasicSchema.atom_site, {
    auth_asym_id: y,
    auth_atom_id: S,
    auth_comp_id: h,
    auth_seq_id: C,
    Cartn_x: qa.Column.ofFloatArray(u),
    Cartn_y: qa.Column.ofFloatArray(l),
    Cartn_z: qa.Column.ofFloatArray(f),
    id: qa.Column.ofIntArray(s),
    label_asym_id: y,
    label_atom_id: S,
    label_comp_id: h,
    label_seq_id: C,
    label_entity_id: qa.Column.ofConst("1", n, qa.Column.Schema.str),
    occupancy: qa.Column.ofConst(1, n, qa.Column.Schema.float),
    type_symbol: S,
    pdbx_PDB_model_num: qa.Column.ofIntArray(d)
  }, n), g = new h1e.EntityBuilder();
  g.setNames([["MOL", "Unknown Entity"]]), g.getEntityId("MOL", 0, "A");
  var _ = new p1e.ComponentBuilder(C, S);
  _.setNames([["MOL", "Unknown Molecule"]]), _.add("MOL", 0);
  var A = (0, KB.createBasic)({
    entity: g.getEntityTable(),
    chem_comp: _.getChemCompTable(),
    atom_site: b
  });
  return (0, v1e.createModels)(A, o3.create(e), r);
}
var o3;
(function(e) {
  function r(n) {
    return (n == null ? void 0 : n.kind) === "xyz";
  }
  e.is = r;
  function t(n) {
    return { kind: "xyz", name: "xyz", data: n };
  }
  e.create = t;
})(o3 || (o3 = {}));
_0.XyzFormat = o3;
function y1e(e) {
  return m1e.Task.create("Parse XYZ", function(r) {
    return g1e(e, r);
  });
}
_0.trajectoryFromXyz = y1e;
var WB;
function _1e() {
  if (WB) return n1;
  WB = 1, Object.defineProperty(n1, "__esModule", { value: !0 }), n1.XyzModel = void 0;
  var e = Te, r = gn(), t = y0, n = _0, a = sn();
  return n1.XyzModel = {
    parse: function(i) {
      return (0, e.__awaiter)(this, void 0, void 0, function() {
        var o, c;
        return (0, e.__generator)(this, function(s) {
          switch (s.label) {
            case 0:
              return i.trim() ? [4, (0, t.parseXyz)(i).run()] : [2, [(0, a.createEmptyStructure)()]];
            case 1:
              if (o = s.sent(), o.isError)
                throw o;
              return [4, (0, n.trajectoryFromXyz)(o.result).run()];
            case 2:
              return c = s.sent(), [2, [r.Structure.ofModel(c.representative, { dynamicBonds: !0 })]];
          }
        });
      });
    }
  }, n1;
}
var a1 = {}, Ys = {}, eA = {};
Object.defineProperty(eA, "__esModule", { value: !0 });
eA.cifToMaterial = void 0;
var i1 = mr(), b1e = ul, bT = Re, S1e = ls;
function C1e(e, r) {
  var t = e.atom_site._rowCount;
  isNaN(t) && (t = 0);
  for (var n = "", a = e.cell, i = a.length_a, o = a.length_b, c = a.length_c, s = a.angle_alpha, u = a.angle_beta, l = a.angle_gamma, f = b1e.createMaterialCell.apply(null, [i, o, c, s, u, l].map(function(I) {
    return +I.value(0);
  })), d = e.atom_site, m = d.fract_x, p = d.fract_y, v = d.fract_z, h = new Float64Array(t), y = new Float64Array(t), C = new Float64Array(t), S = (0, bT.Vec3)(), b = 0; b < t; ++b)
    bT.Vec3.set(S, m.value(b), p.value(b), v.value(b)), bT.Vec3.transformMat4(S, S, f.matrix), h[b] = S[0], y[b] = S[1], C[b] = S[2];
  var g = e.atom_site, _ = g.type_symbol, A = g.label, M;
  if (_.isDefined) {
    for (var P = new Array(t), b = 0; b < t; ++b) {
      var T = _.value(b);
      T = T.replace(/\-/g, ""), T = T.replace(/\+/g, ""), T = T.replace(/[0-9]/g, ""), P[b] = T;
    }
    M = i1.Column.ofStringArray(P);
  } else {
    for (var P = new Array(t), b = 0; b < t; ++b)
      P[b] = (0, S1e.guessElementSymbolString)(A.value(b), "");
    M = i1.Column.ofStringArray(P);
  }
  var x = [], w = {
    count: t,
    comment: n,
    x: i1.Column.ofFloatArray(h),
    y: i1.Column.ofFloatArray(y),
    z: i1.Column.ofFloatArray(C),
    type_symbol: M,
    cell: f,
    fractX: m,
    fractY: p,
    fractZ: v,
    spaceGroup: e.space_group
  };
  x.push(w);
  var E = { molecules: x, isMaterial: !0 };
  return E;
}
eA.cifToMaterial = C1e;
Object.defineProperty(Ys, "__esModule", { value: !0 });
Ys.trajectoryFromCifCore = Ys.trajectoryFromCifCoreMaterial = Ys.CifCoreFormat = Ys.getSymmetry = void 0;
var XB = Te, Bt = mr(), oj = Kr, A1e = xc(), YB = Zo, x1e = yl, T1e = _l, P1e = Vu, QB = nr(), Qf = Re, M1e = ml(), ZB = Cc, ZM = bG(), w1e = ls, JB = wr(), E1e = eA, D1e = va;
function I1e(e) {
  var r = e.it_number.value(0), t = e["name_h-m_full"].value(0).replace("-", " ");
  return e.it_number.isDefined ? (e["name_h-m_full"].isDefined, r) : t;
}
function uj(e) {
  var r = e.cell, t = e.space_group, n = I1e(t), a = QB.SpacegroupCell.create(n, Qf.Vec3.create(r.length_a.value(0), r.length_b.value(0), r.length_c.value(0)), Qf.Vec3.scale((0, Qf.Vec3)(), Qf.Vec3.create(r.angle_alpha.value(0), r.angle_beta.value(0), r.angle_gamma.value(0)), Math.PI / 180));
  return {
    spacegroup: QB.Spacegroup.create(a),
    assemblies: [],
    isNonStandardCrystalFrame: !1,
    ncsOperators: []
  };
}
Ys.getSymmetry = uj;
function B1e(e, r, t) {
  var n;
  return (0, XB.__awaiter)(this, void 0, void 0, function() {
    var a, i, o, c, s, u, l, f, d, m, p, v, h, y, W, C, S, b, g, _, T, A, W, M, P, T, W, x, w, E, I, B, D, N, O, V, k, W, G, L, R, F, U, H, q, K, Y, X, Z, J, $, Q, W, te, oe, z, j;
    return (0, XB.__generator)(this, function(ae) {
      switch (ae.label) {
        case 0:
          for (a = e.atom_site._rowCount, i = Bt.Column.ofConst("MOL", a, Bt.Column.Schema.str), o = Bt.Column.ofConst("A", a, Bt.Column.Schema.str), c = Bt.Column.ofConst(1, a, Bt.Column.Schema.int), s = uj(e), u = s.spacegroup.cell.fromFractional, l = e.atom_site, f = l.fract_x, d = l.fract_y, m = l.fract_z, p = new Float32Array(a), v = new Float32Array(a), h = new Float32Array(a), y = (0, Qf.Vec3)(), W = 0; W < a; ++W)
            Qf.Vec3.set(y, f.value(W), d.value(W), m.value(W)), Qf.Vec3.transformMat4(y, y, u), p[W] = y[0], v[W] = y[1], h[W] = y[2];
          if (C = e.atom_site, S = C.type_symbol, b = C.label, S.isDefined) {
            for (T = new Array(a), A = new Int8Array(a), W = 0; W < a; ++W)
              M = S.value(W), P = M.length, M[P - 1] === "+" ? A[W] = parseInt(M[P - 2]) : M[P - 2] === "+" ? A[W] = parseInt(M[P - 1]) : M[P - 1] === "-" ? A[W] = -parseInt(M[P - 2]) : M[P - 2] === "-" ? A[W] = -parseInt(M[P - 1]) : (T[W] = M, A[W] = 0), M = M.replace(/\-/g, ""), M = M.replace(/\+/g, ""), M = M.replace(/[0-9]/g, ""), T[W] = M;
            g = Bt.Column.ofStringArray(T), _ = Bt.Column.ofIntArray(A);
          } else {
            for (T = new Array(a), W = 0; W < a; ++W)
              T[W] = (0, w1e.guessElementSymbolString)(b.value(W), "");
            g = Bt.Column.ofStringArray(T), _ = Bt.Column.Undefined(a, Bt.Column.Schema.int);
          }
          return x = Bt.Table.ofPartialColumns(YB.BasicSchema.atom_site, {
            auth_asym_id: o,
            auth_atom_id: b,
            auth_comp_id: i,
            auth_seq_id: c,
            Cartn_x: Bt.Column.ofFloatArray(p),
            Cartn_y: Bt.Column.ofFloatArray(v),
            Cartn_z: Bt.Column.ofFloatArray(h),
            id: Bt.Column.range(0, a - 1),
            label_asym_id: o,
            label_atom_id: b,
            label_comp_id: i,
            label_seq_id: c,
            label_entity_id: Bt.Column.ofConst("1", a, Bt.Column.Schema.str),
            occupancy: e.atom_site.occupancy.isDefined ? e.atom_site.occupancy : Bt.Column.ofConst(1, a, Bt.Column.Schema.float),
            type_symbol: g,
            pdbx_formal_charge: _,
            pdbx_PDB_model_num: Bt.Column.ofConst(1, a, Bt.Column.Schema.int),
            B_iso_or_equiv: e.atom_site.u_iso_or_equiv
          }, a), w = e.chemical.name_common.value(0) || e.chemical.name_systematic.value(0) || e.chemical_formula.sum.value(0), E = new T1e.EntityBuilder(), E.setNames([["MOL", w || "Ligand"]]), E.getEntityId("MOL", 0, "A"), I = new x1e.ComponentBuilder(c, e.atom_site.type_symbol), I.setNames([["MOL", w || "Unknown Molecule"]]), I.add("MOL", 0), B = (0, YB.createBasic)({
            entity: E.getEntityTable(),
            chem_comp: I.getChemCompTable(),
            atom_site: x
          }), [4, (0, A1e.createModels)(B, r, t)];
        case 1:
          if (D = ae.sent(), D.frameCount > 0 && (N = D.representative, M1e.ModelSymmetry.Provider.set(N, s), O = e.geom_bond._rowCount, O > 0)) {
            for (V = {}, k = e.atom_site.label, W = 0, G = k.rowCount; W < G; ++W)
              V[k.value(W)] = W;
            for (L = (n = r.data.frame.categories.ccdc_geom_bond_type) === null || n === void 0 ? void 0 : n.getField(""), R = [], F = [], U = [], H = [], q = [], K = /* @__PURE__ */ new Set(), Y = 0, X = e.geom_bond, Z = X.atom_site_label_1, J = X.atom_site_label_2, $ = X.valence, Q = X.distance, W = 0; W < O; ++W)
              te = V[Z.value(W)], oe = V[J.value(W)], z = te < oe ? (0, JB.cantorPairing)(te, oe) : (0, JB.cantorPairing)(oe, te), !K.has(z) && (K.add(z), R[Y] = te, F[Y] = oe, H[Y] = Q.value(W) || -1, L ? (j = L.str(W), j === "D" ? (U[Y] = 2, q[Y] = 1) : j === "A" ? (U[Y] = 1, q[Y] = 17) : (U[Y] = 1, q[Y] = 1)) : (q[Y] = 1, U[Y] = $.isDefined ? $.value(W) : 1), Y += 1);
            ZB.IndexPairBonds.Provider.set(N, ZB.IndexPairBonds.fromData({ pairs: {
              indexA: Bt.Column.ofIntArray(R),
              indexB: Bt.Column.ofIntArray(F),
              order: Bt.Column.ofIntArray(U),
              distance: Bt.Column.ofFloatArray(H),
              flag: Bt.Column.ofIntArray(q)
            }, count: a }));
          }
          return [2, D];
      }
    });
  });
}
function N1e(e) {
  if (b0.is(e.sourceData)) {
    var r = e.sourceData.data.db, t = r.atom_site, n = r.atom_site_aniso, a = Bt.Table.ofPartialColumns(ZM.AtomSiteAnisotrop.Schema, {
      U: n.u
    }, n._rowCount), i = ZM.AtomSiteAnisotrop.getElementToAnsiotropFromLabel(t.label, n.label);
    return { data: a, elementToAnsiotrop: i };
  }
}
function V1e(e) {
  return b0.is(e.sourceData) ? e.sourceData.data.db.atom_site_aniso.u.isDefined : !1;
}
ZM.AtomSiteAnisotrop.Provider.formatRegistry.add("cifCore", N1e, V1e);
var b0;
(function(e) {
  function r(n) {
    return (n == null ? void 0 : n.kind) === "cifCore";
  }
  e.is = r;
  function t(n, a) {
    a || (a = P1e.CIF.schema.cifCore(n));
    var i = a.database_code.depnum_ccdc_archive.value(0) || a.database_code.depnum_ccdc_fiz.value(0) || a.database_code.icsd.value(0) || a.database_code.mdf.value(0) || a.database_code.nbs.value(0) || a.database_code.csd.value(0) || a.database_code.cod.value(0) || a._name;
    return { kind: "cifCore", name: i, data: { db: a, frame: n } };
  }
  e.fromFrame = t;
})(b0 || (b0 = {}));
Ys.CifCoreFormat = b0;
function R1e(e) {
  var r = b0.fromFrame(e), t = (0, E1e.cifToMaterial)(r.data.db, e);
  return oj.Task.create("Parse Material", function(n) {
    return (0, D1e.getMaterialModels)(t, n);
  });
}
Ys.trajectoryFromCifCoreMaterial = R1e;
function O1e(e) {
  var r = b0.fromFrame(e);
  return oj.Task.create("Parse CIF Core", function(t) {
    return B1e(r.data.db, r, t);
  });
}
Ys.trajectoryFromCifCore = O1e;
var eN;
function F1e() {
  if (eN) return a1;
  eN = 1, Object.defineProperty(a1, "__esModule", { value: !0 }), a1.CifModel = void 0;
  var e = Te, r = gn(), t = sn(), n = Vu, a = Jo(), i = Ys, o = 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;
  };
  return a1.CifModel = {
    parse: function(c) {
      return (0, e.__awaiter)(this, void 0, void 0, function() {
        var s, u, l, f, d, m, p;
        return (0, e.__generator)(this, function(v) {
          switch (v.label) {
            case 0:
              return c.trim() ? [4, n.CIF.parse(c).run()] : [2, [(0, t.createEmptyStructure)()]];
            case 1:
              if (s = v.sent(), s.isError)
                throw s;
              u = o(c) === -1 ? a.trajectoryFromMmCIF : i.trajectoryFromCifCore, l = [], f = 0, d = s.result.blocks.length, v.label = 2;
            case 2:
              return f < d ? (m = s.result.blocks[f], [4, u(m).run()]) : [3, 5];
            case 3:
              p = v.sent(), l.push(r.Structure.ofModel(p.frames[0], { dynamicBonds: !0 })), v.label = 4;
            case 4:
              return f++, [3, 2];
            case 5:
              return [2, l];
          }
        });
      });
    }
  }, a1;
}
var o1 = {}, rN;
function L1e() {
  if (rN) return o1;
  rN = 1, Object.defineProperty(o1, "__esModule", { value: !0 }), o1.MMCifModel = void 0;
  var e = Te, r = gn(), t = sn(), n = Vu, a = Jo();
  return o1.MMCifModel = {
    parse: function(i) {
      return (0, e.__awaiter)(this, void 0, void 0, function() {
        var o, c, s, u, l, f;
        return (0, e.__generator)(this, function(d) {
          switch (d.label) {
            case 0:
              return i.trim() ? [4, n.CIF.parse(i).run()] : [2, [(0, t.createEmptyStructure)()]];
            case 1:
              if (o = d.sent(), o.isError)
                throw o;
              c = [], s = 0, u = o.result.blocks.length, d.label = 2;
            case 2:
              return s < u ? (l = o.result.blocks[s], [4, (0, a.trajectoryFromMmCIF)(l).run()]) : [3, 5];
            case 3:
              f = d.sent(), c.push(r.Structure.ofModel(f.frames[0], { dynamicBonds: !0 })), d.label = 4;
            case 4:
              return s++, [3, 2];
            case 5:
              return [2, c];
          }
        });
      });
    }
  }, o1;
}
var u1 = {}, rA = {};
Object.defineProperty(rA, "__esModule", { value: !0 });
rA.parseMaterialPOSCAR = void 0;
var tN = Te, Nf = mr(), Tm = Re, k1e = Kr, Xc = Pi, U1e = ul, z1e = Mi;
function G1e(e) {
  var r = Xc.Tokenizer.readLine(e), t = +Xc.Tokenizer.readLine(e), n = new Float64Array(3), a = new Float64Array(3), i = new Float64Array(3);
  [n, a, i].forEach(function(x) {
    var w = Xc.Tokenizer.readLineTrim(e).trim(), E = w.split(/\s+/g);
    x[0] = +E[0], x[1] = +E[1], x[2] = +E[2];
  });
  for (var o = (0, U1e.createMaterialCellFromVec)(n, a, i), c = Xc.Tokenizer.readLineTrim(e).trim().split(/\s+/g), s = Xc.Tokenizer.readLineTrim(e).trim().split(/\s+/g), u = Xc.Tokenizer.readLineTrim(e), l = ["cartesian", "direct"].includes(u.toLowerCase()) ? "cartesian" : u, f = s.reduce(function(x, w) {
    return +x + +w;
  }, 0), d = new Float64Array(f), m = new Float64Array(f), p = new Float64Array(f), v = new Float64Array(f), h = new Float64Array(f), y = new Float64Array(f), C = new Float64Array(f), S = new Float64Array(f), b = new Float64Array(f), g = new Array(f), _ = function(x) {
    for (var w = function() {
      return x === 0 ? 0 : s.slice(0, x).reduce(function(N, O) {
        return +N + +O;
      }, 0);
    }(), E = 0; E < Number(s[x]); E++) {
      var I = w + E, B = Xc.Tokenizer.readLineTrim(e).trim(), D = B.split(/\s+/g);
      g[I] = c[x], C[I] = +D[0], S[I] = +D[1], b[I] = +D[2];
    }
  }, A = 0; A < s.length; A++)
    _(A);
  if (l === "cartesian")
    for (var A = 0; A < f; A++) {
      d[A] = C[A], m[A] = S[A], p[A] = b[A];
      var M = Tm.Vec3.create(d[A], m[A], p[A]), P = Tm.Vec3.transformMat4(Tm.Vec3.zero(), M, o.invertMatrix);
      v[A] = P[0], h[A] = P[1], y[A] = P[2];
    }
  else
    for (var A = 0; A < f; A++) {
      v[A] = C[A], h[A] = S[A], y[A] = b[A];
      var T = Tm.Vec3.create(d[A], m[A], p[A]), P = Tm.Vec3.transformMat4(Tm.Vec3.zero(), T, o.matrix);
      d[A] = P[0], m[A] = P[1], p[A] = P[2];
    }
  return {
    count: f,
    comment: r,
    scalingFactor: t,
    // coordinateSystem,
    dynamics: l,
    type_symbol: Nf.Column.ofStringArray(g),
    x: Nf.Column.ofFloatArray(d),
    y: Nf.Column.ofFloatArray(m),
    z: Nf.Column.ofFloatArray(p),
    fractX: Nf.Column.ofFloatArray(d),
    fractY: Nf.Column.ofFloatArray(m),
    fractZ: Nf.Column.ofFloatArray(p),
    cell: o
  };
}
function q1e(e) {
  var r = (0, Xc.Tokenizer)(e), t = [], n = G1e(r);
  t.push(n);
  var a = {
    isMaterial: !0,
    molecules: t
  };
  return z1e.ReaderResult.success(a);
}
function H1e(e) {
  var r = this;
  return k1e.Task.create("Parse Mol", function() {
    return (0, tN.__awaiter)(r, void 0, void 0, function() {
      return (0, tN.__generator)(this, function(t) {
        return [2, q1e(e)];
      });
    });
  });
}
rA.parseMaterialPOSCAR = H1e;
var nN;
function j1e() {
  if (nN) return u1;
  nN = 1, Object.defineProperty(u1, "__esModule", { value: !0 }), u1.POSCARModel = void 0;
  var e = Te, r = rA, t = va, n = gn(), a = sn();
  return u1.POSCARModel = {
    parse: function(i) {
      return (0, e.__awaiter)(this, void 0, void 0, function() {
        var o, c;
        return (0, e.__generator)(this, function(s) {
          switch (s.label) {
            case 0:
              return i.trim() ? [4, (0, r.parseMaterialPOSCAR)(i).run()] : [2, [(0, a.createEmptyStructure)()]];
            case 1:
              if (o = s.sent(), o.isError)
                throw o;
              return [4, (0, t.trajectoryFromMaterial)(o.result).run()];
            case 2:
              return c = s.sent(), [2, c.frames.map(function(u) {
                return n.Structure.ofModel(u, { dynamicBonds: !0 });
              })];
          }
        });
      });
    }
  }, u1;
}
var tA = {}, Ey = {};
Object.defineProperty(Ey, "__esModule", { value: !0 });
Ey.parseMaterialInfo = void 0;
var $2 = mr(), $1e = ul;
function K1e(e, r, t) {
  for (var n = function() {
    if (t) {
      var l = t.a, f = t.b, d = t.c, m = t.alpha, p = t.beta, v = t.gamma;
      return (0, $1e.createMaterialCell)(l, f, d, m, p, v);
    }
  }(), a = e.length, i = new Float64Array(a), o = new Float64Array(a), c = new Float64Array(a), s = new Array(a), u = 0; u < a; u++)
    s[u] = e[u], i[u] = r[u][0], o[u] = r[u][1], c[u] = r[u][2];
  return {
    count: a,
    comment: "",
    type_symbol: $2.Column.ofStringArray(s),
    x: $2.Column.ofFloatArray(i),
    y: $2.Column.ofFloatArray(o),
    z: $2.Column.ofFloatArray(c),
    cell: n
  };
}
function W1e(e) {
  var r = [], t = K1e(e.elements, e.xyzs, e.lattice);
  r.push(t);
  var n = {
    isMaterial: !0,
    molecules: r
  };
  return n;
}
function X1e(e) {
  return W1e(e);
}
Ey.parseMaterialInfo = X1e;
Object.defineProperty(tA, "__esModule", { value: !0 });
tA.MaterialModel = void 0;
var aN = Te, Y1e = gn(), Q1e = va, Z1e = Ey;
tA.MaterialModel = {
  parse: function(e) {
    return (0, aN.__awaiter)(this, void 0, void 0, function() {
      var r, t;
      return (0, aN.__generator)(this, function(n) {
        switch (n.label) {
          case 0:
            return r = (0, Z1e.parseMaterialInfo)(e), [4, (0, Q1e.trajectoryFromMaterial)(r).run()];
          case 1:
            return t = n.sent(), [2, t.frames.map(function(a) {
              return Y1e.Structure.ofModel(a, { dynamicBonds: !0 });
            })];
        }
      });
    });
  }
};
var nA = {}, Nd = {}, mo = {};
Object.defineProperty(mo, "__esModule", { value: !0 });
mo.MatScene = mo.MatPolyhedraScenc = mo.MatUnitCellScenc = mo.MatBondsScenc = mo.MatAtomsScenc = mo.SceneJson = void 0;
var Dy = Te, Gp = (
  /** @class */
  /* @__PURE__ */ function() {
    function e(r, t, n, a) {
      this.name = r, this.visible = t, this.origin = n, this.contents = a;
    }
    return e;
  }()
);
mo.SceneJson = Gp;
var J1e = (
  /** @class */
  function(e) {
    (0, Dy.__extends)(r, e);
    function r() {
      return e !== null && e.apply(this, arguments) || this;
    }
    return r;
  }(Gp)
);
mo.MatAtomsScenc = J1e;
var ege = (
  /** @class */
  function(e) {
    (0, Dy.__extends)(r, e);
    function r() {
      return e !== null && e.apply(this, arguments) || this;
    }
    return r;
  }(Gp)
);
mo.MatBondsScenc = ege;
var rge = (
  /** @class */
  function(e) {
    (0, Dy.__extends)(r, e);
    function r() {
      return e !== null && e.apply(this, arguments) || this;
    }
    return r;
  }(Gp)
);
mo.MatUnitCellScenc = rge;
var tge = (
  /** @class */
  function(e) {
    (0, Dy.__extends)(r, e);
    function r() {
      return e !== null && e.apply(this, arguments) || this;
    }
    return r;
  }(Gp)
);
mo.MatPolyhedraScenc = tge;
var nge = (
  /** @class */
  function(e) {
    (0, Dy.__extends)(r, e);
    function r() {
      return e !== null && e.apply(this, arguments) || this;
    }
    return r.create = function(t) {
      var n = t.name, a = t.visible, i = t.origin, o = t.contents, c = {};
      o.forEach(function(u) {
        Reflect.defineProperty(c, u.name, {
          value: u
        });
      });
      var s = new r(n, a, i, c);
      return s;
    }, r;
  }(Gp)
);
mo.MatScene = nge;
Object.defineProperty(Nd, "__esModule", { value: !0 });
Nd.getMolBondsFromPymatgen = Nd.parsePymatgen = void 0;
var rv = Te, K2 = mr(), age = Kr, ige = ul, oge = Mi, uge = mo;
function sge(e) {
  var r = e.scene, t = e.structure, n = uge.MatScene.create(r).contents, a = n.atoms, i = n.bonds, o = "", c = a.contents.length, s = new Float64Array(c), u = new Float64Array(c), l = new Float64Array(c), f = new Array(c), d = function() {
    if (t.lattice) {
      var C = t.lattice, S = C.a, b = C.b, g = C.c, _ = C.alpha, A = C.beta, M = C.gamma;
      return (0, ige.createMaterialCell)(S, b, g, _, A, M);
    }
  }(), m = {};
  i.contents.forEach(function(C) {
    var S = C.positionPairs;
    S.forEach(function(b) {
      var g = b[1], _ = g.join(",");
      m[_] = m[_] || [], m[_].push(b[0]);
    });
  });
  var p = {};
  a.contents.forEach(function(C, S) {
    var b, g = C.positions, _ = C.tooltip, A = g[0];
    s[S] = A[0], u[S] = A[1], l[S] = A[2], f[S] = ((b = _.split(/\s/)[0].match(/[A-Za-z]/g)) === null || b === void 0 ? void 0 : b.join("")) || "";
    for (var M in m) {
      var P = m[M];
      p[M] = p[M] || [], P[0].every(function(T, x) {
        return T === A[x];
      }) && (p[M][0] = S), P[1].every(function(T, x) {
        return T === A[x];
      }) && (p[M][1] = S);
    }
  });
  var v = [], h = [];
  Object.values(p).forEach(function(C) {
    v.push(C[0]), h.push(C[1]);
  });
  var y = {
    count: v.length * 2,
    atomA: (0, rv.__spreadArray)((0, rv.__spreadArray)([], v, !0), h, !0),
    atomB: (0, rv.__spreadArray)((0, rv.__spreadArray)([], h, !0), v, !0)
  };
  return {
    comment: o,
    count: c,
    x: K2.Column.ofFloatArray(s),
    y: K2.Column.ofFloatArray(u),
    z: K2.Column.ofFloatArray(l),
    type_symbol: K2.Column.ofStringArray(f),
    cell: d,
    bonds: y
  };
}
function lge(e) {
  var r = e.map(sge), t = { molecules: r, isMaterial: !0 };
  return oge.ReaderResult.success(t);
}
function cge(e) {
  var r = this;
  return age.Task.create("Parse Mol", function() {
    return (0, rv.__awaiter)(r, void 0, void 0, function() {
      return (0, rv.__generator)(this, function(t) {
        return [2, lge(e)];
      });
    });
  });
}
Nd.parsePymatgen = cge;
function dge(e, r) {
  var t = e.graph, n = t.graphs, a = n.nodes, i = n.adjacency, o = [], c = [];
  return a.forEach(function(s, u) {
    i[u].forEach(function(l) {
      l.to_jimage.some(function(f) {
        return f !== 0;
      }) || (o.push(s.id), c.push(l.id));
    });
  }), {
    count: o.length,
    atomA: o,
    atomB: c
  };
}
Nd.getMolBondsFromPymatgen = dge;
Object.defineProperty(nA, "__esModule", { value: !0 });
nA.PymatgenModel = void 0;
var iN = Te, fge = gn(), mge = va, vge = Nd;
nA.PymatgenModel = {
  parse: function(e) {
    return (0, iN.__awaiter)(this, void 0, void 0, function() {
      var r, t;
      return (0, iN.__generator)(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, (0, vge.parsePymatgen)(e).run()];
          case 1:
            if (r = n.sent(), r.isError)
              throw new Error(r.message);
            return [4, (0, mge.trajectoryFromMaterial)(r.result).run()];
          case 2:
            return t = n.sent(), [2, t.frames.map(function(a) {
              return fge.Structure.ofModel(a, { dynamicBonds: !0 });
            })];
        }
      });
    });
  }
};
var s1 = {}, aA = {};
Object.defineProperty(aA, "__esModule", { value: !0 });
aA.parseMol2 = void 0;
var Vd = Te, Pn = mr(), nt = Pi, Li = Hi, pge = Mi, tD = Kr, nD = nt.Tokenizer.skipWhitespace, sj = nt.Tokenizer.eatValue, yu = nt.Tokenizer.markLine, _u = nt.Tokenizer.getTokenString, lj = nt.Tokenizer.readLine;
function hge() {
  return {
    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: ""
  };
}
function gge(e, r) {
  return {
    tokenizer: e,
    molecule: hge(),
    runtimeCtx: r
  };
}
var cj = /\s+/g;
function yge(e) {
  for (var r = e.tokenizer, t = e.molecule; _u(r) !== "@<TRIPOS>MOLECULE" && r.position < r.data.length; )
    yu(r);
  yu(r), t.mol_name = _u(r), yu(r);
  var n = _u(r).trim().split(cj);
  t.num_atoms = parseInt(n[0]), t.num_bonds = parseInt(n[1]), t.num_subst = parseInt(n[2]), t.num_feat = parseInt(n[3]), t.num_sets = parseInt(n[4]), yu(r);
  var a = _u(r);
  if (!a.startsWith("@<TRIPOS>")) {
    t.mol_type = a, yu(r);
    var i = _u(r);
    if (!i.startsWith("@<TRIPOS>")) {
      t.charge_type = i, yu(r);
      var o = _u(r);
      if (!o.startsWith("@<TRIPOS>")) {
        t.status_bits = o, yu(r);
        var c = _u(r);
        c.startsWith("@<TRIPOS>") || (t.mol_comment = c);
      }
    }
  }
}
function _ge(e) {
  return (0, Vd.__awaiter)(this, void 0, void 0, function() {
    var r, t, n, a, i, o, c, s, u, l, f, d, m, p, v, h, y, C, S, b, g, _, A;
    return (0, Vd.__generator)(this, function(M) {
      switch (M.label) {
        case 0:
          for (r = e.tokenizer, t = e.molecule; _u(r) !== "@<TRIPOS>ATOM" && r.position < r.data.length; )
            yu(r);
          return n = r.position, a = r.lineNumber, i = lj(r), o = i.trim().split(/\s+/g), c = o.length, s = nt.TokenBuilder.create(r.data, t.num_atoms * 2), u = nt.TokenBuilder.create(r.data, t.num_atoms * 2), l = nt.TokenBuilder.create(r.data, t.num_atoms * 2), f = nt.TokenBuilder.create(r.data, t.num_atoms * 2), d = nt.TokenBuilder.create(r.data, t.num_atoms * 2), m = nt.TokenBuilder.create(r.data, t.num_atoms * 2), p = nt.TokenBuilder.create(r.data, t.num_atoms * 2), v = nt.TokenBuilder.create(r.data, t.num_atoms * 2), h = nt.TokenBuilder.create(r.data, t.num_atoms * 2), y = nt.TokenBuilder.create(r.data, t.num_atoms * 2), C = Pn.Column.Undefined(t.num_atoms, Pn.Column.Schema.float), S = Pn.Column.Undefined(t.num_atoms, Pn.Column.Schema.int), b = Pn.Column.Undefined(t.num_atoms, Pn.Column.Schema.str), r.position = n, r.lineNumber = a, g = r.length, _ = 0, [4, (0, tD.chunkedSubtask)(e.runtimeCtx, 1e5, void 0, function(P) {
            for (var T = Math.min(t.num_atoms - _, P), x = 0; x < T; x++)
              for (var w = 0; w < c; w++)
                switch (nD(r), r.tokenStart = r.position, sj(r), w) {
                  case 0:
                    nt.TokenBuilder.addUnchecked(s, r.tokenStart, r.tokenEnd);
                    break;
                  case 1:
                    nt.TokenBuilder.addUnchecked(u, r.tokenStart, r.tokenEnd);
                    break;
                  case 2:
                    nt.TokenBuilder.addUnchecked(l, r.tokenStart, r.tokenEnd);
                    break;
                  case 3:
                    nt.TokenBuilder.addUnchecked(f, r.tokenStart, r.tokenEnd);
                    break;
                  case 4:
                    nt.TokenBuilder.addUnchecked(d, r.tokenStart, r.tokenEnd);
                    break;
                  case 5:
                    nt.TokenBuilder.addUnchecked(m, r.tokenStart, r.tokenEnd);
                    break;
                  case 6:
                    nt.TokenBuilder.addUnchecked(p, r.tokenStart, r.tokenEnd);
                    break;
                  case 7:
                    nt.TokenBuilder.addUnchecked(v, r.tokenStart, r.tokenEnd);
                    break;
                  case 8:
                    nt.TokenBuilder.addUnchecked(h, r.tokenStart, r.tokenEnd);
                    break;
                  case 9:
                    nt.TokenBuilder.addUnchecked(y, r.tokenStart, r.tokenEnd);
                    break;
                }
            return _ += T, T;
          }, function(P) {
            return P.update({
              message: "Parsing...",
              current: r.position,
              max: g
            });
          })];
        case 1:
          return M.sent(), A = {
            count: t.num_atoms,
            atom_id: (0, Li.TokenColumnProvider)(s)(Pn.Column.Schema.int),
            atom_name: (0, Li.TokenColumnProvider)(u)(Pn.Column.Schema.str),
            x: (0, Li.TokenColumnProvider)(l)(Pn.Column.Schema.float),
            y: (0, Li.TokenColumnProvider)(f)(Pn.Column.Schema.float),
            z: (0, Li.TokenColumnProvider)(d)(Pn.Column.Schema.float),
            atom_type: c > 5 ? (0, Li.TokenColumnProvider)(m)(Pn.Column.Schema.str) : b,
            subst_id: c > 6 ? (0, Li.TokenColumnProvider)(p)(Pn.Column.Schema.int) : S,
            subst_name: c > 7 ? (0, Li.TokenColumnProvider)(v)(Pn.Column.Schema.str) : b,
            charge: c > 8 ? (0, Li.TokenColumnProvider)(h)(Pn.Column.Schema.float) : C,
            status_bit: c > 9 ? (0, Li.TokenColumnProvider)(y)(Pn.Column.Schema.str) : b
          }, [2, A];
      }
    });
  });
}
function bge(e) {
  return (0, Vd.__awaiter)(this, void 0, void 0, function() {
    var r, t, n, a, i, o, c, s, u, l, f, d, m, p, v;
    return (0, Vd.__generator)(this, function(h) {
      switch (h.label) {
        case 0:
          for (r = e.tokenizer, t = e.molecule; _u(r) !== "@<TRIPOS>BOND" && r.position < r.data.length; )
            yu(r);
          return n = r.position, a = r.lineNumber, i = lj(r), o = i.trim().split(/\s+/g), c = o.length, s = nt.TokenBuilder.create(r.data, t.num_bonds * 2), u = nt.TokenBuilder.create(r.data, t.num_bonds * 2), l = nt.TokenBuilder.create(r.data, t.num_bonds * 2), f = nt.TokenBuilder.create(r.data, t.num_bonds * 2), d = nt.TokenBuilder.create(r.data, t.num_bonds * 2), r.position = n, r.lineNumber = a, m = r.length, p = 0, [4, (0, tD.chunkedSubtask)(e.runtimeCtx, 1e5, void 0, function(y) {
            for (var C = Math.min(t.num_bonds - p, y), S = 0; S < C; S++)
              for (var b = 0; b < c; b++)
                switch (nD(r), r.tokenStart = r.position, sj(r), b) {
                  case 0:
                    nt.TokenBuilder.addUnchecked(s, r.tokenStart, r.tokenEnd);
                    break;
                  case 1:
                    nt.TokenBuilder.addUnchecked(u, r.tokenStart, r.tokenEnd);
                    break;
                  case 2:
                    nt.TokenBuilder.addUnchecked(l, r.tokenStart, r.tokenEnd);
                    break;
                  case 3:
                    nt.TokenBuilder.addUnchecked(f, r.tokenStart, r.tokenEnd);
                    break;
                  default:
                    nt.TokenBuilder.addUnchecked(d, r.tokenStart, r.tokenEnd);
                    break;
                }
            return p += C, C;
          }, function(y) {
            return y.update({
              message: "Parsing...",
              current: r.position,
              max: m
            });
          })];
        case 1:
          return h.sent(), v = {
            count: t.num_bonds,
            bond_id: (0, Li.TokenColumnProvider)(s)(Pn.Column.Schema.int),
            origin_atom_id: (0, Li.TokenColumnProvider)(u)(Pn.Column.Schema.int),
            target_atom_id: (0, Li.TokenColumnProvider)(l)(Pn.Column.Schema.int),
            bond_type: (0, Li.TokenColumnProvider)(f)(Pn.Column.Schema.str),
            status_bits: c > 4 ? (0, Li.TokenColumnProvider)(d)(Pn.Column.Schema.str) : Pn.Column.Undefined(t.num_bonds, Pn.Column.Schema.str)
          }, [2, v];
      }
    });
  });
}
function Sge(e) {
  for (var r = e.tokenizer; r.position < r.data.length; ) {
    var t = _u(r);
    if (t === "@<TRIPOS>MOLECULE")
      return;
    if (t === "@<TRIPOS>CRYSIN")
      break;
    yu(r);
  }
  if (!(r.position >= r.data.length)) {
    yu(r);
    var n = _u(r).trim().split(cj);
    return {
      a: parseFloat(n[0]),
      b: parseFloat(n[1]),
      c: parseFloat(n[2]),
      alpha: parseFloat(n[3]),
      beta: parseFloat(n[4]),
      gamma: parseFloat(n[5]),
      spaceGroup: parseInt(n[6], 10),
      setting: parseInt(n[7], 10)
    };
  }
}
function Cge(e, r, t) {
  return (0, Vd.__awaiter)(this, void 0, void 0, function() {
    var n, a, i, o, c, s, u;
    return (0, Vd.__generator)(this, function(l) {
      switch (l.label) {
        case 0:
          n = (0, nt.Tokenizer)(r), e.update({ message: "Parsing...", current: 0, max: r.length }), a = [], l.label = 1;
        case 1:
          return n.position < r.length ? (i = gge(n, e), yge(i), [4, _ge(i)]) : [3, 4];
        case 2:
          return o = l.sent(), [4, bge(i)];
        case 3:
          for (c = l.sent(), s = Sge(i), a.push({ molecule: i.molecule, atoms: o, bonds: c, crysin: s }), nD(n); _u(n) !== "@<TRIPOS>MOLECULE" && n.position < n.data.length; )
            yu(n);
          return [3, 1];
        case 4:
          return u = { name: t, structures: a }, [2, pge.ReaderResult.success(u)];
      }
    });
  });
}
function Age(e, r) {
  var t = this;
  return tD.Task.create("Parse MOL2", function(n) {
    return (0, Vd.__awaiter)(t, void 0, void 0, function() {
      return (0, Vd.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return [4, Cge(n, e, r)];
          case 1:
            return [2, a.sent()];
        }
      });
    });
  });
}
aA.parseMol2 = Age;
var Xv = {};
Object.defineProperty(Xv, "__esModule", { value: !0 });
Xv.trajectoryFromMol2 = Xv.Mol2Format = void 0;
var oN = Te, fn = mr(), xge = Kr, Tge = xc(), uN = Zo, Pge = yl, Mge = _l, sN = Cc, wge = Wd, Ege = Je(), Dge = ls, Ige = ml(), lN = nr(), W2 = Re;
function Bge(e, r) {
  return (0, oN.__awaiter)(this, void 0, void 0, function() {
    var t, n, a, i, o, c, s, u, l, f, d, m, p, v, h, y, C, S, b, g, _, A, M, P, T, x, w, E;
    return (0, oN.__generator)(this, function(I) {
      switch (I.label) {
        case 0:
          t = [], n = 0, a = e.structures.length, I.label = 1;
        case 1:
          if (!(n < a)) return [3, 4];
          for (i = e.structures[n], o = i.molecule, c = i.atoms, s = i.bonds, u = i.crysin, l = fn.Column.ofConst("A", c.count, fn.Column.Schema.str), f = new Array(c.count), d = !1, m = 0; m < c.count; ++m)
            if (c.atom_type.value(m).includes(".")) {
              d = !0;
              break;
            }
          for (p = 0; p < c.count; ++p)
            f[p] = d ? c.atom_type.value(p).split(".")[0].toUpperCase() : (0, Dge.guessElementSymbolString)(c.atom_name.value(p), c.subst_name.value(p));
          for (v = fn.Table.ofPartialColumns(uN.BasicSchema.atom_site, {
            auth_asym_id: l,
            auth_atom_id: fn.Column.asArrayColumn(c.atom_name),
            auth_comp_id: c.subst_name,
            auth_seq_id: c.subst_id,
            Cartn_x: fn.Column.asArrayColumn(c.x, Float32Array),
            Cartn_y: fn.Column.asArrayColumn(c.y, Float32Array),
            Cartn_z: fn.Column.asArrayColumn(c.z, Float32Array),
            id: fn.Column.asArrayColumn(c.atom_id),
            label_asym_id: l,
            label_atom_id: fn.Column.asArrayColumn(c.atom_name),
            label_comp_id: c.subst_name,
            label_seq_id: c.subst_id,
            label_entity_id: fn.Column.ofConst("1", c.count, fn.Column.Schema.str),
            occupancy: fn.Column.ofConst(1, c.count, fn.Column.Schema.float),
            type_symbol: fn.Column.ofStringArray(f),
            pdbx_PDB_model_num: fn.Column.ofConst(n, c.count, fn.Column.Schema.int)
          }, c.count), h = new Mge.EntityBuilder(), h.setNames([["MOL", o.mol_name || "Ligand"]]), h.getEntityId("MOL", 0, "A"), y = new Pge.ComponentBuilder(c.subst_id, c.atom_name), C = 0, S = c.subst_name.rowCount; C < S; ++C)
            y.add(c.subst_name.value(C), C);
          return b = (0, uN.createBasic)({
            entity: h.getEntityTable(),
            chem_comp: y.getChemCompTable(),
            atom_site: v
          }), [4, (0, Tge.createModels)(b, u3.create(e), r)];
        case 2:
          g = I.sent(), g.frameCount > 0 && (_ = fn.Column.ofIntArray(fn.Column.mapToArray(s.origin_atom_id, function(B) {
            return B - 1;
          }, Int32Array)), A = fn.Column.ofIntArray(fn.Column.mapToArray(s.target_atom_id, function(B) {
            return B - 1;
          }, Int32Array)), M = s.bond_id, P = fn.Column.ofIntArray(fn.Column.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)), T = fn.Column.ofIntArray(fn.Column.mapToArray(s.bond_type, function(B) {
            switch (B) {
              case "ar":
              case "am":
                return 17;
              case "du":
              case "nc":
                return 0;
              case "un":
              default:
                return 1;
            }
          }, Int8Array)), x = sN.IndexPairBonds.fromData({
            pairs: { key: M, indexA: _, indexB: A, order: P, flag: T },
            count: c.count
          }), w = g.representative, sN.IndexPairBonds.Provider.set(w, x), wge.AtomPartialCharge.Provider.set(w, {
            data: c.charge,
            type: o.charge_type
          }), u && (E = Nge(u), E && Ige.ModelSymmetry.Provider.set(w, E)), t.push(w)), I.label = 3;
        case 3:
          return ++n, [3, 1];
        case 4:
          return [2, new Ege.ArrayTrajectory(t)];
      }
    });
  });
}
function Nge(e) {
  if (e.setting === 1) {
    var r = lN.SpacegroupCell.create(e.spaceGroup, W2.Vec3.create(e.a, e.b, e.c), W2.Vec3.scale((0, W2.Vec3)(), W2.Vec3.create(e.alpha, e.beta, e.gamma), Math.PI / 180));
    return {
      spacegroup: lN.Spacegroup.create(r),
      assemblies: [],
      isNonStandardCrystalFrame: !1,
      ncsOperators: []
    };
  }
}
var u3;
(function(e) {
  function r(n) {
    return (n == null ? void 0 : n.kind) === "mol2";
  }
  e.is = r;
  function t(n) {
    return { kind: "mol2", name: n.name, data: n };
  }
  e.create = t;
})(u3 || (u3 = {}));
Xv.Mol2Format = u3;
function Vge(e) {
  return xge.Task.create("Parse MOL2", function(r) {
    return Bge(e, r);
  });
}
Xv.trajectoryFromMol2 = Vge;
var cN;
function Rge() {
  if (cN) return s1;
  cN = 1, Object.defineProperty(s1, "__esModule", { value: !0 }), s1.Mol2Model = void 0;
  var e = Te, r = gn(), t = sn(), n = aA, a = Xv;
  return s1.Mol2Model = {
    parse: function(i) {
      return (0, e.__awaiter)(this, void 0, void 0, function() {
        var o, c;
        return (0, e.__generator)(this, function(s) {
          switch (s.label) {
            case 0:
              return i.trim() ? [4, (0, n.parseMol2)(i, "").run()] : [2, [(0, t.createEmptyStructure)()]];
            case 1:
              if (o = s.sent(), o.isError)
                throw o;
              return [4, (0, a.trajectoryFromMol2)(o.result).run()];
            case 2:
              return c = s.sent(), [2, [r.Structure.ofModel(c.representative, { dynamicBonds: !0 })]];
          }
        });
      });
    }
  }, s1;
}
var dN;
function qp() {
  if (dN) return Qh;
  dN = 1;
  var e;
  Object.defineProperty(Qh, "__esModule", { value: !0 }), Qh.FormatProvider = void 0;
  var r = wpe(), t = Jt, n = zpe(), a = rhe(), i = W4, o = Y4, c = J4, s = _1e(), u = F1e(), l = L1e(), f = j1e(), d = tA, m = nA, p = Rge();
  return Qh.FormatProvider = (e = {}, e[t.Format.Pdb] = r.PdbModel, e[t.Format.Mol] = n.MolModel, e[t.Format.Sdf] = a.SdfModel, e[t.Format.Gro] = i.GroModel, e[t.Format.Xtc] = o.XtcModel, e[t.Format.Dump] = c.DumpModel, e[t.Format.Xyz] = s.XyzModel, e[t.Format.Cif] = u.CifModel, e[t.Format.MMCif] = l.MMCifModel, e[t.Format.MCif] = l.MMCifModel, e[t.Format.POSCAR] = f.POSCARModel, e[t.Format.Material] = d.MaterialModel, e[t.Format.Pymatgen] = m.PymatgenModel, e[t.Format.Mol2] = p.Mol2Model, e), Qh;
}
var dj = {}, Ue = mC, pv = by, dr = Je(), JM = Gr, Oge = ds, Fge = cs, ST = _s, Lge = wr(), fN = xE(), kge = hr, fr = pv.QuerySymbolRuntime.Const, tr = pv.QuerySymbolRuntime.Dynamic, Uge = [
  // ============= TYPES =============
  fr(Ue.MolScriptSymbolTable.core.type.bool, function(r, t) {
    return !!t[0](r);
  }),
  fr(Ue.MolScriptSymbolTable.core.type.num, function(r, t) {
    return +t[0](r);
  }),
  fr(Ue.MolScriptSymbolTable.core.type.str, function(r, t) {
    return "" + t[0](r);
  }),
  fr(Ue.MolScriptSymbolTable.core.type.list, function(r, t) {
    return pv.QueryRuntimeArguments.forEachEval(t, r, function(n, a, i) {
      return i[a] = n;
    }, []);
  }),
  fr(Ue.MolScriptSymbolTable.core.type.set, function(r, t) {
    return pv.QueryRuntimeArguments.forEachEval(t, r, function(a, i, o) {
      return o.add(a);
    }, /* @__PURE__ */ new Set());
  }),
  fr(Ue.MolScriptSymbolTable.core.type.regex, function(r, t) {
    return new RegExp(t[0](r), t[1] && t[1](r) || "");
  }),
  fr(Ue.MolScriptSymbolTable.core.type.bitflags, function(r, t) {
    return +t[0](r);
  }),
  fr(Ue.MolScriptSymbolTable.core.type.compositeKey, function(r, t) {
    return pv.QueryRuntimeArguments.forEachEval(t, r, function(n, a, i) {
      return i[a] = "" + n;
    }, []).join("-");
  }),
  // ============= LOGIC ================
  fr(Ue.MolScriptSymbolTable.core.logic.not, function(e, r) {
    return !r[0](e);
  }),
  fr(Ue.MolScriptSymbolTable.core.logic.and, function(e, r) {
    if (typeof r.length == "number") {
      for (var t = 0, n = r.length; t < n; t++)
        if (!r[t](e))
          return !1;
    } else
      for (var a = 0, i = Object.keys(r); a < i.length; a++) {
        var o = i[a];
        if (!r[o](e))
          return !1;
      }
    return !0;
  }),
  fr(Ue.MolScriptSymbolTable.core.logic.or, function(e, r) {
    if (typeof r.length == "number") {
      for (var t = 0, n = r.length; t < n; t++)
        if (r[t](e))
          return !0;
    } else
      for (var a = 0, i = Object.keys(r); a < i.length; a++) {
        var o = i[a];
        if (r[o](e))
          return !0;
      }
    return !1;
  }),
  // ============= RELATIONAL ================
  fr(Ue.MolScriptSymbolTable.core.rel.eq, function(e, r) {
    return r[0](e) === r[1](e);
  }),
  fr(Ue.MolScriptSymbolTable.core.rel.neq, function(e, r) {
    return r[0](e) !== r[1](e);
  }),
  fr(Ue.MolScriptSymbolTable.core.rel.lt, function(e, r) {
    return r[0](e) < r[1](e);
  }),
  fr(Ue.MolScriptSymbolTable.core.rel.lte, function(e, r) {
    return r[0](e) <= r[1](e);
  }),
  fr(Ue.MolScriptSymbolTable.core.rel.gr, function(e, r) {
    return r[0](e) > r[1](e);
  }),
  fr(Ue.MolScriptSymbolTable.core.rel.gre, function(e, r) {
    return r[0](e) >= r[1](e);
  }),
  fr(Ue.MolScriptSymbolTable.core.rel.inRange, function(e, r) {
    var t = r[0](e);
    return t >= r[1](e) && t <= r[2](e);
  }),
  // ============= ARITHMETIC ================
  fr(Ue.MolScriptSymbolTable.core.math.add, function(e, r) {
    var t = 0;
    if (typeof r.length == "number")
      for (var n = 0, a = r.length; n < a; n++)
        t += r[n](e);
    else
      for (var i = 0, o = Object.keys(r); i < o.length; i++) {
        var c = o[i];
        t += r[c](e);
      }
    return t;
  }),
  fr(Ue.MolScriptSymbolTable.core.math.sub, function(e, r) {
    var t = 0;
    if (typeof r.length == "number") {
      if (r.length === 1)
        return -r[0](e);
      t = r[0](e) || 0;
      for (var n = 1, a = r.length; n < a; n++)
        t -= r[n](e);
    } else {
      var i = Object.keys(r);
      if (i.length === 1)
        return -r[i[0]](e);
      t = r[i[0]](e) || 0;
      for (var n = 1, a = i.length; n < a; n++)
        t -= r[i[n]](e);
    }
    return t;
  }),
  fr(Ue.MolScriptSymbolTable.core.math.mult, function(e, r) {
    var t = 1;
    if (typeof r.length == "number")
      for (var n = 0, a = r.length; n < a; n++)
        t *= r[n](e);
    else
      for (var i = 0, o = Object.keys(r); i < o.length; i++) {
        var c = o[i];
        t *= r[c](e);
      }
    return t;
  }),
  fr(Ue.MolScriptSymbolTable.core.math.div, function(e, r) {
    return r[0](e) / r[1](e);
  }),
  fr(Ue.MolScriptSymbolTable.core.math.pow, function(e, r) {
    return Math.pow(r[0](e), r[1](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.mod, function(e, r) {
    return r[0](e) % r[1](e);
  }),
  fr(Ue.MolScriptSymbolTable.core.math.min, function(e, r) {
    var t = Number.POSITIVE_INFINITY;
    if (typeof r.length == "number")
      for (var n = 0, a = r.length; n < a; n++)
        t = Math.min(r[n](e), t);
    else
      for (var i = 0, o = Object.keys(r); i < o.length; i++) {
        var c = o[i];
        t = Math.min(r[c](e), t);
      }
    return t;
  }),
  fr(Ue.MolScriptSymbolTable.core.math.max, function(e, r) {
    var t = Number.NEGATIVE_INFINITY;
    if (typeof r.length == "number")
      for (var n = 0, a = r.length; n < a; n++)
        t = Math.max(r[n](e), t);
    else
      for (var i = 0, o = Object.keys(r); i < o.length; i++) {
        var c = o[i];
        t = Math.max(r[c](e), t);
      }
    return t;
  }),
  fr(Ue.MolScriptSymbolTable.core.math.floor, function(e, r) {
    return Math.floor(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.ceil, function(e, r) {
    return Math.ceil(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.roundInt, function(e, r) {
    return Math.round(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.abs, function(e, r) {
    return Math.abs(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.sqrt, function(e, r) {
    return Math.sqrt(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.cbrt, function(e, r) {
    return Math.cbrt(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.sin, function(e, r) {
    return Math.sin(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.cos, function(e, r) {
    return Math.cos(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.tan, function(e, r) {
    return Math.tan(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.asin, function(e, r) {
    return Math.asin(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.acos, function(e, r) {
    return Math.acos(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.atan, function(e, r) {
    return Math.atan(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.sinh, function(e, r) {
    return Math.sinh(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.cosh, function(e, r) {
    return Math.cosh(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.tanh, function(e, r) {
    return Math.tanh(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.exp, function(e, r) {
    return Math.exp(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.log, function(e, r) {
    return Math.log(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.log10, function(e, r) {
    return Math.log10(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.math.atan2, function(e, r) {
    return Math.atan2(r[0](e), r[1](e));
  }),
  // ============= STRING ================
  fr(Ue.MolScriptSymbolTable.core.str.match, function(e, r) {
    return r[0](e).test(r[1](e));
  }),
  fr(Ue.MolScriptSymbolTable.core.str.concat, function(e, r) {
    var t = [];
    if (typeof r.length == "number")
      for (var n = 0, a = r.length; n < a; n++)
        t.push(r[n](e).toString());
    else
      for (var i = 0, o = Object.keys(r); i < o.length; i++) {
        var c = o[i];
        t.push(r[c](e).toString());
      }
    return t.join("");
  }),
  // ============= LIST ================
  fr(Ue.MolScriptSymbolTable.core.list.getAt, function(e, r) {
    return r[0](e)[r[1](e)];
  }),
  fr(Ue.MolScriptSymbolTable.core.list.equal, function(e, r) {
    return (0, kge.arrayEqual)(r[0](e), r[1](e));
  }),
  // ============= SET ================
  fr(Ue.MolScriptSymbolTable.core.set.has, function(r, t) {
    return t[0](r).has(t[1](r));
  }),
  fr(Ue.MolScriptSymbolTable.core.set.isSubset, function(r, t) {
    return Oge.SetUtils.isSuperset(t[1](r), t[0](r));
  }),
  // ============= FLAGS ================
  fr(Ue.MolScriptSymbolTable.core.flags.hasAny, function(e, r) {
    var t = r[1](e), n = r[0](e);
    return t ? (n & t) !== 0 : !!n;
  }),
  fr(Ue.MolScriptSymbolTable.core.flags.hasAll, function(e, r) {
    var t = r[1](e), n = r[0](e);
    return t ? (n & t) === t : !n;
  }),
  // Structure
  // ============= TYPES ================
  fr(Ue.MolScriptSymbolTable.structureQuery.type.elementSymbol, function(e, r) {
    return (0, JM.ElementSymbol)(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.structureQuery.type.atomName, function(e, r) {
    return (0, Fge.upperCaseAny)(r[0](e));
  }),
  fr(Ue.MolScriptSymbolTable.structureQuery.type.bondFlags, function(e, r) {
    var t = 0;
    if (typeof r.length == "number")
      for (var n = 0, a = r.length; n < a; n++)
        t = mN(t, r[n](e));
    else
      for (var i = 0, o = Object.keys(r); i < o.length; i++) {
        var c = o[i];
        t = mN(t, r[c](e));
      }
    return t;
  }),
  fr(Ue.MolScriptSymbolTable.structureQuery.type.ringFingerprint, function(e, r) {
    return dr.UnitRing.elementFingerprint(zge(e, r));
  }),
  fr(Ue.MolScriptSymbolTable.structureQuery.type.secondaryStructureFlags, function(e, r) {
    var t = 0;
    if (typeof r.length == "number")
      for (var n = 0, a = r.length; n < a; n++)
        t = vN(t, r[n](e));
    else
      for (var i = 0, o = Object.keys(r); i < o.length; i++) {
        var c = o[i];
        t = vN(t, r[c](e));
      }
    return t;
  }),
  // TODO:
  // C(MolScript.structureQuery.type.entityType, (ctx, v) => StructureRuntime.Common.entityType(v[0](ctx))),
  // C(MolScript.structureQuery.type.authResidueId, (ctx, v) => ResidueIdentifier.auth(v[0](ctx), v[1](ctx), v[2] && v[2](ctx))),
  // C(MolScript.structureQuery.type.labelResidueId, (ctx, v) => ResidueIdentifier.label(v[0](ctx), v[1](ctx), v[2](ctx), v[3] && v[3](ctx))),
  // ============= SLOTS ================
  // TODO: slots might not be needed after all: reducer simply pushes/pops current element
  // C(MolScript.structureQuery.slot.element, (ctx, _) => ctx_.element),
  // C(MolScript.structureQuery.slot.elementSetReduce, (ctx, _) => ctx_.element),
  // ============= FILTERS ================
  tr(Ue.MolScriptSymbolTable.structureQuery.filter.pick, function(e, r) {
    return dr.Queries.filters.pick(r[0], r.test)(e);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.filter.first, function(e, r) {
    return dr.Queries.filters.first(r[0])(e);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.filter.withSameAtomProperties, function(e, r) {
    return dr.Queries.filters.withSameAtomProperties(r[0], r.source, r.property)(e);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.filter.intersectedBy, function(e, r) {
    return dr.Queries.filters.areIntersectedBy(r[0], r.by)(e);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.filter.within, function(e, r) {
    return dr.Queries.filters.within({
      query: r[0],
      target: r.target,
      minRadius: r["min-radius"],
      maxRadius: r["max-radius"],
      elementRadius: r["atom-radius"],
      invert: r.invert
    })(e);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.filter.isConnectedTo, function(e, r) {
    return dr.Queries.filters.isConnectedTo({
      query: r[0],
      target: r.target,
      disjunct: r.disjunct,
      invert: r.invert,
      bondTest: r["bond-test"]
    })(e);
  }),
  // ============= GENERATORS ================
  tr(Ue.MolScriptSymbolTable.structureQuery.generator.atomGroups, function(r, t) {
    return dr.Queries.generators.atoms({
      entityTest: t["entity-test"],
      chainTest: t["chain-test"],
      residueTest: t["residue-test"],
      atomTest: t["atom-test"],
      groupBy: t["group-by"]
    })(r);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.generator.all, function(r) {
    return dr.Queries.generators.all(r);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.generator.empty, function(r) {
    return dr.Queries.generators.none(r);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.generator.bondedAtomicPairs, function(r, t) {
    return dr.Queries.generators.bondedAtomicPairs(t && t[0])(r);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.generator.rings, function(r, t) {
    var n, a;
    return dr.Queries.generators.rings((n = t == null ? void 0 : t.fingerprint) === null || n === void 0 ? void 0 : n.call(t, r), (a = t == null ? void 0 : t["only-aromatic"]) === null || a === void 0 ? void 0 : a.call(t, r))(r);
  }),
  // ============= MODIFIERS ================
  tr(Ue.MolScriptSymbolTable.structureQuery.modifier.includeSurroundings, function(r, t) {
    return dr.Queries.modifiers.includeSurroundings(t[0], {
      radius: t.radius(r),
      wholeResidues: !!(t["as-whole-residues"] && t["as-whole-residues"](r)),
      elementRadius: t["atom-radius"]
    })(r);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.modifier.surroundingLigands, function(r, t) {
    return dr.Queries.modifiers.surroundingLigands({
      query: t[0],
      radius: t.radius(r),
      includeWater: !!(t["include-water"] && t["include-water"](r))
    })(r);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.modifier.wholeResidues, function(r, t) {
    return dr.Queries.modifiers.wholeResidues(t[0])(r);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.modifier.union, function(r, t) {
    return dr.Queries.modifiers.union(t[0])(r);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.modifier.expandProperty, function(r, t) {
    return dr.Queries.modifiers.expandProperty(t[0], t.property)(r);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.modifier.exceptBy, function(r, t) {
    return dr.Queries.modifiers.exceptBy(t[0], t.by)(r);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.modifier.intersectBy, function(r, t) {
    return dr.Queries.modifiers.intersectBy(t[0], t.by)(r);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.modifier.includeConnected, function(r, t) {
    var n, a;
    return dr.Queries.modifiers.includeConnected({
      query: t[0],
      bondTest: t["bond-test"],
      wholeResidues: !!(t["as-whole-residues"] && t["as-whole-residues"](r)),
      layerCount: t["layer-count"] && t["layer-count"](r) || 1,
      fixedPoint: (a = (n = t["fixed-point"]) === null || n === void 0 ? void 0 : n.call(t, r)) !== null && a !== void 0 ? a : !1
    })(r);
  }),
  // ============= COMBINATORS ================
  tr(Ue.MolScriptSymbolTable.structureQuery.combinator.merge, function(e, r) {
    return dr.Queries.combinators.merge(r)(e);
  }),
  // ============= ATOM PROPERTIES ================
  // ~~~ CORE ~~~
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.core.elementSymbol, vt(dr.StructureProperties.atom.type_symbol)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.core.vdw, function(e, r) {
    return (0, ST.VdwRadius)(dr.StructureProperties.atom.type_symbol(r && r[0] && r[0](e) || e.element));
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.core.mass, function(e, r) {
    return (0, ST.AtomWeight)(dr.StructureProperties.atom.type_symbol(r && r[0] && r[0](e) || e.element));
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.core.atomicNumber, function(e, r) {
    return (0, ST.AtomNumber)(dr.StructureProperties.atom.type_symbol(r && r[0] && r[0](e) || e.element));
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.core.x, vt(dr.StructureProperties.atom.x)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.core.y, vt(dr.StructureProperties.atom.y)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.core.z, vt(dr.StructureProperties.atom.z)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.core.sourceIndex, vt(dr.StructureProperties.atom.sourceIndex)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.core.operatorName, vt(dr.StructureProperties.unit.operator_name)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.core.modelIndex, vt(dr.StructureProperties.unit.model_index)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.core.modelLabel, vt(dr.StructureProperties.unit.model_label)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.core.atomKey, function(e, r) {
    var t = r && r[0] && r[0](e) || e.element;
    return (0, Lge.cantorPairing)(t.unit.id, t.element);
  }),
  // TODO:
  // D(MolScript.structureQuery.atomProperty.core.bondCount, (ctx, _) => ),
  // ~~~ TOPOLOGY ~~~
  // TODO
  // ~~~ MACROMOLECULAR ~~~
  // TODO:
  // // identifiers
  // labelResidueId: prop((env, v) => ResidueIdentifier.labelOfResidueIndex(env.context.model, getAddress(env, v).residue)),
  // authResidueId: prop((env, v) => ResidueIdentifier.authOfResidueIndex(env.context.model, getAddress(env, v).residue)),
  // keys
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.residueKey, function(e, r) {
    return dr.StructureElement.residueIndex(r && r[0] && r[0](e) || e.element);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.chainKey, function(e, r) {
    return dr.StructureElement.chainIndex(r && r[0] && r[0](e) || e.element);
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.entityKey, function(e, r) {
    return dr.StructureElement.entityIndex(r && r[0] && r[0](e) || e.element);
  }),
  // mmCIF
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.id, vt(dr.StructureProperties.atom.id)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.isHet, function(e, r) {
    return dr.StructureProperties.residue.group_PDB(r && r[0] && r[0](e) || e.element) !== "ATOM";
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.label_atom_id, vt(dr.StructureProperties.atom.label_atom_id)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.label_alt_id, vt(dr.StructureProperties.atom.label_alt_id)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.label_comp_id, vt(dr.StructureProperties.atom.label_comp_id)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.label_seq_id, vt(dr.StructureProperties.residue.label_seq_id)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.label_asym_id, vt(dr.StructureProperties.chain.label_asym_id)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.label_entity_id, vt(dr.StructureProperties.entity.id)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.auth_atom_id, vt(dr.StructureProperties.atom.auth_atom_id)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.auth_comp_id, vt(dr.StructureProperties.atom.auth_comp_id)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.auth_seq_id, vt(dr.StructureProperties.residue.auth_seq_id)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.auth_asym_id, vt(dr.StructureProperties.chain.auth_asym_id)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.pdbx_PDB_ins_code, vt(dr.StructureProperties.residue.pdbx_PDB_ins_code)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.pdbx_formal_charge, vt(dr.StructureProperties.atom.pdbx_formal_charge)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.occupancy, vt(dr.StructureProperties.atom.occupancy)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.B_iso_or_equiv, vt(dr.StructureProperties.atom.B_iso_or_equiv)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.entityType, vt(dr.StructureProperties.entity.type)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.entitySubtype, vt(dr.StructureProperties.entity.subtype)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.entityPrdId, vt(dr.StructureProperties.entity.prd_id)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.entityDescription, vt(dr.StructureProperties.entity.pdbx_description)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.objectPrimitive, vt(dr.StructureProperties.unit.object_primitive)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.isNonStandard, vt(dr.StructureProperties.residue.isNonStandard)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.secondaryStructureKey, vt(dr.StructureProperties.residue.secondary_structure_key)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.secondaryStructureFlags, vt(dr.StructureProperties.residue.secondary_structure_type)),
  tr(Ue.MolScriptSymbolTable.structureQuery.atomProperty.macromolecular.chemCompType, vt(dr.StructureProperties.residue.chem_comp_type)),
  // ============= BOND PROPERTIES ================
  tr(Ue.MolScriptSymbolTable.structureQuery.bondProperty.order, function(e, r) {
    return e.atomicBond.order;
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.bondProperty.flags, function(e, r) {
    return e.atomicBond.type;
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.bondProperty.atomA, function(e, r) {
    return e.atomicBond.a;
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.bondProperty.atomB, function(e, r) {
    return e.atomicBond.b;
  }),
  tr(Ue.MolScriptSymbolTable.structureQuery.bondProperty.length, function(e, r) {
    return e.atomicBond.length;
  }),
  // Internal
  tr(Ue.MolScriptSymbolTable.internal.generator.bundleElement, function(r, t) {
    return (0, fN.bundleElementImpl)(t.groupedUnits(r), t.ranges(r), t.set(r));
  }),
  tr(Ue.MolScriptSymbolTable.internal.generator.bundle, function(r, t) {
    return (0, fN.bundleGenerator)(t.elements(r))(r);
  }),
  tr(Ue.MolScriptSymbolTable.internal.generator.current, function(r, t) {
    return r.tryGetCurrentSelection();
  })
];
function vt(e) {
  return function(r, t) {
    return e(t && t[0] && t[0](r) || r.element);
  };
}
function mN(e, r) {
  return e | (JM.BondType.isName(r) ? JM.BondType.fromName(r) : 0);
}
function vN(e, r) {
  switch (r.toLowerCase()) {
    case "helix":
      return e | 2;
    case "alpha":
      return e | 2 | 4096;
    case "pi":
      return e | 2 | 32768;
    case "310":
      return e | 2 | 2048;
    case "beta":
      return e | 4;
    case "strand":
      return e | 4 | 4194304;
    case "sheet":
      return e | 4 | 8388608;
    case "turn":
      return e | 16;
    case "bend":
      return e | 8;
    case "coil":
      return e | 536870912;
    default:
      return e;
  }
}
function zge(e, r) {
  var t = [];
  if (!r)
    return t;
  if (typeof r.length == "number")
    for (var n = 0, a = r.length; n < a; n++)
      t.push(r[n](e));
  else
    for (var i = Object.keys(r), n = 1, a = i.length; n < a; n++)
      t.push(r[i[n]](e));
  return t;
}
(function() {
  for (var e = 0, r = Uge; e < r.length; e++) {
    var t = r[e];
    pv.DefaultQueryRuntimeTable.addSymbol(t);
  }
})();
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 });
  var r = Te;
  (0, r.__exportStar)(by, e);
})(dj);
var ct = {};
Object.defineProperty(ct, "__esModule", { value: !0 });
ct.hasAromaticNeighbour = ct.hasPolarNeighbour = ct.isPolar = ct.isAcetamidine = ct.isGuanidine = ct.isCarboxylate = ct.isCarbonyl = ct.isHalocarbon = ct.isPhosphate = ct.isSulfate = ct.isSulfonicAcid = ct.isSulfonium = ct.isAmide = ct.isImide = ct.isTertiaryAmine = ct.isQuaternaryAmine = void 0;
var Gge = j4, qge = Gr, xr = Rr;
function Hge(e, r) {
  for (var t = e.bonds, n = t.offset, a = t.edgeProps, i = n[r], o = n[r + 1]; i < o; ++i)
    if (qge.BondType.is(16, a.flags[i]))
      return !0;
  return !1;
}
function fj(e, r, t) {
  var n = 0;
  return (0, xr.eachBondedAtom)(e, r, t, function(a, i) {
    mj(e, a, i) && (n += 1);
  }), n;
}
function jge(e, r, t) {
  return (0, xr.typeSymbol)(r, t) === "N" && (0, xr.bondCount)(e, r, t) === 4 && (0, xr.bondToElementCount)(
    e,
    r,
    t,
    "H"
    /* H */
  ) === 0;
}
ct.isQuaternaryAmine = jge;
function $ge(e, r, t, n) {
  return (0, xr.typeSymbol)(r, t) === "N" && (0, xr.bondCount)(e, r, t) === 4 && n === 3;
}
ct.isTertiaryAmine = $ge;
function Kge(e, r, t) {
  var n = !1;
  return (0, xr.typeSymbol)(r, t) === "N" && (0, xr.bondCount)(e, r, t) - (0, xr.bondToElementCount)(
    e,
    r,
    t,
    "H"
    /* H */
  ) === 2 && (n = fj(e, r, t) === 2), n;
}
ct.isImide = Kge;
function Wge(e, r, t) {
  var n = !1;
  return (0, xr.typeSymbol)(r, t) === "N" && (0, xr.bondCount)(e, r, t) - (0, xr.bondToElementCount)(
    e,
    r,
    t,
    "H"
    /* H */
  ) === 2 && (n = fj(e, r, t) === 1), n;
}
ct.isAmide = Wge;
function Xge(e, r, t) {
  return (0, xr.typeSymbol)(r, t) === "S" && (0, xr.bondCount)(e, r, t) === 3 && (0, xr.bondToElementCount)(
    e,
    r,
    t,
    "H"
    /* H */
  ) === 0;
}
ct.isSulfonium = Xge;
function Yge(e, r, t) {
  return (0, xr.typeSymbol)(r, t) === "S" && (0, xr.bondToElementCount)(
    e,
    r,
    t,
    "O"
    /* O */
  ) === 3;
}
ct.isSulfonicAcid = Yge;
function Qge(e, r, t) {
  return (0, xr.typeSymbol)(r, t) === "S" && (0, xr.bondToElementCount)(
    e,
    r,
    t,
    "O"
    /* O */
  ) === 4;
}
ct.isSulfate = Qge;
function Zge(e, r, t) {
  return (0, xr.typeSymbol)(r, t) === "P" && (0, xr.bondToElementCount)(
    e,
    r,
    t,
    "O"
    /* O */
  ) === (0, xr.bondCount)(e, r, t);
}
ct.isPhosphate = Zge;
function Jge(e, r, t) {
  return (0, Gge.isHalogen)((0, xr.typeSymbol)(r, t)) && (0, xr.bondCount)(e, r, t) === 1 && (0, xr.bondToElementCount)(
    e,
    r,
    t,
    "C"
    /* C */
  ) === 1;
}
ct.isHalocarbon = Jge;
function mj(e, r, t) {
  var n = !1;
  if ((0, xr.typeSymbol)(r, t) === "C") {
    for (var a = r.bonds, i = a.offset, o = a.edgeProps, c = a.b, s = i[t], u = i[t + 1]; s < u; ++s)
      if (o.order[s] === 2 && (0, xr.typeSymbol)(r, c[s]) === "O") {
        n = !0;
        break;
      }
  }
  return n;
}
ct.isCarbonyl = mj;
function eye(e, r, t) {
  var n = 0;
  return (0, xr.typeSymbol)(r, t) === "C" && (0, xr.bondToElementCount)(
    e,
    r,
    t,
    "O"
    /* O */
  ) === 2 && (0, xr.bondToElementCount)(
    e,
    r,
    t,
    "C"
    /* C */
  ) === 1 && (0, xr.eachBondedAtom)(e, r, t, function(a, i) {
    (0, xr.typeSymbol)(a, i) === "O" && (0, xr.bondCount)(e, a, i) - (0, xr.bondToElementCount)(
      e,
      a,
      i,
      "H"
      /* H */
    ) === 1 && (n += 1);
  }), n === 2;
}
ct.isCarboxylate = eye;
function rye(e, r, t) {
  var n = 0;
  return (0, xr.typeSymbol)(r, t) === "C" && (0, xr.bondCount)(e, r, t) === 3 && (0, xr.bondToElementCount)(
    e,
    r,
    t,
    "N"
    /* N */
  ) === 3 && (0, xr.eachBondedAtom)(e, r, t, function(a, i) {
    (0, xr.bondCount)(e, a, i) - (0, xr.bondToElementCount)(
      e,
      a,
      i,
      "H"
      /* H */
    ) === 1 && (n += 1);
  }), n === 2;
}
ct.isGuanidine = rye;
function tye(e, r, t) {
  var n = 0;
  return (0, xr.typeSymbol)(r, t) === "C" && (0, xr.bondCount)(e, r, t) === 3 && (0, xr.bondToElementCount)(
    e,
    r,
    t,
    "N"
    /* N */
  ) === 2 && (0, xr.bondToElementCount)(
    e,
    r,
    t,
    "C"
    /* C */
  ) === 1 && (0, xr.eachBondedAtom)(e, r, t, function(a, i) {
    (0, xr.bondCount)(e, a, i) - (0, xr.bondToElementCount)(
      e,
      a,
      i,
      "H"
      /* H */
    ) === 1 && (n += 1);
  }), n === 2;
}
ct.isAcetamidine = tye;
var nye = /* @__PURE__ */ new Set(["N", "O", "S", "F", "CL", "BR", "I"]);
function vj(e) {
  return nye.has(e);
}
ct.isPolar = vj;
function aye(e, r, t) {
  var n = !1;
  return (0, xr.eachBondedAtom)(e, r, t, function(a, i) {
    vj((0, xr.typeSymbol)(a, i)) && (n = !0);
  }), n;
}
ct.hasPolarNeighbour = aye;
function iye(e, r, t) {
  var n = !1;
  return (0, xr.eachBondedAtom)(e, r, t, function(a, i) {
    Hge(a, i) && (n = !0);
  }), n;
}
ct.hasAromaticNeighbour = iye;
var aD = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.StructureSelectionQueries = e.StructureSelectionCategory = void 0;
  var r = gs, t = by, n;
  (function(o) {
    o.Type = "Type", o.Structure = "Structure Property", o.Atom = "Atom Property", o.Bond = "Bond Property", o.Residue = "Residue Property", o.AminoAcid = "Amino Acid", o.NucleicBase = "Nucleic Base", o.Manipulate = "Manipulate Selection", o.Validation = "Validation", o.Misc = "Miscellaneous", o.Internal = "Internal";
  })(n = e.StructureSelectionCategory || (e.StructureSelectionCategory = {}));
  function a(o, c, s) {
    var u;
    s === void 0 && (s = {});
    var l;
    return {
      label: o,
      expression: c,
      description: s.description || "",
      category: (u = s.category) !== null && u !== void 0 ? u : n.Misc,
      isHidden: !!s.isHidden,
      priority: s.priority || 0,
      referencesCurrent: !!s.referencesCurrent,
      get query() {
        return l || (l = (0, t.compile)(c)), l;
      },
      ensureCustomProperties: s.ensureCustomProperties
      // async getSelection(plugin, runtime, structure) {
      //   const current =
      //     plugin.managers.structure.selection.getStructure(structure)
      //   const currentSelection = current
      //     ? StructureSelection.Sequence(structure, [current])
      //     : StructureSelection.Empty(structure)
      //   if (props.ensureCustomProperties) {
      //     await props.ensureCustomProperties(
      //       { runtime, assetManager: plugin.managers.asset },
      //       structure
      //     )
      //   }
      //   if (!_query) _query = compile<StructureSelection>(expression)
      //   return _query(new QueryContext(structure, { currentSelection }))
      // }
    };
  }
  var i = a("Polymer", r.MolScriptBuilder.struct.modifier.union([
    r.MolScriptBuilder.struct.generator.atomGroups({
      "entity-test": r.MolScriptBuilder.core.logic.and([
        r.MolScriptBuilder.core.rel.eq([r.MolScriptBuilder.ammp("entityType"), "polymer"]),
        r.MolScriptBuilder.core.str.match([
          r.MolScriptBuilder.re("(polypeptide|cyclic-pseudo-peptide|peptide-like|nucleotide|peptide nucleic acid)", "i"),
          r.MolScriptBuilder.ammp("entitySubtype")
        ])
      ])
    })
  ]), { category: n.Type });
  e.StructureSelectionQueries = {
    polymer: i
  };
})(aD);
var pN;
function Hp() {
  return pN || (pN = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.uncompressElementIds = e.compressElementIds = e.isNonPolarHydrogen = e.getWholeResiduesCellItem = e.getGlobalCellItems = e.getMergedContent = e.getHydrogenType = e.getStructureByCell = e.getStructureUniqueId = e.getModelByStructure = e.queryCellItemsByHierarchyType = e.sliceCellItemsByGranularity = e.traverseAtoms = e.getAtomHierarchyByStructure = e.getAtomHierarchyByUnit = e.getElementsFromStructure = e.getStructureByStructureQuery = e.getStructureQuery = e.generateStructureByEditFuncAndStructure = e.getTextFromStructure = e.getProteinAndOthersElementIdByStructure = e.getMergedStructure = e.copyStructure = e.getStructureByElementIds = e.getElementIdsFromRepresentation = e.getStructureFromRepresentation = e.removeStructureByElementIds = e.createEmptyStructure = void 0;
    var r = Te, t = Je(), n = Jt, a = eu(), i = Lp, o = Wd, c = kp, s = $H(), u = qp(), l = zp(), f = dj, d = We(), m = Gr, p = Ap, v = wc, h = gs, y = Qe(), C = ct, S = Rr, b = aD, g = function() {
      var $ = t.Structure.Builder();
      return $.getStructure();
    };
    e.createEmptyStructure = g;
    var _ = function($, Q) {
      for (var W = t.Structure.Builder(), te = new Set(Q), oe = 0, z = $.units; oe < z.length; oe++) {
        var j = z[oe], ae = (0, r.__spreadArray)([], j.elements, !0).filter(function(le) {
          return !te.has(le);
        });
        ae.length && W.addUnit(j.kind, j.model, j.conformation.operator, ae, j.traits);
      }
      return W.getStructure();
    };
    e.removeStructureByElementIds = _;
    var A = function($) {
      var Q = $.getLoci();
      return Q.kind === "structure-loci" ? Q.structure : Q.kind === "element-loci" ? a.Loci.toStructure(Q) : t.Structure.Empty;
    };
    e.getStructureFromRepresentation = A;
    var M = function($) {
      var Q = $.getLoci();
      return Q.kind === "structure-loci" ? (0, i.getElementIdsByLoci)(t.Structure.toStructureElementLoci(Q.structure)) : Q.kind === "element-loci" ? (0, i.getElementIdsByLoci)(Q) : [];
    };
    e.getElementIdsFromRepresentation = M;
    var P = function($, Q, W, te) {
      if ((Q == null ? void 0 : Q.length) === 0 && !W)
        return t.Structure.Empty;
      for (var oe = t.Structure.Builder(), z = new Set(Q), j = typeof te == "string" ? te : d.UUID.create22(), ae = 0, le = $.units; ae < le.length; ae++) {
        var ie = le[ae], re = Q != null && Q.length ? (0, r.__spreadArray)([], ie.elements, !0).filter(function(ee) {
          return z.has(ee);
        }) : ie.elements;
        re.length && oe.addUnit(ie.kind, te ? (0, r.__assign)((0, r.__assign)({}, ie.model), { id: j }) : ie.model, ie.conformation.operator, re, ie.traits);
      }
      return oe.getStructure();
    };
    e.getStructureByElementIds = P;
    var T = function($) {
      return t.Structure.create($.units);
    };
    e.copyStructure = T;
    var x = function($, Q) {
      for (var W = t.Structure.Builder(), te = /* @__PURE__ */ new Map(), oe = 0, z = function(le, ie) {
        var re = $[le], ee = re.ref, ne = re.elementIds, se = (0, e.getStructureByCell)(Q.cells.get(ee)), ce = new Set(ne);
        te.set(le, []);
        for (var de = 0, me = se.units; de < me.length; de++) {
          var he = me[de], _e = ne ? (0, r.__spreadArray)([], he.elements, !0).filter(function(Se) {
            return ce.has(Se);
          }) : he.elements;
          _e.length && (te.get(le).push(oe), W.addUnit(he.kind, he.model, he.conformation.operator, _e, he.traits, oe), oe++);
        }
      }, j = 0, ae = $.length; j < ae; j++)
        z(j);
      return {
        unitsMap: te,
        structure: W.getStructure()
      };
    };
    e.getMergedStructure = x;
    var w = function($) {
      if ($.model.sourceData.kind === "gro")
        return {
          polymer: (0, e.getElementsFromStructure)((0, e.getStructureByStructureQuery)((0, e.getStructureQuery)($, b.StructureSelectionQueries.polymer.expression))),
          other: (0, e.getElementsFromStructure)((0, e.getStructureByStructureQuery)((0, e.getStructureQuery)($, h.MolScriptBuilder.struct.modifier.exceptBy({
            0: v.Script.toExpression((0, v.Script)("(sel.atom.all)", "mol-script")),
            by: b.StructureSelectionQueries.polymer.expression
          }))))
        };
      var Q = {}, W = {}, te = /* @__PURE__ */ new Set(), oe = [], z = /* @__PURE__ */ new Map(), j = /* @__PURE__ */ new Map();
      $.units.forEach(function(le) {
        var ie;
        le.elements.forEach(function(ce) {
          var de = (0, e.getAtomHierarchyByUnit)(le, ce);
          if (de.groupPDB === "ATOM" && !["UNK", "MOL"].includes(de.residueName)) {
            (0, s.setHierarchyData)(Q, de), te.add(de.elementId), oe.push(de.elementId);
            return;
          }
          if (de.groupPDB === "HETATM" || ["UNK", "MOL"].includes(de.residueName)) {
            var me = "".concat(de.chainId, "_").concat(de.residueId);
            z.set(me, z.has(me) ? (0, r.__spreadArray)((0, r.__spreadArray)([], z.get(me), !0), [de], !1) : [de]);
            return;
          }
          (0, s.setHierarchyData)(W, de);
        });
        for (var re = 0, ee = le.bonds.a.length; re < ee; re++) {
          var ne = le.elements[le.bonds.a[re]], se = le.elements[le.bonds.b[re]];
          j.has(ne) ? (ie = j.get(ne)) === null || ie === void 0 || ie.add(se) : j.set(ne, /* @__PURE__ */ new Set([se]));
        }
      }), z.forEach(function(le) {
        var ie = !1, re = new Set(le.map(function(ee) {
          return ee.elementId;
        }));
        re.forEach(function(ee) {
          if (j.has(ee)) {
            var ne = j.get(ee);
            ne == null || ne.forEach(function(se) {
              te.has(se) && (ie = !0);
            });
          }
        }), le.forEach(function(ee) {
          ie ? (Object.assign(ee, { isEutectic: !0 }), oe.push(ee.elementId), te.add(ee.elementId)) : (0, s.setHierarchyData)(W, ee);
        });
      });
      var ae = [];
      return Object.keys(W).forEach(function(le) {
        Object.keys(W[le]).forEach(function(ie) {
          ae.push.apply(ae, W[le][ie].map(function(re) {
            return re.elementId;
          }));
        });
      }), {
        polymer: oe,
        other: ae
      };
    };
    e.getProteinAndOthersElementIdByStructure = w;
    var E = function($, Q) {
      var W;
      if (!$.elementCount)
        return "";
      if (Q === n.Format.Pdb)
        return (0, l.parseToPDB)($, void 0, !0);
      var te = (0, e.getModelByStructure)($), oe = (W = te == null ? void 0 : te.entryId) !== null && W !== void 0 ? W : "";
      if (Q === n.Format.Sdf || Q === n.Format.Mol)
        return oe ? (0, r.__spreadArray)([oe], (0, l.parseToSdf)($).split(`
`).slice(1), !0).join(`
`) : (0, l.parseToSdf)($);
    };
    e.getTextFromStructure = E;
    var I = function($, Q, W, te) {
      return (0, r.__awaiter)(void 0, void 0, void 0, function() {
        var oe, z, ie, j, ae, le, ie, re, ee, ne;
        return (0, r.__generator)(this, function(se) {
          switch (se.label) {
            case 0:
              return oe = !((re = $ == null ? void 0 : $.models) === null || re === void 0) && re.length ? $.models[0] : $ == null ? void 0 : $.model, z = (ne = te ?? (oe ? oe.sourceData.kind : (ee = $ == null ? void 0 : $.parent) === null || ee === void 0 ? void 0 : ee.model.sourceData.kind)) !== null && ne !== void 0 ? ne : "sdf", z !== "mmCIF" ? [3, 3] : (ae = (j = u.FormatProvider[n.Format.Pdb]).parse, [4, (0, l.parseToPDB)($, void 0, !0, W)]);
            case 1:
              return [4, ae.apply(j, [se.sent()])];
            case 2:
              return ie = se.sent(), [2, ie];
            case 3:
              return [4, (0, l.parseToSdf)($, void 0, !1, Q)];
            case 4:
              return le = se.sent(), [4, u.FormatProvider[n.Format.Sdf].parse(le)];
            case 5:
              return ie = se.sent(), [2, ie];
          }
        });
      });
    };
    e.generateStructureByEditFuncAndStructure = I;
    var B = function($, Q) {
      var W = (0, f.compile)(Q), te = W(new t.QueryContext($));
      return te;
    };
    e.getStructureQuery = B;
    var D = function($) {
      var Q;
      if ($.structure)
        Q = $.structure;
      else if ($.structures) {
        var W = $.structures.map(function(z) {
          return (z == null ? void 0 : z.units.length) > 0 ? t.Structure.toStructureElementLoci(z) : void 0;
        }).filter(function(z) {
          return z;
        });
        if (W.length === 0)
          return (0, e.createEmptyStructure)();
        for (var te = W[0], oe = 1; oe < W.length; oe++)
          te = a.Loci.union(te, W[oe]);
        Q = a.Loci.toStructure(te);
      }
      return Q;
    };
    e.getStructureByStructureQuery = D;
    var N = function($) {
      var Q = [];
      return $.units.forEach(function(W) {
        Q.push.apply(Q, W.elements);
      }), Q;
    };
    e.getElementsFromStructure = N;
    var O = function($, Q) {
      var W, te = {
        unitId: $.invariantId,
        elementId: Q,
        chainId: $.model.atomicHierarchy.chains.auth_asym_id.value($.chainIndex[Q]),
        groupPDB: $.model.atomicHierarchy.residues.group_PDB.value($.residueIndex[Q]),
        residueId: $.model.atomicHierarchy.residues.auth_seq_id.value($.residueIndex[Q]),
        insertCode: $.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value($.residueIndex[Q]),
        residueName: $.model.atomicHierarchy.atoms.label_comp_id.value(Q),
        atomId: $.model.atomicConformation.atomId.value(Q),
        atomName: $.model.atomicHierarchy.atoms.label_atom_id.value(Q),
        typeSymbol: (0, c.getStandardTypeSymbol)($.model.atomicHierarchy.atoms.type_symbol.value(Q)),
        charge: ((W = o.AtomPartialCharge.Provider.get($.model)) === null || W === void 0 ? void 0 : W.data.value(Q)) || 0,
        altId: $.model.atomicHierarchy.atoms.label_alt_id.value(Q),
        cdr: $.model.atomicHierarchy.atoms.cdr.value(Q) || 0,
        bfactor: $.model.atomicHierarchy.atoms.B_iso_or_equiv.value(Q),
        em_confidence: $.model.atomicHierarchy.atoms.em_confidence.value(Q),
        x: $.model.atomicConformation.x[Q],
        y: $.model.atomicConformation.y[Q],
        z: $.model.atomicConformation.z[Q],
        residueIndex: $.residueIndex[Q],
        occupancy: $.model.atomicConformation.occupancy.value(Q)
      };
      return te;
    };
    e.getAtomHierarchyByUnit = O;
    var V = function($, Q, W) {
      var te = W;
      if (W === void 0 && $.units.some(function(j) {
        return j.elements.includes(Q) ? (te = j.invariantId, !0) : !1;
      }), te === void 0 || !$.unitMap.has(te))
        return {};
      var oe = $.unitMap.get(te), z = (0, e.getAtomHierarchyByUnit)(oe, Q);
      return z;
    };
    e.getAtomHierarchyByStructure = V;
    var k = function($, Q) {
      $.units.forEach(function(W) {
        W.elements.forEach(function(te) {
          var oe = (0, e.getAtomHierarchyByUnit)(W, te);
          Q(oe);
        });
      });
    };
    e.traverseAtoms = k;
    var G = function($, Q, W) {
      var te = [];
      return Q.forEach(function(oe) {
        var z = $.managers.cell.get(oe.ref), j = (0, e.getStructureByCell)(z), ae = /* @__PURE__ */ new Map(), le = new Set(oe.elementIds);
        j && (j.units.forEach(function(ie) {
          ie.elements.forEach(function(re) {
            var ee;
            if (!(oe.elementIds && !le.has(re))) {
              var ne = (0, e.getAtomHierarchyByUnit)(ie, re), se = (0, s.getGranularityUniqueId)(ne, W);
              ae.has(se) ? (ee = ae.get(se)) === null || ee === void 0 || ee.push(ne) : ae.set(se, [ne]);
            }
          });
        }), ae.forEach(function(ie) {
          te.push({
            ref: oe.ref,
            elementIds: ie.map(function(re) {
              return re.elementId;
            }),
            props: (0, s.getGranularityProps)(ie[0], W)
          });
        }));
      }), te;
    };
    e.sliceCellItemsByGranularity = G;
    var L = function($, Q) {
      var W = {}, te = /* @__PURE__ */ new Set(), oe = Q ?? [];
      return Q || $.managers.cell.traverse(function(z, j) {
        (0, e.getStructureByCell)(z) && !j.isHidden && te.add(z.ref);
      }), te.forEach(function(z) {
        oe.push({
          ref: z
        });
      }), oe.forEach(function(z) {
        var j, ae = z.ref, le = z.elementIds, ie = new Set(le), re = $.cells.get(ae);
        if (re) {
          var ee = (0, e.getStructureByCell)(re);
          if (ee) {
            var ne = [], se = [], ce = [], de = /* @__PURE__ */ new Set(), me = /* @__PURE__ */ new Map(), he = /* @__PURE__ */ new Map(), _e = /* @__PURE__ */ new Map(), Se = /* @__PURE__ */ new Map();
            ee.units.forEach(function(Pe) {
              var De;
              Pe.elements.forEach(function(Ae) {
                var ye, be;
                if (!(le && !ie.has(Ae))) {
                  var fe = (0, e.getAtomHierarchyByUnit)(Pe, Ae), ge = (0, s.getGranularityUniqueId)(fe, n.Granularity.Residue);
                  if (s.SolventNameSet.has(fe.residueName.toUpperCase())) {
                    ne.push(fe.elementId);
                    return;
                  }
                  if (m.WaterNames.has(fe.residueName.toUpperCase())) {
                    se.push(fe.elementId);
                    return;
                  }
                  if (s.MetalNameSet.has(fe.typeSymbol.toUpperCase())) {
                    ce.push(fe.elementId);
                    return;
                  }
                  if (p.IonNames.has(fe.residueName.toUpperCase())) {
                    ce.push(fe.elementId);
                    return;
                  }
                  if (fe.groupPDB === "ATOM" && !["UNK", "MOL"].includes(fe.residueName)) {
                    de.add(fe.elementId);
                    return;
                  }
                  if (fe.groupPDB === "HETATM" || ["UNK", "MOL"].includes(fe.residueName)) {
                    _e.has(ge) ? (ye = _e.get(ge)) === null || ye === void 0 || ye.push(fe) : _e.set(ge, [fe]);
                    return;
                  }
                  he.has(ge) ? (be = he.get(ge)) === null || be === void 0 || be.push(fe) : he.set(ge, [fe]);
                }
              });
              for (var Ee = 0, Me = Pe.bonds.a.length; Ee < Me; Ee++) {
                var ue = Pe.elements[Pe.bonds.a[Ee]], pe = Pe.elements[Pe.bonds.b[Ee]];
                Se.has(ue) ? (De = Se.get(ue)) === null || De === void 0 || De.add(pe) : Se.set(ue, /* @__PURE__ */ new Set([pe]));
              }
            }), _e.forEach(function(Pe, De) {
              var Ee = !1, Me = new Set(Pe.map(function(ue) {
                return ue.elementId;
              }));
              Me.forEach(function(ue) {
                if (Se.has(ue)) {
                  var pe = Se.get(ue);
                  pe == null || pe.forEach(function(Ae) {
                    de.has(Ae) && (Ee = !0);
                  });
                }
              }), Pe.forEach(function(ue) {
                var pe;
                Ee ? de.add(ue.elementId) : he.has(De) ? (pe = he.get(De)) === null || pe === void 0 || pe.push(ue) : he.set(De, [ue]);
              });
            }), he.forEach(function(Pe, De) {
              var Ee = Pe.filter(function(Me) {
                return Me.typeSymbol !== "H";
              });
              Ee.length > 10 && Ee.length < 150 ? me.set(De, Pe) : ce.push.apply(ce, Pe.map(function(Me) {
                return Me.elementId;
              }));
            }), W[ae] = (j = {}, j[n.HierarchyType.Protein] = de.size ? [{ ref: ae, elementIds: Array.from(de.values()) }] : [], j[n.HierarchyType.Ligand] = Array.from(me.entries()).map(function(Pe) {
              var De = Pe[0], Ee = Pe[1];
              return {
                ref: ae,
                elementIds: Ee.map(function(Me) {
                  return Me.elementId;
                }),
                name: De
              };
            }), j[n.HierarchyType.Solvent] = ne.length ? [{ ref: ae, elementIds: ne }] : [], j[n.HierarchyType.Water] = se.length ? [{ ref: ae, elementIds: se }] : [], j[n.HierarchyType.Other] = ce.length ? [{ ref: ae, elementIds: ce }] : [], j);
          }
        }
      }), W;
    };
    e.queryCellItemsByHierarchyType = L;
    var R = function($) {
      var Q;
      return (Q = $.model) !== null && Q !== void 0 ? Q : $.models[0];
    };
    e.getModelByStructure = R;
    var F = function($) {
      var Q, W;
      return (W = (Q = $.model) !== null && Q !== void 0 ? Q : $.models[0]) === null || W === void 0 ? void 0 : W.id;
    };
    e.getStructureUniqueId = F;
    var U = function($) {
      var Q, W, te, oe;
      return (Q = $ == null ? void 0 : $.model.structure) !== null && Q !== void 0 ? Q : !((W = $ == null ? void 0 : $.model) === null || W === void 0) && W.trajectory ? t.Structure.ofModel((te = $ == null ? void 0 : $.model.trajectory) === null || te === void 0 ? void 0 : te.state.getFrameAtIndex((oe = $ == null ? void 0 : $.model.trajectory) === null || oe === void 0 ? void 0 : oe.frameIndex)) : void 0;
    };
    e.getStructureByCell = U;
    var H = function($, Q) {
      var W = $.units.filter(function(z) {
        return y.SortedArray.has(z.elements, Q);
      })[0];
      if (!W || t.Unit.isCoarse(W))
        return n.HydrogenVariant.NotHydrogen;
      if (W.model.atomicHierarchy.derived.atom.atomicNumber[Q] !== 1) {
        var te = n.HydrogenVariant.NotHydrogen;
        return (0, S.eachBondedAtom)($, W, W.elements.indexOf(Q), function(z, j) {
          if (z.model.atomicHierarchy.derived.atom.atomicNumber[z.elements[j]] === 1)
            switch ((0, e.getHydrogenType)($, z.elements[j])) {
              case n.HydrogenVariant.Polar:
                te = n.HydrogenVariant.ConnectPolar;
                break;
              case n.HydrogenVariant.NonPolar:
                te = n.HydrogenVariant.ConnectNonPolar;
                break;
            }
        }), te;
      }
      var oe = (0, C.hasPolarNeighbour)($, W, y.SortedArray.indexOf(W.elements, Q));
      return oe ? n.HydrogenVariant.Polar : oe ? n.HydrogenVariant.NotHydrogen : n.HydrogenVariant.NonPolar;
    };
    e.getHydrogenType = H;
    var q = function($, Q) {
      return (0, r.__awaiter)(void 0, void 0, void 0, function() {
        var W;
        return (0, r.__generator)(this, function(te) {
          switch (te.label) {
            case 0:
              return [4, Promise.all(Q.filter(function(oe) {
                return $.cells.has(oe.ref);
              }).map(function(oe) {
                return $.managers.cell.getStructure(oe.ref);
              }))];
            case 1:
              return W = te.sent(), [2, (0, l.getMergedStructureContent)(W)];
          }
        });
      });
    };
    e.getMergedContent = q;
    var K = function($) {
      return Array.from($.cells.entries()).map(function(Q) {
        var W = Q[0], te = Q[1], oe = (0, e.getStructureByCell)(te);
        return oe ? te.representations.size === 0 || Array.from(te.representations.values()).filter(function(z) {
          return !z.isHidden;
        }).length === 0 ? { ref: "" } : { ref: W } : { ref: "" };
      }).filter(function(Q) {
        return Q.ref;
      });
    };
    e.getGlobalCellItems = K;
    var Y = function($, Q) {
      var W = [];
      return Q.forEach(function(te) {
        var oe = te.ref, z = te.elementIds, j = [];
        if (z != null && z.length) {
          var ae = $.managers.cell.get(oe), le = (0, e.getStructureByCell)(ae);
          if (le) {
            var ie = new Set(z.map(function(re) {
              return (0, s.getGranularityUniqueId)((0, e.getAtomHierarchyByStructure)(le, re), n.Granularity.Residue);
            }));
            le.units.forEach(function(re) {
              re.elements.forEach(function(ee) {
                var ne = (0, e.getAtomHierarchyByUnit)(re, ee), se = (0, s.getGranularityUniqueId)(ne, n.Granularity.Residue);
                ie.has(se) && j.push(ee);
              });
            }), j.length && W.push({ ref: oe, elementIds: (0, r.__spreadArray)([], j, !0) });
          }
        }
      }), W;
    };
    e.getWholeResiduesCellItem = Y;
    var X = function($, Q) {
      var W = (0, e.getAtomHierarchyByStructure)($, Q);
      return W.typeSymbol === "H" && (0, e.getHydrogenType)($, Q) === n.HydrogenVariant.NonPolar;
    };
    e.isNonPolarHydrogen = X;
    var Z = function($) {
      if (!$)
        return $;
      var Q = [], W = $.sort(function(oe, z) {
        return +oe - +z;
      }), te = [];
      return W.forEach(function(oe, z) {
        if (te.length === 0) {
          te.push(oe);
          return;
        }
        if (te.length === 1) {
          te[0] === oe - 1 ? te.push(oe) : (Q.push(te[0], te[0]), te = [oe]);
          return;
        }
        te.length === 2 && (te[1] === oe - 1 ? te[1] = oe : (Q.push.apply(Q, te), te = [oe]));
      }), te.length && Q.push.apply(Q, te.length === 2 ? te : [te[0], te[0]]), Q;
    };
    e.compressElementIds = Z;
    var J = function($) {
      for (var Q = [], W = 0, te = $.length; W < te; W += 2)
        for (var oe = $[W]; oe <= $[W + 1]; oe++)
          Q.push(oe);
      return Q;
    };
    e.uncompressElementIds = J;
  }(fT)), fT;
}
var Uo = {}, CT = {}, iA = {}, iD = {}, AT = {}, l1 = {}, hN;
function oA() {
  if (hN) return l1;
  hN = 1, Object.defineProperty(l1, "__esModule", { value: !0 }), l1.ComplexRepresentation = void 0;
  var e = Te, r = Le, t = Ss(), n = Wt, a = Je(), i = cl, o = Si, c = Pc(), s = Kr, u = _r, l = _n, f = k0, d = z0, m = U0, p = G0;
  function v(h, y, C, S) {
    var b = 0, g = y.webgl, _ = new i.Subject(), A = new n.Representation.GeometryState(), M = (0, o.getNextMaterialId)(), P = [], T = t.StructureRepresentationStateBuilder.create(), x, w, E, I, B = c.Theme.createEmpty();
    function D(L, R) {
      var F = this;
      return L === void 0 && (L = {}), R && R !== w && (E = C(y, R), w = R, I || (I = r.ParamDefinition.getDefaultValues(E))), I = Object.assign({}, I, L), s.Task.create("Creating or updating ComplexRepresentation", function(U) {
        return (0, e.__awaiter)(F, void 0, void 0, function() {
          var H, q, K;
          return (0, e.__generator)(this, function(Y) {
            switch (Y.label) {
              case 0:
                return H = !1, x ? !((K = x.mustRecreate) === null || K === void 0) && K.call(x, w, I, g) && (x.destroy(), x = S(M, w, I, g), H = !0) : (x = S(M, w, I, g), H = !0), q = x.createOrUpdate({ webgl: g, runtime: U }, B, I, R), q ? [4, q] : [3, 2];
              case 1:
                Y.sent(), Y.label = 2;
              case 2:
                return H && V(T), P.length = 0, x && x.renderObject && (P.push(x.renderObject), A.add(x.renderObject.id, x.geometryVersion)), A.snapshot(), b += 1, _.next(b), [
                  2
                  /*return*/
                ];
            }
          });
        });
      });
    }
    function N(L) {
      return L === void 0 ? a.Structure.Loci(w.target) : x ? x.getLoci(L) : u.EmptyLoci;
    }
    function O(L, R) {
      if (!w || !l.MarkerActions.is(T.markerActions, R))
        return !1;
      if (a.Structure.isLoci(L) || a.StructureElement.Loci.is(L) || a.Bond.isLoci(L)) {
        if (!a.Structure.areRootsEquivalent(L.structure, w))
          return !1;
        L = u.Loci.remap(L, w), (a.Structure.isLoci(L) || a.StructureElement.Loci.is(L) && a.StructureElement.Loci.isWholeStructure(L)) && (L = u.EveryLoci);
      } else if (!(0, u.isEveryLoci)(L) && !(0, u.isDataLoci)(L))
        return !1;
      return u.Loci.isEmpty(L) ? !1 : x ? x.mark(L, R) : !1;
    }
    function V(L) {
      if (t.StructureRepresentationStateBuilder.update(T, L), L.visible !== void 0 && x && x.setVisibility(L.visible && (T.unitTransforms === null || T.unitTransforms.isIdentity)), L.alphaFactor !== void 0 && x && x.setAlphaFactor(L.alphaFactor), L.pickable !== void 0 && x && x.setPickable(L.pickable), L.overpaint !== void 0 && x) {
        var R = f.Overpaint.remap(L.overpaint, w);
        x.setOverpaint(R, g);
      }
      if (L.transparency !== void 0 && x) {
        var F = m.Transparency.remap(L.transparency, w);
        x.setTransparency(F, g);
      }
      if (L.substance !== void 0 && x) {
        var U = p.Substance.remap(L.substance, w);
        x.setSubstance(U, g);
      }
      if (L.clipping !== void 0 && x) {
        var H = d.Clipping.remap(L.clipping, w);
        x.setClipping(H);
      }
      L.transform !== void 0 && x && x.setTransform(L.transform), L.unitTransforms !== void 0 && x && x.setVisibility(T.visible && (L.unitTransforms === null || L.unitTransforms.isIdentity));
    }
    function k(L) {
      B = L;
    }
    function G() {
      x && x.destroy();
    }
    return {
      label: h,
      get groupCount() {
        return x ? x.groupCount : 0;
      },
      get props() {
        return I;
      },
      get params() {
        return E;
      },
      get state() {
        return T;
      },
      get theme() {
        return B;
      },
      get geometryVersion() {
        return A.version;
      },
      renderObjects: P,
      updated: _,
      createOrUpdate: D,
      setState: V,
      setTheme: k,
      getLoci: N,
      mark: O,
      destroy: G
    };
  }
  return l1.ComplexRepresentation = v, l1;
}
var pt = {}, qt = {}, bl = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.isTrace = e.isH = e.isHydrogen = e.getStructureConformationAndRadius = e.getUnitConformationAndRadius = e.DefaultCommonSurfaceProps = e.CommonSurfaceParams = e.getConformation = e.ensureReasonableResolution = e.getVolumeSliceInfo = e.includesUnitKind = e.UnitKindOptions = e.UnitKindInfo = e.createUnitsTransform = e.getAltResidueLociFromId = e.getAltResidueLoci = e.getResidueLoci = void 0;
  var r = Te, t = Je(), n = Re, a = ji, i = Qe(), o = _r, c = _s, s = hr, u = Le, l = B0, f = nr();
  function d(I, B, D) {
    var N = B.elements, O = B.model;
    if (i.OrderedSet.indexOf(N, D) !== -1) {
      for (var V = O.atomicHierarchy.residueAtomSegments, k = V.index, G = V.offsets, L = k[D], R = [], F = G[L], U = G[L + 1]; F < U; ++F) {
        var H = i.OrderedSet.indexOf(N, F);
        H !== -1 && R.push(H);
      }
      var q = i.OrderedSet.ofSortedArray(i.SortedArray.ofSortedArray(R));
      return t.StructureElement.Loci(I, [{ unit: B, indices: q }]);
    }
    return o.EmptyLoci;
  }
  e.getResidueLoci = d;
  function m(I, B, D) {
    var N = B.elements, O = B.model, V = O.atomicHierarchy.atoms.label_alt_id, k = V.value(D);
    if (i.OrderedSet.indexOf(N, D) !== -1) {
      var G = O.atomicHierarchy.residueAtomSegments.index, L = G[D];
      return p(I, B, L, k);
    }
    return t.StructureElement.Loci(I, []);
  }
  e.getAltResidueLoci = m;
  function p(I, B, D, N) {
    for (var O = B.elements, V = B.model, k = V.atomicHierarchy.atoms.label_alt_id, G = V.atomicHierarchy.residueAtomSegments.offsets, L = [], R = G[D], F = G[D + 1]; R < F; ++R) {
      var U = i.OrderedSet.indexOf(O, R);
      if (U !== -1) {
        var H = k.value(R);
        (N === H || H === "") && L.push(U);
      }
    }
    var q = i.OrderedSet.ofSortedArray(i.SortedArray.ofSortedArray(L));
    return t.StructureElement.Loci(I, [{ unit: B, indices: q }]);
  }
  e.getAltResidueLociFromId = p;
  function v(I, B, D) {
    for (var N = I.structure.child, O = B && N ? I.group.units.filter(function(R) {
      return N.unitMap.has(R.id);
    }) : I.group.units, V = O.length, k = V * 16, G = D && D.aTransform.ref.value.length >= k ? D.aTransform.ref.value : new Float32Array(k), L = 0; L < V; L++)
      n.Mat4.toArray(O[L].conformation.operator.matrix, G, L * 16);
    return (0, a.createTransform)(G, V, D);
  }
  e.createUnitsTransform = v, e.UnitKindInfo = {
    atomic: {},
    spheres: {},
    gaussians: {}
  }, e.UnitKindOptions = u.ParamDefinition.objectToOptions(e.UnitKindInfo);
  function h(I, B) {
    for (var D = 0, N = I.length; D < N; ++D)
      if (t.Unit.isAtomic(B) && I[D] === "atomic" || t.Unit.isSpheres(B) && I[D] === "spheres" || t.Unit.isGaussians(B) && I[D] === "gaussians")
        return !0;
    return !1;
  }
  e.includesUnitKind = h;
  var y = 5e8;
  function C(I, B, D) {
    D === void 0 && (D = y);
    var N = f.Box3D.size((0, n.Vec3)(), I);
    n.Vec3.ceil(N, N), N.sort(function(G, L) {
      return L - G;
    });
    var O = Math.floor(Math.cbrt(D) * Math.cbrt(D)), V = N[0] * N[1], k = Math.ceil(V / (B * B));
    return { area: V, areaCells: k, maxAreaCells: O };
  }
  e.getVolumeSliceInfo = C;
  function S(I, B, D) {
    D === void 0 && (D = y);
    var N = C(I, B.resolution, D), O = N.area, V = N.areaCells, k = N.maxAreaCells, G = V > k ? Math.sqrt(O / k) : B.resolution;
    return (0, r.__assign)((0, r.__assign)({}, B), { resolution: G });
  }
  e.ensureReasonableResolution = S;
  function b(I) {
    switch (I.kind) {
      case 0:
        return I.model.atomicConformation;
      case 1:
        return I.model.coarseConformation.spheres;
      case 2:
        return I.model.coarseConformation.gaussians;
    }
  }
  e.getConformation = b, e.CommonSurfaceParams = {
    ignoreHydrogens: u.ParamDefinition.Boolean(!1, {
      description: "Whether or not to include hydrogen atoms in the surface calculation."
    }),
    traceOnly: u.ParamDefinition.Boolean(!1, {
      description: "Whether or not to only use trace atoms in the surface calculation."
    }),
    includeParent: u.ParamDefinition.Boolean(!1, {
      description: "Include elements of the parent structure in surface calculation to get a surface patch of the current structure."
    })
  }, e.DefaultCommonSurfaceProps = u.ParamDefinition.getDefaultValues(e.CommonSurfaceParams);
  var g = (0, n.Vec3)();
  function _(I, B, D, N) {
    return n.Vec3.squaredDistance(n.Vec3.set(g, I, B, D), N);
  }
  function A(I, B, D) {
    for (var N = 0, O = B.length, V = 0, k = D.length; V < k; ++V) {
      var G = i.SortedArray.indexOfInRange(B, D[V], N, O);
      G === -1 ? I[V] = -2 : (I[V] = G, N = G);
    }
  }
  function M(I, B, D, N) {
    var O = N.ignoreHydrogens, V = N.traceOnly, k = N.includeParent, G = k ? I.root.unitMap.get(B.id) : B, L = b(G), R = L.x, F = L.y, U = L.z, H = G.elements, q = B.boundary.sphere, K = q.center, Y = q.radius, X = (2 + 1.5) * 2, Z = (Y + X) * (Y + X), J, $;
    if (O || V || k && G !== B) {
      for (var Q = [], W = [], te = 0, oe = H.length; te < oe; ++te) {
        var z = H[te];
        O && x(G, z) || V && !E(G, z) || k && _(R[z], F[z], U[z], K) > Z || (Q.push(z), W.push(te));
      }
      J = i.SortedArray.ofSortedArray(Q), $ = W;
    } else
      J = H, $ = (0, s.fillSerial)(new Int32Array(J.length));
    k && G !== B && A($, B.elements, J);
    var j = { indices: J, x: R, y: F, z: U, id: $ }, ae = B === G ? B.boundary : (0, l.getBoundary)(j), le = t.StructureElement.Location.create(I, G), ie = function(re) {
      return le.element = re, D.size(le);
    };
    return { position: j, boundary: ae, radius: ie };
  }
  e.getUnitConformationAndRadius = M;
  function P(I, B, D, N) {
    var O = t.StructureElement.Location.create(I), V, k, G, L, R;
    if (D || N) {
      for (var F = [], U = [], H = [], q = [], K = [], Y = 0, X = 0, Z = I.units.length; Y < Z; ++Y) {
        var J = I.units[Y], $ = J.elements, Q = J.conformation, W = Q.x, te = Q.y, oe = Q.z;
        O.unit = J;
        for (var z = 0, j = $.length; z < j; ++z) {
          var ae = $[z];
          D && x(J, ae) || N && !E(J, ae) || (F.push(W(ae)), U.push(te(ae)), H.push(oe(ae)), O.element = ae, q.push(B.size(O)), K.push(X + z));
        }
        X += $.length;
      }
      V = F, k = U, G = H, L = q, R = K;
    } else {
      for (var le = I.elementCount, F = new Float32Array(le), U = new Float32Array(le), H = new Float32Array(le), q = new Float32Array(le), Y = 0, X = 0, Z = I.units.length; Y < Z; ++Y) {
        var J = I.units[Y], $ = J.elements, ie = J.conformation, W = ie.x, te = ie.y, oe = ie.z;
        O.unit = J;
        for (var z = 0, j = $.length; z < j; ++z) {
          var ae = $[z], re = X + z;
          F[re] = W(ae), U[re] = te(ae), H[re] = oe(ae), O.element = ae, q[re] = B.size(O);
        }
        X += $.length;
      }
      V = F, k = U, G = H, L = q, R = (0, s.fillSerial)(new Uint32Array(le));
    }
    var ee = {
      indices: i.OrderedSet.ofRange(0, R.length),
      x: V,
      y: k,
      z: G,
      id: R
    }, ne = function(se) {
      return L[se];
    };
    return { position: ee, radius: ne };
  }
  e.getStructureConformationAndRadius = P;
  var T = c.AtomicNumbers.H;
  function x(I, B) {
    return t.Unit.isCoarse(I) ? !1 : I.model.atomicHierarchy.derived.atom.atomicNumber[B] === T;
  }
  e.isHydrogen = x;
  function w(I, B) {
    return I[B] === T;
  }
  e.isH = w;
  function E(I, B) {
    if (t.Unit.isCoarse(I))
      return !0;
    var D = I.model.atomicHierarchy.atoms.label_atom_id.value(B);
    return D === "CA" || D === "BB" || D === "P";
  }
  e.isTrace = E;
})(bl);
Object.defineProperty(qt, "__esModule", { value: !0 });
qt.StructureTextureMeshParams = qt.StructureDirectVolumeParams = qt.StructureTextParams = qt.StructureLinesParams = qt.StructurePointsParams = qt.StructureCylindersParams = qt.StructureSpheresParams = qt.StructureMeshParams = qt.StructureParams = qt.getUnitKindsParam = void 0;
var Qd = Te, oye = c4(), uye = Fa(), sye = Dt(), lye = hy(), cye = Ep(), dye = hl(), fye = bs(), mye = yy(), pj = Le, vye = bl;
function hj(e) {
  return pj.ParamDefinition.MultiSelect(e, vye.UnitKindOptions, { description: "For which kinds of units/chains to show the representation visuals." });
}
qt.getUnitKindsParam = hj;
qt.StructureParams = {
  unitKinds: hj(["atomic", "spheres"]),
  includeParent: pj.ParamDefinition.Boolean(!1, { isHidden: !0 })
};
qt.StructureMeshParams = (0, Qd.__assign)({}, sye.Mesh.Params);
qt.StructureSpheresParams = (0, Qd.__assign)({}, cye.Spheres.Params);
qt.StructureCylindersParams = (0, Qd.__assign)({}, dye.Cylinders.Params);
qt.StructurePointsParams = (0, Qd.__assign)({}, lye.Points.Params);
qt.StructureLinesParams = (0, Qd.__assign)({}, uye.Lines.Params);
qt.StructureTextParams = (0, Qd.__assign)({}, fye.Text.Params);
qt.StructureDirectVolumeParams = (0, Qd.__assign)({}, oye.DirectVolume.Params);
qt.StructureTextureMeshParams = (0, Qd.__assign)({}, mye.TextureMesh.Params);
Object.defineProperty(pt, "__esModule", { value: !0 });
pt.ComplexTextureMeshVisual = pt.ComplexTextureMeshParams = pt.ComplexDirectVolumeVisual = pt.ComplexDirectVolumeParams = pt.ComplexTextVisual = pt.ComplexTextParams = pt.ComplexLinesVisual = pt.ComplexLinesParams = pt.ComplexCylindersVisual = pt.ComplexCylindersParams = pt.ComplexMeshVisual = pt.ComplexMeshParams = pt.ComplexVisual = void 0;
var hn = Te, Vs = gl, Vf = Je(), ew = Kd(), pye = Pc(), hye = ji, gye = Si, xT = _r, yye = Qe(), gN = Vp, _ye = Np(), TT = We(), bye = Tc(), Sye = ru(), Cye = _n, Aye = Dt(), xye = hl(), Tye = Fa(), Pye = bs(), jp = _y(), Mye = c4(), wye = na, Du = qt, Eye = yy(), Dye = Ft;
function Iye(e, r, t, n, a, i) {
  var o = ew.Geometry.getUtils(r), c = o.createValues, s = o.createRenderableState, u = (0, hye.createIdentityTransform)(), l = c(r, u, t, n, a), f = s(a);
  return (0, gye.createRenderObject)(r.kind, l, f, i);
}
function j0(e, r) {
  var t = e.defaultProps, n = e.createGeometry, a = e.createLocationIterator, i = e.getLoci, o = e.eachLocation, c = e.setUpdateState, s = e.mustRecreate, u = e.processValues, l = e.dispose, f = e.geometryUtils, d = f.updateValues, m = f.updateBoundingSphere, p = f.updateRenderableState, v = f.createPositionIterator, h = gN.VisualUpdateState.create(), y = { loci: xT.EmptyLoci, action: Cye.MarkerAction.None, status: -1 }, C, S, b, g, _ = Object.assign({}, t), A = pye.Theme.createEmpty(), M, P, T = -1, x, w;
  function E(O, V, k) {
    if (!k && !M)
      throw new Error("missing structure");
    if (S = Object.assign({}, _, V), b = O, g = k, gN.VisualUpdateState.reset(h), !C || !M) {
      h.createNew = !0, h.createGeometry = !0;
      return;
    }
    c(h, S, _, b, A, g, M), Vf.Structure.areEquivalent(g, M) || (h.createGeometry = !0), Vf.Structure.areHierarchiesEqual(g, M) || (h.updateTransform = !0, h.createGeometry = !0), _ye.ColorTheme.areEqual(O.color, A.color) || (h.updateColor = !0), (0, TT.deepEqual)(S.unitKinds, _.unitKinds) || (h.createGeometry = !0), M.child !== g.child && (h.createGeometry = !0), h.updateSize && !("uSize" in C.values) && (h.createGeometry = !0), h.createGeometry && (h.updateColor = !0, h.updateSize = !0);
  }
  function I(O) {
    if (h.createNew)
      if (x = a(g), O)
        C = Iye(g, O, x, b, S, r), w = v(O, C.values);
      else
        throw new Error("expected geometry to be given");
    else {
      if (!C)
        throw new Error("expected renderObject to be available");
      if (h.updateTransform) {
        x = a(g);
        var V = x.instanceCount, k = x.groupCount;
        (0, wye.createMarkers)(V * k, C.values);
      }
      if (h.createGeometry)
        if (O)
          TT.ValueCell.updateIfChanged(C.values.drawCount, ew.Geometry.getDrawCount(O)), TT.ValueCell.updateIfChanged(C.values.uVertexCount, ew.Geometry.getVertexCount(O));
        else
          throw new Error("expected geometry to be given");
      (h.updateTransform || h.createGeometry) && (m(C.values, O || P), w = v(P, C.values)), h.updateSize && "uSize" in C.values && (0, bye.createSizes)(x, b.size, C.values), h.updateColor && (0, Sye.createColors)(x, w, b.color, C.values), d(C.values, S), p(C.state, S);
    }
    _ = S, A = b, M = g, O && (P = O, T += 1);
  }
  function B(O) {
    return !!((0, xT.isEveryLoci)(O) || Vf.Structure.isLoci(O) && Vf.Structure.areRootsEquivalent(O.structure, M) || Vf.StructureElement.Loci.is(O) && Vf.Structure.areRootsEquivalent(O.structure, M) && Vf.StructureElement.Loci.isWholeStructure(O));
  }
  function D(O, V, k) {
    return B(O) ? V(yye.Interval.ofBounds(0, x.groupCount * x.instanceCount)) : o(O, M, V, k);
  }
  function N(O) {
    C && (u == null || u(C.values, P, _, A, O.webgl));
  }
  return {
    get groupCount() {
      return x ? x.count : 0;
    },
    get renderObject() {
      return x && x.count ? C : void 0;
    },
    get geometryVersion() {
      return T;
    },
    createOrUpdate: function(O, V, k, G) {
      if (k === void 0 && (k = {}), E(V, k, G || M), h.createGeometry) {
        var L = n(O, g, b, S, P);
        if ((0, Dye.isPromiseLike)(L))
          return L.then(function(R) {
            I(R), N(O);
          });
        I(L);
      } else
        I();
      N(O);
    },
    getLoci: function(O) {
      return C ? i(O, M, C.id) : xT.EmptyLoci;
    },
    mark: function(O, V) {
      return Vs.Visual.mark(C, O, V, D, y);
    },
    setVisibility: function(O) {
      Vs.Visual.setVisibility(C, O);
    },
    setAlphaFactor: function(O) {
      Vs.Visual.setAlphaFactor(C, O);
    },
    setPickable: function(O) {
      Vs.Visual.setPickable(C, O);
    },
    setColorOnly: function(O) {
      Vs.Visual.setColorOnly(C, O);
    },
    setTransform: function(O, V) {
      Vs.Visual.setTransform(C, O, V);
    },
    setOverpaint: function(O, V) {
      var k = { geometry: P, props: _, webgl: V };
      Vs.Visual.setOverpaint(C, O, D, !0, k);
    },
    setTransparency: function(O, V) {
      var k = { geometry: P, props: _, webgl: V };
      Vs.Visual.setTransparency(C, O, D, !0, k);
    },
    setSubstance: function(O, V) {
      var k = { geometry: P, props: _, webgl: V };
      Vs.Visual.setSubstance(C, O, D, !0, k);
    },
    setClipping: function(O) {
      Vs.Visual.setClipping(C, O, D, !0);
    },
    destroy: function() {
      l == null || l(P), C && (C.state.disposed = !0, C = void 0);
    },
    mustRecreate: s
  };
}
pt.ComplexVisual = j0;
pt.ComplexMeshParams = (0, hn.__assign)((0, hn.__assign)({}, Du.StructureMeshParams), Du.StructureParams);
function Bye(e, r) {
  return j0((0, hn.__assign)((0, hn.__assign)({}, e), { setUpdateState: function(t, n, a, i, o, c, s) {
    e.setUpdateState(t, n, a, i, o, c, s), jp.SizeTheme.areEqual(i.size, o.size) || (t.createGeometry = !0);
  }, geometryUtils: Aye.Mesh.Utils }), r);
}
pt.ComplexMeshVisual = Bye;
pt.ComplexCylindersParams = (0, hn.__assign)((0, hn.__assign)({}, Du.StructureCylindersParams), Du.StructureParams);
function Nye(e, r) {
  return j0((0, hn.__assign)((0, hn.__assign)({}, e), { setUpdateState: function(t, n, a, i, o, c, s) {
    e.setUpdateState(t, n, a, i, o, c, s), jp.SizeTheme.areEqual(i.size, o.size) || (t.updateSize = !0);
  }, geometryUtils: xye.Cylinders.Utils }), r);
}
pt.ComplexCylindersVisual = Nye;
pt.ComplexLinesParams = (0, hn.__assign)((0, hn.__assign)({}, Du.StructureLinesParams), Du.StructureParams);
function Vye(e, r) {
  return j0((0, hn.__assign)((0, hn.__assign)({}, e), { setUpdateState: function(t, n, a, i, o, c, s) {
    e.setUpdateState(t, n, a, i, o, c, s), jp.SizeTheme.areEqual(i.size, o.size) || (t.updateSize = !0);
  }, geometryUtils: Tye.Lines.Utils }), r);
}
pt.ComplexLinesVisual = Vye;
pt.ComplexTextParams = (0, hn.__assign)((0, hn.__assign)({}, Du.StructureTextParams), Du.StructureParams);
function Rye(e, r) {
  return j0((0, hn.__assign)((0, hn.__assign)({}, e), { setUpdateState: function(t, n, a, i, o, c, s) {
    e.setUpdateState(t, n, a, i, o, c, s), jp.SizeTheme.areEqual(i.size, o.size) || (t.updateSize = !0), n.background !== a.background && (t.createGeometry = !0), n.backgroundMargin !== a.backgroundMargin && (t.createGeometry = !0), n.tether !== a.tether && (t.createGeometry = !0), n.tetherLength !== a.tetherLength && (t.createGeometry = !0), n.tetherBaseWidth !== a.tetherBaseWidth && (t.createGeometry = !0), n.attachment !== a.attachment && (t.createGeometry = !0), n.fontFamily !== a.fontFamily && (t.createGeometry = !0), n.fontQuality !== a.fontQuality && (t.createGeometry = !0), n.fontStyle !== a.fontStyle && (t.createGeometry = !0), n.fontVariant !== a.fontVariant && (t.createGeometry = !0), n.fontWeight !== a.fontWeight && (t.createGeometry = !0);
  }, geometryUtils: Pye.Text.Utils }), r);
}
pt.ComplexTextVisual = Rye;
pt.ComplexDirectVolumeParams = (0, hn.__assign)((0, hn.__assign)({}, Du.StructureDirectVolumeParams), Du.StructureParams);
function Oye(e, r) {
  return j0((0, hn.__assign)((0, hn.__assign)({}, e), { setUpdateState: function(t, n, a, i, o, c, s) {
    e.setUpdateState(t, n, a, i, o, c, s), jp.SizeTheme.areEqual(i.size, o.size) || (t.createGeometry = !0);
  }, geometryUtils: Mye.DirectVolume.Utils }), r);
}
pt.ComplexDirectVolumeVisual = Oye;
pt.ComplexTextureMeshParams = (0, hn.__assign)((0, hn.__assign)({}, Du.StructureTextureMeshParams), Du.StructureParams);
function Fye(e, r) {
  return j0((0, hn.__assign)((0, hn.__assign)({}, e), { setUpdateState: function(t, n, a, i, o, c, s) {
    e.setUpdateState(t, n, a, i, o, c, s), jp.SizeTheme.areEqual(i.size, o.size) || (t.createGeometry = !0);
  }, geometryUtils: Eye.TextureMesh.Utils }), r);
}
pt.ComplexTextureMeshVisual = Fye;
var c1 = {}, yN;
function $0() {
  if (yN) return c1;
  yN = 1, Object.defineProperty(c1, "__esModule", { value: !0 }), c1.UnitsRepresentation = void 0;
  var e = Te, r = Le, t = Ss(), n = Wt, a = Je(), i = cl, o = Si, c = Pc(), s = Kr, u = _r, l = _n, f = k0, d = U0, m = Re, p = Qe(), v = z0, h = G0;
  function y(C, S, b, g) {
    var _ = 0, A = S.webgl, M = new i.Subject(), P = (0, o.getNextMaterialId)(), T = [], x = new n.Representation.GeometryState(), w = t.StructureRepresentationStateBuilder.create(), E = /* @__PURE__ */ new Map(), I, B, D, N, O = c.Theme.createEmpty();
    function V(H, q) {
      var K = this;
      return H === void 0 && (H = {}), q && q !== I && (D = b(S, q), N || (N = r.ParamDefinition.getDefaultValues(D))), N = Object.assign({}, N, H), s.Task.create("Creating or updating UnitsRepresentation", function(Y) {
        return (0, e.__awaiter)(K, void 0, void 0, function() {
          var Q, z, oe, j, X, Q, z, J, oe, j, j, Z, oe, j, Q, z, J, oe, j, j, $, Q, W, te, oe, z, j, j, ae, le, ie;
          return (0, e.__generator)(this, function(re) {
            switch (re.label) {
              case 0:
                if (!(!I && !q)) return [3, 1];
                throw new Error("missing structure");
              case 1:
                if (!(q && !I)) return [3, 8];
                B = q.unitSymmetryGroups, Q = 0, re.label = 2;
              case 2:
                return Q < B.length ? (z = B[Q], oe = g(P, q, N, A), j = oe.createOrUpdate({ webgl: A, runtime: Y }, O, N, { group: z, structure: q }), j ? [4, j] : [3, 4]) : [3, 7];
              case 3:
                re.sent(), re.label = 4;
              case 4:
                return L(oe, z, w), E.set(z.hashCode, { visual: oe, group: z }), Y.shouldUpdate ? [4, Y.update({
                  message: "Creating or updating UnitsVisual",
                  current: Q,
                  max: B.length
                })] : [3, 6];
              case 5:
                re.sent(), re.label = 6;
              case 6:
                return Q++, [3, 2];
              case 7:
                return [3, 43];
              case 8:
                if (!(q && (!a.Structure.areUnitIdsAndIndicesEqual(q, I) || q.child !== I.child))) return [3, 22];
                B = q.unitSymmetryGroups, X = E, E = /* @__PURE__ */ new Map(), Q = 0, re.label = 9;
              case 9:
                return Q < B.length ? (z = B[Q], J = X.get(z.hashCode), J ? (oe = J.visual, !((ae = oe.mustRecreate) === null || ae === void 0) && ae.call(oe, { group: z, structure: q }, N, A) ? (oe.destroy(), oe = g(P, q, N, A), j = oe.createOrUpdate({ webgl: A, runtime: Y }, O, N, { group: z, structure: q }), j ? [4, j] : [3, 11]) : [3, 12]) : [3, 15]) : [3, 21];
              case 10:
                re.sent(), re.label = 11;
              case 11:
                return L(oe, z, w), [3, 14];
              case 12:
                return j = oe.createOrUpdate({ webgl: A, runtime: Y }, O, N, { group: z, structure: q }), j ? [4, j] : [3, 14];
              case 13:
                re.sent(), re.label = 14;
              case 14:
                return E.set(z.hashCode, { visual: oe, group: z }), X.delete(z.hashCode), oe.renderObject && (Z = oe.renderObject.values.tMarker.ref.value.array, (0, l.applyMarkerAction)(Z, p.Interval.ofBounds(0, Z.length), l.MarkerAction.RemoveHighlight)), [3, 18];
              case 15:
                return oe = g(P, q, N, A), j = oe.createOrUpdate({ webgl: A, runtime: Y }, O, N, { group: z, structure: q }), j ? [4, j] : [3, 17];
              case 16:
                re.sent(), re.label = 17;
              case 17:
                L(oe, z, w), E.set(z.hashCode, { visual: oe, group: z }), re.label = 18;
              case 18:
                return Y.shouldUpdate ? [4, Y.update({
                  message: "Creating or updating UnitsVisual",
                  current: Q,
                  max: B.length
                })] : [3, 20];
              case 19:
                re.sent(), re.label = 20;
              case 20:
                return Q++, [3, 9];
              case 21:
                return X.forEach(function(ee) {
                  var ne = ee.visual;
                  ne.destroy();
                }), [3, 43];
              case 22:
                if (!(q && q !== I && a.Structure.areUnitIdsAndIndicesEqual(q, I))) return [3, 34];
                B = q.unitSymmetryGroups, Q = 0, re.label = 23;
              case 23:
                return Q < B.length ? (z = B[Q], J = E.get(z.hashCode), J ? (oe = J.visual, !((le = oe.mustRecreate) === null || le === void 0) && le.call(oe, { group: z, structure: q }, N, S.webgl) ? (oe.destroy(), oe = g(P, q, N, S.webgl), J.visual = oe, j = oe.createOrUpdate({ webgl: A, runtime: Y }, O, N, { group: z, structure: q }), j ? [4, j] : [3, 25]) : [3, 26]) : [3, 29]) : [3, 33];
              case 24:
                re.sent(), re.label = 25;
              case 25:
                return L(oe, z, w), [3, 28];
              case 26:
                return j = oe.createOrUpdate({ webgl: A, runtime: Y }, O, N, { group: z, structure: q }), j ? [4, j] : [3, 28];
              case 27:
                re.sent(), re.label = 28;
              case 28:
                return J.group = z, [3, 30];
              case 29:
                throw new Error("expected to find visual for hashCode ".concat(z.hashCode));
              case 30:
                return Y.shouldUpdate ? [4, Y.update({
                  message: "Creating or updating UnitsVisual",
                  current: Q,
                  max: B.length
                })] : [3, 32];
              case 31:
                re.sent(), re.label = 32;
              case 32:
                return Q++, [3, 23];
              case 33:
                return [3, 43];
              case 34:
                $ = [], E.forEach(function(ee) {
                  return $.push(ee);
                }), Q = 0, W = $.length, re.label = 35;
              case 35:
                return Q < W ? (te = $[Q], oe = te.visual, z = te.group, !((ie = oe.mustRecreate) === null || ie === void 0) && ie.call(oe, { group: z, structure: I }, N, S.webgl) ? (oe.destroy(), oe = g(P, I, N, A), $[Q].visual = oe, j = oe.createOrUpdate({ webgl: A, runtime: Y }, O, N, { group: z, structure: I }), j ? [4, j] : [3, 37]) : [3, 38]) : [3, 43];
              case 36:
                re.sent(), re.label = 37;
              case 37:
                return L(oe, z, w), [3, 40];
              case 38:
                return j = oe.createOrUpdate({ webgl: A, runtime: Y }, O, N), j ? [4, j] : [3, 40];
              case 39:
                re.sent(), re.label = 40;
              case 40:
                return Y.shouldUpdate ? [4, Y.update({
                  message: "Creating or updating UnitsVisual",
                  current: Q,
                  max: W
                })] : [3, 42];
              case 41:
                re.sent(), re.label = 42;
              case 42:
                return ++Q, [3, 35];
              case 43:
                return T.length = 0, E.forEach(function(ee) {
                  var ne = ee.visual;
                  ne.renderObject && (T.push(ne.renderObject), x.add(ne.renderObject.id, ne.geometryVersion));
                }), x.snapshot(), q && (I = q), M.next(_++), [
                  2
                  /*return*/
                ];
            }
          });
        });
      });
    }
    function k(H) {
      if (H === void 0)
        return a.Structure.Loci(I.target);
      var q = u.EmptyLoci;
      return E.forEach(function(K) {
        var Y = K.visual, X = Y.getLoci(H);
        (0, u.isEmptyLoci)(X) || (q = X);
      }), q;
    }
    function G(H, q) {
      if (!I || !l.MarkerActions.is(w.markerActions, q))
        return !1;
      if (a.Structure.isLoci(H) || a.StructureElement.Loci.is(H) || a.Bond.isLoci(H)) {
        if (!a.Structure.areRootsEquivalent(H.structure, I))
          return !1;
        H = u.Loci.remap(H, I), (a.Structure.isLoci(H) || a.StructureElement.Loci.is(H) && a.StructureElement.Loci.isWholeStructure(H)) && (H = u.EveryLoci);
      } else if (!(0, u.isEveryLoci)(H) && !(0, u.isDataLoci)(H))
        return !1;
      if (u.Loci.isEmpty(H))
        return !1;
      var K = !1;
      return E.forEach(function(Y) {
        var X = Y.visual;
        K = X.mark(H, q) || K;
      }), K;
    }
    function L(H, q, K) {
      var Y = K.visible, X = K.alphaFactor, Z = K.pickable, J = K.overpaint, $ = K.transparency, Q = K.substance, W = K.clipping, te = K.transform, oe = K.unitTransforms;
      Y !== void 0 && H.setVisibility(Y), X !== void 0 && H.setAlphaFactor(X), Z !== void 0 && H.setPickable(Z), J !== void 0 && H.setOverpaint(J, A), $ !== void 0 && H.setTransparency($, A), Q !== void 0 && H.setSubstance(Q, A), W !== void 0 && H.setClipping(W), te !== void 0 && H.setTransform(te), oe !== void 0 && (oe ? H.setTransform(void 0, oe.getSymmetryGroupTransforms(q)) : H.setTransform(void 0, null));
    }
    function R(H) {
      var q = H.visible, K = H.alphaFactor, Y = H.pickable, X = H.overpaint, Z = H.transparency, J = H.substance, $ = H.clipping, Q = H.transform, W = H.unitTransforms, te = H.syncManually, oe = H.markerActions, z = {};
      q !== w.visible && (z.visible = q), K !== w.alphaFactor && (z.alphaFactor = K), Y !== w.pickable && (z.pickable = Y), X !== void 0 && I && (z.overpaint = f.Overpaint.remap(X, I)), Z !== void 0 && I && (z.transparency = d.Transparency.remap(Z, I)), J !== void 0 && I && (z.substance = h.Substance.remap(J, I)), $ !== void 0 && I && (z.clipping = v.Clipping.remap($, I)), Q !== void 0 && !m.Mat4.areEqual(Q, w.transform, m.EPSILON) && (z.transform = Q), (W !== w.unitTransforms || (W == null ? void 0 : W.version) !== H.unitTransformsVersion) && (z.unitTransforms = W, w.unitTransformsVersion = W ? W == null ? void 0 : W.version : -1), te !== w.syncManually && (z.syncManually = te), oe !== w.markerActions && (z.markerActions = oe), E.forEach(function(j) {
        var ae = j.visual, le = j.group;
        return L(ae, le, z);
      }), t.StructureRepresentationStateBuilder.update(w, z);
    }
    function F(H) {
      O = H;
    }
    function U() {
      E.forEach(function(H) {
        var q = H.visual;
        return q.destroy();
      }), E.clear();
    }
    return {
      label: C,
      get groupCount() {
        var H = 0;
        return E.forEach(function(q) {
          var K = q.visual;
          K.renderObject && (H += K.groupCount);
        }), H;
      },
      get geometryVersion() {
        return x.version;
      },
      get props() {
        return N;
      },
      get params() {
        return D;
      },
      get state() {
        return w;
      },
      get theme() {
        return O;
      },
      renderObjects: T,
      updated: M,
      createOrUpdate: V,
      setState: R,
      setTheme: F,
      getLoci: k,
      mark: G,
      destroy: U
    };
  }
  return c1.UnitsRepresentation = y, c1;
}
var Mr = {};
Object.defineProperty(Mr, "__esModule", { value: !0 });
Mr.UnitsTextureMeshVisual = Mr.UnitsTextureMeshParams = Mr.UnitsDirectVolumeVisual = Mr.UnitsDirectVolumeParams = Mr.UnitsTextVisual = Mr.UnitsTextParams = Mr.UnitsLinesVisual = Mr.UnitsLinesParams = Mr.UnitsPointsVisual = Mr.UnitsPointsParams = Mr.UnitsCylindersVisual = Mr.UnitsCylindersParams = Mr.UnitsSpheresVisual = Mr.UnitsSpheresParams = Mr.UnitsMeshVisual = Mr.UnitsMeshParams = Mr.UnitsVisual = void 0;
var yt = Te, Rl = Je(), Rs = gl, rw = Kd(), Lye = Pc(), tw = bl, kye = Si, PT = _r, Uye = Qe(), _N = Vp, zye = Np(), Gye = na, qye = _n, MT = We(), Hye = Tc(), jye = ru(), $ye = Dt(), Zd = _y(), Kye = Ep(), Wye = hl(), Xye = hy(), Yye = Fa(), Qye = bs(), Zye = c4(), Jye = yy(), Ai = qt, e2e = Ft;
function r2e(e, r, t, n, a, i) {
  var o = rw.Geometry.getUtils(r), c = o.createValues, s = o.createRenderableState, u = (0, tw.createUnitsTransform)(e, a.includeParent), l = c(r, u, t, n, a), f = s(a);
  return (0, kye.createRenderObject)(r.kind, l, f, i);
}
function Dc(e, r) {
  var t = e.defaultProps, n = e.createGeometry, a = e.createLocationIterator, i = e.getLoci, o = e.eachLocation, c = e.setUpdateState, s = e.mustRecreate, u = e.processValues, l = e.dispose, f = e.geometryUtils, d = f.createEmpty, m = f.updateValues, p = f.updateBoundingSphere, v = f.updateRenderableState, h = f.createPositionIterator, y = _N.VisualUpdateState.create(), C = { loci: PT.EmptyLoci, action: qye.MarkerAction.None, status: -1 }, S, b = Object.assign({}, t), g = Lye.Theme.createEmpty(), _, A, M, P, T, x = -1, w, E;
  function I(k, G, L) {
    if (!L && !P)
      throw new Error("missing structureGroup");
    if (b = G, g = k, _ = L, _N.VisualUpdateState.reset(y), !S || !P) {
      y.createNew = !0, y.createGeometry = !0;
      return;
    }
    c(y, b, A, g, M, _, P), Rl.Structure.areHierarchiesEqual(P.structure, _.structure) || (y.updateTransform = !0, y.updateColor = !0, y.updateSize = !0), zye.ColorTheme.areEqual(g.color, M.color) || (y.updateColor = !0), P.structure.child !== _.structure.child && (y.createGeometry = !0), (0, MT.deepEqual)(b.unitKinds, A.unitKinds) || (y.createGeometry = !0), _.group.transformHash !== P.group.transformHash && (_.group.units.length !== P.group.units.length || y.updateColor ? y.updateTransform = !0 : y.updateMatrix = !0);
    var R = _.group.units[0], F = P.group.units[0];
    Rl.Unit.areOperatorsEqual(R, F) || (y.updateTransform = !0), Rl.Unit.areConformationsEqual(R, F) || (y.createGeometry = !0), y.updateTransform && (y.updateMatrix = !0), y.updateSize && !("uSize" in S.values) && (y.createGeometry = !0), (y.createGeometry || y.updateTransform) && (P.structure.hashCode !== _.structure.hashCode && (y.updateColor = !0, y.updateSize = !0), (g.color.granularity.startsWith("vertex") || S.values.dColorType.ref.value.startsWith("vertex") || g.color.granularity.startsWith("volume") || S.values.dColorType.ref.value.startsWith("volume")) && (y.updateColor = !0));
  }
  function B(k) {
    if (y.createNew)
      if (w = a(_), k)
        S = r2e(_, k, w, g, b, r), E = h(k, S.values);
      else
        throw new Error("expected geometry to be given");
    else {
      if (!S)
        throw new Error("expected renderObject to be available");
      if (y.updateTransform) {
        w = a(_);
        var G = w.instanceCount, L = w.groupCount;
        (0, Gye.createMarkers)(G * L, S.values);
      }
      if (y.updateMatrix && (0, tw.createUnitsTransform)(_, b.includeParent, S.values), y.createGeometry)
        if (k)
          MT.ValueCell.updateIfChanged(S.values.drawCount, rw.Geometry.getDrawCount(k)), MT.ValueCell.updateIfChanged(S.values.uVertexCount, rw.Geometry.getVertexCount(k));
        else
          throw new Error("expected geometry to be given");
      (y.updateTransform || y.createGeometry) && (p(S.values, k || T), E = h(k || T, S.values)), y.updateSize && "uSize" in S.values && (0, Hye.createSizes)(w, g.size, S.values), y.updateColor && (0, jye.createColors)(w, E, g.color, S.values), m(S.values, b), v(S.state, b);
    }
    A = b, M = g, P = _, k && (T = k, x += 1);
  }
  function D(k, G, L, R, F, U) {
    return (0, tw.includesUnitKind)(F.unitKinds, G) ? n(k, G, L, R, F, U) : d(U);
  }
  function N(k) {
    return !!((0, PT.isEveryLoci)(k) || Rl.Structure.isLoci(k) && Rl.Structure.areRootsEquivalent(k.structure, P.structure) || Rl.StructureElement.Loci.is(k) && Rl.Structure.areRootsEquivalent(k.structure, P.structure) && Rl.StructureElement.Loci.isWholeStructure(k));
  }
  function O(k, G, L) {
    return N(k) ? G(Uye.Interval.ofBounds(0, w.groupCount * w.instanceCount)) : o(k, P, G, L);
  }
  function V(k) {
    S && (u == null || u(S.values, T, A, M, k.webgl));
  }
  return {
    get groupCount() {
      return w ? w.count : 0;
    },
    get renderObject() {
      return w && w.count ? S : void 0;
    },
    get geometryVersion() {
      return x;
    },
    createOrUpdate: function(k, G, L, R) {
      if (I(G, L, R || P), y.createGeometry) {
        var F = D(k, _.group.units[0], _.structure, g, b, T);
        if ((0, e2e.isPromiseLike)(F))
          return F.then(function(U) {
            B(U), V(k);
          });
        B(F);
      } else
        B();
      V(k);
    },
    getLoci: function(k) {
      return S ? i(k, P, S.id) : PT.EmptyLoci;
    },
    mark: function(k, G) {
      var L = !0;
      if (Rl.StructureElement.Loci.is(k)) {
        L = !1;
        for (var R = P.group.units[0].invariantId, F = 0, U = k.elements; F < U.length; F++) {
          var H = U[F];
          if (H.unit.invariantId === R) {
            L = !0;
            break;
          }
        }
      }
      return L ? Rs.Visual.mark(S, k, G, O, C) : !1;
    },
    setVisibility: function(k) {
      Rs.Visual.setVisibility(S, k);
    },
    setAlphaFactor: function(k) {
      Rs.Visual.setAlphaFactor(S, k);
    },
    setPickable: function(k) {
      Rs.Visual.setPickable(S, k);
    },
    setColorOnly: function(k) {
      Rs.Visual.setColorOnly(S, k);
    },
    setTransform: function(k, G) {
      Rs.Visual.setTransform(S, k, G);
    },
    setOverpaint: function(k, G) {
      var L = { geometry: T, props: A, webgl: G };
      Rs.Visual.setOverpaint(S, k, O, !0, L);
    },
    setTransparency: function(k, G) {
      var L = { geometry: T, props: A, webgl: G };
      Rs.Visual.setTransparency(S, k, O, !0, L);
    },
    setSubstance: function(k, G) {
      var L = { geometry: T, props: A, webgl: G };
      Rs.Visual.setSubstance(S, k, O, !0, L);
    },
    setClipping: function(k) {
      Rs.Visual.setClipping(S, k, O, !0);
    },
    destroy: function() {
      l == null || l(T), S && (S.state.disposed = !0, S = void 0);
    },
    mustRecreate: s
  };
}
Mr.UnitsVisual = Dc;
Mr.UnitsMeshParams = (0, yt.__assign)((0, yt.__assign)({}, Ai.StructureMeshParams), Ai.StructureParams);
function t2e(e, r) {
  return Dc((0, yt.__assign)((0, yt.__assign)({}, e), { setUpdateState: function(t, n, a, i, o, c, s) {
    e.setUpdateState(t, n, a, i, o, c, s), Zd.SizeTheme.areEqual(i.size, o.size) || (t.createGeometry = !0);
  }, geometryUtils: $ye.Mesh.Utils }), r);
}
Mr.UnitsMeshVisual = t2e;
Mr.UnitsSpheresParams = (0, yt.__assign)((0, yt.__assign)({}, Ai.StructureSpheresParams), Ai.StructureParams);
function n2e(e, r) {
  return Dc((0, yt.__assign)((0, yt.__assign)({}, e), { setUpdateState: function(t, n, a, i, o, c, s) {
    e.setUpdateState(t, n, a, i, o, c, s), Zd.SizeTheme.areEqual(i.size, o.size) || (t.updateSize = !0);
  }, geometryUtils: Kye.Spheres.Utils }), r);
}
Mr.UnitsSpheresVisual = n2e;
Mr.UnitsCylindersParams = (0, yt.__assign)((0, yt.__assign)({}, Ai.StructureCylindersParams), Ai.StructureParams);
function a2e(e, r) {
  return Dc((0, yt.__assign)((0, yt.__assign)({}, e), { setUpdateState: function(t, n, a, i, o, c, s) {
    e.setUpdateState(t, n, a, i, o, c, s), Zd.SizeTheme.areEqual(i.size, o.size) || (t.updateSize = !0);
  }, geometryUtils: Wye.Cylinders.Utils }), r);
}
Mr.UnitsCylindersVisual = a2e;
Mr.UnitsPointsParams = (0, yt.__assign)((0, yt.__assign)({}, Ai.StructurePointsParams), Ai.StructureParams);
function i2e(e, r) {
  return Dc((0, yt.__assign)((0, yt.__assign)({}, e), { setUpdateState: function(t, n, a, i, o, c, s) {
    e.setUpdateState(t, n, a, i, o, c, s), Zd.SizeTheme.areEqual(i.size, o.size) || (t.updateSize = !0);
  }, geometryUtils: Xye.Points.Utils }), r);
}
Mr.UnitsPointsVisual = i2e;
Mr.UnitsLinesParams = (0, yt.__assign)((0, yt.__assign)({}, Ai.StructureLinesParams), Ai.StructureParams);
function o2e(e, r) {
  return Dc((0, yt.__assign)((0, yt.__assign)({}, e), { setUpdateState: function(t, n, a, i, o, c, s) {
    e.setUpdateState(t, n, a, i, o, c, s), Zd.SizeTheme.areEqual(i.size, o.size) || (t.updateSize = !0);
  }, geometryUtils: Yye.Lines.Utils }), r);
}
Mr.UnitsLinesVisual = o2e;
Mr.UnitsTextParams = (0, yt.__assign)((0, yt.__assign)({}, Ai.StructureTextParams), Ai.StructureParams);
function u2e(e, r) {
  return Dc((0, yt.__assign)((0, yt.__assign)({}, e), { setUpdateState: function(t, n, a, i, o, c, s) {
    e.setUpdateState(t, n, a, i, o, c, s), Zd.SizeTheme.areEqual(i.size, o.size) || (t.updateSize = !0), n.background !== a.background && (t.createGeometry = !0), n.backgroundMargin !== a.backgroundMargin && (t.createGeometry = !0), n.tether !== a.tether && (t.createGeometry = !0), n.tetherLength !== a.tetherLength && (t.createGeometry = !0), n.tetherBaseWidth !== a.tetherBaseWidth && (t.createGeometry = !0), n.attachment !== a.attachment && (t.createGeometry = !0), n.fontFamily !== a.fontFamily && (t.createGeometry = !0), n.fontQuality !== a.fontQuality && (t.createGeometry = !0), n.fontStyle !== a.fontStyle && (t.createGeometry = !0), n.fontVariant !== a.fontVariant && (t.createGeometry = !0), n.fontWeight !== a.fontWeight && (t.createGeometry = !0);
  }, geometryUtils: Qye.Text.Utils }), r);
}
Mr.UnitsTextVisual = u2e;
Mr.UnitsDirectVolumeParams = (0, yt.__assign)((0, yt.__assign)({}, Ai.StructureDirectVolumeParams), Ai.StructureParams);
function s2e(e, r) {
  return Dc((0, yt.__assign)((0, yt.__assign)({}, e), { setUpdateState: function(t, n, a, i, o, c, s) {
    e.setUpdateState(t, n, a, i, o, c, s), Zd.SizeTheme.areEqual(i.size, o.size) || (t.createGeometry = !0);
  }, geometryUtils: Zye.DirectVolume.Utils }), r);
}
Mr.UnitsDirectVolumeVisual = s2e;
Mr.UnitsTextureMeshParams = (0, yt.__assign)((0, yt.__assign)({}, Ai.StructureTextureMeshParams), Ai.StructureParams);
function l2e(e, r) {
  return Dc((0, yt.__assign)((0, yt.__assign)({}, e), { setUpdateState: function(t, n, a, i, o, c, s) {
    e.setUpdateState(t, n, a, i, o, c, s), Zd.SizeTheme.areEqual(i.size, o.size) || (t.createGeometry = !0);
  }, geometryUtils: Jye.TextureMesh.Utils }), r);
}
Mr.UnitsTextureMeshVisual = l2e;
var bN;
function Ss() {
  return bN || (bN = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.UnitsVisual = e.UnitsRepresentation = e.ComplexVisual = e.ComplexRepresentation = e.StructureRepresentationProvider = e.StructureRepresentationStateBuilder = void 0;
    var r = Te, t = Wt;
    e.StructureRepresentationStateBuilder = {
      create: function() {
        return (0, r.__assign)((0, r.__assign)({}, t.Representation.createState()), { unitTransforms: null, unitTransformsVersion: -1 });
      },
      update: function(s, u) {
        t.Representation.updateState(s, u), u.unitTransforms !== void 0 && (s.unitTransforms = u.unitTransforms);
      }
    };
    function n(s) {
      return s;
    }
    e.StructureRepresentationProvider = n;
    var a = oA();
    Object.defineProperty(e, "ComplexRepresentation", { enumerable: !0, get: function() {
      return a.ComplexRepresentation;
    } });
    var i = pt;
    Object.defineProperty(e, "ComplexVisual", { enumerable: !0, get: function() {
      return i.ComplexVisual;
    } });
    var o = $0();
    Object.defineProperty(e, "UnitsRepresentation", { enumerable: !0, get: function() {
      return o.UnitsRepresentation;
    } });
    var c = Mr;
    Object.defineProperty(e, "UnitsVisual", { enumerable: !0, get: function() {
      return c.UnitsVisual;
    } });
  }(AT)), AT;
}
var gj = {}, oD = {}, wT = {}, Ol = {}, SN;
function c2e() {
  if (SN) return Ol;
  SN = 1, Object.defineProperty(Ol, "__esModule", { value: !0 }), Ol.eachAtomicPolymerBackboneElement = Ol.eachPolymerBackboneElement = Ol.eachPolymerBackboneLink = void 0;
  var e = Qe(), r = Qo, t = K0();
  function n(u, l) {
    switch (u.kind) {
      case 0:
        return a(u, l);
      case 1:
      case 2:
        return i(u, l);
    }
  }
  Ol.eachPolymerBackboneLink = n;
  function a(u, l) {
    for (var f = u.model.atomicRanges.cyclicPolymerMap, d = r.SortedRanges.transientSegments((0, t.getPolymerRanges)(u), u.elements), m = e.Segmentation.transientSegments(u.model.atomicHierarchy.residueAtomSegments, u.elements), p = u.model.atomicHierarchy.derived.residue.traceElementIndex, v = u.model.atomicHierarchy.derived.residue.moleculeType, h = -1, y = -1, C = !0, S = -1, b = 0; d.hasNext; ) {
      for (C = !0, S = b, m.setSegment(d.move()); m.hasNext; ) {
        if (C) {
          var g = m.move().index;
          if (++b, !m.hasNext)
            continue;
          C = !1, y = g;
        }
        var _ = m.move().index;
        h = y, y = _, l(p[h], p[y], b - 1, b, v[h]), ++b;
      }
      f.has(y) && (h = y, y = f.get(h), l(p[h], p[y], b - 1, S, v[h]));
    }
  }
  function i(u, l) {
    for (var f = r.SortedRanges.transientSegments((0, t.getPolymerRanges)(u), u.elements), d = u.elements, m = !0, p = 0; f.hasNext; ) {
      m = !0;
      for (var v = f.move(), h = v.start, y = v.end, C = h, S = y; C < S; ++C) {
        if (m) {
          if (++C, ++p, C > S)
            continue;
          m = !1;
        }
        l(
          d[C - 1],
          d[C],
          p - 1,
          p,
          0
          /* Unknown */
        ), ++p;
      }
    }
  }
  function o(u, l) {
    switch (u.kind) {
      case 0:
        return c(u, l);
      case 1:
      case 2:
        return s(u, l);
    }
  }
  Ol.eachPolymerBackboneElement = o;
  function c(u, l) {
    for (var f = r.SortedRanges.transientSegments((0, t.getPolymerRanges)(u), u.elements), d = e.Segmentation.transientSegments(u.model.atomicHierarchy.residueAtomSegments, u.elements), m = u.model.atomicHierarchy.derived.residue.traceElementIndex, p = 0; f.hasNext; )
      for (d.setSegment(f.move()); d.hasNext; ) {
        var v = d.move().index;
        l(m[v], p), ++p;
      }
  }
  Ol.eachAtomicPolymerBackboneElement = c;
  function s(u, l) {
    for (var f = r.SortedRanges.transientSegments((0, t.getPolymerRanges)(u), u.elements), d = u.elements, m = 0; f.hasNext; )
      for (var p = f.move(), v = p.start, h = p.end, y = v, C = h; y < C; ++y)
        l(d[y], m), ++m;
  }
  return Ol;
}
var Fl = {}, CN;
function d2e() {
  if (CN) return Fl;
  CN = 1, Object.defineProperty(Fl, "__esModule", { value: !0 }), Fl.CoarsePolymerGapIterator = Fl.AtomicPolymerGapIterator = Fl.PolymerGapIterator = void 0;
  var e = Je(), r = Qo, t = K0();
  function n(c, s) {
    switch (s.kind) {
      case 0:
        return new i(c, s);
      case 1:
      case 2:
        return new o(c, s);
    }
  }
  Fl.PolymerGapIterator = n;
  function a(c, s) {
    return {
      centerA: e.StructureElement.Location.create(c, s),
      centerB: e.StructureElement.Location.create(c, s)
    };
  }
  var i = (
    /** @class */
    function() {
      function c(s, u) {
        this.unit = u, this.hasNext = !1, this.traceElementIndex = u.model.atomicHierarchy.derived.residue.traceElementIndex, this.gapIt = r.SortedRanges.transientSegments((0, t.getGapRanges)(u), u.elements), this.value = a(s, u), this.hasNext = this.gapIt.hasNext;
      }
      return c.prototype.move = function() {
        var s = this.unit, u = s.elements, l = s.residueIndex, f = this.gapIt.move();
        return this.value.centerA.element = this.traceElementIndex[l[u[f.start]]], this.value.centerB.element = this.traceElementIndex[l[u[f.end - 1]]], this.hasNext = this.gapIt.hasNext, this.value;
      }, c;
    }()
  );
  Fl.AtomicPolymerGapIterator = i;
  var o = (
    /** @class */
    function() {
      function c(s, u) {
        this.unit = u, this.hasNext = !1, this.gapIt = r.SortedRanges.transientSegments((0, t.getGapRanges)(u), u.elements), this.value = a(s, u), this.hasNext = this.gapIt.hasNext;
      }
      return c.prototype.move = function() {
        var s = this.gapIt.move();
        return this.value.centerA.element = this.unit.elements[s.start], this.value.centerB.element = this.unit.elements[s.end - 1], this.hasNext = this.gapIt.hasNext, this.value;
      }, c;
    }()
  );
  return Fl.CoarsePolymerGapIterator = o, Fl;
}
var Ll = {}, S0 = {}, uA = {};
Object.defineProperty(uA, "__esModule", { value: !0 });
uA.calcHelixOrientation = void 0;
var f2e = nU(), m2e = Qo, v2e = Qe(), br = Re;
function p2e(e) {
  for (var r = e.atomicConformation, t = r.x, n = r.y, a = r.z, i = e.atomicHierarchy.derived.residue, o = i.polymerType, c = i.traceElementIndex, s = o.length, u = v2e.OrderedSet.ofBounds(0, e.atomicConformation.atomId.rowCount), l = m2e.SortedRanges.transientSegments(e.atomicRanges.polymerRanges, u), f = f2e.Segmentation.transientSegments(e.atomicHierarchy.residueAtomSegments, u), d = new Float32Array(s * 3), m = new Float32Array(s * 3), p = 0, v = -1, h = -1, y = (0, br.Vec3)(), C = (0, br.Vec3)(), S = (0, br.Vec3)(), b = (0, br.Vec3)(), g = (0, br.Vec3)(), _ = (0, br.Vec3)(), A = (0, br.Vec3)(), M = (0, br.Vec3)(), P = (0, br.Vec3)(), T = (0, br.Vec3)(), x = (0, br.Vec3)(), w = (0, br.Vec3)(), E = (0, br.Vec3)(), I = (0, br.Vec3)(); l.hasNext; ) {
    var B = l.move();
    for (f.setSegment(B), p = -1, h = -1; f.hasNext; ) {
      p += 1;
      var D = f.move().index;
      p === 0 && (h = D), v = D - 2;
      var N = v * 3;
      br.Vec3.copy(y, C), br.Vec3.copy(C, S), br.Vec3.copy(S, b);
      var O = c[D];
      if (br.Vec3.set(b, t[O], n[O], a[O]), !(p < 3)) {
        br.Vec3.sub(g, C, y), br.Vec3.sub(_, S, C), br.Vec3.sub(A, b, S), br.Vec3.sub(x, g, _), br.Vec3.sub(w, _, A), br.Vec3.cross(E, x, w), br.Vec3.normalize(E, E), br.Vec3.toArray(E, m, N);
        var V = Math.cos(br.Vec3.angle(x, w)), k = br.Vec3.magnitude(x), G = br.Vec3.magnitude(w), L = Math.sqrt(G * k) / // clamp, to avoid numerical instabilities for when
        // angle between diff13 and diff24 is close to 0
        Math.max(2, 2 * (1 - V));
        br.Vec3.scale(M, x, L / k), br.Vec3.sub(M, C, M), br.Vec3.toArray(M, d, N), br.Vec3.scale(P, w, L / G), br.Vec3.sub(P, S, P), br.Vec3.toArray(P, d, N + 3), br.Vec3.copy(I, E);
      }
    }
    var R = h * 3;
    br.Vec3.fromArray(M, d, R + 3), br.Vec3.fromArray(P, d, R + 6), br.Vec3.normalize(E, br.Vec3.sub(E, M, P));
    var F = c[h];
    br.Vec3.set(y, t[F], n[F], a[F]), br.Vec3.copy(T, y), br.Vec3.projectPointOnVector(T, T, E, M), br.Vec3.toArray(T, d, R);
    var U = v + 2, H = U * 3;
    br.Vec3.fromArray(M, d, H - 3), br.Vec3.fromArray(P, d, H - 6), br.Vec3.normalize(E, br.Vec3.sub(E, M, P));
    var q = c[U];
    br.Vec3.set(y, t[q], n[q], a[q]), br.Vec3.copy(T, y), br.Vec3.projectPointOnVector(T, T, E, M), br.Vec3.toArray(T, d, H);
  }
  return {
    centers: d
  };
}
uA.calcHelixOrientation = p2e;
Object.defineProperty(S0, "__esModule", { value: !0 });
S0.HelixOrientationProvider = S0.HelixOrientationParams = void 0;
var AN = Te, h2e = In, g2e = wp, y2e = uA;
S0.HelixOrientationParams = {};
S0.HelixOrientationProvider = g2e.CustomModelProperty.createProvider({
  label: "Helix Orientation",
  descriptor: (0, h2e.CustomPropertyDescriptor)({
    name: "molstar_helix_orientation"
  }),
  type: "dynamic",
  defaultParams: {},
  getParams: function() {
    return {};
  },
  isApplicable: function(e) {
    return !0;
  },
  obtain: function(e, r) {
    return (0, AN.__awaiter)(void 0, void 0, void 0, function() {
      return (0, AN.__generator)(this, function(t) {
        return [2, { value: (0, y2e.calcHelixOrientation)(r) }];
      });
    });
  }
});
var xN;
function _2e() {
  if (xN) return Ll;
  xN = 1, Object.defineProperty(Ll, "__esModule", { value: !0 }), Ll.CoarsePolymerTraceIterator = Ll.AtomicPolymerTraceIterator = Ll.PolymerTraceIterator = void 0;
  var e = Je(), r = Qe(), t = Gr, n = Re, a = Qo, i = K0(), o = Ac(), c = S0;
  function s(C) {
    return t.SecondaryStructureType.is(
      C,
      2
      /* Helix */
    );
  }
  function u(C) {
    return t.SecondaryStructureType.is(
      C,
      4
      /* Beta */
    );
  }
  function l(C, S, b) {
    switch (b === void 0 && (b = {}), C.kind) {
      case 0:
        return new h(C, S, b);
      case 1:
      case 2:
        return new y(C, S);
    }
  }
  Ll.PolymerTraceIterator = l;
  var f = t.SecondaryStructureType.create(
    536870912
    /* NA */
  );
  function d(C, S) {
    return {
      center: e.StructureElement.Location.create(C, S),
      centerPrev: e.StructureElement.Location.create(C, S),
      centerNext: e.StructureElement.Location.create(C, S),
      first: !1,
      last: !1,
      initial: !1,
      final: !1,
      secStrucFirst: !1,
      secStrucLast: !1,
      secStrucType: f,
      moleculeType: 0,
      coarseBackboneFirst: !1,
      coarseBackboneLast: !1,
      isCoarseBackbone: !1,
      p0: (0, n.Vec3)(),
      p1: (0, n.Vec3)(),
      p2: (0, n.Vec3)(),
      p3: (0, n.Vec3)(),
      p4: (0, n.Vec3)(),
      d12: (0, n.Vec3)(),
      d23: (0, n.Vec3)()
    };
  }
  var m = (0, n.Vec3)(), p = (0, n.Vec3)(), v = (0, n.Vec3)(), h = (
    /** @class */
    function() {
      function C(S, b, g) {
        g === void 0 && (g = {});
        var _;
        if (this.unit = S, this.state = 0, this.p0 = (0, n.Vec3)(), this.p1 = (0, n.Vec3)(), this.p2 = (0, n.Vec3)(), this.p3 = (0, n.Vec3)(), this.p4 = (0, n.Vec3)(), this.p5 = (0, n.Vec3)(), this.p6 = (0, n.Vec3)(), this.d01 = (0, n.Vec3)(), this.d12 = (0, n.Vec3)(), this.d23 = (0, n.Vec3)(), this.d34 = (0, n.Vec3)(), this.hasNext = !1, this.atomicConformation = S.model.atomicConformation, this.residueAtomSegments = S.model.atomicHierarchy.residueAtomSegments, this.polymerRanges = S.model.atomicRanges.polymerRanges, this.traceElementIndex = S.model.atomicHierarchy.derived.residue.traceElementIndex, this.directionFromElementIndex = S.model.atomicHierarchy.derived.residue.directionFromElementIndex, this.directionToElementIndex = S.model.atomicHierarchy.derived.residue.directionToElementIndex, this.moleculeType = S.model.atomicHierarchy.derived.residue.moleculeType, this.cyclicPolymerMap = S.model.atomicRanges.cyclicPolymerMap, this.polymerIt = a.SortedRanges.transientSegments(this.polymerRanges, S.elements), this.residueIt = r.Segmentation.transientSegments(this.residueAtomSegments, S.elements), this.value = d(b, S), this.hasNext = this.residueIt.hasNext && this.polymerIt.hasNext, g.ignoreSecondaryStructure || (this.secondaryStructure = (_ = o.SecondaryStructureProvider.get(b).value) === null || _ === void 0 ? void 0 : _.get(S.invariantId)), g.useHelixOrientation) {
          var A = c.HelixOrientationProvider.get(S.model).value;
          if (!A)
            throw new Error("missing helix-orientation");
          this.helixOrientationCenters = A.centers;
        }
      }
      return C.prototype.atomicPos = function(S, b) {
        b !== -1 && (S[0] = this.atomicConformation.x[b], S[1] = this.atomicConformation.y[b], S[2] = this.atomicConformation.z[b]);
      }, C.prototype.pos = function(S, b, g) {
        var _ = this.traceElementIndex[b];
        this.helixOrientationCenters && s(g) ? n.Vec3.fromArray(S, this.helixOrientationCenters, b * 3) : this.atomicPos(S, _);
      }, C.prototype.updateResidueSegmentRange = function(S) {
        var b = this.residueAtomSegments.index;
        this.residueSegmentMin = b[this.polymerRanges[S.index * 2]], this.residueSegmentMax = b[this.polymerRanges[S.index * 2 + 1]];
      }, C.prototype.getResidueIndex = function(S) {
        if (S < this.residueSegmentMin) {
          var b = this.cyclicPolymerMap.get(this.residueSegmentMin);
          b !== void 0 ? S = b - (this.residueSegmentMin - S - 1) : S = this.residueSegmentMin;
        } else if (S > this.residueSegmentMax) {
          var b = this.cyclicPolymerMap.get(this.residueSegmentMax);
          b !== void 0 ? S = b + (S - this.residueSegmentMax - 1) : S = this.residueSegmentMax;
        }
        return S;
      }, C.prototype.getSecStruc = function(S) {
        if (this.secondaryStructure) {
          var b = this.secondaryStructure, g = b.type, _ = b.getIndex, A = g[_(S)];
          return s(A) ? 2 : A;
        } else
          return f;
      }, C.prototype.setControlPoint = function(S, b, g, _, A) {
        u(A) || this.helixOrientationCenters && s(A) ? n.Vec3.scale(S, n.Vec3.add(S, b, n.Vec3.add(S, _, n.Vec3.add(S, g, g))), 1 / 4) : n.Vec3.copy(S, g);
      }, C.prototype.setFromToVector = function(S, b, g) {
        this.value.isCoarseBackbone || this.helixOrientationCenters && s(g) ? n.Vec3.set(S, 1, 0, 0) : (this.atomicPos(p, this.directionFromElementIndex[b]), this.atomicPos(v, this.directionToElementIndex[b]), n.Vec3.sub(S, v, p));
      }, C.prototype.setDirection = function(S, b, g, _) {
        n.Vec3.matchDirection(p, b, g), n.Vec3.matchDirection(v, _, g), n.Vec3.scale(S, n.Vec3.add(S, p, n.Vec3.add(S, v, n.Vec3.add(S, g, g))), 1 / 4);
      }, C.prototype.move = function() {
        var S = this, b = S.residueIt, g = S.polymerIt, _ = S.value;
        if (this.state === 0) {
          for (; g.hasNext; )
            if (this.polymerSegment = g.move(), b.setSegment(this.polymerSegment), this.updateResidueSegmentRange(this.polymerSegment), b.hasNext) {
              this.state = 1;
              var A = this.residueAtomSegments.index[this.unit.elements[this.polymerSegment.start]], M = this.getResidueIndex(A - 1);
              this.currSecStrucType = A === M ? f : this.getSecStruc(M), this.nextSecStrucType = this.getSecStruc(A), this.currCoarseBackbone = this.directionFromElementIndex[M] === -1 || this.directionToElementIndex[M] === -1, this.nextCoarseBackbone = this.directionFromElementIndex[A] === -1 || this.directionToElementIndex[A] === -1;
              break;
            }
        }
        if (this.state === 1) {
          var P = b.move().index, T = this.getResidueIndex(P - 3), x = this.getResidueIndex(P - 2), w = this.getResidueIndex(P - 1), E = this.getResidueIndex(P + 1), I = this.getResidueIndex(P + 2), B = this.getResidueIndex(P + 3);
          this.prevSecStrucType = this.currSecStrucType, this.currSecStrucType = this.nextSecStrucType, this.nextSecStrucType = P === E ? f : this.getSecStruc(E), this.prevCoarseBackbone = this.currCoarseBackbone, this.currCoarseBackbone = this.nextCoarseBackbone, this.nextCoarseBackbone = this.directionFromElementIndex[E] === -1 || this.directionToElementIndex[E] === -1, _.secStrucType = this.currSecStrucType, _.secStrucFirst = this.prevSecStrucType !== this.currSecStrucType, _.secStrucLast = this.currSecStrucType !== this.nextSecStrucType, _.isCoarseBackbone = this.currCoarseBackbone, _.coarseBackboneFirst = this.prevCoarseBackbone !== this.currCoarseBackbone, _.coarseBackboneLast = this.currCoarseBackbone !== this.nextCoarseBackbone, _.first = P === this.residueSegmentMin, _.last = P === this.residueSegmentMax, _.moleculeType = this.moleculeType[P], _.initial = P === w, _.final = P === E, _.centerPrev.element = this.traceElementIndex[w], _.center.element = this.traceElementIndex[P], _.centerNext.element = this.traceElementIndex[E];
          var D = this.getSecStruc(T), N = this.getSecStruc(x), O = this.getSecStruc(w), V = this.getSecStruc(P), k = this.getSecStruc(E), G = this.getSecStruc(I), L = this.getSecStruc(B);
          this.pos(this.p0, T, D), this.pos(this.p1, x, N), this.pos(this.p2, w, O), this.pos(this.p3, P, V), this.pos(this.p4, E, k), this.pos(this.p5, I, G), this.pos(this.p6, B, L);
          var R = s(D), F = s(N), U = s(O), H = s(V), q = s(k), K = s(G), Y = s(L);
          this.helixOrientationCenters && (H !== U ? H ? (n.Vec3.copy(this.p0, this.p3), n.Vec3.copy(this.p1, this.p3), n.Vec3.copy(this.p2, this.p3)) : U && (n.Vec3.scale(m, n.Vec3.sub(m, this.p2, this.p3), 2), n.Vec3.add(this.p2, this.p3, m), n.Vec3.add(this.p1, this.p2, m), n.Vec3.add(this.p0, this.p1, m)) : H !== F ? H ? (n.Vec3.copy(this.p0, this.p2), n.Vec3.copy(this.p1, this.p2)) : F && (n.Vec3.scale(m, n.Vec3.sub(m, this.p1, this.p2), 2), n.Vec3.add(this.p1, this.p2, m), n.Vec3.add(this.p0, this.p1, m)) : H !== R && (H ? n.Vec3.copy(this.p0, this.p1) : R && (n.Vec3.scale(m, n.Vec3.sub(m, this.p0, this.p1), 2), n.Vec3.add(this.p0, this.p1, m))), H !== q ? H ? (n.Vec3.copy(this.p4, this.p3), n.Vec3.copy(this.p5, this.p3), n.Vec3.copy(this.p6, this.p3)) : q && (n.Vec3.scale(m, n.Vec3.sub(m, this.p4, this.p3), 2), n.Vec3.add(this.p4, this.p3, m), n.Vec3.add(this.p5, this.p4, m), n.Vec3.add(this.p6, this.p5, m)) : H !== K ? H ? (n.Vec3.copy(this.p5, this.p4), n.Vec3.copy(this.p6, this.p4)) : K && (n.Vec3.scale(m, n.Vec3.sub(m, this.p5, this.p4), 2), n.Vec3.add(this.p5, this.p4, m), n.Vec3.add(this.p6, this.p5, m)) : H !== Y && (H ? n.Vec3.copy(this.p6, this.p5) : Y && (n.Vec3.scale(m, n.Vec3.sub(m, this.p6, this.p5), 2), n.Vec3.add(this.p6, this.p5, m)))), this.setFromToVector(this.d01, w, O), this.setFromToVector(this.d12, P, V), this.setFromToVector(this.d23, E, k), this.setFromToVector(this.d34, I, G);
          var X = H && this.helixOrientationCenters, Z = 1.5;
          P === w || V !== O && X ? (n.Vec3.setMagnitude(m, n.Vec3.sub(m, this.p3, this.p4), Z), n.Vec3.add(this.p2, this.p3, m), n.Vec3.add(this.p1, this.p2, m), n.Vec3.add(this.p0, this.p1, m)) : w === x || V !== N && X ? (n.Vec3.setMagnitude(m, n.Vec3.sub(m, this.p2, this.p3), Z), n.Vec3.add(this.p1, this.p2, m), n.Vec3.add(this.p0, this.p1, m)) : (x === T || V !== D && X) && (n.Vec3.setMagnitude(m, n.Vec3.sub(m, this.p1, this.p2), Z), n.Vec3.add(this.p0, this.p1, m)), P === E || V !== k && X ? (n.Vec3.setMagnitude(m, n.Vec3.sub(m, this.p3, this.p2), Z), n.Vec3.add(this.p4, this.p3, m), n.Vec3.add(this.p5, this.p4, m), n.Vec3.add(this.p6, this.p5, m)) : E === I || V !== G && X ? (n.Vec3.setMagnitude(m, n.Vec3.sub(m, this.p4, this.p3), Z), n.Vec3.add(this.p5, this.p4, m), n.Vec3.add(this.p6, this.p5, m)) : (I === B || V !== L && X) && (n.Vec3.setMagnitude(m, n.Vec3.sub(m, this.p5, this.p4), Z), n.Vec3.add(this.p6, this.p5, m)), this.setControlPoint(_.p0, this.p0, this.p1, this.p2, N), this.setControlPoint(_.p1, this.p1, this.p2, this.p3, O), this.setControlPoint(_.p2, this.p2, this.p3, this.p4, V), this.setControlPoint(_.p3, this.p3, this.p4, this.p5, k), this.setControlPoint(_.p4, this.p4, this.p5, this.p6, G), this.setDirection(_.d12, this.d01, this.d12, this.d23), this.setDirection(_.d23, this.d12, this.d23, this.d34), b.hasNext || (this.state = 0);
        }
        return this.hasNext = b.hasNext || g.hasNext, this.value;
      }, C;
    }()
  );
  Ll.AtomicPolymerTraceIterator = h;
  var y = (
    /** @class */
    function() {
      function C(S, b) {
        switch (this.unit = S, this.state = 0, this.hasNext = !1, this.polymerIt = a.SortedRanges.transientSegments((0, i.getPolymerRanges)(S), S.elements), this.value = d(b, S), n.Vec3.set(this.value.d12, 1, 0, 0), n.Vec3.set(this.value.d23, 1, 0, 0), S.kind) {
          case 1:
            this.conformation = S.model.coarseConformation.spheres;
            break;
          case 2:
            this.conformation = S.model.coarseConformation.gaussians;
            break;
        }
        this.hasNext = this.polymerIt.hasNext;
      }
      return C.prototype.getElementIndex = function(S) {
        return Math.min(Math.max(this.polymerSegment.start, S), this.polymerSegment.end - 1);
      }, C.prototype.pos = function(S, b) {
        var g = this.unit.elements[b];
        S[0] = this.conformation.x[g], S[1] = this.conformation.y[g], S[2] = this.conformation.z[g];
      }, C.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 S = this.getElementIndex(this.elementIndex - 2), b = this.getElementIndex(this.elementIndex - 1), g = this.getElementIndex(this.elementIndex + 1), _ = this.getElementIndex(this.elementIndex + 2);
          this.value.centerPrev.element = this.value.center.unit.elements[b], this.value.center.element = this.value.center.unit.elements[this.elementIndex], this.value.centerNext.element = this.value.center.unit.elements[g], this.pos(this.value.p0, S), this.pos(this.value.p1, b), this.pos(this.value.p2, this.elementIndex), this.pos(this.value.p3, g), this.pos(this.value.p4, _);
          var A = 0.5;
          this.elementIndex === b ? (n.Vec3.scale(m, n.Vec3.sub(m, this.value.p2, this.value.p3), A), n.Vec3.add(this.value.p1, this.value.p2, m), n.Vec3.add(this.value.p0, this.value.p1, m)) : b === S && (n.Vec3.scale(m, n.Vec3.sub(m, this.value.p1, this.value.p2), A), n.Vec3.add(this.value.p0, this.value.p1, m)), this.elementIndex === g ? (n.Vec3.scale(m, n.Vec3.sub(m, this.value.p2, this.value.p1), A), n.Vec3.add(this.value.p3, this.value.p2, m), n.Vec3.add(this.value.p4, this.value.p3, m)) : g === _ && (n.Vec3.scale(m, n.Vec3.sub(m, this.value.p3, this.value.p2), A), n.Vec3.add(this.value.p4, this.value.p3, m)), 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;
      }, C;
    }()
  );
  return Ll.CoarsePolymerTraceIterator = y, Ll;
}
var Tu = {};
Object.defineProperty(Tu, "__esModule", { value: !0 });
Tu.interpolateSizes = Tu.interpolateNormals = Tu.interpolatePointsAndTangents = Tu.interpolateCurveSegment = Tu.createCurveSegmentState = void 0;
var un = Re, Zf = Zr, Rf = un.Vec3.fromArray, tv = un.Vec3.toArray, nw = un.Vec3.normalize, b2e = un.Vec3.sub, Pm = un.Vec3.spline, S2e = un.Vec3.slerp, TN = un.Vec3.copy, PN = un.Vec3.cross, ET = un.Vec3.orthogonalize, C2e = un.Vec3.matchDirection, A2e = un.Vec3.scale, MN = un.Vec3.add;
function x2e(e) {
  var r = e + 1, t = r * 3;
  return {
    curvePoints: new Float32Array(t),
    tangentVectors: new Float32Array(t),
    normalVectors: new Float32Array(t),
    binormalVectors: new Float32Array(t),
    widthValues: new Float32Array(r),
    heightValues: new Float32Array(r),
    linearSegments: e
  };
}
Tu.createCurveSegmentState = x2e;
function T2e(e, r, t, n) {
  yj(e, r, t, n), _j(e, r);
}
Tu.interpolateCurveSegment = T2e;
var DT = (0, un.Vec3)(), IT = (0, un.Vec3)(), BT = (0, un.Vec3)();
function yj(e, r, t, n) {
  for (var a = e.curvePoints, i = e.tangentVectors, o = e.linearSegments, c = r.p0, s = r.p1, u = r.p2, l = r.p3, f = r.p4, d = r.secStrucFirst, m = r.secStrucLast, p = 1 - n, v = d ? 0.5 : t, h = m ? 0.5 : t, y = 0; y <= o; ++y) {
    var C = y * 1 / o;
    if (C < p) {
      var S = (0, Zf.lerp)(v, t, C);
      Pm(BT, c, s, u, l, C + n, S), Pm(DT, c, s, u, l, C + n + 0.01, v), Pm(IT, c, s, u, l, C + n - 0.01, v);
    } else {
      var S = (0, Zf.lerp)(t, h, C);
      Pm(BT, s, u, l, f, C - p, S), Pm(DT, s, u, l, f, C - p + 0.01, S), Pm(IT, s, u, l, f, C - p - 0.01, S);
    }
    tv(BT, a, y * 3), nw(td, b2e(td, DT, IT)), tv(td, i, y * 3);
  }
}
Tu.interpolatePointsAndTangents = yj;
var P2e = (0, un.Vec3)(), td = (0, un.Vec3)(), zu = (0, un.Vec3)(), Mm = (0, un.Vec3)(), d1 = (0, un.Vec3)(), wN = (0, un.Vec3)(), EN = (0, un.Vec3)(), DN = (0, un.Vec3)(), NT = (0, un.Vec3)(), X2 = (0, un.Vec3)();
function _j(e, r) {
  var t = e.curvePoints, n = e.tangentVectors, a = e.normalVectors, i = e.binormalVectors, o = r.d12, c = r.d23, s = t.length / 3;
  Rf(EN, n, 0), Rf(DN, n, (s - 1) * 3), ET(NT, EN, o), ET(X2, DN, c), C2e(X2, X2, NT), TN(d1, NT);
  for (var u = s - 1, l = 0; l < s; ++l) {
    var f = (0, Zf.smoothstep)(0, u, l) * u, d = l === 0 ? 0 : 1 / (s - f);
    Rf(td, n, l * 3), ET(zu, td, S2e(P2e, d1, X2, d)), tv(zu, a, l * 3), TN(d1, zu), nw(Mm, PN(Mm, td, zu)), tv(Mm, i, l * 3);
  }
  for (var l = 1; l < u; ++l)
    Rf(d1, a, (l - 1) * 3), Rf(zu, a, l * 3), Rf(wN, a, (l + 1) * 3), A2e(zu, MN(zu, d1, MN(zu, wN, zu)), 1 / 3), tv(zu, a, l * 3), Rf(td, n, l * 3), nw(Mm, PN(Mm, td, zu)), tv(Mm, i, l * 3);
}
Tu.interpolateNormals = _j;
function M2e(e, r, t, n, a, i, o, c) {
  for (var s = e.widthValues, u = e.heightValues, l = e.linearSegments, f = 1 - c, d = 0; d <= l; ++d) {
    var m = d * 1 / l;
    m < f ? (s[d] = (0, Zf.lerp)(r, t, m + c), u[d] = (0, Zf.lerp)(a, i, m + c)) : (s[d] = (0, Zf.lerp)(t, n, m - f), u[d] = (0, Zf.lerp)(i, o, m - f));
  }
}
Tu.interpolateSizes = M2e;
var IN;
function K0() {
  return IN || (IN = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.eachPolymerGapElement = e.getPolymerGapElementLoci = e.eachPolymerElement = e.eachAtomicUnitTracedElement = e.getPolymerElementLoci = e.PolymerGapLocationIterator = e.PolymerLocationIterator = e.getGapRanges = e.getPolymerRanges = e.OverhangFactor = e.NucleicShift = e.StandardShift = e.HelixTension = e.StandardTension = void 0;
    var r = Te, t = Je(), n = Qe(), a = _r, i = on, o = bl;
    (0, r.__exportStar)(c2e(), e), (0, r.__exportStar)(d2e(), e), (0, r.__exportStar)(_2e(), e), (0, r.__exportStar)(Tu, e), e.StandardTension = 0.5, e.HelixTension = 0.9, e.StandardShift = 0.5, e.NucleicShift = 0.3, e.OverhangFactor = 2;
    function c(h) {
      switch (h.kind) {
        case 0:
          return h.model.atomicRanges.polymerRanges;
        case 1:
          return h.model.coarseHierarchy.spheres.polymerRanges;
        case 2:
          return h.model.coarseHierarchy.gaussians.polymerRanges;
      }
    }
    e.getPolymerRanges = c;
    function s(h) {
      switch (h.kind) {
        case 0:
          return h.model.atomicRanges.gapRanges;
        case 1:
          return h.model.coarseHierarchy.spheres.gapRanges;
        case 2:
          return h.model.coarseHierarchy.gaussians.gapRanges;
      }
    }
    e.getGapRanges = s, function(h) {
      function y(C) {
        var S = C.group, b = C.structure, g = S.units[0].polymerElements, _ = g.length, A = S.units.length, M = t.StructureElement.Location.create(b), P = function(T, x) {
          var w = S.units[x];
          return M.unit = w, M.element = g[T], M;
        };
        return (0, i.LocationIterator)(_, A, 1, P);
      }
      h.fromGroup = y;
    }(e.PolymerLocationIterator || (e.PolymerLocationIterator = {})), function(h) {
      function y(C) {
        var S = C.group, b = C.structure, g = S.units[0].gapElements, _ = g.length, A = S.units.length, M = t.StructureElement.Location.create(b), P = function(T, x) {
          var w = S.units[x];
          return M.unit = w, M.element = g[T], M;
        };
        return (0, i.LocationIterator)(_, A, 1, P);
      }
      h.fromGroup = y;
    }(e.PolymerGapLocationIterator || (e.PolymerGapLocationIterator = {}));
    function u(h, y, C) {
      var S = h.objectId, b = h.instanceId, g = h.groupId;
      if (C === S) {
        var _ = y.structure, A = y.group, M = A.units[b];
        if (t.Unit.isAtomic(M))
          return (0, o.getResidueLoci)(_, M, M.polymerElements[g]);
        var P = M.elements, T = M.polymerElements[g], x = n.OrderedSet.indexOf(P, T);
        if (x !== -1) {
          var w = n.OrderedSet.ofSingleton(x);
          return t.StructureElement.Loci(_, [{ unit: M, indices: w }]);
        }
      }
      return a.EmptyLoci;
    }
    e.getPolymerElementLoci = u;
    function l(h, y, C, S, b, g) {
      for (var _ = -1, A = -1, M = b; M <= g; M++) {
        var P = C[M];
        if (!(P < 0) && (_ = n.OrderedSet.indexOf(y, P), _ >= 0)) {
          A = M;
          break;
        }
      }
      if (_ < 0)
        return !1;
      for (var T = _, M = g; M > A; M--) {
        var P = C[M];
        if (!(P < 0)) {
          var x = n.OrderedSet.indexOf(y, P);
          if (x >= 0) {
            T = x;
            break;
          }
        }
      }
      return S(n.Interval.ofRange(h + _, h + T));
    }
    function f(h, y, C, S, b) {
      var g = !1, _ = b.unit.elements, A = b.unit.model.atomicHierarchy.derived.residue.traceElementIndex, M = b.unit.model.atomicHierarchy.residueAtomSegments.index, P = C(b.unit);
      if (n.Interval.is(b.indices))
        if (n.Interval.start(b.indices) === 0 && n.Interval.end(b.indices) === b.unit.elements.length)
          g = S(n.Interval.ofBounds(h, h + y)) || g;
        else {
          var T = M[_[n.Interval.min(b.indices)]], x = M[_[n.Interval.max(b.indices)]];
          g = l(h, P, A, S, T, x) || g;
        }
      else
        for (var w = b.indices, E = 0, I = w.length; E < I; E++) {
          for (var T = M[_[w[E]]], x = T, B = E + 1; B < I; ) {
            var D = M[_[w[B]]];
            if (D - x > 1)
              break;
            x = D, B++;
          }
          E = B - 1, g = l(h, P, A, S, T, x) || g;
        }
      return g;
    }
    e.eachAtomicUnitTracedElement = f;
    function d(h) {
      return h.polymerElements;
    }
    function m(h, y, C) {
      var S = !1;
      if (!t.StructureElement.Loci.is(h))
        return !1;
      var b = y.structure, g = y.group;
      if (!t.Structure.areEquivalent(h.structure, b))
        return !1;
      for (var _ = g.units[0].polymerElements.length, A = 0, M = h.elements; A < M.length; A++) {
        var P = M[A];
        if (g.unitIndexMap.has(P.unit.id)) {
          var T = g.unitIndexMap.get(P.unit.id) * _;
          if (t.Unit.isAtomic(P.unit))
            S = f(T, _, d, C, P) || S;
          else if (n.Interval.is(P.indices)) {
            var x = T + n.Interval.start(P.indices), w = T + n.Interval.end(P.indices);
            S = C(n.Interval.ofBounds(x, w)) || S;
          } else
            for (var E = 0, I = P.indices.length; E < I; E++) {
              for (var x = P.indices[E], B = E + 1; B < I && P.indices[B] === x; )
                B++;
              E = B - 1;
              var w = P.indices[E];
              S = C(n.Interval.ofRange(T + x, T + w)) || S;
            }
        }
      }
      return S;
    }
    e.eachPolymerElement = m;
    function p(h, y, C) {
      var S = h.objectId, b = h.instanceId, g = h.groupId;
      if (C === S) {
        var _ = y.structure, A = y.group, M = A.units[b], P = n.OrderedSet.indexOf(M.elements, M.gapElements[g]), T = n.OrderedSet.indexOf(M.elements, M.gapElements[g % 2 ? g - 1 : g + 1]);
        if (P !== -1 && T !== -1)
          return t.Bond.Loci(_, [
            t.Bond.Location(_, M, P, _, M, T),
            t.Bond.Location(_, M, T, _, M, P)
          ]);
      }
      return a.EmptyLoci;
    }
    e.getPolymerGapElementLoci = p;
    function v(h, y, C) {
      var S = !1;
      if (t.Bond.isLoci(h)) {
        var b = y.structure, g = y.group;
        if (!t.Structure.areRootsEquivalent(h.structure, b))
          return !1;
        h = t.Bond.remapLoci(h, b);
        for (var _ = g.units[0].gapElements.length, A = 0, M = h.bonds; A < M.length; A++) {
          var P = M[A], T = g.unitIndexMap.get(P.aUnit.id);
          if (T !== void 0) {
            var x = n.OrderedSet.indexOf(P.aUnit.gapElements, P.aUnit.elements[P.aIndex]), w = n.OrderedSet.indexOf(P.bUnit.gapElements, P.bUnit.elements[P.bIndex]);
            x !== -1 && w !== -1 && C(n.Interval.ofSingleton(T * _ + x)) && (S = !0);
          }
        }
      } else if (t.StructureElement.Loci.is(h)) {
        var b = y.structure, g = y.group;
        if (!t.Structure.areRootsEquivalent(h.structure, b))
          return !1;
        h = t.StructureElement.Loci.remap(h, b);
        for (var E = g.units[0].gapElements.length, I = function(k) {
          var G = g.unitIndexMap.get(k.unit.id);
          G !== void 0 && n.OrderedSet.forEach(k.indices, function(L) {
            var R = n.OrderedSet.indexOf(k.unit.gapElements, k.unit.elements[L]);
            R !== -1 && C(n.Interval.ofSingleton(G * E + R)) && (S = !0);
          });
        }, B = 0, D = h.elements; B < D.length; B++) {
          var N = D[B];
          I(N);
        }
      }
      return S;
    }
    e.eachPolymerGapElement = v;
  }(wT)), wT;
}
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.eachNucleotideElement = e.getNucleotideElementLoci = e.NucleotideLocationIterator = void 0;
  var r = Je(), t = _r, n = on, a = bl, i = K0();
  (function(u) {
    function l(f) {
      var d = f.group, m = f.structure, p = d.units[0], v = r.Unit.isAtomic(p) ? p.nucleotideElements : [], h = v.length, y = d.units.length, C = r.StructureElement.Location.create(m), S = function(b, g) {
        var _ = d.units[g];
        return C.unit = _, C.element = v[b], C;
      };
      return (0, n.LocationIterator)(h, y, 1, S);
    }
    u.fromGroup = l;
  })(e.NucleotideLocationIterator || (e.NucleotideLocationIterator = {}));
  function o(u, l, f) {
    var d = u.objectId, m = u.instanceId, p = u.groupId;
    if (f === d) {
      var v = l.structure, h = l.group, y = h.units[m];
      if (r.Unit.isAtomic(y))
        return (0, a.getResidueLoci)(v, y, y.nucleotideElements[p]);
    }
    return t.EmptyLoci;
  }
  e.getNucleotideElementLoci = o;
  function c(u) {
    return u.nucleotideElements;
  }
  function s(u, l, f) {
    var d = !1;
    if (!r.StructureElement.Loci.is(u))
      return !1;
    var m = l.structure, p = l.group;
    if (!r.Structure.areEquivalent(u.structure, m))
      return !1;
    var v = p.units[0];
    if (!r.Unit.isAtomic(v))
      return !1;
    for (var h = v.nucleotideElements, y = h.length, C = 0, S = u.elements; C < S.length; C++) {
      var b = S[C];
      if (r.Unit.isAtomic(b.unit) && p.unitIndexMap.has(b.unit.id)) {
        var g = p.unitIndexMap.get(b.unit.id) * y;
        r.Unit.isAtomic(b.unit) && (d = (0, i.eachAtomicUnitTracedElement)(g, y, c, f, b) || d);
      }
    }
    return d;
  }
  e.eachNucleotideElement = s;
})(oD);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.NucleotideBlockVisual = e.NucleotideBlockParams = e.DefaultNucleotideBlockMeshProps = e.NucleotideBlockMeshParams = void 0;
  var r = Te, t = Le, n = Re, a = ns, i = Je(), o = Dt(), c = Ca(), s = Qe(), u = Gr, l = Yd(), f = Mr, d = oD, m = Xt, p = nr(), v = (0, n.Vec3)(), h = (0, n.Vec3)(), y = (0, n.Vec3)(), C = (0, n.Vec3)(), S = (0, n.Vec3)(), b = (0, n.Vec3)(), g = (0, n.Vec3)(), _ = (0, n.Vec3)(), A = (0, n.Vec3)(), M = (0, n.Vec3)(), P = n.Mat4.identity(), T = (0, n.Vec3)(), x = (0, a.Box)();
  e.NucleotideBlockMeshParams = {
    sizeFactor: t.ParamDefinition.Numeric(0.2, { min: 0, max: 10, step: 0.01 }),
    radialSegments: t.ParamDefinition.Numeric(16, { min: 2, max: 56, step: 2 }, m.BaseGeometry.CustomQualityParamInfo)
  }, e.DefaultNucleotideBlockMeshProps = t.ParamDefinition.getDefaultValues(e.NucleotideBlockMeshParams);
  function w(I, B, D, N, O, V) {
    if (!i.Unit.isAtomic(B))
      return o.Mesh.createEmpty(V);
    var k = B.nucleotideElements.length;
    if (!k)
      return o.Mesh.createEmpty(V);
    for (var G = O.sizeFactor, L = O.radialSegments, R = k * (x.vertices.length / 3 + L * 2), F = c.MeshBuilder.createState(R, R / 4, V), U = B.elements, H = B.model, q = H.atomicHierarchy, K = q.chainAtomSegments, Y = q.residueAtomSegments, X = q.atoms, Z = q.index, J = H.atomicHierarchy.derived.residue, $ = J.moleculeType, Q = J.traceElementIndex, W = X.label_comp_id, te = B.conformation.invariantPosition, oe = s.Segmentation.transientSegments(K, U), z = s.Segmentation.transientSegments(Y, U), j = {
      radiusTop: 1 * G,
      radiusBottom: 1 * G,
      radialSegments: L,
      bottomCap: !0
    }, ae = 0; oe.hasNext; )
      for (z.setSegment(oe.move()); z.hasNext; ) {
        var le = z.move().index;
        if ((0, u.isNucleic)($[le])) {
          var ie = W.value(Y.offsets[le]), re = -1, ee = -1, ne = -1, se = -1, ce = -1, de = -1, me = 4.5, he = 2.5 * G, _e = 4.5, Se = (0, u.isPurineBase)(ie), Pe = (0, u.isPyrimidineBase)(ie);
          if (!Se && !Pe) {
            var De = Z.findAtomOnResidue(le, "C4"), Ee = Z.findAtomOnResidue(le, "N9");
            De !== -1 && Ee !== -1 && n.Vec3.distance(te(De, v), te(Ee, h)) < 1.6 ? Se = !0 : Pe = !0;
          }
          Se ? (_e = 4.5, re = Z.findAtomOnResidue(le, "N1"), ee = Z.findAtomOnResidue(le, "C4"), ne = Z.findAtomOnResidue(le, "C6"), se = Z.findAtomOnResidue(le, "C2"), ce = Z.findAtomOnResidue(le, "N9"), de = Q[le]) : Pe && (_e = 3, re = Z.findAtomOnResidue(le, "N3"), ee = Z.findAtomOnResidue(le, "C6"), ne = Z.findAtomOnResidue(le, "C4"), se = Z.findAtomOnResidue(le, "C2"), ce = Z.findAtomOnResidue(le, "N1"), ce === -1 && (ce = Z.findAtomOnResidue(le, "C1")), de = Q[le]), ce !== -1 && de !== -1 && (te(ce, S), te(de, b), F.currentGroup = ae, (0, l.addCylinder)(F, S, b, 1, j), re !== -1 && ee !== -1 && ne !== -1 && se !== -1 && (te(re, v), te(ee, h), te(ne, y), te(se, C), n.Vec3.normalize(g, n.Vec3.sub(g, h, v)), n.Vec3.normalize(_, n.Vec3.sub(_, C, y)), n.Vec3.normalize(A, n.Vec3.cross(A, g, _)), n.Mat4.targetTo(P, v, h, A), n.Vec3.scaleAndAdd(M, v, g, _e / 2 - 0.2), n.Mat4.scale(P, P, n.Vec3.set(T, me, he, _e)), n.Mat4.setTranslation(P, M), c.MeshBuilder.addPrimitive(F, P, x))), ++ae;
        }
      }
    var Me = c.MeshBuilder.getMesh(F), ue = p.Sphere3D.expand((0, p.Sphere3D)(), B.boundary.sphere, 1 * O.sizeFactor);
    return Me.setBoundingSphere(ue), Me;
  }
  e.NucleotideBlockParams = (0, r.__assign)((0, r.__assign)({}, f.UnitsMeshParams), e.NucleotideBlockMeshParams);
  function E(I) {
    return (0, f.UnitsMeshVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.NucleotideBlockParams),
      createGeometry: w,
      createLocationIterator: d.NucleotideLocationIterator.fromGroup,
      getLoci: d.getNucleotideElementLoci,
      eachLocation: d.eachNucleotideElement,
      setUpdateState: function(B, D, N) {
        B.createGeometry = D.sizeFactor !== N.sizeFactor || D.radialSegments !== N.radialSegments;
      }
    }, I);
  }
  e.NucleotideBlockVisual = E;
})(gj);
var bj = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.NucleotideRingVisual = e.NucleotideRingParams = e.DefaultNucleotideRingMeshProps = e.NucleotideRingMeshParams = void 0;
  var r = Te, t = Le, n = Re, a = Je(), i = Dt(), o = Ca(), c = Qe(), s = Gr, u = Yd(), l = Xd(), f = Mr, d = oD, m = Xt, p = nr(), v = n.Vec3.zero(), h = n.Vec3.zero(), y = n.Vec3.zero(), C = n.Vec3.zero(), S = n.Vec3.zero(), b = n.Vec3.zero(), g = n.Vec3.zero(), _ = n.Vec3.zero(), A = n.Vec3.zero(), M = n.Vec3.zero(), P = n.Vec3.zero();
  e.NucleotideRingMeshParams = {
    sizeFactor: t.ParamDefinition.Numeric(0.2, { min: 0, max: 10, step: 0.01 }),
    radialSegments: t.ParamDefinition.Numeric(16, { min: 2, max: 56, step: 2 }, m.BaseGeometry.CustomQualityParamInfo),
    detail: t.ParamDefinition.Numeric(0, { min: 0, max: 3, step: 1 }, m.BaseGeometry.CustomQualityParamInfo)
  }, e.DefaultNucleotideRingMeshProps = t.ParamDefinition.getDefaultValues(e.NucleotideRingMeshParams);
  var T = new Float32Array(2 * 9 * 3), x = new Uint32Array([
    0,
    1,
    2,
    3,
    4,
    5,
    6,
    7,
    16,
    17,
    14,
    15,
    12,
    13,
    8,
    9,
    10,
    11,
    0,
    1
  ]), w = new Uint32Array([8, 12, 14, 16, 6, 4, 2, 0, 10]), E = new Uint32Array([9, 11, 1, 3, 5, 7, 17, 15, 13]), I = new Float32Array(2 * 6 * 3), B = new Uint32Array([
    0,
    1,
    2,
    3,
    4,
    5,
    6,
    7,
    8,
    9,
    10,
    11,
    0,
    1
  ]), D = new Uint32Array([0, 10, 8, 6, 4, 2]), N = new Uint32Array([1, 3, 5, 7, 9, 11]), O = n.Vec3.zero();
  function V(L, R) {
    for (var F = [], U = 2; U < arguments.length; U++)
      F[U - 2] = arguments[U];
    for (var H = 0, q = F.length; H < q; ++H) {
      var K = F[H];
      n.Vec3.toArray(n.Vec3.add(O, K, R), L, H * 2 * 3), n.Vec3.toArray(n.Vec3.sub(O, K, R), L, (H * 2 + 1) * 3);
    }
  }
  function k(L, R, F, U, H, q) {
    if (!a.Unit.isAtomic(R))
      return i.Mesh.createEmpty(q);
    var K = R.nucleotideElements.length;
    if (!K)
      return i.Mesh.createEmpty(q);
    for (var Y = H.sizeFactor, X = H.radialSegments, Z = H.detail, J = K * (26 + X * 2), $ = o.MeshBuilder.createState(J, J / 4, q), Q = R.elements, W = R.model, te = W.atomicHierarchy, oe = te.chainAtomSegments, z = te.residueAtomSegments, j = te.atoms, ae = te.index, le = W.atomicHierarchy.derived.residue, ie = le.moleculeType, re = le.traceElementIndex, ee = j.label_comp_id, ne = R.conformation.invariantPosition, se = c.Segmentation.transientSegments(oe, Q), ce = c.Segmentation.transientSegments(z, Q), de = 1 * Y, me = 1.25 * Y, he = {
      radiusTop: 1 * Y,
      radiusBottom: 1 * Y,
      radialSegments: X
    }, _e = 0; se.hasNext; )
      for (ce.setSegment(se.move()); ce.hasNext; ) {
        var Se = ce.move().index;
        if ((0, s.isNucleic)(ie[Se])) {
          var Pe = ee.value(z.offsets[Se]), De = -1, Ee = -1, Me = -1, ue = -1, pe = -1, Ae = -1, ye = -1, be = -1, fe = -1, ge = -1;
          $.currentGroup = _e;
          var xe = (0, s.isPurineBase)(Pe), we = (0, s.isPyrimidineBase)(Pe);
          if (!xe && !we) {
            var Ve = ae.findAtomOnResidue(Se, "C4"), Ne = ae.findAtomOnResidue(Se, "N9");
            Ve !== -1 && Ne !== -1 && n.Vec3.distance(ne(Ve, S), ne(Ne, M)) < 1.6 ? xe = !0 : we = !0;
          }
          xe ? (De = re[Se], Ee = ae.findAtomOnResidue(Se, "N1"), Me = ae.findAtomOnResidue(Se, "C2"), ue = ae.findAtomOnResidue(Se, "N3"), pe = ae.findAtomOnResidue(Se, "C4"), Ae = ae.findAtomOnResidue(Se, "C5"), Ae === -1 && (Ae = ae.findAtomOnResidue(Se, "N5")), ye = ae.findAtomOnResidue(Se, "C6"), be = ae.findAtomOnResidue(Se, "N7"), be === -1 && (be = ae.findAtomOnResidue(Se, "C7")), fe = ae.findAtomOnResidue(Se, "C8"), ge = ae.findAtomOnResidue(Se, "N9"), ge !== -1 && De !== -1 && (ne(ge, M), ne(De, v), $.currentGroup = _e, (0, u.addCylinder)($, M, v, 1, he), (0, l.addSphere)($, M, de, Z)), Ee !== -1 && Me !== -1 && ue !== -1 && pe !== -1 && Ae !== -1 && ye !== -1 && be !== -1 && fe !== -1 && ge !== -1 && (ne(Ee, h), ne(Me, y), ne(ue, C), ne(pe, S), ne(Ae, b), ne(ye, g), ne(be, _), ne(fe, A), n.Vec3.triangleNormal(P, h, S, b), n.Vec3.scale(P, P, me), V(T, P, h, y, C, S, b, g, _, A, M), o.MeshBuilder.addTriangleStrip($, T, x), o.MeshBuilder.addTriangleFan($, T, w), o.MeshBuilder.addTriangleFan($, T, E))) : we && (De = re[Se], Ee = ae.findAtomOnResidue(Se, "N1"), Ee === -1 && (Ee = ae.findAtomOnResidue(Se, "C1")), Me = ae.findAtomOnResidue(Se, "C2"), ue = ae.findAtomOnResidue(Se, "N3"), pe = ae.findAtomOnResidue(Se, "C4"), Ae = ae.findAtomOnResidue(Se, "C5"), ye = ae.findAtomOnResidue(Se, "C6"), Ee !== -1 && De !== -1 && (ne(Ee, h), ne(De, v), $.currentGroup = _e, (0, u.addCylinder)($, h, v, 1, he), (0, l.addSphere)($, h, de, Z)), Ee !== -1 && Me !== -1 && ue !== -1 && pe !== -1 && Ae !== -1 && ye !== -1 && (ne(Me, y), ne(ue, C), ne(pe, S), ne(Ae, b), ne(ye, g), n.Vec3.triangleNormal(P, h, S, b), n.Vec3.scale(P, P, me), V(I, P, h, y, C, S, b, g), o.MeshBuilder.addTriangleStrip($, I, B), o.MeshBuilder.addTriangleFan($, I, D), o.MeshBuilder.addTriangleFan($, I, N))), ++_e;
        }
      }
    var Oe = o.MeshBuilder.getMesh($), ze = p.Sphere3D.expand((0, p.Sphere3D)(), R.boundary.sphere, 1 * H.sizeFactor);
    return Oe.setBoundingSphere(ze), Oe;
  }
  e.NucleotideRingParams = (0, r.__assign)((0, r.__assign)({}, f.UnitsMeshParams), e.NucleotideRingMeshParams);
  function G(L) {
    return (0, f.UnitsMeshVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.NucleotideRingParams),
      createGeometry: k,
      createLocationIterator: d.NucleotideLocationIterator.fromGroup,
      getLoci: d.getNucleotideElementLoci,
      eachLocation: d.eachNucleotideElement,
      setUpdateState: function(R, F, U) {
        R.createGeometry = F.sizeFactor !== U.sizeFactor || F.radialSegments !== U.radialSegments;
      }
    }, L);
  }
  e.NucleotideRingVisual = G;
})(bj);
var Sj = {}, Td = {};
Object.defineProperty(Td, "__esModule", { value: !0 });
Td.WedgeCage = Td.Wedge = Td.createWedge = void 0;
var ao = Re, w2e = ya, E2e = $d, D2e = kE, Of = ao.Vec3.zero(), wm = ao.Vec3.zero(), Ff = ao.Vec3.zero(), BN = ao.Vec3.zero(), Gn = (0, E2e.polygon)(3, !1);
function Cj() {
  for (var e = (0, w2e.PrimitiveBuilder)(8), r = 0; r < 3; ++r) {
    var t = (r + 1) % 3;
    ao.Vec3.set(Of, Gn[r * 3], Gn[r * 3 + 1], -0.5), ao.Vec3.set(wm, Gn[t * 3], Gn[t * 3 + 1], -0.5), ao.Vec3.set(Ff, Gn[t * 3], Gn[t * 3 + 1], 0.5), ao.Vec3.set(BN, Gn[r * 3], Gn[r * 3 + 1], 0.5), e.add(Of, wm, Ff), e.add(Ff, BN, Of);
  }
  return ao.Vec3.set(Of, Gn[0], Gn[1], -0.5), ao.Vec3.set(wm, Gn[3], Gn[4], -0.5), ao.Vec3.set(Ff, Gn[6], Gn[7], -0.5), e.add(Ff, wm, Of), ao.Vec3.set(Of, Gn[0], Gn[1], 0.5), ao.Vec3.set(wm, Gn[3], Gn[4], 0.5), ao.Vec3.set(Ff, Gn[6], Gn[7], 0.5), e.add(Of, wm, Ff), e.getPrimitive();
}
Td.createWedge = Cj;
var VT;
function I2e() {
  return VT || (VT = Cj()), VT;
}
Td.Wedge = I2e;
var RT;
function B2e() {
  return RT || (RT = (0, D2e.PrismCage)(Gn)), RT;
}
Td.WedgeCage = B2e;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.PolymerDirectionVisual = e.PolymerDirectionParams = e.DefaultPolymerDirectionWedgeProps = e.PolymerDirectionWedgeParams = void 0;
  var r = Te, t = Le, n = Re, a = Td, i = Dt(), o = Ca(), c = K0(), s = Gr, u = Mr, l = nr(), f = n.Mat4.identity(), d = n.Vec3.zero(), m = n.Vec3.zero(), p = n.Vec3.zero(), v = n.Vec3.zero(), h = 4, y = 4, C = 6, S = (0, a.Wedge)();
  e.PolymerDirectionWedgeParams = {
    sizeFactor: t.ParamDefinition.Numeric(0.2, { min: 0, max: 10, step: 0.01 })
  }, e.DefaultPolymerDirectionWedgeProps = t.ParamDefinition.getDefaultValues(e.PolymerDirectionWedgeParams);
  function b(_, A, M, P, T, x) {
    var w = A.polymerElements.length;
    if (!w)
      return i.Mesh.createEmpty(x);
    for (var E = T.sizeFactor, I = w * 24, B = o.MeshBuilder.createState(I, I / 10, x), D = 1, N = (0, c.createCurveSegmentState)(D), O = N.normalVectors, V = N.binormalVectors, k = 0, G = (0, c.PolymerTraceIterator)(A, M); G.hasNext; ) {
      var L = G.move();
      B.currentGroup = k;
      var R = (0, s.isNucleic)(L.moleculeType), F = s.SecondaryStructureType.is(
        L.secStrucType,
        4
        /* Beta */
      ), U = R || F ? 0.5 : 0.9, H = R ? 0.3 : 0.5;
      if ((0, c.interpolateCurveSegment)(N, L, U, H), F && !L.secStrucLast || !F) {
        var q = P.size.size(L.center) * E, K = h * q, Y = y * q, X = C * q, Z = R ? V : O;
        n.Vec3.fromArray(m, Z, 0), n.Vec3.fromArray(p, Z, 3), n.Vec3.normalize(v, n.Vec3.add(v, m, p)), n.Mat4.targetTo(f, L.p3, L.p1, v), n.Mat4.mul(f, f, n.Mat4.rotY90Z180), n.Mat4.scale(f, f, n.Vec3.set(d, X, Y, K)), n.Mat4.setTranslation(f, L.p2), o.MeshBuilder.addPrimitive(B, f, S);
      }
      ++k;
    }
    var J = o.MeshBuilder.getMesh(B), $ = l.Sphere3D.expand((0, l.Sphere3D)(), A.boundary.sphere, 1 * T.sizeFactor);
    return J.setBoundingSphere($), J;
  }
  e.PolymerDirectionParams = (0, r.__assign)((0, r.__assign)({}, u.UnitsMeshParams), e.PolymerDirectionWedgeParams);
  function g(_) {
    return (0, u.UnitsMeshVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.PolymerDirectionParams),
      createGeometry: b,
      createLocationIterator: c.PolymerLocationIterator.fromGroup,
      getLoci: c.getPolymerElementLoci,
      eachLocation: c.eachPolymerElement,
      setUpdateState: function(A, M, P) {
        A.createGeometry = M.sizeFactor !== P.sizeFactor;
      }
    }, _);
  }
  e.PolymerDirectionVisual = g;
})(Sj);
var Aj = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.PolymerGapVisual = e.PolymerGapParams = e.DefaultPolymerGapCylinderProps = e.PolymerGapCylinderParams = void 0;
  var r = Te, t = Le, n = Dt(), a = Ca(), i = Re, o = K0(), c = Yd(), s = Mr, u = Xt, l = nr(), f = 10;
  e.PolymerGapCylinderParams = {
    sizeFactor: t.ParamDefinition.Numeric(0.2, { min: 0, max: 10, step: 0.01 }),
    radialSegments: t.ParamDefinition.Numeric(16, { min: 2, max: 56, step: 2 }, u.BaseGeometry.CustomQualityParamInfo)
  }, e.DefaultPolymerGapCylinderProps = t.ParamDefinition.getDefaultValues(e.PolymerGapCylinderParams);
  function d(p, v, h, y, C, S) {
    var b = v.gapElements.length;
    if (!b)
      return n.Mesh.createEmpty(S);
    for (var g = C.sizeFactor, _ = C.radialSegments, A = f * _ * 2 * b * 2, M = a.MeshBuilder.createState(A, A / 10, S), P = v.conformation.invariantPosition, T = i.Vec3.zero(), x = i.Vec3.zero(), w = {
      radiusTop: 1,
      radiusBottom: 1,
      topCap: !0,
      bottomCap: !0,
      radialSegments: _
    }, E = 0, I = (0, o.PolymerGapIterator)(h, v); I.hasNext; ) {
      var B = I.move(), D = B.centerA, N = B.centerB;
      D.element === N.element || (P(D.element, T), P(N.element, x), w.radiusTop = w.radiusBottom = y.size.size(D) * g, M.currentGroup = E, (0, c.addFixedCountDashedCylinder)(M, T, x, 0.5, f, w), w.radiusTop = w.radiusBottom = y.size.size(N) * g, M.currentGroup = E + 1, (0, c.addFixedCountDashedCylinder)(M, x, T, 0.5, f, w)), E += 2;
    }
    var O = a.MeshBuilder.getMesh(M), V = l.Sphere3D.expand((0, l.Sphere3D)(), v.boundary.sphere, 1 * C.sizeFactor);
    return O.setBoundingSphere(V), O;
  }
  e.PolymerGapParams = (0, r.__assign)((0, r.__assign)({}, s.UnitsMeshParams), e.PolymerGapCylinderParams);
  function m(p) {
    return (0, s.UnitsMeshVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.PolymerGapParams),
      createGeometry: d,
      createLocationIterator: o.PolymerGapLocationIterator.fromGroup,
      getLoci: o.getPolymerGapElementLoci,
      eachLocation: o.eachPolymerGapElement,
      setUpdateState: function(v, h, y) {
        v.createGeometry = h.sizeFactor !== y.sizeFactor || h.radialSegments !== y.radialSegments;
      }
    }, p);
  }
  e.PolymerGapVisual = m;
})(Aj);
var xj = {}, sA = {};
Object.defineProperty(sA, "__esModule", { value: !0 });
sA.addSheet = void 0;
var bn = Re, Tj = wr(), Hr = (0, bn.Vec3)(), tt = (0, bn.Vec3)(), N2e = (0, bn.Vec3)(), qo = (0, bn.Vec3)(), Us = (0, bn.Vec3)(), Y2 = (0, bn.Vec3)(), Q2 = (0, bn.Vec3)(), f1 = (0, bn.Vec3)(), Ku = (0, bn.Vec3)(), zs = (0, bn.Vec3)(), OT = (0, bn.Vec3)(), Uc = (0, bn.Vec3)(), zc = (0, bn.Vec3)(), Gc = (0, bn.Vec3)(), qc = (0, bn.Vec3)(), pu = bn.Vec3.fromArray, hv = bn.Vec3.scale, gu = bn.Vec3.add, Wl = bn.Vec3.sub, V2e = bn.Vec3.magnitude, NN = bn.Vec3.negate, aw = bn.Vec3.copy, Pj = bn.Vec3.cross, R2e = bn.Vec3.set, lt = Tj.ChunkedArray.add3, O2e = Tj.ChunkedArray.add;
function Z2(e, r, t, n, a, i, o, c, s) {
  var u = r.vertices, l = r.normals, f = r.indices, d = u.elementCount;
  if (pu(Hr, n, e), hv(Q2, Hr, o), hv(Y2, Hr, c), pu(tt, a, e), hv(qo, tt, i), Pj(zs, tt, Hr), pu(Ku, t, e), gu(Uc, gu(Uc, Ku, qo), Y2), Wl(zc, gu(zc, Ku, qo), Q2), Wl(Gc, Wl(Gc, Ku, qo), Q2), gu(qc, Wl(qc, Ku, qo), Y2), o < c ? (lt(u, qc[0], qc[1], qc[2]), lt(u, Gc[0], Gc[1], Gc[2]), lt(u, zc[0], zc[1], zc[2]), lt(u, Uc[0], Uc[1], Uc[2]), aw(Us, Y2)) : (lt(u, Uc[0], Uc[1], Uc[2]), lt(u, zc[0], zc[1], zc[2]), lt(u, Gc[0], Gc[1], Gc[2]), lt(u, qc[0], qc[1], qc[2]), aw(Us, Q2)), s) {
    for (var m = 0; m < 4; ++m)
      lt(l, -zs[0], -zs[1], -zs[2]);
    lt(f, d, d + 1, d + 2), lt(f, d + 2, d + 3, d);
  } else {
    for (var m = 0; m < 4; ++m)
      lt(l, zs[0], zs[1], zs[2]);
    lt(f, d + 2, d + 1, d), lt(f, d, d + 3, d + 2);
  }
}
function F2e(e, r, t, n, a, i, o, c, s, u) {
  var l = e.currentGroup, f = e.vertices, d = e.normals, m = e.indices, p = e.groups, v = f.elementCount, h = 0;
  c > 0 ? (pu(Hr, r, 0), pu(tt, r, a * 3), h = c / V2e(Wl(N2e, tt, Hr))) : R2e(f1, 0, 0, 0);
  for (var y = 0; y <= a; ++y) {
    var C = i[y], S = o[y], b = c === 0 ? S : c * (1 - y / a), g = y * 3;
    pu(Us, t, g), hv(Us, Us, b), pu(qo, n, g), hv(qo, qo, C), c > 0 && (pu(Hr, t, g), pu(tt, n, g), hv(f1, Pj(f1, Hr, tt), h)), pu(Ku, r, g), pu(zs, t, g), pu(OT, n, g), gu(Hr, gu(Hr, Ku, qo), Us), gu(tt, zs, f1), lt(f, Hr[0], Hr[1], Hr[2]), lt(d, tt[0], tt[1], tt[2]), gu(Hr, Wl(Hr, Ku, qo), Us), lt(f, Hr[0], Hr[1], Hr[2]), lt(d, tt[0], tt[1], tt[2]), NN(tt, OT), lt(f, Hr[0], Hr[1], Hr[2]), lt(d, tt[0], tt[1], tt[2]), Wl(Hr, Wl(Hr, Ku, qo), Us), lt(f, Hr[0], Hr[1], Hr[2]), lt(d, tt[0], tt[1], tt[2]), gu(tt, NN(tt, zs), f1), lt(f, Hr[0], Hr[1], Hr[2]), lt(d, tt[0], tt[1], tt[2]), Wl(Hr, gu(Hr, Ku, qo), Us), lt(f, Hr[0], Hr[1], Hr[2]), lt(d, tt[0], tt[1], tt[2]), aw(tt, OT), lt(f, Hr[0], Hr[1], Hr[2]), lt(d, tt[0], tt[1], tt[2]), gu(Hr, gu(Hr, Ku, qo), Us), lt(f, Hr[0], Hr[1], Hr[2]), lt(d, tt[0], tt[1], tt[2]);
  }
  for (var y = 0; y < a; ++y) {
    for (var _ = 0; _ < 2; _++)
      lt(
        m,
        v + y * 8 + 2 * _,
        // a
        v + (y + 1) * 8 + 2 * _ + 1,
        // c
        v + y * 8 + 2 * _ + 1
        // b
      ), lt(
        m,
        v + y * 8 + 2 * _,
        // a
        v + (y + 1) * 8 + 2 * _,
        // d
        v + (y + 1) * 8 + 2 * _ + 1
        // c
      );
    for (var _ = 2; _ < 4; _++)
      lt(
        m,
        v + y * 8 + 2 * _,
        // a
        v + (y + 1) * 8 + 2 * _,
        // d
        v + y * 8 + 2 * _ + 1
      ), lt(
        m,
        v + (y + 1) * 8 + 2 * _,
        // d
        v + (y + 1) * 8 + 2 * _ + 1,
        // c
        v + y * 8 + 2 * _ + 1
      );
  }
  if (s) {
    var C = i[0], S = o[0], A = c === 0 ? S : c;
    Z2(0, e, r, t, n, C, A, A, !1);
  } else if (c > 0) {
    var C = i[0], S = o[0];
    Z2(0, e, r, t, n, C, c, -S, !1), Z2(0, e, r, t, n, C, -c, S, !1);
  }
  if (u && c === 0) {
    var C = i[a], S = o[a];
    Z2(a * 3, e, r, t, n, C, S, S, !0);
  }
  for (var M = (a + 1) * 8 + (s ? 4 : c > 0 ? 8 : 0) + (u && c === 0 ? 4 : 0), y = 0, P = M; y < P; ++y)
    O2e(p, l);
}
sA.addSheet = F2e;
var lA = {};
Object.defineProperty(lA, "__esModule", { value: !0 });
lA.addTube = void 0;
var Cs = Re, uD = wr(), xn = (0, Cs.Vec3)(), zn = (0, Cs.Vec3)(), Ri = (0, Cs.Vec3)(), Ma = (0, Cs.Vec3)(), fi = (0, Cs.Vec3)();
function J2(e, r, t, n, a) {
  e[0] = r[0] * n + t[0] * a, e[1] = r[1] * n + t[1] * a, e[2] = r[2] * n + t[2] * a;
}
function Em(e, r, t, n, a, i) {
  e[0] = r[0] * a + t[0] * i + n[0], e[1] = r[1] * a + t[1] * i + n[1], e[2] = r[2] * a + t[2] * i + n[2];
}
var kl = Cs.Vec3.fromArray, L2e = Cs.Vec3.normalize, FT = Cs.Vec3.scaleAndAdd, VN = Cs.Vec3.cross, k2e = Cs.Vec3.dot, U2e = Cs.Vec3.unitX, mi = uD.ChunkedArray.add3, LT = /* @__PURE__ */ new Map();
function z2e(e, r) {
  var t = r ? 1 : 0, n = (0, uD.cantorPairing)(e, t);
  if (!LT.has(n)) {
    for (var a = [], i = [], o = 0; o < e; ++o) {
      var c = (o * 2 + t) / e * Math.PI;
      a[o] = Math.cos(c), i[o] = Math.sin(c);
    }
    LT.set(n, { cos: a, sin: i });
  }
  return LT.get(n);
}
function G2e(e, r, t, n, a, i, o, c, s, u, l) {
  for (var f = e.currentGroup, d = e.vertices, m = e.normals, p = e.indices, v = e.groups, h = d.elementCount, y = z2e(i, l === "rounded"), C = y.cos, S = y.sin, b = Math.round(i / 4), g = b * 3, _ = 0; _ <= a; ++_) {
    var A = _ * 3;
    kl(Ma, t, A), kl(fi, n, A), kl(Ri, r, A);
    for (var M = o[_], P = c[_], T = l === "rounded" && P > M, x = 0; x < i; ++x) {
      if (T) {
        Em(zn, Ma, fi, Ri, M * C[x], M * S[x]);
        var w = k2e(fi, U2e) < 0 ? x < b || x >= g ? P - M : -P + M : x >= b && x < g ? -P + M : P - M;
        FT(zn, zn, Ma, w), x === b || x === b - 1 ? J2(xn, Ma, fi, 0, 1) : x === g || x === g - 1 ? J2(xn, Ma, fi, 0, -1) : J2(xn, Ma, fi, C[x], S[x]);
      } else
        Em(zn, Ma, fi, Ri, P * C[x], M * S[x]), J2(xn, Ma, fi, M * C[x], P * S[x]);
      L2e(xn, xn), mi(d, zn[0], zn[1], zn[2]), mi(m, xn[0], xn[1], xn[2]);
    }
  }
  for (var E = Math.round(i / 2), _ = 0; _ < a; ++_) {
    for (var x = 0; x < E; ++x)
      mi(
        p,
        h + _ * i + (x + 1) % i,
        // a
        h + (_ + 1) * i + (x + 1) % i,
        // c
        h + _ * i + x
        // b
      ), mi(
        p,
        h + (_ + 1) * i + (x + 1) % i,
        // c
        h + (_ + 1) * i + x,
        // d
        h + _ * i + x
        // b
      );
    for (var x = E; x < i; ++x)
      mi(
        p,
        h + _ * i + (x + 1) % i,
        // a
        h + (_ + 1) * i + x,
        // d
        h + _ * i + x
        // b
      ), mi(
        p,
        h + (_ + 1) * i + (x + 1) % i,
        // c
        h + (_ + 1) * i + x,
        // d
        h + _ * i + (x + 1) % i
      );
  }
  if (s) {
    var I = 0, B = d.elementCount;
    kl(Ma, t, I), kl(fi, n, I), kl(Ri, r, I), VN(xn, fi, Ma), mi(d, Ri[0], Ri[1], Ri[2]), mi(m, xn[0], xn[1], xn[2]);
    var M = o[0], P = c[0], T = l === "rounded" && P > M;
    T && (P -= M), h = d.elementCount;
    for (var _ = 0; _ < i; ++_)
      T ? (Em(zn, Ma, fi, Ri, M * C[_], M * S[_]), FT(zn, zn, Ma, _ < b || _ >= g ? P : -P)) : Em(zn, Ma, fi, Ri, P * C[_], M * S[_]), mi(d, zn[0], zn[1], zn[2]), mi(m, xn[0], xn[1], xn[2]), mi(p, h + (_ + 1) % i, h + _, B);
  }
  if (u) {
    var I = a * 3, B = d.elementCount;
    kl(Ma, t, I), kl(fi, n, I), kl(Ri, r, I), VN(xn, Ma, fi), mi(d, Ri[0], Ri[1], Ri[2]), mi(m, xn[0], xn[1], xn[2]);
    var M = o[a], P = c[a], T = l === "rounded" && P > M;
    T && (P -= M), h = d.elementCount;
    for (var _ = 0; _ < i; ++_)
      T ? (Em(zn, Ma, fi, Ri, M * C[_], M * S[_]), FT(zn, zn, Ma, _ < b || _ >= g ? P : -P)) : Em(zn, Ma, fi, Ri, P * C[_], M * S[_]), mi(d, zn[0], zn[1], zn[2]), mi(m, xn[0], xn[1], xn[2]), mi(p, h + _, h + (_ + 1) % i, B);
  }
  var D = (a + 1) * i + (s ? i + 1 : 0) + (u ? i + 1 : 0);
  uD.ChunkedArray.addRepeat(v, D, f);
}
lA.addTube = G2e;
var cA = {};
Object.defineProperty(cA, "__esModule", { value: !0 });
cA.addRibbon = void 0;
var si = Re, Mj = wr(), Ul = si.Vec3.fromArray, q2e = si.Vec3.magnitude, kT = si.Vec3.sub, RN = si.Vec3.add, UT = si.Vec3.scale, H2e = si.Vec3.negate, j2e = si.Vec3.copy, $2e = si.Vec3.cross, mu = Mj.ChunkedArray.add3, K2e = Mj.ChunkedArray.add, Qn = (0, si.Vec3)(), wa = (0, si.Vec3)(), W2e = (0, si.Vec3)(), zT = (0, si.Vec3)(), Lf = (0, si.Vec3)(), ON = (0, si.Vec3)(), m1 = (0, si.Vec3)(), X2e = (0, si.Vec3)(), GT = (0, si.Vec3)();
function Y2e(e, r, t, n, a, i, o, c) {
  var s = e.currentGroup, u = e.vertices, l = e.normals, f = e.indices, d = e.groups, m = u.elementCount, p = 0;
  c > 0 && (Ul(Qn, r, 0), Ul(wa, r, a * 3), p = c / q2e(kT(W2e, wa, Qn)));
  for (var v = 0; v <= a; ++v) {
    var h = i[v], y = o[v], C = c === 0 ? y : c * (1 - v / a), S = v * 3;
    Ul(Lf, t, S), UT(Lf, Lf, C), Ul(zT, n, S), UT(zT, zT, h), c > 0 && (Ul(Qn, t, S), Ul(wa, n, S), UT(ON, $2e(ON, Qn, wa), p)), Ul(m1, r, S), Ul(X2e, t, S), Ul(GT, n, S), RN(Qn, m1, Lf), H2e(wa, GT), mu(u, Qn[0], Qn[1], Qn[2]), mu(l, wa[0], wa[1], wa[2]), kT(Qn, m1, Lf), mu(u, Qn[0], Qn[1], Qn[2]), mu(l, wa[0], wa[1], wa[2]), RN(Qn, m1, Lf), j2e(wa, GT), mu(u, Qn[0], Qn[1], Qn[2]), mu(l, wa[0], wa[1], wa[2]), kT(Qn, m1, Lf), mu(u, Qn[0], Qn[1], Qn[2]), mu(l, wa[0], wa[1], wa[2]);
  }
  for (var v = 0; v < a; ++v)
    mu(f, m + v * 4, m + (v + 1) * 4 + 1, m + v * 4 + 1), mu(f, m + v * 4, m + (v + 1) * 4, m + (v + 1) * 4 + 1), mu(f, m + v * 4 + 2 + 1, m + (v + 1) * 4 + 2 + 1, m + v * 4 + 2), mu(f, m + v * 4 + 2, m + (v + 1) * 4 + 2 + 1, m + (v + 1) * 4 + 2);
  for (var b = (a + 1) * 4, v = 0, g = b; v < g; ++v)
    K2e(d, s);
}
cA.addRibbon = Y2e;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.PolymerTraceVisual = e.PolymerTraceParams = e.DefaultPolymerTraceMeshProps = e.PolymerTraceMeshParams = void 0;
  var r = Te, t = Le, n = Je(), a = Dt(), i = Ca(), o = K0(), c = Gr, s = sA, u = lA, l = Mr, f = Ac(), d = cA, m = Xd(), p = Re, v = Xt, h = nr();
  e.PolymerTraceMeshParams = {
    sizeFactor: t.ParamDefinition.Numeric(0.2, { min: 0, max: 10, step: 0.01 }),
    aspectRatio: t.ParamDefinition.Numeric(5, { min: 0.1, max: 10, step: 0.1 }),
    arrowFactor: t.ParamDefinition.Numeric(1.5, { min: 0, max: 3, step: 0.1 }, { description: "Size factor for sheet arrows" }),
    tubularHelices: t.ParamDefinition.Boolean(!1, { description: "Draw alpha helices as tubes" }),
    helixProfile: t.ParamDefinition.Select("elliptical", t.ParamDefinition.arrayToOptions(["elliptical", "rounded", "square"]), { description: "Protein and nucleic helix trace profile" }),
    detail: t.ParamDefinition.Numeric(0, { min: 0, max: 3, step: 1 }, v.BaseGeometry.CustomQualityParamInfo),
    linearSegments: t.ParamDefinition.Numeric(8, { min: 1, max: 48, step: 1 }, v.BaseGeometry.CustomQualityParamInfo),
    radialSegments: t.ParamDefinition.Numeric(16, { min: 2, max: 56, step: 2 }, v.BaseGeometry.CustomQualityParamInfo)
  }, e.DefaultPolymerTraceMeshProps = t.ParamDefinition.getDefaultValues(e.PolymerTraceMeshParams);
  var y = (0, p.Vec3)();
  function C(b, g, _, A, M, P) {
    var T = g.polymerElements.length;
    if (!T)
      return a.Mesh.createEmpty(P);
    for (var x = M.sizeFactor, w = M.detail, E = M.linearSegments, I = M.radialSegments, B = M.aspectRatio, D = M.arrowFactor, N = M.tubularHelices, O = M.helixProfile, V = E * I * T + (I + 1) * T * 2, k = i.MeshBuilder.createState(V, V / 10, P), G = n.Unit.isCoarse(g), L = (0, o.createCurveSegmentState)(E), R = L.curvePoints, F = L.normalVectors, U = L.binormalVectors, H = L.widthValues, q = L.heightValues, K = 0, Y = (0, o.PolymerTraceIterator)(g, _, { ignoreSecondaryStructure: !1, useHelixOrientation: N }); Y.hasNext; ) {
      var X = Y.move();
      k.currentGroup = K;
      var Z = (0, c.isNucleic)(X.moleculeType), J = c.SecondaryStructureType.is(
        X.secStrucType,
        4
        /* Beta */
      ), $ = c.SecondaryStructureType.is(
        X.secStrucType,
        2
        /* Helix */
      ), Q = $ && !N ? o.HelixTension : o.StandardTension, W = Z ? o.NucleicShift : o.StandardShift;
      (0, o.interpolateCurveSegment)(L, X, Q, W);
      var te = A.size.size(X.centerPrev) * x, oe = A.size.size(X.center) * x, z = A.size.size(X.centerNext) * x;
      G && (te *= B / 2, oe *= B / 2, z *= B / 2);
      var j = X.secStrucFirst || X.coarseBackboneFirst || X.first, ae = X.secStrucLast || X.coarseBackboneLast || X.last, le = E;
      if (X.initial) {
        le = Math.max(Math.round(E * W), 1);
        var ie = E - le;
        R.copyWithin(0, ie * 3), U.copyWithin(0, ie * 3), F.copyWithin(0, ie * 3), p.Vec3.fromArray(y, R, 3), p.Vec3.normalize(y, p.Vec3.sub(y, X.p2, y)), p.Vec3.scaleAndAdd(y, X.p2, y, oe * o.OverhangFactor), p.Vec3.toArray(y, R, 0);
      } else X.final && (le = Math.max(Math.round(E * (1 - W)), 1), p.Vec3.fromArray(y, R, le * 3 - 3), p.Vec3.normalize(y, p.Vec3.sub(y, X.p2, y)), p.Vec3.scaleAndAdd(y, X.p2, y, oe * o.OverhangFactor), p.Vec3.toArray(y, R, le * 3));
      if (X.initial === !0 && X.final === !0)
        (0, m.addSphere)(k, X.p2, oe * 2, w);
      else if (J) {
        var re = te * B, ee = oe * B, ne = z * B, se = X.secStrucLast ? ee * D : 0;
        (0, o.interpolateSizes)(L, te, oe, z, re, ee, ne, W), I === 2 ? (0, d.addRibbon)(k, R, F, U, le, H, q, se) : (0, s.addSheet)(k, R, F, U, le, H, q, se, j, ae);
      } else {
        var re = void 0, ee = void 0, ne = void 0;
        $ && !X.isCoarseBackbone ? N ? (te *= B * 1.5, oe *= B * 1.5, z *= B * 1.5, re = te, ee = oe, ne = z) : (re = te * B, ee = oe * B, ne = z * B) : Z && !X.isCoarseBackbone ? (re = te * B, ee = oe * B, ne = z * B) : (re = te, ee = oe, ne = z), (0, o.interpolateSizes)(L, te, oe, z, re, ee, ne, W);
        var ce = Z && !X.isCoarseBackbone ? [U, F] : [F, U], de = ce[0], me = ce[1];
        if (Z && !X.isCoarseBackbone)
          for (var he = 0, _e = de.length; he < _e; he++)
            de[he] *= -1;
        I === 2 ? Z && !X.isCoarseBackbone ? (0, d.addRibbon)(k, R, de, me, le, q, H, 0) : (0, d.addRibbon)(k, R, de, me, le, H, q, 0) : I === 4 ? (0, s.addSheet)(k, R, de, me, le, H, q, 0, j, ae) : ee === oe ? (0, u.addTube)(k, R, de, me, le, I, H, q, j, ae, "elliptical") : O === "square" ? (0, s.addSheet)(k, R, de, me, le, H, q, 0, j, ae) : (0, u.addTube)(k, R, de, me, le, I, H, q, j, ae, O);
      }
      ++K;
    }
    var Se = i.MeshBuilder.getMesh(k), Pe = h.Sphere3D.expand((0, h.Sphere3D)(), g.boundary.sphere, 1 * M.sizeFactor);
    return Se.setBoundingSphere(Pe), Se;
  }
  e.PolymerTraceParams = (0, r.__assign)((0, r.__assign)({}, l.UnitsMeshParams), e.PolymerTraceMeshParams);
  function S(b) {
    return (0, l.UnitsMeshVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.PolymerTraceParams),
      createGeometry: C,
      createLocationIterator: o.PolymerLocationIterator.fromGroup,
      getLoci: o.getPolymerElementLoci,
      eachLocation: o.eachPolymerElement,
      setUpdateState: function(g, _, A, M, P, T, x) {
        g.createGeometry = _.sizeFactor !== A.sizeFactor || _.tubularHelices !== A.tubularHelices || _.detail !== A.detail || _.linearSegments !== A.linearSegments || _.radialSegments !== A.radialSegments || _.aspectRatio !== A.aspectRatio || _.arrowFactor !== A.arrowFactor || _.helixProfile !== A.helixProfile;
        var w = f.SecondaryStructureProvider.get(T.structure).version;
        g.info.secondaryStructureHash !== w && (g.createGeometry = g.info.secondaryStructureHash !== void 0, g.info.secondaryStructureHash = w);
      }
    }, b);
  }
  e.PolymerTraceVisual = S;
})(xj);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.CartoonRepresentationProvider = e.CartoonRepresentation = e.getCartoonParams = e.CartoonParams = void 0;
  var r = Te, t = Je(), n = Wt, a = Le, i = Ss(), o = $0(), c = gj, s = bj, u = Sj, l = Aj, f = xj, d = Ac(), m = S0, p = Xt, v = {
    "polymer-trace": function(C, S) {
      return (0, o.UnitsRepresentation)("Polymer trace mesh", C, S, f.PolymerTraceVisual);
    },
    "polymer-gap": function(C, S) {
      return (0, o.UnitsRepresentation)("Polymer gap cylinder", C, S, l.PolymerGapVisual);
    },
    "nucleotide-block": function(C, S) {
      return (0, o.UnitsRepresentation)("Nucleotide block mesh", C, S, c.NucleotideBlockVisual);
    },
    "nucleotide-ring": function(C, S) {
      return (0, o.UnitsRepresentation)("Nucleotide ring mesh", C, S, s.NucleotideRingVisual);
    },
    "direction-wedge": function(C, S) {
      return (0, o.UnitsRepresentation)("Polymer direction wedge", C, S, u.PolymerDirectionVisual);
    }
  };
  e.CartoonParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, f.PolymerTraceParams), l.PolymerGapParams), c.NucleotideBlockParams), s.NucleotideRingParams), u.PolymerDirectionParams), { sizeFactor: a.ParamDefinition.Numeric(0.2, { min: 0, max: 10, step: 0.01 }), visuals: a.ParamDefinition.MultiSelect(["polymer-trace", "polymer-gap", "nucleotide-ring"], a.ParamDefinition.objectToOptions(v)), bumpFrequency: a.ParamDefinition.Numeric(2, { min: 0, max: 10, step: 0.1 }, p.BaseGeometry.ShadingCategory) });
  function h(C, S) {
    var b = a.ParamDefinition.clone(e.CartoonParams), g = !1, _ = !1;
    return S.units.forEach(function(A) {
      !g && t.Unit.isAtomic(A) && A.nucleotideElements.length && (g = !0), !_ && A.gapElements.length && (_ = !0);
    }), b.visuals.defaultValue = ["polymer-trace"], g && b.visuals.defaultValue.push("nucleotide-ring"), _ && b.visuals.defaultValue.push("polymer-gap"), b;
  }
  e.getCartoonParams = h;
  function y(C, S) {
    return n.Representation.createMulti("Cartoon", C, S, i.StructureRepresentationStateBuilder, v);
  }
  e.CartoonRepresentation = y, e.CartoonRepresentationProvider = (0, i.StructureRepresentationProvider)({
    name: "cartoon",
    label: "Cartoon",
    description: "Displays ribbons, planks, tubes smoothly following the trace atoms of polymers.",
    factory: y,
    getParams: h,
    defaultValues: a.ParamDefinition.getDefaultValues(e.CartoonParams),
    defaultColorTheme: { name: "chain-id" },
    defaultSizeTheme: { name: "uniform" },
    isApplicable: function(C) {
      return C.polymerResidueCount > 0;
    },
    ensureCustomProperties: {
      attach: function(C, S) {
        return (0, r.__awaiter)(void 0, void 0, void 0, function() {
          var b, g, _;
          return (0, r.__generator)(this, function(A) {
            switch (A.label) {
              case 0:
                return [4, d.SecondaryStructureProvider.attach(C, S, void 0, !0)];
              case 1:
                A.sent(), b = 0, g = S.models, A.label = 2;
              case 2:
                return b < g.length ? (_ = g[b], [4, m.HelixOrientationProvider.attach(C, _, void 0, !0)]) : [3, 5];
              case 3:
                A.sent(), A.label = 4;
              case 4:
                return b++, [3, 2];
              case 5:
                return [
                  2
                  /*return*/
                ];
            }
          });
        });
      },
      detach: function(C) {
        d.SecondaryStructureProvider.ref(C, !1);
        for (var S = 0, b = C.models; S < b.length; S++) {
          var g = b[S];
          m.HelixOrientationProvider.ref(g, !1);
        }
      }
    }
  });
})(iD);
Object.defineProperty(iA, "__esModule", { value: !0 });
iA.RibbonRepr = void 0;
var Dm = Te, FN = Ac(), LN = us, kN = ty(), qT = iD;
iA.RibbonRepr = {
  create: function(e, r, t) {
    return (0, Dm.__awaiter)(this, void 0, void 0, function() {
      var n;
      return (0, Dm.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return e.elementCount ? [4, FN.SecondaryStructureProvider.attach({ runtime: LN.SyncRuntimeContext, assetManager: new kN.AssetManager() }, e)] : [3, 2];
          case 1:
            a.sent(), a.label = 2;
          case 2:
            return n = qT.CartoonRepresentationProvider.factory(r, qT.CartoonRepresentationProvider.getParams), n.setTheme(t ?? {
              color: r.colorThemeRegistry.create("element-symbol", {
                structure: e
              }),
              size: r.sizeThemeRegistry.create("uniform", { structure: e })
            }), [4, n.createOrUpdate((0, Dm.__assign)((0, Dm.__assign)({}, qT.CartoonRepresentationProvider.defaultValues), { quality: "auto" }), e).run()];
          case 3:
            return a.sent(), [2, n];
        }
      });
    });
  },
  update: function(e, r, t, n) {
    return (0, Dm.__awaiter)(this, void 0, void 0, function() {
      return (0, Dm.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return e.setTheme(n ?? {
              color: t.colorThemeRegistry.create("element-symbol", {
                structure: r
              }),
              size: t.sizeThemeRegistry.create("uniform", { structure: r })
            }), r.elementCount ? [4, FN.SecondaryStructureProvider.attach({ runtime: LN.SyncRuntimeContext, assetManager: new kN.AssetManager() }, r)] : [3, 2];
          case 1:
            a.sent(), a.label = 2;
          case 2:
            return [4, e.createOrUpdate({}, r).run()];
          case 3:
            return a.sent(), [
              2
              /*return*/
            ];
        }
      });
    });
  }
};
var Iy = {}, sD = {}, lD = {}, Jd = {}, dA = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.CylindersBuilder = void 0;
  var r = wr(), t = hl(), n = Re, a = (0, n.Vec3)(), i = (0, n.Vec3)(), o = (0, n.Vec3)(), c = r.ChunkedArray.add, s = r.ChunkedArray.add3;
  (function(l) {
    function f(d, m, p) {
      d === void 0 && (d = 2048), m === void 0 && (m = 1024);
      var v = r.ChunkedArray.create(Float32Array, 1, m, p ? p.groupBuffer.ref.value : d), h = r.ChunkedArray.create(Float32Array, 3, m, p ? p.startBuffer.ref.value : d), y = r.ChunkedArray.create(Float32Array, 3, m, p ? p.endBuffer.ref.value : d), C = r.ChunkedArray.create(Float32Array, 1, m, p ? p.scaleBuffer.ref.value : d), S = r.ChunkedArray.create(Float32Array, 1, m, p ? p.capBuffer.ref.value : d), b = function(_, A, M, P, T, x, w, E, I, B) {
        for (var D = 0; D < 6; ++D)
          s(h, _, A, M), s(y, P, T, x), c(v, B), c(C, w), c(S, (E ? 1 : 0) + (I ? 2 : 0));
      }, g = function(_, A, M, P, T, x, w) {
        var E = n.Vec3.distance(_, A), I = Math.floor(M / 2), B = 1 / M;
        n.Vec3.sub(o, A, _);
        for (var D = 0; D < I; ++D) {
          var N = B * (D * 2 + 1);
          n.Vec3.setMagnitude(o, o, E * N), n.Vec3.add(a, _, o), n.Vec3.setMagnitude(o, o, E * B * ((D + 1) * 2)), n.Vec3.add(i, _, o), b(a[0], a[1], a[2], i[0], i[1], i[2], P, T, x, w);
        }
      };
      return {
        add: b,
        addFixedCountDashes: g,
        addFixedLengthDashes: function(_, A, M, P, T, x, w) {
          var E = n.Vec3.distance(_, A);
          g(_, A, E / M, P, T, x, w);
        },
        getCylinders: function() {
          var _ = v.elementCount / 6, A = r.ChunkedArray.compact(v, !0), M = r.ChunkedArray.compact(h, !0), P = r.ChunkedArray.compact(y, !0), T = r.ChunkedArray.compact(C, !0), x = r.ChunkedArray.compact(S, !0), w = p && _ <= p.cylinderCount ? p.mappingBuffer.ref.value : new Float32Array(_ * 18), E = p && _ <= p.cylinderCount ? p.indexBuffer.ref.value : new Uint32Array(_ * 12);
          return (!p || _ > p.cylinderCount) && u(_, w, E), t.Cylinders.create(w, E, A, M, P, T, x, _, p);
        }
      };
    }
    l.create = f;
  })(e.CylindersBuilder || (e.CylindersBuilder = {}));
  function u(l, f, d) {
    for (var m = 0; m < l; ++m) {
      var p = m * 18;
      f[p] = -1, f[p + 1] = 1, f[p + 2] = -1, f[p + 3] = -1, f[p + 4] = -1, f[p + 5] = -1, f[p + 6] = 1, f[p + 7] = 1, f[p + 8] = -1, f[p + 9] = 1, f[p + 10] = 1, f[p + 11] = 1, f[p + 12] = 1, f[p + 13] = -1, f[p + 14] = -1, f[p + 15] = 1, f[p + 16] = -1, f[p + 17] = 1;
    }
    for (var m = 0; m < l; ++m) {
      var v = m * 6, h = m * 12;
      d[h] = v, d[h + 1] = v + 1, d[h + 2] = v + 2, d[h + 3] = v + 1, d[h + 4] = v + 4, d[h + 5] = v + 2, d[h + 6] = v + 2, d[h + 7] = v + 4, d[h + 8] = v + 3, d[h + 9] = v + 4, d[h + 10] = v + 5, d[h + 11] = v + 3;
    }
  }
})(dA);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.createLinkLines = e.createLinkCylinderImpostors = e.createLinkCylinderMesh = e.calculateShiftDir = e.DefaultLinkLineProps = e.LinkLineParams = e.DefaultLinkCylinderProps = e.LinkCylinderParams = void 0;
  var r = Re, t = Le, n = Dt(), a = Ca(), i = Yd(), o = Xt, c = Fa(), s = pl(), u = hl(), l = dA, f = lC();
  e.LinkCylinderParams = {
    linkScale: t.ParamDefinition.Numeric(0.45, { min: 0, max: 1, step: 0.01 }),
    linkSpacing: t.ParamDefinition.Numeric(1, { min: 0, max: 2, step: 0.01 }),
    linkCap: t.ParamDefinition.Boolean(!1),
    aromaticScale: t.ParamDefinition.Numeric(0.3, { min: 0, max: 1, step: 0.01 }),
    aromaticSpacing: t.ParamDefinition.Numeric(1.5, { min: 0, max: 3, step: 0.01 }),
    aromaticDashCount: t.ParamDefinition.Numeric(2, { min: 2, max: 6, step: 2 }),
    dashCount: t.ParamDefinition.Numeric(4, { min: 2, max: 10, step: 2 }),
    dashScale: t.ParamDefinition.Numeric(0.8, { min: 0, max: 2, step: 0.1 }),
    dashCap: t.ParamDefinition.Boolean(!0),
    stubCap: t.ParamDefinition.Boolean(!0),
    radialSegments: t.ParamDefinition.Numeric(16, { min: 2, max: 56, step: 2 }, o.BaseGeometry.CustomQualityParamInfo)
  }, e.DefaultLinkCylinderProps = t.ParamDefinition.getDefaultValues(e.LinkCylinderParams), e.LinkLineParams = {
    linkScale: t.ParamDefinition.Numeric(0.5, { min: 0, max: 1, step: 0.1 }),
    linkSpacing: t.ParamDefinition.Numeric(0.1, { min: 0, max: 2, step: 0.01 }),
    aromaticDashCount: t.ParamDefinition.Numeric(2, { min: 2, max: 6, step: 2 }),
    dashCount: t.ParamDefinition.Numeric(4, { min: 2, max: 10, step: 2 })
  }, e.DefaultLinkLineProps = t.ParamDefinition.getDefaultValues(e.LinkLineParams);
  var d = (0, r.Vec3)(), m = (0, r.Vec3)(), p = (0, r.Vec3)(), v = r.Vec3.create(0, 1, 0);
  function h(P, T, x, w) {
    r.Vec3.normalize(m, r.Vec3.sub(m, T, x)), w !== null ? r.Vec3.sub(p, T, w) : r.Vec3.copy(p, T), r.Vec3.normalize(p, p);
    var E = r.Vec3.dot(m, p);
    return 1 - Math.abs(E) < 1e-5 && (r.Vec3.set(p, 1, 0, 0), E = r.Vec3.dot(m, p), 1 - Math.abs(E) < 1e-5 && (r.Vec3.set(p, 0, 1, 0), E = r.Vec3.dot(m, p))), r.Vec3.setMagnitude(m, m, E), r.Vec3.sub(p, p, m), r.Vec3.normalize(P, p);
  }
  e.calculateShiftDir = h;
  var y = r.Vec3.scale, C = r.Vec3.add, S = r.Vec3.sub, b = r.Vec3.setMagnitude, g = r.Vec3.dot;
  function _(P, T, x, w) {
    var E = T.linkCount, I = T.referencePosition, B = T.position, D = T.style, N = T.radius, O = T.ignore, V = T.stub;
    if (!E)
      return { mesh: n.Mesh.createEmpty(w) };
    for (var k = x.linkScale, G = x.linkSpacing, L = x.radialSegments, R = x.linkCap, F = x.aromaticScale, U = x.aromaticSpacing, H = x.aromaticDashCount, q = x.dashCount, K = x.dashScale, Y = x.dashCap, X = x.stubCap, Z = L * 2 * E * 2, J = a.MeshBuilder.createState(Z, Z / 4, w), $ = (0, r.Vec3)(), Q = (0, r.Vec3)(), W = (0, r.Vec3)(), te = (0, r.Vec3)(), oe = 0, z = {
      radiusTop: 1,
      radiusBottom: 1,
      radialSegments: L,
      topCap: R,
      bottomCap: R
    }, j = q + 1, ae = 0, le = E; ae < le; ++ae)
      if (!(O && O(ae))) {
        B($, Q, ae), C(te, te, $), C(te, te, Q), oe += 2, S(d, Q, $);
        var ie = g(d, v) > 0, re = N(ae), ee = D ? D(ae) : 0, ne = X && (V ? V(ae) : !1), se = ie ? [ne, R] : [R, ne], ce = se[0], de = se[1];
        J.currentGroup = ae;
        var me = H + 1;
        if (ee === 0)
          z.radiusTop = z.radiusBottom = re, z.topCap = ce, z.bottomCap = de, (0, i.addCylinder)(J, $, Q, 0.5, z);
        else if (ee === 1)
          z.radiusTop = z.radiusBottom = re * K, z.topCap = z.bottomCap = Y, (0, i.addFixedCountDashedCylinder)(J, $, Q, 0.5, j, z);
        else if (ee === 2 || ee === 3 || ee === 4 || ee === 5 || ee === 7 || ee === 8) {
          var he = ee === 2 || ee === 3 ? 2 : ee === 4 || ee === 5 ? 3 : 1.5, _e = re * (k / (0.5 * he)), Se = (re - _e) * G;
          if (h(W, $, Q, I ? I(ae) : null), z.topCap = ce, z.bottomCap = de, ee === 7 || ee === 8) {
            z.radiusTop = z.radiusBottom = re, (0, i.addCylinder)(J, $, Q, 0.5, z);
            var Pe = re + F * re + F * re * U;
            b(d, S(d, Q, $), re * 0.5), C($, $, d), S(Q, Q, d), z.radiusTop = z.radiusBottom = re * F, z.topCap = z.bottomCap = Y, b(W, W, Pe), S($, $, W), S(Q, Q, W), (0, i.addFixedCountDashedCylinder)(J, $, Q, 0.5, me, z), ee === 8 && (b(W, W, Pe * 2), C($, $, W), C(Q, Q, W), (0, i.addFixedCountDashedCylinder)(J, $, Q, 0.5, me, z));
          } else if (ee === 3 || ee === 5) {
            var De = re + _e + k * re * G;
            b(W, W, De), z.radiusTop = z.radiusBottom = re, (0, i.addCylinder)(J, $, Q, 0.5, z), y(d, d, G * k * 0.2), C($, $, d), S(Q, Q, d), z.radiusTop = z.radiusBottom = _e, z.topCap = ie ? ne : Y, z.bottomCap = ie ? Y : ne, b(W, W, De), S($, $, W), S(Q, Q, W), (0, i.addCylinder)(J, $, Q, 0.5, z), he === 3 && (b(W, W, De * 2), C($, $, W), C(Q, Q, W), (0, i.addCylinder)(J, $, Q, 0.5, z));
          } else
            b(W, W, Se), z.radiusTop = z.radiusBottom = _e, he === 3 && (0, i.addCylinder)(J, $, Q, 0.5, z), (0, i.addDoubleCylinder)(J, $, Q, 0.5, W, z);
        } else ee === 6 && (y(d, d, 0.475), C($, $, d), S(Q, Q, d), z.radiusTop = z.radiusBottom = re, z.topCap = ce, z.bottomCap = de, (0, i.addCylinder)(J, $, Q, 0.5, z));
      }
    var Ee = w ? f.Sphere3D.clone(w.boundingSphere) : void 0, Me = a.MeshBuilder.getMesh(J);
    return oe === 0 ? { mesh: Me } : (r.Vec3.scale(te, te, 1 / oe), Ee && r.Vec3.distance(te, Ee.center) / Ee.radius < 1 ? { mesh: Me, boundingSphere: Ee } : { mesh: Me });
  }
  e.createLinkCylinderMesh = _;
  function A(P, T, x, w) {
    var E = T.linkCount, I = T.referencePosition, B = T.position, D = T.style, N = T.radius, O = T.ignore, V = T.stub;
    if (!E)
      return { cylinders: u.Cylinders.createEmpty(w) };
    for (var k = x.linkScale, G = x.linkSpacing, L = x.linkCap, R = x.aromaticScale, F = x.aromaticSpacing, U = x.aromaticDashCount, H = x.dashCount, q = x.dashScale, K = x.dashCap, Y = x.stubCap, X = E * 2, Z = l.CylindersBuilder.create(X, X / 4, w), J = (0, r.Vec3)(), $ = (0, r.Vec3)(), Q = (0, r.Vec3)(), W = (0, r.Vec3)(), te = (0, r.Vec3)(), oe = 0, z = H % 2 === 1 ? H : H + 1, j = 0.5 - 0.5 / 2 / z, ae = U + 1, le = 0.5 - 0.5 / 2 / ae, ie = 0, re = E; ie < re; ++ie)
      if (!(O && O(ie))) {
        B(J, $, ie), C(te, te, J), C(te, te, $), oe += 2;
        var ee = N(ie), ne = D ? D(ie) : 0, se = Y && (V ? V(ie) : !1);
        if (ne === 0)
          y(Q, C(Q, J, $), 0.5), Z.add(J[0], J[1], J[2], Q[0], Q[1], Q[2], 1, L, se, ie);
        else if (ne === 1)
          y(d, S(d, $, J), j), S($, $, d), Z.addFixedCountDashes(J, $, z, q, K, K, ie);
        else if (ne === 2 || ne === 3 || ne === 4 || ne === 5 || ne === 7 || ne === 8) {
          var ce = ne === 2 || ne === 3 ? 2 : ne === 4 || ne === 5 ? 3 : 1.5, de = k / (0.5 * ce), me = (ee - de * ee) * G;
          if (y(Q, C(Q, J, $), 0.5), h(W, J, $, I ? I(ie) : null), ne === 7 || ne === 8) {
            Z.add(J[0], J[1], J[2], Q[0], Q[1], Q[2], 1, L, se, ie);
            var he = ee + R * ee + R * ee * F;
            y(d, S(d, $, J), le), S($, $, d), b(d, S(d, $, J), ee * 0.5), C(J, J, d), b(W, W, he), S(J, J, W), S($, $, W), Z.addFixedCountDashes(J, $, ae, R, K, K, ie), ne === 8 && (b(W, W, he * 2), C(J, J, W), C($, $, W), Z.addFixedCountDashes(J, $, ae, R, K, K, ie));
          } else if (ne === 3 || ne === 5) {
            var _e = ee + de * ee + k * ee * G;
            b(W, W, _e), Z.add(J[0], J[1], J[2], Q[0], Q[1], Q[2], 1, L, se, ie), b(d, S(d, J, $), ee / 1.5), S(J, J, d), ce === 3 && Z.add(J[0] + W[0], J[1] + W[1], J[2] + W[2], Q[0] + W[0], Q[1] + W[1], Q[2] + W[2], de, L, se, ie), Z.add(J[0] - W[0], J[1] - W[1], J[2] - W[2], Q[0] - W[0], Q[1] - W[1], Q[2] - W[2], de, K, se, ie);
          } else
            b(W, W, me), ce === 3 && Z.add(J[0], J[1], J[2], Q[0], Q[1], Q[2], de, L, se, ie), Z.add(J[0] + W[0], J[1] + W[1], J[2] + W[2], Q[0] + W[0], Q[1] + W[1], Q[2] + W[2], de, L, se, ie), Z.add(J[0] - W[0], J[1] - W[1], J[2] - W[2], Q[0] - W[0], Q[1] - W[1], Q[2] - W[2], de, L, se, ie);
        } else ne === 6 && (y(d, S(d, $, J), 0.475), C(J, J, d), S($, $, d), Z.add(J[0], J[1], J[2], $[0], $[1], $[2], 1, L, se, ie));
      }
    var Se = w ? f.Sphere3D.clone(w.boundingSphere) : void 0, Pe = Z.getCylinders();
    return oe === 0 ? { cylinders: Pe } : (r.Vec3.scale(te, te, 1 / oe), Se && r.Vec3.distance(te, Se.center) / Se.radius < 1 ? { cylinders: Pe, boundingSphere: Se } : { cylinders: Pe });
  }
  e.createLinkCylinderImpostors = A;
  function M(P, T, x, w) {
    var E = T.linkCount, I = T.referencePosition, B = T.position, D = T.style, N = T.ignore;
    if (!E)
      return { lines: c.Lines.createEmpty(w) };
    for (var O = x.linkScale, V = x.linkSpacing, k = x.aromaticDashCount, G = x.dashCount, L = E * 2, R = s.LinesBuilder.create(L, L / 4, w), F = (0, r.Vec3)(), U = (0, r.Vec3)(), H = (0, r.Vec3)(), q = (0, r.Vec3)(), K = (0, r.Vec3)(), Y = 0, X = G % 2 === 1 ? G : G + 1, Z = 0.5 - 0.5 / 2 / X, J = k + 1, $ = 0.5 - 0.5 / 2 / J, Q = 4.5, W = 3, te = 0, oe = E; te < oe; ++te)
      if (!(N && N(te))) {
        B(F, U, te), C(K, K, F), C(K, K, U), Y += 2;
        var z = D ? D(te) : 0;
        if (z === 0)
          y(H, C(H, F, U), 0.5), R.add(F[0], F[1], F[2], H[0], H[1], H[2], te);
        else if (z === 1)
          y(d, S(d, U, F), Z), S(U, U, d), R.addFixedCountDashes(F, U, X, te);
        else if (z === 2 || z === 3 || z === 4 || z === 5 || z === 7 || z === 8) {
          var j = z === 2 || z === 3 ? 2 : z === 4 || z === 5 ? 3 : 1.5, ae = 1 * (O / (0.5 * j)), le = (1 - ae) * V;
          y(H, C(H, F, U), 0.5), h(q, F, U, I ? I(te) : null), z === 7 || z === 8 ? (R.add(F[0], F[1], F[2], H[0], H[1], H[2], te), y(d, S(d, U, F), $), S(U, U, d), b(q, q, le * Q), S(F, F, q), S(U, U, q), R.addFixedCountDashes(F, U, J, te), z === 8 && (b(q, q, le * Q * 2), C(F, F, q), C(U, U, q), R.addFixedCountDashes(F, U, J, te))) : z === 3 || z === 5 ? (b(q, q, le * W), R.add(F[0], F[1], F[2], H[0], H[1], H[2], te), y(d, S(d, F, U), V * O), S(F, F, d), j === 3 && R.add(F[0] + q[0], F[1] + q[1], F[2] + q[2], H[0] + q[0], H[1] + q[1], H[2] + q[2], te), R.add(F[0] - q[0], F[1] - q[1], F[2] - q[2], H[0] - q[0], H[1] - q[1], H[2] - q[2], te)) : (b(q, q, le * 1.5), j === 3 && R.add(F[0], F[1], F[2], H[0], H[1], H[2], te), R.add(F[0] + q[0], F[1] + q[1], F[2] + q[2], H[0] + q[0], H[1] + q[1], H[2] + q[2], te), R.add(F[0] - q[0], F[1] - q[1], F[2] - q[2], H[0] - q[0], H[1] - q[1], H[2] - q[2], te));
        } else z === 6 && (y(d, S(d, U, F), 0.475), C(F, F, d), S(U, U, d), R.add(F[0], F[1], F[2], U[0], U[1], U[2], te));
      }
    var ie = w ? f.Sphere3D.clone(w.boundingSphere) : void 0, re = R.getLines();
    return Y === 0 ? { lines: re } : (r.Vec3.scale(K, K, 1 / Y), ie && r.Vec3.distance(K, ie.center) / ie.radius < 1 ? { lines: re, boundingSphere: ie } : { lines: re });
  }
  e.createLinkLines = M;
})(Jd);
var By = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.eachInterBond = e.getInterBondLoci = e.eachIntraBond = e.getIntraBondLoci = e.BondIterator = e.makeInterBondIgnoreTest = e.makeIntraBondIgnoreTest = e.ignoreBondType = e.DefaultBondLineProps = e.BondLineParams = e.DefaultBondCylinderProps = e.BondCylinderParams = e.DefaultBondProps = e.BondParams = void 0;
  var r = Te, t = Gr, n = Je(), a = Le, i = on, o = Jd, c = Ft, s = _r, u = Qe(), l = bl;
  e.BondParams = {
    includeTypes: a.ParamDefinition.MultiSelect((0, c.ObjectKeys)(t.BondType.Names), a.ParamDefinition.objectToOptions(t.BondType.Names)),
    excludeTypes: a.ParamDefinition.MultiSelect([], a.ParamDefinition.objectToOptions(t.BondType.Names)),
    ignoreHydrogens: a.ParamDefinition.Boolean(!1),
    aromaticBonds: a.ParamDefinition.Boolean(!0, {
      description: "Display aromatic bonds with dashes"
    }),
    multipleBonds: a.ParamDefinition.Select("symmetric", a.ParamDefinition.arrayToOptions(["off", "symmetric", "offset"]))
  }, e.DefaultBondProps = a.ParamDefinition.getDefaultValues(e.BondParams), e.BondCylinderParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, o.LinkCylinderParams), e.BondParams), { adjustCylinderLength: a.ParamDefinition.Boolean(!1, {
    description: "Shorten cylinders to reduce overlap with spheres. Useful for for transparent bonds. Not working well with aromatic bonds."
  }) }), e.DefaultBondCylinderProps = a.ParamDefinition.getDefaultValues(e.BondCylinderParams), e.BondLineParams = (0, r.__assign)((0, r.__assign)({}, o.LinkLineParams), e.BondParams), e.DefaultBondLineProps = a.ParamDefinition.getDefaultValues(e.BondLineParams);
  function f(S, b, g) {
    return !t.BondType.is(S, g) || t.BondType.is(b, g);
  }
  e.ignoreBondType = f;
  function d(S, b, g) {
    var _ = b.elements, A = b.model.atomicHierarchy.derived.atom.atomicNumber, M = b.bonds, P = M.a, T = M.b, x = M.edgeProps, w = x.flags, E = g.ignoreHydrogens, I = g.includeTypes, B = g.excludeTypes, D = t.BondType.fromNames(I), N = t.BondType.fromNames(B), O = t.BondType.isAll(D) && N === 0, V = S.child, k = V == null ? void 0 : V.unitMap.get(b.id);
    if (V && !k)
      throw new Error("expected childUnit to exist if child exists");
    if (!(O && !E && !V))
      return function(G) {
        return !!k && !u.SortedArray.has(k.elements, _[P[G]]) || E && ((0, l.isH)(A, _[P[G]]) || (0, l.isH)(A, _[T[G]])) || !O && f(D, N, w[G]);
      };
  }
  e.makeIntraBondIgnoreTest = d;
  function m(S, b) {
    var g = S.interUnitBonds, _ = g.edges, A = b.ignoreHydrogens, M = b.includeTypes, P = b.excludeTypes, T = t.BondType.fromNames(M), x = t.BondType.fromNames(P), w = t.BondType.isAll(T) && x === 0, E = S.child;
    if (!(w && !A && !E))
      return function(I) {
        if (E) {
          var B = _[I], D = E.unitMap.get(B.unitA);
          if (!D)
            return !0;
          var N = S.unitMap.get(B.unitA), O = N.elements[B.indexA];
          if (!u.SortedArray.has(D.elements, O))
            return !0;
        }
        if (A) {
          var B = _[I], V = S.unitMap.get(B.unitA), k = S.unitMap.get(B.unitB);
          if ((0, l.isHydrogen)(V, V.elements[B.indexA]) || (0, l.isHydrogen)(k, k.elements[B.indexB]))
            return !0;
        }
        return !!(!w && f(T, x, _[I].props.flag));
      };
  }
  e.makeInterBondIgnoreTest = m, function(S) {
    function b(_) {
      var A = _.group, M = _.structure, P = A.units[0], T = n.Unit.isAtomic(P) ? P.bonds.edgeCount * 2 : 0, x = A.units.length, w = n.Bond.Location(M, void 0, void 0, M, void 0, void 0), E = function(I, B) {
        var D = A.units[B];
        return w.aUnit = D, w.bUnit = D, w.aIndex = D.bonds.a[I], w.bIndex = D.bonds.b[I], w;
      };
      return (0, i.LocationIterator)(T, x, 1, E);
    }
    S.fromGroup = b;
    function g(_) {
      var A = _.interUnitBonds.edgeCount, M = 1, P = n.Bond.Location(_, void 0, void 0, _, void 0, void 0), T = function(x) {
        var w = _.interUnitBonds.edges[x];
        return P.aUnit = _.unitMap.get(w.unitA), P.aIndex = w.indexA, P.bUnit = _.unitMap.get(w.unitB), P.bIndex = w.indexB, P;
      };
      return (0, i.LocationIterator)(A, M, 1, T, !0);
    }
    S.fromStructure = g;
  }(e.BondIterator || (e.BondIterator = {}));
  function p(S, b, g) {
    var _ = S.objectId, A = S.instanceId, M = S.groupId;
    if (g === _) {
      var P = b.structure, T = b.group, x = T.units[A];
      if (n.Unit.isAtomic(x)) {
        var w = P.target, E = x.bonds.a[M], I = x.bonds.b[M];
        return n.Bond.Loci(w, [
          n.Bond.Location(w, x, E, w, x, I),
          n.Bond.Location(w, x, I, w, x, E)
        ]);
      }
    }
    return s.EmptyLoci;
  }
  e.getIntraBondLoci = p;
  function v(S, b, g, _) {
    var A = !1;
    if (n.Bond.isLoci(S)) {
      var M = b.structure, P = b.group;
      if (!n.Structure.areEquivalent(S.structure, M))
        return !1;
      var T = P.units[0];
      if (!n.Unit.isAtomic(T))
        return !1;
      for (var x = T.bonds.edgeCount * 2, w = 0, E = S.bonds; w < E.length; w++) {
        var I = E[w];
        if (I.aUnit === I.bUnit) {
          var B = P.unitIndexMap.get(I.aUnit.id);
          if (B !== void 0) {
            var D = T.bonds.getDirectedEdgeIndex(I.aIndex, I.bIndex);
            D !== -1 && g(u.Interval.ofSingleton(B * x + D)) && (A = !0);
          }
        }
      }
    } else if (n.StructureElement.Loci.is(S)) {
      var M = b.structure, P = b.group;
      if (!n.Structure.areEquivalent(S.structure, M))
        return !1;
      var T = P.units[0];
      if (!n.Unit.isAtomic(T))
        return !1;
      for (var N = T.bonds.edgeCount * 2, O = function(U) {
        var H = P.unitIndexMap.get(U.unit.id);
        if (H !== void 0) {
          var q = T.bonds, K = q.offset, Y = q.b;
          u.OrderedSet.forEach(U.indices, function(X) {
            for (var Z = K[X], J = K[X + 1]; Z < J; Z++)
              (!_ || u.OrderedSet.has(U.indices, Y[Z])) && g(u.Interval.ofSingleton(H * N + Z)) && (A = !0);
          });
        }
      }, V = 0, k = S.elements; V < k.length; V++) {
        var G = k[V];
        O(G);
      }
    }
    return A;
  }
  e.eachIntraBond = v;
  function h(S, b, g) {
    var _ = S.objectId, A = S.groupId;
    if (g === _) {
      var M = b.target, P = b.interUnitBonds.edges[A], T = b.unitMap.get(P.unitA), x = b.unitMap.get(P.unitB);
      return n.Bond.Loci(M, [
        n.Bond.Location(M, T, P.indexA, M, x, P.indexB),
        n.Bond.Location(M, x, P.indexB, M, T, P.indexA)
      ]);
    }
    return s.EmptyLoci;
  }
  e.getInterBondLoci = h;
  var y = /* @__PURE__ */ new Map();
  function C(S, b, g, _) {
    var A = !1;
    if (n.Bond.isLoci(S)) {
      if (!n.Structure.areEquivalent(S.structure, b))
        return !1;
      for (var M = 0, P = S.bonds; M < P.length; M++) {
        var T = P[M], x = b.interUnitBonds.getBondIndexFromLocation(T);
        x !== -1 && g(u.Interval.ofSingleton(x)) && (A = !0);
      }
    } else if (n.StructureElement.Loci.is(S)) {
      if (!n.Structure.areEquivalent(S.structure, b) || _ && S.elements.length === 1)
        return !1;
      for (var w = 0, E = S.elements; w < E.length; w++) {
        var I = E[w];
        y.set(I.unit.id, I.indices);
      }
      for (var B = function(O) {
        var V = O.unit;
        if (!n.Unit.isAtomic(V))
          return "continue";
        b.interUnitBonds.getConnectedUnits(V.id).forEach(function(k) {
          var G = y.get(k.unitB);
          (!_ || G) && u.OrderedSet.forEach(O.indices, function(L) {
            k.connectedIndices.includes(L) && k.getEdges(L).forEach(function(R) {
              if (!_ || G && u.OrderedSet.has(G, R.indexB)) {
                var F = b.interUnitBonds.getEdgeIndex(L, V.id, R.indexB, k.unitB);
                g(u.Interval.ofSingleton(F)) && (A = !0);
              }
            });
          });
        });
      }, D = 0, N = S.elements; D < N.length; D++) {
        var I = N[D];
        B(I);
      }
      y.clear();
    }
    return A;
  }
  e.eachInterBond = C;
})(By);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.IntraUnitBondCylinderMeshVisual = e.IntraUnitBondCylinderImpostorVisual = e.IntraUnitBondCylinderVisual = e.IntraUnitBondCylinderParams = void 0;
  var r = Te, t = Le, n = Je(), a = Dt(), i = Re, o = We(), c = Jd, s = Mr, u = Gr, l = By, f = nr(), d = dl, m = hl(), p = Qe(), v = hr, h = u.BondType.is;
  function y(A, M, P, T) {
    var x = A.elements, w = A.bonds, E = w.edgeCount, I = w.a, B = w.b, D = w.edgeProps, N = w.offset, O = D.order, V = D.flags, k = T.sizeFactor, G = T.sizeAspectRatio, L = T.adjustCylinderLength, R = T.aromaticBonds, F = T.includeTypes, U = T.excludeTypes, H = T.multipleBonds, q = H === "off", K = H === "symmetric", Y = u.BondType.fromNames(F), X = u.BondType.fromNames(U), Z = (0, l.ignoreBondType)(
      Y,
      X,
      32
      /* Computed */
    ), J = (0, i.Vec3)(), $ = (0, i.Vec3)(), Q = A.conformation.invariantPosition, W, te = n.StructureElement.Location.create(M, A), oe = n.Bond.Location(M, A, void 0, M, A, void 0), z = M.child;
    if (T.includeParent && z) {
      var j = z.unitMap.get(A.id);
      if (!j)
        throw new Error("expected childUnit to exist");
      W = function(ce) {
        var de = x[I[ce]], me = x[B[ce]];
        return p.SortedArray.has(j.elements, de) && !p.SortedArray.has(j.elements, me);
      };
    }
    var ae = function(ce) {
      return oe.aIndex = I[ce], oe.bIndex = B[ce], P.size.size(oe) * k;
    }, le = function(ce) {
      return te.element = x[I[ce]], P.size.size(te) * k;
    }, ie = function(ce) {
      return te.element = x[B[ce]], P.size.size(te) * k;
    }, re = A.rings, ee = re.elementRingIndices, ne = re.elementAromaticRingIndices, se = R ? A.resonance.delocalizedTriplets : void 0;
    return {
      linkCount: E * 2,
      referencePosition: function(ce) {
        var de, me, he = I[ce], _e = B[ce], Se = se == null ? void 0 : se.getThirdElement(he, _e);
        if (Se !== void 0)
          return Q(x[Se], J);
        he > _e && (de = [_e, he], he = de[0], _e = de[1]), N[he + 1] - N[he] === 1 && (me = [_e, he], he = me[0], _e = me[1]);
        for (var Pe = ne.get(he) || ee.get(he), De = 0, Ee = N[he], Me = N[he + 1]; Ee < Me; ++Ee) {
          var ue = B[Ee];
          if (ue !== _e && ue !== he)
            if (Pe) {
              var pe = ne.get(ue) || ee.get(ue);
              if (!pe)
                continue;
              var Ae = (0, v.arrayIntersectionSize)(Pe, pe);
              Ae > De && (De = Ae, Q(x[ue], J));
            } else
              return Q(x[ue], J);
        }
        return De > 0 ? J : null;
      },
      position: function(ce, de, me) {
        if (Q(x[I[me]], ce), Q(x[B[me]], de), L) {
          var he = le(me), _e = ie(me), Se = Math.min(he, _e) * G, Pe = Math.sqrt(Math.max(0, he * he - Se * Se)) - 0.05, De = Math.sqrt(Math.max(0, _e * _e - Se * Se)) - 0.05;
          if (Pe <= 0.01 && De <= 0.01)
            return;
          i.Vec3.normalize($, i.Vec3.sub($, de, ce)), i.Vec3.scaleAndAdd(ce, ce, $, Pe), i.Vec3.scaleAndAdd(de, de, $, -De);
        }
      },
      style: function(ce) {
        var de = O[ce], me = V[ce];
        if (h(
          me,
          2
          /* MetallicCoordination */
        ) || h(
          me,
          4
          /* HydrogenBond */
        ))
          return 1;
        if (de === 3)
          return q ? 0 : K ? 4 : 5;
        if (R) {
          var he = I[ce], _e = B[ce], Se = ne.get(he), Pe = ne.get(_e), De = Se && Pe ? (0, v.arrayIntersectionSize)(Se, Pe) : 0;
          if (h(
            me,
            16
            /* Aromatic */
          ) || De && !Z) {
            if (De === 2)
              return 8;
            if (De === 1 || se != null && se.getThirdElement(he, _e))
              return 7;
          }
        }
        return de !== 2 || q ? 0 : K ? 2 : 3;
      },
      radius: function(ce) {
        return ae(ce) * G;
      },
      ignore: (0, l.makeIntraBondIgnoreTest)(M, A, T),
      stub: W
    };
  }
  function C(A, M, P, T, x, w) {
    if (!n.Unit.isAtomic(M) || !M.bonds.edgeCount)
      return m.Cylinders.createEmpty(w);
    var E = P.child, I = E == null ? void 0 : E.unitMap.get(M.id);
    if (E && !I)
      return m.Cylinders.createEmpty(w);
    var B = y(M, P, T, x), D = (0, c.createLinkCylinderImpostors)(A, B, x, w), N = D.cylinders, O = D.boundingSphere;
    if (O)
      N.setBoundingSphere(O);
    else if (N.cylinderCount > 0) {
      var V = f.Sphere3D.expand((0, f.Sphere3D)(), (I ?? M).boundary.sphere, 1 * x.sizeFactor);
      N.setBoundingSphere(V);
    }
    return N;
  }
  function S(A, M, P, T, x, w) {
    if (!n.Unit.isAtomic(M) || !M.bonds.edgeCount)
      return a.Mesh.createEmpty(w);
    var E = P.child, I = E == null ? void 0 : E.unitMap.get(M.id);
    if (E && !I)
      return a.Mesh.createEmpty(w);
    var B = y(M, P, T, x), D = (0, c.createLinkCylinderMesh)(A, B, x, w), N = D.mesh, O = D.boundingSphere;
    if (O)
      N.setBoundingSphere(O);
    else if (N.triangleCount > 0) {
      var V = f.Sphere3D.expand((0, f.Sphere3D)(), (I ?? M).boundary.sphere, 1 * x.sizeFactor);
      N.setBoundingSphere(V);
    }
    return N;
  }
  e.IntraUnitBondCylinderParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, s.UnitsMeshParams), s.UnitsCylindersParams), l.BondCylinderParams), { sizeFactor: t.ParamDefinition.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), sizeAspectRatio: t.ParamDefinition.Numeric(2 / 3, { min: 0, max: 3, step: 0.01 }), tryUseImpostor: t.ParamDefinition.Boolean(!0), includeParent: t.ParamDefinition.Boolean(!1) });
  function b(A, M, P, T) {
    return P.tryUseImpostor && T && T.extensions.fragDepth ? g(A) : _(A);
  }
  e.IntraUnitBondCylinderVisual = b;
  function g(A) {
    return (0, s.UnitsCylindersVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.IntraUnitBondCylinderParams),
      createGeometry: C,
      createLocationIterator: l.BondIterator.fromGroup,
      getLoci: l.getIntraBondLoci,
      eachLocation: l.eachIntraBond,
      setUpdateState: function(M, P, T, x, w, E, I) {
        M.createGeometry = P.sizeAspectRatio !== T.sizeAspectRatio || P.linkScale !== T.linkScale || P.linkSpacing !== T.linkSpacing || P.ignoreHydrogens !== T.ignoreHydrogens || P.linkCap !== T.linkCap || P.aromaticScale !== T.aromaticScale || P.aromaticSpacing !== T.aromaticSpacing || P.aromaticDashCount !== T.aromaticDashCount || P.dashCount !== T.dashCount || P.dashScale !== T.dashScale || P.dashCap !== T.dashCap || P.stubCap !== T.stubCap || !(0, o.arrayEqual)(P.includeTypes, T.includeTypes) || !(0, o.arrayEqual)(P.excludeTypes, T.excludeTypes) || P.adjustCylinderLength !== T.adjustCylinderLength || P.aromaticBonds !== T.aromaticBonds || P.multipleBonds !== T.multipleBonds;
        var B = E.group.units[0], D = I.group.units[0];
        n.Unit.isAtomic(B) && n.Unit.isAtomic(D) && (d.IntAdjacencyGraph.areEqual(B.bonds, D.bonds) || (M.createGeometry = !0, M.updateTransform = !0, M.updateColor = !0, M.updateSize = !0));
      },
      mustRecreate: function(M, P, T) {
        return !P.tryUseImpostor || !T;
      }
    }, A);
  }
  e.IntraUnitBondCylinderImpostorVisual = g;
  function _(A) {
    return (0, s.UnitsMeshVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.IntraUnitBondCylinderParams),
      createGeometry: S,
      createLocationIterator: l.BondIterator.fromGroup,
      getLoci: l.getIntraBondLoci,
      eachLocation: l.eachIntraBond,
      setUpdateState: function(M, P, T, x, w, E, I) {
        M.createGeometry = P.sizeFactor !== T.sizeFactor || P.sizeAspectRatio !== T.sizeAspectRatio || P.radialSegments !== T.radialSegments || P.linkScale !== T.linkScale || P.linkSpacing !== T.linkSpacing || P.ignoreHydrogens !== T.ignoreHydrogens || P.linkCap !== T.linkCap || P.aromaticScale !== T.aromaticScale || P.aromaticSpacing !== T.aromaticSpacing || P.aromaticDashCount !== T.aromaticDashCount || P.dashCount !== T.dashCount || P.dashScale !== T.dashScale || P.dashCap !== T.dashCap || P.stubCap !== T.stubCap || !(0, o.arrayEqual)(P.includeTypes, T.includeTypes) || !(0, o.arrayEqual)(P.excludeTypes, T.excludeTypes) || P.adjustCylinderLength !== T.adjustCylinderLength || P.aromaticBonds !== T.aromaticBonds || P.multipleBonds !== T.multipleBonds;
        var B = E.group.units[0], D = I.group.units[0];
        n.Unit.isAtomic(B) && n.Unit.isAtomic(D) && (d.IntAdjacencyGraph.areEqual(B.bonds, D.bonds) || (M.createGeometry = !0, M.updateTransform = !0, M.updateColor = !0, M.updateSize = !0));
      },
      mustRecreate: function(M, P, T) {
        return P.tryUseImpostor && !!T;
      }
    }, A);
  }
  e.IntraUnitBondCylinderMeshVisual = _;
})(lD);
var cD = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.InterUnitBondCylinderMeshVisual = e.InterUnitBondCylinderImpostorVisual = e.InterUnitBondCylinderVisual = e.InterUnitBondCylinderParams = void 0;
  var r = Te, t = Le, n = Je(), a = Dt(), i = Re, o = We(), c = Jd, s = pt, u = Gr, l = By, f = nr(), d = hl(), m = Wg(), p = new n.Bond.ElementBondIterator();
  function v(A, M, P, T) {
    for (p.setElement(M, P, T); p.hasNext; ) {
      var x = p.move();
      return x.otherUnit.conformation.position(x.otherUnit.elements[x.otherIndex], A), A;
    }
    return null;
  }
  var h = (0, i.Vec3)();
  function y(A, M, P) {
    var T = n.StructureElement.Location.create(A), x = n.Bond.Location(A, void 0, void 0, A, void 0, void 0), w = A.interUnitBonds, E = w.edgeCount, I = w.edges, B = P.sizeFactor, D = P.sizeAspectRatio, N = P.adjustCylinderLength, O = P.aromaticBonds, V = P.multipleBonds, k = V === "off", G = V === "symmetric", L = (0, i.Vec3)(), R, F = A.child;
    P.includeParent && F && (R = function(K) {
      var Y = I[K], X = F.unitMap.get(Y.unitA), Z = F.unitMap.get(Y.unitB), J = A.unitMap.get(Y.unitA), $ = J.elements[Y.indexA], Q = A.unitMap.get(Y.unitB), W = Q.elements[Y.indexB];
      return X && m.SortedArray.has(X.elements, $) && (!Z || !m.SortedArray.has(Z.elements, W));
    });
    var U = function(K) {
      var Y = I[K];
      return x.aUnit = A.unitMap.get(Y.unitA), x.aIndex = Y.indexA, x.bUnit = A.unitMap.get(Y.unitB), x.bIndex = Y.indexB, M.size.size(x) * B;
    }, H = function(K) {
      var Y = I[K];
      return T.unit = A.unitMap.get(Y.unitA), T.element = T.unit.elements[Y.indexA], M.size.size(T) * B;
    }, q = function(K) {
      var Y = I[K];
      return T.unit = A.unitMap.get(Y.unitB), T.element = T.unit.elements[Y.indexB], M.size.size(T) * B;
    };
    return {
      linkCount: E,
      referencePosition: function(K) {
        var Y = I[K], X, Z, J, $;
        if (Y.unitA < Y.unitB)
          X = A.unitMap.get(Y.unitA), Z = A.unitMap.get(Y.unitB), J = Y.indexA, $ = Y.indexB;
        else if (Y.unitA > Y.unitB)
          X = A.unitMap.get(Y.unitB), Z = A.unitMap.get(Y.unitA), J = Y.indexB, $ = Y.indexA;
        else
          throw new Error("same units in createInterUnitBondCylinderMesh");
        return v(h, A, X, J) || v(h, A, Z, $);
      },
      position: function(K, Y, X) {
        var Z = I[X], J = A.unitMap.get(Z.unitA), $ = A.unitMap.get(Z.unitB);
        if (J.conformation.position(J.elements[Z.indexA], K), $.conformation.position($.elements[Z.indexB], Y), N) {
          var Q = H(X), W = q(X), te = Math.min(Q, W) * D, oe = Math.sqrt(Math.max(0, Q * Q - te * te)) - 0.05, z = Math.sqrt(Math.max(0, W * W - te * te)) - 0.05;
          if (oe <= 0.01 && z <= 0.01)
            return;
          i.Vec3.normalize(L, i.Vec3.sub(L, Y, K)), i.Vec3.scaleAndAdd(K, K, L, oe), i.Vec3.scaleAndAdd(Y, Y, L, -z);
        }
      },
      style: function(K) {
        var Y = I[K].props.order, X = o.BitFlags.create(I[K].props.flag);
        return u.BondType.is(
          X,
          2
          /* MetallicCoordination */
        ) || u.BondType.is(
          X,
          4
          /* HydrogenBond */
        ) ? 1 : Y === 3 ? k ? 0 : G ? 4 : 5 : O && u.BondType.is(
          X,
          16
          /* Aromatic */
        ) ? 7 : Y !== 2 || k ? 0 : G ? 2 : 3;
      },
      radius: function(K) {
        return U(K) * D;
      },
      ignore: (0, l.makeInterBondIgnoreTest)(A, P),
      stub: R
    };
  }
  function C(A, M, P, T, x) {
    if (!M.interUnitBonds.edgeCount)
      return d.Cylinders.createEmpty(x);
    var w = y(M, P, T), E = (0, c.createLinkCylinderImpostors)(A, w, T, x), I = E.cylinders, B = E.boundingSphere;
    if (B)
      I.setBoundingSphere(B);
    else if (I.cylinderCount > 0) {
      var D = M.child, N = f.Sphere3D.expand((0, f.Sphere3D)(), (D ?? M).boundary.sphere, 1 * T.sizeFactor);
      I.setBoundingSphere(N);
    }
    return I;
  }
  function S(A, M, P, T, x) {
    if (!M.interUnitBonds.edgeCount)
      return a.Mesh.createEmpty(x);
    var w = y(M, P, T), E = (0, c.createLinkCylinderMesh)(A, w, T, x), I = E.mesh, B = E.boundingSphere;
    if (B)
      I.setBoundingSphere(B);
    else if (I.triangleCount > 0) {
      var D = M.child, N = f.Sphere3D.expand((0, f.Sphere3D)(), (D ?? M).boundary.sphere, 1 * T.sizeFactor);
      I.setBoundingSphere(N);
    }
    return I;
  }
  e.InterUnitBondCylinderParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, s.ComplexMeshParams), s.ComplexCylindersParams), l.BondCylinderParams), { sizeFactor: t.ParamDefinition.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), sizeAspectRatio: t.ParamDefinition.Numeric(2 / 3, { min: 0, max: 3, step: 0.01 }), tryUseImpostor: t.ParamDefinition.Boolean(!0), includeParent: t.ParamDefinition.Boolean(!1) });
  function b(A, M, P, T) {
    return P.tryUseImpostor && T && T.extensions.fragDepth ? g(A) : _(A);
  }
  e.InterUnitBondCylinderVisual = b;
  function g(A) {
    return (0, s.ComplexCylindersVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.InterUnitBondCylinderParams),
      createGeometry: C,
      createLocationIterator: l.BondIterator.fromStructure,
      getLoci: l.getInterBondLoci,
      eachLocation: l.eachInterBond,
      setUpdateState: function(M, P, T, x, w, E, I) {
        M.createGeometry = P.sizeAspectRatio !== T.sizeAspectRatio || P.linkScale !== T.linkScale || P.linkSpacing !== T.linkSpacing || P.ignoreHydrogens !== T.ignoreHydrogens || P.linkCap !== T.linkCap || P.aromaticScale !== T.aromaticScale || P.aromaticSpacing !== T.aromaticSpacing || P.aromaticDashCount !== T.aromaticDashCount || P.dashCount !== T.dashCount || P.dashScale !== T.dashScale || P.dashCap !== T.dashCap || P.stubCap !== T.stubCap || !(0, o.arrayEqual)(P.includeTypes, T.includeTypes) || !(0, o.arrayEqual)(P.excludeTypes, T.excludeTypes) || P.adjustCylinderLength !== T.adjustCylinderLength || P.multipleBonds !== T.multipleBonds, E.interUnitBonds !== I.interUnitBonds && (M.createGeometry = !0, M.updateTransform = !0, M.updateColor = !0, M.updateSize = !0);
      },
      mustRecreate: function(M, P, T) {
        return !P.tryUseImpostor || !T;
      }
    }, A);
  }
  e.InterUnitBondCylinderImpostorVisual = g;
  function _(A) {
    return (0, s.ComplexMeshVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.InterUnitBondCylinderParams),
      createGeometry: S,
      createLocationIterator: l.BondIterator.fromStructure,
      getLoci: l.getInterBondLoci,
      eachLocation: l.eachInterBond,
      setUpdateState: function(M, P, T, x, w, E, I) {
        M.createGeometry = P.sizeFactor !== T.sizeFactor || P.sizeAspectRatio !== T.sizeAspectRatio || P.radialSegments !== T.radialSegments || P.linkScale !== T.linkScale || P.linkSpacing !== T.linkSpacing || P.ignoreHydrogens !== T.ignoreHydrogens || P.linkCap !== T.linkCap || P.aromaticScale !== T.aromaticScale || P.aromaticSpacing !== T.aromaticSpacing || P.aromaticDashCount !== T.aromaticDashCount || P.dashCount !== T.dashCount || P.dashScale !== T.dashScale || P.dashCap !== T.dashCap || P.stubCap !== T.stubCap || !(0, o.arrayEqual)(P.includeTypes, T.includeTypes) || !(0, o.arrayEqual)(P.excludeTypes, T.excludeTypes) || P.adjustCylinderLength !== T.adjustCylinderLength || P.multipleBonds !== T.multipleBonds, E.interUnitBonds !== I.interUnitBonds && (M.createGeometry = !0, M.updateTransform = !0, M.updateColor = !0, M.updateSize = !0);
      },
      mustRecreate: function(M, P, T) {
        return P.tryUseImpostor && !!T;
      }
    }, A);
  }
  e.InterUnitBondCylinderMeshVisual = _;
})(cD);
var fA = {}, W0 = {}, dD = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.SpheresBuilder = void 0;
  var r = wr(), t = Ep(), n = new Float32Array([
    -1,
    1,
    -1,
    -1,
    1,
    1,
    1,
    -1
  ]), a = new Uint16Array([
    0,
    1,
    2,
    1,
    3,
    2
  ]), i = r.ChunkedArray.add3, o = r.ChunkedArray.add2, c = r.ChunkedArray.add;
  (function(s) {
    function u(l, f, d) {
      l === void 0 && (l = 2048), f === void 0 && (f = 1024), l *= 4, f *= 4;
      var m = r.ChunkedArray.create(Float32Array, 3, f, d ? d.centerBuffer.ref.value : l), p = r.ChunkedArray.create(Float32Array, 2, f, d ? d.mappingBuffer.ref.value : l), v = r.ChunkedArray.create(Uint32Array, 3, f / 2, d ? d.indexBuffer.ref.value : l / 2), h = r.ChunkedArray.create(Float32Array, 1, f, d ? d.groupBuffer.ref.value : l);
      return {
        add: function(y, C, S, b) {
          for (var g = m.elementCount, _ = 0; _ < 4; ++_)
            i(m, y, C, S), o(p, n[_ * 2], n[_ * 2 + 1]), c(h, b);
          i(v, g + a[0], g + a[1], g + a[2]), i(v, g + a[3], g + a[4], g + a[5]);
        },
        getSpheres: function() {
          var y = r.ChunkedArray.compact(m, !0), C = r.ChunkedArray.compact(p, !0), S = r.ChunkedArray.compact(v, !0), b = r.ChunkedArray.compact(h, !0);
          return t.Spheres.create(y, C, S, b, m.elementCount / 4, d);
        }
      };
    }
    s.create = u;
  })(e.SpheresBuilder || (e.SpheresBuilder = {}));
})(dD);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ElementIterator = e.getSerialElementLoci = e.eachSerialElement = e.getElementLoci = e.eachElement = e.createElementSphereImpostor = e.createElementSphereMesh = e.makeElementIgnoreTest = void 0;
  var r = Re, t = Je(), n = _r, a = Qe(), i = Dt(), o = vc, c = Ca(), s = Xd(), u = on, l = Ep(), f = dD, d = bl, m = nr(), p = r.Vec3.add;
  function v(_, A, M) {
    var P = M.ignoreHydrogens, T = M.traceOnly, x = A.model.atomicHierarchy.derived.atom.atomicNumber, w = t.Unit.isCoarse(A), E = _.child, I = E == null ? void 0 : E.unitMap.get(A.id);
    if (E && !I)
      throw new Error("expected childUnit to exist if child exists");
    if (!(!E && !P && !T))
      return function(B) {
        return !!I && !a.SortedArray.has(I.elements, B) || !w && P && (0, d.isH)(x, B) || T && !(0, d.isTrace)(A, B);
      };
  }
  e.makeElementIgnoreTest = v;
  function h(_, A, M, P, T, x) {
    var w = M.child, E = w == null ? void 0 : w.unitMap.get(A.id);
    if (w && !E)
      return i.Mesh.createEmpty(x);
    for (var I = T.detail, B = T.sizeFactor, D = A.elements, N = D.length, O = N * (0, o.sphereVertexCount)(I), V = c.MeshBuilder.createState(O, O / 2, x), k = (0, r.Vec3)(), G = A.conformation.invariantPosition, L = v(M, A, T), R = t.StructureElement.Location.create(M, A), F = P.size.size, U = (0, r.Vec3)(), H = 0, q = 0, K = 0; K < N; K++)
      if (!(L && L(D[K]))) {
        R.element = D[K], G(D[K], k), p(U, U, k), q += 1, V.currentGroup = K;
        var Y = F(R);
        Y > H && (H = Y), (0, s.addSphere)(V, k, Y * B, I);
      }
    var X = x ? m.Sphere3D.clone(x.boundingSphere) : void 0, Z = c.MeshBuilder.getMesh(V);
    if (q === 0)
      return Z;
    var J;
    return r.Vec3.scale(U, U, 1 / q), X && r.Vec3.distance(U, X.center) / X.radius < 1 ? J = X : J = m.Sphere3D.expand((0, m.Sphere3D)(), (E ?? A).boundary.sphere, H * B + 0.05), Z.setBoundingSphere(J), Z;
  }
  e.createElementSphereMesh = h;
  function y(_, A, M, P, T, x) {
    var w = M.child, E = w == null ? void 0 : w.unitMap.get(A.id);
    if (w && !E)
      return l.Spheres.createEmpty(x);
    for (var I = A.elements, B = I.length, D = f.SpheresBuilder.create(B, B / 2, x), N = (0, r.Vec3)(), O = A.conformation.invariantPosition, V = v(M, A, T), k = t.StructureElement.Location.create(M, A), G = P.size.size, L = (0, r.Vec3)(), R = 0, F = 0, U = 0; U < B; U++)
      if (!(V != null && V(I[U]))) {
        O(I[U], N), D.add(N[0], N[1], N[2], U), p(L, L, N), F += 1, k.element = I[U];
        var H = G(k);
        H > R && (R = H);
      }
    var q = x ? m.Sphere3D.clone(x.boundingSphere) : void 0, K = D.getSpheres();
    if (F === 0)
      return K;
    var Y;
    return r.Vec3.scale(L, L, 1 / F), q && r.Vec3.distance(L, q.center) / q.radius < 1 ? Y = q : Y = m.Sphere3D.expand((0, m.Sphere3D)(), (E ?? A).boundary.sphere, R * T.sizeFactor + 0.05), K.setBoundingSphere(Y), K;
  }
  e.createElementSphereImpostor = y;
  function C(_, A, M) {
    var P = !1;
    if (!t.StructureElement.Loci.is(_))
      return !1;
    var T = A.structure, x = A.group;
    if (!t.Structure.areEquivalent(_.structure, T))
      return !1;
    for (var w = x.elements.length, E = x.unitIndexMap, I = 0, B = _.elements; I < B.length; I++) {
      var D = B[I], N = E.get(D.unit.id);
      if (N !== void 0) {
        var O = N * w;
        if (a.Interval.is(D.indices)) {
          var V = O + a.Interval.start(D.indices), k = O + a.Interval.end(D.indices);
          M(a.Interval.ofBounds(V, k)) && (P = !0);
        } else
          for (var G = 0, L = D.indices.length; G < L; G++) {
            for (var V = D.indices[G], R = G + 1; R < L && D.indices[R] === V; )
              R++;
            G = R - 1;
            var k = D.indices[G];
            P = M(a.Interval.ofRange(O + V, O + k)) || P;
          }
      }
    }
    return P;
  }
  e.eachElement = C;
  function S(_, A, M) {
    var P = _.objectId, T = _.instanceId, x = _.groupId;
    if (M === P) {
      var w = A.structure, E = A.group, I = E.units[T], B = a.OrderedSet.ofSingleton(x);
      return t.StructureElement.Loci(w.target, [{ unit: I, indices: B }]);
    }
    return n.EmptyLoci;
  }
  e.getElementLoci = S;
  function b(_, A, M) {
    var P = !1;
    if (!t.StructureElement.Loci.is(_) || !t.Structure.areEquivalent(_.structure, A))
      return !1;
    for (var T = A.serialMapping.cumulativeUnitElementCount, x = 0, w = _.elements; x < w.length; x++) {
      var E = w[x], I = A.unitIndexMap.get(E.unit.id);
      if (I !== void 0)
        if (a.Interval.is(E.indices)) {
          var B = T[I] + a.Interval.start(E.indices), D = T[I] + a.Interval.end(E.indices);
          M(a.Interval.ofBounds(B, D)) && (P = !0);
        } else
          for (var N = 0, O = E.indices.length; N < O; N++) {
            var V = T[I] + E.indices[N];
            M(a.Interval.ofSingleton(V)) && (P = !0);
          }
    }
    return P;
  }
  e.eachSerialElement = b;
  function g(_, A, M) {
    var P = _.objectId, T = _.groupId;
    if (M === P) {
      var x = A.serialMapping, w = x.unitIndices, E = x.cumulativeUnitElementCount, I = w[T], B = A.units[I], D = T - E[I], N = a.OrderedSet.ofSingleton(D);
      return t.StructureElement.Loci(A, [{ unit: B, indices: N }]);
    }
    return n.EmptyLoci;
  }
  e.getSerialElementLoci = g, function(_) {
    function A(P) {
      var T = P.group, x = P.structure, w = T.elements.length, E = T.units.length, I = t.StructureElement.Location.create(x), B = function(D, N) {
        var O = T.units[N];
        return I.unit = O, I.element = O.elements[D], I;
      };
      return (0, u.LocationIterator)(w, E, 1, B);
    }
    _.fromGroup = A;
    function M(P) {
      var T = P.units, x = P.elementCount, w = x, E = 1, I = P.serialMapping, B = I.unitIndices, D = I.elementIndices, N = t.StructureElement.Location.create(P), O = function(V) {
        return N.unit = T[B[V]], N.element = D[V], N;
      };
      return (0, u.LocationIterator)(w, E, 1, O, !0);
    }
    _.fromStructure = M;
  }(e.ElementIterator || (e.ElementIterator = {}));
})(W0);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ElementSphereMeshVisual = e.ElementSphereImpostorVisual = e.ElementSphereVisual = e.ElementSphereParams = void 0;
  var r = Te, t = Le, n = Mr, a = W0, i = Xt;
  e.ElementSphereParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, n.UnitsMeshParams), n.UnitsSpheresParams), { sizeFactor: t.ParamDefinition.Numeric(1, { min: 0, max: 10, step: 0.1 }), detail: t.ParamDefinition.Numeric(0, { min: 0, max: 3, step: 1 }, i.BaseGeometry.CustomQualityParamInfo), ignoreHydrogens: t.ParamDefinition.Boolean(!1), traceOnly: t.ParamDefinition.Boolean(!1), tryUseImpostor: t.ParamDefinition.Boolean(!0) });
  function o(u, l, f, d) {
    return f.tryUseImpostor && d && d.extensions.fragDepth ? c(u) : s(u);
  }
  e.ElementSphereVisual = o;
  function c(u) {
    return (0, n.UnitsSpheresVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.ElementSphereParams),
      createGeometry: a.createElementSphereImpostor,
      createLocationIterator: a.ElementIterator.fromGroup,
      getLoci: a.getElementLoci,
      eachLocation: a.eachElement,
      setUpdateState: function(l, f, d) {
        l.createGeometry = f.ignoreHydrogens !== d.ignoreHydrogens || f.traceOnly !== d.traceOnly;
      },
      mustRecreate: function(l, f, d) {
        return !f.tryUseImpostor || !d;
      }
    }, u);
  }
  e.ElementSphereImpostorVisual = c;
  function s(u) {
    return (0, n.UnitsMeshVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.ElementSphereParams),
      createGeometry: a.createElementSphereMesh,
      createLocationIterator: a.ElementIterator.fromGroup,
      getLoci: a.getElementLoci,
      eachLocation: a.eachElement,
      setUpdateState: function(l, f, d) {
        l.createGeometry = f.sizeFactor !== d.sizeFactor || f.detail !== d.detail || f.ignoreHydrogens !== d.ignoreHydrogens || f.traceOnly !== d.traceOnly;
      },
      mustRecreate: function(l, f, d) {
        return f.tryUseImpostor && !!d;
      }
    }, u);
  }
  e.ElementSphereMeshVisual = s;
})(fA);
var mA = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ChargeTextVisual = e.ChargeTextParams = void 0;
  var r = Te, t = Le, n = Je(), a = H0, i = pt, o = W0, c = Oa, s = Re;
  e.ChargeTextParams = (0, r.__assign)((0, r.__assign)({}, i.ComplexTextParams), { sizeFactor: t.ParamDefinition.Numeric(0.2, { min: 0, max: 10, step: 0.1 }), background: t.ParamDefinition.Boolean(!1), backgroundMargin: t.ParamDefinition.Numeric(0, { min: 0, max: 1, step: 0.01 }), backgroundColor: t.ParamDefinition.Color(c.ColorNames.black), backgroundOpacity: t.ParamDefinition.Numeric(0.5, { min: 0, max: 1, step: 0.01 }), borderWidth: t.ParamDefinition.Numeric(0.25, { min: 0, max: 0.5, step: 0.01 }), level: t.ParamDefinition.Select("element", [
    ["element", "Element"]
  ], { isEssential: !0 }), chainScale: t.ParamDefinition.Numeric(10, { min: 0, max: 20, step: 0.1 }), residueScale: t.ParamDefinition.Numeric(1, { min: 0, max: 20, step: 0.1 }), elementScale: t.ParamDefinition.Numeric(2, { min: 0, max: 20, step: 0.1 }), attachment: t.ParamDefinition.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: t.ParamDefinition.Boolean(!0), tetherLength: t.ParamDefinition.Numeric(0.2, { min: 0, max: 5, step: 0.1 }), tetherBaseWidth: t.ParamDefinition.Numeric(0, { min: 0, max: 1, step: 0.01 }) });
  function u(m) {
    return (0, i.ComplexTextVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.ChargeTextParams),
      createGeometry: l,
      createLocationIterator: o.ElementIterator.fromStructure,
      getLoci: o.getSerialElementLoci,
      eachLocation: o.eachSerialElement,
      setUpdateState: function(p, v, h) {
        p.createGeometry = v.level !== h.level || v.level === "element" && v.elementScale !== h.elementScale;
      }
    }, m);
  }
  e.ChargeTextVisual = u;
  function l(m, p, v, h, y) {
    return v.size.size = function() {
      return 1;
    }, v.color.color = function(C) {
      if (n.StructureElement.Location.is(C) && n.Unit.isAtomic(C.unit)) {
        var S = n.StructureProperties.atom.pdbx_formal_charge, b = S(C);
        if (b > 0)
          return c.ColorNames.red;
        if (b < 0)
          return c.ColorNames.blue;
      }
      return c.ColorNames.white;
    }, h.sizeFactor = 0.2, d(m, p, v, h, y);
  }
  var f = (0, s.Vec3)();
  function d(m, p, v, h, y) {
    for (var C = n.StructureElement.Location.create(p), S = p.units, b = p.serialMapping, g = n.StructureProperties.atom.pdbx_formal_charge, _ = b.cumulativeUnitElementCount, A = p.elementCount, M = a.TextBuilder.create(h, A, A / 2, y), P = !1, T = 0, x = S.length; T < x; ++T) {
      var w = S[T], E = w.conformation.position, I = w.elements;
      C.unit = w;
      for (var B = _[T], D = 0, N = I.length; D < N; D++) {
        C.element = I[D];
        var O = g(C);
        if (O !== 0) {
          E(C.element, f);
          var V = "".concat(O > 0 ? "+" : "").concat(O);
          M.add(
            V,
            f[0],
            f[1],
            f[2],
            // sizeTheme.size(l),
            0,
            // elementScale,
            5,
            B + D
          ), P = !0;
        }
      }
      if (!P) {
        var k = p.boundary.sphere.center;
        M.add(
          "",
          k[0],
          k[1],
          k[2],
          // sizeTheme.size(l),
          0,
          // elementScale,
          0,
          B + 1
        );
      }
    }
    return M.getText();
  }
})(mA);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.BallAndStickRepresentationProvider = e.BallAndStickRepresentation = e.getBallAndStickParams = e.BallAndStickParams = void 0;
  var r = Te, t = lD, n = cD, a = fA, i = Le, o = $0(), c = oA(), s = Ss(), u = Wt, l = qt, f = Xt, d = mA, m = {
    "element-sphere": function(h, y) {
      return (0, o.UnitsRepresentation)("Element sphere", h, y, a.ElementSphereVisual);
    },
    "intra-bond": function(h, y) {
      return (0, o.UnitsRepresentation)("Intra-unit bond cylinder", h, y, t.IntraUnitBondCylinderVisual);
    },
    "inter-bond": function(h, y) {
      return (0, c.ComplexRepresentation)("Inter-unit bond cylinder", h, y, n.InterUnitBondCylinderVisual);
    },
    "charge-text": function(h, y) {
      return (0, c.ComplexRepresentation)("Charge Text", h, y, d.ChargeTextVisual);
    }
  };
  e.BallAndStickParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.ElementSphereParams), { traceOnly: i.ParamDefinition.Boolean(!1, { isHidden: !0 }) }), t.IntraUnitBondCylinderParams), n.InterUnitBondCylinderParams), { includeParent: i.ParamDefinition.Boolean(!1), unitKinds: (0, l.getUnitKindsParam)(["atomic"]), sizeFactor: i.ParamDefinition.Numeric(0.2, { min: 0.01, max: 10, step: 0.01 }), sizeAspectRatio: i.ParamDefinition.Numeric(0.5, { min: 0.01, max: 3, step: 0.01 }), visuals: i.ParamDefinition.MultiSelect(["element-sphere", "intra-bond", "inter-bond", "charge-text"], i.ParamDefinition.objectToOptions(m)), bumpFrequency: i.ParamDefinition.Numeric(0, { min: 0, max: 10, step: 0.1 }, f.BaseGeometry.ShadingCategory) });
  function p(h, y) {
    return i.ParamDefinition.clone(e.BallAndStickParams);
  }
  e.getBallAndStickParams = p;
  function v(h, y) {
    return u.Representation.createMulti("Ball & Stick", h, y, s.StructureRepresentationStateBuilder, m);
  }
  e.BallAndStickRepresentation = v, e.BallAndStickRepresentationProvider = (0, s.StructureRepresentationProvider)({
    name: "ball-and-stick",
    label: "Ball & Stick",
    description: "Displays atoms as spheres and bonds as cylinders.",
    factory: v,
    getParams: p,
    defaultValues: i.ParamDefinition.getDefaultValues(e.BallAndStickParams),
    defaultColorTheme: { name: "element-symbol" },
    defaultSizeTheme: { name: "physical" },
    isApplicable: function(h) {
      return h.elementCount > 0;
    },
    getData: function(h, y) {
      return y.includeParent ? h.asParent() : h;
    },
    mustRecreate: function(h, y) {
      return h.includeParent !== y.includeParent;
    }
  });
})(sD);
Object.defineProperty(Iy, "__esModule", { value: !0 });
Iy.BallAndStickRepr = void 0;
var Im = Te, HT = sD;
Iy.BallAndStickRepr = {
  create: function(e, r, t) {
    var n;
    return (0, Im.__awaiter)(this, void 0, void 0, function() {
      var a;
      return (0, Im.__generator)(this, function(i) {
        switch (i.label) {
          case 0:
            return a = HT.BallAndStickRepresentationProvider.factory(r, HT.BallAndStickRepresentationProvider.getParams), a.setTheme(t ?? {
              color: r.colorThemeRegistry.create("element-symbol", {
                structure: e
              }),
              size: r.sizeThemeRegistry.create("uniform", {
                structure: e
              })
            }), [4, a.createOrUpdate((0, Im.__assign)((0, Im.__assign)({}, HT.BallAndStickRepresentationProvider.defaultValues), { aromaticBonds: ((n = e.model) === null || n === void 0 ? void 0 : n.sourceData.kind) === "mmCIF", quality: "auto", visuals: r.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"] }), e).run()];
          case 1:
            return i.sent(), [2, a];
        }
      });
    });
  },
  update: function(e, r, t, n) {
    return (0, Im.__awaiter)(this, void 0, void 0, function() {
      return (0, Im.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return e.setTheme(n ?? {
              color: t.colorThemeRegistry.create("element-symbol", {
                structure: r
              }),
              size: t.sizeThemeRegistry.create("uniform", {
                structure: r
              })
            }), [4, e.createOrUpdate({
              visuals: t.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"]
            }, r).run()];
          case 1:
            return a.sent(), [
              2
              /*return*/
            ];
        }
      });
    });
  }
};
var vA = {}, Yv = {}, wo = {};
Object.defineProperty(wo, "__esModule", { value: !0 });
wo.ShapeRepresentation = void 0;
var UN = Te, zN = Kd(), e_ = Wt, Hu = ui(), Q2e = cl, GN = Si, Z2e = Pc(), qN = Vp, J2e = na, e_e = _n, HN = We(), r_e = ru(), t_e = Tc(), jT = _r, jf = Qe(), zl = gl, n_e = Kr, a_e = Le, i_e = Zt;
function o_e(e, r, t) {
  t === void 0 && (t = {});
  var n = 0, a = new Q2e.Subject(), i = e_.Representation.createState(), o = (0, GN.getNextMaterialId)(), c = [], s, u, l = -1, f = Z2e.Theme.createEmpty(), d = a_e.ParamDefinition.getDefaultValues(r.Params), m, p, v;
  t.modifyState && e_.Representation.updateState(i, t.modifyState(i));
  var h = qN.VisualUpdateState.create();
  function y(b, g) {
    qN.VisualUpdateState.reset(h), !(!g && !u) && (g && !u ? h.createNew = !0 : g && u && g.id === u.id || (g && u && g.id !== u.id ? (h.updateTransform = !0, h.createGeometry = !0) : g && console.warn("unexpected state")), h.updateTransform && (h.updateColor = !0, h.updateSize = !0), h.createGeometry && (h.updateColor = !0, h.updateSize = !0));
  }
  function C(b, g) {
    var _ = this;
    return b === void 0 && (b = {}), t.modifyProps && (b = t.modifyProps(b)), n_e.Task.create("ShapeRepresentation.create", function(A) {
      return (0, UN.__awaiter)(_, void 0, void 0, function() {
        var M, P, T, x, w, E, I, B;
        return (0, UN.__generator)(this, function(D) {
          switch (D.label) {
            case 0:
              return M = Object.assign(d, b), g ? [4, e(A, g, M, u)] : [3, 2];
            case 1:
              return T = D.sent(), [3, 3];
            case 2:
              T = void 0, D.label = 3;
            case 3:
              if (P = T, y(b, P), P && (u = P, Object.assign(f, Hu.Shape.getTheme(u))), h.createNew)
                c.length = 0, p = Hu.Shape.groupIterator(u), x = Hu.Shape.createTransform(u.transforms), w = r.createValues(u.geometry, x, p, f, M), E = r.createRenderableState(M), t.modifyState && Object.assign(E, t.modifyState(E)), e_.Representation.updateState(i, E), s = (0, GN.createRenderObject)(u.geometry.kind, w, E, o), s && c.push(s), v = r.createPositionIterator(u.geometry, s.values);
              else {
                if (!s)
                  throw new Error("expected renderObject to be available");
                h.updateTransform && (Hu.Shape.createTransform(u.transforms, s.values), p = Hu.Shape.groupIterator(u), I = p.instanceCount, B = p.groupCount, (0, J2e.createMarkers)(I * B, s.values)), h.createGeometry && (HN.ValueCell.updateIfChanged(s.values.drawCount, zN.Geometry.getDrawCount(u.geometry)), HN.ValueCell.updateIfChanged(s.values.uVertexCount, zN.Geometry.getVertexCount(u.geometry))), (h.updateTransform || h.createGeometry) && (r.updateBoundingSphere(s.values, u.geometry), v = r.createPositionIterator(u.geometry, s.values)), h.updateColor && (0, r_e.createColors)(p, v, f.color, s.values), h.updateSize && "uSize" in s.values && (0, t_e.createSizes)(p, f.size, s.values), r.updateValues(s.values, M), r.updateRenderableState(s.state, M);
              }
              return d = M, (h.createGeometry || h.createNew) && (l += 1), a.next(n++), [
                2
                /*return*/
              ];
          }
        });
      });
    });
  }
  function S(b, g) {
    return (0, jT.isEveryLoci)(b) || Hu.Shape.isLoci(b) && b.shape === u ? g(jf.Interval.ofBounds(0, u.groupCount * u.transforms.length)) : u_e(b, u, g);
  }
  return {
    label: "Shape geometry",
    get groupCount() {
      return p ? p.count : 0;
    },
    get props() {
      return d;
    },
    get params() {
      return m;
    },
    get state() {
      return i;
    },
    get theme() {
      return f;
    },
    renderObjects: c,
    get geometryVersion() {
      return l;
    },
    updated: a,
    createOrUpdate: C,
    getLoci: function(b) {
      if (b === void 0)
        return Hu.Shape.Loci(u);
      var g = b.objectId, _ = b.groupId, A = b.instanceId;
      return s && s.id === g ? Hu.ShapeGroup.Loci(u, [{ ids: jf.OrderedSet.ofSingleton(_), instance: A }]) : jT.EmptyLoci;
    },
    mark: function(b, g) {
      if (!e_e.MarkerActions.is(i.markerActions, g))
        return !1;
      if (Hu.ShapeGroup.isLoci(b) || Hu.Shape.isLoci(b)) {
        if (b.shape !== u)
          return !1;
      } else if (!(0, jT.isEveryLoci)(b))
        return !1;
      return zl.Visual.mark(s, b, g, S);
    },
    setState: function(b) {
      t.modifyState && (b = t.modifyState(b)), s && (b.visible !== void 0 && zl.Visual.setVisibility(s, b.visible), b.alphaFactor !== void 0 && zl.Visual.setAlphaFactor(s, b.alphaFactor), b.pickable !== void 0 && zl.Visual.setPickable(s, b.pickable), b.colorOnly !== void 0 && zl.Visual.setColorOnly(s, b.colorOnly), b.overpaint !== void 0 && zl.Visual.setOverpaint(s, b.overpaint, S, !0), b.transparency !== void 0 && zl.Visual.setTransparency(s, b.transparency, S, !0), b.substance !== void 0 && zl.Visual.setSubstance(s, b.substance, S, !0), b.transform !== void 0 && zl.Visual.setTransform(s, b.transform)), e_.Representation.updateState(i, b);
    },
    setTheme: function(b) {
      i_e.isDebugMode && console.warn("The `ShapeRepresentation` theme is fixed to `ShapeGroupColorTheme` and `ShapeGroupSizeTheme`. Colors are taken from `Shape.getColor` and sizes from `Shape.getSize`");
    },
    destroy: function() {
      c.length = 0, s && (s.state.disposed = !0, s = void 0);
    }
  };
}
wo.ShapeRepresentation = o_e;
function u_e(e, r, t) {
  if (!Hu.ShapeGroup.isLoci(e) || e.shape !== r)
    return !1;
  for (var n = !1, a = r.groupCount, i = e.groups, o = 0, c = i; o < c.length; o++) {
    var s = c[o], u = s.ids, l = s.instance;
    if (jf.Interval.is(u)) {
      var f = l * a + jf.Interval.start(u), d = l * a + jf.Interval.end(u);
      t(jf.Interval.ofBounds(f, d)) && (n = !0);
    } else
      for (var m = 0, p = u.length; m < p; m++) {
        var v = l * a + u[m];
        t(jf.Interval.ofSingleton(v)) && (n = !0);
      }
  }
  return n;
}
var X0 = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.dihedralLabel = e.angleLabel = e.distanceLabel = e.elementLabel = e._bundleLabel = e.bundleLabel = e.bondLabel = e.structureElementLociLabelMany = e.structureElementStatsLabel = e.lociLabel = e.DefaultLabelOptions = void 0;
  var r = Te, t = Je(), n = _r, a = Qe(), i = cs, o = Re, c = kn, s = F0;
  e.DefaultLabelOptions = {
    granularity: "element",
    condensed: !1,
    reverse: !1,
    countsOnly: !1,
    hidePrefix: !1,
    htmlStyling: !0
  };
  function u(x, w) {
    switch (w === void 0 && (w = {}), x.kind) {
      case "structure-loci":
        return x.structure.models.map(function(k) {
          return k.entry;
        }).filter(function(k) {
          return !!k;
        }).join(", ");
      case "element-loci":
        return m(t.StructureElement.Stats.ofLoci(x), w);
      case "bond-loci":
        var E = x.bonds[0];
        return E ? h(E) : "";
      case "shape-loci":
        return x.shape.name;
      case "group-loci":
        var I = x.groups[0];
        return I ? x.shape.getLabel(a.OrderedSet.start(I.ids), I.instance) : "";
      case "every-loci":
        return "Everything";
      case "empty-loci":
        return "Nothing";
      case "data-loci":
        return x.getLabel();
      case "volume-loci":
        return x.volume.label || "Volume";
      case "isosurface-loci":
        return [
          "".concat(x.volume.label || "Volume"),
          "Isosurface at ".concat(s.Volume.IsoValue.toString(x.isoValue))
        ].join(" | ");
      case "cell-loci":
        var B = a.OrderedSet.size(x.indices), D = a.OrderedSet.start(x.indices), N = s.Volume.IsoValue.absolute(x.volume.grid.cells.data[D]), O = s.Volume.IsoValue.toRelative(N, x.volume.grid.stats), V = [
          "".concat(x.volume.label || "Volume"),
          "".concat(B === 1 ? "Cell #".concat(D) : "".concat(B, " Cells"))
        ];
        return B === 1 && V.push("".concat(s.Volume.IsoValue.toString(N), " (").concat(s.Volume.IsoValue.toString(O), ")")), V.join(" | ");
    }
  }
  e.lociLabel = u;
  function l(x, w) {
    return x === 1 ? "1 ".concat(w) : "".concat(x, " ").concat(w, "s");
  }
  function f(x, w, E, I, B, D) {
    return "".concat(S(w, {
      granularity: E,
      hidePrefix: I,
      reverse: B,
      condensed: D
    }), " <small>[+ ").concat(l(x - 1, "other ".concat((0, i.capitalize)(E))), "]</small>");
  }
  function d(x) {
    var w = x.elements, E = x.model, I = E.atomicHierarchy, B = I.chainAtomSegments, D = I.residueAtomSegments, N = B.offsets[B.index[w[0]]], O = B.offsets[B.index[w[w.length - 1]] + 1] - 1;
    return D.index[O] - D.index[N] + 1;
  }
  function m(x, w) {
    w === void 0 && (w = {});
    var E = (0, r.__assign)((0, r.__assign)({}, e.DefaultLabelOptions), w), I = v(x, E.countsOnly, E.hidePrefix, E.condensed, E.reverse);
    return E.htmlStyling ? I : (0, i.stripTags)(I);
  }
  e.structureElementStatsLabel = m;
  function p(x, w) {
    w === void 0 && (w = {});
    for (var E = t.StructureElement.Stats.create(), I = 0, B = x; I < B.length; I++) {
      var D = B[I];
      t.StructureElement.Stats.add(E, E, t.StructureElement.Stats.ofLoci(D));
    }
    return m(E, w);
  }
  e.structureElementLociLabelMany = p;
  function v(x, w, E, I, B) {
    w === void 0 && (w = !1), E === void 0 && (E = !1), I === void 0 && (I = !1), B === void 0 && (B = !1);
    var D = x.structureCount, N = x.chainCount, O = x.residueCount, V = x.conformationCount, k = x.elementCount;
    if (!w && k === 1 && O === 0 && N === 0)
      return S(x.firstElementLoc, {
        hidePrefix: E,
        condensed: I,
        granularity: "element",
        reverse: B
      }, !0);
    if (!w && k === 0 && O === 1 && N === 0)
      return S(x.firstResidueLoc, {
        hidePrefix: E,
        condensed: I,
        granularity: "residue",
        reverse: B
      }, !0);
    if (!w && k === 0 && O === 0 && N === 1) {
      var G = x.firstChainLoc.unit, L = t.Unit.isAtomic(G) && d(G) === 1 || t.Unit.Traits.is(
        G.traits,
        1
        /* MultiChain */
      ) ? "residue" : "chain";
      return S(x.firstChainLoc, {
        hidePrefix: E,
        condensed: I,
        granularity: L,
        reverse: B
      }, !0);
    } else if (w) {
      var R = [];
      return D > 0 && R.push(l(D, "Structure")), N > 0 && R.push(l(N, "Chain")), O > 0 && R.push(l(O, "Residue")), V > 0 && R.push(l(V, "Conformation")), k > 0 && R.push(l(k, "Element")), R.join("<small> + </small>");
    } else {
      var R = [];
      return D > 0 && R.push(D === 1 ? S(x.firstStructureLoc, {
        hidePrefix: E,
        condensed: I,
        granularity: "structure",
        reverse: B
      }, !0) : f(D, x.firstStructureLoc, "structure", E, B, I)), N > 0 && (R.push(N === 1 ? S(x.firstChainLoc, {
        condensed: I,
        granularity: "chain",
        hidePrefix: E,
        reverse: B
      }, !0) : f(N, x.firstChainLoc, "chain", E, B, I)), E = !0), O > 0 && (R.push(O === 1 ? S(x.firstResidueLoc, {
        condensed: I,
        granularity: "residue",
        hidePrefix: E,
        reverse: B
      }, !0) : f(O, x.firstResidueLoc, "residue", E, B, I)), E = !0), V > 0 && (R.push(V === 1 ? S(x.firstConformationLoc, {
        condensed: I,
        granularity: "conformation",
        hidePrefix: E,
        reverse: B
      }, !0) : f(V, x.firstConformationLoc, "conformation", E, B, I)), E = !0), k > 0 && R.push(k === 1 ? S(x.firstElementLoc, {
        condensed: I,
        granularity: "element",
        hidePrefix: E,
        reverse: B
      }, !0) : f(k, x.firstElementLoc, "element", E, B, I)), R.join("<small> + </small>");
    }
  }
  function h(x, w) {
    return w === void 0 && (w = {}), y({
      loci: [
        t.StructureElement.Loci(x.aStructure, [
          { unit: x.aUnit, indices: a.OrderedSet.ofSingleton(x.aIndex) }
        ]),
        t.StructureElement.Loci(x.bStructure, [
          { unit: x.bUnit, indices: a.OrderedSet.ofSingleton(x.bIndex) }
        ])
      ]
    }, w);
  }
  e.bondLabel = h;
  function y(x, w) {
    w === void 0 && (w = {});
    var E = (0, r.__assign)((0, r.__assign)({}, e.DefaultLabelOptions), w), I = C(x, E);
    return E.htmlStyling ? I : (0, i.stripTags)(I);
  }
  e.bundleLabel = y;
  function C(x, w) {
    for (var E = w.granularity, I = w.hidePrefix, B = w.reverse, D = w.condensed, N = !0, O = 0, V = x.loci; O < V.length; O++) {
      var k = V[O];
      if (!t.StructureElement.Loci.is(k) || t.StructureElement.Loci.size(k) !== 1) {
        N = !1;
        break;
      }
    }
    if (N) {
      var G = x.loci.map(function(X) {
        var Z = X.elements[0], J = Z.unit, $ = Z.indices;
        return t.StructureElement.Location.create(X.structure, J, J.elements[a.OrderedSet.start($)]);
      }), L = G.map(function(X) {
        return g(X, E, I, B || D);
      });
      if (D)
        return L.map(function(X) {
          return X[0].replace(/\[.*\]/g, "").trim();
        }).filter(function(X) {
          return !!X;
        }).join(" — ");
      for (var R = 0, F = 0, U = Math.min.apply(Math, L.map(function(X) {
        return X.length;
      })) - 1; F < U; ++F) {
        for (var H = !0, q = 1, K = L.length; q < K; ++q)
          if (L[0][F] !== L[q][F]) {
            H = !1;
            break;
          }
        if (H)
          R += 1;
        else
          break;
      }
      if (R > 0) {
        for (var Y = [L[0].join(" | ")], q = 1, K = L.length; q < K; ++q)
          Y.push(L[q].slice(R).filter(function(J) {
            return !!J;
          }).join(" | "));
        return Y.join(" — ");
      } else
        return L.map(function(X) {
          return X.filter(function(Z) {
            return !!Z;
          }).join(" | ");
        }).filter(function(X) {
          return !!X;
        }).join("</br>");
    } else {
      var L = x.loci.map(function(Z) {
        return u(Z, w);
      });
      return L.filter(function(Z) {
        return !!Z;
      }).join(D ? " — " : "</br>");
    }
  }
  e._bundleLabel = C;
  function S(x, w, E) {
    var I, B;
    w === void 0 && (w = {});
    var D = (0, r.__assign)((0, r.__assign)({}, e.DefaultLabelOptions), w), N = g(x, D.granularity, D.hidePrefix, D.reverse || D.condensed), O = (D.condensed ? (B = (I = N[0]) === null || I === void 0 ? void 0 : I.replace(/\[.*\]/g, "").trim()) !== null && B !== void 0 ? B : "" : N.filter(function(V) {
      return !!V;
    }).join(" | ")) + (E ? b(t.StructureProperties.atom.B_iso_or_equiv(x)) : "");
    return D.htmlStyling ? O : (0, i.stripTags)(O);
  }
  e.elementLabel = S;
  function b(x) {
    if (x >= 90)
      return "<div><small>Plddt ".concat(x, " (Very high)</small></div>");
    if (x < 90 && x >= 70)
      return "<div><small>Plddt ".concat(x, " (Confident)</small></div>");
    if (x < 70 && x >= 50)
      return "<div><small>Plddt ".concat(x, " (Low)</small></div>");
    if (x < 50)
      return "<div><small>Plddt ".concat(x, " (Very low)</small></div>");
  }
  function g(x, w, E, I) {
    w === void 0 && (w = "element"), E === void 0 && (E = !1), I === void 0 && (I = !1);
    var B = [];
    if (!E) {
      var D = x.unit.model.entry;
      D.length > 30 && (D = D.substr(0, 27) + "…"), B.push("<small>".concat(D, "</small>")), w !== "structure" && (B.push("<small>Model ".concat(x.unit.model.modelNum, "</small>")), B.push("<small>Instance ".concat(x.unit.conformation.operator.name, "</small>")));
    }
    return t.Unit.isAtomic(x.unit) ? B.push.apply(B, _(x, w, I)) : t.Unit.isCoarse(x.unit) ? B.push.apply(B, A(x, w)) : B.push("Unknown"), I ? B.reverse() : B;
  }
  function _(x, w, E) {
    E === void 0 && (E = !1);
    var I = t.StructureElement.Location.residueIndex(x), B = t.StructureProperties.chain.label_asym_id(x), D = t.StructureProperties.chain.auth_asym_id(x), N = x.unit.model.atomicHierarchy.residues.label_seq_id.valueKind(I) === 0, O = t.StructureProperties.residue.label_seq_id(x), V = t.StructureProperties.residue.auth_seq_id(x), k = t.StructureProperties.residue.pdbx_PDB_ins_code(x), G = t.StructureProperties.atom.label_comp_id(x), L = t.StructureProperties.atom.label_atom_id(x), R = t.StructureProperties.atom.label_alt_id(x), F = t.StructureProperties.atom.occupancy(x), U = t.StructureProperties.atom.id(x), H = t.StructureProperties.residue.microheterogeneityCompIds(x), q = w === "residue" && H.length > 1 ? "(".concat(H.join("|"), ")") : G, K = [];
    switch (w) {
      case "element":
        K.push("<b>".concat(L, " ").concat(U, "</b>").concat(R ? "%".concat(R) : ""));
      case "conformation":
        w === "conformation" && R && K.push("<small>Conformation</small> <b>".concat(R, "</b>"));
      case "residue":
        var Y = O === V && N ? O : V;
        K.push("<b>".concat(q, " ").concat(Y, "</b>").concat(Y !== O ? " <small>[auth</small> <b>".concat(O, "</b><small>]</small>") : "", "<b>").concat(k || "", "</b>"));
      case "chain":
        B === D ? K.push("<b>".concat(B, "</b>")) : w === "chain" && t.Unit.Traits.is(
          x.unit.traits,
          1
          /* MultiChain */
        ) ? K.push("<small>[auth</small> <b>".concat(D, "</b><small>]</small>")) : K.push("<b>".concat(B, "</b> <small>[auth</small> <b>").concat(D, "</b><small>]</small>"));
    }
    return K.length > 0 && F !== 1 && !E && (K[0] = "".concat(K[0], " <small>[occupancy</small> <b>").concat(Math.round(100 * F) / 100, "</b><small>]</small>")), K.reverse();
  }
  function A(x, w) {
    var E = t.StructureProperties.coarse.asym_id(x), I = t.StructureProperties.coarse.seq_id_begin(x), B = t.StructureProperties.coarse.seq_id_end(x), D = [];
    switch (w) {
      case "element":
      case "conformation":
      case "residue":
        if (I === B) {
          var N = t.StructureProperties.coarse.entityKey(x), O = x.unit.model.sequence.byEntityKey[N], V = O.sequence.compId.value(I - 1);
          D.push("<b>".concat(V, " ").concat(I, "</b>"));
        } else
          D.push("<b>".concat(I, "-").concat(B, "</b>"));
      case "chain":
        D.push("<b>".concat(E, "</b>"));
    }
    return D.reverse();
  }
  function M(x, w) {
    w === void 0 && (w = {});
    var E = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, e.DefaultLabelOptions), { measureOnly: !1, unitLabel: "Å" }), w), I = x.loci.map(function(V) {
      return n.Loci.getCenter(V);
    }), B = I[0], D = I[1], N = "".concat(o.Vec3.distance(B, D).toFixed(2), " ").concat(E.unitLabel);
    if (E.measureOnly)
      return N;
    var O = y(x, E);
    return E.condensed ? "".concat(N, " | ").concat(O) : "Distance ".concat(N, "</br>").concat(O);
  }
  e.distanceLabel = M;
  function P(x, w) {
    w === void 0 && (w = {});
    var E = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, e.DefaultLabelOptions), { measureOnly: !1 }), w), I = x.loci.map(function(L) {
      return n.Loci.getCenter(L);
    }), B = I[0], D = I[1], N = I[2], O = o.Vec3.sub((0, o.Vec3)(), B, D), V = o.Vec3.sub((0, o.Vec3)(), N, D), k = "".concat((0, c.radToDeg)(o.Vec3.angle(O, V)).toFixed(2), "°");
    if (E.measureOnly)
      return k;
    var G = y(x, E);
    return E.condensed ? "".concat(k, " | ").concat(G) : "Angle ".concat(k, "</br>").concat(G);
  }
  e.angleLabel = P;
  function T(x, w) {
    w === void 0 && (w = {});
    var E = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, e.DefaultLabelOptions), { measureOnly: !1 }), w), I = x.loci.map(function(G) {
      return n.Loci.getCenter(G);
    }), B = I[0], D = I[1], N = I[2], O = I[3], V = "".concat((0, c.radToDeg)(o.Vec3.dihedralAngle(B, D, N, O)).toFixed(2), "°");
    if (E.measureOnly)
      return V;
    var k = y(x, E);
    return E.condensed ? "".concat(V, " | ").concat(k) : "Dihedral ".concat(V, "</br>").concat(k);
  }
  e.dihedralLabel = T;
})(X0);
var Ny = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.LociLabelTextParams = e.MeasurementRepresentationCommonTextParams = void 0;
  var r = Te, t = Le, n = Oa, a = bs();
  e.MeasurementRepresentationCommonTextParams = {
    customText: t.ParamDefinition.Text("", {
      label: "Text",
      description: "Override the label with custom value.",
      isEssential: !0
    }),
    textColor: t.ParamDefinition.Color(n.ColorNames.black, { isEssential: !0 }),
    textSize: t.ParamDefinition.Numeric(0.5, { min: 0.1, max: 10, step: 0.1 }, { isEssential: !0 })
  }, e.LociLabelTextParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.Text.Params), e.MeasurementRepresentationCommonTextParams), { borderWidth: t.ParamDefinition.Numeric(0.2, { min: 0, max: 0.5, step: 0.01 }) });
})(Ny);
Object.defineProperty(Yv, "__esModule", { value: !0 });
Yv.LabelRepresentation = Yv.LabelParams = void 0;
var Qv = Te, s_e = _r, l_e = bs(), nv = Le, c_e = wo, jN = Wt, d_e = ui(), f_e = H0, m_e = nr(), v_e = X0, p_e = Ny, h_e = _n, g_e = Tr(), y_e = (0, Qv.__assign)((0, Qv.__assign)({}, p_e.LociLabelTextParams), { offsetZ: nv.ParamDefinition.Numeric(2, { min: 0, max: 10, step: 0.1 }), textSize: nv.ParamDefinition.Numeric(0.7, { min: 0.1, max: 10, step: 0.1 }, { isEssential: !0 }) }), wj = {
  text: function(e, r) {
    return (0, c_e.ShapeRepresentation)(C_e, l_e.Text.Utils, {
      modifyState: function(t) {
        return (0, Qv.__assign)((0, Qv.__assign)({}, t), { pickable: !0 });
      }
    });
  }
};
Yv.LabelParams = (0, Qv.__assign)((0, Qv.__assign)({}, y_e), { scaleByRadius: nv.ParamDefinition.Boolean(!1), visuals: nv.ParamDefinition.MultiSelect(["text"], nv.ParamDefinition.objectToOptions(wj)), textColor: nv.ParamDefinition.Color(g_e.Color.fromRgb(241, 160, 119), { isEssential: !0 }) });
var __e = (0, m_e.Sphere3D)();
function fD(e, r) {
  return r === void 0 && (r = !1), e.label || (0, v_e.lociLabel)(e.loci, {
    hidePrefix: !0,
    htmlStyling: !1,
    condensed: r
  }).split("Plddt")[0];
}
function b_e(e) {
  return e.infos.length === 1 ? fD(e.infos[0]) : "".concat(e.infos.length, " Labels");
}
function S_e(e, r, t) {
  for (var n = f_e.TextBuilder.create(r, 128, 64, t), a = r.customText.trim(), i = 0, o = e.infos.length; i < o; ++i) {
    var c = e.infos[i], s = s_e.Loci.getBoundingSphere(c.loci, __e);
    if (s) {
      var u = s.center, l = s.radius, f = a || fD(c, !0);
      n.add(f, u[0], u[1], u[2], r.scaleByRadius ? l / 0.9 : 0, r.scaleByRadius ? Math.max(1, l) : 1, i);
    }
  }
  return n.getText();
}
function C_e(e, r, t, n) {
  var a = S_e(r, t, n && n.geometry), i = b_e(r), o = t.customText.trim(), c = o ? function(s) {
    return o;
  } : function(s) {
    return fD(r.infos[s]);
  };
  return d_e.Shape.create(i, r, a, function() {
    return t.textColor;
  }, function() {
    return t.textSize;
  }, c);
}
function A_e(e, r) {
  var t = jN.Representation.createMulti("Label", e, r, jN.Representation.StateBuilder, wj);
  return t.setState({ pickable: !0, markerActions: h_e.MarkerActions.All }), t;
}
Yv.LabelRepresentation = A_e;
Object.defineProperty(vA, "__esModule", { value: !0 });
vA.LabelRepr = void 0;
var r_ = Te, $N = Yv;
vA.LabelRepr = {
  create: function(e, r, t, n) {
    return (0, r_.__awaiter)(this, void 0, void 0, function() {
      var a;
      return (0, r_.__generator)(this, function(i) {
        switch (i.label) {
          case 0:
            return a = (0, $N.LabelRepresentation)(r, function() {
              return $N.LabelParams;
            }), [4, a.createOrUpdate(t ?? {}, {
              infos: e[0].loci ? e : e.map(function(o) {
                return { loci: o };
              })
            }).run()];
          case 1:
            return i.sent(), [2, a];
        }
      });
    });
  },
  update: function(e, r, t, n) {
    return (0, r_.__awaiter)(this, void 0, void 0, function() {
      return (0, r_.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return n && e.setTheme(n), [4, e.createOrUpdate(t ?? {}, {
              infos: r.map(function(i) {
                return { loci: i };
              })
            }).run()];
          case 1:
            return a.sent(), [
              2
              /*return*/
            ];
        }
      });
    });
  }
};
var pA = {}, Zv = {};
Object.defineProperty(Zv, "__esModule", { value: !0 });
Zv.DistanceRepresentation = Zv.DistanceParams = void 0;
var Mu = Te, KN = _r, Ej = Fa(), x_e = bs(), Jf = Le, T_e = Oa, WN = wo, XN = Wt, Dj = ui(), P_e = pl(), M_e = H0, cb = Re, iw = _n, mD = X0, w_e = Ny, YN = nr(), Ij = {
  unitLabel: Jf.ParamDefinition.Text("Å", { isEssential: !0 })
}, E_e = (0, Mu.__assign)((0, Mu.__assign)((0, Mu.__assign)({}, Ej.Lines.Params), Ij), { lineSizeAttenuation: Jf.ParamDefinition.Boolean(!0), linesColor: Jf.ParamDefinition.Color(T_e.ColorNames.lightgreen, { isEssential: !0 }), linesSize: Jf.ParamDefinition.Numeric(0.075, { min: 0.01, max: 5, step: 0.01 }), dashLength: Jf.ParamDefinition.Numeric(0.2, { min: 0.01, max: 0.2, step: 0.01 }) }), D_e = (0, Mu.__assign)((0, Mu.__assign)({}, w_e.LociLabelTextParams), Ij), Bj = {
  lines: function(e, r) {
    return (0, WN.ShapeRepresentation)(N_e, Ej.Lines.Utils, {
      modifyState: function(t) {
        return (0, Mu.__assign)((0, Mu.__assign)({}, t), { pickable: !0, markerActions: iw.MarkerActions.All });
      }
    });
  },
  text: function(e, r) {
    return (0, WN.ShapeRepresentation)(R_e, x_e.Text.Utils, {
      modifyState: function(t) {
        return (0, Mu.__assign)((0, Mu.__assign)({}, t), { pickable: !1, markerActions: iw.MarkerActions.All });
      }
    });
  }
};
Zv.DistanceParams = (0, Mu.__assign)((0, Mu.__assign)((0, Mu.__assign)({}, E_e), D_e), { visuals: Jf.ParamDefinition.MultiSelect(["lines", "text"], Jf.ParamDefinition.objectToOptions(Bj)) });
function I_e() {
  return {
    sphereA: (0, YN.Sphere3D)(),
    sphereB: (0, YN.Sphere3D)(),
    center: (0, cb.Vec3)(),
    distance: 0
  };
}
function Nj(e, r) {
  var t = r.sphereA, n = r.sphereB, a = r.center, i = e.loci, o = i[0], c = i[1];
  return KN.Loci.getBoundingSphere(o, t), KN.Loci.getBoundingSphere(c, n), cb.Vec3.add(a, t.center, n.center), cb.Vec3.scale(a, a, 0.5), r.distance = cb.Vec3.distance(t.center, n.center), r;
}
var nd = I_e();
function Vj(e, r) {
  return e.pairs.length === 1 ? "Distance ".concat((0, mD.distanceLabel)(e.pairs[0], {
    unitLabel: r,
    measureOnly: !0
  })) : "".concat(e.pairs.length, " Distances");
}
function B_e(e, r, t) {
  for (var n = P_e.LinesBuilder.create(128, 64, t), a = 0, i = e.pairs.length; a < i; ++a)
    Nj(e.pairs[a], nd), n.addFixedLengthDashes(nd.sphereA.center, nd.sphereB.center, r.dashLength, a);
  return n.getLines();
}
function N_e(e, r, t, n) {
  var a = B_e(r, t, n && n.geometry), i = Vj(r, t.unitLabel), o = function(c) {
    return (0, mD.distanceLabel)(r.pairs[c], t);
  };
  return Dj.Shape.create(i, r, a, function() {
    return t.linesColor;
  }, function() {
    return t.linesSize;
  }, o);
}
function V_e(e, r, t) {
  for (var n = M_e.TextBuilder.create(r, 128, 64, t), a = 0, i = e.pairs.length; a < i; ++a) {
    Nj(e.pairs[a], nd);
    var o = nd.center, c = nd.distance, s = nd.sphereA, u = nd.sphereB, l = r.customText || "".concat(c.toFixed(2), " ").concat(r.unitLabel), f = Math.max(2, s.radius, u.radius), d = f / 2;
    n.add(l, o[0], o[1], o[2], 1, d, a);
  }
  return n.getText();
}
function R_e(e, r, t, n) {
  var a = V_e(r, t, n && n.geometry), i = Vj(r, t.unitLabel), o = function(c) {
    return (0, mD.distanceLabel)(r.pairs[c], t);
  };
  return Dj.Shape.create(i, r, a, function() {
    return t.textColor;
  }, function() {
    return t.textSize;
  }, o);
}
function O_e(e, r) {
  var t = XN.Representation.createMulti("Distance", e, r, XN.Representation.StateBuilder, Bj);
  return t.setState({ pickable: !0, markerActions: iw.MarkerActions.All }), t;
}
Zv.DistanceRepresentation = O_e;
Object.defineProperty(pA, "__esModule", { value: !0 });
pA.DistanceRepr = void 0;
var t_ = Te, QN = Zv;
pA.DistanceRepr = {
  create: function(e, r, t, n) {
    return (0, t_.__awaiter)(this, void 0, void 0, function() {
      var a;
      return (0, t_.__generator)(this, function(i) {
        switch (i.label) {
          case 0:
            return a = (0, QN.DistanceRepresentation)(r, function() {
              return QN.DistanceParams;
            }), [4, a.createOrUpdate(t ?? {}, {
              pairs: [{ loci: e.slice(-2) }]
            }).run()];
          case 1:
            return i.sent(), [2, a];
        }
      });
    });
  },
  update: function(e, r, t, n) {
    return (0, t_.__awaiter)(this, void 0, void 0, function() {
      return (0, t_.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return n && e.setTheme(n), [4, e.createOrUpdate(t ?? {}, {
              pairs: [{ loci: r }]
            }).run()];
          case 1:
            return a.sent(), [
              2
              /*return*/
            ];
        }
      });
    });
  }
};
var hA = {}, Jv = {}, gA = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Circle = e.DefaultCircleProps = void 0;
  var r = Te;
  e.DefaultCircleProps = {
    radius: 1,
    segments: 36,
    thetaStart: 0,
    thetaLength: Math.PI * 2
  };
  function t(n) {
    var a = (0, r.__assign)((0, r.__assign)({}, e.DefaultCircleProps), n), i = a.radius, o = a.segments, c = a.thetaStart, s = a.thetaLength, u = s === Math.PI * 2, l = u ? o + 1 : o + 2, f = new Float32Array(l * 3), d = new Float32Array(l * 3), m = new Uint32Array(o * 3);
    f[0] = 0, f[1] = 0, f[2] = 0, d[0] = 0, d[1] = 1, d[2] = 0;
    for (var p = 0, v = 3; p < o; ++p, v += 3) {
      var h = c + p / o * s;
      f[v] = i * Math.sin(h), f[v + 1] = 0, f[v + 2] = i * Math.cos(h), d[v] = 0, d[v + 1] = 1, d[v + 2] = 0;
    }
    for (var p = 1, v = 0; p < o; ++p, v += 3)
      m[v] = p, m[v + 1] = p + 1, m[v + 2] = 0;
    if (u) {
      var y = (o - 1) * 3;
      m[y] = o, m[y + 1] = 1, m[y + 2] = 0;
    } else {
      var h = c + s, v = (o + 1) * 3;
      f[v] = i * Math.sin(h), f[v + 1] = 0, f[v + 2] = i * Math.cos(h), d[v] = 0, d[v + 1] = 1, d[v + 2] = 0;
      var y = (o - 1) * 3;
      m[y] = o, m[y + 1] = o + 1, m[y + 2] = 0;
    }
    return { vertices: f, normals: d, indices: m };
  }
  e.Circle = t;
})(gA);
Object.defineProperty(Jv, "__esModule", { value: !0 });
Jv.AngleRepresentation = Jv.AngleParams = void 0;
var wn = Te, $T = _r, ow = Fa(), F_e = bs(), oc = Le, L_e = Oa, n_ = wo, ZN = Wt, yA = ui(), Rj = pl(), k_e = H0, ta = Re, Oj = Dt(), a_ = Ca(), Fj = kn, U_e = gA, z_e = ya, JN = _n, vD = X0, KT = nr(), G_e = Ny, Lj = {
  color: oc.ParamDefinition.Color(L_e.ColorNames.lightgreen),
  arcScale: oc.ParamDefinition.Numeric(0.7, { min: 0.01, max: 1, step: 0.01 })
}, kj = (0, wn.__assign)((0, wn.__assign)((0, wn.__assign)({}, ow.Lines.Params), Lj), { lineSizeAttenuation: oc.ParamDefinition.Boolean(!0), linesSize: oc.ParamDefinition.Numeric(0.04, { min: 0.01, max: 5, step: 0.01 }), dashLength: oc.ParamDefinition.Numeric(0.04, { min: 0.01, max: 0.2, step: 0.01 }) }), q_e = (0, wn.__assign)({}, kj), H_e = (0, wn.__assign)({}, kj), j_e = (0, wn.__assign)((0, wn.__assign)((0, wn.__assign)({}, Oj.Mesh.Params), Lj), { ignoreLight: oc.ParamDefinition.Boolean(!0), sectorOpacity: oc.ParamDefinition.Numeric(0.75, { min: 0, max: 1, step: 0.01 }) }), Uj = {
  vectors: function(e, r) {
    return (0, n_.ShapeRepresentation)(W_e, ow.Lines.Utils, {
      modifyState: function(t) {
        return (0, wn.__assign)((0, wn.__assign)({}, t), { pickable: !1 });
      }
    });
  },
  arc: function(e, r) {
    return (0, n_.ShapeRepresentation)(Y_e, ow.Lines.Utils, {
      modifyState: function(t) {
        return (0, wn.__assign)((0, wn.__assign)({}, t), { pickable: !1 });
      }
    });
  },
  sector: function(e, r) {
    return (0, n_.ShapeRepresentation)(Z_e, Oj.Mesh.Utils, {
      modifyProps: function(t) {
        return (0, wn.__assign)((0, wn.__assign)({}, t), { alpha: t.sectorOpacity });
      },
      modifyState: function(t) {
        return (0, wn.__assign)((0, wn.__assign)({}, t), { markerActions: JN.MarkerActions.Highlighting });
      }
    });
  },
  text: function(e, r) {
    return (0, n_.ShapeRepresentation)(ebe, F_e.Text.Utils, {
      modifyState: function(t) {
        return (0, wn.__assign)((0, wn.__assign)({}, t), { markerActions: JN.MarkerAction.None });
      }
    });
  }
};
Jv.AngleParams = (0, wn.__assign)((0, wn.__assign)((0, wn.__assign)((0, wn.__assign)((0, wn.__assign)({}, q_e), H_e), j_e), G_e.LociLabelTextParams), { visuals: oc.ParamDefinition.MultiSelect(["vectors", "sector", "text"], oc.ParamDefinition.objectToOptions(Uj)) });
function $_e() {
  return {
    sphereA: (0, KT.Sphere3D)(),
    sphereB: (0, KT.Sphere3D)(),
    sphereC: (0, KT.Sphere3D)(),
    arcDirA: (0, ta.Vec3)(),
    arcDirC: (0, ta.Vec3)(),
    arcNormal: (0, ta.Vec3)(),
    radius: 0,
    angle: 0
  };
}
var Hc = (0, ta.Vec3)(), v1 = (0, ta.Mat4)();
function _A(e, r, t) {
  var n = r.sphereA, a = r.sphereB, i = r.sphereC, o = r.arcDirA, c = r.arcDirC, s = r.arcNormal, u = e.loci, l = u[0], f = u[1], d = u[2];
  $T.Loci.getBoundingSphere(l, n), $T.Loci.getBoundingSphere(f, a), $T.Loci.getBoundingSphere(d, i), ta.Vec3.sub(o, n.center, a.center), ta.Vec3.sub(c, i.center, a.center), ta.Vec3.cross(s, o, c);
  var m = Math.min(ta.Vec3.magnitude(o), ta.Vec3.magnitude(c)), p = m * t;
  return r.radius = p, r.angle = ta.Vec3.angle(o, c), r;
}
function zj(e, r) {
  var t = e.radius, n = e.angle, a = r ? (0, Fj.arcLength)(n, t) / r : 32;
  ta.Mat4.targetTo(v1, e.sphereB.center, e.sphereA.center, e.arcNormal), ta.Mat4.setTranslation(v1, e.sphereB.center), ta.Mat4.mul(v1, v1, ta.Mat4.rotY180);
  var i = (0, U_e.Circle)({ radius: t, thetaLength: n, segments: a });
  return (0, z_e.transformPrimitive)(i, v1);
}
var Ia = $_e();
function bA(e) {
  return e.triples.length === 1 ? "Angle ".concat((0, vD.angleLabel)(e.triples[0], { measureOnly: !0 })) : "".concat(e.triples.length, " Angles");
}
function K_e(e, r, t) {
  for (var n = Rj.LinesBuilder.create(128, 64, t), a = 0, i = e.triples.length; a < i; ++a)
    _A(e.triples[a], Ia, r.arcScale), n.addFixedLengthDashes(Ia.sphereB.center, Ia.sphereA.center, r.dashLength, a), n.addFixedLengthDashes(Ia.sphereB.center, Ia.sphereC.center, r.dashLength, a);
  return n.getLines();
}
function W_e(e, r, t, n) {
  var a = K_e(r, t, n && n.geometry), i = bA(r);
  return yA.Shape.create(i, r, a, function() {
    return t.color;
  }, function() {
    return t.linesSize;
  }, function() {
    return "";
  });
}
function X_e(e, r, t) {
  for (var n = Rj.LinesBuilder.create(128, 64, t), a = 0, i = e.triples.length; a < i; ++a) {
    _A(e.triples[a], Ia, r.arcScale);
    for (var o = zj(Ia, r.dashLength), c = o.indices, s = o.vertices, u = 0, l = c.length; u < l; u += 3)
      if (u % 2 !== 1) {
        var f = c[u] * 3, d = c[u + 1] * 3, m = s[f], p = s[f + 1], v = s[f + 2], h = s[d], y = s[d + 1], C = s[d + 2];
        n.add(m, p, v, h, y, C, a);
      }
  }
  return n.getLines();
}
function Y_e(e, r, t, n) {
  var a = X_e(r, t, n && n.geometry), i = bA(r);
  return yA.Shape.create(i, r, a, function() {
    return t.color;
  }, function() {
    return t.linesSize;
  }, function() {
    return "";
  });
}
function Q_e(e, r, t) {
  for (var n = a_.MeshBuilder.createState(128, 64, t), a = 0, i = e.triples.length; a < i; ++a) {
    _A(e.triples[a], Ia, r.arcScale);
    var o = zj(Ia);
    n.currentGroup = a, a_.MeshBuilder.addPrimitive(n, ta.Mat4.id, o), a_.MeshBuilder.addPrimitiveFlipped(n, ta.Mat4.id, o);
  }
  return a_.MeshBuilder.getMesh(n);
}
function Z_e(e, r, t, n) {
  var a = Q_e(r, t, n && n.geometry), i = bA(r), o = function(c) {
    return (0, vD.angleLabel)(r.triples[c]);
  };
  return yA.Shape.create(i, r, a, function() {
    return t.color;
  }, function() {
    return 1;
  }, o);
}
function J_e(e, r, t) {
  for (var n = k_e.TextBuilder.create(r, 128, 64, t), a = 0, i = e.triples.length; a < i; ++a) {
    _A(e.triples[a], Ia, r.arcScale), ta.Vec3.add(Hc, Ia.arcDirA, Ia.arcDirC), ta.Vec3.setMagnitude(Hc, Hc, Ia.radius), ta.Vec3.add(Hc, Ia.sphereB.center, Hc);
    var o = (0, Fj.radToDeg)(Ia.angle).toFixed(2), c = r.customText || "".concat(o, "°"), s = Math.max(2, Ia.sphereA.radius, Ia.sphereB.radius, Ia.sphereC.radius), u = s / 2;
    n.add(c, Hc[0], Hc[1], Hc[2], 0.1, u, a);
  }
  return n.getText();
}
function ebe(e, r, t, n) {
  var a = J_e(r, t, n && n.geometry), i = bA(r), o = function(c) {
    return (0, vD.angleLabel)(r.triples[c]);
  };
  return yA.Shape.create(i, r, a, function() {
    return t.textColor;
  }, function() {
    return t.textSize;
  }, o);
}
function rbe(e, r) {
  return ZN.Representation.createMulti("Angle", e, r, ZN.Representation.StateBuilder, Uj);
}
Jv.AngleRepresentation = rbe;
Object.defineProperty(hA, "__esModule", { value: !0 });
hA.AngleRepr = void 0;
var i_ = Te, eV = Jv;
hA.AngleRepr = {
  create: function(e, r, t, n) {
    return (0, i_.__awaiter)(this, void 0, void 0, function() {
      var a;
      return (0, i_.__generator)(this, function(i) {
        switch (i.label) {
          case 0:
            return a = (0, eV.AngleRepresentation)(r, function() {
              return eV.AngleParams;
            }), [4, a.createOrUpdate(t ?? {}, {
              triples: [{ loci: e.slice(-3) }]
            }).run()];
          case 1:
            return i.sent(), [2, a];
        }
      });
    });
  },
  update: function(e, r, t, n) {
    return (0, i_.__awaiter)(this, void 0, void 0, function() {
      return (0, i_.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return n && e.setTheme(n), [4, e.createOrUpdate(t ?? {}, {
              triples: [{ loci: r.slice(-3) }]
            }).run()];
          case 1:
            return a.sent(), [
              2
              /*return*/
            ];
        }
      });
    });
  }
};
var SA = {}, ep = {};
Object.defineProperty(ep, "__esModule", { value: !0 });
ep.DihedralRepresentation = ep.DihedralParams = void 0;
var ft = Te, o_ = _r, $m = Fa(), tbe = bs(), uc = Le, nbe = Oa, kf = wo, rV = Wt, Y0 = ui(), Vy = pl(), abe = H0, Pr = Re, Gj = Dt(), u_ = Ca(), s3 = kn, ibe = gA, obe = ya, Yc = _n, pD = X0, ube = Ny, s_ = nr(), qj = {
  color: uc.ParamDefinition.Color(nbe.ColorNames.lightgreen),
  arcScale: uc.ParamDefinition.Numeric(0.7, { min: 0.01, max: 1, step: 0.01 })
}, CA = (0, ft.__assign)((0, ft.__assign)((0, ft.__assign)({}, $m.Lines.Params), qj), { lineSizeAttenuation: uc.ParamDefinition.Boolean(!0), linesSize: uc.ParamDefinition.Numeric(0.04, { min: 0.01, max: 5, step: 0.01 }), dashLength: uc.ParamDefinition.Numeric(0.04, { min: 0.01, max: 0.2, step: 0.01 }) }), sbe = (0, ft.__assign)({}, CA), lbe = (0, ft.__assign)({}, CA), cbe = (0, ft.__assign)({}, CA), dbe = (0, ft.__assign)({}, CA), fbe = (0, ft.__assign)((0, ft.__assign)((0, ft.__assign)({}, Gj.Mesh.Params), qj), { ignoreLight: uc.ParamDefinition.Boolean(!0), sectorOpacity: uc.ParamDefinition.Numeric(0.75, { min: 0, max: 1, step: 0.01 }) }), Hj = {
  vectors: function(e, r) {
    return (0, kf.ShapeRepresentation)(pbe, $m.Lines.Utils, {
      modifyState: function(t) {
        return (0, ft.__assign)((0, ft.__assign)({}, t), { pickable: !1, markerActions: Yc.MarkerActions.All });
      }
    });
  },
  extenders: function(e, r) {
    return (0, kf.ShapeRepresentation)(Sbe, $m.Lines.Utils, {
      modifyState: function(t) {
        return (0, ft.__assign)((0, ft.__assign)({}, t), { pickable: !1, markerActions: Yc.MarkerActions.All });
      }
    });
  },
  connector: function(e, r) {
    return (0, kf.ShapeRepresentation)(gbe, $m.Lines.Utils, {
      modifyState: function(t) {
        return (0, ft.__assign)((0, ft.__assign)({}, t), { pickable: !1, markerActions: Yc.MarkerActions.All });
      }
    });
  },
  arms: function(e, r) {
    return (0, kf.ShapeRepresentation)(_be, $m.Lines.Utils, {
      modifyState: function(t) {
        return (0, ft.__assign)((0, ft.__assign)({}, t), { pickable: !1, markerActions: Yc.MarkerActions.All });
      }
    });
  },
  arc: function(e, r) {
    return (0, kf.ShapeRepresentation)(Abe, $m.Lines.Utils, {
      modifyState: function(t) {
        return (0, ft.__assign)((0, ft.__assign)({}, t), { pickable: !1, markerActions: Yc.MarkerActions.All });
      }
    });
  },
  sector: function(e, r) {
    return (0, kf.ShapeRepresentation)(Tbe, Gj.Mesh.Utils, {
      modifyProps: function(t) {
        return (0, ft.__assign)((0, ft.__assign)({}, t), { alpha: t.sectorOpacity });
      },
      modifyState: function(t) {
        return (0, ft.__assign)((0, ft.__assign)({}, t), { markerActions: Yc.MarkerActions.All });
      }
    });
  },
  text: function(e, r) {
    return (0, kf.ShapeRepresentation)(Mbe, tbe.Text.Utils, {
      modifyState: function(t) {
        return (0, ft.__assign)((0, ft.__assign)({}, t), { markerActions: Yc.MarkerActions.All });
      }
    });
  }
};
ep.DihedralParams = (0, ft.__assign)((0, ft.__assign)((0, ft.__assign)((0, ft.__assign)((0, ft.__assign)((0, ft.__assign)((0, ft.__assign)({}, sbe), lbe), cbe), dbe), fbe), ube.LociLabelTextParams), { visuals: uc.ParamDefinition.MultiSelect(["extenders", "arms", "sector", "text"], uc.ParamDefinition.objectToOptions(Hj)) });
function mbe() {
  return {
    sphereA: (0, s_.Sphere3D)(),
    sphereB: (0, s_.Sphere3D)(),
    sphereC: (0, s_.Sphere3D)(),
    sphereD: (0, s_.Sphere3D)(),
    dirBA: (0, Pr.Vec3)(),
    dirCD: (0, Pr.Vec3)(),
    projA: (0, Pr.Vec3)(),
    projD: (0, Pr.Vec3)(),
    arcPointA: (0, Pr.Vec3)(),
    arcPointD: (0, Pr.Vec3)(),
    arcDirA: (0, Pr.Vec3)(),
    arcDirD: (0, Pr.Vec3)(),
    arcCenter: (0, Pr.Vec3)(),
    arcNormal: (0, Pr.Vec3)(),
    radius: 0,
    angle: 0
  };
}
var _i = (0, Pr.Vec3)(), p1 = (0, Pr.Mat4)();
function Q0(e, r, t) {
  var n = r.sphereA, a = r.sphereB, i = r.sphereC, o = r.sphereD, c = r.dirBA, s = r.dirCD, u = r.projA, l = r.projD, f = r.arcPointA, d = r.arcPointD, m = r.arcDirA, p = r.arcDirD, v = r.arcCenter, h = r.arcNormal, y = e.loci, C = y[0], S = y[1], b = y[2], g = y[3];
  o_.Loci.getBoundingSphere(C, n), o_.Loci.getBoundingSphere(S, a), o_.Loci.getBoundingSphere(b, i), o_.Loci.getBoundingSphere(g, o), Pr.Vec3.add(v, a.center, i.center), Pr.Vec3.scale(v, v, 0.5), Pr.Vec3.sub(c, n.center, a.center), Pr.Vec3.sub(s, o.center, i.center), Pr.Vec3.add(f, v, c), Pr.Vec3.add(d, v, s), Pr.Vec3.sub(h, i.center, a.center), Pr.Vec3.orthogonalize(m, h, c), Pr.Vec3.orthogonalize(p, h, s), Pr.Vec3.projectPointOnVector(u, f, m, v), Pr.Vec3.projectPointOnVector(l, d, p, v);
  var _ = Math.min(Pr.Vec3.distance(u, v), Pr.Vec3.distance(l, v)), A = _ * t;
  Pr.Vec3.setMagnitude(m, m, A), Pr.Vec3.setMagnitude(p, p, A), Pr.Vec3.add(f, v, m), Pr.Vec3.add(d, v, p), r.radius = A, r.angle = Pr.Vec3.dihedralAngle(n.center, a.center, i.center, o.center), Pr.Vec3.matchDirection(_i, h, Pr.Vec3.sub(_i, f, n.center));
  var M = Pr.Vec3.angle(c, _i), P = A / Math.cos(M - s3.halfPI);
  Pr.Vec3.add(u, a.center, Pr.Vec3.setMagnitude(_i, c, P)), Pr.Vec3.matchDirection(_i, h, Pr.Vec3.sub(_i, d, o.center));
  var T = Pr.Vec3.angle(s, _i), x = A / Math.cos(T - s3.halfPI);
  return Pr.Vec3.add(l, i.center, Pr.Vec3.setMagnitude(_i, s, x)), r;
}
function jj(e, r) {
  var t = e.radius, n = e.angle, a = r ? (0, s3.arcLength)(n, t) / r : 32;
  Pr.Mat4.targetTo(p1, e.arcCenter, n < 0 ? e.arcPointD : e.arcPointA, e.arcNormal), Pr.Mat4.setTranslation(p1, e.arcCenter), Pr.Mat4.mul(p1, p1, Pr.Mat4.rotY180);
  var i = (0, ibe.Circle)({ radius: t, thetaLength: Math.abs(n), segments: a });
  return (0, obe.transformPrimitive)(i, p1);
}
var ht = mbe();
function Z0(e) {
  return e.quads.length === 1 ? "Dihedral ".concat((0, pD.dihedralLabel)(e.quads[0], { measureOnly: !0 })) : "".concat(e.quads.length, " Dihedrals");
}
function vbe(e, r, t) {
  for (var n = Vy.LinesBuilder.create(128, 64, t), a = 0, i = e.quads.length; a < i; ++a)
    Q0(e.quads[a], ht, r.arcScale), n.addFixedLengthDashes(ht.arcCenter, ht.arcPointA, r.dashLength, a), n.addFixedLengthDashes(ht.arcCenter, ht.arcPointD, r.dashLength, a);
  return n.getLines();
}
function pbe(e, r, t, n) {
  var a = vbe(r, t, n && n.geometry), i = Z0(r);
  return Y0.Shape.create(i, r, a, function() {
    return t.color;
  }, function() {
    return t.linesSize;
  }, function() {
    return "";
  });
}
function hbe(e, r, t) {
  for (var n = Vy.LinesBuilder.create(128, 64, t), a = 0, i = e.quads.length; a < i; ++a)
    Q0(e.quads[a], ht, r.arcScale), n.addFixedLengthDashes(ht.sphereB.center, ht.sphereC.center, r.dashLength, a);
  return n.getLines();
}
function gbe(e, r, t, n) {
  var a = hbe(r, t, n && n.geometry), i = Z0(r);
  return Y0.Shape.create(i, r, a, function() {
    return t.color;
  }, function() {
    return t.linesSize;
  }, function() {
    return "";
  });
}
function ybe(e, r, t) {
  for (var n = Vy.LinesBuilder.create(128, 64, t), a = 0, i = e.quads.length; a < i; ++a)
    Q0(e.quads[a], ht, r.arcScale), n.addFixedLengthDashes(ht.sphereB.center, ht.sphereA.center, r.dashLength, a), n.addFixedLengthDashes(ht.sphereC.center, ht.sphereD.center, r.dashLength, a);
  return n.getLines();
}
function _be(e, r, t, n) {
  var a = ybe(r, t, n && n.geometry), i = Z0(r);
  return Y0.Shape.create(i, r, a, function() {
    return t.color;
  }, function() {
    return t.linesSize;
  }, function() {
    return "";
  });
}
function bbe(e, r, t) {
  for (var n = Vy.LinesBuilder.create(128, 64, t), a = 0, i = e.quads.length; a < i; ++a)
    Q0(e.quads[a], ht, r.arcScale), n.addFixedLengthDashes(ht.arcPointA, ht.projA, r.dashLength, a), n.addFixedLengthDashes(ht.arcPointD, ht.projD, r.dashLength, a);
  return n.getLines();
}
function Sbe(e, r, t, n) {
  var a = bbe(r, t, n && n.geometry), i = Z0(r);
  return Y0.Shape.create(i, r, a, function() {
    return t.color;
  }, function() {
    return t.linesSize;
  }, function() {
    return "";
  });
}
function Cbe(e, r, t) {
  for (var n = Vy.LinesBuilder.create(128, 64, t), a = 0, i = e.quads.length; a < i; ++a) {
    Q0(e.quads[a], ht, r.arcScale);
    for (var o = jj(ht, r.dashLength), c = o.indices, s = o.vertices, u = 0, l = c.length; u < l; u += 3)
      if (u % 2 !== 1) {
        var f = c[u] * 3, d = c[u + 1] * 3, m = s[f], p = s[f + 1], v = s[f + 2], h = s[d], y = s[d + 1], C = s[d + 2];
        n.add(m, p, v, h, y, C, a);
      }
  }
  return n.getLines();
}
function Abe(e, r, t, n) {
  var a = Cbe(r, t, n && n.geometry), i = Z0(r);
  return Y0.Shape.create(i, r, a, function() {
    return t.color;
  }, function() {
    return t.linesSize;
  }, function() {
    return "";
  });
}
function xbe(e, r, t) {
  for (var n = u_.MeshBuilder.createState(128, 64, t), a = 0, i = e.quads.length; a < i; ++a) {
    Q0(e.quads[a], ht, r.arcScale);
    var o = jj(ht);
    n.currentGroup = a, u_.MeshBuilder.addPrimitive(n, Pr.Mat4.id, o), u_.MeshBuilder.addPrimitiveFlipped(n, Pr.Mat4.id, o);
  }
  return u_.MeshBuilder.getMesh(n);
}
function Tbe(e, r, t, n) {
  var a = xbe(r, t, n && n.geometry), i = Z0(r), o = function(c) {
    return (0, pD.dihedralLabel)(r.quads[c]);
  };
  return Y0.Shape.create(i, r, a, function() {
    return t.color;
  }, function() {
    return 1;
  }, o);
}
function Pbe(e, r, t) {
  for (var n = abe.TextBuilder.create(r, 128, 64, t), a = 0, i = e.quads.length; a < i; ++a) {
    Q0(e.quads[a], ht, r.arcScale), Pr.Vec3.add(_i, ht.arcDirA, ht.arcDirD), Pr.Vec3.setMagnitude(_i, _i, ht.radius), Pr.Vec3.add(_i, ht.arcCenter, _i);
    var o = (0, s3.radToDeg)(ht.angle).toFixed(2);
    o === "-0.00" && (o = "0.00");
    var c = r.customText || "".concat(o, "°"), s = Math.max(2, ht.sphereA.radius, ht.sphereB.radius, ht.sphereC.radius, ht.sphereD.radius), u = s / 2;
    n.add(c, _i[0], _i[1], _i[2], 0.1, u, a);
  }
  return n.getText();
}
function Mbe(e, r, t, n) {
  var a = Pbe(r, t, n && n.geometry), i = Z0(r), o = function(c) {
    return (0, pD.dihedralLabel)(r.quads[c]);
  };
  return Y0.Shape.create(i, r, a, function() {
    return t.textColor;
  }, function() {
    return t.textSize;
  }, o);
}
function wbe(e, r) {
  var t = rV.Representation.createMulti("Dihedral", e, r, rV.Representation.StateBuilder, Hj);
  return t.setState({ pickable: !0, markerActions: Yc.MarkerActions.All }), t;
}
ep.DihedralRepresentation = wbe;
Object.defineProperty(SA, "__esModule", { value: !0 });
SA.DihedralRepr = void 0;
var l_ = Te, tV = ep;
SA.DihedralRepr = {
  create: function(e, r, t, n) {
    return (0, l_.__awaiter)(this, void 0, void 0, function() {
      var a;
      return (0, l_.__generator)(this, function(i) {
        switch (i.label) {
          case 0:
            return a = (0, tV.DihedralRepresentation)(r, function() {
              return tV.DihedralParams;
            }), [4, a.createOrUpdate(t ?? {}, {
              quads: [{ loci: e.slice(-4) }]
            }).run()];
          case 1:
            return i.sent(), [2, a];
        }
      });
    });
  },
  update: function(e, r, t, n) {
    return (0, l_.__awaiter)(this, void 0, void 0, function() {
      return (0, l_.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return n && e.setTheme(n), [4, e.createOrUpdate(t ?? {}, {
              quads: [{ loci: r.slice(-4) }]
            }).run()];
          case 1:
            return a.sent(), [
              2
              /*return*/
            ];
        }
      });
    });
  }
};
var AA = {}, $j = {}, Kj = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.IntraUnitBondLineVisual = e.IntraUnitBondLineParams = void 0;
  var r = Te, t = Le, n = Je(), a = Re, i = We(), o = Jd, c = Mr, s = Gr, u = By, l = nr(), f = Fa(), d = dl, m = hr, p = s.BondType.is;
  function v(y, C, S, b, g, _) {
    if (!n.Unit.isAtomic(C))
      return f.Lines.createEmpty(_);
    var A = S.child, M = A == null ? void 0 : A.unitMap.get(C.id);
    if (A && !M)
      return f.Lines.createEmpty(_);
    var P = n.StructureElement.Location.create(S, C), T = C.elements, x = C.bonds, w = x.edgeCount, E = x.a, I = x.b, B = x.edgeProps, D = x.offset;
    if (!w)
      return f.Lines.createEmpty(_);
    var N = B.order, O = B.flags, V = g.sizeFactor, k = g.aromaticBonds, G = g.includeTypes, L = g.excludeTypes, R = g.multipleBonds, F = R === "off", U = R === "symmetric", H = s.BondType.fromNames(G), q = s.BondType.fromNames(L), K = (0, u.ignoreBondType)(
      H,
      q,
      32
      /* Computed */
    ), Y = (0, a.Vec3)(), X = C.conformation.invariantPosition, Z = C.rings, J = Z.elementRingIndices, $ = Z.elementAromaticRingIndices, Q = k ? C.resonance.delocalizedTriplets : void 0, W = {
      linkCount: w * 2,
      referencePosition: function(ae) {
        var le, ie, re = E[ae], ee = I[ae], ne = Q == null ? void 0 : Q.getThirdElement(re, ee);
        if (ne !== void 0)
          return X(T[ne], Y);
        re > ee && (le = [ee, re], re = le[0], ee = le[1]), D[re + 1] - D[re] === 1 && (ie = [ee, re], re = ie[0], ee = ie[1]);
        for (var se = $.get(re) || J.get(re), ce = 0, de = D[re], me = D[re + 1]; de < me; ++de) {
          var he = I[de];
          if (he !== ee && he !== re)
            if (se) {
              var _e = $.get(he) || J.get(he);
              if (!_e)
                continue;
              var Se = (0, m.arrayIntersectionSize)(se, _e);
              Se > ce && (ce = Se, X(T[he], Y));
            } else
              return X(T[he], Y);
        }
        return ce > 0 ? Y : null;
      },
      position: function(ae, le, ie) {
        X(T[E[ie]], ae), X(T[I[ie]], le);
      },
      style: function(ae) {
        var le = N[ae], ie = O[ae];
        if (p(
          ie,
          2
          /* MetallicCoordination */
        ) || p(
          ie,
          4
          /* HydrogenBond */
        ))
          return 1;
        if (le === 3)
          return F ? 0 : U ? 4 : 5;
        if (k) {
          var re = E[ae], ee = I[ae], ne = $.get(re), se = $.get(ee), ce = ne && se ? (0, m.arrayIntersectionSize)(ne, se) : 0;
          if (p(
            ie,
            16
            /* Aromatic */
          ) || ce && !K) {
            if (ce === 2)
              return 8;
            if (ce === 1 || Q != null && Q.getThirdElement(re, ee))
              return 7;
          }
        }
        return le !== 2 || F ? 0 : U ? 2 : 3;
      },
      radius: function(ae) {
        P.element = T[E[ae]];
        var le = b.size.size(P);
        P.element = T[I[ae]];
        var ie = b.size.size(P);
        return Math.min(le, ie) * V;
      },
      ignore: (0, u.makeIntraBondIgnoreTest)(S, C, g)
    }, te = (0, o.createLinkLines)(y, W, g, _), oe = te.lines, z = te.boundingSphere;
    if (z)
      oe.setBoundingSphere(z);
    else if (oe.lineCount > 0) {
      var j = l.Sphere3D.expand((0, l.Sphere3D)(), (M ?? C).boundary.sphere, 1 * V);
      oe.setBoundingSphere(j);
    }
    return oe;
  }
  e.IntraUnitBondLineParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, c.UnitsLinesParams), u.BondLineParams), { includeParent: t.ParamDefinition.Boolean(!1) });
  function h(y) {
    return (0, c.UnitsLinesVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.IntraUnitBondLineParams),
      createGeometry: v,
      createLocationIterator: u.BondIterator.fromGroup,
      getLoci: u.getIntraBondLoci,
      eachLocation: u.eachIntraBond,
      setUpdateState: function(C, S, b, g, _, A, M) {
        C.createGeometry = S.sizeFactor !== b.sizeFactor || S.linkScale !== b.linkScale || S.linkSpacing !== b.linkSpacing || S.aromaticDashCount !== b.aromaticDashCount || S.dashCount !== b.dashCount || S.ignoreHydrogens !== b.ignoreHydrogens || !(0, i.arrayEqual)(S.includeTypes, b.includeTypes) || !(0, i.arrayEqual)(S.excludeTypes, b.excludeTypes) || S.aromaticBonds !== b.aromaticBonds || S.multipleBonds !== b.multipleBonds;
        var P = A.group.units[0], T = M.group.units[0];
        n.Unit.isAtomic(P) && n.Unit.isAtomic(T) && (d.IntAdjacencyGraph.areEqual(P.bonds, T.bonds) || (C.createGeometry = !0, C.updateTransform = !0, C.updateColor = !0, C.updateSize = !0));
      }
    }, y);
  }
  e.IntraUnitBondLineVisual = h;
})(Kj);
var Wj = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.InterUnitBondLineVisual = e.InterUnitBondLineParams = void 0;
  var r = Te, t = Le, n = Je(), a = Re, i = We(), o = Jd, c = pt, s = Gr, u = By, l = Fa(), f = nr(), d = new n.Bond.ElementBondIterator();
  function m(h, y, C, S) {
    for (d.setElement(y, C, S); d.hasNext; ) {
      var b = d.move();
      return b.otherUnit.conformation.position(b.otherUnit.elements[b.otherIndex], h), h;
    }
    return null;
  }
  function p(h, y, C, S, b) {
    var g = y.interUnitBonds, _ = g.edgeCount, A = g.edges;
    if (!_)
      return l.Lines.createEmpty(b);
    var M = S.sizeFactor, P = S.aromaticBonds, T = S.multipleBonds, x = T === "off", w = T === "symmetric", E = (0, a.Vec3)(), I = n.StructureElement.Location.create(), B = {
      linkCount: _,
      referencePosition: function(G) {
        var L = A[G], R, F, U, H;
        if (L.unitA < L.unitB)
          R = y.unitMap.get(L.unitA), F = y.unitMap.get(L.unitB), U = L.indexA, H = L.indexB;
        else if (L.unitA > L.unitB)
          R = y.unitMap.get(L.unitB), F = y.unitMap.get(L.unitA), U = L.indexB, H = L.indexA;
        else
          throw new Error("same units in createInterUnitBondLines");
        return m(E, y, R, U) || m(E, y, F, H);
      },
      position: function(G, L, R) {
        var F = A[R], U = y.unitMap.get(F.unitA), H = y.unitMap.get(F.unitB);
        U.conformation.position(U.elements[F.indexA], G), H.conformation.position(H.elements[F.indexB], L);
      },
      style: function(G) {
        var L = A[G].props.order, R = i.BitFlags.create(A[G].props.flag);
        return s.BondType.is(
          R,
          2
          /* MetallicCoordination */
        ) || s.BondType.is(
          R,
          4
          /* HydrogenBond */
        ) ? 1 : L === 3 ? x ? 0 : w ? 4 : 5 : P && s.BondType.is(
          R,
          16
          /* Aromatic */
        ) ? 7 : L !== 2 || x ? 0 : w ? 2 : 3;
      },
      radius: function(G) {
        var L = A[G];
        I.structure = y, I.unit = y.unitMap.get(L.unitA), I.element = I.unit.elements[L.indexA];
        var R = C.size.size(I);
        I.unit = y.unitMap.get(L.unitB), I.element = I.unit.elements[L.indexB];
        var F = C.size.size(I);
        return Math.min(R, F) * M;
      },
      ignore: (0, u.makeInterBondIgnoreTest)(y, S)
    }, D = (0, o.createLinkLines)(h, B, S, b), N = D.lines, O = D.boundingSphere;
    if (O)
      N.setBoundingSphere(O);
    else if (N.lineCount > 0) {
      var V = y.child, k = f.Sphere3D.expand((0, f.Sphere3D)(), (V ?? y).boundary.sphere, 1 * M);
      N.setBoundingSphere(k);
    }
    return N;
  }
  e.InterUnitBondLineParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, c.ComplexLinesParams), u.BondLineParams), { includeParent: t.ParamDefinition.Boolean(!1) });
  function v(h) {
    return (0, c.ComplexLinesVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.InterUnitBondLineParams),
      createGeometry: p,
      createLocationIterator: u.BondIterator.fromStructure,
      getLoci: u.getInterBondLoci,
      eachLocation: u.eachInterBond,
      setUpdateState: function(y, C, S, b, g, _, A) {
        y.createGeometry = C.sizeFactor !== S.sizeFactor || C.linkScale !== S.linkScale || C.linkSpacing !== S.linkSpacing || C.aromaticDashCount !== S.aromaticDashCount || C.dashCount !== S.dashCount || C.ignoreHydrogens !== S.ignoreHydrogens || !(0, i.arrayEqual)(C.includeTypes, S.includeTypes) || !(0, i.arrayEqual)(C.excludeTypes, S.excludeTypes) || C.multipleBonds !== S.multipleBonds, _.interUnitBonds !== A.interUnitBonds && (y.createGeometry = !0, y.updateTransform = !0, y.updateColor = !0, y.updateSize = !0);
      }
    }, h);
  }
  e.InterUnitBondLineVisual = v;
})(Wj);
var Xj = {}, Yj = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.PointsBuilder = void 0;
  var r = wr(), t = hy(), n = r.ChunkedArray.add3, a = r.ChunkedArray.add;
  (function(i) {
    function o(c, s, u) {
      c === void 0 && (c = 2048), s === void 0 && (s = 1024);
      var l = r.ChunkedArray.create(Float32Array, 3, s, u ? u.centerBuffer.ref.value : c), f = r.ChunkedArray.create(Float32Array, 1, s, u ? u.groupBuffer.ref.value : c);
      return {
        add: function(d, m, p, v) {
          n(l, d, m, p), a(f, v);
        },
        getPoints: function() {
          var d = r.ChunkedArray.compact(l, !0), m = r.ChunkedArray.compact(f, !0);
          return t.Points.create(d, m, l.elementCount, u);
        }
      };
    }
    i.create = o;
  })(e.PointsBuilder || (e.PointsBuilder = {}));
})(Yj);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ElementPointVisual = e.createElementPoint = e.ElementPointParams = void 0;
  var r = Te, t = Le, n = Mr, a = hy(), i = Yj, o = Re, c = W0, s = nr(), u = o.Vec3.add;
  e.ElementPointParams = (0, r.__assign)((0, r.__assign)({}, n.UnitsPointsParams), { pointSizeAttenuation: t.ParamDefinition.Boolean(!1), ignoreHydrogens: t.ParamDefinition.Boolean(!1), traceOnly: t.ParamDefinition.Boolean(!1) });
  function l(d, m, p, v, h, y) {
    var C = p.child;
    if (C && !C.unitMap.get(m.id))
      return a.Points.createEmpty(y);
    var S = m.elements, b = S.length, g = i.PointsBuilder.create(b, b / 10, y), _ = (0, o.Vec3)(), A = m.conformation.invariantPosition, M = (0, c.makeElementIgnoreTest)(p, m, h), P = (0, o.Vec3)(), T = 0;
    if (M)
      for (var x = 0; x < b; ++x)
        M(S[x]) || (A(S[x], _), u(P, P, _), T += 1, g.add(_[0], _[1], _[2], x));
    else
      for (var x = 0; x < b; ++x)
        A(S[x], _), u(P, P, _), T += 1, g.add(_[0], _[1], _[2], x);
    var w = y ? s.Sphere3D.clone(y.boundingSphere) : void 0, E = g.getPoints();
    if (T === 0)
      return E;
    var I;
    return o.Vec3.scale(P, P, 1 / T), w && o.Vec3.distance(P, w.center) / w.radius < 1 ? I = w : I = s.Sphere3D.expand((0, s.Sphere3D)(), m.boundary.sphere, 1), E.setBoundingSphere(I), E;
  }
  e.createElementPoint = l;
  function f(d) {
    return (0, n.UnitsPointsVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.ElementPointParams),
      createGeometry: l,
      createLocationIterator: c.ElementIterator.fromGroup,
      getLoci: c.getElementLoci,
      eachLocation: c.eachElement,
      setUpdateState: function(m, p, v) {
        m.createGeometry = p.ignoreHydrogens !== v.ignoreHydrogens || p.traceOnly !== v.traceOnly;
      }
    }, d);
  }
  e.ElementPointVisual = f;
})(Xj);
var Qj = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ElementCrossVisual = e.createElementCross = e.ElementCrossParams = void 0;
  var r = Te, t = Le, n = Mr, a = Je(), i = Re, o = W0, c = nr(), s = Fa(), u = pl(), l = Rr, f = i.Vec3.scaleAndAdd, d = i.Vec3.unitX, m = i.Vec3.unitY, p = i.Vec3.unitZ;
  e.ElementCrossParams = (0, r.__assign)((0, r.__assign)({}, n.UnitsLinesParams), { lineSizeAttenuation: t.ParamDefinition.Boolean(!1), ignoreHydrogens: t.ParamDefinition.Boolean(!1), traceOnly: t.ParamDefinition.Boolean(!1), crosses: t.ParamDefinition.Select("lone", t.ParamDefinition.arrayToOptions(["lone", "all"])), crossSize: t.ParamDefinition.Numeric(0.35, { min: 0, max: 2, step: 0.01 }) });
  function v(y, C, S, b, g, _) {
    var A = S.child;
    if (A && !A.unitMap.get(C.id))
      return s.Lines.createEmpty(_);
    for (var M = C.elements, P = M.length, T = u.LinesBuilder.create(P, P / 10, _), x = (0, i.Vec3)(), w = (0, i.Vec3)(), E = (0, i.Vec3)(), I = C.conformation.invariantPosition, B = (0, o.makeElementIgnoreTest)(S, C, g), D = g.crossSize / 2, N = g.crosses === "lone", O = 0; O < P; ++O)
      B && B(M[O]) || N && a.Unit.isAtomic(C) && (0, l.bondCount)(S, C, O) !== 0 || (I(M[O], x), f(w, x, d, D), f(E, x, d, -D), T.add(w[0], w[1], w[2], E[0], E[1], E[2], O), f(w, x, m, D), f(E, x, m, -D), T.add(w[0], w[1], w[2], E[0], E[1], E[2], O), f(w, x, p, D), f(E, x, p, -D), T.add(w[0], w[1], w[2], E[0], E[1], E[2], O));
    var V = T.getLines(), k = c.Sphere3D.expand((0, c.Sphere3D)(), C.boundary.sphere, 1 * g.sizeFactor);
    return V.setBoundingSphere(k), V;
  }
  e.createElementCross = v;
  function h(y) {
    return (0, n.UnitsLinesVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.ElementCrossParams),
      createGeometry: v,
      createLocationIterator: o.ElementIterator.fromGroup,
      getLoci: o.getElementLoci,
      eachLocation: o.eachElement,
      setUpdateState: function(C, S, b) {
        C.createGeometry = S.ignoreHydrogens !== b.ignoreHydrogens || S.traceOnly !== b.traceOnly || S.crosses !== b.crosses || S.crossSize !== b.crossSize;
      }
    }, y);
  }
  e.ElementCrossVisual = h;
})(Qj);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.LineRepresentationProvider = e.LineRepresentation = e.getLineParams = e.LineParams = void 0;
  var r = Te, t = Kj, n = Wj, a = Le, i = $0(), o = oA(), c = Ss(), s = Wt, u = qt, l = Xj, f = Qj, d = mA, m = {
    square: "Square",
    circle: "Circle",
    fuzzy: "Fuzzy"
  }, p = {
    "intra-bond": function(y, C) {
      return (0, i.UnitsRepresentation)("Intra-unit bond line", y, C, t.IntraUnitBondLineVisual);
    },
    "inter-bond": function(y, C) {
      return (0, o.ComplexRepresentation)("Inter-unit bond line", y, C, n.InterUnitBondLineVisual);
    },
    "element-point": function(y, C) {
      return (0, i.UnitsRepresentation)("Points", y, C, l.ElementPointVisual);
    },
    "element-cross": function(y, C) {
      return (0, i.UnitsRepresentation)("Crosses", y, C, f.ElementCrossVisual);
    },
    "charge-text": function(y, C) {
      return (0, o.ComplexRepresentation)("Charge Text", y, C, d.ChargeTextVisual);
    }
  };
  e.LineParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, t.IntraUnitBondLineParams), n.InterUnitBondLineParams), l.ElementPointParams), f.ElementCrossParams), { multipleBonds: a.ParamDefinition.Select("offset", a.ParamDefinition.arrayToOptions(["off", "symmetric", "offset"])), includeParent: a.ParamDefinition.Boolean(!1), sizeFactor: a.ParamDefinition.Numeric(0.01, { min: 0.01, max: 10, step: 0.01 }), unitKinds: (0, u.getUnitKindsParam)(["atomic"]), visuals: a.ParamDefinition.MultiSelect(["intra-bond", "inter-bond", "element-point", "element-cross", "charge-text"], a.ParamDefinition.objectToOptions(p)), lineSizeAttenuation: a.ParamDefinition.Boolean(!0), traceOnly: a.ParamDefinition.Boolean(!1, { isHidden: !0 }), pointSizeAttenuation: a.ParamDefinition.Boolean(!0), pointStyle: a.ParamDefinition.Select("circle", a.ParamDefinition.objectToOptions(m)) });
  function v(y, C) {
    var S = a.ParamDefinition.clone(e.LineParams);
    return S.pointStyle.defaultValue = "circle", S;
  }
  e.getLineParams = v;
  function h(y, C) {
    return s.Representation.createMulti("Line", y, C, c.StructureRepresentationStateBuilder, p);
  }
  e.LineRepresentation = h, e.LineRepresentationProvider = (0, c.StructureRepresentationProvider)({
    name: "line",
    label: "Line",
    description: "Displays bonds as lines and atoms as points or croses.",
    factory: h,
    getParams: v,
    defaultValues: a.ParamDefinition.getDefaultValues(e.LineParams),
    defaultColorTheme: { name: "element-symbol" },
    defaultSizeTheme: { name: "uniform" },
    isApplicable: function(y) {
      return y.elementCount > 0;
    },
    getData: function(y, C) {
      return C.includeParent ? y.asParent() : y;
    },
    mustRecreate: function(y, C) {
      return y.includeParent !== C.includeParent;
    }
  });
})($j);
Object.defineProperty(AA, "__esModule", { value: !0 });
AA.LineRepr = void 0;
var Bm = Te, WT = $j;
AA.LineRepr = {
  create: function(e, r, t) {
    var n;
    return (0, Bm.__awaiter)(this, void 0, void 0, function() {
      var a;
      return (0, Bm.__generator)(this, function(i) {
        switch (i.label) {
          case 0:
            return a = WT.LineRepresentationProvider.factory(r, WT.LineRepresentationProvider.getParams), a.setTheme(t ?? {
              color: r.colorThemeRegistry.create("element-symbol", {
                structure: e
              }),
              size: r.sizeThemeRegistry.create("uniform", {
                structure: e
              })
            }), [4, a.createOrUpdate((0, Bm.__assign)((0, Bm.__assign)({}, WT.LineRepresentationProvider.defaultValues), { aromaticBonds: ((n = e.model) === null || n === void 0 ? void 0 : n.sourceData.kind) === "mmCIF", quality: "auto", visuals: r.props.hideBond ? ["element-point", "element-cross", "charge-text"] : ["element-point", "element-cross", "charge-text", "intra-bond", "inter-bond"] }), e).run()];
          case 1:
            return i.sent(), [2, a];
        }
      });
    });
  },
  update: function(e, r, t, n) {
    return (0, Bm.__awaiter)(this, void 0, void 0, function() {
      return (0, Bm.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return e.setTheme(n ?? {
              color: t.colorThemeRegistry.create("element-symbol", {
                structure: r
              }),
              size: t.sizeThemeRegistry.create("uniform", {
                structure: r
              })
            }), [4, e.createOrUpdate({
              visuals: t.props.hideBond ? ["element-point", "element-cross", "charge-text"] : ["element-point", "element-cross", "charge-text", "intra-bond", "inter-bond"]
            }, r).run()];
          case 1:
            return a.sent(), [
              2
              /*return*/
            ];
        }
      });
    });
  }
};
var xA = {}, Zj = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.StickRepresentationProvider = e.StickRepresentation = e.getStickParams = e.StickParams = void 0;
  var r = Te, t = lD, n = cD, a = fA, i = Le, o = $0(), c = oA(), s = Ss(), u = Wt, l = qt, f = Xt, d = mA, m = {
    "element-sphere": function(h, y) {
      return (0, o.UnitsRepresentation)("Element sphere", h, y, a.ElementSphereVisual);
    },
    "intra-bond": function(h, y) {
      return (0, o.UnitsRepresentation)("Intra-unit bond cylinder", h, y, t.IntraUnitBondCylinderVisual);
    },
    "inter-bond": function(h, y) {
      return (0, c.ComplexRepresentation)("Inter-unit bond cylinder", h, y, n.InterUnitBondCylinderVisual);
    },
    "charge-text": function(h, y) {
      return (0, c.ComplexRepresentation)("Charge Text", h, y, d.ChargeTextVisual);
    }
  };
  e.StickParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.ElementSphereParams), { traceOnly: i.ParamDefinition.Boolean(!1, { isHidden: !0 }) }), t.IntraUnitBondCylinderParams), n.InterUnitBondCylinderParams), { includeParent: i.ParamDefinition.Boolean(!1), unitKinds: (0, l.getUnitKindsParam)(["atomic"]), visuals: i.ParamDefinition.MultiSelect(["element-sphere", "intra-bond", "inter-bond", "charge-text"], i.ParamDefinition.objectToOptions(m)), bumpFrequency: i.ParamDefinition.Numeric(0, { min: 0, max: 10, step: 0.1 }, f.BaseGeometry.ShadingCategory), sizeFactor: i.ParamDefinition.Numeric(0.15, { min: 0.01, max: 10, step: 0.01 }), sizeAspectRatio: i.ParamDefinition.Numeric(1, { min: 0.01, max: 3, step: 0.01 }), multipleBonds: i.ParamDefinition.Select("offset", i.ParamDefinition.arrayToOptions(["off", "symmetric", "offset"])), tryUseImpostor: i.ParamDefinition.Boolean(!0), linkScale: i.ParamDefinition.Numeric(0.55, { min: 0, max: 1, step: 0.01 }) });
  function p(h, y) {
    return i.ParamDefinition.clone(e.StickParams);
  }
  e.getStickParams = p;
  function v(h, y) {
    return u.Representation.createMulti("Ball & Stick", h, y, s.StructureRepresentationStateBuilder, m);
  }
  e.StickRepresentation = v, e.StickRepresentationProvider = (0, s.StructureRepresentationProvider)({
    name: "stick",
    label: "Stick",
    description: "Displays atoms as spheres and bonds as cylinders.",
    factory: v,
    getParams: p,
    defaultValues: i.ParamDefinition.getDefaultValues(e.StickParams),
    defaultColorTheme: { name: "element-symbol" },
    defaultSizeTheme: { name: "uniform" },
    isApplicable: function(h) {
      return h.elementCount > 0;
    },
    getData: function(h, y) {
      return y.includeParent ? h.asParent() : h;
    },
    mustRecreate: function(h, y) {
      return h.includeParent !== y.includeParent;
    }
  });
})(Zj);
Object.defineProperty(xA, "__esModule", { value: !0 });
xA.StickRepr = void 0;
var Nm = Te, XT = Zj;
xA.StickRepr = {
  create: function(e, r, t) {
    var n;
    return (0, Nm.__awaiter)(this, void 0, void 0, function() {
      var a;
      return (0, Nm.__generator)(this, function(i) {
        switch (i.label) {
          case 0:
            return a = XT.StickRepresentationProvider.factory(r, XT.StickRepresentationProvider.getParams), a.setTheme(t ?? {
              color: r.colorThemeRegistry.create("element-symbol", {
                structure: e
              }),
              size: r.sizeThemeRegistry.create("uniform", {
                structure: e
              })
            }), [4, a.createOrUpdate((0, Nm.__assign)((0, Nm.__assign)({}, XT.StickRepresentationProvider.defaultValues), { aromaticBonds: ((n = e.model) === null || n === void 0 ? void 0 : n.sourceData.kind) === "mmCIF", quality: "auto", visuals: r.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"] }), e).run()];
          case 1:
            return i.sent(), [2, a];
        }
      });
    });
  },
  update: function(e, r, t, n) {
    return (0, Nm.__awaiter)(this, void 0, void 0, function() {
      return (0, Nm.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return e.setTheme(n ?? {
              color: t.colorThemeRegistry.create("element-symbol", {
                structure: r
              }),
              size: t.sizeThemeRegistry.create("uniform", {
                structure: r
              })
            }), [4, e.createOrUpdate({
              visuals: t.props.hideBond ? ["element-sphere", "charge-text"] : ["element-sphere", "intra-bond", "inter-bond", "charge-text"]
            }, r).run()];
          case 1:
            return a.sent(), [
              2
              /*return*/
            ];
        }
      });
    });
  }
};
var h1 = {}, Jj = {}, e$ = {}, TA = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.calcMolecularSurface = e.DefaultMolecularSurfaceCalculationProps = e.MolecularSurfaceCalculationParams = void 0;
  var r = Te, t = Re, n = Le, a = Qe(), i = bc, o = nr(), c = Xt;
  function s(f, d) {
    return f[0] = f[1] = f[2] = 1, d[0] !== 0 ? f[0] = (d[1] + d[2]) / -d[0] : d[1] !== 0 ? f[1] = (d[0] + d[2]) / -d[1] : d[2] !== 0 && (f[2] = (d[0] + d[1]) / -d[2]), f;
  }
  function u(f) {
    for (var d = 0, m = 2 * Math.PI / f, p = new Float32Array(f), v = new Float32Array(f), h = 0; h < f; h++)
      p[h] = Math.cos(d), v[h] = Math.sin(d), d += m;
    return { cosTable: p, sinTable: v };
  }
  e.MolecularSurfaceCalculationParams = {
    probeRadius: n.ParamDefinition.Numeric(1.4, { min: 0, max: 10, step: 0.1 }, { description: "Radius of the probe tracing the molecular surface." }),
    resolution: n.ParamDefinition.Numeric(0.5, { min: 0.01, max: 20, step: 0.01 }, (0, r.__assign)({ description: "Grid resolution/cell spacing." }, c.BaseGeometry.CustomQualityParamInfo)),
    probePositions: n.ParamDefinition.Numeric(36, { min: 12, max: 90, step: 1 }, (0, r.__assign)({ description: "Number of positions tested for probe target intersection." }, c.BaseGeometry.CustomQualityParamInfo))
  }, e.DefaultMolecularSurfaceCalculationProps = n.ParamDefinition.getDefaultValues(e.MolecularSurfaceCalculationParams);
  function l(f, d, m, p, v, h) {
    return (0, r.__awaiter)(this, void 0, void 0, function() {
      function y(Ee, Me, ue, pe, Ae) {
        if (M !== -1) {
          var ye = M;
          if (ye !== pe && ye !== Ae && C(ye, Ee, Me, ue))
            return ye;
          M = -1;
        }
        for (var be = 0, fe = k.count; be < fe; ++be) {
          var ye = a.OrderedSet.getAt(G, k.indices[be]);
          if (ye !== pe && ye !== Ae && C(ye, Ee, Me, ue))
            return M = ye, ye;
        }
        return -1;
      }
      function C(Ee, Me, ue, pe) {
        var Ae = H[Ee], ye = L[Ee] - Me, be = R[Ee] - ue, fe = F[Ee] - pe, ge = ye * ye + be * be + fe * fe;
        return ge < Ae * Ae;
      }
      function S(Ee, Me) {
        for (var ue = Ee; ue < Me; ++ue) {
          var pe = a.OrderedSet.getAt(G, ue), Ae = L[pe], ye = R[pe], be = F[pe], fe = H[pe], ge = fe * fe;
          V.find(Ae, ye, be, fe);
          for (var xe = Math.ceil(fe * D), we = Math.floor(D * (Ae - Z)), Ve = Math.floor(D * (ye - J)), Ne = Math.floor(D * (be - $)), Oe = Math.max(0, we - xe), ze = Math.max(0, Ve - xe), ke = Math.max(0, Ne - xe), je = Math.min(te, we + xe + 2), Xe = Math.min(oe, Ve + xe + 2), Fe = Math.min(z, Ne + xe + 2), He = Oe; He < je; ++He)
            for (var Be = de[He] - Ae, Ye = He * le, cr = ze; cr < Xe; ++cr)
              for (var Ar = me[cr] - ye, Lr = Be * Be + Ar * Ar, It = cr * j + Ye, en = ke; en < Fe; ++en) {
                var Sn = he[en] - be, Wn = Lr + Sn * Sn;
                if (Wn < ge) {
                  var oa = en + It;
                  se[oa] < 0 && (se[oa] *= -1);
                  var La = Math.sqrt(Wn), ci = fe / La, Do = Be * ci + Ae, nu = Ar * ci + ye, Di = Sn * ci + be;
                  if (y(Do, nu, Di, pe, -1) === -1) {
                    var xa = fe - La;
                    xa < se[oa] && (se[oa] = xa, ce[oa] = U[ue]);
                  }
                }
              }
        }
      }
      function b() {
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var Ee;
          return (0, r.__generator)(this, function(Me) {
            switch (Me.label) {
              case 0:
                Ee = 0, Me.label = 1;
              case 1:
                return Ee < q ? (S(Ee, Math.min(Ee + _e, q)), f.shouldUpdate ? [4, f.update({ message: "projecting points", current: Ee, max: q })] : [3, 3]) : [3, 4];
              case 2:
                Me.sent(), Me.label = 3;
              case 3:
                return Ee += _e, [3, 1];
              case 4:
                return [
                  2
                  /*return*/
                ];
            }
          });
        });
      }
      function g(Ee, Me) {
        var ue = H[Ee], pe = H[Me], Ae = P[0] = L[Me] - L[Ee], ye = P[1] = R[Me] - R[Ee], be = P[2] = F[Me] - F[Ee], fe = Ae * Ae + ye * ye + be * be, ge = Math.sqrt(fe), xe = (ue * ue + ge * ge - pe * pe) / (2 * ue * ge), we = ue * xe;
        t.Vec3.normalize(P, P), s(x, P), t.Vec3.normalize(x, x), t.Vec3.cross(w, P, x), t.Vec3.normalize(w, w);
        var Ve = Math.sqrt(ue * ue - we * we);
        t.Vec3.scale(x, x, Ve), t.Vec3.scale(w, w, Ve), t.Vec3.scale(P, P, we), T[0] = P[0] + L[Ee], T[1] = P[1] + R[Ee], T[2] = P[2] + F[Ee], M = -1;
        for (var Ne = 0; Ne < B; ++Ne) {
          var Oe = re[Ne], ze = ee[Ne], ke = T[0] + Oe * x[0] + ze * w[0], je = T[1] + Oe * x[1] + ze * w[1], Xe = T[2] + Oe * x[2] + ze * w[2];
          if (y(ke, je, Xe, Ee, Me) === -1)
            for (var Fe = Math.floor(D * (ke - Z)), He = Math.floor(D * (je - J)), Be = Math.floor(D * (Xe - $)), Ye = Math.max(0, Fe - N), cr = Math.max(0, He - N), Ar = Math.max(0, Be - N), Lr = Math.min(te, Fe + N + 2), It = Math.min(oe, He + N + 2), en = Math.min(z, Be + N + 2), Sn = Ye; Sn < Lr; ++Sn)
              for (var Wn = ke - de[Sn], oa = Sn * le, La = cr; La < It; ++La)
                for (var ci = je - me[La], Do = Wn * Wn + ci * ci, nu = La * j + oa, Di = Ar; Di < en; ++Di) {
                  var xa = Xe - he[Di], Yr = Do + xa * xa, rn = Di + nu, Ps = se[rn];
                  if (Ps > 0 && Yr < Ps * Ps) {
                    se[rn] = Math.sqrt(Yr);
                    var Ge = Wn * P[0] + ci * P[1] + xa * P[2];
                    ce[rn] = U[a.OrderedSet.indexOf(G, Ge < 0 ? Me : Ee)];
                  }
                }
        }
      }
      function _(Ee, Me) {
        for (var ue = Ee; ue < Me; ++ue) {
          var pe = a.OrderedSet.getAt(G, ue);
          V.find(L[pe], R[pe], F[pe], H[pe]);
          for (var Ae = 0, ye = k.count; Ae < ye; ++Ae) {
            var be = a.OrderedSet.getAt(G, k.indices[Ae]);
            pe < be && g(pe, be);
          }
        }
      }
      function A() {
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var Ee;
          return (0, r.__generator)(this, function(Me) {
            switch (Me.label) {
              case 0:
                Ee = 0, Me.label = 1;
              case 1:
                return Ee < q ? (_(Ee, Math.min(Ee + _e, q)), f.shouldUpdate ? [4, f.update({ message: "projecting torii", current: Ee, max: q })] : [3, 3]) : [3, 4];
              case 2:
                Me.sent(), Me.label = 3;
              case 3:
                return Ee += _e, [3, 1];
              case 4:
                return [
                  2
                  /*return*/
                ];
            }
          });
        });
      }
      var M, P, T, x, w, E, I, B, D, N, O, V, k, G, L, R, F, U, H, q, K, Y, X, Z, J, $, Q, W, te, oe, z, j, ae, le, ie, re, ee, ne, se, ce, de, me, he, _e, Se, Pe, De;
      return (0, r.__generator)(this, function(Ee) {
        switch (Ee.label) {
          case 0:
            return M = -1, P = (0, t.Vec3)(), T = (0, t.Vec3)(), x = (0, t.Vec3)(), w = (0, t.Vec3)(), E = h.resolution, I = h.probeRadius, B = h.probePositions, D = 1 / E, N = Math.max(5, 2 + Math.floor(I * D)), O = t.Vec3.create(p, p, p), t.Vec3.scale(O, O, 2), V = (0, o.GridLookup3D)(d, m, O), k = V.result, v === null && (v = V.boundary.box), G = d.indices, L = d.x, R = d.y, F = d.z, U = d.id, H = d.radius, q = a.OrderedSet.size(G), K = p + E, Y = o.Box3D.expand((0, o.Box3D)(), v, t.Vec3.create(K, K, K)), X = Y.min, Z = X[0], J = X[1], $ = X[2], Q = o.Box3D.scale((0, o.Box3D)(), Y, D), W = o.Box3D.size((0, t.Vec3)(), Q), t.Vec3.ceil(W, W), te = W[0], oe = W[1], z = W[2], j = z, ae = oe, le = j * ae, ie = u(B), re = ie.cosTable, ee = ie.sinTable, ne = t.Tensor.Space(W, [0, 1, 2], Float32Array), se = ne.create(), ce = ne.create(), se.fill(-1001), ce.fill(-1), de = (0, o.fillGridDim)(te, Z, E), me = (0, o.fillGridDim)(oe, J, E), he = (0, o.fillGridDim)(z, $, E), _e = Math.ceil(1e5 / (Math.pow(Math.pow(p, 3), 3) * D)), [
              4,
              b()
              // console.timeEnd('MolecularSurface projectPoints')
              // console.time('MolecularSurface projectTorii')
            ];
          case 1:
            return Ee.sent(), [
              4,
              A()
              // console.timeEnd('MolecularSurface projectTorii')
              // console.timeEnd('MolecularSurface')
            ];
          case 2:
            return Ee.sent(), Se = t.Tensor.create(ne, se), Pe = t.Tensor.create(ne, ce), De = i.Mat4.identity(), i.Mat4.fromScaling(De, t.Vec3.create(E, E, E)), i.Mat4.setTranslation(De, Y.min), [2, { field: Se, idField: Pe, transform: De, resolution: E, maxRadius: p }];
        }
      });
    });
  }
  e.calcMolecularSurface = l;
})(TA);
var Ry = {};
Object.defineProperty(Ry, "__esModule", { value: !0 });
Ry.computeUnitMolecularSurface = void 0;
var rp = Te, Ebe = Kr, r$ = bl, Dbe = TA, YT = Qe();
function Ibe(e, r, t, n) {
  for (var a = n.probeRadius, i = (0, r$.getUnitConformationAndRadius)(e, r, t, n), o = i.position, c = i.boundary, s = i.radius, u = o.indices, l = YT.OrderedSet.size(u), f = new Float32Array(YT.OrderedSet.end(u)), d = 0, m = 0; m < l; ++m) {
    var p = YT.OrderedSet.getAt(u, m), v = s(p);
    d < v && (d = v), f[p] = v + a;
  }
  return { position: (0, rp.__assign)((0, rp.__assign)({}, o), { radius: f }), boundary: c, maxRadius: d };
}
function Bbe(e, r, t, n) {
  var a = this, i = r.lookup3d.boundary.box, o = (0, r$.ensureReasonableResolution)(i, n), c = Ibe(e, r, t, o), s = c.position, u = c.boundary, l = c.maxRadius;
  return Ebe.Task.create("Molecular Surface", function(f) {
    return (0, rp.__awaiter)(a, void 0, void 0, function() {
      return (0, rp.__generator)(this, function(d) {
        switch (d.label) {
          case 0:
            return [4, Nbe(f, s, u, l, i, o)];
          case 1:
            return [2, d.sent()];
        }
      });
    });
  });
}
Ry.computeUnitMolecularSurface = Bbe;
function Nbe(e, r, t, n, a, i) {
  return (0, rp.__awaiter)(this, void 0, void 0, function() {
    return (0, rp.__generator)(this, function(o) {
      return [2, (0, Dbe.calcMolecularSurface)(e, r, t, n, a, i)];
    });
  });
}
var Rd = {}, PA = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.AllowedContours = e.TriTable = e.EdgeTable = e.EdgeIdInfo = e.CubeEdges = e.CubeVertices = e.EdgesYZ = e.EdgesXZ = e.EdgesXY = e.IndexPair = e.Index = void 0;
  function r(n, a, i) {
    return { i: n, j: a, k: i };
  }
  e.Index = r;
  function t(n, a) {
    return { a: n, b: a };
  }
  e.IndexPair = t, e.EdgesXY = [
    [],
    [0, 3],
    [0, 1],
    [1, 3],
    [1, 2],
    [0, 1, 1, 2, 2, 3, 0, 3],
    [0, 2],
    [2, 3],
    [2, 3],
    [0, 2],
    [0, 1, 1, 2, 2, 3, 0, 3],
    [1, 2],
    [1, 3],
    [0, 1],
    [0, 3],
    []
  ], e.EdgesXZ = [
    [],
    [0, 8],
    [0, 9],
    [9, 8],
    [9, 4],
    [0, 9, 9, 4, 4, 8, 0, 8],
    [0, 4],
    [4, 8],
    [4, 8],
    [0, 4],
    [0, 9, 9, 4, 4, 8, 0, 8],
    [9, 4],
    [9, 8],
    [0, 9],
    [0, 8],
    []
  ], e.EdgesYZ = [
    [],
    [3, 8],
    [3, 11],
    [11, 8],
    [11, 7],
    [3, 11, 11, 7, 7, 8, 3, 8],
    [3, 7],
    [7, 8],
    [7, 8],
    [3, 7],
    [3, 11, 11, 7, 7, 8, 3, 8],
    [11, 7],
    [11, 8],
    [3, 11],
    [3, 8],
    []
  ], e.CubeVertices = [
    r(0, 0, 0),
    r(1, 0, 0),
    r(1, 1, 0),
    r(0, 1, 0),
    r(0, 0, 1),
    r(1, 0, 1),
    r(1, 1, 1),
    r(0, 1, 1)
    // h
  ], e.CubeEdges = [
    t(e.CubeVertices[0], e.CubeVertices[1]),
    t(e.CubeVertices[1], e.CubeVertices[2]),
    t(e.CubeVertices[2], e.CubeVertices[3]),
    t(e.CubeVertices[3], e.CubeVertices[0]),
    t(e.CubeVertices[4], e.CubeVertices[5]),
    t(e.CubeVertices[5], e.CubeVertices[6]),
    t(e.CubeVertices[6], e.CubeVertices[7]),
    t(e.CubeVertices[7], e.CubeVertices[4]),
    t(e.CubeVertices[0], e.CubeVertices[4]),
    t(e.CubeVertices[1], e.CubeVertices[5]),
    t(e.CubeVertices[2], e.CubeVertices[6]),
    t(e.CubeVertices[3], e.CubeVertices[7])
  ], e.EdgeIdInfo = [
    { 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 }
  ], e.EdgeTable = [
    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
  ], e.TriTable = [
    [],
    [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],
    []
  ], e.AllowedContours = [
    [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]
  ];
})(PA);
var tp = {};
Object.defineProperty(tp, "__esModule", { value: !0 });
tp.MarchinCubesLinesBuilder = tp.MarchinCubesMeshBuilder = void 0;
var Mn = wr(), Vbe = We(), Rbe = Dt(), QT = PA, Obe = pl();
function Fbe(e, r) {
  var t = Math.min(65536, e * 4), n = Mn.ChunkedArray.create(Float32Array, 3, e, r && r.vertexBuffer.ref.value), a = Mn.ChunkedArray.create(Float32Array, 3, e, r && r.normalBuffer.ref.value), i = Mn.ChunkedArray.create(Float32Array, 1, e, r && r.groupBuffer.ref.value), o = Mn.ChunkedArray.create(Uint32Array, 3, t, r && r.indexBuffer.ref.value), c = 0, s = 0;
  return {
    addVertex: function(u, l, f) {
      return ++c, Mn.ChunkedArray.add3(n, u, l, f);
    },
    addNormal: function(u, l, f) {
      Mn.ChunkedArray.add3(a, u, l, f);
    },
    addGroup: function(u) {
      Mn.ChunkedArray.add(i, u);
    },
    addTriangle: function(u, l, f, d) {
      var m = u[l], p = u[f], v = u[d];
      m >= 0 && p >= 0 && v >= 0 && (++s, Mn.ChunkedArray.add3(o, m, p, v));
    },
    get: function() {
      var u = Mn.ChunkedArray.compact(n, !0), l = Mn.ChunkedArray.compact(a, !0), f = Mn.ChunkedArray.compact(o, !0), d = Mn.ChunkedArray.compact(i, !0);
      return Rbe.Mesh.create(u, f, l, d, c, s, r);
    }
  };
}
tp.MarchinCubesMeshBuilder = Fbe;
function Lbe(e, r) {
  var t = Mn.ChunkedArray.create(Float32Array, 3, e), n = Mn.ChunkedArray.create(Float32Array, 1, e), a = Mn.ChunkedArray.create(Float32Array, 2, e), i = 0;
  return {
    addVertex: function(o, c, s) {
      return Mn.ChunkedArray.add3(t, o, c, s);
    },
    addNormal: function() {
      return Vbe.noop;
    },
    addGroup: function(o) {
      Mn.ChunkedArray.add(n, o);
    },
    addTriangle: function(o, c, s, u, l) {
      var f = o[c], d = o[s], m = o[u];
      f >= 0 && d >= 0 && m >= 0 && (QT.AllowedContours[c][s] & l && (++i, Mn.ChunkedArray.add2(a, o[c], o[s])), QT.AllowedContours[s][u] & l && (++i, Mn.ChunkedArray.add2(a, o[s], o[u])), QT.AllowedContours[c][u] & l && (++i, Mn.ChunkedArray.add2(a, o[c], o[u])));
    },
    get: function() {
      for (var o = Mn.ChunkedArray.compact(t, !0), c = Mn.ChunkedArray.compact(a, !0), s = Mn.ChunkedArray.compact(n, !0), u = Obe.LinesBuilder.create(i, i / 10, r), l = 0; l < i; ++l) {
        var f = c[l * 2], d = c[l * 2 + 1];
        u.add(o[f * 3], o[f * 3 + 1], o[f * 3 + 2], o[d * 3], o[d * 3 + 1], o[d * 3 + 2], s[f]);
      }
      return u.getLines();
    }
  };
}
tp.MarchinCubesLinesBuilder = Lbe;
Object.defineProperty(Rd, "__esModule", { value: !0 });
Rd.computeMarchingCubesLines = Rd.computeMarchingCubesMesh = void 0;
var Qs = Te, t$ = Kr, c_ = PA, nV = We(), n$ = tp;
function a$(e) {
  return (0, Qs.__assign)((0, Qs.__assign)({}, e), { bottomLeft: (0, nV.defaults)(e.bottomLeft, [0, 0, 0]), topRight: (0, nV.defaults)(e.topRight, e.scalarField.space.dimensions) });
}
function i$(e) {
  return {
    dX: e.topRight[0] - e.bottomLeft[0],
    dY: e.topRight[1] - e.bottomLeft[1],
    dZ: e.topRight[2] - e.bottomLeft[2]
  };
}
function kbe(e, r) {
  var t = this;
  return t$.Task.create("Marching Cubes Mesh", function(n) {
    return (0, Qs.__awaiter)(t, void 0, void 0, function() {
      var a, i, o, c, s, u, l;
      return (0, Qs.__generator)(this, function(f) {
        switch (f.label) {
          case 0:
            return a = a$(e), i = i$(a), o = i.dX, c = i.dY, s = i.dZ, u = Math.min(262144, Math.max(o * c * s / 32, 1024)), l = (0, n$.MarchinCubesMeshBuilder)(u, r), [4, new o$(n, l, a).run()];
          case 1:
            return f.sent(), [2, l.get()];
        }
      });
    });
  });
}
Rd.computeMarchingCubesMesh = kbe;
function Ube(e, r) {
  var t = this;
  return t$.Task.create("Marching Cubes Lines", function(n) {
    return (0, Qs.__awaiter)(t, void 0, void 0, function() {
      var a, i, o, c, s, u, l;
      return (0, Qs.__generator)(this, function(f) {
        switch (f.label) {
          case 0:
            return a = a$(e), i = i$(a), o = i.dX, c = i.dY, s = i.dZ, u = Math.min(262144, Math.max(o * c * s / 32, 1024)), l = (0, n$.MarchinCubesLinesBuilder)(u, r), [4, new o$(n, l, a).run()];
          case 1:
            return f.sent(), [2, l.get()];
        }
      });
    });
  });
}
Rd.computeMarchingCubesLines = Ube;
var o$ = (
  /** @class */
  function() {
    function e(r, t, n) {
      this.ctx = r, this.minX = 0, this.minY = 0, this.minZ = 0, this.maxX = 0, this.maxY = 0, this.maxZ = 0, this.state = new zbe(t, 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 (0, Qs.__awaiter)(this, void 0, void 0, function() {
        var r, t;
        return (0, Qs.__generator)(this, function(n) {
          switch (n.label) {
            case 0:
              r = 0, this.edgeFilter = 15, t = this.minZ, n.label = 1;
            case 1:
              return t < this.maxZ ? (this.slice(t), r += this.sliceSize, this.ctx.shouldUpdate ? [4, this.ctx.update({ message: "Computing surface...", current: r, max: this.size })] : [3, 3]) : [3, 4];
            case 2:
              n.sent(), n.label = 3;
            case 3:
              return t++, this.edgeFilter &= -5, [3, 1];
            case 4:
              return [
                2
                /*return*/
              ];
          }
        });
      });
    }, e.prototype.slice = function(r) {
      this.edgeFilter |= 2;
      for (var t = this.minY; t < this.maxY; t++, this.edgeFilter &= -3) {
        this.edgeFilter |= 1;
        for (var n = this.minX; n < this.maxX; n++, this.edgeFilter &= -2)
          this.state.processCell(n, t, r, this.edgeFilter);
      }
      this.state.clearEdgeVertexIndexSlice(r);
    }, e.prototype.run = function() {
      return (0, Qs.__awaiter)(this, void 0, void 0, function() {
        return (0, Qs.__generator)(this, function(r) {
          switch (r.label) {
            case 0:
              return [4, this.doSlices()];
            case 1:
              return r.sent(), [
                2
                /*return*/
              ];
          }
        });
      });
    }, e;
  }()
), zbe = (
  /** @class */
  function() {
    function e(r, t) {
      this.builder = r, 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 = t.scalarField.space.dimensions;
      this.nX = n[0], this.nY = n[1], this.nZ = n[2], this.isoLevel = t.isoLevel, this.scalarFieldGet = t.scalarField.space.get, this.scalarField = t.scalarField.data, t.idField && (this.idField = t.idField.data, this.idFieldGet = t.idField.space.get), this.verticesOnEdges = new Int32Array(3 * this.nX * this.nY * 2);
    }
    return e.prototype.get3dOffsetFromEdgeInfo = function(r) {
      return this.nX * ((this.k + r.k) % 2 * this.nY + this.j + r.j) + this.i + r.i;
    }, e.prototype.clearEdgeVertexIndexSlice = function(r) {
      var t = r % 2 === 0 ? 0 : 3 * this.nX * this.nY, n = r % 2 === 0 ? 3 * this.nX * this.nY : this.verticesOnEdges.length;
      this.verticesOnEdges.fill(0, t, n);
    }, e.prototype.interpolate = function(r) {
      var t = c_.EdgeIdInfo[r], n = 3 * this.get3dOffsetFromEdgeInfo(t) + t.e, a = this.verticesOnEdges[n];
      if (a > 0)
        return a - 1;
      var i = this.scalarField, o = this.scalarFieldGet, c = c_.CubeEdges[r], s = c.a, u = c.b, l = s.i + this.i, f = s.j + this.j, d = s.k + this.k, m = u.i + this.i, p = u.j + this.j, v = u.k + this.k, h = o(i, l, f, d), y = o(i, m, p, v), C = (this.isoLevel - h) / (h - y);
      if (this.idField) {
        var S = this.idFieldGet(this.idField, l, f, d), b = this.idFieldGet(this.idField, m, p, v), g = C < 0.5 ? S : b;
        if (g === -1 && (g = C < 0.5 ? b : S), g === -2)
          return -1;
        this.builder.addGroup(g);
      } else
        this.builder.addGroup(0);
      var _ = this.builder.addVertex(l + C * (l - m), f + C * (f - p), d + C * (d - v));
      this.verticesOnEdges[n] = _ + 1;
      var A = o(i, Math.max(0, l - 1), f, d) - o(i, Math.min(this.nX - 1, l + 1), f, d), M = o(i, l, Math.max(0, f - 1), d) - o(i, l, Math.min(this.nY - 1, f + 1), d), P = o(i, l, f, Math.max(0, d - 1)) - o(i, l, f, Math.min(this.nZ, d + 1)), T = o(i, Math.max(0, m - 1), p, v) - o(i, Math.min(this.nX - 1, m + 1), p, v), x = o(i, m, Math.max(0, p - 1), v) - o(i, m, Math.min(this.nY - 1, p + 1), v), w = o(i, m, p, Math.max(0, v - 1)) - o(i, m, p, Math.min(this.nZ - 1, v + 1)), E = A + C * (A - T), I = M + C * (M - x), B = P + C * (P - w);
      return this.isoLevel >= 0 ? this.builder.addNormal(E, I, B) : this.builder.addNormal(-E, -I, -B), _;
    }, e.prototype.get = function(r, t, n) {
      return this.scalarFieldGet(this.scalarField, r, t, n);
    }, e.prototype.processCell = function(r, t, n, a) {
      var i = 0;
      if (this.get(r, t, n) < this.isoLevel && (i |= 1), this.get(r + 1, t, n) < this.isoLevel && (i |= 2), this.get(r + 1, t + 1, n) < this.isoLevel && (i |= 4), this.get(r, t + 1, n) < this.isoLevel && (i |= 8), this.get(r, t, n + 1) < this.isoLevel && (i |= 16), this.get(r + 1, t, n + 1) < this.isoLevel && (i |= 32), this.get(r + 1, t + 1, n + 1) < this.isoLevel && (i |= 64), this.get(r, t + 1, n + 1) < this.isoLevel && (i |= 128), !(i === 0 || i === 255)) {
        this.i = r, this.j = t, this.k = n;
        var o = c_.EdgeTable[i];
        (o & 1) > 0 && (this.vertList[0] = this.interpolate(0)), (o & 2) > 0 && (this.vertList[1] = this.interpolate(1)), (o & 4) > 0 && (this.vertList[2] = this.interpolate(2)), (o & 8) > 0 && (this.vertList[3] = this.interpolate(3)), (o & 16) > 0 && (this.vertList[4] = this.interpolate(4)), (o & 32) > 0 && (this.vertList[5] = this.interpolate(5)), (o & 64) > 0 && (this.vertList[6] = this.interpolate(6)), (o & 128) > 0 && (this.vertList[7] = this.interpolate(7)), (o & 256) > 0 && (this.vertList[8] = this.interpolate(8)), (o & 512) > 0 && (this.vertList[9] = this.interpolate(9)), (o & 1024) > 0 && (this.vertList[10] = this.interpolate(10)), (o & 2048) > 0 && (this.vertList[11] = this.interpolate(11));
        for (var c = c_.TriTable[i], s = 0; s < c.length; s += 3) {
          var u = c[s], l = c[s + 1], f = c[s + 2];
          this.isoLevel >= 0 ? this.builder.addTriangle(this.vertList, u, l, f, a) : this.builder.addTriangle(this.vertList, f, l, u, a);
        }
      }
    }, e;
  }()
);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.MolecularSurfaceMeshVisual = e.MolecularSurfaceMeshParams = void 0;
  var r = Te, t = Le, n = Mr, a = TA, i = Dt(), o = Ry, c = Rd, s = W0, u = bl, l = nr(), f = Gi, d = Xt;
  e.MolecularSurfaceMeshParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, n.UnitsMeshParams), a.MolecularSurfaceCalculationParams), u.CommonSurfaceParams), d.ColorSmoothingParams);
  function m(v, h, y, C, S, b) {
    return (0, r.__awaiter)(this, void 0, void 0, function() {
      var g, _, A, M, P, T, x, w, E, I;
      return (0, r.__generator)(this, function(B) {
        switch (B.label) {
          case 0:
            return [4, (0, o.computeUnitMolecularSurface)(y, h, C.size, S).runInContext(v.runtime)];
          case 1:
            return g = B.sent(), _ = g.transform, A = g.field, M = g.idField, P = g.resolution, T = g.maxRadius, x = {
              isoLevel: S.probeRadius,
              scalarField: A,
              idField: M
            }, [4, (0, c.computeMarchingCubesMesh)(x, b).runAsChild(v.runtime)];
          case 2:
            return w = B.sent(), S.includeParent && (E = Math.ceil(2 / S.resolution), i.Mesh.smoothEdges(w, { iterations: E, maxNewEdgeLength: Math.sqrt(2) })), i.Mesh.transform(w, _), v.webgl && !v.webgl.isWebGL2 && i.Mesh.uniformTriangleGroup(w), I = l.Sphere3D.expand((0, l.Sphere3D)(), h.boundary.sphere, T), w.setBoundingSphere(I), w.meta.resolution = P, [2, w];
        }
      });
    });
  }
  function p(v) {
    return (0, n.UnitsMeshVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.MolecularSurfaceMeshParams),
      createGeometry: m,
      createLocationIterator: s.ElementIterator.fromGroup,
      getLoci: s.getElementLoci,
      eachLocation: s.eachElement,
      setUpdateState: function(h, y, C) {
        y.resolution !== C.resolution && (h.createGeometry = !0), y.probeRadius !== C.probeRadius && (h.createGeometry = !0), y.probePositions !== C.probePositions && (h.createGeometry = !0), y.ignoreHydrogens !== C.ignoreHydrogens && (h.createGeometry = !0), y.traceOnly !== C.traceOnly && (h.createGeometry = !0), y.includeParent !== C.includeParent && (h.createGeometry = !0), y.smoothColors.name !== C.smoothColors.name ? h.updateColor = !0 : y.smoothColors.name === "on" && C.smoothColors.name === "on" && (y.smoothColors.params.resolutionFactor !== C.smoothColors.params.resolutionFactor && (h.updateColor = !0), y.smoothColors.params.sampleStride !== C.smoothColors.params.sampleStride && (h.updateColor = !0));
      },
      processValues: function(h, y, C, S, b) {
        var g = y.meta, _ = g.resolution, A = g.colorTexture, M = (0, d.getColorSmoothingProps)(C.smoothColors, S.color.preferSmoothing, _);
        M && ((0, f.applyMeshColorSmoothing)(h, M.resolution, M.stride, b, A), y.meta.colorTexture = h.tColorGrid.ref.value);
      },
      dispose: function(h) {
        var y;
        (y = h.meta.colorTexture) === null || y === void 0 || y.destroy();
      }
    }, v);
  }
  e.MolecularSurfaceMeshVisual = p;
})(e$);
var u$ = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.MolecularSurfaceWireframeVisual = e.MolecularSurfaceWireframeParams = void 0;
  var r = Te, t = Le, n = Mr, a = TA, i = Fa(), o = Ry, c = Rd, s = W0, u = bl, l = nr();
  e.MolecularSurfaceWireframeParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, n.UnitsLinesParams), a.MolecularSurfaceCalculationParams), u.CommonSurfaceParams), { sizeFactor: t.ParamDefinition.Numeric(1.5, { min: 0, max: 10, step: 0.1 }) });
  function f(m, p, v, h, y, C) {
    return (0, r.__awaiter)(this, void 0, void 0, function() {
      var S, b, g, _, A, M, P, T;
      return (0, r.__generator)(this, function(x) {
        switch (x.label) {
          case 0:
            return [4, (0, o.computeUnitMolecularSurface)(v, p, h.size, y).runInContext(m.runtime)];
          case 1:
            return S = x.sent(), b = S.transform, g = S.field, _ = S.idField, A = S.maxRadius, M = {
              isoLevel: y.probeRadius,
              scalarField: g,
              idField: _
            }, [4, (0, c.computeMarchingCubesLines)(M, C).runAsChild(m.runtime)];
          case 2:
            return P = x.sent(), i.Lines.transform(P, b), T = l.Sphere3D.expand((0, l.Sphere3D)(), p.boundary.sphere, A), P.setBoundingSphere(T), [2, P];
        }
      });
    });
  }
  function d(m) {
    return (0, n.UnitsLinesVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.MolecularSurfaceWireframeParams),
      createGeometry: f,
      createLocationIterator: s.ElementIterator.fromGroup,
      getLoci: s.getElementLoci,
      eachLocation: s.eachElement,
      setUpdateState: function(p, v, h) {
        v.resolution !== h.resolution && (p.createGeometry = !0), v.probeRadius !== h.probeRadius && (p.createGeometry = !0), v.probePositions !== h.probePositions && (p.createGeometry = !0), v.ignoreHydrogens !== h.ignoreHydrogens && (p.createGeometry = !0), v.includeParent !== h.includeParent && (p.createGeometry = !0);
      }
    }, m);
  }
  e.MolecularSurfaceWireframeVisual = d;
})(u$);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.MolecularSurfaceRepresentationProvider = e.MolecularSurfaceRepresentation = e.getMolecularSurfaceParams = e.MolecularSurfaceParams = void 0;
  var r = Te, t = e$, n = $0(), a = Le, i = Ss(), o = Wt, c = u$, s = Xt, u = {
    "molecular-surface-mesh": function(d, m) {
      return (0, n.UnitsRepresentation)("Molecular surface mesh", d, m, t.MolecularSurfaceMeshVisual);
    },
    "molecular-surface-wireframe": function(d, m) {
      return (0, n.UnitsRepresentation)("Molecular surface wireframe", d, m, c.MolecularSurfaceWireframeVisual);
    }
  };
  e.MolecularSurfaceParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, t.MolecularSurfaceMeshParams), c.MolecularSurfaceWireframeParams), { visuals: a.ParamDefinition.MultiSelect(["molecular-surface-mesh"], a.ParamDefinition.objectToOptions(u)), bumpFrequency: a.ParamDefinition.Numeric(1, { min: 0, max: 10, step: 0.1 }, s.BaseGeometry.ShadingCategory) });
  function l(d, m) {
    return a.ParamDefinition.clone(e.MolecularSurfaceParams);
  }
  e.getMolecularSurfaceParams = l;
  function f(d, m) {
    return o.Representation.createMulti("Molecular Surface", d, m, i.StructureRepresentationStateBuilder, u);
  }
  e.MolecularSurfaceRepresentation = f, e.MolecularSurfaceRepresentationProvider = (0, i.StructureRepresentationProvider)({
    name: "molecular-surface",
    label: "Molecular Surface",
    description: "Displays a molecular surface.",
    factory: f,
    getParams: l,
    defaultValues: a.ParamDefinition.getDefaultValues(e.MolecularSurfaceParams),
    defaultColorTheme: { name: "chain-id" },
    defaultSizeTheme: { name: "physical" },
    isApplicable: function(d) {
      return d.elementCount > 0;
    }
  });
})(Jj);
var aV;
function Gbe() {
  if (aV) return h1;
  aV = 1, Object.defineProperty(h1, "__esModule", { value: !0 }), h1.SurfaceRepr = void 0;
  var e = Te, r = Jt, t = Jj, n = Je(), a = sn();
  return h1.SurfaceRepr = {
    parse: function(i, o) {
      var c, s = o.managers.cell.get(i.ref), u = (0, a.getStructureByCell)(s);
      return u ? (0, a.getStructureByElementIds)(u, (c = i.elementIds) !== null && c !== void 0 ? c : [], !0) : n.Structure.Empty;
    },
    createTheme: function(i, o, c) {
      return o.managers.representation.createTheme(r.RepresentationType.Surface, this.parse(i, o), c);
    },
    create: function(i, o, c) {
      return (0, e.__awaiter)(this, void 0, void 0, function() {
        var s;
        return (0, e.__generator)(this, function(u) {
          switch (u.label) {
            case 0:
              return s = t.MolecularSurfaceRepresentationProvider.factory(o, t.MolecularSurfaceRepresentationProvider.getParams), s.setTheme(c ?? {
                color: o.colorThemeRegistry.create("element-symbol", {
                  structure: i
                }),
                size: o.sizeThemeRegistry.create("physical", {
                  structure: i
                })
              }), [4, s.createOrUpdate((0, e.__assign)((0, e.__assign)({}, t.MolecularSurfaceRepresentationProvider.defaultValues), { quality: "auto" }), i).run()];
            case 1:
              return u.sent(), [2, s];
          }
        });
      });
    },
    update: function(i, o, c, s) {
      return (0, e.__awaiter)(this, void 0, void 0, function() {
        return (0, e.__generator)(this, function(u) {
          switch (u.label) {
            case 0:
              return i.setTheme(s ?? {
                color: c.colorThemeRegistry.create("element-symbol", {
                  structure: o
                }),
                size: c.sizeThemeRegistry.create("physical", {
                  structure: o
                })
              }), [4, i.createOrUpdate({}, o).run()];
            case 1:
              return u.sent(), [
                2
                /*return*/
              ];
          }
        });
      });
    }
  }, h1;
}
var MA = {}, s$ = {}, vo = {};
Object.defineProperty(vo, "__esModule", { value: !0 });
vo.OctagonalPyramidCage = vo.PyramidCage = vo.PerforatedOctagonalPyramid = vo.OctagonalPyramid = vo.TriangularPyramid = vo.Pyramid = void 0;
var $a = Re, l$ = ya, wA = $d, qbe = $a.Vec3.create(0, 0, -0.5), db = $a.Vec3.create(0, 0, 0.5), jc = (0, $a.Vec3)(), $c = (0, $a.Vec3)(), d_ = (0, $a.Vec3)(), iV = (0, $a.Vec3)();
function hD(e) {
  for (var r = e.length / 3, t = r === 3 ? 1 : r === 4 ? 2 : r, n = t + r, a = r === 4 ? r * 3 + 4 : n * 3, i = (0, l$.PrimitiveBuilder)(n, a), o = 0; o < r; ++o) {
    var c = (o + 1) % r;
    $a.Vec3.set(jc, e[o * 3], e[o * 3 + 1], -0.5), $a.Vec3.set($c, e[c * 3], e[c * 3 + 1], -0.5), i.add(jc, $c, db);
  }
  if (r === 3)
    $a.Vec3.set(jc, e[0], e[1], -0.5), $a.Vec3.set($c, e[3], e[4], -0.5), $a.Vec3.set(d_, e[6], e[7], -0.5), i.add(d_, $c, jc);
  else if (r === 4)
    $a.Vec3.set(jc, e[0], e[1], -0.5), $a.Vec3.set($c, e[3], e[4], -0.5), $a.Vec3.set(d_, e[6], e[7], -0.5), $a.Vec3.set(iV, e[9], e[10], -0.5), i.addQuad(iV, d_, $c, jc);
  else
    for (var o = 0; o < r; ++o) {
      var c = (o + 1) % r;
      $a.Vec3.set(jc, e[o * 3], e[o * 3 + 1], -0.5), $a.Vec3.set($c, e[c * 3], e[c * 3 + 1], -0.5), i.add(qbe, $c, jc);
    }
  return i.getPrimitive();
}
vo.Pyramid = hD;
var ZT;
function Hbe() {
  return ZT || (ZT = hD((0, wA.polygon)(3, !0))), ZT;
}
vo.TriangularPyramid = Hbe;
var JT;
function jbe() {
  return JT || (JT = hD((0, wA.polygon)(8, !0))), JT;
}
vo.OctagonalPyramid = jbe;
var eP;
function $be() {
  if (!eP) {
    for (var e = (0, wA.polygon)(8, !0), r = new Float32Array(8 * 3 + 6), t = 0; t < 8; ++t)
      r[t * 3] = e[t * 3], r[t * 3 + 1] = e[t * 3 + 1], r[t * 3 + 2] = -0.5;
    r[8 * 3] = 0, r[8 * 3 + 1] = 0, r[8 * 3 + 2] = -0.5, r[8 * 3 + 3] = 0, r[8 * 3 + 4] = 0, r[8 * 3 + 5] = 0.5;
    var n = [
      0,
      1,
      8,
      1,
      2,
      8,
      4,
      5,
      8,
      5,
      6,
      8,
      2,
      3,
      9,
      3,
      4,
      9,
      6,
      7,
      9,
      7,
      0,
      9
    ];
    eP = (0, l$.createPrimitive)(r, n);
  }
  return eP;
}
vo.PerforatedOctagonalPyramid = $be;
function c$(e) {
  var r = e.length / 3, t = [], n = [], a = 1;
  t.push(db[0], db[1], db[2]);
  for (var i = 0; i < r; ++i)
    t.push(e[i * 3], e[i * 3 + 1], -0.5), n.push(0, a), a += 1;
  for (var i = 0; i < r; ++i) {
    var o = (i + 1) % r;
    n.push(i + 1, o + 1);
  }
  return { vertices: t, edges: n };
}
vo.PyramidCage = c$;
var rP;
function Kbe() {
  return rP || (rP = c$((0, wA.polygon)(8, !0))), rP;
}
vo.OctagonalPyramidCage = Kbe;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.RotateArrowRepresentation = e.getRotateArrowParams = e.RotateArrowArrowHeadParams = e.RotateArrowCylinderParams = e.RotateArrowParams = void 0;
  var r = Te, t = hl(), n = dA, a = Fa(), i = Dt(), o = Ca(), c = vo, s = Re, u = ui(), l = Tr(), f = Oa, d = _n, m = Le, p = Wt, v = Ss(), h = wo, y = {
    center: m.ParamDefinition.Vec3((0, s.Vec3)()),
    vec: m.ParamDefinition.Vec3((0, s.Vec3)()),
    color: m.ParamDefinition.Color(l.Color.fromRgb(255, 196, 36)),
    alpha: m.ParamDefinition.Numeric(0.9, { min: 0, max: 1, step: 0.1 })
  }, C = {
    "rotate-arrow-cylinder": function(A, M) {
      return (0, h.ShapeRepresentation)(S, t.Cylinders.Utils, { modifyState: function(P) {
        return (0, r.__assign)((0, r.__assign)({}, P), { markerActions: d.MarkerActions.All });
      } });
    },
    "rotate-arrow-arrowhead": function(A, M) {
      return (0, h.ShapeRepresentation)(b, i.Mesh.Utils);
    }
  };
  e.RotateArrowParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.Lines.Params), y), { visuals: m.ParamDefinition.MultiSelect(["rotate-arrow-cylinder", "rotate-arrow-arrowhead"], m.ParamDefinition.objectToOptions(C)) }), e.RotateArrowCylinderParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, t.Cylinders.Params), y), { color: m.ParamDefinition.Color(l.Color.fromRgb(255, 196, 36)), sizeFactor: m.ParamDefinition.Numeric(0.1, { min: 0, max: 10, step: 0.1 }) }), e.RotateArrowArrowHeadParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, i.Mesh.Params), y), { color: m.ParamDefinition.Color(f.ColorNames.brown) });
  function S(A, M, P, T) {
    var x = P.center, w = P.vec, E = s.Vec3.create(0, 0, 0);
    s.Vec3.normalize(E, w);
    var I = s.Vec3.create(0, 0, 0);
    s.Vec3.scale(I, E, 0.25);
    var B = s.Vec3.create(0, 0, 0);
    s.Vec3.sub(B, w, I);
    var D = s.Vec3.create(0, 0, 0);
    s.Vec3.add(D, x, B);
    var N = s.Vec3.create(0, 0, 0);
    s.Vec3.scale(N, E, 0.45), s.Vec3.sub(D, D, N);
    var O = n.CylindersBuilder.create(128, 64);
    return O.add(x[0], x[1], x[2], D[0], D[1], D[2], 0.05, !0, !0, 2), u.Shape.create("RotateArrow-cylinder", P, O.getCylinders(), function() {
      return P.color;
    }, function() {
      return P.sizeFactor;
    }, function() {
      return "RotateArrow";
    });
  }
  function b(A, M, P, T) {
    var x = o.MeshBuilder.createState(256, 128), w = (0, c.OctagonalPyramid)(), E = P.center, I = P.vec, B = s.Vec3.create(0, 0, 0);
    s.Vec3.normalize(B, I);
    var D = s.Vec3.create(0, 0, 0);
    s.Vec3.scale(D, B, 0.1);
    var N = s.Vec3.create(0, 0, 0);
    s.Vec3.sub(N, I, D);
    var O = s.Vec3.create(0, 0, 0);
    s.Vec3.add(O, E, N);
    var V = s.Vec3.create(0, 0, 0), k = s.Vec3.create(0, 0, 0);
    s.Vec3.scale(k, B, 0.35), s.Vec3.sub(V, O, k);
    var G = 0.4, L = s.Mat4.identity(), R = (0, s.Vec3)();
    return s.Vec3.add(R, V, I), s.Mat4.targetTo(L, R, V, s.Vec3.create(1, 0, 0)), s.Mat4.setTranslation(L, V), x.currentGroup = 0, s.Mat4.scaleUniformly(L, L, G * 1.5), o.MeshBuilder.addPrimitive(x, L, w), u.Shape.create("axes", P, o.MeshBuilder.getMesh(x), function() {
      return P.color;
    }, function() {
      return 0.05;
    }, function() {
      return "";
    });
  }
  function g(A) {
    return m.ParamDefinition.clone(e.RotateArrowParams);
  }
  e.getRotateArrowParams = g;
  function _(A, M) {
    var P = p.Representation.createMulti("RotateArrow", A, M, v.StructureRepresentationStateBuilder, C);
    return P.setState({ markerActions: d.MarkerActions.All }), P;
  }
  e.RotateArrowRepresentation = _;
})(s$);
Object.defineProperty(MA, "__esModule", { value: !0 });
MA.RotateArrowRepr = void 0;
var f_ = Te, oV = s$;
MA.RotateArrowRepr = {
  create: function(e, r, t) {
    return (0, f_.__awaiter)(this, void 0, void 0, function() {
      var n;
      return (0, f_.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return n = (0, oV.RotateArrowRepresentation)(r, function() {
              return oV.RotateArrowParams;
            }), [4, n.createOrUpdate(e, e).run()];
          case 1:
            return a.sent(), [2, n];
        }
      });
    });
  },
  update: function(e, r, t, n) {
    return (0, f_.__awaiter)(this, void 0, void 0, function() {
      return (0, f_.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return [4, e.createOrUpdate(r, r).run()];
          case 1:
            return a.sent(), [
              2
              /*return*/
            ];
        }
      });
    });
  }
};
var EA = {}, d$ = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.SpacefillRepresentationProvider = e.SpacefillRepresentation = e.getSpacefillParams = e.SpacefillParams = void 0;
  var r = Te, t = fA, n = $0(), a = Le, i = Ss(), o = Wt, c = Xt, s = {
    "element-sphere": function(f, d) {
      return (0, n.UnitsRepresentation)("Sphere mesh", f, d, t.ElementSphereVisual);
    }
  };
  e.SpacefillParams = (0, r.__assign)((0, r.__assign)({}, t.ElementSphereParams), { bumpFrequency: a.ParamDefinition.Numeric(1, { min: 0, max: 10, step: 0.1 }, c.BaseGeometry.ShadingCategory) });
  function u(f, d) {
    var m = a.ParamDefinition.clone(e.SpacefillParams);
    return d.isCoarseGrained && (m.sizeFactor.defaultValue = 2), m;
  }
  e.getSpacefillParams = u;
  function l(f, d) {
    return o.Representation.createMulti("Spacefill", f, d, i.StructureRepresentationStateBuilder, s);
  }
  e.SpacefillRepresentation = l, e.SpacefillRepresentationProvider = (0, i.StructureRepresentationProvider)({
    name: "spacefill",
    label: "Spacefill",
    description: "Displays atomic/coarse elements as spheres.",
    factory: l,
    getParams: u,
    defaultValues: a.ParamDefinition.getDefaultValues(e.SpacefillParams),
    defaultColorTheme: { name: "element-symbol" },
    defaultSizeTheme: { name: "physical" },
    isApplicable: function(f) {
      return f.elementCount > 0;
    }
  });
})(d$);
Object.defineProperty(EA, "__esModule", { value: !0 });
EA.CPKRepr = void 0;
var Vm = Te, tP = d$;
EA.CPKRepr = {
  create: function(e, r, t) {
    return (0, Vm.__awaiter)(this, void 0, void 0, function() {
      var n;
      return (0, Vm.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return n = tP.SpacefillRepresentationProvider.factory(r, tP.SpacefillRepresentationProvider.getParams), n.setTheme(t ?? {
              color: r.colorThemeRegistry.create("element-symbol", {
                structure: e
              }),
              size: r.sizeThemeRegistry.create("physical", {
                structure: e
              })
            }), [4, n.createOrUpdate((0, Vm.__assign)((0, Vm.__assign)({}, tP.SpacefillRepresentationProvider.defaultValues), { quality: "auto" }), e).run()];
          case 1:
            return a.sent(), [2, n];
        }
      });
    });
  },
  update: function(e, r, t, n) {
    return (0, Vm.__awaiter)(this, void 0, void 0, function() {
      return (0, Vm.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return e.setTheme(n ?? {
              color: t.colorThemeRegistry.create("element-symbol", {
                structure: r
              }),
              size: t.sizeThemeRegistry.create("physical", {
                structure: r
              })
            }), [4, e.createOrUpdate({}, r).run()];
          case 1:
            return a.sent(), [
              2
              /*return*/
            ];
        }
      });
    });
  }
};
var DA = {}, Pd = {};
Object.defineProperty(Pd, "__esModule", { value: !0 });
Pd.GridPocketRepresentation = Pd.getGridPocketData = Pd.GridPocketParams = void 0;
var Wu = Te, uV = wo, f$ = ui(), J1 = Oa, qs = Le, gv = Dt(), eg = Ca(), Wbe = ns, Dn = Re, l3 = wu, k1 = nr(), m_ = Xd(), nP = Yd(), sV = Wt, Xbe = Dn.Mat4.fromTranslation((0, Dn.Mat4)(), Dn.Vec3.create(0.5, 0.5, 0.5)), Ybe = (0, l3.transformCage)((0, l3.cloneCage)((0, Wbe.BoxCage)()), Xbe), Uf = (0, Dn.Vec3)(), lV = (0, Dn.Mat4)(), m$ = (0, Wu.__assign)((0, Wu.__assign)({}, gv.Mesh.Params), { alpha: (0, Wu.__assign)((0, Wu.__assign)({}, gv.Mesh.Params.alpha), { defaultValue: 0.51 }), ignoreLight: (0, Wu.__assign)((0, Wu.__assign)({}, gv.Mesh.Params.ignoreLight), { defaultValue: !0 }), colorX: qs.ParamDefinition.Color(J1.ColorNames.red, { isEssential: !0 }), colorY: qs.ParamDefinition.Color(J1.ColorNames.green, { isEssential: !0 }), colorZ: qs.ParamDefinition.Color(J1.ColorNames.blue, { isEssential: !0 }), scale: qs.ParamDefinition.Numeric(2, { min: 0.1, max: 5, step: 0.1 }) }), Qbe = (0, Wu.__assign)((0, Wu.__assign)((0, Wu.__assign)({}, gv.Mesh.Params), m$), { pocketColor: qs.ParamDefinition.Color(J1.ColorNames.red), pocketScale: qs.ParamDefinition.Numeric(4, { min: 0.1, max: 5, step: 0.1 }), x: qs.ParamDefinition.Numeric(10), y: qs.ParamDefinition.Numeric(10), z: qs.ParamDefinition.Numeric(10), center: qs.ParamDefinition.Vec3((0, Dn.Vec3)()) });
Pd.GridPocketParams = (0, Wu.__assign)((0, Wu.__assign)({}, Qbe), m$);
var Zbe = {
  axes: function(e, r) {
    return (0, uV.ShapeRepresentation)(n3e, gv.Mesh.Utils);
  },
  mesh: function(e, r) {
    return (0, uV.ShapeRepresentation)(e3e, gv.Mesh.Utils);
  }
};
function Jbe(e, r, t) {
  var n = eg.MeshBuilder.createState(256, 128, t), a = e.gridPocket.fromFractional;
  Dn.Vec3.copy(Uf, e.ref), Dn.Vec3.subScalar(Uf, Uf, 0.5), Dn.Mat4.fromTranslation(lV, Uf);
  var i = (0, l3.transformCage)((0, l3.cloneCage)(Ybe), lV), o = Math.cbrt(e.gridPocket.volume) / 300 * r.pocketScale;
  n.currentGroup = 1, eg.MeshBuilder.addCage(n, a, i, o, 2, 20);
  var c = k1.Sphere3D.fromDimensionsAndTransform((0, k1.Sphere3D)(), Dn.Vec3.unit, a);
  Dn.Vec3.transformMat4(Uf, Uf, a), k1.Sphere3D.translate(c, c, Uf), k1.Sphere3D.expand(c, c, o);
  var s = eg.MeshBuilder.getMesh(n);
  return s.setBoundingSphere(c), s;
}
function e3e(e, r, t, n) {
  var a = Jbe(r, t, n && n.geometry), i = "Grid Pocket Box";
  return f$.Shape.create(i, r, a, function() {
    return t.pocketColor;
  }, function() {
    return 1;
  }, function() {
    return i;
  });
}
function r3e(e, r, t, n) {
  var a = (0, Dn.Vec3)(), i = Dn.Mat4.ofRows([
    [e, 0, 0, 0],
    [0, r, 0, 0],
    [0, 0, t, 0],
    [0, 0, 0, 1]
  ]), o = Dn.Mat4.invert(Dn.Mat4.zero(), i), c = {
    ref: Dn.Vec3.transformMat4(a, n, o),
    gridPocket: {
      fromFractional: i,
      toFractional: o,
      x: e,
      y: r,
      z: t,
      center: n,
      volume: e * r * t
    }
  };
  return c;
}
Pd.getGridPocketData = r3e;
function t3e(e, r, t) {
  var n = r.gridPocket, a = n.x, i = n.y, o = n.z, c = n.center, s = n.volume, u = eg.MeshBuilder.createState(512, 256, t), l = Math.cbrt(s) / 300 * e, f = c[0], d = c[1], m = c[2], p = Math.min(a, i, o), v = Dn.Vec3.create(f + p / 3, d, m), h = Dn.Vec3.create(f, d + p / 3, m), y = Dn.Vec3.create(f, d, m + p / 3), C = { radiusTop: l, radiusBottom: l, radialSegments: 32 };
  return u.currentGroup = 0, (0, m_.addSphere)(u, c, l, 2), u.currentGroup = 1, (0, m_.addSphere)(u, v, l, 2), (0, nP.addCylinder)(u, c, v, 1, C), u.currentGroup = 2, (0, m_.addSphere)(u, h, l, 2), (0, nP.addCylinder)(u, c, h, 1, C), u.currentGroup = 3, (0, m_.addSphere)(u, y, l, 2), (0, nP.addCylinder)(u, c, y, 1, C), Dn.Vec3.scale(v, v, 0.5), Dn.Vec3.scale(h, h, 0.5), Dn.Vec3.scale(y, y, 0.5), eg.MeshBuilder.getMesh(u);
}
function n3e(e, r, t, n) {
  var a = t.scale, i = t3e(a, r, n == null ? void 0 : n.geometry);
  i.setBoundingSphere(k1.Sphere3D.create(Dn.Vec3.create(a / 2, a / 2, a / 2), a + a / 4));
  var o = function(c) {
    switch (c) {
      case 1:
        return t.colorX;
      case 2:
        return t.colorY;
      case 3:
        return t.colorZ;
      default:
        return J1.ColorNames.grey;
    }
  };
  return f$.Shape.create("axes", {}, i, o, function() {
    return 1;
  }, function() {
    return "";
  });
}
function a3e(e, r) {
  return sV.Representation.createMulti("Grid Pocket", e, r, sV.Representation.StateBuilder, Zbe);
}
Pd.GridPocketRepresentation = a3e;
Object.defineProperty(DA, "__esModule", { value: !0 });
DA.PocketRepr = void 0;
var v_ = Te, p_ = Pd;
DA.PocketRepr = {
  create: function(e, r, t) {
    return (0, v_.__awaiter)(this, void 0, void 0, function() {
      var n, a, i, o, c;
      return (0, v_.__generator)(this, function(s) {
        switch (s.label) {
          case 0:
            return n = (0, p_.GridPocketRepresentation)(r, function() {
              return p_.GridPocketParams;
            }), a = e.x, i = e.y, o = e.z, c = e.center, [4, n.createOrUpdate(e, (0, p_.getGridPocketData)(a, i, o, c)).run()];
          case 1:
            return s.sent(), [2, n];
        }
      });
    });
  },
  update: function(e, r, t, n) {
    return (0, v_.__awaiter)(this, void 0, void 0, function() {
      var a, i, o, c;
      return (0, v_.__generator)(this, function(s) {
        switch (s.label) {
          case 0:
            return a = r.x, i = r.y, o = r.z, c = r.center, [4, e.createOrUpdate(r, (0, p_.getGridPocketData)(a, i, o, c)).run()];
          case 1:
            return s.sent(), [
              2
              /*return*/
            ];
        }
      });
    });
  }
};
var IA = {}, v$ = {}, p$ = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.Tetrahedron1 = e.TetrahedronCage = e.Tetrahedron = e.tetrahedronIndices = e.tetrahedronVertices = void 0;
  var r = ya, t = wu;
  e.tetrahedronVertices = [
    3,
    3,
    3,
    -3,
    -3,
    3,
    -3,
    3,
    -3,
    3,
    -3,
    -3
  ], e.tetrahedronIndices = [
    2,
    1,
    0,
    0,
    3,
    2,
    1,
    3,
    0,
    2,
    3,
    1
  ];
  var n = [
    0,
    1,
    1,
    2,
    2,
    0,
    0,
    3,
    1,
    3,
    2,
    3
  ], a;
  function i() {
    return a || (a = (0, r.createPrimitive)(e.tetrahedronVertices, e.tetrahedronIndices)), a;
  }
  e.Tetrahedron = i;
  var o = (0, t.createCage)(e.tetrahedronVertices, n);
  function c() {
    return o;
  }
  e.TetrahedronCage = c;
  function s(u) {
    return (0, r.createPrimitive)(u, e.tetrahedronIndices);
  }
  e.Tetrahedron1 = s;
})(p$);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.PharmacophoreRepresentation = e.getPharmacophoreParams = e.getPharmacophoreSphere2 = e.getPharmacophoreSphere1 = e.addSphere = e.getSphere = e.PharmacophoreArrowHeadParams = e.PharmacophoreCylinderParams = e.PharmacophoreSphere2Params = e.PharmacophoreSphere1Params = e.PharmacophoreParams = void 0;
  var r = Te, t = hl(), n = dA, a = Fa(), i = pl(), o = Dt(), c = Ca(), s = Ep(), u = dD, l = gA, f = ya, d = vc, m = p$, p = Re, v = ui(), h = Oa, y = _n, C = Le, S = Wt, b = Ss(), g = wo, _ = {
    radiusFactor: C.ParamDefinition.Numeric(1, { min: 0.1, max: 3, step: 0.01 }, { description: "Scale the radius of the membrane layer" }),
    center: C.ParamDefinition.Vec3((0, p.Vec3)()),
    radius: C.ParamDefinition.Numeric(1),
    vec: C.ParamDefinition.Vec3((0, p.Vec3)())
  }, A = {
    "pharmacophore-ball-1": function(U, H) {
      return (0, g.ShapeRepresentation)(T, a.Lines.Utils, { modifyState: function(q) {
        return (0, r.__assign)((0, r.__assign)({}, q), { markerActions: y.MarkerActions.All });
      } });
    },
    "pharmacophore-ball-2": function(U, H) {
      return (0, g.ShapeRepresentation)(x, a.Lines.Utils, { modifyState: function(q) {
        return (0, r.__assign)((0, r.__assign)({}, q), { markerActions: y.MarkerActions.All });
      } });
    },
    "pharmacophore-sphere-1": function(U, H) {
      return (0, g.ShapeRepresentation)(V, s.Spheres.Utils, { modifyState: function(q) {
        return (0, r.__assign)((0, r.__assign)({}, q), { markerActions: y.MarkerActions.All });
      } });
    },
    "pharmacophore-sphere-2": function(U, H) {
      return (0, g.ShapeRepresentation)(k, s.Spheres.Utils, { modifyState: function(q) {
        return (0, r.__assign)((0, r.__assign)({}, q), { markerActions: y.MarkerActions.All });
      } });
    },
    "pharmacophore-cylinder": function(U, H) {
      return (0, g.ShapeRepresentation)(G, t.Cylinders.Utils, { modifyState: function(q) {
        return (0, r.__assign)((0, r.__assign)({}, q), { markerActions: y.MarkerActions.All });
      } });
    },
    // 'pharmacophore-arrow': (ctx: RepresentationContext, getParams: RepresentationParamsGetter<PharmacophoreData, PharmacophoreArrowParams>) => ShapeRepresentation(getPharmacophoreArrow, Lines.Utils, { modifyState: s => ({ ...s, markerActions: MarkerActions.Highlighting }) })
    "pharmacophore-arrowhead": function(U, H) {
      return (0, g.ShapeRepresentation)(L, o.Mesh.Utils);
    }
  }, M = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.Lines.Params), _), { color: C.ParamDefinition.Color(h.ColorNames.blue), lineSizeAttenuation: C.ParamDefinition.Boolean(!1), linesSize: C.ParamDefinition.Numeric(1, { min: 0.01, max: 50, step: 0.01 }), dashedLines: C.ParamDefinition.Boolean(!1), alpha: C.ParamDefinition.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), P = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.Lines.Params), _), { color: C.ParamDefinition.Color(h.ColorNames.blue), lineSizeAttenuation: C.ParamDefinition.Boolean(!1), linesSize: C.ParamDefinition.Numeric(1, { min: 0.01, max: 50, step: 0.01 }), dashedLines: C.ParamDefinition.Boolean(!1), alpha: C.ParamDefinition.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) });
  e.PharmacophoreParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, M), P), { visuals: C.ParamDefinition.MultiSelect(["pharmacophore-ball-1", "pharmacophore-ball-2", "pharmacophore-sphere-1", "pharmacophore-sphere-2", "pharmacophore-cylinder", "pharmacophore-arrowhead"], C.ParamDefinition.objectToOptions(A)), alpha: C.ParamDefinition.Numeric(0.2, { min: 0, max: 1, step: 0.1 }) }), e.PharmacophoreSphere1Params = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, s.Spheres.Params), _), { sizeFactor: C.ParamDefinition.Numeric(1, { min: 0, max: 10, step: 0.1 }), color: C.ParamDefinition.Color(h.ColorNames.green), alpha: C.ParamDefinition.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), e.PharmacophoreSphere2Params = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, s.Spheres.Params), _), { sizeFactor: C.ParamDefinition.Numeric(1, { min: 0, max: 10, step: 0.1 }), color: C.ParamDefinition.Color(h.ColorNames.brown), alpha: C.ParamDefinition.Numeric(0.2, { min: 0, max: 0.4, step: 0.1 }) }), e.PharmacophoreCylinderParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, t.Cylinders.Params), _), { color: C.ParamDefinition.Color(h.ColorNames.brown), sizeFactor: C.ParamDefinition.Numeric(0.1, { min: 0, max: 10, step: 0.1 }) }), e.PharmacophoreArrowHeadParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, o.Mesh.Params), _), { color: C.ParamDefinition.Color(h.ColorNames.brown) });
  function T(U, H, q, K) {
    var Y = q.radiusFactor, X = q.center, Z = q.radius, J = Y * Z, $ = i.LinesBuilder.create(128, 64, K == null ? void 0 : K.geometry), Q = p.Vec3.create(0, 0, 0);
    p.Vec3.add(Q, X, p.Vec3.create(0, 1, 0));
    var W = p.Vec3.create(0, 0, 0);
    p.Vec3.add(W, X, p.Vec3.create(0, 0, 1));
    var te = p.Vec3.create(0, 0, 0);
    p.Vec3.add(te, X, p.Vec3.create(1, 0, 0)), w($, X, Q, J, q), w($, X, W, J, q), w($, X, te, J, q);
    {
      var oe = p.Vec3.create(0, 0, 0);
      p.Vec3.add(oe, X, p.Vec3.create(0, 0.5 * J, 0));
      var z = p.Vec3.create(0, 0, 0);
      p.Vec3.add(z, oe, p.Vec3.create(0, Math.sqrt(0.75), 0)), w($, oe, z, Math.sqrt(0.75) * J, q);
      var j = p.Vec3.create(0, 0, 0);
      p.Vec3.add(j, X, p.Vec3.create(0, -0.5 * J, 0));
      var ae = p.Vec3.create(0, 0, 0);
      p.Vec3.add(ae, j, p.Vec3.create(0, -Math.sqrt(0.75), 0)), w($, j, ae, Math.sqrt(0.75) * J, q);
    }
    {
      var oe = p.Vec3.create(0, 0, 0);
      p.Vec3.add(oe, X, p.Vec3.create(0.5 * J, 0, 0));
      var z = p.Vec3.create(0, 0, 0);
      p.Vec3.add(z, oe, p.Vec3.create(Math.sqrt(0.75), 0, 0)), w($, oe, z, Math.sqrt(0.75) * J, q);
      var j = p.Vec3.create(0, 0, 0);
      p.Vec3.add(j, X, p.Vec3.create(-0.5 * J, 0, 0));
      var ae = p.Vec3.create(0, 0, 0);
      p.Vec3.add(ae, j, p.Vec3.create(-Math.sqrt(0.75), 0, 0)), w($, j, ae, Math.sqrt(0.75) * J, q);
    }
    {
      var oe = p.Vec3.create(0, 0, 0);
      p.Vec3.add(oe, X, p.Vec3.create(0, 0, 0.5 * J));
      var z = p.Vec3.create(0, 0, 0);
      p.Vec3.add(z, oe, p.Vec3.create(0, 0, Math.sqrt(0.75))), w($, oe, z, Math.sqrt(0.75) * J, q);
      var j = p.Vec3.create(0, 0, 0);
      p.Vec3.add(j, X, p.Vec3.create(0, 0, -0.5 * J));
      var ae = p.Vec3.create(0, 0, 0);
      p.Vec3.add(ae, j, p.Vec3.create(0, 0, -Math.sqrt(0.75))), w($, j, ae, Math.sqrt(0.75) * J, q);
    }
    return v.Shape.create("pharmacophore-ball-1", q, $.getLines(), function() {
      return q.color;
    }, function() {
      return q.linesSize;
    }, function() {
      return "pharmacophore";
    });
  }
  function x(U, H, q, K) {
    var Y = q.radiusFactor, X = q.center, Z = q.radius, J = q.vec, $ = Y * Z, Q = p.Vec3.create(0, 0, 0);
    p.Vec3.add(Q, X, J);
    var W = i.LinesBuilder.create(128, 64, K == null ? void 0 : K.geometry), te = p.Vec3.create(0, 0, 0);
    p.Vec3.add(te, Q, p.Vec3.create(0, 1, 0));
    var oe = p.Vec3.create(0, 0, 0);
    p.Vec3.add(oe, Q, p.Vec3.create(0, 0, 1));
    var z = p.Vec3.create(0, 0, 0);
    p.Vec3.add(z, Q, p.Vec3.create(1, 0, 0)), w(W, Q, te, $, q), w(W, Q, oe, $, q), w(W, Q, z, $, q);
    {
      var j = p.Vec3.create(0, 0, 0);
      p.Vec3.add(j, Q, p.Vec3.create(0, 0.5 * $, 0));
      var ae = p.Vec3.create(0, 0, 0);
      p.Vec3.add(ae, j, p.Vec3.create(0, Math.sqrt(0.75), 0)), w(W, j, ae, Math.sqrt(0.75) * $, q);
      var le = p.Vec3.create(0, 0, 0);
      p.Vec3.add(le, Q, p.Vec3.create(0, -0.5 * $, 0));
      var ie = p.Vec3.create(0, 0, 0);
      p.Vec3.add(ie, le, p.Vec3.create(0, -Math.sqrt(0.75), 0)), w(W, le, ie, Math.sqrt(0.75) * $, q);
    }
    {
      var j = p.Vec3.create(0, 0, 0);
      p.Vec3.add(j, Q, p.Vec3.create(0.5 * $, 0, 0));
      var ae = p.Vec3.create(0, 0, 0);
      p.Vec3.add(ae, j, p.Vec3.create(Math.sqrt(0.75), 0, 0)), w(W, j, ae, Math.sqrt(0.75) * $, q);
      var le = p.Vec3.create(0, 0, 0);
      p.Vec3.add(le, Q, p.Vec3.create(-0.5 * $, 0, 0));
      var ie = p.Vec3.create(0, 0, 0);
      p.Vec3.add(ie, le, p.Vec3.create(-Math.sqrt(0.75), 0, 0)), w(W, le, ie, Math.sqrt(0.75) * $, q);
    }
    {
      var j = p.Vec3.create(0, 0, 0);
      p.Vec3.add(j, Q, p.Vec3.create(0, 0, 0.5 * $));
      var ae = p.Vec3.create(0, 0, 0);
      p.Vec3.add(ae, j, p.Vec3.create(0, 0, Math.sqrt(0.75))), w(W, j, ae, Math.sqrt(0.75) * $, q);
      var le = p.Vec3.create(0, 0, 0);
      p.Vec3.add(le, Q, p.Vec3.create(0, 0, -0.5 * $));
      var ie = p.Vec3.create(0, 0, 0);
      p.Vec3.add(ie, le, p.Vec3.create(0, 0, -Math.sqrt(0.75))), w(W, le, ie, Math.sqrt(0.75) * $, q);
    }
    return v.Shape.create("pharmacophore-ball-2", q, W.getLines(), function() {
      return q.color;
    }, function() {
      return q.linesSize;
    }, function() {
      return "pharmacophore";
    });
  }
  function w(U, H, q, K, Y, X) {
    for (var Z = B(H, q, K), J = Z.indices, $ = Z.vertices, Q = 0, W = J.length; Q < W; Q += 3)
      if (!(Y.dashedLines && Q % 2 === 1)) {
        var te = J[Q] * 3, oe = J[Q + 1] * 3, z = $[te], j = $[te + 1], ae = $[te + 2], le = $[oe], ie = $[oe + 1], re = $[oe + 2];
        U.add(z, j, ae, le, ie, re, 0);
      }
  }
  var E = (0, p.Mat4)(), I = (0, p.Vec3)();
  function B(U, H, q) {
    p.Vec3.dot(p.Vec3.unitY, p.Vec3.sub(I, U, H)) === 0 ? p.Mat4.targetTo(E, U, H, p.Vec3.unitY) : p.Mat4.targetTo(E, U, H, p.Vec3.unitX), p.Mat4.setTranslation(E, U), p.Mat4.mul(E, E, p.Mat4.rotX90);
    var K = (0, l.Circle)({ radius: q, segments: 64 });
    return (0, f.transformPrimitive)(K, E);
  }
  var D = /* @__PURE__ */ new Map();
  function N(U) {
    var H = D.get(U);
    return H === void 0 && (H = (0, d.Sphere)(U), D.set(U, H)), H;
  }
  e.getSphere = N;
  function O(U, H, q, K) {
    U.add(H[0], H[1], H[2], K);
  }
  e.addSphere = O;
  function V(U, H, q, K) {
    var Y = q.center, X = q.radius, Z = q.radiusFactor, J = u.SpheresBuilder.create(128, 64);
    return O(J, Y, X, 0), v.Shape.create("pharmacophore-sphere-1", (0, r.__assign)((0, r.__assign)({}, q), { sizeFactor: q.radius * 0.1 }), J.getSpheres(), function() {
      return q.color;
    }, function() {
      return X * Z / 2;
    }, function() {
      return "pharmacophore";
    });
  }
  e.getPharmacophoreSphere1 = V;
  function k(U, H, q, K) {
    var Y = q.center, X = q.radius, Z = q.vec, J = q.radiusFactor, $ = p.Vec3.create(0, 0, 0);
    p.Vec3.add($, Y, Z);
    var Q = u.SpheresBuilder.create(128, 64);
    return O(Q, $, X, 1), v.Shape.create("pharmacophore-sphere-2", (0, r.__assign)((0, r.__assign)({}, q), { sizeFactor: q.radius * 0.1 }), Q.getSpheres(), function() {
      return q.color;
    }, function() {
      return X * J / 2;
    }, function() {
      return "pharmacophore";
    });
  }
  e.getPharmacophoreSphere2 = k;
  function G(U, H, q, K) {
    var Y = q.center, X = q.vec, Z = p.Vec3.create(0, 0, 0);
    p.Vec3.normalize(Z, X);
    var J = p.Vec3.create(0, 0, 0);
    p.Vec3.scale(J, Z, 0.25);
    var $ = p.Vec3.create(0, 0, 0);
    p.Vec3.sub($, X, J);
    var Q = p.Vec3.create(0, 0, 0);
    p.Vec3.add(Q, Y, $);
    var W = p.Vec3.create(0, 0, 0);
    p.Vec3.scale(W, Z, 0.3), p.Vec3.sub(Q, Q, W);
    var te = n.CylindersBuilder.create(128, 64);
    return te.add(Y[0], Y[1], Y[2], Q[0], Q[1], Q[2], 0.025, !0, !0, 2), v.Shape.create("pharmacophore-cylinder", q, te.getCylinders(), function() {
      return q.color;
    }, function() {
      return q.sizeFactor;
    }, function() {
      return "pharmacophore";
    });
  }
  function L(U, H, q, K) {
    var Y = q.center, X = q.vec, Z = p.Vec3.create(0, 0, 0);
    p.Vec3.normalize(Z, X);
    var J = p.Vec3.create(0, 0, 0);
    p.Vec3.scale(J, Z, 0.25);
    var $ = p.Vec3.create(0, 0, 0);
    p.Vec3.sub($, X, J);
    var Q = p.Vec3.create(0, 0, 0);
    p.Vec3.add(Q, Y, $);
    var W = p.Vec3.create(0, 0, 0), te = p.Vec3.create(0, 0, 0);
    p.Vec3.scale(te, Z, 0.3), p.Vec3.sub(W, Q, te);
    var oe = p.Vec3.create(0, 0, 0), z = p.Vec3.create(1, 2, W[2] - (Z[0] * (1 - W[0]) + Z[1] * (2 - W[1])) / Z[2]);
    p.Vec3.sub(oe, z, W), p.Vec3.normalize(oe, oe);
    var j = p.Vec3.create(0, 0, 0);
    p.Vec3.scale(j, oe, 0.3);
    var ae = p.Vec3.create(0, 0, 0);
    p.Vec3.add(ae, W, j);
    var le = p.Vec3.create(0, 0, 0);
    p.Vec3.sub(le, ae, W);
    var ie = p.Vec3.create(0, 0, 0);
    {
      var re = p.Vec3.create(0, 0, 0);
      p.Vec3.scale(re, le, Math.cos(120 * Math.PI / 180));
      var ee = p.Vec3.create(0, 0, 0);
      p.Vec3.cross(ee, Z, le), p.Vec3.scale(ee, ee, Math.sin(120 * Math.PI / 180));
      var ne = p.Vec3.create(0, 0, 0);
      p.Vec3.scale(ne, Z, p.Vec3.dot(Z, le) * (1 - Math.cos(120 * Math.PI / 180))), p.Vec3.add(ie, re, ee), p.Vec3.add(ie, ie, ne), p.Vec3.add(ie, ie, W);
    }
    var se = p.Vec3.create(0, 0, 0);
    {
      var re = p.Vec3.create(0, 0, 0);
      p.Vec3.scale(re, le, Math.cos(240 * Math.PI / 180));
      var ee = p.Vec3.create(0, 0, 0);
      p.Vec3.cross(ee, Z, le), p.Vec3.scale(ee, ee, Math.sin(240 * Math.PI / 180));
      var ne = p.Vec3.create(0, 0, 0);
      p.Vec3.scale(ne, Z, p.Vec3.dot(Z, le) * (1 - Math.cos(240 * Math.PI / 180))), p.Vec3.add(se, re, ee), p.Vec3.add(se, se, ne), p.Vec3.add(se, se, W);
    }
    var ce = c.MeshBuilder.createState(128, 64), de = [Q[0], Q[1], Q[2], ae[0], ae[1], ae[2], ie[0], ie[1], ie[2], se[0], se[1], se[2]], me = (0, m.Tetrahedron1)(de), he = p.Mat4.ofRows([
      [1, 0, 0, 0],
      [0, 1, 0, 0],
      [0, 0, 1, 0],
      [0, 0, 0, 1]
    ]), _e = p.Mat4.invert(p.Mat4.zero(), he);
    return c.MeshBuilder.addPrimitive(ce, _e, me), v.Shape.create("axes", {}, c.MeshBuilder.getMesh(ce), function() {
      return q.color;
    }, function() {
      return 0.15;
    }, function() {
      return "";
    });
  }
  function R(U) {
    return C.ParamDefinition.clone(e.PharmacophoreParams);
  }
  e.getPharmacophoreParams = R;
  function F(U, H) {
    var q = S.Representation.createMulti("Pharmacophore", U, H, b.StructureRepresentationStateBuilder, A);
    return q.setState({ markerActions: y.MarkerActions.All }), q;
  }
  e.PharmacophoreRepresentation = F;
})(v$);
Object.defineProperty(IA, "__esModule", { value: !0 });
IA.PharmachophoreRepr = void 0;
var h_ = Te, cV = v$;
IA.PharmachophoreRepr = {
  create: function(e, r, t) {
    return (0, h_.__awaiter)(this, void 0, void 0, function() {
      var n;
      return (0, h_.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return n = (0, cV.PharmacophoreRepresentation)(r, function() {
              return cV.PharmacophoreParams;
            }), [4, n.createOrUpdate(e, e).run()];
          case 1:
            return a.sent(), [2, n];
        }
      });
    });
  },
  update: function(e, r, t, n) {
    return (0, h_.__awaiter)(this, void 0, void 0, function() {
      return (0, h_.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return [4, e.createOrUpdate(r, r).run()];
          case 1:
            return a.sent(), [
              2
              /*return*/
            ];
        }
      });
    });
  }
};
var BA = {}, h$ = {}, Zs = {};
Object.defineProperty(Zs, "__esModule", { value: !0 });
Zs.VolumeRepresentation = Zs.VolumeParams = Zs.VolumeRepresentationProvider = Zs.VolumeVisual = void 0;
var Rg = Te, i3e = Le, Os = gl, o3e = F0, uw = Kd(), g$ = Pc(), u3e = ji, y$ = Si, sw = _r, s3e = Qe(), lw = Vp, l3e = Np(), dV = We(), c3e = Tc(), d3e = ru(), aP = Wt, f3e = Xt, m3e = cl, v3e = Kr, p3e = Ft;
function h3e(e, r, t, n, a, i) {
  var o = uw.Geometry.getUtils(r), c = o.createValues, s = o.createRenderableState, u = (0, u3e.createIdentityTransform)(), l = c(r, u, t, n, a), f = s(a);
  return (0, y$.createRenderObject)(r.kind, l, f, i);
}
function g3e(e, r) {
  var t = e.defaultProps, n = e.createGeometry, a = e.createLocationIterator, i = e.getLoci, o = e.eachLocation, c = e.setUpdateState, s = e.mustRecreate, u = e.dispose, l = e.geometryUtils, f = l.updateValues, d = l.updateBoundingSphere, m = l.updateRenderableState, p = l.createPositionIterator, v = lw.VisualUpdateState.create(), h, y, C, S, b = Object.assign({}, t), g = g$.Theme.createEmpty(), _, A, M = -1, P, T;
  function x(I, B, D) {
    if (!D && !_)
      throw new Error("missing volume");
    if (y = Object.assign({}, b, B), C = I, S = D, lw.VisualUpdateState.reset(v), h ? (!_ || !o3e.Volume.areEquivalent(S, _)) && (v.createNew = !0) : v.createNew = !0, v.createNew) {
      v.createGeometry = !0;
      return;
    }
    c(v, D, y, b, C, g), l3e.ColorTheme.areEqual(I.color, g.color) || (v.updateColor = !0), v.createGeometry && (v.updateColor = !0);
  }
  function w(I) {
    if (v.createNew)
      if (P = a(S), I)
        h = h3e(S, I, P, C, y, r), T = p(I, h.values);
      else
        throw new Error("expected geometry to be given");
    else {
      if (!h)
        throw new Error("expected renderObject to be available");
      if (P.reset(), v.createGeometry)
        if (I)
          dV.ValueCell.updateIfChanged(h.values.drawCount, uw.Geometry.getDrawCount(I)), dV.ValueCell.updateIfChanged(h.values.uVertexCount, uw.Geometry.getVertexCount(I));
        else
          throw new Error("expected geometry to be given");
      (v.updateTransform || v.createGeometry) && (d(h.values, I || A), T = p(I || A, h.values)), v.updateSize && "uSize" in h.values && (0, c3e.createSizes)(P, C.size, h.values), v.updateColor && (0, d3e.createColors)(P, T, C.color, h.values), f(h.values, y), m(h.state, y);
    }
    b = y, g = C, _ = S, I && (A = I, M += 1);
  }
  function E(I, B) {
    return (0, sw.isEveryLoci)(I) ? B(s3e.Interval.ofBounds(0, P.groupCount * P.instanceCount)) : o(I, _, b, B);
  }
  return {
    get groupCount() {
      return P ? P.count : 0;
    },
    get renderObject() {
      return h;
    },
    get geometryVersion() {
      return M;
    },
    createOrUpdate: function(I, B, D, N) {
      return D === void 0 && (D = {}), (0, Rg.__awaiter)(this, void 0, void 0, function() {
        var O;
        return (0, Rg.__generator)(this, function(V) {
          return x(B, D, N || _), v.createGeometry ? (O = n(I, S, C, y, A), [2, (0, p3e.isPromiseLike)(O) ? O.then(w) : w(O)]) : (w(), [
            2
            /*return*/
          ]);
        });
      });
    },
    getLoci: function(I) {
      return h ? i(I, _, b, h.id) : sw.EmptyLoci;
    },
    mark: function(I, B) {
      return Os.Visual.mark(h, I, B, E);
    },
    setVisibility: function(I) {
      Os.Visual.setVisibility(h, I);
    },
    setAlphaFactor: function(I) {
      Os.Visual.setAlphaFactor(h, I);
    },
    setPickable: function(I) {
      Os.Visual.setPickable(h, I);
    },
    setColorOnly: function(I) {
      Os.Visual.setColorOnly(h, I);
    },
    setTransform: function(I, B) {
      Os.Visual.setTransform(h, I, B);
    },
    setOverpaint: function(I) {
      return Os.Visual.setOverpaint(h, I, E, !0);
    },
    setTransparency: function(I) {
      return Os.Visual.setTransparency(h, I, E, !0);
    },
    setSubstance: function(I) {
      return Os.Visual.setSubstance(h, I, E, !0);
    },
    setClipping: function(I) {
      return Os.Visual.setClipping(h, I, E, !0);
    },
    destroy: function() {
      u == null || u(A), h && (h.state.disposed = !0, h = void 0);
    },
    mustRecreate: s
  };
}
Zs.VolumeVisual = g3e;
function y3e(e) {
  return e;
}
Zs.VolumeRepresentationProvider = y3e;
Zs.VolumeParams = (0, Rg.__assign)({}, f3e.BaseGeometry.Params);
function _3e(e, r, t, n, a) {
  var i = 0, o = r.webgl, c = new m3e.Subject(), s = new aP.Representation.GeometryState(), u = (0, y$.getNextMaterialId)(), l = [], f = aP.Representation.createState(), d, m, p, v, h = g$.Theme.createEmpty();
  function y(_, A) {
    var M = this;
    _ === void 0 && (_ = {}), A && A !== m && (p = t(r, A), m = A, v || (v = i3e.ParamDefinition.getDefaultValues(p)));
    var P = (0, lw.getQualityProps)(Object.assign({}, v, _), m);
    return Object.assign(v, _, P), v3e.Task.create("Creating or updating VolumeRepresentation", function(T) {
      return (0, Rg.__awaiter)(M, void 0, void 0, function() {
        var x, w;
        return (0, Rg.__generator)(this, function(E) {
          switch (E.label) {
            case 0:
              return d ? !((w = d.mustRecreate) === null || w === void 0) && w.call(d, m, v, o) && (d.destroy(), d = n(u, m, v, o)) : d = n(u, m, v, o), x = d.createOrUpdate({ webgl: o, runtime: T }, h, v, A), x ? [
                4,
                x
                // update list of renderObjects
              ] : [3, 2];
            case 1:
              E.sent(), E.label = 2;
            case 2:
              return l.length = 0, d && d.renderObject && (l.push(d.renderObject), s.add(d.renderObject.id, d.geometryVersion)), s.snapshot(), c.next(i++), [
                2
                /*return*/
              ];
          }
        });
      });
    });
  }
  function C(_, A) {
    return d ? d.mark(_, A) : !1;
  }
  function S(_) {
    _.visible !== void 0 && d && d.setVisibility(_.visible), _.alphaFactor !== void 0 && d && d.setAlphaFactor(_.alphaFactor), _.pickable !== void 0 && d && d.setPickable(_.pickable), _.overpaint !== void 0 && d && d.setOverpaint(_.overpaint), _.transparency !== void 0 && d && d.setTransparency(_.transparency), _.transform !== void 0 && d && d.setTransform(_.transform), aP.Representation.updateState(f, _);
  }
  function b(_) {
    h = _;
  }
  function g() {
    d && d.destroy();
  }
  return {
    label: e,
    get groupCount() {
      return d ? d.groupCount : 0;
    },
    get props() {
      return v;
    },
    get params() {
      return p;
    },
    get state() {
      return f;
    },
    get theme() {
      return h;
    },
    get geometryVersion() {
      return s.version;
    },
    renderObjects: l,
    updated: c,
    createOrUpdate: y,
    setState: S,
    setTheme: b,
    getLoci: function(_) {
      return _ === void 0 ? a(m, v) : d ? d.getLoci(_) : sw.EmptyLoci;
    },
    mark: C,
    destroy: g
  };
}
Zs.VolumeRepresentation = _3e;
var np = {}, NA = {}, VA = {}, RA = {};
Object.defineProperty(RA, "__esModule", { value: !0 });
RA.sum_frag = void 0;
RA.sum_frag = `
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
}
`;
Object.defineProperty(VA, "__esModule", { value: !0 });
VA.getHistopyramidSum = void 0;
var rg = Te, b3e = Kt, S3e = Lt, C3e = yn, A3e = Bn(), _$ = We(), x3e = ts, b$ = Yi, T3e = Qi, P3e = RA, iP = vs(), M3e = (0, rg.__assign)((0, rg.__assign)({}, b$.QuadSchema), { tTexture: (0, C3e.TextureSpec)("texture", "rgba", "float", "nearest") }), bu = "histopyramid-sum";
function w3e(e, r) {
  if (e.namedComputeRenderables[bu]) {
    var t = e.namedComputeRenderables[bu].values;
    _$.ValueCell.update(t.tTexture, r), e.namedComputeRenderables[bu].update();
  } else
    e.namedComputeRenderables[bu] = E3e(e, r);
  return e.namedComputeRenderables[bu];
}
function E3e(e, r) {
  var t = (0, rg.__assign)((0, rg.__assign)({}, b$.QuadValues), { tTexture: _$.ValueCell.create(r) }), n = (0, rg.__assign)({}, M3e), a = (0, A3e.ShaderCode)("sum", T3e.quad_vert, P3e.sum_frag, {}, { 0: "ivec4" }), i = (0, S3e.createComputeRenderItem)(e, "triangles", a, n, t);
  return (0, b3e.createComputeRenderable)(i, t);
}
function D3e(e) {
  var r = e.gl, t = e.state;
  t.disable(r.CULL_FACE), t.disable(r.BLEND), t.disable(r.DEPTH_TEST), t.disable(r.SCISSOR_TEST), t.depthMask(!1), t.colorMask(!0, !0, !0, !0), t.clearColor(0, 0, 0, 0);
}
var g_ = new Uint8Array(4), fV = new Int32Array(4);
function I3e(e, r) {
  var t = e.gl, n = e.resources, a = w3e(e, r);
  e.state.currentRenderItemId = -1, e.namedFramebuffers[bu] || (e.namedFramebuffers[bu] = n.framebuffer());
  var i = e.namedFramebuffers[bu];
  e.namedTextures[bu] || (e.namedTextures[bu] = (0, iP.isWebGL2)(t) ? n.texture("image-int32", "rgba", "int", "nearest") : n.texture("image-uint8", "rgba", "ubyte", "nearest"), e.namedTextures[bu].define(1, 1));
  var o = e.namedTextures[bu];
  return o.attachFramebuffer(i, 0), D3e(e), t.viewport(0, 0, 1, 1), a.render(), t.finish(), e.readPixels(0, 0, 1, 1, (0, iP.isWebGL2)(t) ? fV : g_), e.unbindFramebuffer(), (0, iP.isWebGL2)(t) ? fV[0] : (0, x3e.unpackRGBToInt)(g_[0], g_[1], g_[2]);
}
VA.getHistopyramidSum = I3e;
var OA = {};
Object.defineProperty(OA, "__esModule", { value: !0 });
OA.reduction_frag = void 0;
OA.reduction_frag = `
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
}
`;
Object.defineProperty(NA, "__esModule", { value: !0 });
NA.createHistogramPyramid = void 0;
var tg = Te, B3e = Kt, N3e = Lt, g1 = yn, V3e = Bn(), Qu = We(), S$ = Yi, R3e = VA, O3e = kn, F3e = Qi, L3e = OA, mV = vs(), k3e = (0, tg.__assign)((0, tg.__assign)({}, S$.QuadSchema), { tInputLevel: (0, g1.TextureSpec)("texture", "rgba", "float", "nearest"), tPreviousLevel: (0, g1.TextureSpec)("texture", "rgba", "float", "nearest"), uSize: (0, g1.UniformSpec)("f"), uTexSize: (0, g1.UniformSpec)("f"), uFirst: (0, g1.UniformSpec)("b") }), ad = "histogram-pyramid";
function U3e(e, r, t) {
  if (e.namedComputeRenderables[ad]) {
    var n = e.namedComputeRenderables[ad].values;
    Qu.ValueCell.update(n.tInputLevel, r), Qu.ValueCell.update(n.tPreviousLevel, t), e.namedComputeRenderables[ad].update();
  } else
    e.namedComputeRenderables[ad] = z3e(e, r, t);
  return e.namedComputeRenderables[ad];
}
function z3e(e, r, t) {
  var n = (0, tg.__assign)((0, tg.__assign)({}, S$.QuadValues), { tInputLevel: Qu.ValueCell.create(r), tPreviousLevel: Qu.ValueCell.create(t), uSize: Qu.ValueCell.create(0), uTexSize: Qu.ValueCell.create(0), uFirst: Qu.ValueCell.create(!0) }), a = (0, tg.__assign)({}, k3e), i = (0, V3e.ShaderCode)("reduction", F3e.quad_vert, L3e.reduction_frag, {}, { 0: "ivec4" }), o = (0, N3e.createComputeRenderItem)(e, "triangles", i, a, n);
  return (0, B3e.createComputeRenderable)(o, n);
}
function G3e(e, r) {
  var t = Math.pow(2, r), n = "level".concat(r), a = e.isWebGL2 ? c3(n, e, "image-int32", "alpha", "int", "nearest") : c3(n, e, "image-uint8", "rgba", "ubyte", "nearest");
  a.define(t, t);
  var i = H3e(n, e);
  return i || (i = C$(n, e), a.attachFramebuffer(i, 0)), { texture: a, framebuffer: i };
}
function q3e(e) {
  var r = e.gl, t = e.state;
  t.disable(r.CULL_FACE), t.disable(r.BLEND), t.disable(r.DEPTH_TEST), t.enable(r.SCISSOR_TEST), t.depthMask(!1), t.colorMask(!0, !0, !0, !0), t.clearColor(0, 0, 0, 0);
}
function C$(e, r) {
  var t = "".concat(ad, "-").concat(e);
  return r.namedFramebuffers[t] || (r.namedFramebuffers[t] = r.resources.framebuffer()), r.namedFramebuffers[t];
}
function c3(e, r, t, n, a, i) {
  var o = "".concat(ad, "-").concat(e);
  return r.namedTextures[o] || (r.namedTextures[o] = r.resources.texture(t, n, a, i)), r.namedTextures[o];
}
function H3e(e, r) {
  var t = "".concat(ad, "-").concat(e);
  return r.namedFramebuffers[t];
}
function j3e(e, r, t, n) {
  var a = e.gl, i = r.getWidth(), o = r.getHeight();
  if (i !== o || !(0, O3e.isPowerOfTwo)(i))
    throw new Error("inputTexture must be of square power-of-two size");
  var c = Math.ceil(Math.log(i) / Math.log(2)), s = Math.pow(2, c), u = Math.pow(2, c), l = Math.pow(2, c - 1), f = e.isWebGL2 ? c3("pyramid", e, "image-int32", "alpha", "int", "nearest") : c3("pyramid", e, "image-uint8", "rgba", "ubyte", "nearest");
  f.define(u, l);
  var d = C$("pyramid", e);
  f.attachFramebuffer(d, 0), a.viewport(0, 0, u, l), (0, mV.isWebGL2)(a) ? a.clearBufferiv(a.COLOR, 0, [0, 0, 0, 0]) : a.clear(a.COLOR_BUFFER_BIT);
  for (var m = [], p = 0; p < c; ++p)
    m.push(G3e(e, p));
  var v = U3e(e, r, m[0].texture);
  e.state.currentRenderItemId = -1, q3e(e);
  for (var h = 0, p = 0; p < c; p++) {
    var y = c - 1 - p, C = m[y];
    C.framebuffer.bind();
    var S = Math.pow(2, y);
    Qu.ValueCell.update(v.values.uSize, Math.pow(2, p + 1) / s), Qu.ValueCell.update(v.values.uTexSize, S), Qu.ValueCell.updateIfChanged(v.values.uFirst, p === 0), p > 0 && (Qu.ValueCell.update(v.values.tPreviousLevel, m[c - p].texture), v.update()), e.state.currentRenderItemId = -1, a.viewport(0, 0, S, S), a.scissor(0, 0, S, S), (0, mV.isWebGL2)(a) ? a.clearBufferiv(a.COLOR, 0, [0, 0, 0, 0]) : a.clear(a.COLOR_BUFFER_BIT), a.scissor(0, 0, n[0], n[1]), v.render(), f.bind(0), a.copyTexSubImage2D(a.TEXTURE_2D, 0, h, 0, 0, 0, S, S), f.unbind(0), h += S;
  }
  a.finish();
  var b = Math.max(1, (0, R3e.getHistopyramidSum)(e, m[0].texture)), g = Math.ceil(b / Math.pow(2, c));
  return { pyramidTex: f, count: b, height: g, levels: c, scale: t };
}
NA.createHistogramPyramid = j3e;
var C0 = {};
Object.defineProperty(C0, "__esModule", { value: !0 });
C0.getTriIndices = C0.getTriCount = void 0;
var ng = PA, A$ = ut, y1;
function $3e() {
  if (y1 !== void 0)
    return y1;
  y1 = (0, A$.createTextureImage)(16 * 16, 1, Uint8Array);
  for (var e = y1.array, r = 0, t = ng.TriTable.length; r < t; ++r)
    e[r] = ng.TriTable[r].length / 3;
  return y1;
}
C0.getTriCount = $3e;
var _1;
function K3e() {
  if (_1 !== void 0)
    return _1;
  _1 = (0, A$.createTextureImage)(64 * 64, 1, Uint8Array);
  for (var e = _1.array, r = 0, t = ng.TriTable.length; r < t; ++r)
    for (var n = 0; n < 16; ++n)
      n < ng.TriTable[r].length ? e[r * 16 + n] = ng.TriTable[r][n] : e[r * 16 + n] = 255;
  return _1;
}
C0.getTriIndices = K3e;
var FA = {};
Object.defineProperty(FA, "__esModule", { value: !0 });
FA.isosurface_frag = void 0;
FA.isosurface_frag = `
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)));
}
`;
var LA = {}, kA = {};
Object.defineProperty(kA, "__esModule", { value: !0 });
kA.activeVoxels_frag = void 0;
kA.activeVoxels_frag = `
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);
}
`;
Object.defineProperty(LA, "__esModule", { value: !0 });
LA.calcActiveVoxels = void 0;
var ag = Te, W3e = Kt, X3e = Lt, Rm = yn, Y3e = Bn(), Ho = We(), x$ = Yi, Q3e = C0, Z3e = Qi, J3e = kA, eSe = (0, ag.__assign)((0, ag.__assign)({}, x$.QuadSchema), { tTriCount: (0, Rm.TextureSpec)("image-uint8", "alpha", "ubyte", "nearest"), tVolumeData: (0, Rm.TextureSpec)("texture", "rgba", "ubyte", "nearest"), uIsoValue: (0, Rm.UniformSpec)("f"), uGridDim: (0, Rm.UniformSpec)("v3"), uGridTexDim: (0, Rm.UniformSpec)("v3"), uScale: (0, Rm.UniformSpec)("v2") }), Xu = "active-voxels";
function rSe(e, r, t, n, a, i) {
  if (e.namedComputeRenderables[Xu]) {
    var o = e.namedComputeRenderables[Xu].values;
    Ho.ValueCell.update(o.uQuadScale, i), Ho.ValueCell.update(o.tVolumeData, r), Ho.ValueCell.updateIfChanged(o.uIsoValue, a), Ho.ValueCell.update(o.uGridDim, t), Ho.ValueCell.update(o.uGridTexDim, n), Ho.ValueCell.update(o.uScale, i), e.namedComputeRenderables[Xu].update();
  } else
    e.namedComputeRenderables[Xu] = tSe(e, r, t, n, a, i);
  return e.namedComputeRenderables[Xu];
}
function tSe(e, r, t, n, a, i) {
  var o = (0, ag.__assign)((0, ag.__assign)({}, x$.QuadValues), { tTriCount: Ho.ValueCell.create((0, Q3e.getTriCount)()), uQuadScale: Ho.ValueCell.create(i), tVolumeData: Ho.ValueCell.create(r), uIsoValue: Ho.ValueCell.create(a), uGridDim: Ho.ValueCell.create(t), uGridTexDim: Ho.ValueCell.create(n), uScale: Ho.ValueCell.create(i) }), c = (0, ag.__assign)({}, eSe), s = (0, Y3e.ShaderCode)("active-voxels", Z3e.quad_vert, J3e.activeVoxels_frag), u = (0, X3e.createComputeRenderItem)(e, "triangles", s, c, o);
  return (0, W3e.createComputeRenderable)(u, o);
}
function nSe(e) {
  var r = e.gl, t = e.state;
  t.disable(r.CULL_FACE), t.disable(r.BLEND), t.disable(r.DEPTH_TEST), t.enable(r.SCISSOR_TEST), t.depthMask(!1), t.colorMask(!0, !0, !0, !0), t.clearColor(0, 0, 0, 0);
}
function aSe(e, r, t, n, a, i) {
  var o = e.gl, c = e.resources, s = r.getWidth(), u = r.getHeight();
  e.namedFramebuffers[Xu] || (e.namedFramebuffers[Xu] = c.framebuffer());
  var l = e.namedFramebuffers[Xu];
  l.bind(), e.namedTextures[Xu] || (e.namedTextures[Xu] = c.texture("image-uint8", "rgba", "ubyte", "nearest"));
  var f = e.namedTextures[Xu];
  f.define(s, u);
  var d = rSe(e, r, t, n, a, i);
  return e.state.currentRenderItemId = -1, f.attachFramebuffer(l, 0), nSe(e), o.viewport(0, 0, s, u), o.scissor(0, 0, s, u), o.clear(o.COLOR_BUFFER_BIT), o.scissor(0, 0, n[0], n[1]), d.render(), o.finish(), f;
}
LA.calcActiveVoxels = aSe;
Object.defineProperty(np, "__esModule", { value: !0 });
np.extractIsosurface = np.createIsosurfaceBuffers = void 0;
var ig = Te, iSe = Kt, oSe = Lt, Oi = yn, uSe = Bn(), Tt = We(), T$ = Yi, sSe = NA, lSe = C0, cSe = Qi, dSe = FA, fSe = LA, mSe = vs(), vSe = (0, ig.__assign)((0, ig.__assign)({}, T$.QuadSchema), { tTriIndices: (0, Oi.TextureSpec)("image-uint8", "alpha", "ubyte", "nearest"), tActiveVoxelsPyramid: (0, Oi.TextureSpec)("texture", "rgba", "float", "nearest"), tActiveVoxelsBase: (0, Oi.TextureSpec)("texture", "rgba", "float", "nearest"), tVolumeData: (0, Oi.TextureSpec)("texture", "rgba", "ubyte", "nearest"), uIsoValue: (0, Oi.UniformSpec)("f"), uSize: (0, Oi.UniformSpec)("f"), uLevels: (0, Oi.UniformSpec)("f"), uCount: (0, Oi.UniformSpec)("f"), uInvert: (0, Oi.UniformSpec)("b"), uGridDim: (0, Oi.UniformSpec)("v3"), uGridTexDim: (0, Oi.UniformSpec)("v3"), uGridTransform: (0, Oi.UniformSpec)("m4"), uScale: (0, Oi.UniformSpec)("v2"), dPackedGroup: (0, Oi.DefineSpec)("boolean"), dAxisOrder: (0, Oi.DefineSpec)("string", ["012", "021", "102", "120", "201", "210"]) }), id = "isosurface";
function pSe(e, r, t, n, a, i, o, c, s, u, l, f, d, m) {
  if (e.namedComputeRenderables[id]) {
    var p = e.namedComputeRenderables[id].values;
    Tt.ValueCell.update(p.tActiveVoxelsPyramid, r), Tt.ValueCell.update(p.tActiveVoxelsBase, t), Tt.ValueCell.update(p.tVolumeData, n), Tt.ValueCell.updateIfChanged(p.uIsoValue, c), Tt.ValueCell.updateIfChanged(p.uSize, Math.pow(2, s)), Tt.ValueCell.updateIfChanged(p.uLevels, s), Tt.ValueCell.updateIfChanged(p.uCount, l), Tt.ValueCell.updateIfChanged(p.uInvert, f), Tt.ValueCell.update(p.uGridDim, a), Tt.ValueCell.update(p.uGridTexDim, i), Tt.ValueCell.update(p.uGridTransform, o), Tt.ValueCell.update(p.uScale, u), Tt.ValueCell.update(p.dPackedGroup, d), Tt.ValueCell.updateIfChanged(p.dAxisOrder, m.join("")), e.namedComputeRenderables[id].update();
  } else
    e.namedComputeRenderables[id] = hSe(e, r, t, n, a, i, o, c, s, u, l, f, d, m);
  return e.namedComputeRenderables[id];
}
function hSe(e, r, t, n, a, i, o, c, s, u, l, f, d, m) {
  var p = (0, ig.__assign)((0, ig.__assign)({}, T$.QuadValues), { tTriIndices: Tt.ValueCell.create((0, lSe.getTriIndices)()), tActiveVoxelsPyramid: Tt.ValueCell.create(r), tActiveVoxelsBase: Tt.ValueCell.create(t), tVolumeData: Tt.ValueCell.create(n), uIsoValue: Tt.ValueCell.create(c), uSize: Tt.ValueCell.create(Math.pow(2, s)), uLevels: Tt.ValueCell.create(s), uCount: Tt.ValueCell.create(l), uInvert: Tt.ValueCell.create(f), uGridDim: Tt.ValueCell.create(a), uGridTexDim: Tt.ValueCell.create(i), uGridTransform: Tt.ValueCell.create(o), uScale: Tt.ValueCell.create(u), dPackedGroup: Tt.ValueCell.create(d), dAxisOrder: Tt.ValueCell.create(m.join("")) }), v = (0, ig.__assign)({}, vSe), h = (0, uSe.ShaderCode)("isosurface", cSe.quad_vert, dSe.isosurface_frag, {
    drawBuffers: "required"
  }), y = (0, oSe.createComputeRenderItem)(e, "triangles", h, v, p);
  return (0, iSe.createComputeRenderable)(y, p);
}
function gSe(e) {
  var r = e.gl, t = e.state;
  t.disable(r.CULL_FACE), t.disable(r.BLEND), t.disable(r.DEPTH_TEST), t.disable(r.SCISSOR_TEST), t.depthMask(!1), t.colorMask(!0, !0, !0, !0), t.clearColor(0, 0, 0, 0);
}
function P$(e, r, t, n, a, i, o, c, s, u, l, f, d, m) {
  var p = e.extensions.drawBuffers;
  if (!p)
    throw new Error("need WebGL draw buffers");
  var v = e.gl, h = e.resources, y = e.extensions, C = n.pyramidTex, S = n.height, b = n.levels, g = n.scale, _ = n.count, A = C.getWidth();
  e.namedFramebuffers[id] || (e.namedFramebuffers[id] = h.framebuffer());
  var M = e.namedFramebuffers[id];
  (0, mSe.isWebGL2)(v) ? (f || (f = y.colorBufferHalfFloat && y.textureHalfFloat ? h.texture("image-float16", "rgba", "fp16", "nearest") : h.texture("image-float32", "rgba", "float", "nearest")), d || (d = h.texture("image-uint8", "rgba", "ubyte", "nearest")), m || (m = y.colorBufferHalfFloat && y.textureHalfFloat ? h.texture("image-float16", "rgba", "fp16", "nearest") : h.texture("image-float32", "rgba", "float", "nearest"))) : (f || (f = h.texture("image-float32", "rgba", "float", "nearest")), d || (d = h.texture("image-float32", "rgba", "float", "nearest")), m || (m = h.texture("image-float32", "rgba", "float", "nearest"))), f.define(A, S), d.define(A, S), m.define(A, S), f.attachFramebuffer(M, 0), d.attachFramebuffer(M, 1), m.attachFramebuffer(M, 2);
  var P = pSe(e, C, r, t, a, i, o, c, b, g, _, s, u, l);
  return e.state.currentRenderItemId = -1, M.bind(), p.drawBuffers([
    p.COLOR_ATTACHMENT0,
    p.COLOR_ATTACHMENT1,
    p.COLOR_ATTACHMENT2
  ]), gSe(e), v.viewport(0, 0, A, S), v.clear(v.COLOR_BUFFER_BIT), P.render(), v.finish(), { vertexTexture: f, groupTexture: d, normalTexture: m, vertexCount: _ };
}
np.createIsosurfaceBuffers = P$;
function ySe(e, r, t, n, a, i, o, c, s, u, l, f, d) {
  var m = (0, fSe.calcActiveVoxels)(e, r, t, n, o, a), p = (0, sSe.createHistogramPyramid)(e, m, a, n), v = P$(e, m, r, p, t, n, i, o, c, s, u, l, f, d);
  return v;
}
np.extractIsosurface = ySe;
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.IsosurfaceRepresentationProvider = e.IsosurfaceRepresentation = e.getIsosurfaceParams = e.IsosurfaceParams = e.IsosurfaceWireframeVisual = e.IsosurfaceWireframeParams = e.createVolumeIsosurfaceWireframe = e.IsosurfaceTextureMeshVisual = e.IsosurfaceMeshVisual = e.IsosurfaceMeshParams = e.createVolumeIsosurfaceMesh = e.eachIsosurface = e.IsosurfaceVisual = e.VolumeIsosurfaceParams = void 0;
  var r = Te, t = Le, n = F0, a = Dt(), i = Rd, o = Zs, c = on, s = Ja, u = Fa(), l = Wt, f = _r, d = Qe(), m = Re, p = hr, v = Zu, h = yy(), y = np, C = In, S = Xt;
  e.VolumeIsosurfaceParams = {
    isoValue: n.Volume.IsoValueParam
  };
  function b(G) {
    return G.extensions.colorBufferFloat && G.extensions.textureFloat && G.extensions.drawBuffers;
  }
  var g = 1;
  function _(G, L) {
    if (G.grid.cells.data.length < Math.pow(10, 3))
      return !1;
    var R = G.grid.cells.space.dimensions, F = (0, v.getVolumeTexture2dLayout)(R, g).powerOfTwoSize;
    return F <= L.maxTextureSize / 2;
  }
  function A(G, L, R, F) {
    return R.tryUseGpu && F && b(F) && _(L, F) ? B(G) : w(G);
  }
  e.IsosurfaceVisual = A;
  function M(G, L) {
    return n.Volume.Isosurface.Loci(G, L.isoValue);
  }
  function P(G, L, R, F) {
    var U = G.objectId, H = G.groupId;
    return F === U ? n.Volume.Cell.Loci(L, d.Interval.ofSingleton(H)) : f.EmptyLoci;
  }
  function T(G, L, R, F) {
    return (0, v.eachVolumeLoci)(G, L, R.isoValue, F);
  }
  e.eachIsosurface = T;
  function x(G, L, R, F, U) {
    return (0, r.__awaiter)(this, void 0, void 0, function() {
      var H, q, K;
      return (0, r.__generator)(this, function(Y) {
        switch (Y.label) {
          case 0:
            return G.runtime.update({ message: "Marching cubes..." }), H = (0, p.fillSerial)(new Int32Array(L.grid.cells.data.length)), [4, (0, i.computeMarchingCubesMesh)({
              isoLevel: n.Volume.IsoValue.toAbsolute(F.isoValue, L.grid.stats).absoluteValue,
              scalarField: L.grid.cells,
              idField: m.Tensor.create(L.grid.cells.space, m.Tensor.Data1(H))
            }, U).runAsChild(G.runtime)];
          case 1:
            return q = Y.sent(), K = n.Grid.getGridToCartesianTransform(L.grid), a.Mesh.transform(q, K), G.webgl && !G.webgl.isWebGL2 && a.Mesh.uniformTriangleGroup(q, !1), q.setBoundingSphere(n.Volume.getBoundingSphere(L)), [2, q];
        }
      });
    });
  }
  e.createVolumeIsosurfaceMesh = x, e.IsosurfaceMeshParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)((0, r.__assign)({}, a.Mesh.Params), h.TextureMesh.Params), e.VolumeIsosurfaceParams), { quality: (0, r.__assign)((0, r.__assign)({}, a.Mesh.Params.quality), { isEssential: !1 }), tryUseGpu: t.ParamDefinition.Boolean(!0) });
  function w(G) {
    return (0, o.VolumeVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.IsosurfaceMeshParams),
      createGeometry: x,
      createLocationIterator: function(L) {
        return (0, c.LocationIterator)(L.grid.cells.data.length, 1, 1, function() {
          return s.NullLocation;
        });
      },
      getLoci: P,
      eachLocation: T,
      setUpdateState: function(L, R, F, U) {
        n.Volume.IsoValue.areSame(F.isoValue, U.isoValue, R.grid.stats) || (L.createGeometry = !0);
      },
      geometryUtils: a.Mesh.Utils,
      mustRecreate: function(L, R, F) {
        return R.tryUseGpu && !!F && _(L, F);
      }
    }, G);
  }
  e.IsosurfaceMeshVisual = w;
  var E;
  (function(G) {
    var L = "volume-isosurface-texture";
    G.descriptor = (0, C.CustomPropertyDescriptor)({ name: L });
    function R(F, U) {
      var H = U.resources, q = n.Grid.getGridToCartesianTransform(F.grid), K = m.Vec3.clone(F.grid.cells.space.dimensions), Y = (0, v.getVolumeTexture2dLayout)(K, g), X = Y.width, Z = Y.height, J = Y.powerOfTwoSize, $ = m.Vec3.create(X, Z, 0), Q = m.Vec2.create(X / J, Z / J);
      if (J > U.maxTextureSize / 2)
        throw new Error("volume too large for gpu isosurface extraction");
      if (!F._propertyData[L]) {
        F._propertyData[L] = H.texture("image-uint8", "alpha", "ubyte", "linear");
        var W = F._propertyData[L];
        W.define(J, J), W.load((0, v.createVolumeTexture2d)(F, "data", g), !0), F.customProperties.add(G.descriptor), F.customProperties.assets(G.descriptor, [
          { dispose: function() {
            return W.destroy();
          } }
        ]);
      }
      return K[0] += g, K[1] += g, {
        texture: F._propertyData[L],
        transform: q,
        gridDimension: K,
        gridTexDim: $,
        gridTexScale: Q
      };
    }
    G.get = R;
  })(E || (E = {}));
  function I(G, L, R, F, U) {
    return (0, r.__awaiter)(this, void 0, void 0, function() {
      var H, q, K, Y, X, Z, J, $, Q, W, te, oe, z, j, ae, le;
      return (0, r.__generator)(this, function(ie) {
        if (!G.webgl)
          throw new Error("webgl context required to create volume isosurface texture-mesh");
        return L.grid.cells.data.length <= 1 ? [2, h.TextureMesh.createEmpty(U)] : (H = L.grid.stats, q = H.max, K = H.min, Y = q - K, X = n.Volume.IsoValue.toAbsolute(F.isoValue, L.grid.stats).absoluteValue, Z = (X - K) / Y, J = E.get(L, G.webgl), $ = J.texture, Q = J.gridDimension, W = J.gridTexDim, te = J.gridTexScale, oe = J.transform, z = L.grid.cells.space.axisOrderSlowToFast, j = U == null ? void 0 : U.doubleBuffer.get(), ae = (0, y.extractIsosurface)(G.webgl, $, Q, W, te, oe, Z, X < 0, !1, z, j == null ? void 0 : j.vertex, j == null ? void 0 : j.group, j == null ? void 0 : j.normal), le = h.TextureMesh.create(ae.vertexCount, 1, ae.vertexTexture, ae.groupTexture, ae.normalTexture, n.Volume.getBoundingSphere(L), U), [2, le]);
      });
    });
  }
  function B(G) {
    return (0, o.VolumeVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.IsosurfaceMeshParams),
      createGeometry: I,
      createLocationIterator: function(L) {
        return (0, c.LocationIterator)(L.grid.cells.data.length, 1, 1, function() {
          return s.NullLocation;
        });
      },
      getLoci: P,
      eachLocation: T,
      setUpdateState: function(L, R, F, U) {
        n.Volume.IsoValue.areSame(F.isoValue, U.isoValue, R.grid.stats) || (L.createGeometry = !0);
      },
      geometryUtils: h.TextureMesh.Utils,
      mustRecreate: function(L, R, F) {
        return !R.tryUseGpu || !F || !_(L, F);
      },
      dispose: function(L) {
        L.vertexTexture.ref.value.destroy(), L.groupTexture.ref.value.destroy(), L.normalTexture.ref.value.destroy(), L.doubleBuffer.destroy();
      }
    }, G);
  }
  e.IsosurfaceTextureMeshVisual = B;
  function D(G, L, R, F, U) {
    return (0, r.__awaiter)(this, void 0, void 0, function() {
      var H, q, K;
      return (0, r.__generator)(this, function(Y) {
        switch (Y.label) {
          case 0:
            return G.runtime.update({ message: "Marching cubes..." }), H = (0, p.fillSerial)(new Int32Array(L.grid.cells.data.length)), [4, (0, i.computeMarchingCubesLines)({
              isoLevel: n.Volume.IsoValue.toAbsolute(F.isoValue, L.grid.stats).absoluteValue,
              scalarField: L.grid.cells,
              idField: m.Tensor.create(L.grid.cells.space, m.Tensor.Data1(H))
            }, U).runAsChild(G.runtime)];
          case 1:
            return q = Y.sent(), K = n.Grid.getGridToCartesianTransform(L.grid), u.Lines.transform(q, K), q.setBoundingSphere(n.Volume.getBoundingSphere(L)), [2, q];
        }
      });
    });
  }
  e.createVolumeIsosurfaceWireframe = D, e.IsosurfaceWireframeParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, u.Lines.Params), e.VolumeIsosurfaceParams), { quality: (0, r.__assign)((0, r.__assign)({}, u.Lines.Params.quality), { isEssential: !1 }), sizeFactor: t.ParamDefinition.Numeric(3, { min: 0, max: 10, step: 0.1 }) });
  function N(G) {
    return (0, o.VolumeVisual)({
      defaultProps: t.ParamDefinition.getDefaultValues(e.IsosurfaceWireframeParams),
      createGeometry: D,
      createLocationIterator: function(L) {
        return (0, c.LocationIterator)(L.grid.cells.data.length, 1, 1, function() {
          return s.NullLocation;
        });
      },
      getLoci: P,
      eachLocation: T,
      setUpdateState: function(L, R, F, U) {
        n.Volume.IsoValue.areSame(F.isoValue, U.isoValue, R.grid.stats) || (L.createGeometry = !0);
      },
      geometryUtils: u.Lines.Utils
    }, G);
  }
  e.IsosurfaceWireframeVisual = N;
  var O = {
    solid: function(G, L) {
      return (0, o.VolumeRepresentation)("Isosurface mesh", G, L, A, M);
    },
    wireframe: function(G, L) {
      return (0, o.VolumeRepresentation)("Isosurface wireframe", G, L, N, M);
    }
  };
  e.IsosurfaceParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, e.IsosurfaceMeshParams), e.IsosurfaceWireframeParams), { visuals: t.ParamDefinition.MultiSelect(["solid"], t.ParamDefinition.objectToOptions(O)), bumpFrequency: t.ParamDefinition.Numeric(1, { min: 0, max: 10, step: 0.1 }, S.BaseGeometry.ShadingCategory), alpha: t.ParamDefinition.Numeric(0.12, { min: 0, max: 1, step: 0.01 }, {
    label: "Opacity",
    isEssential: !0,
    description: "How opaque/transparent the representation is rendered."
  }) });
  function V(G, L) {
    var R = t.ParamDefinition.clone(e.IsosurfaceParams);
    return R.isoValue = n.Volume.createIsoValueParam(n.Volume.IsoValue.relative(2), L.grid.stats), R;
  }
  e.getIsosurfaceParams = V;
  function k(G, L) {
    return l.Representation.createMulti("Isosurface", G, L, l.Representation.StateBuilder, O);
  }
  e.IsosurfaceRepresentation = k, e.IsosurfaceRepresentationProvider = (0, o.VolumeRepresentationProvider)({
    name: "isosurface",
    label: "Isosurface",
    description: "Displays a triangulated isosurface of volumetric data.",
    factory: k,
    getParams: V,
    defaultValues: t.ParamDefinition.getDefaultValues(e.IsosurfaceParams),
    defaultColorTheme: { name: "uniform" },
    defaultSizeTheme: { name: "uniform" },
    isApplicable: function(G) {
      return !n.Volume.isEmpty(G);
    }
  });
})(h$);
var UA = {}, qi = {}, M$ = {}, zA = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.SimpleBuffer = void 0;
  var r = We();
  (function(t) {
    function n(u) {
      var l = new DataView(u.buffer);
      return Object.assign(u.subarray(0), {
        readInt8: function(f) {
          return l.getInt8(f);
        },
        readUInt8: function(f) {
          return l.getUint8(f);
        },
        writeInt8: function(f, d) {
          return l.setInt8(d, f);
        },
        writeUInt8: function(f, d) {
          return l.setUint8(d, f);
        },
        readInt16LE: function(f) {
          return l.getInt16(f, !0);
        },
        readInt32LE: function(f) {
          return l.getInt32(f, !0);
        },
        readUInt16LE: function(f) {
          return l.getUint16(f, !0);
        },
        readUInt32LE: function(f) {
          return l.getUint32(f, !0);
        },
        readFloatLE: function(f) {
          return l.getFloat32(f, !0);
        },
        readDoubleLE: function(f) {
          return l.getFloat64(f, !0);
        },
        writeInt16LE: function(f, d) {
          return l.setInt16(d, f, !0);
        },
        writeInt32LE: function(f, d) {
          return l.setInt32(d, f, !0);
        },
        writeUInt16LE: function(f, d) {
          return l.setUint16(d, f, !0);
        },
        writeUInt32LE: function(f, d) {
          return l.setUint32(d, f, !0);
        },
        writeFloatLE: function(f, d) {
          return l.setFloat32(d, f, !0);
        },
        writeDoubleLE: function(f, d) {
          return l.setFloat64(d, f, !0);
        },
        readInt16BE: function(f) {
          return l.getInt16(f, !1);
        },
        readInt32BE: function(f) {
          return l.getInt32(f, !1);
        },
        readUInt16BE: function(f) {
          return l.getUint16(f, !1);
        },
        readUInt32BE: function(f) {
          return l.getUint32(f, !1);
        },
        readFloatBE: function(f) {
          return l.getFloat32(f, !1);
        },
        readDoubleBE: function(f) {
          return l.getFloat64(f, !1);
        },
        writeInt16BE: function(f, d) {
          return l.setInt16(d, f, !1);
        },
        writeInt32BE: function(f, d) {
          return l.setInt32(d, f, !1);
        },
        writeUInt16BE: function(f, d) {
          return l.setUint16(d, f, !1);
        },
        writeUInt32BE: function(f, d) {
          return l.setUint32(d, f, !1);
        },
        writeFloatBE: function(f, d) {
          return l.setFloat32(d, f, !1);
        },
        writeDoubleBE: function(f, d) {
          return l.setFloat64(d, f, !1);
        },
        copy: function(f, d, m, p) {
          return d = (0, r.defaults)(d, 0), m = (0, r.defaults)(m, 0), p = (0, r.defaults)(p, u.length), f.set(u.subarray(m, p), d), p - m;
        }
      });
    }
    t.fromUint8Array = n;
    function a(u) {
      return n(new Uint8Array(u));
    }
    t.fromArrayBuffer = a;
    function i(u) {
      return n(new Uint8Array(u));
    }
    t.fromBuffer = i, t.IsNativeEndianLittle = new Uint16Array(new Uint8Array([18, 52]).buffer)[0] === 13330;
    function o(u, l, f, d, m) {
      for (var p = 0, v = f; p < v; p += d)
        for (var h = 0; h < d; h++)
          l[m + p + d - h - 1] = u[m + p + h];
    }
    t.flipByteOrder = o;
    function c(u, l, f) {
      l === void 0 && (l = 0);
      for (var d = new Int16Array(u, l, f), m = 0, p = d.length; m < p; ++m) {
        var v = d[m];
        d[m] = (v & 255) << 8 | v >> 8 & 255;
      }
    }
    t.flipByteOrderInPlace2 = c;
    function s(u, l, f, d, m) {
      t.IsNativeEndianLittle || !f || d <= 1 || o(u, l, f, d, m);
    }
    t.ensureLittleEndian = s;
  })(e.SimpleBuffer || (e.SimpleBuffer = {}));
})(zA);
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.FileHandle = void 0;
  var r = We(), t = zA;
  (function(n) {
    function a(i, o) {
      return {
        name: o,
        readBuffer: function(c, s, u, l) {
          var f, d;
          if (typeof s == "number") {
            u = (0, r.defaults)(u, s);
            var m = c, p = Math.min(i.length, m + u);
            f = p - m, d = t.SimpleBuffer.fromUint8Array(new Uint8Array(i.buffer, m, p - m));
          } else {
            u = (0, r.defaults)(u, s.length);
            var m = c, p = Math.min(i.length, m + u);
            s.set(i.subarray(m, p), l), f = p - m, d = s;
          }
          return u !== f && console.warn("byteCount ".concat(u, " and bytesRead ").concat(f, " differ")), Promise.resolve({ bytesRead: f, buffer: d });
        },
        writeBuffer: function(c, s, u) {
          return u = (0, r.defaults)(u, s.length), console.error(".writeBuffer not implemented for FileHandle.fromBuffer"), Promise.resolve(0);
        },
        writeBufferSync: function(c, s, u) {
          return u = (0, r.defaults)(u, s.length), console.error(".writeSync not implemented for FileHandle.fromBuffer"), 0;
        },
        close: r.noop
      };
    }
    n.fromBuffer = a;
  })(e.FileHandle || (e.FileHandle = {}));
})(M$);
var gD = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.readTypedArray = e.createTypedArrayBufferContext = e.createTypedArray = e.makeTypedArray = e.getElementByteSize = e.TypedArrayValueType = void 0;
  var r = Te, t = zA, n;
  (function(u) {
    u.Float32 = "float32", u.Int8 = "int8", u.Int16 = "int16", u.Uint16 = "uint16";
  })(n = e.TypedArrayValueType || (e.TypedArrayValueType = {}));
  function a(u) {
    return u === n.Float32 ? 4 : u === n.Int16 || u === n.Uint16 ? 2 : 1;
  }
  e.getElementByteSize = a;
  function i(u, l, f, d) {
    return f === void 0 && (f = 0), u === n.Float32 ? new Float32Array(l, f, d) : u === n.Int16 ? new Int16Array(l, f, d) : u === n.Uint16 ? new Uint16Array(l, f, d) : new Int8Array(l, f, d);
  }
  e.makeTypedArray = i;
  function o(u, l) {
    switch (u) {
      case n.Float32:
        return new Float32Array(new ArrayBuffer(4 * l));
      case n.Int8:
        return new Int8Array(new ArrayBuffer(1 * l));
      case n.Int16:
        return new Int16Array(new ArrayBuffer(2 * l));
      case n.Uint16:
        return new Uint16Array(new ArrayBuffer(2 * l));
    }
    throw Error("".concat(u, " is not a supported value format."));
  }
  e.createTypedArray = o;
  function c(u, l) {
    var f = a(l), d = new ArrayBuffer(f * u), m = t.SimpleBuffer.fromArrayBuffer(d), p = t.SimpleBuffer.IsNativeEndianLittle ? d : new ArrayBuffer(f * u);
    return {
      type: l,
      elementByteSize: f,
      readBuffer: m,
      valuesBuffer: new Uint8Array(p),
      values: i(l, p)
    };
  }
  e.createTypedArrayBufferContext = c;
  function s(u, l, f, d, m, p) {
    return (0, r.__awaiter)(this, void 0, void 0, function() {
      return (0, r.__generator)(this, function(v) {
        switch (v.label) {
          case 0:
            return [4, l.readBuffer(f, u.readBuffer, d, m)];
          case 1:
            return v.sent(), u.elementByteSize > 1 && (p !== void 0 && p !== t.SimpleBuffer.IsNativeEndianLittle || !t.SimpleBuffer.IsNativeEndianLittle) && t.SimpleBuffer.flipByteOrder(u.readBuffer, u.valuesBuffer, d, u.elementByteSize, m), [2, u.values];
        }
      });
    });
  }
  e.readTypedArray = s;
})(gD);
Object.defineProperty(qi, "__esModule", { value: !0 });
qi.parse = qi.parseFile = qi.getCcp4DataOffset = qi.getCcp4ValueType = qi.readCcp4Slices = qi.readCcp4Header = void 0;
var Od = Te, _Se = Kr, vV = Mi, bSe = M$, SSe = zA, cd = gD;
function w$(e) {
  return (0, Od.__awaiter)(this, void 0, void 0, function() {
    var r, t, n, a, i, o, c, s, u;
    return (0, Od.__generator)(this, function(l) {
      switch (l.label) {
        case 0:
          return r = 1024, [4, e.readBuffer(0, r)];
        case 1:
          if (t = l.sent().buffer, n = String.fromCharCode(t.readUInt8(52 * 4), t.readUInt8(52 * 4 + 1), t.readUInt8(52 * 4 + 2), t.readUInt8(52 * 4 + 3)), n !== "MAP ")
            throw new Error('ccp4 format error, missing "MAP " string');
          return a = [t.readUInt8(53 * 4), t.readUInt8(53 * 4 + 1)], i = !1, a[0] === 68 && a[1] === 65 ? i = !0 : a[0] === 17 && a[1] === 17 ? i = !1 : (o = t.readInt32LE(3 * 4), o <= 16 && (i = !0)), c = i ? function(f) {
            return t.readInt32LE(f * 4);
          } : function(f) {
            return t.readInt32BE(f * 4);
          }, s = i ? function(f) {
            return t.readFloatLE(f * 4);
          } : function(f) {
            return t.readFloatBE(f * 4);
          }, u = {
            NC: c(0),
            NR: c(1),
            NS: c(2),
            MODE: c(3),
            NCSTART: c(4),
            NRSTART: c(5),
            NSSTART: c(6),
            NX: c(7),
            NY: c(8),
            NZ: c(9),
            xLength: s(10),
            yLength: s(11),
            zLength: s(12),
            alpha: s(13),
            beta: s(14),
            gamma: s(15),
            MAPC: c(16),
            MAPR: c(17),
            MAPS: c(18),
            AMIN: s(19),
            AMAX: s(20),
            AMEAN: s(21),
            ISPG: c(22),
            NSYMBT: c(23),
            LSKFLG: c(24),
            SKWMAT: [],
            SKWTRN: [],
            userFlag1: c(39),
            userFlag2: c(40),
            // bytes 50-52 origin in X,Y,Z used for transforms
            originX: s(49),
            originY: s(50),
            originZ: s(51),
            MAP: n,
            MACHST: a,
            ARMS: s(54)
            // TODO bytes 56 NLABL
            // TODO bytes 57-256 LABEL
          }, [2, { header: u, littleEndian: i }];
      }
    });
  });
}
qi.readCcp4Header = w$;
function E$(e, r, t, n, a, i) {
  return (0, Od.__awaiter)(this, void 0, void 0, function() {
    var o, c, s, u, l, f;
    return (0, Od.__generator)(this, function(d) {
      switch (d.label) {
        case 0:
          return I$(e) ? (o = 3 * a, [4, t.readBuffer(n, r.readBuffer, a, o)]) : [3, 2];
        case 1:
          for (d.sent(), c = new Int8Array(r.valuesBuffer.buffer, o), s = (e.AMAX - e.AMIN) / 255, u = 0.5 * (e.AMIN + e.AMAX + s), l = 0, f = a; l < f; ++l)
            r.values[l] = s * c[l] + u;
          return [3, 4];
        case 2:
          return [4, (0, cd.readTypedArray)(r, t, n, a, 0, i)];
        case 3:
          d.sent(), d.label = 4;
        case 4:
          return [
            2
            /*return*/
          ];
      }
    });
  });
}
qi.readCcp4Slices = E$;
function D$(e) {
  switch (e) {
    case 0:
      return cd.TypedArrayValueType.Int8;
    case 1:
      return cd.TypedArrayValueType.Int16;
    case 2:
      return cd.TypedArrayValueType.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:
      cd.TypedArrayValueType.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 I$(e) {
  return e.userFlag1 === -128 && e.userFlag2 === 127;
}
function B$(e) {
  return I$(e) ? cd.TypedArrayValueType.Float32 : D$(e.MODE);
}
qi.getCcp4ValueType = B$;
function N$(e) {
  return 256 * 4 + e.NSYMBT;
}
qi.getCcp4DataOffset = N$;
function CSe(e, r, t) {
  return (0, Od.__awaiter)(this, void 0, void 0, function() {
    var n, a, i, o, c, s, u, l, f, d, m;
    return (0, Od.__generator)(this, function(p) {
      switch (p.label) {
        case 0:
          return [4, t.update({ message: "Parsing CCP4/MRC/MAP file..." })];
        case 1:
          return p.sent(), [4, w$(e)];
        case 2:
          return n = p.sent(), a = n.header, i = n.littleEndian, o = N$(a), c = D$(a.MODE), s = B$(a), u = a.NC * a.NR * a.NS, l = (0, cd.getElementByteSize)(c), f = u * l, d = (0, cd.createTypedArrayBufferContext)(u, s), E$(a, d, e, o, f, i), m = { header: a, values: d.values, name: e.name }, [2, m];
      }
    });
  });
}
function V$(e, r) {
  var t = this;
  return _Se.Task.create("Parse CCP4/MRC/MAP", function(n) {
    return (0, Od.__awaiter)(t, void 0, void 0, function() {
      var a, i, o;
      return (0, Od.__generator)(this, function(c) {
        switch (c.label) {
          case 0:
            return c.trys.push([0, 2, , 3]), i = (a = vV.ReaderResult).success, [4, CSe(e, r, n)];
          case 1:
            return [2, i.apply(a, [c.sent()])];
          case 2:
            return o = c.sent(), [2, vV.ReaderResult.error(o)];
          case 3:
            return [
              2
              /*return*/
            ];
        }
      });
    });
  });
}
qi.parseFile = V$;
function ASe(e, r) {
  return V$(bSe.FileHandle.fromBuffer(SSe.SimpleBuffer.fromUint8Array(e), r), e.length);
}
qi.parse = ASe;
var Md = {};
Object.defineProperty(Md, "__esModule", { value: !0 });
Md.Ccp4Format = Md.volumeFromCcp4 = Md.getCcp4Origin = void 0;
var pV = Te, xSe = Kr, hV = nr(), pi = Re, oP = kn, TSe = qi, y_ = gD, __ = hr, PSe = In;
function R$(e) {
  return e.originX === 0 && e.originY === 0 && e.originZ === 0 ? pi.Vec3.create(e.NCSTART, e.NRSTART, e.NSSTART) : pi.Vec3.create(e.originX / (e.xLength / e.NX), e.originY / (e.yLength / e.NY), e.originZ / (e.zLength / e.NZ));
}
Md.getCcp4Origin = R$;
function MSe(e) {
  var r = (0, TSe.getCcp4ValueType)(e);
  switch (r) {
    case y_.TypedArrayValueType.Float32:
      return Float32Array;
    case y_.TypedArrayValueType.Int8:
      return Int8Array;
    case y_.TypedArrayValueType.Int16:
      return Int16Array;
    case y_.TypedArrayValueType.Uint16:
      return Uint16Array;
  }
  throw Error("".concat(r, " is not a supported value format."));
}
function wSe(e, r) {
  var t = this;
  return xSe.Task.create("Create Volume", function(n) {
    return (0, pV.__awaiter)(t, void 0, void 0, function() {
      var a, i, o, c, s, u, l, f, d, m, p, v, h, y, C, S, b;
      return (0, pV.__generator)(this, function(g) {
        return a = e.header, i = e.values, o = pi.Vec3.create(a.xLength, a.yLength, a.zLength), r && r.voxelSize && pi.Vec3.mul(o, o, r.voxelSize), c = pi.Vec3.create((0, oP.degToRad)(a.alpha), (0, oP.degToRad)(a.beta), (0, oP.degToRad)(a.gamma)), s = a.ISPG > 65536 ? 0 : a.ISPG, u = hV.SpacegroupCell.create(s || "P 1", o, c), l = pi.Vec3.create(a.MAPC - 1, a.MAPR - 1, a.MAPS - 1), f = pi.Tensor.convertToCanonicalAxisIndicesFastToSlow(l), d = [a.NX, a.NY, a.NZ], m = f([a.NC, a.NR, a.NS]), p = R$(a), r != null && r.offset && pi.Vec3.add(p, p, r.offset), v = f(p), h = pi.Vec3.create(v[0] / d[0], v[1] / d[1], v[2] / d[2]), y = pi.Vec3.create(m[0] / d[0], m[1] / d[1], m[2] / d[2]), C = pi.Tensor.Space(m, pi.Tensor.invertAxisOrder(l), MSe(a)), S = pi.Tensor.create(C, pi.Tensor.Data1(i)), b = a.AMIN === 0 && a.AMAX === 0 && a.AMEAN === 0 && a.ARMS === 0, [2, {
          label: r == null ? void 0 : r.label,
          entryId: r == null ? void 0 : r.entryId,
          grid: {
            transform: { kind: "spacegroup", cell: u, fractionalBox: hV.Box3D.create(h, pi.Vec3.add(pi.Vec3.zero(), h, y)) },
            cells: S,
            stats: {
              min: isNaN(a.AMIN) || b ? (0, __.arrayMin)(i) : a.AMIN,
              max: isNaN(a.AMAX) || b ? (0, __.arrayMax)(i) : a.AMAX,
              mean: isNaN(a.AMEAN) || b ? (0, __.arrayMean)(i) : a.AMEAN,
              sigma: isNaN(a.ARMS) || a.ARMS === 0 ? (0, __.arrayRms)(i) : a.ARMS
            }
          },
          sourceData: d3.create(e),
          customProperties: new PSe.CustomProperties(),
          _propertyData: /* @__PURE__ */ Object.create(null)
        }];
      });
    });
  });
}
Md.volumeFromCcp4 = wSe;
var d3;
(function(e) {
  function r(n) {
    return (n == null ? void 0 : n.kind) === "ccp4";
  }
  e.is = r;
  function t(n) {
    return { kind: "ccp4", name: n.name, data: n };
  }
  e.create = t;
})(d3 || (d3 = {}));
Md.Ccp4Format = d3;
Object.defineProperty(UA, "__esModule", { value: !0 });
UA.CCP4Model = void 0;
var cw = Te, ESe = (0, cw.__importStar)(qi), DSe = Md;
UA.CCP4Model = {
  parse: function(e) {
    return (0, cw.__awaiter)(this, void 0, void 0, function() {
      var r, t;
      return (0, cw.__generator)(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, ESe.parse(e, "Hermite").run()];
          case 1:
            if (r = n.sent(), r.isError)
              throw r;
            return [4, (0, DSe.volumeFromCcp4)(r.result).run()];
          case 2:
            return t = n.sent(), [2, t];
        }
      });
    });
  }
};
Object.defineProperty(BA, "__esModule", { value: !0 });
BA.IsoSurfaceRepr = void 0;
var Om = Te, gV = h$, ISe = UA;
BA.IsoSurfaceRepr = {
  createTheme: function(e, r, t) {
    var n, a;
    if (t != null && t.color)
      return {
        color: (n = r.managers.representation.ctx) === null || n === void 0 ? void 0 : n.colorThemeRegistry.create(t.color.name, { volume: e }, t.color.props),
        size: (a = r.managers.representation.ctx) === null || a === void 0 ? void 0 : a.colorThemeRegistry.create("uniform", {}, {})
      };
  },
  parse: function(e, r) {
    return (0, Om.__awaiter)(this, void 0, void 0, function() {
      var t, n;
      return (0, Om.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return [4, e.arrayBuffer()];
          case 1:
            return t = a.sent(), [4, ISe.CCP4Model.parse(new Uint8Array(t))];
          case 2:
            return n = a.sent(), [2, n];
        }
      });
    });
  },
  create: function(e, r, t, n) {
    return (0, Om.__awaiter)(this, void 0, void 0, function() {
      var a;
      return (0, Om.__generator)(this, function(i) {
        switch (i.label) {
          case 0:
            return a = (0, gV.IsosurfaceRepresentation)(r, function() {
              return gV.IsosurfaceParams;
            }), t && a.setTheme(t), [4, a.createOrUpdate(n ?? {}, e).run()];
          case 1:
            return i.sent(), [2, a];
        }
      });
    });
  },
  update: function(e, r, t, n, a) {
    return (0, Om.__awaiter)(this, void 0, void 0, function() {
      return (0, Om.__generator)(this, function(i) {
        switch (i.label) {
          case 0:
            return [4, e.createOrUpdate(a ?? {}, r).run()];
          case 1:
            return i.sent(), n && e.setTheme(n), [
              2
              /*return*/
            ];
        }
      });
    });
  }
};
var b1 = {}, ap = {};
Object.defineProperty(ap, "__esModule", { value: !0 });
ap.InteractionLineRepresentation = ap.InteractionLineParams = void 0;
var a0 = Te, yV = _r, O$ = Fa(), e0 = Le, BSe = wo, _V = Wt, NSe = ui(), VSe = pl(), fb = Re, F$ = _n, L$ = X0, bV = nr(), RSe = Tr(), OSe = {
  unitLabel: e0.ParamDefinition.Text("Å", { isEssential: !0 })
}, FSe = (0, a0.__assign)((0, a0.__assign)((0, a0.__assign)({}, O$.Lines.Params), OSe), {
  lineSizeAttenuation: e0.ParamDefinition.Boolean(!1),
  linesColor: e0.ParamDefinition.Color((0, RSe.Color)(14080239), { isEssential: !0 }),
  linesSize: e0.ParamDefinition.Numeric(0.8),
  // alpha: PD.Numeric(0.6, { min: 0, max: 1, step: 0.01 })
  alpha: e0.ParamDefinition.Numeric(0.6, { min: 0, max: 1, step: 0.01 }, {
    label: "Opacity",
    isEssential: !0,
    description: "How opaque/transparent the representation is rendered."
  })
}), k$ = {
  lines: function(e, r) {
    return (0, BSe.ShapeRepresentation)(GSe, O$.Lines.Utils, {
      modifyState: function(t) {
        return (0, a0.__assign)((0, a0.__assign)({}, t), { markerActions: F$.MarkerActions.Highlighting });
      }
    });
  }
};
ap.InteractionLineParams = (0, a0.__assign)((0, a0.__assign)({}, FSe), { visuals: e0.ParamDefinition.MultiSelect(["lines"], e0.ParamDefinition.objectToOptions(k$)) });
function LSe() {
  return {
    sphereA: (0, bV.Sphere3D)(),
    sphereB: (0, bV.Sphere3D)(),
    center: (0, fb.Vec3)(),
    distance: 0
  };
}
function kSe(e, r) {
  var t = r.sphereA, n = r.sphereB, a = r.center, i = e.loci, o = i[0], c = i[1];
  return yV.Loci.getBoundingSphere(o, t), yV.Loci.getBoundingSphere(c, n), fb.Vec3.add(a, t.center, n.center), fb.Vec3.scale(a, a, 0.5), r.distance = fb.Vec3.distance(t.center, n.center), r;
}
var zf = LSe();
function USe(e, r) {
  return e.pairs.length === 1 ? "interactionLine ".concat((0, L$.distanceLabel)(e.pairs[0], {
    unitLabel: r,
    measureOnly: !0
  })) : "".concat(e.pairs.length, " interactionLines");
}
function zSe(e, r, t) {
  for (var n = VSe.LinesBuilder.create(128, 64, t), a = 0, i = e.pairs.length; a < i; ++a)
    kSe(e.pairs[a], zf), n.add(zf.sphereA.center[0], zf.sphereA.center[1], zf.sphereA.center[2], zf.sphereB.center[0], zf.sphereB.center[1], zf.sphereB.center[2], a);
  return n.getLines();
}
function GSe(e, r, t, n) {
  var a = zSe(r, t, n && n.geometry), i = USe(r, t.unitLabel), o = function(c) {
    return (0, L$.distanceLabel)(r.pairs[c], t);
  };
  return NSe.Shape.create(i, r, a, function() {
    return t.linesColor;
  }, function() {
    return t.linesSize;
  }, o);
}
function qSe(e, r) {
  var t = _V.Representation.createMulti("interactionLine", e, r, _V.Representation.StateBuilder, k$);
  return t.setState({ pickable: !0, markerActions: F$.MarkerActions.All }), t;
}
ap.InteractionLineRepresentation = qSe;
var SV;
function HSe() {
  if (SV) return b1;
  SV = 1, Object.defineProperty(b1, "__esModule", { value: !0 }), b1.MappingLineRepr = void 0;
  var e = Te, r = ap, t = sn();
  return b1.MappingLineRepr = {
    parse: function(n, a) {
      return n.map(function(i) {
        var o = a.managers.cell.get(i.ref), c = (0, t.getStructureByCell)(o);
        return (0, t.getLoci)(c, i.elementIds);
      });
    },
    create: function(n, a, i) {
      return (0, e.__awaiter)(this, void 0, void 0, function() {
        var o;
        return (0, e.__generator)(this, function(c) {
          switch (c.label) {
            case 0:
              return o = (0, r.InteractionLineRepresentation)(a, function() {
                return r.InteractionLineParams;
              }), [4, o.createOrUpdate({}, {
                pairs: [{ loci: n }]
              }).run()];
            case 1:
              return c.sent(), [2, o];
          }
        });
      });
    },
    update: function(n, a, i, o) {
      return (0, e.__awaiter)(this, void 0, void 0, function() {
        return (0, e.__generator)(this, function(c) {
          switch (c.label) {
            case 0:
              return [4, n.createOrUpdate({}, {
                pairs: [{ loci: a }]
              }).run()];
            case 1:
              return c.sent(), [
                2
                /*return*/
              ];
          }
        });
      });
    }
  }, b1;
}
var GA = {}, sc = {};
Object.defineProperty(sc, "__esModule", { value: !0 });
sc.UnitcellRepresentation = sc.getUnitcellData = sc.UnitcellParams = void 0;
var dw = Te, U$ = Je(), jSe = wo, $Se = ui(), KSe = Oa, Fm = Le, z$ = Dt(), uP = Ca(), WSe = ns, so = Re, f3 = wu, b_ = nr(), CV = Wt, XSe = so.Mat4.fromTranslation((0, so.Mat4)(), so.Vec3.create(0.5, 0.5, 0.5)), YSe = (0, f3.transformCage)((0, f3.cloneCage)((0, WSe.BoxCage)()), XSe), Gu = (0, so.Vec3)(), AV = (0, so.Mat4)(), QSe = {
  origin: "Origin",
  model: "Model"
}, ZSe = {
  corner: "Corner",
  center: "Center"
}, JSe = (0, dw.__assign)((0, dw.__assign)({}, z$.Mesh.Params), { cellColor: Fm.ParamDefinition.Color(KSe.ColorNames.black), cellScale: Fm.ParamDefinition.Numeric(2, { min: 0.1, max: 5, step: 0.1 }), ref: Fm.ParamDefinition.Select("model", Fm.ParamDefinition.objectToOptions(QSe), { isEssential: !0 }), attachment: Fm.ParamDefinition.Select("corner", Fm.ParamDefinition.objectToOptions(ZSe), {
  isEssential: !0
}) }), eCe = {
  mesh: function(e, r) {
    return (0, jSe.ShapeRepresentation)(tCe, z$.Mesh.Utils);
  }
};
sc.UnitcellParams = (0, dw.__assign)({}, JSe);
function rCe(e, r, t) {
  var n = uP.MeshBuilder.createState(256, 128, t), a = e.symmetry.spacegroup.cell.fromFractional;
  so.Vec3.copy(Gu, e.ref), r.attachment === "center" ? (so.Vec3.trunc(Gu, Gu), so.Vec3.subScalar(Gu, Gu, 0.5)) : so.Vec3.floor(Gu, Gu), so.Mat4.fromTranslation(AV, Gu);
  var i = (0, f3.transformCage)((0, f3.cloneCage)(YSe), AV), o = Math.cbrt(e.symmetry.spacegroup.cell.volume) / 300 * r.cellScale;
  n.currentGroup = 1, uP.MeshBuilder.addCage(n, a, i, o, 2, 20);
  var c = b_.Sphere3D.fromDimensionsAndTransform((0, b_.Sphere3D)(), so.Vec3.unit, a);
  so.Vec3.transformMat4(Gu, Gu, a), b_.Sphere3D.translate(c, c, Gu), b_.Sphere3D.expand(c, c, o);
  var s = uP.MeshBuilder.getMesh(n);
  return s.setBoundingSphere(c), s;
}
function tCe(e, r, t, n) {
  var a = rCe(r, t, n && n.geometry), i = U$.Symmetry.getUnitcellLabel(r.symmetry);
  return $Se.Shape.create(i, r, a, function() {
    return t.cellColor;
  }, function() {
    return 1;
  }, function() {
    return i;
  });
}
function nCe(e, r, t) {
  var n = (0, so.Vec3)();
  return t.ref === "model" && so.Vec3.transformMat4(n, U$.Model.getCenter(e), r.spacegroup.cell.toFractional), { symmetry: r, ref: n };
}
sc.getUnitcellData = nCe;
function aCe(e, r) {
  return CV.Representation.createMulti("Unit Cell", e, r, CV.Representation.StateBuilder, eCe);
}
sc.UnitcellRepresentation = aCe;
Object.defineProperty(GA, "__esModule", { value: !0 });
GA.UnitCellRepr = void 0;
var S_ = Te, xV = sc;
GA.UnitCellRepr = {
  create: function(e, r, t) {
    return (0, S_.__awaiter)(this, void 0, void 0, function() {
      var n;
      return (0, S_.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return n = (0, xV.UnitcellRepresentation)(r, function() {
              return xV.UnitcellParams;
            }), [4, n.createOrUpdate({}, e).run()];
          case 1:
            return a.sent(), [2, n];
        }
      });
    });
  },
  update: function(e, r, t, n) {
    return (0, S_.__awaiter)(this, void 0, void 0, function() {
      return (0, S_.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return [4, e.createOrUpdate({}, r).run()];
          case 1:
            return a.sent(), [
              2
              /*return*/
            ];
        }
      });
    });
  }
};
var qA = {}, ip = {}, G$ = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 });
  var r = Te;
  (0, r.__exportStar)(q3, e);
})(G$);
Object.defineProperty(ip, "__esModule", { value: !0 });
ip.CustomLinesRepresentation = ip.CustomLinesParams = void 0;
var i0 = Te, q$ = Fa(), Kl = Le, iCe = wo, TV = Wt, oCe = ui(), uCe = pl(), H$ = _n, sCe = Oa, PV = G$, lCe = {
  unitLabel: Kl.ParamDefinition.Text("Å", { isEssential: !0 })
}, cCe = (0, i0.__assign)((0, i0.__assign)((0, i0.__assign)({}, q$.Lines.Params), lCe), { lineSizeAttenuation: Kl.ParamDefinition.Boolean(!1), linesColor: Kl.ParamDefinition.Color(sCe.ColorNames.black), linesSize: Kl.ParamDefinition.Numeric(2), alpha: Kl.ParamDefinition.Numeric(0.6, { min: 0, max: 1, step: 0.01 }, {
  label: "Opacity",
  isEssential: !0,
  description: "How opaque/transparent the representation is rendered."
}), isDash: Kl.ParamDefinition.Boolean(!1), dashLength: Kl.ParamDefinition.Numeric(0.04, { min: 0.01, max: 0.2, step: 0.01 }) }), j$ = {
  lines: function(e, r) {
    return (0, iCe.ShapeRepresentation)(mCe, q$.Lines.Utils, {
      modifyState: function(t) {
        return (0, i0.__assign)((0, i0.__assign)({}, t), { markerActions: H$.MarkerActions.Selecting });
      }
    });
  }
};
ip.CustomLinesParams = (0, i0.__assign)((0, i0.__assign)({}, cCe), { visuals: Kl.ParamDefinition.MultiSelect(["lines"], Kl.ParamDefinition.objectToOptions(j$)) });
function dCe(e, r) {
  return "".concat(e.lines.length, " interactionLines");
}
function fCe(e, r, t) {
  for (var n = uCe.LinesBuilder.create(128, 64, t), a = 0, i = e.lines.length; a < i; ++a)
    r.isDash ? n.addFixedLengthDashes(PV.Vec3.create(e.lines[a][0][0], e.lines[a][0][1], e.lines[a][0][2]), PV.Vec3.create(e.lines[a][1][0], e.lines[a][1][1], e.lines[a][1][2]), r.dashLength, a) : n.add(e.lines[a][0][0], e.lines[a][0][1], e.lines[a][0][2], e.lines[a][1][0], e.lines[a][1][1], e.lines[a][1][2], a);
  return n.getLines();
}
function mCe(e, r, t, n) {
  var a = fCe(r, t, n && n.geometry), i = dCe(r, t.unitLabel);
  return oCe.Shape.create(i, r, a, function() {
    return t.linesColor;
  }, function() {
    return t.linesSize;
  }, function() {
    return "CustomLines";
  });
}
function vCe(e, r) {
  var t = TV.Representation.createMulti("customLines", e, r, TV.Representation.StateBuilder, j$);
  return t.setState({ pickable: !1, markerActions: H$.MarkerActions.Selecting }), t;
}
ip.CustomLinesRepresentation = vCe;
Object.defineProperty(qA, "__esModule", { value: !0 });
qA.CustomLinesRepr = void 0;
var C_ = Te, MV = ip;
qA.CustomLinesRepr = {
  create: function(e, r, t, n) {
    return (0, C_.__awaiter)(this, void 0, void 0, function() {
      var a;
      return (0, C_.__generator)(this, function(i) {
        switch (i.label) {
          case 0:
            return a = (0, MV.CustomLinesRepresentation)(r, function() {
              return MV.CustomLinesParams;
            }), [4, a.createOrUpdate(n ?? {}, {
              lines: e
            }).run()];
          case 1:
            return i.sent(), [2, a];
        }
      });
    });
  },
  update: function(e, r, t, n, a) {
    return (0, C_.__awaiter)(this, void 0, void 0, function() {
      return (0, C_.__generator)(this, function(i) {
        switch (i.label) {
          case 0:
            return [4, e.createOrUpdate(a ?? {}, {
              lines: r
            }).run()];
          case 1:
            return i.sent(), [
              2
              /*return*/
            ];
        }
      });
    });
  }
};
var HA = {}, op = {};
Object.defineProperty(op, "__esModule", { value: !0 });
op.CustomPlanesRepresentation = op.CustomPlanesParams = void 0;
var m3 = Te, v3 = Le, pCe = Oa, hCe = wo, wV = Wt, gCe = ui(), $$ = Dt(), sP = Ca(), Lm = Re, yCe = _n, _Ce = (0, m3.__assign)((0, m3.__assign)({}, $$.Mesh.Params), { color: v3.ParamDefinition.Color(pCe.ColorNames.orange), scaleFactor: v3.ParamDefinition.Numeric(1, { min: 0.1, max: 10, step: 0.1 }) }), K$ = {
  plane: function(e, r) {
    return (0, hCe.ShapeRepresentation)(SCe, $$.Mesh.Utils);
  }
};
op.CustomPlanesParams = (0, m3.__assign)((0, m3.__assign)({}, _Ce), { visuals: v3.ParamDefinition.MultiSelect(["plane"], v3.ParamDefinition.objectToOptions(K$)) });
function bCe(e, r, t) {
  var n = sP.MeshBuilder.createState(256, 128, t);
  return e.planes.forEach(function(a) {
    sP.MeshBuilder.addTriangle(n, Lm.Vec3.create.apply(Lm.Vec3, a[0]), Lm.Vec3.create.apply(Lm.Vec3, a[1]), Lm.Vec3.create.apply(Lm.Vec3, a[2]));
  }), sP.MeshBuilder.getMesh(n);
}
function SCe(e, r, t, n) {
  var a = bCe(r, t, n && n.geometry);
  return gCe.Shape.create("CustomPlanes", r, a, function() {
    return t.color;
  }, function() {
    return 1;
  }, function() {
    return "CustomPlanes";
  });
}
function CCe(e, r) {
  var t = wV.Representation.createMulti("CustomPlanes", e, r, wV.Representation.StateBuilder, K$);
  return t.setState({ pickable: !1, markerActions: yCe.MarkerActions.Selecting }), t;
}
op.CustomPlanesRepresentation = CCe;
Object.defineProperty(HA, "__esModule", { value: !0 });
HA.CustomPlanesRepr = void 0;
var A_ = Te, EV = op;
HA.CustomPlanesRepr = {
  create: function(e, r, t, n) {
    return (0, A_.__awaiter)(this, void 0, void 0, function() {
      var a;
      return (0, A_.__generator)(this, function(i) {
        switch (i.label) {
          case 0:
            return a = (0, EV.CustomPlanesRepresentation)(r, function() {
              return EV.CustomPlanesParams;
            }), [4, a.createOrUpdate(n ?? {}, {
              planes: e
            }).run()];
          case 1:
            return i.sent(), [2, a];
        }
      });
    });
  },
  update: function(e, r, t, n, a) {
    return (0, A_.__awaiter)(this, void 0, void 0, function() {
      return (0, A_.__generator)(this, function(i) {
        switch (i.label) {
          case 0:
            return [4, e.createOrUpdate(a ?? {}, {
              planes: r
            }).run()];
          case 1:
            return i.sent(), [
              2
              /*return*/
            ];
        }
      });
    });
  }
};
var DV;
function $p() {
  return DV || (DV = 1, function(e) {
    var r, t, n;
    Object.defineProperty(e, "__esModule", { value: !0 }), e.INTERACTION_TYPE = e.OtherRepresentation = e.MeasurementRepresentation = e.MolecularRepresentation = void 0;
    var a = Jt, i = iA, o = Iy, c = vA, s = pA, u = hA, l = SA, f = AA, d = xA, m = Gbe(), p = MA, v = EA, h = DA, y = IA, C = BA, S = HSe(), b = GA, g = qA, _ = HA;
    e.MolecularRepresentation = (r = {}, r[a.RepresentationType.Ribbon] = i.RibbonRepr, r[a.RepresentationType.BallAndStick] = o.BallAndStickRepr, r[a.RepresentationType.Line] = f.LineRepr, r[a.RepresentationType.Stick] = d.StickRepr, r[a.RepresentationType.CPK] = v.CPKRepr, r), e.MeasurementRepresentation = (t = {}, t[a.RepresentationType.Label] = c.LabelRepr, t[a.RepresentationType.Distance] = s.DistanceRepr, t[a.RepresentationType.Angle] = u.AngleRepr, t[a.RepresentationType.Dihedral] = l.DihedralRepr, t), e.OtherRepresentation = (n = {}, n[a.RepresentationType.Surface] = m.SurfaceRepr, n[a.RepresentationType.IsoSurface] = C.IsoSurfaceRepr, n[a.RepresentationType.RotateArrow] = p.RotateArrowRepr, n[a.RepresentationType.Pocket] = h.PocketRepr, n[a.RepresentationType.Pharmacophore] = y.PharmachophoreRepr, n[a.RepresentationType.MappingLine] = S.MappingLineRepr, n[a.RepresentationType.UnitCell] = b.UnitCellRepr, n[a.RepresentationType.CustomLines] = g.CustomLinesRepr, n[a.RepresentationType.CustomPlanes] = _.CustomPlanesRepr, n), function(A) {
      A.LigandReceptor = "ligand-receptor", A.IntraLigand = "intra-ligand", A.IntraReceptor = "intra-receptor", A.All = "all";
    }(e.INTERACTION_TYPE || (e.INTERACTION_TYPE = {}));
  }(CT)), CT;
}
var IV;
function ACe() {
  if (IV) return Uo;
  IV = 1;
  var e;
  Object.defineProperty(Uo, "__esModule", { value: !0 }), Uo.getMeasurementProps = Uo.removeElementIdsInRepresentation = Uo.overlapRepresentationByElementIds = Uo.isCellItemIntersectCellItem = Uo.isRepresentationIntersectElementIds = void 0;
  var r = eu(), t = Jt, n = Lp, a = Hp(), i = $p(), o = ef(), c = function(m, p) {
    var v, h, y, C = (0, n.transformLociToElementLoci)(m.getLoci());
    if (!C || !(!((y = (h = (v = C == null ? void 0 : C.elements) === null || v === void 0 ? void 0 : v[0]) === null || h === void 0 ? void 0 : h.unit) === null || y === void 0) && y.elements))
      return t.Intersection.Not;
    var S = new Set((0, n.getElementIdsByLoci)(C)), b = 0;
    return p.forEach(function(g) {
      S.has(g) && b++;
    }), b ? b === p.length ? t.Intersection.Include : b === S.size ? t.Intersection.BeIncluded : t.Intersection.Cross : t.Intersection.Not;
  };
  Uo.isRepresentationIntersectElementIds = c;
  var s = function(m, p) {
    var v, h;
    if (m.ref !== p.ref)
      return !1;
    if (!(!((v = m.elementIds) === null || v === void 0) && v.length) || !(!((h = p.elementIds) === null || h === void 0) && h.length))
      return !0;
    var y = new Set(p.elementIds);
    return m.elementIds.some(function(C) {
      return y.has(C);
    });
  };
  Uo.isCellItemIntersectCellItem = s;
  var u = function(m, p) {
    var v = (0, n.transformLociToElementLoci)(m.getLoci());
    if (!v)
      return [];
    var h = (0, n.getLoci)(v == null ? void 0 : v.structure, p), y = r.Loci.intersect(v, h);
    return (0, n.getElementIdsByLoci)(y);
  };
  Uo.overlapRepresentationByElementIds = u;
  var l = function(m, p, v, h, y) {
    var C = (0, a.getStructureFromRepresentation)(m);
    if (!C) {
      console.warn("removeElementIdsInRepresentation");
      return;
    }
    var S = (0, a.removeStructureByElementIds)(C, p);
    return i.MolecularRepresentation[v].update(m, S, o.lightPlugin.managers.representation.ctx, h ? h(S) : m.theme), y && m.setState({
      transparency: y(S)
    }), m;
  };
  Uo.removeElementIdsInRepresentation = l;
  var f = (e = {}, // 'customText', 'textColor', 'textSize', 'borderWidth', 'borderColor', 'background', 'backgroundColor', 'alpha', 'attachment'
  e[t.RepresentationType.Label] = ["customText", "textColor", "textSize"], // 'alpha', 'lineColor', 'linesSize', 'dashLength', 'unitLabel', 'customText'
  e[t.RepresentationType.Distance] = ["linesColor", "textSize", "textColor"], // 'color', 'arcScale', 'sectorOpacity', 'linesSize', 'dashLength', 'customText'
  e[t.RepresentationType.Angle] = ["color", "textSize", "textColor"], // 'color', 'arcScale', 'sectorOpacity', 'linesSize', 'dashLength', 'customText'
  e[t.RepresentationType.Dihedral] = ["color", "textSize", "textColor"], e), d = function(m, p) {
    if (t.MeasurementType.has(m)) {
      var v = {};
      return f[m].forEach(function(h) {
        v[h] = p.props[h];
      }), v;
    }
  };
  return Uo.getMeasurementProps = d, Uo;
}
var qu = {}, BV;
function jA() {
  if (BV) return qu;
  BV = 1, Object.defineProperty(qu, "__esModule", { value: !0 }), qu.getUnitCellData = qu.getBox = qu.getDragOffset = qu.rotateArbitraryLine = void 0;
  var e = Re, r = Lp, t = ia(), n = Hp(), a = ml(), i = sc, o = function(l, f, d, m) {
    var p = [
      [0, 0, 0, 0],
      [0, 0, 0, 0],
      [0, 0, 0, 0],
      [0, 0, 0, 0]
    ], v = l[0], h = l[1], y = l[2], C = function(H, q) {
      return [q[0] - H[0], q[1] - H[1], q[2] - H[2]];
    }, S = function(H) {
      var q = e.Vec3.create(H[0], H[1], H[2]);
      return e.Vec3.normalize(q, q), [q[0], q[1], q[2]];
    }, b = S(C(l, f)), g = b[0], _ = b[1], A = b[2], M = g * g, P = g * _, T = g * A, x = _ * _, w = _ * A, E = A * A, I = v * g, B = v * _, D = v * A, N = h * g, O = h * _, V = h * A, k = y * g, G = y * _, L = y * A, R = Math.cos(d * (Math.PI / 180)), F = Math.sin(d * (Math.PI / 180));
    p[0][0] = M + (x + E) * R, p[0][1] = P * (1 - R) + A * F, p[0][2] = T * (1 - R) - _ * F, p[0][3] = 0, p[1][0] = P * (1 - R) - A * F, p[1][1] = x + (M + E) * R, p[1][2] = w * (1 - R) + g * F, p[1][3] = 0, p[2][0] = T * (1 - R) + _ * F, p[2][1] = w * (1 - R) - g * F, p[2][2] = E + (M + x) * R, p[2][3] = 0, p[3][0] = (v * (x + E) - g * (O + L)) * (1 - R) + (V - G) * F, p[3][1] = (h * (M + E) - _ * (I + L)) * (1 - R) + (k - D) * F, p[3][2] = (y * (M + x) - A * (I + O)) * (1 - R) + (B - N) * F, p[3][3] = 1;
    var U = [
      m[0] * p[0][0] + m[1] * p[1][0] + m[2] * p[2][0] + p[3][0],
      m[0] * p[0][1] + m[1] * p[1][1] + m[2] * p[2][1] + p[3][1],
      m[0] * p[0][2] + m[1] * p[1][2] + m[2] * p[2][2] + p[3][2]
    ];
    return U;
  };
  qu.rotateArbitraryLine = o;
  var c = function(l, f, d) {
    var m, p, v, h, y, C;
    if (!l.canvas3d)
      return e.Vec3.create(0, 0, 0);
    var S = e.Vec2.create(0, 0), b = e.Vec3.create(0, 0, 0), g = e.Vec3.create(0, 0, 0);
    if (e.Vec2.sub(S, e.Vec2.copy(S, d), f), e.Vec2.squaredMagnitude(S)) {
      var _ = (p = (m = l.canvas3d) === null || m === void 0 ? void 0 : m.input.pixelRatio) !== null && p !== void 0 ? p : 1;
      return S[0] *= 1 / l.canvas3d.camera.zoom * l.canvas3d.camera.viewport.width * _, S[1] *= 1 / l.canvas3d.camera.zoom * l.canvas3d.camera.viewport.height * _ * (((h = (v = l.layout) === null || v === void 0 ? void 0 : v.canvas.clientWidth) !== null && h !== void 0 ? h : 1) / ((C = (y = l.layout) === null || y === void 0 ? void 0 : y.canvas.clientHeight) !== null && C !== void 0 ? C : 1)), e.Vec3.cross(b, e.Vec3.sub(b, l.canvas3d.camera.position, l.canvas3d.camera.target), l.canvas3d.camera.up), e.Vec3.setMagnitude(b, b, S[0]), e.Vec3.setMagnitude(g, l.canvas3d.camera.up, S[1]), e.Vec3.add(b, b, g), e.Vec3.scale(b, b, 1 / 2100), b;
    }
    return e.Vec3.create(0, 0, 0);
  };
  qu.getDragOffset = c;
  var s = function(l, f) {
    var d = t.StructureElement.Loci.getBoundary((0, r.getLoci)(l, f));
    return {
      center: e.Vec3.create((d.box.max[0] + d.box.min[0]) / 2, (d.box.max[1] + d.box.min[1]) / 2, (d.box.max[2] + d.box.min[2]) / 2),
      size: e.Vec3.create(d.box.max[0] - d.box.min[0], d.box.max[1] - d.box.min[1], d.box.max[2] - d.box.min[2])
    };
  };
  qu.getBox = s;
  var u = function(l) {
    var f = (0, n.getModelByStructure)(l);
    if (f) {
      var d = a.ModelSymmetry.Provider.get(f);
      if (d) {
        var m = (0, i.getUnitcellData)(f, d, {});
        return m;
      }
    }
  };
  return qu.getUnitCellData = u, qu;
}
var $A = {};
Object.defineProperty($A, "__esModule", { value: !0 });
$A.timeSlicing = void 0;
window.requestIdleCallback = window.requestIdleCallback || function(e) {
  var r = Date.now();
  return setTimeout(function() {
    e({
      didTimeout: !1,
      timeRemaining: function() {
        return Math.max(0, 50 - (Date.now() - r));
      }
    });
  }, 1);
};
function W$(e, r) {
  window.requestIdleCallback(function(t) {
    for (var n = e.next(); !n.done; ) {
      if (t.timeRemaining() <= (r ?? 0)) {
        W$(e, r);
        return;
      }
      n = e.next();
    }
  });
}
$A.timeSlicing = W$;
var NV;
function sn() {
  return NV || (NV = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 });
    var r = Te;
    (0, r.__exportStar)(Lp, e), (0, r.__exportStar)(ZE, e), (0, r.__exportStar)(Hp(), e), (0, r.__exportStar)($H(), e), (0, r.__exportStar)(kp, e), (0, r.__exportStar)(ACe(), e), (0, r.__exportStar)(Up, e), (0, r.__exportStar)(jA(), e), (0, r.__exportStar)(xy, e), (0, r.__exportStar)(aD, e), (0, r.__exportStar)($A, e), (0, r.__exportStar)(zp(), e);
  }(dT)), dT;
}
var VV;
function xCe() {
  if (VV) return Xh;
  VV = 1, Object.defineProperty(Xh, "__esModule", { value: !0 }), Xh.CameraManager = void 0;
  var e = Te, r = Jt, t = q3, n = ys, a = Mp(), i = sn(), o = new n.BoundaryHelper("98"), c = (
    /** @class */
    function() {
      function u(l) {
        this.boundaryHelper = new n.BoundaryHelper("98"), this.plugin = l;
      }
      return u.prototype.focus = function(l) {
        var f;
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var d, m, p, v, h, y, C, S, b, g, _, A, T, x, M, P, w, T, x, w, E = this;
          return (0, e.__generator)(this, function(I) {
            switch (I.label) {
              case 0:
                if (d = !1, m = [], p = [], l ? l.forEach(function(B) {
                  var D = E.plugin.cells.get(B.ref);
                  if (D) {
                    if (Array.from(D.representations.keys()).some(function(N) {
                      return r.MeasurementType.has(N) || r.OtherReprType.has(N);
                    })) {
                      p.push(B);
                      return;
                    }
                    m.push(B);
                  }
                }) : (p.push.apply(p, Array.from(this.plugin.managers.selection.shape.selection.values()).map(function(B) {
                  return { ref: B };
                })), m.push.apply(m, this.plugin.managers.selection.structure.getSelectionCellItems().length ? this.plugin.managers.selection.structure.getSelectionCellItems() : p.length ? [] : this.plugin.managers.cell.getAllDisplayedCellsRef().map(function(B) {
                  return { ref: B };
                }))), !m.length && !p.length)
                  return [
                    2
                    /*return*/
                  ];
                v = t.Vec3.create(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), h = t.Vec3.create(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), o.reset(), y = [], p.forEach(function(B) {
                  var D = E.plugin.cells.get(B.ref);
                  if (D) {
                    if (D.representations.has(r.RepresentationType.Surface)) {
                      m.push(D.model.other);
                      return;
                    }
                    if (D.representations.has(r.RepresentationType.Pharmacophore)) {
                      var N = D.model.other, O = N.center, V = N.normal, k = N.radius;
                      if (!V) {
                        t.Vec3.min(v, v, t.Vec3.create(O[0] - k, O[1] - k, O[2] - k)), t.Vec3.max(h, h, t.Vec3.create(O[0] + k, O[1] + k, O[2] + k)), d = !0;
                        return;
                      }
                      var G = t.Vec3.create((O[0] + V[0]) / 2, (O[1] + V[1]) / 2, (O[2] + V[2]) / 2), L = (t.Vec3.distance(V, O) + k) / 2;
                      t.Vec3.min(v, v, t.Vec3.create(G[0] - L, G[1] - L, G[2] - L)), t.Vec3.max(h, h, t.Vec3.create(G[0] + L, G[1] + L, G[2] + L)), d = !0;
                      return;
                    }
                    if (D.representations.has(r.RepresentationType.Pocket)) {
                      var R = D.model.other, O = R.center, F = R.size, U = [(O[0] * 2 + F[0]) / 2, (O[1] * 2 + F[1]) / 2, (O[2] * 2 + F[2]) / 2], H = [(O[0] * 2 - F[0]) / 2, (O[1] * 2 - F[1]) / 2, (O[2] * 2 - F[2]) / 2], q = { min: t.Vec3.fromArray(t.Vec3.zero(), H, 0), max: t.Vec3.fromArray(t.Vec3.zero(), U, 0) };
                      t.Vec3.min(v, v, q.min), t.Vec3.max(h, h, q.max), d = !0;
                      return;
                    }
                    m.push.apply(m, D.dependency.on);
                  }
                }), C = 0, S = m, I.label = 1;
              case 1:
                return C < S.length ? (b = S[C], g = this.plugin.cells.get(b.ref), g ? [4, this.plugin.managers.cell.getStructure(b.ref)] : [
                  2
                  /*return*/
                ]) : [3, 4];
              case 2:
                if (_ = I.sent(), !_)
                  return [
                    2
                    /*return*/
                  ];
                A = (0, i.getLoci)(_, b.elementIds), (!a.StructureElement.Loci.isEmpty(A) || ((f = A == null ? void 0 : A.elements) === null || f === void 0 ? void 0 : f.length) > 0) && y.push(a.StructureElement.Loci.getBoundary(A)), I.label = 3;
              case 3:
                return C++, [3, 1];
              case 4:
                if (!y.length)
                  return d && this.focusSphere({
                    center: t.Vec3.create((h[0] + v[0]) / 2, (h[1] + v[1]) / 2, (h[2] + v[2]) / 2),
                    radius: t.Vec3.distance(h, v) / 2
                  }), [
                    2
                    /*return*/
                  ];
                for (T = 0, x = y.length; T < x; ++T)
                  M = y[T], P = M.box, w = M.sphere, t.Vec3.min(v, v, P.min), t.Vec3.max(h, h, P.max), o.includePositionRadius(w.center, w.radius);
                for (o.finishedIncludeStep(), T = 0, x = y.length; T < x; ++T)
                  w = y[T].sphere, o.radiusPositionRadius(w.center, w.radius);
                return this.focusSphere(o.getSphere()), [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, u.prototype.focusSphere = function(l, f) {
        var d, m, p = (0, e.__assign)({ minRadius: 5, extraRadius: 4, durationMs: 250 }, f), v = p.extraRadius, h = p.minRadius, y = p.durationMs, C = Math.max(l.radius + v, h), S = (d = this.plugin.canvas3d) === null || d === void 0 ? void 0 : d.camera.getFocus(l.center, C);
        (m = this.plugin.canvas3d) === null || m === void 0 || m.requestCameraReset({ durationMs: y, snapshot: S });
      }, u.prototype.reset = function() {
        var l;
        (l = this.plugin.canvas3d) === null || l === void 0 || l.requestCameraReset({
          durationMs: 200
        });
      }, u.prototype.zoomIn = function() {
        var l, f, d = (l = this.plugin.canvas3d) === null || l === void 0 ? void 0 : l.camera.getSnapshot();
        if (d) {
          var m = s(d, 1);
          t.Vec3.distance(d.target, m) < 10 || (d.position = m, (f = this.plugin.canvas3d) === null || f === void 0 || f.camera.setState(d, 200));
        }
      }, u.prototype.zoomOut = function() {
        var l, f, d = (l = this.plugin.canvas3d) === null || l === void 0 ? void 0 : l.camera.getSnapshot();
        if (d) {
          var m = s(d, -1);
          d.position = m, (f = this.plugin.canvas3d) === null || f === void 0 || f.camera.setState(d, 200);
        }
      }, u.prototype.updateAxes = function(l) {
        var f, d, m, p, v, h, y, C, S = {
          vecA: t.Vec3.unitX,
          vecB: t.Vec3.unitY,
          vecC: t.Vec3.unitZ
        }, b = this.plugin.cells.get(l);
        if (b) {
          var g = (0, i.getStructureByCell)(b);
          if (g && (!((p = (m = (d = (f = (0, i.getModelByStructure)(g)) === null || f === void 0 ? void 0 : f.sourceData) === null || d === void 0 ? void 0 : d.data) === null || m === void 0 ? void 0 : m.molecules) === null || p === void 0) && p.length)) {
            var _ = (y = (h = (v = (0, i.getModelByStructure)(g)) === null || v === void 0 ? void 0 : v.sourceData) === null || h === void 0 ? void 0 : h.data) === null || y === void 0 ? void 0 : y.molecules[0].cell, A = _.vecA, M = _.vecB, P = _.vecC;
            S = {
              vecA: t.Vec3.scale((0, t.Vec3)(), A, 1 / t.Vec3.distance((0, t.Vec3)(), A)),
              vecB: t.Vec3.scale((0, t.Vec3)(), M, 1 / t.Vec3.distance((0, t.Vec3)(), M)),
              vecC: t.Vec3.scale((0, t.Vec3)(), P, 1 / t.Vec3.distance((0, t.Vec3)(), P))
            };
          }
        }
        (C = this.plugin.canvas3d) === null || C === void 0 || C.setProps({
          camera: {
            helper: {
              // @ts-ignore
              axes: {
                name: "on",
                params: S
              }
            }
          }
        });
      }, u;
    }()
  );
  Xh.CameraManager = c;
  function s(u, l) {
    var f = (0, t.Vec3)();
    t.Vec3.sub(f, u.target, u.position), t.Vec3.normalize(f, f), t.Vec3.scale(f, f, 5 * l);
    var d = u.position;
    return t.Vec3.add(d, d, f), d;
  }
  return Xh;
}
var S1 = {}, lP = {}, cP = {}, dP = {}, up = {};
Object.defineProperty(up, "__esModule", { value: !0 });
up.InterContactsBuilder = up.IntraContactsBuilder = void 0;
var TCe = dl, fw = Mo, PCe = qd, mw;
(function(e) {
  function r(t, n) {
    var a = [], i = [], o = [];
    return {
      add: function(c, s, u) {
        a[a.length] = c, i[i.length] = s, o[o.length] = u;
      },
      getContacts: function() {
        for (var c = new TCe.IntAdjacencyGraph.EdgeBuilder(t.count, a, i), s = new Int8Array(c.slotCount), u = new Int8Array(c.slotCount), l = 0, f = c.edgeCount; l < f; l++)
          c.addNextEdge(), c.assignProperty(s, o[l]);
        var d = c.createGraph({ type: s, flag: u }), m, p = Object.defineProperty(d, "elementsIndex", {
          get: function() {
            return m || (m = fw.InteractionsIntraContacts.createElementsIndex(d, t, n));
          }
        });
        return p;
      }
    };
  }
  e.create = r;
})(mw || (mw = {}));
up.IntraContactsBuilder = mw;
var vw;
(function(e) {
  function r() {
    var t = new PCe.InterUnitGraph.Builder();
    return {
      startUnitPair: function(n, a) {
        t.startUnitPair(n.id, a.id);
      },
      finishUnitPair: function() {
        t.finishUnitPair();
      },
      add: function(n, a, i) {
        t.add(n, a, { type: i, flag: fw.InteractionFlag.None });
      },
      getContacts: function(n) {
        return new fw.InteractionsInterContacts(t.getMap(), n);
      }
    };
  }
  e.create = r;
})(vw || (vw = {}));
up.InterContactsBuilder = vw;
var wd = {};
Object.defineProperty(wd, "__esModule", { value: !0 });
wd.addStructureContacts = wd.addUnitContacts = wd.ContactsParams = void 0;
var MCe = Te, fP = Qe(), po = Re, wCe = Je(), ECe = _s, DCe = lG(), ICe = Le, yv = Rr, Og = Ao;
wd.ContactsParams = {
  lineOfSightDistFactor: ICe.ParamDefinition.Numeric(1, { min: 0, max: 3, step: 0.1 })
};
var BCe = 3;
function X$(e, r, t) {
  var n = r.members[r.offsets[r.feature]], a = t.members[t.offsets[t.feature]];
  if (n === a && r.unit === t.unit)
    return !1;
  var i = (0, yv.altLoc)(r.unit, n), o = (0, yv.altLoc)(t.unit, a);
  return !(i && o && i !== o || r.unit.residueIndex[r.unit.elements[n]] === t.unit.residueIndex[t.unit.elements[a]] && r.unit === t.unit || (0, yv.connectedTo)(e, r.unit, n, t.unit, a));
}
function RV(e, r, t, n) {
  var a = (0, yv.altLoc)(e, r), i = (0, yv.altLoc)(t, n);
  return a && i && a !== i;
}
function OV(e, r) {
  for (var t = r.feature, n = r.offsets, a = r.members, i = n[t], o = n[t + 1]; i < o; ++i)
    if (a[i] === e)
      return !0;
  return !1;
}
var Kc = (0, po.Vec3)(), mP = (0, po.Vec3)(), vP = (0, po.Vec3)(), NCe = (0, DCe.StructureLookup3DResultContext)();
function VCe(e, r, t, n) {
  var a = r.feature, i = t.feature, o = r.members[r.offsets[a]], c = t.members[t.offsets[i]];
  Og.Features.position(mP, r), Og.Features.position(vP, t), po.Vec3.scale(Kc, po.Vec3.add(Kc, mP, vP), 0.5);
  var s = n * BCe, u = e.lookup3d.find(Kc[0], Kc[1], Kc[2], s, NCe), l = u.count, f = u.indices, d = u.units, m = u.squaredDistances;
  if (l === 0)
    return !0;
  for (var p = 0; p < l; ++p) {
    var v = f[p], h = d[p];
    if (wCe.Unit.isAtomic(h)) {
      var y = (0, yv.typeSymbol)(h, v);
      if (y !== "H") {
        var C = (0, ECe.VdwRadius)(y);
        if (!(C * C * n * n <= m[p]) && !(RV(h, v, r.unit, o) || RV(h, v, t.unit, c)) && !(r.unit === h && OV(v, r) || t.unit === h && OV(v, t)) && (h.conformation.position(h.elements[v], Kc), !(po.Vec3.squaredDistance(Kc, mP) < 1 || po.Vec3.squaredDistance(Kc, vP) < 1)))
          return !1;
      }
    }
  }
  return !0;
}
function RCe(e, r, t, n, a, i, o) {
  for (var c = 0, s = a; c < s.length; c++) {
    var u = s[c];
    OCe(e, r, t, n, u, i, o);
  }
}
wd.addUnitContacts = RCe;
function OCe(e, r, t, n, a, i, o) {
  for (var c = t.x, s = t.y, u = t.z, l = t.subset(a.requiredFeatures), f = l.lookup3d, d = l.indices, m = Og.Features.Info(e, r, t), p = (0, MCe.__assign)({}, m), v = 0, h = fP.OrderedSet.size(d); v < h; ++v) {
    var y = fP.OrderedSet.getAt(d, v), C = f.find(c[y], s[y], u[y], a.maxDistance), S = C.count, b = C.indices, g = C.squaredDistances;
    if (S !== 0) {
      m.feature = y;
      for (var _ = 0; _ < S; ++_) {
        var A = fP.OrderedSet.getAt(d, b[_]);
        if (!(A <= y)) {
          p.feature = A;
          var M = m.unit.elements[m.members[m.offsets[m.feature]]], P = p.unit.elements[p.members[p.offsets[p.feature]]];
          if (!(o && !o(m.unit, M, p.unit, P)) && X$(e, m, p)) {
            var T = a.getType(e, m, p, g[_]);
            T && n.add(y, A, T);
          }
        }
      }
    }
  }
}
var FCe = (0, po.Mat4)();
function LCe(e, r, t, n, a, i, o, c, s) {
  var u = t.count, l = t.x, f = t.y, d = t.z, m = a.lookup3d, p = po.Mat4.mul(FCe, n.conformation.operator.inverse, r.conformation.operator.matrix), v = !po.Mat4.isIdentity(p), h = (0, po.Vec3)(), y = Math.max.apply(Math, o.map(function(G) {
    return G.maxDistance;
  })), C = m.boundary.sphere, S = C.center, b = C.radius, g = (b + y) * (b + y), _ = c.lineOfSightDistFactor, A = Og.Features.Info(e, r, t), M = Og.Features.Info(e, n, a);
  i.startUnitPair(r, n);
  for (var P = 0; P < u; ++P)
    if (po.Vec3.set(h, l[P], f[P], d[P]), v && po.Vec3.transformMat4(h, h, p), !(po.Vec3.squaredDistance(h, S) > g)) {
      var T = m.find(h[0], h[1], h[2], y), x = T.indices, w = T.count, E = T.squaredDistances;
      if (w !== 0) {
        A.feature = P;
        for (var I = 0; I < w; ++I) {
          var B = x[I];
          if (M.feature = B, !(s && !s(A.unit, A.unit.elements[A.members[A.offsets[P]]], M.unit, M.unit.elements[M.members[M.offsets[B]]]) || !X$(e, A, M)))
            for (var D = E[I], N = 0, O = o; N < O.length; N++) {
              var V = O[N];
              if (D < V.maxDistance * V.maxDistance) {
                var k = V.getType(e, A, M, D);
                if (k && VCe(e, A, M, _)) {
                  i.add(P, B, k);
                  break;
                }
              }
            }
        }
      }
    }
  i.finishUnitPair();
}
wd.addStructureContacts = LCe;
var sp = {};
Object.defineProperty(sp, "__esModule", { value: !0 });
sp.HydrophobicProvider = sp.HydrophobicAtomProvider = void 0;
var kCe = Le, UCe = Ao, og = Rr, zCe = Mo, GCe = {
  distanceMax: kCe.ParamDefinition.Numeric(4, { min: 1, max: 5, step: 0.1 })
};
function qCe(e, r, t) {
  for (var n = r.elements, a = r.model.atomicConformation, i = a.x, o = a.y, c = a.z, s = function(f, d) {
    var m = (0, og.typeSymbol)(r, f), p = !1;
    m === "C" ? (p = !0, (0, og.eachBondedAtom)(e, r, f, function(v, h) {
      var y = (0, og.typeSymbol)(v, h);
      y !== "C" && y !== "H" && (p = !1);
    })) : m === "F" && (p = !0), p && t.add(8, 0, i[n[f]], o[n[f]], c[n[f]], f);
  }, u = 0, l = n.length; u < l; ++u)
    s(u);
}
function HCe(e, r) {
  return e === 8 && r === 8;
}
function jCe(e, r, t, n) {
  var a = r.types[r.feature], i = t.types[t.feature];
  if (HCe(a, i)) {
    var o = r.members[r.offsets[r.feature]], c = t.members[t.offsets[t.feature]];
    if (!((0, og.typeSymbol)(r.unit, o) === "F" && (0, og.typeSymbol)(t.unit, c) === "F"))
      return zCe.InteractionType.Hydrophobic;
  }
}
sp.HydrophobicAtomProvider = UCe.Features.Provider([
  8
  /* HydrophobicAtom */
], qCe);
sp.HydrophobicProvider = {
  name: "hydrophobic",
  params: GCe,
  createTester: function(e) {
    return {
      maxDistance: e.distanceMax,
      requiredFeatures: /* @__PURE__ */ new Set([
        8
        /* HydrophobicAtom */
      ]),
      getType: function(r, t, n, a) {
        return jCe(r, t, n);
      }
    };
  }
};
var KA = {};
Object.defineProperty(KA, "__esModule", { value: !0 });
KA.refineInteractions = void 0;
var pn = Mo, $Ce = Je(), U1 = Ao;
function KCe(e, r) {
  for (var t = r.contacts, n = r.unitsContacts, a = r.unitsFeatures, i = [
    WCe(e, r),
    XCe(e, r),
    YCe(e, r),
    QCe(e, r),
    ZCe(e, r)
  ], o = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), u = 0, l = t.edgeCount; u < l; ++u) {
    var f = t.edges[u], d = e.unitMap.get(f.unitA), m = e.unitMap.get(f.unitB), p = U1.Features.Info(e, d, a.get(f.unitA));
    p.feature = f.indexA;
    var v = U1.Features.Info(e, m, a.get(f.unitB));
    if (v.feature = f.indexB, f.props.type === 5) {
      for (var h = p.types[p.feature], y = h === 5 ? p : v, C = [], S = y.offsets[y.feature], b = y.offsets[y.feature + 1]; S < b; S++)
        C.push(y.members[S]);
      C.length > 1 && c.set(u, C), C.length === 1 && o.add(C[0]);
    }
    if (n.size)
      for (var g = 0, _ = i; g < _.length; g++) {
        var A = _[g];
        A.isApplicable(f.props.type) && A.handleInterContact(u, p, v);
      }
  }
  for (var M = n.keys(); ; ) {
    var P = M.next(), T = P.done, x = P.value;
    if (T)
      break;
    var w = n.get(x), E = a.get(x), I = e.unitMap.get(x);
    if ($Ce.Unit.isAtomic(I)) {
      for (var p = U1.Features.Info(e, I, E), v = U1.Features.Info(e, I, E), B = 0, D = i; B < D.length; B++) {
        var A = D[B];
        A.startUnit(I, w, E);
      }
      for (var u = 0, l = w.edgeCount * 2; u < l; ++u) {
        p.feature = w.a[u], v.feature = w.b[u];
        var N = w.edgeProps.type[u];
        if (N === 5) {
          for (var h = p.types[p.feature], y = h === 5 ? p : v, C = [], S = y.offsets[y.feature], b = y.offsets[y.feature + 1]; S < b; S++)
            C.push(y.members[S]);
          C.length > 1 && s.set(u, { elements: C, value: x }), C.length === 1 && o.add(C[0]);
        }
        for (var O = 0, V = i; O < V.length; O++) {
          var A = V[O];
          A.isApplicable(w.edgeProps.type[u]) && A.handleIntraContact(u, p, v);
        }
      }
    }
  }
  c.forEach(function(k, G) {
    k.filter(function(L) {
      return o.has(L);
    }).length > 0 && (t.edges[G].props.flag = pn.InteractionFlag.Filtered);
  }), s.forEach(function(k, G) {
    var L = k.elements, R = k.value;
    L.filter(function(F) {
      return o.has(F);
    }).length > 0 && (n.get(R).edgeProps.flag[G] = pn.InteractionFlag.Filtered);
  });
}
KA.refineInteractions = KCe;
function WCe(e, r) {
  var t = r.contacts, n = function(u, l, f, d, m) {
    var p = d.get(f) || [1 / 0, -1], v = p[0], h = p[1];
    u < v ? (h !== -1 && m(h), d.set(f, [u, l])) : m(l);
  };
  function a(u, l, f, d, m) {
    var p = l.members[l.offsets[l.feature]], v = f.members[f.offsets[f.feature]], h = l.unit.getResidueIndex(p), y = f.unit.getResidueIndex(v), C = "".concat(p, "|").concat(l.unit.id, "|").concat(y, "|").concat(f.unit.id, "|A"), S = "".concat(v, "|").concat(f.unit.id, "|").concat(h, "|").concat(l.unit.id, "|B"), b = U1.Features.distance(l, f);
    n(b, u, C, d, m), n(b, u, S, d, m);
  }
  var i = /* @__PURE__ */ new Map(), o = function(u) {
    return t.edges[u].props.flag = pn.InteractionFlag.Filtered;
  }, c, s;
  return {
    isApplicable: function(u) {
      return u === pn.InteractionType.Hydrophobic;
    },
    handleInterContact: function(u, l, f) {
      a(u, l, f, i, o);
    },
    startUnit: function(u, l, f) {
      c = /* @__PURE__ */ new Map(), s = function(d) {
        return l.edgeProps.flag[d] = pn.InteractionFlag.Filtered;
      };
    },
    handleIntraContact: function(u, l, f) {
      a(u, l, f, c, s);
    }
  };
}
function XCe(e, r) {
  var t = r.contacts, n = function(a, i) {
    for (var o = a.types[a.feature] === 9 ? i : a, c = o.members[o.offsets[o.feature]], s = r.unitsContacts.get(o.unit.id), u = s.edgeProps.type, l = s.elementsIndex, f = l.offsets, d = l.indices, m = f[c], p = f[c + 1]; m < p; ++m)
      if (u[d[m]] === pn.InteractionType.HydrogenBond)
        return !0;
    for (var v = t.getEdgeIndices(o.feature, o.unit.id), m = 0, p = v.length; m < p; ++m)
      if (t.edges[v[m]].props.type === pn.InteractionType.HydrogenBond)
        return !0;
    return !1;
  };
  return {
    isApplicable: function(a) {
      return a === pn.InteractionType.WeakHydrogenBond;
    },
    handleInterContact: function(a, i, o) {
      n(i, o) && (t.edges[a].props.flag = pn.InteractionFlag.Filtered);
    },
    startUnit: function() {
    },
    handleIntraContact: function(a, i, o) {
      if (n(i, o)) {
        var c = r.unitsContacts.get(i.unit.id).edgeProps.flag;
        c[a] = pn.InteractionFlag.Filtered;
      }
    }
  };
}
function yD(e, r, t, n, a) {
  for (var i = t.offsets, o = t.feature, c = n.offsets, s = n.feature, u = i[o], l = i[o + 1]; u < l; ++u)
    for (var f = t.members[u], d = a.getContactIndicesForElement(f, t.unit), m = 0, p = d.length; m < p; ++m) {
      var v = d[m];
      if (e.includes(a.edges[v].props.type))
        for (var h = c[s], y = c[s + 1]; h < y; ++h) {
          var C = n.members[h];
          if (a.getContactIndicesForElement(C, n.unit).includes(v)) {
            a.edges[r].props.flag = pn.InteractionFlag.Filtered;
            return;
          }
        }
    }
}
function _D(e, r, t, n, a) {
  for (var i = a.edgeProps, o = i.type, c = i.flag, s = a.elementsIndex, u = s.offsets, l = s.indices, f = t.offsets, d = t.feature, m = n.offsets, p = n.feature, v = f[d], h = f[d + 1]; v < h; ++v)
    for (var y = t.members[v], C = u[y], S = u[y + 1]; C < S; ++C) {
      var b = l[C];
      if (e.includes(o[b])) {
        for (var g = m[p], _ = m[p + 1]; g < _; ++g)
          for (var A = n.members[g], M = u[A], P = u[A + 1]; M < P; ++M)
            if (b === l[M]) {
              c[r] = pn.InteractionFlag.Filtered;
              return;
            }
      }
    }
}
function YCe(e, r) {
  var t = r.contacts;
  return {
    isApplicable: function(n) {
      return n === pn.InteractionType.Ionic;
    },
    handleInterContact: function(n, a, i) {
      yD([pn.InteractionType.HydrogenBond, pn.InteractionType.WeakHydrogenBond], n, a, i, t);
    },
    startUnit: function() {
    },
    handleIntraContact: function(n, a, i) {
      _D([pn.InteractionType.HydrogenBond, pn.InteractionType.WeakHydrogenBond], n, a, i, r.unitsContacts.get(a.unit.id));
    }
  };
}
function QCe(e, r) {
  var t = r.contacts;
  return {
    isApplicable: function(n) {
      return n === pn.InteractionType.Hydrophobic || n === pn.InteractionType.CationPi;
    },
    handleInterContact: function(n, a, i) {
      yD([pn.InteractionType.PiStacking], n, a, i, t);
    },
    startUnit: function() {
    },
    handleIntraContact: function(n, a, i) {
      _D([pn.InteractionType.PiStacking], n, a, i, r.unitsContacts.get(a.unit.id));
    }
  };
}
function ZCe(e, r) {
  var t = r.contacts;
  return {
    isApplicable: function(n) {
      return n === pn.InteractionType.Ionic;
    },
    handleInterContact: function(n, a, i) {
      yD([pn.InteractionType.MetalCoordination], n, a, i, t);
    },
    startUnit: function() {
    },
    handleIntraContact: function(n, a, i) {
      _D([pn.InteractionType.MetalCoordination], n, a, i, r.unitsContacts.get(a.unit.id));
    }
  };
}
var pP = {}, hP = {}, gP = {}, FV;
function JCe() {
  return FV || (FV = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.InteractionsIntraUnitVisual = e.InteractionsIntraUnitParams = void 0;
    var r = Te, t = Je(), n = Re, a = _r, i = Qe(), o = Le, c = Dt(), s = Fy(), u = Jd, l = Mr, f = on, d = Oy(), m = Mo, p = nr();
    function v(g, _, A, M, P, T) {
      return (0, r.__awaiter)(this, void 0, void 0, function() {
        var x, w, E, I, B, D, N, O, V, k, G, L, R, F, U, H, q, K, Y, X, Z;
        return (0, r.__generator)(this, function(J) {
          return t.Unit.isAtomic(_) ? (x = A.child, w = x == null ? void 0 : x.unitMap.get(_.id), x && !w ? [2, c.Mesh.createEmpty(T)] : (E = t.StructureElement.Location.create(A, _), I = s.InteractionsProvider.get(A).value, B = I.unitsFeatures.get(_.id), D = I.unitsContacts.get(_.id), N = B.x, O = B.y, V = B.z, k = B.members, G = B.offsets, L = D.edgeCount, R = D.a, F = D.b, U = D.edgeProps.flag, H = P.sizeFactor, L ? (q = {
            linkCount: L * 2,
            position: function($, Q, W) {
              n.Vec3.set($, N[R[W]], O[R[W]], V[R[W]]), n.Vec3.set(Q, N[F[W]], O[F[W]], V[F[W]]);
            },
            style: function($) {
              return 1;
            },
            radius: function($) {
              E.element = _.elements[k[G[R[$]]]];
              var Q = M.size.size(E);
              E.element = _.elements[k[G[F[$]]]];
              var W = M.size.size(E);
              return Math.min(Q, W) * H;
            },
            ignore: function($) {
              if (U[$] === m.InteractionFlag.Filtered)
                return !0;
              if (w)
                for (var Q = R[$], W = G[Q], te = G[Q + 1]; W < te; ++W) {
                  var oe = _.elements[k[G[W]]];
                  if (!i.SortedArray.has(w.elements, oe))
                    return !0;
                }
              return !1;
            }
          }, K = (0, u.createLinkCylinderMesh)(g, q, P, T), Y = K.mesh, X = K.boundingSphere, X ? Y.setBoundingSphere(X) : Y.triangleCount > 0 && (Z = p.Sphere3D.expand((0, p.Sphere3D)(), (w ?? _).boundary.sphere, 1 * H), Y.setBoundingSphere(Z)), [2, Y]) : [2, c.Mesh.createEmpty(T)])) : [2, c.Mesh.createEmpty(T)];
        });
      });
    }
    e.InteractionsIntraUnitParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, l.UnitsMeshParams), u.LinkCylinderParams), { sizeFactor: o.ParamDefinition.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), dashCount: o.ParamDefinition.Numeric(6, { min: 2, max: 10, step: 2 }), dashScale: o.ParamDefinition.Numeric(0.6, { min: 0, max: 2, step: 0.1 }), includeParent: o.ParamDefinition.Boolean(!1) });
    function h(g) {
      return (0, l.UnitsMeshVisual)({
        defaultProps: o.ParamDefinition.getDefaultValues(e.InteractionsIntraUnitParams),
        createGeometry: v,
        createLocationIterator: b,
        getLoci: y,
        eachLocation: S,
        setUpdateState: function(_, A, M, P, T, x, w) {
          _.createGeometry = A.sizeFactor !== M.sizeFactor || A.dashCount !== M.dashCount || A.dashScale !== M.dashScale || A.dashCap !== M.dashCap || A.radialSegments !== M.radialSegments;
          var E = s.InteractionsProvider.get(x.structure).version;
          _.info.interactionsHash !== E && (_.createGeometry = !0, _.updateTransform = !0, _.updateColor = !0, _.info.interactionsHash = E);
        }
      }, g);
    }
    e.InteractionsIntraUnitVisual = h;
    function y(g, _, A) {
      var M = g.objectId, P = g.instanceId, T = g.groupId;
      if (A === M) {
        var x = _.structure, w = _.group, E = x.unitMap.get(w.units[P].id), I = s.InteractionsProvider.get(x).value, B = I.unitsContacts.get(E.id), D = B.a, N = B.b;
        return d.Interactions.Loci(x, I, [
          { unitA: E, indexA: D[T], unitB: E, indexB: N[T] },
          { unitA: E, indexA: N[T], unitB: E, indexB: D[T] }
        ]);
      }
      return a.EmptyLoci;
    }
    var C = /* @__PURE__ */ new Set();
    function S(g, _, A, M) {
      var P = !1;
      if (d.Interactions.isLoci(g)) {
        var T = _.structure, x = _.group;
        if (!t.Structure.areEquivalent(g.data.structure, T))
          return !1;
        var w = s.InteractionsProvider.get(T).value;
        if (g.data.interactions !== w)
          return !1;
        for (var E = x.units[0], I = w.unitsContacts.get(E.id), B = I.edgeCount * 2, D = 0, N = g.elements; D < N.length; D++) {
          var O = N[D];
          if (O.unitA === O.unitB) {
            var V = x.unitIndexMap.get(O.unitA.id);
            if (V !== void 0) {
              var k = I.getDirectedEdgeIndex(O.indexA, O.indexB);
              k !== -1 && A(i.Interval.ofSingleton(V * B + k)) && (P = !0);
            }
          }
        }
      } else if (t.StructureElement.Loci.is(g)) {
        var T = _.structure, x = _.group;
        if (!t.Structure.areEquivalent(g.structure, T))
          return !1;
        var w = s.InteractionsProvider.get(T).value;
        if (!w)
          return !1;
        for (var E = x.units[0], G = w.unitsContacts.get(E.id), L = w.unitsFeatures.get(E.id), R = G.edgeCount * 2, F = G.offset, U = L.elementsIndex, H = U.offsets, q = U.indices, K = L.members, Y = L.offsets, X = function(oe) {
          var z = x.unitIndexMap.get(oe.unit.id);
          if (z === void 0)
            return "continue";
          i.OrderedSet.forEach(oe.indices, function(j) {
            for (var ae = H[j], le = H[j + 1]; ae < le; ++ae)
              for (var ie = q[ae], re = F[ie], ee = F[ie + 1]; re < ee; ++re)
                C.add(re);
          }), C.forEach(function(j) {
            if (M) {
              for (var ae = G.a[j], le = Y[ae], ie = Y[ae + 1]; le < ie; ++le)
                if (!i.OrderedSet.has(oe.indices, K[le]))
                  return;
              for (var re = G.b[j], le = Y[re], ie = Y[re + 1]; le < ie; ++le)
                if (!i.OrderedSet.has(oe.indices, K[le]))
                  return;
            }
            A(i.Interval.ofSingleton(z * R + j)) && (P = !0);
          }), C.clear();
        }, Z = 0, J = g.elements; Z < J.length; Z++) {
          var O = J[Z];
          X(O);
        }
      }
      return P;
    }
    function b(g) {
      var _ = g.structure, A = g.group, M = A.units[0], P = s.InteractionsProvider.get(_).value, T = P.unitsContacts.get(M.id), x = T.edgeCount * 2, w = A.units.length, E = d.Interactions.Location(P, _), I = E.element, B = function(D, N) {
        var O = A.units[N];
        return I.unitA = O, I.indexA = T.a[D], I.unitB = O, I.indexB = T.b[D], E;
      };
      return (0, f.LocationIterator)(x, w, 1, B);
    }
  }(gP)), gP;
}
var yP = {}, LV;
function e4e() {
  return LV || (LV = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.InteractionsInterUnitVisual = e.InteractionsInterUnitParams = void 0;
    var r = Te, t = Le, n = Je(), a = Dt(), i = Re, o = Jd, c = pt, s = _r, u = Qe(), l = Oy(), f = Fy(), d = on, m = Mo, p = ia(), v = nr();
    function h(A, M, P, T, x) {
      if (!M.hasAtomic)
        return a.Mesh.createEmpty(x);
      var w = n.StructureElement.Location.create(M), E = f.InteractionsProvider.get(M).value, I = E.contacts, B = E.unitsFeatures, D = I.edgeCount, N = I.edges, O = T.sizeFactor;
      if (!D)
        return a.Mesh.createEmpty(x);
      var V = M.child, k = {
        linkCount: D,
        position: function(H, q, K) {
          var Y = N[K], X = Y.unitA, Z = Y.indexA, J = Y.unitB, $ = Y.indexB, Q = B.get(X), W = B.get(J), te = M.unitMap.get(X), oe = M.unitMap.get(J);
          i.Vec3.set(H, Q.x[Z], Q.y[Z], Q.z[Z]), i.Vec3.transformMat4(H, H, te.conformation.operator.matrix), i.Vec3.set(q, W.x[$], W.y[$], W.z[$]), i.Vec3.transformMat4(q, q, oe.conformation.operator.matrix);
        },
        style: function(H) {
          return 1;
        },
        radius: function(H) {
          var q = N[H], K = B.get(q.unitA);
          w.unit = M.unitMap.get(q.unitA), w.element = w.unit.elements[K.members[K.offsets[q.indexA]]];
          var Y = P.size.size(w), X = B.get(q.unitB);
          w.unit = M.unitMap.get(q.unitB), w.element = w.unit.elements[X.members[X.offsets[q.indexB]]];
          var Z = P.size.size(w);
          return Math.min(Y, Z) * O;
        },
        ignore: function(H) {
          if (N[H].props.flag === m.InteractionFlag.Filtered)
            return !0;
          if (V) {
            var q = N[H], K = V.unitMap.get(q.unitA);
            if (!K)
              return !0;
            for (var Y = M.unitMap.get(q.unitA), X = B.get(q.unitA), Z = X.offsets, J = X.members, $ = Z[q.indexA], Q = Z[q.indexA + 1]; $ < Q; ++$) {
              var W = Y.elements[J[$]];
              if (!u.SortedArray.has(K.elements, W))
                return !0;
            }
          }
          return !1;
        }
      }, G = (0, o.createLinkCylinderMesh)(A, k, T, x), L = G.mesh, R = G.boundingSphere;
      if (R)
        L.setBoundingSphere(R);
      else if (L.triangleCount > 0) {
        var F = M.child, U = v.Sphere3D.expand((0, v.Sphere3D)(), (F ?? M).boundary.sphere, 1 * O);
        L.setBoundingSphere(U);
      }
      return L;
    }
    e.InteractionsInterUnitParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, c.ComplexMeshParams), o.LinkCylinderParams), { sizeFactor: t.ParamDefinition.Numeric(0.3, { min: 0, max: 10, step: 0.01 }), dashCount: t.ParamDefinition.Numeric(6, { min: 2, max: 10, step: 2 }), dashScale: t.ParamDefinition.Numeric(0.6, { min: 0, max: 2, step: 0.1 }), includeParent: t.ParamDefinition.Boolean(!1) });
    function y(A) {
      return (0, c.ComplexMeshVisual)({
        defaultProps: t.ParamDefinition.getDefaultValues(e.InteractionsInterUnitParams),
        createGeometry: h,
        createLocationIterator: _,
        getLoci: C,
        eachLocation: g,
        setUpdateState: function(M, P, T, x, w, E, I) {
          M.createGeometry = P.sizeFactor !== T.sizeFactor || P.dashCount !== T.dashCount || P.dashScale !== T.dashScale || P.dashCap !== T.dashCap || P.radialSegments !== T.radialSegments;
          var B = f.InteractionsProvider.get(E).version;
          M.info.interactionsHash !== B && (M.createGeometry = !0, M.updateTransform = !0, M.updateColor = !0, M.info.interactionsHash = B);
        }
      }, A);
    }
    e.InteractionsInterUnitVisual = y;
    function C(A, M, P) {
      var T = A.objectId, x = A.groupId;
      if (P === T) {
        var w = f.InteractionsProvider.get(M).value, E = w.contacts.edges[x], I = M.unitMap.get(E.unitA), B = M.unitMap.get(E.unitB);
        return l.Interactions.Loci(M, w, [
          { unitA: I, indexA: E.indexA, unitB: B, indexB: E.indexB },
          { unitA: B, indexA: E.indexB, unitB: I, indexB: E.indexA }
        ]);
      }
      return s.EmptyLoci;
    }
    var S = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Set();
    function g(A, M, P, T) {
      var x = !1;
      if (l.Interactions.isLoci(A)) {
        if (!n.Structure.areEquivalent(A.data.structure, M))
          return !1;
        var w = f.InteractionsProvider.get(M).value;
        if (A.data.interactions !== w)
          return !1;
        for (var E = w.contacts, I = 0, B = A.elements; I < B.length; I++) {
          var D = B[I], N = E.getEdgeIndex(D.indexA, D.unitA.id, D.indexB, D.unitB.id);
          N !== -1 && P(u.Interval.ofSingleton(N)) && (x = !0);
        }
      } else if (n.StructureElement.Loci.is(A)) {
        if (!n.Structure.areEquivalent(A.structure, M) || T && A.elements.length === 1)
          return !1;
        var w = f.InteractionsProvider.get(M).value;
        if (!w)
          return !1;
        for (var O = w.contacts, V = w.unitsFeatures, k = 0, G = A.elements; k < G.length; k++) {
          var L = G[k];
          S.set(L.unit.id, L.indices);
        }
        for (var R = function(q) {
          var K = q.unit;
          if (!p.Unit.isAtomic(K))
            return "continue";
          u.OrderedSet.forEach(q.indices, function(Y) {
            for (var X = 0, Z = O.getContactIndicesForElement(Y, K); X < Z.length; X++) {
              var J = Z[X];
              b.add(J);
            }
          });
        }, F = 0, U = A.elements; F < U.length; F++) {
          var L = U[F];
          R(L);
        }
        b.forEach(function(q) {
          if (T) {
            var K = O.edges[q], Y = K.indexA, X = K.unitA, Z = K.indexB, J = K.unitB, $ = S.get(X), Q = S.get(J);
            if (!$ || !Q)
              return;
            for (var W = V.get(X), te = W.offsets, oe = W.members, z = te[Y], j = te[Y + 1]; z < j; ++z)
              if (!u.OrderedSet.has($, oe[z]))
                return;
            for (var ae = V.get(J), le = ae.offsets, ie = ae.members, z = le[Z], j = le[Z + 1]; z < j; ++z)
              if (!u.OrderedSet.has(Q, ie[z]))
                return;
          }
          P(u.Interval.ofSingleton(q)) && (x = !0);
        }), S.clear(), b.clear();
      }
      return x;
    }
    function _(A) {
      var M = f.InteractionsProvider.get(A).value, P = M.contacts, T = P.edgeCount, x = 1, w = l.Interactions.Location(M, A), E = w.element, I = function(B) {
        var D = P.edges[B];
        return E.unitA = A.unitMap.get(D.unitA), E.indexA = D.indexA, E.unitB = A.unitMap.get(D.unitB), E.indexB = D.indexB, w;
      };
      return (0, d.LocationIterator)(T, x, 1, I, !0);
    }
  }(yP)), yP;
}
var kV;
function r4e() {
  return kV || (kV = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.InteractionsRepresentationProvider = e.InteractionRepresentation = e.getInteractionParams = e.InteractionsParams = void 0;
    var r = Te, t = Le, n = Wt, a = Ss(), i = JCe(), o = Fy(), c = e4e(), s = qt, u = {
      "intra-unit": function(d, m) {
        return (0, a.UnitsRepresentation)("Intra-unit interactions cylinder", d, m, i.InteractionsIntraUnitVisual);
      },
      "inter-unit": function(d, m) {
        return (0, a.ComplexRepresentation)("Inter-unit interactions cylinder", d, m, c.InteractionsInterUnitVisual);
      }
    };
    e.InteractionsParams = (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, i.InteractionsIntraUnitParams), c.InteractionsInterUnitParams), { unitKinds: (0, s.getUnitKindsParam)(["atomic"]), sizeFactor: t.ParamDefinition.Numeric(0.15, { min: 0.01, max: 1, step: 0.01 }), visuals: t.ParamDefinition.MultiSelect(["intra-unit", "inter-unit"], t.ParamDefinition.objectToOptions(u)) });
    function l(d, m) {
      return t.ParamDefinition.clone(e.InteractionsParams);
    }
    e.getInteractionParams = l;
    function f(d, m) {
      return n.Representation.createMulti("Interactions", d, m, a.StructureRepresentationStateBuilder, u);
    }
    e.InteractionRepresentation = f, e.InteractionsRepresentationProvider = (0, a.StructureRepresentationProvider)({
      name: "interactions",
      label: "Non-covalent Interactions",
      description: "Displays non-covalent interactions as dashed cylinders.",
      factory: f,
      getParams: l,
      defaultValues: t.ParamDefinition.getDefaultValues(e.InteractionsParams),
      defaultColorTheme: { name: "interaction-type" },
      defaultSizeTheme: { name: "uniform" },
      isApplicable: function(d) {
        return d.elementCount > 0 && o.InteractionsProvider.isApplicable(d);
      },
      ensureCustomProperties: {
        attach: function(d, m) {
          return o.InteractionsProvider.attach(d, m, void 0, !0);
        },
        detach: function(d) {
          return o.InteractionsProvider.ref(d, !1);
        }
      },
      getData: function(d, m) {
        return m.includeParent ? d.asParent() : d;
      },
      mustRecreate: function(d, m) {
        return d.includeParent !== m.includeParent;
      }
    });
  }(hP)), hP;
}
var UV;
function Y$() {
  return UV || (UV = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.InteractionsRepr = e.INTERACTION_TYPE = void 0;
    var r = Te, t = Jt, n = us, a = ty(), i = Fy(), o = r4e(), c = sn(), s = Ao, u = Mo, l = Fp, f = Oy(), d = Ft, m = ds, p = $p();
    Object.defineProperty(e, "INTERACTION_TYPE", { enumerable: !0, get: function() {
      return p.INTERACTION_TYPE;
    } }), e.InteractionsRepr = {
      createOrUpdateInCellItems: function(v, h, y, C, S) {
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var b, g, _, A;
          return (0, r.__generator)(this, function(M) {
            switch (M.label) {
              case 0:
                return b = (0, c.getMergedStructure)(v, h).structure, g = (0, r.__assign)((0, r.__assign)({}, i.InteractionsProvider.defaultParams), { type: y }), C && (g.providers.defaultValue = C), [4, i.InteractionsProvider.attach({ runtime: n.SyncRuntimeContext, assetManager: new a.AssetManager() }, b, g)];
              case 1:
                return M.sent(), h.managers.cell.traverse(function(P, T) {
                  var x;
                  T.type === t.RepresentationType.IntraInteractions && (_ = P.ref, T.state && ((x = h.canvas3d) === null || x === void 0 || x.remove(T.state), T.state.destroy())), T.type === t.RepresentationType.BetweenInteractions && h.managers.cell.remove([{ ref: P.ref }]);
                }), A = o.InteractionsRepresentationProvider.factory(h.managers.representation.ctx, o.InteractionsRepresentationProvider.getParams), A.setTheme({
                  color: h.managers.representation.ctx.colorThemeRegistry.create("interaction-type", {
                    structure: b
                  }),
                  size: h.managers.representation.ctx.sizeThemeRegistry.create("uniform", {
                    structure: b
                  })
                }), [4, A.createOrUpdate({}, b).run()];
              case 2:
                return M.sent(), [2, { representation: A, structure: b, ref: _ }];
            }
          });
        });
      },
      createOrUpdateBetweenCellItems: function(v, h, y, C, S) {
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var b, g, _, A, M, P, I, T, I, T, x, w, E, I, B, D, N, O, V, k, G, L, R;
          return (0, r.__generator)(this, function(F) {
            switch (F.label) {
              case 0:
                for (b = (0, c.getMergedStructure)((0, r.__spreadArray)((0, r.__spreadArray)([], v, !0), h, !0), y), g = b.unitsMap, _ = b.structure, A = (0, r.__assign)({}, i.InteractionsProvider.defaultParams), C && (A.providers.defaultValue = C), M = /* @__PURE__ */ new Set(), P = /* @__PURE__ */ new Set(), I = 0, T = v.length; I < T; I++)
                  g.get(I).forEach(function(U) {
                    return M.add(U);
                  });
                for (I = 0, T = h.length; I < T; I++)
                  g.get(I + v.length).forEach(function(U) {
                    return P.add(U);
                  });
                return [
                  4,
                  i.InteractionsProvider.attach({ runtime: n.SyncRuntimeContext, assetManager: new a.AssetManager() }, _, A)
                  // 过滤非itemsA与itemsB之间的相互作用，只处理contacts不管unitsContacts,因为unitsContacts全不要，通过repr的visuals属性排除所有intra-unit
                ];
              case 1:
                if (F.sent(), !_.state.propertyData.molstar_computed_interactions)
                  return [2, {}];
                for (x = _.state.propertyData.molstar_computed_interactions.data.value, w = x.contacts, E = x.unitsFeatures, I = 0, B = w.edgeCount; I < B; ++I)
                  D = w.edges[I], N = _.unitMap.get(D.unitA), O = _.unitMap.get(D.unitB), V = s.Features.Info(_, N, E.get(D.unitA)), V.feature = D.indexA, k = s.Features.Info(_, O, E.get(D.unitB)), k.feature = D.indexB, M.has(D.unitA) && P.has(D.unitB) || P.has(D.unitA) && M.has(D.unitB) || (w.edges[I].props.flag = u.InteractionFlag.Filtered);
                return L = [], y.managers.cell.traverse(function(U, H) {
                  var q;
                  H.type === t.RepresentationType.BetweenInteractions && (G = U.ref, H.state && ((q = y.canvas3d) === null || q === void 0 || q.remove(H.state), H.state.destroy())), H.type === t.RepresentationType.IntraInteractions && L.push({ ref: U.ref });
                }), [4, y.managers.cell.remove(L)];
              case 2:
                return F.sent(), R = o.InteractionsRepresentationProvider.factory(y.managers.representation.ctx, o.InteractionsRepresentationProvider.getParams), R.setTheme({
                  color: y.managers.representation.ctx.colorThemeRegistry.create("interaction-type", {
                    structure: _
                  }),
                  size: y.managers.representation.ctx.sizeThemeRegistry.create("uniform", {
                    structure: _
                  })
                }), [4, R.createOrUpdate({ visuals: ["inter-unit"] }, _).run()];
              case 3:
                return F.sent(), [2, { representation: R, structure: _, ref: G }];
            }
          });
        });
      },
      createOrUpdateGlobal: function(v, h, y, C, S, b) {
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var g, _, A, M, P, T, F, U, x, w, E, I, B, D, N, O, V, k, G, L, R, F, U, H, q, K, Y, X, Z, J, $;
          return (0, r.__generator)(this, function(Q) {
            switch (Q.label) {
              case 0:
                g = /* @__PURE__ */ new Map(), _ = [], A = 0, M = [], (0, d.ObjectKeys)(f.ContactProviders).forEach(function(W) {
                  var te = (C ?? q.providers.defaultValue)[W], oe = te.name, z = te.params;
                  oe === "on" && M.push(f.ContactProviders[W].createTester(z));
                }), P = /* @__PURE__ */ new Set(), M.forEach(function(W) {
                  return m.SetUtils.add(P, W.requiredFeatures);
                }), T = f.FeatureProviders.filter(function(W) {
                  return m.SetUtils.areIntersecting(P, W.types);
                }), F = 0, U = v.length, Q.label = 1;
              case 1:
                return F < U ? (x = v[F], w = h.cells.get(x.ref), w ? (E = x.elementIds ? (0, c.getStructureByElementIds)((0, c.getStructureByCell)(w), x.elementIds) : (0, c.getStructureByCell)(w), [4, l.ValenceModelProvider.attach({ runtime: n.SyncRuntimeContext, assetManager: new a.AssetManager() }, E)]) : [3, 3]) : [3, 4];
              case 2:
                for (Q.sent(), E.currentPropertyData.molstar_computed_valence_model.data.value.forEach(function(W) {
                  g.set(A, W), A++;
                }), I = 0, B = E.units.length; I < B; I++)
                  D = (0, f.findUnitFeatures)(E, E.units[I], T), _.push(D);
                Q.label = 3;
              case 3:
                return F++, [3, 1];
              case 4:
                for (N = (0, c.getMergedStructure)(v, h), O = N.unitsMap, V = N.structure, k = /* @__PURE__ */ new Map(), G = /* @__PURE__ */ new Map(), L = /* @__PURE__ */ new Map(), R = function(W, te) {
                  L.set(v[W].ref, /* @__PURE__ */ new Set());
                  var oe = O.get(W), z = h.cells.get(v[W].ref);
                  if (z) {
                    var j = (0, c.getStructureByCell)(z).units;
                    oe.forEach(function(ae, le) {
                      k.set(ae, v[W].ref), j && j[le] && G.set("".concat(v[W].ref, "_").concat(j[le].invariantId), ae);
                    });
                  }
                }, F = 0, U = v.length; F < U; F++)
                  R(F, U);
                return Object.assign(V.currentPropertyData, {
                  molstar_computed_valence_model: {
                    props: {
                      assignCharge: "auto",
                      assignH: "auto"
                    },
                    data: {
                      id: 3224,
                      version: 1,
                      value: g
                    }
                  }
                }), H = /* @__PURE__ */ new Set(), b == null || b.map(function(W) {
                  var te = W.ref, oe = W.elementIds, z = h.cells.get(te);
                  if (z) {
                    var j = (0, c.getStructureByCell)(z);
                    j.units.forEach(function(ae) {
                      ae.elements.filter(function(le) {
                        return oe == null ? void 0 : oe.includes(le);
                      }).forEach(function(le) {
                        return H.add("".concat(G.get("".concat(te, "_").concat(ae.invariantId)), "_").concat(le));
                      });
                    });
                  }
                }), q = (0, r.__assign)((0, r.__assign)({}, i.InteractionsProvider.defaultParams), { type: y, featuresList: _, filterKeys: b ? Array.from(H.values()) : void 0 }), C && (q.providers.defaultValue = C), [
                  4,
                  i.InteractionsProvider.attach({ runtime: n.SyncRuntimeContext, assetManager: new a.AssetManager() }, V, q)
                  // 获取有相互作用力的结构
                ];
              case 5:
                return Q.sent(), K = V.state.propertyData.molstar_computed_interactions.data.value, Y = K.contacts, X = K.unitsContacts, Z = K.unitsFeatures, Y.edges.forEach(function(W) {
                  var te = W.indexA, oe = W.indexB, z = W.unitA, j = W.unitB, ae = W.props.flag, le = Z.get(z), ie = le.members, re = le.offsets, ee = Z.get(j), ne = ee.members, se = ee.offsets;
                  if (ae !== u.InteractionFlag.Filtered) {
                    var ce = V.unitMap.get(z).elements[ie[re[te]]], de = V.unitMap.get(j).elements[ne[se[oe]]];
                    L.get(k.get(z)).add(ce), L.get(k.get(j)).add(de);
                  }
                }), Array.from(X.entries()).forEach(function(W) {
                  for (var te = W[0], oe = W[1], z = Z.get(te), j = z.members, ae = z.offsets, le = oe.a, ie = oe.b, re = 0, ee = le.length; re < ee; re++) {
                    var ne = V.unitMap.get(te).elements[j[ae[le[re]]]], se = V.unitMap.get(te).elements[j[ae[ie[re]]]];
                    L.get(k.get(te)).add(ne), L.get(k.get(te)).add(se);
                  }
                }), h.managers.cell.traverse(function(W, te) {
                  var oe;
                  te.type === t.RepresentationType.IntraInteractions && (J = W.ref, te.state && ((oe = h.canvas3d) === null || oe === void 0 || oe.remove(te.state), te.state.destroy()));
                }), $ = o.InteractionsRepresentationProvider.factory(h.managers.representation.ctx, o.InteractionsRepresentationProvider.getParams), $.setTheme({
                  color: h.managers.representation.ctx.colorThemeRegistry.create("interaction-type", {
                    structure: V
                  }),
                  size: h.managers.representation.ctx.sizeThemeRegistry.create("uniform", {
                    structure: V
                  })
                }), [4, $.createOrUpdate({}, V).run()];
              case 6:
                return Q.sent(), [2, { representation: $, structure: V, ref: J, interactionElementIds: Array.from(L.keys()).map(function(W) {
                  return { ref: W, elementIds: Array.from(L.get(W).values()) };
                }).filter(function(W) {
                  return W.elementIds.length;
                }) }];
            }
          });
        });
      }
    };
  }(pP)), pP;
}
var zV;
function Oy() {
  return zV || (zV = 1, function(e) {
    var r;
    Object.defineProperty(e, "__esModule", { value: !0 }), e.findUnitFeatures = e.computeInteractions = e.InteractionsParams = e.InteractionTypeOptions = e.InteractionTypeNames = e.InteractionTypeInfo = e.ContactProviderParams = e.ContactProviders = e.FeatureProviders = e.Interactions = void 0;
    var t = Te, n = Le, a = Je(), i = Ao, o = Mo, c = up, s = Qe(), u = wd, l = Ju, f = Wa, d = qn, m = sp, p = ds, v = QE, h = KA, y = Ja, C = Gd, S = _r, b = X0, g = Ft, _ = Y$(), A = sn(), M;
    (function(I) {
      function B(F, U, H, q, K, Y) {
        return (0, y.DataLocation)("interactions", { structure: U, interactions: F }, {
          unitA: H,
          indexA: q,
          unitB: K,
          indexB: Y
        });
      }
      I.Location = B;
      function D(F) {
        return !!F && F.kind === "data-location" && F.tag === "interactions";
      }
      I.isLocation = D;
      function N(F, U) {
        return F.data.structure === U.data.structure && F.data.interactions === U.data.interactions && F.element.indexA === U.element.indexA && F.element.indexB === U.element.indexB && F.element.unitA === U.element.unitA && F.element.unitB === U.element.unitB;
      }
      I.areLocationsEqual = N;
      function O(F, U) {
        var H = U.unitA, q = U.indexA, K = U.unitB, Y = U.indexB, X = F.contacts, Z = F.unitsContacts;
        if (H === K) {
          var J = Z.get(H.id), $ = J.getDirectedEdgeIndex(q, Y);
          return (0, o.interactionTypeLabel)(J.edgeProps.type[$]);
        } else {
          var $ = X.getEdgeIndex(q, H.id, Y, K.id);
          return (0, o.interactionTypeLabel)(X.edges[$].props.type);
        }
      }
      function V(F) {
        return O(F.data.interactions, F.element);
      }
      I.locationLabel = V;
      function k(F, U, H) {
        return (0, S.DataLoci)("interactions", { structure: F, interactions: U }, H, function(q) {
          return L(U, H, q);
        }, function() {
          return R(F, U, H);
        });
      }
      I.Loci = k;
      function G(F) {
        return !!F && F.kind === "data-loci" && F.tag === "interactions";
      }
      I.isLoci = G;
      function L(F, U, H) {
        var q = F.unitsFeatures;
        return C.CentroidHelper.fromPairProvider(U.length, function(K, Y, X) {
          var Z = U[K];
          i.Features.setPosition(Y, Z.unitA, Z.indexA, q.get(Z.unitA.id)), i.Features.setPosition(X, Z.unitB, Z.indexB, q.get(Z.unitB.id));
        }, H);
      }
      I.getBoundingSphere = L;
      function R(F, U, H) {
        var q = H[0];
        if (q === void 0)
          return "";
        var K = q.unitA, Y = q.indexA, X = q.unitB, Z = q.indexB, J = U.unitsFeatures, $ = J.get(K.id), Q = $.members, W = $.offsets, te = J.get(X.id), oe = te.members, z = te.offsets, j = { granularity: "element" };
        return (W[Y + 1] - W[Y] > 1 || z[Z + 1] - z[Z] > 1) && (j.granularity = "residue"), [
          O(U, q),
          (0, b.bondLabel)(a.Bond.Location(F, K, Q[W[Y]], F, X, oe[z[Z]]), j)
        ].join("</br>");
      }
      I.getLabel = R;
    })(M || (M = {})), e.Interactions = M, e.FeatureProviders = [
      f.HydrogenDonorProvider,
      f.WeakHydrogenDonorProvider,
      f.HydrogenAcceptorProvider,
      d.NegativChargeProvider,
      d.PositiveChargeProvider,
      d.AromaticRingProvider,
      l.HalogenDonorProvider,
      l.HalogenAcceptorProvider,
      m.HydrophobicAtomProvider,
      v.MetalProvider,
      v.MetalBindingProvider
    ], e.ContactProviders = {
      ionic: d.IonicProvider,
      "pi-stacking": d.PiStackingProvider,
      "cation-pi": d.CationPiProvider,
      "halogen-bonds": l.HalogenBondsProvider,
      "hydrogen-bonds": f.HydrogenBondsProvider,
      "weak-hydrogen-bonds": f.WeakHydrogenBondsProvider,
      hydrophobic: m.HydrophobicProvider,
      "metal-coordination": v.MetalCoordinationProvider
    };
    function P(I) {
      I === void 0 && (I = []);
      var B = /* @__PURE__ */ Object.create(null);
      return Object.keys(e.ContactProviders).forEach(function(D) {
        B[D] = n.ParamDefinition.MappedStatic(I.includes(D) ? "on" : "off", {
          on: n.ParamDefinition.Group(e.ContactProviders[D].params),
          off: n.ParamDefinition.Group({})
        }, { cycle: !0 });
      }), B;
    }
    e.ContactProviderParams = P([
      "ionic",
      "cation-pi",
      "pi-stacking",
      "hydrogen-bonds",
      "halogen-bonds",
      // 'hydrophobic',
      "metal-coordination",
      "weak-hydrogen-bonds"
    ]), e.InteractionTypeInfo = (r = {}, r[_.INTERACTION_TYPE.LigandReceptor] = {}, r[_.INTERACTION_TYPE.IntraLigand] = {}, r[_.INTERACTION_TYPE.IntraReceptor] = {}, r[_.INTERACTION_TYPE.All] = {}, r), e.InteractionTypeNames = Object.keys(e.InteractionTypeInfo), e.InteractionTypeOptions = n.ParamDefinition.arrayToOptions(e.InteractionTypeNames), e.InteractionsParams = {
      providers: n.ParamDefinition.Group(e.ContactProviderParams, { isFlat: !0 }),
      contacts: n.ParamDefinition.Group(u.ContactsParams, { label: "Advanced Options" }),
      type: n.ParamDefinition.Select(_.INTERACTION_TYPE.LigandReceptor, e.InteractionTypeOptions, { isEssential: !0, description: "Visual/rendering quality of the representation." }),
      featuresList: n.ParamDefinition.Value([], { isHidden: !0 }),
      filterKeys: n.ParamDefinition.Value(void 0, { isHidden: !0 })
    };
    function T(I, B, D) {
      return (0, t.__awaiter)(this, void 0, void 0, function() {
        var N, O, V, k, G, L, R, F, U, H, q, K, Y, X, Z, J, $, Q, W, te, oe, z, j, ae, le;
        return (0, t.__generator)(this, function(ie) {
          switch (ie.label) {
            case 0:
              N = (0, t.__assign)((0, t.__assign)({}, n.ParamDefinition.getDefaultValues(e.InteractionsParams)), D), O = N.type, V = N.featuresList, k = N.filterKeys, G = new Set(k), L = (0, A.getHierarchy)(B).data, R = L.ligand, F = L.other, U = /* @__PURE__ */ new Set(), H = /* @__PURE__ */ new Set(), Object.keys(R).forEach(function(re) {
                Object.keys(R[re]).forEach(function(ee) {
                  R[re][ee].forEach(function(ne) {
                    U.add(ne.unitId), H.add("".concat(ne.unitId, "_").concat(ne.elementId));
                  });
                });
              }), Object.keys(F).forEach(function(re) {
                Object.keys(F[re]).forEach(function(ee) {
                  F[re][ee].forEach(function(ne) {
                    U.add(ne.unitId), H.add("".concat(ne.unitId, "_").concat(ne.elementId));
                  });
                });
              }), q = [], (0, g.ObjectKeys)(e.ContactProviders).forEach(function(re) {
                var ee = N.providers[re], ne = ee.name, se = ee.params;
                ne === "on" && q.push(e.ContactProviders[re].createTester(O === _.INTERACTION_TYPE.All && ["hydrogen-bonds", "weak-hydrogen-bonds"].includes(re) ? (0, t.__assign)((0, t.__assign)({}, se), { water: !0 }) : se));
              }), K = /* @__PURE__ */ new Set(), q.forEach(function(re) {
                return p.SetUtils.add(K, re.requiredFeatures);
              }), Y = e.FeatureProviders.filter(function(re) {
                return p.SetUtils.areIntersecting(K, re.types);
              }), X = s.IntMap.Mutable(), Z = s.IntMap.Mutable(), J = 0, $ = B.unitSymmetryGroups.length, ie.label = 1;
            case 1:
              return J < $ ? (Q = B.unitSymmetryGroups[J], I.runtime.shouldUpdate ? [4, I.runtime.update({
                message: "computing interactions",
                current: J,
                max: $
              })] : [3, 3]) : [3, 5];
            case 2:
              ie.sent(), ie.label = 3;
            case 3:
              for (W = V && V[J] ? V[J] : x(B, Q.units[0], Y), te = w(B, Q.units[0], W, q, N.contacts, function(re, ee, ne, se) {
                return k && !(G.has("".concat(re.invariantId, "_").concat(ee)) && G.has("".concat(ne.invariantId, "_").concat(se))) || O === _.INTERACTION_TYPE.IntraReceptor ? !1 : O === _.INTERACTION_TYPE.All ? !0 : ["".concat(re.invariantId, "_").concat(ee), "".concat(ne.invariantId, "_").concat(se)].filter(function(ce) {
                  return H.has(ce);
                }).length === (O === _.INTERACTION_TYPE.LigandReceptor ? 1 : 2);
              }), oe = 0, z = Q.units.length; oe < z; ++oe)
                j = Q.units[oe], X.set(j.id, W), Z.set(j.id, te);
              ie.label = 4;
            case 4:
              return ++J, [3, 1];
            case 5:
              return ae = E(B, X, q, N.contacts, {
                unitFilter: function(re, ee) {
                  return O === _.INTERACTION_TYPE.LigandReceptor ? [re.invariantId, ee.invariantId].filter(function(ne) {
                    return U.has(ne);
                  }).length >= 1 : O === _.INTERACTION_TYPE.IntraLigand ? [re.invariantId, ee.invariantId].filter(function(ne) {
                    return U.has(ne);
                  }).length === 2 : !0;
                },
                elementIdFilter: function(re, ee, ne, se) {
                  return k && !(G.has("".concat(re.invariantId, "_").concat(ee)) && G.has("".concat(ne.invariantId, "_").concat(se))) ? !1 : O === _.INTERACTION_TYPE.All ? !0 : ["".concat(re.invariantId, "_").concat(ee), "".concat(ne.invariantId, "_").concat(se)].filter(function(ce) {
                    return H.has(ce);
                  }).length === (O === _.INTERACTION_TYPE.LigandReceptor ? 1 : O === _.INTERACTION_TYPE.IntraReceptor ? 0 : 2);
                }
              }), le = { unitsFeatures: X, unitsContacts: Z, contacts: ae }, (0, h.refineInteractions)(B, le), [2, le];
          }
        });
      });
    }
    e.computeInteractions = T;
    function x(I, B, D) {
      var N = B.elements.length, O = i.FeaturesBuilder.create(N, N / 2);
      if (a.Unit.isAtomic(B))
        for (var V = 0, k = D; V < k.length; V++) {
          var G = k[V];
          G.add(I, B, O);
        }
      return O.getFeatures(N);
    }
    e.findUnitFeatures = x;
    function w(I, B, D, N, O, V) {
      var k = c.IntraContactsBuilder.create(D, B.elements.length);
      return a.Unit.isAtomic(B) && (0, u.addUnitContacts)(I, B, D, k, N, O, V), k.getContacts();
    }
    function E(I, B, D, N, O) {
      var V = c.InterContactsBuilder.create();
      return a.Structure.eachUnitPair(I, function(k, G) {
        var L = B.get(k.id), R = B.get(G.id);
        (0, u.addStructureContacts)(I, k, L, G, R, V, D, N, O == null ? void 0 : O.elementIdFilter);
      }, {
        maxRadius: Math.max.apply(Math, D.map(function(k) {
          return k.maxDistance;
        })),
        validUnit: function(k) {
          return a.Unit.isAtomic(k);
        },
        validUnitPair: function(k, G) {
          var L = a.Structure.validUnitPair(I, k, G);
          return L && (O != null && O.unitFilter ? O.unitFilter(k, G) : !0);
        }
      }), V.getContacts(B);
    }
  }(dP)), dP;
}
var GV;
function Fy() {
  return GV || (GV = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.InteractionsProvider = e.InteractionsParams = void 0;
    var r = Te, t = Le, n = Oy(), a = N0, i = In;
    e.InteractionsParams = (0, r.__assign)({}, n.InteractionsParams), e.InteractionsProvider = a.CustomStructureProperty.createProvider({
      label: "Interactions",
      descriptor: (0, i.CustomPropertyDescriptor)({
        name: "molstar_computed_interactions"
        // TODO `cifExport` and `symbol`
      }),
      type: "local",
      defaultParams: e.InteractionsParams,
      getParams: function(o) {
        return e.InteractionsParams;
      },
      isApplicable: function(o) {
        return !o.isCoarseGrained;
      },
      obtain: function(o, c, s) {
        return (0, r.__awaiter)(void 0, void 0, void 0, function() {
          var u, l;
          return (0, r.__generator)(this, function(f) {
            switch (f.label) {
              case 0:
                return u = (0, r.__assign)((0, r.__assign)({}, t.ParamDefinition.getDefaultValues(e.InteractionsParams)), s), l = {}, [4, (0, n.computeInteractions)(o, c, u)];
              case 1:
                return [2, (l.value = f.sent(), l)];
            }
          });
        });
      }
    });
  }(cP)), cP;
}
var qV;
function t4e() {
  return qV || (qV = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.InteractionTypeColorThemeProvider = e.InteractionTypeColorTheme = e.getInteractionTypeColorThemeParams = e.InteractionTypeColorThemeParams = void 0;
    var r = Tr(), t = Le, n = Fy(), a = Mo, i = ti, o = Oy(), c = wr(), s = (0, r.Color)(13421772), u = "Assigns colors according the interaction type of a link.", l = (0, r.ColorMap)({
      HydrogenBond: 16751667,
      Hydrophobic: 8421504,
      HalogenBond: 6154474,
      Ionic: 15820019,
      MetalCoordination: 11646163,
      CationPi: 3392621,
      PiStacking: 4436985,
      WeakHydrogenBond: 16771231
    }), f = [
      ["Hydrogen Bond", l.HydrogenBond],
      ["Hydrophobic", l.Hydrophobic],
      ["Halogen Bond", l.HalogenBond],
      ["Ionic", l.Ionic],
      ["Metal Coordination", l.MetalCoordination],
      ["Cation Pi", l.CationPi],
      ["Pi Stacking", l.PiStacking],
      ["Weak HydrogenBond", l.WeakHydrogenBond]
    ];
    function d(v) {
      switch (v) {
        case a.InteractionType.HydrogenBond:
          return l.HydrogenBond;
        case a.InteractionType.Hydrophobic:
          return l.Hydrophobic;
        case a.InteractionType.HalogenBond:
          return l.HalogenBond;
        case a.InteractionType.Ionic:
          return l.Ionic;
        case a.InteractionType.MetalCoordination:
          return l.MetalCoordination;
        case a.InteractionType.CationPi:
          return l.CationPi;
        case a.InteractionType.PiStacking:
          return l.PiStacking;
        case a.InteractionType.WeakHydrogenBond:
          return l.WeakHydrogenBond;
        case a.InteractionType.Unknown:
          return s;
      }
    }
    e.InteractionTypeColorThemeParams = {};
    function m(v) {
      return e.InteractionTypeColorThemeParams;
    }
    e.getInteractionTypeColorThemeParams = m;
    function p(v, h) {
      var y, C = v.structure ? n.InteractionsProvider.get(v.structure) : void 0, S = C ? (0, c.hash2)(C.id, C.version) : -1;
      return C && C.value ? y = function(b) {
        if (o.Interactions.isLocation(b)) {
          var g = b.data.interactions, _ = g.unitsContacts, A = g.contacts, M = b.element, P = M.unitA, T = M.unitB, x = M.indexA, w = M.indexB;
          if (P === T) {
            var E = _.get(P.id), I = E.getDirectedEdgeIndex(x, w);
            return d(E.edgeProps.type[I]);
          } else {
            var I = A.getEdgeIndex(x, P.id, w, T.id);
            return d(A.edges[I].props.type);
          }
        }
        return s;
      } : y = function() {
        return s;
      }, {
        factory: p,
        granularity: "group",
        color: y,
        props: h,
        contextHash: S,
        description: u,
        legend: (0, i.TableLegend)(f)
      };
    }
    e.InteractionTypeColorTheme = p, e.InteractionTypeColorThemeProvider = {
      name: "interaction-type",
      label: "Interaction Type",
      category: "Miscellaneous",
      factory: p,
      getParams: m,
      defaultValues: t.ParamDefinition.getDefaultValues(e.InteractionTypeColorThemeParams),
      isApplicable: function(v) {
        return !!v.structure;
      },
      ensureCustomProperties: {
        attach: function(v, h) {
          return h.structure ? n.InteractionsProvider.attach(v, h.structure, void 0, !0) : Promise.resolve();
        },
        detach: function(v) {
          return v.structure && n.InteractionsProvider.ref(v.structure, !1);
        }
      }
    };
  }(lP)), lP;
}
var _P = {}, HV;
function Q$() {
  return HV || (HV = 1, function(e) {
    var r, t, n;
    Object.defineProperty(e, "__esModule", { value: !0 }), e.RepresentationTheme = e.DefaultLigandColorTheme = e.initialTheme = void 0;
    var a = Te, i = Jt, o = gn(), c = AE(), s = sn(), u = eu(), l = $p(), f = Tr();
    e.initialTheme = {
      color: (r = {}, r[i.ThemeC.ATOM] = {
        name: "element-symbol",
        props: {
          carbonColor: {
            name: "uniform",
            params: {
              value: (0, f.Color)(14474728)
              // value: Color(0x48e533),
            }
          }
        }
      }, r[i.ThemeC.RIBBON] = { name: "uniform", props: { value: (0, f.Color)(14474728) } }, r[i.ThemeC.SURFACE] = { name: "uniform" }, r),
      size: (t = {}, t[i.RepresentationType.BallAndStick] = { name: "physical" }, t[i.RepresentationType.Stick] = { name: "uniform" }, t[i.RepresentationType.Line] = { name: "physical" }, t[i.RepresentationType.CPK] = { name: "physical" }, t[i.RepresentationType.Ribbon] = { name: "uniform" }, t[i.RepresentationType.Surface] = { name: "physical" }, t),
      transparency: (n = {}, n[i.ThemeC.ATOM] = 0, n[i.ThemeC.RIBBON] = 0, n[i.ThemeC.SURFACE] = 0, n)
    }, e.DefaultLigandColorTheme = {
      name: "element-symbol",
      props: {
        carbonColor: {
          name: "uniform",
          params: {
            value: (0, f.Color)(4777267)
          }
        }
      }
    };
    var d = (
      /** @class */
      function() {
        function m(p, v) {
          this.plugin = p, this.defaultTheme = (0, a.__assign)((0, a.__assign)({}, e.initialTheme), v);
        }
        return m.prototype.createColorTheme = function(p, v, h) {
          var y = this, C, S, b, g, _;
          return p.name === "multi-theme" ? (C = this.ctx) === null || C === void 0 ? void 0 : C.colorThemeRegistry.create("multi-theme", { structure: v }, {
            themes: (g = !((b = (S = p.props) === null || S === void 0 ? void 0 : S.themes) === null || b === void 0) && b.length ? p.props.themes : [this.defaultTheme.color[h]]) === null || g === void 0 ? void 0 : g.map(function(A) {
              return {
                colorTheme: y.createColorTheme(A, A.elementIds ? (0, s.getStructureByElementIds)(v, A.elementIds) : v, h),
                bundle: c.Bundle.fromLoci((0, s.getLoci)(v, A.elementIds))
              };
            })
          }) : (_ = this.ctx) === null || _ === void 0 ? void 0 : _.colorThemeRegistry.create(p.name, { structure: p.elementIds ? (0, s.getStructureByElementIds)(v, p.elementIds) : v }, p.props);
        }, m.prototype.createTheme = function(p, v, h) {
          var y = Object.keys(i.ReprCBasedTheme).find(function(b) {
            return i.ReprCBasedTheme[b].includes(p);
          }), C = h != null && h.color ? h == null ? void 0 : h.color : this.defaultTheme.color[y], S = h != null && h.size ? h == null ? void 0 : h.size : this.defaultTheme.size[p];
          return {
            color: this.createColorTheme(C, v, y),
            size: this.ctx.sizeThemeRegistry.create(S.name, {
              structure: v
            }, S.props)
          };
        }, m.prototype.createTransparencyLayers = function(p, v) {
          if (!(v != null && v.length))
            return {
              kind: "empty-loci",
              layers: []
            };
          var h = v.map(function(y) {
            var C = y.elementIds, S = y.value;
            return {
              loci: (0, s.getLoci)(p, C),
              value: S !== void 0 ? 1 - S : 0
            };
          });
          return { kind: "element-loci", layers: h };
        }, m.prototype.setColorTheme = function(p, v, h) {
          var y = this;
          p.forEach(function(C) {
            var S, b, g, _, A = C.ref, M = C.elementIds, P = y.plugin.cells.get(A);
            if (!(P != null && P.model.structure) && (P != null && P.representations.has(i.RepresentationType.Surface))) {
              if (h !== i.ThemeC.SURFACE)
                return;
              var T = u.Loci.toStructure(
                // Repr Cache Compatible
                (0, s.transformLociToElementLoci)(P.representations.get(i.RepresentationType.Surface).state.getLoci())
              ), x = (0, s.getElementsFromStructure)(T);
              P.theme.color = (S = {
                Atom: [],
                Ribbon: []
              }, S[i.ThemeC.SURFACE] = [
                (0, a.__assign)({ elementIds: x }, v)
              ], S), l.OtherRepresentation[i.RepresentationType.Surface].update((g = P == null ? void 0 : P.representations.get(i.RepresentationType.Surface)) === null || g === void 0 ? void 0 : g.state, T, y.ctx, y.createTheme(i.RepresentationType.Surface, T, {
                color: v
              }));
              return;
            }
            var w = (0, a.__spreadArray)([], M ?? [], !0);
            M || w.push.apply(w, (0, s.getElementIdsByLoci)(o.Structure.toStructureElementLoci((0, s.getStructureByCell)(P))));
            var E = new Set(w);
            P && (P.theme.color ? (!((_ = P.theme.color[h]) === null || _ === void 0) && _.length && (P.theme.color[h].forEach(function(I, B) {
              P.theme.color[h][B].elementIds = P.theme.color[h][B].elementIds.filter(function(D) {
                return !E.has(D);
              });
            }), P.theme.color[h] = P.theme.color[h].filter(function(I) {
              var B = I.elementIds;
              return B == null ? void 0 : B.length;
            })), P.theme.color[h].push((0, a.__assign)({ elementIds: Array.from(E.values()) }, v))) : P.theme.color = (b = {
              Atom: [],
              Ribbon: [],
              Surface: []
            }, b[h] = [(0, a.__assign)({ elementIds: Array.from(E.values()) }, v)], b), i.ReprCBasedTheme[h].forEach(function(I) {
              var B, D = P.representations.get(I);
              if (D) {
                var N = (0, s.getStructureFromRepresentation)(D.state);
                l.MolecularRepresentation[I].update(
                  // Repr Cache Compatible
                  D.state,
                  N,
                  y.ctx,
                  {
                    color: y.ctx.colorThemeRegistry.create("multi-theme", { structure: N }, {
                      themes: (B = P.theme.color[h]) === null || B === void 0 ? void 0 : B.map(function(O) {
                        return {
                          colorTheme: y.createColorTheme(O, N, h),
                          bundle: c.Bundle.fromLoci((0, s.getLoci)(N, O.elementIds))
                        };
                      })
                    }),
                    // Repr Cache Compatible
                    size: D.state.theme.size
                  }
                );
              }
            }));
          }), this.plugin.managers.snapshot.event.changed.next({
            from: "repr: setColorTheme"
          });
        }, m.prototype.setTransparency = function(p, v, h) {
          var y = this, C = /* @__PURE__ */ new Set();
          p.forEach(function(b) {
            var g, _, A, M, P = b.ref, T = b.elementIds, x = y.plugin.cells.get(P);
            if (!(x != null && x.model.structure) && (x != null && x.representations.has(i.RepresentationType.Surface))) {
              if (h !== i.ThemeC.SURFACE)
                return;
              var w = u.Loci.toStructure((0, s.transformLociToElementLoci)(x.representations.get(i.RepresentationType.Surface).state.getLoci())), E = (0, s.getElementsFromStructure)(w);
              x.theme.transparency = (g = {}, g[i.ThemeC.SURFACE] = [
                {
                  elementIds: E,
                  value: v
                }
              ], g), (A = x == null ? void 0 : x.representations.get(i.RepresentationType.Surface)) === null || A === void 0 || A.state.setState({
                transparency: y.createTransparencyLayers((0, s.getStructureFromRepresentation)((M = x == null ? void 0 : x.representations.get(i.RepresentationType.Surface)) === null || M === void 0 ? void 0 : M.state), x == null ? void 0 : x.theme.transparency[h])
              });
              return;
            }
            var I = (0, a.__spreadArray)([], T ?? [], !0);
            if (!T && x) {
              var w = (0, s.getStructureByCell)(x);
              w && I.push.apply(I, (0, s.getElementIdsByLoci)(o.Structure.toStructureElementLoci(w)));
            }
            var B = new Set(I);
            if (x)
              if (C.add(P), !x.theme.transparency)
                x.theme.transparency = (_ = {}, _[i.ThemeC.ATOM] = [], _[i.ThemeC.RIBBON] = [], _[i.ThemeC.SURFACE] = [], _[h] = {
                  elementIds: Array.from(B.values()),
                  value: v
                }, _);
              else {
                var D = x.theme.transparency[h];
                D.length && (D.forEach(function(N, O) {
                  N.elementIds, D[O].elementIds = I.filter(function(V) {
                    return !B.has(V);
                  });
                }), x.theme.transparency[h] = D.filter(function(N) {
                  return N.elementIds, I.length;
                })), x.theme.transparency[h].push({
                  elementIds: Array.from(B.values()),
                  value: v
                });
              }
          });
          var S = i.ReprCBasedTheme[h];
          C.forEach(function(b) {
            var g = y.plugin.cells.get(b);
            S.forEach(function(_) {
              var A = g == null ? void 0 : g.representations.get(_);
              if (A) {
                var M = (0, s.getStructureFromRepresentation)(A.state), P = y.createTransparencyLayers(M, g == null ? void 0 : g.theme.transparency[h]);
                A.state.setState({
                  transparency: P
                });
              }
            });
          }), this.plugin.managers.snapshot.event.changed.next({
            from: "repr: setColorTheme"
          });
        }, m.prototype.setDefaultTheme = function(p) {
          var v;
          this.defaultTheme = (0, a.__assign)((0, a.__assign)((0, a.__assign)({}, e.initialTheme), (v = this.defaultTheme) !== null && v !== void 0 ? v : {}), p);
        }, m;
      }()
    );
    e.RepresentationTheme = d;
  }(_P)), _P;
}
var C1 = {}, jV;
function n4e() {
  if (jV) return C1;
  jV = 1, Object.defineProperty(C1, "__esModule", { value: !0 }), C1.RepresentationInteractions = void 0;
  var e = Te, r = Jt, t = Y$(), n = Q$(), a = sn(), i = Ti, o = [
    r.RepresentationType.BallAndStick,
    r.RepresentationType.Line,
    r.RepresentationType.Stick,
    r.RepresentationType.CPK
  ], c = (
    /** @class */
    function(s) {
      (0, e.__extends)(u, s);
      function u(l, f, d) {
        var m = s.call(this, l, f) || this;
        return m.ev = i.RxEventHelper.create(), m.event = {
          interactionParamsUpdated: m.ev(),
          interactionUpdated: m.ev()
        }, m.plugin = l, m.type = t.INTERACTION_TYPE.LigandReceptor, m.interactionParams = (0, e.__assign)((0, e.__assign)({}, d), (0, r.getDefaultInteractionParams)()), m;
      }
      return u.prototype.showInteractionInCellItems = function(l, f, d, m) {
        var p;
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var v, h, y, C, S, b, g = this;
          return (0, e.__generator)(this, function(_) {
            switch (_.label) {
              case 0:
                return v = /* @__PURE__ */ new Map(), m && Array.from(l.map(function(A) {
                  return A.ref;
                })).forEach(function(A) {
                  var M = g.plugin.cells.get(A);
                  if (M) {
                    var P = [];
                    r.ReprCBasedTheme[r.ThemeC.ATOM].forEach(function(T) {
                      M.representations.has(T) && M.representations.get(T).state && P.push.apply(P, (0, a.getElementIdsByLoci)((0, a.transformLociToElementLoci)(M.representations.get(T).state.getLoci())));
                    }), v.set(A, new Set(P));
                  }
                }), h = m ? l.map(function(A) {
                  var M, P, T = A.ref, x = A.elementIds, w = x ? x.filter(function(E) {
                    var I;
                    return (I = v.get(T)) === null || I === void 0 ? void 0 : I.has(E);
                  }) : Array.from((P = (M = v.get(T)) === null || M === void 0 ? void 0 : M.values()) !== null && P !== void 0 ? P : []);
                  return {
                    ref: T,
                    elementIds: w
                  };
                }).filter(function(A) {
                  return A.elementIds.length;
                }) : l, [4, t.InteractionsRepr.createOrUpdateInCellItems(h, this.plugin, f, this.interactionParams, d)];
              case 1:
                return y = _.sent(), C = y.representation, S = y.ref, b = {
                  representations: [
                    {
                      state: C,
                      isHidden: !1,
                      type: r.RepresentationType.IntraInteractions
                    }
                  ],
                  model: { other: null },
                  dependency: {
                    on: l
                  }
                }, (p = this.plugin.canvas3d) === null || p === void 0 || p.add(C), S ? (this.plugin.managers.cell.update(S, b), [2, S]) : [2, this.plugin.managers.cell.create(b)];
            }
          });
        });
      }, u.prototype.showInteractionBetweenCellItems = function(l, f, d, m) {
        var p;
        return m === void 0 && (m = !1), (0, e.__awaiter)(this, void 0, void 0, function() {
          var v, h, y, C, S, b, g, _ = this;
          return (0, e.__generator)(this, function(A) {
            switch (A.label) {
              case 0:
                return v = /* @__PURE__ */ new Map(), m && Array.from((0, e.__spreadArray)((0, e.__spreadArray)([], l, !0), f, !0).map(function(M) {
                  return M.ref;
                })).forEach(function(M) {
                  var P = _.plugin.cells.get(M);
                  if (P) {
                    var T = [];
                    r.ReprCBasedTheme[r.ThemeC.ATOM].forEach(function(x) {
                      P.representations.has(x) && P.representations.get(x).state && T.push.apply(T, (0, a.getElementIdsByLoci)((0, a.transformLociToElementLoci)(P.representations.get(x).state.getLoci())));
                    }), v.set(M, new Set(T));
                  }
                }), h = m ? l.map(function(M) {
                  var P, T, x = M.ref, w = M.elementIds, E = w ? w.filter(function(I) {
                    var B;
                    return (B = v.get(x)) === null || B === void 0 ? void 0 : B.has(I);
                  }) : Array.from((T = (P = v.get(x)) === null || P === void 0 ? void 0 : P.values()) !== null && T !== void 0 ? T : []);
                  return {
                    ref: x,
                    elementIds: E
                  };
                }).filter(function(M) {
                  return M.elementIds.length;
                }) : l, y = m ? f.map(function(M) {
                  var P, T, x = M.ref, w = M.elementIds, E = w ? w.filter(function(I) {
                    var B;
                    return (B = v.get(x)) === null || B === void 0 ? void 0 : B.has(I);
                  }) : Array.from((T = (P = v.get(x)) === null || P === void 0 ? void 0 : P.values()) !== null && T !== void 0 ? T : []);
                  return {
                    ref: x,
                    elementIds: E
                  };
                }).filter(function(M) {
                  return M.elementIds.length;
                }) : f, [4, t.InteractionsRepr.createOrUpdateBetweenCellItems(h, y, this.plugin, this.interactionParams, d)];
              case 1:
                return C = A.sent(), S = C.representation, b = C.ref, S ? (g = {
                  representations: [
                    {
                      state: S,
                      isHidden: !1,
                      type: r.RepresentationType.BetweenInteractions
                    }
                  ],
                  model: { other: { itemsA: h, itemsB: y } },
                  dependency: {
                    on: h.concat(y)
                  }
                }, (p = this.plugin.canvas3d) === null || p === void 0 || p.add(S), b ? (this.plugin.managers.cell.update(b, g), [
                  2
                  /*return*/
                ]) : [2, this.plugin.managers.cell.create(g)]) : [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, u.prototype.setInteractionParams = function(l, f) {
        var d = this, m = new Set(Object.keys(this.interactionParams).filter(function(v) {
          var h;
          return ((h = d.interactionParams[v]) === null || h === void 0 ? void 0 : h.name) === "on";
        }));
        if (this.type === f && l.length === m.size && l.every(function(v) {
          return m.has(v);
        }))
          return !1;
        this.type = f, this.interactionParams = (0, r.getDefaultInteractionParams)(l);
        var p = !1;
        return this.plugin.managers.cell.traverse(function(v, h) {
          h.type === r.RepresentationType.IntraInteractions && (p = !0, d.showGlobalInteraction(void 0, "lightPlugin.managers.representation.interactions.setInteractionParams"));
        }), this.event.interactionParamsUpdated.next({ params: this.interactionParams, type: f }), p;
      }, u.prototype.showGlobalInteraction = function(l, f) {
        var d;
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var m, p, v, h, y, C, S, b, g, _, A, M, P, T, x, w = this;
          return (0, e.__generator)(this, function(E) {
            switch (E.label) {
              case 0:
                return m = /* @__PURE__ */ new Map(), p = (0, a.getGlobalCellItems)(this.plugin), l && Array.from(p.map(function(I) {
                  return I.ref;
                })).forEach(function(I) {
                  var B = w.plugin.cells.get(I);
                  if (B) {
                    var D = [];
                    r.ReprCBasedTheme[r.ThemeC.ATOM].forEach(function(N) {
                      B.representations.has(N) && B.representations.get(N).state && D.push.apply(D, (0, a.getElementIdsByLoci)((0, a.transformLociToElementLoci)(B.representations.get(N).state.getLoci())));
                    }), m.set(I, new Set(D));
                  }
                }), v = l ? p.map(function(I) {
                  var B, D, N = I.ref, O = I.elementIds, V = O ? O.filter(function(k) {
                    var G;
                    return (G = m.get(N)) === null || G === void 0 ? void 0 : G.has(k);
                  }) : Array.from((D = (B = m.get(N)) === null || B === void 0 ? void 0 : B.values()) !== null && D !== void 0 ? D : []);
                  return {
                    ref: N,
                    elementIds: V
                  };
                }).filter(function(I) {
                  return I.elementIds.length;
                }) : void 0, [4, t.InteractionsRepr.createOrUpdateGlobal(p, this.plugin, this.type, this.interactionParams, void 0, v)];
              case 1:
                if (h = E.sent(), y = h.representation, C = h.ref, S = h.interactionElementIds, b = {
                  representations: [
                    {
                      state: y,
                      isHidden: !1,
                      type: r.RepresentationType.IntraInteractions
                    }
                  ],
                  model: {
                    other: {
                      type: this.type
                    }
                  },
                  dependency: {
                    on: p
                  }
                }, (d = this.plugin.canvas3d) === null || d === void 0 || d.add(y), l) return [3, 5];
                g = [], _ = {}, S.forEach(function(I) {
                  var B, D = I.ref, N = I.elementIds, O = w.plugin.cells.get(D);
                  if (O) {
                    _[D] = (B = {}, B[r.RepresentationType.BallAndStick] = /* @__PURE__ */ new Set(), B[r.RepresentationType.Line] = /* @__PURE__ */ new Set(), B[r.RepresentationType.Stick] = /* @__PURE__ */ new Set(), B[r.RepresentationType.CPK] = /* @__PURE__ */ new Set(), B);
                    var V = new Set(N);
                    o.forEach(function(k) {
                      if (!(!O.representations.has(k) || !O.representations.get(k).state)) {
                        var G = (0, a.getElementIdsFromRepresentation)(O.representations.get(k).state);
                        _[D][k] = new Set(G), V.forEach(function(L) {
                          _[D][k].has(L) && V.delete(L);
                        });
                      }
                    }), V.size && g.push({ ref: D, elementIds: Array.from(V.values()) });
                  }
                }), A = (x = {}, x[r.RepresentationType.BallAndStick] = [], x[r.RepresentationType.Line] = [], x[r.RepresentationType.Stick] = [], x[r.RepresentationType.CPK] = [], x), g.forEach(function(I) {
                  var B, D = I.ref, N = I.elementIds, O = (B = {}, B[r.RepresentationType.BallAndStick] = [], B[r.RepresentationType.Line] = [], B[r.RepresentationType.Stick] = [], B[r.RepresentationType.CPK] = [], B), V = /* @__PURE__ */ new Map();
                  if (N != null && N.length) {
                    var k = w.plugin.managers.cell.get(D), G = (0, a.getStructureByCell)(k);
                    if (G) {
                      var L = new Set(N), R = new Set(N.map(function(U) {
                        return (0, a.getGranularityUniqueId)((0, a.getAtomHierarchyByStructure)(G, U), r.Granularity.Residue);
                      })), F = /* @__PURE__ */ new Map();
                      G.units.forEach(function(U) {
                        U.elements.forEach(function(H) {
                          var q = (0, a.getAtomHierarchyByUnit)(U, H), K = (0, a.getGranularityUniqueId)(q, r.Granularity.Residue);
                          R.has(K) && (V.has(K) || V.set(K, /* @__PURE__ */ new Set()), (L.has(H) || q.typeSymbol !== "H" || (0, a.getHydrogenType)(G, H) === r.HydrogenVariant.Polar) && F.set(K, (0, e.__spreadArray)([H], F.has(K) ? F.get(K) : [], !0)), o.some(function(Y) {
                            var X, Z;
                            !((X = _[D][Y]) === null || X === void 0) && X.has(H) && ((Z = V.get(K)) === null || Z === void 0 || Z.add(Y));
                          }));
                        });
                      }), R.forEach(function(U) {
                        var H, q, K = V.get(U);
                        if (!K || K.size === 0) {
                          (H = O[r.RepresentationType.Stick]).push.apply(H, F.get(U));
                          return;
                        }
                        K.size > 0 && (q = O[Array.from(K.values())[0]]).push.apply(q, F.get(U));
                      }), o.forEach(function(U) {
                        O[U].length && A[U].push({ ref: D, elementIds: O[U] });
                      });
                    }
                  }
                }), M = 0, P = o.length, E.label = 2;
              case 2:
                return M < P ? (T = o[M], A[T].length ? [4, this.plugin.managers.representation.setMolecularRepr(A[T], T, !0, !1)] : [3, 4]) : [3, 5];
              case 3:
                E.sent(), E.label = 4;
              case 4:
                return M++, [3, 2];
              case 5:
                return C ? (this.plugin.managers.cell.update(C, b), this.event.interactionUpdated.next({ from: f }), [2, S]) : (this.event.interactionUpdated.next({ from: f }), [4, this.plugin.managers.cell.create(b)]);
              case 6:
                return E.sent(), [2, S];
            }
          });
        });
      }, u;
    }(n.RepresentationTheme)
  );
  return C1.RepresentationInteractions = c, C1;
}
var Ly = {}, ky = {};
Object.defineProperty(ky, "__esModule", { value: !0 });
ky.GroTrajModel = void 0;
var $V = Te, a4e = Py, i4e = g0;
ky.GroTrajModel = {
  parse: function(e) {
    return (0, $V.__awaiter)(this, void 0, void 0, function() {
      var r, t;
      return (0, $V.__generator)(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, (0, a4e.parseGRO)(e).run()];
          case 1:
            if (r = n.sent(), r.isError)
              throw r;
            return [4, (0, i4e.trajectoryFromGRO)(r.result).run()];
          case 2:
            return t = n.sent(), [2, t];
        }
      });
    });
  }
};
var A0 = {};
Object.defineProperty(A0, "__esModule", { value: !0 });
A0.getTrajByPymatgen = A0.DumpTrajModel = void 0;
var av = Te, Z$ = wy, J$ = va, o4e = Nd;
A0.DumpTrajModel = {
  parse: function(e) {
    return (0, av.__awaiter)(this, void 0, void 0, function() {
      var r, t, n;
      return (0, av.__generator)(this, function(a) {
        switch (a.label) {
          case 0:
            return [4, (0, Z$.parseDump)(e).run()];
          case 1:
            if (r = a.sent(), r.isError)
              throw r;
            return t = r.result, [4, (0, J$.trajectoryFromMaterial)(t).run()];
          case 2:
            return n = a.sent(), [2, n];
        }
      });
    });
  }
};
var u4e = function(e, r) {
  return (0, av.__awaiter)(void 0, void 0, void 0, function() {
    var t, n, a, i;
    return (0, av.__generator)(this, function(o) {
      switch (o.label) {
        case 0:
          return [4, (0, Z$.parseDump)(e).run()];
        case 1:
          if (t = o.sent(), t.isError)
            throw t;
          return n = t.result, r && (a = (0, o4e.getMolBondsFromPymatgen)(r[0], n.molecules[0]), n.molecules[0] = (0, av.__assign)((0, av.__assign)({}, n.molecules[0]), { bonds: a })), [4, (0, J$.trajectoryFromMaterial)(n).run()];
        case 2:
          return i = o.sent(), [2, i];
      }
    });
  });
};
A0.getTrajByPymatgen = u4e;
var WA = {};
Object.defineProperty(WA, "__esModule", { value: !0 });
WA.PdbTrajModel = void 0;
var KV = Te, s4e = Ty, l4e = p0;
WA.PdbTrajModel = {
  parse: function(e) {
    return (0, KV.__awaiter)(this, void 0, void 0, function() {
      var r, t;
      return (0, KV.__generator)(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, (0, s4e.parsePDB)(e).run()];
          case 1:
            if (r = n.sent(), r.isError)
              throw r;
            return [4, (0, l4e.trajectoryFromPDB)(r.result).run()];
          case 2:
            return t = n.sent(), [2, t];
        }
      });
    });
  }
};
var XA = {};
Object.defineProperty(XA, "__esModule", { value: !0 });
XA.XyzTrajModel = void 0;
var WV = Te, c4e = y0, d4e = _0;
XA.XyzTrajModel = {
  parse: function(e) {
    return (0, WV.__awaiter)(this, void 0, void 0, function() {
      var r, t;
      return (0, WV.__generator)(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, (0, c4e.parseXyz)(e).run()];
          case 1:
            if (r = n.sent(), r.isError)
              throw r;
            return [4, (0, d4e.trajectoryFromXyz)(r.result).run()];
          case 2:
            return t = n.sent(), [2, t];
        }
      });
    });
  }
};
var YA = {};
Object.defineProperty(YA, "__esModule", { value: !0 });
YA.MaterialTrajModel = void 0;
var XV = Te, f4e = va, m4e = Ey;
YA.MaterialTrajModel = {
  parse: function(e) {
    return (0, XV.__awaiter)(this, void 0, void 0, function() {
      var r, t;
      return (0, XV.__generator)(this, function(n) {
        switch (n.label) {
          case 0:
            return r = (0, m4e.parseMaterialInfo)(e), [4, (0, f4e.trajectoryFromMaterial)(r).run()];
          case 1:
            return t = n.sent(), [2, t];
        }
      });
    });
  }
};
var QA = {};
Object.defineProperty(QA, "__esModule", { value: !0 });
QA.PymatgenTrajModel = void 0;
var YV = Te, v4e = va, p4e = Nd;
QA.PymatgenTrajModel = {
  parse: function(e) {
    return (0, YV.__awaiter)(this, void 0, void 0, function() {
      var r, t;
      return (0, YV.__generator)(this, function(n) {
        switch (n.label) {
          case 0:
            return [4, (0, p4e.parsePymatgen)(e).run()];
          case 1:
            if (r = n.sent(), r.isError)
              throw new Error(r.message);
            return [4, (0, v4e.trajectoryFromMaterial)(r.result).run()];
          case 2:
            return t = n.sent(), [2, t];
        }
      });
    });
  }
};
var Wc;
Object.defineProperty(Ly, "__esModule", { value: !0 });
Ly.TrajectoryFormatProvider = void 0;
var h4e = ky, g4e = A0, km = Jt, y4e = WA, _4e = XA, b4e = YA, S4e = QA;
Ly.TrajectoryFormatProvider = (Wc = {}, Wc[km.Format.Dump] = g4e.DumpTrajModel, Wc[km.Format.Gro] = h4e.GroTrajModel, Wc[km.Format.Pdb] = y4e.PdbTrajModel, Wc[km.Format.Xyz] = _4e.XyzTrajModel, Wc[km.Format.Material] = b4e.MaterialTrajModel, Wc[km.Format.Pymatgen] = S4e.PymatgenTrajModel, Wc);
var QV;
function C4e() {
  if (QV) return S1;
  QV = 1, Object.defineProperty(S1, "__esModule", { value: !0 }), S1.RepresentationManager = void 0;
  var e = Te, r = Np(), t = _y(), n = Jt, a = t4e(), i = qp(), o = gn(), c = $p(), s = sn(), u = eu(), l = gs, f = Qe(), d = Rr, m = Q$(), p = n4e(), v = Tr(), h = _n, y = Ly, C = (
    /** @class */
    function(S) {
      (0, e.__extends)(b, S);
      function b(g, _, A) {
        var M = S.call(this, g, _) || this;
        return M.defaultTheme = (0, e.__assign)((0, e.__assign)({}, m.initialTheme), _), M.plugin = g, M.interactionParams = (0, e.__assign)((0, e.__assign)({}, A), (0, n.getDefaultInteractionParams)()), M.showPolarHydrogenOnly = !0, M.ctx = {
          webgl: void 0,
          colorThemeRegistry: r.ColorTheme.createRegistry(),
          sizeThemeRegistry: t.SizeTheme.createRegistry(),
          props: {
            hideBond: !1
          }
        }, M;
      }
      return Object.defineProperty(b.prototype, "hideBond", {
        get: function() {
          var g, _;
          return (_ = (g = this.ctx) === null || g === void 0 ? void 0 : g.props.hideBond) !== null && _ !== void 0 ? _ : !1;
        },
        set: function(g) {
          this.ctx.props.hideBond !== g && (this.ctx.props.hideBond = g, this.plugin.managers.cell.traverse(function(_, A) {
            var M, P, T, x, w;
            if (n.AtomWithBondReprType.has(A.type)) {
              var E = g ? (T = (P = (M = A.state) === null || M === void 0 ? void 0 : M.props) === null || P === void 0 ? void 0 : P.visuals) === null || T === void 0 ? void 0 : T.filter(function(I) {
                return I !== "intra-bond" && I !== "inter-bond";
              }) : Array.from(new Set((0, e.__spreadArray)((0, e.__spreadArray)([], (w = (x = A.state) === null || x === void 0 ? void 0 : x.props) === null || w === void 0 ? void 0 : w.visuals, !0), ["inter-bond", "intra-bond"], !1)));
              A.state.createOrUpdate({
                visuals: E
              }, (0, s.getStructureFromRepresentation)(A.state)).run();
            }
          }));
        },
        enumerable: !1,
        configurable: !0
      }), b.prototype.createContext = function() {
        this.ctx = {
          webgl: this.plugin.canvas3d.webgl,
          colorThemeRegistry: r.ColorTheme.createRegistry(),
          sizeThemeRegistry: t.SizeTheme.createRegistry(),
          props: {
            hideBond: !1
          }
        }, this.ctx.colorThemeRegistry.add(a.InteractionTypeColorThemeProvider);
      }, b.prototype.createMolecular = function(g) {
        var _, A, M, P, T, x, w, E, I, B, D, N, O, V, k, G, L, R, F, U, H, q, K;
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var Y, X, Z, J, $, Q, W, te, oe, z, j, ae, le, ie, re, ee, ne, se, ce, de, me, he, _e, Se, Pe, De, Ee, Me = this;
          return (0, e.__generator)(this, function(ue) {
            switch (ue.label) {
              case 0:
                Y = g.format, X = g.reprType, Z = g.theme, J = Z === void 0 ? {} : Z, $ = g.elementIds, Q = g.ref, W = g.defaultShown, te = g.updateInteraction, oe = te === void 0 ? !0 : te, z = g.autoConvertToTrajectory, j = z === void 0 ? !1 : z, ue.label = 1;
              case 1:
                return ue.trys.push([1, 12, , 13]), ae = typeof g.data == "string" || g.data instanceof File, ae ? [4, (0, s.readAsString)(g.data)] : [3, 3];
              case 2:
                return ie = ue.sent(), [3, 4];
              case 3:
                ie = g.data, ue.label = 4;
              case 4:
                return le = ie, [4, i.FormatProvider[Y].parse(le)];
              case 5:
                return re = ue.sent(), re.length > 1 && j && y.TrajectoryFormatProvider[Y] ? [4, this.plugin.managers.trajectory.importTrajectory({ data: le, format: Y })] : [3, 7];
              case 6:
                return ee = ue.sent(), [2, ee ? [ee] : []];
              case 7:
                ne = g.data instanceof File ? g.data.name : "", se = W ?? re.length, ce = Object.keys(n.ReprCBasedTheme).find(function(pe) {
                  return n.ReprCBasedTheme[pe].includes(X);
                }), de = [], me = 0, he = function(pe) {
                  var Ae, ye, be, fe, ge, xe, we, Ve, Ne, Oe, ze, ke, je, Xe, Fe, He, Be, Ye, cr, Ar;
                  return (0, e.__generator)(this, function(Lr) {
                    switch (Lr.label) {
                      case 0:
                        return Ae = (0, e.__spreadArray)([], $ ?? [], !0), ye = pe, _e.showPolarHydrogenOnly && n.AtomReprType.has(X) && (Ae = ($ ?? (0, s.getElementsFromStructure)(pe)).filter(function(It) {
                          return !(0, s.isNonPolarHydrogen)(pe, It);
                        }), ye = (0, s.getStructureByElementIds)(pe, Ae)), be = !se, fe = ((_ = (0, s.getTextFromStructure)(pe, Y)) !== null && _ !== void 0 ? _ : ae) ? le : (0, s.getModelByStructure)(pe).sourceData.data, ge = {
                          representations: [
                            {
                              // state: representation,
                              isHidden: be,
                              type: X
                            }
                          ],
                          // model: { structure },
                          model: {},
                          assets: [
                            {
                              format: Y,
                              data: ["sdf", "mol"].includes(Y) && ne && !(fe != null && fe.split(`
`)[0].trim()) ? (0, e.__spreadArray)(["".concat(ne).concat(me > 0 ? "_".concat(me) : "")], fe.split(`
`).slice(1), !0).join(`
`) : fe
                            }
                          ],
                          theme: {
                            color: (je = {}, je[ce] = [
                              (0, e.__assign)({ elementIds: $ ?? (0, s.getElementIdsByLoci)(o.Structure.toStructureElementLoci(pe)) }, (M = (A = J[ce]) === null || A === void 0 ? void 0 : A.color) !== null && M !== void 0 ? M : ce === n.ThemeC.ATOM ? m.DefaultLigandColorTheme : _e.defaultTheme.color[ce])
                            ], je),
                            transparency: (Xe = {}, Xe[n.ThemeC.ATOM] = [], Xe[n.ThemeC.RIBBON] = [], Xe[n.ThemeC.SURFACE] = [], Xe[ce] = !((P = J[ce]) === null || P === void 0) && P.transparency ? [(T = J[ce]) === null || T === void 0 ? void 0 : T.transparency] : [], Xe),
                            size: (Fe = {}, Fe[n.ThemeC.ATOM] = [], Fe[n.ThemeC.RIBBON] = [], Fe[n.ThemeC.SURFACE] = [], Fe[ce] = !((x = J[ce]) === null || x === void 0) && x.size ? [(w = J[ce]) === null || w === void 0 ? void 0 : w.size] : [], Fe)
                          },
                          ref: Q
                        }, me++, be ? [3, 2] : [4, c.MolecularRepresentation[X].create(ye, _e.ctx, _e.createTheme(X, pe, (0, e.__assign)((0, e.__assign)({}, J[ce]), ce === n.ThemeC.ATOM && !(!((E = J[ce]) === null || E === void 0) && E.color) ? { color: m.DefaultLigandColorTheme } : {})))];
                      case 1:
                        return xe = Lr.sent(), !((I = J[ce]) === null || I === void 0) && I.transparency && xe.setState({
                          transparency: _e.createTransparencyLayers(pe, [
                            (B = J[ce]) === null || B === void 0 ? void 0 : B.transparency
                          ])
                        }), se--, (D = _e.plugin.canvas3d) === null || D === void 0 || D.add(xe), Object.assign(ge.representations[0], { state: xe }), [3, 3];
                      case 2:
                        Object.assign(ge.representations[0], {
                          cache: {
                            isHidden: be,
                            type: X,
                            elementIds: Ae
                          }
                        }), Lr.label = 3;
                      case 3:
                        return we = _e.plugin.managers.cell.create(ge), de.push(we), Y === n.Format.Pdb && !($ != null && $.length) ? (Ve = (0, s.getProteinAndOthersElementIdByStructure)(pe), Ne = Ve.polymer, Oe = Ve.other, Oe.length ? be ? [3, 6] : (ze = (0, s.getStructureByElementIds)(pe, Ne), [4, c.MolecularRepresentation[n.RepresentationType.Ribbon].update(ge.representations[0].state, (0, s.getStructureByElementIds)(pe, Ne), _e.ctx, _e.createTheme(n.RepresentationType.Ribbon, ze, J[n.ThemeC.RIBBON]))]) : [3, 7]) : [3, 7];
                      case 4:
                        return Lr.sent(), ke = (0, s.getStructureByElementIds)(pe, Oe), _e.plugin.managers.cell.update(we, {
                          representations: [],
                          model: { structure: pe },
                          theme: {
                            color: (He = {}, He[n.ThemeC.ATOM] = [
                              (0, e.__assign)({ elementIds: Oe ?? (0, s.getElementIdsByLoci)(o.Structure.toStructureElementLoci(pe)) }, (O = (N = J[n.ThemeC.ATOM]) === null || N === void 0 ? void 0 : N.color) !== null && O !== void 0 ? O : {
                                name: "element-symbol",
                                props: {
                                  carbonColor: {
                                    name: "uniform",
                                    params: {
                                      value: (0, v.Color)(4777267)
                                    }
                                  }
                                }
                              })
                            ], He),
                            transparency: (Be = {}, Be[n.ThemeC.ATOM] = !((V = J[n.ThemeC.ATOM]) === null || V === void 0) && V.transparency ? [(k = J[n.ThemeC.ATOM]) === null || k === void 0 ? void 0 : k.transparency] : [], Be),
                            size: (Ye = {}, Ye[n.ThemeC.ATOM] = [], Ye[n.ThemeC.RIBBON] = [], Ye[n.ThemeC.SURFACE] = [], Ye[ce] = !((G = J[n.ThemeC.ATOM]) === null || G === void 0) && G.size ? [(L = J[n.ThemeC.ATOM]) === null || L === void 0 ? void 0 : L.size] : [], Ye)
                          }
                        }), [4, _e.addMolecularRepr(we, {
                          elementIds: Oe,
                          reprType: n.RepresentationType.BallAndStick,
                          isHidden: be,
                          theme: _e.createTheme(n.RepresentationType.BallAndStick, ke, (0, e.__assign)({ color: (0, e.__assign)({ elementIds: Oe }, m.DefaultLigandColorTheme) }, J[n.ThemeC.ATOM])),
                          transparency: !((R = J[n.ThemeC.ATOM]) === null || R === void 0) && R.transparency ? [(F = J[n.ThemeC.ATOM]) === null || F === void 0 ? void 0 : F.transparency] : void 0
                        })];
                      case 5:
                        return Lr.sent(), [3, 7];
                      case 6:
                        _e.plugin.managers.cell.update(we, {
                          representations: [
                            (0, e.__assign)((0, e.__assign)({}, ge.representations[0]), { cache: (0, e.__assign)((0, e.__assign)({}, ge.representations[0].cache), { elementIds: Ne }) }),
                            {
                              // state: representation,
                              isHidden: be,
                              type: n.RepresentationType.BallAndStick,
                              cache: {
                                isHidden: be,
                                type: n.RepresentationType.BallAndStick,
                                elementIds: Oe
                              }
                            }
                          ],
                          model: {},
                          theme: {
                            color: (cr = {}, cr[n.ThemeC.ATOM] = [
                              (0, e.__assign)({ elementIds: Oe ?? (0, s.getElementIdsByLoci)(o.Structure.toStructureElementLoci(pe)) }, (H = (U = J[n.ThemeC.ATOM]) === null || U === void 0 ? void 0 : U.color) !== null && H !== void 0 ? H : {
                                name: "element-symbol",
                                props: {
                                  carbonColor: {
                                    name: "uniform",
                                    params: {
                                      value: (0, v.Color)(4777267)
                                    }
                                  }
                                }
                              })
                            ], cr),
                            transparency: (Ar = {}, Ar[n.ThemeC.ATOM] = !((q = J[n.ThemeC.ATOM]) === null || q === void 0) && q.transparency ? [(K = J[n.ThemeC.ATOM]) === null || K === void 0 ? void 0 : K.transparency] : [], Ar)
                          }
                        }), Lr.label = 7;
                      case 7:
                        return be || _e.plugin.managers.cell.update(we, {
                          model: { structure: pe }
                        }), oe && _e.plugin.managers.cell.traverse(function(It, en) {
                          en.type === n.RepresentationType.IntraInteractions && Me.plugin.managers.representation.showGlobalInteraction(void 0, "lightPlugin.managers.representation.createMolecular");
                        }), _e.plugin.managers.snapshot.event.changed.next({
                          from: "repr: createMolecular"
                        }), [
                          2
                          /*return*/
                        ];
                    }
                  });
                }, _e = this, Se = 0, Pe = re, ue.label = 8;
              case 8:
                return Se < Pe.length ? (De = Pe[Se], [5, he(De)]) : [3, 11];
              case 9:
                ue.sent(), ue.label = 10;
              case 10:
                return Se++, [3, 8];
              case 11:
                return [2, de];
              case 12:
                return Ee = ue.sent(), console.log(Ee), [2, []];
              case 13:
                return [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, b.prototype.updateMolecular = function(g) {
        var _;
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var A, M, P, T, x, w, E, I, B, D, N, O, V, k, G, L, R, F, U, H, q, K, Y = this;
          return (0, e.__generator)(this, function(X) {
            for (A = g.ref, M = g.structure, P = this.plugin.managers.cell.get(A), T = u.Loci.toExpression(o.Structure.toStructureElementLoci(P.model.structure)), x = u.Loci.toExpression(o.Structure.toStructureElementLoci(M)), w = l.MolScriptBuilder.struct.modifier.exceptBy({
              0: x,
              by: T
            }), E = (0, s.getElementsFromStructure)((0, s.getStructureByStructureQuery)((0, s.getStructureQuery)(M, w))), E.length && (I = P.theme.color[n.ThemeC.ATOM], (I == null ? void 0 : I.length) === 1 ? I[0].elementIds ? (q = I[0].elementIds).push.apply(q, E) : I[0].elementIds = (0, e.__spreadArray)([], E, !0) : I == null || I.push((0, e.__assign)({ elementIds: E }, this.defaultTheme.color[n.ThemeC.ATOM])), this.plugin.managers.cell.update(A, {
              representations: [],
              model: {},
              theme: {
                color: (K = {}, K[n.ThemeC.ATOM] = I, K)
              }
            })), B = [
              n.RepresentationType.BallAndStick,
              n.RepresentationType.Stick,
              n.RepresentationType.Line,
              n.RepresentationType.CPK
            ], B.forEach(function(Z) {
              !D && P.representations.has(Z) && (D = Z);
            }), N = function(Z) {
              var J = Z[0], $ = Z[1], Q = Object.keys(n.ReprCBasedTheme).find(function(j) {
                return n.ReprCBasedTheme[j].includes(J);
              }), W = P.theme.color[Q], te = $.state.getLoci(), oe = u.Loci.toExpression(o.Structure.toStructureElementLoci(te.structure));
              (!B.includes(J) || J === D) && (oe = l.MolScriptBuilder.struct.modifier.union([
                l.MolScriptBuilder.struct.combinator.merge([
                  w,
                  oe
                ])
              ]));
              var z = (0, s.getStructureByStructureQuery)((0, s.getStructureQuery)(M, oe));
              c.MolecularRepresentation[J].update(
                // Repr State Cache
                $.state,
                z,
                O.ctx,
                O.createTheme(J, M, {
                  color: { name: "multi-theme", props: { themes: W } },
                  size: P.theme.size && (!((_ = P.theme.size[Q]) === null || _ === void 0) && _.length) ? P.theme.size[Q][0] : O.defaultTheme.size[J]
                })
              ), $.state.setState({
                transparency: O.createTransparencyLayers(z, P == null ? void 0 : P.theme.transparency[Q])
              });
            }, O = this, V = 0, k = Array.from(P.representations); V < k.length; V++)
              G = k[V], N(G);
            for (L = function(Z) {
              var J = R.plugin.cells.get(Z);
              J && J.representations.forEach(function($, Q) {
                Q === n.RepresentationType.IntraInteractions && Y.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.representation.updateMolecular"), Object.keys(c.MeasurementRepresentation).includes(Q) && Y.plugin.managers.representation.updateMeasurement({
                  items: J.dependency.on,
                  ref: Z
                });
              });
            }, R = this, F = 0, U = P.dependency.by; F < U.length; F++)
              H = U[F], L(H);
            return this.plugin.managers.snapshot.event.changed.next({
              from: "repr: updateMolecular"
            }), [2, P];
          });
        });
      }, b.prototype.createMeasurement = function(g) {
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var _, A, M, P, T, x, w, E, I, B, D, N;
          return (0, e.__generator)(this, function(O) {
            switch (O.label) {
              case 0:
                if (_ = g.type, A = g.theme, M = g.items, P = g.ref, T = g.isHidden, !n.MeasurementType.has(_))
                  return console.warn("There is no ".concat(_, " type ")), [2, ""];
                x = [], w = 0, E = M, O.label = 1;
              case 1:
                return w < E.length ? (I = E[w], [4, this.plugin.managers.cell.getStructure(I.ref)]) : [3, 4];
              case 2:
                if (B = O.sent(), !B)
                  return [2, ""];
                x.push((0, s.getLoci)(B, I.elementIds)), O.label = 3;
              case 3:
                return w++, [3, 1];
              case 4:
                return [4, c.MeasurementRepresentation[_].create(x, this.ctx, g.props, A)];
              case 5:
                return D = O.sent(), N = this.plugin.managers.cell.create({
                  representations: [
                    {
                      state: D,
                      isHidden: T ?? !1,
                      type: _
                    }
                  ],
                  model: { loci: x },
                  dependency: {
                    // on: Array.from(new Set(valid.map((item) => item.ref)))
                    on: M
                  },
                  ref: P
                }), this.plugin.managers.snapshot.event.changed.next({
                  from: "repr: createMeasurement"
                }), [2, N];
            }
          });
        });
      }, b.prototype.updateMeasurement = function(g) {
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var _, A, M, P, T, x, w, E, I, B = this;
          return (0, e.__generator)(this, function(D) {
            switch (D.label) {
              case 0:
                return _ = g.items, A = g.ref, M = g.params, P = this.plugin.cells.get(A), T = _.filter(function(N) {
                  return (0, s.getStructureByCell)(B.plugin.cells.get(N.ref));
                }), x = T.map(function(N) {
                  return (0, s.getLoci)((0, s.getStructureByCell)(B.plugin.cells.get(N.ref)), N.elementIds);
                }), P ? (w = Array.from(P.representations)[0], E = w[0], I = w[1], !E || !I ? (console.error("There is no ".concat(E)), [2, !1]) : I.state ? [4, c.MeasurementRepresentation[E].update(I.state, x, M)] : [3, 2]) : (console.warn("There is no ".concat(A)), [2, !1]);
              case 1:
                D.sent(), D.label = 2;
              case 2:
                return this.plugin.managers.cell.update(A, { model: { loci: x } }), [2, !0];
            }
          });
        });
      }, b.prototype.createStaticLabel = function(g) {
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var _, A, M, P, T, x, w, E, I, B, D;
          return (0, e.__generator)(this, function(N) {
            switch (N.label) {
              case 0:
                _ = g.theme, A = g.items, M = g.ref, P = g.isHidden, T = [], x = 0, w = A, N.label = 1;
              case 1:
                return x < w.length ? (E = w[x], [4, this.plugin.managers.cell.getStructure(E.item.ref)]) : [3, 4];
              case 2:
                if (I = N.sent(), !I)
                  return [2, ""];
                T.push({ loci: (0, s.getLoci)(I, E.item.elementIds), label: E.label }), N.label = 3;
              case 3:
                return x++, [3, 1];
              case 4:
                return [4, c.MeasurementRepresentation[n.RepresentationType.Label].create(T, this.ctx, g.props, _)];
              case 5:
                return B = N.sent(), D = this.plugin.managers.cell.create({
                  representations: [
                    {
                      state: B,
                      isHidden: P ?? !1,
                      type: n.RepresentationType.Label
                    }
                  ],
                  model: { loci: T.map(function(O) {
                    return O.loci;
                  }) },
                  dependency: {
                    // on: Array.from(new Set(valid.map((item) => item.ref)))
                    on: A.map(function(O) {
                      return O.item;
                    })
                  },
                  ref: M
                }), this.plugin.managers.snapshot.event.changed.next({
                  from: "repr: createMeasurement"
                }), [2, D];
            }
          });
        });
      }, b.prototype.createOther = function(g) {
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var _, A, M, P, T, x, w, E, I, B, D, N, O, V, k, G;
          return (0, e.__generator)(this, function(L) {
            switch (L.label) {
              case 0:
                return _ = g.type, A = g.theme, M = g.data, P = g.ref, T = g.isHidden, x = T === void 0 ? !1 : T, w = g.serverData, E = g.params, c.OtherRepresentation[_] ? (I = c.OtherRepresentation[_], I.parse ? [4, I.parse(M, this.plugin)] : [3, 2]) : (console.warn("There is no ".concat(_, " type ")), [
                  2
                  /*return*/
                ]);
              case 1:
                return D = L.sent(), [3, 3];
              case 2:
                D = M, L.label = 3;
              case 3:
                return B = D, [4, I.create(B, this.ctx, I.createTheme ? I.createTheme(_ === n.RepresentationType.IsoSurface ? B : M, this.plugin, A) : void 0, E)];
              case 4:
                return N = L.sent(), _ === n.RepresentationType.Surface && (A != null && A.transparency) && N.setState({
                  transparency: this.createTransparencyLayers(B, [
                    A == null ? void 0 : A.transparency
                  ])
                }), O = this.plugin.managers.cell.create({
                  representations: [
                    {
                      state: N,
                      isHidden: x,
                      type: _
                    }
                  ],
                  model: {
                    other: w ? { serverData: w, data: M } : M
                  },
                  // theme目前是molecular repr的统一逻辑，surface由于不跟着structure的变化而变化，所以放到other中，做特殊处理
                  theme: _ === n.RepresentationType.Surface ? {
                    color: (V = {}, V[n.ThemeC.SURFACE] = A != null && A.color ? [A == null ? void 0 : A.color] : [], V),
                    transparency: (k = {}, k[n.ThemeC.SURFACE] = A != null && A.transparency ? [A == null ? void 0 : A.transparency] : [], k),
                    size: (G = {}, G[n.ThemeC.SURFACE] = A != null && A.size ? [A == null ? void 0 : A.size] : [], G)
                  } : void 0,
                  ref: P,
                  dependency: _ === n.RepresentationType.Surface ? {
                    on: [M]
                  } : _ === n.RepresentationType.MappingLine ? { on: M } : void 0
                }), this.plugin.managers.snapshot.event.changed.next({
                  from: "repr: createOther"
                }), [2, O];
            }
          });
        });
      }, b.prototype.updateOther = function(g) {
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var _, A, M, P, T, x;
          return (0, e.__generator)(this, function(w) {
            switch (w.label) {
              case 0:
                return _ = g.data, A = g.ref, M = this.plugin.cells.get(A), M ? (P = Array.from(M.representations)[0], T = P[0], x = P[1], !T || !x ? (console.error("There is no ".concat(T)), [2, !1]) : [4, c.OtherRepresentation[T].update(x.state, _, this.ctx)]) : (console.warn("There is no ".concat(A)), [2, !1]);
              case 1:
                return w.sent(), this.plugin.managers.cell.update(A, { model: { other: _ } }), this.plugin.managers.snapshot.event.changed.next({
                  from: "repr: updateOther"
                }), [2, !0];
            }
          });
        });
      }, b.prototype.addMolecularRepr = function(g, _) {
        var A;
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var M, P, T, x, w, E, I, B, D, N;
          return (0, e.__generator)(this, function(O) {
            switch (O.label) {
              case 0:
                return M = _.elementIds, P = _.reprType, T = _.isHidden, x = _.theme, w = _.transparency, E = this.plugin.managers.cell.get(g), I = (0, s.getStructureByCell)(E), !E || !I ? [
                  2
                  /*return*/
                ] : (B = (0, e.__spreadArray)([], M ?? [], !0), n.AtomReprType.has(P) && this.showPolarHydrogenOnly && (B = (M || (0, s.getElementsFromStructure)(I)).filter(function(V) {
                  return !(0, s.isNonPolarHydrogen)(I, V);
                })), D = (0, s.getStructureByElementIds)(I, B, !0), [4, c.MolecularRepresentation[P].create(D, this.ctx, x)]);
              case 1:
                return N = O.sent(), w && N.setState({
                  transparency: this.createTransparencyLayers(D, w)
                }), T || (A = this.plugin.canvas3d) === null || A === void 0 || A.add(N), E.representations.set(P, {
                  state: N,
                  isHidden: T,
                  type: P
                }), this.plugin.managers.snapshot.event.changed.next({
                  from: "repr: addMolecularRepr"
                }), [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, b.prototype.checkStructuresDisplayed = function(g, _) {
        var A, M = this.plugin.managers.cell.get(g.ref), P = (0, s.getStructureByCell)(M), T = new Set((!_ || n.AtomReprType.has(_)) && this.showPolarHydrogenOnly ? ((A = g.elementIds) !== null && A !== void 0 ? A : []).filter(function(w) {
          return !(0, s.isNonPolarHydrogen)(P, w);
        }) : g.elementIds), x = (_ ? [M.representations.get(_)] : Array.from(M.representations.values())).filter(function(w) {
          return (w == null ? void 0 : w.isHidden) !== !0 && (w == null ? void 0 : w.state);
        });
        return x.forEach(function(w) {
          var E, I, B;
          if (T.size) {
            var D = (0, s.transformLociToElementLoci)(w.state.getLoci());
            !D || !(!((B = (I = (E = D == null ? void 0 : D.elements) === null || E === void 0 ? void 0 : E[0]) === null || I === void 0 ? void 0 : I.unit) === null || B === void 0) && B.elements) || (0, s.getElementIdsByLoci)(D).forEach(function(N) {
              return T.delete(N);
            });
          }
        }), T.size === 0;
      }, b.prototype.setMolecularRepr = function(g, _, A, M, P) {
        var T, x, w, E, I, B, D, N, O, V, k, G, L, R, F, U, H;
        return M === void 0 && (M = !0), P === void 0 && (P = !0), (0, e.__awaiter)(this, void 0, void 0, function() {
          var q, K, Y, X, Z, J, $, Q, W, ae, te, oe, z, j, ae, le, ie, re, ee, ne, se, ce = this;
          return (0, e.__generator)(this, function(de) {
            switch (de.label) {
              case 0:
                if (q = /* @__PURE__ */ new Map(), K = g.filter(function(me) {
                  return (0, s.getStructureByCell)(ce.plugin.managers.cell.get(me.ref));
                }), Y = M ? K.every(
                  function(me) {
                    return ce.checkStructuresDisplayed(me, _);
                  }
                  // {
                  //   const cell = this.plugin.managers.cell.get(item.ref)
                  //   const representation = cell.representations.get(reprType)
                  //   const structure = getStructureByCell(cell)
                  //   return (
                  //     representation &&
                  //     !representation.isHidden &&
                  //     isRepresentationIntersectElementIds(
                  //       representation.state!,
                  //       AtomReprType.has(reprType) && this.showPolarHydrogenOnly ? (item.elementIds ?? []).filter(elementId => !isNonPolarHydrogen(structure, elementId)) : item.elementIds ?? []
                  //     ) === Intersection.Include
                  //   )
                  // }
                ) : !1, X = Object.keys(n.ReprCBasedTheme).find(function(me) {
                  return n.ReprCBasedTheme[me].includes(_);
                }), Z = [], !Y) return [3, 5];
                J = function(me) {
                  var he, _e, Se;
                  return (0, e.__generator)(this, function(Pe) {
                    switch (Pe.label) {
                      case 0:
                        return q.set(me.ref, /* @__PURE__ */ new Set()), he = $.plugin.managers.cell.get(me.ref), _e = he.representations.get(_), Se = he.theme.color[X], [4, (0, s.removeElementIdsInRepresentation)(_e == null ? void 0 : _e.state, (T = me.elementIds) !== null && T !== void 0 ? T : [], _, function(De) {
                          var Ee;
                          return ce.createTheme(_, De, {
                            color: { name: "multi-theme", props: { themes: Se } },
                            size: he.theme.size && (!((Ee = he.theme.size[X]) === null || Ee === void 0) && Ee.length) ? he.theme.size[X][0] : ce.defaultTheme.size[_]
                          });
                        }, function(De) {
                          return ce.createTransparencyLayers(De, he == null ? void 0 : he.theme.transparency[X]);
                        })];
                      case 1:
                        return Pe.sent(), (x = q.get(me.ref)) === null || x === void 0 || x.add(_), he.dependency.by.length && Z.push.apply(Z, he.dependency.by), [
                          2
                          /*return*/
                        ];
                    }
                  });
                }, $ = this, Q = 0, W = K, de.label = 1;
              case 1:
                return Q < W.length ? (ae = W[Q], [5, J(ae)]) : [3, 4];
              case 2:
                de.sent(), de.label = 3;
              case 3:
                return Q++, [3, 1];
              case 4:
                return [3, 9];
              case 5:
                te = function(me) {
                  var he, _e, Se, Pe, De, Ee, Me, ue, pe, Ae, ye, be, fe, ge, xe, we, Ve, we, Ve, Ne, Oe;
                  return (0, e.__generator)(this, function(ze) {
                    switch (ze.label) {
                      case 0:
                        if (q.set(me.ref, /* @__PURE__ */ new Set()), he = oe.plugin.managers.cell.get(me.ref), _e = he.representations.get(_), Se = (0, s.getStructureByCell)(he), Pe = he.theme.color[X], De = [], Pe == null || Pe.forEach(function(ke) {
                          var je;
                          De.push.apply(De, (je = ke.elementIds) !== null && je !== void 0 ? je : []);
                        }), Ee = new Set(De), Me = ((w = me.elementIds) !== null && w !== void 0 ? w : []).filter(function(ke) {
                          return !Ee.has(ke);
                        }), Me.length && (Pe == null || Pe.push((0, e.__assign)({ elementIds: Me }, oe.defaultTheme.color[X])), he.theme.color = (0, e.__assign)((0, e.__assign)({}, he.theme.color), (Oe = {}, Oe[X] = Pe, Oe))), ue = [], !A) return [3, 4];
                        pe = function(ke) {
                          var je;
                          return (0, e.__generator)(this, function(Xe) {
                            switch (Xe.label) {
                              case 0:
                                return !M && ke.type !== n.RepresentationType.Ribbon && _ !== n.RepresentationType.Ribbon && (je = (0, s.overlapRepresentationByElementIds)(
                                  // Repr Cache Compatible
                                  ke.state,
                                  (E = me.elementIds) !== null && E !== void 0 ? E : []
                                ), je.length) ? (me.elementIds = (I = me.elementIds) === null || I === void 0 ? void 0 : I.filter(function(Fe) {
                                  return !je.includes(Fe);
                                }), [2, "continue"]) : ke.type === _ || ke.type === n.RepresentationType.Ribbon || ke.isHidden || (0, s.isRepresentationIntersectElementIds)(
                                  // Repr Cache Compatible
                                  ke.state,
                                  (B = me.elementIds) !== null && B !== void 0 ? B : []
                                ) === n.Intersection.Not ? [2, "continue"] : (ue.push.apply(ue, (0, s.overlapRepresentationByElementIds)(ke == null ? void 0 : ke.state, (D = me.elementIds) !== null && D !== void 0 ? D : [])), [4, (0, s.removeElementIdsInRepresentation)(ke == null ? void 0 : ke.state, (N = me.elementIds) !== null && N !== void 0 ? N : [], ke == null ? void 0 : ke.type, function(Fe) {
                                  var He;
                                  return ce.createTheme(ke == null ? void 0 : ke.type, Fe, {
                                    color: { name: "multi-theme", props: { themes: Pe } },
                                    size: he.theme.size && (!((He = he.theme.size[X]) === null || He === void 0) && He.length) ? he.theme.size[X][0] : ce.defaultTheme.size[ke == null ? void 0 : ke.type]
                                  });
                                }, function(Fe) {
                                  return ce.createTransparencyLayers(Fe, he == null ? void 0 : he.theme.transparency[X]);
                                })]);
                              case 1:
                                return Xe.sent(), (O = q.get(me.ref)) === null || O === void 0 || O.add(ke.type), [
                                  2
                                  /*return*/
                                ];
                            }
                          });
                        }, Ae = 0, ye = Array.from(he.representations), ze.label = 1;
                      case 1:
                        return Ae < ye.length ? (be = ye[Ae], fe = be[1], [5, pe(fe)]) : [3, 4];
                      case 2:
                        ze.sent(), ze.label = 3;
                      case 3:
                        return Ae++, [3, 1];
                      case 4:
                        return ge = new Set(ue), _e ? (xe = // Repr Cache Compatible
                        (V = (0, s.getElementIdsFromRepresentation)(_e.state)) !== null && V !== void 0 ? V : [], we = (0, s.getStructureByElementIds)(Se, Array.from(new Set(xe.concat(n.AtomReprType.has(_) && oe.showPolarHydrogenOnly ? ((k = me.elementIds) !== null && k !== void 0 ? k : []).filter(function(ke) {
                          return ge.has(ke) || !(0, s.isNonPolarHydrogen)(Se, ke);
                        }) : (G = me.elementIds) !== null && G !== void 0 ? G : [])))), Ve = oe.createTransparencyLayers(we, he == null ? void 0 : he.theme.transparency[X]), [4, c.MolecularRepresentation[_].update(_e == null ? void 0 : _e.state, we, oe.ctx, oe.createTheme(_, we, {
                          color: { name: "multi-theme", props: { themes: Pe } },
                          size: he.theme.size && (!((L = he.theme.size[X]) === null || L === void 0) && L.length) ? he.theme.size[X][0] : oe.defaultTheme.size[_]
                        }))]) : [3, 6];
                      case 5:
                        return ze.sent(), (R = q.get(me.ref)) === null || R === void 0 || R.add(_), _e.state.setState({
                          transparency: Ve
                        }), [3, 8];
                      case 6:
                        return we = (0, s.getStructureByElementIds)(Se, n.AtomReprType.has(_) && oe.showPolarHydrogenOnly ? me.elementIds.filter(function(ke) {
                          return ge.has(ke) || !(0, s.isNonPolarHydrogen)(Se, ke);
                        }) : me.elementIds), Ve = oe.createTransparencyLayers(he == null ? void 0 : he.model.structure, he == null ? void 0 : he.theme.transparency[X]), [4, c.MolecularRepresentation[_].create(we, oe.plugin.managers.representation.ctx, oe.createTheme(_, we, {
                          color: { name: "multi-theme", props: { themes: Pe } },
                          size: he.theme.size && (!((F = he.theme.size[X]) === null || F === void 0) && F.length) ? he.theme.size[X][0] : oe.defaultTheme.size[_]
                        }))];
                      case 7:
                        Ne = ze.sent(), (U = q.get(me.ref)) === null || U === void 0 || U.add(_), (H = oe.plugin.canvas3d) === null || H === void 0 || H.add(Ne), Ne.setState({
                          transparency: Ve
                        }), he.representations.set(_, {
                          state: Ne,
                          isHidden: !1,
                          type: _
                        }), ze.label = 8;
                      case 8:
                        return he.dependency.by.length && Z.push.apply(Z, he.dependency.by), [
                          2
                          /*return*/
                        ];
                    }
                  });
                }, oe = this, z = 0, j = K, de.label = 6;
              case 6:
                return z < j.length ? (ae = j[z], [5, te(ae)]) : [3, 9];
              case 7:
                de.sent(), de.label = 8;
              case 8:
                return z++, [3, 6];
              case 9:
                for (le = this.plugin.managers.selection.structure.getSelection(), q.forEach(function(me, he) {
                  var _e;
                  if (me.size) {
                    var Se = ce.plugin.cells.get(he), Pe = (_e = le[he]) !== null && _e !== void 0 ? _e : [];
                    me.forEach(function(De) {
                      var Ee, Me = Se == null ? void 0 : Se.representations.get(De);
                      if (Me) {
                        var ue = (
                          // Repr Cache Compatible
                          (0, s.getLoci)((0, s.getStructureFromRepresentation)(Me.state), Pe)
                        );
                        (Ee = ce.plugin.canvas3d) === null || Ee === void 0 || Ee.mark({
                          loci: ue,
                          repr: Me.state
                        }, h.MarkerAction.Select);
                      }
                    });
                  }
                }), ie = Array.from(new Set(Z).values()), re = 0, ee = ie; re < ee.length; re++)
                  ne = ee[re], se = this.plugin.cells.get(ne), se && se.representations.forEach(function(me, he) {
                    he === n.RepresentationType.IntraInteractions && P && ce.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.representation.setMolecularRepr");
                  });
                return this.plugin.managers.snapshot.event.changed.next({
                  from: "repr: setMolecularRepr"
                }), [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, b.prototype.showOrHideHs = function(g, _, A) {
        var M = this, P = A ?? this.plugin.managers.selection.structure.getSelectionCellItems(), T = [];
        P.forEach(function(D) {
          var N = M.plugin.cells.get(D.ref);
          if (N) {
            var O = (0, s.getStructureByCell)(N);
            if (O) {
              D.elementIds || Object.assign(D, { elementIds: (0, s.getElementsFromStructure)(O) });
              var V = D.elementIds.map(function(F) {
                return (0, s.getHydrogenType)(O, F);
              }), k = /* @__PURE__ */ new Map(), G = /* @__PURE__ */ new Map();
              N.representations.forEach(function(F, U) {
                if ([
                  n.RepresentationType.BallAndStick,
                  n.RepresentationType.CPK,
                  n.RepresentationType.Stick,
                  n.RepresentationType.Line
                ].includes(U)) {
                  var H = (0, s.transformLociToElementLoci)(F.state.getLoci());
                  if (!H)
                    return;
                  var q = (0, s.getElementIdsByLoci)(H);
                  G.set(U, (0, e.__spreadArray)([], q, !0)), q.forEach(function(K) {
                    k.set(K, U);
                  });
                }
              });
              var L = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Map();
              V.forEach(function(F, U) {
                var H;
                if (D.elementIds) {
                  var q = D.elementIds[U], K = O.units.filter(function(Y) {
                    return f.SortedArray.indexOf(Y.elements, q) !== -1;
                  })[0];
                  if ((!_ && F === n.HydrogenVariant.NonPolar || !g && F === n.HydrogenVariant.Polar) && k.has(q)) {
                    L.has(k.get(q)) ? (H = L.get(k.get(q))) === null || H === void 0 || H.add(q) : L.set(k.get(q), /* @__PURE__ */ new Set([q]));
                    return;
                  }
                  if ((!_ && F === n.HydrogenVariant.ConnectNonPolar || !g && F === n.HydrogenVariant.ConnectPolar) && (0, d.eachBondedAtom)(O, K, K.elements.indexOf(q), function(Y, X) {
                    var Z;
                    Y.model.atomicHierarchy.derived.atom.atomicNumber[Y.elements[X]] === 1 && k.has(Y.elements[X]) && (L.has(k.get(q)) ? (Z = L.get(k.get(q))) === null || Z === void 0 || Z.add(Y.elements[X]) : L.set(k.get(q), /* @__PURE__ */ new Set([Y.elements[X]])));
                  }), (_ && F === n.HydrogenVariant.NonPolar || g && F === n.HydrogenVariant.Polar) && !k.has(q)) {
                    (0, d.eachBondedAtom)(O, K, K.elements.indexOf(q), function(Y, X) {
                      var Z;
                      Y.model.atomicHierarchy.derived.atom.atomicNumber[Y.elements[X]] !== 1 && k.has(Y.elements[X]) && (R.has(k.get(Y.elements[X])) ? (Z = R.get(k.get(Y.elements[X]))) === null || Z === void 0 || Z.add(q) : R.set(k.get(Y.elements[X]), /* @__PURE__ */ new Set([q])));
                    });
                    return;
                  }
                  (_ && F === n.HydrogenVariant.ConnectNonPolar || g && F === n.HydrogenVariant.ConnectPolar) && k.has(q) && (0, d.eachBondedAtom)(O, K, K.elements.indexOf(q), function(Y, X) {
                    var Z;
                    Y.model.atomicHierarchy.derived.atom.atomicNumber[Y.elements[X]] === 1 && !k.has(Y.elements[X]) && (R.has(k.get(q)) ? (Z = R.get(k.get(q))) === null || Z === void 0 || Z.add(Y.elements[X]) : R.set(k.get(q), /* @__PURE__ */ new Set([Y.elements[X]])));
                  });
                }
              }), N.representations.forEach(function(F, U) {
                var H;
                if ([
                  n.RepresentationType.BallAndStick,
                  n.RepresentationType.CPK,
                  n.RepresentationType.Stick,
                  n.RepresentationType.Line
                ].includes(U)) {
                  var q = !1, K = G.get(U);
                  if (L.has(U) && L.get(U).size > 0) {
                    var Y = L.get(U);
                    K = K == null ? void 0 : K.filter(function($) {
                      return !Y.has($);
                    }), q = !0;
                  }
                  if (R.has(U) && R.get(U).size > 0) {
                    var X = R.get(U);
                    K = Array.from(new Set((0, e.__spreadArray)((0, e.__spreadArray)([], Array.from(X.values()), !0), K, !0))), q = !0;
                  }
                  if (q) {
                    var Z = (0, s.getStructureByElementIds)(O, K), J = N.theme.color[n.ThemeC.ATOM];
                    c.MolecularRepresentation[U].update(
                      // Repr Cache Compatible
                      F.state,
                      Z,
                      M.ctx,
                      M.createTheme(U, Z, {
                        color: { name: "multi-theme", props: { themes: J } },
                        size: N.theme.size && (!((H = N.theme.size[n.ThemeC.ATOM]) === null || H === void 0) && H.length) ? N.theme.size[n.ThemeC.ATOM][0] : M.defaultTheme.size[U]
                      })
                    );
                  }
                }
              }), N.dependency.by.length && T.push.apply(T, N.dependency.by);
            }
          }
        });
        for (var x = Array.from(new Set(T).values()), w = 0, E = x; w < E.length; w++) {
          var I = E[w], B = this.plugin.cells.get(I);
          B && B.representations.forEach(function(D, N) {
            N === n.RepresentationType.IntraInteractions && M.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.representation.showOrHideHs");
          });
        }
      }, b.prototype.redraw = function() {
        var g = this;
        this.plugin.canvas3d && (this.plugin.canvas3d.clear(), Array.from(this.plugin.cells.values()).forEach(function(_) {
          _.representations.forEach(function(A) {
            var M;
            A.isHidden !== !0 && A.state && ((M = g.plugin.canvas3d) === null || M === void 0 || M.add(A.state));
          });
        }));
      }, b;
    }(p.RepresentationInteractions)
  );
  return S1.RepresentationManager = C, S1;
}
var A1 = {}, ZV;
function A4e() {
  if (ZV) return A1;
  ZV = 1;
  var e;
  Object.defineProperty(A1, "__esModule", { value: !0 }), A1.CellManager = void 0;
  var r = Te, t = ef(), n = Jt, a = We(), i = eu(), o = sn(), c = $p(), s = Yo, u = kn, l = _r, f = Iy, d = zp(), m = ma, p = qp(), v = Ac(), h = Je(), y = (e = {}, e[n.ThemeC.ATOM] = [], e[n.ThemeC.RIBBON] = [], e[n.ThemeC.SURFACE] = [], e), C = (
    /** @class */
    function() {
      function S(b) {
        var g = this, _;
        this.plugin = b, (_ = this.plugin.canvas3d) === null || _ === void 0 || _.reprCount.subscribe(function(A) {
          if (A > 100 && g.idleCellSet.size) {
            var M = Array.from(g.idleCellSet.values())[0];
            g.idleCellSet.delete(M), g.clearReprState(M);
          }
        }), this.idleCellSet = /* @__PURE__ */ new Set();
      }
      return S.prototype.get = function(b) {
        var g = this.plugin.cells.get(b);
        if (!g) {
          console.error("no ".concat(b, " cell"));
          return;
        }
        return g;
      }, S.prototype.getHierarchy = function(b) {
        var g = this, _ = this.get(b);
        if (!(_ != null && _.model.structure))
          return console.error("".concat(b, " cell does not have structure")), {
            data: {
              polymer: {},
              water: {},
              otherSolvent: {},
              metal: {},
              ion: {},
              ligand: {},
              other: {}
            },
            extraData: {
              sequenceData: {}
            }
          };
        var A = [], M = [];
        _.dependency.by.forEach(function(T) {
          var x, w, E;
          if (g.plugin.cells.has(T)) {
            var I = g.get(T);
            I && (I.representations.has(t.RepresentationType.Label) && M.push({
              ref: T,
              dependencies: (0, r.__spreadArray)([], I.dependency.on, !0),
              // Repr State Cache
              label: ((w = (x = I.representations.get(t.RepresentationType.Label)) === null || x === void 0 ? void 0 : x.state) !== null && w !== void 0 ? w : (E = I.representations.get(t.RepresentationType.Label)) === null || E === void 0 ? void 0 : E.cache).props.customText
            }), I.representations.has(t.RepresentationType.Surface) && A.push({
              ref: T,
              dependencies: (0, r.__spreadArray)([], I.dependency.on, !0)
            }));
          }
        });
        var P = (0, o.getHierarchy)(_.model.structure);
        return (0, r.__assign)((0, r.__assign)({}, P), { extraData: (0, r.__assign)((0, r.__assign)({}, P.extraData), { label: M, surface: A }) });
      }, S.prototype.getSequence = function(b) {
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var g;
          return (0, r.__generator)(this, function(_) {
            switch (_.label) {
              case 0:
                return [4, this.getStructure(b)];
              case 1:
                return g = _.sent(), g ? [2, (0, o.getSequence)(g)] : [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, S.prototype.getStructure = function(b) {
        var g;
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var _, A, M, P, T, x, w, E;
          return (0, r.__generator)(this, function(I) {
            switch (I.label) {
              case 0:
                return _ = this.get(b), _ ? (A = (0, o.getStructureByCell)(_), A ? [2, A] : !A && (!((g = _.assets) === null || g === void 0) && g.length) ? (M = _.assets[0], P = M.data, T = M.format, E = (w = p.FormatProvider[T]).parse, [4, (0, o.readAsString)(P)]) : [3, 5]) : [
                  2
                  /*return*/
                ];
              case 1:
                return [4, E.apply(w, [I.sent()])];
              case 2:
                return x = I.sent()[0], T === n.Format.Pdb && x.elementCount && !h.Model.hasSecondaryStructure(x == null ? void 0 : x.model) ? [4, v.SecondaryStructureProvider.attach({}, x, {
                  type: {
                    name: "dssp",
                    params: { oldDefinition: !0, oldOrdering: !0 }
                  }
                }, !0)] : [3, 4];
              case 3:
                I.sent(), I.label = 4;
              case 4:
                return this.update(b, { model: { structure: x } }), [2, x];
              case 5:
                return [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, S.prototype.getLoci = function(b) {
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var g;
          return (0, r.__generator)(this, function(_) {
            switch (_.label) {
              case 0:
                return [4, this.getStructure(b.ref)];
              case 1:
                return g = _.sent(), g ? [2, (0, o.getLoci)(g, b.elementIds)] : [2, l.EmptyLoci];
            }
          });
        });
      }, S.prototype.getMolecularName = function(b) {
        var g, _, A, M, P, T, x = this.get(b);
        if (!x.model.structure)
          return !((g = x.assets) === null || g === void 0) && g.length && ["sdf", "mol"].includes(x.assets[0].format) ? "".concat(x.assets[0].data).split(`
`)[0] : "";
        var w = ((A = (_ = x.model.structure) === null || _ === void 0 ? void 0 : _.state.model) !== null && A !== void 0 ? A : !((M = x.model.structure) === null || M === void 0) && M.state.models) ? (P = x.model.structure) === null || P === void 0 ? void 0 : P.state.models[0] : void 0;
        if (!w)
          return "";
        var E = (T = w.sourceData) === null || T === void 0 ? void 0 : T.kind;
        return E === "sdf" || E === "mol" ? w.entryId : "";
      }, S.prototype.isFromPdb = function(b) {
        var g, _ = this.plugin.cells.get(b);
        if (!_)
          return !1;
        var A = (0, o.getStructureByCell)(_);
        if (!A)
          return !1;
        var M = ((g = (0, o.getModelByStructure)(A)) === null || g === void 0 ? void 0 : g.sourceData.kind) === "mmCIF";
        return M;
      }, S.prototype.getCellPdbId = function(b) {
        if (!this.isFromPdb(b))
          return "";
        var g = this.plugin.cells.get(b);
        if (!g)
          return "";
        var _ = (0, o.getStructureByCell)(g);
        if (!_)
          return "";
        var A = "";
        if (this.plugin.managers.cell.isFromPdb(b)) {
          for (var M = (0, d.getPDBSectionLine)(_, ["HEADER"]), P = 0, T = M.length; P < T && !A; P++)
            if (M[P].startsWith("HEADER") && M[P].length >= 66) {
              var x = M[P].slice(62, 66).replace(" ", "");
              x.length === 4 && /^[A-Za-z0-9]*$/.test(x) && (A = x);
            }
        }
        return A;
      }, S.prototype.getMeasurementName = function(b, g) {
        var _, A, M = this.get(b), P = M.representations.get(g);
        if (!P)
          return console.warn("There is no ".concat(g, " in ").concat(b, " cell"));
        var T = ((A = (_ = M.model) === null || _ === void 0 ? void 0 : _.loci) !== null && A !== void 0 ? A : []).map(function(x) {
          return l.Loci.getCenter(x);
        });
        return g === t.RepresentationType.Distance ? "".concat(s.Vec3.distance(T[0], T[1]).toFixed(2), "Å") : g === t.RepresentationType.Angle ? "".concat((0, u.radToDeg)(s.Vec3.angle(s.Vec3.sub((0, s.Vec3)(), T[0], T[1]), s.Vec3.sub((0, s.Vec3)(), T[2], T[1]))).toFixed(2), "°") : g === t.RepresentationType.Dihedral ? "".concat((0, u.radToDeg)(s.Vec3.dihedralAngle(T[0], T[1], T[2], T[3])).toFixed(2), "°") : "";
      }, S.prototype.create = function(b) {
        var g = this, _, A, M = b.representations, P = b.model, T = b.assets, x = b.dependency, w = b.ref, E = b.theme, I = w ?? a.UUID.create22(), B = /* @__PURE__ */ new Map();
        return M.forEach(function(D) {
          var N;
          !D.isHidden && D.state && ((N = g.plugin.canvas3d) === null || N === void 0 || N.add(D.state)), B.set(D.type, D);
        }), this.plugin.cells.set(I, {
          ref: I,
          representations: B,
          dependency: (0, r.__assign)({ on: [], by: [] }, x),
          theme: {
            color: (0, r.__assign)((0, r.__assign)({}, y), E == null ? void 0 : E.color),
            size: (0, r.__assign)((0, r.__assign)({}, y), E == null ? void 0 : E.size),
            transparency: (0, r.__assign)((0, r.__assign)({}, y), E == null ? void 0 : E.transparency)
          },
          assets: T,
          model: P
        }), !((_ = x == null ? void 0 : x.on) === null || _ === void 0) && _.length && Array.from(new Set(x == null ? void 0 : x.on)).forEach(function(D) {
          g.addDependency(D.ref, { by: [I] });
        }), !((A = x == null ? void 0 : x.by) === null || A === void 0) && A.length && Array.from(new Set(x == null ? void 0 : x.by)).forEach(function(D) {
          g.addDependency(D, { on: [{ ref: I }] });
        }), this.plugin.managers.snapshot.event.changed.next({ from: "cell:create" }), I;
      }, S.prototype.createEmptyMolecularCell = function(b) {
        var g, _, A, M;
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var P, T, x, w, E;
          return (0, r.__generator)(this, function(I) {
            switch (I.label) {
              case 0:
                return P = (0, o.createEmptyStructure)(), [4, f.BallAndStickRepr.create(P, this.plugin.managers.representation.ctx)];
              case 1:
                return T = I.sent(), x = this.create({
                  representations: [
                    {
                      state: T,
                      isHidden: !1,
                      type: t.RepresentationType.BallAndStick
                    }
                  ],
                  model: { structure: P },
                  assets: [{ format: n.Format.Sdf, data: "" }],
                  theme: {
                    transparency: (w = {}, w[n.ThemeC.ATOM] = b && (!((g = b[n.ThemeC.ATOM]) === null || g === void 0) && g.transparency) ? [(_ = b[n.ThemeC.ATOM]) === null || _ === void 0 ? void 0 : _.transparency] : [], w[n.ThemeC.RIBBON] = [], w[n.ThemeC.SURFACE] = [], w),
                    size: (E = {}, E[n.ThemeC.ATOM] = b && (!((A = b[n.ThemeC.ATOM]) === null || A === void 0) && A.size) ? [(M = b[n.ThemeC.ATOM]) === null || M === void 0 ? void 0 : M.size] : [], E[n.ThemeC.RIBBON] = [], E[n.ThemeC.SURFACE] = [], E)
                  }
                }), [2, x];
            }
          });
        });
      }, S.prototype.copyMolecular = function(b, g) {
        var _, A, M, P, T, x;
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var w, E, I, B, D, N;
          return (0, r.__generator)(this, function(O) {
            switch (O.label) {
              case 0:
                w = [], E = function(V) {
                  var k, G, L, R, F, U, H, q, K, Y, X, Z, J;
                  return (0, r.__generator)(this, function($) {
                    switch ($.label) {
                      case 0:
                        return k = I.get(V.ref), [4, I.getStructure(V.ref)];
                      case 1:
                        return G = $.sent(), L = [], R = (0, o.getStructureByElementIds)(G, (_ = V.elementIds) !== null && _ !== void 0 ? _ : [], !0, !0), R.elementCount ? [4, v.SecondaryStructureProvider.attach({}, R, void 0, !0)] : [3, 3];
                      case 2:
                        $.sent(), $.label = 3;
                      case 3:
                        return F = (0, o.getStructureUniqueId)(R), V.representationType ? (U = Object.keys(n.ReprCBasedTheme).find(function(Q) {
                          return n.ReprCBasedTheme[Q].includes(V.representationType);
                        }), [4, c.MolecularRepresentation[V.representationType].create(R, I.plugin.managers.representation.ctx, I.plugin.managers.representation.createTheme(V.representationType, R, {
                          color: { name: "multi-theme", props: { themes: k.theme.color[U] } },
                          size: k.theme.size && (!((A = k.theme.size[U]) === null || A === void 0) && A.length) ? k.theme.size[U][0] : I.plugin.managers.representation.defaultTheme.size[V.representationType]
                        }))]) : [3, 5];
                      case 4:
                        return H = $.sent(), L.push({
                          state: H,
                          isHidden: (M = g == null ? void 0 : g.isHidden) !== null && M !== void 0 ? M : !0,
                          type: V.representationType
                        }), [3, 9];
                      case 5:
                        q = function(Q, W) {
                          var te, oe, z, j;
                          return (0, r.__generator)(this, function(ae) {
                            switch (ae.label) {
                              case 0:
                                return te = Object.keys(n.ReprCBasedTheme).find(function(le) {
                                  return n.ReprCBasedTheme[le].includes(Q);
                                }), oe = !((P = V.elementIds) === null || P === void 0) && P.length ? (0, o.overlapRepresentationByElementIds)(W.state, V.elementIds).length : !0, oe ? (z = (0, o.getStructureByElementIds)(W.state ? (0, o.getStructureFromRepresentation)(W.state) : (0, o.getStructureByElementIds)(R, W.cache.elementIds, !0), (T = V.elementIds) !== null && T !== void 0 ? T : [], !0, F), [4, c.MolecularRepresentation[Q].create(z, I.plugin.managers.representation.ctx, I.plugin.managers.representation.createTheme(Q, z, {
                                  color: { name: "multi-theme", props: { themes: k.theme.color[te] } },
                                  size: I.plugin.managers.representation.defaultTheme.size[Q]
                                }))]) : [3, 2];
                              case 1:
                                j = ae.sent(), L.push({
                                  state: j,
                                  isHidden: (x = g == null ? void 0 : g.isHidden) !== null && x !== void 0 ? x : !0,
                                  type: Q
                                }), ae.label = 2;
                              case 2:
                                return [
                                  2
                                  /*return*/
                                ];
                            }
                          });
                        }, K = 0, Y = Array.from(k.representations), $.label = 6;
                      case 6:
                        return K < Y.length ? (X = Y[K], Z = X[0], J = X[1], [5, q(Z, J)]) : [3, 9];
                      case 7:
                        $.sent(), $.label = 8;
                      case 8:
                        return K++, [3, 6];
                      case 9:
                        return w.push(I.create({
                          representations: L,
                          model: {
                            structure: R
                          },
                          assets: k.assets,
                          theme: (0, r.__assign)({}, k.theme)
                        })), [
                          2
                          /*return*/
                        ];
                    }
                  });
                }, I = this, B = 0, D = b, O.label = 1;
              case 1:
                return B < D.length ? (N = D[B], [5, E(N)]) : [3, 4];
              case 2:
                O.sent(), O.label = 3;
              case 3:
                return B++, [3, 1];
              case 4:
                return this.plugin.managers.snapshot.event.changed.next({
                  from: "cell:copyMolecular"
                }), [2, w];
            }
          });
        });
      }, S.prototype.update = function(b, g) {
        var _ = this, A, M, P, T, x, w, E, I = this.plugin.managers.cell.get(b);
        I.model = Object.assign(I.model, g.model), g.theme && (I.theme = {
          color: (0, r.__assign)((0, r.__assign)({}, I.theme.color), g.theme.color),
          size: (0, r.__assign)((0, r.__assign)({}, I.theme.size), g.theme.size),
          transparency: (0, r.__assign)((0, r.__assign)({}, I.theme.transparency), g.theme.transparency)
        }), !((A = g.representations) === null || A === void 0) && A.length && g.representations.forEach(function(B) {
          var D;
          I.representations.set(B.type, Object.assign((D = I.representations.get(B.type)) !== null && D !== void 0 ? D : {}, B));
        }), !((P = (M = g.dependency) === null || M === void 0 ? void 0 : M.on) === null || P === void 0) && P.length && (this.removeDependency(b, { on: I.dependency.on }), Array.from(new Set((T = g.dependency) === null || T === void 0 ? void 0 : T.on)).forEach(function(B) {
          _.addDependency(B.ref, { by: [b] });
        })), !((w = (x = g.dependency) === null || x === void 0 ? void 0 : x.by) === null || w === void 0) && w.length && (this.removeDependency(b, { by: I.dependency.by }), Array.from(new Set((E = g.dependency) === null || E === void 0 ? void 0 : E.by)).forEach(function(B) {
          _.addDependency(B, { on: [{ ref: b }] });
        })), I.dependency = (0, r.__assign)((0, r.__assign)({}, I.dependency), g.dependency), g.assets && (I.assets = g.assets), this.plugin.managers.snapshot.event.changed.next({ from: "cell:update" });
      }, S.prototype.remove = function(b, g) {
        var _, A;
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var M, P, T, x, w, E, I, B = this;
          return (0, r.__generator)(this, function(D) {
            switch (D.label) {
              case 0:
                M = "", P = /* @__PURE__ */ new Map(), T = function(N) {
                  var O, V, k, G, L, R, F, U, H, q, K, Y;
                  return (0, r.__generator)(this, function(X) {
                    switch (X.label) {
                      case 0:
                        return x.plugin.cells.has(N.ref) ? (O = x.get(N.ref), [4, x.getStructure(N.ref)]) : [2, "continue"];
                      case 1:
                        if (V = X.sent(), N.ref && V && x.plugin.managers.selection.structure.remove({ item: { ref: N.ref, elementIds: (_ = N.elementIds) !== null && _ !== void 0 ? _ : (0, o.getElementsFromStructure)(V) } }), P.has(N.ref) && P.get(N.ref) !== void 0 ? P.set(N.ref, N.elementIds === void 0 ? void 0 : (0, r.__spreadArray)((0, r.__spreadArray)([], N.elementIds, !0), P.get(N.ref), !0)) : P.set(N.ref, N.elementIds), g)
                          O.representations.forEach(function(Z) {
                            var J, $;
                            if (n.MeasurementType.has(Z.type) && O.dependency.on.length) {
                              var Q = O.dependency.on.some(function(W) {
                                return (0, o.isCellItemIntersectCellItem)(W, g);
                              });
                              Q && (!Z.isHidden && Z.state && ((J = B.plugin.canvas3d) === null || J === void 0 || J.remove(Z.state)), O.representations.delete(Z.type));
                            }
                            Z.type === t.RepresentationType.Surface && (g.elementIds || (Z.state && (($ = B.plugin.canvas3d) === null || $ === void 0 || $.remove(Z.state)), O.representations.delete(Z.type)));
                          });
                        else if (!(!((A = N == null ? void 0 : N.elementIds) === null || A === void 0) && A.length))
                          O.representations.forEach(function(Z) {
                            var J;
                            !Z.isHidden && Z.state && ((J = B.plugin.canvas3d) === null || J === void 0 || J.remove(Z.state)), O.representations.delete(Z.type);
                          });
                        else {
                          for (k = function(Z, J) {
                            var $ = Object.keys(n.ReprCBasedTheme).find(function(Q) {
                              return n.ReprCBasedTheme[Q].includes(Z);
                            });
                            (0, o.removeElementIdsInRepresentation)(
                              // Repr Cache Compatible
                              J.state,
                              N.elementIds,
                              Z,
                              function(Q) {
                                var W;
                                return B.plugin.managers.representation.createTheme(Z, Q, {
                                  color: { name: "multi-theme", props: { themes: O.theme.color[$] } },
                                  size: O.theme.size && (!((W = O.theme.size[$]) === null || W === void 0) && W.length) ? O.theme.size[$][0] : B.plugin.managers.representation.defaultTheme.size[J.type]
                                });
                              },
                              function(Q) {
                                var W;
                                return B.plugin.managers.representation.createTransparencyLayers(Q, (0, r.__spreadArray)([], (W = O == null ? void 0 : O.theme.transparency[$]) !== null && W !== void 0 ? W : [], !0));
                              }
                            );
                          }, G = 0, L = Array.from(O.representations); G < L.length; G++)
                            R = L[G], F = R[0], U = R[1], k(F, U);
                          V && (O.model.structure = (0, o.removeStructureByElementIds)(V, N.elementIds));
                        }
                        if (!O.dependency.by.length) return [3, 6];
                        H = 0, q = Array.from(new Set(O.dependency.by)), X.label = 2;
                      case 2:
                        return H < q.length ? (K = q[H], Y = x.plugin.cells.get(K), Y != null && Y.representations.has(t.RepresentationType.IntraInteractions) ? (M = K, [3, 5]) : [3, 3]) : [3, 6];
                      case 3:
                        return [4, x.remove([{ ref: K }], N)];
                      case 4:
                        X.sent(), X.label = 5;
                      case 5:
                        return H++, [3, 2];
                      case 6:
                        return O.representations.size || (O.dependency.on.length && Array.from(new Set(O.dependency.on)).forEach(function(Z) {
                          var J = B.plugin.cells.get(Z.ref);
                          if (J) {
                            var $ = J.dependency.by.findIndex(function(Q) {
                              return Q === N.ref;
                            });
                            $ !== -1 && J.dependency.by.splice($, 1);
                          }
                        }), x.plugin.cells.delete(N.ref)), [
                          2
                          /*return*/
                        ];
                    }
                  });
                }, x = this, w = 0, E = b, D.label = 1;
              case 1:
                return w < E.length ? (I = E[w], [5, T(I)]) : [3, 4];
              case 2:
                D.sent(), D.label = 3;
              case 3:
                return w++, [3, 1];
              case 4:
                return M && this.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.cell.remove"), this.plugin.managers.snapshot.event.changed.next({ from: "cell:remove" }), [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, S.prototype.extractMolecular = function(b, g) {
        var _, A, M, P, T;
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var x, w, E, I, B, D, N, O, V, k, G, L, R, F, U, H;
          return (0, r.__generator)(this, function(q) {
            switch (q.label) {
              case 0:
                x = [], w = 0, E = b, q.label = 1;
              case 1:
                return w < E.length ? (I = E[w], B = this.get(I.ref), [4, this.getStructure(I.ref)]) : [3, 8];
              case 2:
                D = q.sent(), N = (0, o.getStructureByElementIds)(D, (_ = I.elementIds) !== null && _ !== void 0 ? _ : [], !0, !0), O = !((A = B.assets) === null || A === void 0) && A.length && (!((M = B.assets[0]) === null || M === void 0) && M.format) ? B.assets[0].format : n.Format.Pdb, V = [], k = function(K, Y) {
                  var X, Z, J, $;
                  return (0, r.__generator)(this, function(Q) {
                    switch (Q.label) {
                      case 0:
                        return X = Object.keys(n.ReprCBasedTheme).find(function(W) {
                          return n.ReprCBasedTheme[W].includes(K);
                        }), Z = (0, o.overlapRepresentationByElementIds)(
                          // Repr Cache Compatible
                          Y.state,
                          I.elementIds
                        ), Z.length ? (J = (0, o.getStructureByElementIds)(N, Z), [4, c.MolecularRepresentation[K].create(J, G.plugin.managers.representation.ctx, G.plugin.managers.representation.createTheme(K, J, {
                          color: { name: "multi-theme", props: { themes: B.theme.color[X] } },
                          size: B.theme.size && (!((P = B.theme.size[X]) === null || P === void 0) && P.length) ? B.theme.size[X][0] : G.plugin.managers.representation.defaultTheme.size[Y.type]
                        }))]) : [3, 2];
                      case 1:
                        $ = Q.sent(), V.push({
                          state: $,
                          isHidden: (T = g == null ? void 0 : g.isHidden) !== null && T !== void 0 ? T : !0,
                          type: K
                        }), Q.label = 2;
                      case 2:
                        return [
                          2
                          /*return*/
                        ];
                    }
                  });
                }, G = this, L = 0, R = Array.from(B.representations), q.label = 3;
              case 3:
                return L < R.length ? (F = R[L], U = F[0], H = F[1], [5, k(U, H)]) : [3, 6];
              case 4:
                q.sent(), q.label = 5;
              case 5:
                return L++, [3, 3];
              case 6:
                x.push(this.create({
                  representations: V,
                  model: {
                    structure: N
                  },
                  assets: [
                    { format: O, data: (0, o.getTextFromStructure)(N, O) }
                  ],
                  theme: (0, r.__assign)({}, B.theme)
                })), this.remove([I]), q.label = 7;
              case 7:
                return w++, [3, 1];
              case 8:
                return this.plugin.managers.snapshot.event.changed.next({
                  from: "cell:extractMolecular"
                }), [2, x];
            }
          });
        });
      }, S.prototype.addDependency = function(b, g) {
        var _, A, M = this.get(b);
        !((_ = g.on) === null || _ === void 0) && _.length && (M.dependency.on = M.dependency.on.concat(g.on)), !((A = g.by) === null || A === void 0) && A.length && (M.dependency.by = Array.from(new Set(M.dependency.by.concat(g.by))));
      }, S.prototype.removeDependency = function(b, g) {
        var _ = this, A, M;
        !((A = g.on) === null || A === void 0) && A.length && g.on.forEach(function(P) {
          _.plugin.cells.has(P.ref) && (_.get(P.ref).dependency.by = _.get(P.ref).dependency.by.filter(function(T) {
            return T !== b;
          }));
        }), !((M = g.by) === null || M === void 0) && M.length && g.by.forEach(function(P) {
          _.plugin.cells.has(P) && (_.get(P).dependency.on = _.get(P).dependency.on.filter(function(T) {
            return T.ref !== b;
          }));
        });
      }, S.prototype.query = function(b) {
        var g = [];
        return this.plugin.cells.forEach(function(_) {
          _.representations.forEach(function(A) {
            b(_, A) && g.push(_);
          });
        }), g;
      }, S.prototype.traverse = function(b) {
        this.plugin.cells.forEach(function(g) {
          g.representations.forEach(function(_) {
            b(g, _);
          });
        });
      }, S.prototype.getAllDisplayedCellsRef = function() {
        var b = /* @__PURE__ */ new Set();
        return this.plugin.managers.cell.traverse(function(g, _) {
          [t.RepresentationType.Ribbon, t.RepresentationType.BallAndStick, t.RepresentationType.Line, t.RepresentationType.Stick, t.RepresentationType.CPK].includes(_.type) && !_.isHidden && (0, o.getStructureByCell)(g) && b.add(g.ref);
        }), Array.from(b.values());
      }, S.prototype.clearReprState = function(b) {
        var g = this, _ = this.get(b), A = /* @__PURE__ */ new Map(), M = _.model.structure;
        if (M) {
          if (M) {
            var P = 0;
            M.units.forEach(function(T) {
              T.elements.forEach(function(x) {
                A.set(x, P++);
              });
            });
          }
          Array.from(_.representations.entries()).forEach(function(T) {
            var x;
            T[0];
            var w = T[1];
            w.state && ((x = g.plugin.canvas3d) === null || x === void 0 || x.remove(w.state), _.representations.set(w.type, {
              isHidden: w.isHidden,
              type: w.type,
              cache: {
                type: w.type,
                elementIds: (0, o.getElementIdsFromRepresentation)(w.state).map(function(E) {
                  return A && (A != null && A.has(E)) ? A == null ? void 0 : A.get(E) : E;
                }),
                isHidden: w.isHidden,
                params: n.MeasurementType.has(w.type) ? (0, o.getMeasurementProps)(w.type, w.state) : void 0
              }
            }));
          });
        }
      }, S.prototype.recoveryCache = function(b, g) {
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var _, A, M, P, T;
          return (0, r.__generator)(this, function(x) {
            switch (x.label) {
              case 0:
                return _ = this.get(b), A = Array.from(_.representations.values()), g ? [4, this.recoveryReprCache(_, g)] : [3, 2];
              case 1:
                x.sent(), x.label = 2;
              case 2:
                M = 0, P = A, x.label = 3;
              case 3:
                return M < P.length ? (T = P[M], T.cache ? [4, this.recoveryReprCache(_, T.cache)] : [3, 5]) : [3, 6];
              case 4:
                x.sent(), x.label = 5;
              case 5:
                return M++, [3, 3];
              case 6:
                return [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, S.prototype.recoveryReprCache = function(b, g) {
        var _, A;
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var M, P, T, x;
          return (0, r.__generator)(this, function(w) {
            switch (w.label) {
              case 0:
                return [4, this.getStructure(b.ref)];
              case 1:
                return M = w.sent(), M ? (P = Object.keys(n.ReprCBasedTheme).find(function(E) {
                  return n.ReprCBasedTheme[E].includes(g.type);
                }), T = b.theme.color[P], x = b.theme.transparency ? b.theme.transparency[P] : void 0, [4, this.plugin.managers.representation.addMolecularRepr(b.ref, {
                  reprType: g.type,
                  elementIds: g.elementIds,
                  isHidden: g.isHidden,
                  theme: this.plugin.managers.representation.createTheme(g.type, (0, o.getStructureByElementIds)(M, (_ = g.elementIds) !== null && _ !== void 0 ? _ : [], !0), {
                    color: {
                      name: "multi-theme",
                      props: { themes: T }
                    },
                    size: b.theme.size && (!((A = b.theme.size[P]) === null || A === void 0) && A.length) ? b.theme.size[P][0] : this.plugin.managers.representation.defaultTheme.size[g.type]
                  }),
                  transparency: x
                })]) : [
                  2
                  /*return*/
                ];
              case 2:
                return w.sent(), [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, S.prototype.overlapLigands = function(b, g, _) {
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var A, M, P, T, x, w, E, I, D, N, D, N, B, D, N;
          return (0, r.__generator)(this, function(O) {
            switch (O.label) {
              case 0:
                return A = (0, m.parseMolText)(_), M = [
                  Array.from(A.atoms.x.toArray()).reduce(function(V, k) {
                    return V + k;
                  }) / A.atoms.count,
                  Array.from(A.atoms.y.toArray()).reduce(function(V, k) {
                    return V + k;
                  }) / A.atoms.count,
                  Array.from(A.atoms.z.toArray()).reduce(function(V, k) {
                    return V + k;
                  }) / A.atoms.count
                ], [4, this.getStructure(b)];
              case 1:
                for (P = O.sent(), T = (0, o.getLoci)(P, g), x = i.Loci.getBoundary(T).sphere.center, w = [
                  x[0] - M[0],
                  x[1] - M[1],
                  x[2] - M[2]
                ], E = [], I = /* @__PURE__ */ new Map(), D = 0, N = A.formalCharges.atomIdx.rowCount; D < N; D++)
                  I.set(A.formalCharges.atomIdx.value(D) - 1, A.formalCharges.charge.value(D));
                for (D = 0, N = A.atoms.count; D < N; D++)
                  E.push({
                    x: A.atoms.x.value(D) + w[0],
                    y: A.atoms.y.value(D) + w[1],
                    z: A.atoms.z.value(D) + w[2],
                    type_symbol: A.atoms.type_symbol.value(D),
                    charge: I.get(D) || 0
                  });
                for (B = [], D = 0, N = A.bonds.count; D < N; D++)
                  B.push({
                    a: A.bonds.atomIdxA.value(D),
                    b: A.bonds.atomIdxB.value(D),
                    order: A.bonds.order.value(D)
                  });
                return [2, {
                  atoms: E,
                  bonds: B
                }];
            }
          });
        });
      }, S.prototype.getUnitCellData = function(b) {
        var g = this.get(b);
        if (g) {
          var _ = (0, o.getStructureByCell)(g);
          return (0, o.getUnitCellData)(_);
        }
      }, S;
    }()
  );
  return A1.CellManager = C, A1;
}
var x1 = {}, T1 = {}, JV;
function x4e() {
  if (JV) return T1;
  JV = 1, Object.defineProperty(T1, "__esModule", { value: !0 }), T1.TrajectoryRepr = void 0;
  var e = Te, r = Jt, t = o4(), n = gn(), a = sD, i = sn(), o = iD, c = eu(), s = Ac(), u = us, l = ty(), f = Tr();
  return T1.TrajectoryRepr = {
    createByTrajectory: function(d, m) {
      return (0, e.__awaiter)(this, void 0, void 0, function() {
        var p, v, h, y, C, S, b, g, _, A, M, P, T, x;
        return (0, e.__generator)(this, function(w) {
          switch (w.label) {
            case 0:
              return p = d.trajectory, v = d.frameIndex, h = d.mode, y = p, C = n.Structure.ofModel(y.getFrameAtIndex(v)), S = [], h !== r.VisualizationMode.Drug ? [3, 7] : (b = (0, i.getProteinAndOthersElementIdByStructure)(C), g = b.polymer, _ = b.other, g.length ? (A = (0, i.getStructureByElementIds)(C, g), A.elementCount ? [4, s.SecondaryStructureProvider.attach({ runtime: u.SyncRuntimeContext, assetManager: new l.AssetManager() }, A, {
                type: {
                  name: "dssp",
                  params: { oldDefinition: !0, oldOrdering: !0 }
                }
              })] : [3, 2]) : [3, 4]);
            case 1:
              w.sent(), w.label = 2;
            case 2:
              return M = o.CartoonRepresentationProvider.factory(m, o.CartoonRepresentationProvider.getParams), M.setTheme({
                color: m.colorThemeRegistry.create("uniform", {
                  structure: A
                }, { value: (0, f.Color)(14474728) }),
                size: m.sizeThemeRegistry.create("uniform", {
                  structure: A
                })
              }), [4, M.createOrUpdate((0, e.__assign)((0, e.__assign)({}, o.CartoonRepresentationProvider.defaultValues), { quality: "auto" }), A).run()];
            case 3:
              w.sent(), S.push({
                state: M,
                type: r.RepresentationType.Ribbon
              }), w.label = 4;
            case 4:
              return _.length ? (P = (0, i.getStructureByElementIds)(C, _), T = a.BallAndStickRepresentationProvider.factory(m, a.BallAndStickRepresentationProvider.getParams), T.setTheme({
                color: m.colorThemeRegistry.create("element-symbol", {
                  structure: P
                }, {
                  carbonColor: {
                    name: "uniform",
                    params: {
                      value: (0, f.Color)(14474728)
                      // value: Color(0x48e533),
                    }
                  }
                }),
                size: m.sizeThemeRegistry.create("physical", {
                  structure: P
                })
              }), [4, T.createOrUpdate((0, e.__assign)((0, e.__assign)({}, a.BallAndStickRepresentationProvider.defaultValues), { quality: "auto" }), P).run()]) : [3, 6];
            case 5:
              w.sent(), S.push({
                state: T,
                type: r.RepresentationType.BallAndStick
              }), w.label = 6;
            case 6:
              return [3, 9];
            case 7:
              return x = a.BallAndStickRepresentationProvider.factory(m, a.BallAndStickRepresentationProvider.getParams), x.setTheme({
                color: m.colorThemeRegistry.create("material-element-symbol", {
                  structure: C
                }),
                size: m.sizeThemeRegistry.create("physical", {
                  structure: C
                })
              }), [4, x.createOrUpdate((0, e.__assign)((0, e.__assign)({}, a.BallAndStickRepresentationProvider.defaultValues), { quality: "auto" }), C).run()];
            case 8:
              w.sent(), S.push({
                state: x,
                type: r.RepresentationType.BallAndStick
              }), w.label = 9;
            case 9:
              return [2, {
                model: y,
                reprs: S
              }];
          }
        });
      });
    },
    create: function(d, m) {
      return (0, e.__awaiter)(this, void 0, void 0, function() {
        var p, v, h, y, C, S, b, g, _, A, M, P, T, x, w;
        return (0, e.__generator)(this, function(E) {
          switch (E.label) {
            case 0:
              return p = d.model, v = d.coordinates, h = d.frameIndex, y = d.mode, C = t.Model.trajectoryFromModelAndCoordinates(p, v), S = n.Structure.ofModel(C.getFrameAtIndex(h)), b = [], y !== r.VisualizationMode.Drug ? [3, 7] : (g = (0, i.getProteinAndOthersElementIdByStructure)(S), _ = g.polymer, A = g.other, _.length ? (M = (0, i.getStructureByElementIds)(S, _), M.elementCount ? [4, s.SecondaryStructureProvider.attach({ runtime: u.SyncRuntimeContext, assetManager: new l.AssetManager() }, M, {
                type: {
                  name: "dssp",
                  params: { oldDefinition: !0, oldOrdering: !0 }
                }
              })] : [3, 2]) : [3, 4]);
            case 1:
              E.sent(), E.label = 2;
            case 2:
              return P = o.CartoonRepresentationProvider.factory(m, o.CartoonRepresentationProvider.getParams), P.setTheme({
                color: m.colorThemeRegistry.create("uniform", {
                  structure: M
                }, { value: (0, f.Color)(14474728) }),
                size: m.sizeThemeRegistry.create("uniform", {
                  structure: M
                })
              }), [4, P.createOrUpdate((0, e.__assign)((0, e.__assign)({}, o.CartoonRepresentationProvider.defaultValues), { quality: "auto" }), M).run()];
            case 3:
              E.sent(), b.push({
                state: P,
                type: r.RepresentationType.Ribbon
              }), E.label = 4;
            case 4:
              return A.length ? (T = (0, i.getStructureByElementIds)(S, A), x = a.BallAndStickRepresentationProvider.factory(m, a.BallAndStickRepresentationProvider.getParams), x.setTheme({
                color: m.colorThemeRegistry.create("element-symbol", {
                  structure: T
                }, {
                  carbonColor: {
                    name: "uniform",
                    params: {
                      value: (0, f.Color)(14474728)
                      // value: Color(0x48e533),
                    }
                  }
                }),
                size: m.sizeThemeRegistry.create("physical", {
                  structure: T
                })
              }), [4, x.createOrUpdate((0, e.__assign)((0, e.__assign)({}, a.BallAndStickRepresentationProvider.defaultValues), { quality: "auto" }), T).run()]) : [3, 6];
            case 5:
              E.sent(), b.push({
                state: x,
                type: r.RepresentationType.BallAndStick
              }), E.label = 6;
            case 6:
              return [3, 9];
            case 7:
              return w = a.BallAndStickRepresentationProvider.factory(m, a.BallAndStickRepresentationProvider.getParams), w.setTheme({
                color: m.colorThemeRegistry.create("material-element-symbol", {
                  structure: S
                }),
                size: m.sizeThemeRegistry.create("physical", {
                  structure: S
                })
              }), [4, w.createOrUpdate((0, e.__assign)((0, e.__assign)({}, a.BallAndStickRepresentationProvider.defaultValues), { quality: "auto" }), S).run()];
            case 8:
              E.sent(), b.push({
                state: w,
                type: r.RepresentationType.BallAndStick
              }), E.label = 9;
            case 9:
              return [2, {
                model: C,
                reprs: b
              }];
          }
        });
      });
    },
    update: function(d, m, p) {
      return (0, e.__awaiter)(this, void 0, void 0, function() {
        var v, h, y, C;
        return (0, e.__generator)(this, function(S) {
          switch (S.label) {
            case 0:
              return v = m.trajectory, h = m.frameIndex, y = m.mode, C = n.Structure.ofModel(v.getFrameAtIndex(h)), C.elementCount ? [4, s.SecondaryStructureProvider.attach({ runtime: u.SyncRuntimeContext, assetManager: new l.AssetManager() }, C, {
                type: {
                  name: "dssp",
                  params: { oldDefinition: !0, oldOrdering: !0 }
                }
              })] : [3, 2];
            case 1:
              S.sent(), S.label = 2;
            case 2:
              return [4, Promise.all(d.map(function(b) {
                var g = Object.keys(r.ReprCBasedTheme).find(function(M) {
                  return r.ReprCBasedTheme[M].includes(b.type);
                }), _ = c.Loci.toExpression(n.Structure.toStructureElementLoci(b.getLoci().structure)), A = (0, i.getStructureByStructureQuery)((0, i.getStructureQuery)(C, _));
                b.setTheme({
                  color: p.colorThemeRegistry.create(y === r.VisualizationMode.Drug ? g === r.ThemeC.RIBBON ? "uniform" : "element-symbol" : "material-element-symbol", {
                    structure: A
                  }, y === r.VisualizationMode.Drug ? g === r.ThemeC.RIBBON ? { value: (0, f.Color)(14474728) } : {
                    carbonColor: {
                      name: "uniform",
                      params: {
                        value: (0, f.Color)(14474728)
                        // value: Color(0x48e533),
                      }
                    }
                  } : {}),
                  size: p.sizeThemeRegistry.create(g === r.ThemeC.RIBBON ? "uniform" : "physical", {
                    structure: A
                  }, b.theme.size.props)
                }), b.createOrUpdate({}, A).run();
              }))];
            case 3:
              return S.sent(), [
                2
                /*return*/
              ];
          }
        });
      });
    }
  }, T1;
}
var eR;
function T4e() {
  if (eR) return x1;
  eR = 1, Object.defineProperty(x1, "__esModule", { value: !0 }), x1.TrajectoryManager = void 0;
  var e = Te, r = sn(), t = Jt, n = qp(), a = x4e(), i = Je(), o = Ti, c = $p(), s = ky, u = Ly, l = A0, f = (
    /** @class */
    function() {
      function d(m) {
        this.ev = o.RxEventHelper.create(), this.updated = this.ev(), this.plugin = m, this.paused = !1;
      }
      return d.prototype.import = function(m, p) {
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var v, h, y, C, S, b;
          return (0, e.__generator)(this, function(g) {
            switch (g.label) {
              case 0:
                return [4, (0, r.readAsString)(m.data)];
              case 1:
                return v = g.sent(), [4, n.FormatProvider[m.format].parse(v)];
              case 2:
                return h = g.sent(), [4, (0, r.readAsBlob)(p.data)];
              case 3:
                return y = g.sent(), [4, n.FormatProvider[p.format].parse(y)];
              case 4:
                return C = g.sent(), [4, a.TrajectoryRepr.create({
                  model: m.format === t.Format.Gro ? h : h[0].model,
                  coordinates: C,
                  frameIndex: 0,
                  mode: this.plugin.mode
                }, this.plugin.managers.representation.ctx)];
              case 5:
                return S = g.sent(), b = (0, r.getElementIdsByLoci)(i.Structure.toStructureElementLoci(m.format === t.Format.Gro ? i.Structure.ofModel(S.model.frames[0], { dynamicBonds: !0 }) : h[0])), [2, this.plugin.managers.cell.create({
                  representations: S.reprs.map(function(_) {
                    return (0, e.__assign)({ isHidden: !1 }, _);
                  }),
                  model: {
                    trajectory: {
                      state: S.model,
                      frameIndex: 0
                    }
                  },
                  assets: [
                    { data: v, format: m.format },
                    { data: y, format: p.format }
                  ],
                  theme: {
                    color: {
                      Atom: [
                        (0, e.__assign)({ elementIds: b }, this.plugin.managers.representation.defaultTheme.color[t.ThemeC.ATOM])
                      ],
                      Ribbon: [
                        (0, e.__assign)({ elementIds: b }, this.plugin.managers.representation.defaultTheme.color[t.ThemeC.RIBBON])
                      ]
                    }
                  }
                })];
            }
          });
        });
      }, d.prototype.importWithGro = function(m) {
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var p, v, h;
          return (0, e.__generator)(this, function(y) {
            switch (y.label) {
              case 0:
                return [4, (0, r.readAsString)(m.data)];
              case 1:
                return p = y.sent(), [4, s.GroTrajModel.parse(p)];
              case 2:
                return v = y.sent(), [4, a.TrajectoryRepr.createByTrajectory({ trajectory: v, frameIndex: 0, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)];
              case 3:
                return h = y.sent(), [2, this.plugin.managers.cell.create({
                  representations: h.reprs.map(function(C) {
                    return (0, e.__assign)({ isHidden: !1 }, C);
                  }),
                  model: {
                    trajectory: {
                      state: h.model,
                      frameIndex: 0
                    }
                  },
                  assets: [
                    { data: p, format: m.format }
                  ]
                })];
            }
          });
        });
      }, d.prototype.importTrajectory = function(m) {
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var p, v, h, y, C;
          return (0, e.__generator)(this, function(S) {
            switch (S.label) {
              case 0:
                return u.TrajectoryFormatProvider[m.format] ? (p = typeof m.data == "string" || m.data instanceof File, p ? [4, (0, r.readAsString)(m.data)] : [3, 2]) : [
                  2
                  /*return*/
                ];
              case 1:
                return h = S.sent(), [3, 3];
              case 2:
                h = m.data, S.label = 3;
              case 3:
                return v = h, [4, u.TrajectoryFormatProvider[m.format].parse(v)];
              case 4:
                return y = S.sent(), [4, a.TrajectoryRepr.createByTrajectory({ trajectory: y, frameIndex: 0, mode: this.plugin.mode }, this.plugin.managers.representation.ctx)];
              case 5:
                return C = S.sent(), [2, this.plugin.managers.cell.create({
                  representations: C.reprs.map(function(b) {
                    return (0, e.__assign)({ isHidden: !1 }, b);
                  }),
                  model: {
                    trajectory: {
                      state: C.model,
                      frameIndex: 0
                    }
                  },
                  assets: [
                    { data: v, format: m.format }
                  ]
                })];
            }
          });
        });
      }, d.prototype.getTrajectoryCell = function(m) {
        var p = [];
        if (m) {
          var v = this.plugin.cells.get(m);
          if (!(v != null && v.model.trajectory))
            return [];
          p.push(v);
        } else
          this.plugin.cells.forEach(function(h) {
            h.model.trajectory && p.push(h);
          });
        return p;
      }, d.prototype.play = function(m) {
        var p = this;
        this.paused = !1;
        var v = function() {
          p.next(m), p.paused || window.requestAnimationFrame(v);
        };
        window.requestAnimationFrame(v);
      }, d.prototype.next = function(m) {
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var p, v, h, y, C, S, b, g;
          return (0, e.__generator)(this, function(_) {
            switch (_.label) {
              case 0:
                p = this.getTrajectoryCell(m), v = 0, h = p, _.label = 1;
              case 1:
                return v < h.length ? (y = h[v], C = y.model.trajectory, S = C.state, b = C.frameIndex, g = b >= S.frameCount - 1 ? 0 : b + 1, [4, a.TrajectoryRepr.update(
                  // Repr State Cache
                  Array.from(y.representations).map(function(A) {
                    A[0];
                    var M = A[1];
                    return M.state;
                  }),
                  {
                    trajectory: S,
                    frameIndex: g,
                    mode: this.plugin.mode
                  },
                  this.plugin.managers.representation.ctx
                )]) : [3, 4];
              case 2:
                _.sent(), y.model.trajectory.frameIndex = g, this.updateDependencyByCells(m), m && this.updated.next({ ref: m, frame: g }), _.label = 3;
              case 3:
                return v++, [3, 1];
              case 4:
                return [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, d.prototype.setFrameIndex = function(m, p) {
        var v;
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var h, y, C, S;
          return (0, e.__generator)(this, function(b) {
            switch (b.label) {
              case 0:
                h = this.getTrajectoryCell(p), y = 0, C = h, b.label = 1;
              case 1:
                return y < C.length ? (S = C[y], [4, a.TrajectoryRepr.update(
                  // Repr State Cache
                  Array.from(S.representations).map(function(g) {
                    g[0];
                    var _ = g[1];
                    return _.state;
                  }),
                  {
                    trajectory: (v = S.model.trajectory) === null || v === void 0 ? void 0 : v.state,
                    frameIndex: m,
                    mode: this.plugin.mode
                  },
                  this.plugin.managers.representation.ctx
                )]) : [3, 4];
              case 2:
                b.sent(), S.model.trajectory.frameIndex = m, b.label = 3;
              case 3:
                return y++, [3, 1];
              case 4:
                return [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, d.prototype.updateDependencyByCells = function(m) {
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var p, v, h, y, C, S, b, g, _, A = this;
          return (0, e.__generator)(this, function(M) {
            for (p = this.getTrajectoryCell(m), v = 0, h = p; v < h.length; v++)
              if (y = h[v], y.dependency.by.length)
                for (C = function(P) {
                  var T = S.plugin.cells.get(P);
                  T && T.representations.forEach(function(x, w) {
                    w === t.RepresentationType.IntraInteractions && A.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.trajectory.updateDependencyByCells"), Object.keys(c.MeasurementRepresentation).includes(w) && A.plugin.managers.representation.updateMeasurement({
                      items: T.dependency.on,
                      ref: P
                    });
                  });
                }, S = this, b = 0, g = y.dependency.by; b < g.length; b++)
                  _ = g[b], C(_);
            return [
              2
              /*return*/
            ];
          });
        });
      }, d.prototype.mergeDumpAndPymatgen = function(m, p) {
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var v, h, y;
          return (0, e.__generator)(this, function(C) {
            switch (C.label) {
              case 0:
                return v = this.getTrajectoryCell(p), !v.length || v[0].assets[0].format !== t.Format.Dump ? [
                  2
                  /*return*/
                ] : (h = v[0], [4, (0, l.getTrajByPymatgen)(h.assets[0].data, m)]);
              case 1:
                return y = C.sent(), h.model.trajectory = {
                  state: y,
                  frameIndex: h.model.trajectory.frameIndex
                }, [4, a.TrajectoryRepr.update(Array.from(h.representations).map(function(S) {
                  S[0];
                  var b = S[1];
                  return b.state;
                }), {
                  trajectory: y,
                  frameIndex: h.model.trajectory.frameIndex,
                  mode: this.plugin.mode
                }, this.plugin.managers.representation.ctx)];
              case 2:
                return C.sent(), h.model.trajectory.frameIndex = h.model.trajectory.frameIndex, this.updateDependencyByCells(p), [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, d.prototype.pause = function() {
        this.paused = !0;
      }, d;
    }()
  );
  return x1.TrajectoryManager = f, x1;
}
var P1 = {}, Uy = {};
Object.defineProperty(Uy, "__esModule", { value: !0 });
Uy.download = void 0;
function P4e(e) {
  var r = window.open(e, "_blank");
  r || (window.location.href = e);
}
function rR(e) {
  try {
    e.dispatchEvent(new MouseEvent("click"));
  } catch {
    var r = document.createEvent("MouseEvents");
    r.initMouseEvent("click", !0, !0, window, 0, 0, 0, 80, 20, !1, !1, !1, !1, 0, null), e.dispatchEvent(r);
  }
}
function M4e(e, r) {
  if (r === void 0 && (r = "download"), !!e)
    if ("download" in HTMLAnchorElement.prototype) {
      var t = document.createElement("a");
      t.download = r, t.rel = "noopener", typeof e == "string" ? (t.href = e, rR(t)) : (t.href = URL.createObjectURL(e), setTimeout(function() {
        return URL.revokeObjectURL(t.href);
      }, 4e4), setTimeout(function() {
        return rR(t);
      }));
    } else if (typeof navigator < "u" && navigator.msSaveOrOpenBlob)
      navigator.msSaveOrOpenBlob(e, r);
    else {
      var n = window.navigator.userAgent, a = /Safari/i.test(n), i = /CriOS\/[\d]+/.test(n), o = function(u) {
        P4e(i ? u : u.replace(/^data:[^;]*;/, "data:attachment/file;"));
      };
      if ((a || i) && FileReader)
        if (e instanceof Blob) {
          var c = new FileReader();
          c.onloadend = function() {
            return o(c.result);
          }, c.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);
      }
    }
}
Uy.download = M4e;
var tR;
function w4e() {
  if (tR) return P1;
  tR = 1, Object.defineProperty(P1, "__esModule", { value: !0 }), P1.SnapshotManager = void 0;
  var e = Te, r = ef(), t = Jt, n = nn, a = sn(), i = Uy, o = Ti, c = qp(), s = Ac(), u = O0(), l = (
    /** @class */
    function() {
      function f(d) {
        this.ev = o.RxEventHelper.create(), this.event = {
          changed: this.ev()
        }, this.plugin = d;
      }
      return f.prototype.setSnapshot = function(d, m) {
        var p, v, h, y, C;
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var S, b, g, T, _, A, M, P, T;
          return (0, e.__generator)(this, function(x) {
            switch (x.label) {
              case 0:
                for (S = /* @__PURE__ */ new Map(), ((p = d == null ? void 0 : d.params) === null || p === void 0 ? void 0 : p.showPolarHydrogenOnly) !== void 0 && (this.plugin.managers.representation.showPolarHydrogenOnly = d.params.showPolarHydrogenOnly), ((v = d == null ? void 0 : d.params) === null || v === void 0 ? void 0 : v.interactionParams) !== void 0 && (this.plugin.managers.representation.interactionParams = d.params.interactionParams), b = 0, g = d.cells; b < g.length; b++)
                  T = g[b], S.set(T.ref, {
                    ref: T.ref,
                    assets: T.assets,
                    dependency: T.dependency,
                    model: {},
                    representations: /* @__PURE__ */ new Map(),
                    theme: T.theme
                  });
                this.plugin.cells = S, _ = function(w) {
                  var E, I, B, D, N, O, V, k, G, L, R, F, U, H, q, K, Y, X, X, Z, J, $, Q;
                  return (0, e.__generator)(this, function(W) {
                    switch (W.label) {
                      case 0:
                        return E = w.model, I = E.structure, E.trajectory, B = E.other, D = w.representations, N = w.dependency, O = w.theme, V = void 0, I ? D != null && D.some(function(te) {
                          return te.isHidden !== !0;
                        }) ? (k = typeof I.data == "string" || I.data instanceof File, R = (L = c.FormatProvider[I.format]).parse, k ? [4, (0, a.readAsString)(I.data)] : [3, 2]) : [3, 7] : [3, 8];
                      case 1:
                        return F = W.sent(), [3, 3];
                      case 2:
                        F = I.data, W.label = 3;
                      case 3:
                        return [4, R.apply(L, [F])];
                      case 4:
                        return G = W.sent(), I.format === t.Format.Pdb && G[0].elementCount && !u.Model.hasSecondaryStructure((h = G[0]) === null || h === void 0 ? void 0 : h.model) ? [4, s.SecondaryStructureProvider.attach({}, G[0], {
                          type: {
                            name: "dssp",
                            params: { oldDefinition: !0, oldOrdering: !0 }
                          }
                        }, !0)] : [3, 6];
                      case 5:
                        W.sent(), W.label = 6;
                      case 6:
                        return V = G[0], A.plugin.managers.cell.update(w.ref, {
                          representations: [],
                          model: {
                            structure: G[0]
                          },
                          assets: [{ format: I.format, data: I.data }]
                        }), [3, 8];
                      case 7:
                        A.plugin.managers.cell.update(w.ref, {
                          representations: [],
                          model: {
                            structure: void 0
                          },
                          assets: [{ format: I.format, data: I.data }]
                        }), W.label = 8;
                      case 8:
                        return U = w.theme, O && (H = {}, Object.keys(O).forEach(function(te) {
                          var oe = O[te];
                          if (oe) {
                            var z = {};
                            Object.keys(oe).forEach(function(j) {
                              var ae = oe[j], le = [];
                              ae != null && ae.length && ae.forEach(function(ie) {
                                le.push((0, e.__assign)((0, e.__assign)({}, ie), { elementIds: ie.elementIds ? (0, a.uncompressElementIds)(ie.elementIds) : ie.elementIds }));
                              }), z[j] = le;
                            }), H[te] = z;
                          }
                        }), U = H, A.plugin.managers.cell.update(w.ref, {
                          representations: [],
                          model: {},
                          theme: H
                        })), D != null && D.length ? V ? [3, 9] : (A.plugin.managers.cell.update(w.ref, {
                          representations: D == null ? void 0 : D.map(function(te) {
                            var oe;
                            return te.cache ? te : (0, e.__assign)((0, e.__assign)({}, te), { elementIds: [], cache: (0, e.__assign)((0, e.__assign)({}, te), { elementIds: !((oe = te.elementIds) === null || oe === void 0) && oe.length ? (0, a.uncompressElementIds)(te.elementIds) : te.elementIds }) });
                          }),
                          model: {}
                        }), [3, 13]) : [3, 13];
                      case 9:
                        q = function(te) {
                          var oe, z, j, ae;
                          return (0, e.__generator)(this, function(le) {
                            switch (le.label) {
                              case 0:
                                return !((y = te.elementIds) === null || y === void 0) && y.length ? (oe = Object.keys(t.ReprCBasedTheme).find(function(ie) {
                                  return t.ReprCBasedTheme[ie].includes(te.type);
                                }), z = U.color[oe], j = U.transparency ? U.transparency[oe] : void 0, ae = te.elementIds ? (0, a.uncompressElementIds)(te.elementIds) : [], [4, A.plugin.managers.representation.addMolecularRepr(w.ref, {
                                  reprType: te.type,
                                  elementIds: ae,
                                  isHidden: te.isHidden,
                                  theme: A.plugin.managers.representation.createTheme(te.type, (0, a.getStructureByElementIds)(V, ae, !0), {
                                    color: {
                                      name: "multi-theme",
                                      props: { themes: z }
                                    },
                                    size: U.size && (!((C = U.size[oe]) === null || C === void 0) && C.length) ? U.size[oe][0] : A.plugin.managers.representation.defaultTheme.size[te.type]
                                  }),
                                  transparency: j
                                })]) : [3, 2];
                              case 1:
                                le.sent(), le.label = 2;
                              case 2:
                                return [
                                  2
                                  /*return*/
                                ];
                            }
                          });
                        }, K = 0, Y = D, W.label = 10;
                      case 10:
                        return K < Y.length ? (X = Y[K], [5, q(X)]) : [3, 13];
                      case 11:
                        W.sent(), W.label = 12;
                      case 12:
                        return K++, [3, 10];
                      case 13:
                        return B ? (X = D[0], Z = B.serverData && !B.data, Z && m ? [4, m(B.serverData)] : [3, 15]) : [3, 18];
                      case 14:
                        return $ = W.sent(), [3, 16];
                      case 15:
                        $ = B, W.label = 16;
                      case 16:
                        return J = $, [4, A.plugin.managers.representation.createOther({
                          data: X.type === r.RepresentationType.IsoSurface ? new File([J.data], J.name) : J,
                          serverData: B.serverData,
                          type: X.type,
                          ref: w.ref,
                          isHidden: X.isHidden
                          // TODO other 类型的repr有theme吗
                        })];
                      case 17:
                        W.sent(), W.label = 18;
                      case 18:
                        return N.on.length ? (Q = N.on.map(function(te) {
                          return (0, e.__assign)((0, e.__assign)({}, te), { elementIds: te.elementIds ? (0, a.uncompressElementIds)(te.elementIds) : te.elementIds });
                        }), [4, A.plugin.managers.representation.createMeasurement({
                          items: Q,
                          type: D[0].type,
                          ref: w.ref,
                          props: D[0].params,
                          isHidden: D[0].isHidden
                        })]) : [3, 20];
                      case 19:
                        W.sent(), A.plugin.managers.cell.update(w.ref, {
                          representations: [],
                          model: {},
                          dependency: (0, e.__assign)((0, e.__assign)({}, w.dependency), { on: Q })
                        }), W.label = 20;
                      case 20:
                        return [
                          2
                          /*return*/
                        ];
                    }
                  });
                }, A = this, M = 0, P = d.cells, x.label = 1;
              case 1:
                return M < P.length ? (T = P[M], [5, _(T)]) : [3, 4];
              case 2:
                x.sent(), x.label = 3;
              case 3:
                return M++, [3, 1];
              case 4:
                return this.refresh(), [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, f.prototype.getSnapshot = function(d) {
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var m, p, v = this;
          return (0, e.__generator)(this, function(h) {
            switch (h.label) {
              case 0:
                return this.timestamp = Date.now(), m = [], p = {}, Array.from(this.plugin.cells.values()).map(function(y) {
                  var C = y.model.structure, S = y.ref;
                  if (C) {
                    var b = /* @__PURE__ */ new Map(), g = 0;
                    C.units.forEach(function(_) {
                      _.elements.forEach(function(A) {
                        b.set(A, g++);
                      });
                    }), p[S] = b;
                  }
                }), [4, Promise.all(Array.from(this.plugin.cells.values()).map(function(y) {
                  return (0, e.__awaiter)(v, void 0, void 0, function() {
                    var C, S, b, g, _, A, M, P, T, x, w, E, I, B, D, N, O, V, k, G, L;
                    return (0, e.__generator)(this, function(R) {
                      switch (R.label) {
                        case 0:
                          return C = y.representations, S = y.assets, b = y.model, g = b.structure, _ = b.trajectory, A = b.other, M = (0, e.__rest)(y, ["representations", "assets", "model"]), P = (0, n.deepClone)(M), P.model = {}, C.get(r.RepresentationType.IntraInteractions) || C.get(r.RepresentationType.BetweenInteractions) ? [
                            2
                            /*return*/
                          ] : (g ? P.model.structure = {
                            data: (V = (O = (0, a.getTextFromStructure)(g, S == null ? void 0 : S[0].format)) !== null && O !== void 0 ? O : S == null ? void 0 : S[0].data) !== null && V !== void 0 ? V : (0, a.getModelByStructure)(g).sourceData.data,
                            format: S == null ? void 0 : S[0].format
                          } : S && (P.assets = S), _ && (P.model.trajectory = {
                            data: "提取的结构信息",
                            format: S == null ? void 0 : S[0].format
                          }), A ? C.get(r.RepresentationType.IsoSurface) ? (T = !!y.model.other.serverData, x = T ? y.model.other.data : y.model.other, w = P.model, d ? (E = {
                            serverData: T ? y.model.other.serverData : y.model.other
                          }, [3, 3]) : [3, 1]) : [3, 4] : [3, 5]);
                        case 1:
                          return N = {}, I = Uint8Array.bind, [4, x.arrayBuffer()];
                        case 2:
                          E = (N.data = new (I.apply(Uint8Array, [void 0, R.sent()]))(), N.name = x.name, N.serverData = T ? y.model.other.serverData : y.model.other, N), R.label = 3;
                        case 3:
                          return w.other = E, [3, 5];
                        case 4:
                          P.model.other = y.model.other, R.label = 5;
                        case 5:
                          return C != null && C.size && (P.representations = [], B = p[M.ref], C.forEach(function(F) {
                            P.representations.push({
                              type: F.type,
                              elementIds: F.state ? (0, a.compressElementIds)((0, a.getElementIdsFromRepresentation)(F.state).map(function(U) {
                                return B && (B != null && B.has(U)) ? B == null ? void 0 : B.get(U) : U;
                              })) : [],
                              isHidden: F.isHidden,
                              params: t.MeasurementType.has(F.type) && F.state ? (0, a.getMeasurementProps)(F.type, F.state) : void 0,
                              cache: F.cache
                            });
                          }), M.theme && Object.keys(M.theme).forEach(function(F) {
                            var U = M.theme[F];
                            if (U) {
                              var H = {};
                              Object.keys(U).forEach(function(q) {
                                var K = U[q], Y = [];
                                K != null && K.length && K.forEach(function(X) {
                                  Y.push((0, e.__assign)((0, e.__assign)({}, X), { elementIds: (0, a.compressElementIds)(X.elementIds && B ? X.elementIds.map(function(Z) {
                                    var J;
                                    return (J = B.get(Z)) !== null && J !== void 0 ? J : Z;
                                  }) : X.elementIds) }));
                                }), H[q] = Y;
                              }), P.theme[F] = H;
                            }
                          })), !((G = (k = M.dependency) === null || k === void 0 ? void 0 : k.on) === null || G === void 0) && G.length && (D = [], (L = M.dependency) === null || L === void 0 || L.on.forEach(function(F) {
                            var U = p[M.ref];
                            D.push((0, e.__assign)((0, e.__assign)({}, F), { elementIds: (0, a.compressElementIds)(F.elementIds && U ? F.elementIds.map(function(H) {
                              var q;
                              return (q = U.get(H)) !== null && q !== void 0 ? q : H;
                            }) : F.elementIds) }));
                          }), P.dependency.on = D), m.push(P), [
                            2
                            /*return*/
                          ];
                      }
                    });
                  });
                }))];
              case 1:
                return h.sent(), [2, {
                  cells: m,
                  timestamp: this.timestamp,
                  params: {
                    interactionParams: (0, n.deepClone)(this.plugin.managers.representation.interactionParams),
                    showPolarHydrogenOnly: this.plugin.managers.representation.showPolarHydrogenOnly
                  }
                }];
            }
          });
        });
      }, f.prototype.refresh = function() {
        var d, m, p, v = this.plugin;
        (d = v.canvas3d) === null || d === void 0 || d.pause(!0), (m = v.canvas3d) === null || m === void 0 || m.clear(), v.cells.forEach(function(h) {
          h.representations.forEach(function(y) {
            var C;
            !y.isHidden && y.state && ((C = v.canvas3d) === null || C === void 0 || C.add(y.state));
          });
        }), (p = v.canvas3d) === null || p === void 0 || p.animate();
      }, f.prototype.downloadAsImage = function(d, m) {
        var p, v;
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var h, y, C, S, b, g, _, A, M, P, T, x, w, E, I;
          return (0, e.__generator)(this, function(B) {
            switch (B.label) {
              case 0:
                if (h = m || {
                  width: ((p = this.plugin.canvas3d) === null || p === void 0 ? void 0 : p.webgl.gl.drawingBufferWidth) || 0,
                  height: ((v = this.plugin.canvas3d) === null || v === void 0 ? void 0 : v.webgl.gl.drawingBufferHeight) || 0
                }, y = h.width, C = h.height, S = { x: 0, y: 0, width: 1, height: 1 }, b = {
                  x: Math.floor(S.x * y),
                  y: Math.floor(S.y * C),
                  width: Math.ceil(S.width * y),
                  height: Math.ceil(S.height * C)
                }, b.width + b.x > y && (b.width = y - b.x), b.height + b.y > C && (b.height = C - b.y), y <= 0 || C <= 0)
                  return [
                    2
                    /*return*/
                  ];
                if (g = this.plugin.canvas3d, _ = g.webgl.extensions, A = _.colorBufferFloat, M = _.textureFloat, P = g.props.postprocessing.occlusion, T = g.getImagePass({
                  transparentBackground: !0,
                  cameraHelper: { axes: { name: "off", params: {} } },
                  multiSample: (0, e.__assign)((0, e.__assign)({}, g.props.multiSample), { mode: "on", sampleLevel: A && M ? 4 : 2 }),
                  postprocessing: (0, e.__assign)((0, e.__assign)({}, g.props.postprocessing), { occlusion: P.name === "on" ? {
                    name: "on",
                    params: (0, e.__assign)((0, e.__assign)({}, P.params), { samples: 128, resolutionScale: g.webgl.pixelRatio })
                  } : P }),
                  marking: (0, e.__assign)({}, g.props.marking)
                }), x = T.getImageData(y, C, b), w = document.createElement("canvas"), w.width = x.width, w.height = x.height, E = w.getContext("2d"), !E)
                  throw new Error("Could not create canvas 2d context");
                return E.putImageData(x, 0, 0), [4, (0, a.canvasToBlob)(w, "png")];
              case 1:
                return I = B.sent(), (0, i.download)(I, d), [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, f;
    }()
  );
  return P1.SnapshotManager = l, P1;
}
var M1 = {}, ZA = {};
Object.defineProperty(ZA, "__esModule", { value: !0 });
ZA.ShapeSelectionManager = void 0;
var bP = _n, E4e = Ti, Km = Jt, D4e = {
  Dihedral: Km.RepresentationType.Dihedral,
  Distance: Km.RepresentationType.Distance,
  Angle: Km.RepresentationType.Angle,
  Label: Km.RepresentationType.Label,
  "Molecular Surface": Km.RepresentationType.Surface
}, I4e = (
  /** @class */
  function() {
    function e(r) {
      var t = this;
      this.ev = E4e.RxEventHelper.create(), this.prev = /* @__PURE__ */ new Map(), this.event = {
        change: this.ev(),
        add: this.ev(),
        remove: this.ev(),
        clear: this.ev()
      }, this.plugin = r, this.selection = /* @__PURE__ */ new Set(), this.event.change.subscribe(function(n) {
        var a = n.current, i = a.repr, o = a.loci;
        if (o.kind === "empty-loci") {
          t.clear();
          return;
        }
        var c = D4e[i.label];
        c === Km.RepresentationType.Surface && (n.current.loci = n.current.repr.getLoci()), r.cells.forEach(function(s) {
          var u;
          s.representations.has(c) && ((u = s.representations.get(c)) === null || u === void 0 ? void 0 : u.state) === i && (t.selection.has(s.ref) ? n.button !== 2 && t.remove({ item: { ref: s.ref }, loci: n.current }) : t.add({ item: { ref: s.ref }, loci: n.current }));
        });
      });
    }
    return e.prototype.add = function(r) {
      var t, n, a = r.item.ref;
      this.selection.add(a);
      var i = this.plugin.cells.get(a);
      if (i) {
        var o = Array.from(i.representations.values())[0];
        if (!(!(r != null && r.loci) && !o.state)) {
          var c = (t = r.loci) !== null && t !== void 0 ? t : { repr: o.state, loci: o.state.getLoci() };
          (n = this.plugin.canvas3d) === null || n === void 0 || n.mark(c, bP.MarkerAction.Select), this.event.add.next({ ref: a, loci: c }), this.prev.set(a, c), this.plugin.managers.selection.event.changed.next({});
        }
      }
    }, e.prototype.remove = function(r) {
      var t, n, a = r.item.ref;
      this.selection.delete(a);
      var i = this.plugin.cells.get(a);
      if (i) {
        var o = Array.from(i.representations.values())[0];
        if (o.state) {
          var c = (t = r.loci) !== null && t !== void 0 ? t : { repr: o.state, loci: o.state.getLoci() };
          (n = this.plugin.canvas3d) === null || n === void 0 || n.mark(c, bP.MarkerAction.Deselect), this.event.remove.next({ ref: a, loci: c }), this.prev.delete(a), this.plugin.managers.selection.event.changed.next({});
        }
      }
    }, e.prototype.clear = function() {
      var r = this;
      this.selection.clear(), this.prev.forEach(function(t) {
        var n;
        (n = r.plugin.canvas3d) === null || n === void 0 || n.mark(t, bP.MarkerAction.Deselect);
      }), this.prev.clear(), this.event.clear.next({}), this.plugin.managers.selection.event.changed.next({});
    }, e;
  }()
);
ZA.ShapeSelectionManager = I4e;
var w1 = {}, nR;
function B4e() {
  if (nR) return w1;
  nR = 1, Object.defineProperty(w1, "__esModule", { value: !0 }), w1.StructureSelectionManager = void 0;
  var e = Te, r = _n, t = Ti, n = ef(), a = Jt, i = sn(), o = _r, c = eu(), s = gs, u = Je(), l = (
    /** @class */
    function() {
      function f(d) {
        var m = this;
        this.ev = t.RxEventHelper.create(), this.lociGranularity = "residue", this.prev = [], this.event = {
          change: this.ev(),
          add: this.ev(),
          remove: this.ev(),
          clear: this.ev()
        }, this.plugin = d, this.selection = /* @__PURE__ */ new Map(), this.event.change.subscribe(function(p) {
          if (p.current.loci.kind === "element-loci" && m.plugin.cells.forEach(function(C, S) {
            var b;
            if (C != null && C.model.structure && (0, i.getStructureUniqueId)(C == null ? void 0 : C.model.structure) === (0, i.getStructureUniqueId)(p.current.loci.structure) || C.model.trajectory && (C == null ? void 0 : C.model.trajectory.state.getFrameAtIndex(C.model.trajectory.frameIndex).id) === (0, i.getStructureUniqueId)(p.current.loci.structure)) {
              var g = (0, i.getStructureByCell)(C);
              p.current.loci = o.Loci.normalize((0, i.getLoci)(g, (0, i.getElementIdsByLoci)(p.current.loci)), m.lociGranularity, !0);
              var _ = (0, i.getElementIdsByLoci)(p.current.loci), A = new Set((b = m.selection.get(S)) !== null && b !== void 0 ? b : []), M = A.size ? _.filter(function(P) {
                return !A.has(P);
              }) : _;
              p.button !== 2 && M.length === 0 ? m.remove({ item: { ref: S, elementIds: _ }, reprLoci: p.current }) : m.add({
                item: { ref: S, elementIds: M },
                reprLoci: p.current
              });
            }
          }), p.current.loci.kind === "bond-loci") {
            var v = p.current.loci;
            p.current.loci = o.Loci.normalize(p.current.loci, m.lociGranularity, !0);
            var h = /* @__PURE__ */ new Set();
            v.bonds.forEach(function(C) {
              h.add(C.aUnit.elements[C.aIndex]), h.add(C.bUnit.elements[C.bIndex]);
            });
            var y = (0, i.getElementIdsByLoci)(p.current.loci);
            m.plugin.cells.forEach(function(C, S) {
              var b;
              if (C != null && C.model.structure && (0, i.getStructureUniqueId)(C == null ? void 0 : C.model.structure) === (0, i.getStructureUniqueId)(v.bonds[0].aStructure)) {
                var g = new Set((b = m.selection.get(S)) !== null && b !== void 0 ? b : []), _ = g.size ? y.filter(function(A) {
                  return !g.has(A);
                }) : y;
                p.button !== 2 && _.length === 0 ? m.remove({ item: { ref: S, elementIds: y }, reprLoci: p.current }) : m.add({
                  item: { ref: S, elementIds: _ },
                  reprLoci: p.current
                });
              }
            });
          }
          p.current.loci.kind === "empty-loci" && m.clear();
        });
      }
      return Object.defineProperty(f.prototype, "granularity", {
        get: function() {
          return n.LociGranularityToGranularity[this.lociGranularity];
        },
        enumerable: !1,
        configurable: !0
      }), f.prototype.getSelectionCellItems = function(d) {
        d === void 0 && (d = !1);
        var m = Array.from(this.selection).map(function(p) {
          var v = p[0], h = p[1];
          return {
            ref: v,
            elementIds: h
          };
        }).filter(function(p) {
          var v;
          return (v = p.elementIds) === null || v === void 0 ? void 0 : v.length;
        });
        return d && !m.length ? (0, i.getGlobalCellItems)(this.plugin) : m;
      }, f.prototype.getSelection = function() {
        return Array.from(this.selection).reduce(function(d, m) {
          var p;
          return (0, e.__assign)((0, e.__assign)({}, d), (p = {}, p[m[0]] = m[1], p));
        }, {});
      }, f.prototype.add = function(d, m, p) {
        var v = this, h, y;
        m === void 0 && (m = !0), p === void 0 && (p = !1);
        var C = d.item, S = C.ref, b = C.elementIds;
        if (b && !b.length) {
          console.warn("add selection, elementIds is empty");
          return;
        }
        this.selection.set(S, Array.from(new Set((0, e.__spreadArray)((0, e.__spreadArray)([], (h = this.selection.get(S)) !== null && h !== void 0 ? h : [], !0), b ?? [], !0))));
        var g = this.plugin.cells.get(S);
        if (g) {
          var _ = (0, i.getStructureByCell)(g);
          if (_) {
            var A = this.selection.get(S), M;
            g == null || g.representations.forEach(function(P) {
              var T;
              if (!(P.isHidden || !P.state)) {
                var x = m ? o.Loci.normalize(c.Loci.intersect((0, i.getLoci)((0, i.getStructureFromRepresentation)(P.state), A), (0, i.transformLociToElementLoci)(P.state.getLoci())), v.lociGranularity, !0) : c.Loci.intersect((0, i.getLoci)((0, i.getStructureFromRepresentation)(P.state), A), (0, i.transformLociToElementLoci)(P.state.getLoci()));
                M = {
                  loci: x,
                  repr: P.state
                }, (T = v.plugin.canvas3d) === null || T === void 0 || T.mark(M, r.MarkerAction.Select);
              }
            }), this.prev.push({ ref: S, elementIds: b }), p || (this.event.add.next({
              loci: (y = d.reprLoci) !== null && y !== void 0 ? y : { loci: (0, i.getLoci)(_, A) },
              item: d.item
            }), this.plugin.managers.selection.event.changed.next({}));
          }
        }
      }, f.prototype.remove = function(d, m, p) {
        var v = this, h;
        m === void 0 && (m = !0), p === void 0 && (p = !1);
        var y = d.item, C = y.ref, S = y.elementIds;
        if (S && !S.length) {
          console.warn("remove selection, elementIds is empty");
          return;
        }
        if (this.selection.has(C)) {
          var b = /* @__PURE__ */ new Set(), g = [], _ = new Set(S);
          this.selection.get(C).forEach(function(x) {
            if (!_.has(x)) {
              g.push(x);
              return;
            }
            b.add(x);
          }), g.length ? this.selection.set(C, g) : this.selection.delete(C);
          var A = this.plugin.cells.get(C), M = (h = this.selection.get(C)) !== null && h !== void 0 ? h : [], P;
          A == null || A.representations.forEach(function(x) {
            var w, E;
            if (!(x.isHidden || !x.state)) {
              var I = m ? o.Loci.normalize(c.Loci.intersect((0, i.getLoci)((0, i.getStructureFromRepresentation)(x.state), M), (0, i.transformLociToElementLoci)(x.state.getLoci())), v.lociGranularity, !0) : c.Loci.intersect((0, i.getLoci)((0, i.getStructureFromRepresentation)(x.state), M), (0, i.transformLociToElementLoci)(x.state.getLoci()));
              (w = v.plugin.canvas3d) === null || w === void 0 || w.mark({
                loci: (0, i.transformLociToElementLoci)(x.state.getLoci()),
                repr: x.state
              }, r.MarkerAction.Deselect), P = {
                loci: I,
                repr: x.state
              }, (E = v.plugin.canvas3d) === null || E === void 0 || E.mark(P, r.MarkerAction.Select);
            }
          });
          var T = [];
          this.prev.forEach(function(x) {
            var w = x.ref, E = x.elementIds;
            if (w === C) {
              var I = [];
              E == null || E.forEach(function(B) {
                b.has(B) || I.push(B);
              }), I.length && T.push({
                ref: w,
                elementIds: I
              });
            }
          }), this.prev = T, p || (this.event.remove.next({ loci: P, item: d.item }), this.plugin.managers.selection.event.changed.next({}));
        }
      }, f.prototype.clear = function() {
        var d = this;
        Array.from(this.selection.keys()).forEach(function(m) {
          var p = d.plugin.cells.get(m);
          p && (p == null || p.representations.forEach(function(v) {
            var h;
            v.isHidden || !v.state || (h = d.plugin.canvas3d) === null || h === void 0 || h.mark({
              loci: (0, i.transformLociToElementLoci)(v.state.getLoci()),
              repr: v.state
            }, r.MarkerAction.Deselect);
          }));
        }), this.selection.clear(), this.prev = [], this.event.clear.next({}), this.plugin.managers.selection.event.changed.next({});
      }, f.prototype.setGranularity = function(d) {
        this.lociGranularity = a.GranularityToLociGranularity[d];
      }, f.prototype.expand = function(d, m) {
        var p = this, v = m ?? this.getSelectionCellItems(), h = this.plugin.managers.cell.getAllDisplayedCellsRef(), y = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), S = (0, i.getMergedStructure)(h.map(function(B) {
          return { ref: B };
        }), this.plugin), b = S.unitsMap, g = S.structure;
        b.forEach(function(B, D) {
          y.set(h[D], B.map(function(N) {
            return g.unitMap.get(N);
          })), B.forEach(function(N) {
            return C.set(N, h[D]);
          });
        });
        var _ = (0, i.flattenDeep)(v.map(function(B) {
          var D, N = y.get(B.ref), O = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Map();
          N.forEach(function(G, L) {
            O.set(L, new Set(G.elements)), V.set(L, []);
          }), (D = B.elementIds) === null || D === void 0 || D.forEach(function(G) {
            O.forEach(function(L, R) {
              var F;
              L.has(G) && ((F = V.get(R)) === null || F === void 0 || F.push(N[R].elements.indexOf(G)));
            });
          });
          var k = Array.from(V.entries()).filter(function(G) {
            G[0];
            var L = G[1];
            return L.length;
          }).map(function(G) {
            var L = G[0], R = G[1];
            return { unit: N[L], indices: R };
          });
          return k;
        })), A = u.StructureElement.Loci(g, _), M = c.Loci.toExpression(A), P = s.MolScriptBuilder.struct.modifier.union([
          s.MolScriptBuilder.struct.modifier.exceptBy({
            0: s.MolScriptBuilder.struct.modifier.includeSurroundings({
              0: M,
              radius: d.radius,
              "as-whole-residues": d.asWholeResidue
            }),
            by: M
          })
        ]), T = (0, i.getStructureByStructureQuery)((0, i.getStructureQuery)(g, P)), x = /* @__PURE__ */ new Map();
        T.units.forEach(function(B) {
          var D, N = C.get(B.id);
          N && (x.has(N) ? (D = x.get(N)) === null || D === void 0 || D.push.apply(D, B.elements) : x.set(N, (0, e.__spreadArray)([], B.elements, !0)));
        });
        var w = Array.from(x.entries()).map(function(B) {
          var D = B[0], N = B[1];
          return { ref: D, elementIds: N };
        }), E = (0, i.queryCellItemsByHierarchyType)(this.plugin, w), I = a.ExpandFilterToHierarchyTypes[d.filter];
        d.excludeSelectedAtoms && this.clear(), Object.keys(E).forEach(function(B) {
          var D = [];
          I.forEach(function(N) {
            E[B][N].forEach(function(O) {
              return D.push.apply(D, O.elementIds);
            });
          }), p.add({
            item: {
              ref: B,
              elementIds: D
            }
          }, !1);
        });
      }, f;
    }()
  );
  return w1.StructureSelectionManager = l, w1;
}
var aR;
function N4e() {
  if (aR) return M1;
  aR = 1, Object.defineProperty(M1, "__esModule", { value: !0 }), M1.SelectionManager = void 0;
  var e = ZA, r = B4e(), t = Ti, n = (
    /** @class */
    function() {
      function a(i) {
        this.ev = t.RxEventHelper.create(), this.event = {
          changed: this.ev()
        }, this.plugin = i, this.structure = new r.StructureSelectionManager(i), this.shape = new e.ShapeSelectionManager(i);
      }
      return a.prototype.clear = function() {
        this.structure.clear(), this.shape.clear();
      }, a;
    }()
  );
  return M1.SelectionManager = n, M1;
}
var JA = {};
Object.defineProperty(JA, "__esModule", { value: !0 });
JA.EventsManager = void 0;
var V4e = Ti, R4e = Up, O4e = (
  /** @class */
  function() {
    function e(r) {
      this.ev = V4e.RxEventHelper.create(), this.allowEmptyClick = !0, this.allowSelect = !0, this.rightClick = this.ev(), this.plugin = r, this.allowEmptyClick = !0, this.allowSelect = !0;
    }
    return e.prototype.subscribe = function() {
      var r = this, t, n;
      (t = this.plugin.canvas3d) === null || t === void 0 || t.interaction.click.subscribe(function(a) {
        if (a.current.loci.kind === "empty-loci") {
          if (!r.allowEmptyClick || a.button === 2)
            return;
          r.plugin.managers.selection.shape.event.change.next(a), r.plugin.managers.selection.structure.event.change.next(a);
        } else if (r.allowSelect)
          a.current.repr.label === "Molecular Surface" || a.current.loci.kind === "group-loci" ? r.plugin.managers.selection.shape.event.change.next(a) : (a.current.loci.kind === "element-loci" || a.current.loci.kind === "bond-loci") && r.plugin.managers.selection.structure.event.change.next(a);
        else if (a.button !== 2)
          return;
        a.button === 2 && r.rightClick.next({
          loci: a.current,
          modifiers: a.modifiers,
          isEmpty: a.current.loci.kind === "empty-loci",
          isSelection: !1,
          reprType: R4e.ReprLabelToType[a.current.repr.label]
        });
      }), (n = this.plugin.canvas3d) === null || n === void 0 || n.interaction.hover.subscribe(function(a) {
        a.current.loci.kind !== "empty-loci" ? r.plugin.managers.highlight.setHoverSelection(a.current) : r.plugin.managers.highlight.setHoverSelection();
      });
    }, e.prototype.setAllowEmptyClick = function(r) {
      this.allowEmptyClick = r;
    }, e.prototype.setAllowSelect = function(r) {
      this.allowSelect = r;
    }, e;
  }()
);
JA.EventsManager = O4e;
var SP = {}, E1 = {}, iR;
function F4e() {
  if (iR) return E1;
  iR = 1, Object.defineProperty(E1, "__esModule", { value: !0 }), E1.DragEditor = void 0;
  var e = Te, r = ef(), t = Re, n = Je(), a = Qe(), i = eu(), o = jA(), c = {
    interval: void 0,
    observers: void 0,
    cRef: "",
    elementId: -1,
    totalOffset: t.Vec3.create(0, 0, 0)
  }, s = (
    /** @class */
    function() {
      function u(l) {
        this.state = c, this.intervalTime = 300, this.plugin = l;
      }
      return u.prototype.start = function() {
        var l = this, f, d;
        this.plugin.managers.editor.disabledInteraction = ["click", "drag"], this.plugin.managers.selection.structure.setGranularity(r.Granularity.Atom), this.state.observers = (f = this.plugin.canvas3d) === null || f === void 0 ? void 0 : f.interaction.drag.observers.pop(), this.state.interval = setInterval(function() {
          if (!(l.state.totalOffset.filter(function(p) {
            return p !== 0;
          }).length === 0 || l.state.elementId === -1)) {
            var m = (0, e.__spreadArray)([], l.state.totalOffset, !0);
            l.state.totalOffset = t.Vec3.create(0, 0, 0), l.plugin.managers.editor.executeEdit(l.state.cRef, function(p, v) {
              var h = (0, e.__spreadArray)([], p, !0), y = (0, e.__spreadArray)([], v, !0);
              return h.forEach(function(C) {
                C.elementId === l.state.elementId && (C.x -= m[0], C.y -= m[1], C.z -= m[2]);
              }), {
                editedAtomList: h,
                editedBondList: y
              };
            }, function(p, v) {
              var h = (0, e.__spreadArray)([], p, !0), y = (0, e.__spreadArray)([], v, !0);
              return h.forEach(function(C) {
                C.elementId === l.state.elementId && (C.x -= m[0], C.y -= m[1], C.z -= m[2]);
              }), {
                editedAtomList: h,
                editedBondList: y
              };
            });
          }
        }, this.intervalTime), (d = this.plugin.canvas3d) === null || d === void 0 || d.interaction.drag.subscribe(function(m) {
          var p = m.current.loci;
          if (p.kind === "element-loci") {
            var v = a.OrderedSet.toArray(p.elements[0].indices);
            if (v.length === 1) {
              l.plugin.cells.forEach(function(y, C) {
                y.model.structure && i.Loci.isSubset(n.Structure.toStructureElementLoci(y.model.structure), p) && (l.state.cRef = C);
              });
              var h = (0, o.getDragOffset)(l.plugin, m.pageStart, m.pageEnd);
              t.Vec3.add(l.state.totalOffset, l.state.totalOffset, h), l.state.elementId = p.elements[0].unit.elements[v[0]];
            }
          }
        });
      }, u.prototype.end = function() {
        var l, f;
        this.state.interval && clearInterval(this.state.interval), (l = this.plugin.canvas3d) === null || l === void 0 || l.interaction.drag.observers.pop(), this.state.observers && ((f = this.plugin.canvas3d) === null || f === void 0 || f.interaction.drag.subscribe(this.state.observers)), this.state.observers = void 0, this.state.cRef = "", this.state.elementId = -1, this.state.totalOffset = t.Vec3.create(0, 0, 0);
      }, u;
    }()
  );
  return E1.DragEditor = s, E1;
}
var D1 = {}, oR;
function L4e() {
  if (oR) return D1;
  oR = 1, Object.defineProperty(D1, "__esModule", { value: !0 }), D1.DrawEditor = void 0;
  var e = Te, r = eu(), t = ef(), n = Je(), a = Qe(), i = Ti, o = zp(), c = {
    elementType: "C",
    drawClickObserver: void 0,
    position: void 0,
    isDelete: !1
  }, s = (
    /** @class */
    function() {
      function u(l) {
        this.ev = i.RxEventHelper.create(), this.state = c, this.event = {
          update: this.ev()
        }, this.plugin = l;
      }
      return u.prototype.setElementType = function(l) {
        this.state.elementType = l;
      }, u.prototype.setPosition = function(l) {
        this.state.position = l;
      }, u.prototype.setIsDelete = function(l) {
        this.state.isDelete = l;
      }, u.prototype.start = function() {
        var l = this, f, d;
        this.plugin.managers.editor.disabledInteraction = ["click"], this.plugin.managers.selection.structure.setGranularity(t.Granularity.Atom), this.state.drawClickObserver = (f = this.plugin.canvas3d) === null || f === void 0 ? void 0 : f.interaction.click.observers.pop(), (d = this.plugin.canvas3d) === null || d === void 0 || d.interaction.click.subscribe(function(m) {
          return (0, e.__awaiter)(l, void 0, void 0, function() {
            var p, v, h, y, C, S, b, g, _, A = this, M, P, T, x;
            return (0, e.__generator)(this, function(w) {
              switch (w.label) {
                case 0:
                  return m.current.loci && m.current.loci.kind === "element-loci" ? (p = m.current.loci, v = a.OrderedSet.toArray(p.elements[0].indices), v.length !== 1 ? [3, 5] : (this.plugin.cells.forEach(function(E, I) {
                    E.model.structure && r.Loci.isSubset(n.Structure.toStructureElementLoci(E.model.structure), p) && (h = I);
                  }), y = p.elements[0].unit.elements[v[0]], h ? this.state.isDelete ? [3, 2] : [4, this.plugin.managers.editor.editAtomType(this.state.elementType, [
                    { ref: h, elementIds: [y] }
                  ])] : [
                    2
                    /*return*/
                  ])) : [3, 6];
                case 1:
                  return w.sent(), [3, 4];
                case 2:
                  return [4, this.plugin.managers.cell.remove([
                    { ref: h, elementIds: [y] }
                  ])];
                case 3:
                  w.sent(), w.label = 4;
                case 4:
                  this.event.update.next({ isUpdateHierarchy: !0, cRef: h }), w.label = 5;
                case 5:
                  return [3, 9];
                case 6:
                  return m.current.loci && m.current.loci.kind === "empty-loci" && !this.state.isDelete ? (C = Array.from(this.plugin.cells.entries()).filter(function(E) {
                    E[0];
                    var I = E[1];
                    return I.model.structure && (Array.from(I.representations.values()).findIndex(function(B) {
                      return B.isHidden === !1;
                    }) !== -1 || !I.representations.size);
                  }), C.length ? (S = ((M = C[0][1].model.structure) === null || M === void 0 ? void 0 : M.units.length) === 0, b = (((P = this.plugin.canvas3d) === null || P === void 0 ? void 0 : P.getPosition(m.page[0], m.page[1])) || { position: void 0 }).position, b ? C.length !== 1 ? [3, 8] : (g = C[0][1].model.structure, g ? (_ = "".concat(Math.max.apply(Math, Array.from((x = (T = g.model) === null || T === void 0 ? void 0 : T.atomicConformation.atomId.toArray()) !== null && x !== void 0 ? x : [0])) + 1), [4, this.plugin.managers.editor.executeEdit(C[0][0], function(E, I) {
                    var B = (0, e.__spreadArray)((0, e.__spreadArray)([], E, !0), [
                      (0, o.getDefaultAtomData)(_, A.state.elementType, b)
                    ], !1), D = (0, e.__spreadArray)([], I, !0);
                    return {
                      editedAtomList: B,
                      editedBondList: D,
                      affectedAtomIds: [+_]
                    };
                  }, function(E, I) {
                    var B = (0, e.__spreadArray)((0, e.__spreadArray)([], E, !0), [
                      (0, o.getDefaultAtomData)(_, A.state.elementType, b)
                    ], !1), D = (0, e.__spreadArray)([], I, !0);
                    return {
                      editedAtomList: B,
                      editedBondList: D
                    };
                  })]) : [
                    2
                    /*return*/
                  ]) : [3, 9]) : (this.event.update.next({ hasMultiRef: !0 }), [
                    2
                    /*return*/
                  ])) : [3, 9];
                case 7:
                  return w.sent(), this.event.update.next({
                    isUpdateHierarchy: !0,
                    cRef: C[0][0],
                    isEmpty: S
                  }), [3, 9];
                case 8:
                  this.setPosition(b), this.event.update.next({ hasMultiRef: !0, newAtom: (0, o.getDefaultAtomData)("", this.state.elementType, b) }), w.label = 9;
                case 9:
                  return [
                    2
                    /*return*/
                  ];
              }
            });
          });
        });
      }, u.prototype.end = function() {
        var l, f;
        (l = this.plugin.canvas3d) === null || l === void 0 || l.interaction.click.observers.pop(), this.state.drawClickObserver && ((f = this.plugin.canvas3d) === null || f === void 0 || f.interaction.click.subscribe(this.state.drawClickObserver)), this.state.drawClickObserver = void 0;
      }, u.prototype.addAtomByRef = function(l) {
        var f = this, d, m;
        if (this.state.position) {
          var p = this.plugin.cells.get(l);
          if (p) {
            var v = p.model.structure;
            if (v) {
              var h = "".concat(Math.max.apply(Math, Array.from((m = (d = v.model) === null || d === void 0 ? void 0 : d.atomicConformation.atomId.toArray()) !== null && m !== void 0 ? m : [0])) + 1);
              this.plugin.managers.editor.executeEdit(l, function(y, C) {
                var S = (0, e.__spreadArray)((0, e.__spreadArray)([], y, !0), [
                  (0, o.getDefaultAtomData)(h, f.state.elementType, f.state.position)
                ], !1), b = (0, e.__spreadArray)([], C, !0);
                return {
                  editedAtomList: S,
                  editedBondList: b,
                  affectedAtomIds: [+h]
                };
              }, function(y, C) {
                var S = (0, e.__spreadArray)((0, e.__spreadArray)([], y, !0), [
                  (0, o.getDefaultAtomData)(h, f.state.elementType, f.state.position)
                ], !1), b = (0, e.__spreadArray)([], C, !0);
                return {
                  editedAtomList: S,
                  editedBondList: b
                };
              }), this.setPosition();
            }
          }
        }
      }, u;
    }()
  );
  return D1.DrawEditor = s, D1;
}
var I1 = {}, uR;
function k4e() {
  if (uR) return I1;
  uR = 1, Object.defineProperty(I1, "__esModule", { value: !0 }), I1.RotateEditor = void 0;
  var e = Te, r = Qe(), t = Re, n = Tr(), a = Jt, i = jA(), o = {
    interval: void 0,
    dragObserver: void 0,
    cRef: "",
    elementIds: [],
    unit: void 0,
    rotateOffset: t.Vec3.create(0, 0, 0),
    rotateAtoms: [],
    arrowCRef: void 0,
    invert: !1,
    pointA: t.Vec3.create(0, 0, 0),
    pointB: t.Vec3.create(0, 0, 0)
  }, c = (
    /** @class */
    function() {
      function s(u) {
        this.state = o, this.intervalTime = 300, this.plugin = u;
      }
      return s.prototype.start = function() {
        var u, l, f;
        return (0, e.__awaiter)(this, void 0, void 0, function() {
          var d, m = this;
          return (0, e.__generator)(this, function(p) {
            switch (p.label) {
              case 0:
                return this.plugin.managers.editor.disabledInteraction = ["drag"], this.plugin.managers.selection.structure.setGranularity(a.Granularity.Atom), this.state.dragObserver = (u = this.plugin.canvas3d) === null || u === void 0 ? void 0 : u.interaction.drag.observers.pop(), d = function() {
                  return (0, e.__awaiter)(m, void 0, void 0, function() {
                    var v, h, y, C, S, b, g, _, A, M, P, T, x, w, E, I, B, D, N, O, V, k, G, L;
                    return (0, e.__generator)(this, function(R) {
                      switch (R.label) {
                        case 0:
                          if (this.state.arrowCRef && (this.plugin.managers.cell.remove([{ ref: this.state.arrowCRef }]), this.state.arrowCRef = void 0), v = this.plugin.managers.selection.structure.selection, this.state.cRef = "", this.state.elementIds = [], this.state.unit = void 0, h = Array.from(v.entries()).filter(function(F) {
                            F[0];
                            var U = F[1];
                            return U.length > 0;
                          }), h.length !== 1) return [3, 2];
                          if (y = h[0][1], y.length !== 2) return [3, 2];
                          if (this.state.cRef = h[0][0], this.state.elementIds = (0, e.__spreadArray)([], y, !0), C = (L = this.plugin.cells.get(h[0][0])) === null || L === void 0 ? void 0 : L.model.structure, !C)
                            return [
                              2
                              /*return*/
                            ];
                          for (S = C.units.find(function(F) {
                            return r.SortedArray.has(F.elements, y[0]) && r.SortedArray.has(F.elements, y[1]);
                          }), this.state.unit = S, b = S, g = b.bonds, _ = b.conformation, A = b.rings, M = b.elements, P = /* @__PURE__ */ new Map(), T = -1, x = 0, w = g.a.length; x < w; x++) {
                            if (T === -1 && (M[g.a[x]] === y[0] && M[g.b[x]] === y[1] && g.edgeProps.order[x] === 1 || M[g.a[x]] === y[1] && M[g.b[x]] === y[0] && g.edgeProps.order[x] === 1)) {
                              for (E = 0, I = A.all.length; E < I; E++)
                                if (A.all[E].includes(y[0]) && A.all[E].includes(y[1]))
                                  return [
                                    2
                                    /*return*/
                                  ];
                              T = x;
                            }
                            P.has(M[g.a[x]]) ? P.set(M[g.a[x]], (0, e.__spreadArray)((0, e.__spreadArray)([], P.get(M[g.a[x]]), !0), [M[g.b[x]]], !1)) : P.set(M[g.a[x]], [M[g.b[x]]]);
                          }
                          return T !== -1 && P.get(y[0]).length > 1 && P.get(y[1]).length > 1 ? (B = this.state.invert ? 1 : 0, D = this.state.invert ? 0 : 1, this.state.pointA = t.Vec3.create(_.x(y[D]), _.y(y[D]), _.z(y[D])), this.state.pointB = t.Vec3.create(_.x(y[B]), _.y(y[B]), _.z(y[B])), N = this.state, [4, this.plugin.managers.representation.createOther({
                            data: {
                              center: this.state.pointA,
                              vec: t.Vec3.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: n.Color.fromRgb(255, 196, 36),
                              alpha: 0.9
                            },
                            type: a.RepresentationType.RotateArrow
                          })]) : [3, 2];
                        case 1:
                          for (N.arrowCRef = R.sent(), O = (0, e.__spreadArray)([], P.get(y[B]).filter(function(F) {
                            return F !== y[D] && F !== y[B];
                          }), !0), V = [y[B]], this.state.rotateAtoms = (0, e.__spreadArray)([], O, !0); O.length; )
                            k = O.shift(), (G = this.state.rotateAtoms).push.apply(G, P.get(k)), V.push(k), O.push.apply(O, P.get(k).filter(function(F) {
                              return !V.includes(F);
                            }));
                          this.state.rotateAtoms = Array.from(new Set(this.state.rotateAtoms.filter(function(F) {
                            return F !== y[D] && F !== y[B];
                          }))), R.label = 2;
                        case 2:
                          return [
                            2
                            /*return*/
                          ];
                      }
                    });
                  });
                }, [4, d()];
              case 1:
                return p.sent(), this.plugin.managers.selection.structure.event.add.subscribe(function() {
                  m.state.invert = !1, m.state.rotateOffset = t.Vec3.create(0, 0, 0), m.state.rotateAtoms = [], m.state.cRef = "", m.state.elementIds = [], m.state.unit = void 0, d();
                }), this.plugin.managers.selection.structure.event.remove.subscribe(function() {
                  m.state.invert = !1, m.state.rotateOffset = t.Vec3.create(0, 0, 0), m.state.rotateAtoms = [], m.state.cRef = "", m.state.elementIds = [], m.state.unit = void 0, d();
                }), this.plugin.managers.selection.structure.event.clear.subscribe(function() {
                  m.state.invert = !1, m.state.rotateOffset = t.Vec3.create(0, 0, 0), m.state.rotateAtoms = [], m.state.cRef = "", m.state.elementIds = [], m.state.unit = void 0, m.state.arrowCRef && m.plugin.managers.cell.remove([{ ref: m.state.arrowCRef }]);
                }), (l = this.plugin.canvas3d) === null || l === void 0 || l.interaction.click.subscribe(function(v) {
                  v.current.loci.kind === "group-loci" && (v.current.repr ? v.current.repr.label === "RotateArrow" : v.current.loci.shape.name.split("-").shift() === "RotateArrow") && (m.state.invert = !m.state.invert, d());
                }), this.state.interval = setInterval(function() {
                  if (!(m.state.rotateOffset.filter(function(b) {
                    return b !== 0;
                  }).length === 0 || !m.state.cRef || m.state.elementIds.length !== 2 || m.state.rotateAtoms.length === 0)) {
                    var v = m.state.elementIds, h = m.state.unit.conformation, y = t.Vec3.angle(t.Vec3.sub(t.Vec3.create(0, 0, 0), m.state.pointA, m.state.pointB), t.Vec3.create(m.state.rotateOffset[0], m.state.rotateOffset[1], m.state.rotateOffset[2])), C = t.Vec3.cross(t.Vec3.create(0, 0, 0), t.Vec3.sub(t.Vec3.create(0, 0, 0), m.state.pointA, m.state.pointB), t.Vec3.create(m.state.rotateOffset[0], m.state.rotateOffset[1], m.state.rotateOffset[2]));
                    C[2] < 0 && (y = Math.PI * 2 - y);
                    var S = t.Vec3.distance(t.Vec3.create(0, 0, 0), t.Vec3.create(m.state.rotateOffset[0], m.state.rotateOffset[1], m.state.rotateOffset[2])) * 5 * (y < Math.PI && y > 0 ? -1 : 1);
                    m.state.rotateOffset = t.Vec3.create(0, 0, 0), m.plugin.managers.editor.executeEdit(m.state.cRef, function(b, g) {
                      var _ = (0, e.__spreadArray)([], b, !0), A = (0, e.__spreadArray)([], g, !0);
                      return _.forEach(function(M) {
                        if (m.state.rotateAtoms.includes(M.elementId)) {
                          var P = (0, i.rotateArbitraryLine)([
                            h.x(v[1]),
                            h.y(v[1]),
                            h.z(v[1])
                          ], [
                            h.x(v[0]),
                            h.y(v[0]),
                            h.z(v[0])
                          ], S, [M.x, M.y, M.z]);
                          M.x = P[0], M.y = P[1], M.z = P[2];
                        }
                      }), {
                        editedAtomList: _,
                        editedBondList: A
                      };
                    }, function(b, g) {
                      var _ = (0, e.__spreadArray)([], b, !0), A = (0, e.__spreadArray)([], g, !0);
                      return _.forEach(function(M) {
                        if (m.state.rotateAtoms.includes(M.elementId)) {
                          var P = (0, i.rotateArbitraryLine)([
                            h.x(v[1]),
                            h.y(v[1]),
                            h.z(v[1])
                          ], [
                            h.x(v[0]),
                            h.y(v[0]),
                            h.z(v[0])
                          ], S, [M.x, M.y, M.z]);
                          M.x = P[0], M.y = P[1], M.z = P[2];
                        }
                      }), {
                        editedAtomList: _,
                        editedBondList: A
                      };
                    });
                  }
                }, this.intervalTime), (f = this.plugin.canvas3d) === null || f === void 0 || f.interaction.drag.subscribe(function(v) {
                  if (m.state.rotateAtoms.length) {
                    var h = (0, i.getDragOffset)(m.plugin, v.pageStart, v.pageEnd);
                    m.state.rotateOffset[0] += h[0], m.state.rotateOffset[1] += h[1], m.state.rotateOffset[2] += h[2];
                  }
                }), [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, s.prototype.end = function() {
        var u, l, f;
        this.state.arrowCRef && (this.plugin.managers.cell.remove([{ ref: this.state.arrowCRef }]), this.state.arrowCRef = void 0), this.state.interval && clearInterval(this.state.interval), (u = this.plugin.canvas3d) === null || u === void 0 || u.interaction.drag.observers.pop(), this.state.dragObserver && ((l = this.plugin.canvas3d) === null || l === void 0 || l.interaction.drag.subscribe(this.state.dragObserver)), this.state.invert = !1, this.state.dragObserver = void 0, this.state.rotateOffset = t.Vec3.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(), (f = this.plugin.canvas3d) === null || f === void 0 || f.interaction.click.observers.pop();
      }, s;
    }()
  );
  return I1.RotateEditor = c, I1;
}
var sR;
function U4e() {
  return sR || (sR = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.EditorManager = e.BOND_ORDER = e.EditorMode = void 0;
    var r = Te, t = _n, n = Ti, a = qp(), i = Jt, o = sn(), c = Hp(), s = F4e(), u = L4e(), l = k4e(), f;
    (function(v) {
      v[v.None = 0] = "None", v[v.Drag = 1] = "Drag", v[v.Rotate = 2] = "Rotate", v[v.Draw = 3] = "Draw";
    })(f = e.EditorMode || (e.EditorMode = {}));
    var d;
    (function(v) {
      v[v.SINGLE = 1] = "SINGLE", v[v.DOUBLE = 2] = "DOUBLE", v[v.TRIPLE = 3] = "TRIPLE", v[v.AROMATIC = 4] = "AROMATIC", v[v.SINGLE_OR_DOUBLE = 5] = "SINGLE_OR_DOUBLE", v[v.SINGLE_OR_AROMATIC = 6] = "SINGLE_OR_AROMATIC", v[v.DOUBLE_OR_AROMATIC = 7] = "DOUBLE_OR_AROMATIC", v[v.ANY = 8] = "ANY";
    })(d = e.BOND_ORDER || (e.BOND_ORDER = {}));
    var m = [d.SINGLE, d.DOUBLE, d.TRIPLE], p = (
      /** @class */
      function() {
        function v(h) {
          var y;
          this.state = {
            mode: f.None,
            editAtomDisabled: !1,
            addBondDisabled: !1,
            editBondDisabled: !1,
            selectedPdb: !1,
            isMergeNeeded: !1
          }, this.ev = n.RxEventHelper.create(), this.editStateUpdated = this.ev(), this.editStructureUpdated = this.ev(), this.plugin = h, this.instance = (y = {}, y[f.Drag] = new s.DragEditor(h), y[f.Rotate] = new l.RotateEditor(h), y[f.Draw] = new u.DrawEditor(h), y[f.None] = void 0, y);
        }
        return Object.defineProperty(v.prototype, "isEditing", {
          get: function() {
            var h;
            return !!(!((h = this.plugin.canvas3d) === null || h === void 0) && h.controls.isEditing);
          },
          set: function(h) {
            var y, C, S = ((y = this.plugin.canvas3d) === null || y === void 0 ? void 0 : y.controls.isEditing) === !1 && h;
            if ((C = this.plugin.canvas3d) === null || C === void 0 || C.controls.setEditState(h), S && this.setState(this.getEditState()), !h) {
              var b = [];
              this.plugin.cells.forEach(function(g, _) {
                g.representations.has(i.RepresentationType.RotateArrow) && b.push({ ref: _ });
              }), this.plugin.managers.cell.remove(b);
            }
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty(v.prototype, "disabledInteraction", {
          get: function() {
            var h;
            return ((h = this.plugin.canvas3d) === null || h === void 0 ? void 0 : h.controls.disabledInteraction) || [];
          },
          set: function(h) {
            var y;
            (y = this.plugin.canvas3d) === null || y === void 0 || y.controls.setDisabledInteractionState(h);
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty(v.prototype, "isLockCamera", {
          get: function() {
            var h;
            return !!(!((h = this.plugin.canvas3d) === null || h === void 0) && h.controls.isLockCamera);
          },
          set: function(h) {
            var y;
            (y = this.plugin.canvas3d) === null || y === void 0 || y.controls.setLockCameraState(h);
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty(v.prototype, "drawEditor", {
          get: function() {
            return this.instance[f.Draw];
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty(v.prototype, "rotateEditor", {
          get: function() {
            return this.instance[f.Rotate];
          },
          enumerable: !1,
          configurable: !0
        }), Object.defineProperty(v.prototype, "dragEditor", {
          get: function() {
            return this.instance[f.Drag];
          },
          enumerable: !1,
          configurable: !0
        }), v.prototype.setState = function(h) {
          Object.assign(this.state, h), this.editStateUpdated.next(this.state);
        }, v.prototype.setEditorMode = function(h, y, C) {
          y === void 0 && (y = !1), C === void 0 && (C = ["click", "drag"]), this.isEditing = h, this.isLockCamera = y, this.disabledInteraction = C;
        }, v.prototype.getEditState = function() {
          var h = this, y, C, S, b, g = !0, _ = !0, A = !0, M = !1, P = !1;
          if (!this.isEditing)
            return {
              editAtomDisabled: g,
              addBondDisabled: _,
              editBondDisabled: A,
              selectedPdb: M,
              isMergeNeeded: P
            };
          var T = this.plugin.managers.selection.structure.selection, x = [];
          if (T.forEach(function(N, O) {
            x.push(O), M = M || h.plugin.managers.cell.isFromPdb(O);
          }), x.length > 0)
            for (var w = 0, E = x.length; w < E; w++) {
              var I = x[w];
              T.has(I) && (g = !1);
            }
          if (x.length === 0 || x.length > 2)
            return {
              editAtomDisabled: g,
              addBondDisabled: _,
              editBondDisabled: A,
              selectedPdb: M,
              isMergeNeeded: P
            };
          if (x.length === 2) {
            var B = (0, r.__spreadArray)((0, r.__spreadArray)([], (y = T.get(x[0])) !== null && y !== void 0 ? y : [], !0), (C = T.get(x[1])) !== null && C !== void 0 ? C : [], !0);
            B.length === 2 && (_ = !1, P = !0);
          } else if (x.length === 1) {
            var B = T.get(x[0]);
            if ((B == null ? void 0 : B.length) === 2) {
              _ = !1;
              var D = this.plugin.cells.get(x[0]);
              !((S = D == null ? void 0 : D.model.structure) === null || S === void 0) && S.units.length && ((b = D == null ? void 0 : D.model.structure) === null || b === void 0 ? void 0 : b.units[0]).bonds.getEdgeIndex(B[0], B[1]) !== -1 && (A = !1);
            }
          }
          return {
            editAtomDisabled: g,
            addBondDisabled: _,
            editBondDisabled: A,
            selectedPdb: M,
            isMergeNeeded: P
          };
        }, v.prototype.executeEdit = function(h, y, C, S) {
          var b, g, _;
          return (0, r.__awaiter)(this, void 0, void 0, function() {
            var A, M, P, T, x, w = this;
            return (0, r.__generator)(this, function(E) {
              switch (E.label) {
                case 0:
                  return A = this.plugin.cells.get(h), M = (b = A == null ? void 0 : A.model) === null || b === void 0 ? void 0 : b.structure, M ? [4, (0, c.generateStructureByEditFuncAndStructure)(M, y, C, S)] : [
                    2
                    /*return*/
                  ];
                case 1:
                  return P = E.sent(), P.length <= 0 ? [
                    2
                    /*return*/
                  ] : [4, this.plugin.managers.representation.updateMolecular({
                    ref: h,
                    structure: P[0]
                  })];
                case 2:
                  return T = E.sent(), T.model.structure = P[0], x = ((_ = (g = (0, c.getModelByStructure)(P[0])) === null || g === void 0 ? void 0 : g.sourceData) === null || _ === void 0 ? void 0 : _.kind) !== "mmCIF" ? i.Format.Sdf : i.Format.Pdb, this.plugin.managers.cell.update(h, {
                    model: T.model,
                    representations: Array.from(T.representations.values()),
                    assets: [{ format: x, data: (0, c.getTextFromStructure)(P[0], x) }]
                  }), this.editStructureUpdated.next(h), this.plugin.managers.cell.traverse(function(I, B) {
                    B.type === i.RepresentationType.IntraInteractions && w.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.editor.executeEdit");
                  }), [
                    2
                    /*return*/
                  ];
              }
            });
          });
        }, v.prototype.coverSourceData = function(h, y, C, S) {
          var b, g, _, A, M, P, T;
          return (0, r.__awaiter)(this, void 0, void 0, function() {
            var x, w, E, I, B, D, N, O, V, k, G, L = this;
            return (0, r.__generator)(this, function(R) {
              switch (R.label) {
                case 0:
                  return this.plugin.cells.has(h) ? (E = (w = a.FormatProvider[y]).parse, [4, (0, o.readAsString)(C)]) : [
                    2
                    /*return*/
                  ];
                case 1:
                  return [4, E.apply(w, [R.sent()])];
                case 2:
                  return x = R.sent(), S ? (I = this.plugin.cells.get(h), I == null || I.representations.forEach(function(F) {
                    var U;
                    F.state && ((U = L.plugin.canvas3d) === null || U === void 0 || U.remove(F.state));
                  }), this.plugin.managers.cell.update(h, {
                    model: {
                      structure: x[0]
                    },
                    representations: [],
                    assets: [{ format: y, data: C }]
                  }), I.representations = /* @__PURE__ */ new Map(), [
                    4,
                    this.plugin.managers.representation.setMolecularRepr([{ ref: h, elementIds: (0, c.getElementsFromStructure)(x[0]) }], S, !1)
                    // 更新selection的mark
                  ]) : [3, 4];
                case 3:
                  return R.sent(), B = this.plugin.managers.selection.structure.getSelection(), D = (b = B[h]) !== null && b !== void 0 ? b : [], N = (g = this.plugin.cells.get(h)) === null || g === void 0 ? void 0 : g.representations.get(S), N && (O = (0, o.getLoci)((0, c.getStructureFromRepresentation)(N.state), D), (_ = this.plugin.canvas3d) === null || _ === void 0 || _.mark({
                    loci: O,
                    repr: N.state
                  }, t.MarkerAction.Select)), [
                    2
                    /*return*/
                  ];
                case 4:
                  return [4, this.plugin.managers.representation.updateMolecular({
                    ref: h,
                    structure: x[0]
                  })];
                case 5:
                  return V = R.sent(), V.model.structure = x[0], this.plugin.managers.cell.update(h, {
                    model: V.model,
                    representations: Array.from(V.representations.values()),
                    assets: [{ format: y, data: C }]
                  }), k = this.plugin.managers.selection.structure.getSelection(), G = (A = k[h]) !== null && A !== void 0 ? A : [], (M = this.plugin.cells.get(h)) === null || M === void 0 || M.representations.values(), Array.from((T = (P = this.plugin.cells.get(h)) === null || P === void 0 ? void 0 : P.representations.values()) !== null && T !== void 0 ? T : []).forEach(function(F) {
                    var U, H = (
                      // Repr Cache Compatible
                      (0, o.getLoci)((0, c.getStructureFromRepresentation)(F.state), G)
                    );
                    (U = L.plugin.canvas3d) === null || U === void 0 || U.mark({
                      loci: H,
                      repr: F.state
                    }, t.MarkerAction.Select);
                  }), this.plugin.managers.cell.traverse(function(F, U) {
                    U.type === i.RepresentationType.IntraInteractions && L.plugin.managers.representation.showGlobalInteraction(!0, "lightPlugin.managers.editor.coverSourceData");
                  }), [
                    2
                    /*return*/
                  ];
              }
            });
          });
        }, v.prototype.edit = function(h, y) {
          return (0, r.__awaiter)(this, void 0, void 0, function() {
            var C, S, b, g = this;
            return (0, r.__generator)(this, function(_) {
              switch (_.label) {
                case 0:
                  return C = this.isLockCamera, this.isLockCamera = !0, S = y ?? this.plugin.managers.selection.structure.getSelectionCellItems(), [
                    4,
                    Promise.all(S.map(function(A) {
                      var M = A.ref, P = A.elementIds;
                      return h(M, P ?? []);
                    }))
                    // 更新selection的mark
                  ];
                case 1:
                  return _.sent(), b = this.plugin.managers.selection.structure.getSelection(), S.forEach(function(A) {
                    var M, P, T = A.ref, x = g.plugin.cells.get(T), w = (M = b[T]) !== null && M !== void 0 ? M : [];
                    Array.from((P = x == null ? void 0 : x.representations.values()) !== null && P !== void 0 ? P : []).forEach(function(E) {
                      var I, B = (
                        // Repr Cache Compatible
                        (0, o.getLoci)((0, c.getStructureFromRepresentation)(E.state), w)
                      );
                      (I = g.plugin.canvas3d) === null || I === void 0 || I.mark({
                        loci: B,
                        repr: E.state
                      }, t.MarkerAction.Select);
                    });
                  }), this.isLockCamera = C, [
                    2
                    /*return*/
                  ];
              }
            });
          });
        }, v.prototype.deleteAtoms = function(h) {
          return (0, r.__awaiter)(this, void 0, void 0, function() {
            var y, C, S = this;
            return (0, r.__generator)(this, function(b) {
              switch (b.label) {
                case 0:
                  return y = {}, C = function(g, _) {
                    return S.executeEdit(g, function(A, M) {
                      var P = new Set(_), T = /* @__PURE__ */ new Map(), x = [];
                      A.forEach(function(E) {
                        var I = P.has(E.elementId);
                        return I || (y[E.elementId] = x.length, x.push((0, r.__assign)({}, E)), T.set(E.elementId + 1, x.length)), !I;
                      });
                      var w = M.filter(function(E) {
                        var I = P.has(E.a - 1) || P.has(E.b - 1);
                        return T.has(E.a) && (E.a = T.get(E.a)), T.has(E.b) && (E.b = T.get(E.b)), !I;
                      });
                      return {
                        editedAtomList: x,
                        editedBondList: w
                      };
                    }, function(A, M) {
                      var P = new Set(_), T = [];
                      A.forEach(function(E) {
                        P.has(E.elementId) || (y[E.elementId] = T.length, T.push(E));
                      });
                      var x = (0, r.__spreadArray)([], M, !0), w = [];
                      return {
                        editedAtomList: T,
                        editedBondList: x,
                        affectedAtomIds: w
                      };
                    });
                  }, [4, this.edit(C, h)];
                case 1:
                  return b.sent(), [2, y];
              }
            });
          });
        }, v.prototype.editAtomCharge = function(h, y) {
          var C = this, S = function(b, g) {
            return C.executeEdit(b, function(_, A) {
              var M = new Set(g), P = (0, r.__spreadArray)([], _, !0), T = (0, r.__spreadArray)([], A, !0), x = [];
              return P.forEach(function(w) {
                if (M.has(w.elementId)) {
                  var E = w.charge !== void 0 ? w.charge + h : h;
                  E <= 3 && E >= -3 && (w.charge = E, x.push(parseInt(w.atom_id, 10)));
                }
              }), {
                editedAtomList: P,
                editedBondList: T,
                affectedAtomIds: x
              };
            }, function(_, A) {
              var M = new Set(g), P = (0, r.__spreadArray)([], _, !0), T = (0, r.__spreadArray)([], A, !0), x = [];
              return P.forEach(function(w) {
                if (M.has(w.elementId)) {
                  var E = w.charge !== void 0 ? w.charge + h : h;
                  E <= 3 && E >= -3 && (w.charge = E, x.push(parseInt(w.atom_id, 10)));
                }
              }), {
                editedAtomList: P,
                editedBondList: T,
                affectedAtomIds: x
              };
            });
          };
          return this.edit(S, y);
        }, v.prototype.editAtomType = function(h, y) {
          var C = this, S = h ?? this.instance[f.Draw].state.elementType, b = function(g, _) {
            return C.executeEdit(g, function(A, M) {
              var P = new Set(_), T = (0, r.__spreadArray)([], A, !0), x = (0, r.__spreadArray)([], M, !0), w = [];
              return T.forEach(function(E) {
                P.has(E.elementId) && (E.auth_atom_id = S, E.type_symbol = S, w.push(parseInt(E.atom_id, 10)));
              }), {
                editedAtomList: T,
                editedBondList: x,
                affectedAtomIds: w
              };
            }, function(A, M) {
              var P = new Set(_), T = (0, r.__spreadArray)([], A, !0), x = (0, r.__spreadArray)([], M, !0), w = [];
              return T.forEach(function(E) {
                P.has(E.elementId) && (E.auth_atom_id = S, E.type_symbol = S, w.push(parseInt(E.atom_id, 10)));
              }), {
                editedAtomList: T,
                editedBondList: x,
                affectedAtomIds: w
              };
            });
          };
          return this.edit(b, y);
        }, v.prototype.editBondOrder = function(h, y) {
          var C = this, S = function(b, g) {
            return C.executeEdit(b, function(_, A) {
              var M = (0, r.__spreadArray)([], _, !0), P = (0, r.__spreadArray)([], A, !0), T = /* @__PURE__ */ new Set();
              return P.forEach(function(x) {
                if (x.a - 1 === g[0] && x.b - 1 === g[1] || x.a - 1 === g[1] && x.b - 1 === g[0]) {
                  var w = x.order + h;
                  m.includes(w) && (x.order = w, T.add(x.a - 1), T.add(x.b - 1));
                }
              }), {
                editedAtomList: M,
                editedBondList: P,
                affectedAtomIds: Array.from(T)
              };
            }, function(_, A) {
              var M = (0, r.__spreadArray)([], _, !0), P = (0, r.__spreadArray)([], A, !0), T = /* @__PURE__ */ new Set();
              return P.forEach(function(x) {
                if (x.a === g[0] && x.b === g[1] || x.a === g[1] && x.b === g[0]) {
                  var w = x.order + h;
                  m.includes(w) && (x.order = w, T.add(x.atom_idA === void 0 ? x.a - 1 : parseInt(x.atom_idA, 10)), T.add(x.atom_idB === void 0 ? x.b - 1 : parseInt(x.atom_idB, 10)));
                }
              }), {
                editedAtomList: M,
                editedBondList: P,
                affectedAtomIds: Array.from(T)
              };
            });
          };
          return this.edit(S, y);
        }, v.prototype.addOrDelBond = function(h, y) {
          var C = this, S;
          if (!(y && (y.length !== 1 || ((S = y[0].elementIds) === null || S === void 0 ? void 0 : S.length) !== 2))) {
            if (!y) {
              var b = this.plugin.managers.selection.structure.selection;
              if (b.size !== 1 && Array.from(b.values())[0].length !== 2)
                return;
            }
            var g = function(_, A) {
              return C.executeEdit(_, function(M, P) {
                var T = (0, r.__spreadArray)([], M, !0), x = (0, r.__spreadArray)([], P, !0), w = (0, r.__spreadArray)([], A, !0);
                return h ? x.filter(function(E) {
                  return E.a - 1 === A[0] && E.b - 1 === A[1] || E.a - 1 === A[1] && E.b - 1 === A[0];
                }).length === 0 && x.push({
                  a: A[0] + 1,
                  b: A[1] + 1,
                  order: 1
                }) : x = x.filter(function(E) {
                  return !(E.a - 1 === A[0] && E.b - 1 === A[1] || E.a - 1 === A[1] && E.b - 1 === A[0]);
                }), {
                  editedAtomList: T,
                  editedBondList: x,
                  affectedAtomIds: w
                };
              }, function(M, P) {
                var T, x = (0, r.__spreadArray)([], M, !0), w = (0, r.__spreadArray)([], P, !0), E = [];
                if (!h)
                  w = w.filter(function(O) {
                    return O.a === A[0] && O.b === A[1] || O.a === A[1] && O.b === A[0] ? (E.push(O.atom_idA === void 0 ? O.a - 1 : parseInt(O.atom_idA, 10), O.atom_idB === void 0 ? O.b - 1 : parseInt(O.atom_idB, 10)), !1) : !0;
                  });
                else if (w.filter(function(O) {
                  return O.a === A[0] && O.b === A[1] || O.a === A[1] && O.b === A[0];
                }).length === 0) {
                  var I = (T = C.plugin.cells.get(_)) === null || T === void 0 ? void 0 : T.model.structure;
                  if (I && I.units.length > 0) {
                    var B = I.units[0], D = B.model.atomicConformation.atomId.value(A[0]), N = B.model.atomicConformation.atomId.value(A[1]);
                    w.push({
                      a: A[0],
                      b: A[1],
                      order: 1,
                      atom_idA: "".concat(D),
                      atom_idB: "".concat(N)
                    }), E.push(D, N);
                  }
                }
                return {
                  editedAtomList: x,
                  editedBondList: w,
                  affectedAtomIds: E
                };
              });
            };
            return this.edit(g, y);
          }
        }, v.prototype.changeEditorMode = function(h) {
          var y = this.instance[this.state.mode];
          this.isLockCamera = !1, this.disabledInteraction = [], y && y.end();
          var C = this.instance[h];
          C && (this.isEditing = !0, this.isLockCamera = !0, C.start()), this.setState({
            mode: h
          });
        }, v.prototype.start = function() {
          var h = this;
          this.plugin.managers.selection.event.changed.subscribe(function() {
            h.setState(h.getEditState());
          });
        }, v;
      }()
    );
    e.EditorManager = p;
  }(SP)), SP;
}
var B1 = {}, lR;
function z4e() {
  if (lR) return B1;
  lR = 1, Object.defineProperty(B1, "__esModule", { value: !0 }), B1.HighlightManager = void 0;
  var e = Te, r = _r, t = _n, n = Ti, a = ef(), i = sn(), o = Up, c = (
    /** @class */
    function() {
      function s(u) {
        this.ev = n.RxEventHelper.create(), this.info = this.ev(), this.handleHighlightLocis = [], this.plugin = u;
      }
      return s.prototype.setHoverSelection = function(u, l) {
        var f = this, d, m, p;
        if (l === void 0 && (l = !0), this.hoverLoci && ((d = this.plugin.canvas3d) === null || d === void 0 || d.mark(this.hoverLoci, t.MarkerAction.RemoveHighlight)), !((m = this.handleHighlightLocis) === null || m === void 0) && m.length && this.handleHighlightLocis.forEach(function(h) {
          var y;
          (y = f.plugin.canvas3d) === null || y === void 0 || y.mark(h, t.MarkerAction.RemoveHighlight);
        }), !u) {
          this.info.next({});
          return;
        }
        var v = {
          loci: r.Loci.normalize(u.loci, this.plugin.managers.selection.structure.lociGranularity),
          repr: u.repr
        };
        (p = this.plugin.canvas3d) === null || p === void 0 || p.mark(v, t.MarkerAction.Highlight), this.hoverLoci = v, l && this.info.next({ loci: v, info: this.createHighlightInfo(v) });
      }, s.prototype.addHighlightLocis = function(u, l) {
        var f, d = this;
        l === void 0 && (l = !0), l && (this.handleHighlightLocis.forEach(function(m) {
          var p;
          (p = d.plugin.canvas3d) === null || p === void 0 || p.mark(m, t.MarkerAction.RemoveHighlight);
        }), this.handleHighlightLocis = []), u.forEach(function(m) {
          var p;
          (p = d.plugin.canvas3d) === null || p === void 0 || p.mark(m, t.MarkerAction.Highlight);
        }), (f = this.handleHighlightLocis).push.apply(f, u);
      }, s.prototype.createHighlightInfo = function(u) {
        if (u.loci.kind === "element-loci") {
          var l = "";
          if (Array.from(this.plugin.cells.entries()).some(function(P) {
            var T = P[0], x = P[1];
            return !l && (0, i.getStructureByCell)(x) && (0, i.getStructureUniqueId)((0, i.getStructureByCell)(x)) === (0, i.getStructureUniqueId)(u.loci.structure) ? (l = T, !0) : !1;
          }), !l)
            return;
          var f = this.plugin.cells.get(l), d, m = "";
          if (Object.entries(a.ReprCBasedTheme).forEach(function(P) {
            var T = P[0], x = P[1];
            x.includes(o.ReprLabelToType[u.repr.label]) && (d = T);
          }), d && f.theme.color && f.theme.color[d]) {
            var p = f.theme.color[d], v = (0, i.getElementIdsByLoci)(u.loci);
            p.forEach(function(P) {
              var T = new Set(P.elementIds);
              v.filter(function(x) {
                return !T.has(x);
              }).length === 0 && (m = P.name);
            });
          }
          var h = (0, e.__assign)({ type: a.HighlightLabelType.Structure, ref: l, colorThemeName: m }, (0, i.getElementLociInfo)(u.loci, this.plugin.managers.selection.structure.granularity));
          return h;
        }
        if (u.loci.kind === "data-loci" && u.loci.tag === "interactions") {
          var y = "", C = "", S = u.loci.elements[0], b = S.unitA, g = S.unitB;
          Array.from(this.plugin.cells.entries()).some(function(T) {
            var x = T[0], w = T[1];
            if (y && C)
              return !0;
            if (w.model.structure) {
              var E = (0, i.getStructureUniqueId)(w.model.structure);
              E === b.model.id && (y = x), E === g.model.id && (C = x);
            }
            return !1;
          });
          var h = (0, e.__assign)({ type: a.HighlightLabelType.Interaction }, (0, i.getInteractionLociInfo)(u.loci));
          return Object.assign(h.infoA, { ref: y }), Object.assign(h.infoB, { ref: C }), h;
        }
        if (u.loci.kind === "group-loci")
          return {};
        if (u.loci.kind === "bond-loci") {
          var _ = "";
          Array.from(this.plugin.cells.entries()).some(function(T) {
            var x = T[0], w = T[1];
            return !_ && w.model.structure && (0, i.getStructureUniqueId)(w.model.structure) === (0, i.getStructureUniqueId)(u.loci.structure) ? (_ = x, !0) : !1;
          });
          var A = (0, i.getAtomHierarchyByUnit)(u.loci.bonds[0].aUnit, u.loci.bonds[0].aUnit.elements[u.loci.bonds[0].aIndex]), M = (0, i.getAtomHierarchyByUnit)(u.loci.bonds[0].bUnit, u.loci.bonds[0].bUnit.elements[u.loci.bonds[0].bIndex]), h = {
            infoA: A,
            infoB: M,
            ref: _,
            type: a.HighlightLabelType.Bond
          };
          return h;
        }
      }, s.prototype.clear = function() {
        this.hoverLoci = void 0;
      }, s;
    }()
  );
  return B1.HighlightManager = c, B1;
}
var eK = {};
(function(e) {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.ViewportScreenshotHelper = e.ViewportScreenshotResolutionOptions = void 0;
  var r = Te, t = Ay, n = tc, a = Ci, i = Tr(), o = Uy, c = Le, s = Ti;
  e.ViewportScreenshotResolutionOptions = [
    ["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"]
  ];
  var u = (
    /** @class */
    function() {
      function l(f) {
        this.plugin = f, this.ev = s.RxEventHelper.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 = function() {
          var d = document.createElement("canvas");
          return d;
        }(), this.previewCanvas = function() {
          var d = document.createElement("canvas");
          return d;
        }(), this.previewData = {
          image: { data: new Uint8ClampedArray(1), width: 1, height: 0 },
          background: (0, i.Color)(0),
          transparent: !1
        };
      }
      return l.prototype.createParams = function() {
        var f = Math.min(this.plugin.canvas3d ? this.plugin.canvas3d.webgl.maxRenderbufferSize : 4096, 4096);
        return {
          resolution: c.ParamDefinition.MappedStatic("ultra-hd", {
            viewport: c.ParamDefinition.Group({}),
            hd: c.ParamDefinition.Group({}),
            "full-hd": c.ParamDefinition.Group({}),
            "ultra-hd": c.ParamDefinition.Group({}),
            custom: c.ParamDefinition.Group({
              width: c.ParamDefinition.Numeric(1920, { min: 128, max: f, step: 1 }),
              height: c.ParamDefinition.Numeric(1080, { min: 128, max: f, step: 1 })
            }, { isFlat: !0 })
          }, {
            options: e.ViewportScreenshotResolutionOptions
          }),
          transparent: c.ParamDefinition.Boolean(!1),
          axes: t.CameraHelperParams.axes
        };
      }, Object.defineProperty(l.prototype, "params", {
        get: function() {
          return this._params ? this._params : this._params = this.createParams();
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(l.prototype, "values", {
        get: function() {
          return this.behaviors.values.value;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(l.prototype, "cropParams", {
        get: function() {
          return this.behaviors.cropParams.value;
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(l.prototype, "relativeCrop", {
        get: function() {
          return this.behaviors.relativeCrop.value;
        },
        enumerable: !1,
        configurable: !0
      }), l.prototype.getCanvasSize = function() {
        var f, d;
        return {
          width: ((f = this.plugin.canvas3d) === null || f === void 0 ? void 0 : f.webgl.gl.drawingBufferWidth) || 0,
          height: ((d = this.plugin.canvas3d) === null || d === void 0 ? void 0 : d.webgl.gl.drawingBufferHeight) || 0
        };
      }, l.prototype.getSize = function() {
        var f = this.values;
        switch (f.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: f.resolution.params.width,
              height: f.resolution.params.height
            };
        }
      }, l.prototype.createPass = function(f) {
        var d = this.plugin.canvas3d, m = d.webgl.extensions, p = m.colorBufferFloat, v = m.textureFloat, h = d.props.postprocessing.occlusion;
        return d.getImagePass({
          transparentBackground: this.values.transparent,
          cameraHelper: { axes: this.values.axes },
          multiSample: {
            mode: f ? "on" : "off",
            sampleLevel: p && v ? 4 : 2
          },
          postprocessing: (0, r.__assign)((0, r.__assign)({}, d.props.postprocessing), { occlusion: h.name === "on" ? {
            name: "on",
            params: (0, r.__assign)((0, r.__assign)({}, h.params), { samples: 128, resolutionScale: 1 })
          } : h }),
          marking: (0, r.__assign)({}, d.props.marking)
        });
      }, Object.defineProperty(l.prototype, "previewPass", {
        get: function() {
          return this._previewPass || (this._previewPass = this.createPass(!1));
        },
        enumerable: !1,
        configurable: !0
      }), Object.defineProperty(l.prototype, "imagePass", {
        get: function() {
          if (this._imagePass) {
            var f = this.plugin.canvas3d, d = f.props.postprocessing.occlusion;
            return this._imagePass.setProps({
              cameraHelper: { axes: this.values.axes },
              transparentBackground: this.values.transparent,
              // TODO: optimize because this creates a copy of a large object!
              postprocessing: (0, r.__assign)((0, r.__assign)({}, f.props.postprocessing), { occlusion: d.name === "on" ? {
                name: "on",
                params: (0, r.__assign)((0, r.__assign)({}, d.params), { samples: 128, resolutionScale: 1 })
              } : d }),
              marking: (0, r.__assign)({}, f.props.marking)
            }), this._imagePass;
          }
          return this._imagePass = this.createPass(!0);
        },
        enumerable: !1,
        configurable: !0
      }), l.prototype.resetCrop = function() {
        this.behaviors.relativeCrop.next({ x: 0, y: 0, width: 1, height: 1 });
      }, l.prototype.toggleAutocrop = function() {
        this.cropParams.auto ? (this.behaviors.cropParams.next((0, r.__assign)((0, r.__assign)({}, this.cropParams), { auto: !1 })), this.resetCrop()) : this.behaviors.cropParams.next((0, r.__assign)((0, r.__assign)({}, this.cropParams), { auto: !0 }));
      }, Object.defineProperty(l.prototype, "isFullFrame", {
        get: function() {
          var f = this.relativeCrop;
          return (0, a.equalEps)(f.x, 0, 1e-5) && (0, a.equalEps)(f.y, 0, 1e-5) && (0, a.equalEps)(f.width, 1, 1e-5) && (0, a.equalEps)(f.height, 1, 1e-5);
        },
        enumerable: !1,
        configurable: !0
      }), l.prototype.autocrop = function(f) {
        f === void 0 && (f = this.cropParams.relativePadding);
        for (var d = this.previewData.image, m = d.data, p = d.width, v = d.height, h = this.previewData.transparent, y = h ? this.previewData.background : 4278190080 | this.previewData.background, C = p, S = 0, b = v, g = 0, _ = 0; _ < v; _++)
          for (var A = _ * p, M = 0; M < p; M++) {
            var P = 4 * (A + M);
            if (h) {
              if (m[P + 3] === 0)
                continue;
            } else {
              var T = m[P] << 16 | m[P + 1] << 8 | m[P + 2] | m[P + 3] << 24;
              if (T === y)
                continue;
            }
            M < C && (C = M), M > S && (S = M), _ < b && (b = _), _ > g && (g = _);
          }
        if (C > S) {
          var x = C;
          C = S, S = x;
        }
        if (b > g) {
          var x = b;
          b = g, g = x;
        }
        var w = S - C + 1, E = g - b + 1;
        C -= f * w, S += f * w, b -= f * E, g += f * E;
        var I = {
          x: Math.max(0, C / p),
          y: Math.max(0, b / v),
          width: Math.min(1, (S - C + 1) / p),
          height: Math.min(1, (g - b + 1) / v)
        };
        this.behaviors.relativeCrop.next(I);
      }, l.prototype.getPreview = function(f) {
        f === void 0 && (f = 320);
        var d = this.getSize(), m = d.width, p = d.height;
        if (!(m <= 0 || p <= 0)) {
          var v = m / p, h = 0, y = 0;
          v > 1 ? (h = f, y = Math.round(f / v)) : (y = f, h = Math.round(f * v));
          var C = this.plugin.canvas3d.props;
          this.previewPass.setProps({
            cameraHelper: { axes: this.values.axes },
            transparentBackground: this.values.transparent,
            // TODO: optimize because this creates a copy of a large object!
            postprocessing: C.postprocessing,
            marking: C.marking
          });
          var S = this.previewPass.getImageData(h, y), b = this.previewCanvas;
          b.width = S.width, b.height = S.height, this.previewData.image = S, this.previewData.background = C.renderer.backgroundColor, this.previewData.transparent = this.values.transparent;
          var g = b.getContext("2d");
          if (!g)
            throw new Error("Could not create canvas 2d context");
          return g.putImageData(S, 0, 0), this.cropParams.auto && this.autocrop(), this.events.previewed.next(void 0), { canvas: b, width: h, height: y };
        }
      }, l.prototype.getSizeAndViewport = function() {
        var f = this.getSize(), d = f.width, m = f.height, p = this.relativeCrop, v = {
          x: Math.floor(p.x * d),
          y: Math.floor(p.y * m),
          width: Math.ceil(p.width * d),
          height: Math.ceil(p.height * m)
        };
        return v.width + v.x > d && (v.width = d - v.x), v.height + v.y > m && (v.height = m - v.y), { width: d, height: m, viewport: v };
      }, l.prototype.draw = function() {
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var f, d, m, p, v, h, y;
          return (0, r.__generator)(this, function(C) {
            if (f = this.getSizeAndViewport(), d = f.width, m = f.height, p = f.viewport, d <= 0 || m <= 0)
              return [
                2
                /*return*/
              ];
            if (v = this.imagePass.getImageData(d, m, p), h = this.canvas, h.width = v.width, h.height = v.height, y = h.getContext("2d"), !y)
              throw new Error("Could not create canvas 2d context");
            return y.putImageData(v, 0, 0), [
              2
              /*return*/
            ];
          });
        });
      }, l.prototype.getImageDataUri = function() {
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          return (0, r.__generator)(this, function(f) {
            switch (f.label) {
              case 0:
                return [4, this.draw()];
              case 1:
                return f.sent(), [2, this.canvas.toDataURL("png")];
            }
          });
        });
      }, l.prototype.copyToClipboard = function() {
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var f, d, m;
          return (0, r.__generator)(this, function(p) {
            switch (p.label) {
              case 0:
                return f = navigator.clipboard, f != null && f.write ? [4, this.draw()] : [
                  2
                  /*return*/
                ];
              case 1:
                return p.sent(), [4, (0, n.canvasToBlob)(this.canvas, "png")];
              case 2:
                return d = p.sent(), m = new ClipboardItem({ "image/png": d }), [4, f.write([m])];
              case 3:
                return p.sent(), [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, l.prototype.getAxesScale = function() {
        var f = this.getSize(), d = f.width * f.height;
        switch (!0) {
          case d <= 1280 * 720:
            return 0.22;
          case d <= 1920 * 1080:
            return 0.33;
          case d <= 3840 * 2160:
            return 0.5;
          default:
            return 0.65;
        }
      }, l.prototype.download = function(f) {
        return (0, r.__awaiter)(this, void 0, void 0, function() {
          var d;
          return (0, r.__generator)(this, function(m) {
            switch (m.label) {
              case 0:
                return this.behaviors.values.next({
                  transparent: this.values.transparent,
                  axes: (0, r.__assign)((0, r.__assign)({}, this.values.axes), { params: (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, this.params.axes.defaultValue), this.values.axes.params), { scale: this.getAxesScale() }) }),
                  resolution: this.values.resolution
                }), [4, this.draw()];
              case 1:
                return m.sent(), this.behaviors.cropParams.next((0, r.__assign)((0, r.__assign)({}, this.cropParams), { auto: !1 })), this.resetCrop(), [4, (0, n.canvasToBlob)(this.canvas, "png")];
              case 2:
                return d = m.sent(), (0, o.download)(d, f), this.behaviors.values.next({
                  transparent: this.values.transparent,
                  axes: (0, r.__assign)((0, r.__assign)({}, this.values.axes), { params: (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, this.params.axes.defaultValue), this.values.axes.params), { scale: 0.11 }) }),
                  resolution: this.values.resolution
                }), [
                  2
                  /*return*/
                ];
            }
          });
        });
      }, l;
    }()
  );
  e.ViewportScreenshotHelper = u;
})(eK);
var cR;
function ef() {
  return cR || (cR = 1, function(e) {
    Object.defineProperty(e, "__esModule", { value: !0 }), e.lightPlugin = e.LightPlugin = e.DefaultCanvas3DParams = void 0;
    var r = Te, t = iU, n = tc, a = xCe(), i = C4e(), o = Jt, c = A4e(), s = T4e(), u = w4e(), l = Le, f = N4e(), d = JA, m = U4e(), p = z4e(), v = sn(), h = Tr(), y = zp(), C = jA(), S = eK;
    e.DefaultCanvas3DParams = l.ParamDefinition.getDefaultValues(t.Canvas3DParams);
    var b = (
      /** @class */
      function() {
        function g() {
          this.mode = o.VisualizationMode.Drug, this.cells = /* @__PURE__ */ new Map(), this.managers = {
            camera: new a.CameraManager(this),
            representation: new i.RepresentationManager(this),
            cell: new c.CellManager(this),
            trajectory: new s.TrajectoryManager(this),
            snapshot: new u.SnapshotManager(this),
            selection: new f.SelectionManager(this),
            events: new d.EventsManager(this),
            highlight: new p.HighlightManager(this),
            editor: new m.EditorManager(this),
            screenshot: new S.ViewportScreenshotHelper(this)
          };
        }
        g.prototype.createCanvas = function(A, M) {
          var P = document.createElement("canvas");
          A.appendChild(P), (0, n.resizeCanvas)(P, A), this.layout = {
            root: A,
            canvas: P
          }, this.canvas3d = t.Canvas3D.create(t.Canvas3DContext.fromCanvas(P), l.ParamDefinition.merge(t.Canvas3DParams, l.ParamDefinition.getDefaultValues(t.Canvas3DParams), (0, r.__assign)({ 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: (0, r.__assign)((0, r.__assign)({}, e.DefaultCanvas3DParams.renderer), { backgroundColor: (0, h.Color)(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 }, M))), this.canvas3d.animate(), this.managers.representation.createContext(), this.managers.events.subscribe(), this.managers.editor.start();
        }, g.prototype.focus = function(A, M) {
          return (0, r.__awaiter)(this, void 0, void 0, function() {
            var P, T, x, w, E = this;
            return (0, r.__generator)(this, function(I) {
              switch (I.label) {
                case 0:
                  return P = [], T = new Set(A.map(function(B) {
                    var D, N, O;
                    return P.push.apply(P, (O = (N = (D = E.cells.get(B.ref)) === null || D === void 0 ? void 0 : D.dependency) === null || N === void 0 ? void 0 : N.by) !== null && O !== void 0 ? O : []), B.ref;
                  })), x = new Set(P), w = Array.from(this.cells).map(function(B) {
                    var D = B[0];
                    return { ref: D };
                  }).filter(function(B) {
                    return !T.has(B.ref) && !x.has(B.ref);
                  }), this.hide(w, !0), [4, this.show(A, M)];
                case 1:
                  return I.sent(), [2, w];
              }
            });
          });
        }, g.prototype.show = function(A, M) {
          var P;
          return (0, r.__awaiter)(this, void 0, void 0, function() {
            var T, x, w, E, I, B = this;
            return (0, r.__generator)(this, function(D) {
              switch (D.label) {
                case 0:
                  T = function(N) {
                    var O, V, k, G, L, R, F, U;
                    return (0, r.__generator)(this, function(H) {
                      switch (H.label) {
                        case 0:
                          return x.managers.cell.idleCellSet.delete(N.ref), O = x.managers.cell.get(N.ref), [4, x.managers.cell.getStructure(N.ref)];
                        case 1:
                          if (H.sent(), !O || !N.representationType && Array.from(O.representations.values()).some(function(q) {
                            return !q.isHidden;
                          }))
                            return [2, "continue"];
                          V = 0, k = Array.from(O.representations), H.label = 2;
                        case 2:
                          return V < k.length ? (G = k[V], L = G[0], R = G[1], R.state ? (R.isHidden && (!N.representationType || N.representationType === L) && ((P = x.canvas3d) === null || P === void 0 || P.add(R.state), O.representations.set(L, (0, r.__assign)((0, r.__assign)({}, R), { isHidden: !1 }))), [3, 5]) : [3, 3]) : [3, 6];
                        case 3:
                          return R.cache ? [4, e.lightPlugin.managers.cell.recoveryReprCache(O, (0, r.__assign)((0, r.__assign)({}, R.cache), { isHidden: !1 }))] : [3, 5];
                        case 4:
                          H.sent(), H.label = 5;
                        case 5:
                          return V++, [3, 2];
                        case 6:
                          return O.dependency.by.length && (F = [], U = O.dependency.by.filter(function(q) {
                            var K = B.cells.has(q);
                            if (!K)
                              F.push(q);
                            else {
                              var Y = B.cells.get(q);
                              if (Y.dependency.on.some(function(X) {
                                var Z, J;
                                return Array.from((J = (Z = B.cells.get(X.ref)) === null || Z === void 0 ? void 0 : Z.representations.values()) !== null && J !== void 0 ? J : []).filter(function($) {
                                  return $.isHidden !== !0;
                                }).length === 0;
                              }))
                                return !1;
                            }
                            return K;
                          }), x.show(U.map(function(q) {
                            return { ref: q };
                          }), !0), F.length && x.managers.cell.update(N.ref, {
                            model: {},
                            dependency: { by: U }
                          })), [
                            2
                            /*return*/
                          ];
                      }
                    });
                  }, x = this, w = 0, E = A, D.label = 1;
                case 1:
                  return w < E.length ? (I = E[w], [5, T(I)]) : [3, 4];
                case 2:
                  D.sent(), D.label = 3;
                case 3:
                  return w++, [3, 1];
                case 4:
                  return M || this.managers.cell.traverse(function(N, O) {
                    O.type === o.RepresentationType.IntraInteractions && B.managers.representation.showGlobalInteraction(void 0, "lightPlugin.show");
                  }), this.managers.snapshot.event.changed.next({ from: "show" }), [
                    2
                    /*return*/
                  ];
              }
            });
          });
        }, g.prototype.hide = function(A, M) {
          var P = this;
          A.forEach(function(T) {
            P.managers.cell.idleCellSet.add(T.ref);
            var x = P.cells.get(T.ref);
            if (x && (P.managers.selection.shape.selection.has(T.ref) && P.managers.selection.shape.remove({ item: T }), P.managers.selection.structure.selection.has(T.ref) && P.managers.selection.structure.remove({ item: { ref: T.ref, elementIds: (0, v.getElementsFromStructure)((0, v.getStructureByCell)(x)) } }), x.representations.forEach(function(I, B) {
              var D;
              !I.isHidden && (!T.representationType || T.representationType === B) && (I.state && ((D = P.canvas3d) === null || D === void 0 || D.remove(I.state)), x.representations.set(B, (0, r.__assign)((0, r.__assign)((0, r.__assign)({}, I), { isHidden: !0 }), I.cache ? {
                cache: (0, r.__assign)((0, r.__assign)({}, I.cache), { isHidden: !0 })
              } : {})));
            }), x.dependency.by.length)) {
              var w = [], E = x.dependency.by.filter(function(I) {
                var B = P.cells.has(I);
                B || w.push(I);
                var D = P.cells.get(I);
                return D != null && D.representations.has(o.RepresentationType.IntraInteractions) ? !1 : B;
              });
              P.hide(E.map(function(I) {
                return { ref: I };
              }), !0), w.length && P.managers.cell.update(T.ref, {
                model: {},
                dependency: { by: E }
              });
            }
          }), M || this.managers.cell.traverse(function(T, x) {
            x.type === o.RepresentationType.IntraInteractions && P.managers.representation.showGlobalInteraction(void 0, "lightPlugin.show");
          }), this.managers.snapshot.event.changed.next({ from: "hide" });
        }, g.prototype.toggle = function(A) {
          var M = this, P = A.types, T = A.forceAction, x = A.refs, w = Array.from(this.cells).filter(function(B) {
            var D = B[0], N = B[1], O = (!x || x.includes(D)) && P.some(function(V) {
              return N.representations.get(V);
            });
            return !(!O || !N.dependency.on.every(function(V) {
              var k = M.cells.get(V.ref);
              return !(!k || Array.from(k.representations.values()).every(function(G) {
                return G.isHidden === !0;
              }));
            }));
          });
          if (w.length) {
            var E = T ?? w.some(function(B) {
              B[0];
              var D = B[1];
              return P.some(function(N) {
                var O;
                return (O = D.representations.get(N)) === null || O === void 0 ? void 0 : O.isHidden;
              });
            }) ? "show" : "hide", I = (0, v.flattenDeep)(w.map(function(B) {
              var D = B[0], N = B[1];
              return Array.from(N.representations).filter(function(O) {
                var V = O[0];
                return P.includes(V);
              }).map(function(O) {
                var V = O[0];
                return {
                  representationType: V,
                  ref: D
                };
              });
            }));
            this[E](I);
          }
        }, g.prototype.refresh = function(A) {
          var M, P, T, x;
          if (!(!this.canvas3d || !(!((P = (M = this.layout) === null || M === void 0 ? void 0 : M.root.children[0]) === null || P === void 0) && P.clientWidth))) {
            var w;
            A != null && A.fixCamera && (w = this.canvas3d.camera.getSnapshot()), (0, n.resizeCanvas)(this.layout.canvas, this.layout.root), (T = this.canvas3d) === null || T === void 0 || T.handleResize(), A != null && A.fixCamera ? (x = this.canvas3d) === null || x === void 0 || x.camera.setState(w) : this.managers.camera.focus();
          }
        }, g.prototype.clear = function() {
          var A;
          this.managers.selection.clear(), this.managers.highlight.clear(), this.managers.editor.changeEditorMode(m.EditorMode.None), this.cells = /* @__PURE__ */ new Map(), (A = this.canvas3d) === null || A === void 0 || A.clear();
        }, g.prototype.dispose = function() {
          var A;
          (A = this.canvas3d) === null || A === void 0 || A.dispose(), this.layout = void 0, this.canvas3d = void 0, this.cells = /* @__PURE__ */ new Map(), this.managers = {
            camera: new a.CameraManager(this),
            representation: new i.RepresentationManager(this),
            cell: new c.CellManager(this),
            trajectory: new s.TrajectoryManager(this),
            snapshot: new u.SnapshotManager(this),
            selection: new f.SelectionManager(this),
            events: new d.EventsManager(this),
            highlight: new p.HighlightManager(this),
            editor: new m.EditorManager(this),
            screenshot: new S.ViewportScreenshotHelper(this)
          };
        };
        var _;
        return _ = g, g.Utils = {
          sliceCellItems: function(A, M) {
            return (0, v.sliceCellItemsByGranularity)(e.lightPlugin, A, M);
          },
          queryCellItems: function(A) {
            return (0, v.queryCellItemsByHierarchyType)(e.lightPlugin, A);
          },
          exportToPdb: function(A) {
            return (0, r.__awaiter)(void 0, void 0, void 0, function() {
              var M;
              return (0, r.__generator)(_, function(P) {
                switch (P.label) {
                  case 0:
                    return [4, e.lightPlugin.managers.cell.getStructure(A.ref)];
                  case 1:
                    return M = P.sent(), [2, (0, y.parseToPDB)(M, A.elementIds, !1)];
                }
              });
            });
          },
          getBox: function(A) {
            return (0, r.__awaiter)(void 0, void 0, void 0, function() {
              var M, P;
              return (0, r.__generator)(_, function(T) {
                switch (T.label) {
                  case 0:
                    return [4, e.lightPlugin.managers.cell.getStructure(A.ref)];
                  case 1:
                    return M = T.sent(), [2, (0, C.getBox)(M, (P = A.elementIds) !== null && P !== void 0 ? P : [])];
                }
              });
            });
          },
          splitMolecularContent: function(A, M) {
            return (0, y.splitMolecularContent)(A, M);
          },
          checkMolecularContentVerify: function(A, M) {
            return (0, y.checkFileFormat)(A, M);
          },
          getMergedContent: function(A) {
            return (0, v.getMergedContent)(e.lightPlugin, A);
          },
          traverseAtoms: function(A, M) {
            return (0, r.__awaiter)(void 0, void 0, void 0, function() {
              var P;
              return (0, r.__generator)(_, function(T) {
                switch (T.label) {
                  case 0:
                    return [4, e.lightPlugin.managers.cell.getStructure(A)];
                  case 1:
                    return P = T.sent(), P ? ((0, v.traverseAtoms)(P, M), [
                      2
                      /*return*/
                    ]) : [
                      2
                      /*return*/
                    ];
                }
              });
            });
          }
        }, g;
      }()
    );
    e.LightPlugin = b, e.lightPlugin = new b(), (0, r.__exportStar)(Jt, e);
  }(Dx)), Dx;
}
var Gf = ef(), G4e = sn();
function Xa() {
  return Xa = Object.assign ? Object.assign.bind() : function(e) {
    for (var r = 1; r < arguments.length; r++) {
      var t = arguments[r];
      for (var n in t) ({}).hasOwnProperty.call(t, n) && (e[n] = t[n]);
    }
    return e;
  }, Xa.apply(null, arguments);
}
var ex = {
  // 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 Or(e) {
  return typeof e == "number";
}
function Ir(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 rK(e) {
  return typeof e == "bigint";
}
function as(e) {
  return e && typeof e == "object" && Object.getPrototypeOf(e).isComplex === !0 || !1;
}
function J0(e) {
  return e && typeof e == "object" && Object.getPrototypeOf(e).isFraction === !0 || !1;
}
function ho(e) {
  return e && e.constructor.prototype.isUnit === !0 || !1;
}
function Ya(e) {
  return typeof e == "string";
}
var dt = Array.isArray;
function gr(e) {
  return e && e.constructor.prototype.isMatrix === !0 || !1;
}
function Xo(e) {
  return Array.isArray(e) || gr(e);
}
function Fg(e) {
  return e && e.isDenseMatrix && e.constructor.prototype.isMatrix === !0 || !1;
}
function dd(e) {
  return e && e.isSparseMatrix && e.constructor.prototype.isMatrix === !0 || !1;
}
function rx(e) {
  return e && e.constructor.prototype.isRange === !0 || !1;
}
function zy(e) {
  return e && e.constructor.prototype.isIndex === !0 || !1;
}
function tK(e) {
  return typeof e == "boolean";
}
function nK(e) {
  return e && e.constructor.prototype.isResultSet === !0 || !1;
}
function bD(e) {
  return e && e.constructor.prototype.isHelp === !0 || !1;
}
function aK(e) {
  return typeof e == "function";
}
function iK(e) {
  return e instanceof Date;
}
function oK(e) {
  return e instanceof RegExp;
}
function Gy(e) {
  return !!(e && typeof e == "object" && e.constructor === Object && !as(e) && !J0(e));
}
function uK(e) {
  return e === null;
}
function sK(e) {
  return e === void 0;
}
function Fd(e) {
  return e && e.isAccessorNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function jo(e) {
  return e && e.isArrayNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function lK(e) {
  return e && e.isAssignmentNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function cK(e) {
  return e && e.isBlockNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function dK(e) {
  return e && e.isConditionalNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function Jr(e) {
  return e && e.isConstantNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function pw(e) {
  return Jr(e) || Hn(e) && e.args.length === 1 && Jr(e.args[0]) && "-+~".includes(e.op);
}
function Kp(e) {
  return e && e.isFunctionAssignmentNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function hc(e) {
  return e && e.isFunctionNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function em(e) {
  return e && e.isIndexNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function St(e) {
  return e && e.isNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function qy(e) {
  return e && e.isObjectNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function Hn(e) {
  return e && e.isOperatorNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function sl(e) {
  return e && e.isParenthesisNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function fK(e) {
  return e && e.isRangeNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function mK(e) {
  return e && e.isRelationalNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function _a(e) {
  return e && e.isSymbolNode === !0 && e.constructor.prototype.isNode === !0 || !1;
}
function SD(e) {
  return e && e.constructor.prototype.isChain === !0 || !1;
}
function Et(e) {
  var r = typeof e;
  return r === "object" ? e === null ? "null" : Ir(e) ? "BigNumber" : e.constructor && e.constructor.name ? e.constructor.name : "Object" : r;
}
function Sr(e) {
  var r = typeof e;
  if (r === "number" || r === "bigint" || r === "string" || r === "boolean" || e === null || e === void 0)
    return e;
  if (typeof e.clone == "function")
    return e.clone();
  if (Array.isArray(e))
    return e.map(function(t) {
      return Sr(t);
    });
  if (e instanceof Date) return new Date(e.valueOf());
  if (Ir(e)) return e;
  if (Gy(e))
    return q4e(e, Sr);
  throw new TypeError("Cannot clone: unknown type of value (value: ".concat(e, ")"));
}
function q4e(e, r) {
  var t = {};
  for (var n in e)
    er(e, n) && (t[n] = r(e[n]));
  return t;
}
function vK(e, r) {
  for (var t in r)
    er(r, t) && (e[t] = r[t]);
  return e;
}
function pK(e, r) {
  if (Array.isArray(r))
    throw new TypeError("Arrays are not supported by deepExtend");
  for (var t in r)
    if (er(r, t) && !(t in Object.prototype) && !(t in Function.prototype))
      if (r[t] && r[t].constructor === Object)
        e[t] === void 0 && (e[t] = {}), e[t] && e[t].constructor === Object ? pK(e[t], r[t]) : e[t] = r[t];
      else {
        if (Array.isArray(r[t]))
          throw new TypeError("Arrays are not supported by deepExtend");
        e[t] = r[t];
      }
  return e;
}
function gc(e, r) {
  var t, n, a;
  if (Array.isArray(e)) {
    if (!Array.isArray(r) || e.length !== r.length)
      return !1;
    for (n = 0, a = e.length; n < a; n++)
      if (!gc(e[n], r[n]))
        return !1;
    return !0;
  } else {
    if (typeof e == "function")
      return e === r;
    if (e instanceof Object) {
      if (Array.isArray(r) || !(r instanceof Object))
        return !1;
      for (t in e)
        if (!(t in r) || !gc(e[t], r[t]))
          return !1;
      for (t in r)
        if (!(t in e))
          return !1;
      return !0;
    } else
      return e === r;
  }
}
function H4e(e) {
  var r = {};
  return hK(e, r), r;
}
function hK(e, r) {
  for (var t in e)
    if (er(e, t)) {
      var n = e[t];
      typeof n == "object" && n !== null ? hK(n, r) : r[t] = n;
    }
}
function mb(e, r, t) {
  var n = !0, a;
  Object.defineProperty(e, r, {
    get: function() {
      return n && (a = t(), n = !1), a;
    },
    set: function(o) {
      a = o, n = !1;
    },
    configurable: !0,
    enumerable: !0
  });
}
function er(e, r) {
  return e && Object.hasOwnProperty.call(e, r);
}
function j4e(e) {
  return e && typeof e.factory == "function";
}
function $4e(e, r) {
  for (var t = {}, n = 0; n < r.length; n++) {
    var a = r[n], i = e[a];
    i !== void 0 && (t[a] = i);
  }
  return t;
}
var hw = ["Matrix", "Array"], gw = ["number", "BigNumber", "Fraction"];
function K4e(e, r) {
  function t(n) {
    if (n) {
      if (n.epsilon !== void 0) {
        console.warn('Warning: The configuration option "epsilon" is deprecated. Use "relTol" and "absTol" instead.');
        var a = Sr(n);
        return a.relTol = n.epsilon, a.absTol = n.epsilon * 1e-3, delete a.epsilon, t(a);
      }
      var i = Sr(e);
      dR(n, "matrix", hw), dR(n, "number", gw), pK(e, n);
      var o = Sr(e), c = Sr(n);
      return r("config", o, i, c), o;
    } else
      return Sr(e);
  }
  return t.MATRIX_OPTIONS = hw, t.NUMBER_OPTIONS = gw, Object.keys(ex).forEach((n) => {
    Object.defineProperty(t, n, {
      get: () => e[n],
      enumerable: !0,
      configurable: !0
    });
  }), t;
}
function dR(e, r, t) {
  e[r] !== void 0 && !t.includes(e[r]) && console.warn('Warning: Unknown value "' + e[r] + '" for configuration option "' + r + '". Available options: ' + t.map((n) => JSON.stringify(n)).join(", ") + ".");
}
var wi = function(r) {
  if (r)
    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(ex);
};
Xa(wi, ex, {
  MATRIX_OPTIONS: hw,
  NUMBER_OPTIONS: gw
});
function fR() {
  return !0;
}
function vu() {
  return !1;
}
function Um() {
}
const mR = "Argument is not a typed-function.";
function gK() {
  function e(re) {
    return typeof re == "object" && re !== null && re.constructor === Object;
  }
  const r = [{
    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;
    }
  }], t = {
    name: "any",
    test: fR,
    isAny: !0
  };
  let n, a, i = 0, o = {
    createCount: 0
  };
  function c(re) {
    const ee = n.get(re);
    if (ee)
      return ee;
    let ne = 'Unknown type "' + re + '"';
    const se = re.toLowerCase();
    let ce;
    for (ce of a)
      if (ce.toLowerCase() === se) {
        ne += '. Did you mean "' + ce + '" ?';
        break;
      }
    throw new TypeError(ne);
  }
  function s(re) {
    let ee = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "any";
    const ne = ee ? c(ee).index : a.length, se = [];
    for (let de = 0; de < re.length; ++de) {
      if (!re[de] || typeof re[de].name != "string" || typeof re[de].test != "function")
        throw new TypeError("Object with properties {name: string, test: function} expected");
      const me = re[de].name;
      if (n.has(me))
        throw new TypeError('Duplicate type name "' + me + '"');
      se.push(me), n.set(me, {
        name: me,
        test: re[de].test,
        isAny: re[de].isAny,
        index: ne + de,
        conversionsTo: []
        // Newly added type can't have any conversions to it
      });
    }
    const ce = a.slice(ne);
    a = a.slice(0, ne).concat(se).concat(ce);
    for (let de = ne + se.length; de < a.length; ++de)
      n.get(a[de]).index = de;
  }
  function u() {
    n = /* @__PURE__ */ new Map(), a = [], i = 0, s([t], !1);
  }
  u(), s(r);
  function l() {
    let re;
    for (re of a)
      n.get(re).conversionsTo = [];
    i = 0;
  }
  function f(re) {
    const ee = a.filter((ne) => {
      const se = n.get(ne);
      return !se.isAny && se.test(re);
    });
    return ee.length ? ee : ["any"];
  }
  function d(re) {
    return re && typeof re == "function" && "_typedFunctionData" in re;
  }
  function m(re, ee, ne) {
    if (!d(re))
      throw new TypeError(mR);
    const se = ne && ne.exact, ce = Array.isArray(ee) ? ee.join(",") : ee, de = b(ce), me = h(de);
    if (!se || me in re.signatures) {
      const Pe = re._typedFunctionData.signatureMap.get(me);
      if (Pe)
        return Pe;
    }
    const he = de.length;
    let _e;
    if (se) {
      _e = [];
      let Pe;
      for (Pe in re.signatures)
        _e.push(re._typedFunctionData.signatureMap.get(Pe));
    } else
      _e = re._typedFunctionData.signatures;
    for (let Pe = 0; Pe < he; ++Pe) {
      const De = de[Pe], Ee = [];
      let Me;
      for (Me of _e) {
        const ue = M(Me.params, Pe);
        if (!(!ue || De.restParam && !ue.restParam)) {
          if (!ue.hasAny) {
            const pe = S(ue);
            if (De.types.some((Ae) => !pe.has(Ae.name)))
              continue;
          }
          Ee.push(Me);
        }
      }
      if (_e = Ee, _e.length === 0) break;
    }
    let Se;
    for (Se of _e)
      if (Se.params.length <= he)
        return Se;
    throw new TypeError("Signature not found (signature: " + (re.name || "unnamed") + "(" + h(de, ", ") + "))");
  }
  function p(re, ee, ne) {
    return m(re, ee, ne).implementation;
  }
  function v(re, ee) {
    const ne = c(ee);
    if (ne.test(re))
      return re;
    const se = ne.conversionsTo;
    if (se.length === 0)
      throw new Error("There are no conversions to " + ee + " defined.");
    for (let ce = 0; ce < se.length; ce++)
      if (c(se[ce].from).test(re))
        return se[ce].convert(re);
    throw new Error("Cannot convert " + re + " to " + ee);
  }
  function h(re) {
    let ee = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ",";
    return re.map((ne) => ne.name).join(ee);
  }
  function y(re) {
    const ee = re.indexOf("...") === 0, se = (ee ? re.length > 3 ? re.slice(3) : "any" : re).split("|").map((he) => c(he.trim()));
    let ce = !1, de = ee ? "..." : "";
    return {
      types: se.map(function(he) {
        return ce = he.isAny || ce, de += he.name + "|", {
          name: he.name,
          typeIndex: he.index,
          test: he.test,
          isAny: he.isAny,
          conversion: null,
          conversionIndex: -1
        };
      }),
      name: de.slice(0, -1),
      // remove trailing '|' from above
      hasAny: ce,
      hasConversion: !1,
      restParam: ee
    };
  }
  function C(re) {
    const ee = re.types.map((me) => me.name), ne = N(ee);
    let se = re.hasAny, ce = re.name;
    const de = ne.map(function(me) {
      const he = c(me.from);
      return se = he.isAny || se, ce += "|" + me.from, {
        name: me.from,
        typeIndex: he.index,
        test: he.test,
        isAny: he.isAny,
        conversion: me,
        conversionIndex: me.index
      };
    });
    return {
      types: re.types.concat(de),
      name: ce,
      hasAny: se,
      hasConversion: de.length > 0,
      restParam: re.restParam
    };
  }
  function S(re) {
    return re.typeSet || (re.typeSet = /* @__PURE__ */ new Set(), re.types.forEach((ee) => re.typeSet.add(ee.name))), re.typeSet;
  }
  function b(re) {
    const ee = [];
    if (typeof re != "string")
      throw new TypeError("Signatures must be strings");
    const ne = re.trim();
    if (ne === "")
      return ee;
    const se = ne.split(",");
    for (let ce = 0; ce < se.length; ++ce) {
      const de = y(se[ce].trim());
      if (de.restParam && ce !== se.length - 1)
        throw new SyntaxError('Unexpected rest parameter "' + se[ce] + '": only allowed for the last parameter');
      if (de.types.length === 0)
        return null;
      ee.push(de);
    }
    return ee;
  }
  function g(re) {
    const ee = Y(re);
    return ee ? ee.restParam : !1;
  }
  function _(re) {
    if (!re || re.types.length === 0)
      return fR;
    if (re.types.length === 1)
      return c(re.types[0].name).test;
    if (re.types.length === 2) {
      const ee = c(re.types[0].name).test, ne = c(re.types[1].name).test;
      return function(ce) {
        return ee(ce) || ne(ce);
      };
    } else {
      const ee = re.types.map(function(ne) {
        return c(ne.name).test;
      });
      return function(se) {
        for (let ce = 0; ce < ee.length; ce++)
          if (ee[ce](se))
            return !0;
        return !1;
      };
    }
  }
  function A(re) {
    let ee, ne, se;
    if (g(re)) {
      ee = K(re).map(_);
      const ce = ee.length, de = _(Y(re)), me = function(he) {
        for (let _e = ce; _e < he.length; _e++)
          if (!de(he[_e]))
            return !1;
        return !0;
      };
      return function(_e) {
        for (let Se = 0; Se < ee.length; Se++)
          if (!ee[Se](_e[Se]))
            return !1;
        return me(_e) && _e.length >= ce + 1;
      };
    } else
      return re.length === 0 ? function(de) {
        return de.length === 0;
      } : re.length === 1 ? (ne = _(re[0]), function(de) {
        return ne(de[0]) && de.length === 1;
      }) : re.length === 2 ? (ne = _(re[0]), se = _(re[1]), function(de) {
        return ne(de[0]) && se(de[1]) && de.length === 2;
      }) : (ee = re.map(_), function(de) {
        for (let me = 0; me < ee.length; me++)
          if (!ee[me](de[me]))
            return !1;
        return de.length === ee.length;
      });
  }
  function M(re, ee) {
    return ee < re.length ? re[ee] : g(re) ? Y(re) : null;
  }
  function P(re, ee) {
    const ne = M(re, ee);
    return ne ? S(ne) : /* @__PURE__ */ new Set();
  }
  function T(re) {
    return re.conversion === null || re.conversion === void 0;
  }
  function x(re, ee) {
    const ne = /* @__PURE__ */ new Set();
    return re.forEach((se) => {
      const ce = P(se.params, ee);
      let de;
      for (de of ce)
        ne.add(de);
    }), ne.has("any") ? ["any"] : Array.from(ne);
  }
  function w(re, ee, ne) {
    let se, ce;
    const de = re || "unnamed";
    let me = ne, he;
    for (he = 0; he < ee.length; he++) {
      const De = [];
      if (me.forEach((Ee) => {
        const Me = M(Ee.params, he), ue = _(Me);
        (he < Ee.params.length || g(Ee.params)) && ue(ee[he]) && De.push(Ee);
      }), De.length === 0) {
        if (ce = x(me, he), ce.length > 0) {
          const Ee = f(ee[he]);
          return se = new TypeError("Unexpected type of argument in function " + de + " (expected: " + ce.join(" or ") + ", actual: " + Ee.join(" | ") + ", index: " + he + ")"), se.data = {
            category: "wrongType",
            fn: de,
            index: he,
            actual: Ee,
            expected: ce
          }, se;
        }
      } else
        me = De;
    }
    const _e = me.map(function(De) {
      return g(De.params) ? 1 / 0 : De.params.length;
    });
    if (ee.length < Math.min.apply(null, _e))
      return ce = x(me, he), se = new TypeError("Too few arguments in function " + de + " (expected: " + ce.join(" or ") + ", index: " + ee.length + ")"), se.data = {
        category: "tooFewArgs",
        fn: de,
        index: ee.length,
        expected: ce
      }, se;
    const Se = Math.max.apply(null, _e);
    if (ee.length > Se)
      return se = new TypeError("Too many arguments in function " + de + " (expected: " + Se + ", actual: " + ee.length + ")"), se.data = {
        category: "tooManyArgs",
        fn: de,
        index: ee.length,
        expectedLength: Se
      }, se;
    const Pe = [];
    for (let De = 0; De < ee.length; ++De)
      Pe.push(f(ee[De]).join("|"));
    return se = new TypeError('Arguments of type "' + Pe.join(", ") + '" do not match any of the defined signatures of function ' + de + "."), se.data = {
      category: "mismatch",
      actual: Pe
    }, se;
  }
  function E(re) {
    let ee = a.length + 1;
    for (let ne = 0; ne < re.types.length; ne++)
      T(re.types[ne]) && (ee = Math.min(ee, re.types[ne].typeIndex));
    return ee;
  }
  function I(re) {
    let ee = i + 1;
    for (let ne = 0; ne < re.types.length; ne++)
      T(re.types[ne]) || (ee = Math.min(ee, re.types[ne].conversionIndex));
    return ee;
  }
  function B(re, ee) {
    if (re.hasAny) {
      if (!ee.hasAny)
        return 1;
    } else if (ee.hasAny)
      return -1;
    if (re.restParam) {
      if (!ee.restParam)
        return 1;
    } else if (ee.restParam)
      return -1;
    if (re.hasConversion) {
      if (!ee.hasConversion)
        return 1;
    } else if (ee.hasConversion)
      return -1;
    const ne = E(re) - E(ee);
    if (ne < 0)
      return -1;
    if (ne > 0)
      return 1;
    const se = I(re) - I(ee);
    return se < 0 ? -1 : se > 0 ? 1 : 0;
  }
  function D(re, ee) {
    const ne = re.params, se = ee.params, ce = Y(ne), de = Y(se), me = g(ne), he = g(se);
    if (me && ce.hasAny) {
      if (!he || !de.hasAny)
        return 1;
    } else if (he && de.hasAny)
      return -1;
    let _e = 0, Se = 0, Pe;
    for (Pe of ne)
      Pe.hasAny && ++_e, Pe.hasConversion && ++Se;
    let De = 0, Ee = 0;
    for (Pe of se)
      Pe.hasAny && ++De, Pe.hasConversion && ++Ee;
    if (_e !== De)
      return _e - De;
    if (me && ce.hasConversion) {
      if (!he || !de.hasConversion)
        return 1;
    } else if (he && de.hasConversion)
      return -1;
    if (Se !== Ee)
      return Se - Ee;
    if (me) {
      if (!he)
        return 1;
    } else if (he)
      return -1;
    const Me = (ne.length - se.length) * (me ? -1 : 1);
    if (Me !== 0)
      return Me;
    const ue = [];
    let pe = 0;
    for (let ye = 0; ye < ne.length; ++ye) {
      const be = B(ne[ye], se[ye]);
      ue.push(be), pe += be;
    }
    if (pe !== 0)
      return pe;
    let Ae;
    for (Ae of ue)
      if (Ae !== 0)
        return Ae;
    return 0;
  }
  function N(re) {
    if (re.length === 0)
      return [];
    const ee = re.map(c);
    re.length > 1 && ee.sort((ce, de) => ce.index - de.index);
    let ne = ee[0].conversionsTo;
    if (re.length === 1)
      return ne;
    ne = ne.concat([]);
    const se = new Set(re);
    for (let ce = 1; ce < ee.length; ++ce) {
      let de;
      for (de of ee[ce].conversionsTo)
        se.has(de.from) || (ne.push(de), se.add(de.from));
    }
    return ne;
  }
  function O(re, ee) {
    let ne = ee;
    if (re.some((ce) => ce.hasConversion)) {
      const ce = g(re), de = re.map(V);
      ne = function() {
        const he = [], _e = ce ? arguments.length - 1 : arguments.length;
        for (let Se = 0; Se < _e; Se++)
          he[Se] = de[Se](arguments[Se]);
        return ce && (he[_e] = arguments[_e].map(de[_e])), ee.apply(this, he);
      };
    }
    let se = ne;
    if (g(re)) {
      const ce = re.length - 1;
      se = function() {
        return ne.apply(this, X(arguments, 0, ce).concat([X(arguments, ce)]));
      };
    }
    return se;
  }
  function V(re) {
    let ee, ne, se, ce;
    const de = [], me = [];
    switch (re.types.forEach(function(he) {
      he.conversion && (de.push(c(he.conversion.from).test), me.push(he.conversion.convert));
    }), me.length) {
      case 0:
        return function(_e) {
          return _e;
        };
      case 1:
        return ee = de[0], se = me[0], function(_e) {
          return ee(_e) ? se(_e) : _e;
        };
      case 2:
        return ee = de[0], ne = de[1], se = me[0], ce = me[1], function(_e) {
          return ee(_e) ? se(_e) : ne(_e) ? ce(_e) : _e;
        };
      default:
        return function(_e) {
          for (let Se = 0; Se < me.length; Se++)
            if (de[Se](_e))
              return me[Se](_e);
          return _e;
        };
    }
  }
  function k(re) {
    function ee(ne, se, ce) {
      if (se < ne.length) {
        const de = ne[se];
        let me = [];
        if (de.restParam) {
          const he = de.types.filter(T);
          he.length < de.types.length && me.push({
            types: he,
            name: "..." + he.map((_e) => _e.name).join("|"),
            hasAny: he.some((_e) => _e.isAny),
            hasConversion: !1,
            restParam: !0
          }), me.push(de);
        } else
          me = de.types.map(function(he) {
            return {
              types: [he],
              name: he.name,
              hasAny: he.isAny,
              hasConversion: he.conversion,
              restParam: !1
            };
          });
        return J(me, function(he) {
          return ee(ne, se + 1, ce.concat([he]));
        });
      } else
        return [ce];
    }
    return ee(re, 0, []);
  }
  function G(re, ee) {
    const ne = Math.max(re.length, ee.length);
    for (let he = 0; he < ne; he++) {
      const _e = P(re, he), Se = P(ee, he);
      let Pe = !1, De;
      for (De of Se)
        if (_e.has(De)) {
          Pe = !0;
          break;
        }
      if (!Pe)
        return !1;
    }
    const se = re.length, ce = ee.length, de = g(re), me = g(ee);
    return de ? me ? se === ce : ce >= se : me ? se >= ce : se === ce;
  }
  function L(re) {
    return re.map((ee) => oe(ee) ? W(ee.referToSelf.callback) : te(ee) ? Q(ee.referTo.references, ee.referTo.callback) : ee);
  }
  function R(re, ee, ne) {
    const se = [];
    let ce;
    for (ce of re) {
      let de = ne[ce];
      if (typeof de != "number")
        throw new TypeError('No definition for referenced signature "' + ce + '"');
      if (de = ee[de], typeof de != "function")
        return !1;
      se.push(de);
    }
    return se;
  }
  function F(re, ee, ne) {
    const se = L(re), ce = new Array(se.length).fill(!1);
    let de = !0;
    for (; de; ) {
      de = !1;
      let me = !0;
      for (let he = 0; he < se.length; ++he) {
        if (ce[he]) continue;
        const _e = se[he];
        if (oe(_e))
          se[he] = _e.referToSelf.callback(ne), se[he].referToSelf = _e.referToSelf, ce[he] = !0, me = !1;
        else if (te(_e)) {
          const Se = R(_e.referTo.references, se, ee);
          Se ? (se[he] = _e.referTo.callback.apply(this, Se), se[he].referTo = _e.referTo, ce[he] = !0, me = !1) : de = !0;
        }
      }
      if (me && de)
        throw new SyntaxError("Circular reference detected in resolving typed.referTo");
    }
    return se;
  }
  function U(re) {
    const ee = /\bthis(\(|\.signatures\b)/;
    Object.keys(re).forEach((ne) => {
      const se = re[ne];
      if (ee.test(se.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 H(re, ee) {
    if (o.createCount++, Object.keys(ee).length === 0)
      throw new SyntaxError("No signatures provided");
    o.warnAgainstDeprecatedThis && U(ee);
    const ne = [], se = [], ce = {}, de = [];
    let me;
    for (me in ee) {
      if (!Object.prototype.hasOwnProperty.call(ee, me))
        continue;
      const Yr = b(me);
      if (!Yr) continue;
      ne.forEach(function(ar) {
        if (G(ar, Yr))
          throw new TypeError('Conflicting signatures "' + h(ar) + '" and "' + h(Yr) + '".');
      }), ne.push(Yr);
      const rn = se.length;
      se.push(ee[me]);
      const Ps = Yr.map(C);
      let Ge;
      for (Ge of k(Ps)) {
        const ar = h(Ge);
        de.push({
          params: Ge,
          name: ar,
          fn: rn
        }), Ge.every((Er) => !Er.hasConversion) && (ce[ar] = rn);
      }
    }
    de.sort(D);
    const he = F(se, ce, xa);
    let _e;
    for (_e in ce)
      Object.prototype.hasOwnProperty.call(ce, _e) && (ce[_e] = he[ce[_e]]);
    const Se = [], Pe = /* @__PURE__ */ new Map();
    for (_e of de)
      Pe.has(_e.name) || (_e.fn = he[_e.fn], Se.push(_e), Pe.set(_e.name, _e));
    const De = Se[0] && Se[0].params.length <= 2 && !g(Se[0].params), Ee = Se[1] && Se[1].params.length <= 2 && !g(Se[1].params), Me = Se[2] && Se[2].params.length <= 2 && !g(Se[2].params), ue = Se[3] && Se[3].params.length <= 2 && !g(Se[3].params), pe = Se[4] && Se[4].params.length <= 2 && !g(Se[4].params), Ae = Se[5] && Se[5].params.length <= 2 && !g(Se[5].params), ye = De && Ee && Me && ue && pe && Ae;
    for (let Yr = 0; Yr < Se.length; ++Yr)
      Se[Yr].test = A(Se[Yr].params);
    const be = De ? _(Se[0].params[0]) : vu, fe = Ee ? _(Se[1].params[0]) : vu, ge = Me ? _(Se[2].params[0]) : vu, xe = ue ? _(Se[3].params[0]) : vu, we = pe ? _(Se[4].params[0]) : vu, Ve = Ae ? _(Se[5].params[0]) : vu, Ne = De ? _(Se[0].params[1]) : vu, Oe = Ee ? _(Se[1].params[1]) : vu, ze = Me ? _(Se[2].params[1]) : vu, ke = ue ? _(Se[3].params[1]) : vu, je = pe ? _(Se[4].params[1]) : vu, Xe = Ae ? _(Se[5].params[1]) : vu;
    for (let Yr = 0; Yr < Se.length; ++Yr)
      Se[Yr].implementation = O(Se[Yr].params, Se[Yr].fn);
    const Fe = De ? Se[0].implementation : Um, He = Ee ? Se[1].implementation : Um, Be = Me ? Se[2].implementation : Um, Ye = ue ? Se[3].implementation : Um, cr = pe ? Se[4].implementation : Um, Ar = Ae ? Se[5].implementation : Um, Lr = De ? Se[0].params.length : -1, It = Ee ? Se[1].params.length : -1, en = Me ? Se[2].params.length : -1, Sn = ue ? Se[3].params.length : -1, Wn = pe ? Se[4].params.length : -1, oa = Ae ? Se[5].params.length : -1, La = ye ? 6 : 0, ci = Se.length, Do = Se.map((Yr) => Yr.test), nu = Se.map((Yr) => Yr.implementation), Di = function() {
      for (let rn = La; rn < ci; rn++)
        if (Do[rn](arguments))
          return nu[rn].apply(this, arguments);
      return o.onMismatch(re, arguments, Se);
    };
    function xa(Yr, rn) {
      return arguments.length === Lr && be(Yr) && Ne(rn) ? Fe.apply(this, arguments) : arguments.length === It && fe(Yr) && Oe(rn) ? He.apply(this, arguments) : arguments.length === en && ge(Yr) && ze(rn) ? Be.apply(this, arguments) : arguments.length === Sn && xe(Yr) && ke(rn) ? Ye.apply(this, arguments) : arguments.length === Wn && we(Yr) && je(rn) ? cr.apply(this, arguments) : arguments.length === oa && Ve(Yr) && Xe(rn) ? Ar.apply(this, arguments) : Di.apply(this, arguments);
    }
    try {
      Object.defineProperty(xa, "name", {
        value: re
      });
    } catch {
    }
    return xa.signatures = ce, xa._typedFunctionData = {
      signatures: Se,
      signatureMap: Pe
    }, xa;
  }
  function q(re, ee, ne) {
    throw w(re, ee, ne);
  }
  function K(re) {
    return X(re, 0, re.length - 1);
  }
  function Y(re) {
    return re[re.length - 1];
  }
  function X(re, ee, ne) {
    return Array.prototype.slice.call(re, ee, ne);
  }
  function Z(re, ee) {
    for (let ne = 0; ne < re.length; ne++)
      if (ee(re[ne]))
        return re[ne];
  }
  function J(re, ee) {
    return Array.prototype.concat.apply([], re.map(ee));
  }
  function $() {
    const re = K(arguments).map((ne) => h(b(ne))), ee = Y(arguments);
    if (typeof ee != "function")
      throw new TypeError("Callback function expected as last argument");
    return Q(re, ee);
  }
  function Q(re, ee) {
    return {
      referTo: {
        references: re,
        callback: ee
      }
    };
  }
  function W(re) {
    if (typeof re != "function")
      throw new TypeError("Callback function expected as first argument");
    return {
      referToSelf: {
        callback: re
      }
    };
  }
  function te(re) {
    return re && typeof re.referTo == "object" && Array.isArray(re.referTo.references) && typeof re.referTo.callback == "function";
  }
  function oe(re) {
    return re && typeof re.referToSelf == "object" && typeof re.referToSelf.callback == "function";
  }
  function z(re, ee) {
    if (!re)
      return ee;
    if (ee && ee !== re) {
      const ne = new Error("Function names do not match (expected: " + re + ", actual: " + ee + ")");
      throw ne.data = {
        actual: ee,
        expected: re
      }, ne;
    }
    return re;
  }
  function j(re) {
    let ee;
    for (const ne in re)
      Object.prototype.hasOwnProperty.call(re, ne) && (d(re[ne]) || typeof re[ne].signature == "string") && (ee = z(ee, re[ne].name));
    return ee;
  }
  function ae(re, ee) {
    let ne;
    for (ne in ee)
      if (Object.prototype.hasOwnProperty.call(ee, ne)) {
        if (ne in re && ee[ne] !== re[ne]) {
          const se = new Error('Signature "' + ne + '" is defined twice');
          throw se.data = {
            signature: ne,
            sourceFunction: ee[ne],
            destFunction: re[ne]
          }, se;
        }
        re[ne] = ee[ne];
      }
  }
  const le = o;
  o = function(re) {
    const ee = typeof re == "string", ne = ee ? 1 : 0;
    let se = ee ? re : "";
    const ce = {};
    for (let de = ne; de < arguments.length; ++de) {
      const me = arguments[de];
      let he = {}, _e;
      if (typeof me == "function" ? (_e = me.name, typeof me.signature == "string" ? he[me.signature] = me : d(me) && (he = me.signatures)) : e(me) && (he = me, ee || (_e = j(me))), Object.keys(he).length === 0) {
        const Se = new TypeError("Argument to 'typed' at index " + de + " is not a (typed) function, nor an object with signatures as keys and functions as values.");
        throw Se.data = {
          index: de,
          argument: me
        }, Se;
      }
      ee || (se = z(se, _e)), ae(ce, he);
    }
    return H(se || "", ce);
  }, o.create = gK, o.createCount = le.createCount, o.onMismatch = q, o.throwMismatchError = q, o.createError = w, o.clear = u, o.clearConversions = l, o.addTypes = s, o._findType = c, o.referTo = $, o.referToSelf = W, o.convert = v, o.findSignature = m, o.find = p, o.isTypedFunction = d, o.warnAgainstDeprecatedThis = !0, o.addType = function(re, ee) {
    let ne = "any";
    ee !== !1 && n.has("Object") && (ne = "Object"), o.addTypes([re], ne);
  };
  function ie(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 ee = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
      override: !1
    };
    ie(re);
    const ne = c(re.to), se = ne.conversionsTo.find((ce) => ce.from === re.from);
    if (se)
      if (ee && ee.override)
        o.removeConversion({
          from: se.from,
          to: re.to,
          convert: se.convert
        });
      else
        throw new Error('There is already a conversion from "' + re.from + '" to "' + ne.name + '"');
    ne.conversionsTo.push({
      from: re.from,
      convert: re.convert,
      index: i++
    });
  }, o.addConversions = function(re, ee) {
    re.forEach((ne) => o.addConversion(ne, ee));
  }, o.removeConversion = function(re) {
    ie(re);
    const ee = c(re.to), ne = Z(ee.conversionsTo, (ce) => ce.from === re.from);
    if (!ne)
      throw new Error("Attempt to remove nonexistent conversion from " + re.from + " to " + re.to);
    if (ne.convert !== re.convert)
      throw new Error("Conversion to remove does not match existing conversion");
    const se = ee.conversionsTo.indexOf(ne);
    ee.conversionsTo.splice(se, 1);
  }, o.resolve = function(re, ee) {
    if (!d(re))
      throw new TypeError(mR);
    const ne = re._typedFunctionData.signatures;
    for (let se = 0; se < ne.length; ++se)
      if (ne[se].test(ee))
        return ne[se];
    return null;
  }, o;
}
const r0 = gK();
function lr(e) {
  return typeof e == "boolean" ? !0 : isFinite(e) ? e === Math.round(e) : !1;
}
function W4e(e) {
  return /^-?\d+$/.test(e);
}
function rf(e, r) {
  return r.number === "bigint" && !W4e(e) ? r.numberFallback : r.number;
}
var fd = Math.sign || function(e) {
  return e > 0 ? 1 : e < 0 ? -1 : 0;
}, X4e = Math.log2 || function(r) {
  return Math.log(r) / Math.LN2;
}, Y4e = Math.log10 || function(r) {
  return Math.log(r) / Math.LN10;
}, Q4e = Math.log1p || function(e) {
  return Math.log(e + 1);
}, Z4e = Math.cbrt || function(r) {
  if (r === 0)
    return r;
  var t = r < 0, n;
  return t && (r = -r), isFinite(r) ? (n = Math.exp(Math.log(r) / 3), n = (r / (n * n) + 2 * n) / 3) : n = r, t ? -n : n;
}, J4e = Math.expm1 || function(r) {
  return r >= 2e-4 || r <= -2e-4 ? Math.exp(r) - 1 : r + r * r / 2 + r * r * r / 6;
};
function CP(e, r, t) {
  var n = {
    2: "0b",
    8: "0o",
    16: "0x"
  }, a = n[r], i = "";
  if (t) {
    if (t < 1)
      throw new Error("size must be in greater than 0");
    if (!lr(t))
      throw new Error("size must be an integer");
    if (e > 2 ** (t - 1) - 1 || e < -(2 ** (t - 1)))
      throw new Error("Value must be in range [-2^".concat(t - 1, ", 2^").concat(t - 1, "-1]"));
    if (!lr(e))
      throw new Error("Value must be an integer");
    e < 0 && (e = e + 2 ** t), i = "i".concat(t);
  }
  var o = "";
  return e < 0 && (e = -e, o = "-"), "".concat(o).concat(a).concat(e.toString(r)).concat(i);
}
function o0(e, r) {
  if (typeof r == "function")
    return r(e);
  if (e === 1 / 0)
    return "Infinity";
  if (e === -1 / 0)
    return "-Infinity";
  if (isNaN(e))
    return "NaN";
  var {
    notation: t,
    precision: n,
    wordSize: a
  } = yK(r);
  switch (t) {
    case "fixed":
      return _K(e, n);
    case "exponential":
      return bK(e, n);
    case "engineering":
      return eAe(e, n);
    case "bin":
      return CP(e, 2, a);
    case "oct":
      return CP(e, 8, a);
    case "hex":
      return CP(e, 16, a);
    case "auto":
      return rAe(e, n, r).replace(/((\.\d*?)(0+))($|e)/, function() {
        var i = arguments[2], o = arguments[4];
        return i !== "." ? i + o : o;
      });
    default:
      throw new Error('Unknown notation "' + t + '". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.');
  }
}
function yK(e) {
  var r = "auto", t, n;
  if (e !== void 0)
    if (Or(e))
      t = e;
    else if (Ir(e))
      t = e.toNumber();
    else if (Gy(e))
      e.precision !== void 0 && (t = vR(e.precision, () => {
        throw new Error('Option "precision" must be a number or BigNumber');
      })), e.wordSize !== void 0 && (n = vR(e.wordSize, () => {
        throw new Error('Option "wordSize" must be a number or BigNumber');
      })), e.notation && (r = e.notation);
    else
      throw new Error("Unsupported type of options, number, BigNumber, or object expected");
  return {
    notation: r,
    precision: t,
    wordSize: n
  };
}
function Hy(e) {
  var r = String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);
  if (!r)
    throw new SyntaxError("Invalid number " + e);
  var t = r[1], n = r[2], a = parseFloat(r[4] || "0"), i = n.indexOf(".");
  a += i !== -1 ? i - 1 : n.length - 1;
  var o = n.replace(".", "").replace(/^0*/, function(c) {
    return a -= c.length, "";
  }).replace(/0*$/, "").split("").map(function(c) {
    return parseInt(c);
  });
  return o.length === 0 && (o.push(0), a++), {
    sign: t,
    coefficients: o,
    exponent: a
  };
}
function eAe(e, r) {
  if (isNaN(e) || !isFinite(e))
    return String(e);
  var t = Hy(e), n = tx(t, r), a = n.exponent, i = n.coefficients, o = a % 3 === 0 ? a : a < 0 ? a - 3 - a % 3 : a - a % 3;
  if (Or(r))
    for (; r > i.length || a - o + 1 > i.length; )
      i.push(0);
  else
    for (var c = Math.abs(a - o) - (i.length - 1), s = 0; s < c; s++)
      i.push(0);
  for (var u = Math.abs(a - o), l = 1; u > 0; )
    l++, u--;
  var f = i.slice(l).join(""), d = Or(r) && f.length || f.match(/[1-9]/) ? "." + f : "", m = i.slice(0, l).join("") + d + "e" + (a >= 0 ? "+" : "") + o.toString();
  return n.sign + m;
}
function _K(e, r) {
  if (isNaN(e) || !isFinite(e))
    return String(e);
  var t = Hy(e), n = typeof r == "number" ? tx(t, t.exponent + 1 + r) : t, a = n.coefficients, i = n.exponent + 1, o = i + (r || 0);
  return a.length < o && (a = a.concat(_v(o - a.length))), i < 0 && (a = _v(-i + 1).concat(a), i = 1), i < a.length && a.splice(i, 0, i === 0 ? "0." : "."), n.sign + a.join("");
}
function bK(e, r) {
  if (isNaN(e) || !isFinite(e))
    return String(e);
  var t = Hy(e), n = r ? tx(t, r) : t, a = n.coefficients, i = n.exponent;
  a.length < r && (a = a.concat(_v(r - a.length)));
  var o = a.shift();
  return n.sign + o + (a.length > 0 ? "." + a.join("") : "") + "e" + (i >= 0 ? "+" : "") + i;
}
function rAe(e, r, t) {
  if (isNaN(e) || !isFinite(e))
    return String(e);
  var n = pR(t == null ? void 0 : t.lowerExp, -3), a = pR(t == null ? void 0 : t.upperExp, 5), i = Hy(e), o = r ? tx(i, r) : i;
  if (o.exponent < n || o.exponent >= a)
    return bK(e, r);
  var c = o.coefficients, s = o.exponent;
  c.length < r && (c = c.concat(_v(r - c.length))), c = c.concat(_v(s - c.length + 1 + (c.length < r ? r - c.length : 0))), c = _v(-s).concat(c);
  var u = s > 0 ? s : 0;
  return u < c.length - 1 && c.splice(u + 1, 0, "."), o.sign + c.join("");
}
function tx(e, r) {
  for (var t = {
    sign: e.sign,
    coefficients: e.coefficients,
    exponent: e.exponent
  }, n = t.coefficients; r <= 0; )
    n.unshift(0), t.exponent++, r++;
  if (n.length > r) {
    var a = n.splice(r, n.length - r);
    if (a[0] >= 5) {
      var i = r - 1;
      for (n[i]++; n[i] === 10; )
        n.pop(), i === 0 && (n.unshift(0), t.exponent++, i++), i--, n[i]++;
    }
  }
  return t;
}
function _v(e) {
  for (var r = [], t = 0; t < e; t++)
    r.push(0);
  return r;
}
function tAe(e) {
  return e.toExponential().replace(/e.*$/, "").replace(/^0\.?0*|\./, "").length;
}
function oi(e, r) {
  var t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1e-8, n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0;
  if (t <= 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(r) ? !1 : !isFinite(e) || !isFinite(r) ? e === r : e === r ? !0 : Math.abs(e - r) <= Math.max(t * Math.max(Math.abs(e), Math.abs(r)), n);
}
var nAe = Math.acosh || function(e) {
  return Math.log(Math.sqrt(e * e - 1) + e);
}, aAe = Math.asinh || function(e) {
  return Math.log(Math.sqrt(e * e + 1) + e);
}, iAe = Math.atanh || function(e) {
  return Math.log((1 + e) / (1 - e)) / 2;
}, oAe = Math.cosh || function(e) {
  return (Math.exp(e) + Math.exp(-e)) / 2;
}, uAe = Math.sinh || function(e) {
  return (Math.exp(e) - Math.exp(-e)) / 2;
}, sAe = Math.tanh || function(e) {
  var r = Math.exp(2 * e);
  return (r - 1) / (r + 1);
};
function lAe(e, r) {
  var t = !0, n = r > 0 ? !0 : r < 0 ? !1 : 1 / r === 1 / 0;
  return t ^ n ? -e : e;
}
function vR(e, r) {
  if (Or(e))
    return e;
  if (Ir(e))
    return e.toNumber();
  r();
}
function pR(e, r) {
  return Or(e) ? e : Ir(e) ? e.toNumber() : r;
}
function Ce(e, r, t, n) {
  function a(i) {
    var o = $4e(i, r.map(SK));
    return cAe(e, r, i), t(o);
  }
  return a.isFactory = !0, a.fn = e, a.dependencies = r.slice().sort(), n && (a.meta = n), a;
}
function ug(e) {
  return typeof e == "function" && typeof e.fn == "string" && Array.isArray(e.dependencies);
}
function cAe(e, r, t) {
  var n = r.filter((i) => !dAe(i)).every((i) => t[i] !== void 0);
  if (!n) {
    var a = r.filter((i) => t[i] === void 0);
    throw new Error('Cannot create function "'.concat(e, '", ') + "some dependencies are missing: ".concat(a.map((i) => '"'.concat(i, '"')).join(", "), "."));
  }
}
function dAe(e) {
  return e && e[0] === "?";
}
function SK(e) {
  return e && e[0] === "?" ? e.slice(1) : e;
}
function Ki(e, r) {
  if (AK(e) && CK(e, r))
    return e[r];
  throw typeof e[r] == "function" && CD(e, r) ? new Error('Cannot access method "' + r + '" as a property') : new Error('No access to property "' + r + '"');
}
function lp(e, r, t) {
  if (AK(e) && CK(e, r))
    return e[r] = t, t;
  throw new Error('No access to property "' + r + '"');
}
function fAe(e, r) {
  return r in e;
}
function CK(e, r) {
  return !e || typeof e != "object" ? !1 : er(vAe, r) ? !0 : !(r in Object.prototype || r in Function.prototype);
}
function mAe(e, r) {
  if (!CD(e, r))
    throw new Error('No access to method "' + r + '"');
  return e[r];
}
function CD(e, r) {
  return e == null || typeof e[r] != "function" || er(e, r) && Object.getPrototypeOf && r in Object.getPrototypeOf(e) ? !1 : er(pAe, r) ? !0 : !(r in Object.prototype || r in Function.prototype);
}
function AK(e) {
  return typeof e == "object" && e && e.constructor === Object;
}
var vAe = {
  length: !0,
  name: !0
}, pAe = {
  toString: !0,
  valueOf: !0,
  toLocaleString: !0
};
class nx {
  constructor(r) {
    this.wrappedObject = r, this[Symbol.iterator] = this.entries;
  }
  keys() {
    return Object.keys(this.wrappedObject).values();
  }
  get(r) {
    return Ki(this.wrappedObject, r);
  }
  set(r, t) {
    return lp(this.wrappedObject, r, t), this;
  }
  has(r) {
    return fAe(this.wrappedObject, r);
  }
  entries() {
    return TK(this.keys(), (r) => [r, this.get(r)]);
  }
  forEach(r) {
    for (var t of this.keys())
      r(this.get(t), t, this);
  }
  delete(r) {
    delete this.wrappedObject[r];
  }
  clear() {
    for (var r of this.keys())
      this.delete(r);
  }
  get size() {
    return Object.keys(this.wrappedObject).length;
  }
}
class xK {
  /**
   * @param {Map} a
   * @param {Map} b
   * @param {Set} bKeys
   */
  constructor(r, t, n) {
    this.a = r, this.b = t, this.bKeys = n, this[Symbol.iterator] = this.entries;
  }
  get(r) {
    return this.bKeys.has(r) ? this.b.get(r) : this.a.get(r);
  }
  set(r, t) {
    return this.bKeys.has(r) ? this.b.set(r, t) : this.a.set(r, t), this;
  }
  has(r) {
    return this.b.has(r) || this.a.has(r);
  }
  keys() {
    return (/* @__PURE__ */ new Set([...this.a.keys(), ...this.b.keys()]))[Symbol.iterator]();
  }
  entries() {
    return TK(this.keys(), (r) => [r, this.get(r)]);
  }
  forEach(r) {
    for (var t of this.keys())
      r(this.get(t), t, this);
  }
  delete(r) {
    return this.bKeys.has(r) ? this.b.delete(r) : this.a.delete(r);
  }
  clear() {
    this.a.clear(), this.b.clear();
  }
  get size() {
    return [...this.keys()].length;
  }
}
function TK(e, r) {
  return {
    next: () => {
      var t = e.next();
      return t.done ? t : {
        value: r(t.value),
        done: !1
      };
    }
  };
}
function Lg() {
  return /* @__PURE__ */ new Map();
}
function bv(e) {
  if (!e)
    return Lg();
  if (PK(e))
    return e;
  if (Gy(e))
    return new nx(e);
  throw new Error("createMap can create maps from objects or Maps");
}
function hAe(e) {
  if (e instanceof nx)
    return e.wrappedObject;
  var r = {};
  for (var t of e.keys()) {
    var n = e.get(t);
    lp(r, t, n);
  }
  return r;
}
function PK(e) {
  return e ? e instanceof Map || e instanceof nx || typeof e.set == "function" && typeof e.get == "function" && typeof e.keys == "function" && typeof e.has == "function" : !1;
}
var MK = function() {
  return MK = r0.create, r0;
}, gAe = ["?BigNumber", "?Complex", "?DenseMatrix", "?Fraction"], wK = /* @__PURE__ */ Ce("typed", gAe, function(r) {
  var {
    BigNumber: t,
    Complex: n,
    DenseMatrix: a,
    Fraction: i
  } = r, o = MK();
  return o.clear(), o.addTypes([
    {
      name: "number",
      test: Or
    },
    {
      name: "Complex",
      test: as
    },
    {
      name: "BigNumber",
      test: Ir
    },
    {
      name: "bigint",
      test: rK
    },
    {
      name: "Fraction",
      test: J0
    },
    {
      name: "Unit",
      test: ho
    },
    // 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: (c) => Ya && /^(?:[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(c)
    },
    {
      name: "string",
      test: Ya
    },
    {
      name: "Chain",
      test: SD
    },
    {
      name: "Array",
      test: dt
    },
    {
      name: "Matrix",
      test: gr
    },
    {
      name: "DenseMatrix",
      test: Fg
    },
    {
      name: "SparseMatrix",
      test: dd
    },
    {
      name: "Range",
      test: rx
    },
    {
      name: "Index",
      test: zy
    },
    {
      name: "boolean",
      test: tK
    },
    {
      name: "ResultSet",
      test: nK
    },
    {
      name: "Help",
      test: bD
    },
    {
      name: "function",
      test: aK
    },
    {
      name: "Date",
      test: iK
    },
    {
      name: "RegExp",
      test: oK
    },
    {
      name: "null",
      test: uK
    },
    {
      name: "undefined",
      test: sK
    },
    {
      name: "AccessorNode",
      test: Fd
    },
    {
      name: "ArrayNode",
      test: jo
    },
    {
      name: "AssignmentNode",
      test: lK
    },
    {
      name: "BlockNode",
      test: cK
    },
    {
      name: "ConditionalNode",
      test: dK
    },
    {
      name: "ConstantNode",
      test: Jr
    },
    {
      name: "FunctionNode",
      test: hc
    },
    {
      name: "FunctionAssignmentNode",
      test: Kp
    },
    {
      name: "IndexNode",
      test: em
    },
    {
      name: "Node",
      test: St
    },
    {
      name: "ObjectNode",
      test: qy
    },
    {
      name: "OperatorNode",
      test: Hn
    },
    {
      name: "ParenthesisNode",
      test: sl
    },
    {
      name: "RangeNode",
      test: fK
    },
    {
      name: "RelationalNode",
      test: mK
    },
    {
      name: "SymbolNode",
      test: _a
    },
    {
      name: "Map",
      test: PK
    },
    {
      name: "Object",
      test: Gy
    }
    // order 'Object' last, it matches on other classes too
  ]), o.addConversions([{
    from: "number",
    to: "BigNumber",
    convert: function(s) {
      if (t || x_(s), tAe(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 t(s);
    }
  }, {
    from: "number",
    to: "Complex",
    convert: function(s) {
      return n || T_(s), new n(s, 0);
    }
  }, {
    from: "BigNumber",
    to: "Complex",
    convert: function(s) {
      return n || T_(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 t || x_(s), new t(s.toString());
    }
  }, {
    from: "bigint",
    to: "Fraction",
    convert: function(s) {
      return i || P_(s), new i(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 || T_(s), new n(s.valueOf(), 0);
    }
  }, {
    from: "number",
    to: "Fraction",
    convert: function(s) {
      i || P_(s);
      var u = new i(s);
      if (u.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 u;
    }
  }, {
    // 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 u = Number(s);
      if (isNaN(u))
        throw new Error('Cannot convert "' + s + '" to a number');
      return u;
    }
  }, {
    from: "string",
    to: "BigNumber",
    convert: function(s) {
      t || x_(s);
      try {
        return new t(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) {
      i || P_(s);
      try {
        return new i(s);
      } catch {
        throw new Error('Cannot convert "' + s + '" to Fraction');
      }
    }
  }, {
    from: "string",
    to: "Complex",
    convert: function(s) {
      n || T_(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 t || x_(s), new t(+s);
    }
  }, {
    from: "boolean",
    to: "bigint",
    convert: function(s) {
      return BigInt(+s);
    }
  }, {
    from: "boolean",
    to: "Fraction",
    convert: function(s) {
      return i || P_(s), new i(+s);
    }
  }, {
    from: "boolean",
    to: "string",
    convert: function(s) {
      return String(s);
    }
  }, {
    from: "Array",
    to: "Matrix",
    convert: function(s) {
      return a || yAe(), new a(s);
    }
  }, {
    from: "Matrix",
    to: "Array",
    convert: function(s) {
      return s.valueOf();
    }
  }]), o.onMismatch = (c, s, u) => {
    var l = o.createError(c, s, u);
    if (["wrongType", "mismatch"].includes(l.data.category) && s.length === 1 && Xo(s[0]) && // check if the function can be unary:
    u.some((d) => !d.params.includes(","))) {
      var f = new TypeError("Function '".concat(c, "' doesn't apply to matrices. To call it ") + "elementwise on a matrix 'M', try 'map(M, ".concat(c, ")'."));
      throw f.data = l.data, f;
    }
    throw l;
  }, o.onMismatch = (c, s, u) => {
    var l = o.createError(c, s, u);
    if (["wrongType", "mismatch"].includes(l.data.category) && s.length === 1 && Xo(s[0]) && // check if the function can be unary:
    u.some((d) => !d.params.includes(","))) {
      var f = new TypeError("Function '".concat(c, "' doesn't apply to matrices. To call it ") + "elementwise on a matrix 'M', try 'map(M, ".concat(c, ")'."));
      throw f.data = l.data, f;
    }
    throw l;
  }, o;
});
function x_(e) {
  throw new Error("Cannot convert value ".concat(e, " into a BigNumber: no class 'BigNumber' provided"));
}
function T_(e) {
  throw new Error("Cannot convert value ".concat(e, " into a Complex number: no class 'Complex' provided"));
}
function yAe() {
  throw new Error("Cannot convert array into a Matrix: no class 'DenseMatrix' provided");
}
function P_(e) {
  throw new Error("Cannot convert value ".concat(e, " into a Fraction, no class 'Fraction' provided."));
}
var _Ae = "ResultSet", bAe = [], SAe = /* @__PURE__ */ Ce(_Ae, bAe, () => {
  function e(r) {
    if (!(this instanceof e))
      throw new SyntaxError("Constructor must be called with the new operator");
    this.entries = r || [];
  }
  return e.prototype.type = "ResultSet", e.prototype.isResultSet = !0, e.prototype.valueOf = function() {
    return this.entries;
  }, e.prototype.toString = function() {
    return "[" + this.entries.join(", ") + "]";
  }, e.prototype.toJSON = function() {
    return {
      mathjs: "ResultSet",
      entries: this.entries
    };
  }, e.fromJSON = function(r) {
    return new e(r.entries);
  }, e;
}, {
  isClass: !0
});
/*!
 *  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 iv = 9e15, tf = 1e9, yw = "0123456789abcdef", p3 = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058", h3 = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789", _w = {
  // 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: -iv,
  // -1 to -EXP_LIMIT
  // The maximum exponent value, above which overflow to Infinity occurs.
  // JavaScript numbers: 308  (1.7976931348623157e+308)
  maxE: iv,
  // 1 to EXP_LIMIT
  // Whether to use cryptographically-secure random number generation, if available.
  crypto: !1
  // true/false
}, EK, Ql, Br = !0, ax = "[DecimalError] ", Ld = ax + "Invalid argument: ", DK = ax + "Precision limit exceeded", IK = ax + "crypto unavailable", BK = "[object Decimal]", xi = Math.floor, da = Math.pow, CAe = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i, AAe = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i, xAe = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i, NK = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, is = 1e7, Cr = 7, TAe = 9007199254740991, PAe = p3.length - 1, bw = h3.length - 1, qe = { toStringTag: BK };
qe.absoluteValue = qe.abs = function() {
  var e = new this.constructor(this);
  return e.s < 0 && (e.s = 1), vr(e);
};
qe.ceil = function() {
  return vr(new this.constructor(this), this.e + 1, 2);
};
qe.clampedTo = qe.clamp = function(e, r) {
  var t, n = this, a = n.constructor;
  if (e = new a(e), r = new a(r), !e.s || !r.s) return new a(NaN);
  if (e.gt(r)) throw Error(Ld + r);
  return t = n.cmp(e), t < 0 ? e : n.cmp(r) > 0 ? r : new a(n);
};
qe.comparedTo = qe.cmp = function(e) {
  var r, t, n, a, i = this, o = i.d, c = (e = new i.constructor(e)).d, s = i.s, u = e.s;
  if (!o || !c)
    return !s || !u ? NaN : s !== u ? s : o === c ? 0 : !o ^ s < 0 ? 1 : -1;
  if (!o[0] || !c[0]) return o[0] ? s : c[0] ? -u : 0;
  if (s !== u) return s;
  if (i.e !== e.e) return i.e > e.e ^ s < 0 ? 1 : -1;
  for (n = o.length, a = c.length, r = 0, t = n < a ? n : a; r < t; ++r)
    if (o[r] !== c[r]) return o[r] > c[r] ^ s < 0 ? 1 : -1;
  return n === a ? 0 : n > a ^ s < 0 ? 1 : -1;
};
qe.cosine = qe.cos = function() {
  var e, r, t = this, n = t.constructor;
  return t.d ? t.d[0] ? (e = n.precision, r = n.rounding, n.precision = e + Math.max(t.e, t.sd()) + Cr, n.rounding = 1, t = MAe(n, LK(n, t)), n.precision = e, n.rounding = r, vr(Ql == 2 || Ql == 3 ? t.neg() : t, e, r, !0)) : new n(1) : new n(NaN);
};
qe.cubeRoot = qe.cbrt = function() {
  var e, r, t, n, a, i, o, c, s, u, l = this, f = l.constructor;
  if (!l.isFinite() || l.isZero()) return new f(l);
  for (Br = !1, i = l.s * da(l.s * l, 1 / 3), !i || Math.abs(i) == 1 / 0 ? (t = ei(l.d), e = l.e, (i = (e - t.length + 1) % 3) && (t += i == 1 || i == -2 ? "0" : "00"), i = da(t, 1 / 3), e = xi((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2)), i == 1 / 0 ? t = "5e" + e : (t = i.toExponential(), t = t.slice(0, t.indexOf("e") + 1) + e), n = new f(t), n.s = l.s) : n = new f(i.toString()), o = (e = f.precision) + 3; ; )
    if (c = n, s = c.times(c).times(c), u = s.plus(l), n = Ht(u.plus(l).times(c), u.plus(s), o + 2, 1), ei(c.d).slice(0, o) === (t = ei(n.d)).slice(0, o))
      if (t = t.slice(o - 3, o + 1), t == "9999" || !a && t == "4999") {
        if (!a && (vr(c, e + 1, 0), c.times(c).times(c).eq(l))) {
          n = c;
          break;
        }
        o += 4, a = 1;
      } else {
        (!+t || !+t.slice(1) && t.charAt(0) == "5") && (vr(n, e + 1, 1), r = !n.times(n).times(n).eq(l));
        break;
      }
  return Br = !0, vr(n, e, f.rounding, r);
};
qe.decimalPlaces = qe.dp = function() {
  var e, r = this.d, t = NaN;
  if (r) {
    if (e = r.length - 1, t = (e - xi(this.e / Cr)) * Cr, e = r[e], e) for (; e % 10 == 0; e /= 10) t--;
    t < 0 && (t = 0);
  }
  return t;
};
qe.dividedBy = qe.div = function(e) {
  return Ht(this, new this.constructor(e));
};
qe.dividedToIntegerBy = qe.divToInt = function(e) {
  var r = this, t = r.constructor;
  return vr(Ht(r, new t(e), 0, 1, 1), t.precision, t.rounding);
};
qe.equals = qe.eq = function(e) {
  return this.cmp(e) === 0;
};
qe.floor = function() {
  return vr(new this.constructor(this), this.e + 1, 3);
};
qe.greaterThan = qe.gt = function(e) {
  return this.cmp(e) > 0;
};
qe.greaterThanOrEqualTo = qe.gte = function(e) {
  var r = this.cmp(e);
  return r == 1 || r === 0;
};
qe.hyperbolicCosine = qe.cosh = function() {
  var e, r, t, n, a, i = this, o = i.constructor, c = new o(1);
  if (!i.isFinite()) return new o(i.s ? 1 / 0 : NaN);
  if (i.isZero()) return c;
  t = o.precision, n = o.rounding, o.precision = t + Math.max(i.e, i.sd()) + 4, o.rounding = 1, a = i.d.length, a < 32 ? (e = Math.ceil(a / 3), r = (1 / ox(4, e)).toString()) : (e = 16, r = "2.3283064365386962890625e-10"), i = cp(o, 1, i.times(r), new o(1), !0);
  for (var s, u = e, l = new o(8); u--; )
    s = i.times(i), i = c.minus(s.times(l.minus(s.times(l))));
  return vr(i, o.precision = t, o.rounding = n, !0);
};
qe.hyperbolicSine = qe.sinh = function() {
  var e, r, t, n, a = this, i = a.constructor;
  if (!a.isFinite() || a.isZero()) return new i(a);
  if (r = i.precision, t = i.rounding, i.precision = r + Math.max(a.e, a.sd()) + 4, i.rounding = 1, n = a.d.length, n < 3)
    a = cp(i, 2, a, a, !0);
  else {
    e = 1.4 * Math.sqrt(n), e = e > 16 ? 16 : e | 0, a = a.times(1 / ox(5, e)), a = cp(i, 2, a, a, !0);
    for (var o, c = new i(5), s = new i(16), u = new i(20); e--; )
      o = a.times(a), a = a.times(c.plus(o.times(s.times(o).plus(u))));
  }
  return i.precision = r, i.rounding = t, vr(a, r, t, !0);
};
qe.hyperbolicTangent = qe.tanh = function() {
  var e, r, t = this, n = t.constructor;
  return t.isFinite() ? t.isZero() ? new n(t) : (e = n.precision, r = n.rounding, n.precision = e + 7, n.rounding = 1, Ht(t.sinh(), t.cosh(), n.precision = e, n.rounding = r)) : new n(t.s);
};
qe.inverseCosine = qe.acos = function() {
  var e, r = this, t = r.constructor, n = r.abs().cmp(1), a = t.precision, i = t.rounding;
  return n !== -1 ? n === 0 ? r.isNeg() ? es(t, a, i) : new t(0) : new t(NaN) : r.isZero() ? es(t, a + 4, i).times(0.5) : (t.precision = a + 6, t.rounding = 1, r = r.asin(), e = es(t, a + 4, i).times(0.5), t.precision = a, t.rounding = i, e.minus(r));
};
qe.inverseHyperbolicCosine = qe.acosh = function() {
  var e, r, t = this, n = t.constructor;
  return t.lte(1) ? new n(t.eq(1) ? 0 : NaN) : t.isFinite() ? (e = n.precision, r = n.rounding, n.precision = e + Math.max(Math.abs(t.e), t.sd()) + 4, n.rounding = 1, Br = !1, t = t.times(t).minus(1).sqrt().plus(t), Br = !0, n.precision = e, n.rounding = r, t.ln()) : new n(t);
};
qe.inverseHyperbolicSine = qe.asinh = function() {
  var e, r, t = this, n = t.constructor;
  return !t.isFinite() || t.isZero() ? new n(t) : (e = n.precision, r = n.rounding, n.precision = e + 2 * Math.max(Math.abs(t.e), t.sd()) + 6, n.rounding = 1, Br = !1, t = t.times(t).plus(1).sqrt().plus(t), Br = !0, n.precision = e, n.rounding = r, t.ln());
};
qe.inverseHyperbolicTangent = qe.atanh = function() {
  var e, r, t, n, a = this, i = a.constructor;
  return a.isFinite() ? a.e >= 0 ? new i(a.abs().eq(1) ? a.s / 0 : a.isZero() ? a : NaN) : (e = i.precision, r = i.rounding, n = a.sd(), Math.max(n, e) < 2 * -a.e - 1 ? vr(new i(a), e, r, !0) : (i.precision = t = n - a.e, a = Ht(a.plus(1), new i(1).minus(a), t + e, 1), i.precision = e + 4, i.rounding = 1, a = a.ln(), i.precision = e, i.rounding = r, a.times(0.5))) : new i(NaN);
};
qe.inverseSine = qe.asin = function() {
  var e, r, t, n, a = this, i = a.constructor;
  return a.isZero() ? new i(a) : (r = a.abs().cmp(1), t = i.precision, n = i.rounding, r !== -1 ? r === 0 ? (e = es(i, t + 4, n).times(0.5), e.s = a.s, e) : new i(NaN) : (i.precision = t + 6, i.rounding = 1, a = a.div(new i(1).minus(a.times(a)).sqrt().plus(1)).atan(), i.precision = t, i.rounding = n, a.times(2)));
};
qe.inverseTangent = qe.atan = function() {
  var e, r, t, n, a, i, o, c, s, u = this, l = u.constructor, f = l.precision, d = l.rounding;
  if (u.isFinite()) {
    if (u.isZero())
      return new l(u);
    if (u.abs().eq(1) && f + 4 <= bw)
      return o = es(l, f + 4, d).times(0.25), o.s = u.s, o;
  } else {
    if (!u.s) return new l(NaN);
    if (f + 4 <= bw)
      return o = es(l, f + 4, d).times(0.5), o.s = u.s, o;
  }
  for (l.precision = c = f + 10, l.rounding = 1, t = Math.min(28, c / Cr + 2 | 0), e = t; e; --e) u = u.div(u.times(u).plus(1).sqrt().plus(1));
  for (Br = !1, r = Math.ceil(c / Cr), n = 1, s = u.times(u), o = new l(u), a = u; e !== -1; )
    if (a = a.times(s), i = o.minus(a.div(n += 2)), a = a.times(s), o = i.plus(a.div(n += 2)), o.d[r] !== void 0) for (e = r; o.d[e] === i.d[e] && e--; ) ;
  return t && (o = o.times(2 << t - 1)), Br = !0, vr(o, l.precision = f, l.rounding = d, !0);
};
qe.isFinite = function() {
  return !!this.d;
};
qe.isInteger = qe.isInt = function() {
  return !!this.d && xi(this.e / Cr) > this.d.length - 2;
};
qe.isNaN = function() {
  return !this.s;
};
qe.isNegative = qe.isNeg = function() {
  return this.s < 0;
};
qe.isPositive = qe.isPos = function() {
  return this.s > 0;
};
qe.isZero = function() {
  return !!this.d && this.d[0] === 0;
};
qe.lessThan = qe.lt = function(e) {
  return this.cmp(e) < 0;
};
qe.lessThanOrEqualTo = qe.lte = function(e) {
  return this.cmp(e) < 1;
};
qe.logarithm = qe.log = function(e) {
  var r, t, n, a, i, o, c, s, u = this, l = u.constructor, f = l.precision, d = l.rounding, m = 5;
  if (e == null)
    e = new l(10), r = !0;
  else {
    if (e = new l(e), t = e.d, e.s < 0 || !t || !t[0] || e.eq(1)) return new l(NaN);
    r = e.eq(10);
  }
  if (t = u.d, u.s < 0 || !t || !t[0] || u.eq(1))
    return new l(t && !t[0] ? -1 / 0 : u.s != 1 ? NaN : t ? 0 : 1 / 0);
  if (r)
    if (t.length > 1)
      i = !0;
    else {
      for (a = t[0]; a % 10 === 0; ) a /= 10;
      i = a !== 1;
    }
  if (Br = !1, c = f + m, o = md(u, c), n = r ? g3(l, c + 10) : md(e, c), s = Ht(o, n, c, 1), kg(s.d, a = f, d))
    do
      if (c += 10, o = md(u, c), n = r ? g3(l, c + 10) : md(e, c), s = Ht(o, n, c, 1), !i) {
        +ei(s.d).slice(a + 1, a + 15) + 1 == 1e14 && (s = vr(s, f + 1, 0));
        break;
      }
    while (kg(s.d, a += 10, d));
  return Br = !0, vr(s, f, d);
};
qe.minus = qe.sub = function(e) {
  var r, t, n, a, i, o, c, s, u, l, f, d, m = this, p = m.constructor;
  if (e = new p(e), !m.d || !e.d)
    return !m.s || !e.s ? e = new p(NaN) : m.d ? e.s = -e.s : e = new p(e.d || m.s !== e.s ? m : NaN), e;
  if (m.s != e.s)
    return e.s = -e.s, m.plus(e);
  if (u = m.d, d = e.d, c = p.precision, s = p.rounding, !u[0] || !d[0]) {
    if (d[0]) e.s = -e.s;
    else if (u[0]) e = new p(m);
    else return new p(s === 3 ? -0 : 0);
    return Br ? vr(e, c, s) : e;
  }
  if (t = xi(e.e / Cr), l = xi(m.e / Cr), u = u.slice(), i = l - t, i) {
    for (f = i < 0, f ? (r = u, i = -i, o = d.length) : (r = d, t = l, o = u.length), n = Math.max(Math.ceil(c / Cr), o) + 2, i > n && (i = n, r.length = 1), r.reverse(), n = i; n--; ) r.push(0);
    r.reverse();
  } else {
    for (n = u.length, o = d.length, f = n < o, f && (o = n), n = 0; n < o; n++)
      if (u[n] != d[n]) {
        f = u[n] < d[n];
        break;
      }
    i = 0;
  }
  for (f && (r = u, u = d, d = r, e.s = -e.s), o = u.length, n = d.length - o; n > 0; --n) u[o++] = 0;
  for (n = d.length; n > i; ) {
    if (u[--n] < d[n]) {
      for (a = n; a && u[--a] === 0; ) u[a] = is - 1;
      --u[a], u[n] += is;
    }
    u[n] -= d[n];
  }
  for (; u[--o] === 0; ) u.pop();
  for (; u[0] === 0; u.shift()) --t;
  return u[0] ? (e.d = u, e.e = ix(u, t), Br ? vr(e, c, s) : e) : new p(s === 3 ? -0 : 0);
};
qe.modulo = qe.mod = function(e) {
  var r, t = this, n = t.constructor;
  return e = new n(e), !t.d || !e.s || e.d && !e.d[0] ? new n(NaN) : !e.d || t.d && !t.d[0] ? vr(new n(t), n.precision, n.rounding) : (Br = !1, n.modulo == 9 ? (r = Ht(t, e.abs(), 0, 3, 1), r.s *= e.s) : r = Ht(t, e, 0, n.modulo, 1), r = r.times(e), Br = !0, t.minus(r));
};
qe.naturalExponential = qe.exp = function() {
  return Sw(this);
};
qe.naturalLogarithm = qe.ln = function() {
  return md(this);
};
qe.negated = qe.neg = function() {
  var e = new this.constructor(this);
  return e.s = -e.s, vr(e);
};
qe.plus = qe.add = function(e) {
  var r, t, n, a, i, o, c, s, u, l, f = this, d = f.constructor;
  if (e = new d(e), !f.d || !e.d)
    return !f.s || !e.s ? e = new d(NaN) : f.d || (e = new d(e.d || f.s === e.s ? f : NaN)), e;
  if (f.s != e.s)
    return e.s = -e.s, f.minus(e);
  if (u = f.d, l = e.d, c = d.precision, s = d.rounding, !u[0] || !l[0])
    return l[0] || (e = new d(f)), Br ? vr(e, c, s) : e;
  if (i = xi(f.e / Cr), n = xi(e.e / Cr), u = u.slice(), a = i - n, a) {
    for (a < 0 ? (t = u, a = -a, o = l.length) : (t = l, n = i, o = u.length), i = Math.ceil(c / Cr), o = i > o ? i + 1 : o + 1, a > o && (a = o, t.length = 1), t.reverse(); a--; ) t.push(0);
    t.reverse();
  }
  for (o = u.length, a = l.length, o - a < 0 && (a = o, t = l, l = u, u = t), r = 0; a; )
    r = (u[--a] = u[a] + l[a] + r) / is | 0, u[a] %= is;
  for (r && (u.unshift(r), ++n), o = u.length; u[--o] == 0; ) u.pop();
  return e.d = u, e.e = ix(u, n), Br ? vr(e, c, s) : e;
};
qe.precision = qe.sd = function(e) {
  var r, t = this;
  if (e !== void 0 && e !== !!e && e !== 1 && e !== 0) throw Error(Ld + e);
  return t.d ? (r = VK(t.d), e && t.e + 1 > r && (r = t.e + 1)) : r = NaN, r;
};
qe.round = function() {
  var e = this, r = e.constructor;
  return vr(new r(e), e.e + 1, r.rounding);
};
qe.sine = qe.sin = function() {
  var e, r, t = this, n = t.constructor;
  return t.isFinite() ? t.isZero() ? new n(t) : (e = n.precision, r = n.rounding, n.precision = e + Math.max(t.e, t.sd()) + Cr, n.rounding = 1, t = EAe(n, LK(n, t)), n.precision = e, n.rounding = r, vr(Ql > 2 ? t.neg() : t, e, r, !0)) : new n(NaN);
};
qe.squareRoot = qe.sqrt = function() {
  var e, r, t, n, a, i, o = this, c = o.d, s = o.e, u = o.s, l = o.constructor;
  if (u !== 1 || !c || !c[0])
    return new l(!u || u < 0 && (!c || c[0]) ? NaN : c ? o : 1 / 0);
  for (Br = !1, u = Math.sqrt(+o), u == 0 || u == 1 / 0 ? (r = ei(c), (r.length + s) % 2 == 0 && (r += "0"), u = Math.sqrt(r), s = xi((s + 1) / 2) - (s < 0 || s % 2), u == 1 / 0 ? r = "5e" + s : (r = u.toExponential(), r = r.slice(0, r.indexOf("e") + 1) + s), n = new l(r)) : n = new l(u.toString()), t = (s = l.precision) + 3; ; )
    if (i = n, n = i.plus(Ht(o, i, t + 2, 1)).times(0.5), ei(i.d).slice(0, t) === (r = ei(n.d)).slice(0, t))
      if (r = r.slice(t - 3, t + 1), r == "9999" || !a && r == "4999") {
        if (!a && (vr(i, s + 1, 0), i.times(i).eq(o))) {
          n = i;
          break;
        }
        t += 4, a = 1;
      } else {
        (!+r || !+r.slice(1) && r.charAt(0) == "5") && (vr(n, s + 1, 1), e = !n.times(n).eq(o));
        break;
      }
  return Br = !0, vr(n, s, l.rounding, e);
};
qe.tangent = qe.tan = function() {
  var e, r, t = this, n = t.constructor;
  return t.isFinite() ? t.isZero() ? new n(t) : (e = n.precision, r = n.rounding, n.precision = e + 10, n.rounding = 1, t = t.sin(), t.s = 1, t = Ht(t, new n(1).minus(t.times(t)).sqrt(), e + 10, 0), n.precision = e, n.rounding = r, vr(Ql == 2 || Ql == 4 ? t.neg() : t, e, r, !0)) : new n(NaN);
};
qe.times = qe.mul = function(e) {
  var r, t, n, a, i, o, c, s, u, l = this, f = l.constructor, d = l.d, m = (e = new f(e)).d;
  if (e.s *= l.s, !d || !d[0] || !m || !m[0])
    return new f(!e.s || d && !d[0] && !m || m && !m[0] && !d ? NaN : !d || !m ? e.s / 0 : e.s * 0);
  for (t = xi(l.e / Cr) + xi(e.e / Cr), s = d.length, u = m.length, s < u && (i = d, d = m, m = i, o = s, s = u, u = o), i = [], o = s + u, n = o; n--; ) i.push(0);
  for (n = u; --n >= 0; ) {
    for (r = 0, a = s + n; a > n; )
      c = i[a] + m[n] * d[a - n - 1] + r, i[a--] = c % is | 0, r = c / is | 0;
    i[a] = (i[a] + r) % is | 0;
  }
  for (; !i[--o]; ) i.pop();
  return r ? ++t : i.shift(), e.d = i, e.e = ix(i, t), Br ? vr(e, f.precision, f.rounding) : e;
};
qe.toBinary = function(e, r) {
  return AD(this, 2, e, r);
};
qe.toDecimalPlaces = qe.toDP = function(e, r) {
  var t = this, n = t.constructor;
  return t = new n(t), e === void 0 ? t : (xo(e, 0, tf), r === void 0 ? r = n.rounding : xo(r, 0, 8), vr(t, e + t.e + 1, r));
};
qe.toExponential = function(e, r) {
  var t, n = this, a = n.constructor;
  return e === void 0 ? t = ll(n, !0) : (xo(e, 0, tf), r === void 0 ? r = a.rounding : xo(r, 0, 8), n = vr(new a(n), e + 1, r), t = ll(n, !0, e + 1)), n.isNeg() && !n.isZero() ? "-" + t : t;
};
qe.toFixed = function(e, r) {
  var t, n, a = this, i = a.constructor;
  return e === void 0 ? t = ll(a) : (xo(e, 0, tf), r === void 0 ? r = i.rounding : xo(r, 0, 8), n = vr(new i(a), e + a.e + 1, r), t = ll(n, !1, e + n.e + 1)), a.isNeg() && !a.isZero() ? "-" + t : t;
};
qe.toFraction = function(e) {
  var r, t, n, a, i, o, c, s, u, l, f, d, m = this, p = m.d, v = m.constructor;
  if (!p) return new v(m);
  if (u = t = new v(1), n = s = new v(0), r = new v(n), i = r.e = VK(p) - m.e - 1, o = i % Cr, r.d[0] = da(10, o < 0 ? Cr + o : o), e == null)
    e = i > 0 ? r : u;
  else {
    if (c = new v(e), !c.isInt() || c.lt(u)) throw Error(Ld + c);
    e = c.gt(r) ? i > 0 ? r : u : c;
  }
  for (Br = !1, c = new v(ei(p)), l = v.precision, v.precision = i = p.length * Cr * 2; f = Ht(c, r, 0, 1, 1), a = t.plus(f.times(n)), a.cmp(e) != 1; )
    t = n, n = a, a = u, u = s.plus(f.times(a)), s = a, a = r, r = c.minus(f.times(a)), c = a;
  return a = Ht(e.minus(t), n, 0, 1, 1), s = s.plus(a.times(u)), t = t.plus(a.times(n)), s.s = u.s = m.s, d = Ht(u, n, i, 1).minus(m).abs().cmp(Ht(s, t, i, 1).minus(m).abs()) < 1 ? [u, n] : [s, t], v.precision = l, Br = !0, d;
};
qe.toHexadecimal = qe.toHex = function(e, r) {
  return AD(this, 16, e, r);
};
qe.toNearest = function(e, r) {
  var t = this, n = t.constructor;
  if (t = new n(t), e == null) {
    if (!t.d) return t;
    e = new n(1), r = n.rounding;
  } else {
    if (e = new n(e), r === void 0 ? r = n.rounding : xo(r, 0, 8), !t.d) return e.s ? t : e;
    if (!e.d)
      return e.s && (e.s = t.s), e;
  }
  return e.d[0] ? (Br = !1, t = Ht(t, e, 0, r, 1).times(e), Br = !0, vr(t)) : (e.s = t.s, t = e), t;
};
qe.toNumber = function() {
  return +this;
};
qe.toOctal = function(e, r) {
  return AD(this, 8, e, r);
};
qe.toPower = qe.pow = function(e) {
  var r, t, n, a, i, o, c = this, s = c.constructor, u = +(e = new s(e));
  if (!c.d || !e.d || !c.d[0] || !e.d[0]) return new s(da(+c, u));
  if (c = new s(c), c.eq(1)) return c;
  if (n = s.precision, i = s.rounding, e.eq(1)) return vr(c, n, i);
  if (r = xi(e.e / Cr), r >= e.d.length - 1 && (t = u < 0 ? -u : u) <= TAe)
    return a = RK(s, c, t, n), e.s < 0 ? new s(1).div(a) : vr(a, n, i);
  if (o = c.s, o < 0) {
    if (r < e.d.length - 1) return new s(NaN);
    if (e.d[r] & 1 || (o = 1), c.e == 0 && c.d[0] == 1 && c.d.length == 1)
      return c.s = o, c;
  }
  return t = da(+c, u), r = t == 0 || !isFinite(t) ? xi(u * (Math.log("0." + ei(c.d)) / Math.LN10 + c.e + 1)) : new s(t + "").e, r > s.maxE + 1 || r < s.minE - 1 ? new s(r > 0 ? o / 0 : 0) : (Br = !1, s.rounding = c.s = 1, t = Math.min(12, (r + "").length), a = Sw(e.times(md(c, n + t)), n), a.d && (a = vr(a, n + 5, 1), kg(a.d, n, i) && (r = n + 10, a = vr(Sw(e.times(md(c, r + t)), r), r + 5, 1), +ei(a.d).slice(n + 1, n + 15) + 1 == 1e14 && (a = vr(a, n + 1, 0)))), a.s = o, Br = !0, s.rounding = i, vr(a, n, i));
};
qe.toPrecision = function(e, r) {
  var t, n = this, a = n.constructor;
  return e === void 0 ? t = ll(n, n.e <= a.toExpNeg || n.e >= a.toExpPos) : (xo(e, 1, tf), r === void 0 ? r = a.rounding : xo(r, 0, 8), n = vr(new a(n), e, r), t = ll(n, e <= n.e || n.e <= a.toExpNeg, e)), n.isNeg() && !n.isZero() ? "-" + t : t;
};
qe.toSignificantDigits = qe.toSD = function(e, r) {
  var t = this, n = t.constructor;
  return e === void 0 ? (e = n.precision, r = n.rounding) : (xo(e, 1, tf), r === void 0 ? r = n.rounding : xo(r, 0, 8)), vr(new n(t), e, r);
};
qe.toString = function() {
  var e = this, r = e.constructor, t = ll(e, e.e <= r.toExpNeg || e.e >= r.toExpPos);
  return e.isNeg() && !e.isZero() ? "-" + t : t;
};
qe.truncated = qe.trunc = function() {
  return vr(new this.constructor(this), this.e + 1, 1);
};
qe.valueOf = qe.toJSON = function() {
  var e = this, r = e.constructor, t = ll(e, e.e <= r.toExpNeg || e.e >= r.toExpPos);
  return e.isNeg() ? "-" + t : t;
};
function ei(e) {
  var r, t, n, a = e.length - 1, i = "", o = e[0];
  if (a > 0) {
    for (i += o, r = 1; r < a; r++)
      n = e[r] + "", t = Cr - n.length, t && (i += Zc(t)), i += n;
    o = e[r], n = o + "", t = Cr - n.length, t && (i += Zc(t));
  } else if (o === 0)
    return "0";
  for (; o % 10 === 0; ) o /= 10;
  return i + o;
}
function xo(e, r, t) {
  if (e !== ~~e || e < r || e > t)
    throw Error(Ld + e);
}
function kg(e, r, t, n) {
  var a, i, o, c;
  for (i = e[0]; i >= 10; i /= 10) --r;
  return --r < 0 ? (r += Cr, a = 0) : (a = Math.ceil((r + 1) / Cr), r %= Cr), i = da(10, Cr - r), c = e[a] % i | 0, n == null ? r < 3 ? (r == 0 ? c = c / 100 | 0 : r == 1 && (c = c / 10 | 0), o = t < 4 && c == 99999 || t > 3 && c == 49999 || c == 5e4 || c == 0) : o = (t < 4 && c + 1 == i || t > 3 && c + 1 == i / 2) && (e[a + 1] / i / 100 | 0) == da(10, r - 2) - 1 || (c == i / 2 || c == 0) && (e[a + 1] / i / 100 | 0) == 0 : r < 4 ? (r == 0 ? c = c / 1e3 | 0 : r == 1 ? c = c / 100 | 0 : r == 2 && (c = c / 10 | 0), o = (n || t < 4) && c == 9999 || !n && t > 3 && c == 4999) : o = ((n || t < 4) && c + 1 == i || !n && t > 3 && c + 1 == i / 2) && (e[a + 1] / i / 1e3 | 0) == da(10, r - 3) - 1, o;
}
function vb(e, r, t) {
  for (var n, a = [0], i, o = 0, c = e.length; o < c; ) {
    for (i = a.length; i--; ) a[i] *= r;
    for (a[0] += yw.indexOf(e.charAt(o++)), n = 0; n < a.length; n++)
      a[n] > t - 1 && (a[n + 1] === void 0 && (a[n + 1] = 0), a[n + 1] += a[n] / t | 0, a[n] %= t);
  }
  return a.reverse();
}
function MAe(e, r) {
  var t, n, a;
  if (r.isZero()) return r;
  n = r.d.length, n < 32 ? (t = Math.ceil(n / 3), a = (1 / ox(4, t)).toString()) : (t = 16, a = "2.3283064365386962890625e-10"), e.precision += t, r = cp(e, 1, r.times(a), new e(1));
  for (var i = t; i--; ) {
    var o = r.times(r);
    r = o.times(o).minus(o).times(8).plus(1);
  }
  return e.precision -= t, r;
}
var Ht = /* @__PURE__ */ function() {
  function e(n, a, i) {
    var o, c = 0, s = n.length;
    for (n = n.slice(); s--; )
      o = n[s] * a + c, n[s] = o % i | 0, c = o / i | 0;
    return c && n.unshift(c), n;
  }
  function r(n, a, i, o) {
    var c, s;
    if (i != o)
      s = i > o ? 1 : -1;
    else
      for (c = s = 0; c < i; c++)
        if (n[c] != a[c]) {
          s = n[c] > a[c] ? 1 : -1;
          break;
        }
    return s;
  }
  function t(n, a, i, o) {
    for (var c = 0; i--; )
      n[i] -= c, c = n[i] < a[i] ? 1 : 0, n[i] = c * o + n[i] - a[i];
    for (; !n[0] && n.length > 1; ) n.shift();
  }
  return function(n, a, i, o, c, s) {
    var u, l, f, d, m, p, v, h, y, C, S, b, g, _, A, M, P, T, x, w, E = n.constructor, I = n.s == a.s ? 1 : -1, B = n.d, D = a.d;
    if (!B || !B[0] || !D || !D[0])
      return new E(
        // Return NaN if either NaN, or both Infinity or 0.
        !n.s || !a.s || (B ? D && B[0] == D[0] : !D) ? NaN : (
          // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
          B && B[0] == 0 || !D ? I * 0 : I / 0
        )
      );
    for (s ? (m = 1, l = n.e - a.e) : (s = is, m = Cr, l = xi(n.e / m) - xi(a.e / m)), x = D.length, P = B.length, y = new E(I), C = y.d = [], f = 0; D[f] == (B[f] || 0); f++) ;
    if (D[f] > (B[f] || 0) && l--, i == null ? (_ = i = E.precision, o = E.rounding) : c ? _ = i + (n.e - a.e) + 1 : _ = i, _ < 0)
      C.push(1), p = !0;
    else {
      if (_ = _ / m + 2 | 0, f = 0, x == 1) {
        for (d = 0, D = D[0], _++; (f < P || d) && _--; f++)
          A = d * s + (B[f] || 0), C[f] = A / D | 0, d = A % D | 0;
        p = d || f < P;
      } else {
        for (d = s / (D[0] + 1) | 0, d > 1 && (D = e(D, d, s), B = e(B, d, s), x = D.length, P = B.length), M = x, S = B.slice(0, x), b = S.length; b < x; ) S[b++] = 0;
        w = D.slice(), w.unshift(0), T = D[0], D[1] >= s / 2 && ++T;
        do
          d = 0, u = r(D, S, x, b), u < 0 ? (g = S[0], x != b && (g = g * s + (S[1] || 0)), d = g / T | 0, d > 1 ? (d >= s && (d = s - 1), v = e(D, d, s), h = v.length, b = S.length, u = r(v, S, h, b), u == 1 && (d--, t(v, x < h ? w : D, h, s))) : (d == 0 && (u = d = 1), v = D.slice()), h = v.length, h < b && v.unshift(0), t(S, v, b, s), u == -1 && (b = S.length, u = r(D, S, x, b), u < 1 && (d++, t(S, x < b ? w : D, b, s))), b = S.length) : u === 0 && (d++, S = [0]), C[f++] = d, u && S[0] ? S[b++] = B[M] || 0 : (S = [B[M]], b = 1);
        while ((M++ < P || S[0] !== void 0) && _--);
        p = S[0] !== void 0;
      }
      C[0] || C.shift();
    }
    if (m == 1)
      y.e = l, EK = p;
    else {
      for (f = 1, d = C[0]; d >= 10; d /= 10) f++;
      y.e = f + l * m - 1, vr(y, c ? i + y.e + 1 : i, o, p);
    }
    return y;
  };
}();
function vr(e, r, t, n) {
  var a, i, o, c, s, u, l, f, d, m = e.constructor;
  e: if (r != null) {
    if (f = e.d, !f) return e;
    for (a = 1, c = f[0]; c >= 10; c /= 10) a++;
    if (i = r - a, i < 0)
      i += Cr, o = r, l = f[d = 0], s = l / da(10, a - o - 1) % 10 | 0;
    else if (d = Math.ceil((i + 1) / Cr), c = f.length, d >= c)
      if (n) {
        for (; c++ <= d; ) f.push(0);
        l = s = 0, a = 1, i %= Cr, o = i - Cr + 1;
      } else
        break e;
    else {
      for (l = c = f[d], a = 1; c >= 10; c /= 10) a++;
      i %= Cr, o = i - Cr + a, s = o < 0 ? 0 : l / da(10, a - o - 1) % 10 | 0;
    }
    if (n = n || r < 0 || f[d + 1] !== void 0 || (o < 0 ? l : l % da(10, a - o - 1)), u = t < 4 ? (s || n) && (t == 0 || t == (e.s < 0 ? 3 : 2)) : s > 5 || s == 5 && (t == 4 || n || t == 6 && // Check whether the digit to the left of the rounding digit is odd.
    (i > 0 ? o > 0 ? l / da(10, a - o) : 0 : f[d - 1]) % 10 & 1 || t == (e.s < 0 ? 8 : 7)), r < 1 || !f[0])
      return f.length = 0, u ? (r -= e.e + 1, f[0] = da(10, (Cr - r % Cr) % Cr), e.e = -r || 0) : f[0] = e.e = 0, e;
    if (i == 0 ? (f.length = d, c = 1, d--) : (f.length = d + 1, c = da(10, Cr - i), f[d] = o > 0 ? (l / da(10, a - o) % da(10, o) | 0) * c : 0), u)
      for (; ; )
        if (d == 0) {
          for (i = 1, o = f[0]; o >= 10; o /= 10) i++;
          for (o = f[0] += c, c = 1; o >= 10; o /= 10) c++;
          i != c && (e.e++, f[0] == is && (f[0] = 1));
          break;
        } else {
          if (f[d] += c, f[d] != is) break;
          f[d--] = 0, c = 1;
        }
    for (i = f.length; f[--i] === 0; ) f.pop();
  }
  return Br && (e.e > m.maxE ? (e.d = null, e.e = NaN) : e.e < m.minE && (e.e = 0, e.d = [0])), e;
}
function ll(e, r, t) {
  if (!e.isFinite()) return FK(e);
  var n, a = e.e, i = ei(e.d), o = i.length;
  return r ? (t && (n = t - o) > 0 ? i = i.charAt(0) + "." + i.slice(1) + Zc(n) : o > 1 && (i = i.charAt(0) + "." + i.slice(1)), i = i + (e.e < 0 ? "e" : "e+") + e.e) : a < 0 ? (i = "0." + Zc(-a - 1) + i, t && (n = t - o) > 0 && (i += Zc(n))) : a >= o ? (i += Zc(a + 1 - o), t && (n = t - a - 1) > 0 && (i = i + "." + Zc(n))) : ((n = a + 1) < o && (i = i.slice(0, n) + "." + i.slice(n)), t && (n = t - o) > 0 && (a + 1 === o && (i += "."), i += Zc(n))), i;
}
function ix(e, r) {
  var t = e[0];
  for (r *= Cr; t >= 10; t /= 10) r++;
  return r;
}
function g3(e, r, t) {
  if (r > PAe)
    throw Br = !0, t && (e.precision = t), Error(DK);
  return vr(new e(p3), r, 1, !0);
}
function es(e, r, t) {
  if (r > bw) throw Error(DK);
  return vr(new e(h3), r, t, !0);
}
function VK(e) {
  var r = e.length - 1, t = r * Cr + 1;
  if (r = e[r], r) {
    for (; r % 10 == 0; r /= 10) t--;
    for (r = e[0]; r >= 10; r /= 10) t++;
  }
  return t;
}
function Zc(e) {
  for (var r = ""; e--; ) r += "0";
  return r;
}
function RK(e, r, t, n) {
  var a, i = new e(1), o = Math.ceil(n / Cr + 4);
  for (Br = !1; ; ) {
    if (t % 2 && (i = i.times(r), gR(i.d, o) && (a = !0)), t = xi(t / 2), t === 0) {
      t = i.d.length - 1, a && i.d[t] === 0 && ++i.d[t];
      break;
    }
    r = r.times(r), gR(r.d, o);
  }
  return Br = !0, i;
}
function hR(e) {
  return e.d[e.d.length - 1] & 1;
}
function OK(e, r, t) {
  for (var n, a = new e(r[0]), i = 0; ++i < r.length; )
    if (n = new e(r[i]), n.s)
      a[t](n) && (a = n);
    else {
      a = n;
      break;
    }
  return a;
}
function Sw(e, r) {
  var t, n, a, i, o, c, s, u = 0, l = 0, f = 0, d = e.constructor, m = d.rounding, p = d.precision;
  if (!e.d || !e.d[0] || e.e > 17)
    return new d(e.d ? e.d[0] ? e.s < 0 ? 0 : 1 / 0 : 1 : e.s ? e.s < 0 ? 0 : e : NaN);
  for (r == null ? (Br = !1, s = p) : s = r, c = new d(0.03125); e.e > -2; )
    e = e.times(c), f += 5;
  for (n = Math.log(da(2, f)) / Math.LN10 * 2 + 5 | 0, s += n, t = i = o = new d(1), d.precision = s; ; ) {
    if (i = vr(i.times(e), s, 1), t = t.times(++l), c = o.plus(Ht(i, t, s, 1)), ei(c.d).slice(0, s) === ei(o.d).slice(0, s)) {
      for (a = f; a--; ) o = vr(o.times(o), s, 1);
      if (r == null)
        if (u < 3 && kg(o.d, s - n, m, u))
          d.precision = s += 10, t = i = c = new d(1), l = 0, u++;
        else
          return vr(o, d.precision = p, m, Br = !0);
      else
        return d.precision = p, o;
    }
    o = c;
  }
}
function md(e, r) {
  var t, n, a, i, o, c, s, u, l, f, d, m = 1, p = 10, v = e, h = v.d, y = v.constructor, C = y.rounding, S = y.precision;
  if (v.s < 0 || !h || !h[0] || !v.e && h[0] == 1 && h.length == 1)
    return new y(h && !h[0] ? -1 / 0 : v.s != 1 ? NaN : h ? 0 : v);
  if (r == null ? (Br = !1, l = S) : l = r, y.precision = l += p, t = ei(h), n = t.charAt(0), Math.abs(i = v.e) < 15e14) {
    for (; n < 7 && n != 1 || n == 1 && t.charAt(1) > 3; )
      v = v.times(e), t = ei(v.d), n = t.charAt(0), m++;
    i = v.e, n > 1 ? (v = new y("0." + t), i++) : v = new y(n + "." + t.slice(1));
  } else
    return u = g3(y, l + 2, S).times(i + ""), v = md(new y(n + "." + t.slice(1)), l - p).plus(u), y.precision = S, r == null ? vr(v, S, C, Br = !0) : v;
  for (f = v, s = o = v = Ht(v.minus(1), v.plus(1), l, 1), d = vr(v.times(v), l, 1), a = 3; ; ) {
    if (o = vr(o.times(d), l, 1), u = s.plus(Ht(o, new y(a), l, 1)), ei(u.d).slice(0, l) === ei(s.d).slice(0, l))
      if (s = s.times(2), i !== 0 && (s = s.plus(g3(y, l + 2, S).times(i + ""))), s = Ht(s, new y(m), l, 1), r == null)
        if (kg(s.d, l - p, C, c))
          y.precision = l += p, u = o = v = Ht(f.minus(1), f.plus(1), l, 1), d = vr(v.times(v), l, 1), a = c = 1;
        else
          return vr(s, y.precision = S, C, Br = !0);
      else
        return y.precision = S, s;
    s = u, a += 2;
  }
}
function FK(e) {
  return String(e.s * e.s / 0);
}
function Cw(e, r) {
  var t, n, a;
  for ((t = r.indexOf(".")) > -1 && (r = r.replace(".", "")), (n = r.search(/e/i)) > 0 ? (t < 0 && (t = n), t += +r.slice(n + 1), r = r.substring(0, n)) : t < 0 && (t = r.length), n = 0; r.charCodeAt(n) === 48; n++) ;
  for (a = r.length; r.charCodeAt(a - 1) === 48; --a) ;
  if (r = r.slice(n, a), r) {
    if (a -= n, e.e = t = t - n - 1, e.d = [], n = (t + 1) % Cr, t < 0 && (n += Cr), n < a) {
      for (n && e.d.push(+r.slice(0, n)), a -= Cr; n < a; ) e.d.push(+r.slice(n, n += Cr));
      r = r.slice(n), n = Cr - r.length;
    } else
      n -= a;
    for (; n--; ) r += "0";
    e.d.push(+r), Br && (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 wAe(e, r) {
  var t, n, a, i, o, c, s, u, l;
  if (r.indexOf("_") > -1) {
    if (r = r.replace(/(\d)_(?=\d)/g, "$1"), NK.test(r)) return Cw(e, r);
  } else if (r === "Infinity" || r === "NaN")
    return +r || (e.s = NaN), e.e = NaN, e.d = null, e;
  if (AAe.test(r))
    t = 16, r = r.toLowerCase();
  else if (CAe.test(r))
    t = 2;
  else if (xAe.test(r))
    t = 8;
  else
    throw Error(Ld + r);
  for (i = r.search(/p/i), i > 0 ? (s = +r.slice(i + 1), r = r.substring(2, i)) : r = r.slice(2), i = r.indexOf("."), o = i >= 0, n = e.constructor, o && (r = r.replace(".", ""), c = r.length, i = c - i, a = RK(n, new n(t), i, i * 2)), u = vb(r, t, is), l = u.length - 1, i = l; u[i] === 0; --i) u.pop();
  return i < 0 ? new n(e.s * 0) : (e.e = ix(u, l), e.d = u, Br = !1, o && (e = Ht(e, a, c * 4)), s && (e = e.times(Math.abs(s) < 54 ? da(2, s) : kd.pow(2, s))), Br = !0, e);
}
function EAe(e, r) {
  var t, n = r.d.length;
  if (n < 3)
    return r.isZero() ? r : cp(e, 2, r, r);
  t = 1.4 * Math.sqrt(n), t = t > 16 ? 16 : t | 0, r = r.times(1 / ox(5, t)), r = cp(e, 2, r, r);
  for (var a, i = new e(5), o = new e(16), c = new e(20); t--; )
    a = r.times(r), r = r.times(i.plus(a.times(o.times(a).minus(c))));
  return r;
}
function cp(e, r, t, n, a) {
  var i, o, c, s, u = e.precision, l = Math.ceil(u / Cr);
  for (Br = !1, s = t.times(t), c = new e(n); ; ) {
    if (o = Ht(c.times(s), new e(r++ * r++), u, 1), c = a ? n.plus(o) : n.minus(o), n = Ht(o.times(s), new e(r++ * r++), u, 1), o = c.plus(n), o.d[l] !== void 0) {
      for (i = l; o.d[i] === c.d[i] && i--; ) ;
      if (i == -1) break;
    }
    i = c, c = n, n = o, o = i;
  }
  return Br = !0, o.d.length = l + 1, o;
}
function ox(e, r) {
  for (var t = e; --r; ) t *= e;
  return t;
}
function LK(e, r) {
  var t, n = r.s < 0, a = es(e, e.precision, 1), i = a.times(0.5);
  if (r = r.abs(), r.lte(i))
    return Ql = n ? 4 : 1, r;
  if (t = r.divToInt(a), t.isZero())
    Ql = n ? 3 : 2;
  else {
    if (r = r.minus(t.times(a)), r.lte(i))
      return Ql = hR(t) ? n ? 2 : 3 : n ? 4 : 1, r;
    Ql = hR(t) ? n ? 1 : 4 : n ? 3 : 2;
  }
  return r.minus(a).abs();
}
function AD(e, r, t, n) {
  var a, i, o, c, s, u, l, f, d, m = e.constructor, p = t !== void 0;
  if (p ? (xo(t, 1, tf), n === void 0 ? n = m.rounding : xo(n, 0, 8)) : (t = m.precision, n = m.rounding), !e.isFinite())
    l = FK(e);
  else {
    for (l = ll(e), o = l.indexOf("."), p ? (a = 2, r == 16 ? t = t * 4 - 3 : r == 8 && (t = t * 3 - 2)) : a = r, o >= 0 && (l = l.replace(".", ""), d = new m(1), d.e = l.length - o, d.d = vb(ll(d), 10, a), d.e = d.d.length), f = vb(l, 10, a), i = s = f.length; f[--s] == 0; ) f.pop();
    if (!f[0])
      l = p ? "0p+0" : "0";
    else {
      if (o < 0 ? i-- : (e = new m(e), e.d = f, e.e = i, e = Ht(e, d, t, n, 0, a), f = e.d, i = e.e, u = EK), o = f[t], c = a / 2, u = u || f[t + 1] !== void 0, u = n < 4 ? (o !== void 0 || u) && (n === 0 || n === (e.s < 0 ? 3 : 2)) : o > c || o === c && (n === 4 || u || n === 6 && f[t - 1] & 1 || n === (e.s < 0 ? 8 : 7)), f.length = t, u)
        for (; ++f[--t] > a - 1; )
          f[t] = 0, t || (++i, f.unshift(1));
      for (s = f.length; !f[s - 1]; --s) ;
      for (o = 0, l = ""; o < s; o++) l += yw.charAt(f[o]);
      if (p) {
        if (s > 1)
          if (r == 16 || r == 8) {
            for (o = r == 16 ? 4 : 3, --s; s % o; s++) l += "0";
            for (f = vb(l, a, r), s = f.length; !f[s - 1]; --s) ;
            for (o = 1, l = "1."; o < s; o++) l += yw.charAt(f[o]);
          } else
            l = l.charAt(0) + "." + l.slice(1);
        l = l + (i < 0 ? "p" : "p+") + i;
      } else if (i < 0) {
        for (; ++i; ) l = "0" + l;
        l = "0." + l;
      } else if (++i > s) for (i -= s; i--; ) l += "0";
      else i < s && (l = l.slice(0, i) + "." + l.slice(i));
    }
    l = (r == 16 ? "0x" : r == 2 ? "0b" : r == 8 ? "0o" : "") + l;
  }
  return e.s < 0 ? "-" + l : l;
}
function gR(e, r) {
  if (e.length > r)
    return e.length = r, !0;
}
function DAe(e) {
  return new this(e).abs();
}
function IAe(e) {
  return new this(e).acos();
}
function BAe(e) {
  return new this(e).acosh();
}
function NAe(e, r) {
  return new this(e).plus(r);
}
function VAe(e) {
  return new this(e).asin();
}
function RAe(e) {
  return new this(e).asinh();
}
function OAe(e) {
  return new this(e).atan();
}
function FAe(e) {
  return new this(e).atanh();
}
function LAe(e, r) {
  e = new this(e), r = new this(r);
  var t, n = this.precision, a = this.rounding, i = n + 4;
  return !e.s || !r.s ? t = new this(NaN) : !e.d && !r.d ? (t = es(this, i, 1).times(r.s > 0 ? 0.25 : 0.75), t.s = e.s) : !r.d || e.isZero() ? (t = r.s < 0 ? es(this, n, a) : new this(0), t.s = e.s) : !e.d || r.isZero() ? (t = es(this, i, 1).times(0.5), t.s = e.s) : r.s < 0 ? (this.precision = i, this.rounding = 1, t = this.atan(Ht(e, r, i, 1)), r = es(this, i, 1), this.precision = n, this.rounding = a, t = e.s < 0 ? t.minus(r) : t.plus(r)) : t = this.atan(Ht(e, r, i, 1)), t;
}
function kAe(e) {
  return new this(e).cbrt();
}
function UAe(e) {
  return vr(e = new this(e), e.e + 1, 2);
}
function zAe(e, r, t) {
  return new this(e).clamp(r, t);
}
function GAe(e) {
  if (!e || typeof e != "object") throw Error(ax + "Object expected");
  var r, t, n, a = e.defaults === !0, i = [
    "precision",
    1,
    tf,
    "rounding",
    0,
    8,
    "toExpNeg",
    -iv,
    0,
    "toExpPos",
    0,
    iv,
    "maxE",
    0,
    iv,
    "minE",
    -iv,
    0,
    "modulo",
    0,
    9
  ];
  for (r = 0; r < i.length; r += 3)
    if (t = i[r], a && (this[t] = _w[t]), (n = e[t]) !== void 0)
      if (xi(n) === n && n >= i[r + 1] && n <= i[r + 2]) this[t] = n;
      else throw Error(Ld + t + ": " + n);
  if (t = "crypto", a && (this[t] = _w[t]), (n = e[t]) !== void 0)
    if (n === !0 || n === !1 || n === 0 || n === 1)
      if (n)
        if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes))
          this[t] = !0;
        else
          throw Error(IK);
      else
        this[t] = !1;
    else
      throw Error(Ld + t + ": " + n);
  return this;
}
function qAe(e) {
  return new this(e).cos();
}
function HAe(e) {
  return new this(e).cosh();
}
function kK(e) {
  var r, t, n;
  function a(i) {
    var o, c, s, u = this;
    if (!(u instanceof a)) return new a(i);
    if (u.constructor = a, yR(i)) {
      u.s = i.s, Br ? !i.d || i.e > a.maxE ? (u.e = NaN, u.d = null) : i.e < a.minE ? (u.e = 0, u.d = [0]) : (u.e = i.e, u.d = i.d.slice()) : (u.e = i.e, u.d = i.d ? i.d.slice() : i.d);
      return;
    }
    if (s = typeof i, s === "number") {
      if (i === 0) {
        u.s = 1 / i < 0 ? -1 : 1, u.e = 0, u.d = [0];
        return;
      }
      if (i < 0 ? (i = -i, u.s = -1) : u.s = 1, i === ~~i && i < 1e7) {
        for (o = 0, c = i; c >= 10; c /= 10) o++;
        Br ? o > a.maxE ? (u.e = NaN, u.d = null) : o < a.minE ? (u.e = 0, u.d = [0]) : (u.e = o, u.d = [i]) : (u.e = o, u.d = [i]);
        return;
      } else if (i * 0 !== 0) {
        i || (u.s = NaN), u.e = NaN, u.d = null;
        return;
      }
      return Cw(u, i.toString());
    } else if (s !== "string")
      throw Error(Ld + i);
    return (c = i.charCodeAt(0)) === 45 ? (i = i.slice(1), u.s = -1) : (c === 43 && (i = i.slice(1)), u.s = 1), NK.test(i) ? Cw(u, i) : wAe(u, i);
  }
  if (a.prototype = qe, a.ROUND_UP = 0, a.ROUND_DOWN = 1, a.ROUND_CEIL = 2, a.ROUND_FLOOR = 3, a.ROUND_HALF_UP = 4, a.ROUND_HALF_DOWN = 5, a.ROUND_HALF_EVEN = 6, a.ROUND_HALF_CEIL = 7, a.ROUND_HALF_FLOOR = 8, a.EUCLID = 9, a.config = a.set = GAe, a.clone = kK, a.isDecimal = yR, a.abs = DAe, a.acos = IAe, a.acosh = BAe, a.add = NAe, a.asin = VAe, a.asinh = RAe, a.atan = OAe, a.atanh = FAe, a.atan2 = LAe, a.cbrt = kAe, a.ceil = UAe, a.clamp = zAe, a.cos = qAe, a.cosh = HAe, a.div = jAe, a.exp = $Ae, a.floor = KAe, a.hypot = WAe, a.ln = XAe, a.log = YAe, a.log10 = ZAe, a.log2 = QAe, a.max = JAe, a.min = exe, a.mod = rxe, a.mul = txe, a.pow = nxe, a.random = axe, a.round = ixe, a.sign = oxe, a.sin = uxe, a.sinh = sxe, a.sqrt = lxe, a.sub = cxe, a.sum = dxe, a.tan = fxe, a.tanh = mxe, a.trunc = vxe, e === void 0 && (e = {}), e && e.defaults !== !0)
    for (n = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"], r = 0; r < n.length; ) e.hasOwnProperty(t = n[r++]) || (e[t] = this[t]);
  return a.config(e), a;
}
function jAe(e, r) {
  return new this(e).div(r);
}
function $Ae(e) {
  return new this(e).exp();
}
function KAe(e) {
  return vr(e = new this(e), e.e + 1, 3);
}
function WAe() {
  var e, r, t = new this(0);
  for (Br = !1, e = 0; e < arguments.length; )
    if (r = new this(arguments[e++]), r.d)
      t.d && (t = t.plus(r.times(r)));
    else {
      if (r.s)
        return Br = !0, new this(1 / 0);
      t = r;
    }
  return Br = !0, t.sqrt();
}
function yR(e) {
  return e instanceof kd || e && e.toStringTag === BK || !1;
}
function XAe(e) {
  return new this(e).ln();
}
function YAe(e, r) {
  return new this(e).log(r);
}
function QAe(e) {
  return new this(e).log(2);
}
function ZAe(e) {
  return new this(e).log(10);
}
function JAe() {
  return OK(this, arguments, "lt");
}
function exe() {
  return OK(this, arguments, "gt");
}
function rxe(e, r) {
  return new this(e).mod(r);
}
function txe(e, r) {
  return new this(e).mul(r);
}
function nxe(e, r) {
  return new this(e).pow(r);
}
function axe(e) {
  var r, t, n, a, i = 0, o = new this(1), c = [];
  if (e === void 0 ? e = this.precision : xo(e, 1, tf), n = Math.ceil(e / Cr), this.crypto)
    if (crypto.getRandomValues)
      for (r = crypto.getRandomValues(new Uint32Array(n)); i < n; )
        a = r[i], a >= 429e7 ? r[i] = crypto.getRandomValues(new Uint32Array(1))[0] : c[i++] = a % 1e7;
    else if (crypto.randomBytes) {
      for (r = crypto.randomBytes(n *= 4); i < n; )
        a = r[i] + (r[i + 1] << 8) + (r[i + 2] << 16) + ((r[i + 3] & 127) << 24), a >= 214e7 ? crypto.randomBytes(4).copy(r, i) : (c.push(a % 1e7), i += 4);
      i = n / 4;
    } else
      throw Error(IK);
  else for (; i < n; ) c[i++] = Math.random() * 1e7 | 0;
  for (n = c[--i], e %= Cr, n && e && (a = da(10, Cr - e), c[i] = (n / a | 0) * a); c[i] === 0; i--) c.pop();
  if (i < 0)
    t = 0, c = [0];
  else {
    for (t = -1; c[0] === 0; t -= Cr) c.shift();
    for (n = 1, a = c[0]; a >= 10; a /= 10) n++;
    n < Cr && (t -= Cr - n);
  }
  return o.e = t, o.d = c, o;
}
function ixe(e) {
  return vr(e = new this(e), e.e + 1, this.rounding);
}
function oxe(e) {
  return e = new this(e), e.d ? e.d[0] ? e.s : 0 * e.s : e.s || NaN;
}
function uxe(e) {
  return new this(e).sin();
}
function sxe(e) {
  return new this(e).sinh();
}
function lxe(e) {
  return new this(e).sqrt();
}
function cxe(e, r) {
  return new this(e).sub(r);
}
function dxe() {
  var e = 0, r = arguments, t = new this(r[e]);
  for (Br = !1; t.s && ++e < r.length; ) t = t.plus(r[e]);
  return Br = !0, vr(t, this.precision, this.rounding);
}
function fxe(e) {
  return new this(e).tan();
}
function mxe(e) {
  return new this(e).tanh();
}
function vxe(e) {
  return vr(e = new this(e), e.e + 1, 1);
}
qe[Symbol.for("nodejs.util.inspect.custom")] = qe.toString;
qe[Symbol.toStringTag] = "Decimal";
var kd = qe.constructor = kK(_w);
p3 = new kd(p3);
h3 = new kd(h3);
var pxe = "BigNumber", hxe = ["?on", "config"], UK = /* @__PURE__ */ Ce(pxe, hxe, (e) => {
  var {
    on: r,
    config: t
  } = e, n = kd.clone({
    precision: t.precision,
    modulo: kd.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(a) {
    return new n(a.value);
  }, r && r("config", function(a, i) {
    a.precision !== i.precision && n.config({
      precision: a.precision
    });
  }), n;
}, {
  isClass: !0
}), zK = { 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, r) {
  (function(t) {
    var n = Math.cosh || function(f) {
      return Math.abs(f) < 1e-9 ? 1 - f : (Math.exp(f) + Math.exp(-f)) * 0.5;
    }, a = Math.sinh || function(f) {
      return Math.abs(f) < 1e-9 ? f : (Math.exp(f) - Math.exp(-f)) * 0.5;
    }, i = function(f) {
      var d = Math.PI / 4;
      if (-d > f || f > d)
        return Math.cos(f) - 1;
      var m = f * f;
      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(f, d) {
      var m = Math.abs(f), p = Math.abs(d);
      return m < 3e3 && p < 3e3 ? Math.sqrt(m * m + p * p) : (m < p ? (m = p, p = f / d) : p = d / f, m * Math.sqrt(1 + p * p));
    }, c = function() {
      throw SyntaxError("Invalid Param");
    };
    function s(f, d) {
      var m = Math.abs(f), p = Math.abs(d);
      return f === 0 ? Math.log(p) : d === 0 ? Math.log(m) : m < 3e3 && p < 3e3 ? Math.log(f * f + d * d) * 0.5 : (f = f / 2, d = d / 2, 0.5 * Math.log(f * f + d * d) + Math.LN2);
    }
    var u = function(f, d) {
      var m = { re: 0, im: 0 };
      if (f == null)
        m.re = m.im = 0;
      else if (d !== void 0)
        m.re = f, m.im = d;
      else
        switch (typeof f) {
          case "object":
            if ("im" in f && "re" in f)
              m.re = f.re, m.im = f.im;
            else if ("abs" in f && "arg" in f) {
              if (!Number.isFinite(f.abs) && Number.isFinite(f.arg))
                return l.INFINITY;
              m.re = f.abs * Math.cos(f.arg), m.im = f.abs * Math.sin(f.arg);
            } else if ("r" in f && "phi" in f) {
              if (!Number.isFinite(f.r) && Number.isFinite(f.phi))
                return l.INFINITY;
              m.re = f.r * Math.cos(f.phi), m.im = f.r * Math.sin(f.phi);
            } else f.length === 2 ? (m.re = f[0], m.im = f[1]) : c();
            break;
          case "string":
            m.im = /* void */
            m.re = 0;
            var p = f.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g), v = 1, h = 0;
            p === null && c();
            for (var y = 0; y < p.length; y++) {
              var C = p[y];
              C === " " || C === "	" || C === `
` || (C === "+" ? v++ : C === "-" ? h++ : C === "i" || C === "I" ? (v + h === 0 && c(), p[y + 1] !== " " && !isNaN(p[y + 1]) ? (m.im += parseFloat((h % 2 ? "-" : "") + p[y + 1]), y++) : m.im += parseFloat((h % 2 ? "-" : "") + "1"), v = h = 0) : ((v + h === 0 || isNaN(C)) && c(), p[y + 1] === "i" || p[y + 1] === "I" ? (m.im += parseFloat((h % 2 ? "-" : "") + C), y++) : m.re += parseFloat((h % 2 ? "-" : "") + C), v = h = 0));
            }
            v + h > 0 && c();
            break;
          case "number":
            m.im = 0, m.re = f;
            break;
          default:
            c();
        }
      return isNaN(m.re) || isNaN(m.im), m;
    };
    function l(f, d) {
      if (!(this instanceof l))
        return new l(f, d);
      var m = u(f, d);
      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 f = this.abs();
        return new l(
          this.re / f,
          this.im / f
        );
      },
      /**
       * Adds two complex numbers
       *
       * @returns {Complex}
       */
      add: function(f, d) {
        var m = new l(f, d);
        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(f, d) {
        var m = new l(f, d);
        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(f, d) {
        var m = new l(f, d);
        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(f, d) {
        var m = new l(f, d);
        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;
        f = this.re, d = this.im;
        var p = m.re, v = m.im, h, y;
        return v === 0 ? new l(f / p, d / p) : Math.abs(p) < Math.abs(v) ? (y = p / v, h = p * y + v, new l(
          (f * y + d) / h,
          (d * y - f) / h
        )) : (y = v / p, h = v * y + p, new l(
          (f + d * y) / h,
          (d - f * y) / h
        ));
      },
      /**
       * Calculate the power of two complex numbers
       *
       * @returns {Complex}
       */
      pow: function(f, d) {
        var m = new l(f, d);
        if (f = this.re, d = this.im, m.isZero())
          return l.ONE;
        if (m.im === 0) {
          if (d === 0 && f > 0)
            return new l(Math.pow(f, m.re), 0);
          if (f === 0)
            switch ((m.re % 4 + 4) % 4) {
              case 0:
                return new l(Math.pow(d, m.re), 0);
              case 1:
                return new l(0, Math.pow(d, m.re));
              case 2:
                return new l(-Math.pow(d, m.re), 0);
              case 3:
                return new l(0, -Math.pow(d, m.re));
            }
        }
        if (f === 0 && d === 0 && m.re > 0 && m.im >= 0)
          return l.ZERO;
        var p = Math.atan2(d, f), v = s(f, d);
        return f = Math.exp(m.re * v - m.im * p), d = m.im * v + m.re * p, new l(
          f * Math.cos(d),
          f * Math.sin(d)
        );
      },
      /**
       * Calculate the complex square root
       *
       * @returns {Complex}
       */
      sqrt: function() {
        var f = this.re, d = this.im, m = this.abs(), p, v;
        if (f >= 0) {
          if (d === 0)
            return new l(Math.sqrt(f), 0);
          p = 0.5 * Math.sqrt(2 * (m + f));
        } else
          p = Math.abs(d) / Math.sqrt(2 * (m - f));
        return f <= 0 ? v = 0.5 * Math.sqrt(2 * (m - f)) : v = Math.abs(d) / Math.sqrt(2 * (m + f)), new l(p, d < 0 ? -v : v);
      },
      /**
       * Calculate the complex exponent
       *
       * @returns {Complex}
       */
      exp: function() {
        var f = Math.exp(this.re);
        return this.im, new l(
          f * Math.cos(this.im),
          f * 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 f = this.re, d = this.im;
        return new l(
          Math.expm1(f) * Math.cos(d) + i(d),
          Math.exp(f) * Math.sin(d)
        );
      },
      /**
       * Calculate the natural log
       *
       * @returns {Complex}
       */
      log: function() {
        var f = this.re, d = this.im;
        return new l(
          s(f, d),
          Math.atan2(d, f)
        );
      },
      /**
       * 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 f = this.re, d = this.im;
        return new l(
          Math.sin(f) * n(d),
          Math.cos(f) * a(d)
        );
      },
      /**
       * Calculate the cosine
       *
       * @returns {Complex}
       */
      cos: function() {
        var f = this.re, d = this.im;
        return new l(
          Math.cos(f) * n(d),
          -Math.sin(f) * a(d)
        );
      },
      /**
       * Calculate the tangent
       *
       * @returns {Complex}
       */
      tan: function() {
        var f = 2 * this.re, d = 2 * this.im, m = Math.cos(f) + n(d);
        return new l(
          Math.sin(f) / m,
          a(d) / m
        );
      },
      /**
       * Calculate the cotangent
       *
       * @returns {Complex}
       */
      cot: function() {
        var f = 2 * this.re, d = 2 * this.im, m = Math.cos(f) - n(d);
        return new l(
          -Math.sin(f) / m,
          a(d) / m
        );
      },
      /**
       * Calculate the secant
       *
       * @returns {Complex}
       */
      sec: function() {
        var f = this.re, d = this.im, m = 0.5 * n(2 * d) + 0.5 * Math.cos(2 * f);
        return new l(
          Math.cos(f) * n(d) / m,
          Math.sin(f) * a(d) / m
        );
      },
      /**
       * Calculate the cosecans
       *
       * @returns {Complex}
       */
      csc: function() {
        var f = this.re, d = this.im, m = 0.5 * n(2 * d) - 0.5 * Math.cos(2 * f);
        return new l(
          Math.sin(f) * n(d) / m,
          -Math.cos(f) * a(d) / m
        );
      },
      /**
       * Calculate the complex arcus sinus
       *
       * @returns {Complex}
       */
      asin: function() {
        var f = this.re, d = this.im, m = new l(
          d * d - f * f + 1,
          -2 * f * d
        ).sqrt(), p = new l(
          m.re - d,
          m.im + f
        ).log();
        return new l(p.im, -p.re);
      },
      /**
       * Calculate the complex arcus cosinus
       *
       * @returns {Complex}
       */
      acos: function() {
        var f = this.re, d = this.im, m = new l(
          d * d - f * f + 1,
          -2 * f * d
        ).sqrt(), p = new l(
          m.re - d,
          m.im + f
        ).log();
        return new l(Math.PI / 2 - p.im, p.re);
      },
      /**
       * Calculate the complex arcus tangent
       *
       * @returns {Complex}
       */
      atan: function() {
        var f = this.re, d = this.im;
        if (f === 0) {
          if (d === 1)
            return new l(0, 1 / 0);
          if (d === -1)
            return new l(0, -1 / 0);
        }
        var m = f * f + (1 - d) * (1 - d), p = new l(
          (1 - d * d - f * f) / m,
          -2 * f / m
        ).log();
        return new l(-0.5 * p.im, 0.5 * p.re);
      },
      /**
       * Calculate the complex arcus cotangent
       *
       * @returns {Complex}
       */
      acot: function() {
        var f = this.re, d = this.im;
        if (d === 0)
          return new l(Math.atan2(1, f), 0);
        var m = f * f + d * d;
        return m !== 0 ? new l(
          f / m,
          -d / m
        ).atan() : new l(
          f !== 0 ? f / 0 : 0,
          d !== 0 ? -d / 0 : 0
        ).atan();
      },
      /**
       * Calculate the complex arcus secant
       *
       * @returns {Complex}
       */
      asec: function() {
        var f = this.re, d = this.im;
        if (f === 0 && d === 0)
          return new l(0, 1 / 0);
        var m = f * f + d * d;
        return m !== 0 ? new l(
          f / m,
          -d / m
        ).acos() : new l(
          f !== 0 ? f / 0 : 0,
          d !== 0 ? -d / 0 : 0
        ).acos();
      },
      /**
       * Calculate the complex arcus cosecans
       *
       * @returns {Complex}
       */
      acsc: function() {
        var f = this.re, d = this.im;
        if (f === 0 && d === 0)
          return new l(Math.PI / 2, 1 / 0);
        var m = f * f + d * d;
        return m !== 0 ? new l(
          f / m,
          -d / m
        ).asin() : new l(
          f !== 0 ? f / 0 : 0,
          d !== 0 ? -d / 0 : 0
        ).asin();
      },
      /**
       * Calculate the complex sinh
       *
       * @returns {Complex}
       */
      sinh: function() {
        var f = this.re, d = this.im;
        return new l(
          a(f) * Math.cos(d),
          n(f) * Math.sin(d)
        );
      },
      /**
       * Calculate the complex cosh
       *
       * @returns {Complex}
       */
      cosh: function() {
        var f = this.re, d = this.im;
        return new l(
          n(f) * Math.cos(d),
          a(f) * Math.sin(d)
        );
      },
      /**
       * Calculate the complex tanh
       *
       * @returns {Complex}
       */
      tanh: function() {
        var f = 2 * this.re, d = 2 * this.im, m = n(f) + Math.cos(d);
        return new l(
          a(f) / m,
          Math.sin(d) / m
        );
      },
      /**
       * Calculate the complex coth
       *
       * @returns {Complex}
       */
      coth: function() {
        var f = 2 * this.re, d = 2 * this.im, m = n(f) - Math.cos(d);
        return new l(
          a(f) / m,
          -Math.sin(d) / m
        );
      },
      /**
       * Calculate the complex coth
       *
       * @returns {Complex}
       */
      csch: function() {
        var f = this.re, d = this.im, m = Math.cos(2 * d) - n(2 * f);
        return new l(
          -2 * a(f) * Math.cos(d) / m,
          2 * n(f) * Math.sin(d) / m
        );
      },
      /**
       * Calculate the complex sech
       *
       * @returns {Complex}
       */
      sech: function() {
        var f = this.re, d = this.im, m = Math.cos(2 * d) + n(2 * f);
        return new l(
          2 * n(f) * Math.cos(d) / m,
          -2 * a(f) * Math.sin(d) / m
        );
      },
      /**
       * Calculate the complex asinh
       *
       * @returns {Complex}
       */
      asinh: function() {
        var f = this.im;
        this.im = -this.re, this.re = f;
        var d = this.asin();
        return this.re = -this.im, this.im = f, f = d.re, d.re = -d.im, d.im = f, d;
      },
      /**
       * Calculate the complex acosh
       *
       * @returns {Complex}
       */
      acosh: function() {
        var f = this.acos();
        if (f.im <= 0) {
          var d = f.re;
          f.re = -f.im, f.im = d;
        } else {
          var d = f.im;
          f.im = -f.re, f.re = d;
        }
        return f;
      },
      /**
       * Calculate the complex atanh
       *
       * @returns {Complex}
       */
      atanh: function() {
        var f = this.re, d = this.im, m = f > 1 && d === 0, p = 1 - f, v = 1 + f, h = p * p + d * d, y = h !== 0 ? new l(
          (v * p - d * d) / h,
          (d * p + v * d) / h
        ) : new l(
          f !== -1 ? f / 0 : 0,
          d !== 0 ? d / 0 : 0
        ), C = y.re;
        return y.re = s(y.re, y.im) / 2, y.im = Math.atan2(y.im, C) / 2, m && (y.im = -y.im), y;
      },
      /**
       * Calculate the complex acoth
       *
       * @returns {Complex}
       */
      acoth: function() {
        var f = this.re, d = this.im;
        if (f === 0 && d === 0)
          return new l(0, Math.PI / 2);
        var m = f * f + d * d;
        return m !== 0 ? new l(
          f / m,
          -d / m
        ).atanh() : new l(
          f !== 0 ? f / 0 : 0,
          d !== 0 ? -d / 0 : 0
        ).atanh();
      },
      /**
       * Calculate the complex acsch
       *
       * @returns {Complex}
       */
      acsch: function() {
        var f = this.re, d = this.im;
        if (d === 0)
          return new l(
            f !== 0 ? Math.log(f + Math.sqrt(f * f + 1)) : 1 / 0,
            0
          );
        var m = f * f + d * d;
        return m !== 0 ? new l(
          f / m,
          -d / m
        ).asinh() : new l(
          f !== 0 ? f / 0 : 0,
          d !== 0 ? -d / 0 : 0
        ).asinh();
      },
      /**
       * Calculate the complex asech
       *
       * @returns {Complex}
       */
      asech: function() {
        var f = this.re, d = this.im;
        if (this.isZero())
          return l.INFINITY;
        var m = f * f + d * d;
        return m !== 0 ? new l(
          f / m,
          -d / m
        ).acosh() : new l(
          f !== 0 ? f / 0 : 0,
          d !== 0 ? -d / 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 f = this.re, d = this.im, m = f * f + d * d;
        return new l(f / m, -d / 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(f) {
        return f = Math.pow(10, f || 0), new l(
          Math.ceil(this.re * f) / f,
          Math.ceil(this.im * f) / f
        );
      },
      /**
       * Floors the actual complex number
       *
       * @returns {Complex}
       */
      floor: function(f) {
        return f = Math.pow(10, f || 0), new l(
          Math.floor(this.re * f) / f,
          Math.floor(this.im * f) / f
        );
      },
      /**
       * Ceils the actual complex number
       *
       * @returns {Complex}
       */
      round: function(f) {
        return f = Math.pow(10, f || 0), new l(
          Math.round(this.re * f) / f,
          Math.round(this.im * f) / f
        );
      },
      /**
       * Compares two complex numbers
       *
       * **Note:** new Complex(Infinity).equals(Infinity) === false
       *
       * @returns {boolean}
       */
      equals: function(f, d) {
        var m = new l(f, d);
        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 f = this.re, d = this.im, m = "";
        return this.isNaN() ? "NaN" : this.isInfinite() ? "Infinity" : (Math.abs(f) < l.EPSILON && (f = 0), Math.abs(d) < l.EPSILON && (d = 0), d === 0 ? m + f : (f !== 0 ? (m += f, m += " ", d < 0 ? (d = -d, m += "-") : m += "+", m += " ") : d < 0 && (d = -d, m += "-"), d !== 1 && (m += d), 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;
  })();
})(zK);
var gxe = zK.exports;
const Ha = /* @__PURE__ */ qg(gxe);
var yxe = "Complex", _xe = [], GK = /* @__PURE__ */ Ce(yxe, _xe, () => (Object.defineProperty(Ha, "name", {
  value: "Complex"
}), Ha.prototype.constructor = Ha, Ha.prototype.type = "Complex", Ha.prototype.isComplex = !0, Ha.prototype.toJSON = function() {
  return {
    mathjs: "Complex",
    re: this.re,
    im: this.im
  };
}, Ha.prototype.toPolar = function() {
  return {
    r: this.abs(),
    phi: this.arg()
  };
}, Ha.prototype.format = function(e) {
  var r = "", t = this.im, n = this.re, a = o0(this.re, e), i = o0(this.im, e), o = Or(e) ? e : e ? e.precision : null;
  if (o !== null) {
    var c = Math.pow(10, -o);
    Math.abs(n / t) < c && (n = 0), Math.abs(t / n) < c && (t = 0);
  }
  return t === 0 ? r = a : n === 0 ? t === 1 ? r = "i" : t === -1 ? r = "-i" : r = i + "i" : t < 0 ? t === -1 ? r = a + " - i" : r = a + " - " + i.substring(1) + "i" : t === 1 ? r = a + " + i" : r = a + " + " + i + "i", r;
}, Ha.fromPolar = function(e) {
  switch (arguments.length) {
    case 1: {
      var r = arguments[0];
      if (typeof r == "object")
        return Ha(r);
      throw new TypeError("Input has to be an object with r and phi keys.");
    }
    case 2: {
      var t = arguments[0], n = arguments[1];
      if (Or(t)) {
        if (ho(n) && n.hasBase("ANGLE") && (n = n.toNumber("rad")), Or(n))
          return new Ha({
            r: t,
            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");
  }
}, Ha.prototype.valueOf = Ha.prototype.toString, Ha.fromJSON = function(e) {
  return new Ha(e);
}, Ha.compare = function(e, r) {
  return e.re > r.re ? 1 : e.re < r.re ? -1 : e.im > r.im ? 1 : e.im < r.im ? -1 : 0;
}, Ha), {
  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 bxe = 2e3, sr = {
  s: 1,
  n: 0,
  d: 1
};
function Gl(e, r) {
  if (isNaN(e = parseInt(e, 10)))
    throw pb();
  return e * r;
}
function Tn(e, r) {
  if (r === 0)
    throw xD();
  var t = Object.create(yi.prototype);
  t.s = e < 0 ? -1 : 1, e = e < 0 ? -e : e;
  var n = ov(e, r);
  return t.n = e / n, t.d = r / n, t;
}
function _R(e) {
  for (var r = {}, t = e, n = 2, a = 4; a <= t; ) {
    for (; t % n === 0; )
      t /= n, r[n] = (r[n] || 0) + 1;
    a += 1 + 2 * n++;
  }
  return t !== e ? t > 1 && (r[t] = (r[t] || 0) + 1) : r[e] = (r[e] || 0) + 1, r;
}
var Go = function(e, r) {
  var t = 0, n = 1, a = 1, i = 0, o = 0, c = 0, s = 1, u = 1, l = 0, f = 1, d = 1, m = 1, p = 1e7, v;
  if (e != null) if (r !== void 0) {
    if (t = e, n = r, a = t * n, t % 1 !== 0 || n % 1 !== 0)
      throw xxe();
  } else
    switch (typeof e) {
      case "object": {
        if ("d" in e && "n" in e)
          t = e.n, n = e.d, "s" in e && (t *= e.s);
        else if (0 in e)
          t = e[0], 1 in e && (n = e[1]);
        else
          throw pb();
        a = t * n;
        break;
      }
      case "number": {
        if (e < 0 && (a = e, e = -e), e % 1 === 0)
          t = e;
        else if (e > 0) {
          for (e >= 1 && (u = Math.pow(10, Math.floor(1 + Math.log(e) / Math.LN10)), e /= u); f <= p && m <= p; )
            if (v = (l + d) / (f + m), e === v) {
              f + m <= p ? (t = l + d, n = f + m) : m > f ? (t = d, n = m) : (t = l, n = f);
              break;
            } else
              e > v ? (l += d, f += m) : (d += l, m += f), f > p ? (t = d, n = m) : (t = l, n = f);
          t *= u;
        } else (isNaN(e) || isNaN(r)) && (n = t = NaN);
        break;
      }
      case "string": {
        if (f = e.match(/\d+|./g), f === null)
          throw pb();
        if (f[l] === "-" ? (a = -1, l++) : f[l] === "+" && l++, f.length === l + 1 ? o = Gl(f[l++], a) : f[l + 1] === "." || f[l] === "." ? (f[l] !== "." && (i = Gl(f[l++], a)), l++, (l + 1 === f.length || f[l + 1] === "(" && f[l + 3] === ")" || f[l + 1] === "'" && f[l + 3] === "'") && (o = Gl(f[l], a), s = Math.pow(10, f[l].length), l++), (f[l] === "(" && f[l + 2] === ")" || f[l] === "'" && f[l + 2] === "'") && (c = Gl(f[l + 1], a), u = Math.pow(10, f[l + 1].length) - 1, l += 3)) : f[l + 1] === "/" || f[l + 1] === ":" ? (o = Gl(f[l], a), s = Gl(f[l + 2], 1), l += 3) : f[l + 3] === "/" && f[l + 1] === " " && (i = Gl(f[l], a), o = Gl(f[l + 2], a), s = Gl(f[l + 4], 1), l += 5), f.length <= l) {
          n = s * u, a = /* void */
          t = c + n * i + u * o;
          break;
        }
      }
      default:
        throw pb();
    }
  if (n === 0)
    throw xD();
  sr.s = a < 0 ? -1 : 1, sr.n = Math.abs(t), sr.d = Math.abs(n);
};
function Sxe(e, r, t) {
  for (var n = 1; r > 0; e = e * e % t, r >>= 1)
    r & 1 && (n = n * e % t);
  return n;
}
function Cxe(e, r) {
  for (; r % 2 === 0; r /= 2)
    ;
  for (; r % 5 === 0; r /= 5)
    ;
  if (r === 1)
    return 0;
  for (var t = 10 % r, n = 1; t !== 1; n++)
    if (t = t * 10 % r, n > bxe)
      return 0;
  return n;
}
function Axe(e, r, t) {
  for (var n = 1, a = Sxe(10, t, r), i = 0; i < 300; i++) {
    if (n === a)
      return i;
    n = n * 10 % r, a = a * 10 % r;
  }
  return 0;
}
function ov(e, r) {
  if (!e)
    return r;
  if (!r)
    return e;
  for (; ; ) {
    if (e %= r, !e)
      return r;
    if (r %= e, !r)
      return e;
  }
}
function yi(e, r) {
  if (Go(e, r), this instanceof yi)
    e = ov(sr.d, sr.n), this.s = sr.s, this.n = sr.n / e, this.d = sr.d / e;
  else
    return Tn(sr.s * sr.n, sr.d);
}
var xD = function() {
  return new Error("Division by Zero");
}, pb = function() {
  return new Error("Invalid argument");
}, xxe = function() {
  return new Error("Parameters must be integer");
};
yi.prototype = {
  s: 1,
  n: 0,
  d: 1,
  /**
   * Calculates the absolute value
   *
   * Ex: new Fraction(-4).abs() => 4
   **/
  abs: function() {
    return Tn(this.n, this.d);
  },
  /**
   * Inverts the sign of the current fraction
   *
   * Ex: new Fraction(-4).neg() => 4
   **/
  neg: function() {
    return Tn(-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, r) {
    return Go(e, r), Tn(
      this.s * this.n * sr.d + sr.s * this.d * sr.n,
      this.d * sr.d
    );
  },
  /**
   * Subtracts two rational numbers
   *
   * Ex: new Fraction({n: 2, d: 3}).add("14.9") => -427 / 30
   **/
  sub: function(e, r) {
    return Go(e, r), Tn(
      this.s * this.n * sr.d - sr.s * this.d * sr.n,
      this.d * sr.d
    );
  },
  /**
   * Multiplies two rational numbers
   *
   * Ex: new Fraction("-17.(345)").mul(3) => 5776 / 111
   **/
  mul: function(e, r) {
    return Go(e, r), Tn(
      this.s * sr.s * this.n * sr.n,
      this.d * sr.d
    );
  },
  /**
   * Divides two rational numbers
   *
   * Ex: new Fraction("-17.(345)").inverse().div(3)
   **/
  div: function(e, r) {
    return Go(e, r), Tn(
      this.s * sr.s * this.n * sr.d,
      this.d * sr.n
    );
  },
  /**
   * Clones the actual object
   *
   * Ex: new Fraction("-17.(345)").clone()
   **/
  clone: function() {
    return Tn(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, r) {
    if (isNaN(this.n) || isNaN(this.d))
      return new yi(NaN);
    if (e === void 0)
      return Tn(this.s * this.n % this.d, 1);
    if (Go(e, r), sr.n === 0 && this.d === 0)
      throw xD();
    return Tn(
      this.s * (sr.d * this.n) % (sr.n * this.d),
      sr.d * this.d
    );
  },
  /**
   * Calculates the fractional gcd of two rational numbers
   *
   * Ex: new Fraction(5,8).gcd(3,7) => 1/56
   */
  gcd: function(e, r) {
    return Go(e, r), Tn(ov(sr.n, this.n) * ov(sr.d, this.d), sr.d * this.d);
  },
  /**
   * Calculates the fractional lcm of two rational numbers
   *
   * Ex: new Fraction(5,8).lcm(3,7) => 15
   */
  lcm: function(e, r) {
    return Go(e, r), sr.n === 0 && this.n === 0 ? Tn(0, 1) : Tn(sr.n * this.n, ov(sr.n, this.n) * ov(sr.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 yi(NaN) : Tn(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 yi(NaN) : Tn(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 yi(NaN) : Tn(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, r) {
    return Go(e, r), Tn(this.s * Math.round(this.n * sr.d / (this.d * sr.n)) * sr.n, sr.d);
  },
  /**
   * Gets the inverse of the fraction, means numerator and denominator are exchanged
   *
   * Ex: new Fraction([-3, 4]).inverse() => -4 / 3
   **/
  inverse: function() {
    return Tn(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, r) {
    if (Go(e, r), sr.d === 1)
      return sr.s < 0 ? Tn(Math.pow(this.s * this.d, sr.n), Math.pow(this.n, sr.n)) : Tn(Math.pow(this.s * this.n, sr.n), Math.pow(this.d, sr.n));
    if (this.s < 0) return null;
    var t = _R(this.n), n = _R(this.d), a = 1, i = 1;
    for (var o in t)
      if (o !== "1") {
        if (o === "0") {
          a = 0;
          break;
        }
        if (t[o] *= sr.n, t[o] % sr.d === 0)
          t[o] /= sr.d;
        else return null;
        a *= Math.pow(o, t[o]);
      }
    for (var o in n)
      if (o !== "1") {
        if (n[o] *= sr.n, n[o] % sr.d === 0)
          n[o] /= sr.d;
        else return null;
        i *= Math.pow(o, n[o]);
      }
    return sr.s < 0 ? Tn(i, a) : Tn(a, i);
  },
  /**
   * Check if two rational numbers are the same
   *
   * Ex: new Fraction(19.6).equals([98, 5]);
   **/
  equals: function(e, r) {
    return Go(e, r), this.s * this.n * sr.d === sr.s * sr.n * this.d;
  },
  /**
   * Check if two rational numbers are the same
   *
   * Ex: new Fraction(19.6).equals([98, 5]);
   **/
  compare: function(e, r) {
    Go(e, r);
    var t = this.s * this.n * sr.d - sr.s * sr.n * this.d;
    return (0 < t) - (t < 0);
  },
  simplify: function(e) {
    if (isNaN(this.n) || isNaN(this.d))
      return this;
    e = e || 1e-3;
    for (var r = this.abs(), t = r.toContinued(), n = 1; n < t.length; n++) {
      for (var a = Tn(t[n - 1], 1), i = n - 2; i >= 0; i--)
        a = a.inverse().add(t[i]);
      if (Math.abs(a.sub(r).valueOf()) < e)
        return a.mul(this.s);
    }
    return this;
  },
  /**
   * Check if two rational numbers are divisible
   *
   * Ex: new Fraction(19.6).divisible(1.5);
   */
  divisible: function(e, r) {
    return Go(e, r), !(!(sr.n * this.d) || this.n * sr.d % (sr.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 r, t = "", n = this.n, a = this.d;
    return this.s < 0 && (t += "-"), a === 1 ? t += n : (e && (r = Math.floor(n / a)) > 0 && (t += r, t += " ", n %= a), t += n, t += "/", t += a), t;
  },
  /**
   * Returns a latex representation of a Fraction object
   *
   * Ex: new Fraction("1.'3'").toLatex() => "\frac{4}{3}"
   **/
  toLatex: function(e) {
    var r, t = "", n = this.n, a = this.d;
    return this.s < 0 && (t += "-"), a === 1 ? t += n : (e && (r = Math.floor(n / a)) > 0 && (t += r, n %= a), t += "\\frac{", t += n, t += "}{", t += a, t += "}"), t;
  },
  /**
   * Returns an array of continued fraction elements
   *
   * Ex: new Fraction("7/8").toContinued() => [0,1,7]
   */
  toContinued: function() {
    var e, r = this.n, t = this.d, n = [];
    if (isNaN(r) || isNaN(t))
      return n;
    do
      n.push(Math.floor(r / t)), e = r % t, r = t, t = e;
    while (r !== 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 r = this.n, t = this.d;
    if (isNaN(r) || isNaN(t))
      return "NaN";
    e = e || 15;
    var n = Cxe(r, t), a = Axe(r, t, n), i = this.s < 0 ? "-" : "";
    if (i += r / t | 0, r %= t, r *= 10, r && (i += "."), n) {
      for (var o = a; o--; )
        i += r / t | 0, r %= t, r *= 10;
      i += "(";
      for (var o = n; o--; )
        i += r / t | 0, r %= t, r *= 10;
      i += ")";
    } else
      for (var o = e; r && o--; )
        i += r / t | 0, r %= t, r *= 10;
    return i;
  }
};
var Txe = "Fraction", Pxe = [], qK = /* @__PURE__ */ Ce(Txe, Pxe, () => (Object.defineProperty(yi, "name", {
  value: "Fraction"
}), yi.prototype.constructor = yi, yi.prototype.type = "Fraction", yi.prototype.isFraction = !0, yi.prototype.toJSON = function() {
  return {
    mathjs: "Fraction",
    n: this.s * this.n,
    d: this.d
  };
}, yi.fromJSON = function(e) {
  return new yi(e);
}, yi), {
  isClass: !0
}), Mxe = "Range", wxe = [], Exe = /* @__PURE__ */ Ce(Mxe, wxe, () => {
  function e(r, t, n) {
    if (!(this instanceof e))
      throw new SyntaxError("Constructor must be called with the new operator");
    var a = r != null, i = t != null, o = n != null;
    if (a) {
      if (Ir(r))
        r = r.toNumber();
      else if (typeof r != "number")
        throw new TypeError("Parameter start must be a number");
    }
    if (i) {
      if (Ir(t))
        t = t.toNumber();
      else if (typeof t != "number")
        throw new TypeError("Parameter end must be a number");
    }
    if (o) {
      if (Ir(n))
        n = n.toNumber();
      else if (typeof n != "number")
        throw new TypeError("Parameter step must be a number");
    }
    this.start = a ? parseFloat(r) : 0, this.end = i ? parseFloat(t) : 0, this.step = o ? parseFloat(n) : 1;
  }
  return e.prototype.type = "Range", e.prototype.isRange = !0, e.parse = function(r) {
    if (typeof r != "string")
      return null;
    var t = r.split(":"), n = t.map(function(i) {
      return parseFloat(i);
    }), a = n.some(function(i) {
      return isNaN(i);
    });
    if (a)
      return null;
    switch (n.length) {
      case 2:
        return new e(n[0], n[1]);
      case 3:
        return new e(n[0], n[2], n[1]);
      default:
        return null;
    }
  }, e.prototype.clone = function() {
    return new e(this.start, this.end, this.step);
  }, e.prototype.size = function() {
    var r = 0, t = this.start, n = this.step, a = this.end, i = a - t;
    return fd(n) === fd(i) ? r = Math.ceil(i / n) : i === 0 && (r = 0), isNaN(r) && (r = 0), [r];
  }, e.prototype.min = function() {
    var r = this.size()[0];
    if (r > 0)
      return this.step > 0 ? this.start : this.start + (r - 1) * this.step;
  }, e.prototype.max = function() {
    var r = this.size()[0];
    if (r > 0)
      return this.step > 0 ? this.start + (r - 1) * this.step : this.start;
  }, e.prototype.forEach = function(r) {
    var t = this.start, n = this.step, a = this.end, i = 0;
    if (n > 0)
      for (; t < a; )
        r(t, [i], this), t += n, i++;
    else if (n < 0)
      for (; t > a; )
        r(t, [i], this), t += n, i++;
  }, e.prototype.map = function(r) {
    var t = [];
    return this.forEach(function(n, a, i) {
      t[a[0]] = r(n, a, i);
    }), t;
  }, e.prototype.toArray = function() {
    var r = [];
    return this.forEach(function(t, n) {
      r[n[0]] = t;
    }), r;
  }, e.prototype.valueOf = function() {
    return this.toArray();
  }, e.prototype.format = function(r) {
    var t = o0(this.start, r);
    return this.step !== 1 && (t += ":" + o0(this.step, r)), t += ":" + o0(this.end, r), t;
  }, e.prototype.toString = function() {
    return this.format();
  }, e.prototype.toJSON = function() {
    return {
      mathjs: "Range",
      start: this.start,
      end: this.end,
      step: this.step
    };
  }, e.fromJSON = function(r) {
    return new e(r.start, r.end, r.step);
  }, e;
}, {
  isClass: !0
}), Dxe = "Matrix", Ixe = [], HK = /* @__PURE__ */ Ce(Dxe, Ixe, () => {
  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(r, t) {
    throw new Error("Cannot invoke create on a Matrix interface");
  }, e.prototype.subset = function(r, t, n) {
    throw new Error("Cannot invoke subset on a Matrix interface");
  }, e.prototype.get = function(r) {
    throw new Error("Cannot invoke get on a Matrix interface");
  }, e.prototype.set = function(r, t, n) {
    throw new Error("Cannot invoke set on a Matrix interface");
  }, e.prototype.resize = function(r, t) {
    throw new Error("Cannot invoke resize on a Matrix interface");
  }, e.prototype.reshape = function(r, t) {
    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(r, t) {
    throw new Error("Cannot invoke map on a Matrix interface");
  }, e.prototype.forEach = function(r) {
    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(r) {
    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 AP(e, r, t) {
  var n = e.constructor, a = new n(2), i = "";
  if (t) {
    if (t < 1)
      throw new Error("size must be in greater than 0");
    if (!lr(t))
      throw new Error("size must be an integer");
    if (e.greaterThan(a.pow(t - 1).sub(1)) || e.lessThan(a.pow(t - 1).mul(-1)))
      throw new Error("Value must be in range [-2^".concat(t - 1, ", 2^").concat(t - 1, "-1]"));
    if (!e.isInteger())
      throw new Error("Value must be an integer");
    e.lessThan(0) && (e = e.add(a.pow(t))), i = "i".concat(t);
  }
  switch (r) {
    case 2:
      return "".concat(e.toBinary()).concat(i);
    case 8:
      return "".concat(e.toOctal()).concat(i);
    case 16:
      return "".concat(e.toHexadecimal()).concat(i);
    default:
      throw new Error("Base ".concat(r, " not supported "));
  }
}
function Bxe(e, r) {
  if (typeof r == "function")
    return r(e);
  if (!e.isFinite())
    return e.isNaN() ? "NaN" : e.gt(0) ? "Infinity" : "-Infinity";
  var {
    notation: t,
    precision: n,
    wordSize: a
  } = yK(r);
  switch (t) {
    case "fixed":
      return Vxe(e, n);
    case "exponential":
      return bR(e, n);
    case "engineering":
      return Nxe(e, n);
    case "bin":
      return AP(e, 2, a);
    case "oct":
      return AP(e, 8, a);
    case "hex":
      return AP(e, 16, a);
    case "auto": {
      var i = SR(r == null ? void 0 : r.lowerExp, -3), o = SR(r == null ? void 0 : r.upperExp, 5);
      if (e.isZero()) return "0";
      var c, s = e.toSignificantDigits(n), u = s.e;
      return u >= i && u < o ? c = s.toFixed() : c = bR(e, n), c.replace(/((\.\d*?)(0+))($|e)/, function() {
        var l = arguments[2], f = arguments[4];
        return l !== "." ? l + f : f;
      });
    }
    default:
      throw new Error('Unknown notation "' + t + '". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.');
  }
}
function Nxe(e, r) {
  var t = e.e, n = t % 3 === 0 ? t : t < 0 ? t - 3 - t % 3 : t - t % 3, a = e.mul(Math.pow(10, -n)), i = a.toPrecision(r);
  if (i.includes("e")) {
    var o = e.constructor;
    i = new o(i).toFixed();
  }
  return i + "e" + (t >= 0 ? "+" : "") + n.toString();
}
function bR(e, r) {
  return r !== void 0 ? e.toExponential(r - 1) : e.toExponential();
}
function Vxe(e, r) {
  return e.toFixed(r);
}
function SR(e, r) {
  return Or(e) ? e : Ir(e) ? e.toNumber() : r;
}
function Rxe(e, r) {
  var t = e.length - r.length, n = e.length;
  return e.substring(t, n) === r;
}
function $r(e, r) {
  var t = Oxe(e, r);
  return r && typeof r == "object" && "truncate" in r && t.length > r.truncate ? t.substring(0, r.truncate - 3) + "..." : t;
}
function Oxe(e, r) {
  if (typeof e == "number")
    return o0(e, r);
  if (Ir(e))
    return Bxe(e, r);
  if (Fxe(e))
    return !r || r.fraction !== "decimal" ? e.s * e.n + "/" + e.d : e.toString();
  if (Array.isArray(e))
    return jK(e, r);
  if (Ya(e))
    return uv(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(r);
    if (e && e.toString(r) !== {}.toString())
      return e.toString(r);
    var t = Object.keys(e).map((n) => uv(n) + ": " + $r(e[n], r));
    return "{" + t.join(", ") + "}";
  }
  return String(e);
}
function uv(e) {
  for (var r = String(e), t = "", n = 0; n < r.length; ) {
    var a = r.charAt(n);
    t += a in CR ? CR[a] : a, n++;
  }
  return '"' + t + '"';
}
var CR = {
  '"': '\\"',
  "\\": "\\\\",
  "\b": "\\b",
  "\f": "\\f",
  "\n": "\\n",
  "\r": "\\r",
  "	": "\\t"
};
function Pu(e) {
  var r = String(e);
  return r = r.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&#39;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), r;
}
function jK(e, r) {
  if (Array.isArray(e)) {
    for (var t = "[", n = e.length, a = 0; a < n; a++)
      a !== 0 && (t += ", "), t += jK(e[a], r);
    return t += "]", t;
  } else
    return $r(e, r);
}
function Fxe(e) {
  return e && typeof e == "object" && typeof e.s == "number" && typeof e.n == "number" && typeof e.d == "number" || !1;
}
function Aw(e, r) {
  if (!Ya(e))
    throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: " + Et(e) + ", index: 0)");
  if (!Ya(r))
    throw new TypeError("Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: " + Et(r) + ", index: 1)");
  return e === r ? 0 : e > r ? 1 : -1;
}
function kr(e, r, t) {
  if (!(this instanceof kr))
    throw new SyntaxError("Constructor must be called with the new operator");
  this.actual = e, this.expected = r, this.relation = t, this.message = "Dimension mismatch (" + (Array.isArray(e) ? "[" + e.join(", ") + "]" : e) + " " + (this.relation || "!=") + " " + (Array.isArray(r) ? "[" + r.join(", ") + "]" : r) + ")", this.stack = new Error().stack;
}
kr.prototype = new RangeError();
kr.prototype.constructor = RangeError;
kr.prototype.name = "DimensionError";
kr.prototype.isDimensionError = !0;
function Ru(e, r, t) {
  if (!(this instanceof Ru))
    throw new SyntaxError("Constructor must be called with the new operator");
  this.index = e, arguments.length < 3 ? (this.min = 0, this.max = r) : (this.min = r, this.max = t), 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;
}
Ru.prototype = new RangeError();
Ru.prototype.constructor = RangeError;
Ru.prototype.name = "IndexError";
Ru.prototype.isIndexError = !0;
function Fr(e) {
  for (var r = []; Array.isArray(e); )
    r.push(e.length), e = e[0];
  return r;
}
function $K(e, r, t) {
  var n, a = e.length;
  if (a !== r[t])
    throw new kr(a, r[t]);
  if (t < r.length - 1) {
    var i = t + 1;
    for (n = 0; n < a; n++) {
      var o = e[n];
      if (!Array.isArray(o))
        throw new kr(r.length - 1, r.length, "<");
      $K(e[n], r, i);
    }
  } else
    for (n = 0; n < a; n++)
      if (Array.isArray(e[n]))
        throw new kr(r.length + 1, r.length, ">");
}
function AR(e, r) {
  var t = r.length === 0;
  if (t) {
    if (Array.isArray(e))
      throw new kr(e.length, 0);
  } else
    $K(e, r, 0);
}
function y3(e, r) {
  var t = e.isMatrix ? e._size : Fr(e), n = r._sourceSize;
  n.forEach((a, i) => {
    if (a !== null && a !== t[i])
      throw new kr(a, t[i]);
  });
}
function Pt(e, r) {
  if (e !== void 0) {
    if (!Or(e) || !lr(e))
      throw new TypeError("Index must be an integer (value: " + e + ")");
    if (e < 0 || typeof r == "number" && e >= r)
      throw new Ru(e, r);
  }
}
function dp(e) {
  for (var r = 0; r < e._dimensions.length; ++r) {
    var t = e._dimensions[r];
    if (t._data && dt(t._data)) {
      if (t._size[0] === 0)
        return !0;
    } else if (t.isRange) {
      if (t.start === t.end)
        return !0;
    } else if (Ya(t) && t.length === 0)
      return !0;
  }
  return !1;
}
function fp(e, r, t) {
  if (!Array.isArray(r))
    throw new TypeError("Array expected");
  if (r.length === 0)
    throw new Error("Resizing to scalar is not supported");
  r.forEach(function(a) {
    if (!Or(a) || !lr(a) || a < 0)
      throw new TypeError("Invalid size, must contain positive integers (size: " + $r(r) + ")");
  }), (Or(e) || Ir(e)) && (e = [e]);
  var n = t !== void 0 ? t : 0;
  return xw(e, r, 0, n), e;
}
function xw(e, r, t, n) {
  var a, i, o = e.length, c = r[t], s = Math.min(o, c);
  if (e.length = c, t < r.length - 1) {
    var u = t + 1;
    for (a = 0; a < s; a++)
      i = e[a], Array.isArray(i) || (i = [i], e[a] = i), xw(i, r, u, n);
    for (a = s; a < c; a++)
      i = [], e[a] = i, xw(i, r, u, n);
  } else {
    for (a = 0; a < s; a++)
      for (; Array.isArray(e[a]); )
        e[a] = e[a][0];
    for (a = s; a < c; a++)
      e[a] = n;
  }
}
function TD(e, r) {
  var t = st(e), n = t.length;
  if (!Array.isArray(e) || !Array.isArray(r))
    throw new TypeError("Array expected");
  if (r.length === 0)
    throw new kr(0, n, "!=");
  r = PD(r, n);
  var a = KK(r);
  if (n !== a)
    throw new kr(a, n, "!=");
  try {
    return Lxe(t, r);
  } catch (i) {
    throw i instanceof kr ? new kr(a, n, "!=") : i;
  }
}
function PD(e, r) {
  var t = KK(e), n = e.slice(), a = -1, i = e.indexOf(a), o = e.indexOf(a, i + 1) >= 0;
  if (o)
    throw new Error("More than one wildcard in sizes");
  var c = i >= 0, s = r % t === 0;
  if (c)
    if (s)
      n[i] = -r / t;
    else
      throw new Error("Could not replace wildcard, since " + r + " is no multiple of " + -t);
  return n;
}
function KK(e) {
  return e.reduce((r, t) => r * t, 1);
}
function Lxe(e, r) {
  for (var t = e, n, a = r.length - 1; a > 0; a--) {
    var i = r[a];
    n = [];
    for (var o = t.length / i, c = 0; c < o; c++)
      n.push(t.slice(c * i, (c + 1) * i));
    t = n;
  }
  return t;
}
function _3(e, r) {
  for (var t = Fr(e); Array.isArray(e) && e.length === 1; )
    e = e[0], t.shift();
  for (var n = t.length; t[n - 1] === 1; )
    n--;
  return n < t.length && (e = WK(e, n, 0), t.length = n), e;
}
function WK(e, r, t) {
  var n, a;
  if (t < r) {
    var i = t + 1;
    for (n = 0, a = e.length; n < a; n++)
      e[n] = WK(e[n], r, i);
  } else
    for (; Array.isArray(e); )
      e = e[0];
  return e;
}
function XK(e, r, t, n) {
  var a = n || Fr(e);
  if (t)
    for (var i = 0; i < t; i++)
      e = [e], a.unshift(1);
  for (e = YK(e, r, 0); a.length < r; )
    a.push(1);
  return e;
}
function YK(e, r, t) {
  var n, a;
  if (Array.isArray(e)) {
    var i = t + 1;
    for (n = 0, a = e.length; n < a; n++)
      e[n] = YK(e[n], r, i);
  } else
    for (var o = t; o < r; o++)
      e = [e];
  return e;
}
function st(e) {
  if (!Array.isArray(e))
    return e;
  var r = [];
  return e.forEach(function t(n) {
    Array.isArray(n) ? n.forEach(t) : r.push(n);
  }), r;
}
function lc(e, r) {
  return Array.prototype.map.call(e, r);
}
function ux(e, r) {
  Array.prototype.forEach.call(e, r);
}
function QK(e, r) {
  if (Fr(e).length !== 1)
    throw new Error("Only one dimensional matrices supported");
  return Array.prototype.filter.call(e, r);
}
function b3(e, r) {
  if (Fr(e).length !== 1)
    throw new Error("Only one dimensional matrices supported");
  return Array.prototype.filter.call(e, (t) => r.test(t));
}
function xR(e, r) {
  return Array.prototype.join.call(e, r);
}
function mp(e) {
  if (!Array.isArray(e))
    throw new TypeError("Array input expected");
  if (e.length === 0)
    return e;
  var r = [], t = 0;
  r[0] = {
    value: e[0],
    identifier: 0
  };
  for (var n = 1; n < e.length; n++)
    e[n] === e[n - 1] ? t++ : t = 0, r.push({
      value: e[n],
      identifier: t
    });
  return r;
}
function S3(e) {
  if (!Array.isArray(e))
    throw new TypeError("Array input expected");
  if (e.length === 0)
    return e;
  for (var r = [], t = 0; t < e.length; t++)
    r.push(e[t].value);
  return r;
}
function Ug(e, r) {
  for (var t, n = 0, a = 0; a < e.length; a++) {
    var i = e[a], o = Array.isArray(i);
    if (a === 0 && o && (n = i.length), o && i.length !== n)
      return;
    var c = o ? Ug(i, r) : r(i);
    if (t === void 0)
      t = c;
    else if (t !== c)
      return "mixed";
  }
  return t;
}
function ZK(e, r, t, n) {
  if (n < t) {
    if (e.length !== r.length)
      throw new kr(e.length, r.length);
    for (var a = [], i = 0; i < e.length; i++)
      a[i] = ZK(e[i], r[i], t, n + 1);
    return a;
  } else
    return e.concat(r);
}
function JK() {
  var e = Array.prototype.slice.call(arguments, 0, -1), r = Array.prototype.slice.call(arguments, -1);
  if (e.length === 1)
    return e[0];
  if (e.length > 1)
    return e.slice(1).reduce(function(t, n) {
      return ZK(t, n, r, 0);
    }, e[0]);
  throw new Error("Wrong number of arguments in function concat");
}
function eW() {
  for (var e = arguments.length, r = new Array(e), t = 0; t < e; t++)
    r[t] = arguments[t];
  for (var n = r.map((d) => d.length), a = Math.max(...n), i = new Array(a).fill(null), o = 0; o < r.length; o++)
    for (var c = r[o], s = n[o], u = 0; u < s; u++) {
      var l = a - s + u;
      c[u] > i[l] && (i[l] = c[u]);
    }
  for (var f = 0; f < r.length; f++)
    rW(r[f], i);
  return i;
}
function rW(e, r) {
  for (var t = r.length, n = e.length, a = 0; a < n; a++) {
    var i = t - n + a;
    if (e[a] < r[i] && e[a] > 1 || e[a] > r[i])
      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[a], " to size ").concat(r[i]));
  }
}
function Tw(e, r) {
  var t = Fr(e);
  if (gc(t, r))
    return e;
  rW(t, r);
  var n = eW(t, r), a = n.length, i = [...Array(a - t.length).fill(1), ...t], o = Uxe(e);
  t.length < a && (o = TD(o, i), t = Fr(o));
  for (var c = 0; c < a; c++)
    t[c] < n[c] && (o = kxe(o, n[c], c), t = Fr(o));
  return o;
}
function kxe(e, r, t) {
  return JK(...Array(r).fill(e), t);
}
function Uxe(e) {
  return Xa([], e);
}
function zxe(e) {
  var r = 0, t = 1, n = /* @__PURE__ */ Object.create(null), a = /* @__PURE__ */ Object.create(null), i = 0, o = function(s) {
    var u = a[s];
    if (u && (delete n[u], delete a[s], --r, t === u)) {
      if (!r) {
        i = 0, t = 1;
        return;
      }
      for (; !Object.prototype.hasOwnProperty.call(n, ++t); )
        ;
    }
  };
  return e = Math.abs(e), {
    hit: function(s) {
      var u = a[s], l = ++i;
      if (n[l] = s, a[s] = l, !u)
        return ++r, r <= e ? void 0 : (s = n[t], o(s), s);
      if (delete n[u], t === u)
        for (; !Object.prototype.hasOwnProperty.call(n, ++t); )
          ;
    },
    delete: o,
    clear: function() {
      r = i = 0, t = 1, n = /* @__PURE__ */ Object.create(null), a = /* @__PURE__ */ Object.create(null);
    }
  };
}
function jy(e) {
  var {
    hasher: r,
    limit: t
  } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
  return t = t ?? Number.POSITIVE_INFINITY, r = r ?? JSON.stringify, function n() {
    typeof n.cache != "object" && (n.cache = {
      values: /* @__PURE__ */ new Map(),
      lru: zxe(t || Number.POSITIVE_INFINITY)
    });
    for (var a = [], i = 0; i < arguments.length; i++)
      a[i] = arguments[i];
    var o = r(a);
    if (n.cache.values.has(o))
      return n.cache.lru.hit(o), n.cache.values.get(o);
    var c = e.apply(e, a);
    return n.cache.values.set(o, c), n.cache.values.delete(n.cache.lru.hit(o)), c;
  };
}
function tW(e) {
  return Object.keys(e.signatures || {}).reduce(function(r, t) {
    var n = (t.match(/,/g) || []).length + 1;
    return Math.max(r, n);
  }, -1);
}
var Gxe = "DenseMatrix", qxe = ["Matrix"], nW = /* @__PURE__ */ Ce(Gxe, qxe, (e) => {
  var {
    Matrix: r
  } = e;
  function t(l, f) {
    if (!(this instanceof t))
      throw new SyntaxError("Constructor must be called with the new operator");
    if (f && !Ya(f))
      throw new Error("Invalid datatype: " + f);
    if (gr(l))
      l.type === "DenseMatrix" ? (this._data = Sr(l._data), this._size = Sr(l._size), this._datatype = f || l._datatype) : (this._data = l.toArray(), this._size = l.size(), this._datatype = f || l._datatype);
    else if (l && dt(l.data) && dt(l.size))
      this._data = l.data, this._size = l.size, AR(this._data, this._size), this._datatype = f || l.datatype;
    else if (dt(l))
      this._data = u(l), this._size = Fr(this._data), AR(this._data, this._size), this._datatype = f;
    else {
      if (l)
        throw new TypeError("Unsupported type of data (" + Et(l) + ")");
      this._data = [], this._size = [0], this._datatype = f;
    }
  }
  t.prototype = new r(), t.prototype.createDenseMatrix = function(l, f) {
    return new t(l, f);
  }, Object.defineProperty(t, "name", {
    value: "DenseMatrix"
  }), t.prototype.constructor = t, t.prototype.type = "DenseMatrix", t.prototype.isDenseMatrix = !0, t.prototype.getDataType = function() {
    return Ug(this._data, Et);
  }, t.prototype.storage = function() {
    return "dense";
  }, t.prototype.datatype = function() {
    return this._datatype;
  }, t.prototype.create = function(l, f) {
    return new t(l, f);
  }, t.prototype.subset = function(l, f, d) {
    switch (arguments.length) {
      case 1:
        return n(this, l);
      case 2:
      case 3:
        return i(this, l, f, d);
      default:
        throw new SyntaxError("Wrong number of arguments");
    }
  }, t.prototype.get = function(l) {
    if (!dt(l))
      throw new TypeError("Array expected");
    if (l.length !== this._size.length)
      throw new kr(l.length, this._size.length);
    for (var f = 0; f < l.length; f++)
      Pt(l[f], this._size[f]);
    for (var d = this._data, m = 0, p = l.length; m < p; m++) {
      var v = l[m];
      Pt(v, d.length), d = d[v];
    }
    return d;
  }, t.prototype.set = function(l, f, d) {
    if (!dt(l))
      throw new TypeError("Array expected");
    if (l.length < this._size.length)
      throw new kr(l.length, this._size.length, "<");
    var m, p, v, h = l.map(function(C) {
      return C + 1;
    });
    s(this, h, d);
    var y = this._data;
    for (m = 0, p = l.length - 1; m < p; m++)
      v = l[m], Pt(v, y.length), y = y[v];
    return v = l[l.length - 1], Pt(v, y.length), y[v] = f, this;
  };
  function n(l, f) {
    if (!zy(f))
      throw new TypeError("Invalid index");
    var d = f.isScalar();
    if (d)
      return l.get(f.min());
    var m = f.size();
    if (m.length !== l._size.length)
      throw new kr(m.length, l._size.length);
    for (var p = f.min(), v = f.max(), h = 0, y = l._size.length; h < y; h++)
      Pt(p[h], l._size[h]), Pt(v[h], l._size[h]);
    return new t(a(l._data, f, m.length, 0), l._datatype);
  }
  function a(l, f, d, m) {
    var p = m === d - 1, v = f.dimension(m);
    return p ? v.map(function(h) {
      return Pt(h, l.length), l[h];
    }).valueOf() : v.map(function(h) {
      Pt(h, l.length);
      var y = l[h];
      return a(y, f, d, m + 1);
    }).valueOf();
  }
  function i(l, f, d, m) {
    if (!f || f.isIndex !== !0)
      throw new TypeError("Invalid index");
    var p = f.size(), v = f.isScalar(), h;
    if (gr(d) ? (h = d.size(), d = d.valueOf()) : h = Fr(d), v) {
      if (h.length !== 0)
        throw new TypeError("Scalar expected");
      l.set(f.min(), d, m);
    } else {
      if (!gc(h, p))
        try {
          h.length === 0 ? d = Tw([d], p) : d = Tw(d, p), h = Fr(d);
        } catch {
        }
      if (p.length < l._size.length)
        throw new kr(p.length, l._size.length, "<");
      if (h.length < p.length) {
        for (var y = 0, C = 0; p[y] === 1 && h[y] === 1; )
          y++;
        for (; p[y] === 1; )
          C++, y++;
        d = XK(d, p.length, C, h);
      }
      if (!gc(p, h))
        throw new kr(p, h, ">");
      var S = f.max().map(function(_) {
        return _ + 1;
      });
      s(l, S, m);
      var b = p.length, g = 0;
      o(l._data, f, d, b, g);
    }
    return l;
  }
  function o(l, f, d, m, p) {
    var v = p === m - 1, h = f.dimension(p);
    v ? h.forEach(function(y, C) {
      Pt(y), l[y] = d[C[0]];
    }) : h.forEach(function(y, C) {
      Pt(y), o(l[y], f, d[C[0]], m, p + 1);
    });
  }
  t.prototype.resize = function(l, f, d) {
    if (!Xo(l))
      throw new TypeError("Array or Matrix expected");
    var m = l.valueOf().map((v) => Array.isArray(v) && v.length === 1 ? v[0] : v), p = d ? this.clone() : this;
    return c(p, m, f);
  };
  function c(l, f, d) {
    if (f.length === 0) {
      for (var m = l._data; dt(m); )
        m = m[0];
      return m;
    }
    return l._size = f.slice(0), l._data = fp(l._data, l._size, d), l;
  }
  t.prototype.reshape = function(l, f) {
    var d = f ? this.clone() : this;
    d._data = TD(d._data, l);
    var m = d._size.reduce((p, v) => p * v);
    return d._size = PD(l, m), d;
  };
  function s(l, f, d) {
    for (var m = l._size.slice(0), p = !1; m.length < f.length; )
      m.push(0), p = !0;
    for (var v = 0, h = f.length; v < h; v++)
      f[v] > m[v] && (m[v] = f[v], p = !0);
    p && c(l, m, d);
  }
  t.prototype.clone = function() {
    var l = new t({
      data: Sr(this._data),
      size: Sr(this._size),
      datatype: this._datatype
    });
    return l;
  }, t.prototype.size = function() {
    return this._size.slice(0);
  }, t.prototype.map = function(l) {
    var f = this, d = tW(l), m = function h(y, C) {
      return dt(y) ? y.map(function(S, b) {
        return h(S, C.concat(b));
      }) : d === 1 ? l(y) : d === 2 ? l(y, C) : l(y, C, f);
    }, p = m(this._data, []), v = this._datatype !== void 0 ? Ug(p, Et) : void 0;
    return new t(p, v);
  }, t.prototype.forEach = function(l) {
    var f = this, d = function m(p, v) {
      dt(p) ? p.forEach(function(h, y) {
        m(h, v.concat(y));
      }) : l(p, v, f);
    };
    d(this._data, []);
  }, t.prototype[Symbol.iterator] = function* () {
    var l = function* f(d, m) {
      if (dt(d))
        for (var p = 0; p < d.length; p++)
          yield* f(d[p], m.concat(p));
      else
        yield {
          value: d,
          index: m
        };
    };
    yield* l(this._data, []);
  }, t.prototype.rows = function() {
    var l = [], f = this.size();
    if (f.length !== 2)
      throw new TypeError("Rows can only be returned for a 2D matrix.");
    var d = this._data;
    for (var m of d)
      l.push(new t([m], this._datatype));
    return l;
  }, t.prototype.columns = function() {
    var l = this, f = [], d = this.size();
    if (d.length !== 2)
      throw new TypeError("Rows can only be returned for a 2D matrix.");
    for (var m = this._data, p = function(y) {
      var C = m.map((S) => [S[y]]);
      f.push(new t(C, l._datatype));
    }, v = 0; v < d[1]; v++)
      p(v);
    return f;
  }, t.prototype.toArray = function() {
    return Sr(this._data);
  }, t.prototype.valueOf = function() {
    return this._data;
  }, t.prototype.format = function(l) {
    return $r(this._data, l);
  }, t.prototype.toString = function() {
    return $r(this._data);
  }, t.prototype.toJSON = function() {
    return {
      mathjs: "DenseMatrix",
      data: this._data,
      size: this._size,
      datatype: this._datatype
    };
  }, t.prototype.diagonal = function(l) {
    if (l) {
      if (Ir(l) && (l = l.toNumber()), !Or(l) || !lr(l))
        throw new TypeError("The parameter k must be an integer number");
    } else
      l = 0;
    for (var f = l > 0 ? l : 0, d = l < 0 ? -l : 0, m = this._size[0], p = this._size[1], v = Math.min(m - d, p - f), h = [], y = 0; y < v; y++)
      h[y] = this._data[y + d][y + f];
    return new t({
      data: h,
      size: [v],
      datatype: this._datatype
    });
  }, t.diagonal = function(l, f, d, m) {
    if (!dt(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(A) {
      if (Ir(A) && (A = A.toNumber()), !Or(A) || !lr(A) || A < 1)
        throw new Error("Size values must be positive integers");
      return A;
    }), d) {
      if (Ir(d) && (d = d.toNumber()), !Or(d) || !lr(d))
        throw new TypeError("The parameter k must be an integer number");
    } else
      d = 0;
    var p = d > 0 ? d : 0, v = d < 0 ? -d : 0, h = l[0], y = l[1], C = Math.min(h - v, y - p), S;
    if (dt(f)) {
      if (f.length !== C)
        throw new Error("Invalid value array length");
      S = function(M) {
        return f[M];
      };
    } else if (gr(f)) {
      var b = f.size();
      if (b.length !== 1 || b[0] !== C)
        throw new Error("Invalid matrix length");
      S = function(M) {
        return f.get([M]);
      };
    } else
      S = function() {
        return f;
      };
    m || (m = Ir(S(0)) ? S(0).mul(0) : 0);
    var g = [];
    if (l.length > 0) {
      g = fp(g, l, m);
      for (var _ = 0; _ < C; _++)
        g[_ + v][_ + p] = S(_);
    }
    return new t({
      data: g,
      size: [h, y]
    });
  }, t.fromJSON = function(l) {
    return new t(l);
  }, t.prototype.swapRows = function(l, f) {
    if (!Or(l) || !lr(l) || !Or(f) || !lr(f))
      throw new Error("Row index must be positive integers");
    if (this._size.length !== 2)
      throw new Error("Only two dimensional matrix is supported");
    return Pt(l, this._size[0]), Pt(f, this._size[0]), t._swapRows(l, f, this._data), this;
  }, t._swapRows = function(l, f, d) {
    var m = d[l];
    d[l] = d[f], d[f] = m;
  };
  function u(l) {
    return gr(l) ? u(l.valueOf()) : dt(l) ? l.map(u) : l;
  }
  return t;
}, {
  isClass: !0
}), TR = "clone", Hxe = ["typed"], jxe = /* @__PURE__ */ Ce(TR, Hxe, (e) => {
  var {
    typed: r
  } = e;
  return r(TR, {
    any: Sr
  });
});
function aW(e) {
  var r = e.length, t = e[0].length, n, a, i = [];
  for (a = 0; a < t; a++) {
    var o = [];
    for (n = 0; n < r; n++)
      o.push(e[n][a]);
    i.push(o);
  }
  return i;
}
function Wp(e) {
  for (var r = 0; r < e.length; r++)
    if (Xo(e[r]))
      return !0;
  return !1;
}
function yc(e, r) {
  gr(e) && (e = e.valueOf());
  for (var t = 0, n = e.length; t < n; t++) {
    var a = e[t];
    Array.isArray(a) ? yc(a, r) : r(a);
  }
}
function zr(e, r, t) {
  return e && typeof e.map == "function" ? e.map(function(n) {
    return zr(n, r);
  }) : r(e);
}
function sx(e, r, t) {
  var n = Array.isArray(e) ? Fr(e) : e.size();
  if (r < 0 || r >= n.length)
    throw new Ru(r, n.length);
  return gr(e) ? e.create(C3(e.valueOf(), r, t)) : C3(e, r, t);
}
function C3(e, r, t) {
  var n, a, i, o;
  if (r <= 0)
    if (Array.isArray(e[0])) {
      for (o = aW(e), a = [], n = 0; n < o.length; n++)
        a[n] = C3(o[n], r - 1, t);
      return a;
    } else {
      for (i = e[0], n = 1; n < e.length; n++)
        i = t(i, e[n]);
      return i;
    }
  else {
    for (a = [], n = 0; n < e.length; n++)
      a[n] = C3(e[n], r - 1, t);
    return a;
  }
}
function PR(e, r, t, n, a, i, o, c, s, u, l) {
  var f = e._values, d = e._index, m = e._ptr, p, v, h, y;
  if (n)
    for (v = m[r], h = m[r + 1], p = v; p < h; p++)
      y = d[p], t[y] !== i ? (t[y] = i, o.push(y), n[y] = f[p]) : (n[y] = c(n[y], f[p]), a[y] = i);
  else
    for (v = m[r], h = m[r + 1], p = v; p < h; p++)
      y = d[p], t[y] !== i ? (t[y] = i, o.push(y)) : a[y] = i;
}
var MR = "isInteger", $xe = ["typed"], iW = /* @__PURE__ */ Ce(MR, $xe, (e) => {
  var {
    typed: r
  } = e;
  return r(MR, {
    number: lr,
    // 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": r.referToSelf((t) => (n) => zr(n, t))
  });
}), As = "number", Xp = "number, number";
function oW(e) {
  return Math.abs(e);
}
oW.signature = As;
function uW(e, r) {
  return e + r;
}
uW.signature = Xp;
function sW(e, r) {
  return e - r;
}
sW.signature = Xp;
function lW(e, r) {
  return e * r;
}
lW.signature = Xp;
function cW(e) {
  return -e;
}
cW.signature = As;
function dW(e) {
  return e;
}
dW.signature = As;
function z1(e) {
  return Z4e(e);
}
z1.signature = As;
function fW(e) {
  return e * e * e;
}
fW.signature = As;
function mW(e) {
  return Math.exp(e);
}
mW.signature = As;
function vW(e) {
  return J4e(e);
}
vW.signature = As;
function pW(e, r) {
  if (!lr(e) || !lr(r))
    throw new Error("Parameters in function lcm must be integer numbers");
  if (e === 0 || r === 0)
    return 0;
  for (var t, n = e * r; r !== 0; )
    t = r, r = e % t, e = t;
  return Math.abs(n / e);
}
pW.signature = Xp;
function Kxe(e, r) {
  return Math.log(e);
}
function hW(e) {
  return Y4e(e);
}
hW.signature = As;
function gW(e) {
  return X4e(e);
}
gW.signature = As;
function wR(e) {
  var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 2, t = r < 0;
  if (t && (r = -r), r === 0)
    throw new Error("Root must be non-zero");
  if (e < 0 && Math.abs(r) % 2 !== 1)
    throw new Error("Root must be odd when a is negative.");
  if (e === 0)
    return t ? 1 / 0 : 0;
  if (!isFinite(e))
    return t ? 0 : e;
  var n = Math.pow(Math.abs(e), 1 / r);
  return n = e < 0 ? -n : n, t ? 1 / n : n;
}
function Pw(e) {
  return fd(e);
}
Pw.signature = As;
function yW(e) {
  return e * e;
}
yW.signature = As;
function _W(e, r) {
  var t, n, a, i = 0, o = 1, c = 1, s = 0;
  if (!lr(e) || !lr(r))
    throw new Error("Parameters in function xgcd must be integer numbers");
  for (; r; )
    n = Math.floor(e / r), a = e - n * r, t = i, i = o - n * i, o = t, t = c, c = s - n * c, s = t, e = r, r = a;
  var u;
  return e < 0 ? u = [-e, -o, -s] : u = [e, e ? o : 0, s], u;
}
_W.signature = Xp;
function bW(e, r) {
  return e * e < 1 && r === 1 / 0 || e * e > 1 && r === -1 / 0 ? 0 : Math.pow(e, r);
}
bW.signature = Xp;
function N1(e) {
  var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
  if (!lr(r) || r < 0 || r > 15)
    throw new Error("Number of decimals in function round must be an integer from 0 to 15 inclusive");
  return parseFloat(_K(e, r));
}
var Wxe = "number", Yp = "number, number";
function SW(e, r) {
  if (!lr(e) || !lr(r))
    throw new Error("Integers expected in function bitAnd");
  return e & r;
}
SW.signature = Yp;
function CW(e) {
  if (!lr(e))
    throw new Error("Integer expected in function bitNot");
  return ~e;
}
CW.signature = Wxe;
function AW(e, r) {
  if (!lr(e) || !lr(r))
    throw new Error("Integers expected in function bitOr");
  return e | r;
}
AW.signature = Yp;
function xW(e, r) {
  if (!lr(e) || !lr(r))
    throw new Error("Integers expected in function bitXor");
  return e ^ r;
}
xW.signature = Yp;
function TW(e, r) {
  if (!lr(e) || !lr(r))
    throw new Error("Integers expected in function leftShift");
  return e << r;
}
TW.signature = Yp;
function PW(e, r) {
  if (!lr(e) || !lr(r))
    throw new Error("Integers expected in function rightArithShift");
  return e >> r;
}
PW.signature = Yp;
function MW(e, r) {
  if (!lr(e) || !lr(r))
    throw new Error("Integers expected in function rightLogShift");
  return e >>> r;
}
MW.signature = Yp;
function Zl(e, r) {
  if (r < e)
    return 1;
  if (r === e)
    return r;
  var t = r + e >> 1;
  return Zl(e, t) * Zl(t + 1, r);
}
function wW(e, r) {
  if (!lr(e) || e < 0)
    throw new TypeError("Positive integer value expected in function combinations");
  if (!lr(r) || r < 0)
    throw new TypeError("Positive integer value expected in function combinations");
  if (r > e)
    throw new TypeError("k must be less than or equal to n");
  for (var t = e - r, n = 1, a = r < t ? t + 1 : r + 1, i = 2, o = r < t ? r : t, c = a; c <= e; ++c)
    for (n *= c; i <= o && n % i === 0; )
      n /= i, ++i;
  return i <= o && (n /= Zl(i, o)), n;
}
wW.signature = "number, number";
var Xxe = Math.PI, Yxe = 2 * Math.PI, Qxe = Math.E, Zxe = 1.618033988749895, Jxe = "number", MD = "number, number";
function EW(e) {
  return !e;
}
EW.signature = Jxe;
function Mw(e, r) {
  return !!(e || r);
}
Mw.signature = MD;
function ww(e, r) {
  return !!e != !!r;
}
ww.signature = MD;
function Ew(e, r) {
  return !!(e && r);
}
Ew.signature = MD;
function A3(e) {
  var r;
  if (lr(e))
    return e <= 0 ? isFinite(e) ? 1 / 0 : NaN : e > 171 ? 1 / 0 : Zl(1, e - 1);
  if (e < 0.5)
    return Math.PI / (Math.sin(Math.PI * e) * A3(1 - e));
  if (e >= 171.35)
    return 1 / 0;
  if (e > 85) {
    var t = e * e, n = t * e, a = n * e, i = a * e;
    return Math.sqrt(2 * Math.PI / e) * Math.pow(e / Math.E, e) * (1 + 1 / (12 * e) + 1 / (288 * t) - 139 / (51840 * n) - 571 / (2488320 * a) + 163879 / (209018880 * i) + 5246819 / (75246796800 * i * e));
  }
  --e, r = Sv[0];
  for (var o = 1; o < Sv.length; ++o)
    r += Sv[o] / (e + o);
  var c = e + DW + 0.5;
  return Math.sqrt(2 * Math.PI) * Math.pow(c, e + 0.5) * Math.exp(-c) * r;
}
A3.signature = "number";
var DW = 4.7421875, Sv = [0.9999999999999971, 57.15623566586292, -59.59796035547549, 14.136097974741746, -0.4919138160976202, 3399464998481189e-20, 4652362892704858e-20, -9837447530487956e-20, 1580887032249125e-19, -21026444172410488e-20, 21743961811521265e-20, -1643181065367639e-19, 8441822398385275e-20, -26190838401581408e-21, 36899182659531625e-22], IW = 0.9189385332046728, e5e = 5, r5e = 7, ER = [1.000000000190015, 76.18009172947146, -86.50532032941678, 24.01409824083091, -1.231739572450155, 0.001208650973866179, -5395239384953e-18];
function x3(e) {
  if (e < 0) return NaN;
  if (e === 0) return 1 / 0;
  if (!isFinite(e)) return e;
  if (e < 0.5)
    return Math.log(Math.PI / Math.sin(Math.PI * e)) - x3(1 - e);
  e = e - 1;
  for (var r = e + e5e + 0.5, t = ER[0], n = r5e - 1; n >= 1; n--)
    t += ER[n] / (e + n);
  return IW + (e + 0.5) * Math.log(r) - r + Math.log(t);
}
x3.signature = "number";
var Ei = "number";
function BW(e) {
  return nAe(e);
}
BW.signature = Ei;
function NW(e) {
  return Math.atan(1 / e);
}
NW.signature = Ei;
function VW(e) {
  return isFinite(e) ? (Math.log((e + 1) / e) + Math.log(e / (e - 1))) / 2 : 0;
}
VW.signature = Ei;
function RW(e) {
  return Math.asin(1 / e);
}
RW.signature = Ei;
function OW(e) {
  var r = 1 / e;
  return Math.log(r + Math.sqrt(r * r + 1));
}
OW.signature = Ei;
function FW(e) {
  return Math.acos(1 / e);
}
FW.signature = Ei;
function LW(e) {
  var r = 1 / e, t = Math.sqrt(r * r - 1);
  return Math.log(t + r);
}
LW.signature = Ei;
function kW(e) {
  return aAe(e);
}
kW.signature = Ei;
function UW(e) {
  return iAe(e);
}
UW.signature = Ei;
function zW(e) {
  return 1 / Math.tan(e);
}
zW.signature = Ei;
function GW(e) {
  var r = Math.exp(2 * e);
  return (r + 1) / (r - 1);
}
GW.signature = Ei;
function qW(e) {
  return 1 / Math.sin(e);
}
qW.signature = Ei;
function HW(e) {
  return e === 0 ? Number.POSITIVE_INFINITY : Math.abs(2 / (Math.exp(e) - Math.exp(-e))) * fd(e);
}
HW.signature = Ei;
function jW(e) {
  return 1 / Math.cos(e);
}
jW.signature = Ei;
function $W(e) {
  return 2 / (Math.exp(e) + Math.exp(-e));
}
$W.signature = Ei;
function KW(e) {
  return uAe(e);
}
KW.signature = Ei;
var wD = "number";
function WW(e) {
  return e < 0;
}
WW.signature = wD;
function XW(e) {
  return e > 0;
}
XW.signature = wD;
function YW(e) {
  return Number.isNaN(e);
}
YW.signature = wD;
function To(e, r) {
  var t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1e-9, n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0;
  if (t <= 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() || r.isNaN() ? !1 : !e.isFinite() || !r.isFinite() ? e.eq(r) : e.eq(r) ? !0 : e.minus(r).abs().lte(e.constructor.max(e.constructor.max(e.abs(), r.abs()).mul(t), n));
}
var DR = "isNegative", t5e = ["typed", "config"], n5e = /* @__PURE__ */ Ce(DR, t5e, (e) => {
  var {
    typed: r,
    config: t
  } = e;
  return r(DR, {
    number: (n) => oi(n, 0, t.relTol, t.absTol) ? !1 : WW(n),
    BigNumber: (n) => To(n, new n.constructor(0), t.relTol, t.absTol) ? !1 : n.isNeg() && !n.isZero() && !n.isNaN(),
    bigint: (n) => n < 0n,
    Fraction: (n) => n.s < 0,
    // It's enough to decide on the sign
    Unit: r.referToSelf((n) => (a) => r.find(n, a.valueType())(a.value)),
    "Array | Matrix": r.referToSelf((n) => (a) => zr(a, n))
  });
}), IR = "isNumeric", a5e = ["typed"], i5e = /* @__PURE__ */ Ce(IR, a5e, (e) => {
  var {
    typed: r
  } = e;
  return r(IR, {
    "number | BigNumber | bigint | Fraction | boolean": () => !0,
    "Complex | Unit | string | null | undefined | Node": () => !1,
    "Array | Matrix": r.referToSelf((t) => (n) => zr(n, t))
  });
}), BR = "hasNumericValue", o5e = ["typed", "isNumeric"], u5e = /* @__PURE__ */ Ce(BR, o5e, (e) => {
  var {
    typed: r,
    isNumeric: t
  } = e;
  return r(BR, {
    boolean: () => !0,
    string: function(a) {
      return a.trim().length > 0 && !isNaN(Number(a));
    },
    any: function(a) {
      return t(a);
    }
  });
}), NR = "isPositive", s5e = ["typed", "config"], QW = /* @__PURE__ */ Ce(NR, s5e, (e) => {
  var {
    typed: r,
    config: t
  } = e;
  return r(NR, {
    number: (n) => oi(n, 0, t.relTol, t.absTol) ? !1 : XW(n),
    BigNumber: (n) => To(n, new n.constructor(0), t.relTol, t.absTol) ? !1 : !n.isNeg() && !n.isZero() && !n.isNaN(),
    bigint: (n) => n > 0n,
    Fraction: (n) => n.s > 0 && n.n > 0,
    Unit: r.referToSelf((n) => (a) => r.find(n, a.valueType())(a.value)),
    "Array | Matrix": r.referToSelf((n) => (a) => zr(a, n))
  });
}), VR = "isZero", l5e = ["typed", "equalScalar"], ZW = /* @__PURE__ */ Ce(VR, l5e, (e) => {
  var {
    typed: r,
    equalScalar: t
  } = e;
  return r(VR, {
    "number | BigNumber | Complex | Fraction": (n) => t(n, 0),
    bigint: (n) => n === 0n,
    Unit: r.referToSelf((n) => (a) => r.find(n, a.valueType())(a.value)),
    "Array | Matrix": r.referToSelf((n) => (a) => zr(a, n))
  });
}), RR = "isNaN", c5e = ["typed"], d5e = /* @__PURE__ */ Ce(RR, c5e, (e) => {
  var {
    typed: r
  } = e;
  return r(RR, {
    number: YW,
    BigNumber: function(n) {
      return n.isNaN();
    },
    bigint: function(n) {
      return !1;
    },
    Fraction: function(n) {
      return !1;
    },
    Complex: function(n) {
      return n.isNaN();
    },
    Unit: function(n) {
      return Number.isNaN(n.value);
    },
    "Array | Matrix": r.referToSelf((t) => (n) => zr(n, t))
  });
}), OR = "typeOf", f5e = ["typed"], m5e = /* @__PURE__ */ Ce(OR, f5e, (e) => {
  var {
    typed: r
  } = e;
  return r(OR, {
    any: Et
  });
});
function v5e(e, r, t, n) {
  return oi(e.re, r.re, t, n) && oi(e.im, r.im, t, n);
}
var Qp = /* @__PURE__ */ Ce("compareUnits", ["typed"], (e) => {
  var {
    typed: r
  } = e;
  return {
    "Unit, Unit": r.referToSelf((t) => (n, a) => {
      if (!n.equalBase(a))
        throw new Error("Cannot compare units with different base");
      return r.find(t, [n.valueType(), a.valueType()])(n.value, a.value);
    })
  };
}), T3 = "equalScalar", p5e = ["typed", "config"], JW = /* @__PURE__ */ Ce(T3, p5e, (e) => {
  var {
    typed: r,
    config: t
  } = e, n = Qp({
    typed: r
  });
  return r(T3, {
    "boolean, boolean": function(i, o) {
      return i === o;
    },
    "number, number": function(i, o) {
      return oi(i, o, t.relTol, t.absTol);
    },
    "BigNumber, BigNumber": function(i, o) {
      return i.eq(o) || To(i, o, t.relTol, t.absTol);
    },
    "bigint, bigint": function(i, o) {
      return i === o;
    },
    "Fraction, Fraction": function(i, o) {
      return i.equals(o);
    },
    "Complex, Complex": function(i, o) {
      return v5e(i, o, t.relTol, t.absTol);
    }
  }, n);
});
Ce(T3, ["typed", "config"], (e) => {
  var {
    typed: r,
    config: t
  } = e;
  return r(T3, {
    "number, number": function(a, i) {
      return oi(a, i, t.relTol, t.absTol);
    }
  });
});
var h5e = "SparseMatrix", g5e = ["typed", "equalScalar", "Matrix"], eX = /* @__PURE__ */ Ce(h5e, g5e, (e) => {
  var {
    typed: r,
    equalScalar: t,
    Matrix: n
  } = e;
  function a(v, h) {
    if (!(this instanceof a))
      throw new SyntaxError("Constructor must be called with the new operator");
    if (h && !Ya(h))
      throw new Error("Invalid datatype: " + h);
    if (gr(v))
      i(this, v, h);
    else if (v && dt(v.index) && dt(v.ptr) && dt(v.size))
      this._values = v.values, this._index = v.index, this._ptr = v.ptr, this._size = v.size, this._datatype = h || v.datatype;
    else if (dt(v))
      o(this, v, h);
    else {
      if (v)
        throw new TypeError("Unsupported type of data (" + Et(v) + ")");
      this._values = [], this._index = [], this._ptr = [0], this._size = [0, 0], this._datatype = h;
    }
  }
  function i(v, h, y) {
    h.type === "SparseMatrix" ? (v._values = h._values ? Sr(h._values) : void 0, v._index = Sr(h._index), v._ptr = Sr(h._ptr), v._size = Sr(h._size), v._datatype = y || h._datatype) : o(v, h.valueOf(), y || h._datatype);
  }
  function o(v, h, y) {
    v._values = [], v._index = [], v._ptr = [], v._datatype = y;
    var C = h.length, S = 0, b = t, g = 0;
    if (Ya(y) && (b = r.find(t, [y, y]) || t, g = r.convert(0, y)), C > 0) {
      var _ = 0;
      do {
        v._ptr.push(v._index.length);
        for (var A = 0; A < C; A++) {
          var M = h[A];
          if (dt(M)) {
            if (_ === 0 && S < M.length && (S = M.length), _ < M.length) {
              var P = M[_];
              b(P, g) || (v._values.push(P), v._index.push(A));
            }
          } else
            _ === 0 && S < 1 && (S = 1), b(M, g) || (v._values.push(M), v._index.push(A));
        }
        _++;
      } while (_ < S);
    }
    v._ptr.push(v._index.length), v._size = [C, S];
  }
  a.prototype = new n(), a.prototype.createSparseMatrix = function(v, h) {
    return new a(v, h);
  }, Object.defineProperty(a, "name", {
    value: "SparseMatrix"
  }), a.prototype.constructor = a, a.prototype.type = "SparseMatrix", a.prototype.isSparseMatrix = !0, a.prototype.getDataType = function() {
    return Ug(this._values, Et);
  }, a.prototype.storage = function() {
    return "sparse";
  }, a.prototype.datatype = function() {
    return this._datatype;
  }, a.prototype.create = function(v, h) {
    return new a(v, h);
  }, a.prototype.density = function() {
    var v = this._size[0], h = this._size[1];
    return v !== 0 && h !== 0 ? this._index.length / (v * h) : 0;
  }, a.prototype.subset = function(v, h, y) {
    if (!this._values)
      throw new Error("Cannot invoke subset on a Pattern only matrix");
    switch (arguments.length) {
      case 1:
        return c(this, v);
      case 2:
      case 3:
        return s(this, v, h, y);
      default:
        throw new SyntaxError("Wrong number of arguments");
    }
  };
  function c(v, h) {
    if (!zy(h))
      throw new TypeError("Invalid index");
    var y = h.isScalar();
    if (y)
      return v.get(h.min());
    var C = h.size();
    if (C.length !== v._size.length)
      throw new kr(C.length, v._size.length);
    var S, b, g, _, A = h.min(), M = h.max();
    for (S = 0, b = v._size.length; S < b; S++)
      Pt(A[S], v._size[S]), Pt(M[S], v._size[S]);
    var P = v._values, T = v._index, x = v._ptr, w = h.dimension(0), E = h.dimension(1), I = [], B = [];
    w.forEach(function(V, k) {
      B[V] = k[0], I[V] = !0;
    });
    var D = P ? [] : void 0, N = [], O = [];
    return E.forEach(function(V) {
      for (O.push(N.length), g = x[V], _ = x[V + 1]; g < _; g++)
        S = T[g], I[S] === !0 && (N.push(B[S]), D && D.push(P[g]));
    }), O.push(N.length), new a({
      values: D,
      index: N,
      ptr: O,
      size: C,
      datatype: v._datatype
    });
  }
  function s(v, h, y, C) {
    if (!h || h.isIndex !== !0)
      throw new TypeError("Invalid index");
    var S = h.size(), b = h.isScalar(), g;
    if (gr(y) ? (g = y.size(), y = y.toArray()) : g = Fr(y), b) {
      if (g.length !== 0)
        throw new TypeError("Scalar expected");
      v.set(h.min(), y, C);
    } else {
      if (S.length !== 1 && S.length !== 2)
        throw new kr(S.length, v._size.length, "<");
      if (g.length < S.length) {
        for (var _ = 0, A = 0; S[_] === 1 && g[_] === 1; )
          _++;
        for (; S[_] === 1; )
          A++, _++;
        y = XK(y, S.length, A, g);
      }
      if (!gc(S, g))
        throw new kr(S, g, ">");
      if (S.length === 1) {
        var M = h.dimension(0);
        M.forEach(function(x, w) {
          Pt(x), v.set([x, 0], y[w[0]], C);
        });
      } else {
        var P = h.dimension(0), T = h.dimension(1);
        P.forEach(function(x, w) {
          Pt(x), T.forEach(function(E, I) {
            Pt(E), v.set([x, E], y[w[0]][I[0]], C);
          });
        });
      }
    }
    return v;
  }
  a.prototype.get = function(v) {
    if (!dt(v))
      throw new TypeError("Array expected");
    if (v.length !== this._size.length)
      throw new kr(v.length, this._size.length);
    if (!this._values)
      throw new Error("Cannot invoke get on a Pattern only matrix");
    var h = v[0], y = v[1];
    Pt(h, this._size[0]), Pt(y, this._size[1]);
    var C = u(h, this._ptr[y], this._ptr[y + 1], this._index);
    return C < this._ptr[y + 1] && this._index[C] === h ? this._values[C] : 0;
  }, a.prototype.set = function(v, h, y) {
    if (!dt(v))
      throw new TypeError("Array expected");
    if (v.length !== this._size.length)
      throw new kr(v.length, this._size.length);
    if (!this._values)
      throw new Error("Cannot invoke set on a Pattern only matrix");
    var C = v[0], S = v[1], b = this._size[0], g = this._size[1], _ = t, A = 0;
    Ya(this._datatype) && (_ = r.find(t, [this._datatype, this._datatype]) || t, A = r.convert(0, this._datatype)), (C > b - 1 || S > g - 1) && (d(this, Math.max(C + 1, b), Math.max(S + 1, g), y), b = this._size[0], g = this._size[1]), Pt(C, b), Pt(S, g);
    var M = u(C, this._ptr[S], this._ptr[S + 1], this._index);
    return M < this._ptr[S + 1] && this._index[M] === C ? _(h, A) ? l(M, S, this._values, this._index, this._ptr) : this._values[M] = h : _(h, A) || f(M, C, S, h, this._values, this._index, this._ptr), this;
  };
  function u(v, h, y, C) {
    if (y - h === 0)
      return y;
    for (var S = h; S < y; S++)
      if (C[S] === v)
        return S;
    return h;
  }
  function l(v, h, y, C, S) {
    y.splice(v, 1), C.splice(v, 1);
    for (var b = h + 1; b < S.length; b++)
      S[b]--;
  }
  function f(v, h, y, C, S, b, g) {
    S.splice(v, 0, C), b.splice(v, 0, h);
    for (var _ = y + 1; _ < g.length; _++)
      g[_]++;
  }
  a.prototype.resize = function(v, h, y) {
    if (!Xo(v))
      throw new TypeError("Array or Matrix expected");
    var C = v.valueOf().map((b) => Array.isArray(b) && b.length === 1 ? b[0] : b);
    if (C.length !== 2)
      throw new Error("Only two dimensions matrix are supported");
    C.forEach(function(b) {
      if (!Or(b) || !lr(b) || b < 0)
        throw new TypeError("Invalid size, must contain positive integers (size: " + $r(C) + ")");
    });
    var S = y ? this.clone() : this;
    return d(S, C[0], C[1], h);
  };
  function d(v, h, y, C) {
    var S = C || 0, b = t, g = 0;
    Ya(v._datatype) && (b = r.find(t, [v._datatype, v._datatype]) || t, g = r.convert(0, v._datatype), S = r.convert(S, v._datatype));
    var _ = !b(S, g), A = v._size[0], M = v._size[1], P, T, x;
    if (y > M) {
      for (T = M; T < y; T++)
        if (v._ptr[T] = v._values.length, _)
          for (P = 0; P < A; P++)
            v._values.push(S), v._index.push(P);
      v._ptr[y] = v._values.length;
    } else y < M && (v._ptr.splice(y + 1, M - y), v._values.splice(v._ptr[y], v._values.length), v._index.splice(v._ptr[y], v._index.length));
    if (M = y, h > A) {
      if (_) {
        var w = 0;
        for (T = 0; T < M; T++) {
          v._ptr[T] = v._ptr[T] + w, x = v._ptr[T + 1] + w;
          var E = 0;
          for (P = A; P < h; P++, E++)
            v._values.splice(x + E, 0, S), v._index.splice(x + E, 0, P), w++;
        }
        v._ptr[M] = v._values.length;
      }
    } else if (h < A) {
      var I = 0;
      for (T = 0; T < M; T++) {
        v._ptr[T] = v._ptr[T] - I;
        var B = v._ptr[T], D = v._ptr[T + 1] - I;
        for (x = B; x < D; x++)
          P = v._index[x], P > h - 1 && (v._values.splice(x, 1), v._index.splice(x, 1), I++);
      }
      v._ptr[T] = v._values.length;
    }
    return v._size[0] = h, v._size[1] = y, v;
  }
  a.prototype.reshape = function(v, h) {
    if (!dt(v))
      throw new TypeError("Array expected");
    if (v.length !== 2)
      throw new Error("Sparse matrices can only be reshaped in two dimensions");
    v.forEach(function(V) {
      if (!Or(V) || !lr(V) || V <= -2 || V === 0)
        throw new TypeError("Invalid size, must contain positive integers or -1 (size: " + $r(v) + ")");
    });
    var y = this._size[0] * this._size[1];
    v = PD(v, y);
    var C = v[0] * v[1];
    if (y !== C)
      throw new Error("Reshaping sparse matrix will result in the wrong number of elements");
    var S = h ? this.clone() : this;
    if (this._size[0] === v[0] && this._size[1] === v[1])
      return S;
    for (var b = [], g = 0; g < S._ptr.length; g++)
      for (var _ = 0; _ < S._ptr[g + 1] - S._ptr[g]; _++)
        b.push(g);
    for (var A = S._values.slice(), M = S._index.slice(), P = 0; P < S._index.length; P++) {
      var T = M[P], x = b[P], w = T * S._size[1] + x;
      b[P] = w % v[1], M[P] = Math.floor(w / v[1]);
    }
    S._values.length = 0, S._index.length = 0, S._ptr.length = v[1] + 1, S._size = v.slice();
    for (var E = 0; E < S._ptr.length; E++)
      S._ptr[E] = 0;
    for (var I = 0; I < A.length; I++) {
      var B = M[I], D = b[I], N = A[I], O = u(B, S._ptr[D], S._ptr[D + 1], S._index);
      f(O, B, D, N, S._values, S._index, S._ptr);
    }
    return S;
  }, a.prototype.clone = function() {
    var v = new a({
      values: this._values ? Sr(this._values) : void 0,
      index: Sr(this._index),
      ptr: Sr(this._ptr),
      size: Sr(this._size),
      datatype: this._datatype
    });
    return v;
  }, a.prototype.size = function() {
    return this._size.slice(0);
  }, a.prototype.map = function(v, h) {
    if (!this._values)
      throw new Error("Cannot invoke map on a Pattern only matrix");
    var y = this, C = this._size[0], S = this._size[1], b = tW(v), g = function(A, M, P) {
      return b === 1 ? v(A) : b === 2 ? v(A, [M, P]) : v(A, [M, P], y);
    };
    return m(this, 0, C - 1, 0, S - 1, g, h);
  };
  function m(v, h, y, C, S, b, g) {
    var _ = [], A = [], M = [], P = t, T = 0;
    Ya(v._datatype) && (P = r.find(t, [v._datatype, v._datatype]) || t, T = r.convert(0, v._datatype));
    for (var x = function(R, F, U) {
      R = b(R, F, U), P(R, T) || (_.push(R), A.push(F));
    }, w = C; w <= S; w++) {
      M.push(_.length);
      var E = v._ptr[w], I = v._ptr[w + 1];
      if (g)
        for (var B = E; B < I; B++) {
          var D = v._index[B];
          D >= h && D <= y && x(v._values[B], D - h, w - C);
        }
      else {
        for (var N = {}, O = E; O < I; O++) {
          var V = v._index[O];
          N[V] = v._values[O];
        }
        for (var k = h; k <= y; k++) {
          var G = k in N ? N[k] : 0;
          x(G, k - h, w - C);
        }
      }
    }
    return M.push(_.length), new a({
      values: _,
      index: A,
      ptr: M,
      size: [y - h + 1, S - C + 1]
    });
  }
  a.prototype.forEach = function(v, h) {
    if (!this._values)
      throw new Error("Cannot invoke forEach on a Pattern only matrix");
    for (var y = this, C = this._size[0], S = this._size[1], b = 0; b < S; b++) {
      var g = this._ptr[b], _ = this._ptr[b + 1];
      if (h)
        for (var A = g; A < _; A++) {
          var M = this._index[A];
          v(this._values[A], [M, b], y);
        }
      else {
        for (var P = {}, T = g; T < _; T++) {
          var x = this._index[T];
          P[x] = this._values[T];
        }
        for (var w = 0; w < C; w++) {
          var E = w in P ? P[w] : 0;
          v(E, [w, b], y);
        }
      }
    }
  }, a.prototype[Symbol.iterator] = function* () {
    if (!this._values)
      throw new Error("Cannot iterate a Pattern only matrix");
    for (var v = this._size[1], h = 0; h < v; h++)
      for (var y = this._ptr[h], C = this._ptr[h + 1], S = y; S < C; S++) {
        var b = this._index[S];
        yield {
          value: this._values[S],
          index: [b, h]
        };
      }
  }, a.prototype.toArray = function() {
    return p(this._values, this._index, this._ptr, this._size, !0);
  }, a.prototype.valueOf = function() {
    return p(this._values, this._index, this._ptr, this._size, !1);
  };
  function p(v, h, y, C, S) {
    var b = C[0], g = C[1], _ = [], A, M;
    for (A = 0; A < b; A++)
      for (_[A] = [], M = 0; M < g; M++)
        _[A][M] = 0;
    for (M = 0; M < g; M++)
      for (var P = y[M], T = y[M + 1], x = P; x < T; x++)
        A = h[x], _[A][M] = v ? S ? Sr(v[x]) : v[x] : 1;
    return _;
  }
  return a.prototype.format = function(v) {
    for (var h = this._size[0], y = this._size[1], C = this.density(), S = "Sparse Matrix [" + $r(h, v) + " x " + $r(y, v) + "] density: " + $r(C, v) + `
`, b = 0; b < y; b++)
      for (var g = this._ptr[b], _ = this._ptr[b + 1], A = g; A < _; A++) {
        var M = this._index[A];
        S += `
    (` + $r(M, v) + ", " + $r(b, v) + ") ==> " + (this._values ? $r(this._values[A], v) : "X");
      }
    return S;
  }, a.prototype.toString = function() {
    return $r(this.toArray());
  }, a.prototype.toJSON = function() {
    return {
      mathjs: "SparseMatrix",
      values: this._values,
      index: this._index,
      ptr: this._ptr,
      size: this._size,
      datatype: this._datatype
    };
  }, a.prototype.diagonal = function(v) {
    if (v) {
      if (Ir(v) && (v = v.toNumber()), !Or(v) || !lr(v))
        throw new TypeError("The parameter k must be an integer number");
    } else
      v = 0;
    var h = v > 0 ? v : 0, y = v < 0 ? -v : 0, C = this._size[0], S = this._size[1], b = Math.min(C - y, S - h), g = [], _ = [], A = [];
    A[0] = 0;
    for (var M = h; M < S && g.length < b; M++)
      for (var P = this._ptr[M], T = this._ptr[M + 1], x = P; x < T; x++) {
        var w = this._index[x];
        if (w === M - h + y) {
          g.push(this._values[x]), _[g.length - 1] = w - y;
          break;
        }
      }
    return A.push(g.length), new a({
      values: g,
      index: _,
      ptr: A,
      size: [b, 1]
    });
  }, a.fromJSON = function(v) {
    return new a(v);
  }, a.diagonal = function(v, h, y, C, S) {
    if (!dt(v))
      throw new TypeError("Array expected, size parameter");
    if (v.length !== 2)
      throw new Error("Only two dimensions matrix are supported");
    if (v = v.map(function(V) {
      if (Ir(V) && (V = V.toNumber()), !Or(V) || !lr(V) || V < 1)
        throw new Error("Size values must be positive integers");
      return V;
    }), y) {
      if (Ir(y) && (y = y.toNumber()), !Or(y) || !lr(y))
        throw new TypeError("The parameter k must be an integer number");
    } else
      y = 0;
    var b = t, g = 0;
    Ya(S) && (b = r.find(t, [S, S]) || t, g = r.convert(0, S));
    var _ = y > 0 ? y : 0, A = y < 0 ? -y : 0, M = v[0], P = v[1], T = Math.min(M - A, P - _), x;
    if (dt(h)) {
      if (h.length !== T)
        throw new Error("Invalid value array length");
      x = function(k) {
        return h[k];
      };
    } else if (gr(h)) {
      var w = h.size();
      if (w.length !== 1 || w[0] !== T)
        throw new Error("Invalid matrix length");
      x = function(k) {
        return h.get([k]);
      };
    } else
      x = function() {
        return h;
      };
    for (var E = [], I = [], B = [], D = 0; D < P; D++) {
      B.push(E.length);
      var N = D - _;
      if (N >= 0 && N < T) {
        var O = x(N);
        b(O, g) || (I.push(N + A), E.push(O));
      }
    }
    return B.push(E.length), new a({
      values: E,
      index: I,
      ptr: B,
      size: [M, P]
    });
  }, a.prototype.swapRows = function(v, h) {
    if (!Or(v) || !lr(v) || !Or(h) || !lr(h))
      throw new Error("Row index must be positive integers");
    if (this._size.length !== 2)
      throw new Error("Only two dimensional matrix is supported");
    return Pt(v, this._size[0]), Pt(h, this._size[0]), a._swapRows(v, h, this._size[1], this._values, this._index, this._ptr), this;
  }, a._forEachRow = function(v, h, y, C, S) {
    for (var b = C[v], g = C[v + 1], _ = b; _ < g; _++)
      S(y[_], h[_]);
  }, a._swapRows = function(v, h, y, C, S, b) {
    for (var g = 0; g < y; g++) {
      var _ = b[g], A = b[g + 1], M = u(v, _, A, S), P = u(h, _, A, S);
      if (M < A && P < A && S[M] === v && S[P] === h) {
        if (C) {
          var T = C[M];
          C[M] = C[P], C[P] = T;
        }
        continue;
      }
      if (M < A && S[M] === v && (P >= A || S[P] !== h)) {
        var x = C ? C[M] : void 0;
        S.splice(P, 0, h), C && C.splice(P, 0, x), S.splice(P <= M ? M + 1 : M, 1), C && C.splice(P <= M ? M + 1 : M, 1);
        continue;
      }
      if (P < A && S[P] === h && (M >= A || S[M] !== v)) {
        var w = C ? C[P] : void 0;
        S.splice(M, 0, v), C && C.splice(M, 0, w), S.splice(M <= P ? P + 1 : P, 1), C && C.splice(M <= P ? P + 1 : P, 1);
      }
    }
  }, a;
}, {
  isClass: !0
}), y5e = "number", _5e = ["typed"];
function b5e(e) {
  var r = e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);
  if (r) {
    var t = {
      "0b": 2,
      "0o": 8,
      "0x": 16
    }[r[1]], n = r[2], a = r[3];
    return {
      input: e,
      radix: t,
      integerPart: n,
      fractionalPart: a
    };
  } else
    return null;
}
function S5e(e) {
  for (var r = parseInt(e.integerPart, e.radix), t = 0, n = 0; n < e.fractionalPart.length; n++) {
    var a = parseInt(e.fractionalPart[n], e.radix);
    t += a / Math.pow(e.radix, n + 1);
  }
  var i = r + t;
  if (isNaN(i))
    throw new SyntaxError('String "' + e.input + '" is not a valid number');
  return i;
}
var rX = /* @__PURE__ */ Ce(y5e, _5e, (e) => {
  var {
    typed: r
  } = e, t = r("number", {
    "": function() {
      return 0;
    },
    number: function(a) {
      return a;
    },
    string: function(a) {
      if (a === "NaN") return NaN;
      var i = b5e(a);
      if (i)
        return S5e(i);
      var o = 0, c = a.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);
      c && (o = Number(c[2]), a = c[1]);
      var s = Number(a);
      if (isNaN(s))
        throw new SyntaxError('String "' + a + '" is not a valid number');
      if (c) {
        if (s > 2 ** o - 1)
          throw new SyntaxError('String "'.concat(a, '" is out of range'));
        s >= 2 ** (o - 1) && (s = s - 2 ** o);
      }
      return s;
    },
    BigNumber: function(a) {
      return a.toNumber();
    },
    bigint: function(a) {
      return Number(a);
    },
    Fraction: function(a) {
      return a.valueOf();
    },
    Unit: r.referToSelf((n) => (a) => {
      var i = a.clone();
      return i.value = n(a.value), i;
    }),
    null: function(a) {
      return 0;
    },
    "Unit, string | Unit": function(a, i) {
      return a.toNumber(i);
    },
    "Array | Matrix": r.referToSelf((n) => (a) => zr(a, n))
  });
  return t.fromJSON = function(n) {
    return parseFloat(n.value);
  }, t;
}), C5e = "bigint", A5e = ["typed"], x5e = /* @__PURE__ */ Ce(C5e, A5e, (e) => {
  var {
    typed: r
  } = e, t = r("bigint", {
    "": function() {
      return 0n;
    },
    bigint: function(a) {
      return a;
    },
    number: function(a) {
      return BigInt(a.toFixed());
    },
    BigNumber: function(a) {
      return BigInt(a.round().toString());
    },
    Fraction: function(a) {
      return BigInt(a.valueOf().toFixed());
    },
    "string | boolean": function(a) {
      return BigInt(a);
    },
    null: function(a) {
      return 0n;
    },
    "Array | Matrix": r.referToSelf((n) => (a) => zr(a, n))
  });
  return t.fromJSON = function(n) {
    return BigInt(n.value);
  }, t;
}), FR = "string", T5e = ["typed"], P5e = /* @__PURE__ */ Ce(FR, T5e, (e) => {
  var {
    typed: r
  } = e;
  return r(FR, {
    "": function() {
      return "";
    },
    number: o0,
    null: function(n) {
      return "null";
    },
    boolean: function(n) {
      return n + "";
    },
    string: function(n) {
      return n;
    },
    "Array | Matrix": r.referToSelf((t) => (n) => zr(n, t)),
    any: function(n) {
      return String(n);
    }
  });
}), LR = "boolean", M5e = ["typed"], w5e = /* @__PURE__ */ Ce(LR, M5e, (e) => {
  var {
    typed: r
  } = e;
  return r(LR, {
    "": function() {
      return !1;
    },
    boolean: function(n) {
      return n;
    },
    number: function(n) {
      return !!n;
    },
    null: function(n) {
      return !1;
    },
    BigNumber: function(n) {
      return !n.isZero();
    },
    string: function(n) {
      var a = n.toLowerCase();
      if (a === "true")
        return !0;
      if (a === "false")
        return !1;
      var i = Number(n);
      if (n !== "" && !isNaN(i))
        return !!i;
      throw new Error('Cannot convert "' + n + '" to a boolean');
    },
    "Array | Matrix": r.referToSelf((t) => (n) => zr(n, t))
  });
}), E5e = "bignumber", D5e = ["typed", "BigNumber"], tX = /* @__PURE__ */ Ce(E5e, D5e, (e) => {
  var {
    typed: r,
    BigNumber: t
  } = e;
  return r("bignumber", {
    "": function() {
      return new t(0);
    },
    number: function(a) {
      return new t(a + "");
    },
    string: function(a) {
      var i = a.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);
      if (i) {
        var o = i[2], c = t(i[1]), s = new t(2).pow(Number(o));
        if (c.gt(s.sub(1)))
          throw new SyntaxError('String "'.concat(a, '" is out of range'));
        var u = new t(2).pow(Number(o) - 1);
        return c.gte(u) ? c.sub(s) : c;
      }
      return new t(a);
    },
    BigNumber: function(a) {
      return a;
    },
    bigint: function(a) {
      return new t(a.toString());
    },
    Unit: r.referToSelf((n) => (a) => {
      var i = a.clone();
      return i.value = n(a.value), i;
    }),
    Fraction: function(a) {
      return new t(a.n).div(a.d).times(a.s);
    },
    null: function(a) {
      return new t(0);
    },
    "Array | Matrix": r.referToSelf((n) => (a) => zr(a, n))
  });
}), I5e = "complex", B5e = ["typed", "Complex"], nX = /* @__PURE__ */ Ce(I5e, B5e, (e) => {
  var {
    typed: r,
    Complex: t
  } = e;
  return r("complex", {
    "": function() {
      return t.ZERO;
    },
    number: function(a) {
      return new t(a, 0);
    },
    "number, number": function(a, i) {
      return new t(a, i);
    },
    // TODO: this signature should be redundant
    "BigNumber, BigNumber": function(a, i) {
      return new t(a.toNumber(), i.toNumber());
    },
    Fraction: function(a) {
      return new t(a.valueOf(), 0);
    },
    Complex: function(a) {
      return a.clone();
    },
    string: function(a) {
      return t(a);
    },
    null: function(a) {
      return t(0);
    },
    Object: function(a) {
      if ("re" in a && "im" in a)
        return new t(a.re, a.im);
      if ("r" in a && "phi" in a || "abs" in a && "arg" in a)
        return new t(a);
      throw new Error("Expected object with properties (re and im) or (r and phi) or (abs and arg)");
    },
    "Array | Matrix": r.referToSelf((n) => (a) => zr(a, n))
  });
}), N5e = "fraction", V5e = ["typed", "Fraction"], aX = /* @__PURE__ */ Ce(N5e, V5e, (e) => {
  var {
    typed: r,
    Fraction: t
  } = e;
  return r("fraction", {
    number: function(a) {
      if (!isFinite(a) || isNaN(a))
        throw new Error(a + " cannot be represented as a fraction");
      return new t(a);
    },
    string: function(a) {
      return new t(a);
    },
    "number, number": function(a, i) {
      return new t(a, i);
    },
    null: function(a) {
      return new t(0);
    },
    BigNumber: function(a) {
      return new t(a.toString());
    },
    bigint: function(a) {
      return new t(a.toString());
    },
    Fraction: function(a) {
      return a;
    },
    Unit: r.referToSelf((n) => (a) => {
      var i = a.clone();
      return i.value = n(a.value), i;
    }),
    Object: function(a) {
      return new t(a);
    },
    "Array | Matrix": r.referToSelf((n) => (a) => zr(a, n))
  });
}), kR = "matrix", R5e = ["typed", "Matrix", "DenseMatrix", "SparseMatrix"], iX = /* @__PURE__ */ Ce(kR, R5e, (e) => {
  var {
    typed: r,
    Matrix: t,
    DenseMatrix: n,
    SparseMatrix: a
  } = e;
  return r(kR, {
    "": function() {
      return i([]);
    },
    string: function(c) {
      return i([], c);
    },
    "string, string": function(c, s) {
      return i([], c, s);
    },
    Array: function(c) {
      return i(c);
    },
    Matrix: function(c) {
      return i(c, c.storage());
    },
    "Array | Matrix, string": i,
    "Array | Matrix, string, string": i
  });
  function i(o, c, s) {
    if (c === "dense" || c === "default" || c === void 0)
      return new n(o, s);
    if (c === "sparse")
      return new a(o, s);
    throw new TypeError("Unknown matrix type " + JSON.stringify(c) + ".");
  }
}), UR = "matrixFromFunction", O5e = ["typed", "matrix", "isZero"], F5e = /* @__PURE__ */ Ce(UR, O5e, (e) => {
  var {
    typed: r,
    matrix: t,
    isZero: n
  } = e;
  return r(UR, {
    "Array | Matrix, function, string, string": function(o, c, s, u) {
      return a(o, c, s, u);
    },
    "Array | Matrix, function, string": function(o, c, s) {
      return a(o, c, s);
    },
    "Matrix, function": function(o, c) {
      return a(o, c, "dense");
    },
    "Array, function": function(o, c) {
      return a(o, c, "dense").toArray();
    },
    "Array | Matrix, string, function": function(o, c, s) {
      return a(o, s, c);
    },
    "Array | Matrix, string, string, function": function(o, c, s, u) {
      return a(o, u, c, s);
    }
  });
  function a(i, o, c, s) {
    var u;
    return s !== void 0 ? u = t(c, s) : u = t(c), u.resize(i), u.forEach(function(l, f) {
      var d = o(f);
      n(d) || u.set(f, d);
    }), u;
  }
}), zR = "matrixFromRows", L5e = ["typed", "matrix", "flatten", "size"], k5e = /* @__PURE__ */ Ce(zR, L5e, (e) => {
  var {
    typed: r,
    matrix: t,
    flatten: n,
    size: a
  } = e;
  return r(zR, {
    "...Array": function(s) {
      return i(s);
    },
    "...Matrix": function(s) {
      return t(i(s.map((u) => u.toArray())));
    }
    // TODO implement this properly for SparseMatrix
  });
  function i(c) {
    if (c.length === 0) throw new TypeError("At least one row is needed to construct a matrix.");
    var s = o(c[0]), u = [];
    for (var l of c) {
      var f = o(l);
      if (f !== s)
        throw new TypeError("The vectors had different length: " + (s | 0) + " ≠ " + (f | 0));
      u.push(n(l));
    }
    return u;
  }
  function o(c) {
    var s = a(c);
    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.");
  }
}), GR = "matrixFromColumns", U5e = ["typed", "matrix", "flatten", "size"], oX = /* @__PURE__ */ Ce(GR, U5e, (e) => {
  var {
    typed: r,
    matrix: t,
    flatten: n,
    size: a
  } = e;
  return r(GR, {
    "...Array": function(s) {
      return i(s);
    },
    "...Matrix": function(s) {
      return t(i(s.map((u) => u.toArray())));
    }
    // TODO implement this properly for SparseMatrix
  });
  function i(c) {
    if (c.length === 0) throw new TypeError("At least one column is needed to construct a matrix.");
    for (var s = o(c[0]), u = [], l = 0; l < s; l++)
      u[l] = [];
    for (var f of c) {
      var d = o(f);
      if (d !== s)
        throw new TypeError("The vectors had different length: " + (s | 0) + " ≠ " + (d | 0));
      for (var m = n(f), p = 0; p < s; p++)
        u[p].push(m[p]);
    }
    return u;
  }
  function o(c) {
    var s = a(c);
    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.");
  }
}), qR = "splitUnit", z5e = ["typed"], G5e = /* @__PURE__ */ Ce(qR, z5e, (e) => {
  var {
    typed: r
  } = e;
  return r(qR, {
    "Unit, Array": function(n, a) {
      return n.splitUnit(a);
    }
  });
}), HR = "unaryMinus", q5e = ["typed"], uX = /* @__PURE__ */ Ce(HR, q5e, (e) => {
  var {
    typed: r
  } = e;
  return r(HR, {
    number: cW,
    "Complex | BigNumber | Fraction": (t) => t.neg(),
    bigint: (t) => -t,
    Unit: r.referToSelf((t) => (n) => {
      var a = n.clone();
      return a.value = r.find(t, a.valueType())(n.value), a;
    }),
    // deep map collection, skip zeros since unaryMinus(0) = 0
    "Array | Matrix": r.referToSelf((t) => (n) => zr(n, t))
    // TODO: add support for string
  });
}), jR = "unaryPlus", H5e = ["typed", "config", "numeric"], j5e = /* @__PURE__ */ Ce(jR, H5e, (e) => {
  var {
    typed: r,
    config: t,
    numeric: n
  } = e;
  return r(jR, {
    number: dW,
    Complex: function(i) {
      return i;
    },
    BigNumber: function(i) {
      return i;
    },
    bigint: function(i) {
      return i;
    },
    Fraction: function(i) {
      return i;
    },
    Unit: function(i) {
      return i.clone();
    },
    // deep map collection, skip zeros since unaryPlus(0) = 0
    "Array | Matrix": r.referToSelf((a) => (i) => zr(i, a)),
    boolean: function(i) {
      return n(i ? 1 : 0, t.number);
    },
    string: function(i) {
      return n(i, rf(i, t));
    }
  });
}), $R = "abs", $5e = ["typed"], sX = /* @__PURE__ */ Ce($R, $5e, (e) => {
  var {
    typed: r
  } = e;
  return r($R, {
    number: oW,
    "Complex | BigNumber | Fraction | Unit": (t) => t.abs(),
    bigint: (t) => t < 0n ? -t : t,
    // deep map collection, skip zeros since abs(0) = 0
    "Array | Matrix": r.referToSelf((t) => (n) => zr(n, t))
  });
}), KR = "apply", K5e = ["typed", "isInteger"], ED = /* @__PURE__ */ Ce(KR, K5e, (e) => {
  var {
    typed: r,
    isInteger: t
  } = e;
  return r(KR, {
    "Array | Matrix, number | BigNumber, function": function(a, i, o) {
      if (!t(i))
        throw new TypeError("Integer number expected for dimension");
      var c = Array.isArray(a) ? Fr(a) : a.size();
      if (i < 0 || i >= c.length)
        throw new Ru(i, c.length);
      return gr(a) ? a.create(P3(a.valueOf(), i, o)) : P3(a, i, o);
    }
  });
});
function P3(e, r, t) {
  var n, a, i;
  if (r <= 0)
    if (Array.isArray(e[0])) {
      for (i = W5e(e), a = [], n = 0; n < i.length; n++)
        a[n] = P3(i[n], r - 1, t);
      return a;
    } else
      return t(e);
  else {
    for (a = [], n = 0; n < e.length; n++)
      a[n] = P3(e[n], r - 1, t);
    return a;
  }
}
function W5e(e) {
  var r = e.length, t = e[0].length, n, a, i = [];
  for (a = 0; a < t; a++) {
    var o = [];
    for (n = 0; n < r; n++)
      o.push(e[n][a]);
    i.push(o);
  }
  return i;
}
var WR = "addScalar", X5e = ["typed"], lX = /* @__PURE__ */ Ce(WR, X5e, (e) => {
  var {
    typed: r
  } = e;
  return r(WR, {
    "number, number": uW,
    "Complex, Complex": function(n, a) {
      return n.add(a);
    },
    "BigNumber, BigNumber": function(n, a) {
      return n.plus(a);
    },
    "bigint, bigint": function(n, a) {
      return n + a;
    },
    "Fraction, Fraction": function(n, a) {
      return n.add(a);
    },
    "Unit, Unit": r.referToSelf((t) => (n, a) => {
      if (n.value === null || n.value === void 0)
        throw new Error("Parameter x contains a unit with undefined value");
      if (a.value === null || a.value === void 0)
        throw new Error("Parameter y contains a unit with undefined value");
      if (!n.equalBase(a)) throw new Error("Units do not match");
      var i = n.clone();
      return i.value = r.find(t, [i.valueType(), a.valueType()])(i.value, a.value), i.fixPrefix = !1, i;
    })
  });
}), XR = "subtractScalar", Y5e = ["typed"], cX = /* @__PURE__ */ Ce(XR, Y5e, (e) => {
  var {
    typed: r
  } = e;
  return r(XR, {
    "number, number": sW,
    "Complex, Complex": function(n, a) {
      return n.sub(a);
    },
    "BigNumber, BigNumber": function(n, a) {
      return n.minus(a);
    },
    "bigint, bigint": function(n, a) {
      return n - a;
    },
    "Fraction, Fraction": function(n, a) {
      return n.sub(a);
    },
    "Unit, Unit": r.referToSelf((t) => (n, a) => {
      if (n.value === null || n.value === void 0)
        throw new Error("Parameter x contains a unit with undefined value");
      if (a.value === null || a.value === void 0)
        throw new Error("Parameter y contains a unit with undefined value");
      if (!n.equalBase(a)) throw new Error("Units do not match");
      var i = n.clone();
      return i.value = r.find(t, [i.valueType(), a.valueType()])(i.value, a.value), i.fixPrefix = !1, i;
    })
  });
}), YR = "cbrt", Q5e = ["config", "typed", "isNegative", "unaryMinus", "matrix", "Complex", "BigNumber", "Fraction"], Z5e = /* @__PURE__ */ Ce(YR, Q5e, (e) => {
  var {
    config: r,
    typed: t,
    isNegative: n,
    unaryMinus: a,
    matrix: i,
    Complex: o,
    BigNumber: c,
    Fraction: s
  } = e;
  return t(YR, {
    number: z1,
    // note: signature 'number, boolean' is also supported,
    //       created by typed as it knows how to convert number to Complex
    Complex: u,
    "Complex, boolean": u,
    BigNumber: function(d) {
      return d.cbrt();
    },
    Unit: l
  });
  function u(f, d) {
    var m = f.arg() / 3, p = f.abs(), v = new o(z1(p), 0).mul(new o(0, m).exp());
    if (d) {
      var h = [v, new o(z1(p), 0).mul(new o(0, m + Math.PI * 2 / 3).exp()), new o(z1(p), 0).mul(new o(0, m - Math.PI * 2 / 3).exp())];
      return r.matrix === "Array" ? h : i(h);
    } else
      return v;
  }
  function l(f) {
    if (f.value && as(f.value)) {
      var d = f.clone();
      return d.value = 1, d = d.pow(1 / 3), d.value = u(f.value), d;
    } else {
      var m = n(f.value);
      m && (f.value = a(f.value));
      var p;
      Ir(f.value) ? p = new c(1).div(3) : J0(f.value) ? p = new s(1, 3) : p = 1 / 3;
      var v = f.pow(p);
      return m && (v.value = a(v.value)), v;
    }
  }
}), J5e = "matAlgo11xS0s", eTe = ["typed", "equalScalar"], li = /* @__PURE__ */ Ce(J5e, eTe, (e) => {
  var {
    typed: r,
    equalScalar: t
  } = e;
  return function(a, i, o, c) {
    var s = a._values, u = a._index, l = a._ptr, f = a._size, d = a._datatype;
    if (!s)
      throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");
    var m = f[0], p = f[1], v, h = t, y = 0, C = o;
    typeof d == "string" && (v = d, h = r.find(t, [v, v]), y = r.convert(0, v), i = r.convert(i, v), C = r.find(o, [v, v]));
    for (var S = [], b = [], g = [], _ = 0; _ < p; _++) {
      g[_] = b.length;
      for (var A = l[_], M = l[_ + 1], P = A; P < M; P++) {
        var T = u[P], x = c ? C(i, s[P]) : C(s[P], i);
        h(x, y) || (b.push(T), S.push(x));
      }
    }
    return g[p] = b.length, a.createSparseMatrix({
      values: S,
      index: b,
      ptr: g,
      size: [m, p],
      datatype: v
    });
  };
}), rTe = "matAlgo12xSfs", tTe = ["typed", "DenseMatrix"], Aa = /* @__PURE__ */ Ce(rTe, tTe, (e) => {
  var {
    typed: r,
    DenseMatrix: t
  } = e;
  return function(a, i, o, c) {
    var s = a._values, u = a._index, l = a._ptr, f = a._size, d = a._datatype;
    if (!s)
      throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");
    var m = f[0], p = f[1], v, h = o;
    typeof d == "string" && (v = d, i = r.convert(i, v), h = r.find(o, [v, v]));
    for (var y = [], C = [], S = [], b = 0; b < p; b++) {
      for (var g = b + 1, _ = l[b], A = l[b + 1], M = _; M < A; M++) {
        var P = u[M];
        C[P] = s[M], S[P] = g;
      }
      for (var T = 0; T < m; T++)
        b === 0 && (y[T] = []), S[T] === g ? y[T][b] = c ? h(i, C[T]) : h(C[T], i) : y[T][b] = c ? h(i, 0) : h(0, i);
    }
    return new t({
      data: y,
      size: [m, p],
      datatype: v
    });
  };
}), nTe = "matAlgo14xDs", aTe = ["typed"], xs = /* @__PURE__ */ Ce(nTe, aTe, (e) => {
  var {
    typed: r
  } = e;
  return function(a, i, o, c) {
    var s = a._data, u = a._size, l = a._datatype, f, d = o;
    typeof l == "string" && (f = l, i = r.convert(i, f), d = r.find(o, [f, f]));
    var m = u.length > 0 ? t(d, 0, u, u[0], s, i, c) : [];
    return a.createDenseMatrix({
      data: m,
      size: Sr(u),
      datatype: f
    });
  };
  function t(n, a, i, o, c, s, u) {
    var l = [];
    if (a === i.length - 1)
      for (var f = 0; f < o; f++)
        l[f] = u ? n(s, c[f]) : n(c[f], s);
    else
      for (var d = 0; d < o; d++)
        l[d] = t(n, a + 1, i, i[a + 1], c[d], s, u);
    return l;
  }
}), Dw = "ceil", iTe = ["typed", "config", "round", "matrix", "equalScalar", "zeros", "DenseMatrix"], oTe = /* @__PURE__ */ Ce(Dw, ["typed", "config", "round"], (e) => {
  var {
    typed: r,
    config: t,
    round: n
  } = e;
  return r(Dw, {
    number: function(i) {
      return oi(i, n(i), t.relTol, t.absTol) ? n(i) : Math.ceil(i);
    },
    "number, number": function(i, o) {
      if (oi(i, n(i, o), t.relTol, t.absTol))
        return n(i, o);
      var [c, s] = "".concat(i, "e").split("e"), u = Math.ceil(Number("".concat(c, "e").concat(Number(s) + o)));
      return [c, s] = "".concat(u, "e").split("e"), Number("".concat(c, "e").concat(Number(s) - o));
    }
  });
}), uTe = /* @__PURE__ */ Ce(Dw, iTe, (e) => {
  var {
    typed: r,
    config: t,
    round: n,
    matrix: a,
    equalScalar: i,
    zeros: o,
    DenseMatrix: c
  } = e, s = li({
    typed: r,
    equalScalar: i
  }), u = Aa({
    typed: r,
    DenseMatrix: c
  }), l = xs({
    typed: r
  }), f = oTe({
    typed: r,
    config: t,
    round: n
  });
  return r("ceil", {
    number: f.signatures.number,
    "number,number": f.signatures["number,number"],
    Complex: function(m) {
      return m.ceil();
    },
    "Complex, number": function(m, p) {
      return m.ceil(p);
    },
    "Complex, BigNumber": function(m, p) {
      return m.ceil(p.toNumber());
    },
    BigNumber: function(m) {
      return To(m, n(m), t.relTol, t.absTol) ? n(m) : m.ceil();
    },
    "BigNumber, BigNumber": function(m, p) {
      return To(m, n(m, p), t.relTol, t.absTol) ? n(m, p) : m.toDecimalPlaces(p.toNumber(), kd.ROUND_CEIL);
    },
    Fraction: function(m) {
      return m.ceil();
    },
    "Fraction, number": function(m, p) {
      return m.ceil(p);
    },
    "Fraction, BigNumber": function(m, p) {
      return m.ceil(p.toNumber());
    },
    "Array | Matrix": r.referToSelf((d) => (m) => zr(m, d)),
    "Array, number | BigNumber": r.referToSelf((d) => (m, p) => zr(m, (v) => d(v, p))),
    "SparseMatrix, number | BigNumber": r.referToSelf((d) => (m, p) => s(m, p, d, !1)),
    "DenseMatrix, number | BigNumber": r.referToSelf((d) => (m, p) => l(m, p, d, !1)),
    "number | Complex | Fraction | BigNumber, Array": r.referToSelf((d) => (m, p) => l(a(p), m, d, !0).valueOf()),
    "number | Complex | Fraction | BigNumber, Matrix": r.referToSelf((d) => (m, p) => i(m, 0) ? o(p.size(), p.storage()) : p.storage() === "dense" ? l(p, m, d, !0) : u(p, m, d, !0))
  });
}), QR = "cube", sTe = ["typed"], lTe = /* @__PURE__ */ Ce(QR, sTe, (e) => {
  var {
    typed: r
  } = e;
  return r(QR, {
    number: fW,
    Complex: function(n) {
      return n.mul(n).mul(n);
    },
    BigNumber: function(n) {
      return n.times(n).times(n);
    },
    bigint: function(n) {
      return n * n * n;
    },
    Fraction: function(n) {
      return n.pow(3);
    },
    Unit: function(n) {
      return n.pow(3);
    }
  });
}), ZR = "exp", cTe = ["typed"], dTe = /* @__PURE__ */ Ce(ZR, cTe, (e) => {
  var {
    typed: r
  } = e;
  return r(ZR, {
    number: mW,
    Complex: function(n) {
      return n.exp();
    },
    BigNumber: function(n) {
      return n.exp();
    }
  });
}), JR = "expm1", fTe = ["typed", "Complex"], mTe = /* @__PURE__ */ Ce(JR, fTe, (e) => {
  var {
    typed: r,
    Complex: t
  } = e;
  return r(JR, {
    number: vW,
    Complex: function(a) {
      var i = Math.exp(a.re);
      return new t(i * Math.cos(a.im) - 1, i * Math.sin(a.im));
    },
    BigNumber: function(a) {
      return a.exp().minus(1);
    }
  });
}), Iw = "fix", vTe = ["typed", "Complex", "matrix", "ceil", "floor", "equalScalar", "zeros", "DenseMatrix"], pTe = /* @__PURE__ */ Ce(Iw, ["typed", "ceil", "floor"], (e) => {
  var {
    typed: r,
    ceil: t,
    floor: n
  } = e;
  return r(Iw, {
    number: function(i) {
      return i > 0 ? n(i) : t(i);
    },
    "number, number": function(i, o) {
      return i > 0 ? n(i, o) : t(i, o);
    }
  });
}), hTe = /* @__PURE__ */ Ce(Iw, vTe, (e) => {
  var {
    typed: r,
    Complex: t,
    matrix: n,
    ceil: a,
    floor: i,
    equalScalar: o,
    zeros: c,
    DenseMatrix: s
  } = e, u = Aa({
    typed: r,
    DenseMatrix: s
  }), l = xs({
    typed: r
  }), f = pTe({
    typed: r,
    ceil: a,
    floor: i
  });
  return r("fix", {
    number: f.signatures.number,
    "number, number | BigNumber": f.signatures["number,number"],
    Complex: function(m) {
      return new t(m.re > 0 ? Math.floor(m.re) : Math.ceil(m.re), m.im > 0 ? Math.floor(m.im) : Math.ceil(m.im));
    },
    "Complex, number": function(m, p) {
      return new t(m.re > 0 ? i(m.re, p) : a(m.re, p), m.im > 0 ? i(m.im, p) : a(m.im, p));
    },
    "Complex, BigNumber": function(m, p) {
      var v = p.toNumber();
      return new t(m.re > 0 ? i(m.re, v) : a(m.re, v), m.im > 0 ? i(m.im, v) : a(m.im, v));
    },
    BigNumber: function(m) {
      return m.isNegative() ? a(m) : i(m);
    },
    "BigNumber, number | BigNumber": function(m, p) {
      return m.isNegative() ? a(m, p) : i(m, p);
    },
    Fraction: function(m) {
      return m.s < 0 ? m.ceil() : m.floor();
    },
    "Fraction, number | BigNumber": function(m, p) {
      return m.s < 0 ? a(m, p) : i(m, p);
    },
    "Array | Matrix": r.referToSelf((d) => (m) => zr(m, d)),
    "Array | Matrix, number | BigNumber": r.referToSelf((d) => (m, p) => zr(m, (v) => d(v, p))),
    "number | Complex | Fraction | BigNumber, Array": r.referToSelf((d) => (m, p) => l(n(p), m, d, !0).valueOf()),
    "number | Complex | Fraction | BigNumber, Matrix": r.referToSelf((d) => (m, p) => o(m, 0) ? c(p.size(), p.storage()) : p.storage() === "dense" ? l(p, m, d, !0) : u(p, m, d, !0))
  });
}), Bw = "floor", gTe = ["typed", "config", "round", "matrix", "equalScalar", "zeros", "DenseMatrix"], yTe = /* @__PURE__ */ Ce(Bw, ["typed", "config", "round"], (e) => {
  var {
    typed: r,
    config: t,
    round: n
  } = e;
  return r(Bw, {
    number: function(i) {
      return oi(i, n(i), t.relTol, t.absTol) ? n(i) : Math.floor(i);
    },
    "number, number": function(i, o) {
      if (oi(i, n(i, o), t.relTol, t.absTol))
        return n(i, o);
      var [c, s] = "".concat(i, "e").split("e"), u = Math.floor(Number("".concat(c, "e").concat(Number(s) + o)));
      return [c, s] = "".concat(u, "e").split("e"), Number("".concat(c, "e").concat(Number(s) - o));
    }
  });
}), dX = /* @__PURE__ */ Ce(Bw, gTe, (e) => {
  var {
    typed: r,
    config: t,
    round: n,
    matrix: a,
    equalScalar: i,
    zeros: o,
    DenseMatrix: c
  } = e, s = li({
    typed: r,
    equalScalar: i
  }), u = Aa({
    typed: r,
    DenseMatrix: c
  }), l = xs({
    typed: r
  }), f = yTe({
    typed: r,
    config: t,
    round: n
  });
  return r("floor", {
    number: f.signatures.number,
    "number,number": f.signatures["number,number"],
    Complex: function(m) {
      return m.floor();
    },
    "Complex, number": function(m, p) {
      return m.floor(p);
    },
    "Complex, BigNumber": function(m, p) {
      return m.floor(p.toNumber());
    },
    BigNumber: function(m) {
      return To(m, n(m), t.relTol, t.absTol) ? n(m) : m.floor();
    },
    "BigNumber, BigNumber": function(m, p) {
      return To(m, n(m, p), t.relTol, t.absTol) ? n(m, p) : m.toDecimalPlaces(p.toNumber(), kd.ROUND_FLOOR);
    },
    Fraction: function(m) {
      return m.floor();
    },
    "Fraction, number": function(m, p) {
      return m.floor(p);
    },
    "Fraction, BigNumber": function(m, p) {
      return m.floor(p.toNumber());
    },
    "Array | Matrix": r.referToSelf((d) => (m) => zr(m, d)),
    "Array, number | BigNumber": r.referToSelf((d) => (m, p) => zr(m, (v) => d(v, p))),
    "SparseMatrix, number | BigNumber": r.referToSelf((d) => (m, p) => s(m, p, d, !1)),
    "DenseMatrix, number | BigNumber": r.referToSelf((d) => (m, p) => l(m, p, d, !1)),
    "number | Complex | Fraction | BigNumber, Array": r.referToSelf((d) => (m, p) => l(a(p), m, d, !0).valueOf()),
    "number | Complex | Fraction | BigNumber, Matrix": r.referToSelf((d) => (m, p) => i(m, 0) ? o(p.size(), p.storage()) : p.storage() === "dense" ? l(p, m, d, !0) : u(p, m, d, !0))
  });
}), _Te = "matAlgo02xDS0", bTe = ["typed", "equalScalar"], Ts = /* @__PURE__ */ Ce(_Te, bTe, (e) => {
  var {
    typed: r,
    equalScalar: t
  } = e;
  return function(a, i, o, c) {
    var s = a._data, u = a._size, l = a._datatype || a.getDataType(), f = i._values, d = i._index, m = i._ptr, p = i._size, v = i._datatype || i._data === void 0 ? i._datatype : i.getDataType();
    if (u.length !== p.length)
      throw new kr(u.length, p.length);
    if (u[0] !== p[0] || u[1] !== p[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + u + ") must match Matrix B (" + p + ")");
    if (!f)
      throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");
    var h = u[0], y = u[1], C, S = t, b = 0, g = o;
    typeof l == "string" && l === v && l !== "mixed" && (C = l, S = r.find(t, [C, C]), b = r.convert(0, C), g = r.find(o, [C, C]));
    for (var _ = [], A = [], M = [], P = 0; P < y; P++) {
      M[P] = A.length;
      for (var T = m[P], x = m[P + 1], w = T; w < x; w++) {
        var E = d[w], I = c ? g(f[w], s[E][P]) : g(s[E][P], f[w]);
        S(I, b) || (A.push(E), _.push(I));
      }
    }
    return M[y] = A.length, i.createSparseMatrix({
      values: _,
      index: A,
      ptr: M,
      size: [h, y],
      datatype: l === a._datatype && v === i._datatype ? C : void 0
    });
  };
}), STe = "matAlgo03xDSf", CTe = ["typed"], Zi = /* @__PURE__ */ Ce(STe, CTe, (e) => {
  var {
    typed: r
  } = e;
  return function(n, a, i, o) {
    var c = n._data, s = n._size, u = n._datatype || n.getDataType(), l = a._values, f = a._index, d = a._ptr, m = a._size, p = a._datatype || a._data === void 0 ? a._datatype : a.getDataType();
    if (s.length !== m.length)
      throw new kr(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 v = s[0], h = s[1], y, C = 0, S = i;
    typeof u == "string" && u === p && u !== "mixed" && (y = u, C = r.convert(0, y), S = r.find(i, [y, y]));
    for (var b = [], g = 0; g < v; g++)
      b[g] = [];
    for (var _ = [], A = [], M = 0; M < h; M++) {
      for (var P = M + 1, T = d[M], x = d[M + 1], w = T; w < x; w++) {
        var E = f[w];
        _[E] = o ? S(l[w], c[E][M]) : S(c[E][M], l[w]), A[E] = P;
      }
      for (var I = 0; I < v; I++)
        A[I] === P ? b[I][M] = _[I] : b[I][M] = o ? S(C, c[I][M]) : S(c[I][M], C);
    }
    return n.createDenseMatrix({
      data: b,
      size: [v, h],
      datatype: u === n._datatype && p === a._datatype ? y : void 0
    });
  };
}), ATe = "matAlgo05xSfSf", xTe = ["typed", "equalScalar"], lx = /* @__PURE__ */ Ce(ATe, xTe, (e) => {
  var {
    typed: r,
    equalScalar: t
  } = e;
  return function(a, i, o) {
    var c = a._values, s = a._index, u = a._ptr, l = a._size, f = a._datatype || a._data === void 0 ? a._datatype : a.getDataType(), d = i._values, m = i._index, p = i._ptr, v = i._size, h = i._datatype || i._data === void 0 ? i._datatype : i.getDataType();
    if (l.length !== v.length)
      throw new kr(l.length, v.length);
    if (l[0] !== v[0] || l[1] !== v[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + l + ") must match Matrix B (" + v + ")");
    var y = l[0], C = l[1], S, b = t, g = 0, _ = o;
    typeof f == "string" && f === h && f !== "mixed" && (S = f, b = r.find(t, [S, S]), g = r.convert(0, S), _ = r.find(o, [S, S]));
    var A = c && d ? [] : void 0, M = [], P = [], T = A ? [] : void 0, x = A ? [] : void 0, w = [], E = [], I, B, D, N;
    for (B = 0; B < C; B++) {
      P[B] = M.length;
      var O = B + 1;
      for (D = u[B], N = u[B + 1]; D < N; D++)
        I = s[D], M.push(I), w[I] = O, T && (T[I] = c[D]);
      for (D = p[B], N = p[B + 1]; D < N; D++)
        I = m[D], w[I] !== O && M.push(I), E[I] = O, x && (x[I] = d[D]);
      if (A)
        for (D = P[B]; D < M.length; ) {
          I = M[D];
          var V = w[I], k = E[I];
          if (V === O || k === O) {
            var G = V === O ? T[I] : g, L = k === O ? x[I] : g, R = _(G, L);
            b(R, g) ? M.splice(D, 1) : (A.push(R), D++);
          }
        }
    }
    return P[C] = M.length, a.createSparseMatrix({
      values: A,
      index: M,
      ptr: P,
      size: [y, C],
      datatype: f === a._datatype && h === i._datatype ? S : void 0
    });
  };
}), TTe = "matAlgo13xDD", PTe = ["typed"], MTe = /* @__PURE__ */ Ce(TTe, PTe, (e) => {
  var {
    typed: r
  } = e;
  return function(a, i, o) {
    var c = a._data, s = a._size, u = a._datatype, l = i._data, f = i._size, d = i._datatype, m = [];
    if (s.length !== f.length)
      throw new kr(s.length, f.length);
    for (var p = 0; p < s.length; p++) {
      if (s[p] !== f[p])
        throw new RangeError("Dimension mismatch. Matrix A (" + s + ") must match Matrix B (" + f + ")");
      m[p] = s[p];
    }
    var v, h = o;
    typeof u == "string" && u === d && (v = u, h = r.find(o, [v, v]));
    var y = m.length > 0 ? t(h, 0, m, m[0], c, l) : [];
    return a.createDenseMatrix({
      data: y,
      size: m,
      datatype: v
    });
  };
  function t(n, a, i, o, c, s) {
    var u = [];
    if (a === i.length - 1)
      for (var l = 0; l < o; l++)
        u[l] = n(c[l], s[l]);
    else
      for (var f = 0; f < o; f++)
        u[f] = t(n, a + 1, i, i[a + 1], c[f], s[f]);
    return u;
  }
});
function Ea(e, r) {
  if (gc(e.size(), r.size()))
    return [e, r];
  var t = eW(e.size(), r.size());
  return [e, r].map((n) => wTe(n, t));
}
function wTe(e, r) {
  return gc(e.size(), r) ? e : e.create(Tw(e.valueOf(), r), e.datatype());
}
var ETe = "matrixAlgorithmSuite", DTe = ["typed", "matrix"], kt = /* @__PURE__ */ Ce(ETe, DTe, (e) => {
  var {
    typed: r,
    matrix: t
  } = e, n = MTe({
    typed: r
  }), a = xs({
    typed: r
  });
  return function(o) {
    var c = o.elop, s = o.SD || o.DS, u;
    c ? (u = {
      "DenseMatrix, DenseMatrix": (m, p) => n(...Ea(m, p), c),
      "Array, Array": (m, p) => n(...Ea(t(m), t(p)), c).valueOf(),
      "Array, DenseMatrix": (m, p) => n(...Ea(t(m), p), c),
      "DenseMatrix, Array": (m, p) => n(...Ea(m, t(p)), c)
    }, o.SS && (u["SparseMatrix, SparseMatrix"] = (m, p) => o.SS(...Ea(m, p), c, !1)), o.DS && (u["DenseMatrix, SparseMatrix"] = (m, p) => o.DS(...Ea(m, p), c, !1), u["Array, SparseMatrix"] = (m, p) => o.DS(...Ea(t(m), p), c, !1)), s && (u["SparseMatrix, DenseMatrix"] = (m, p) => s(...Ea(p, m), c, !0), u["SparseMatrix, Array"] = (m, p) => s(...Ea(t(p), m), c, !0))) : (u = {
      "DenseMatrix, DenseMatrix": r.referToSelf((m) => (p, v) => n(...Ea(p, v), m)),
      "Array, Array": r.referToSelf((m) => (p, v) => n(...Ea(t(p), t(v)), m).valueOf()),
      "Array, DenseMatrix": r.referToSelf((m) => (p, v) => n(...Ea(t(p), v), m)),
      "DenseMatrix, Array": r.referToSelf((m) => (p, v) => n(...Ea(p, t(v)), m))
    }, o.SS && (u["SparseMatrix, SparseMatrix"] = r.referToSelf((m) => (p, v) => o.SS(...Ea(p, v), m, !1))), o.DS && (u["DenseMatrix, SparseMatrix"] = r.referToSelf((m) => (p, v) => o.DS(...Ea(p, v), m, !1)), u["Array, SparseMatrix"] = r.referToSelf((m) => (p, v) => o.DS(...Ea(t(p), v), m, !1))), s && (u["SparseMatrix, DenseMatrix"] = r.referToSelf((m) => (p, v) => s(...Ea(v, p), m, !0)), u["SparseMatrix, Array"] = r.referToSelf((m) => (p, v) => s(...Ea(t(v), p), m, !0))));
    var l = o.scalar || "any", f = o.Ds || o.Ss;
    f && (c ? (u["DenseMatrix," + l] = (m, p) => a(m, p, c, !1), u[l + ", DenseMatrix"] = (m, p) => a(p, m, c, !0), u["Array," + l] = (m, p) => a(t(m), p, c, !1).valueOf(), u[l + ", Array"] = (m, p) => a(t(p), m, c, !0).valueOf()) : (u["DenseMatrix," + l] = r.referToSelf((m) => (p, v) => a(p, v, m, !1)), u[l + ", DenseMatrix"] = r.referToSelf((m) => (p, v) => a(v, p, m, !0)), u["Array," + l] = r.referToSelf((m) => (p, v) => a(t(p), v, m, !1).valueOf()), u[l + ", Array"] = r.referToSelf((m) => (p, v) => a(t(v), p, m, !0).valueOf())));
    var d = o.sS !== void 0 ? o.sS : o.Ss;
    return c ? (o.Ss && (u["SparseMatrix," + l] = (m, p) => o.Ss(m, p, c, !1)), d && (u[l + ", SparseMatrix"] = (m, p) => d(p, m, c, !0))) : (o.Ss && (u["SparseMatrix," + l] = r.referToSelf((m) => (p, v) => o.Ss(p, v, m, !1))), d && (u[l + ", SparseMatrix"] = r.referToSelf((m) => (p, v) => d(v, p, m, !0)))), c && c.signatures && vK(u, c.signatures), u;
  };
}), eO = "mod", ITe = ["typed", "config", "round", "matrix", "equalScalar", "zeros", "DenseMatrix", "concat"], fX = /* @__PURE__ */ Ce(eO, ITe, (e) => {
  var {
    typed: r,
    config: t,
    round: n,
    matrix: a,
    equalScalar: i,
    zeros: o,
    DenseMatrix: c,
    concat: s
  } = e, u = dX({
    typed: r,
    config: t,
    round: n,
    matrix: a,
    equalScalar: i,
    zeros: o,
    DenseMatrix: c
  }), l = Ts({
    typed: r,
    equalScalar: i
  }), f = Zi({
    typed: r
  }), d = lx({
    typed: r,
    equalScalar: i
  }), m = li({
    typed: r,
    equalScalar: i
  }), p = Aa({
    typed: r,
    DenseMatrix: c
  }), v = kt({
    typed: r,
    matrix: a,
    concat: s
  });
  return r(eO, {
    "number, number": h,
    "BigNumber, BigNumber": function(C, S) {
      return S.isZero() ? C : C.sub(S.mul(u(C.div(S))));
    },
    "bigint, bigint": function(C, S) {
      if (S === 0n)
        return C;
      if (C < 0) {
        var b = C % S;
        return b === 0n ? b : b + S;
      }
      return C % S;
    },
    "Fraction, Fraction": function(C, S) {
      return S.equals(0) ? C : C.sub(S.mul(u(C.div(S))));
    }
  }, v({
    SS: d,
    DS: f,
    SD: l,
    Ss: m,
    sS: p
  }));
  function h(y, C) {
    return C === 0 ? y : y - C * u(y / C);
  }
}), BTe = "matAlgo01xDSid", NTe = ["typed"], nf = /* @__PURE__ */ Ce(BTe, NTe, (e) => {
  var {
    typed: r
  } = e;
  return function(n, a, i, o) {
    var c = n._data, s = n._size, u = n._datatype || n.getDataType(), l = a._values, f = a._index, d = a._ptr, m = a._size, p = a._datatype || a._data === void 0 ? a._datatype : a.getDataType();
    if (s.length !== m.length)
      throw new kr(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 v = s[0], h = s[1], y = typeof u == "string" && u !== "mixed" && u === p ? u : void 0, C = y ? r.find(i, [y, y]) : i, S, b, g = [];
    for (S = 0; S < v; S++)
      g[S] = [];
    var _ = [], A = [];
    for (b = 0; b < h; b++) {
      for (var M = b + 1, P = d[b], T = d[b + 1], x = P; x < T; x++)
        S = f[x], _[S] = o ? C(l[x], c[S][b]) : C(c[S][b], l[x]), A[S] = M;
      for (S = 0; S < v; S++)
        A[S] === M ? g[S][b] = _[S] : g[S][b] = c[S][b];
    }
    return n.createDenseMatrix({
      data: g,
      size: [v, h],
      datatype: u === n._datatype && p === a._datatype ? y : void 0
    });
  };
}), VTe = "matAlgo04xSidSid", RTe = ["typed", "equalScalar"], DD = /* @__PURE__ */ Ce(VTe, RTe, (e) => {
  var {
    typed: r,
    equalScalar: t
  } = e;
  return function(a, i, o) {
    var c = a._values, s = a._index, u = a._ptr, l = a._size, f = a._datatype || a._data === void 0 ? a._datatype : a.getDataType(), d = i._values, m = i._index, p = i._ptr, v = i._size, h = i._datatype || i._data === void 0 ? i._datatype : i.getDataType();
    if (l.length !== v.length)
      throw new kr(l.length, v.length);
    if (l[0] !== v[0] || l[1] !== v[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + l + ") must match Matrix B (" + v + ")");
    var y = l[0], C = l[1], S, b = t, g = 0, _ = o;
    typeof f == "string" && f === h && f !== "mixed" && (S = f, b = r.find(t, [S, S]), g = r.convert(0, S), _ = r.find(o, [S, S]));
    var A = c && d ? [] : void 0, M = [], P = [], T = c && d ? [] : void 0, x = c && d ? [] : void 0, w = [], E = [], I, B, D, N, O;
    for (B = 0; B < C; B++) {
      P[B] = M.length;
      var V = B + 1;
      for (N = u[B], O = u[B + 1], D = N; D < O; D++)
        I = s[D], M.push(I), w[I] = V, T && (T[I] = c[D]);
      for (N = p[B], O = p[B + 1], D = N; D < O; D++)
        if (I = m[D], w[I] === V) {
          if (T) {
            var k = _(T[I], d[D]);
            b(k, g) ? w[I] = null : T[I] = k;
          }
        } else
          M.push(I), E[I] = V, x && (x[I] = d[D]);
      if (T && x)
        for (D = P[B]; D < M.length; )
          I = M[D], w[I] === V ? (A[D] = T[I], D++) : E[I] === V ? (A[D] = x[I], D++) : M.splice(D, 1);
    }
    return P[C] = M.length, a.createSparseMatrix({
      values: A,
      index: M,
      ptr: P,
      size: [y, C],
      datatype: f === a._datatype && h === i._datatype ? S : void 0
    });
  };
}), OTe = "matAlgo10xSids", FTe = ["typed", "DenseMatrix"], rm = /* @__PURE__ */ Ce(OTe, FTe, (e) => {
  var {
    typed: r,
    DenseMatrix: t
  } = e;
  return function(a, i, o, c) {
    var s = a._values, u = a._index, l = a._ptr, f = a._size, d = a._datatype;
    if (!s)
      throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");
    var m = f[0], p = f[1], v, h = o;
    typeof d == "string" && (v = d, i = r.convert(i, v), h = r.find(o, [v, v]));
    for (var y = [], C = [], S = [], b = 0; b < p; b++) {
      for (var g = b + 1, _ = l[b], A = l[b + 1], M = _; M < A; M++) {
        var P = u[M];
        C[P] = s[M], S[P] = g;
      }
      for (var T = 0; T < m; T++)
        b === 0 && (y[T] = []), S[T] === g ? y[T][b] = c ? h(i, C[T]) : h(C[T], i) : y[T][b] = i;
    }
    return new t({
      data: y,
      size: [m, p],
      datatype: v
    });
  };
});
function Ic(e, r, t, n) {
  if (!(this instanceof Ic))
    throw new SyntaxError("Constructor must be called with the new operator");
  this.fn = e, this.count = r, this.min = t, this.max = n, this.message = "Wrong number of arguments in function " + e + " (" + r + " provided, " + t + (n != null ? "-" + n : "") + " expected)", this.stack = new Error().stack;
}
Ic.prototype = new Error();
Ic.prototype.constructor = Error;
Ic.prototype.name = "ArgumentsError";
Ic.prototype.isArgumentsError = !0;
var rO = "gcd", LTe = ["typed", "config", "round", "matrix", "equalScalar", "zeros", "BigNumber", "DenseMatrix", "concat"], xP = "number | BigNumber | Fraction | Matrix | Array", kTe = "".concat(xP, ", ").concat(xP, ", ...").concat(xP);
function tO(e) {
  return !e.some((r) => Array.isArray(r));
}
var UTe = /* @__PURE__ */ Ce(rO, LTe, (e) => {
  var {
    typed: r,
    matrix: t,
    config: n,
    round: a,
    equalScalar: i,
    zeros: o,
    BigNumber: c,
    DenseMatrix: s,
    concat: u
  } = e, l = fX({
    typed: r,
    config: n,
    round: a,
    matrix: t,
    equalScalar: i,
    zeros: o,
    DenseMatrix: s,
    concat: u
  }), f = nf({
    typed: r
  }), d = DD({
    typed: r,
    equalScalar: i
  }), m = rm({
    typed: r,
    DenseMatrix: s
  }), p = kt({
    typed: r,
    matrix: t,
    concat: u
  });
  return r(rO, {
    "number, number": v,
    "BigNumber, BigNumber": h,
    "Fraction, Fraction": (y, C) => y.gcd(C)
  }, p({
    SS: d,
    DS: f,
    Ss: m
  }), {
    [kTe]: r.referToSelf((y) => (C, S, b) => {
      for (var g = y(C, S), _ = 0; _ < b.length; _++)
        g = y(g, b[_]);
      return g;
    }),
    Array: r.referToSelf((y) => (C) => {
      if (C.length === 1 && Array.isArray(C[0]) && tO(C[0]))
        return y(...C[0]);
      if (tO(C))
        return y(...C);
      throw new Ic("gcd() supports only 1d matrices!");
    }),
    Matrix: r.referToSelf((y) => (C) => y(C.toArray()))
  });
  function v(y, C) {
    if (!lr(y) || !lr(C))
      throw new Error("Parameters in function gcd must be integer numbers");
    for (var S; C !== 0; )
      S = l(y, C), y = C, C = S;
    return y < 0 ? -y : y;
  }
  function h(y, C) {
    if (!y.isInt() || !C.isInt())
      throw new Error("Parameters in function gcd must be integer numbers");
    for (var S = new c(0); !C.isZero(); ) {
      var b = l(y, C);
      y = C, C = b;
    }
    return y.lt(S) ? y.neg() : y;
  }
}), zTe = "matAlgo06xS0S0", GTe = ["typed", "equalScalar"], cx = /* @__PURE__ */ Ce(zTe, GTe, (e) => {
  var {
    typed: r,
    equalScalar: t
  } = e;
  return function(a, i, o) {
    var c = a._values, s = a._size, u = a._datatype || a._data === void 0 ? a._datatype : a.getDataType(), l = i._values, f = i._size, d = i._datatype || i._data === void 0 ? i._datatype : i.getDataType();
    if (s.length !== f.length)
      throw new kr(s.length, f.length);
    if (s[0] !== f[0] || s[1] !== f[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + s + ") must match Matrix B (" + f + ")");
    var m = s[0], p = s[1], v, h = t, y = 0, C = o;
    typeof u == "string" && u === d && u !== "mixed" && (v = u, h = r.find(t, [v, v]), y = r.convert(0, v), C = r.find(o, [v, v]));
    for (var S = c && l ? [] : void 0, b = [], g = [], _ = S ? [] : void 0, A = [], M = [], P = 0; P < p; P++) {
      g[P] = b.length;
      var T = P + 1;
      if (PR(a, P, A, _, M, T, b, C), PR(i, P, A, _, M, T, b, C), _)
        for (var x = g[P]; x < b.length; ) {
          var w = b[x];
          if (M[w] === T) {
            var E = _[w];
            h(E, y) ? b.splice(x, 1) : (S.push(E), x++);
          } else
            b.splice(x, 1);
        }
      else
        for (var I = g[P]; I < b.length; ) {
          var B = b[I];
          M[B] !== T ? b.splice(I, 1) : I++;
        }
    }
    return g[p] = b.length, a.createSparseMatrix({
      values: S,
      index: b,
      ptr: g,
      size: [m, p],
      datatype: u === a._datatype && d === i._datatype ? v : void 0
    });
  };
}), nO = "lcm", qTe = ["typed", "matrix", "equalScalar", "concat"], HTe = /* @__PURE__ */ Ce(nO, qTe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    concat: a
  } = e, i = Ts({
    typed: r,
    equalScalar: n
  }), o = cx({
    typed: r,
    equalScalar: n
  }), c = li({
    typed: r,
    equalScalar: n
  }), s = kt({
    typed: r,
    matrix: t,
    concat: a
  }), u = "number | BigNumber | Fraction | Matrix | Array", l = {};
  return l["".concat(u, ", ").concat(u, ", ...").concat(u)] = r.referToSelf((d) => (m, p, v) => {
    for (var h = d(m, p), y = 0; y < v.length; y++)
      h = d(h, v[y]);
    return h;
  }), r(nO, {
    "number, number": pW,
    "BigNumber, BigNumber": f,
    "Fraction, Fraction": (d, m) => d.lcm(m)
  }, s({
    SS: o,
    DS: i,
    Ss: c
  }), l);
  function f(d, m) {
    if (!d.isInt() || !m.isInt())
      throw new Error("Parameters in function lcm must be integer numbers");
    if (d.isZero())
      return d;
    if (m.isZero())
      return m;
    for (var p = d.times(m); !m.isZero(); ) {
      var v = m;
      m = d.mod(v), d = v;
    }
    return p.div(d).abs();
  }
}), aO = "log10", jTe = ["typed", "config", "Complex"], $Te = /* @__PURE__ */ Ce(aO, jTe, (e) => {
  var {
    typed: r,
    config: t,
    Complex: n
  } = e;
  return r(aO, {
    number: function(i) {
      return i >= 0 || t.predictable ? hW(i) : new n(i, 0).log().div(Math.LN10);
    },
    Complex: function(i) {
      return new n(i).log().div(Math.LN10);
    },
    BigNumber: function(i) {
      return !i.isNegative() || t.predictable ? i.log() : new n(i.toNumber(), 0).log().div(Math.LN10);
    },
    "Array | Matrix": r.referToSelf((a) => (i) => zr(i, a))
  });
}), iO = "log2", KTe = ["typed", "config", "Complex"], WTe = /* @__PURE__ */ Ce(iO, KTe, (e) => {
  var {
    typed: r,
    config: t,
    Complex: n
  } = e;
  return r(iO, {
    number: function(o) {
      return o >= 0 || t.predictable ? gW(o) : a(new n(o, 0));
    },
    Complex: a,
    BigNumber: function(o) {
      return !o.isNegative() || t.predictable ? o.log(2) : a(new n(o.toNumber(), 0));
    },
    "Array | Matrix": r.referToSelf((i) => (o) => zr(o, i))
  });
  function a(i) {
    var o = Math.sqrt(i.re * i.re + i.im * i.im);
    return new n(Math.log2 ? Math.log2(o) : Math.log(o) / Math.LN2, Math.atan2(i.im, i.re) / Math.LN2);
  }
}), XTe = "multiplyScalar", YTe = ["typed"], mX = /* @__PURE__ */ Ce(XTe, YTe, (e) => {
  var {
    typed: r
  } = e;
  return r("multiplyScalar", {
    "number, number": lW,
    "Complex, Complex": function(n, a) {
      return n.mul(a);
    },
    "BigNumber, BigNumber": function(n, a) {
      return n.times(a);
    },
    "bigint, bigint": function(n, a) {
      return n * a;
    },
    "Fraction, Fraction": function(n, a) {
      return n.mul(a);
    },
    "number | Fraction | BigNumber | Complex, Unit": (t, n) => n.multiply(t),
    "Unit, number | Fraction | BigNumber | Complex | Unit": (t, n) => t.multiply(n)
  });
}), oO = "multiply", QTe = ["typed", "matrix", "addScalar", "multiplyScalar", "equalScalar", "dot"], vX = /* @__PURE__ */ Ce(oO, QTe, (e) => {
  var {
    typed: r,
    matrix: t,
    addScalar: n,
    multiplyScalar: a,
    equalScalar: i,
    dot: o
  } = e, c = li({
    typed: r,
    equalScalar: i
  }), s = xs({
    typed: r
  });
  function u(g, _) {
    switch (g.length) {
      case 1:
        switch (_.length) {
          case 1:
            if (g[0] !== _[0])
              throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");
            break;
          case 2:
            if (g[0] !== _[0])
              throw new RangeError("Dimension mismatch in multiplication. Vector length (" + g[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 (g[1] !== _[0])
              throw new RangeError("Dimension mismatch in multiplication. Matrix columns (" + g[1] + ") must match Vector length (" + _[0] + ")");
            break;
          case 2:
            if (g[1] !== _[0])
              throw new RangeError("Dimension mismatch in multiplication. Matrix A columns (" + g[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 " + g.length + " dimensions)");
    }
  }
  function l(g, _, A) {
    if (A === 0)
      throw new Error("Cannot multiply two empty vectors");
    return o(g, _);
  }
  function f(g, _) {
    if (_.storage() !== "dense")
      throw new Error("Support for SparseMatrix not implemented");
    return d(g, _);
  }
  function d(g, _) {
    var A = g._data, M = g._size, P = g._datatype || g.getDataType(), T = _._data, x = _._size, w = _._datatype || _.getDataType(), E = M[0], I = x[1], B, D = n, N = a;
    P && w && P === w && typeof P == "string" && P !== "mixed" && (B = P, D = r.find(n, [B, B]), N = r.find(a, [B, B]));
    for (var O = [], V = 0; V < I; V++) {
      for (var k = N(A[0], T[0][V]), G = 1; G < E; G++)
        k = D(k, N(A[G], T[G][V]));
      O[V] = k;
    }
    return g.createDenseMatrix({
      data: O,
      size: [I],
      datatype: P === g._datatype && w === _._datatype ? B : void 0
    });
  }
  var m = r("_multiplyMatrixVector", {
    "DenseMatrix, any": v,
    "SparseMatrix, any": C
  }), p = r("_multiplyMatrixMatrix", {
    "DenseMatrix, DenseMatrix": h,
    "DenseMatrix, SparseMatrix": y,
    "SparseMatrix, DenseMatrix": S,
    "SparseMatrix, SparseMatrix": b
  });
  function v(g, _) {
    var A = g._data, M = g._size, P = g._datatype || g.getDataType(), T = _._data, x = _._datatype || _.getDataType(), w = M[0], E = M[1], I, B = n, D = a;
    P && x && P === x && typeof P == "string" && P !== "mixed" && (I = P, B = r.find(n, [I, I]), D = r.find(a, [I, I]));
    for (var N = [], O = 0; O < w; O++) {
      for (var V = A[O], k = D(V[0], T[0]), G = 1; G < E; G++)
        k = B(k, D(V[G], T[G]));
      N[O] = k;
    }
    return g.createDenseMatrix({
      data: N,
      size: [w],
      datatype: P === g._datatype && x === _._datatype ? I : void 0
    });
  }
  function h(g, _) {
    var A = g._data, M = g._size, P = g._datatype || g.getDataType(), T = _._data, x = _._size, w = _._datatype || _.getDataType(), E = M[0], I = M[1], B = x[1], D, N = n, O = a;
    P && w && P === w && typeof P == "string" && P !== "mixed" && P !== "mixed" && (D = P, N = r.find(n, [D, D]), O = r.find(a, [D, D]));
    for (var V = [], k = 0; k < E; k++) {
      var G = A[k];
      V[k] = [];
      for (var L = 0; L < B; L++) {
        for (var R = O(G[0], T[0][L]), F = 1; F < I; F++)
          R = N(R, O(G[F], T[F][L]));
        V[k][L] = R;
      }
    }
    return g.createDenseMatrix({
      data: V,
      size: [E, B],
      datatype: P === g._datatype && w === _._datatype ? D : void 0
    });
  }
  function y(g, _) {
    var A = g._data, M = g._size, P = g._datatype || g.getDataType(), T = _._values, x = _._index, w = _._ptr, E = _._size, I = _._datatype || _._data === void 0 ? _._datatype : _.getDataType();
    if (!T)
      throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");
    var B = M[0], D = E[1], N, O = n, V = a, k = i, G = 0;
    P && I && P === I && typeof P == "string" && P !== "mixed" && (N = P, O = r.find(n, [N, N]), V = r.find(a, [N, N]), k = r.find(i, [N, N]), G = r.convert(0, N));
    for (var L = [], R = [], F = [], U = _.createSparseMatrix({
      values: L,
      index: R,
      ptr: F,
      size: [B, D],
      datatype: P === g._datatype && I === _._datatype ? N : void 0
    }), H = 0; H < D; H++) {
      F[H] = R.length;
      var q = w[H], K = w[H + 1];
      if (K > q)
        for (var Y = 0, X = 0; X < B; X++) {
          for (var Z = X + 1, J = void 0, $ = q; $ < K; $++) {
            var Q = x[$];
            Y !== Z ? (J = V(A[X][Q], T[$]), Y = Z) : J = O(J, V(A[X][Q], T[$]));
          }
          Y === Z && !k(J, G) && (R.push(X), L.push(J));
        }
    }
    return F[D] = R.length, U;
  }
  function C(g, _) {
    var A = g._values, M = g._index, P = g._ptr, T = g._datatype || g._data === void 0 ? g._datatype : g.getDataType();
    if (!A)
      throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");
    var x = _._data, w = _._datatype || _.getDataType(), E = g._size[0], I = _._size[0], B = [], D = [], N = [], O, V = n, k = a, G = i, L = 0;
    T && w && T === w && typeof T == "string" && T !== "mixed" && (O = T, V = r.find(n, [O, O]), k = r.find(a, [O, O]), G = r.find(i, [O, O]), L = r.convert(0, O));
    var R = [], F = [];
    N[0] = 0;
    for (var U = 0; U < I; U++) {
      var H = x[U];
      if (!G(H, L))
        for (var q = P[U], K = P[U + 1], Y = q; Y < K; Y++) {
          var X = M[Y];
          F[X] ? R[X] = V(R[X], k(H, A[Y])) : (F[X] = !0, D.push(X), R[X] = k(H, A[Y]));
        }
    }
    for (var Z = D.length, J = 0; J < Z; J++) {
      var $ = D[J];
      B[J] = R[$];
    }
    return N[1] = D.length, g.createSparseMatrix({
      values: B,
      index: D,
      ptr: N,
      size: [E, 1],
      datatype: T === g._datatype && w === _._datatype ? O : void 0
    });
  }
  function S(g, _) {
    var A = g._values, M = g._index, P = g._ptr, T = g._datatype || g._data === void 0 ? g._datatype : g.getDataType();
    if (!A)
      throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");
    var x = _._data, w = _._datatype || _.getDataType(), E = g._size[0], I = _._size[0], B = _._size[1], D, N = n, O = a, V = i, k = 0;
    T && w && T === w && typeof T == "string" && T !== "mixed" && (D = T, N = r.find(n, [D, D]), O = r.find(a, [D, D]), V = r.find(i, [D, D]), k = r.convert(0, D));
    for (var G = [], L = [], R = [], F = g.createSparseMatrix({
      values: G,
      index: L,
      ptr: R,
      size: [E, B],
      datatype: T === g._datatype && w === _._datatype ? D : void 0
    }), U = [], H = [], q = 0; q < B; q++) {
      R[q] = L.length;
      for (var K = q + 1, Y = 0; Y < I; Y++) {
        var X = x[Y][q];
        if (!V(X, k))
          for (var Z = P[Y], J = P[Y + 1], $ = Z; $ < J; $++) {
            var Q = M[$];
            H[Q] !== K ? (H[Q] = K, L.push(Q), U[Q] = O(X, A[$])) : U[Q] = N(U[Q], O(X, A[$]));
          }
      }
      for (var W = R[q], te = L.length, oe = W; oe < te; oe++) {
        var z = L[oe];
        G[oe] = U[z];
      }
    }
    return R[B] = L.length, F;
  }
  function b(g, _) {
    var A = g._values, M = g._index, P = g._ptr, T = g._datatype || g._data === void 0 ? g._datatype : g.getDataType(), x = _._values, w = _._index, E = _._ptr, I = _._datatype || _._data === void 0 ? _._datatype : _.getDataType(), B = g._size[0], D = _._size[1], N = A && x, O, V = n, k = a;
    T && I && T === I && typeof T == "string" && T !== "mixed" && (O = T, V = r.find(n, [O, O]), k = r.find(a, [O, O]));
    for (var G = N ? [] : void 0, L = [], R = [], F = g.createSparseMatrix({
      values: G,
      index: L,
      ptr: R,
      size: [B, D],
      datatype: T === g._datatype && I === _._datatype ? O : void 0
    }), U = N ? [] : void 0, H = [], q, K, Y, X, Z, J, $, Q, W = 0; W < D; W++) {
      R[W] = L.length;
      var te = W + 1;
      for (Z = E[W], J = E[W + 1], X = Z; X < J; X++)
        if (Q = w[X], N)
          for (K = P[Q], Y = P[Q + 1], q = K; q < Y; q++)
            $ = M[q], H[$] !== te ? (H[$] = te, L.push($), U[$] = k(x[X], A[q])) : U[$] = V(U[$], k(x[X], A[q]));
        else
          for (K = P[Q], Y = P[Q + 1], q = K; q < Y; q++)
            $ = M[q], H[$] !== te && (H[$] = te, L.push($));
      if (N)
        for (var oe = R[W], z = L.length, j = oe; j < z; j++) {
          var ae = L[j];
          G[j] = U[ae];
        }
    }
    return R[D] = L.length, F;
  }
  return r(oO, a, {
    // we extend the signatures of multiplyScalar with signatures dealing with matrices
    "Array, Array": r.referTo("Matrix, Matrix", (g) => (_, A) => {
      u(Fr(_), Fr(A));
      var M = g(t(_), t(A));
      return gr(M) ? M.valueOf() : M;
    }),
    "Matrix, Matrix": function(_, A) {
      var M = _.size(), P = A.size();
      return u(M, P), M.length === 1 ? P.length === 1 ? l(_, A, M[0]) : f(_, A) : P.length === 1 ? m(_, A) : p(_, A);
    },
    "Matrix, Array": r.referTo("Matrix,Matrix", (g) => (_, A) => g(_, t(A))),
    "Array, Matrix": r.referToSelf((g) => (_, A) => g(t(_, A.storage()), A)),
    "SparseMatrix, any": function(_, A) {
      return c(_, A, a, !1);
    },
    "DenseMatrix, any": function(_, A) {
      return s(_, A, a, !1);
    },
    "any, SparseMatrix": function(_, A) {
      return c(A, _, a, !0);
    },
    "any, DenseMatrix": function(_, A) {
      return s(A, _, a, !0);
    },
    "Array, any": function(_, A) {
      return s(t(_), A, a, !1).valueOf();
    },
    "any, Array": function(_, A) {
      return s(t(A), _, a, !0).valueOf();
    },
    "any, any": a,
    "any, any, ...any": r.referToSelf((g) => (_, A, M) => {
      for (var P = g(_, A), T = 0; T < M.length; T++)
        P = g(P, M[T]);
      return P;
    })
  });
}), uO = "nthRoot", ZTe = ["typed", "matrix", "equalScalar", "BigNumber", "concat"], JTe = /* @__PURE__ */ Ce(uO, ZTe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    BigNumber: a,
    concat: i
  } = e, o = nf({
    typed: r
  }), c = Ts({
    typed: r,
    equalScalar: n
  }), s = cx({
    typed: r,
    equalScalar: n
  }), u = li({
    typed: r,
    equalScalar: n
  }), l = kt({
    typed: r,
    matrix: t,
    concat: i
  });
  function f() {
    throw new Error("Complex number not supported in function nthRoot. Use nthRoots instead.");
  }
  return r(uO, {
    number: wR,
    "number, number": wR,
    BigNumber: (m) => d(m, new a(2)),
    "BigNumber, BigNumber": d,
    Complex: f,
    "Complex, number": f,
    Array: r.referTo("DenseMatrix,number", (m) => (p) => m(t(p), 2).valueOf()),
    DenseMatrix: r.referTo("DenseMatrix,number", (m) => (p) => m(p, 2)),
    SparseMatrix: r.referTo("SparseMatrix,number", (m) => (p) => m(p, 2)),
    "SparseMatrix, SparseMatrix": r.referToSelf((m) => (p, v) => {
      if (v.density() === 1)
        return s(p, v, m);
      throw new Error("Root must be non-zero");
    }),
    "DenseMatrix, SparseMatrix": r.referToSelf((m) => (p, v) => {
      if (v.density() === 1)
        return o(p, v, m, !1);
      throw new Error("Root must be non-zero");
    }),
    "Array, SparseMatrix": r.referTo("DenseMatrix,SparseMatrix", (m) => (p, v) => m(t(p), v)),
    "number | BigNumber, SparseMatrix": r.referToSelf((m) => (p, v) => {
      if (v.density() === 1)
        return u(v, p, m, !0);
      throw new Error("Root must be non-zero");
    })
  }, l({
    scalar: "number | BigNumber",
    SD: c,
    Ss: u,
    sS: !1
  }));
  function d(m, p) {
    var v = a.precision, h = a.clone({
      precision: v + 2
    }), y = new a(0), C = new h(1), S = p.isNegative();
    if (S && (p = p.neg()), p.isZero())
      throw new Error("Root must be non-zero");
    if (m.isNegative() && !p.abs().mod(2).equals(1))
      throw new Error("Root must be odd when a is negative.");
    if (m.isZero())
      return S ? new h(1 / 0) : 0;
    if (!m.isFinite())
      return S ? y : m;
    var b = m.abs().pow(C.div(p));
    return b = m.isNeg() ? b.neg() : b, new a((S ? C.div(b) : b).toPrecision(v));
  }
}), sO = "sign", ePe = ["typed", "BigNumber", "Fraction", "complex"], pX = /* @__PURE__ */ Ce(sO, ePe, (e) => {
  var {
    typed: r,
    BigNumber: t,
    complex: n,
    Fraction: a
  } = e;
  return r(sO, {
    number: Pw,
    Complex: function(o) {
      return o.im === 0 ? n(Pw(o.re)) : o.sign();
    },
    BigNumber: function(o) {
      return new t(o.cmp(0));
    },
    bigint: function(o) {
      return o > 0n ? 1n : o < 0n ? -1n : 0n;
    },
    Fraction: function(o) {
      return new a(o.s, 1);
    },
    // deep map collection, skip zeros since sign(0) = 0
    "Array | Matrix": r.referToSelf((i) => (o) => zr(o, i)),
    Unit: r.referToSelf((i) => (o) => {
      if (!o._isDerived() && o.units[0].unit.offset !== 0)
        throw new TypeError("sign is ambiguous for units with offset");
      return r.find(i, o.valueType())(o.value);
    })
  });
}), rPe = "sqrt", tPe = ["config", "typed", "Complex"], hX = /* @__PURE__ */ Ce(rPe, tPe, (e) => {
  var {
    config: r,
    typed: t,
    Complex: n
  } = e;
  return t("sqrt", {
    number: a,
    Complex: function(o) {
      return o.sqrt();
    },
    BigNumber: function(o) {
      return !o.isNegative() || r.predictable ? o.sqrt() : a(o.toNumber());
    },
    Unit: function(o) {
      return o.pow(0.5);
    }
  });
  function a(i) {
    return isNaN(i) ? NaN : i >= 0 || r.predictable ? Math.sqrt(i) : new n(i, 0).sqrt();
  }
}), lO = "square", nPe = ["typed"], aPe = /* @__PURE__ */ Ce(lO, nPe, (e) => {
  var {
    typed: r
  } = e;
  return r(lO, {
    number: yW,
    Complex: function(n) {
      return n.mul(n);
    },
    BigNumber: function(n) {
      return n.times(n);
    },
    bigint: function(n) {
      return n * n;
    },
    Fraction: function(n) {
      return n.mul(n);
    },
    Unit: function(n) {
      return n.pow(2);
    }
  });
}), cO = "subtract", iPe = ["typed", "matrix", "equalScalar", "subtractScalar", "unaryMinus", "DenseMatrix", "concat"], gX = /* @__PURE__ */ Ce(cO, iPe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    subtractScalar: a,
    unaryMinus: i,
    DenseMatrix: o,
    concat: c
  } = e, s = nf({
    typed: r
  }), u = Zi({
    typed: r
  }), l = lx({
    typed: r,
    equalScalar: n
  }), f = rm({
    typed: r,
    DenseMatrix: o
  }), d = Aa({
    typed: r,
    DenseMatrix: o
  }), m = kt({
    typed: r,
    matrix: t,
    concat: c
  });
  return r(cO, {
    "any, any": a
  }, m({
    elop: a,
    SS: l,
    DS: s,
    SD: u,
    Ss: d,
    sS: f
  }));
}), dO = "xgcd", oPe = ["typed", "config", "matrix", "BigNumber"], uPe = /* @__PURE__ */ Ce(dO, oPe, (e) => {
  var {
    typed: r,
    config: t,
    matrix: n,
    BigNumber: a
  } = e;
  return r(dO, {
    "number, number": function(c, s) {
      var u = _W(c, s);
      return t.matrix === "Array" ? u : n(u);
    },
    "BigNumber, BigNumber": i
    // TODO: implement support for Fraction
  });
  function i(o, c) {
    var s, u, l, f = new a(0), d = new a(1), m = f, p = d, v = d, h = f;
    if (!o.isInt() || !c.isInt())
      throw new Error("Parameters in function xgcd must be integer numbers");
    for (; !c.isZero(); )
      u = o.div(c).floor(), l = o.mod(c), s = m, m = p.minus(u.times(m)), p = s, s = v, v = h.minus(u.times(v)), h = s, o = c, c = l;
    var y;
    return o.lt(f) ? y = [o.neg(), p.neg(), h.neg()] : y = [o, o.isZero() ? 0 : p, h], t.matrix === "Array" ? y : n(y);
  }
}), fO = "invmod", sPe = ["typed", "config", "BigNumber", "xgcd", "equal", "smaller", "mod", "add", "isInteger"], lPe = /* @__PURE__ */ Ce(fO, sPe, (e) => {
  var {
    typed: r,
    config: t,
    BigNumber: n,
    xgcd: a,
    equal: i,
    smaller: o,
    mod: c,
    add: s,
    isInteger: u
  } = e;
  return r(fO, {
    "number, number": l,
    "BigNumber, BigNumber": l
  });
  function l(f, d) {
    if (!u(f) || !u(d)) throw new Error("Parameters in function invmod must be integer numbers");
    if (f = c(f, d), i(d, 0)) throw new Error("Divisor must be non zero");
    var m = a(f, d);
    m = m.valueOf();
    var [p, v] = m;
    return i(p, n(1)) ? (v = c(v, d), o(v, n(0)) && (v = s(v, d)), v) : NaN;
  }
}), cPe = "matAlgo09xS0Sf", dPe = ["typed", "equalScalar"], yX = /* @__PURE__ */ Ce(cPe, dPe, (e) => {
  var {
    typed: r,
    equalScalar: t
  } = e;
  return function(a, i, o) {
    var c = a._values, s = a._index, u = a._ptr, l = a._size, f = a._datatype || a._data === void 0 ? a._datatype : a.getDataType(), d = i._values, m = i._index, p = i._ptr, v = i._size, h = i._datatype || i._data === void 0 ? i._datatype : i.getDataType();
    if (l.length !== v.length)
      throw new kr(l.length, v.length);
    if (l[0] !== v[0] || l[1] !== v[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + l + ") must match Matrix B (" + v + ")");
    var y = l[0], C = l[1], S, b = t, g = 0, _ = o;
    typeof f == "string" && f === h && f !== "mixed" && (S = f, b = r.find(t, [S, S]), g = r.convert(0, S), _ = r.find(o, [S, S]));
    var A = c && d ? [] : void 0, M = [], P = [], T = A ? [] : void 0, x = [], w, E, I, B, D;
    for (E = 0; E < C; E++) {
      P[E] = M.length;
      var N = E + 1;
      if (T)
        for (B = p[E], D = p[E + 1], I = B; I < D; I++)
          w = m[I], x[w] = N, T[w] = d[I];
      for (B = u[E], D = u[E + 1], I = B; I < D; I++)
        if (w = s[I], T) {
          var O = x[w] === N ? T[w] : g, V = _(c[I], O);
          b(V, g) || (M.push(w), A.push(V));
        } else
          M.push(w);
    }
    return P[C] = M.length, a.createSparseMatrix({
      values: A,
      index: M,
      ptr: P,
      size: [y, C],
      datatype: f === a._datatype && h === i._datatype ? S : void 0
    });
  };
}), mO = "dotMultiply", fPe = ["typed", "matrix", "equalScalar", "multiplyScalar", "concat"], mPe = /* @__PURE__ */ Ce(mO, fPe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    multiplyScalar: a,
    concat: i
  } = e, o = Ts({
    typed: r,
    equalScalar: n
  }), c = yX({
    typed: r,
    equalScalar: n
  }), s = li({
    typed: r,
    equalScalar: n
  }), u = kt({
    typed: r,
    matrix: t,
    concat: i
  });
  return r(mO, u({
    elop: a,
    SS: c,
    DS: o,
    Ss: s
  }));
});
function vPe(e, r) {
  if (e.isFinite() && !e.isInteger() || r.isFinite() && !r.isInteger())
    throw new Error("Integers expected in function bitAnd");
  var t = e.constructor;
  if (e.isNaN() || r.isNaN())
    return new t(NaN);
  if (e.isZero() || r.eq(-1) || e.eq(r))
    return e;
  if (r.isZero() || e.eq(-1))
    return r;
  if (!e.isFinite() || !r.isFinite()) {
    if (!e.isFinite() && !r.isFinite())
      return e.isNegative() === r.isNegative() ? e : new t(0);
    if (!e.isFinite())
      return r.isNegative() ? e : e.isNegative() ? new t(0) : r;
    if (!r.isFinite())
      return e.isNegative() ? r : r.isNegative() ? new t(0) : e;
  }
  return ID(e, r, function(n, a) {
    return n & a;
  });
}
function zg(e) {
  if (e.isFinite() && !e.isInteger())
    throw new Error("Integer expected in function bitNot");
  var r = e.constructor, t = r.precision;
  r.config({
    precision: 1e9
  });
  var n = e.plus(new r(1));
  return n.s = -n.s || null, r.config({
    precision: t
  }), n;
}
function pPe(e, r) {
  if (e.isFinite() && !e.isInteger() || r.isFinite() && !r.isInteger())
    throw new Error("Integers expected in function bitOr");
  var t = e.constructor;
  if (e.isNaN() || r.isNaN())
    return new t(NaN);
  var n = new t(-1);
  return e.isZero() || r.eq(n) || e.eq(r) ? r : r.isZero() || e.eq(n) ? e : !e.isFinite() || !r.isFinite() ? !e.isFinite() && !e.isNegative() && r.isNegative() || e.isNegative() && !r.isNegative() && !r.isFinite() ? n : e.isNegative() && r.isNegative() ? e.isFinite() ? e : r : e.isFinite() ? r : e : ID(e, r, function(a, i) {
    return a | i;
  });
}
function ID(e, r, t) {
  var n = e.constructor, a, i, o = +(e.s < 0), c = +(r.s < 0);
  if (o) {
    a = M_(zg(e));
    for (var s = 0; s < a.length; ++s)
      a[s] ^= 1;
  } else
    a = M_(e);
  if (c) {
    i = M_(zg(r));
    for (var u = 0; u < i.length; ++u)
      i[u] ^= 1;
  } else
    i = M_(r);
  var l, f, d;
  a.length <= i.length ? (l = a, f = i, d = o) : (l = i, f = a, d = c);
  var m = l.length, p = f.length, v = t(o, c) ^ 1, h = new n(v ^ 1), y = new n(1), C = new n(2), S = n.precision;
  for (n.config({
    precision: 1e9
  }); m > 0; )
    t(l[--m], f[--p]) === v && (h = h.plus(y)), y = y.times(C);
  for (; p > 0; )
    t(d, f[--p]) === v && (h = h.plus(y)), y = y.times(C);
  return n.config({
    precision: S
  }), v === 0 && (h.s = -h.s), h;
}
function M_(e) {
  for (var r = e.d, t = r[0] + "", n = 1; n < r.length; ++n) {
    for (var a = r[n] + "", i = 7 - a.length; i--; )
      a = "0" + a;
    t += a;
  }
  for (var o = t.length; t.charAt(o) === "0"; )
    o--;
  var c = e.e, s = t.slice(0, o + 1 || 1), u = s.length;
  if (c > 0)
    if (++c > u)
      for (c -= u; c--; )
        s += "0";
    else c < u && (s = s.slice(0, c) + "." + s.slice(c));
  for (var l = [0], f = 0; f < s.length; ) {
    for (var d = l.length; d--; )
      l[d] *= 10;
    l[0] += parseInt(s.charAt(f++));
    for (var m = 0; m < l.length; ++m)
      l[m] > 1 && ((l[m + 1] === null || l[m + 1] === void 0) && (l[m + 1] = 0), l[m + 1] += l[m] >> 1, l[m] &= 1);
  }
  return l.reverse();
}
function hPe(e, r) {
  if (e.isFinite() && !e.isInteger() || r.isFinite() && !r.isInteger())
    throw new Error("Integers expected in function bitXor");
  var t = e.constructor;
  if (e.isNaN() || r.isNaN())
    return new t(NaN);
  if (e.isZero())
    return r;
  if (r.isZero())
    return e;
  if (e.eq(r))
    return new t(0);
  var n = new t(-1);
  return e.eq(n) ? zg(r) : r.eq(n) ? zg(e) : !e.isFinite() || !r.isFinite() ? !e.isFinite() && !r.isFinite() ? n : new t(e.isNegative() === r.isNegative() ? 1 / 0 : -1 / 0) : ID(e, r, function(a, i) {
    return a ^ i;
  });
}
function gPe(e, r) {
  if (e.isFinite() && !e.isInteger() || r.isFinite() && !r.isInteger())
    throw new Error("Integers expected in function leftShift");
  var t = e.constructor;
  return e.isNaN() || r.isNaN() || r.isNegative() && !r.isZero() ? new t(NaN) : e.isZero() || r.isZero() ? e : !e.isFinite() && !r.isFinite() ? new t(NaN) : r.lt(55) ? e.times(Math.pow(2, r.toNumber()) + "") : e.times(new t(2).pow(r));
}
function yPe(e, r) {
  if (e.isFinite() && !e.isInteger() || r.isFinite() && !r.isInteger())
    throw new Error("Integers expected in function rightArithShift");
  var t = e.constructor;
  return e.isNaN() || r.isNaN() || r.isNegative() && !r.isZero() ? new t(NaN) : e.isZero() || r.isZero() ? e : r.isFinite() ? r.lt(55) ? e.div(Math.pow(2, r.toNumber()) + "").floor() : e.div(new t(2).pow(r)).floor() : e.isNegative() ? new t(-1) : e.isFinite() ? new t(0) : new t(NaN);
}
var vO = "bitAnd", _Pe = ["typed", "matrix", "equalScalar", "concat"], _X = /* @__PURE__ */ Ce(vO, _Pe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    concat: a
  } = e, i = Ts({
    typed: r,
    equalScalar: n
  }), o = cx({
    typed: r,
    equalScalar: n
  }), c = li({
    typed: r,
    equalScalar: n
  }), s = kt({
    typed: r,
    matrix: t,
    concat: a
  });
  return r(vO, {
    "number, number": SW,
    "BigNumber, BigNumber": vPe,
    "bigint, bigint": (u, l) => u & l
  }, s({
    SS: o,
    DS: i,
    Ss: c
  }));
}), pO = "bitNot", bPe = ["typed"], SPe = /* @__PURE__ */ Ce(pO, bPe, (e) => {
  var {
    typed: r
  } = e;
  return r(pO, {
    number: CW,
    BigNumber: zg,
    bigint: (t) => ~t,
    "Array | Matrix": r.referToSelf((t) => (n) => zr(n, t))
  });
}), hO = "bitOr", CPe = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"], bX = /* @__PURE__ */ Ce(hO, CPe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    DenseMatrix: a,
    concat: i
  } = e, o = nf({
    typed: r
  }), c = DD({
    typed: r,
    equalScalar: n
  }), s = rm({
    typed: r,
    DenseMatrix: a
  }), u = kt({
    typed: r,
    matrix: t,
    concat: i
  });
  return r(hO, {
    "number, number": AW,
    "BigNumber, BigNumber": pPe,
    "bigint, bigint": (l, f) => l | f
  }, u({
    SS: c,
    DS: o,
    Ss: s
  }));
}), APe = "matAlgo07xSSf", xPe = ["typed", "DenseMatrix"], Sl = /* @__PURE__ */ Ce(APe, xPe, (e) => {
  var {
    typed: r,
    DenseMatrix: t
  } = e;
  return function(i, o, c) {
    var s = i._size, u = i._datatype || i._data === void 0 ? i._datatype : i.getDataType(), l = o._size, f = o._datatype || o._data === void 0 ? o._datatype : o.getDataType();
    if (s.length !== l.length)
      throw new kr(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 d = s[0], m = s[1], p, v = 0, h = c;
    typeof u == "string" && u === f && u !== "mixed" && (p = u, v = r.convert(0, p), h = r.find(c, [p, p]));
    var y, C, S = [];
    for (y = 0; y < d; y++)
      S[y] = [];
    var b = [], g = [], _ = [], A = [];
    for (C = 0; C < m; C++) {
      var M = C + 1;
      for (n(i, C, _, b, M), n(o, C, A, g, M), y = 0; y < d; y++) {
        var P = _[y] === M ? b[y] : v, T = A[y] === M ? g[y] : v;
        S[y][C] = h(P, T);
      }
    }
    return new t({
      data: S,
      size: [d, m],
      datatype: u === i._datatype && f === o._datatype ? p : void 0
    });
  };
  function n(a, i, o, c, s) {
    for (var u = a._values, l = a._index, f = a._ptr, d = f[i], m = f[i + 1]; d < m; d++) {
      var p = l[d];
      o[p] = s, c[p] = u[d];
    }
  }
}), gO = "bitXor", TPe = ["typed", "matrix", "DenseMatrix", "concat"], PPe = /* @__PURE__ */ Ce(gO, TPe, (e) => {
  var {
    typed: r,
    matrix: t,
    DenseMatrix: n,
    concat: a
  } = e, i = Zi({
    typed: r
  }), o = Sl({
    typed: r,
    DenseMatrix: n
  }), c = Aa({
    typed: r,
    DenseMatrix: n
  }), s = kt({
    typed: r,
    matrix: t,
    concat: a
  });
  return r(gO, {
    "number, number": xW,
    "BigNumber, BigNumber": hPe,
    "bigint, bigint": (u, l) => u ^ l
  }, s({
    SS: o,
    DS: i,
    Ss: c
  }));
}), yO = "arg", MPe = ["typed"], wPe = /* @__PURE__ */ Ce(yO, MPe, (e) => {
  var {
    typed: r
  } = e;
  return r(yO, {
    number: function(n) {
      return Math.atan2(0, n);
    },
    BigNumber: function(n) {
      return n.constructor.atan2(0, n);
    },
    Complex: function(n) {
      return n.arg();
    },
    // TODO: implement BigNumber support for function arg
    "Array | Matrix": r.referToSelf((t) => (n) => zr(n, t))
  });
}), _O = "conj", EPe = ["typed"], SX = /* @__PURE__ */ Ce(_O, EPe, (e) => {
  var {
    typed: r
  } = e;
  return r(_O, {
    "number | BigNumber | Fraction": (t) => t,
    Complex: (t) => t.conjugate(),
    "Array | Matrix": r.referToSelf((t) => (n) => zr(n, t))
  });
}), bO = "im", DPe = ["typed"], CX = /* @__PURE__ */ Ce(bO, DPe, (e) => {
  var {
    typed: r
  } = e;
  return r(bO, {
    number: () => 0,
    "BigNumber | Fraction": (t) => t.mul(0),
    Complex: (t) => t.im,
    "Array | Matrix": r.referToSelf((t) => (n) => zr(n, t))
  });
}), SO = "re", IPe = ["typed"], AX = /* @__PURE__ */ Ce(SO, IPe, (e) => {
  var {
    typed: r
  } = e;
  return r(SO, {
    "number | BigNumber | Fraction": (t) => t,
    Complex: (t) => t.re,
    "Array | Matrix": r.referToSelf((t) => (n) => zr(n, t))
  });
}), CO = "not", BPe = ["typed"], NPe = /* @__PURE__ */ Ce(CO, BPe, (e) => {
  var {
    typed: r
  } = e;
  return r(CO, {
    "null | undefined": () => !0,
    number: EW,
    Complex: function(n) {
      return n.re === 0 && n.im === 0;
    },
    BigNumber: function(n) {
      return n.isZero() || n.isNaN();
    },
    bigint: (t) => !t,
    Unit: r.referToSelf((t) => (n) => r.find(t, n.valueType())(n.value)),
    "Array | Matrix": r.referToSelf((t) => (n) => zr(n, t))
  });
}), AO = "or", VPe = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"], xX = /* @__PURE__ */ Ce(AO, VPe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    DenseMatrix: a,
    concat: i
  } = e, o = Zi({
    typed: r
  }), c = lx({
    typed: r,
    equalScalar: n
  }), s = Aa({
    typed: r,
    DenseMatrix: a
  }), u = kt({
    typed: r,
    matrix: t,
    concat: i
  });
  return r(AO, {
    "number, number": Mw,
    "Complex, Complex": function(f, d) {
      return f.re !== 0 || f.im !== 0 || d.re !== 0 || d.im !== 0;
    },
    "BigNumber, BigNumber": function(f, d) {
      return !f.isZero() && !f.isNaN() || !d.isZero() && !d.isNaN();
    },
    "bigint, bigint": Mw,
    "Unit, Unit": r.referToSelf((l) => (f, d) => l(f.value || 0, d.value || 0))
  }, u({
    SS: c,
    DS: o,
    Ss: s
  }));
}), xO = "xor", RPe = ["typed", "matrix", "DenseMatrix", "concat"], OPe = /* @__PURE__ */ Ce(xO, RPe, (e) => {
  var {
    typed: r,
    matrix: t,
    DenseMatrix: n,
    concat: a
  } = e, i = Zi({
    typed: r
  }), o = Sl({
    typed: r,
    DenseMatrix: n
  }), c = Aa({
    typed: r,
    DenseMatrix: n
  }), s = kt({
    typed: r,
    matrix: t,
    concat: a
  });
  return r(xO, {
    "number, number": ww,
    "Complex, Complex": function(l, f) {
      return (l.re !== 0 || l.im !== 0) != (f.re !== 0 || f.im !== 0);
    },
    "bigint, bigint": ww,
    "BigNumber, BigNumber": function(l, f) {
      return (!l.isZero() && !l.isNaN()) != (!f.isZero() && !f.isNaN());
    },
    "Unit, Unit": r.referToSelf((u) => (l, f) => u(l.value || 0, f.value || 0))
  }, s({
    SS: o,
    DS: i,
    Ss: c
  }));
}), TO = "concat", FPe = ["typed", "matrix", "isInteger"], BD = /* @__PURE__ */ Ce(TO, FPe, (e) => {
  var {
    typed: r,
    matrix: t,
    isInteger: n
  } = e;
  return r(TO, {
    // TODO: change signature to '...Array | Matrix, dim?' when supported
    "...Array | Matrix | number | BigNumber": function(i) {
      var o, c = i.length, s = -1, u, l = !1, f = [];
      for (o = 0; o < c; o++) {
        var d = i[o];
        if (gr(d) && (l = !0), Or(d) || Ir(d)) {
          if (o !== c - 1)
            throw new Error("Dimension must be specified as last argument");
          if (u = s, s = d.valueOf(), !n(s))
            throw new TypeError("Integer number expected for dimension");
          if (s < 0 || o > 0 && s > u)
            throw new Ru(s, u + 1);
        } else {
          var m = Sr(d).valueOf(), p = Fr(m);
          if (f[o] = m, u = s, s = p.length - 1, o > 0 && s !== u)
            throw new kr(u + 1, s + 1);
        }
      }
      if (f.length === 0)
        throw new SyntaxError("At least one matrix expected");
      for (var v = f.shift(); f.length; )
        v = JK(v, f.shift(), s);
      return l ? t(v) : v;
    },
    "...string": function(i) {
      return i.join("");
    }
  });
}), PO = "column", LPe = ["typed", "Index", "matrix", "range"], ND = /* @__PURE__ */ Ce(PO, LPe, (e) => {
  var {
    typed: r,
    Index: t,
    matrix: n,
    range: a
  } = e;
  return r(PO, {
    "Matrix, number": i,
    "Array, number": function(c, s) {
      return i(n(Sr(c)), s).valueOf();
    }
  });
  function i(o, c) {
    if (o.size().length !== 2)
      throw new Error("Only two dimensional matrix is supported");
    Pt(c, o.size()[1]);
    var s = a(0, o.size()[0]), u = new t(s, c), l = o.subset(u);
    return gr(l) ? l : n([[l]]);
  }
}), MO = "count", kPe = ["typed", "size", "prod"], UPe = /* @__PURE__ */ Ce(MO, kPe, (e) => {
  var {
    typed: r,
    size: t,
    prod: n
  } = e;
  return r(MO, {
    string: function(i) {
      return i.length;
    },
    "Matrix | Array": function(i) {
      return n(t(i));
    }
  });
}), wO = "cross", zPe = ["typed", "matrix", "subtract", "multiply"], TX = /* @__PURE__ */ Ce(wO, zPe, (e) => {
  var {
    typed: r,
    matrix: t,
    subtract: n,
    multiply: a
  } = e;
  return r(wO, {
    "Matrix, Matrix": function(c, s) {
      return t(i(c.toArray(), s.toArray()));
    },
    "Matrix, Array": function(c, s) {
      return t(i(c.toArray(), s));
    },
    "Array, Matrix": function(c, s) {
      return t(i(c, s.toArray()));
    },
    "Array, Array": i
  });
  function i(o, c) {
    var s = Math.max(Fr(o).length, Fr(c).length);
    o = _3(o), c = _3(c);
    var u = Fr(o), l = Fr(c);
    if (u.length !== 1 || l.length !== 1 || u[0] !== 3 || l[0] !== 3)
      throw new RangeError("Vectors with length 3 expected (Size A = [" + u.join(", ") + "], B = [" + l.join(", ") + "])");
    var f = [n(a(o[1], c[2]), a(o[2], c[1])), n(a(o[2], c[0]), a(o[0], c[2])), n(a(o[0], c[1]), a(o[1], c[0]))];
    return s > 1 ? [f] : f;
  }
}), EO = "diag", GPe = ["typed", "matrix", "DenseMatrix", "SparseMatrix"], PX = /* @__PURE__ */ Ce(EO, GPe, (e) => {
  var {
    typed: r,
    matrix: t,
    DenseMatrix: n,
    SparseMatrix: a
  } = e;
  return r(EO, {
    // FIXME: simplify this huge amount of signatures as soon as typed-function supports optional arguments
    Array: function(u) {
      return i(u, 0, Fr(u), null);
    },
    "Array, number": function(u, l) {
      return i(u, l, Fr(u), null);
    },
    "Array, BigNumber": function(u, l) {
      return i(u, l.toNumber(), Fr(u), null);
    },
    "Array, string": function(u, l) {
      return i(u, 0, Fr(u), l);
    },
    "Array, number, string": function(u, l, f) {
      return i(u, l, Fr(u), f);
    },
    "Array, BigNumber, string": function(u, l, f) {
      return i(u, l.toNumber(), Fr(u), f);
    },
    Matrix: function(u) {
      return i(u, 0, u.size(), u.storage());
    },
    "Matrix, number": function(u, l) {
      return i(u, l, u.size(), u.storage());
    },
    "Matrix, BigNumber": function(u, l) {
      return i(u, l.toNumber(), u.size(), u.storage());
    },
    "Matrix, string": function(u, l) {
      return i(u, 0, u.size(), l);
    },
    "Matrix, number, string": function(u, l, f) {
      return i(u, l, u.size(), f);
    },
    "Matrix, BigNumber, string": function(u, l, f) {
      return i(u, l.toNumber(), u.size(), f);
    }
  });
  function i(s, u, l, f) {
    if (!lr(u))
      throw new TypeError("Second parameter in function diag must be an integer");
    var d = u > 0 ? u : 0, m = u < 0 ? -u : 0;
    switch (l.length) {
      case 1:
        return o(s, u, f, l[0], m, d);
      case 2:
        return c(s, u, f, l, m, d);
    }
    throw new RangeError("Matrix for function diag must be 2 dimensional");
  }
  function o(s, u, l, f, d, m) {
    var p = [f + d, f + m];
    if (l && l !== "sparse" && l !== "dense")
      throw new TypeError("Unknown matrix type ".concat(l, '"'));
    var v = l === "sparse" ? a.diagonal(p, s, u) : n.diagonal(p, s, u);
    return l !== null ? v : v.valueOf();
  }
  function c(s, u, l, f, d, m) {
    if (gr(s)) {
      var p = s.diagonal(u);
      return l !== null ? l !== p.storage() ? t(p, l) : p : p.valueOf();
    }
    for (var v = Math.min(f[0] - d, f[1] - m), h = [], y = 0; y < v; y++)
      h[y] = s[y + d][y + m];
    return l !== null ? t(h) : h;
  }
});
function Zp(e, r, t, n, a) {
  if (r0.isTypedFunction(e)) {
    var i = [r, t, n], o = r0.resolve(e, i);
    if (o)
      return f(o.implementation, i);
    var c = [r, t], s = r0.resolve(e, c);
    if (s)
      return f(s.implementation, c);
    var u = [r], l = r0.resolve(e, u);
    return l ? f(l.implementation, u) : f(e, i);
  } else
    return e(r, t, n);
  function f(d, m) {
    try {
      return d.apply(d, m);
    } catch (h) {
      var p;
      if (h instanceof TypeError && ((p = h.data) === null || p === void 0 ? void 0 : p.category) === "wrongType") {
        var v = [];
        throw v.push("value: ".concat(Et(r))), m.length >= 2 && v.push("index: ".concat(Et(t))), m.length >= 3 && v.push("array: ".concat(Et(n))), new TypeError("Function ".concat(a, " cannot apply callback arguments ") + "".concat(e.name, "(").concat(v.join(", "), ") at index ").concat(JSON.stringify(t)));
      } else
        throw new TypeError("Function ".concat(a, " cannot apply callback arguments ") + "to function ".concat(e.name, ": ").concat(h.message));
    }
  }
}
var qPe = "filter", HPe = ["typed"], jPe = /* @__PURE__ */ Ce(qPe, HPe, (e) => {
  var {
    typed: r
  } = e;
  return r("filter", {
    "Array, function": DO,
    "Matrix, function": function(n, a) {
      return n.create(DO(n.toArray(), a));
    },
    "Array, RegExp": b3,
    "Matrix, RegExp": function(n, a) {
      return n.create(b3(n.toArray(), a));
    }
  });
});
function DO(e, r) {
  return QK(e, function(t, n, a) {
    return Zp(r, t, [n], a, "filter");
  });
}
var IO = "flatten", $Pe = ["typed", "matrix"], MX = /* @__PURE__ */ Ce(IO, $Pe, (e) => {
  var {
    typed: r,
    matrix: t
  } = e;
  return r(IO, {
    Array: function(a) {
      return st(a);
    },
    Matrix: function(a) {
      var i = st(a.toArray());
      return t(i);
    }
  });
}), BO = "forEach", KPe = ["typed"], WPe = /* @__PURE__ */ Ce(BO, KPe, (e) => {
  var {
    typed: r
  } = e;
  return r(BO, {
    "Array, function": XPe,
    "Matrix, function": function(n, a) {
      n.forEach(a);
    }
  });
});
function XPe(e, r) {
  var t = function n(a, i) {
    if (Array.isArray(a))
      ux(a, function(o, c) {
        n(o, i.concat(c));
      });
    else
      return Zp(r, a, i, e, "forEach");
  };
  t(e, []);
}
var NO = "getMatrixDataType", YPe = ["typed"], wX = /* @__PURE__ */ Ce(NO, YPe, (e) => {
  var {
    typed: r
  } = e;
  return r(NO, {
    Array: function(n) {
      return Ug(n, Et);
    },
    Matrix: function(n) {
      return n.getDataType();
    }
  });
}), VO = "identity", QPe = ["typed", "config", "matrix", "BigNumber", "DenseMatrix", "SparseMatrix"], EX = /* @__PURE__ */ Ce(VO, QPe, (e) => {
  var {
    typed: r,
    config: t,
    matrix: n,
    BigNumber: a,
    DenseMatrix: i,
    SparseMatrix: o
  } = e;
  return r(VO, {
    "": function() {
      return t.matrix === "Matrix" ? n([]) : [];
    },
    string: function(l) {
      return n(l);
    },
    "number | BigNumber": function(l) {
      return s(l, l, t.matrix === "Matrix" ? "dense" : void 0);
    },
    "number | BigNumber, string": function(l, f) {
      return s(l, l, f);
    },
    "number | BigNumber, number | BigNumber": function(l, f) {
      return s(l, f, t.matrix === "Matrix" ? "dense" : void 0);
    },
    "number | BigNumber, number | BigNumber, string": function(l, f, d) {
      return s(l, f, d);
    },
    Array: function(l) {
      return c(l);
    },
    "Array, string": function(l, f) {
      return c(l, f);
    },
    Matrix: function(l) {
      return c(l.valueOf(), l.storage());
    },
    "Matrix, string": function(l, f) {
      return c(l.valueOf(), f);
    }
  });
  function c(u, l) {
    switch (u.length) {
      case 0:
        return l ? n(l) : [];
      case 1:
        return s(u[0], u[0], l);
      case 2:
        return s(u[0], u[1], l);
      default:
        throw new Error("Vector containing two values expected");
    }
  }
  function s(u, l, f) {
    var d = Ir(u) || Ir(l) ? a : null;
    if (Ir(u) && (u = u.toNumber()), Ir(l) && (l = l.toNumber()), !lr(u) || u < 1)
      throw new Error("Parameters in function identity must be positive integers");
    if (!lr(l) || l < 1)
      throw new Error("Parameters in function identity must be positive integers");
    var m = d ? new a(1) : 1, p = d ? new d(0) : 0, v = [u, l];
    if (f) {
      if (f === "sparse")
        return o.diagonal(v, m, 0, p);
      if (f === "dense")
        return i.diagonal(v, m, 0, p);
      throw new TypeError('Unknown matrix type "'.concat(f, '"'));
    }
    for (var h = fp([], v, p), y = u < l ? u : l, C = 0; C < y; C++)
      h[C][C] = m;
    return h;
  }
}), RO = "kron", ZPe = ["typed", "matrix", "multiplyScalar"], JPe = /* @__PURE__ */ Ce(RO, ZPe, (e) => {
  var {
    typed: r,
    matrix: t,
    multiplyScalar: n
  } = e;
  return r(RO, {
    "Matrix, Matrix": function(o, c) {
      return t(a(o.toArray(), c.toArray()));
    },
    "Matrix, Array": function(o, c) {
      return t(a(o.toArray(), c));
    },
    "Array, Matrix": function(o, c) {
      return t(a(o, c.toArray()));
    },
    "Array, Array": a
  });
  function a(i, o) {
    if (Fr(i).length === 1 && (i = [i]), Fr(o).length === 1 && (o = [o]), Fr(i).length > 2 || Fr(o).length > 2)
      throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = " + JSON.stringify(i.length) + ", y = " + JSON.stringify(o.length) + ")");
    var c = [], s = [];
    return i.map(function(u) {
      return o.map(function(l) {
        return s = [], c.push(s), u.map(function(f) {
          return l.map(function(d) {
            return s.push(n(f, d));
          });
        });
      });
    }) && c;
  }
}), OO = "map", eMe = ["typed"], rMe = /* @__PURE__ */ Ce(OO, eMe, (e) => {
  var {
    typed: r
  } = e;
  return r(OO, {
    "Array, function": tMe,
    "Matrix, function": function(n, a) {
      return n.map(a);
    }
  });
});
function tMe(e, r) {
  var t = function n(a, i) {
    return Array.isArray(a) ? a.map(function(o, c) {
      return n(o, i.concat(c));
    }) : Zp(r, a, i, e, "map");
  };
  return t(e, []);
}
var FO = "diff", nMe = ["typed", "matrix", "subtract", "number"], DX = /* @__PURE__ */ Ce(FO, nMe, (e) => {
  var {
    typed: r,
    matrix: t,
    subtract: n,
    number: a
  } = e;
  return r(FO, {
    "Array | Matrix": function(l) {
      return gr(l) ? t(o(l.toArray())) : o(l);
    },
    "Array | Matrix, number": function(l, f) {
      if (!lr(f)) throw new RangeError("Dimension must be a whole number");
      return gr(l) ? t(i(l.toArray(), f)) : i(l, f);
    },
    "Array, BigNumber": r.referTo("Array,number", (u) => (l, f) => u(l, a(f))),
    "Matrix, BigNumber": r.referTo("Matrix,number", (u) => (l, f) => u(l, a(f)))
  });
  function i(u, l) {
    if (gr(u) && (u = u.toArray()), !Array.isArray(u))
      throw RangeError("Array/Matrix does not have that many dimensions");
    if (l > 0) {
      var f = [];
      return u.forEach((d) => {
        f.push(i(d, l - 1));
      }), f;
    } else {
      if (l === 0)
        return o(u);
      throw RangeError("Cannot have negative dimension");
    }
  }
  function o(u) {
    for (var l = [], f = u.length, d = 1; d < f; d++)
      l.push(c(u[d - 1], u[d]));
    return l;
  }
  function c(u, l) {
    gr(u) && (u = u.toArray()), gr(l) && (l = l.toArray());
    var f = Array.isArray(u), d = Array.isArray(l);
    if (f && d)
      return s(u, l);
    if (!f && !d)
      return n(l, u);
    throw TypeError("Cannot calculate difference between 1 array and 1 non-array");
  }
  function s(u, l) {
    if (u.length !== l.length)
      throw RangeError("Not all sub-arrays have the same length");
    for (var f = [], d = u.length, m = 0; m < d; m++)
      f.push(c(u[m], l[m]));
    return f;
  }
}), aMe = "ones", iMe = ["typed", "config", "matrix", "BigNumber"], oMe = /* @__PURE__ */ Ce(aMe, iMe, (e) => {
  var {
    typed: r,
    config: t,
    matrix: n,
    BigNumber: a
  } = e;
  return r("ones", {
    "": function() {
      return t.matrix === "Array" ? i([]) : i([], "default");
    },
    // math.ones(m, n, p, ..., format)
    // TODO: more accurate signature '...number | BigNumber, string' as soon as typed-function supports this
    "...number | BigNumber | string": function(u) {
      var l = u[u.length - 1];
      if (typeof l == "string") {
        var f = u.pop();
        return i(u, f);
      } else return t.matrix === "Array" ? i(u) : i(u, "default");
    },
    Array: i,
    Matrix: function(u) {
      var l = u.storage();
      return i(u.valueOf(), l);
    },
    "Array | Matrix, string": function(u, l) {
      return i(u.valueOf(), l);
    }
  });
  function i(s, u) {
    var l = o(s), f = l ? new a(1) : 1;
    if (c(s), u) {
      var d = n(u);
      return s.length > 0 ? d.resize(s, f) : d;
    } else {
      var m = [];
      return s.length > 0 ? fp(m, s, f) : m;
    }
  }
  function o(s) {
    var u = !1;
    return s.forEach(function(l, f, d) {
      Ir(l) && (u = !0, d[f] = l.toNumber());
    }), u;
  }
  function c(s) {
    s.forEach(function(u) {
      if (typeof u != "number" || !lr(u) || u < 0)
        throw new Error("Parameters in function ones must be positive integers");
    });
  }
});
function VD() {
  throw new Error('No "bignumber" implementation available');
}
function IX() {
  throw new Error('No "fraction" implementation available');
}
function BX() {
  throw new Error('No "matrix" implementation available');
}
var LO = "range", uMe = ["typed", "config", "?matrix", "?bignumber", "smaller", "smallerEq", "larger", "largerEq", "add", "isPositive"], RD = /* @__PURE__ */ Ce(LO, uMe, (e) => {
  var {
    typed: r,
    config: t,
    matrix: n,
    bignumber: a,
    smaller: i,
    smallerEq: o,
    larger: c,
    largerEq: s,
    add: u,
    isPositive: l
  } = e;
  return r(LO, {
    // 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: d,
    "string, boolean": d,
    "number, number": function(h, y) {
      return f(m(h, y, 1, !1));
    },
    "number, number, number": function(h, y, C) {
      return f(m(h, y, C, !1));
    },
    "number, number, boolean": function(h, y, C) {
      return f(m(h, y, 1, C));
    },
    "number, number, number, boolean": function(h, y, C, S) {
      return f(m(h, y, C, S));
    },
    "BigNumber, BigNumber": function(h, y) {
      var C = h.constructor;
      return f(m(h, y, new C(1), !1));
    },
    "BigNumber, BigNumber, BigNumber": function(h, y, C) {
      return f(m(h, y, C, !1));
    },
    "BigNumber, BigNumber, boolean": function(h, y, C) {
      var S = h.constructor;
      return f(m(h, y, new S(1), C));
    },
    "BigNumber, BigNumber, BigNumber, boolean": function(h, y, C, S) {
      return f(m(h, y, C, S));
    },
    "Unit, Unit, Unit": function(h, y, C) {
      return f(m(h, y, C, !1));
    },
    "Unit, Unit, Unit, boolean": function(h, y, C, S) {
      return f(m(h, y, C, S));
    }
  });
  function f(v) {
    return t.matrix === "Matrix" ? n ? n(v) : BX() : v;
  }
  function d(v, h) {
    var y = p(v);
    if (!y)
      throw new SyntaxError('String "' + v + '" is no valid range');
    return t.number === "BigNumber" ? (a === void 0 && VD(), f(m(a(y.start), a(y.end), a(y.step)))) : f(m(y.start, y.end, y.step, h));
  }
  function m(v, h, y, C) {
    for (var S = [], b = l(y) ? C ? o : i : C ? s : c, g = v; b(g, h); )
      S.push(g), g = u(g, y);
    return S;
  }
  function p(v) {
    var h = v.split(":"), y = h.map(function(S) {
      return Number(S);
    }), C = y.some(function(S) {
      return isNaN(S);
    });
    if (C)
      return null;
    switch (y.length) {
      case 2:
        return {
          start: y[0],
          end: y[1],
          step: 1
        };
      case 3:
        return {
          start: y[0],
          end: y[2],
          step: y[1]
        };
      default:
        return null;
    }
  }
}), kO = "reshape", sMe = ["typed", "isInteger", "matrix"], NX = /* @__PURE__ */ Ce(kO, sMe, (e) => {
  var {
    typed: r,
    isInteger: t
  } = e;
  return r(kO, {
    "Matrix, Array": function(a, i) {
      return a.reshape(i, !0);
    },
    "Array, Array": function(a, i) {
      return i.forEach(function(o) {
        if (!t(o))
          throw new TypeError("Invalid size for dimension: " + o);
      }), TD(a, i);
    }
  });
}), lMe = "resize", cMe = ["config", "matrix"], dMe = /* @__PURE__ */ Ce(lMe, cMe, (e) => {
  var {
    config: r,
    matrix: t
  } = e;
  return function(i, o, c) {
    if (arguments.length !== 2 && arguments.length !== 3)
      throw new Ic("resize", arguments.length, 2, 3);
    if (gr(o) && (o = o.valueOf()), Ir(o[0]) && (o = o.map(function(l) {
      return Ir(l) ? l.toNumber() : l;
    })), gr(i))
      return i.resize(o, c, !0);
    if (typeof i == "string")
      return n(i, o, c);
    var s = Array.isArray(i) ? !1 : r.matrix !== "Array";
    if (o.length === 0) {
      for (; Array.isArray(i); )
        i = i[0];
      return Sr(i);
    } else {
      Array.isArray(i) || (i = [i]), i = Sr(i);
      var u = fp(i, o, c);
      return s ? t(u) : u;
    }
  };
  function n(a, i, o) {
    if (o !== void 0) {
      if (typeof o != "string" || o.length !== 1)
        throw new TypeError("Single character expected as defaultValue");
    } else
      o = " ";
    if (i.length !== 1)
      throw new kr(i.length, 1);
    var c = i[0];
    if (typeof c != "number" || !lr(c))
      throw new TypeError("Invalid size, must contain positive integers (size: " + $r(i) + ")");
    if (a.length > c)
      return a.substring(0, c);
    if (a.length < c) {
      for (var s = a, u = 0, l = c - a.length; u < l; u++)
        s += o;
      return s;
    } else
      return a;
  }
}), UO = "rotate", fMe = ["typed", "multiply", "rotationMatrix"], mMe = /* @__PURE__ */ Ce(UO, fMe, (e) => {
  var {
    typed: r,
    multiply: t,
    rotationMatrix: n
  } = e;
  return r(UO, {
    "Array , number | BigNumber | Complex | Unit": function(o, c) {
      a(o, 2);
      var s = t(n(c), o);
      return s.toArray();
    },
    "Matrix , number | BigNumber | Complex | Unit": function(o, c) {
      return a(o, 2), t(n(c), o);
    },
    "Array, number | BigNumber | Complex | Unit, Array | Matrix": function(o, c, s) {
      a(o, 3);
      var u = t(n(c, s), o);
      return u;
    },
    "Matrix, number | BigNumber | Complex | Unit, Array | Matrix": function(o, c, s) {
      return a(o, 3), t(n(c, s), o);
    }
  });
  function a(i, o) {
    var c = Array.isArray(i) ? Fr(i) : i.size();
    if (c.length > 2)
      throw new RangeError("Vector must be of dimensions 1x".concat(o));
    if (c.length === 2 && c[1] !== 1)
      throw new RangeError("Vector must be of dimensions 1x".concat(o));
    if (c[0] !== o)
      throw new RangeError("Vector must be of dimensions 1x".concat(o));
  }
}), zO = "rotationMatrix", vMe = ["typed", "config", "multiplyScalar", "addScalar", "unaryMinus", "norm", "matrix", "BigNumber", "DenseMatrix", "SparseMatrix", "cos", "sin"], pMe = /* @__PURE__ */ Ce(zO, vMe, (e) => {
  var {
    typed: r,
    config: t,
    multiplyScalar: n,
    addScalar: a,
    unaryMinus: i,
    norm: o,
    BigNumber: c,
    matrix: s,
    DenseMatrix: u,
    SparseMatrix: l,
    cos: f,
    sin: d
  } = e;
  return r(zO, {
    "": function() {
      return t.matrix === "Matrix" ? s([]) : [];
    },
    string: function(S) {
      return s(S);
    },
    "number | BigNumber | Complex | Unit": function(S) {
      return m(S, t.matrix === "Matrix" ? "dense" : void 0);
    },
    "number | BigNumber | Complex | Unit, string": function(S, b) {
      return m(S, b);
    },
    "number | BigNumber | Complex | Unit, Array": function(S, b) {
      var g = s(b);
      return p(g), y(S, g, void 0);
    },
    "number | BigNumber | Complex | Unit, Matrix": function(S, b) {
      p(b);
      var g = b.storage() || (t.matrix === "Matrix" ? "dense" : void 0);
      return y(S, b, g);
    },
    "number | BigNumber | Complex | Unit, Array, string": function(S, b, g) {
      var _ = s(b);
      return p(_), y(S, _, g);
    },
    "number | BigNumber | Complex | Unit, Matrix, string": function(S, b, g) {
      return p(b), y(S, b, g);
    }
  });
  function m(C, S) {
    var b = Ir(C), g = b ? new c(-1) : -1, _ = f(C), A = d(C), M = [[_, n(g, A)], [A, _]];
    return h(M, S);
  }
  function p(C) {
    var S = C.size();
    if (S.length < 1 || S[0] !== 3)
      throw new RangeError("Vector must be of dimensions 1x3");
  }
  function v(C) {
    return C.reduce((S, b) => n(S, b));
  }
  function h(C, S) {
    if (S) {
      if (S === "sparse")
        return new l(C);
      if (S === "dense")
        return new u(C);
      throw new TypeError('Unknown matrix type "'.concat(S, '"'));
    }
    return C;
  }
  function y(C, S, b) {
    var g = o(S);
    if (g === 0)
      throw new RangeError("Rotation around zero vector");
    var _ = Ir(C) ? c : null, A = _ ? new _(1) : 1, M = _ ? new _(-1) : -1, P = _ ? new _(S.get([0]) / g) : S.get([0]) / g, T = _ ? new _(S.get([1]) / g) : S.get([1]) / g, x = _ ? new _(S.get([2]) / g) : S.get([2]) / g, w = f(C), E = a(A, i(w)), I = d(C), B = a(w, v([P, P, E])), D = a(v([P, T, E]), v([M, x, I])), N = a(v([P, x, E]), v([T, I])), O = a(v([P, T, E]), v([x, I])), V = a(w, v([T, T, E])), k = a(v([T, x, E]), v([M, P, I])), G = a(v([P, x, E]), v([M, T, I])), L = a(v([T, x, E]), v([P, I])), R = a(w, v([x, x, E])), F = [[B, D, N], [O, V, k], [G, L, R]];
    return h(F, b);
  }
}), GO = "row", hMe = ["typed", "Index", "matrix", "range"], VX = /* @__PURE__ */ Ce(GO, hMe, (e) => {
  var {
    typed: r,
    Index: t,
    matrix: n,
    range: a
  } = e;
  return r(GO, {
    "Matrix, number": i,
    "Array, number": function(c, s) {
      return i(n(Sr(c)), s).valueOf();
    }
  });
  function i(o, c) {
    if (o.size().length !== 2)
      throw new Error("Only two dimensional matrix is supported");
    Pt(c, o.size()[0]);
    var s = a(0, o.size()[1]), u = new t(c, s), l = o.subset(u);
    return gr(l) ? l : n([[l]]);
  }
}), qO = "size", gMe = ["typed", "config", "?matrix"], RX = /* @__PURE__ */ Ce(qO, gMe, (e) => {
  var {
    typed: r,
    config: t,
    matrix: n
  } = e;
  return r(qO, {
    Matrix: function(i) {
      return i.create(i.size());
    },
    Array: Fr,
    string: function(i) {
      return t.matrix === "Array" ? [i.length] : n([i.length]);
    },
    "number | Complex | BigNumber | Unit | boolean | null": function(i) {
      return t.matrix === "Array" ? [] : n ? n([]) : BX();
    }
  });
}), HO = "squeeze", yMe = ["typed", "matrix"], _Me = /* @__PURE__ */ Ce(HO, yMe, (e) => {
  var {
    typed: r,
    matrix: t
  } = e;
  return r(HO, {
    Array: function(a) {
      return _3(Sr(a));
    },
    Matrix: function(a) {
      var i = _3(a.toArray());
      return Array.isArray(i) ? t(i) : i;
    },
    any: function(a) {
      return Sr(a);
    }
  });
}), jO = "subset", bMe = ["typed", "matrix", "zeros", "add"], OX = /* @__PURE__ */ Ce(jO, bMe, (e) => {
  var {
    typed: r,
    matrix: t,
    zeros: n,
    add: a
  } = e;
  return r(jO, {
    // get subset
    "Matrix, Index": function(c, s) {
      return dp(s) ? t() : (y3(c, s), c.subset(s));
    },
    "Array, Index": r.referTo("Matrix, Index", function(o) {
      return function(c, s) {
        var u = o(t(c), s);
        return s.isScalar() ? u : u.valueOf();
      };
    }),
    "Object, Index": CMe,
    "string, Index": SMe,
    // set subset
    "Matrix, Index, any, any": function(c, s, u, l) {
      return dp(s) ? c : (y3(c, s), c.clone().subset(s, i(u, s), l));
    },
    "Array, Index, any, any": r.referTo("Matrix, Index, any, any", function(o) {
      return function(c, s, u, l) {
        var f = o(t(c), s, u, l);
        return f.isMatrix ? f.valueOf() : f;
      };
    }),
    "Array, Index, any": r.referTo("Matrix, Index, any, any", function(o) {
      return function(c, s, u) {
        return o(t(c), s, u, void 0).valueOf();
      };
    }),
    "Matrix, Index, any": r.referTo("Matrix, Index, any, any", function(o) {
      return function(c, s, u) {
        return o(c, s, u, void 0);
      };
    }),
    "string, Index, string": $O,
    "string, Index, string, string": $O,
    "Object, Index, any": AMe
  });
  function i(o, c) {
    if (typeof o == "string")
      throw new Error("can't boradcast a string");
    if (c._isScalar)
      return o;
    var s = c.size();
    if (s.every((u) => u > 0))
      try {
        return a(o, n(s));
      } catch {
        return o;
      }
    else
      return o;
  }
});
function SMe(e, r) {
  if (!zy(r))
    throw new TypeError("Index expected");
  if (dp(r))
    return "";
  if (y3(Array.from(e), r), r.size().length !== 1)
    throw new kr(r.size().length, 1);
  var t = e.length;
  Pt(r.min()[0], t), Pt(r.max()[0], t);
  var n = r.dimension(0), a = "";
  return n.forEach(function(i) {
    a += e.charAt(i);
  }), a;
}
function $O(e, r, t, n) {
  if (!r || r.isIndex !== !0)
    throw new TypeError("Index expected");
  if (dp(r))
    return e;
  if (y3(Array.from(e), r), r.size().length !== 1)
    throw new kr(r.size().length, 1);
  if (n !== void 0) {
    if (typeof n != "string" || n.length !== 1)
      throw new TypeError("Single character expected as defaultValue");
  } else
    n = " ";
  var a = r.dimension(0), i = a.size()[0];
  if (i !== t.length)
    throw new kr(a.size()[0], t.length);
  var o = e.length;
  Pt(r.min()[0]), Pt(r.max()[0]);
  for (var c = [], s = 0; s < o; s++)
    c[s] = e.charAt(s);
  if (a.forEach(function(f, d) {
    c[f] = t.charAt(d[0]);
  }), c.length > o)
    for (var u = o - 1, l = c.length; u < l; u++)
      c[u] || (c[u] = n);
  return c.join("");
}
function CMe(e, r) {
  if (!dp(r)) {
    if (r.size().length !== 1)
      throw new kr(r.size(), 1);
    var t = r.dimension(0);
    if (typeof t != "string")
      throw new TypeError("String expected as index to retrieve an object property");
    return Ki(e, t);
  }
}
function AMe(e, r, t) {
  if (dp(r))
    return e;
  if (r.size().length !== 1)
    throw new kr(r.size(), 1);
  var n = r.dimension(0);
  if (typeof n != "string")
    throw new TypeError("String expected as index to retrieve an object property");
  var a = Sr(e);
  return lp(a, n, t), a;
}
var KO = "transpose", xMe = ["typed", "matrix"], FX = /* @__PURE__ */ Ce(KO, xMe, (e) => {
  var {
    typed: r,
    matrix: t
  } = e;
  return r(KO, {
    Array: (o) => n(t(o)).valueOf(),
    Matrix: n,
    any: Sr
    // scalars
  });
  function n(o) {
    var c = o.size(), s;
    switch (c.length) {
      case 1:
        s = o.clone();
        break;
      case 2:
        {
          var u = c[0], l = c[1];
          if (l === 0)
            throw new RangeError("Cannot transpose a 2D matrix with no columns (size: " + $r(c) + ")");
          switch (o.storage()) {
            case "dense":
              s = a(o, u, l);
              break;
            case "sparse":
              s = i(o, u, l);
              break;
          }
        }
        break;
      default:
        throw new RangeError("Matrix must be a vector or two dimensional (size: " + $r(c) + ")");
    }
    return s;
  }
  function a(o, c, s) {
    for (var u = o._data, l = [], f, d = 0; d < s; d++) {
      f = l[d] = [];
      for (var m = 0; m < c; m++)
        f[m] = Sr(u[m][d]);
    }
    return o.createDenseMatrix({
      data: l,
      size: [s, c],
      datatype: o._datatype
    });
  }
  function i(o, c, s) {
    for (var u = o._values, l = o._index, f = o._ptr, d = u ? [] : void 0, m = [], p = [], v = [], h = 0; h < c; h++)
      v[h] = 0;
    var y, C, S;
    for (y = 0, C = l.length; y < C; y++)
      v[l[y]]++;
    for (var b = 0, g = 0; g < c; g++)
      p.push(b), b += v[g], v[g] = p[g];
    for (p.push(b), S = 0; S < s; S++)
      for (var _ = f[S], A = f[S + 1], M = _; M < A; M++) {
        var P = v[l[M]]++;
        m[P] = S, u && (d[P] = Sr(u[M]));
      }
    return o.createSparseMatrix({
      values: d,
      index: m,
      ptr: p,
      size: [s, c],
      datatype: o._datatype
    });
  }
}), WO = "ctranspose", TMe = ["typed", "transpose", "conj"], LX = /* @__PURE__ */ Ce(WO, TMe, (e) => {
  var {
    typed: r,
    transpose: t,
    conj: n
  } = e;
  return r(WO, {
    any: function(i) {
      return n(t(i));
    }
  });
}), XO = "zeros", PMe = ["typed", "config", "matrix", "BigNumber"], kX = /* @__PURE__ */ Ce(XO, PMe, (e) => {
  var {
    typed: r,
    config: t,
    matrix: n,
    BigNumber: a
  } = e;
  return r(XO, {
    "": function() {
      return t.matrix === "Array" ? i([]) : i([], "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(u) {
      var l = u[u.length - 1];
      if (typeof l == "string") {
        var f = u.pop();
        return i(u, f);
      } else return t.matrix === "Array" ? i(u) : i(u, "default");
    },
    Array: i,
    Matrix: function(u) {
      var l = u.storage();
      return i(u.valueOf(), l);
    },
    "Array | Matrix, string": function(u, l) {
      return i(u.valueOf(), l);
    }
  });
  function i(s, u) {
    var l = o(s), f = l ? new a(0) : 0;
    if (c(s), u) {
      var d = n(u);
      return s.length > 0 ? d.resize(s, f) : d;
    } else {
      var m = [];
      return s.length > 0 ? fp(m, s, f) : m;
    }
  }
  function o(s) {
    var u = !1;
    return s.forEach(function(l, f, d) {
      Ir(l) && (u = !0, d[f] = l.toNumber());
    }), u;
  }
  function c(s) {
    s.forEach(function(u) {
      if (typeof u != "number" || !lr(u) || u < 0)
        throw new Error("Parameters in function zeros must be positive integers");
    });
  }
}), YO = "fft", MMe = ["typed", "matrix", "addScalar", "multiplyScalar", "divideScalar", "exp", "tau", "i", "dotDivide", "conj", "pow", "ceil", "log2"], wMe = /* @__PURE__ */ Ce(YO, MMe, (e) => {
  var {
    typed: r,
    matrix: t,
    addScalar: n,
    multiplyScalar: a,
    divideScalar: i,
    exp: o,
    tau: c,
    i: s,
    dotDivide: u,
    conj: l,
    pow: f,
    ceil: d,
    log2: m
  } = e;
  return r(YO, {
    Array: p,
    Matrix: function(S) {
      return S.create(p(S.toArray()));
    }
  });
  function p(C) {
    var S = Fr(C);
    return S.length === 1 ? y(C, S[0]) : v(C.map((b) => p(b, S.slice(1))), 0);
  }
  function v(C, S) {
    var b = Fr(C);
    if (S !== 0) return new Array(b[0]).fill(0).map((_, A) => v(C[A], S - 1));
    if (b.length === 1) return y(C);
    function g(_) {
      var A = Fr(_);
      return new Array(A[1]).fill(0).map((M, P) => new Array(A[0]).fill(0).map((T, x) => _[x][P]));
    }
    return g(v(g(C), 1));
  }
  function h(C) {
    for (var S = C.length, b = o(i(a(-1, a(s, c)), S)), g = [], _ = 1 - S; _ < S; _++)
      g.push(f(b, i(f(_, 2), 2)));
    for (var A = f(2, d(m(S + S - 1))), M = [...new Array(S).fill(0).map((D, N) => a(C[N], g[S - 1 + N])), ...new Array(A - S).fill(0)], P = [...new Array(S + S - 1).fill(0).map((D, N) => i(1, g[N])), ...new Array(A - (S + S - 1)).fill(0)], T = y(M), x = y(P), w = new Array(A).fill(0).map((D, N) => a(T[N], x[N])), E = u(l(p(l(w))), A), I = [], B = S - 1; B < S + S - 1; B++)
      I.push(a(E[B], g[B]));
    return I;
  }
  function y(C) {
    var S = C.length;
    if (S === 1) return [C[0]];
    if (S % 2 === 0) {
      for (var b = [...y(C.filter((M, P) => P % 2 === 0)), ...y(C.filter((M, P) => P % 2 === 1))], g = 0; g < S / 2; g++) {
        var _ = b[g], A = a(b[g + S / 2], o(a(a(c, s), i(-g, S))));
        b[g] = n(_, A), b[g + S / 2] = n(_, a(-1, A));
      }
      return b;
    } else
      return h(C);
  }
}), QO = "ifft", EMe = ["typed", "fft", "dotDivide", "conj"], DMe = /* @__PURE__ */ Ce(QO, EMe, (e) => {
  var {
    typed: r,
    fft: t,
    dotDivide: n,
    conj: a
  } = e;
  return r(QO, {
    "Array | Matrix": function(o) {
      var c = gr(o) ? o.size() : Fr(o);
      return n(a(t(a(o))), c.reduce((s, u) => s * u, 1));
    }
  });
});
function Gg(e) {
  "@babel/helpers - typeof";
  return Gg = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(r) {
    return typeof r;
  } : function(r) {
    return r && typeof Symbol == "function" && r.constructor === Symbol && r !== Symbol.prototype ? "symbol" : typeof r;
  }, Gg(e);
}
function IMe(e, r) {
  if (Gg(e) != "object" || !e) return e;
  var t = e[Symbol.toPrimitive];
  if (t !== void 0) {
    var n = t.call(e, r || "default");
    if (Gg(n) != "object") return n;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return (r === "string" ? String : Number)(e);
}
function BMe(e) {
  var r = IMe(e, "string");
  return Gg(r) == "symbol" ? r : r + "";
}
function ba(e, r, t) {
  return (r = BMe(r)) in e ? Object.defineProperty(e, r, {
    value: t,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : e[r] = t, e;
}
function ZO(e, r) {
  var t = Object.keys(e);
  if (Object.getOwnPropertySymbols) {
    var n = Object.getOwnPropertySymbols(e);
    r && (n = n.filter(function(a) {
      return Object.getOwnPropertyDescriptor(e, a).enumerable;
    })), t.push.apply(t, n);
  }
  return t;
}
function NMe(e) {
  for (var r = 1; r < arguments.length; r++) {
    var t = arguments[r] != null ? arguments[r] : {};
    r % 2 ? ZO(Object(t), !0).forEach(function(n) {
      ba(e, n, t[n]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ZO(Object(t)).forEach(function(n) {
      Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(t, n));
    });
  }
  return e;
}
var VMe = "solveODE", RMe = ["typed", "add", "subtract", "multiply", "divide", "max", "map", "abs", "isPositive", "isNegative", "larger", "smaller", "matrix", "bignumber", "unaryMinus"], OMe = /* @__PURE__ */ Ce(VMe, RMe, (e) => {
  var {
    typed: r,
    add: t,
    subtract: n,
    multiply: a,
    divide: i,
    max: o,
    map: c,
    abs: s,
    isPositive: u,
    isNegative: l,
    larger: f,
    smaller: d,
    matrix: m,
    bignumber: p,
    unaryMinus: v
  } = e;
  function h(M) {
    return function(P, T, x, w) {
      var E = !(T.length === 2 && (T.every(_) || T.every(ho)));
      if (E)
        throw new Error('"tspan" must be an Array of two numeric values or two units [tStart, tEnd]');
      var I = T[0], B = T[1], D = f(B, I), N = w.firstStep;
      if (N !== void 0 && !u(N))
        throw new Error('"firstStep" must be positive');
      var O = w.maxStep;
      if (O !== void 0 && !u(O))
        throw new Error('"maxStep" must be positive');
      var V = w.minStep;
      if (V && l(V))
        throw new Error('"minStep" must be positive or zero');
      var k = [I, B, N, V, O].filter((re) => re !== void 0);
      if (!(k.every(_) || k.every(ho)))
        throw new Error('Inconsistent type of "t" dependant variables');
      for (var G = 1, L = w.tol ? w.tol : 1e-4, R = w.minDelta ? w.minDelta : 0.2, F = w.maxDelta ? w.maxDelta : 5, U = w.maxIter ? w.maxIter : 1e4, H = [I, B, ...x, O, V].some(Ir), [q, K, Y, X] = H ? [p(M.a), p(M.c), p(M.b), p(M.bp)] : [M.a, M.c, M.b, M.bp], Z = N ? D ? N : v(N) : i(n(B, I), G), J = [I], $ = [x], Q = n(Y, X), W = 0, te = 0, oe = b(D), z = g(D); oe(J[W], B); ) {
        var j = [];
        Z = z(J[W], B, Z), j.push(P(J[W], $[W]));
        for (var ae = 1; ae < K.length; ++ae)
          j.push(P(t(J[W], a(K[ae], Z)), t($[W], a(Z, q[ae], j))));
        var le = o(s(c(a(Q, j), (re) => ho(re) ? re.value : re)));
        le < L && L / le > 1 / 4 && (J.push(t(J[W], Z)), $.push(t($[W], a(Z, Y, j))), W++);
        var ie = 0.84 * (L / le) ** (1 / 5);
        if (d(ie, R) ? ie = R : f(ie, F) && (ie = F), ie = H ? p(ie) : ie, Z = a(Z, ie), O && f(s(Z), O) ? Z = D ? O : v(O) : V && d(s(Z), V) && (Z = D ? V : v(V)), te++, te > U)
          throw new Error("Maximum number of iterations reached, try changing options");
      }
      return {
        t: J,
        y: $
      };
    };
  }
  function y(M, P, T, x) {
    var w = [[], [0.5], [0, 0.75], [0.2222222222222222, 0.3333333333333333, 0.4444444444444444]], E = [null, 1 / 2, 3 / 4, 1], I = [2 / 9, 1 / 3, 4 / 9, 0], B = [7 / 24, 1 / 4, 1 / 3, 1 / 8], D = {
      a: w,
      c: E,
      b: I,
      bp: B
    };
    return h(D)(M, P, T, x);
  }
  function C(M, P, T, x) {
    var w = [[], [0.2], [0.075, 0.225], [0.9777777777777777, -3.7333333333333334, 3.5555555555555554], [2.9525986892242035, -11.595793324188385, 9.822892851699436, -0.2908093278463649], [2.8462752525252526, -10.757575757575758, 8.906422717743473, 0.2784090909090909, -0.2735313036020583], [0.09114583333333333, 0, 0.44923629829290207, 0.6510416666666666, -0.322376179245283, 0.13095238095238096]], E = [null, 1 / 5, 3 / 10, 4 / 5, 8 / 9, 1, 1], I = [35 / 384, 0, 500 / 1113, 125 / 192, -2187 / 6784, 11 / 84, 0], B = [5179 / 57600, 0, 7571 / 16695, 393 / 640, -92097 / 339200, 187 / 2100, 1 / 40], D = {
      a: w,
      c: E,
      b: I,
      bp: B
    };
    return h(D)(M, P, T, x);
  }
  function S(M, P, T, x) {
    var w = x.method ? x.method : "RK45", E = {
      RK23: y,
      RK45: C
    };
    if (w.toUpperCase() in E) {
      var I = NMe({}, x);
      return delete I.method, E[w.toUpperCase()](M, P, T, I);
    } else {
      var B = Object.keys(E).map((N) => '"'.concat(N, '"')), D = "".concat(B.slice(0, -1).join(", "), " and ").concat(B.slice(-1));
      throw new Error('Unavailable method "'.concat(w, '". Available methods are ').concat(D));
    }
  }
  function b(M) {
    return M ? d : f;
  }
  function g(M) {
    var P = M ? f : d;
    return function(T, x, w) {
      var E = t(T, w);
      return P(E, x) ? n(x, T) : w;
    };
  }
  function _(M) {
    return Ir(M) || Or(M);
  }
  function A(M, P, T, x) {
    var w = S(M, P.toArray(), T.toArray(), x);
    return {
      t: m(w.t),
      y: m(w.y)
    };
  }
  return r("solveODE", {
    "function, Array, Array, Object": S,
    "function, Matrix, Matrix, Object": A,
    "function, Array, Array": (M, P, T) => S(M, P, T, {}),
    "function, Matrix, Matrix": (M, P, T) => A(M, P, T, {}),
    "function, Array, number | BigNumber | Unit": (M, P, T) => {
      var x = S(M, P, [T], {});
      return {
        t: x.t,
        y: x.y.map((w) => w[0])
      };
    },
    "function, Matrix, number | BigNumber | Unit": (M, P, T) => {
      var x = S(M, P.toArray(), [T], {});
      return {
        t: m(x.t),
        y: m(x.y.map((w) => w[0]))
      };
    },
    "function, Array, number | BigNumber | Unit, Object": (M, P, T, x) => {
      var w = S(M, P, [T], x);
      return {
        t: w.t,
        y: w.y.map((E) => E[0])
      };
    },
    "function, Matrix, number | BigNumber | Unit, Object": (M, P, T, x) => {
      var w = S(M, P.toArray(), [T], x);
      return {
        t: m(w.t),
        y: m(w.y.map((E) => E[0]))
      };
    }
  });
}), FMe = "erf", LMe = ["typed"], kMe = /* @__PURE__ */ Ce(FMe, LMe, (e) => {
  var {
    typed: r
  } = e;
  return r("name", {
    number: function(o) {
      var c = Math.abs(o);
      return c >= GMe ? fd(o) : c <= UMe ? fd(o) * t(c) : c <= 4 ? fd(o) * (1 - n(c)) : fd(o) * (1 - a(c));
    },
    "Array | Matrix": r.referToSelf((i) => (o) => zr(o, i))
    // TODO: For complex numbers, use the approximation for the Faddeeva function
    //  from "More Efficient Computation of the Complex Error Function" (AMS)
  });
  function t(i) {
    var o = i * i, c = ql[0][4] * o, s = o, u;
    for (u = 0; u < 3; u += 1)
      c = (c + ql[0][u]) * o, s = (s + zm[0][u]) * o;
    return i * (c + ql[0][3]) / (s + zm[0][3]);
  }
  function n(i) {
    var o = ql[1][8] * i, c = i, s;
    for (s = 0; s < 7; s += 1)
      o = (o + ql[1][s]) * i, c = (c + zm[1][s]) * i;
    var u = (o + ql[1][7]) / (c + zm[1][7]), l = parseInt(i * 16) / 16, f = (i - l) * (i + l);
    return Math.exp(-l * l) * Math.exp(-f) * u;
  }
  function a(i) {
    var o = 1 / (i * i), c = ql[2][5] * o, s = o, u;
    for (u = 0; u < 4; u += 1)
      c = (c + ql[2][u]) * o, s = (s + zm[2][u]) * o;
    var l = o * (c + ql[2][4]) / (s + zm[2][4]);
    l = (zMe - l) / i, o = parseInt(i * 16) / 16;
    var f = (i - o) * (i + o);
    return Math.exp(-o * o) * Math.exp(-f) * l;
  }
}), UMe = 0.46875, zMe = 0.5641895835477563, ql = [[3.1611237438705655, 113.86415415105016, 377.485237685302, 3209.3775891384694, 0.18577770618460315], [0.5641884969886701, 8.883149794388377, 66.11919063714163, 298.6351381974001, 881.952221241769, 1712.0476126340707, 2051.0783778260716, 1230.3393547979972, 21531153547440383e-24], [0.30532663496123236, 0.36034489994980445, 0.12578172611122926, 0.016083785148742275, 6587491615298378e-19, 0.016315387137302097]], zm = [[23.601290952344122, 244.02463793444417, 1282.6165260773723, 2844.236833439171], [15.744926110709835, 117.6939508913125, 537.1811018620099, 1621.3895745666903, 3290.7992357334597, 4362.619090143247, 3439.3676741437216, 1230.3393548037495], [2.568520192289822, 1.8729528499234604, 0.5279051029514285, 0.06051834131244132, 0.0023352049762686918]], GMe = Math.pow(2, 53), JO = "zeta", qMe = ["typed", "config", "multiply", "pow", "divide", "factorial", "equal", "smallerEq", "isNegative", "gamma", "sin", "subtract", "add", "?Complex", "?BigNumber", "pi"], HMe = /* @__PURE__ */ Ce(JO, qMe, (e) => {
  var {
    typed: r,
    config: t,
    multiply: n,
    pow: a,
    divide: i,
    factorial: o,
    equal: c,
    smallerEq: s,
    isNegative: u,
    gamma: l,
    sin: f,
    subtract: d,
    add: m,
    Complex: p,
    BigNumber: v,
    pi: h
  } = e;
  return r(JO, {
    number: (_) => y(_, (A) => A, () => 20),
    BigNumber: (_) => y(_, (A) => new v(A), () => Math.abs(Math.log10(t.relTol))),
    Complex: C
  });
  function y(_, A, M) {
    return c(_, 0) ? A(-0.5) : c(_, 1) ? A(NaN) : isFinite(_) ? S(_, A, M, (P) => P) : u(_) ? A(NaN) : A(1);
  }
  function C(_) {
    return _.re === 0 && _.im === 0 ? new p(-0.5) : _.re === 1 ? new p(NaN, NaN) : _.re === 1 / 0 && _.im === 0 ? new p(1) : _.im === 1 / 0 || _.re === -1 / 0 ? new p(NaN, NaN) : S(_, (A) => A, (A) => Math.round(1.3 * 15 + 0.9 * Math.abs(A.im)), (A) => A.re);
  }
  function S(_, A, M, P) {
    var T = M(_);
    if (P(_) > -(T - 1) / 2)
      return g(_, A(T), A);
    var x = n(a(2, _), a(A(h), d(_, 1)));
    return x = n(x, f(n(i(A(h), 2), _))), x = n(x, l(d(1, _))), n(x, S(d(1, _), A, M, P));
  }
  function b(_, A) {
    for (var M = _, P = _; s(P, A); P = m(P, 1)) {
      var T = i(n(o(m(A, d(P, 1))), a(4, P)), n(o(d(A, P)), o(n(2, P))));
      M = m(M, T);
    }
    return n(A, M);
  }
  function g(_, A, M) {
    for (var P = i(1, n(b(M(0), A), d(1, a(2, d(1, _))))), T = M(0), x = M(1); s(x, A); x = m(x, 1))
      T = m(T, i(n((-1) ** (x - 1), b(x, A)), a(x, _)));
    return n(P, T);
  }
}), eF = "mode", jMe = ["typed", "isNaN", "isNumeric"], $Me = /* @__PURE__ */ Ce(eF, jMe, (e) => {
  var {
    typed: r,
    isNaN: t,
    isNumeric: n
  } = e;
  return r(eF, {
    "Array | Matrix": a,
    "...": function(o) {
      return a(o);
    }
  });
  function a(i) {
    i = st(i.valueOf());
    var o = i.length;
    if (o === 0)
      throw new Error("Cannot calculate mode of an empty array");
    for (var c = {}, s = [], u = 0, l = 0; l < i.length; l++) {
      var f = i[l];
      if (n(f) && t(f))
        throw new Error("Cannot calculate mode of an array containing NaN values");
      f in c || (c[f] = 0), c[f]++, c[f] === u ? s.push(f) : c[f] > u && (u = c[f], s = [f]);
    }
    return s;
  }
});
function Xi(e, r, t) {
  var n;
  return String(e).includes("Unexpected type") ? (n = arguments.length > 2 ? " (type: " + Et(t) + ", value: " + JSON.stringify(t) + ")" : " (type: " + e.data.actual + ")", new TypeError("Cannot calculate " + r + ", unexpected type of argument" + n)) : String(e).includes("complex numbers") ? (n = arguments.length > 2 ? " (type: " + Et(t) + ", value: " + JSON.stringify(t) + ")" : "", new TypeError("Cannot calculate " + r + ", no ordering relation is defined for complex numbers" + n)) : e;
}
var rF = "prod", KMe = ["typed", "config", "multiplyScalar", "numeric"], WMe = /* @__PURE__ */ Ce(rF, KMe, (e) => {
  var {
    typed: r,
    config: t,
    multiplyScalar: n,
    numeric: a
  } = e;
  return r(rF, {
    // prod([a, b, c, d, ...])
    "Array | Matrix": i,
    // prod([a, b, c, d, ...], dim)
    "Array | Matrix, number | BigNumber": function(c, s) {
      throw new Error("prod(A, dim) is not yet supported");
    },
    // prod(a, b, c, d, ...)
    "...": function(c) {
      return i(c);
    }
  });
  function i(o) {
    var c;
    if (yc(o, function(s) {
      try {
        c = c === void 0 ? s : n(c, s);
      } catch (u) {
        throw Xi(u, "prod", s);
      }
    }), typeof c == "string" && (c = a(c, rf(c, t))), c === void 0)
      throw new Error("Cannot calculate prod of an empty array");
    return c;
  }
}), tF = "format", XMe = ["typed"], YMe = /* @__PURE__ */ Ce(tF, XMe, (e) => {
  var {
    typed: r
  } = e;
  return r(tF, {
    any: $r,
    "any, Object | function | number | BigNumber": $r
  });
}), nF = "bin", QMe = ["typed", "format"], ZMe = Ce(nF, QMe, (e) => {
  var {
    typed: r,
    format: t
  } = e;
  return r(nF, {
    "number | BigNumber": function(a) {
      return t(a, {
        notation: "bin"
      });
    },
    "number | BigNumber, number | BigNumber": function(a, i) {
      return t(a, {
        notation: "bin",
        wordSize: i
      });
    }
  });
}), aF = "oct", JMe = ["typed", "format"], ewe = Ce(aF, JMe, (e) => {
  var {
    typed: r,
    format: t
  } = e;
  return r(aF, {
    "number | BigNumber": function(a) {
      return t(a, {
        notation: "oct"
      });
    },
    "number | BigNumber, number | BigNumber": function(a, i) {
      return t(a, {
        notation: "oct",
        wordSize: i
      });
    }
  });
}), iF = "hex", rwe = ["typed", "format"], twe = Ce(iF, rwe, (e) => {
  var {
    typed: r,
    format: t
  } = e;
  return r(iF, {
    "number | BigNumber": function(a) {
      return t(a, {
        notation: "hex"
      });
    },
    "number | BigNumber, number | BigNumber": function(a, i) {
      return t(a, {
        notation: "hex",
        wordSize: i
      });
    }
  });
}), UX = /\$([\w.]+)/g, oF = "print", nwe = ["typed"], zX = /* @__PURE__ */ Ce(oF, nwe, (e) => {
  var {
    typed: r
  } = e;
  return r(oF, {
    // note: Matrix will be converted automatically to an Array
    "string, Object | Array": uF,
    "string, Object | Array, number | Object": uF
  });
});
function uF(e, r, t) {
  return e.replace(UX, function(n, a) {
    var i = a.split("."), o = r[i.shift()];
    for (o !== void 0 && o.isMatrix && (o = o.toArray()); i.length && o !== void 0; ) {
      var c = i.shift();
      o = c ? o[c] : o + ".";
    }
    return o !== void 0 ? Ya(o) ? o : $r(o, t) : n;
  });
}
var sF = "to", awe = ["typed", "matrix", "concat"], iwe = /* @__PURE__ */ Ce(sF, awe, (e) => {
  var {
    typed: r,
    matrix: t,
    concat: n
  } = e, a = kt({
    typed: r,
    matrix: t,
    concat: n
  });
  return r(sF, {
    "Unit, Unit | string": (i, o) => i.to(o)
  }, a({
    Ds: !0
  }));
}), lF = "isPrime", owe = ["typed"], uwe = /* @__PURE__ */ Ce(lF, owe, (e) => {
  var {
    typed: r
  } = e;
  return r(lF, {
    number: function(n) {
      if (n <= 3)
        return n > 1;
      if (n % 2 === 0 || n % 3 === 0)
        return !1;
      for (var a = 5; a * a <= n; a += 6)
        if (n % a === 0 || n % (a + 2) === 0)
          return !1;
      return !0;
    },
    bigint: function(n) {
      if (n <= 3n)
        return n > 1n;
      if (n % 2n === 0n || n % 3n === 0n)
        return !1;
      for (var a = 5n; a * a <= n; a += 6n)
        if (n % a === 0n || n % (a + 2n) === 0n)
          return !1;
      return !0;
    },
    BigNumber: function(n) {
      if (n.lte(3)) return n.gt(1);
      if (n.mod(2).eq(0) || n.mod(3).eq(0)) return !1;
      if (n.lt(Math.pow(2, 32))) {
        for (var a = n.toNumber(), i = 5; i * i <= a; i += 6)
          if (a % i === 0 || a % (i + 2) === 0)
            return !1;
        return !0;
      }
      function o(C, S, b) {
        for (var g = 1; !S.eq(0); )
          S.mod(2).eq(0) ? (S = S.div(2), C = C.mul(C).mod(b)) : (S = S.sub(1), g = C.mul(g).mod(b));
        return g;
      }
      var c = n.constructor.clone({
        precision: n.toFixed(0).length * 2
      });
      n = new c(n);
      for (var s = 0, u = n.sub(1); u.mod(2).eq(0); )
        u = u.div(2), s += 1;
      var l = null;
      if (n.lt("3317044064679887385961981"))
        l = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41].filter((C) => C < n);
      else {
        var f = Math.min(n.toNumber() - 2, Math.floor(2 * Math.pow(n.toFixed(0).length * Math.log(10), 2)));
        l = [];
        for (var d = 2; d <= f; d += 1)
          l.push(f);
      }
      for (var m = 0; m < l.length; m += 1) {
        var p = l[m], v = o(n.sub(n).add(p), u, n);
        if (!v.eq(1)) {
          for (var h = 0, y = v; !y.eq(n.sub(1)); h += 1, y = y.mul(y).mod(n))
            if (h === s - 1)
              return !1;
        }
      }
      return !0;
    },
    "Array | Matrix": r.referToSelf((t) => (n) => zr(n, t))
  });
}), swe = "numeric", lwe = ["number", "?bignumber", "?fraction"], GX = /* @__PURE__ */ Ce(swe, lwe, (e) => {
  var {
    number: r,
    bignumber: t,
    fraction: n
  } = e, a = {
    string: !0,
    number: !0,
    BigNumber: !0,
    Fraction: !0
  }, i = {
    number: (o) => r(o),
    BigNumber: t ? (o) => t(o) : VD,
    bigint: (o) => BigInt(o),
    Fraction: n ? (o) => n(o) : IX
  };
  return function(c) {
    var s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "number", u = arguments.length > 2 ? arguments[2] : void 0;
    if (u !== void 0)
      throw new SyntaxError("numeric() takes one or two arguments");
    var l = Et(c);
    if (!(l in a))
      throw new TypeError("Cannot convert " + c + ' of type "' + l + '"; valid input types are ' + Object.keys(a).join(", "));
    if (!(s in i))
      throw new TypeError("Cannot convert " + c + ' to type "' + s + '"; valid output types are ' + Object.keys(i).join(", "));
    return s === l ? c : i[s](c);
  };
}), cF = "divideScalar", cwe = ["typed", "numeric"], qX = /* @__PURE__ */ Ce(cF, cwe, (e) => {
  var {
    typed: r,
    numeric: t
  } = e;
  return r(cF, {
    "number, number": function(a, i) {
      return a / i;
    },
    "Complex, Complex": function(a, i) {
      return a.div(i);
    },
    "BigNumber, BigNumber": function(a, i) {
      return a.div(i);
    },
    "bigint, bigint": function(a, i) {
      return a / i;
    },
    "Fraction, Fraction": function(a, i) {
      return a.div(i);
    },
    "Unit, number | Complex | Fraction | BigNumber | Unit": (n, a) => n.divide(a),
    "number | Fraction | Complex | BigNumber, Unit": (n, a) => a.divideInto(n)
  });
}), dF = "pow", dwe = ["typed", "config", "identity", "multiply", "matrix", "inv", "fraction", "number", "Complex"], HX = /* @__PURE__ */ Ce(dF, dwe, (e) => {
  var {
    typed: r,
    config: t,
    identity: n,
    multiply: a,
    matrix: i,
    inv: o,
    number: c,
    fraction: s,
    Complex: u
  } = e;
  return r(dF, {
    "number, number": l,
    "Complex, Complex": function(p, v) {
      return p.pow(v);
    },
    "BigNumber, BigNumber": function(p, v) {
      return v.isInteger() || p >= 0 || t.predictable ? p.pow(v) : new u(p.toNumber(), 0).pow(v.toNumber(), 0);
    },
    "bigint, bigint": (m, p) => m ** p,
    "Fraction, Fraction": function(p, v) {
      var h = p.pow(v);
      if (h != null)
        return h;
      if (t.predictable)
        throw new Error("Result of pow is non-rational and cannot be expressed as a fraction");
      return l(p.valueOf(), v.valueOf());
    },
    "Array, number": f,
    "Array, BigNumber": function(p, v) {
      return f(p, v.toNumber());
    },
    "Matrix, number": d,
    "Matrix, BigNumber": function(p, v) {
      return d(p, v.toNumber());
    },
    "Unit, number | BigNumber": function(p, v) {
      return p.pow(v);
    }
  });
  function l(m, p) {
    if (t.predictable && !lr(p) && m < 0)
      try {
        var v = s(p), h = c(v);
        if ((p === h || Math.abs((p - h) / p) < 1e-14) && v.d % 2 === 1)
          return (v.n % 2 === 0 ? 1 : -1) * Math.pow(-m, p);
      } catch {
      }
    return t.predictable && (m < -1 && p === 1 / 0 || m > -1 && m < 0 && p === -1 / 0) ? NaN : lr(p) || m >= 0 || t.predictable ? bW(m, p) : m * m < 1 && p === 1 / 0 || m * m > 1 && p === -1 / 0 ? 0 : new u(m, 0).pow(p, 0);
  }
  function f(m, p) {
    if (!lr(p))
      throw new TypeError("For A^b, b must be an integer (value is " + p + ")");
    var v = Fr(m);
    if (v.length !== 2)
      throw new Error("For A^b, A must be 2 dimensional (A has " + v.length + " dimensions)");
    if (v[0] !== v[1])
      throw new Error("For A^b, A must be square (size is " + v[0] + "x" + v[1] + ")");
    if (p < 0)
      try {
        return f(o(m), -p);
      } catch (C) {
        throw C.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 " + p + ")") : C;
      }
    for (var h = n(v[0]).valueOf(), y = m; p >= 1; )
      (p & 1) === 1 && (h = a(y, h)), p >>= 1, y = a(y, y);
    return h;
  }
  function d(m, p) {
    return i(f(m.valueOf(), p));
  }
}), Gm = "Number of decimals in function round must be an integer", fF = "round", fwe = ["typed", "config", "matrix", "equalScalar", "zeros", "BigNumber", "DenseMatrix"], mwe = /* @__PURE__ */ Ce(fF, fwe, (e) => {
  var {
    typed: r,
    config: t,
    matrix: n,
    equalScalar: a,
    zeros: i,
    BigNumber: o,
    DenseMatrix: c
  } = e, s = li({
    typed: r,
    equalScalar: a
  }), u = Aa({
    typed: r,
    DenseMatrix: c
  }), l = xs({
    typed: r
  });
  function f(d) {
    return Math.abs(Hy(d).exponent);
  }
  return r(fF, {
    number: function(m) {
      var p = N1(m, f(t.relTol)), v = oi(m, p, t.relTol, t.absTol) ? p : m;
      return N1(v);
    },
    "number, number": function(m, p) {
      var v = f(t.relTol);
      if (p >= v)
        return N1(m, p);
      var h = N1(m, v), y = oi(m, h, t.relTol, t.absTol) ? h : m;
      return N1(y, p);
    },
    "number, BigNumber": function(m, p) {
      if (!p.isInteger())
        throw new TypeError(Gm);
      return new o(m).toDecimalPlaces(p.toNumber());
    },
    Complex: function(m) {
      return m.round();
    },
    "Complex, number": function(m, p) {
      if (p % 1)
        throw new TypeError(Gm);
      return m.round(p);
    },
    "Complex, BigNumber": function(m, p) {
      if (!p.isInteger())
        throw new TypeError(Gm);
      var v = p.toNumber();
      return m.round(v);
    },
    BigNumber: function(m) {
      var p = new o(m).toDecimalPlaces(f(t.relTol)), v = To(m, p, t.relTol, t.absTol) ? p : m;
      return v.toDecimalPlaces(0);
    },
    "BigNumber, BigNumber": function(m, p) {
      if (!p.isInteger())
        throw new TypeError(Gm);
      var v = f(t.relTol);
      if (p >= v)
        return m.toDecimalPlaces(p.toNumber());
      var h = m.toDecimalPlaces(v), y = To(m, h, t.relTol, t.absTol) ? h : m;
      return y.toDecimalPlaces(p.toNumber());
    },
    Fraction: function(m) {
      return m.round();
    },
    "Fraction, number": function(m, p) {
      if (p % 1)
        throw new TypeError(Gm);
      return m.round(p);
    },
    "Fraction, BigNumber": function(m, p) {
      if (!p.isInteger())
        throw new TypeError(Gm);
      return m.round(p.toNumber());
    },
    "Unit, number, Unit": r.referToSelf((d) => function(m, p, v) {
      var h = m.toNumeric(v);
      return v.multiply(d(h, p));
    }),
    "Unit, BigNumber, Unit": r.referToSelf((d) => (m, p, v) => d(m, p.toNumber(), v)),
    "Unit, Unit": r.referToSelf((d) => (m, p) => d(m, 0, p)),
    "Array | Matrix, number, Unit": r.referToSelf((d) => (m, p, v) => zr(m, (h) => d(h, p, v))),
    "Array | Matrix, BigNumber, Unit": r.referToSelf((d) => (m, p, v) => d(m, p.toNumber(), v)),
    "Array | Matrix, Unit": r.referToSelf((d) => (m, p) => d(m, 0, p)),
    "Array | Matrix": r.referToSelf((d) => (m) => zr(m, d)),
    "SparseMatrix, number | BigNumber": r.referToSelf((d) => (m, p) => s(m, p, d, !1)),
    "DenseMatrix, number | BigNumber": r.referToSelf((d) => (m, p) => l(m, p, d, !1)),
    "Array, number | BigNumber": r.referToSelf((d) => (m, p) => l(n(m), p, d, !1).valueOf()),
    "number | Complex | BigNumber | Fraction, SparseMatrix": r.referToSelf((d) => (m, p) => a(m, 0) ? i(p.size(), p.storage()) : u(p, m, d, !0)),
    "number | Complex | BigNumber | Fraction, DenseMatrix": r.referToSelf((d) => (m, p) => a(m, 0) ? i(p.size(), p.storage()) : l(p, m, d, !0)),
    "number | Complex | BigNumber | Fraction, Array": r.referToSelf((d) => (m, p) => l(n(p), m, d, !0).valueOf())
  });
}), mF = "log", vwe = ["config", "typed", "divideScalar", "Complex"], pwe = /* @__PURE__ */ Ce(mF, vwe, (e) => {
  var {
    typed: r,
    config: t,
    divideScalar: n,
    Complex: a
  } = e;
  return r(mF, {
    number: function(o) {
      return o >= 0 || t.predictable ? Kxe(o) : new a(o, 0).log();
    },
    Complex: function(o) {
      return o.log();
    },
    BigNumber: function(o) {
      return !o.isNegative() || t.predictable ? o.ln() : new a(o.toNumber(), 0).log();
    },
    "any, any": r.referToSelf((i) => (o, c) => n(i(o), i(c)))
  });
}), vF = "log1p", hwe = ["typed", "config", "divideScalar", "log", "Complex"], gwe = /* @__PURE__ */ Ce(vF, hwe, (e) => {
  var {
    typed: r,
    config: t,
    divideScalar: n,
    log: a,
    Complex: i
  } = e;
  return r(vF, {
    number: function(s) {
      return s >= -1 || t.predictable ? Q4e(s) : o(new i(s, 0));
    },
    Complex: o,
    BigNumber: function(s) {
      var u = s.plus(1);
      return !u.isNegative() || t.predictable ? u.ln() : o(new i(s.toNumber(), 0));
    },
    "Array | Matrix": r.referToSelf((c) => (s) => zr(s, c)),
    "any, any": r.referToSelf((c) => (s, u) => n(c(s), a(u)))
  });
  function o(c) {
    var s = c.re + 1;
    return new i(Math.log(Math.sqrt(s * s + c.im * c.im)), Math.atan2(c.im, s));
  }
}), pF = "nthRoots", ywe = ["config", "typed", "divideScalar", "Complex"], _we = /* @__PURE__ */ Ce(pF, ywe, (e) => {
  var {
    typed: r,
    config: t,
    divideScalar: n,
    Complex: a
  } = e, i = [function(s) {
    return new a(s, 0);
  }, function(s) {
    return new a(0, s);
  }, function(s) {
    return new a(-s, 0);
  }, function(s) {
    return new a(0, -s);
  }];
  function o(c, s) {
    if (s < 0) throw new Error("Root must be greater than zero");
    if (s === 0) throw new Error("Root must be non-zero");
    if (s % 1 !== 0) throw new Error("Root must be an integer");
    if (c === 0 || c.abs() === 0) return [new a(0, 0)];
    var u = typeof c == "number", l;
    (u || c.re === 0 || c.im === 0) && (u ? l = 2 * +(c < 0) : c.im === 0 ? l = 2 * +(c.re < 0) : l = 2 * +(c.im < 0) + 1);
    for (var f = c.arg(), d = c.abs(), m = [], p = Math.pow(d, 1 / s), v = 0; v < s; v++) {
      var h = (l + 4 * v) / s;
      if (h === Math.round(h)) {
        m.push(i[h % 4](p));
        continue;
      }
      m.push(new a({
        r: p,
        phi: (f + 2 * Math.PI * v) / s
      }));
    }
    return m;
  }
  return r(pF, {
    Complex: function(s) {
      return o(s, 2);
    },
    "Complex, number": o
  });
}), hF = "dotPow", bwe = ["typed", "equalScalar", "matrix", "pow", "DenseMatrix", "concat"], Swe = /* @__PURE__ */ Ce(hF, bwe, (e) => {
  var {
    typed: r,
    equalScalar: t,
    matrix: n,
    pow: a,
    DenseMatrix: i,
    concat: o
  } = e, c = Zi({
    typed: r
  }), s = Sl({
    typed: r,
    DenseMatrix: i
  }), u = li({
    typed: r,
    equalScalar: t
  }), l = Aa({
    typed: r,
    DenseMatrix: i
  }), f = kt({
    typed: r,
    matrix: n,
    concat: o
  }), d = {};
  for (var m in a.signatures)
    Object.prototype.hasOwnProperty.call(a.signatures, m) && !m.includes("Matrix") && !m.includes("Array") && (d[m] = a.signatures[m]);
  var p = r(d);
  return r(hF, f({
    elop: p,
    SS: s,
    DS: c,
    Ss: u,
    sS: l
  }));
}), gF = "dotDivide", Cwe = ["typed", "matrix", "equalScalar", "divideScalar", "DenseMatrix", "concat"], Awe = /* @__PURE__ */ Ce(gF, Cwe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    divideScalar: a,
    DenseMatrix: i,
    concat: o
  } = e, c = Ts({
    typed: r,
    equalScalar: n
  }), s = Zi({
    typed: r
  }), u = Sl({
    typed: r,
    DenseMatrix: i
  }), l = li({
    typed: r,
    equalScalar: n
  }), f = Aa({
    typed: r,
    DenseMatrix: i
  }), d = kt({
    typed: r,
    matrix: t,
    concat: o
  });
  return r(gF, d({
    elop: a,
    SS: u,
    DS: s,
    SD: c,
    Ss: l,
    sS: f
  }));
});
function $y(e) {
  var {
    DenseMatrix: r
  } = e;
  return function(n, a, i) {
    var o = n.size();
    if (o.length !== 2)
      throw new RangeError("Matrix must be two dimensional (size: " + $r(o) + ")");
    var c = o[0], s = o[1];
    if (c !== s)
      throw new RangeError("Matrix must be square (size: " + $r(o) + ")");
    var u = [];
    if (gr(a)) {
      var l = a.size(), f = a._data;
      if (l.length === 1) {
        if (l[0] !== c)
          throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
        for (var d = 0; d < c; d++)
          u[d] = [f[d]];
        return new r({
          data: u,
          size: [c, 1],
          datatype: a._datatype
        });
      }
      if (l.length === 2) {
        if (l[0] !== c || l[1] !== 1)
          throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
        if (Fg(a)) {
          if (i) {
            u = [];
            for (var m = 0; m < c; m++)
              u[m] = [f[m][0]];
            return new r({
              data: u,
              size: [c, 1],
              datatype: a._datatype
            });
          }
          return a;
        }
        if (dd(a)) {
          for (var p = 0; p < c; p++)
            u[p] = [0];
          for (var v = a._values, h = a._index, y = a._ptr, C = y[1], S = y[0]; S < C; S++) {
            var b = h[S];
            u[b][0] = v[S];
          }
          return new r({
            data: u,
            size: [c, 1],
            datatype: a._datatype
          });
        }
      }
      throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.");
    }
    if (dt(a)) {
      var g = Fr(a);
      if (g.length === 1) {
        if (g[0] !== c)
          throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
        for (var _ = 0; _ < c; _++)
          u[_] = [a[_]];
        return new r({
          data: u,
          size: [c, 1]
        });
      }
      if (g.length === 2) {
        if (g[0] !== c || g[1] !== 1)
          throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");
        for (var A = 0; A < c; A++)
          u[A] = [a[A][0]];
        return new r({
          data: u,
          size: [c, 1]
        });
      }
      throw new RangeError("Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.");
    }
  };
}
var yF = "lsolve", xwe = ["typed", "matrix", "divideScalar", "multiplyScalar", "subtractScalar", "equalScalar", "DenseMatrix"], Twe = /* @__PURE__ */ Ce(yF, xwe, (e) => {
  var {
    typed: r,
    matrix: t,
    divideScalar: n,
    multiplyScalar: a,
    subtractScalar: i,
    equalScalar: o,
    DenseMatrix: c
  } = e, s = $y({
    DenseMatrix: c
  });
  return r(yF, {
    "SparseMatrix, Array | Matrix": function(d, m) {
      return l(d, m);
    },
    "DenseMatrix, Array | Matrix": function(d, m) {
      return u(d, m);
    },
    "Array, Array | Matrix": function(d, m) {
      var p = t(d), v = u(p, m);
      return v.valueOf();
    }
  });
  function u(f, d) {
    d = s(f, d, !0);
    for (var m = d._data, p = f._size[0], v = f._size[1], h = [], y = f._data, C = 0; C < v; C++) {
      var S = m[C][0] || 0, b = void 0;
      if (o(S, 0))
        b = 0;
      else {
        var g = y[C][C];
        if (o(g, 0))
          throw new Error("Linear system cannot be solved since matrix is singular");
        b = n(S, g);
        for (var _ = C + 1; _ < p; _++)
          m[_] = [i(m[_][0] || 0, a(b, y[_][C]))];
      }
      h[C] = [b];
    }
    return new c({
      data: h,
      size: [p, 1]
    });
  }
  function l(f, d) {
    d = s(f, d, !0);
    for (var m = d._data, p = f._size[0], v = f._size[1], h = f._values, y = f._index, C = f._ptr, S = [], b = 0; b < v; b++) {
      var g = m[b][0] || 0;
      if (o(g, 0))
        S[b] = [0];
      else {
        for (var _ = 0, A = [], M = [], P = C[b], T = C[b + 1], x = P; x < T; x++) {
          var w = y[x];
          w === b ? _ = h[x] : w > b && (A.push(h[x]), M.push(w));
        }
        if (o(_, 0))
          throw new Error("Linear system cannot be solved since matrix is singular");
        for (var E = n(g, _), I = 0, B = M.length; I < B; I++) {
          var D = M[I];
          m[D] = [i(m[D][0] || 0, a(E, A[I]))];
        }
        S[b] = [E];
      }
    }
    return new c({
      data: S,
      size: [p, 1]
    });
  }
}), _F = "usolve", Pwe = ["typed", "matrix", "divideScalar", "multiplyScalar", "subtractScalar", "equalScalar", "DenseMatrix"], jX = /* @__PURE__ */ Ce(_F, Pwe, (e) => {
  var {
    typed: r,
    matrix: t,
    divideScalar: n,
    multiplyScalar: a,
    subtractScalar: i,
    equalScalar: o,
    DenseMatrix: c
  } = e, s = $y({
    DenseMatrix: c
  });
  return r(_F, {
    "SparseMatrix, Array | Matrix": function(d, m) {
      return l(d, m);
    },
    "DenseMatrix, Array | Matrix": function(d, m) {
      return u(d, m);
    },
    "Array, Array | Matrix": function(d, m) {
      var p = t(d), v = u(p, m);
      return v.valueOf();
    }
  });
  function u(f, d) {
    d = s(f, d, !0);
    for (var m = d._data, p = f._size[0], v = f._size[1], h = [], y = f._data, C = v - 1; C >= 0; C--) {
      var S = m[C][0] || 0, b = void 0;
      if (o(S, 0))
        b = 0;
      else {
        var g = y[C][C];
        if (o(g, 0))
          throw new Error("Linear system cannot be solved since matrix is singular");
        b = n(S, g);
        for (var _ = C - 1; _ >= 0; _--)
          m[_] = [i(m[_][0] || 0, a(b, y[_][C]))];
      }
      h[C] = [b];
    }
    return new c({
      data: h,
      size: [p, 1]
    });
  }
  function l(f, d) {
    d = s(f, d, !0);
    for (var m = d._data, p = f._size[0], v = f._size[1], h = f._values, y = f._index, C = f._ptr, S = [], b = v - 1; b >= 0; b--) {
      var g = m[b][0] || 0;
      if (o(g, 0))
        S[b] = [0];
      else {
        for (var _ = 0, A = [], M = [], P = C[b], T = C[b + 1], x = T - 1; x >= P; x--) {
          var w = y[x];
          w === b ? _ = h[x] : w < b && (A.push(h[x]), M.push(w));
        }
        if (o(_, 0))
          throw new Error("Linear system cannot be solved since matrix is singular");
        for (var E = n(g, _), I = 0, B = M.length; I < B; I++) {
          var D = M[I];
          m[D] = [i(m[D][0], a(E, A[I]))];
        }
        S[b] = [E];
      }
    }
    return new c({
      data: S,
      size: [p, 1]
    });
  }
}), bF = "lsolveAll", Mwe = ["typed", "matrix", "divideScalar", "multiplyScalar", "subtractScalar", "equalScalar", "DenseMatrix"], wwe = /* @__PURE__ */ Ce(bF, Mwe, (e) => {
  var {
    typed: r,
    matrix: t,
    divideScalar: n,
    multiplyScalar: a,
    subtractScalar: i,
    equalScalar: o,
    DenseMatrix: c
  } = e, s = $y({
    DenseMatrix: c
  });
  return r(bF, {
    "SparseMatrix, Array | Matrix": function(d, m) {
      return l(d, m);
    },
    "DenseMatrix, Array | Matrix": function(d, m) {
      return u(d, m);
    },
    "Array, Array | Matrix": function(d, m) {
      var p = t(d), v = u(p, m);
      return v.map((h) => h.valueOf());
    }
  });
  function u(f, d) {
    for (var m = [s(f, d, !0)._data.map((M) => M[0])], p = f._data, v = f._size[0], h = f._size[1], y = 0; y < h; y++)
      for (var C = m.length, S = 0; S < C; S++) {
        var b = m[S];
        if (o(p[y][y], 0))
          if (o(b[y], 0)) {
            if (S === 0) {
              var _ = [...b];
              _[y] = 1;
              for (var A = y + 1; A < h; A++)
                _[A] = i(_[A], p[A][y]);
              m.push(_);
            }
          } else {
            if (S === 0)
              return [];
            m.splice(S, 1), S -= 1, C -= 1;
          }
        else {
          b[y] = n(b[y], p[y][y]);
          for (var g = y + 1; g < h; g++)
            b[g] = i(b[g], a(b[y], p[g][y]));
        }
      }
    return m.map((M) => new c({
      data: M.map((P) => [P]),
      size: [v, 1]
    }));
  }
  function l(f, d) {
    for (var m = [s(f, d, !0)._data.map((G) => G[0])], p = f._size[0], v = f._size[1], h = f._values, y = f._index, C = f._ptr, S = 0; S < v; S++)
      for (var b = m.length, g = 0; g < b; g++) {
        for (var _ = m[g], A = [], M = [], P = C[S], T = C[S + 1], x = 0, w = P; w < T; w++) {
          var E = y[w];
          E === S ? x = h[w] : E > S && (A.push(h[w]), M.push(E));
        }
        if (o(x, 0))
          if (o(_[S], 0)) {
            if (g === 0) {
              var N = [..._];
              N[S] = 1;
              for (var O = 0, V = M.length; O < V; O++) {
                var k = M[O];
                N[k] = i(N[k], A[O]);
              }
              m.push(N);
            }
          } else {
            if (g === 0)
              return [];
            m.splice(g, 1), g -= 1, b -= 1;
          }
        else {
          _[S] = n(_[S], x);
          for (var I = 0, B = M.length; I < B; I++) {
            var D = M[I];
            _[D] = i(_[D], a(_[S], A[I]));
          }
        }
      }
    return m.map((G) => new c({
      data: G.map((L) => [L]),
      size: [p, 1]
    }));
  }
}), SF = "usolveAll", Ewe = ["typed", "matrix", "divideScalar", "multiplyScalar", "subtractScalar", "equalScalar", "DenseMatrix"], $X = /* @__PURE__ */ Ce(SF, Ewe, (e) => {
  var {
    typed: r,
    matrix: t,
    divideScalar: n,
    multiplyScalar: a,
    subtractScalar: i,
    equalScalar: o,
    DenseMatrix: c
  } = e, s = $y({
    DenseMatrix: c
  });
  return r(SF, {
    "SparseMatrix, Array | Matrix": function(d, m) {
      return l(d, m);
    },
    "DenseMatrix, Array | Matrix": function(d, m) {
      return u(d, m);
    },
    "Array, Array | Matrix": function(d, m) {
      var p = t(d), v = u(p, m);
      return v.map((h) => h.valueOf());
    }
  });
  function u(f, d) {
    for (var m = [s(f, d, !0)._data.map((M) => M[0])], p = f._data, v = f._size[0], h = f._size[1], y = h - 1; y >= 0; y--)
      for (var C = m.length, S = 0; S < C; S++) {
        var b = m[S];
        if (o(p[y][y], 0))
          if (o(b[y], 0)) {
            if (S === 0) {
              var _ = [...b];
              _[y] = 1;
              for (var A = y - 1; A >= 0; A--)
                _[A] = i(_[A], p[A][y]);
              m.push(_);
            }
          } else {
            if (S === 0)
              return [];
            m.splice(S, 1), S -= 1, C -= 1;
          }
        else {
          b[y] = n(b[y], p[y][y]);
          for (var g = y - 1; g >= 0; g--)
            b[g] = i(b[g], a(b[y], p[g][y]));
        }
      }
    return m.map((M) => new c({
      data: M.map((P) => [P]),
      size: [v, 1]
    }));
  }
  function l(f, d) {
    for (var m = [s(f, d, !0)._data.map((G) => G[0])], p = f._size[0], v = f._size[1], h = f._values, y = f._index, C = f._ptr, S = v - 1; S >= 0; S--)
      for (var b = m.length, g = 0; g < b; g++) {
        for (var _ = m[g], A = [], M = [], P = C[S], T = C[S + 1], x = 0, w = T - 1; w >= P; w--) {
          var E = y[w];
          E === S ? x = h[w] : E < S && (A.push(h[w]), M.push(E));
        }
        if (o(x, 0))
          if (o(_[S], 0)) {
            if (g === 0) {
              var N = [..._];
              N[S] = 1;
              for (var O = 0, V = M.length; O < V; O++) {
                var k = M[O];
                N[k] = i(N[k], A[O]);
              }
              m.push(N);
            }
          } else {
            if (g === 0)
              return [];
            m.splice(g, 1), g -= 1, b -= 1;
          }
        else {
          _[S] = n(_[S], x);
          for (var I = 0, B = M.length; I < B; I++) {
            var D = M[I];
            _[D] = i(_[D], a(_[S], A[I]));
          }
        }
      }
    return m.map((G) => new c({
      data: G.map((L) => [L]),
      size: [p, 1]
    }));
  }
}), Dwe = "matAlgo08xS0Sid", Iwe = ["typed", "equalScalar"], OD = /* @__PURE__ */ Ce(Dwe, Iwe, (e) => {
  var {
    typed: r,
    equalScalar: t
  } = e;
  return function(a, i, o) {
    var c = a._values, s = a._index, u = a._ptr, l = a._size, f = a._datatype || a._data === void 0 ? a._datatype : a.getDataType(), d = i._values, m = i._index, p = i._ptr, v = i._size, h = i._datatype || i._data === void 0 ? i._datatype : i.getDataType();
    if (l.length !== v.length)
      throw new kr(l.length, v.length);
    if (l[0] !== v[0] || l[1] !== v[1])
      throw new RangeError("Dimension mismatch. Matrix A (" + l + ") must match Matrix B (" + v + ")");
    if (!c || !d)
      throw new Error("Cannot perform operation on Pattern Sparse Matrices");
    var y = l[0], C = l[1], S, b = t, g = 0, _ = o;
    typeof f == "string" && f === h && f !== "mixed" && (S = f, b = r.find(t, [S, S]), g = r.convert(0, S), _ = r.find(o, [S, S]));
    for (var A = [], M = [], P = [], T = [], x = [], w, E, I, B, D = 0; D < C; D++) {
      P[D] = M.length;
      var N = D + 1;
      for (E = u[D], I = u[D + 1], w = E; w < I; w++)
        B = s[w], x[B] = N, T[B] = c[w], M.push(B);
      for (E = p[D], I = p[D + 1], w = E; w < I; w++)
        B = m[w], x[B] === N && (T[B] = _(T[B], d[w]));
      for (w = P[D]; w < M.length; ) {
        B = M[w];
        var O = T[B];
        b(O, g) ? M.splice(w, 1) : (A.push(O), w++);
      }
    }
    return P[C] = M.length, a.createSparseMatrix({
      values: A,
      index: M,
      ptr: P,
      size: [y, C],
      datatype: f === a._datatype && h === i._datatype ? S : void 0
    });
  };
}), FD = /* @__PURE__ */ Ce("useMatrixForArrayScalar", ["typed", "matrix"], (e) => {
  var {
    typed: r,
    matrix: t
  } = e;
  return {
    "Array, number": r.referTo("DenseMatrix, number", (n) => (a, i) => n(t(a), i).valueOf()),
    "Array, BigNumber": r.referTo("DenseMatrix, BigNumber", (n) => (a, i) => n(t(a), i).valueOf()),
    "number, Array": r.referTo("number, DenseMatrix", (n) => (a, i) => n(a, t(i)).valueOf()),
    "BigNumber, Array": r.referTo("BigNumber, DenseMatrix", (n) => (a, i) => n(a, t(i)).valueOf())
  };
}), CF = "leftShift", Bwe = ["typed", "matrix", "equalScalar", "zeros", "DenseMatrix", "concat"], Nwe = /* @__PURE__ */ Ce(CF, Bwe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    zeros: a,
    DenseMatrix: i,
    concat: o
  } = e, c = nf({
    typed: r
  }), s = Ts({
    typed: r,
    equalScalar: n
  }), u = OD({
    typed: r,
    equalScalar: n
  }), l = rm({
    typed: r,
    DenseMatrix: i
  }), f = li({
    typed: r,
    equalScalar: n
  }), d = xs({
    typed: r
  }), m = kt({
    typed: r,
    matrix: t,
    concat: o
  }), p = FD({
    typed: r,
    matrix: t
  });
  return r(CF, {
    "number, number": TW,
    "BigNumber, BigNumber": gPe,
    "bigint, bigint": (v, h) => v << h,
    "SparseMatrix, number | BigNumber": r.referToSelf((v) => (h, y) => n(y, 0) ? h.clone() : f(h, y, v, !1)),
    "DenseMatrix, number | BigNumber": r.referToSelf((v) => (h, y) => n(y, 0) ? h.clone() : d(h, y, v, !1)),
    "number | BigNumber, SparseMatrix": r.referToSelf((v) => (h, y) => n(h, 0) ? a(y.size(), y.storage()) : l(y, h, v, !0)),
    "number | BigNumber, DenseMatrix": r.referToSelf((v) => (h, y) => n(h, 0) ? a(y.size(), y.storage()) : d(y, h, v, !0))
  }, p, m({
    SS: u,
    DS: c,
    SD: s
  }));
}), AF = "rightArithShift", Vwe = ["typed", "matrix", "equalScalar", "zeros", "DenseMatrix", "concat"], Rwe = /* @__PURE__ */ Ce(AF, Vwe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    zeros: a,
    DenseMatrix: i,
    concat: o
  } = e, c = nf({
    typed: r
  }), s = Ts({
    typed: r,
    equalScalar: n
  }), u = OD({
    typed: r,
    equalScalar: n
  }), l = rm({
    typed: r,
    DenseMatrix: i
  }), f = li({
    typed: r,
    equalScalar: n
  }), d = xs({
    typed: r
  }), m = kt({
    typed: r,
    matrix: t,
    concat: o
  }), p = FD({
    typed: r,
    matrix: t
  });
  return r(AF, {
    "number, number": PW,
    "BigNumber, BigNumber": yPe,
    "bigint, bigint": (v, h) => v >> h,
    "SparseMatrix, number | BigNumber": r.referToSelf((v) => (h, y) => n(y, 0) ? h.clone() : f(h, y, v, !1)),
    "DenseMatrix, number | BigNumber": r.referToSelf((v) => (h, y) => n(y, 0) ? h.clone() : d(h, y, v, !1)),
    "number | BigNumber, SparseMatrix": r.referToSelf((v) => (h, y) => n(h, 0) ? a(y.size(), y.storage()) : l(y, h, v, !0)),
    "number | BigNumber, DenseMatrix": r.referToSelf((v) => (h, y) => n(h, 0) ? a(y.size(), y.storage()) : d(y, h, v, !0))
  }, p, m({
    SS: u,
    DS: c,
    SD: s
  }));
}), xF = "rightLogShift", Owe = ["typed", "matrix", "equalScalar", "zeros", "DenseMatrix", "concat"], Fwe = /* @__PURE__ */ Ce(xF, Owe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    zeros: a,
    DenseMatrix: i,
    concat: o
  } = e, c = nf({
    typed: r
  }), s = Ts({
    typed: r,
    equalScalar: n
  }), u = OD({
    typed: r,
    equalScalar: n
  }), l = rm({
    typed: r,
    DenseMatrix: i
  }), f = li({
    typed: r,
    equalScalar: n
  }), d = xs({
    typed: r
  }), m = kt({
    typed: r,
    matrix: t,
    concat: o
  }), p = FD({
    typed: r,
    matrix: t
  });
  return r(xF, {
    "number, number": MW,
    // 'BigNumber, BigNumber': ..., // TODO: implement BigNumber support for rightLogShift
    "SparseMatrix, number | BigNumber": r.referToSelf((v) => (h, y) => n(y, 0) ? h.clone() : f(h, y, v, !1)),
    "DenseMatrix, number | BigNumber": r.referToSelf((v) => (h, y) => n(y, 0) ? h.clone() : d(h, y, v, !1)),
    "number | BigNumber, SparseMatrix": r.referToSelf((v) => (h, y) => n(h, 0) ? a(y.size(), y.storage()) : l(y, h, v, !0)),
    "number | BigNumber, DenseMatrix": r.referToSelf((v) => (h, y) => n(h, 0) ? a(y.size(), y.storage()) : d(y, h, v, !0))
  }, p, m({
    SS: u,
    DS: c,
    SD: s
  }));
}), TF = "and", Lwe = ["typed", "matrix", "equalScalar", "zeros", "not", "concat"], KX = /* @__PURE__ */ Ce(TF, Lwe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    zeros: a,
    not: i,
    concat: o
  } = e, c = Ts({
    typed: r,
    equalScalar: n
  }), s = cx({
    typed: r,
    equalScalar: n
  }), u = li({
    typed: r,
    equalScalar: n
  }), l = xs({
    typed: r
  }), f = kt({
    typed: r,
    matrix: t,
    concat: o
  });
  return r(TF, {
    "number, number": Ew,
    "Complex, Complex": function(m, p) {
      return (m.re !== 0 || m.im !== 0) && (p.re !== 0 || p.im !== 0);
    },
    "BigNumber, BigNumber": function(m, p) {
      return !m.isZero() && !p.isZero() && !m.isNaN() && !p.isNaN();
    },
    "bigint, bigint": Ew,
    "Unit, Unit": r.referToSelf((d) => (m, p) => d(m.value || 0, p.value || 0)),
    "SparseMatrix, any": r.referToSelf((d) => (m, p) => i(p) ? a(m.size(), m.storage()) : u(m, p, d, !1)),
    "DenseMatrix, any": r.referToSelf((d) => (m, p) => i(p) ? a(m.size(), m.storage()) : l(m, p, d, !1)),
    "any, SparseMatrix": r.referToSelf((d) => (m, p) => i(m) ? a(m.size(), m.storage()) : u(p, m, d, !0)),
    "any, DenseMatrix": r.referToSelf((d) => (m, p) => i(m) ? a(m.size(), m.storage()) : l(p, m, d, !0)),
    "Array, any": r.referToSelf((d) => (m, p) => d(t(m), p).valueOf()),
    "any, Array": r.referToSelf((d) => (m, p) => d(m, t(p)).valueOf())
  }, f({
    SS: s,
    DS: c
  }));
}), M3 = "compare", kwe = ["typed", "config", "matrix", "equalScalar", "BigNumber", "Fraction", "DenseMatrix", "concat"], Uwe = /* @__PURE__ */ Ce(M3, kwe, (e) => {
  var {
    typed: r,
    config: t,
    equalScalar: n,
    matrix: a,
    BigNumber: i,
    Fraction: o,
    DenseMatrix: c,
    concat: s
  } = e, u = Zi({
    typed: r
  }), l = lx({
    typed: r,
    equalScalar: n
  }), f = Aa({
    typed: r,
    DenseMatrix: c
  }), d = kt({
    typed: r,
    matrix: a,
    concat: s
  }), m = Qp({
    typed: r
  });
  return r(M3, zwe({
    typed: r,
    config: t
  }), {
    "boolean, boolean": function(v, h) {
      return v === h ? 0 : v > h ? 1 : -1;
    },
    "BigNumber, BigNumber": function(v, h) {
      return To(v, h, t.relTol, t.absTol) ? new i(0) : new i(v.cmp(h));
    },
    "bigint, bigint": function(v, h) {
      return v === h ? 0n : v > h ? 1n : -1n;
    },
    "Fraction, Fraction": function(v, h) {
      return new o(v.compare(h));
    },
    "Complex, Complex": function() {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, m, d({
    SS: l,
    DS: u,
    Ss: f
  }));
}), zwe = /* @__PURE__ */ Ce(M3, ["typed", "config"], (e) => {
  var {
    typed: r,
    config: t
  } = e;
  return r(M3, {
    "number, number": function(a, i) {
      return oi(a, i, t.relTol, t.absTol) ? 0 : a > i ? 1 : -1;
    }
  });
}), Gwe = function e(r, t) {
  var n = /(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi, a = /(^[ ]*|[ ]*$)/g, i = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/, o = /^0x[0-9a-f]+$/i, c = /^0/, s = function(S) {
    return e.insensitive && ("" + S).toLowerCase() || "" + S;
  }, u = s(r).replace(a, "") || "", l = s(t).replace(a, "") || "", f = u.replace(n, "\0$1\0").replace(/\0$/, "").replace(/^\0/, "").split("\0"), d = l.replace(n, "\0$1\0").replace(/\0$/, "").replace(/^\0/, "").split("\0"), m = parseInt(u.match(o), 16) || f.length !== 1 && u.match(i) && Date.parse(u), p = parseInt(l.match(o), 16) || m && l.match(i) && Date.parse(l) || null, v, h;
  if (p) {
    if (m < p)
      return -1;
    if (m > p)
      return 1;
  }
  for (var y = 0, C = Math.max(f.length, d.length); y < C; y++) {
    if (v = !(f[y] || "").match(c) && parseFloat(f[y]) || f[y] || 0, h = !(d[y] || "").match(c) && parseFloat(d[y]) || d[y] || 0, isNaN(v) !== isNaN(h))
      return isNaN(v) ? 1 : -1;
    if (typeof v != typeof h && (v += "", h += ""), v < h)
      return -1;
    if (v > h)
      return 1;
  }
  return 0;
};
const qm = /* @__PURE__ */ qg(Gwe);
var PF = "compareNatural", qwe = ["typed", "compare"], Hwe = /* @__PURE__ */ Ce(PF, qwe, (e) => {
  var {
    typed: r,
    compare: t
  } = e, n = t.signatures["boolean,boolean"];
  return r(PF, {
    "any, any": a
  });
  function a(s, u) {
    var l = Et(s), f = Et(u), d;
    if ((l === "number" || l === "BigNumber" || l === "Fraction") && (f === "number" || f === "BigNumber" || f === "Fraction"))
      return d = t(s, u), d.toString() !== "0" ? d > 0 ? 1 : -1 : qm(l, f);
    var m = ["Array", "DenseMatrix", "SparseMatrix"];
    if (m.includes(l) || m.includes(f))
      return d = i(a, s, u), d !== 0 ? d : qm(l, f);
    if (l !== f)
      return qm(l, f);
    if (l === "Complex")
      return jwe(s, u);
    if (l === "Unit")
      return s.equalBase(u) ? a(s.value, u.value) : o(a, s.formatUnits(), u.formatUnits());
    if (l === "boolean")
      return n(s, u);
    if (l === "string")
      return qm(s, u);
    if (l === "Object")
      return c(a, s, u);
    if (l === "null" || l === "undefined")
      return 0;
    throw new TypeError('Unsupported type of value "' + l + '"');
  }
  function i(s, u, l) {
    return dd(u) && dd(l) ? o(s, u.toJSON().values, l.toJSON().values) : dd(u) ? i(s, u.toArray(), l) : dd(l) ? i(s, u, l.toArray()) : Fg(u) ? i(s, u.toJSON().data, l) : Fg(l) ? i(s, u, l.toJSON().data) : Array.isArray(u) ? Array.isArray(l) ? o(s, u, l) : i(s, u, [l]) : i(s, [u], l);
  }
  function o(s, u, l) {
    for (var f = 0, d = Math.min(u.length, l.length); f < d; f++) {
      var m = s(u[f], l[f]);
      if (m !== 0)
        return m;
    }
    return u.length > l.length ? 1 : u.length < l.length ? -1 : 0;
  }
  function c(s, u, l) {
    var f = Object.keys(u), d = Object.keys(l);
    f.sort(qm), d.sort(qm);
    var m = o(s, f, d);
    if (m !== 0)
      return m;
    for (var p = 0; p < f.length; p++) {
      var v = s(u[f[p]], l[d[p]]);
      if (v !== 0)
        return v;
    }
    return 0;
  }
});
function jwe(e, r) {
  return e.re > r.re ? 1 : e.re < r.re ? -1 : e.im > r.im ? 1 : e.im < r.im ? -1 : 0;
}
var MF = "compareText", $we = ["typed", "matrix", "concat"];
Aw.signature = "any, any";
var Kwe = /* @__PURE__ */ Ce(MF, $we, (e) => {
  var {
    typed: r,
    matrix: t,
    concat: n
  } = e, a = kt({
    typed: r,
    matrix: t,
    concat: n
  });
  return r(MF, Aw, a({
    elop: Aw,
    Ds: !0
  }));
}), w3 = "equal", Wwe = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"], WX = /* @__PURE__ */ Ce(w3, Wwe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    DenseMatrix: a,
    concat: i
  } = e, o = Zi({
    typed: r
  }), c = Sl({
    typed: r,
    DenseMatrix: a
  }), s = Aa({
    typed: r,
    DenseMatrix: a
  }), u = kt({
    typed: r,
    matrix: t,
    concat: i
  });
  return r(w3, Xwe({
    typed: r,
    equalScalar: n
  }), u({
    elop: n,
    SS: c,
    DS: o,
    Ss: s
  }));
}), Xwe = Ce(w3, ["typed", "equalScalar"], (e) => {
  var {
    typed: r,
    equalScalar: t
  } = e;
  return r(w3, {
    "any, any": function(a, i) {
      return a === null ? i === null : i === null ? a === null : a === void 0 ? i === void 0 : i === void 0 ? a === void 0 : t(a, i);
    }
  });
}), wF = "equalText", Ywe = ["typed", "compareText", "isZero"], Qwe = /* @__PURE__ */ Ce(wF, Ywe, (e) => {
  var {
    typed: r,
    compareText: t,
    isZero: n
  } = e;
  return r(wF, {
    "any, any": function(i, o) {
      return n(t(i, o));
    }
  });
}), E3 = "smaller", Zwe = ["typed", "config", "matrix", "DenseMatrix", "concat"], XX = /* @__PURE__ */ Ce(E3, Zwe, (e) => {
  var {
    typed: r,
    config: t,
    matrix: n,
    DenseMatrix: a,
    concat: i
  } = e, o = Zi({
    typed: r
  }), c = Sl({
    typed: r,
    DenseMatrix: a
  }), s = Aa({
    typed: r,
    DenseMatrix: a
  }), u = kt({
    typed: r,
    matrix: n,
    concat: i
  }), l = Qp({
    typed: r
  });
  return r(E3, Jwe({
    typed: r,
    config: t
  }), {
    "boolean, boolean": (f, d) => f < d,
    "BigNumber, BigNumber": function(d, m) {
      return d.lt(m) && !To(d, m, t.relTol, t.absTol);
    },
    "bigint, bigint": (f, d) => f < d,
    "Fraction, Fraction": (f, d) => f.compare(d) === -1,
    "Complex, Complex": function(d, m) {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, l, u({
    SS: c,
    DS: o,
    Ss: s
  }));
}), Jwe = /* @__PURE__ */ Ce(E3, ["typed", "config"], (e) => {
  var {
    typed: r,
    config: t
  } = e;
  return r(E3, {
    "number, number": function(a, i) {
      return a < i && !oi(a, i, t.relTol, t.absTol);
    }
  });
}), D3 = "smallerEq", eEe = ["typed", "config", "matrix", "DenseMatrix", "concat"], YX = /* @__PURE__ */ Ce(D3, eEe, (e) => {
  var {
    typed: r,
    config: t,
    matrix: n,
    DenseMatrix: a,
    concat: i
  } = e, o = Zi({
    typed: r
  }), c = Sl({
    typed: r,
    DenseMatrix: a
  }), s = Aa({
    typed: r,
    DenseMatrix: a
  }), u = kt({
    typed: r,
    matrix: n,
    concat: i
  }), l = Qp({
    typed: r
  });
  return r(D3, rEe({
    typed: r,
    config: t
  }), {
    "boolean, boolean": (f, d) => f <= d,
    "BigNumber, BigNumber": function(d, m) {
      return d.lte(m) || To(d, m, t.relTol, t.absTol);
    },
    "bigint, bigint": (f, d) => f <= d,
    "Fraction, Fraction": (f, d) => f.compare(d) !== 1,
    "Complex, Complex": function() {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, l, u({
    SS: c,
    DS: o,
    Ss: s
  }));
}), rEe = /* @__PURE__ */ Ce(D3, ["typed", "config"], (e) => {
  var {
    typed: r,
    config: t
  } = e;
  return r(D3, {
    "number, number": function(a, i) {
      return a <= i || oi(a, i, t.relTol, t.absTol);
    }
  });
}), I3 = "larger", tEe = ["typed", "config", "matrix", "DenseMatrix", "concat"], QX = /* @__PURE__ */ Ce(I3, tEe, (e) => {
  var {
    typed: r,
    config: t,
    matrix: n,
    DenseMatrix: a,
    concat: i
  } = e, o = Zi({
    typed: r
  }), c = Sl({
    typed: r,
    DenseMatrix: a
  }), s = Aa({
    typed: r,
    DenseMatrix: a
  }), u = kt({
    typed: r,
    matrix: n,
    concat: i
  }), l = Qp({
    typed: r
  });
  return r(I3, nEe({
    typed: r,
    config: t
  }), {
    "boolean, boolean": (f, d) => f > d,
    "BigNumber, BigNumber": function(d, m) {
      return d.gt(m) && !To(d, m, t.relTol, t.absTol);
    },
    "bigint, bigint": (f, d) => f > d,
    "Fraction, Fraction": (f, d) => f.compare(d) === 1,
    "Complex, Complex": function() {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, l, u({
    SS: c,
    DS: o,
    Ss: s
  }));
}), nEe = /* @__PURE__ */ Ce(I3, ["typed", "config"], (e) => {
  var {
    typed: r,
    config: t
  } = e;
  return r(I3, {
    "number, number": function(a, i) {
      return a > i && !oi(a, i, t.relTol, t.absTol);
    }
  });
}), B3 = "largerEq", aEe = ["typed", "config", "matrix", "DenseMatrix", "concat"], ZX = /* @__PURE__ */ Ce(B3, aEe, (e) => {
  var {
    typed: r,
    config: t,
    matrix: n,
    DenseMatrix: a,
    concat: i
  } = e, o = Zi({
    typed: r
  }), c = Sl({
    typed: r,
    DenseMatrix: a
  }), s = Aa({
    typed: r,
    DenseMatrix: a
  }), u = kt({
    typed: r,
    matrix: n,
    concat: i
  }), l = Qp({
    typed: r
  });
  return r(B3, iEe({
    typed: r,
    config: t
  }), {
    "boolean, boolean": (f, d) => f >= d,
    "BigNumber, BigNumber": function(d, m) {
      return d.gte(m) || To(d, m, t.relTol, t.absTol);
    },
    "bigint, bigint": function(d, m) {
      return d >= m;
    },
    "Fraction, Fraction": (f, d) => f.compare(d) !== -1,
    "Complex, Complex": function() {
      throw new TypeError("No ordering relation is defined for complex numbers");
    }
  }, l, u({
    SS: c,
    DS: o,
    Ss: s
  }));
}), iEe = /* @__PURE__ */ Ce(B3, ["typed", "config"], (e) => {
  var {
    typed: r,
    config: t
  } = e;
  return r(B3, {
    "number, number": function(a, i) {
      return a >= i || oi(a, i, t.relTol, t.absTol);
    }
  });
}), EF = "deepEqual", oEe = ["typed", "equal"], uEe = /* @__PURE__ */ Ce(EF, oEe, (e) => {
  var {
    typed: r,
    equal: t
  } = e;
  return r(EF, {
    "any, any": function(i, o) {
      return n(i.valueOf(), o.valueOf());
    }
  });
  function n(a, i) {
    if (Array.isArray(a))
      if (Array.isArray(i)) {
        var o = a.length;
        if (o !== i.length)
          return !1;
        for (var c = 0; c < o; c++)
          if (!n(a[c], i[c]))
            return !1;
        return !0;
      } else
        return !1;
    else
      return Array.isArray(i) ? !1 : t(a, i);
  }
}), N3 = "unequal", sEe = ["typed", "config", "equalScalar", "matrix", "DenseMatrix", "concat"], lEe = /* @__PURE__ */ Ce(N3, sEe, (e) => {
  var {
    typed: r,
    config: t,
    equalScalar: n,
    matrix: a,
    DenseMatrix: i,
    concat: o
  } = e, c = Zi({
    typed: r
  }), s = Sl({
    typed: r,
    DenseMatrix: i
  }), u = Aa({
    typed: r,
    DenseMatrix: i
  }), l = kt({
    typed: r,
    matrix: a,
    concat: o
  });
  return r(N3, cEe({
    typed: r,
    equalScalar: n
  }), l({
    elop: f,
    SS: s,
    DS: c,
    Ss: u
  }));
  function f(d, m) {
    return !n(d, m);
  }
}), cEe = Ce(N3, ["typed", "equalScalar"], (e) => {
  var {
    typed: r,
    equalScalar: t
  } = e;
  return r(N3, {
    "any, any": function(a, i) {
      return a === null ? i !== null : i === null ? a !== null : a === void 0 ? i !== void 0 : i === void 0 ? a !== void 0 : !t(a, i);
    }
  });
}), DF = "partitionSelect", dEe = ["typed", "isNumeric", "isNaN", "compare"], fEe = /* @__PURE__ */ Ce(DF, dEe, (e) => {
  var {
    typed: r,
    isNumeric: t,
    isNaN: n,
    compare: a
  } = e, i = a, o = (u, l) => -a(u, l);
  return r(DF, {
    "Array | Matrix, number": function(l, f) {
      return c(l, f, i);
    },
    "Array | Matrix, number, string": function(l, f, d) {
      if (d === "asc")
        return c(l, f, i);
      if (d === "desc")
        return c(l, f, o);
      throw new Error('Compare string must be "asc" or "desc"');
    },
    "Array | Matrix, number, function": c
  });
  function c(u, l, f) {
    if (!lr(l) || l < 0)
      throw new Error("k must be a non-negative integer");
    if (gr(u)) {
      var d = u.size();
      if (d.length > 1)
        throw new Error("Only one dimensional matrices supported");
      return s(u.valueOf(), l, f);
    }
    if (Array.isArray(u))
      return s(u, l, f);
  }
  function s(u, l, f) {
    if (l >= u.length)
      throw new Error("k out of bounds");
    for (var d = 0; d < u.length; d++)
      if (t(u[d]) && n(u[d]))
        return u[d];
    for (var m = 0, p = u.length - 1; m < p; ) {
      for (var v = m, h = p, y = u[Math.floor(Math.random() * (p - m + 1)) + m]; v < h; )
        if (f(u[v], y) >= 0) {
          var C = u[h];
          u[h] = u[v], u[v] = C, --h;
        } else
          ++v;
      f(u[v], y) > 0 && --v, l <= v ? p = v : m = v + 1;
    }
    return u[l];
  }
}), IF = "sort", mEe = ["typed", "matrix", "compare", "compareNatural"], vEe = /* @__PURE__ */ Ce(IF, mEe, (e) => {
  var {
    typed: r,
    matrix: t,
    compare: n,
    compareNatural: a
  } = e, i = n, o = (l, f) => -n(l, f);
  return r(IF, {
    Array: function(f) {
      return s(f), f.sort(i);
    },
    Matrix: function(f) {
      return u(f), t(f.toArray().sort(i), f.storage());
    },
    "Array, function": function(f, d) {
      return s(f), f.sort(d);
    },
    "Matrix, function": function(f, d) {
      return u(f), t(f.toArray().sort(d), f.storage());
    },
    "Array, string": function(f, d) {
      return s(f), f.sort(c(d));
    },
    "Matrix, string": function(f, d) {
      return u(f), t(f.toArray().sort(c(d)), f.storage());
    }
  });
  function c(l) {
    if (l === "asc")
      return i;
    if (l === "desc")
      return o;
    if (l === "natural")
      return a;
    throw new Error('String "asc", "desc", or "natural" expected');
  }
  function s(l) {
    if (Fr(l).length !== 1)
      throw new Error("One dimensional array expected");
  }
  function u(l) {
    if (l.size().length !== 1)
      throw new Error("One dimensional matrix expected");
  }
}), BF = "max", pEe = ["typed", "config", "numeric", "larger"], JX = /* @__PURE__ */ Ce(BF, pEe, (e) => {
  var {
    typed: r,
    config: t,
    numeric: n,
    larger: a
  } = e;
  return r(BF, {
    // max([a, b, c, d, ...])
    "Array | Matrix": o,
    // max([a, b, c, d, ...], dim)
    "Array | Matrix, number | BigNumber": function(s, u) {
      return sx(s, u.valueOf(), i);
    },
    // max(a, b, c, d, ...)
    "...": function(s) {
      if (Wp(s))
        throw new TypeError("Scalar values expected in function max");
      return o(s);
    }
  });
  function i(c, s) {
    try {
      return a(c, s) ? c : s;
    } catch (u) {
      throw Xi(u, "max", s);
    }
  }
  function o(c) {
    var s;
    if (yc(c, function(u) {
      try {
        isNaN(u) && typeof u == "number" ? s = NaN : (s === void 0 || a(u, s)) && (s = u);
      } catch (l) {
        throw Xi(l, "max", u);
      }
    }), s === void 0)
      throw new Error("Cannot calculate max of an empty array");
    return typeof s == "string" && (s = n(s, rf(s, t))), s;
  }
}), NF = "min", hEe = ["typed", "config", "numeric", "smaller"], eY = /* @__PURE__ */ Ce(NF, hEe, (e) => {
  var {
    typed: r,
    config: t,
    numeric: n,
    smaller: a
  } = e;
  return r(NF, {
    // min([a, b, c, d, ...])
    "Array | Matrix": o,
    // min([a, b, c, d, ...], dim)
    "Array | Matrix, number | BigNumber": function(s, u) {
      return sx(s, u.valueOf(), i);
    },
    // min(a, b, c, d, ...)
    "...": function(s) {
      if (Wp(s))
        throw new TypeError("Scalar values expected in function min");
      return o(s);
    }
  });
  function i(c, s) {
    try {
      return a(c, s) ? c : s;
    } catch (u) {
      throw Xi(u, "min", s);
    }
  }
  function o(c) {
    var s;
    if (yc(c, function(u) {
      try {
        isNaN(u) && typeof u == "number" ? s = NaN : (s === void 0 || a(u, s)) && (s = u);
      } catch (l) {
        throw Xi(l, "min", u);
      }
    }), s === void 0)
      throw new Error("Cannot calculate min of an empty array");
    return typeof s == "string" && (s = n(s, rf(s, t))), s;
  }
}), gEe = "ImmutableDenseMatrix", yEe = ["smaller", "DenseMatrix"], rY = /* @__PURE__ */ Ce(gEe, yEe, (e) => {
  var {
    smaller: r,
    DenseMatrix: t
  } = e;
  function n(a, i) {
    if (!(this instanceof n))
      throw new SyntaxError("Constructor must be called with the new operator");
    if (i && !Ya(i))
      throw new Error("Invalid datatype: " + i);
    if (gr(a) || dt(a)) {
      var o = new t(a, i);
      this._data = o._data, this._size = o._size, this._datatype = o._datatype, this._min = null, this._max = null;
    } else if (a && dt(a.data) && dt(a.size))
      this._data = a.data, this._size = a.size, this._datatype = a.datatype, this._min = typeof a.min < "u" ? a.min : null, this._max = typeof a.max < "u" ? a.max : null;
    else {
      if (a)
        throw new TypeError("Unsupported type of data (" + Et(a) + ")");
      this._data = [], this._size = [0], this._datatype = i, this._min = null, this._max = null;
    }
  }
  return n.prototype = new t(), n.prototype.type = "ImmutableDenseMatrix", n.prototype.isImmutableDenseMatrix = !0, n.prototype.subset = function(a) {
    switch (arguments.length) {
      case 1: {
        var i = t.prototype.subset.call(this, a);
        return gr(i) ? new n({
          data: i._data,
          size: i._size,
          datatype: i._datatype
        }) : i;
      }
      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: Sr(this._data),
      size: Sr(this._size),
      datatype: this._datatype
    });
  }, n.prototype.toJSON = function() {
    return {
      mathjs: "ImmutableDenseMatrix",
      data: this._data,
      size: this._size,
      datatype: this._datatype
    };
  }, n.fromJSON = function(a) {
    return new n(a);
  }, n.prototype.swapRows = function() {
    throw new Error("Cannot invoke swapRows on an Immutable Matrix instance");
  }, n.prototype.min = function() {
    if (this._min === null) {
      var a = null;
      this.forEach(function(i) {
        (a === null || r(i, a)) && (a = i);
      }), this._min = a !== null ? a : void 0;
    }
    return this._min;
  }, n.prototype.max = function() {
    if (this._max === null) {
      var a = null;
      this.forEach(function(i) {
        (a === null || r(a, i)) && (a = i);
      }), this._max = a !== null ? a : void 0;
    }
    return this._max;
  }, n;
}, {
  isClass: !0
}), _Ee = "Index", bEe = ["ImmutableDenseMatrix", "getMatrixDataType"], tY = /* @__PURE__ */ Ce(_Ee, bEe, (e) => {
  var {
    ImmutableDenseMatrix: r,
    getMatrixDataType: t
  } = e;
  function n(i) {
    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, c = arguments.length; o < c; o++) {
      var s = arguments[o], u = dt(s), l = gr(s), f = null;
      if (rx(s))
        this._dimensions.push(s), this._isScalar = !1;
      else if (u || l) {
        var d = void 0;
        t(s) === "boolean" ? (u && (d = a(VF(s).valueOf())), l && (d = a(VF(s._data).valueOf())), f = s.valueOf().length) : d = a(s.valueOf()), this._dimensions.push(d);
        var m = d.size();
        (m.length !== 1 || m[0] !== 1 || f !== null) && (this._isScalar = !1);
      } else if (typeof s == "number")
        this._dimensions.push(a([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(f);
    }
  }
  n.prototype.type = "Index", n.prototype.isIndex = !0;
  function a(i) {
    for (var o = 0, c = i.length; o < c; o++)
      if (typeof i[o] != "number" || !lr(i[o]))
        throw new TypeError("Index parameters must be positive integer numbers");
    return new r(i);
  }
  return n.prototype.clone = function() {
    var i = new n();
    return i._dimensions = Sr(this._dimensions), i._isScalar = this._isScalar, i._sourceSize = this._sourceSize, i;
  }, n.create = function(i) {
    var o = new n();
    return n.apply(o, i), o;
  }, n.prototype.size = function() {
    for (var i = [], o = 0, c = this._dimensions.length; o < c; o++) {
      var s = this._dimensions[o];
      i[o] = typeof s == "string" ? 1 : s.size()[0];
    }
    return i;
  }, n.prototype.max = function() {
    for (var i = [], o = 0, c = this._dimensions.length; o < c; o++) {
      var s = this._dimensions[o];
      i[o] = typeof s == "string" ? s : s.max();
    }
    return i;
  }, n.prototype.min = function() {
    for (var i = [], o = 0, c = this._dimensions.length; o < c; o++) {
      var s = this._dimensions[o];
      i[o] = typeof s == "string" ? s : s.min();
    }
    return i;
  }, n.prototype.forEach = function(i) {
    for (var o = 0, c = this._dimensions.length; o < c; o++)
      i(this._dimensions[o], o, this);
  }, n.prototype.dimension = function(i) {
    return this._dimensions[i] || 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 i = [], o = 0, c = this._dimensions.length; o < c; o++) {
      var s = this._dimensions[o];
      i.push(typeof s == "string" ? s : s.toArray());
    }
    return i;
  }, n.prototype.valueOf = n.prototype.toArray, n.prototype.toString = function() {
    for (var i = [], o = 0, c = this._dimensions.length; o < c; o++) {
      var s = this._dimensions[o];
      typeof s == "string" ? i.push(JSON.stringify(s)) : i.push(s.toString());
    }
    return "[" + i.join(", ") + "]";
  }, n.prototype.toJSON = function() {
    return {
      mathjs: "Index",
      dimensions: this._dimensions
    };
  }, n.fromJSON = function(i) {
    return n.create(i.dimensions);
  }, n;
}, {
  isClass: !0
});
function VF(e) {
  var r = [];
  return e.forEach((t, n) => {
    t && r.push(n);
  }), r;
}
var SEe = "FibonacciHeap", CEe = ["smaller", "larger"], AEe = /* @__PURE__ */ Ce(SEe, CEe, (e) => {
  var {
    smaller: r,
    larger: t
  } = e, n = 1 / Math.log((1 + Math.sqrt(5)) / 2);
  function a() {
    if (!(this instanceof a))
      throw new SyntaxError("Constructor must be called with the new operator");
    this._minimum = null, this._size = 0;
  }
  a.prototype.type = "FibonacciHeap", a.prototype.isFibonacciHeap = !0, a.prototype.insert = function(l, f) {
    var d = {
      key: l,
      value: f,
      degree: 0
    };
    if (this._minimum) {
      var m = this._minimum;
      d.left = m, d.right = m.right, m.right = d, d.right.left = d, r(l, m.key) && (this._minimum = d);
    } else
      d.left = d, d.right = d, this._minimum = d;
    return this._size++, d;
  }, a.prototype.size = function() {
    return this._size;
  }, a.prototype.clear = function() {
    this._minimum = null, this._size = 0;
  }, a.prototype.isEmpty = function() {
    return this._size === 0;
  }, a.prototype.extractMinimum = function() {
    var l = this._minimum;
    if (l === null)
      return l;
    for (var f = this._minimum, d = l.degree, m = l.child; d > 0; ) {
      var p = m.right;
      m.left.right = m.right, m.right.left = m.left, m.left = f, m.right = f.right, f.right = m, m.right.left = m, m.parent = null, m = p, d--;
    }
    return l.left.right = l.right, l.right.left = l.left, l === l.right ? f = null : (f = l.right, f = u(f, this._size)), this._size--, this._minimum = f, l;
  }, a.prototype.remove = function(l) {
    this._minimum = i(this._minimum, l, -1), this.extractMinimum();
  };
  function i(l, f, d) {
    f.key = d;
    var m = f.parent;
    return m && r(f.key, m.key) && (o(l, f, m), c(l, m)), r(f.key, l.key) && (l = f), l;
  }
  function o(l, f, d) {
    f.left.right = f.right, f.right.left = f.left, d.degree--, d.child === f && (d.child = f.right), d.degree === 0 && (d.child = null), f.left = l, f.right = l.right, l.right = f, f.right.left = f, f.parent = null, f.mark = !1;
  }
  function c(l, f) {
    var d = f.parent;
    d && (f.mark ? (o(l, f, d), c(d)) : f.mark = !0);
  }
  var s = function(f, d) {
    f.left.right = f.right, f.right.left = f.left, f.parent = d, d.child ? (f.left = d.child, f.right = d.child.right, d.child.right = f, f.right.left = f) : (d.child = f, f.right = f, f.left = f), d.degree++, f.mark = !1;
  };
  function u(l, f) {
    var d = Math.floor(Math.log(f) * n) + 1, m = new Array(d), p = 0, v = l;
    if (v)
      for (p++, v = v.right; v !== l; )
        p++, v = v.right;
    for (var h; p > 0; ) {
      for (var y = v.degree, C = v.right; h = m[y], !!h; ) {
        if (t(v.key, h.key)) {
          var S = h;
          h = v, v = S;
        }
        s(h, v), m[y] = null, y++;
      }
      m[y] = v, v = C, p--;
    }
    l = null;
    for (var b = 0; b < d; b++)
      h = m[b], h && (l ? (h.left.right = h.right, h.right.left = h.left, h.left = l, h.right = l.right, l.right = h, h.right.left = h, r(h.key, l.key) && (l = h)) : l = h);
    return l;
  }
  return a;
}, {
  isClass: !0
}), xEe = "Spa", TEe = ["addScalar", "equalScalar", "FibonacciHeap"], PEe = /* @__PURE__ */ Ce(xEe, TEe, (e) => {
  var {
    addScalar: r,
    equalScalar: t,
    FibonacciHeap: n
  } = e;
  function a() {
    if (!(this instanceof a))
      throw new SyntaxError("Constructor must be called with the new operator");
    this._values = [], this._heap = new n();
  }
  return a.prototype.type = "Spa", a.prototype.isSpa = !0, a.prototype.set = function(i, o) {
    if (this._values[i])
      this._values[i].value = o;
    else {
      var c = this._heap.insert(i, o);
      this._values[i] = c;
    }
  }, a.prototype.get = function(i) {
    var o = this._values[i];
    return o ? o.value : 0;
  }, a.prototype.accumulate = function(i, o) {
    var c = this._values[i];
    c ? c.value = r(c.value, o) : (c = this._heap.insert(i, o), this._values[i] = c);
  }, a.prototype.forEach = function(i, o, c) {
    var s = this._heap, u = this._values, l = [], f = s.extractMinimum();
    for (f && l.push(f); f && f.key <= o; )
      f.key >= i && (t(f.value, 0) || c(f.key, f.value, this)), f = s.extractMinimum(), f && l.push(f);
    for (var d = 0; d < l.length; d++) {
      var m = l[d];
      f = s.insert(m.key, m.value), u[f.key] = f;
    }
  }, a.prototype.swap = function(i, o) {
    var c = this._values[i], s = this._values[o];
    if (!c && s)
      c = this._heap.insert(i, s.value), this._heap.remove(s), this._values[i] = c, this._values[o] = void 0;
    else if (c && !s)
      s = this._heap.insert(o, c.value), this._heap.remove(c), this._values[o] = s, this._values[i] = void 0;
    else if (c && s) {
      var u = c.value;
      c.value = s.value, s.value = u;
    }
  }, a;
}, {
  isClass: !0
}), MEe = jy(function(e) {
  return new e(1).exp();
}, {
  hasher: dx
}), wEe = jy(function(e) {
  return new e(1).plus(new e(5).sqrt()).div(2);
}, {
  hasher: dx
}), LD = jy(function(e) {
  return e.acos(-1);
}, {
  hasher: dx
}), EEe = jy(function(e) {
  return LD(e).times(2);
}, {
  hasher: dx
});
function dx(e) {
  return e[0].precision;
}
function RF(e, r) {
  var t = Object.keys(e);
  if (Object.getOwnPropertySymbols) {
    var n = Object.getOwnPropertySymbols(e);
    r && (n = n.filter(function(a) {
      return Object.getOwnPropertyDescriptor(e, a).enumerable;
    })), t.push.apply(t, n);
  }
  return t;
}
function TP(e) {
  for (var r = 1; r < arguments.length; r++) {
    var t = arguments[r] != null ? arguments[r] : {};
    r % 2 ? RF(Object(t), !0).forEach(function(n) {
      ba(e, n, t[n]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : RF(Object(t)).forEach(function(n) {
      Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(t, n));
    });
  }
  return e;
}
var DEe = "Unit", IEe = ["?on", "config", "addScalar", "subtractScalar", "multiplyScalar", "divideScalar", "pow", "abs", "fix", "round", "equal", "isNumeric", "format", "number", "Complex", "BigNumber", "Fraction"], BEe = /* @__PURE__ */ Ce(DEe, IEe, (e) => {
  var {
    on: r,
    config: t,
    addScalar: n,
    subtractScalar: a,
    multiplyScalar: i,
    divideScalar: o,
    pow: c,
    abs: s,
    fix: u,
    round: l,
    equal: f,
    isNumeric: d,
    format: m,
    number: p,
    Complex: v,
    BigNumber: h,
    Fraction: y
  } = e, C = p;
  function S(W, te) {
    if (!(this instanceof S))
      throw new Error("Constructor must be called with the new operator");
    if (!(W == null || d(W) || as(W)))
      throw new TypeError("First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined");
    if (this.fixPrefix = !1, this.skipAutomaticSimplification = !0, te === void 0)
      this.units = [], this.dimensions = O.map((z) => 0);
    else if (typeof te == "string") {
      var oe = S.parse(te);
      this.units = oe.units, this.dimensions = oe.dimensions;
    } else if (ho(te) && te.value === null)
      this.fixPrefix = te.fixPrefix, this.skipAutomaticSimplification = te.skipAutomaticSimplification, this.dimensions = te.dimensions.slice(0), this.units = te.units.map((z) => Xa({}, z));
    else
      throw new TypeError("Second parameter in Unit constructor must be a string or valueless Unit");
    this.value = this._normalize(W);
  }
  Object.defineProperty(S, "name", {
    value: "Unit"
  }), S.prototype.constructor = S, S.prototype.type = "Unit", S.prototype.isUnit = !0;
  var b, g, _;
  function A() {
    for (; _ === " " || _ === "	"; )
      T();
  }
  function M(W) {
    return W >= "0" && W <= "9" || W === ".";
  }
  function P(W) {
    return W >= "0" && W <= "9";
  }
  function T() {
    g++, _ = b.charAt(g);
  }
  function x(W) {
    g = W, _ = b.charAt(g);
  }
  function w() {
    var W = "", te = g;
    if (_ === "+" ? T() : _ === "-" && (W += _, T()), !M(_))
      return x(te), null;
    if (_ === ".") {
      if (W += _, T(), !P(_))
        return x(te), null;
    } else {
      for (; P(_); )
        W += _, T();
      _ === "." && (W += _, T());
    }
    for (; P(_); )
      W += _, T();
    if (_ === "E" || _ === "e") {
      var oe = "", z = g;
      if (oe += _, T(), (_ === "+" || _ === "-") && (oe += _, T()), !P(_))
        return x(z), W;
      for (W = W + oe; P(_); )
        W += _, T();
    }
    return W;
  }
  function E() {
    for (var W = ""; P(_) || S.isValidAlpha(_); )
      W += _, T();
    var te = W.charAt(0);
    return S.isValidAlpha(te) ? W : null;
  }
  function I(W) {
    return _ === W ? (T(), W) : null;
  }
  S.parse = function(W, te) {
    if (te = te || {}, b = W, g = -1, _ = "", typeof b != "string")
      throw new TypeError("Invalid argument in Unit.parse, string expected");
    var oe = new S();
    oe.units = [];
    var z = 1, j = !1;
    T(), A();
    var ae = w(), le = null;
    if (ae) {
      if (t.number === "BigNumber")
        le = new h(ae);
      else if (t.number === "Fraction")
        try {
          le = new y(ae);
        } catch {
          le = parseFloat(ae);
        }
      else
        le = parseFloat(ae);
      A(), I("*") ? (z = 1, j = !0) : I("/") && (z = -1, j = !0);
    }
    for (var ie = [], re = 1; ; ) {
      for (A(); _ === "("; )
        ie.push(z), re *= z, z = 1, T(), A();
      var ee = void 0;
      if (_) {
        var ne = _;
        if (ee = E(), ee === null)
          throw new SyntaxError('Unexpected "' + ne + '" in "' + b + '" at index ' + g.toString());
      } else
        break;
      var se = B(ee);
      if (se === null)
        throw new SyntaxError('Unit "' + ee + '" not found.');
      var ce = z * re;
      if (A(), I("^")) {
        A();
        var de = w();
        if (de === null)
          throw new SyntaxError('In "' + W + '", "^" must be followed by a floating-point number');
        ce *= de;
      }
      oe.units.push({
        unit: se.unit,
        prefix: se.prefix,
        power: ce
      });
      for (var me = 0; me < O.length; me++)
        oe.dimensions[me] += (se.unit.dimensions[me] || 0) * ce;
      for (A(); _ === ")"; ) {
        if (ie.length === 0)
          throw new SyntaxError('Unmatched ")" in "' + b + '" at index ' + g.toString());
        re /= ie.pop(), T(), A();
      }
      if (j = !1, I("*") ? (z = 1, j = !0) : I("/") ? (z = -1, j = !0) : z = 1, se.unit.base) {
        var he = se.unit.base.key;
        H.auto[he] = {
          unit: se.unit,
          prefix: se.prefix
        };
      }
    }
    if (A(), _)
      throw new SyntaxError('Could not parse: "' + W + '"');
    if (j)
      throw new SyntaxError('Trailing characters: "' + W + '"');
    if (ie.length !== 0)
      throw new SyntaxError('Unmatched "(" in "' + b + '"');
    if (oe.units.length === 0 && !te.allowNoUnits)
      throw new SyntaxError('"' + W + '" contains no units');
    return oe.value = le !== void 0 ? oe._normalize(le) : null, oe;
  }, S.prototype.clone = function() {
    var W = new S();
    W.fixPrefix = this.fixPrefix, W.skipAutomaticSimplification = this.skipAutomaticSimplification, W.value = Sr(this.value), W.dimensions = this.dimensions.slice(0), W.units = [];
    for (var te = 0; te < this.units.length; te++) {
      W.units[te] = {};
      for (var oe in this.units[te])
        er(this.units[te], oe) && (W.units[te][oe] = this.units[te][oe]);
    }
    return W;
  }, S.prototype.valueType = function() {
    return Et(this.value);
  }, S.prototype._isDerived = function() {
    return this.units.length === 0 ? !1 : this.units.length > 1 || Math.abs(this.units[0].power - 1) > 1e-15;
  }, S.prototype._normalize = function(W) {
    if (W == null || this.units.length === 0)
      return W;
    for (var te = W, oe = S._getNumberConverter(Et(W)), z = 0; z < this.units.length; z++) {
      var j = oe(this.units[z].unit.value), ae = oe(this.units[z].prefix.value), le = oe(this.units[z].power);
      te = i(te, c(i(j, ae), le));
    }
    return te;
  }, S.prototype._denormalize = function(W, te) {
    if (W == null || this.units.length === 0)
      return W;
    for (var oe = W, z = S._getNumberConverter(Et(W)), j = 0; j < this.units.length; j++) {
      var ae = z(this.units[j].unit.value), le = z(this.units[j].prefix.value), ie = z(this.units[j].power);
      oe = o(oe, c(i(ae, le), ie));
    }
    return oe;
  };
  var B = jy((W) => {
    if (er(R, W)) {
      var te = R[W], oe = te.prefixes[""];
      return {
        unit: te,
        prefix: oe
      };
    }
    for (var z in R)
      if (er(R, z) && Rxe(W, z)) {
        var j = R[z], ae = W.length - z.length, le = W.substring(0, ae), ie = er(j.prefixes, le) ? j.prefixes[le] : void 0;
        if (ie !== void 0)
          return {
            unit: j,
            prefix: ie
          };
      }
    return null;
  }, {
    hasher: (W) => W[0],
    limit: 100
  });
  S.isValuelessUnit = function(W) {
    return B(W) !== null;
  }, S.prototype.hasBase = function(W) {
    if (typeof W == "string" && (W = V[W]), !W)
      return !1;
    for (var te = 0; te < O.length; te++)
      if (Math.abs((this.dimensions[te] || 0) - (W.dimensions[te] || 0)) > 1e-12)
        return !1;
    return !0;
  }, S.prototype.equalBase = function(W) {
    for (var te = 0; te < O.length; te++)
      if (Math.abs((this.dimensions[te] || 0) - (W.dimensions[te] || 0)) > 1e-12)
        return !1;
    return !0;
  }, S.prototype.equals = function(W) {
    return this.equalBase(W) && f(this.value, W.value);
  }, S.prototype.multiply = function(W) {
    for (var te = this.clone(), oe = ho(W) ? W : new S(W), z = 0; z < O.length; z++)
      te.dimensions[z] = (this.dimensions[z] || 0) + (oe.dimensions[z] || 0);
    for (var j = 0; j < oe.units.length; j++) {
      var ae = TP({}, oe.units[j]);
      te.units.push(ae);
    }
    if (this.value !== null || oe.value !== null) {
      var le = this.value === null ? this._normalize(1) : this.value, ie = oe.value === null ? oe._normalize(1) : oe.value;
      te.value = i(le, ie);
    } else
      te.value = null;
    return ho(W) && (te.skipAutomaticSimplification = !1), D(te);
  }, S.prototype.divideInto = function(W) {
    return new S(W).divide(this);
  }, S.prototype.divide = function(W) {
    for (var te = this.clone(), oe = ho(W) ? W : new S(W), z = 0; z < O.length; z++)
      te.dimensions[z] = (this.dimensions[z] || 0) - (oe.dimensions[z] || 0);
    for (var j = 0; j < oe.units.length; j++) {
      var ae = TP(TP({}, oe.units[j]), {}, {
        power: -oe.units[j].power
      });
      te.units.push(ae);
    }
    if (this.value !== null || oe.value !== null) {
      var le = this.value === null ? this._normalize(1) : this.value, ie = oe.value === null ? oe._normalize(1) : oe.value;
      te.value = o(le, ie);
    } else
      te.value = null;
    return ho(W) && (te.skipAutomaticSimplification = !1), D(te);
  }, S.prototype.pow = function(W) {
    for (var te = this.clone(), oe = 0; oe < O.length; oe++)
      te.dimensions[oe] = (this.dimensions[oe] || 0) * W;
    for (var z = 0; z < te.units.length; z++)
      te.units[z].power *= W;
    return te.value !== null ? te.value = c(te.value, W) : te.value = null, te.skipAutomaticSimplification = !1, D(te);
  };
  function D(W) {
    return W.equalBase(V.NONE) && W.value !== null && !t.predictable ? W.value : W;
  }
  S.prototype.abs = function() {
    var W = this.clone();
    if (W.value !== null)
      if (W._isDerived() || W.units.length === 0 || W.units[0].unit.offset === 0)
        W.value = s(W.value);
      else {
        var te = W._numberConverter(), oe = te(W.units[0].unit.value), z = te(W.units[0].unit.offset), j = i(oe, z);
        W.value = a(s(n(W.value, j)), j);
      }
    for (var ae in W.units)
      (W.units[ae].unit.name === "VA" || W.units[ae].unit.name === "VAR") && (W.units[ae].unit = R.W);
    return W;
  }, S.prototype.to = function(W) {
    var te = this.value === null ? this._normalize(1) : this.value, oe;
    if (typeof W == "string")
      oe = S.parse(W);
    else if (ho(W))
      oe = W.clone();
    else
      throw new Error("String or Unit expected as parameter");
    if (!this.equalBase(oe))
      throw new Error("Units do not match ('".concat(oe.toString(), "' != '").concat(this.toString(), "')"));
    if (oe.value !== null)
      throw new Error("Cannot convert to a unit with a value");
    if (this.value === null || this._isDerived() || this.units.length === 0 || oe.units.length === 0 || this.units[0].unit.offset === oe.units[0].unit.offset)
      oe.value = Sr(te);
    else {
      var z = S._getNumberConverter(Et(te)), j = this.units[0].unit.value, ae = this.units[0].unit.offset, le = i(j, ae), ie = oe.units[0].unit.value, re = oe.units[0].unit.offset, ee = i(ie, re);
      oe.value = n(te, z(a(le, ee)));
    }
    return oe.fixPrefix = !0, oe.skipAutomaticSimplification = !0, oe;
  }, S.prototype.toNumber = function(W) {
    return C(this.toNumeric(W));
  }, S.prototype.toNumeric = function(W) {
    var te;
    return W ? te = this.to(W) : te = this.clone(), te._isDerived() || te.units.length === 0 ? te._denormalize(te.value) : te._denormalize(te.value, te.units[0].prefix.value);
  }, S.prototype.toString = function() {
    return this.format();
  }, S.prototype.toJSON = function() {
    return {
      mathjs: "Unit",
      value: this._denormalize(this.value),
      unit: this.units.length > 0 ? this.formatUnits() : null,
      fixPrefix: this.fixPrefix
    };
  }, S.fromJSON = function(W) {
    var te, oe = new S(W.value, (te = W.unit) !== null && te !== void 0 ? te : void 0);
    return oe.fixPrefix = W.fixPrefix || !1, oe;
  }, S.prototype.valueOf = S.prototype.toString, S.prototype.simplify = function() {
    var W = this.clone(), te = [], oe;
    for (var z in q)
      if (er(q, z) && W.hasBase(V[z])) {
        oe = z;
        break;
      }
    if (oe === "NONE")
      W.units = [];
    else {
      var j;
      if (oe && er(q, oe) && (j = q[oe]), j)
        W.units = [{
          unit: j.unit,
          prefix: j.prefix,
          power: 1
        }];
      else {
        for (var ae = !1, le = 0; le < O.length; le++) {
          var ie = O[le];
          Math.abs(W.dimensions[le] || 0) > 1e-12 && (er(q, ie) ? te.push({
            unit: q[ie].unit,
            prefix: q[ie].prefix,
            power: W.dimensions[le] || 0
          }) : ae = !0);
        }
        te.length < W.units.length && !ae && (W.units = te);
      }
    }
    return W;
  }, S.prototype.toSI = function() {
    for (var W = this.clone(), te = [], oe = 0; oe < O.length; oe++) {
      var z = O[oe];
      if (Math.abs(W.dimensions[oe] || 0) > 1e-12)
        if (er(H.si, z))
          te.push({
            unit: H.si[z].unit,
            prefix: H.si[z].prefix,
            power: W.dimensions[oe] || 0
          });
        else
          throw new Error("Cannot express custom unit " + z + " in SI units");
    }
    return W.units = te, W.fixPrefix = !0, W.skipAutomaticSimplification = !0, this.value !== null ? (W.value = null, this.to(W)) : W;
  }, S.prototype.formatUnits = function() {
    for (var W = "", te = "", oe = 0, z = 0, j = 0; j < this.units.length; j++)
      this.units[j].power > 0 ? (oe++, W += " " + this.units[j].prefix.name + this.units[j].unit.name, Math.abs(this.units[j].power - 1) > 1e-15 && (W += "^" + this.units[j].power)) : this.units[j].power < 0 && z++;
    if (z > 0)
      for (var ae = 0; ae < this.units.length; ae++)
        this.units[ae].power < 0 && (oe > 0 ? (te += " " + this.units[ae].prefix.name + this.units[ae].unit.name, Math.abs(this.units[ae].power + 1) > 1e-15 && (te += "^" + -this.units[ae].power)) : (te += " " + this.units[ae].prefix.name + this.units[ae].unit.name, te += "^" + this.units[ae].power));
    W = W.substr(1), te = te.substr(1), oe > 1 && z > 0 && (W = "(" + W + ")"), z > 1 && oe > 0 && (te = "(" + te + ")");
    var le = W;
    return oe > 0 && z > 0 && (le += " / "), le += te, le;
  }, S.prototype.format = function(W) {
    var te = this.skipAutomaticSimplification || this.value === null ? this.clone() : this.simplify(), oe = !1;
    typeof te.value < "u" && te.value !== null && as(te.value) && (oe = Math.abs(te.value.re) < 1e-14);
    for (var z in te.units)
      er(te.units, z) && te.units[z].unit && (te.units[z].unit.name === "VA" && oe ? te.units[z].unit = R.VAR : te.units[z].unit.name === "VAR" && !oe && (te.units[z].unit = R.VA));
    te.units.length === 1 && !te.fixPrefix && Math.abs(te.units[0].power - Math.round(te.units[0].power)) < 1e-14 && (te.units[0].prefix = te._bestPrefix());
    var j = te._denormalize(te.value), ae = te.value !== null ? m(j, W || {}) : "", le = te.formatUnits();
    return te.value && as(te.value) && (ae = "(" + ae + ")"), le.length > 0 && ae.length > 0 && (ae += " "), ae += le, ae;
  }, S.prototype._bestPrefix = function() {
    if (this.units.length !== 1)
      throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");
    if (Math.abs(this.units[0].power - Math.round(this.units[0].power)) >= 1e-14)
      throw new Error("Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!");
    var W = this.value !== null ? s(this.value) : 0, te = s(this.units[0].unit.value), oe = this.units[0].prefix;
    if (W === 0)
      return oe;
    var z = this.units[0].power, j = Math.log(W / Math.pow(oe.value * te, z)) / Math.LN10 - 1.2;
    if (j > -2.200001 && j < 1.800001) return oe;
    j = Math.abs(j);
    var ae = this.units[0].unit.prefixes;
    for (var le in ae)
      if (er(ae, le)) {
        var ie = ae[le];
        if (ie.scientific) {
          var re = Math.abs(Math.log(W / Math.pow(ie.value * te, z)) / Math.LN10 - 1.2);
          (re < j || re === j && ie.name.length < oe.name.length) && (oe = ie, j = re);
        }
      }
    return oe;
  }, S.prototype.splitUnit = function(W) {
    for (var te = this.clone(), oe = [], z = 0; z < W.length && (te = te.to(W[z]), z !== W.length - 1); z++) {
      var j = te.toNumeric(), ae = l(j), le = void 0, ie = f(ae, j);
      ie ? le = ae : le = u(te.toNumeric());
      var re = new S(le, W[z].toString());
      oe.push(re), te = a(te, re);
    }
    for (var ee = 0, ne = 0; ne < oe.length; ne++)
      ee = n(ee, oe[ne].value);
    return f(ee, this.value) && (te.value = 0), oe.push(te), oe;
  };
  var N = {
    NONE: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      }
    },
    SHORT: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      da: {
        name: "da",
        value: 10,
        scientific: !1
      },
      h: {
        name: "h",
        value: 100,
        scientific: !1
      },
      k: {
        name: "k",
        value: 1e3,
        scientific: !0
      },
      M: {
        name: "M",
        value: 1e6,
        scientific: !0
      },
      G: {
        name: "G",
        value: 1e9,
        scientific: !0
      },
      T: {
        name: "T",
        value: 1e12,
        scientific: !0
      },
      P: {
        name: "P",
        value: 1e15,
        scientific: !0
      },
      E: {
        name: "E",
        value: 1e18,
        scientific: !0
      },
      Z: {
        name: "Z",
        value: 1e21,
        scientific: !0
      },
      Y: {
        name: "Y",
        value: 1e24,
        scientific: !0
      },
      R: {
        name: "R",
        value: 1e27,
        scientific: !0
      },
      Q: {
        name: "Q",
        value: 1e30,
        scientific: !0
      },
      d: {
        name: "d",
        value: 0.1,
        scientific: !1
      },
      c: {
        name: "c",
        value: 0.01,
        scientific: !1
      },
      m: {
        name: "m",
        value: 1e-3,
        scientific: !0
      },
      u: {
        name: "u",
        value: 1e-6,
        scientific: !0
      },
      n: {
        name: "n",
        value: 1e-9,
        scientific: !0
      },
      p: {
        name: "p",
        value: 1e-12,
        scientific: !0
      },
      f: {
        name: "f",
        value: 1e-15,
        scientific: !0
      },
      a: {
        name: "a",
        value: 1e-18,
        scientific: !0
      },
      z: {
        name: "z",
        value: 1e-21,
        scientific: !0
      },
      y: {
        name: "y",
        value: 1e-24,
        scientific: !0
      },
      r: {
        name: "r",
        value: 1e-27,
        scientific: !0
      },
      q: {
        name: "q",
        value: 1e-30,
        scientific: !0
      }
    },
    LONG: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      deca: {
        name: "deca",
        value: 10,
        scientific: !1
      },
      hecto: {
        name: "hecto",
        value: 100,
        scientific: !1
      },
      kilo: {
        name: "kilo",
        value: 1e3,
        scientific: !0
      },
      mega: {
        name: "mega",
        value: 1e6,
        scientific: !0
      },
      giga: {
        name: "giga",
        value: 1e9,
        scientific: !0
      },
      tera: {
        name: "tera",
        value: 1e12,
        scientific: !0
      },
      peta: {
        name: "peta",
        value: 1e15,
        scientific: !0
      },
      exa: {
        name: "exa",
        value: 1e18,
        scientific: !0
      },
      zetta: {
        name: "zetta",
        value: 1e21,
        scientific: !0
      },
      yotta: {
        name: "yotta",
        value: 1e24,
        scientific: !0
      },
      ronna: {
        name: "ronna",
        value: 1e27,
        scientific: !0
      },
      quetta: {
        name: "quetta",
        value: 1e30,
        scientific: !0
      },
      deci: {
        name: "deci",
        value: 0.1,
        scientific: !1
      },
      centi: {
        name: "centi",
        value: 0.01,
        scientific: !1
      },
      milli: {
        name: "milli",
        value: 1e-3,
        scientific: !0
      },
      micro: {
        name: "micro",
        value: 1e-6,
        scientific: !0
      },
      nano: {
        name: "nano",
        value: 1e-9,
        scientific: !0
      },
      pico: {
        name: "pico",
        value: 1e-12,
        scientific: !0
      },
      femto: {
        name: "femto",
        value: 1e-15,
        scientific: !0
      },
      atto: {
        name: "atto",
        value: 1e-18,
        scientific: !0
      },
      zepto: {
        name: "zepto",
        value: 1e-21,
        scientific: !0
      },
      yocto: {
        name: "yocto",
        value: 1e-24,
        scientific: !0
      },
      ronto: {
        name: "ronto",
        value: 1e-27,
        scientific: !0
      },
      quecto: {
        name: "quecto",
        value: 1e-30,
        scientific: !0
      }
    },
    SQUARED: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      da: {
        name: "da",
        value: 100,
        scientific: !1
      },
      h: {
        name: "h",
        value: 1e4,
        scientific: !1
      },
      k: {
        name: "k",
        value: 1e6,
        scientific: !0
      },
      M: {
        name: "M",
        value: 1e12,
        scientific: !0
      },
      G: {
        name: "G",
        value: 1e18,
        scientific: !0
      },
      T: {
        name: "T",
        value: 1e24,
        scientific: !0
      },
      P: {
        name: "P",
        value: 1e30,
        scientific: !0
      },
      E: {
        name: "E",
        value: 1e36,
        scientific: !0
      },
      Z: {
        name: "Z",
        value: 1e42,
        scientific: !0
      },
      Y: {
        name: "Y",
        value: 1e48,
        scientific: !0
      },
      R: {
        name: "R",
        value: 1e54,
        scientific: !0
      },
      Q: {
        name: "Q",
        value: 1e60,
        scientific: !0
      },
      d: {
        name: "d",
        value: 0.01,
        scientific: !1
      },
      c: {
        name: "c",
        value: 1e-4,
        scientific: !1
      },
      m: {
        name: "m",
        value: 1e-6,
        scientific: !0
      },
      u: {
        name: "u",
        value: 1e-12,
        scientific: !0
      },
      n: {
        name: "n",
        value: 1e-18,
        scientific: !0
      },
      p: {
        name: "p",
        value: 1e-24,
        scientific: !0
      },
      f: {
        name: "f",
        value: 1e-30,
        scientific: !0
      },
      a: {
        name: "a",
        value: 1e-36,
        scientific: !0
      },
      z: {
        name: "z",
        value: 1e-42,
        scientific: !0
      },
      y: {
        name: "y",
        value: 1e-48,
        scientific: !0
      },
      r: {
        name: "r",
        value: 1e-54,
        scientific: !0
      },
      q: {
        name: "q",
        value: 1e-60,
        scientific: !0
      }
    },
    CUBIC: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      da: {
        name: "da",
        value: 1e3,
        scientific: !1
      },
      h: {
        name: "h",
        value: 1e6,
        scientific: !1
      },
      k: {
        name: "k",
        value: 1e9,
        scientific: !0
      },
      M: {
        name: "M",
        value: 1e18,
        scientific: !0
      },
      G: {
        name: "G",
        value: 1e27,
        scientific: !0
      },
      T: {
        name: "T",
        value: 1e36,
        scientific: !0
      },
      P: {
        name: "P",
        value: 1e45,
        scientific: !0
      },
      E: {
        name: "E",
        value: 1e54,
        scientific: !0
      },
      Z: {
        name: "Z",
        value: 1e63,
        scientific: !0
      },
      Y: {
        name: "Y",
        value: 1e72,
        scientific: !0
      },
      R: {
        name: "R",
        value: 1e81,
        scientific: !0
      },
      Q: {
        name: "Q",
        value: 1e90,
        scientific: !0
      },
      d: {
        name: "d",
        value: 1e-3,
        scientific: !1
      },
      c: {
        name: "c",
        value: 1e-6,
        scientific: !1
      },
      m: {
        name: "m",
        value: 1e-9,
        scientific: !0
      },
      u: {
        name: "u",
        value: 1e-18,
        scientific: !0
      },
      n: {
        name: "n",
        value: 1e-27,
        scientific: !0
      },
      p: {
        name: "p",
        value: 1e-36,
        scientific: !0
      },
      f: {
        name: "f",
        value: 1e-45,
        scientific: !0
      },
      a: {
        name: "a",
        value: 1e-54,
        scientific: !0
      },
      z: {
        name: "z",
        value: 1e-63,
        scientific: !0
      },
      y: {
        name: "y",
        value: 1e-72,
        scientific: !0
      },
      r: {
        name: "r",
        value: 1e-81,
        scientific: !0
      },
      q: {
        name: "q",
        value: 1e-90,
        scientific: !0
      }
    },
    BINARY_SHORT_SI: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      k: {
        name: "k",
        value: 1e3,
        scientific: !0
      },
      M: {
        name: "M",
        value: 1e6,
        scientific: !0
      },
      G: {
        name: "G",
        value: 1e9,
        scientific: !0
      },
      T: {
        name: "T",
        value: 1e12,
        scientific: !0
      },
      P: {
        name: "P",
        value: 1e15,
        scientific: !0
      },
      E: {
        name: "E",
        value: 1e18,
        scientific: !0
      },
      Z: {
        name: "Z",
        value: 1e21,
        scientific: !0
      },
      Y: {
        name: "Y",
        value: 1e24,
        scientific: !0
      }
    },
    BINARY_SHORT_IEC: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      Ki: {
        name: "Ki",
        value: 1024,
        scientific: !0
      },
      Mi: {
        name: "Mi",
        value: Math.pow(1024, 2),
        scientific: !0
      },
      Gi: {
        name: "Gi",
        value: Math.pow(1024, 3),
        scientific: !0
      },
      Ti: {
        name: "Ti",
        value: Math.pow(1024, 4),
        scientific: !0
      },
      Pi: {
        name: "Pi",
        value: Math.pow(1024, 5),
        scientific: !0
      },
      Ei: {
        name: "Ei",
        value: Math.pow(1024, 6),
        scientific: !0
      },
      Zi: {
        name: "Zi",
        value: Math.pow(1024, 7),
        scientific: !0
      },
      Yi: {
        name: "Yi",
        value: Math.pow(1024, 8),
        scientific: !0
      }
    },
    BINARY_LONG_SI: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      kilo: {
        name: "kilo",
        value: 1e3,
        scientific: !0
      },
      mega: {
        name: "mega",
        value: 1e6,
        scientific: !0
      },
      giga: {
        name: "giga",
        value: 1e9,
        scientific: !0
      },
      tera: {
        name: "tera",
        value: 1e12,
        scientific: !0
      },
      peta: {
        name: "peta",
        value: 1e15,
        scientific: !0
      },
      exa: {
        name: "exa",
        value: 1e18,
        scientific: !0
      },
      zetta: {
        name: "zetta",
        value: 1e21,
        scientific: !0
      },
      yotta: {
        name: "yotta",
        value: 1e24,
        scientific: !0
      }
    },
    BINARY_LONG_IEC: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      kibi: {
        name: "kibi",
        value: 1024,
        scientific: !0
      },
      mebi: {
        name: "mebi",
        value: Math.pow(1024, 2),
        scientific: !0
      },
      gibi: {
        name: "gibi",
        value: Math.pow(1024, 3),
        scientific: !0
      },
      tebi: {
        name: "tebi",
        value: Math.pow(1024, 4),
        scientific: !0
      },
      pebi: {
        name: "pebi",
        value: Math.pow(1024, 5),
        scientific: !0
      },
      exi: {
        name: "exi",
        value: Math.pow(1024, 6),
        scientific: !0
      },
      zebi: {
        name: "zebi",
        value: Math.pow(1024, 7),
        scientific: !0
      },
      yobi: {
        name: "yobi",
        value: Math.pow(1024, 8),
        scientific: !0
      }
    },
    BTU: {
      "": {
        name: "",
        value: 1,
        scientific: !0
      },
      MM: {
        name: "MM",
        value: 1e6,
        scientific: !0
      }
    }
  };
  N.SHORTLONG = Xa({}, N.SHORT, N.LONG), N.BINARY_SHORT = Xa({}, N.BINARY_SHORT_SI, N.BINARY_SHORT_IEC), N.BINARY_LONG = Xa({}, N.BINARY_LONG_SI, N.BINARY_LONG_IEC);
  var O = ["MASS", "LENGTH", "TIME", "CURRENT", "TEMPERATURE", "LUMINOUS_INTENSITY", "AMOUNT_OF_SUBSTANCE", "ANGLE", "BIT"], V = {
    NONE: {
      dimensions: [0, 0, 0, 0, 0, 0, 0, 0, 0]
    },
    MASS: {
      dimensions: [1, 0, 0, 0, 0, 0, 0, 0, 0]
    },
    LENGTH: {
      dimensions: [0, 1, 0, 0, 0, 0, 0, 0, 0]
    },
    TIME: {
      dimensions: [0, 0, 1, 0, 0, 0, 0, 0, 0]
    },
    CURRENT: {
      dimensions: [0, 0, 0, 1, 0, 0, 0, 0, 0]
    },
    TEMPERATURE: {
      dimensions: [0, 0, 0, 0, 1, 0, 0, 0, 0]
    },
    LUMINOUS_INTENSITY: {
      dimensions: [0, 0, 0, 0, 0, 1, 0, 0, 0]
    },
    AMOUNT_OF_SUBSTANCE: {
      dimensions: [0, 0, 0, 0, 0, 0, 1, 0, 0]
    },
    FORCE: {
      dimensions: [1, 1, -2, 0, 0, 0, 0, 0, 0]
    },
    SURFACE: {
      dimensions: [0, 2, 0, 0, 0, 0, 0, 0, 0]
    },
    VOLUME: {
      dimensions: [0, 3, 0, 0, 0, 0, 0, 0, 0]
    },
    ENERGY: {
      dimensions: [1, 2, -2, 0, 0, 0, 0, 0, 0]
    },
    POWER: {
      dimensions: [1, 2, -3, 0, 0, 0, 0, 0, 0]
    },
    PRESSURE: {
      dimensions: [1, -1, -2, 0, 0, 0, 0, 0, 0]
    },
    ELECTRIC_CHARGE: {
      dimensions: [0, 0, 1, 1, 0, 0, 0, 0, 0]
    },
    ELECTRIC_CAPACITANCE: {
      dimensions: [-1, -2, 4, 2, 0, 0, 0, 0, 0]
    },
    ELECTRIC_POTENTIAL: {
      dimensions: [1, 2, -3, -1, 0, 0, 0, 0, 0]
    },
    ELECTRIC_RESISTANCE: {
      dimensions: [1, 2, -3, -2, 0, 0, 0, 0, 0]
    },
    ELECTRIC_INDUCTANCE: {
      dimensions: [1, 2, -2, -2, 0, 0, 0, 0, 0]
    },
    ELECTRIC_CONDUCTANCE: {
      dimensions: [-1, -2, 3, 2, 0, 0, 0, 0, 0]
    },
    MAGNETIC_FLUX: {
      dimensions: [1, 2, -2, -1, 0, 0, 0, 0, 0]
    },
    MAGNETIC_FLUX_DENSITY: {
      dimensions: [1, 0, -2, -1, 0, 0, 0, 0, 0]
    },
    FREQUENCY: {
      dimensions: [0, 0, -1, 0, 0, 0, 0, 0, 0]
    },
    ANGLE: {
      dimensions: [0, 0, 0, 0, 0, 0, 0, 1, 0]
    },
    BIT: {
      dimensions: [0, 0, 0, 0, 0, 0, 0, 0, 1]
    }
  };
  for (var k in V)
    er(V, k) && (V[k].key = k);
  var G = {}, L = {
    name: "",
    base: G,
    value: 1,
    offset: 0,
    dimensions: O.map((W) => 0)
  }, R = {
    // length
    meter: {
      name: "meter",
      base: V.LENGTH,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    inch: {
      name: "inch",
      base: V.LENGTH,
      prefixes: N.NONE,
      value: 0.0254,
      offset: 0
    },
    foot: {
      name: "foot",
      base: V.LENGTH,
      prefixes: N.NONE,
      value: 0.3048,
      offset: 0
    },
    yard: {
      name: "yard",
      base: V.LENGTH,
      prefixes: N.NONE,
      value: 0.9144,
      offset: 0
    },
    mile: {
      name: "mile",
      base: V.LENGTH,
      prefixes: N.NONE,
      value: 1609.344,
      offset: 0
    },
    link: {
      name: "link",
      base: V.LENGTH,
      prefixes: N.NONE,
      value: 0.201168,
      offset: 0
    },
    rod: {
      name: "rod",
      base: V.LENGTH,
      prefixes: N.NONE,
      value: 5.0292,
      offset: 0
    },
    chain: {
      name: "chain",
      base: V.LENGTH,
      prefixes: N.NONE,
      value: 20.1168,
      offset: 0
    },
    angstrom: {
      name: "angstrom",
      base: V.LENGTH,
      prefixes: N.NONE,
      value: 1e-10,
      offset: 0
    },
    m: {
      name: "m",
      base: V.LENGTH,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    in: {
      name: "in",
      base: V.LENGTH,
      prefixes: N.NONE,
      value: 0.0254,
      offset: 0
    },
    ft: {
      name: "ft",
      base: V.LENGTH,
      prefixes: N.NONE,
      value: 0.3048,
      offset: 0
    },
    yd: {
      name: "yd",
      base: V.LENGTH,
      prefixes: N.NONE,
      value: 0.9144,
      offset: 0
    },
    mi: {
      name: "mi",
      base: V.LENGTH,
      prefixes: N.NONE,
      value: 1609.344,
      offset: 0
    },
    li: {
      name: "li",
      base: V.LENGTH,
      prefixes: N.NONE,
      value: 0.201168,
      offset: 0
    },
    rd: {
      name: "rd",
      base: V.LENGTH,
      prefixes: N.NONE,
      value: 5.02921,
      offset: 0
    },
    ch: {
      name: "ch",
      base: V.LENGTH,
      prefixes: N.NONE,
      value: 20.1168,
      offset: 0
    },
    mil: {
      name: "mil",
      base: V.LENGTH,
      prefixes: N.NONE,
      value: 254e-7,
      offset: 0
    },
    // 1/1000 inch
    // Surface
    m2: {
      name: "m2",
      base: V.SURFACE,
      prefixes: N.SQUARED,
      value: 1,
      offset: 0
    },
    sqin: {
      name: "sqin",
      base: V.SURFACE,
      prefixes: N.NONE,
      value: 64516e-8,
      offset: 0
    },
    // 645.16 mm2
    sqft: {
      name: "sqft",
      base: V.SURFACE,
      prefixes: N.NONE,
      value: 0.09290304,
      offset: 0
    },
    // 0.09290304 m2
    sqyd: {
      name: "sqyd",
      base: V.SURFACE,
      prefixes: N.NONE,
      value: 0.83612736,
      offset: 0
    },
    // 0.83612736 m2
    sqmi: {
      name: "sqmi",
      base: V.SURFACE,
      prefixes: N.NONE,
      value: 2589988110336e-6,
      offset: 0
    },
    // 2.589988110336 km2
    sqrd: {
      name: "sqrd",
      base: V.SURFACE,
      prefixes: N.NONE,
      value: 25.29295,
      offset: 0
    },
    // 25.29295 m2
    sqch: {
      name: "sqch",
      base: V.SURFACE,
      prefixes: N.NONE,
      value: 404.6873,
      offset: 0
    },
    // 404.6873 m2
    sqmil: {
      name: "sqmil",
      base: V.SURFACE,
      prefixes: N.NONE,
      value: 64516e-14,
      offset: 0
    },
    // 6.4516 * 10^-10 m2
    acre: {
      name: "acre",
      base: V.SURFACE,
      prefixes: N.NONE,
      value: 4046.86,
      offset: 0
    },
    // 4046.86 m2
    hectare: {
      name: "hectare",
      base: V.SURFACE,
      prefixes: N.NONE,
      value: 1e4,
      offset: 0
    },
    // 10000 m2
    // Volume
    m3: {
      name: "m3",
      base: V.VOLUME,
      prefixes: N.CUBIC,
      value: 1,
      offset: 0
    },
    L: {
      name: "L",
      base: V.VOLUME,
      prefixes: N.SHORT,
      value: 1e-3,
      offset: 0
    },
    // litre
    l: {
      name: "l",
      base: V.VOLUME,
      prefixes: N.SHORT,
      value: 1e-3,
      offset: 0
    },
    // litre
    litre: {
      name: "litre",
      base: V.VOLUME,
      prefixes: N.LONG,
      value: 1e-3,
      offset: 0
    },
    cuin: {
      name: "cuin",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 16387064e-12,
      offset: 0
    },
    // 1.6387064e-5 m3
    cuft: {
      name: "cuft",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 0.028316846592,
      offset: 0
    },
    // 28.316 846 592 L
    cuyd: {
      name: "cuyd",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 0.764554857984,
      offset: 0
    },
    // 764.554 857 984 L
    teaspoon: {
      name: "teaspoon",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 5e-6,
      offset: 0
    },
    // 5 mL
    tablespoon: {
      name: "tablespoon",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 15e-6,
      offset: 0
    },
    // 15 mL
    // {name: 'cup', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.000240, offset: 0}, // 240 mL  // not possible, we have already another cup
    drop: {
      name: "drop",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 5e-8,
      offset: 0
    },
    // 0.05 mL = 5e-8 m3
    gtt: {
      name: "gtt",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 5e-8,
      offset: 0
    },
    // 0.05 mL = 5e-8 m3
    // Liquid volume
    minim: {
      name: "minim",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 6161152e-14,
      offset: 0
    },
    // 0.06161152 mL
    fluiddram: {
      name: "fluiddram",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 36966911e-13,
      offset: 0
    },
    // 3.696691 mL
    fluidounce: {
      name: "fluidounce",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 2957353e-11,
      offset: 0
    },
    // 29.57353 mL
    gill: {
      name: "gill",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 1182941e-10,
      offset: 0
    },
    // 118.2941 mL
    cc: {
      name: "cc",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 1e-6,
      offset: 0
    },
    // 1e-6 L
    cup: {
      name: "cup",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 2365882e-10,
      offset: 0
    },
    // 236.5882 mL
    pint: {
      name: "pint",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 4731765e-10,
      offset: 0
    },
    // 473.1765 mL
    quart: {
      name: "quart",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 9463529e-10,
      offset: 0
    },
    // 946.3529 mL
    gallon: {
      name: "gallon",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 3785412e-9,
      offset: 0
    },
    // 3.785412 L
    beerbarrel: {
      name: "beerbarrel",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 0.1173478,
      offset: 0
    },
    // 117.3478 L
    oilbarrel: {
      name: "oilbarrel",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 0.1589873,
      offset: 0
    },
    // 158.9873 L
    hogshead: {
      name: "hogshead",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 0.238481,
      offset: 0
    },
    // 238.4810 L
    // {name: 'min', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.00000006161152, offset: 0}, // 0.06161152 mL // min is already in use as minute
    fldr: {
      name: "fldr",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 36966911e-13,
      offset: 0
    },
    // 3.696691 mL
    floz: {
      name: "floz",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 2957353e-11,
      offset: 0
    },
    // 29.57353 mL
    gi: {
      name: "gi",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 1182941e-10,
      offset: 0
    },
    // 118.2941 mL
    cp: {
      name: "cp",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 2365882e-10,
      offset: 0
    },
    // 236.5882 mL
    pt: {
      name: "pt",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 4731765e-10,
      offset: 0
    },
    // 473.1765 mL
    qt: {
      name: "qt",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 9463529e-10,
      offset: 0
    },
    // 946.3529 mL
    gal: {
      name: "gal",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 3785412e-9,
      offset: 0
    },
    // 3.785412 L
    bbl: {
      name: "bbl",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 0.1173478,
      offset: 0
    },
    // 117.3478 L
    obl: {
      name: "obl",
      base: V.VOLUME,
      prefixes: N.NONE,
      value: 0.1589873,
      offset: 0
    },
    // 158.9873 L
    // {name: 'hogshead', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.2384810, offset: 0}, // 238.4810 L // TODO: hh?
    // Mass
    g: {
      name: "g",
      base: V.MASS,
      prefixes: N.SHORT,
      value: 1e-3,
      offset: 0
    },
    gram: {
      name: "gram",
      base: V.MASS,
      prefixes: N.LONG,
      value: 1e-3,
      offset: 0
    },
    ton: {
      name: "ton",
      base: V.MASS,
      prefixes: N.SHORT,
      value: 907.18474,
      offset: 0
    },
    t: {
      name: "t",
      base: V.MASS,
      prefixes: N.SHORT,
      value: 1e3,
      offset: 0
    },
    tonne: {
      name: "tonne",
      base: V.MASS,
      prefixes: N.LONG,
      value: 1e3,
      offset: 0
    },
    grain: {
      name: "grain",
      base: V.MASS,
      prefixes: N.NONE,
      value: 6479891e-11,
      offset: 0
    },
    dram: {
      name: "dram",
      base: V.MASS,
      prefixes: N.NONE,
      value: 0.0017718451953125,
      offset: 0
    },
    ounce: {
      name: "ounce",
      base: V.MASS,
      prefixes: N.NONE,
      value: 0.028349523125,
      offset: 0
    },
    poundmass: {
      name: "poundmass",
      base: V.MASS,
      prefixes: N.NONE,
      value: 0.45359237,
      offset: 0
    },
    hundredweight: {
      name: "hundredweight",
      base: V.MASS,
      prefixes: N.NONE,
      value: 45.359237,
      offset: 0
    },
    stick: {
      name: "stick",
      base: V.MASS,
      prefixes: N.NONE,
      value: 0.115,
      offset: 0
    },
    stone: {
      name: "stone",
      base: V.MASS,
      prefixes: N.NONE,
      value: 6.35029318,
      offset: 0
    },
    gr: {
      name: "gr",
      base: V.MASS,
      prefixes: N.NONE,
      value: 6479891e-11,
      offset: 0
    },
    dr: {
      name: "dr",
      base: V.MASS,
      prefixes: N.NONE,
      value: 0.0017718451953125,
      offset: 0
    },
    oz: {
      name: "oz",
      base: V.MASS,
      prefixes: N.NONE,
      value: 0.028349523125,
      offset: 0
    },
    lbm: {
      name: "lbm",
      base: V.MASS,
      prefixes: N.NONE,
      value: 0.45359237,
      offset: 0
    },
    cwt: {
      name: "cwt",
      base: V.MASS,
      prefixes: N.NONE,
      value: 45.359237,
      offset: 0
    },
    // Time
    s: {
      name: "s",
      base: V.TIME,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    min: {
      name: "min",
      base: V.TIME,
      prefixes: N.NONE,
      value: 60,
      offset: 0
    },
    h: {
      name: "h",
      base: V.TIME,
      prefixes: N.NONE,
      value: 3600,
      offset: 0
    },
    second: {
      name: "second",
      base: V.TIME,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    sec: {
      name: "sec",
      base: V.TIME,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    minute: {
      name: "minute",
      base: V.TIME,
      prefixes: N.NONE,
      value: 60,
      offset: 0
    },
    hour: {
      name: "hour",
      base: V.TIME,
      prefixes: N.NONE,
      value: 3600,
      offset: 0
    },
    day: {
      name: "day",
      base: V.TIME,
      prefixes: N.NONE,
      value: 86400,
      offset: 0
    },
    week: {
      name: "week",
      base: V.TIME,
      prefixes: N.NONE,
      value: 7 * 86400,
      offset: 0
    },
    month: {
      name: "month",
      base: V.TIME,
      prefixes: N.NONE,
      value: 2629800,
      // 1/12th of Julian year
      offset: 0
    },
    year: {
      name: "year",
      base: V.TIME,
      prefixes: N.NONE,
      value: 31557600,
      // Julian year
      offset: 0
    },
    decade: {
      name: "decade",
      base: V.TIME,
      prefixes: N.NONE,
      value: 315576e3,
      // Julian decade
      offset: 0
    },
    century: {
      name: "century",
      base: V.TIME,
      prefixes: N.NONE,
      value: 315576e4,
      // Julian century
      offset: 0
    },
    millennium: {
      name: "millennium",
      base: V.TIME,
      prefixes: N.NONE,
      value: 315576e5,
      // Julian millennium
      offset: 0
    },
    // Frequency
    hertz: {
      name: "Hertz",
      base: V.FREQUENCY,
      prefixes: N.LONG,
      value: 1,
      offset: 0,
      reciprocal: !0
    },
    Hz: {
      name: "Hz",
      base: V.FREQUENCY,
      prefixes: N.SHORT,
      value: 1,
      offset: 0,
      reciprocal: !0
    },
    // Angle
    rad: {
      name: "rad",
      base: V.ANGLE,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    radian: {
      name: "radian",
      base: V.ANGLE,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    // deg = rad / (2*pi) * 360 = rad / 0.017453292519943295769236907684888
    deg: {
      name: "deg",
      base: V.ANGLE,
      prefixes: N.SHORT,
      value: null,
      // will be filled in by calculateAngleValues()
      offset: 0
    },
    degree: {
      name: "degree",
      base: V.ANGLE,
      prefixes: N.LONG,
      value: null,
      // will be filled in by calculateAngleValues()
      offset: 0
    },
    // grad = rad / (2*pi) * 400  = rad / 0.015707963267948966192313216916399
    grad: {
      name: "grad",
      base: V.ANGLE,
      prefixes: N.SHORT,
      value: null,
      // will be filled in by calculateAngleValues()
      offset: 0
    },
    gradian: {
      name: "gradian",
      base: V.ANGLE,
      prefixes: N.LONG,
      value: null,
      // will be filled in by calculateAngleValues()
      offset: 0
    },
    // cycle = rad / (2*pi) = rad / 6.2831853071795864769252867665793
    cycle: {
      name: "cycle",
      base: V.ANGLE,
      prefixes: N.NONE,
      value: null,
      // will be filled in by calculateAngleValues()
      offset: 0
    },
    // arcsec = rad / (3600 * (360 / 2 * pi)) = rad / 0.0000048481368110953599358991410235795
    arcsec: {
      name: "arcsec",
      base: V.ANGLE,
      prefixes: N.NONE,
      value: null,
      // will be filled in by calculateAngleValues()
      offset: 0
    },
    // arcmin = rad / (60 * (360 / 2 * pi)) = rad / 0.00029088820866572159615394846141477
    arcmin: {
      name: "arcmin",
      base: V.ANGLE,
      prefixes: N.NONE,
      value: null,
      // will be filled in by calculateAngleValues()
      offset: 0
    },
    // Electric current
    A: {
      name: "A",
      base: V.CURRENT,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    ampere: {
      name: "ampere",
      base: V.CURRENT,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    // Temperature
    // K(C) = °C + 273.15
    // K(F) = (°F + 459.67) * (5 / 9)
    // K(R) = °R * (5 / 9)
    K: {
      name: "K",
      base: V.TEMPERATURE,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    degC: {
      name: "degC",
      base: V.TEMPERATURE,
      prefixes: N.SHORT,
      value: 1,
      offset: 273.15
    },
    degF: {
      name: "degF",
      base: V.TEMPERATURE,
      prefixes: N.SHORT,
      value: new y(5, 9),
      offset: 459.67
    },
    degR: {
      name: "degR",
      base: V.TEMPERATURE,
      prefixes: N.SHORT,
      value: new y(5, 9),
      offset: 0
    },
    kelvin: {
      name: "kelvin",
      base: V.TEMPERATURE,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    celsius: {
      name: "celsius",
      base: V.TEMPERATURE,
      prefixes: N.LONG,
      value: 1,
      offset: 273.15
    },
    fahrenheit: {
      name: "fahrenheit",
      base: V.TEMPERATURE,
      prefixes: N.LONG,
      value: new y(5, 9),
      offset: 459.67
    },
    rankine: {
      name: "rankine",
      base: V.TEMPERATURE,
      prefixes: N.LONG,
      value: new y(5, 9),
      offset: 0
    },
    // amount of substance
    mol: {
      name: "mol",
      base: V.AMOUNT_OF_SUBSTANCE,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    mole: {
      name: "mole",
      base: V.AMOUNT_OF_SUBSTANCE,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    // luminous intensity
    cd: {
      name: "cd",
      base: V.LUMINOUS_INTENSITY,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    candela: {
      name: "candela",
      base: V.LUMINOUS_INTENSITY,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    // TODO: units STERADIAN
    // {name: 'sr', base: BASE_UNITS.STERADIAN, prefixes: PREFIXES.NONE, value: 1, offset: 0},
    // {name: 'steradian', base: BASE_UNITS.STERADIAN, prefixes: PREFIXES.NONE, value: 1, offset: 0},
    // Force
    N: {
      name: "N",
      base: V.FORCE,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    newton: {
      name: "newton",
      base: V.FORCE,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    dyn: {
      name: "dyn",
      base: V.FORCE,
      prefixes: N.SHORT,
      value: 1e-5,
      offset: 0
    },
    dyne: {
      name: "dyne",
      base: V.FORCE,
      prefixes: N.LONG,
      value: 1e-5,
      offset: 0
    },
    lbf: {
      name: "lbf",
      base: V.FORCE,
      prefixes: N.NONE,
      value: 4.4482216152605,
      offset: 0
    },
    poundforce: {
      name: "poundforce",
      base: V.FORCE,
      prefixes: N.NONE,
      value: 4.4482216152605,
      offset: 0
    },
    kip: {
      name: "kip",
      base: V.FORCE,
      prefixes: N.LONG,
      value: 4448.2216,
      offset: 0
    },
    kilogramforce: {
      name: "kilogramforce",
      base: V.FORCE,
      prefixes: N.NONE,
      value: 9.80665,
      offset: 0
    },
    // Energy
    J: {
      name: "J",
      base: V.ENERGY,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    joule: {
      name: "joule",
      base: V.ENERGY,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    erg: {
      name: "erg",
      base: V.ENERGY,
      prefixes: N.SHORTLONG,
      // Both kiloerg and kerg are acceptable
      value: 1e-7,
      offset: 0
    },
    Wh: {
      name: "Wh",
      base: V.ENERGY,
      prefixes: N.SHORT,
      value: 3600,
      offset: 0
    },
    BTU: {
      name: "BTU",
      base: V.ENERGY,
      prefixes: N.BTU,
      value: 1055.05585262,
      offset: 0
    },
    eV: {
      name: "eV",
      base: V.ENERGY,
      prefixes: N.SHORT,
      value: 1602176565e-28,
      offset: 0
    },
    electronvolt: {
      name: "electronvolt",
      base: V.ENERGY,
      prefixes: N.LONG,
      value: 1602176565e-28,
      offset: 0
    },
    // Power
    W: {
      name: "W",
      base: V.POWER,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    watt: {
      name: "watt",
      base: V.POWER,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    hp: {
      name: "hp",
      base: V.POWER,
      prefixes: N.NONE,
      value: 745.6998715386,
      offset: 0
    },
    // Electrical power units
    VAR: {
      name: "VAR",
      base: V.POWER,
      prefixes: N.SHORT,
      value: v.I,
      offset: 0
    },
    VA: {
      name: "VA",
      base: V.POWER,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    // Pressure
    Pa: {
      name: "Pa",
      base: V.PRESSURE,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    psi: {
      name: "psi",
      base: V.PRESSURE,
      prefixes: N.NONE,
      value: 6894.75729276459,
      offset: 0
    },
    atm: {
      name: "atm",
      base: V.PRESSURE,
      prefixes: N.NONE,
      value: 101325,
      offset: 0
    },
    bar: {
      name: "bar",
      base: V.PRESSURE,
      prefixes: N.SHORTLONG,
      value: 1e5,
      offset: 0
    },
    torr: {
      name: "torr",
      base: V.PRESSURE,
      prefixes: N.NONE,
      value: 133.322,
      offset: 0
    },
    mmHg: {
      name: "mmHg",
      base: V.PRESSURE,
      prefixes: N.NONE,
      value: 133.322,
      offset: 0
    },
    mmH2O: {
      name: "mmH2O",
      base: V.PRESSURE,
      prefixes: N.NONE,
      value: 9.80665,
      offset: 0
    },
    cmH2O: {
      name: "cmH2O",
      base: V.PRESSURE,
      prefixes: N.NONE,
      value: 98.0665,
      offset: 0
    },
    // Electric charge
    coulomb: {
      name: "coulomb",
      base: V.ELECTRIC_CHARGE,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    C: {
      name: "C",
      base: V.ELECTRIC_CHARGE,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    // Electric capacitance
    farad: {
      name: "farad",
      base: V.ELECTRIC_CAPACITANCE,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    F: {
      name: "F",
      base: V.ELECTRIC_CAPACITANCE,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    // Electric potential
    volt: {
      name: "volt",
      base: V.ELECTRIC_POTENTIAL,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    V: {
      name: "V",
      base: V.ELECTRIC_POTENTIAL,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    // Electric resistance
    ohm: {
      name: "ohm",
      base: V.ELECTRIC_RESISTANCE,
      prefixes: N.SHORTLONG,
      // Both Mohm and megaohm are acceptable
      value: 1,
      offset: 0
    },
    /*
     * Unicode breaks in browsers if charset is not specified
    Ω: {
      name: 'Ω',
      base: BASE_UNITS.ELECTRIC_RESISTANCE,
      prefixes: PREFIXES.SHORT,
      value: 1,
      offset: 0
    },
    */
    // Electric inductance
    henry: {
      name: "henry",
      base: V.ELECTRIC_INDUCTANCE,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    H: {
      name: "H",
      base: V.ELECTRIC_INDUCTANCE,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    // Electric conductance
    siemens: {
      name: "siemens",
      base: V.ELECTRIC_CONDUCTANCE,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    S: {
      name: "S",
      base: V.ELECTRIC_CONDUCTANCE,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    // Magnetic flux
    weber: {
      name: "weber",
      base: V.MAGNETIC_FLUX,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    Wb: {
      name: "Wb",
      base: V.MAGNETIC_FLUX,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    // Magnetic flux density
    tesla: {
      name: "tesla",
      base: V.MAGNETIC_FLUX_DENSITY,
      prefixes: N.LONG,
      value: 1,
      offset: 0
    },
    T: {
      name: "T",
      base: V.MAGNETIC_FLUX_DENSITY,
      prefixes: N.SHORT,
      value: 1,
      offset: 0
    },
    // Binary
    b: {
      name: "b",
      base: V.BIT,
      prefixes: N.BINARY_SHORT,
      value: 1,
      offset: 0
    },
    bits: {
      name: "bits",
      base: V.BIT,
      prefixes: N.BINARY_LONG,
      value: 1,
      offset: 0
    },
    B: {
      name: "B",
      base: V.BIT,
      prefixes: N.BINARY_SHORT,
      value: 8,
      offset: 0
    },
    bytes: {
      name: "bytes",
      base: V.BIT,
      prefixes: N.BINARY_LONG,
      value: 8,
      offset: 0
    }
  }, F = {
    meters: "meter",
    inches: "inch",
    feet: "foot",
    yards: "yard",
    miles: "mile",
    links: "link",
    rods: "rod",
    chains: "chain",
    angstroms: "angstrom",
    lt: "l",
    litres: "litre",
    liter: "litre",
    liters: "litre",
    teaspoons: "teaspoon",
    tablespoons: "tablespoon",
    minims: "minim",
    fluiddrams: "fluiddram",
    fluidounces: "fluidounce",
    gills: "gill",
    cups: "cup",
    pints: "pint",
    quarts: "quart",
    gallons: "gallon",
    beerbarrels: "beerbarrel",
    oilbarrels: "oilbarrel",
    hogsheads: "hogshead",
    gtts: "gtt",
    grams: "gram",
    tons: "ton",
    tonnes: "tonne",
    grains: "grain",
    drams: "dram",
    ounces: "ounce",
    poundmasses: "poundmass",
    hundredweights: "hundredweight",
    sticks: "stick",
    lb: "lbm",
    lbs: "lbm",
    kips: "kip",
    kgf: "kilogramforce",
    acres: "acre",
    hectares: "hectare",
    sqfeet: "sqft",
    sqyard: "sqyd",
    sqmile: "sqmi",
    sqmiles: "sqmi",
    mmhg: "mmHg",
    mmh2o: "mmH2O",
    cmh2o: "cmH2O",
    seconds: "second",
    secs: "second",
    minutes: "minute",
    mins: "minute",
    hours: "hour",
    hr: "hour",
    hrs: "hour",
    days: "day",
    weeks: "week",
    months: "month",
    years: "year",
    decades: "decade",
    centuries: "century",
    millennia: "millennium",
    hertz: "hertz",
    radians: "radian",
    degrees: "degree",
    gradians: "gradian",
    cycles: "cycle",
    arcsecond: "arcsec",
    arcseconds: "arcsec",
    arcminute: "arcmin",
    arcminutes: "arcmin",
    BTUs: "BTU",
    watts: "watt",
    joules: "joule",
    amperes: "ampere",
    amps: "ampere",
    amp: "ampere",
    coulombs: "coulomb",
    volts: "volt",
    ohms: "ohm",
    farads: "farad",
    webers: "weber",
    teslas: "tesla",
    electronvolts: "electronvolt",
    moles: "mole",
    bit: "bits",
    byte: "bytes"
  };
  function U(W) {
    if (W.number === "BigNumber") {
      var te = LD(h);
      R.rad.value = new h(1), R.deg.value = te.div(180), R.grad.value = te.div(200), R.cycle.value = te.times(2), R.arcsec.value = te.div(648e3), R.arcmin.value = te.div(10800);
    } else
      R.rad.value = 1, R.deg.value = Math.PI / 180, R.grad.value = Math.PI / 200, R.cycle.value = Math.PI * 2, R.arcsec.value = Math.PI / 648e3, R.arcmin.value = Math.PI / 10800;
    R.radian.value = R.rad.value, R.degree.value = R.deg.value, R.gradian.value = R.grad.value;
  }
  U(t), r && r("config", function(W, te) {
    W.number !== te.number && U(W);
  });
  var H = {
    si: {
      // Base units
      NONE: {
        unit: L,
        prefix: N.NONE[""]
      },
      LENGTH: {
        unit: R.m,
        prefix: N.SHORT[""]
      },
      MASS: {
        unit: R.g,
        prefix: N.SHORT.k
      },
      TIME: {
        unit: R.s,
        prefix: N.SHORT[""]
      },
      CURRENT: {
        unit: R.A,
        prefix: N.SHORT[""]
      },
      TEMPERATURE: {
        unit: R.K,
        prefix: N.SHORT[""]
      },
      LUMINOUS_INTENSITY: {
        unit: R.cd,
        prefix: N.SHORT[""]
      },
      AMOUNT_OF_SUBSTANCE: {
        unit: R.mol,
        prefix: N.SHORT[""]
      },
      ANGLE: {
        unit: R.rad,
        prefix: N.SHORT[""]
      },
      BIT: {
        unit: R.bits,
        prefix: N.SHORT[""]
      },
      // Derived units
      FORCE: {
        unit: R.N,
        prefix: N.SHORT[""]
      },
      ENERGY: {
        unit: R.J,
        prefix: N.SHORT[""]
      },
      POWER: {
        unit: R.W,
        prefix: N.SHORT[""]
      },
      PRESSURE: {
        unit: R.Pa,
        prefix: N.SHORT[""]
      },
      ELECTRIC_CHARGE: {
        unit: R.C,
        prefix: N.SHORT[""]
      },
      ELECTRIC_CAPACITANCE: {
        unit: R.F,
        prefix: N.SHORT[""]
      },
      ELECTRIC_POTENTIAL: {
        unit: R.V,
        prefix: N.SHORT[""]
      },
      ELECTRIC_RESISTANCE: {
        unit: R.ohm,
        prefix: N.SHORT[""]
      },
      ELECTRIC_INDUCTANCE: {
        unit: R.H,
        prefix: N.SHORT[""]
      },
      ELECTRIC_CONDUCTANCE: {
        unit: R.S,
        prefix: N.SHORT[""]
      },
      MAGNETIC_FLUX: {
        unit: R.Wb,
        prefix: N.SHORT[""]
      },
      MAGNETIC_FLUX_DENSITY: {
        unit: R.T,
        prefix: N.SHORT[""]
      },
      FREQUENCY: {
        unit: R.Hz,
        prefix: N.SHORT[""]
      }
    }
  };
  H.cgs = JSON.parse(JSON.stringify(H.si)), H.cgs.LENGTH = {
    unit: R.m,
    prefix: N.SHORT.c
  }, H.cgs.MASS = {
    unit: R.g,
    prefix: N.SHORT[""]
  }, H.cgs.FORCE = {
    unit: R.dyn,
    prefix: N.SHORT[""]
  }, H.cgs.ENERGY = {
    unit: R.erg,
    prefix: N.NONE[""]
  }, H.us = JSON.parse(JSON.stringify(H.si)), H.us.LENGTH = {
    unit: R.ft,
    prefix: N.NONE[""]
  }, H.us.MASS = {
    unit: R.lbm,
    prefix: N.NONE[""]
  }, H.us.TEMPERATURE = {
    unit: R.degF,
    prefix: N.NONE[""]
  }, H.us.FORCE = {
    unit: R.lbf,
    prefix: N.NONE[""]
  }, H.us.ENERGY = {
    unit: R.BTU,
    prefix: N.BTU[""]
  }, H.us.POWER = {
    unit: R.hp,
    prefix: N.NONE[""]
  }, H.us.PRESSURE = {
    unit: R.psi,
    prefix: N.NONE[""]
  }, H.auto = JSON.parse(JSON.stringify(H.si));
  var q = H.auto;
  S.setUnitSystem = function(W) {
    if (er(H, W))
      q = H[W];
    else
      throw new Error("Unit system " + W + " does not exist. Choices are: " + Object.keys(H).join(", "));
  }, S.getUnitSystem = function() {
    for (var W in H)
      if (er(H, W) && H[W] === q)
        return W;
  }, S.typeConverters = {
    BigNumber: function(te) {
      return te != null && te.isFraction ? new h(te.n).div(te.d).times(te.s) : new h(te + "");
    },
    Fraction: function(te) {
      return new y(te);
    },
    Complex: function(te) {
      return te;
    },
    number: function(te) {
      return te != null && te.isFraction ? p(te) : te;
    }
  }, S.prototype._numberConverter = function() {
    var W = S.typeConverters[this.valueType()];
    if (W)
      return W;
    throw new TypeError('Unsupported Unit value type "' + this.valueType() + '"');
  }, S._getNumberConverter = function(W) {
    if (!S.typeConverters[W])
      throw new TypeError('Unsupported type "' + W + '"');
    return S.typeConverters[W];
  };
  for (var K in R)
    if (er(R, K)) {
      var Y = R[K];
      Y.dimensions = Y.base.dimensions;
    }
  for (var X in F)
    if (er(F, X)) {
      var Z = R[F[X]], J = {};
      for (var $ in Z)
        er(Z, $) && (J[$] = Z[$]);
      J.name = X, R[X] = J;
    }
  S.isValidAlpha = function(te) {
    return /^[a-zA-Z]$/.test(te);
  };
  function Q(W) {
    for (var te = 0; te < W.length; te++) {
      if (_ = W.charAt(te), te === 0 && !S.isValidAlpha(_))
        throw new Error('Invalid unit name (must begin with alpha character): "' + W + '"');
      if (te > 0 && !(S.isValidAlpha(_) || P(_)))
        throw new Error('Invalid unit name (only alphanumeric characters are allowed): "' + W + '"');
    }
  }
  return S.createUnit = function(W, te) {
    if (typeof W != "object")
      throw new TypeError("createUnit expects first parameter to be of type 'Object'");
    if (te && te.override) {
      for (var oe in W)
        if (er(W, oe) && S.deleteUnit(oe), W[oe].aliases)
          for (var z = 0; z < W[oe].aliases.length; z++)
            S.deleteUnit(W[oe].aliases[z]);
    }
    var j;
    for (var ae in W)
      er(W, ae) && (j = S.createUnitSingle(ae, W[ae]));
    return j;
  }, S.createUnitSingle = function(W, te) {
    if ((typeof te > "u" || te === null) && (te = {}), typeof W != "string")
      throw new TypeError("createUnitSingle expects first parameter to be of type 'string'");
    if (er(R, W))
      throw new Error('Cannot create unit "' + W + '": a unit with that name already exists');
    Q(W);
    var oe = null, z = [], j = 0, ae, le, ie;
    if (te && te.type === "Unit")
      oe = te.clone();
    else if (typeof te == "string")
      te !== "" && (ae = te);
    else if (typeof te == "object")
      ae = te.definition, le = te.prefixes, j = te.offset, ie = te.baseName, te.aliases && (z = te.aliases.valueOf());
    else
      throw new TypeError('Cannot create unit "' + W + '" from "' + te.toString() + '": expecting "string" or "Unit" or "Object"');
    if (z) {
      for (var re = 0; re < z.length; re++)
        if (er(R, z[re]))
          throw new Error('Cannot create alias "' + z[re] + '": a unit with that name already exists');
    }
    if (ae && typeof ae == "string" && !oe)
      try {
        oe = S.parse(ae, {
          allowNoUnits: !0
        });
      } catch (ue) {
        throw ue.message = 'Could not create unit "' + W + '" from "' + ae + '": ' + ue.message, ue;
      }
    else ae && ae.type === "Unit" && (oe = ae.clone());
    z = z || [], j = j || 0, le && le.toUpperCase ? le = N[le.toUpperCase()] || N.NONE : le = N.NONE;
    var ee = {};
    if (oe) {
      ee = {
        name: W,
        value: oe.value,
        dimensions: oe.dimensions.slice(0),
        prefixes: le,
        offset: j
      };
      var de = !1;
      for (var me in V)
        if (er(V, me)) {
          for (var he = !0, _e = 0; _e < O.length; _e++)
            if (Math.abs((ee.dimensions[_e] || 0) - (V[me].dimensions[_e] || 0)) > 1e-12) {
              he = !1;
              break;
            }
          if (he) {
            de = !0, ee.base = V[me];
            break;
          }
        }
      if (!de) {
        ie = ie || W + "_STUFF";
        var Se = {
          dimensions: oe.dimensions.slice(0)
        };
        Se.key = ie, V[ie] = Se, q[ie] = {
          unit: ee,
          prefix: N.NONE[""]
        }, ee.base = V[ie];
      }
    } else {
      if (ie = ie || W + "_STUFF", O.indexOf(ie) >= 0)
        throw new Error('Cannot create new base unit "' + W + '": a base unit with that name already exists (and cannot be overridden)');
      O.push(ie);
      for (var ne in V)
        er(V, ne) && (V[ne].dimensions[O.length - 1] = 0);
      for (var se = {
        dimensions: []
      }, ce = 0; ce < O.length; ce++)
        se.dimensions[ce] = 0;
      se.dimensions[O.length - 1] = 1, se.key = ie, V[ie] = se, ee = {
        name: W,
        value: 1,
        dimensions: V[ie].dimensions.slice(0),
        prefixes: le,
        offset: j,
        base: V[ie]
      }, q[ie] = {
        unit: ee,
        prefix: N.NONE[""]
      };
    }
    S.UNITS[W] = ee;
    for (var Pe = 0; Pe < z.length; Pe++) {
      var De = z[Pe], Ee = {};
      for (var Me in ee)
        er(ee, Me) && (Ee[Me] = ee[Me]);
      Ee.name = De, S.UNITS[De] = Ee;
    }
    return delete B.cache, new S(null, W);
  }, S.deleteUnit = function(W) {
    delete S.UNITS[W], delete B.cache;
  }, S.PREFIXES = N, S.BASE_DIMENSIONS = O, S.BASE_UNITS = V, S.UNIT_SYSTEMS = H, S.UNITS = R, S;
}, {
  isClass: !0
}), OF = "unit", NEe = ["typed", "Unit"], VEe = /* @__PURE__ */ Ce(OF, NEe, (e) => {
  var {
    typed: r,
    Unit: t
  } = e;
  return r(OF, {
    Unit: function(a) {
      return a.clone();
    },
    string: function(a) {
      return t.isValuelessUnit(a) ? new t(null, a) : t.parse(a, {
        allowNoUnits: !0
      });
    },
    "number | BigNumber | Fraction | Complex, string | Unit": function(a, i) {
      return new t(a, i);
    },
    "number | BigNumber | Fraction": function(a) {
      return new t(a);
    },
    "Array | Matrix": r.referToSelf((n) => (a) => zr(a, n))
  });
}), FF = "sparse", REe = ["typed", "SparseMatrix"], OEe = /* @__PURE__ */ Ce(FF, REe, (e) => {
  var {
    typed: r,
    SparseMatrix: t
  } = e;
  return r(FF, {
    "": function() {
      return new t([]);
    },
    string: function(a) {
      return new t([], a);
    },
    "Array | Matrix": function(a) {
      return new t(a);
    },
    "Array | Matrix, string": function(a, i) {
      return new t(a, i);
    }
  });
}), LF = "createUnit", FEe = ["typed", "Unit"], LEe = /* @__PURE__ */ Ce(LF, FEe, (e) => {
  var {
    typed: r,
    Unit: t
  } = e;
  return r(LF, {
    // General function signature. First parameter is an object where each property is the definition of a new unit. The object keys are the unit names and the values are the definitions. The values can be objects, strings, or Units. If a property is an empty object or an empty string, a new base unit is created. The second parameter is the options.
    "Object, Object": function(a, i) {
      return t.createUnit(a, i);
    },
    // Same as above but without the options.
    Object: function(a) {
      return t.createUnit(a, {});
    },
    // Shortcut method for creating one unit.
    "string, Unit | string | Object, Object": function(a, i, o) {
      var c = {};
      return c[a] = i, t.createUnit(c, o);
    },
    // Same as above but without the options.
    "string, Unit | string | Object": function(a, i) {
      var o = {};
      return o[a] = i, t.createUnit(o, {});
    },
    // Without a definition, creates a base unit.
    string: function(a) {
      var i = {};
      return i[a] = {}, t.createUnit(i, {});
    }
  });
}), kF = "acos", kEe = ["typed", "config", "Complex"], UEe = /* @__PURE__ */ Ce(kF, kEe, (e) => {
  var {
    typed: r,
    config: t,
    Complex: n
  } = e;
  return r(kF, {
    number: function(i) {
      return i >= -1 && i <= 1 || t.predictable ? Math.acos(i) : new n(i, 0).acos();
    },
    Complex: function(i) {
      return i.acos();
    },
    BigNumber: function(i) {
      return i.acos();
    }
  });
}), UF = "acosh", zEe = ["typed", "config", "Complex"], GEe = /* @__PURE__ */ Ce(UF, zEe, (e) => {
  var {
    typed: r,
    config: t,
    Complex: n
  } = e;
  return r(UF, {
    number: function(i) {
      return i >= 1 || t.predictable ? BW(i) : i <= -1 ? new n(Math.log(Math.sqrt(i * i - 1) - i), Math.PI) : new n(i, 0).acosh();
    },
    Complex: function(i) {
      return i.acosh();
    },
    BigNumber: function(i) {
      return i.acosh();
    }
  });
}), zF = "acot", qEe = ["typed", "BigNumber"], HEe = /* @__PURE__ */ Ce(zF, qEe, (e) => {
  var {
    typed: r,
    BigNumber: t
  } = e;
  return r(zF, {
    number: NW,
    Complex: function(a) {
      return a.acot();
    },
    BigNumber: function(a) {
      return new t(1).div(a).atan();
    }
  });
}), GF = "acoth", jEe = ["typed", "config", "Complex", "BigNumber"], $Ee = /* @__PURE__ */ Ce(GF, jEe, (e) => {
  var {
    typed: r,
    config: t,
    Complex: n,
    BigNumber: a
  } = e;
  return r(GF, {
    number: function(o) {
      return o >= 1 || o <= -1 || t.predictable ? VW(o) : new n(o, 0).acoth();
    },
    Complex: function(o) {
      return o.acoth();
    },
    BigNumber: function(o) {
      return new a(1).div(o).atanh();
    }
  });
}), qF = "acsc", KEe = ["typed", "config", "Complex", "BigNumber"], WEe = /* @__PURE__ */ Ce(qF, KEe, (e) => {
  var {
    typed: r,
    config: t,
    Complex: n,
    BigNumber: a
  } = e;
  return r(qF, {
    number: function(o) {
      return o <= -1 || o >= 1 || t.predictable ? RW(o) : new n(o, 0).acsc();
    },
    Complex: function(o) {
      return o.acsc();
    },
    BigNumber: function(o) {
      return new a(1).div(o).asin();
    }
  });
}), HF = "acsch", XEe = ["typed", "BigNumber"], YEe = /* @__PURE__ */ Ce(HF, XEe, (e) => {
  var {
    typed: r,
    BigNumber: t
  } = e;
  return r(HF, {
    number: OW,
    Complex: function(a) {
      return a.acsch();
    },
    BigNumber: function(a) {
      return new t(1).div(a).asinh();
    }
  });
}), jF = "asec", QEe = ["typed", "config", "Complex", "BigNumber"], ZEe = /* @__PURE__ */ Ce(jF, QEe, (e) => {
  var {
    typed: r,
    config: t,
    Complex: n,
    BigNumber: a
  } = e;
  return r(jF, {
    number: function(o) {
      return o <= -1 || o >= 1 || t.predictable ? FW(o) : new n(o, 0).asec();
    },
    Complex: function(o) {
      return o.asec();
    },
    BigNumber: function(o) {
      return new a(1).div(o).acos();
    }
  });
}), $F = "asech", JEe = ["typed", "config", "Complex", "BigNumber"], eDe = /* @__PURE__ */ Ce($F, JEe, (e) => {
  var {
    typed: r,
    config: t,
    Complex: n,
    BigNumber: a
  } = e;
  return r($F, {
    number: function(o) {
      if (o <= 1 && o >= -1 || t.predictable) {
        var c = 1 / o;
        if (c > 0 || t.predictable)
          return LW(o);
        var s = Math.sqrt(c * c - 1);
        return new n(Math.log(s - c), Math.PI);
      }
      return new n(o, 0).asech();
    },
    Complex: function(o) {
      return o.asech();
    },
    BigNumber: function(o) {
      return new a(1).div(o).acosh();
    }
  });
}), KF = "asin", rDe = ["typed", "config", "Complex"], tDe = /* @__PURE__ */ Ce(KF, rDe, (e) => {
  var {
    typed: r,
    config: t,
    Complex: n
  } = e;
  return r(KF, {
    number: function(i) {
      return i >= -1 && i <= 1 || t.predictable ? Math.asin(i) : new n(i, 0).asin();
    },
    Complex: function(i) {
      return i.asin();
    },
    BigNumber: function(i) {
      return i.asin();
    }
  });
}), nDe = "asinh", aDe = ["typed"], iDe = /* @__PURE__ */ Ce(nDe, aDe, (e) => {
  var {
    typed: r
  } = e;
  return r("asinh", {
    number: kW,
    Complex: function(n) {
      return n.asinh();
    },
    BigNumber: function(n) {
      return n.asinh();
    }
  });
}), oDe = "atan", uDe = ["typed"], nY = /* @__PURE__ */ Ce(oDe, uDe, (e) => {
  var {
    typed: r
  } = e;
  return r("atan", {
    number: function(n) {
      return Math.atan(n);
    },
    Complex: function(n) {
      return n.atan();
    },
    BigNumber: function(n) {
      return n.atan();
    }
  });
}), WF = "atan2", sDe = ["typed", "matrix", "equalScalar", "BigNumber", "DenseMatrix", "concat"], lDe = /* @__PURE__ */ Ce(WF, sDe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    BigNumber: a,
    DenseMatrix: i,
    concat: o
  } = e, c = Ts({
    typed: r,
    equalScalar: n
  }), s = Zi({
    typed: r
  }), u = yX({
    typed: r,
    equalScalar: n
  }), l = li({
    typed: r,
    equalScalar: n
  }), f = Aa({
    typed: r,
    DenseMatrix: i
  }), d = kt({
    typed: r,
    matrix: t,
    concat: o
  });
  return r(WF, {
    "number, number": Math.atan2,
    // Complex numbers doesn't seem to have a reasonable implementation of
    // atan2(). Even Matlab removed the support, after they only calculated
    // the atan only on base of the real part of the numbers and ignored
    // the imaginary.
    "BigNumber, BigNumber": (m, p) => a.atan2(m, p)
  }, d({
    scalar: "number | BigNumber",
    SS: u,
    DS: s,
    SD: c,
    Ss: l,
    sS: f
  }));
}), XF = "atanh", cDe = ["typed", "config", "Complex"], dDe = /* @__PURE__ */ Ce(XF, cDe, (e) => {
  var {
    typed: r,
    config: t,
    Complex: n
  } = e;
  return r(XF, {
    number: function(i) {
      return i <= 1 && i >= -1 || t.predictable ? UW(i) : new n(i, 0).atanh();
    },
    Complex: function(i) {
      return i.atanh();
    },
    BigNumber: function(i) {
      return i.atanh();
    }
  });
}), Jp = /* @__PURE__ */ Ce("trigUnit", ["typed"], (e) => {
  var {
    typed: r
  } = e;
  return {
    Unit: r.referToSelf((t) => (n) => {
      if (!n.hasBase(n.constructor.BASE_UNITS.ANGLE))
        throw new TypeError("Unit in function cot is no angle");
      return r.find(t, n.valueType())(n.value);
    })
  };
}), YF = "cos", fDe = ["typed"], aY = /* @__PURE__ */ Ce(YF, fDe, (e) => {
  var {
    typed: r
  } = e, t = Jp({
    typed: r
  });
  return r(YF, {
    number: Math.cos,
    "Complex | BigNumber": (n) => n.cos()
  }, t);
}), QF = "cosh", mDe = ["typed"], vDe = /* @__PURE__ */ Ce(QF, mDe, (e) => {
  var {
    typed: r
  } = e;
  return r(QF, {
    number: oAe,
    "Complex | BigNumber": (t) => t.cosh()
  });
}), ZF = "cot", pDe = ["typed", "BigNumber"], hDe = /* @__PURE__ */ Ce(ZF, pDe, (e) => {
  var {
    typed: r,
    BigNumber: t
  } = e, n = Jp({
    typed: r
  });
  return r(ZF, {
    number: zW,
    Complex: (a) => a.cot(),
    BigNumber: (a) => new t(1).div(a.tan())
  }, n);
}), JF = "coth", gDe = ["typed", "BigNumber"], yDe = /* @__PURE__ */ Ce(JF, gDe, (e) => {
  var {
    typed: r,
    BigNumber: t
  } = e;
  return r(JF, {
    number: GW,
    Complex: (n) => n.coth(),
    BigNumber: (n) => new t(1).div(n.tanh())
  });
}), eL = "csc", _De = ["typed", "BigNumber"], bDe = /* @__PURE__ */ Ce(eL, _De, (e) => {
  var {
    typed: r,
    BigNumber: t
  } = e, n = Jp({
    typed: r
  });
  return r(eL, {
    number: qW,
    Complex: (a) => a.csc(),
    BigNumber: (a) => new t(1).div(a.sin())
  }, n);
}), rL = "csch", SDe = ["typed", "BigNumber"], CDe = /* @__PURE__ */ Ce(rL, SDe, (e) => {
  var {
    typed: r,
    BigNumber: t
  } = e;
  return r(rL, {
    number: HW,
    Complex: (n) => n.csch(),
    BigNumber: (n) => new t(1).div(n.sinh())
  });
}), tL = "sec", ADe = ["typed", "BigNumber"], xDe = /* @__PURE__ */ Ce(tL, ADe, (e) => {
  var {
    typed: r,
    BigNumber: t
  } = e, n = Jp({
    typed: r
  });
  return r(tL, {
    number: jW,
    Complex: (a) => a.sec(),
    BigNumber: (a) => new t(1).div(a.cos())
  }, n);
}), nL = "sech", TDe = ["typed", "BigNumber"], PDe = /* @__PURE__ */ Ce(nL, TDe, (e) => {
  var {
    typed: r,
    BigNumber: t
  } = e;
  return r(nL, {
    number: $W,
    Complex: (n) => n.sech(),
    BigNumber: (n) => new t(1).div(n.cosh())
  });
}), aL = "sin", MDe = ["typed"], iY = /* @__PURE__ */ Ce(aL, MDe, (e) => {
  var {
    typed: r
  } = e, t = Jp({
    typed: r
  });
  return r(aL, {
    number: Math.sin,
    "Complex | BigNumber": (n) => n.sin()
  }, t);
}), iL = "sinh", wDe = ["typed"], EDe = /* @__PURE__ */ Ce(iL, wDe, (e) => {
  var {
    typed: r
  } = e;
  return r(iL, {
    number: KW,
    "Complex | BigNumber": (t) => t.sinh()
  });
}), oL = "tan", DDe = ["typed"], IDe = /* @__PURE__ */ Ce(oL, DDe, (e) => {
  var {
    typed: r
  } = e, t = Jp({
    typed: r
  });
  return r(oL, {
    number: Math.tan,
    "Complex | BigNumber": (n) => n.tan()
  }, t);
}), BDe = "tanh", NDe = ["typed"], VDe = /* @__PURE__ */ Ce(BDe, NDe, (e) => {
  var {
    typed: r
  } = e;
  return r("tanh", {
    number: sAe,
    "Complex | BigNumber": (t) => t.tanh()
  });
}), uL = "setCartesian", RDe = ["typed", "size", "subset", "compareNatural", "Index", "DenseMatrix"], ODe = /* @__PURE__ */ Ce(uL, RDe, (e) => {
  var {
    typed: r,
    size: t,
    subset: n,
    compareNatural: a,
    Index: i,
    DenseMatrix: o
  } = e;
  return r(uL, {
    "Array | Matrix, Array | Matrix": function(s, u) {
      var l = [];
      if (n(t(s), new i(0)) !== 0 && n(t(u), new i(0)) !== 0) {
        var f = st(Array.isArray(s) ? s : s.toArray()).sort(a), d = st(Array.isArray(u) ? u : u.toArray()).sort(a);
        l = [];
        for (var m = 0; m < f.length; m++)
          for (var p = 0; p < d.length; p++)
            l.push([f[m], d[p]]);
      }
      return Array.isArray(s) && Array.isArray(u) ? l : new o(l);
    }
  });
}), sL = "setDifference", FDe = ["typed", "size", "subset", "compareNatural", "Index", "DenseMatrix"], LDe = /* @__PURE__ */ Ce(sL, FDe, (e) => {
  var {
    typed: r,
    size: t,
    subset: n,
    compareNatural: a,
    Index: i,
    DenseMatrix: o
  } = e;
  return r(sL, {
    "Array | Matrix, Array | Matrix": function(s, u) {
      var l;
      if (n(t(s), new i(0)) === 0)
        l = [];
      else {
        if (n(t(u), new i(0)) === 0)
          return st(s.toArray());
        var f = mp(st(Array.isArray(s) ? s : s.toArray()).sort(a)), d = mp(st(Array.isArray(u) ? u : u.toArray()).sort(a));
        l = [];
        for (var m, p = 0; p < f.length; p++) {
          m = !1;
          for (var v = 0; v < d.length; v++)
            if (a(f[p].value, d[v].value) === 0 && f[p].identifier === d[v].identifier) {
              m = !0;
              break;
            }
          m || l.push(f[p]);
        }
      }
      return Array.isArray(s) && Array.isArray(u) ? S3(l) : new o(S3(l));
    }
  });
}), lL = "setDistinct", kDe = ["typed", "size", "subset", "compareNatural", "Index", "DenseMatrix"], UDe = /* @__PURE__ */ Ce(lL, kDe, (e) => {
  var {
    typed: r,
    size: t,
    subset: n,
    compareNatural: a,
    Index: i,
    DenseMatrix: o
  } = e;
  return r(lL, {
    "Array | Matrix": function(s) {
      var u;
      if (n(t(s), new i(0)) === 0)
        u = [];
      else {
        var l = st(Array.isArray(s) ? s : s.toArray()).sort(a);
        u = [], u.push(l[0]);
        for (var f = 1; f < l.length; f++)
          a(l[f], l[f - 1]) !== 0 && u.push(l[f]);
      }
      return Array.isArray(s) ? u : new o(u);
    }
  });
}), cL = "setIntersect", zDe = ["typed", "size", "subset", "compareNatural", "Index", "DenseMatrix"], GDe = /* @__PURE__ */ Ce(cL, zDe, (e) => {
  var {
    typed: r,
    size: t,
    subset: n,
    compareNatural: a,
    Index: i,
    DenseMatrix: o
  } = e;
  return r(cL, {
    "Array | Matrix, Array | Matrix": function(s, u) {
      var l;
      if (n(t(s), new i(0)) === 0 || n(t(u), new i(0)) === 0)
        l = [];
      else {
        var f = mp(st(Array.isArray(s) ? s : s.toArray()).sort(a)), d = mp(st(Array.isArray(u) ? u : u.toArray()).sort(a));
        l = [];
        for (var m = 0; m < f.length; m++)
          for (var p = 0; p < d.length; p++)
            if (a(f[m].value, d[p].value) === 0 && f[m].identifier === d[p].identifier) {
              l.push(f[m]);
              break;
            }
      }
      return Array.isArray(s) && Array.isArray(u) ? S3(l) : new o(S3(l));
    }
  });
}), dL = "setIsSubset", qDe = ["typed", "size", "subset", "compareNatural", "Index"], HDe = /* @__PURE__ */ Ce(dL, qDe, (e) => {
  var {
    typed: r,
    size: t,
    subset: n,
    compareNatural: a,
    Index: i
  } = e;
  return r(dL, {
    "Array | Matrix, Array | Matrix": function(c, s) {
      if (n(t(c), new i(0)) === 0)
        return !0;
      if (n(t(s), new i(0)) === 0)
        return !1;
      for (var u = mp(st(Array.isArray(c) ? c : c.toArray()).sort(a)), l = mp(st(Array.isArray(s) ? s : s.toArray()).sort(a)), f, d = 0; d < u.length; d++) {
        f = !1;
        for (var m = 0; m < l.length; m++)
          if (a(u[d].value, l[m].value) === 0 && u[d].identifier === l[m].identifier) {
            f = !0;
            break;
          }
        if (f === !1)
          return !1;
      }
      return !0;
    }
  });
}), fL = "setMultiplicity", jDe = ["typed", "size", "subset", "compareNatural", "Index"], $De = /* @__PURE__ */ Ce(fL, jDe, (e) => {
  var {
    typed: r,
    size: t,
    subset: n,
    compareNatural: a,
    Index: i
  } = e;
  return r(fL, {
    "number | BigNumber | Fraction | Complex, Array | Matrix": function(c, s) {
      if (n(t(s), new i(0)) === 0)
        return 0;
      for (var u = st(Array.isArray(s) ? s : s.toArray()), l = 0, f = 0; f < u.length; f++)
        a(u[f], c) === 0 && l++;
      return l;
    }
  });
}), mL = "setPowerset", KDe = ["typed", "size", "subset", "compareNatural", "Index"], WDe = /* @__PURE__ */ Ce(mL, KDe, (e) => {
  var {
    typed: r,
    size: t,
    subset: n,
    compareNatural: a,
    Index: i
  } = e;
  return r(mL, {
    "Array | Matrix": function(u) {
      if (n(t(u), new i(0)) === 0)
        return [];
      for (var l = st(Array.isArray(u) ? u : u.toArray()).sort(a), f = [], d = 0; d.toString(2).length <= l.length; )
        f.push(o(l, d.toString(2).split("").reverse())), d++;
      return c(f);
    }
  });
  function o(s, u) {
    for (var l = [], f = 0; f < u.length; f++)
      u[f] === "1" && l.push(s[f]);
    return l;
  }
  function c(s) {
    for (var u = [], l = s.length - 1; l > 0; l--)
      for (var f = 0; f < l; f++)
        s[f].length > s[f + 1].length && (u = s[f], s[f] = s[f + 1], s[f + 1] = u);
    return s;
  }
}), vL = "setSize", XDe = ["typed", "compareNatural"], YDe = /* @__PURE__ */ Ce(vL, XDe, (e) => {
  var {
    typed: r,
    compareNatural: t
  } = e;
  return r(vL, {
    "Array | Matrix": function(a) {
      return Array.isArray(a) ? st(a).length : st(a.toArray()).length;
    },
    "Array | Matrix, boolean": function(a, i) {
      if (i === !1 || a.length === 0)
        return Array.isArray(a) ? st(a).length : st(a.toArray()).length;
      for (var o = st(Array.isArray(a) ? a : a.toArray()).sort(t), c = 1, s = 1; s < o.length; s++)
        t(o[s], o[s - 1]) !== 0 && c++;
      return c;
    }
  });
}), pL = "setSymDifference", QDe = ["typed", "size", "concat", "subset", "setDifference", "Index"], ZDe = /* @__PURE__ */ Ce(pL, QDe, (e) => {
  var {
    typed: r,
    size: t,
    concat: n,
    subset: a,
    setDifference: i,
    Index: o
  } = e;
  return r(pL, {
    "Array | Matrix, Array | Matrix": function(s, u) {
      if (a(t(s), new o(0)) === 0)
        return st(u);
      if (a(t(u), new o(0)) === 0)
        return st(s);
      var l = st(s), f = st(u);
      return n(i(l, f), i(f, l));
    }
  });
}), hL = "setUnion", JDe = ["typed", "size", "concat", "subset", "setIntersect", "setSymDifference", "Index"], e6e = /* @__PURE__ */ Ce(hL, JDe, (e) => {
  var {
    typed: r,
    size: t,
    concat: n,
    subset: a,
    setIntersect: i,
    setSymDifference: o,
    Index: c
  } = e;
  return r(hL, {
    "Array | Matrix, Array | Matrix": function(u, l) {
      if (a(t(u), new c(0)) === 0)
        return st(l);
      if (a(t(l), new c(0)) === 0)
        return st(u);
      var f = st(u), d = st(l);
      return n(o(f, d), i(f, d));
    }
  });
}), gL = "add", r6e = ["typed", "matrix", "addScalar", "equalScalar", "DenseMatrix", "SparseMatrix", "concat"], oY = /* @__PURE__ */ Ce(gL, r6e, (e) => {
  var {
    typed: r,
    matrix: t,
    addScalar: n,
    equalScalar: a,
    DenseMatrix: i,
    SparseMatrix: o,
    concat: c
  } = e, s = nf({
    typed: r
  }), u = DD({
    typed: r,
    equalScalar: a
  }), l = rm({
    typed: r,
    DenseMatrix: i
  }), f = kt({
    typed: r,
    matrix: t,
    concat: c
  });
  return r(gL, {
    "any, any": n,
    "any, any, ...any": r.referToSelf((d) => (m, p, v) => {
      for (var h = d(m, p), y = 0; y < v.length; y++)
        h = d(h, v[y]);
      return h;
    })
  }, f({
    elop: n,
    DS: s,
    SS: u,
    Ss: l
  }));
}), yL = "hypot", t6e = ["typed", "abs", "addScalar", "divideScalar", "multiplyScalar", "sqrt", "smaller", "isPositive"], n6e = /* @__PURE__ */ Ce(yL, t6e, (e) => {
  var {
    typed: r,
    abs: t,
    addScalar: n,
    divideScalar: a,
    multiplyScalar: i,
    sqrt: o,
    smaller: c,
    isPositive: s
  } = e;
  return r(yL, {
    "... number | BigNumber": u,
    Array: u,
    Matrix: (l) => u(st(l.toArray()))
  });
  function u(l) {
    for (var f = 0, d = 0, m = 0; m < l.length; m++) {
      if (as(l[m]))
        throw new TypeError("Unexpected type of argument to hypot");
      var p = t(l[m]);
      c(d, p) ? (f = i(f, i(a(d, p), a(d, p))), f = n(f, 1), d = p) : f = n(f, s(p) ? i(a(p, d), a(p, d)) : p);
    }
    return i(d, o(f));
  }
}), _L = "norm", a6e = ["typed", "abs", "add", "pow", "conj", "sqrt", "multiply", "equalScalar", "larger", "smaller", "matrix", "ctranspose", "eigs"], uY = /* @__PURE__ */ Ce(_L, a6e, (e) => {
  var {
    typed: r,
    abs: t,
    add: n,
    pow: a,
    conj: i,
    sqrt: o,
    multiply: c,
    equalScalar: s,
    larger: u,
    smaller: l,
    matrix: f,
    ctranspose: d,
    eigs: m
  } = e;
  return r(_L, {
    number: Math.abs,
    Complex: function(M) {
      return M.abs();
    },
    BigNumber: function(M) {
      return M.abs();
    },
    boolean: function(M) {
      return Math.abs(M);
    },
    Array: function(M) {
      return _(f(M), 2);
    },
    Matrix: function(M) {
      return _(M, 2);
    },
    "Array, number | BigNumber | string": function(M, P) {
      return _(f(M), P);
    },
    "Matrix, number | BigNumber | string": function(M, P) {
      return _(M, P);
    }
  });
  function p(A) {
    var M = 0;
    return A.forEach(function(P) {
      var T = t(P);
      u(T, M) && (M = T);
    }, !0), M;
  }
  function v(A) {
    var M;
    return A.forEach(function(P) {
      var T = t(P);
      (!M || l(T, M)) && (M = T);
    }, !0), M || 0;
  }
  function h(A, M) {
    if (M === Number.POSITIVE_INFINITY || M === "inf")
      return p(A);
    if (M === Number.NEGATIVE_INFINITY || M === "-inf")
      return v(A);
    if (M === "fro")
      return _(A, 2);
    if (typeof M == "number" && !isNaN(M)) {
      if (!s(M, 0)) {
        var P = 0;
        return A.forEach(function(T) {
          P = n(a(t(T), M), P);
        }, !0), a(P, 1 / M);
      }
      return Number.POSITIVE_INFINITY;
    }
    throw new Error("Unsupported parameter value");
  }
  function y(A) {
    var M = 0;
    return A.forEach(function(P, T) {
      M = n(M, c(P, i(P)));
    }), t(o(M));
  }
  function C(A) {
    var M = [], P = 0;
    return A.forEach(function(T, x) {
      var w = x[1], E = n(M[w] || 0, t(T));
      u(E, P) && (P = E), M[w] = E;
    }, !0), P;
  }
  function S(A) {
    var M = A.size();
    if (M[0] !== M[1])
      throw new RangeError("Invalid matrix dimensions");
    var P = d(A), T = c(P, A), x = m(T).values.toArray(), w = x[x.length - 1];
    return t(o(w));
  }
  function b(A) {
    var M = [], P = 0;
    return A.forEach(function(T, x) {
      var w = x[0], E = n(M[w] || 0, t(T));
      u(E, P) && (P = E), M[w] = E;
    }, !0), P;
  }
  function g(A, M) {
    if (M === 1)
      return C(A);
    if (M === Number.POSITIVE_INFINITY || M === "inf")
      return b(A);
    if (M === "fro")
      return y(A);
    if (M === 2)
      return S(A);
    throw new Error("Unsupported parameter value " + M);
  }
  function _(A, M) {
    var P = A.size();
    if (P.length === 1)
      return h(A, M);
    if (P.length === 2) {
      if (P[0] && P[1])
        return g(A, M);
      throw new RangeError("Invalid matrix dimensions");
    }
  }
}), bL = "dot", i6e = ["typed", "addScalar", "multiplyScalar", "conj", "size"], sY = /* @__PURE__ */ Ce(bL, i6e, (e) => {
  var {
    typed: r,
    addScalar: t,
    multiplyScalar: n,
    conj: a,
    size: i
  } = e;
  return r(bL, {
    "Array | DenseMatrix, Array | DenseMatrix": c,
    "SparseMatrix, SparseMatrix": s
  });
  function o(l, f) {
    var d = u(l), m = u(f), p, v;
    if (d.length === 1)
      p = d[0];
    else if (d.length === 2 && d[1] === 1)
      p = d[0];
    else
      throw new RangeError("Expected a column vector, instead got a matrix of size (" + d.join(", ") + ")");
    if (m.length === 1)
      v = m[0];
    else if (m.length === 2 && m[1] === 1)
      v = m[0];
    else
      throw new RangeError("Expected a column vector, instead got a matrix of size (" + m.join(", ") + ")");
    if (p !== v) throw new RangeError("Vectors must have equal length (" + p + " != " + v + ")");
    if (p === 0) throw new RangeError("Cannot calculate the dot product of empty vectors");
    return p;
  }
  function c(l, f) {
    var d = o(l, f), m = gr(l) ? l._data : l, p = gr(l) ? l._datatype || l.getDataType() : void 0, v = gr(f) ? f._data : f, h = gr(f) ? f._datatype || f.getDataType() : void 0, y = u(l).length === 2, C = u(f).length === 2, S = t, b = n;
    if (p && h && p === h && typeof p == "string" && p !== "mixed") {
      var g = p;
      S = r.find(t, [g, g]), b = r.find(n, [g, g]);
    }
    if (!y && !C) {
      for (var _ = b(a(m[0]), v[0]), A = 1; A < d; A++)
        _ = S(_, b(a(m[A]), v[A]));
      return _;
    }
    if (!y && C) {
      for (var M = b(a(m[0]), v[0][0]), P = 1; P < d; P++)
        M = S(M, b(a(m[P]), v[P][0]));
      return M;
    }
    if (y && !C) {
      for (var T = b(a(m[0][0]), v[0]), x = 1; x < d; x++)
        T = S(T, b(a(m[x][0]), v[x]));
      return T;
    }
    if (y && C) {
      for (var w = b(a(m[0][0]), v[0][0]), E = 1; E < d; E++)
        w = S(w, b(a(m[E][0]), v[E][0]));
      return w;
    }
  }
  function s(l, f) {
    o(l, f);
    for (var d = l._index, m = l._values, p = f._index, v = f._values, h = 0, y = t, C = n, S = 0, b = 0; S < d.length && b < p.length; ) {
      var g = d[S], _ = p[b];
      if (g < _) {
        S++;
        continue;
      }
      if (g > _) {
        b++;
        continue;
      }
      g === _ && (h = y(h, C(m[S], v[b])), S++, b++);
    }
    return h;
  }
  function u(l) {
    return gr(l) ? l.size() : i(l);
  }
}), o6e = "trace", u6e = ["typed", "matrix", "add"], s6e = /* @__PURE__ */ Ce(o6e, u6e, (e) => {
  var {
    typed: r,
    matrix: t,
    add: n
  } = e;
  return r("trace", {
    Array: function(c) {
      return a(t(c));
    },
    SparseMatrix: i,
    DenseMatrix: a,
    any: Sr
  });
  function a(o) {
    var c = o._size, s = o._data;
    switch (c.length) {
      case 1:
        if (c[0] === 1)
          return Sr(s[0]);
        throw new RangeError("Matrix must be square (size: " + $r(c) + ")");
      case 2: {
        var u = c[0], l = c[1];
        if (u === l) {
          for (var f = 0, d = 0; d < u; d++)
            f = n(f, s[d][d]);
          return f;
        } else
          throw new RangeError("Matrix must be square (size: " + $r(c) + ")");
      }
      default:
        throw new RangeError("Matrix must be two dimensional (size: " + $r(c) + ")");
    }
  }
  function i(o) {
    var c = o._values, s = o._index, u = o._ptr, l = o._size, f = l[0], d = l[1];
    if (f === d) {
      var m = 0;
      if (c.length > 0)
        for (var p = 0; p < d; p++)
          for (var v = u[p], h = u[p + 1], y = v; y < h; y++) {
            var C = s[y];
            if (C === p) {
              m = n(m, c[y]);
              break;
            }
            if (C > p)
              break;
          }
      return m;
    }
    throw new RangeError("Matrix must be square (size: " + $r(l) + ")");
  }
}), SL = "index", l6e = ["typed", "Index"], c6e = /* @__PURE__ */ Ce(SL, l6e, (e) => {
  var {
    typed: r,
    Index: t
  } = e;
  return r(SL, {
    "...number | string | BigNumber | Range | Array | Matrix": function(a) {
      var i = a.map(function(c) {
        return Ir(c) ? c.toNumber() : dt(c) || gr(c) ? c.map(function(s) {
          return Ir(s) ? s.toNumber() : s;
        }) : c;
      }), o = new t();
      return t.apply(o, i), o;
    }
  });
}), lY = /* @__PURE__ */ new Set(["end"]), d6e = "Node", f6e = ["mathWithTransform"], m6e = /* @__PURE__ */ Ce(d6e, f6e, (e) => {
  var {
    mathWithTransform: r
  } = e;
  function t(a) {
    for (var i of [...lY])
      if (a.has(i))
        throw new Error('Scope contains an illegal symbol, "' + i + '" is a reserved keyword');
  }
  class n {
    get type() {
      return "Node";
    }
    get isNode() {
      return !0;
    }
    /**
     * Evaluate the node
     * @param {Object} [scope]  Scope to read/write variables
     * @return {*}              Returns the result
     */
    evaluate(i) {
      return this.compile().evaluate(i);
    }
    /**
     * Compile the node into an optimized, evauatable JavaScript function
     * @return {{evaluate: function([Object])}} object
     *                Returns an object with a function 'evaluate',
     *                which can be invoked as expr.evaluate([scope: Object]),
     *                where scope is an optional object with
     *                variables.
     */
    compile() {
      var i = this._compile(r, {}), o = {}, c = null;
      function s(u) {
        var l = bv(u);
        return t(l), i(l, o, c);
      }
      return {
        evaluate: s
      };
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(i, o) {
      throw new Error("Method _compile must be implemented by type " + this.type);
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(i) {
      throw new Error("Cannot run forEach on a Node interface");
    }
    /**
     * Create a new Node whose children are the results of calling the
     * provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {OperatorNode} Returns a transformed copy of the node
     */
    map(i) {
      throw new Error("Cannot run map on a Node interface");
    }
    /**
     * Validate whether an object is a Node, for use with map
     * @param {Node} node
     * @returns {Node} Returns the input if it's a node, else throws an Error
     * @protected
     */
    _ifNode(i) {
      if (!St(i))
        throw new TypeError("Callback function must return a Node");
      return i;
    }
    /**
     * Recursively traverse all nodes in a node tree. Executes given callback for
     * this node and each of its child nodes.
     * @param {function(node: Node, path: string, parent: Node)} callback
     *          A callback called for every node in the node tree.
     */
    traverse(i) {
      i(this, null, null);
      function o(c, s) {
        c.forEach(function(u, l, f) {
          s(u, l, f), o(u, s);
        });
      }
      o(this, i);
    }
    /**
     * Recursively transform a node tree via a transform function.
     *
     * For example, to replace all nodes of type SymbolNode having name 'x' with
     * a ConstantNode with value 2:
     *
     *     const res = Node.transform(function (node, path, parent) {
     *       if (node && node.isSymbolNode) && (node.name === 'x')) {
     *         return new ConstantNode(2)
     *       }
     *       else {
     *         return node
     *       }
     *     })
     *
     * @param {function(node: Node, path: string, parent: Node) : Node} callback
     *          A mapping function accepting a node, and returning
     *          a replacement for the node or the original node. The "signature"
     *          of the callback must be:
     *          callback(node: Node, index: string, parent: Node) : Node
     * @return {Node} Returns the original node or its replacement
     */
    transform(i) {
      function o(c, s, u) {
        var l = i(c, s, u);
        return l !== c ? l : c.map(o);
      }
      return o(this, null, null);
    }
    /**
     * Find any node in the node tree matching given filter function. For
     * example, to find all nodes of type SymbolNode having name 'x':
     *
     *     const results = Node.filter(function (node) {
     *       return (node && node.isSymbolNode) && (node.name === 'x')
     *     })
     *
     * @param {function(node: Node, path: string, parent: Node) : Node} callback
     *            A test function returning true when a node matches, and false
     *            otherwise. Function signature:
     *            callback(node: Node, index: string, parent: Node) : boolean
     * @return {Node[]} nodes
     *            An array with nodes matching given filter criteria
     */
    filter(i) {
      var o = [];
      return this.traverse(function(c, s, u) {
        i(c, s, u) && o.push(c);
      }), o;
    }
    /**
     * Create a shallow clone of this node
     * @return {Node}
     */
    clone() {
      throw new Error("Cannot clone a Node interface");
    }
    /**
     * Create a deep clone of this node
     * @return {Node}
     */
    cloneDeep() {
      return this.map(function(i) {
        return i.cloneDeep();
      });
    }
    /**
     * Deep compare this node with another node.
     * @param {Node} other
     * @return {boolean} Returns true when both nodes are of the same type and
     *                   contain the same values (as do their childs)
     */
    equals(i) {
      return i ? this.type === i.type && gc(this, i) : !1;
    }
    /**
     * Get string representation. (wrapper function)
     *
     * This function can get an object of the following form:
     * {
     *    handler: //This can be a callback function of the form
     *             // "function callback(node, options)"or
     *             // a map that maps function names (used in FunctionNodes)
     *             // to callbacks
     *    parenthesis: "keep" //the parenthesis option (This is optional)
     * }
     *
     * @param {Object} [options]
     * @return {string}
     */
    toString(i) {
      var o = this._getCustomString(i);
      return typeof o < "u" ? o : this._toString(i);
    }
    /**
     * Internal function to generate the string output.
     * This has to be implemented by every Node
     *
     * @throws {Error}
     */
    _toString() {
      throw new Error("_toString not implemented for " + this.type);
    }
    /**
     * Get a JSON representation of the node
     * Both .toJSON() and the static .fromJSON(json) should be implemented by all
     * implementations of Node
     * @returns {Object}
     */
    toJSON() {
      throw new Error("Cannot serialize object: toJSON not implemented by " + this.type);
    }
    /**
     * Get HTML representation. (wrapper function)
     *
     * This function can get an object of the following form:
     * {
     *    handler: //This can be a callback function of the form
     *             // "function callback(node, options)" or
     *             // a map that maps function names (used in FunctionNodes)
     *             // to callbacks
     *    parenthesis: "keep" //the parenthesis option (This is optional)
     * }
     *
     * @param {Object} [options]
     * @return {string}
     */
    toHTML(i) {
      var o = this._getCustomString(i);
      return typeof o < "u" ? o : this._toHTML(i);
    }
    /**
     * Internal function to generate the HTML output.
     * This has to be implemented by every Node
     *
     * @throws {Error}
     */
    _toHTML() {
      throw new Error("_toHTML not implemented for " + this.type);
    }
    /**
     * Get LaTeX representation. (wrapper function)
     *
     * This function can get an object of the following form:
     * {
     *    handler: //This can be a callback function of the form
     *             // "function callback(node, options)"or
     *             // a map that maps function names (used in FunctionNodes)
     *             // to callbacks
     *    parenthesis: "keep" //the parenthesis option (This is optional)
     * }
     *
     * @param {Object} [options]
     * @return {string}
     */
    toTex(i) {
      var o = this._getCustomString(i);
      return typeof o < "u" ? o : this._toTex(i);
    }
    /**
     * Internal function to generate the LaTeX output.
     * This has to be implemented by every Node
     *
     * @param {Object} [options]
     * @throws {Error}
     */
    _toTex(i) {
      throw new Error("_toTex not implemented for " + this.type);
    }
    /**
     * Helper used by `to...` functions.
     */
    _getCustomString(i) {
      if (i && typeof i == "object")
        switch (typeof i.handler) {
          case "object":
          case "undefined":
            return;
          case "function":
            return i.handler(this, i);
          default:
            throw new TypeError("Object or function expected as callback");
        }
    }
    /**
     * Get identifier.
     * @return {string}
     */
    getIdentifier() {
      return this.type;
    }
    /**
     * Get the content of the current Node.
     * @return {Node} node
     **/
    getContent() {
      return this;
    }
  }
  return n;
}, {
  isClass: !0,
  isNode: !0
});
function Ji(e) {
  return e && e.isIndexError ? new Ru(e.index + 1, e.min + 1, e.max !== void 0 ? e.max + 1 : void 0) : e;
}
function cY(e) {
  var {
    subset: r
  } = e;
  return function(n, a) {
    try {
      if (Array.isArray(n))
        return r(n, a);
      if (n && typeof n.subset == "function")
        return n.subset(a);
      if (typeof n == "string")
        return r(n, a);
      if (typeof n == "object") {
        if (!a.isObjectProperty())
          throw new TypeError("Cannot apply a numeric index as object property");
        return Ki(n, a.getObjectProperty());
      } else
        throw new TypeError("Cannot apply index: unsupported type of object");
    } catch (i) {
      throw Ji(i);
    }
  };
}
var w_ = "AccessorNode", v6e = ["subset", "Node"], p6e = /* @__PURE__ */ Ce(w_, v6e, (e) => {
  var {
    subset: r,
    Node: t
  } = e, n = cY({
    subset: r
  });
  function a(o) {
    return !(Fd(o) || jo(o) || Jr(o) || hc(o) || qy(o) || sl(o) || _a(o));
  }
  class i extends t {
    /**
     * @constructor AccessorNode
     * @extends {Node}
     * Access an object property or get a matrix subset
     *
     * @param {Node} object                 The object from which to retrieve
     *                                      a property or subset.
     * @param {IndexNode} index             IndexNode containing ranges
     */
    constructor(c, s) {
      if (super(), !St(c))
        throw new TypeError('Node expected for parameter "object"');
      if (!em(s))
        throw new TypeError('IndexNode expected for parameter "index"');
      this.object = c, this.index = s;
    }
    // readonly property name
    get name() {
      return this.index ? this.index.isObjectProperty() ? this.index.getObjectProperty() : "" : this.object.name || "";
    }
    get type() {
      return w_;
    }
    get isAccessorNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(c, s) {
      var u = this.object._compile(c, s), l = this.index._compile(c, s);
      if (this.index.isObjectProperty()) {
        var f = this.index.getObjectProperty();
        return function(m, p, v) {
          return Ki(u(m, p, v), f);
        };
      } else
        return function(m, p, v) {
          var h = u(m, p, v), y = l(m, p, h);
          return n(h, y);
        };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(c) {
      c(this.object, "object", this), c(this.index, "index", this);
    }
    /**
     * Create a new AccessorNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {AccessorNode} Returns a transformed copy of the node
     */
    map(c) {
      return new i(this._ifNode(c(this.object, "object", this)), this._ifNode(c(this.index, "index", this)));
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {AccessorNode}
     */
    clone() {
      return new i(this.object, this.index);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string}
     */
    _toString(c) {
      var s = this.object.toString(c);
      return a(this.object) && (s = "(" + s + ")"), s + this.index.toString(c);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string}
     */
    _toHTML(c) {
      var s = this.object.toHTML(c);
      return a(this.object) && (s = '<span class="math-parenthesis math-round-parenthesis">(</span>' + s + '<span class="math-parenthesis math-round-parenthesis">)</span>'), s + this.index.toHTML(c);
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string}
     */
    _toTex(c) {
      var s = this.object.toTex(c);
      return a(this.object) && (s = "\\left(' + object + '\\right)"), s + this.index.toTex(c);
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: w_,
        object: this.object,
        index: this.index
      };
    }
    /**
     * Instantiate an AccessorNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     `{"mathjs": "AccessorNode", object: ..., index: ...}`,
     *     where mathjs is optional
     * @returns {AccessorNode}
     */
    static fromJSON(c) {
      return new i(c.object, c.index);
    }
  }
  return ba(i, "name", w_), i;
}, {
  isClass: !0,
  isNode: !0
}), E_ = "ArrayNode", h6e = ["Node"], g6e = /* @__PURE__ */ Ce(E_, h6e, (e) => {
  var {
    Node: r
  } = e;
  class t extends r {
    /**
     * @constructor ArrayNode
     * @extends {Node}
     * Holds an 1-dimensional array with items
     * @param {Node[]} [items]   1 dimensional array with items
     */
    constructor(a) {
      if (super(), this.items = a || [], !Array.isArray(this.items) || !this.items.every(St))
        throw new TypeError("Array containing Nodes expected");
    }
    get type() {
      return E_;
    }
    get isArrayNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(a, i) {
      var o = lc(this.items, function(u) {
        return u._compile(a, i);
      }), c = a.config.matrix !== "Array";
      if (c) {
        var s = a.matrix;
        return function(l, f, d) {
          return s(lc(o, function(m) {
            return m(l, f, d);
          }));
        };
      } else
        return function(l, f, d) {
          return lc(o, function(m) {
            return m(l, f, d);
          });
        };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(a) {
      for (var i = 0; i < this.items.length; i++) {
        var o = this.items[i];
        a(o, "items[" + i + "]", this);
      }
    }
    /**
     * Create a new ArrayNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {ArrayNode} Returns a transformed copy of the node
     */
    map(a) {
      for (var i = [], o = 0; o < this.items.length; o++)
        i[o] = this._ifNode(a(this.items[o], "items[" + o + "]", this));
      return new t(i);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {ArrayNode}
     */
    clone() {
      return new t(this.items.slice(0));
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toString(a) {
      var i = this.items.map(function(o) {
        return o.toString(a);
      });
      return "[" + i.join(", ") + "]";
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: E_,
        items: this.items
      };
    }
    /**
     * Instantiate an ArrayNode from its JSON representation
     * @param {Object} json  An object structured like
     *                       `{"mathjs": "ArrayNode", items: [...]}`,
     *                       where mathjs is optional
     * @returns {ArrayNode}
     */
    static fromJSON(a) {
      return new t(a.items);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toHTML(a) {
      var i = this.items.map(function(o) {
        return o.toHTML(a);
      });
      return '<span class="math-parenthesis math-square-parenthesis">[</span>' + i.join('<span class="math-separator">,</span>') + '<span class="math-parenthesis math-square-parenthesis">]</span>';
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(a) {
      function i(o, c) {
        var s = o.some(jo) && !o.every(jo), u = c || s, l = u ? "&" : "\\\\", f = o.map(function(d) {
          return d.items ? i(d.items, !c) : d.toTex(a);
        }).join(l);
        return s || !u || u && !c ? "\\begin{bmatrix}" + f + "\\end{bmatrix}" : f;
      }
      return i(this.items, !1);
    }
  }
  return ba(t, "name", E_), t;
}, {
  isClass: !0,
  isNode: !0
});
function y6e(e) {
  var {
    subset: r,
    matrix: t
  } = e;
  return function(a, i, o) {
    try {
      if (Array.isArray(a)) {
        var c = t(a).subset(i, o).valueOf();
        return c.forEach((s, u) => {
          a[u] = s;
        }), a;
      } else {
        if (a && typeof a.subset == "function")
          return a.subset(i, o);
        if (typeof a == "string")
          return r(a, i, o);
        if (typeof a == "object") {
          if (!i.isObjectProperty())
            throw TypeError("Cannot apply a numeric index as object property");
          return lp(a, i.getObjectProperty(), o), a;
        } else
          throw new TypeError("Cannot apply index: unsupported type of object");
      }
    } catch (s) {
      throw Ji(s);
    }
  };
}
var Yu = [{
  // assignment
  AssignmentNode: {},
  FunctionAssignmentNode: {}
}, {
  // conditional expression
  ConditionalNode: {
    latexLeftParens: !1,
    latexRightParens: !1,
    latexParens: !1
    // conditionals don't need parentheses in LaTeX because
    // they are 2 dimensional
  }
}, {
  // logical or
  "OperatorNode:or": {
    op: "or",
    associativity: "left",
    associativeWith: []
  }
}, {
  // logical xor
  "OperatorNode:xor": {
    op: "xor",
    associativity: "left",
    associativeWith: []
  }
}, {
  // logical and
  "OperatorNode:and": {
    op: "and",
    associativity: "left",
    associativeWith: []
  }
}, {
  // bitwise or
  "OperatorNode:bitOr": {
    op: "|",
    associativity: "left",
    associativeWith: []
  }
}, {
  // bitwise xor
  "OperatorNode:bitXor": {
    op: "^|",
    associativity: "left",
    associativeWith: []
  }
}, {
  // bitwise and
  "OperatorNode:bitAnd": {
    op: "&",
    associativity: "left",
    associativeWith: []
  }
}, {
  // relational operators
  "OperatorNode:equal": {
    op: "==",
    associativity: "left",
    associativeWith: []
  },
  "OperatorNode:unequal": {
    op: "!=",
    associativity: "left",
    associativeWith: []
  },
  "OperatorNode:smaller": {
    op: "<",
    associativity: "left",
    associativeWith: []
  },
  "OperatorNode:larger": {
    op: ">",
    associativity: "left",
    associativeWith: []
  },
  "OperatorNode:smallerEq": {
    op: "<=",
    associativity: "left",
    associativeWith: []
  },
  "OperatorNode:largerEq": {
    op: ">=",
    associativity: "left",
    associativeWith: []
  },
  RelationalNode: {
    associativity: "left",
    associativeWith: []
  }
}, {
  // bitshift operators
  "OperatorNode:leftShift": {
    op: "<<",
    associativity: "left",
    associativeWith: []
  },
  "OperatorNode:rightArithShift": {
    op: ">>",
    associativity: "left",
    associativeWith: []
  },
  "OperatorNode:rightLogShift": {
    op: ">>>",
    associativity: "left",
    associativeWith: []
  }
}, {
  // unit conversion
  "OperatorNode:to": {
    op: "to",
    associativity: "left",
    associativeWith: []
  }
}, {
  // range
  RangeNode: {}
}, {
  // addition, subtraction
  "OperatorNode:add": {
    op: "+",
    associativity: "left",
    associativeWith: ["OperatorNode:add", "OperatorNode:subtract"]
  },
  "OperatorNode:subtract": {
    op: "-",
    associativity: "left",
    associativeWith: []
  }
}, {
  // multiply, divide, modulus
  "OperatorNode:multiply": {
    op: "*",
    associativity: "left",
    associativeWith: ["OperatorNode:multiply", "OperatorNode:divide", "Operator:dotMultiply", "Operator:dotDivide"]
  },
  "OperatorNode:divide": {
    op: "/",
    associativity: "left",
    associativeWith: [],
    latexLeftParens: !1,
    latexRightParens: !1,
    latexParens: !1
    // fractions don't require parentheses because
    // they're 2 dimensional, so parens aren't needed
    // in LaTeX
  },
  "OperatorNode:dotMultiply": {
    op: ".*",
    associativity: "left",
    associativeWith: ["OperatorNode:multiply", "OperatorNode:divide", "OperatorNode:dotMultiply", "OperatorNode:doDivide"]
  },
  "OperatorNode:dotDivide": {
    op: "./",
    associativity: "left",
    associativeWith: []
  },
  "OperatorNode:mod": {
    op: "mod",
    associativity: "left",
    associativeWith: []
  }
}, {
  // Repeat multiplication for implicit multiplication
  "OperatorNode:multiply": {
    associativity: "left",
    associativeWith: ["OperatorNode:multiply", "OperatorNode:divide", "Operator:dotMultiply", "Operator:dotDivide"]
  }
}, {
  // unary prefix operators
  "OperatorNode:unaryPlus": {
    op: "+",
    associativity: "right"
  },
  "OperatorNode:unaryMinus": {
    op: "-",
    associativity: "right"
  },
  "OperatorNode:bitNot": {
    op: "~",
    associativity: "right"
  },
  "OperatorNode:not": {
    op: "not",
    associativity: "right"
  }
}, {
  // exponentiation
  "OperatorNode:pow": {
    op: "^",
    associativity: "right",
    associativeWith: [],
    latexRightParens: !1
    // the exponent doesn't need parentheses in
    // LaTeX because it's 2 dimensional
    // (it's on top)
  },
  "OperatorNode:dotPow": {
    op: ".^",
    associativity: "right",
    associativeWith: []
  }
}, {
  // factorial
  "OperatorNode:factorial": {
    op: "!",
    associativity: "left"
  }
}, {
  // matrix transpose
  "OperatorNode:ctranspose": {
    op: "'",
    associativity: "left"
  }
}];
function D_(e, r) {
  if (!r || r !== "auto") return e;
  for (var t = e; sl(t); ) t = t.content;
  return t;
}
function Mt(e, r, t, n) {
  var a = e;
  r !== "keep" && (a = e.getContent());
  for (var i = a.getIdentifier(), o = null, c = 0; c < Yu.length; c++)
    if (i in Yu[c]) {
      o = c;
      break;
    }
  if (i === "OperatorNode:multiply" && a.implicit && t !== "show") {
    var s = D_(a.args[0], r);
    !(Jr(s) && n && n.getIdentifier() === "OperatorNode:divide" && pw(D_(n.args[0], r))) && !(s.getIdentifier() === "OperatorNode:divide" && pw(D_(s.args[0], r)) && Jr(D_(s.args[1]))) && (o += 1);
  }
  return o;
}
function V1(e, r) {
  var t = e;
  r !== "keep" && (t = e.getContent());
  var n = t.getIdentifier(), a = Mt(t, r);
  if (a === null)
    return null;
  var i = Yu[a][n];
  if (er(i, "associativity")) {
    if (i.associativity === "left")
      return "left";
    if (i.associativity === "right")
      return "right";
    throw Error("'" + n + "' has the invalid associativity '" + i.associativity + "'.");
  }
  return null;
}
function PP(e, r, t) {
  var n = t !== "keep" ? e.getContent() : e, a = t !== "keep" ? e.getContent() : r, i = n.getIdentifier(), o = a.getIdentifier(), c = Mt(n, t);
  if (c === null)
    return null;
  var s = Yu[c][i];
  if (er(s, "associativeWith") && s.associativeWith instanceof Array) {
    for (var u = 0; u < s.associativeWith.length; u++)
      if (s.associativeWith[u] === o)
        return !0;
    return !1;
  }
  return null;
}
function _6e(e) {
  var r = "OperatorNode:" + e;
  for (var t of Yu)
    if (r in t)
      return t[r].op;
  return null;
}
var I_ = "AssignmentNode", b6e = [
  "subset",
  "?matrix",
  // FIXME: should not be needed at all, should be handled by subset
  "Node"
], S6e = /* @__PURE__ */ Ce(I_, b6e, (e) => {
  var {
    subset: r,
    matrix: t,
    Node: n
  } = e, a = cY({
    subset: r
  }), i = y6e({
    subset: r,
    matrix: t
  });
  function o(s, u, l) {
    u || (u = "keep");
    var f = Mt(s, u, l), d = Mt(s.value, u, l);
    return u === "all" || d !== null && d <= f;
  }
  class c extends n {
    /**
     * @constructor AssignmentNode
     * @extends {Node}
     *
     * Define a symbol, like `a=3.2`, update a property like `a.b=3.2`, or
     * replace a subset of a matrix like `A[2,2]=42`.
     *
     * Syntax:
     *
     *     new AssignmentNode(symbol, value)
     *     new AssignmentNode(object, index, value)
     *
     * Usage:
     *
     *    new AssignmentNode(new SymbolNode('a'), new ConstantNode(2))  // a=2
     *    new AssignmentNode(new SymbolNode('a'),
     *                       new IndexNode('b'),
     *                       new ConstantNode(2))   // a.b=2
     *    new AssignmentNode(new SymbolNode('a'),
     *                       new IndexNode(1, 2),
     *                       new ConstantNode(3))  // a[1,2]=3
     *
     * @param {SymbolNode | AccessorNode} object
     *     Object on which to assign a value
     * @param {IndexNode} [index=null]
     *     Index, property name or matrix index. Optional. If not provided
     *     and `object` is a SymbolNode, the property is assigned to the
     *     global scope.
     * @param {Node} value
     *     The value to be assigned
     */
    constructor(u, l, f) {
      if (super(), this.object = u, this.index = f ? l : null, this.value = f || l, !_a(u) && !Fd(u))
        throw new TypeError('SymbolNode or AccessorNode expected as "object"');
      if (_a(u) && u.name === "end")
        throw new Error('Cannot assign to symbol "end"');
      if (this.index && !em(this.index))
        throw new TypeError('IndexNode expected as "index"');
      if (!St(this.value))
        throw new TypeError('Node expected as "value"');
    }
    // class name for typing purposes:
    // readonly property name
    get name() {
      return this.index ? this.index.isObjectProperty() ? this.index.getObjectProperty() : "" : this.object.name || "";
    }
    get type() {
      return I_;
    }
    get isAssignmentNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(u, l) {
      var f = this.object._compile(u, l), d = this.index ? this.index._compile(u, l) : null, m = this.value._compile(u, l), p = this.object.name;
      if (this.index)
        if (this.index.isObjectProperty()) {
          var v = this.index.getObjectProperty();
          return function(b, g, _) {
            var A = f(b, g, _), M = m(b, g, _);
            return lp(A, v, M), M;
          };
        } else {
          if (_a(this.object))
            return function(b, g, _) {
              var A = f(b, g, _), M = m(b, g, _), P = d(b, g, A);
              return b.set(p, i(A, P, M)), M;
            };
          var h = this.object.object._compile(u, l);
          if (this.object.index.isObjectProperty()) {
            var y = this.object.index.getObjectProperty();
            return function(b, g, _) {
              var A = h(b, g, _), M = Ki(A, y), P = d(b, g, M), T = m(b, g, _);
              return lp(A, y, i(M, P, T)), T;
            };
          } else {
            var C = this.object.index._compile(u, l);
            return function(b, g, _) {
              var A = h(b, g, _), M = C(b, g, A), P = a(A, M), T = d(b, g, P), x = m(b, g, _);
              return i(A, M, i(P, T, x)), x;
            };
          }
        }
      else {
        if (!_a(this.object))
          throw new TypeError("SymbolNode expected as object");
        return function(b, g, _) {
          var A = m(b, g, _);
          return b.set(p, A), A;
        };
      }
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(u) {
      u(this.object, "object", this), this.index && u(this.index, "index", this), u(this.value, "value", this);
    }
    /**
     * Create a new AssignmentNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {AssignmentNode} Returns a transformed copy of the node
     */
    map(u) {
      var l = this._ifNode(u(this.object, "object", this)), f = this.index ? this._ifNode(u(this.index, "index", this)) : null, d = this._ifNode(u(this.value, "value", this));
      return new c(l, f, d);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {AssignmentNode}
     */
    clone() {
      return new c(this.object, this.index, this.value);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string}
     */
    _toString(u) {
      var l = this.object.toString(u), f = this.index ? this.index.toString(u) : "", d = this.value.toString(u);
      return o(this, u && u.parenthesis, u && u.implicit) && (d = "(" + d + ")"), l + f + " = " + d;
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: I_,
        object: this.object,
        index: this.index,
        value: this.value
      };
    }
    /**
     * Instantiate an AssignmentNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     `{"mathjs": "AssignmentNode", object: ..., index: ..., value: ...}`,
     *     where mathjs is optional
     * @returns {AssignmentNode}
     */
    static fromJSON(u) {
      return new c(u.object, u.index, u.value);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string}
     */
    _toHTML(u) {
      var l = this.object.toHTML(u), f = this.index ? this.index.toHTML(u) : "", d = this.value.toHTML(u);
      return o(this, u && u.parenthesis, u && u.implicit) && (d = '<span class="math-paranthesis math-round-parenthesis">(</span>' + d + '<span class="math-paranthesis math-round-parenthesis">)</span>'), l + f + '<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>' + d;
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string}
     */
    _toTex(u) {
      var l = this.object.toTex(u), f = this.index ? this.index.toTex(u) : "", d = this.value.toTex(u);
      return o(this, u && u.parenthesis, u && u.implicit) && (d = "\\left(".concat(d, "\\right)")), l + f + "=" + d;
    }
  }
  return ba(c, "name", I_), c;
}, {
  isClass: !0,
  isNode: !0
}), B_ = "BlockNode", C6e = ["ResultSet", "Node"], A6e = /* @__PURE__ */ Ce(B_, C6e, (e) => {
  var {
    ResultSet: r,
    Node: t
  } = e;
  class n extends t {
    /**
     * @constructor BlockNode
     * @extends {Node}
     * Holds a set with blocks
     * @param {Array.<{node: Node} | {node: Node, visible: boolean}>} blocks
     *            An array with blocks, where a block is constructed as an
     *            Object with properties block, which is a Node, and visible,
     *            which is a boolean. The property visible is optional and
     *            is true by default
     */
    constructor(i) {
      if (super(), !Array.isArray(i)) throw new Error("Array expected");
      this.blocks = i.map(function(o) {
        var c = o && o.node, s = o && o.visible !== void 0 ? o.visible : !0;
        if (!St(c)) throw new TypeError('Property "node" must be a Node');
        if (typeof s != "boolean")
          throw new TypeError('Property "visible" must be a boolean');
        return {
          node: c,
          visible: s
        };
      });
    }
    get type() {
      return B_;
    }
    get isBlockNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(i, o) {
      var c = lc(this.blocks, function(s) {
        return {
          evaluate: s.node._compile(i, o),
          visible: s.visible
        };
      });
      return function(u, l, f) {
        var d = [];
        return ux(c, function(p) {
          var v = p.evaluate(u, l, f);
          p.visible && d.push(v);
        }), new r(d);
      };
    }
    /**
     * Execute a callback for each of the child blocks of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(i) {
      for (var o = 0; o < this.blocks.length; o++)
        i(this.blocks[o].node, "blocks[" + o + "].node", this);
    }
    /**
     * Create a new BlockNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {BlockNode} Returns a transformed copy of the node
     */
    map(i) {
      for (var o = [], c = 0; c < this.blocks.length; c++) {
        var s = this.blocks[c], u = this._ifNode(i(s.node, "blocks[" + c + "].node", this));
        o[c] = {
          node: u,
          visible: s.visible
        };
      }
      return new n(o);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {BlockNode}
     */
    clone() {
      var i = this.blocks.map(function(o) {
        return {
          node: o.node,
          visible: o.visible
        };
      });
      return new n(i);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toString(i) {
      return this.blocks.map(function(o) {
        return o.node.toString(i) + (o.visible ? "" : ";");
      }).join(`
`);
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: B_,
        blocks: this.blocks
      };
    }
    /**
     * Instantiate an BlockNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     `{"mathjs": "BlockNode", blocks: [{node: ..., visible: false}, ...]}`,
     *     where mathjs is optional
     * @returns {BlockNode}
     */
    static fromJSON(i) {
      return new n(i.blocks);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toHTML(i) {
      return this.blocks.map(function(o) {
        return o.node.toHTML(i) + (o.visible ? "" : '<span class="math-separator">;</span>');
      }).join('<span class="math-separator"><br /></span>');
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(i) {
      return this.blocks.map(function(o) {
        return o.node.toTex(i) + (o.visible ? "" : ";");
      }).join(`\\;\\;
`);
    }
  }
  return ba(n, "name", B_), n;
}, {
  isClass: !0,
  isNode: !0
}), N_ = "ConditionalNode", x6e = ["Node"], T6e = /* @__PURE__ */ Ce(N_, x6e, (e) => {
  var {
    Node: r
  } = e;
  function t(a) {
    if (typeof a == "number" || typeof a == "boolean" || typeof a == "string")
      return !!a;
    if (a) {
      if (Ir(a))
        return !a.isZero();
      if (as(a))
        return !!(a.re || a.im);
      if (ho(a))
        return !!a.value;
    }
    if (a == null)
      return !1;
    throw new TypeError('Unsupported type of condition "' + Et(a) + '"');
  }
  class n extends r {
    /**
     * A lazy evaluating conditional operator: 'condition ? trueExpr : falseExpr'
     *
     * @param {Node} condition   Condition, must result in a boolean
     * @param {Node} trueExpr    Expression evaluated when condition is true
     * @param {Node} falseExpr   Expression evaluated when condition is true
     *
     * @constructor ConditionalNode
     * @extends {Node}
     */
    constructor(i, o, c) {
      if (super(), !St(i))
        throw new TypeError("Parameter condition must be a Node");
      if (!St(o))
        throw new TypeError("Parameter trueExpr must be a Node");
      if (!St(c))
        throw new TypeError("Parameter falseExpr must be a Node");
      this.condition = i, this.trueExpr = o, this.falseExpr = c;
    }
    get type() {
      return N_;
    }
    get isConditionalNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(i, o) {
      var c = this.condition._compile(i, o), s = this.trueExpr._compile(i, o), u = this.falseExpr._compile(i, o);
      return function(f, d, m) {
        return t(c(f, d, m)) ? s(f, d, m) : u(f, d, m);
      };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(i) {
      i(this.condition, "condition", this), i(this.trueExpr, "trueExpr", this), i(this.falseExpr, "falseExpr", this);
    }
    /**
     * Create a new ConditionalNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {ConditionalNode} Returns a transformed copy of the node
     */
    map(i) {
      return new n(this._ifNode(i(this.condition, "condition", this)), this._ifNode(i(this.trueExpr, "trueExpr", this)), this._ifNode(i(this.falseExpr, "falseExpr", this)));
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {ConditionalNode}
     */
    clone() {
      return new n(this.condition, this.trueExpr, this.falseExpr);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     */
    _toString(i) {
      var o = i && i.parenthesis ? i.parenthesis : "keep", c = Mt(this, o, i && i.implicit), s = this.condition.toString(i), u = Mt(this.condition, o, i && i.implicit);
      (o === "all" || this.condition.type === "OperatorNode" || u !== null && u <= c) && (s = "(" + s + ")");
      var l = this.trueExpr.toString(i), f = Mt(this.trueExpr, o, i && i.implicit);
      (o === "all" || this.trueExpr.type === "OperatorNode" || f !== null && f <= c) && (l = "(" + l + ")");
      var d = this.falseExpr.toString(i), m = Mt(this.falseExpr, o, i && i.implicit);
      return (o === "all" || this.falseExpr.type === "OperatorNode" || m !== null && m <= c) && (d = "(" + d + ")"), s + " ? " + l + " : " + d;
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: N_,
        condition: this.condition,
        trueExpr: this.trueExpr,
        falseExpr: this.falseExpr
      };
    }
    /**
     * Instantiate an ConditionalNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     ```
     *     {"mathjs": "ConditionalNode",
     *      "condition": ...,
     *      "trueExpr": ...,
     *      "falseExpr": ...}
     *     ```
     *     where mathjs is optional
     * @returns {ConditionalNode}
     */
    static fromJSON(i) {
      return new n(i.condition, i.trueExpr, i.falseExpr);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     */
    _toHTML(i) {
      var o = i && i.parenthesis ? i.parenthesis : "keep", c = Mt(this, o, i && i.implicit), s = this.condition.toHTML(i), u = Mt(this.condition, o, i && i.implicit);
      (o === "all" || this.condition.type === "OperatorNode" || u !== null && u <= c) && (s = '<span class="math-parenthesis math-round-parenthesis">(</span>' + s + '<span class="math-parenthesis math-round-parenthesis">)</span>');
      var l = this.trueExpr.toHTML(i), f = Mt(this.trueExpr, o, i && i.implicit);
      (o === "all" || this.trueExpr.type === "OperatorNode" || f !== null && f <= c) && (l = '<span class="math-parenthesis math-round-parenthesis">(</span>' + l + '<span class="math-parenthesis math-round-parenthesis">)</span>');
      var d = this.falseExpr.toHTML(i), m = Mt(this.falseExpr, o, i && i.implicit);
      return (o === "all" || this.falseExpr.type === "OperatorNode" || m !== null && m <= c) && (d = '<span class="math-parenthesis math-round-parenthesis">(</span>' + d + '<span class="math-parenthesis math-round-parenthesis">)</span>'), s + '<span class="math-operator math-conditional-operator">?</span>' + l + '<span class="math-operator math-conditional-operator">:</span>' + d;
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(i) {
      return "\\begin{cases} {" + this.trueExpr.toTex(i) + "}, &\\quad{\\text{if }\\;" + this.condition.toTex(i) + "}\\\\{" + this.falseExpr.toTex(i) + "}, &\\quad{\\text{otherwise}}\\end{cases}";
    }
  }
  return ba(n, "name", N_), n;
}, {
  isClass: !0,
  isNode: !0
}), Nw = Object.assign || function(e) {
  for (var r = 1; r < arguments.length; r++) {
    var t = arguments[r];
    for (var n in t)
      Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
  }
  return e;
}, P6e = {
  "{": "\\{",
  "}": "\\}",
  "\\": "\\textbackslash{}",
  "#": "\\#",
  $: "\\$",
  "%": "\\%",
  "&": "\\&",
  "^": "\\textasciicircum{}",
  _: "\\_",
  "~": "\\textasciitilde{}"
}, M6e = {
  "–": "\\--",
  "—": "\\---",
  " ": "~",
  "	": "\\qquad{}",
  "\r\n": "\\newline{}",
  "\n": "\\newline{}"
}, w6e = function(r, t) {
  return Nw({}, r, t);
}, E6e = function(e) {
  for (var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, t = r.preserveFormatting, n = t === void 0 ? !1 : t, a = r.escapeMapFn, i = a === void 0 ? w6e : a, o = String(e), c = "", s = i(Nw({}, P6e), n ? Nw({}, M6e) : {}), u = Object.keys(s), l = function() {
    var d = !1;
    u.forEach(function(m, p) {
      d || o.length >= m.length && o.slice(0, m.length) === m && (c += s[u[p]], o = o.slice(m.length, o.length), d = !0);
    }), d || (c += o.slice(0, 1), o = o.slice(1, o.length));
  }; o; )
    l();
  return c;
};
const D6e = /* @__PURE__ */ qg(E6e);
var Vw = {
  // GREEK LETTERS
  Alpha: "A",
  alpha: "\\alpha",
  Beta: "B",
  beta: "\\beta",
  Gamma: "\\Gamma",
  gamma: "\\gamma",
  Delta: "\\Delta",
  delta: "\\delta",
  Epsilon: "E",
  epsilon: "\\epsilon",
  varepsilon: "\\varepsilon",
  Zeta: "Z",
  zeta: "\\zeta",
  Eta: "H",
  eta: "\\eta",
  Theta: "\\Theta",
  theta: "\\theta",
  vartheta: "\\vartheta",
  Iota: "I",
  iota: "\\iota",
  Kappa: "K",
  kappa: "\\kappa",
  varkappa: "\\varkappa",
  Lambda: "\\Lambda",
  lambda: "\\lambda",
  Mu: "M",
  mu: "\\mu",
  Nu: "N",
  nu: "\\nu",
  Xi: "\\Xi",
  xi: "\\xi",
  Omicron: "O",
  omicron: "o",
  Pi: "\\Pi",
  pi: "\\pi",
  varpi: "\\varpi",
  Rho: "P",
  rho: "\\rho",
  varrho: "\\varrho",
  Sigma: "\\Sigma",
  sigma: "\\sigma",
  varsigma: "\\varsigma",
  Tau: "T",
  tau: "\\tau",
  Upsilon: "\\Upsilon",
  upsilon: "\\upsilon",
  Phi: "\\Phi",
  phi: "\\phi",
  varphi: "\\varphi",
  Chi: "X",
  chi: "\\chi",
  Psi: "\\Psi",
  psi: "\\psi",
  Omega: "\\Omega",
  omega: "\\omega",
  // logic
  true: "\\mathrm{True}",
  false: "\\mathrm{False}",
  // other
  i: "i",
  // TODO use \i ??
  inf: "\\infty",
  Inf: "\\infty",
  infinity: "\\infty",
  Infinity: "\\infty",
  oo: "\\infty",
  lim: "\\lim",
  undefined: "\\mathbf{?}"
}, ot = {
  transpose: "^\\top",
  ctranspose: "^H",
  factorial: "!",
  pow: "^",
  dotPow: ".^\\wedge",
  // TODO find ideal solution
  unaryPlus: "+",
  unaryMinus: "-",
  bitNot: "\\~",
  // TODO find ideal solution
  not: "\\neg",
  multiply: "\\cdot",
  divide: "\\frac",
  // TODO how to handle that properly?
  dotMultiply: ".\\cdot",
  // TODO find ideal solution
  dotDivide: ".:",
  // TODO find ideal solution
  mod: "\\mod",
  add: "+",
  subtract: "-",
  to: "\\rightarrow",
  leftShift: "<<",
  rightArithShift: ">>",
  rightLogShift: ">>>",
  equal: "=",
  unequal: "\\neq",
  smaller: "<",
  larger: ">",
  smallerEq: "\\leq",
  largerEq: "\\geq",
  bitAnd: "\\&",
  bitXor: "\\underline{|}",
  bitOr: "|",
  and: "\\wedge",
  xor: "\\veebar",
  or: "\\vee"
}, CL = {
  // arithmetic
  abs: {
    1: "\\left|${args[0]}\\right|"
  },
  add: {
    2: "\\left(${args[0]}".concat(ot.add, "${args[1]}\\right)")
  },
  cbrt: {
    1: "\\sqrt[3]{${args[0]}}"
  },
  ceil: {
    1: "\\left\\lceil${args[0]}\\right\\rceil"
  },
  cube: {
    1: "\\left(${args[0]}\\right)^3"
  },
  divide: {
    2: "\\frac{${args[0]}}{${args[1]}}"
  },
  dotDivide: {
    2: "\\left(${args[0]}".concat(ot.dotDivide, "${args[1]}\\right)")
  },
  dotMultiply: {
    2: "\\left(${args[0]}".concat(ot.dotMultiply, "${args[1]}\\right)")
  },
  dotPow: {
    2: "\\left(${args[0]}".concat(ot.dotPow, "${args[1]}\\right)")
  },
  exp: {
    1: "\\exp\\left(${args[0]}\\right)"
  },
  expm1: "\\left(e".concat(ot.pow, "{${args[0]}}-1\\right)"),
  fix: {
    1: "\\mathrm{${name}}\\left(${args[0]}\\right)"
  },
  floor: {
    1: "\\left\\lfloor${args[0]}\\right\\rfloor"
  },
  gcd: "\\gcd\\left(${args}\\right)",
  hypot: "\\hypot\\left(${args}\\right)",
  log: {
    1: "\\ln\\left(${args[0]}\\right)",
    2: "\\log_{${args[1]}}\\left(${args[0]}\\right)"
  },
  log10: {
    1: "\\log_{10}\\left(${args[0]}\\right)"
  },
  log1p: {
    1: "\\ln\\left(${args[0]}+1\\right)",
    2: "\\log_{${args[1]}}\\left(${args[0]}+1\\right)"
  },
  log2: "\\log_{2}\\left(${args[0]}\\right)",
  mod: {
    2: "\\left(${args[0]}".concat(ot.mod, "${args[1]}\\right)")
  },
  multiply: {
    2: "\\left(${args[0]}".concat(ot.multiply, "${args[1]}\\right)")
  },
  norm: {
    1: "\\left\\|${args[0]}\\right\\|",
    2: void 0
    // use default template
  },
  nthRoot: {
    2: "\\sqrt[${args[1]}]{${args[0]}}"
  },
  nthRoots: {
    2: "\\{y : $y^{args[1]} = {${args[0]}}\\}"
  },
  pow: {
    2: "\\left(${args[0]}\\right)".concat(ot.pow, "{${args[1]}}")
  },
  round: {
    1: "\\left\\lfloor${args[0]}\\right\\rceil",
    2: void 0
    // use default template
  },
  sign: {
    1: "\\mathrm{${name}}\\left(${args[0]}\\right)"
  },
  sqrt: {
    1: "\\sqrt{${args[0]}}"
  },
  square: {
    1: "\\left(${args[0]}\\right)^2"
  },
  subtract: {
    2: "\\left(${args[0]}".concat(ot.subtract, "${args[1]}\\right)")
  },
  unaryMinus: {
    1: "".concat(ot.unaryMinus, "\\left(${args[0]}\\right)")
  },
  unaryPlus: {
    1: "".concat(ot.unaryPlus, "\\left(${args[0]}\\right)")
  },
  // bitwise
  bitAnd: {
    2: "\\left(${args[0]}".concat(ot.bitAnd, "${args[1]}\\right)")
  },
  bitNot: {
    1: ot.bitNot + "\\left(${args[0]}\\right)"
  },
  bitOr: {
    2: "\\left(${args[0]}".concat(ot.bitOr, "${args[1]}\\right)")
  },
  bitXor: {
    2: "\\left(${args[0]}".concat(ot.bitXor, "${args[1]}\\right)")
  },
  leftShift: {
    2: "\\left(${args[0]}".concat(ot.leftShift, "${args[1]}\\right)")
  },
  rightArithShift: {
    2: "\\left(${args[0]}".concat(ot.rightArithShift, "${args[1]}\\right)")
  },
  rightLogShift: {
    2: "\\left(${args[0]}".concat(ot.rightLogShift, "${args[1]}\\right)")
  },
  // combinatorics
  bellNumbers: {
    1: "\\mathrm{B}_{${args[0]}}"
  },
  catalan: {
    1: "\\mathrm{C}_{${args[0]}}"
  },
  stirlingS2: {
    2: "\\mathrm{S}\\left(${args}\\right)"
  },
  // complex
  arg: {
    1: "\\arg\\left(${args[0]}\\right)"
  },
  conj: {
    1: "\\left(${args[0]}\\right)^*"
  },
  im: {
    1: "\\Im\\left\\lbrace${args[0]}\\right\\rbrace"
  },
  re: {
    1: "\\Re\\left\\lbrace${args[0]}\\right\\rbrace"
  },
  // logical
  and: {
    2: "\\left(${args[0]}".concat(ot.and, "${args[1]}\\right)")
  },
  not: {
    1: ot.not + "\\left(${args[0]}\\right)"
  },
  or: {
    2: "\\left(${args[0]}".concat(ot.or, "${args[1]}\\right)")
  },
  xor: {
    2: "\\left(${args[0]}".concat(ot.xor, "${args[1]}\\right)")
  },
  // matrix
  cross: {
    2: "\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"
  },
  ctranspose: {
    1: "\\left(${args[0]}\\right)".concat(ot.ctranspose)
  },
  det: {
    1: "\\det\\left(${args[0]}\\right)"
  },
  dot: {
    2: "\\left(${args[0]}\\cdot${args[1]}\\right)"
  },
  expm: {
    1: "\\exp\\left(${args[0]}\\right)"
  },
  inv: {
    1: "\\left(${args[0]}\\right)^{-1}"
  },
  pinv: {
    1: "\\left(${args[0]}\\right)^{+}"
  },
  sqrtm: {
    1: "{${args[0]}}".concat(ot.pow, "{\\frac{1}{2}}")
  },
  trace: {
    1: "\\mathrm{tr}\\left(${args[0]}\\right)"
  },
  transpose: {
    1: "\\left(${args[0]}\\right)".concat(ot.transpose)
  },
  // probability
  combinations: {
    2: "\\binom{${args[0]}}{${args[1]}}"
  },
  combinationsWithRep: {
    2: "\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"
  },
  factorial: {
    1: "\\left(${args[0]}\\right)".concat(ot.factorial)
  },
  gamma: {
    1: "\\Gamma\\left(${args[0]}\\right)"
  },
  lgamma: {
    1: "\\ln\\Gamma\\left(${args[0]}\\right)"
  },
  // relational
  equal: {
    2: "\\left(${args[0]}".concat(ot.equal, "${args[1]}\\right)")
  },
  larger: {
    2: "\\left(${args[0]}".concat(ot.larger, "${args[1]}\\right)")
  },
  largerEq: {
    2: "\\left(${args[0]}".concat(ot.largerEq, "${args[1]}\\right)")
  },
  smaller: {
    2: "\\left(${args[0]}".concat(ot.smaller, "${args[1]}\\right)")
  },
  smallerEq: {
    2: "\\left(${args[0]}".concat(ot.smallerEq, "${args[1]}\\right)")
  },
  unequal: {
    2: "\\left(${args[0]}".concat(ot.unequal, "${args[1]}\\right)")
  },
  // special
  erf: {
    1: "erf\\left(${args[0]}\\right)"
  },
  // statistics
  max: "\\max\\left(${args}\\right)",
  min: "\\min\\left(${args}\\right)",
  variance: "\\mathrm{Var}\\left(${args}\\right)",
  // trigonometry
  acos: {
    1: "\\cos^{-1}\\left(${args[0]}\\right)"
  },
  acosh: {
    1: "\\cosh^{-1}\\left(${args[0]}\\right)"
  },
  acot: {
    1: "\\cot^{-1}\\left(${args[0]}\\right)"
  },
  acoth: {
    1: "\\coth^{-1}\\left(${args[0]}\\right)"
  },
  acsc: {
    1: "\\csc^{-1}\\left(${args[0]}\\right)"
  },
  acsch: {
    1: "\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"
  },
  asec: {
    1: "\\sec^{-1}\\left(${args[0]}\\right)"
  },
  asech: {
    1: "\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"
  },
  asin: {
    1: "\\sin^{-1}\\left(${args[0]}\\right)"
  },
  asinh: {
    1: "\\sinh^{-1}\\left(${args[0]}\\right)"
  },
  atan: {
    1: "\\tan^{-1}\\left(${args[0]}\\right)"
  },
  atan2: {
    2: "\\mathrm{atan2}\\left(${args}\\right)"
  },
  atanh: {
    1: "\\tanh^{-1}\\left(${args[0]}\\right)"
  },
  cos: {
    1: "\\cos\\left(${args[0]}\\right)"
  },
  cosh: {
    1: "\\cosh\\left(${args[0]}\\right)"
  },
  cot: {
    1: "\\cot\\left(${args[0]}\\right)"
  },
  coth: {
    1: "\\coth\\left(${args[0]}\\right)"
  },
  csc: {
    1: "\\csc\\left(${args[0]}\\right)"
  },
  csch: {
    1: "\\mathrm{csch}\\left(${args[0]}\\right)"
  },
  sec: {
    1: "\\sec\\left(${args[0]}\\right)"
  },
  sech: {
    1: "\\mathrm{sech}\\left(${args[0]}\\right)"
  },
  sin: {
    1: "\\sin\\left(${args[0]}\\right)"
  },
  sinh: {
    1: "\\sinh\\left(${args[0]}\\right)"
  },
  tan: {
    1: "\\tan\\left(${args[0]}\\right)"
  },
  tanh: {
    1: "\\tanh\\left(${args[0]}\\right)"
  },
  // unit
  to: {
    2: "\\left(${args[0]}".concat(ot.to, "${args[1]}\\right)")
  },
  // utils
  numeric: function(r, t) {
    return r.args[0].toTex();
  },
  // type
  number: {
    0: "0",
    1: "\\left(${args[0]}\\right)",
    2: "\\left(\\left(${args[0]}\\right)${args[1]}\\right)"
  },
  string: {
    0: '\\mathtt{""}',
    1: "\\mathrm{string}\\left(${args[0]}\\right)"
  },
  bignumber: {
    0: "0",
    1: "\\left(${args[0]}\\right)"
  },
  bigint: {
    0: "0",
    1: "\\left(${args[0]}\\right)"
  },
  complex: {
    0: "0",
    1: "\\left(${args[0]}\\right)",
    2: "\\left(\\left(${args[0]}\\right)+".concat(Vw.i, "\\cdot\\left(${args[1]}\\right)\\right)")
  },
  matrix: {
    0: "\\begin{bmatrix}\\end{bmatrix}",
    1: "\\left(${args[0]}\\right)",
    2: "\\left(${args[0]}\\right)"
  },
  sparse: {
    0: "\\begin{bsparse}\\end{bsparse}",
    1: "\\left(${args[0]}\\right)"
  },
  unit: {
    1: "\\left(${args[0]}\\right)",
    2: "\\left(\\left(${args[0]}\\right)${args[1]}\\right)"
  }
}, I6e = "\\mathrm{${name}}\\left(${args}\\right)", AL = {
  deg: "^\\circ"
};
function Rw(e) {
  return D6e(e, {
    preserveFormatting: !0
  });
}
function dY(e, r) {
  return r = typeof r > "u" ? !1 : r, r ? er(AL, e) ? AL[e] : "\\mathrm{" + Rw(e) + "}" : er(Vw, e) ? Vw[e] : Rw(e);
}
var V_ = "ConstantNode", B6e = ["Node"], N6e = /* @__PURE__ */ Ce(V_, B6e, (e) => {
  var {
    Node: r
  } = e;
  class t extends r {
    /**
     * A ConstantNode holds a constant value like a number or string.
     *
     * Usage:
     *
     *     new ConstantNode(2.3)
     *     new ConstantNode('hello')
     *
     * @param {*} value    Value can be any type (number, BigNumber, bigint, string, ...)
     * @constructor ConstantNode
     * @extends {Node}
     */
    constructor(a) {
      super(), this.value = a;
    }
    get type() {
      return V_;
    }
    get isConstantNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(a, i) {
      var o = this.value;
      return function() {
        return o;
      };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(a) {
    }
    /**
     * Create a new ConstantNode with children produced by the given callback.
     * Trivial because there are no children.
     * @param {function(child: Node, path: string, parent: Node) : Node} callback
     * @returns {ConstantNode} Returns a clone of the node
     */
    map(a) {
      return this.clone();
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {ConstantNode}
     */
    clone() {
      return new t(this.value);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     */
    _toString(a) {
      return $r(this.value, a);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     */
    _toHTML(a) {
      var i = this._toString(a);
      switch (Et(this.value)) {
        case "number":
        case "bigint":
        case "BigNumber":
        case "Fraction":
          return '<span class="math-number">' + i + "</span>";
        case "string":
          return '<span class="math-string">' + i + "</span>";
        case "boolean":
          return '<span class="math-boolean">' + i + "</span>";
        case "null":
          return '<span class="math-null-symbol">' + i + "</span>";
        case "undefined":
          return '<span class="math-undefined">' + i + "</span>";
        default:
          return '<span class="math-symbol">' + i + "</span>";
      }
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: V_,
        value: this.value
      };
    }
    /**
     * Instantiate a ConstantNode from its JSON representation
     * @param {Object} json  An object structured like
     *                       `{"mathjs": "SymbolNode", value: 2.3}`,
     *                       where mathjs is optional
     * @returns {ConstantNode}
     */
    static fromJSON(a) {
      return new t(a.value);
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(a) {
      var i = this._toString(a), o = Et(this.value);
      switch (o) {
        case "string":
          return "\\mathtt{" + Rw(i) + "}";
        case "number":
        case "BigNumber": {
          var c = o === "BigNumber" ? this.value.isFinite() : isFinite(this.value);
          if (!c)
            return this.value.valueOf() < 0 ? "-\\infty" : "\\infty";
          var s = i.toLowerCase().indexOf("e");
          return s !== -1 ? i.substring(0, s) + "\\cdot10^{" + i.substring(s + 1) + "}" : i;
        }
        case "bigint":
          return i.toString();
        case "Fraction":
          return this.value.toLatex();
        default:
          return i;
      }
    }
  }
  return ba(t, "name", V_), t;
}, {
  isClass: !0,
  isNode: !0
}), R_ = "FunctionAssignmentNode", V6e = ["typed", "Node"], R6e = /* @__PURE__ */ Ce(R_, V6e, (e) => {
  var {
    typed: r,
    Node: t
  } = e;
  function n(i, o, c) {
    var s = Mt(i, o, c), u = Mt(i.expr, o, c);
    return o === "all" || u !== null && u <= s;
  }
  class a extends t {
    /**
     * @constructor FunctionAssignmentNode
     * @extends {Node}
     * Function assignment
     *
     * @param {string} name           Function name
     * @param {string[] | Array.<{name: string, type: string}>} params
     *                                Array with function parameter names, or an
     *                                array with objects containing the name
     *                                and type of the parameter
     * @param {Node} expr             The function expression
     */
    constructor(o, c, s) {
      if (super(), typeof o != "string")
        throw new TypeError('String expected for parameter "name"');
      if (!Array.isArray(c))
        throw new TypeError('Array containing strings or objects expected for parameter "params"');
      if (!St(s))
        throw new TypeError('Node expected for parameter "expr"');
      if (lY.has(o))
        throw new Error('Illegal function name, "' + o + '" is a reserved keyword');
      var u = /* @__PURE__ */ new Set();
      for (var l of c) {
        var f = typeof l == "string" ? l : l.name;
        if (u.has(f))
          throw new Error('Duplicate parameter name "'.concat(f, '"'));
        u.add(f);
      }
      this.name = o, this.params = c.map(function(d) {
        return d && d.name || d;
      }), this.types = c.map(function(d) {
        return d && d.type || "any";
      }), this.expr = s;
    }
    get type() {
      return R_;
    }
    get isFunctionAssignmentNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(o, c) {
      var s = Object.create(c);
      ux(this.params, function(p) {
        s[p] = !0;
      });
      var u = this.expr._compile(o, s), l = this.name, f = this.params, d = xR(this.types, ","), m = l + "(" + xR(this.params, ", ") + ")";
      return function(v, h, y) {
        var C = {};
        C[d] = function() {
          for (var b = Object.create(h), g = 0; g < f.length; g++)
            b[f[g]] = arguments[g];
          return u(v, b, y);
        };
        var S = r(l, C);
        return S.syntax = m, v.set(l, S), S;
      };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(o) {
      o(this.expr, "expr", this);
    }
    /**
     * Create a new FunctionAssignmentNode whose children are the results of
     * calling the provided callback function for each child of the original
     * node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {FunctionAssignmentNode} Returns a transformed copy of the node
     */
    map(o) {
      var c = this._ifNode(o(this.expr, "expr", this));
      return new a(this.name, this.params.slice(0), c);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {FunctionAssignmentNode}
     */
    clone() {
      return new a(this.name, this.params.slice(0), this.expr);
    }
    /**
     * get string representation
     * @param {Object} options
     * @return {string} str
     */
    _toString(o) {
      var c = o && o.parenthesis ? o.parenthesis : "keep", s = this.expr.toString(o);
      return n(this, c, o && o.implicit) && (s = "(" + s + ")"), this.name + "(" + this.params.join(", ") + ") = " + s;
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      var o = this.types;
      return {
        mathjs: R_,
        name: this.name,
        params: this.params.map(function(c, s) {
          return {
            name: c,
            type: o[s]
          };
        }),
        expr: this.expr
      };
    }
    /**
     * Instantiate an FunctionAssignmentNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     ```
     *     {"mathjs": "FunctionAssignmentNode",
     *      name: ..., params: ..., expr: ...}
     *     ```
     *     where mathjs is optional
     * @returns {FunctionAssignmentNode}
     */
    static fromJSON(o) {
      return new a(o.name, o.params, o.expr);
    }
    /**
     * get HTML representation
     * @param {Object} options
     * @return {string} str
     */
    _toHTML(o) {
      for (var c = o && o.parenthesis ? o.parenthesis : "keep", s = [], u = 0; u < this.params.length; u++)
        s.push('<span class="math-symbol math-parameter">' + Pu(this.params[u]) + "</span>");
      var l = this.expr.toHTML(o);
      return n(this, c, o && o.implicit) && (l = '<span class="math-parenthesis math-round-parenthesis">(</span>' + l + '<span class="math-parenthesis math-round-parenthesis">)</span>'), '<span class="math-function">' + Pu(this.name) + '</span><span class="math-parenthesis math-round-parenthesis">(</span>' + s.join('<span class="math-separator">,</span>') + '<span class="math-parenthesis math-round-parenthesis">)</span><span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>' + l;
    }
    /**
     * get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(o) {
      var c = o && o.parenthesis ? o.parenthesis : "keep", s = this.expr.toTex(o);
      return n(this, c, o && o.implicit) && (s = "\\left(".concat(s, "\\right)")), "\\mathrm{" + this.name + "}\\left(" + this.params.map(dY).join(",") + "\\right)=" + s;
    }
  }
  return ba(a, "name", R_), a;
}, {
  isClass: !0,
  isNode: !0
}), O_ = "IndexNode", O6e = ["Node", "size"], F6e = /* @__PURE__ */ Ce(O_, O6e, (e) => {
  var {
    Node: r,
    size: t
  } = e;
  class n extends r {
    /**
     * @constructor IndexNode
     * @extends Node
     *
     * Describes a subset of a matrix or an object property.
     * Cannot be used on its own, needs to be used within an AccessorNode or
     * AssignmentNode.
     *
     * @param {Node[]} dimensions
     * @param {boolean} [dotNotation=false]
     *     Optional property describing whether this index was written using dot
     *     notation like `a.b`, or using bracket notation like `a["b"]`
     *     (which is the default). This property is used for string conversion.
     */
    constructor(i, o) {
      if (super(), this.dimensions = i, this.dotNotation = o || !1, !Array.isArray(i) || !i.every(St))
        throw new TypeError('Array containing Nodes expected for parameter "dimensions"');
      if (this.dotNotation && !this.isObjectProperty())
        throw new Error("dotNotation only applicable for object properties");
    }
    get type() {
      return O_;
    }
    get isIndexNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(i, o) {
      var c = lc(this.dimensions, function(u, l) {
        var f = u.filter((p) => p.isSymbolNode && p.name === "end").length > 0;
        if (f) {
          var d = Object.create(o);
          d.end = !0;
          var m = u._compile(i, d);
          return function(v, h, y) {
            if (!gr(y) && !dt(y) && !Ya(y))
              throw new TypeError('Cannot resolve "end": context must be a Matrix, Array, or string but is ' + Et(y));
            var C = t(y).valueOf(), S = Object.create(h);
            return S.end = C[l], m(v, S, y);
          };
        } else
          return u._compile(i, o);
      }), s = Ki(i, "index");
      return function(l, f, d) {
        var m = lc(c, function(p) {
          return p(l, f, d);
        });
        return s(...m);
      };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(i) {
      for (var o = 0; o < this.dimensions.length; o++)
        i(this.dimensions[o], "dimensions[" + o + "]", this);
    }
    /**
     * Create a new IndexNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {IndexNode} Returns a transformed copy of the node
     */
    map(i) {
      for (var o = [], c = 0; c < this.dimensions.length; c++)
        o[c] = this._ifNode(i(this.dimensions[c], "dimensions[" + c + "]", this));
      return new n(o, this.dotNotation);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {IndexNode}
     */
    clone() {
      return new n(this.dimensions.slice(0), this.dotNotation);
    }
    /**
     * Test whether this IndexNode contains a single property name
     * @return {boolean}
     */
    isObjectProperty() {
      return this.dimensions.length === 1 && Jr(this.dimensions[0]) && typeof this.dimensions[0].value == "string";
    }
    /**
     * Returns the property name if IndexNode contains a property.
     * If not, returns null.
     * @return {string | null}
     */
    getObjectProperty() {
      return this.isObjectProperty() ? this.dimensions[0].value : null;
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     */
    _toString(i) {
      return this.dotNotation ? "." + this.getObjectProperty() : "[" + this.dimensions.join(", ") + "]";
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: O_,
        dimensions: this.dimensions,
        dotNotation: this.dotNotation
      };
    }
    /**
     * Instantiate an IndexNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     `{"mathjs": "IndexNode", dimensions: [...], dotNotation: false}`,
     *     where mathjs is optional
     * @returns {IndexNode}
     */
    static fromJSON(i) {
      return new n(i.dimensions, i.dotNotation);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     */
    _toHTML(i) {
      for (var o = [], c = 0; c < this.dimensions.length; c++)
        o[c] = this.dimensions[c].toHTML();
      return this.dotNotation ? '<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">' + Pu(this.getObjectProperty()) + "</span>" : '<span class="math-parenthesis math-square-parenthesis">[</span>' + o.join('<span class="math-separator">,</span>') + '<span class="math-parenthesis math-square-parenthesis">]</span>';
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(i) {
      var o = this.dimensions.map(function(c) {
        return c.toTex(i);
      });
      return this.dotNotation ? "." + this.getObjectProperty() : "_{" + o.join(",") + "}";
    }
  }
  return ba(n, "name", O_), n;
}, {
  isClass: !0,
  isNode: !0
}), F_ = "ObjectNode", L6e = ["Node"], k6e = /* @__PURE__ */ Ce(F_, L6e, (e) => {
  var {
    Node: r
  } = e;
  class t extends r {
    /**
     * @constructor ObjectNode
     * @extends {Node}
     * Holds an object with keys/values
     * @param {Object.<string, Node>} [properties]   object with key/value pairs
     */
    constructor(a) {
      if (super(), this.properties = a || {}, a && (typeof a != "object" || !Object.keys(a).every(function(i) {
        return St(a[i]);
      })))
        throw new TypeError("Object containing Nodes expected");
    }
    get type() {
      return F_;
    }
    get isObjectNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(a, i) {
      var o = {};
      for (var c in this.properties)
        if (er(this.properties, c)) {
          var s = uv(c), u = JSON.parse(s), l = Ki(this.properties, c);
          o[u] = l._compile(a, i);
        }
      return function(d, m, p) {
        var v = {};
        for (var h in o)
          er(o, h) && (v[h] = o[h](d, m, p));
        return v;
      };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(a) {
      for (var i in this.properties)
        er(this.properties, i) && a(this.properties[i], "properties[" + uv(i) + "]", this);
    }
    /**
     * Create a new ObjectNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {ObjectNode} Returns a transformed copy of the node
     */
    map(a) {
      var i = {};
      for (var o in this.properties)
        er(this.properties, o) && (i[o] = this._ifNode(a(this.properties[o], "properties[" + uv(o) + "]", this)));
      return new t(i);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {ObjectNode}
     */
    clone() {
      var a = {};
      for (var i in this.properties)
        er(this.properties, i) && (a[i] = this.properties[i]);
      return new t(a);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toString(a) {
      var i = [];
      for (var o in this.properties)
        er(this.properties, o) && i.push(uv(o) + ": " + this.properties[o].toString(a));
      return "{" + i.join(", ") + "}";
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: F_,
        properties: this.properties
      };
    }
    /**
     * Instantiate an OperatorNode from its JSON representation
     * @param {Object} json  An object structured like
     *                       `{"mathjs": "ObjectNode", "properties": {...}}`,
     *                       where mathjs is optional
     * @returns {ObjectNode}
     */
    static fromJSON(a) {
      return new t(a.properties);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toHTML(a) {
      var i = [];
      for (var o in this.properties)
        er(this.properties, o) && i.push('<span class="math-symbol math-property">' + Pu(o) + '</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>' + this.properties[o].toHTML(a));
      return '<span class="math-parenthesis math-curly-parenthesis">{</span>' + i.join('<span class="math-separator">,</span>') + '<span class="math-parenthesis math-curly-parenthesis">}</span>';
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(a) {
      var i = [];
      for (var o in this.properties)
        er(this.properties, o) && i.push("\\mathbf{" + o + ":} & " + this.properties[o].toTex(a) + "\\\\");
      var c = "\\left\\{\\begin{array}{ll}" + i.join(`
`) + "\\end{array}\\right\\}";
      return c;
    }
  }
  return ba(t, "name", F_), t;
}, {
  isClass: !0,
  isNode: !0
});
function G1(e, r) {
  return new xK(e, new nx(r), new Set(Object.keys(r)));
}
var L_ = "OperatorNode", U6e = ["Node"], z6e = /* @__PURE__ */ Ce(L_, U6e, (e) => {
  var {
    Node: r
  } = e;
  function t(i, o) {
    var c = i;
    if (o === "auto")
      for (; sl(c); ) c = c.content;
    return Jr(c) ? !0 : Hn(c) ? t(c.args[0], o) : !1;
  }
  function n(i, o, c, s, u) {
    var l = Mt(i, o, c), f = V1(i, o);
    if (o === "all" || s.length > 2 && i.getIdentifier() !== "OperatorNode:add" && i.getIdentifier() !== "OperatorNode:multiply")
      return s.map(function(T) {
        switch (T.getContent().type) {
          case "ArrayNode":
          case "ConstantNode":
          case "SymbolNode":
          case "ParenthesisNode":
            return !1;
          default:
            return !0;
        }
      });
    var d;
    switch (s.length) {
      case 0:
        d = [];
        break;
      case 1:
        {
          var m = Mt(s[0], o, c, i);
          if (u && m !== null) {
            var p, v;
            if (o === "keep" ? (p = s[0].getIdentifier(), v = i.getIdentifier()) : (p = s[0].getContent().getIdentifier(), v = i.getContent().getIdentifier()), Yu[l][v].latexLeftParens === !1) {
              d = [!1];
              break;
            }
            if (Yu[m][p].latexParens === !1) {
              d = [!1];
              break;
            }
          }
          if (m === null) {
            d = [!1];
            break;
          }
          if (m <= l) {
            d = [!0];
            break;
          }
          d = [!1];
        }
        break;
      case 2:
        {
          var h, y = Mt(s[0], o, c, i), C = PP(i, s[0], o);
          y === null ? h = !1 : y === l && f === "right" && !C || y < l ? h = !0 : h = !1;
          var S, b = Mt(s[1], o, c, i), g = PP(i, s[1], o);
          if (b === null ? S = !1 : b === l && f === "left" && !g || b < l ? S = !0 : S = !1, u) {
            var _, A, M;
            o === "keep" ? (_ = i.getIdentifier(), A = i.args[0].getIdentifier(), M = i.args[1].getIdentifier()) : (_ = i.getContent().getIdentifier(), A = i.args[0].getContent().getIdentifier(), M = i.args[1].getContent().getIdentifier()), y !== null && (Yu[l][_].latexLeftParens === !1 && (h = !1), Yu[y][A].latexParens === !1 && (h = !1)), b !== null && (Yu[l][_].latexRightParens === !1 && (S = !1), Yu[b][M].latexParens === !1 && (S = !1));
          }
          d = [h, S];
        }
        break;
      default:
        (i.getIdentifier() === "OperatorNode:add" || i.getIdentifier() === "OperatorNode:multiply") && (d = s.map(function(T) {
          var x = Mt(T, o, c, i), w = PP(i, T, o), E = V1(T, o);
          return x === null ? !1 : l === x && f === E && !w ? !0 : x < l;
        }));
        break;
    }
    if (s.length >= 2 && i.getIdentifier() === "OperatorNode:multiply" && i.implicit && o !== "all" && c === "hide")
      for (var P = 1; P < d.length; ++P)
        t(s[P], o) && !d[P - 1] && (o !== "keep" || !sl(s[P - 1])) && (d[P] = !0);
    return d;
  }
  class a extends r {
    /**
     * @constructor OperatorNode
     * @extends {Node}
     * An operator with two arguments, like 2+3
     *
     * @param {string} op           Operator name, for example '+'
     * @param {string} fn           Function name, for example 'add'
     * @param {Node[]} args         Operator arguments
     * @param {boolean} [implicit]  Is this an implicit multiplication?
     * @param {boolean} [isPercentage] Is this an percentage Operation?
     */
    constructor(o, c, s, u, l) {
      if (super(), typeof o != "string")
        throw new TypeError('string expected for parameter "op"');
      if (typeof c != "string")
        throw new TypeError('string expected for parameter "fn"');
      if (!Array.isArray(s) || !s.every(St))
        throw new TypeError('Array containing Nodes expected for parameter "args"');
      this.implicit = u === !0, this.isPercentage = l === !0, this.op = o, this.fn = c, this.args = s || [];
    }
    get type() {
      return L_;
    }
    get isOperatorNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(o, c) {
      if (typeof this.fn != "string" || !CD(o, this.fn))
        throw o[this.fn] ? new Error('No access to function "' + this.fn + '"') : new Error("Function " + this.fn + ' missing in provided namespace "math"');
      var s = Ki(o, this.fn), u = lc(this.args, function(p) {
        return p._compile(o, c);
      });
      if (typeof s == "function" && s.rawArgs === !0) {
        var l = this.args;
        return function(v, h, y) {
          return s(l, o, G1(v, h));
        };
      } else if (u.length === 1) {
        var f = u[0];
        return function(v, h, y) {
          return s(f(v, h, y));
        };
      } else if (u.length === 2) {
        var d = u[0], m = u[1];
        return function(v, h, y) {
          return s(d(v, h, y), m(v, h, y));
        };
      } else
        return function(v, h, y) {
          return s.apply(null, lc(u, function(C) {
            return C(v, h, y);
          }));
        };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(o) {
      for (var c = 0; c < this.args.length; c++)
        o(this.args[c], "args[" + c + "]", this);
    }
    /**
     * Create a new OperatorNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {OperatorNode} Returns a transformed copy of the node
     */
    map(o) {
      for (var c = [], s = 0; s < this.args.length; s++)
        c[s] = this._ifNode(o(this.args[s], "args[" + s + "]", this));
      return new a(this.op, this.fn, c, this.implicit, this.isPercentage);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {OperatorNode}
     */
    clone() {
      return new a(this.op, this.fn, this.args.slice(0), this.implicit, this.isPercentage);
    }
    /**
     * Check whether this is an unary OperatorNode:
     * has exactly one argument, like `-a`.
     * @return {boolean}
     *     Returns true when an unary operator node, false otherwise.
     */
    isUnary() {
      return this.args.length === 1;
    }
    /**
     * Check whether this is a binary OperatorNode:
     * has exactly two arguments, like `a + b`.
     * @return {boolean}
     *     Returns true when a binary operator node, false otherwise.
     */
    isBinary() {
      return this.args.length === 2;
    }
    /**
     * Get string representation.
     * @param {Object} options
     * @return {string} str
     */
    _toString(o) {
      var c = o && o.parenthesis ? o.parenthesis : "keep", s = o && o.implicit ? o.implicit : "hide", u = this.args, l = n(this, c, s, u, !1);
      if (u.length === 1) {
        var f = V1(this, c), d = u[0].toString(o);
        l[0] && (d = "(" + d + ")");
        var m = /[a-zA-Z]+/.test(this.op);
        return f === "right" ? this.op + (m ? " " : "") + d : f === "left" ? d + (m ? " " : "") + this.op : d + this.op;
      } else if (u.length === 2) {
        var p = u[0].toString(o), v = u[1].toString(o);
        return l[0] && (p = "(" + p + ")"), l[1] && (v = "(" + v + ")"), this.implicit && this.getIdentifier() === "OperatorNode:multiply" && s === "hide" ? p + " " + v : p + " " + this.op + " " + v;
      } else if (u.length > 2 && (this.getIdentifier() === "OperatorNode:add" || this.getIdentifier() === "OperatorNode:multiply")) {
        var h = u.map(function(y, C) {
          return y = y.toString(o), l[C] && (y = "(" + y + ")"), y;
        });
        return this.implicit && this.getIdentifier() === "OperatorNode:multiply" && s === "hide" ? h.join(" ") : h.join(" " + this.op + " ");
      } else
        return this.fn + "(" + this.args.join(", ") + ")";
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: L_,
        op: this.op,
        fn: this.fn,
        args: this.args,
        implicit: this.implicit,
        isPercentage: this.isPercentage
      };
    }
    /**
     * Instantiate an OperatorNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     ```
     *     {"mathjs": "OperatorNode",
     *      "op": "+", "fn": "add", "args": [...],
     *      "implicit": false,
     *      "isPercentage":false}
     *     ```
     *     where mathjs is optional
     * @returns {OperatorNode}
     */
    static fromJSON(o) {
      return new a(o.op, o.fn, o.args, o.implicit, o.isPercentage);
    }
    /**
     * Get HTML representation.
     * @param {Object} options
     * @return {string} str
     */
    _toHTML(o) {
      var c = o && o.parenthesis ? o.parenthesis : "keep", s = o && o.implicit ? o.implicit : "hide", u = this.args, l = n(this, c, s, u, !1);
      if (u.length === 1) {
        var f = V1(this, c), d = u[0].toHTML(o);
        return l[0] && (d = '<span class="math-parenthesis math-round-parenthesis">(</span>' + d + '<span class="math-parenthesis math-round-parenthesis">)</span>'), f === "right" ? '<span class="math-operator math-unary-operator math-lefthand-unary-operator">' + Pu(this.op) + "</span>" + d : d + '<span class="math-operator math-unary-operator math-righthand-unary-operator">' + Pu(this.op) + "</span>";
      } else if (u.length === 2) {
        var m = u[0].toHTML(o), p = u[1].toHTML(o);
        return l[0] && (m = '<span class="math-parenthesis math-round-parenthesis">(</span>' + m + '<span class="math-parenthesis math-round-parenthesis">)</span>'), l[1] && (p = '<span class="math-parenthesis math-round-parenthesis">(</span>' + p + '<span class="math-parenthesis math-round-parenthesis">)</span>'), this.implicit && this.getIdentifier() === "OperatorNode:multiply" && s === "hide" ? m + '<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>' + p : m + '<span class="math-operator math-binary-operator math-explicit-binary-operator">' + Pu(this.op) + "</span>" + p;
      } else {
        var v = u.map(function(h, y) {
          return h = h.toHTML(o), l[y] && (h = '<span class="math-parenthesis math-round-parenthesis">(</span>' + h + '<span class="math-parenthesis math-round-parenthesis">)</span>'), h;
        });
        return u.length > 2 && (this.getIdentifier() === "OperatorNode:add" || this.getIdentifier() === "OperatorNode:multiply") ? this.implicit && this.getIdentifier() === "OperatorNode:multiply" && s === "hide" ? v.join('<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>') : v.join('<span class="math-operator math-binary-operator math-explicit-binary-operator">' + Pu(this.op) + "</span>") : '<span class="math-function">' + Pu(this.fn) + '</span><span class="math-paranthesis math-round-parenthesis">(</span>' + v.join('<span class="math-separator">,</span>') + '<span class="math-paranthesis math-round-parenthesis">)</span>';
      }
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(o) {
      var c = o && o.parenthesis ? o.parenthesis : "keep", s = o && o.implicit ? o.implicit : "hide", u = this.args, l = n(this, c, s, u, !0), f = ot[this.fn];
      if (f = typeof f > "u" ? this.op : f, u.length === 1) {
        var d = V1(this, c), m = u[0].toTex(o);
        return l[0] && (m = "\\left(".concat(m, "\\right)")), d === "right" ? f + m : m + f;
      } else if (u.length === 2) {
        var p = u[0], v = p.toTex(o);
        l[0] && (v = "\\left(".concat(v, "\\right)"));
        var h = u[1], y = h.toTex(o);
        l[1] && (y = "\\left(".concat(y, "\\right)"));
        var C;
        switch (c === "keep" ? C = p.getIdentifier() : C = p.getContent().getIdentifier(), this.getIdentifier()) {
          case "OperatorNode:divide":
            return f + "{" + v + "}{" + y + "}";
          case "OperatorNode:pow":
            switch (v = "{" + v + "}", y = "{" + y + "}", C) {
              case "ConditionalNode":
              case "OperatorNode:divide":
                v = "\\left(".concat(v, "\\right)");
            }
            break;
          case "OperatorNode:multiply":
            if (this.implicit && s === "hide")
              return v + "~" + y;
        }
        return v + f + y;
      } else if (u.length > 2 && (this.getIdentifier() === "OperatorNode:add" || this.getIdentifier() === "OperatorNode:multiply")) {
        var S = u.map(function(b, g) {
          return b = b.toTex(o), l[g] && (b = "\\left(".concat(b, "\\right)")), b;
        });
        return this.getIdentifier() === "OperatorNode:multiply" && this.implicit && s === "hide" ? S.join("~") : S.join(f);
      } else
        return "\\mathrm{" + this.fn + "}\\left(" + u.map(function(b) {
          return b.toTex(o);
        }).join(",") + "\\right)";
    }
    /**
     * Get identifier.
     * @return {string}
     */
    getIdentifier() {
      return this.type + ":" + this.fn;
    }
  }
  return ba(a, "name", L_), a;
}, {
  isClass: !0,
  isNode: !0
}), k_ = "ParenthesisNode", G6e = ["Node"], q6e = /* @__PURE__ */ Ce(k_, G6e, (e) => {
  var {
    Node: r
  } = e;
  class t extends r {
    /**
     * @constructor ParenthesisNode
     * @extends {Node}
     * A parenthesis node describes manual parenthesis from the user input
     * @param {Node} content
     * @extends {Node}
     */
    constructor(a) {
      if (super(), !St(a))
        throw new TypeError('Node expected for parameter "content"');
      this.content = a;
    }
    get type() {
      return k_;
    }
    get isParenthesisNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(a, i) {
      return this.content._compile(a, i);
    }
    /**
     * Get the content of the current Node.
     * @return {Node} content
     * @override
     **/
    getContent() {
      return this.content.getContent();
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(a) {
      a(this.content, "content", this);
    }
    /**
     * Create a new ParenthesisNode whose child is the result of calling
     * the provided callback function on the child of this node.
     * @param {function(child: Node, path: string, parent: Node) : Node} callback
     * @returns {ParenthesisNode} Returns a clone of the node
     */
    map(a) {
      var i = a(this.content, "content", this);
      return new t(i);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {ParenthesisNode}
     */
    clone() {
      return new t(this.content);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toString(a) {
      return !a || a && !a.parenthesis || a && a.parenthesis === "keep" ? "(" + this.content.toString(a) + ")" : this.content.toString(a);
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: k_,
        content: this.content
      };
    }
    /**
     * Instantiate an ParenthesisNode from its JSON representation
     * @param {Object} json  An object structured like
     *                       `{"mathjs": "ParenthesisNode", "content": ...}`,
     *                       where mathjs is optional
     * @returns {ParenthesisNode}
     */
    static fromJSON(a) {
      return new t(a.content);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toHTML(a) {
      return !a || a && !a.parenthesis || a && a.parenthesis === "keep" ? '<span class="math-parenthesis math-round-parenthesis">(</span>' + this.content.toHTML(a) + '<span class="math-parenthesis math-round-parenthesis">)</span>' : this.content.toHTML(a);
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toTex(a) {
      return !a || a && !a.parenthesis || a && a.parenthesis === "keep" ? "\\left(".concat(this.content.toTex(a), "\\right)") : this.content.toTex(a);
    }
  }
  return ba(t, "name", k_), t;
}, {
  isClass: !0,
  isNode: !0
}), U_ = "RangeNode", H6e = ["Node"], j6e = /* @__PURE__ */ Ce(U_, H6e, (e) => {
  var {
    Node: r
  } = e;
  function t(a, i, o) {
    var c = Mt(a, i, o), s = {}, u = Mt(a.start, i, o);
    if (s.start = u !== null && u <= c || i === "all", a.step) {
      var l = Mt(a.step, i, o);
      s.step = l !== null && l <= c || i === "all";
    }
    var f = Mt(a.end, i, o);
    return s.end = f !== null && f <= c || i === "all", s;
  }
  class n extends r {
    /**
     * @constructor RangeNode
     * @extends {Node}
     * create a range
     * @param {Node} start  included lower-bound
     * @param {Node} end    included upper-bound
     * @param {Node} [step] optional step
     */
    constructor(i, o, c) {
      if (super(), !St(i)) throw new TypeError("Node expected");
      if (!St(o)) throw new TypeError("Node expected");
      if (c && !St(c)) throw new TypeError("Node expected");
      if (arguments.length > 3) throw new Error("Too many arguments");
      this.start = i, this.end = o, this.step = c || null;
    }
    get type() {
      return U_;
    }
    get isRangeNode() {
      return !0;
    }
    /**
     * Check whether the RangeNode needs the `end` symbol to be defined.
     * This end is the size of the Matrix in current dimension.
     * @return {boolean}
     */
    needsEnd() {
      var i = this.filter(function(o) {
        return _a(o) && o.name === "end";
      });
      return i.length > 0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(i, o) {
      var c = i.range, s = this.start._compile(i, o), u = this.end._compile(i, o);
      if (this.step) {
        var l = this.step._compile(i, o);
        return function(d, m, p) {
          return c(s(d, m, p), u(d, m, p), l(d, m, p));
        };
      } else
        return function(d, m, p) {
          return c(s(d, m, p), u(d, m, p));
        };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(i) {
      i(this.start, "start", this), i(this.end, "end", this), this.step && i(this.step, "step", this);
    }
    /**
     * Create a new RangeNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {RangeNode} Returns a transformed copy of the node
     */
    map(i) {
      return new n(this._ifNode(i(this.start, "start", this)), this._ifNode(i(this.end, "end", this)), this.step && this._ifNode(i(this.step, "step", this)));
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {RangeNode}
     */
    clone() {
      return new n(this.start, this.end, this.step && this.step);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     */
    _toString(i) {
      var o = i && i.parenthesis ? i.parenthesis : "keep", c = t(this, o, i && i.implicit), s, u = this.start.toString(i);
      if (c.start && (u = "(" + u + ")"), s = u, this.step) {
        var l = this.step.toString(i);
        c.step && (l = "(" + l + ")"), s += ":" + l;
      }
      var f = this.end.toString(i);
      return c.end && (f = "(" + f + ")"), s += ":" + f, s;
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: U_,
        start: this.start,
        end: this.end,
        step: this.step
      };
    }
    /**
     * Instantiate an RangeNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     `{"mathjs": "RangeNode", "start": ..., "end": ..., "step": ...}`,
     *     where mathjs is optional
     * @returns {RangeNode}
     */
    static fromJSON(i) {
      return new n(i.start, i.end, i.step);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     */
    _toHTML(i) {
      var o = i && i.parenthesis ? i.parenthesis : "keep", c = t(this, o, i && i.implicit), s, u = this.start.toHTML(i);
      if (c.start && (u = '<span class="math-parenthesis math-round-parenthesis">(</span>' + u + '<span class="math-parenthesis math-round-parenthesis">)</span>'), s = u, this.step) {
        var l = this.step.toHTML(i);
        c.step && (l = '<span class="math-parenthesis math-round-parenthesis">(</span>' + l + '<span class="math-parenthesis math-round-parenthesis">)</span>'), s += '<span class="math-operator math-range-operator">:</span>' + l;
      }
      var f = this.end.toHTML(i);
      return c.end && (f = '<span class="math-parenthesis math-round-parenthesis">(</span>' + f + '<span class="math-parenthesis math-round-parenthesis">)</span>'), s += '<span class="math-operator math-range-operator">:</span>' + f, s;
    }
    /**
     * Get LaTeX representation
     * @params {Object} options
     * @return {string} str
     */
    _toTex(i) {
      var o = i && i.parenthesis ? i.parenthesis : "keep", c = t(this, o, i && i.implicit), s = this.start.toTex(i);
      if (c.start && (s = "\\left(".concat(s, "\\right)")), this.step) {
        var u = this.step.toTex(i);
        c.step && (u = "\\left(".concat(u, "\\right)")), s += ":" + u;
      }
      var l = this.end.toTex(i);
      return c.end && (l = "\\left(".concat(l, "\\right)")), s += ":" + l, s;
    }
  }
  return ba(n, "name", U_), n;
}, {
  isClass: !0,
  isNode: !0
}), z_ = "RelationalNode", $6e = ["Node"], K6e = /* @__PURE__ */ Ce(z_, $6e, (e) => {
  var {
    Node: r
  } = e, t = {
    equal: "==",
    unequal: "!=",
    smaller: "<",
    larger: ">",
    smallerEq: "<=",
    largerEq: ">="
  };
  class n extends r {
    /**
     * A node representing a chained conditional expression, such as 'x > y > z'
     *
     * @param {String[]} conditionals
     *     An array of conditional operators used to compare the parameters
     * @param {Node[]} params
     *     The parameters that will be compared
     *
     * @constructor RelationalNode
     * @extends {Node}
     */
    constructor(i, o) {
      if (super(), !Array.isArray(i))
        throw new TypeError("Parameter conditionals must be an array");
      if (!Array.isArray(o))
        throw new TypeError("Parameter params must be an array");
      if (i.length !== o.length - 1)
        throw new TypeError("Parameter params must contain exactly one more element than parameter conditionals");
      this.conditionals = i, this.params = o;
    }
    get type() {
      return z_;
    }
    get isRelationalNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(i, o) {
      var c = this, s = this.params.map((u) => u._compile(i, o));
      return function(l, f, d) {
        for (var m, p = s[0](l, f, d), v = 0; v < c.conditionals.length; v++) {
          m = p, p = s[v + 1](l, f, d);
          var h = Ki(i, c.conditionals[v]);
          if (!h(m, p))
            return !1;
        }
        return !0;
      };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(i) {
      this.params.forEach((o, c) => i(o, "params[" + c + "]", this), this);
    }
    /**
     * Create a new RelationalNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {RelationalNode} Returns a transformed copy of the node
     */
    map(i) {
      return new n(this.conditionals.slice(), this.params.map((o, c) => this._ifNode(i(o, "params[" + c + "]", this)), this));
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {RelationalNode}
     */
    clone() {
      return new n(this.conditionals, this.params);
    }
    /**
     * Get string representation.
     * @param {Object} options
     * @return {string} str
     */
    _toString(i) {
      for (var o = i && i.parenthesis ? i.parenthesis : "keep", c = Mt(this, o, i && i.implicit), s = this.params.map(function(f, d) {
        var m = Mt(f, o, i && i.implicit);
        return o === "all" || m !== null && m <= c ? "(" + f.toString(i) + ")" : f.toString(i);
      }), u = s[0], l = 0; l < this.conditionals.length; l++)
        u += " " + t[this.conditionals[l]], u += " " + s[l + 1];
      return u;
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: z_,
        conditionals: this.conditionals,
        params: this.params
      };
    }
    /**
     * Instantiate a RelationalNode from its JSON representation
     * @param {Object} json
     *     An object structured like
     *     `{"mathjs": "RelationalNode", "conditionals": ..., "params": ...}`,
     *     where mathjs is optional
     * @returns {RelationalNode}
     */
    static fromJSON(i) {
      return new n(i.conditionals, i.params);
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     */
    _toHTML(i) {
      for (var o = i && i.parenthesis ? i.parenthesis : "keep", c = Mt(this, o, i && i.implicit), s = this.params.map(function(f, d) {
        var m = Mt(f, o, i && i.implicit);
        return o === "all" || m !== null && m <= c ? '<span class="math-parenthesis math-round-parenthesis">(</span>' + f.toHTML(i) + '<span class="math-parenthesis math-round-parenthesis">)</span>' : f.toHTML(i);
      }), u = s[0], l = 0; l < this.conditionals.length; l++)
        u += '<span class="math-operator math-binary-operator math-explicit-binary-operator">' + Pu(t[this.conditionals[l]]) + "</span>" + s[l + 1];
      return u;
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(i) {
      for (var o = i && i.parenthesis ? i.parenthesis : "keep", c = Mt(this, o, i && i.implicit), s = this.params.map(function(f, d) {
        var m = Mt(f, o, i && i.implicit);
        return o === "all" || m !== null && m <= c ? "\\left(" + f.toTex(i) + "\right)" : f.toTex(i);
      }), u = s[0], l = 0; l < this.conditionals.length; l++)
        u += ot[this.conditionals[l]] + s[l + 1];
      return u;
    }
  }
  return ba(n, "name", z_), n;
}, {
  isClass: !0,
  isNode: !0
}), W6e = "SymbolNode", X6e = ["math", "?Unit", "Node"], Y6e = /* @__PURE__ */ Ce(W6e, X6e, (e) => {
  var {
    math: r,
    Unit: t,
    Node: n
  } = e;
  function a(o) {
    return t ? t.isValuelessUnit(o) : !1;
  }
  class i extends n {
    /**
     * @constructor SymbolNode
     * @extends {Node}
     * A symbol node can hold and resolve a symbol
     * @param {string} name
     * @extends {Node}
     */
    constructor(c) {
      if (super(), typeof c != "string")
        throw new TypeError('String expected for parameter "name"');
      this.name = c;
    }
    get type() {
      return "SymbolNode";
    }
    get isSymbolNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(c, s) {
      var u = this.name;
      if (s[u] === !0)
        return function(f, d, m) {
          return Ki(d, u);
        };
      if (u in c)
        return function(f, d, m) {
          return f.has(u) ? f.get(u) : Ki(c, u);
        };
      var l = a(u);
      return function(f, d, m) {
        return f.has(u) ? f.get(u) : l ? new t(null, u) : i.onUndefinedSymbol(u);
      };
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(c) {
    }
    /**
     * Create a new SymbolNode with children produced by the given callback.
     * Trivial since a SymbolNode has no children
     * @param {function(child: Node, path: string, parent: Node) : Node} callback
     * @returns {SymbolNode} Returns a clone of the node
     */
    map(c) {
      return this.clone();
    }
    /**
     * Throws an error 'Undefined symbol {name}'
     * @param {string} name
     */
    static onUndefinedSymbol(c) {
      throw new Error("Undefined symbol " + c);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {SymbolNode}
     */
    clone() {
      return new i(this.name);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toString(c) {
      return this.name;
    }
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toHTML(c) {
      var s = Pu(this.name);
      return s === "true" || s === "false" ? '<span class="math-symbol math-boolean">' + s + "</span>" : s === "i" ? '<span class="math-symbol math-imaginary-symbol">' + s + "</span>" : s === "Infinity" ? '<span class="math-symbol math-infinity-symbol">' + s + "</span>" : s === "NaN" ? '<span class="math-symbol math-nan-symbol">' + s + "</span>" : s === "null" ? '<span class="math-symbol math-null-symbol">' + s + "</span>" : s === "undefined" ? '<span class="math-symbol math-undefined-symbol">' + s + "</span>" : '<span class="math-symbol">' + s + "</span>";
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: "SymbolNode",
        name: this.name
      };
    }
    /**
     * Instantiate a SymbolNode from its JSON representation
     * @param {Object} json  An object structured like
     *                       `{"mathjs": "SymbolNode", name: "x"}`,
     *                       where mathjs is optional
     * @returns {SymbolNode}
     */
    static fromJSON(c) {
      return new i(c.name);
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     * @override
     */
    _toTex(c) {
      var s = !1;
      typeof r[this.name] > "u" && a(this.name) && (s = !0);
      var u = dY(this.name, s);
      return u[0] === "\\" ? u : " " + u;
    }
  }
  return i;
}, {
  isClass: !0,
  isNode: !0
}), G_ = "FunctionNode", Q6e = ["math", "Node", "SymbolNode"], Z6e = /* @__PURE__ */ Ce(G_, Q6e, (e) => {
  var r, {
    math: t,
    Node: n,
    SymbolNode: a
  } = e, i = (s) => $r(s, {
    truncate: 78
  });
  function o(s, u, l) {
    for (var f = "", d = /\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi, m = 0, p; (p = d.exec(s)) !== null; )
      if (f += s.substring(m, p.index), m = p.index, p[0] === "$$")
        f += "$", m++;
      else {
        m += p[0].length;
        var v = u[p[1]];
        if (!v)
          throw new ReferenceError("Template: Property " + p[1] + " does not exist.");
        if (p[2] === void 0)
          switch (typeof v) {
            case "string":
              f += v;
              break;
            case "object":
              if (St(v))
                f += v.toTex(l);
              else if (Array.isArray(v))
                f += v.map(function(h, y) {
                  if (St(h))
                    return h.toTex(l);
                  throw new TypeError("Template: " + p[1] + "[" + y + "] is not a Node.");
                }).join(",");
              else
                throw new TypeError("Template: " + p[1] + " has to be a Node, String or array of Nodes");
              break;
            default:
              throw new TypeError("Template: " + p[1] + " has to be a Node, String or array of Nodes");
          }
        else if (St(v[p[2]] && v[p[2]]))
          f += v[p[2]].toTex(l);
        else
          throw new TypeError("Template: " + p[1] + "[" + p[2] + "] is not a Node.");
      }
    return f += s.slice(m), f;
  }
  class c extends n {
    /**
     * @constructor FunctionNode
     * @extends {./Node}
     * invoke a list with arguments on a node
     * @param {./Node | string} fn
     *     Item resolving to a function on which to invoke
     *     the arguments, typically a SymboNode or AccessorNode
     * @param {./Node[]} args
     */
    constructor(u, l) {
      if (super(), typeof u == "string" && (u = new a(u)), !St(u)) throw new TypeError('Node expected as parameter "fn"');
      if (!Array.isArray(l) || !l.every(St))
        throw new TypeError('Array containing Nodes expected for parameter "args"');
      this.fn = u, this.args = l || [];
    }
    // readonly property name
    get name() {
      return this.fn.name || "";
    }
    get type() {
      return G_;
    }
    get isFunctionNode() {
      return !0;
    }
    /**
     * Compile a node into a JavaScript function.
     * This basically pre-calculates as much as possible and only leaves open
     * calculations which depend on a dynamic scope with variables.
     * @param {Object} math     Math.js namespace with functions and constants.
     * @param {Object} argNames An object with argument names as key and `true`
     *                          as value. Used in the SymbolNode to optimize
     *                          for arguments from user assigned functions
     *                          (see FunctionAssignmentNode) or special symbols
     *                          like `end` (see IndexNode).
     * @return {function} Returns a function which can be called like:
     *                        evalNode(scope: Object, args: Object, context: *)
     */
    _compile(u, l) {
      var f = this.args.map((M) => M._compile(u, l));
      if (_a(this.fn)) {
        var d = this.fn.name;
        if (l[d]) {
          var y = this.args;
          return function(P, T, x) {
            var w = Ki(T, d);
            if (typeof w != "function")
              throw new TypeError("Argument '".concat(d, "' was not a function; received: ").concat(i(w)));
            if (w.rawArgs)
              return w(y, u, G1(P, T));
            var E = f.map((I) => I(P, T, x));
            return w.apply(w, E);
          };
        } else {
          var m = d in u ? Ki(u, d) : void 0, p = typeof m == "function" && m.rawArgs === !0, v = (M) => {
            var P;
            if (M.has(d))
              P = M.get(d);
            else if (d in u)
              P = Ki(u, d);
            else
              return c.onUndefinedFunction(d);
            if (typeof P == "function")
              return P;
            throw new TypeError("'".concat(d, `' is not a function; its value is:
  `).concat(i(P)));
          };
          if (p) {
            var h = this.args;
            return function(P, T, x) {
              var w = v(P);
              return w(h, u, G1(P, T));
            };
          } else
            switch (f.length) {
              case 0:
                return function(P, T, x) {
                  var w = v(P);
                  return w();
                };
              case 1:
                return function(P, T, x) {
                  var w = v(P), E = f[0];
                  return w(E(P, T, x));
                };
              case 2:
                return function(P, T, x) {
                  var w = v(P), E = f[0], I = f[1];
                  return w(E(P, T, x), I(P, T, x));
                };
              default:
                return function(P, T, x) {
                  var w = v(P), E = f.map((I) => I(P, T, x));
                  return w(...E);
                };
            }
        }
      } else if (Fd(this.fn) && em(this.fn.index) && this.fn.index.isObjectProperty()) {
        var C = this.fn.object._compile(u, l), S = this.fn.index.getObjectProperty(), b = this.args;
        return function(P, T, x) {
          var w = C(P, T, x), E = mAe(w, S);
          if (E != null && E.rawArgs)
            return E(b, u, G1(P, T));
          var I = f.map((B) => B(P, T, x));
          return E.apply(w, I);
        };
      } else {
        var g = this.fn.toString(), _ = this.fn._compile(u, l), A = this.args;
        return function(P, T, x) {
          var w = _(P, T, x);
          if (typeof w != "function")
            throw new TypeError("Expression '".concat(g, "' did not evaluate to a function; value is:") + `
  `.concat(i(w)));
          if (w.rawArgs)
            return w(A, u, G1(P, T));
          var E = f.map((I) => I(P, T, x));
          return w.apply(w, E);
        };
      }
    }
    /**
     * Execute a callback for each of the child nodes of this node
     * @param {function(child: Node, path: string, parent: Node)} callback
     */
    forEach(u) {
      u(this.fn, "fn", this);
      for (var l = 0; l < this.args.length; l++)
        u(this.args[l], "args[" + l + "]", this);
    }
    /**
     * Create a new FunctionNode whose children are the results of calling
     * the provided callback function for each child of the original node.
     * @param {function(child: Node, path: string, parent: Node): Node} callback
     * @returns {FunctionNode} Returns a transformed copy of the node
     */
    map(u) {
      for (var l = this._ifNode(u(this.fn, "fn", this)), f = [], d = 0; d < this.args.length; d++)
        f[d] = this._ifNode(u(this.args[d], "args[" + d + "]", this));
      return new c(l, f);
    }
    /**
     * Create a clone of this node, a shallow copy
     * @return {FunctionNode}
     */
    clone() {
      return new c(this.fn, this.args.slice(0));
    }
    /**
     * Throws an error 'Undefined function {name}'
     * @param {string} name
     */
    /**
     * Get string representation. (wrapper function)
     * This overrides parts of Node's toString function.
     * If callback is an object containing callbacks, it
     * calls the correct callback for the current node,
     * otherwise it falls back to calling Node's toString
     * function.
     *
     * @param {Object} options
     * @return {string} str
     * @override
     */
    toString(u) {
      var l, f = this.fn.toString(u);
      return u && typeof u.handler == "object" && er(u.handler, f) && (l = u.handler[f](this, u)), typeof l < "u" ? l : super.toString(u);
    }
    /**
     * Get string representation
     * @param {Object} options
     * @return {string} str
     */
    _toString(u) {
      var l = this.args.map(function(d) {
        return d.toString(u);
      }), f = Kp(this.fn) ? "(" + this.fn.toString(u) + ")" : this.fn.toString(u);
      return f + "(" + l.join(", ") + ")";
    }
    /**
     * Get a JSON representation of the node
     * @returns {Object}
     */
    toJSON() {
      return {
        mathjs: G_,
        fn: this.fn,
        args: this.args
      };
    }
    /**
     * Instantiate an AssignmentNode from its JSON representation
     * @param {Object} json  An object structured like
     *                       `{"mathjs": "FunctionNode", fn: ..., args: ...}`,
     *                       where mathjs is optional
     * @returns {FunctionNode}
     */
    /**
     * Get HTML representation
     * @param {Object} options
     * @return {string} str
     */
    _toHTML(u) {
      var l = this.args.map(function(f) {
        return f.toHTML(u);
      });
      return '<span class="math-function">' + Pu(this.fn) + '</span><span class="math-paranthesis math-round-parenthesis">(</span>' + l.join('<span class="math-separator">,</span>') + '<span class="math-paranthesis math-round-parenthesis">)</span>';
    }
    /**
     * Get LaTeX representation. (wrapper function)
     * This overrides parts of Node's toTex function.
     * If callback is an object containing callbacks, it
     * calls the correct callback for the current node,
     * otherwise it falls back to calling Node's toTex
     * function.
     *
     * @param {Object} options
     * @return {string}
     */
    toTex(u) {
      var l;
      return u && typeof u.handler == "object" && er(u.handler, this.name) && (l = u.handler[this.name](this, u)), typeof l < "u" ? l : super.toTex(u);
    }
    /**
     * Get LaTeX representation
     * @param {Object} options
     * @return {string} str
     */
    _toTex(u) {
      var l = this.args.map(function(m) {
        return m.toTex(u);
      }), f;
      CL[this.name] && (f = CL[this.name]), t[this.name] && (typeof t[this.name].toTex == "function" || typeof t[this.name].toTex == "object" || typeof t[this.name].toTex == "string") && (f = t[this.name].toTex);
      var d;
      switch (typeof f) {
        case "function":
          d = f(this, u);
          break;
        case "string":
          d = o(f, this, u);
          break;
        case "object":
          switch (typeof f[l.length]) {
            case "function":
              d = f[l.length](this, u);
              break;
            case "string":
              d = o(f[l.length], this, u);
              break;
          }
      }
      return typeof d < "u" ? d : o(I6e, this, u);
    }
    /**
     * Get identifier.
     * @return {string}
     */
    getIdentifier() {
      return this.type + ":" + this.name;
    }
  }
  return r = c, ba(c, "name", G_), ba(c, "onUndefinedFunction", function(s) {
    throw new Error("Undefined function " + s);
  }), ba(c, "fromJSON", function(s) {
    return new r(s.fn, s.args);
  }), c;
}, {
  isClass: !0,
  isNode: !0
}), xL = "parse", J6e = ["typed", "numeric", "config", "AccessorNode", "ArrayNode", "AssignmentNode", "BlockNode", "ConditionalNode", "ConstantNode", "FunctionAssignmentNode", "FunctionNode", "IndexNode", "ObjectNode", "OperatorNode", "ParenthesisNode", "RangeNode", "RelationalNode", "SymbolNode"], eIe = /* @__PURE__ */ Ce(xL, J6e, (e) => {
  var {
    typed: r,
    numeric: t,
    config: n,
    AccessorNode: a,
    ArrayNode: i,
    AssignmentNode: o,
    BlockNode: c,
    ConditionalNode: s,
    ConstantNode: u,
    FunctionAssignmentNode: l,
    FunctionNode: f,
    IndexNode: d,
    ObjectNode: m,
    OperatorNode: p,
    ParenthesisNode: v,
    RangeNode: h,
    RelationalNode: y,
    SymbolNode: C
  } = e, S = r(xL, {
    string: function(pe) {
      return G(pe, {});
    },
    "Array | Matrix": function(pe) {
      return b(pe, {});
    },
    "string, Object": function(pe, Ae) {
      var ye = Ae.nodes !== void 0 ? Ae.nodes : {};
      return G(pe, ye);
    },
    "Array | Matrix, Object": b
  });
  function b(ue) {
    var pe = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, Ae = pe.nodes !== void 0 ? pe.nodes : {};
    return zr(ue, function(ye) {
      if (typeof ye != "string") throw new TypeError("String expected");
      return G(ye, Ae);
    });
  }
  var g = {
    NULL: 0,
    DELIMITER: 1,
    NUMBER: 2,
    SYMBOL: 3,
    UNKNOWN: 4
  }, _ = {
    ",": !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,
    ">=": !0,
    "<<": !0,
    ">>": !0,
    ">>>": !0
  }, A = {
    mod: !0,
    to: !0,
    in: !0,
    and: !0,
    xor: !0,
    or: !0,
    not: !0
  }, M = {
    true: !0,
    false: !1,
    null: null,
    undefined: void 0
  }, P = ["NaN", "Infinity"], T = {
    '"': '"',
    "'": "'",
    "\\": "\\",
    "/": "/",
    b: "\b",
    f: "\f",
    n: `
`,
    r: "\r",
    t: "	"
    // note that \u is handled separately in parseStringToken()
  };
  function x() {
    return {
      extraNodes: {},
      // current extra nodes, must be careful not to mutate
      expression: "",
      // current expression
      comment: "",
      // last parsed comment
      index: 0,
      // current index in expr
      token: "",
      // current token
      tokenType: g.NULL,
      // type of the token
      nestingLevel: 0,
      // level of nesting inside parameters, used to ignore newline characters
      conditionalLevel: null
      // when a conditional is being parsed, the level of the conditional is stored here
    };
  }
  function w(ue, pe) {
    return ue.expression.substr(ue.index, pe);
  }
  function E(ue) {
    return w(ue, 1);
  }
  function I(ue) {
    ue.index++;
  }
  function B(ue) {
    return ue.expression.charAt(ue.index - 1);
  }
  function D(ue) {
    return ue.expression.charAt(ue.index + 1);
  }
  function N(ue) {
    for (ue.tokenType = g.NULL, ue.token = "", ue.comment = ""; ; ) {
      if (E(ue) === "#")
        for (; E(ue) !== `
` && E(ue) !== ""; )
          ue.comment += E(ue), I(ue);
      if (S.isWhitespace(E(ue), ue.nestingLevel))
        I(ue);
      else
        break;
    }
    if (E(ue) === "") {
      ue.tokenType = g.DELIMITER;
      return;
    }
    if (E(ue) === `
` && !ue.nestingLevel) {
      ue.tokenType = g.DELIMITER, ue.token = E(ue), I(ue);
      return;
    }
    var pe = E(ue), Ae = w(ue, 2), ye = w(ue, 3);
    if (ye.length === 3 && _[ye]) {
      ue.tokenType = g.DELIMITER, ue.token = ye, I(ue), I(ue), I(ue);
      return;
    }
    if (Ae.length === 2 && _[Ae]) {
      ue.tokenType = g.DELIMITER, ue.token = Ae, I(ue), I(ue);
      return;
    }
    if (_[pe]) {
      ue.tokenType = g.DELIMITER, ue.token = pe, I(ue);
      return;
    }
    if (S.isDigitDot(pe)) {
      ue.tokenType = g.NUMBER;
      var be = w(ue, 2);
      if (be === "0b" || be === "0o" || be === "0x") {
        for (ue.token += E(ue), I(ue), ue.token += E(ue), I(ue); S.isHexDigit(E(ue)); )
          ue.token += E(ue), I(ue);
        if (E(ue) === ".")
          for (ue.token += ".", I(ue); S.isHexDigit(E(ue)); )
            ue.token += E(ue), I(ue);
        else if (E(ue) === "i")
          for (ue.token += "i", I(ue); S.isDigit(E(ue)); )
            ue.token += E(ue), I(ue);
        return;
      }
      if (E(ue) === ".") {
        if (ue.token += E(ue), I(ue), !S.isDigit(E(ue))) {
          ue.tokenType = g.DELIMITER;
          return;
        }
      } else {
        for (; S.isDigit(E(ue)); )
          ue.token += E(ue), I(ue);
        S.isDecimalMark(E(ue), D(ue)) && (ue.token += E(ue), I(ue));
      }
      for (; S.isDigit(E(ue)); )
        ue.token += E(ue), I(ue);
      if (E(ue) === "E" || E(ue) === "e") {
        if (S.isDigit(D(ue)) || D(ue) === "-" || D(ue) === "+") {
          if (ue.token += E(ue), I(ue), (E(ue) === "+" || E(ue) === "-") && (ue.token += E(ue), I(ue)), !S.isDigit(E(ue)))
            throw Ee(ue, 'Digit expected, got "' + E(ue) + '"');
          for (; S.isDigit(E(ue)); )
            ue.token += E(ue), I(ue);
          if (S.isDecimalMark(E(ue), D(ue)))
            throw Ee(ue, 'Digit expected, got "' + E(ue) + '"');
        } else if (D(ue) === ".")
          throw I(ue), Ee(ue, 'Digit expected, got "' + E(ue) + '"');
      }
      return;
    }
    if (S.isAlpha(E(ue), B(ue), D(ue))) {
      for (; S.isAlpha(E(ue), B(ue), D(ue)) || S.isDigit(E(ue)); )
        ue.token += E(ue), I(ue);
      er(A, ue.token) ? ue.tokenType = g.DELIMITER : ue.tokenType = g.SYMBOL;
      return;
    }
    for (ue.tokenType = g.UNKNOWN; E(ue) !== ""; )
      ue.token += E(ue), I(ue);
    throw Ee(ue, 'Syntax error in part "' + ue.token + '"');
  }
  function O(ue) {
    do
      N(ue);
    while (ue.token === `
`);
  }
  function V(ue) {
    ue.nestingLevel++;
  }
  function k(ue) {
    ue.nestingLevel--;
  }
  S.isAlpha = function(pe, Ae, ye) {
    return S.isValidLatinOrGreek(pe) || S.isValidMathSymbol(pe, ye) || S.isValidMathSymbol(Ae, pe);
  }, S.isValidLatinOrGreek = function(pe) {
    return /^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(pe);
  }, S.isValidMathSymbol = function(pe, Ae) {
    return /^[\uD835]$/.test(pe) && /^[\uDC00-\uDFFF]$/.test(Ae) && /^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(Ae);
  }, S.isWhitespace = function(pe, Ae) {
    return pe === " " || pe === "	" || pe === `
` && Ae > 0;
  }, S.isDecimalMark = function(pe, Ae) {
    return pe === "." && Ae !== "/" && Ae !== "*" && Ae !== "^";
  }, S.isDigitDot = function(pe) {
    return pe >= "0" && pe <= "9" || pe === ".";
  }, S.isDigit = function(pe) {
    return pe >= "0" && pe <= "9";
  }, S.isHexDigit = function(pe) {
    return pe >= "0" && pe <= "9" || pe >= "a" && pe <= "f" || pe >= "A" && pe <= "F";
  };
  function G(ue, pe) {
    var Ae = x();
    Xa(Ae, {
      expression: ue,
      extraNodes: pe
    }), N(Ae);
    var ye = L(Ae);
    if (Ae.token !== "")
      throw Ae.tokenType === g.DELIMITER ? Me(Ae, "Unexpected operator " + Ae.token) : Ee(Ae, 'Unexpected part "' + Ae.token + '"');
    return ye;
  }
  function L(ue) {
    var pe, Ae = [], ye;
    for (ue.token !== "" && ue.token !== `
` && ue.token !== ";" && (pe = R(ue), ue.comment && (pe.comment = ue.comment)); ue.token === `
` || ue.token === ";"; )
      Ae.length === 0 && pe && (ye = ue.token !== ";", Ae.push({
        node: pe,
        visible: ye
      })), N(ue), ue.token !== `
` && ue.token !== ";" && ue.token !== "" && (pe = R(ue), ue.comment && (pe.comment = ue.comment), ye = ue.token !== ";", Ae.push({
        node: pe,
        visible: ye
      }));
    return Ae.length > 0 ? new c(Ae) : (pe || (pe = new u(void 0), ue.comment && (pe.comment = ue.comment)), pe);
  }
  function R(ue) {
    var pe, Ae, ye, be, fe = F(ue);
    if (ue.token === "=") {
      if (_a(fe))
        return pe = fe.name, O(ue), ye = R(ue), new o(new C(pe), ye);
      if (Fd(fe))
        return O(ue), ye = R(ue), new o(fe.object, fe.index, ye);
      if (hc(fe) && _a(fe.fn) && (be = !0, Ae = [], pe = fe.name, fe.args.forEach(function(ge, xe) {
        _a(ge) ? Ae[xe] = ge.name : be = !1;
      }), be))
        return O(ue), ye = R(ue), new l(pe, Ae, ye);
      throw Ee(ue, "Invalid left hand side of assignment operator =");
    }
    return fe;
  }
  function F(ue) {
    for (var pe = U(ue); ue.token === "?"; ) {
      var Ae = ue.conditionalLevel;
      ue.conditionalLevel = ue.nestingLevel, O(ue);
      var ye = pe, be = R(ue);
      if (ue.token !== ":") throw Ee(ue, "False part of conditional expression expected");
      ue.conditionalLevel = null, O(ue);
      var fe = R(ue);
      pe = new s(ye, be, fe), ue.conditionalLevel = Ae;
    }
    return pe;
  }
  function U(ue) {
    for (var pe = H(ue); ue.token === "or"; )
      O(ue), pe = new p("or", "or", [pe, H(ue)]);
    return pe;
  }
  function H(ue) {
    for (var pe = q(ue); ue.token === "xor"; )
      O(ue), pe = new p("xor", "xor", [pe, q(ue)]);
    return pe;
  }
  function q(ue) {
    for (var pe = K(ue); ue.token === "and"; )
      O(ue), pe = new p("and", "and", [pe, K(ue)]);
    return pe;
  }
  function K(ue) {
    for (var pe = Y(ue); ue.token === "|"; )
      O(ue), pe = new p("|", "bitOr", [pe, Y(ue)]);
    return pe;
  }
  function Y(ue) {
    for (var pe = X(ue); ue.token === "^|"; )
      O(ue), pe = new p("^|", "bitXor", [pe, X(ue)]);
    return pe;
  }
  function X(ue) {
    for (var pe = Z(ue); ue.token === "&"; )
      O(ue), pe = new p("&", "bitAnd", [pe, Z(ue)]);
    return pe;
  }
  function Z(ue) {
    for (var pe = [J(ue)], Ae = [], ye = {
      "==": "equal",
      "!=": "unequal",
      "<": "smaller",
      ">": "larger",
      "<=": "smallerEq",
      ">=": "largerEq"
    }; er(ye, ue.token); ) {
      var be = {
        name: ue.token,
        fn: ye[ue.token]
      };
      Ae.push(be), O(ue), pe.push(J(ue));
    }
    return pe.length === 1 ? pe[0] : pe.length === 2 ? new p(Ae[0].name, Ae[0].fn, pe) : new y(Ae.map((fe) => fe.fn), pe);
  }
  function J(ue) {
    var pe, Ae, ye, be;
    pe = $(ue);
    for (var fe = {
      "<<": "leftShift",
      ">>": "rightArithShift",
      ">>>": "rightLogShift"
    }; er(fe, ue.token); )
      Ae = ue.token, ye = fe[Ae], O(ue), be = [pe, $(ue)], pe = new p(Ae, ye, be);
    return pe;
  }
  function $(ue) {
    var pe, Ae, ye, be;
    pe = Q(ue);
    for (var fe = {
      to: "to",
      in: "to"
      // alias of 'to'
    }; er(fe, ue.token); )
      Ae = ue.token, ye = fe[Ae], O(ue), Ae === "in" && ue.token === "" ? pe = new p("*", "multiply", [pe, new C("in")], !0) : (be = [pe, Q(ue)], pe = new p(Ae, ye, be));
    return pe;
  }
  function Q(ue) {
    var pe, Ae = [];
    if (ue.token === ":" ? pe = new u(1) : pe = W(ue), ue.token === ":" && ue.conditionalLevel !== ue.nestingLevel) {
      for (Ae.push(pe); ue.token === ":" && Ae.length < 3; )
        O(ue), ue.token === ")" || ue.token === "]" || ue.token === "," || ue.token === "" ? Ae.push(new C("end")) : Ae.push(W(ue));
      Ae.length === 3 ? pe = new h(Ae[0], Ae[2], Ae[1]) : pe = new h(Ae[0], Ae[1]);
    }
    return pe;
  }
  function W(ue) {
    var pe, Ae, ye, be;
    pe = te(ue);
    for (var fe = {
      "+": "add",
      "-": "subtract"
    }; er(fe, ue.token); ) {
      Ae = ue.token, ye = fe[Ae], O(ue);
      var ge = te(ue);
      ge.isPercentage ? be = [pe, new p("*", "multiply", [pe, ge])] : be = [pe, ge], pe = new p(Ae, ye, be);
    }
    return pe;
  }
  function te(ue) {
    var pe, Ae, ye, be;
    pe = oe(ue), Ae = pe;
    for (var fe = {
      "*": "multiply",
      ".*": "dotMultiply",
      "/": "divide",
      "./": "dotDivide"
    }; er(fe, ue.token); )
      ye = ue.token, be = fe[ye], O(ue), Ae = oe(ue), pe = new p(ye, be, [pe, Ae]);
    return pe;
  }
  function oe(ue) {
    var pe, Ae;
    for (pe = z(ue), Ae = pe; ue.tokenType === g.SYMBOL || ue.token === "in" && Jr(pe) || ue.tokenType === g.NUMBER && !Jr(Ae) && (!Hn(Ae) || Ae.op === "!") || ue.token === "("; )
      Ae = z(ue), pe = new p(
        "*",
        "multiply",
        [pe, Ae],
        !0
        /* implicit */
      );
    return pe;
  }
  function z(ue) {
    for (var pe = j(ue), Ae = pe, ye = []; ue.token === "/" && pw(Ae); )
      if (ye.push(Xa({}, ue)), O(ue), ue.tokenType === g.NUMBER)
        if (ye.push(Xa({}, ue)), O(ue), ue.tokenType === g.SYMBOL || ue.token === "(")
          Xa(ue, ye.pop()), ye.pop(), Ae = j(ue), pe = new p("/", "divide", [pe, Ae]);
        else {
          ye.pop(), Xa(ue, ye.pop());
          break;
        }
      else {
        Xa(ue, ye.pop());
        break;
      }
    return pe;
  }
  function j(ue) {
    var pe, Ae, ye, be;
    pe = ae(ue);
    for (var fe = {
      "%": "mod",
      mod: "mod"
    }; er(fe, ue.token); )
      Ae = ue.token, ye = fe[Ae], O(ue), Ae === "%" && ue.tokenType === g.DELIMITER && ue.token !== "(" ? pe = new p("/", "divide", [pe, new u(100)], !1, !0) : (be = [pe, ae(ue)], pe = new p(Ae, ye, be));
    return pe;
  }
  function ae(ue) {
    var pe, Ae, ye, be = {
      "-": "unaryMinus",
      "+": "unaryPlus",
      "~": "bitNot",
      not: "not"
    };
    return er(be, ue.token) ? (ye = be[ue.token], pe = ue.token, O(ue), Ae = [ae(ue)], new p(pe, ye, Ae)) : le(ue);
  }
  function le(ue) {
    var pe, Ae, ye, be;
    return pe = ie(ue), (ue.token === "^" || ue.token === ".^") && (Ae = ue.token, ye = Ae === "^" ? "pow" : "dotPow", O(ue), be = [pe, ae(ue)], pe = new p(Ae, ye, be)), pe;
  }
  function ie(ue) {
    var pe, Ae, ye, be;
    pe = re(ue);
    for (var fe = {
      "!": "factorial",
      "'": "ctranspose"
    }; er(fe, ue.token); )
      Ae = ue.token, ye = fe[Ae], N(ue), be = [pe], pe = new p(Ae, ye, be), pe = ne(ue, pe);
    return pe;
  }
  function re(ue) {
    var pe = [];
    if (ue.tokenType === g.SYMBOL && er(ue.extraNodes, ue.token)) {
      var Ae = ue.extraNodes[ue.token];
      if (N(ue), ue.token === "(") {
        if (pe = [], V(ue), N(ue), ue.token !== ")")
          for (pe.push(R(ue)); ue.token === ","; )
            N(ue), pe.push(R(ue));
        if (ue.token !== ")")
          throw Ee(ue, "Parenthesis ) expected");
        k(ue), N(ue);
      }
      return new Ae(pe);
    }
    return ee(ue);
  }
  function ee(ue) {
    var pe, Ae;
    return ue.tokenType === g.SYMBOL || ue.tokenType === g.DELIMITER && ue.token in A ? (Ae = ue.token, N(ue), er(M, Ae) ? pe = new u(M[Ae]) : P.includes(Ae) ? pe = new u(t(Ae, "number")) : pe = new C(Ae), pe = ne(ue, pe), pe) : se(ue);
  }
  function ne(ue, pe, Ae) {
    for (var ye; (ue.token === "(" || ue.token === "[" || ue.token === ".") && !Ae; )
      if (ye = [], ue.token === "(")
        if (_a(pe) || Fd(pe)) {
          if (V(ue), N(ue), ue.token !== ")")
            for (ye.push(R(ue)); ue.token === ","; )
              N(ue), ye.push(R(ue));
          if (ue.token !== ")")
            throw Ee(ue, "Parenthesis ) expected");
          k(ue), N(ue), pe = new f(pe, ye);
        } else
          return pe;
      else if (ue.token === "[") {
        if (V(ue), N(ue), ue.token !== "]")
          for (ye.push(R(ue)); ue.token === ","; )
            N(ue), ye.push(R(ue));
        if (ue.token !== "]")
          throw Ee(ue, "Parenthesis ] expected");
        k(ue), N(ue), pe = new a(pe, new d(ye));
      } else {
        N(ue);
        var be = ue.tokenType === g.SYMBOL || ue.tokenType === g.DELIMITER && ue.token in A;
        if (!be)
          throw Ee(ue, "Property name expected after dot");
        ye.push(new u(ue.token)), N(ue);
        var fe = !0;
        pe = new a(pe, new d(ye, fe));
      }
    return pe;
  }
  function se(ue) {
    var pe, Ae;
    return ue.token === '"' || ue.token === "'" ? (Ae = ce(ue, ue.token), pe = new u(Ae), pe = ne(ue, pe), pe) : de(ue);
  }
  function ce(ue, pe) {
    for (var Ae = ""; E(ue) !== "" && E(ue) !== pe; )
      if (E(ue) === "\\") {
        I(ue);
        var ye = E(ue), be = T[ye];
        if (be !== void 0)
          Ae += be, ue.index += 1;
        else if (ye === "u") {
          var fe = ue.expression.slice(ue.index + 1, ue.index + 5);
          if (/^[0-9A-Fa-f]{4}$/.test(fe))
            Ae += String.fromCharCode(parseInt(fe, 16)), ue.index += 5;
          else
            throw Ee(ue, "Invalid unicode character \\u".concat(fe));
        } else
          throw Ee(ue, "Bad escape character \\".concat(ye));
      } else
        Ae += E(ue), I(ue);
    if (N(ue), ue.token !== pe)
      throw Ee(ue, "End of string ".concat(pe, " expected"));
    return N(ue), Ae;
  }
  function de(ue) {
    var pe, Ae, ye, be;
    if (ue.token === "[") {
      if (V(ue), N(ue), ue.token !== "]") {
        var fe = me(ue);
        if (ue.token === ";") {
          for (ye = 1, Ae = [fe]; ue.token === ";"; )
            N(ue), ue.token !== "]" && (Ae[ye] = me(ue), ye++);
          if (ue.token !== "]")
            throw Ee(ue, "End of matrix ] expected");
          k(ue), N(ue), be = Ae[0].items.length;
          for (var ge = 1; ge < ye; ge++)
            if (Ae[ge].items.length !== be)
              throw Me(ue, "Column dimensions mismatch (" + Ae[ge].items.length + " !== " + be + ")");
          pe = new i(Ae);
        } else {
          if (ue.token !== "]")
            throw Ee(ue, "End of matrix ] expected");
          k(ue), N(ue), pe = fe;
        }
      } else
        k(ue), N(ue), pe = new i([]);
      return ne(ue, pe);
    }
    return he(ue);
  }
  function me(ue) {
    for (var pe = [R(ue)], Ae = 1; ue.token === ","; )
      N(ue), ue.token !== "]" && ue.token !== ";" && (pe[Ae] = R(ue), Ae++);
    return new i(pe);
  }
  function he(ue) {
    if (ue.token === "{") {
      V(ue);
      var pe, Ae = {};
      do
        if (N(ue), ue.token !== "}") {
          if (ue.token === '"' || ue.token === "'")
            pe = ce(ue, ue.token);
          else if (ue.tokenType === g.SYMBOL || ue.tokenType === g.DELIMITER && ue.token in A)
            pe = ue.token, N(ue);
          else
            throw Ee(ue, "Symbol or string expected as object key");
          if (ue.token !== ":")
            throw Ee(ue, "Colon : expected after object key");
          N(ue), Ae[pe] = R(ue);
        }
      while (ue.token === ",");
      if (ue.token !== "}")
        throw Ee(ue, "Comma , or bracket } expected after object value");
      k(ue), N(ue);
      var ye = new m(Ae);
      return ye = ne(ue, ye), ye;
    }
    return _e(ue);
  }
  function _e(ue) {
    var pe;
    if (ue.tokenType === g.NUMBER) {
      pe = ue.token, N(ue);
      var Ae = rf(pe, n), ye = t(pe, Ae);
      return new u(ye);
    }
    return Se(ue);
  }
  function Se(ue) {
    var pe;
    if (ue.token === "(") {
      if (V(ue), N(ue), pe = R(ue), ue.token !== ")")
        throw Ee(ue, "Parenthesis ) expected");
      return k(ue), N(ue), pe = new v(pe), pe = ne(ue, pe), pe;
    }
    return Pe(ue);
  }
  function Pe(ue) {
    throw ue.token === "" ? Ee(ue, "Unexpected end of expression") : Ee(ue, "Value expected");
  }
  function De(ue) {
    return ue.index - ue.token.length + 1;
  }
  function Ee(ue, pe) {
    var Ae = De(ue), ye = new SyntaxError(pe + " (char " + Ae + ")");
    return ye.char = Ae, ye;
  }
  function Me(ue, pe) {
    var Ae = De(ue), ye = new SyntaxError(pe + " (char " + Ae + ")");
    return ye.char = Ae, ye;
  }
  return r.addConversion({
    from: "string",
    to: "Node",
    convert: S
  }), S;
}), TL = "compile", rIe = ["typed", "parse"], tIe = /* @__PURE__ */ Ce(TL, rIe, (e) => {
  var {
    typed: r,
    parse: t
  } = e;
  return r(TL, {
    string: function(a) {
      return t(a).compile();
    },
    "Array | Matrix": function(a) {
      return zr(a, function(i) {
        return t(i).compile();
      });
    }
  });
}), PL = "evaluate", nIe = ["typed", "parse"], aIe = /* @__PURE__ */ Ce(PL, nIe, (e) => {
  var {
    typed: r,
    parse: t
  } = e;
  return r(PL, {
    string: function(a) {
      var i = Lg();
      return t(a).compile().evaluate(i);
    },
    "string, Map | Object": function(a, i) {
      return t(a).compile().evaluate(i);
    },
    "Array | Matrix": function(a) {
      var i = Lg();
      return zr(a, function(o) {
        return t(o).compile().evaluate(i);
      });
    },
    "Array | Matrix, Map | Object": function(a, i) {
      return zr(a, function(o) {
        return t(o).compile().evaluate(i);
      });
    }
  });
}), iIe = "Parser", oIe = ["evaluate"], uIe = /* @__PURE__ */ Ce(iIe, oIe, (e) => {
  var {
    evaluate: r
  } = e;
  function t() {
    if (!(this instanceof t))
      throw new SyntaxError("Constructor must be called with the new operator");
    Object.defineProperty(this, "scope", {
      value: Lg(),
      writable: !1
    });
  }
  return t.prototype.type = "Parser", t.prototype.isParser = !0, t.prototype.evaluate = function(n) {
    return r(n, this.scope);
  }, t.prototype.get = function(n) {
    if (this.scope.has(n))
      return this.scope.get(n);
  }, t.prototype.getAll = function() {
    return hAe(this.scope);
  }, t.prototype.getAllAsMap = function() {
    return this.scope;
  }, t.prototype.set = function(n, a) {
    return this.scope.set(n, a), a;
  }, t.prototype.remove = function(n) {
    this.scope.delete(n);
  }, t.prototype.clear = function() {
    this.scope.clear();
  }, t;
}, {
  isClass: !0
}), ML = "parser", sIe = ["typed", "Parser"], lIe = /* @__PURE__ */ Ce(ML, sIe, (e) => {
  var {
    typed: r,
    Parser: t
  } = e;
  return r(ML, {
    "": function() {
      return new t();
    }
  });
}), wL = "lup", cIe = ["typed", "matrix", "abs", "addScalar", "divideScalar", "multiplyScalar", "subtractScalar", "larger", "equalScalar", "unaryMinus", "DenseMatrix", "SparseMatrix", "Spa"], dIe = /* @__PURE__ */ Ce(wL, cIe, (e) => {
  var {
    typed: r,
    matrix: t,
    abs: n,
    addScalar: a,
    divideScalar: i,
    multiplyScalar: o,
    subtractScalar: c,
    larger: s,
    equalScalar: u,
    unaryMinus: l,
    DenseMatrix: f,
    SparseMatrix: d,
    Spa: m
  } = e;
  return r(wL, {
    DenseMatrix: function(y) {
      return p(y);
    },
    SparseMatrix: function(y) {
      return v(y);
    },
    Array: function(y) {
      var C = t(y), S = p(C);
      return {
        L: S.L.valueOf(),
        U: S.U.valueOf(),
        p: S.p
      };
    }
  });
  function p(h) {
    var y = h._size[0], C = h._size[1], S = Math.min(y, C), b = Sr(h._data), g = [], _ = [y, S], A = [], M = [S, C], P, T, x, w = [];
    for (P = 0; P < y; P++)
      w[P] = P;
    for (T = 0; T < C; T++) {
      if (T > 0)
        for (P = 0; P < y; P++) {
          var E = Math.min(P, T), I = 0;
          for (x = 0; x < E; x++)
            I = a(I, o(b[P][x], b[x][T]));
          b[P][T] = c(b[P][T], I);
        }
      var B = T, D = 0, N = 0;
      for (P = T; P < y; P++) {
        var O = b[P][T], V = n(O);
        s(V, D) && (B = P, D = V, N = O);
      }
      if (T !== B && (w[T] = [w[B], w[B] = w[T]][0], f._swapRows(T, B, b)), T < y)
        for (P = T + 1; P < y; P++) {
          var k = b[P][T];
          u(k, 0) || (b[P][T] = i(b[P][T], N));
        }
    }
    for (T = 0; T < C; T++)
      for (P = 0; P < y; P++) {
        if (T === 0 && (P < C && (A[P] = []), g[P] = []), P < T) {
          P < C && (A[P][T] = b[P][T]), T < y && (g[P][T] = 0);
          continue;
        }
        if (P === T) {
          P < C && (A[P][T] = b[P][T]), T < y && (g[P][T] = 1);
          continue;
        }
        P < C && (A[P][T] = 0), T < y && (g[P][T] = b[P][T]);
      }
    var G = new f({
      data: g,
      size: _
    }), L = new f({
      data: A,
      size: M
    }), R = [];
    for (P = 0, S = w.length; P < S; P++)
      R[w[P]] = P;
    return {
      L: G,
      U: L,
      p: R,
      toString: function() {
        return "L: " + this.L.toString() + `
U: ` + this.U.toString() + `
P: ` + this.p;
      }
    };
  }
  function v(h) {
    var y = h._size[0], C = h._size[1], S = Math.min(y, C), b = h._values, g = h._index, _ = h._ptr, A = [], M = [], P = [], T = [y, S], x = [], w = [], E = [], I = [S, C], B, D, N, O = [], V = [];
    for (B = 0; B < y; B++)
      O[B] = B, V[B] = B;
    var k = function(R, F) {
      var U = V[R], H = V[F];
      O[U] = F, O[H] = R, V[R] = H, V[F] = U;
    }, G = function() {
      var R = new m();
      D < y && (P.push(A.length), A.push(1), M.push(D)), E.push(x.length);
      var F = _[D], U = _[D + 1];
      for (N = F; N < U; N++)
        B = g[N], R.set(O[B], b[N]);
      D > 0 && R.forEach(0, D - 1, function(Y, X) {
        d._forEachRow(Y, A, M, P, function(Z, J) {
          Z > Y && R.accumulate(Z, l(o(J, X)));
        });
      });
      var H = D, q = R.get(D), K = n(q);
      R.forEach(D + 1, y - 1, function(Y, X) {
        var Z = n(X);
        s(Z, K) && (H = Y, K = Z, q = X);
      }), D !== H && (d._swapRows(D, H, T[1], A, M, P), d._swapRows(D, H, I[1], x, w, E), R.swap(D, H), k(D, H)), R.forEach(0, y - 1, function(Y, X) {
        Y <= D ? (x.push(X), w.push(Y)) : (X = i(X, q), u(X, 0) || (A.push(X), M.push(Y)));
      });
    };
    for (D = 0; D < C; D++)
      G();
    return E.push(x.length), P.push(A.length), {
      L: new d({
        values: A,
        index: M,
        ptr: P,
        size: T
      }),
      U: new d({
        values: x,
        index: w,
        ptr: E,
        size: I
      }),
      p: O,
      toString: function() {
        return "L: " + this.L.toString() + `
U: ` + this.U.toString() + `
P: ` + this.p;
      }
    };
  }
}), EL = "qr", fIe = ["typed", "matrix", "zeros", "identity", "isZero", "equal", "sign", "sqrt", "conj", "unaryMinus", "addScalar", "divideScalar", "multiplyScalar", "subtractScalar", "complex"], fY = /* @__PURE__ */ Ce(EL, fIe, (e) => {
  var {
    typed: r,
    matrix: t,
    zeros: n,
    identity: a,
    isZero: i,
    equal: o,
    sign: c,
    sqrt: s,
    conj: u,
    unaryMinus: l,
    addScalar: f,
    divideScalar: d,
    multiplyScalar: m,
    subtractScalar: p,
    complex: v
  } = e;
  return Xa(r(EL, {
    DenseMatrix: function(b) {
      return y(b);
    },
    SparseMatrix: function(b) {
      return C();
    },
    Array: function(b) {
      var g = t(b), _ = y(g);
      return {
        Q: _.Q.valueOf(),
        R: _.R.valueOf()
      };
    }
  }), {
    _denseQRimpl: h
  });
  function h(S) {
    var b = S._size[0], g = S._size[1], _ = a([b], "dense"), A = _._data, M = S.clone(), P = M._data, T, x, w, E = n([b], "");
    for (w = 0; w < Math.min(g, b); ++w) {
      var I = P[w][w], B = l(o(I, 0) ? 1 : c(I)), D = u(B), N = 0;
      for (T = w; T < b; T++)
        N = f(N, m(P[T][w], u(P[T][w])));
      var O = m(B, s(N));
      if (!i(O)) {
        var V = p(I, O);
        for (E[w] = 1, T = w + 1; T < b; T++)
          E[T] = d(P[T][w], V);
        var k = l(u(d(V, O))), G = void 0;
        for (x = w; x < g; x++) {
          for (G = 0, T = w; T < b; T++)
            G = f(G, m(u(E[T]), P[T][x]));
          for (G = m(G, k), T = w; T < b; T++)
            P[T][x] = m(p(P[T][x], m(E[T], G)), D);
        }
        for (T = 0; T < b; T++) {
          for (G = 0, x = w; x < b; x++)
            G = f(G, m(A[T][x], E[x]));
          for (G = m(G, k), x = w; x < b; ++x)
            A[T][x] = d(p(A[T][x], m(G, u(E[x]))), D);
        }
      }
    }
    return {
      Q: _,
      R: M,
      toString: function() {
        return "Q: " + this.Q.toString() + `
R: ` + this.R.toString();
      }
    };
  }
  function y(S) {
    var b = h(S), g = b.R._data;
    if (S._data.length > 0)
      for (var _ = g[0][0].type === "Complex" ? v(0) : 0, A = 0; A < g.length; ++A)
        for (var M = 0; M < A && M < (g[0] || []).length; ++M)
          g[A][M] = _;
    return b;
  }
  function C(S) {
    throw new Error("qr not implemented for sparse matrices yet");
  }
});
function mIe(e, r, t, n) {
  e._values;
  for (var a = e._index, i = e._ptr, o = e._size, c = e._datatype, s = o[0], u = o[1], l = null, f = [], d = [], m = 0, p = 0; p < u; p++) {
    d[p] = m;
    for (var v = t ? t[p] : p, h = i[v], y = i[v + 1], C = h; C < y; C++) {
      var S = a[C];
      f[m] = S, m++;
    }
  }
  return d[u] = m, e.createSparseMatrix({
    values: l,
    index: f,
    ptr: d,
    size: [s, u],
    datatype: c
  });
}
function mY(e, r, t, n, a, i, o) {
  var c = 0;
  for (t[o] = e; c >= 0; ) {
    var s = t[o + c], u = t[n + s];
    u === -1 ? (c--, i[r++] = s) : (t[n + s] = t[a + u], ++c, t[o + c] = u);
  }
  return r;
}
function vIe(e, r) {
  if (!e)
    return null;
  var t = 0, n, a = [], i = [], o = 0, c = r, s = 2 * r;
  for (n = 0; n < r; n++)
    i[o + n] = -1;
  for (n = r - 1; n >= 0; n--)
    e[n] !== -1 && (i[c + n] = i[o + e[n]], i[o + e[n]] = n);
  for (n = 0; n < r; n++)
    e[n] === -1 && (t = mY(n, t, i, o, c, a, s));
  return a;
}
function pIe(e, r) {
  if (!e)
    return null;
  var t = e._index, n = e._ptr, a = e._size, i = a[0], o = a[1], c = [], s = [], u = 0, l = o, f, d;
  for (f = 0; f < i; f++)
    s[l + f] = -1;
  for (var m = 0; m < o; m++) {
    c[m] = -1, s[u + m] = -1;
    for (var p = n[m], v = n[m + 1], h = p; h < v; h++) {
      var y = t[h];
      for (f = s[l + y]; f !== -1 && f < m; f = d)
        d = s[u + f], s[u + f] = m, d === -1 && (c[f] = m);
      s[l + y] = m;
    }
  }
  return c;
}
function hIe(e, r, t) {
  for (var n = e._values, a = e._index, i = e._ptr, o = e._size, c = o[1], s = 0, u = 0; u < c; u++) {
    var l = i[u];
    for (i[u] = s; l < i[u + 1]; l++)
      r(a[l], u, n ? n[l] : 1, t) && (a[s] = a[l], n && (n[s] = n[l]), s++);
  }
  return i[c] = s, a.splice(s, a.length - s), n && n.splice(s, n.length - s), s;
}
function Jc(e) {
  return -e - 2;
}
var gIe = "csAmd", yIe = ["add", "multiply", "transpose"], _Ie = /* @__PURE__ */ Ce(gIe, yIe, (e) => {
  var {
    add: r,
    multiply: t,
    transpose: n
  } = e;
  return function(l, f) {
    if (!f || l <= 0 || l > 3)
      return null;
    var d = f._size, m = d[0], p = d[1], v = 0, h = Math.max(16, 10 * Math.sqrt(p));
    h = Math.min(p - 2, h);
    var y = a(l, f, m, p, h);
    hIe(y, s, null);
    for (var C = y._index, S = y._ptr, b = S[p], g = [], _ = [], A = 0, M = p + 1, P = 2 * (p + 1), T = 3 * (p + 1), x = 4 * (p + 1), w = 5 * (p + 1), E = 6 * (p + 1), I = 7 * (p + 1), B = g, D = i(p, S, _, A, T, B, P, I, M, E, x, w), N = o(p, S, _, w, x, E, h, M, T, B, P), O = 0, V, k, G, L, R, F, U, H, q, K, Y, X, Z, J, $, Q; N < p; ) {
      for (G = -1; O < p && (G = _[T + O]) === -1; O++) ;
      _[P + G] !== -1 && (B[_[P + G]] = -1), _[T + O] = _[P + G];
      var W = _[x + G], te = _[M + G];
      N += te;
      var oe = 0;
      _[M + G] = -te;
      var z = S[G], j = W === 0 ? z : b, ae = j;
      for (L = 1; L <= W + 1; L++) {
        for (L > W ? (F = G, U = z, H = _[A + G] - W) : (F = C[z++], U = S[F], H = _[A + F]), R = 1; R <= H; R++)
          V = C[U++], !((q = _[M + V]) <= 0) && (oe += q, _[M + V] = -q, C[ae++] = V, _[P + V] !== -1 && (B[_[P + V]] = B[V]), B[V] !== -1 ? _[P + B[V]] = _[P + V] : _[T + _[w + V]] = _[P + V]);
        F !== G && (S[F] = Jc(G), _[E + F] = 0);
      }
      for (W !== 0 && (b = ae), _[w + G] = oe, S[G] = j, _[A + G] = ae - j, _[x + G] = -2, D = c(D, v, _, E, p), K = j; K < ae; K++)
        if (V = C[K], !((Y = _[x + V]) <= 0)) {
          q = -_[M + V];
          var le = D - q;
          for (z = S[V], X = S[V] + Y - 1; z <= X; z++)
            F = C[z], _[E + F] >= D ? _[E + F] -= q : _[E + F] !== 0 && (_[E + F] = _[w + F] + le);
        }
      for (K = j; K < ae; K++) {
        for (V = C[K], X = S[V], Z = X + _[x + V] - 1, J = X, $ = 0, Q = 0, z = X; z <= Z; z++)
          if (F = C[z], _[E + F] !== 0) {
            var ie = _[E + F] - D;
            ie > 0 ? (Q += ie, C[J++] = F, $ += F) : (S[F] = Jc(G), _[E + F] = 0);
          }
        _[x + V] = J - X + 1;
        var re = J, ee = X + _[A + V];
        for (z = Z + 1; z < ee; z++) {
          k = C[z];
          var ne = _[M + k];
          ne <= 0 || (Q += ne, C[J++] = k, $ += k);
        }
        Q === 0 ? (S[V] = Jc(G), q = -_[M + V], oe -= q, te += q, N += q, _[M + V] = 0, _[x + V] = -1) : (_[w + V] = Math.min(_[w + V], Q), C[J] = C[re], C[re] = C[X], C[X] = G, _[A + V] = J - X + 1, $ = ($ < 0 ? -$ : $) % p, _[P + V] = _[I + $], _[I + $] = V, B[V] = $);
      }
      for (_[w + G] = oe, v = Math.max(v, oe), D = c(D + v, v, _, E, p), K = j; K < ae; K++)
        if (V = C[K], !(_[M + V] >= 0))
          for ($ = B[V], V = _[I + $], _[I + $] = -1; V !== -1 && _[P + V] !== -1; V = _[P + V], D++) {
            for (H = _[A + V], Y = _[x + V], z = S[V] + 1; z <= S[V] + H - 1; z++)
              _[E + C[z]] = D;
            var se = V;
            for (k = _[P + V]; k !== -1; ) {
              var ce = _[A + k] === H && _[x + k] === Y;
              for (z = S[k] + 1; ce && z <= S[k] + H - 1; z++)
                _[E + C[z]] !== D && (ce = 0);
              ce ? (S[k] = Jc(V), _[M + V] += _[M + k], _[M + k] = 0, _[x + k] = -1, k = _[P + k], _[P + se] = k) : (se = k, k = _[P + k]);
            }
          }
      for (z = j, K = j; K < ae; K++)
        V = C[K], !((q = -_[M + V]) <= 0) && (_[M + V] = q, Q = _[w + V] + oe - q, Q = Math.min(Q, p - N - q), _[T + Q] !== -1 && (B[_[T + Q]] = V), _[P + V] = _[T + Q], B[V] = -1, _[T + Q] = V, O = Math.min(O, Q), _[w + V] = Q, C[z++] = V);
      _[M + G] = te, (_[A + G] = z - j) === 0 && (S[G] = -1, _[E + G] = 0), W !== 0 && (b = z);
    }
    for (V = 0; V < p; V++)
      S[V] = Jc(S[V]);
    for (k = 0; k <= p; k++)
      _[T + k] = -1;
    for (k = p; k >= 0; k--)
      _[M + k] > 0 || (_[P + k] = _[T + S[k]], _[T + S[k]] = k);
    for (F = p; F >= 0; F--)
      _[M + F] <= 0 || S[F] !== -1 && (_[P + F] = _[T + S[F]], _[T + S[F]] = F);
    for (G = 0, V = 0; V <= p; V++)
      S[V] === -1 && (G = mY(V, G, _, T, P, g, E));
    return g.splice(g.length - 1, 1), g;
  };
  function a(u, l, f, d, m) {
    var p = n(l);
    if (u === 1 && d === f)
      return r(l, p);
    if (u === 2) {
      for (var v = p._index, h = p._ptr, y = 0, C = 0; C < f; C++) {
        var S = h[C];
        if (h[C] = y, !(h[C + 1] - S > m))
          for (var b = h[C + 1]; S < b; S++)
            v[y++] = v[S];
      }
      return h[f] = y, l = n(p), t(p, l);
    }
    return t(p, l);
  }
  function i(u, l, f, d, m, p, v, h, y, C, S, b) {
    for (var g = 0; g < u; g++)
      f[d + g] = l[g + 1] - l[g];
    f[d + u] = 0;
    for (var _ = 0; _ <= u; _++)
      f[m + _] = -1, p[_] = -1, f[v + _] = -1, f[h + _] = -1, f[y + _] = 1, f[C + _] = 1, f[S + _] = 0, f[b + _] = f[d + _];
    var A = c(0, 0, f, C, u);
    return f[S + u] = -2, l[u] = -1, f[C + u] = 0, A;
  }
  function o(u, l, f, d, m, p, v, h, y, C, S) {
    for (var b = 0, g = 0; g < u; g++) {
      var _ = f[d + g];
      if (_ === 0)
        f[m + g] = -2, b++, l[g] = -1, f[p + g] = 0;
      else if (_ > v)
        f[h + g] = 0, f[m + g] = -1, b++, l[g] = Jc(u), f[h + u]++;
      else {
        var A = f[y + _];
        A !== -1 && (C[A] = g), f[S + g] = f[y + _], f[y + _] = g;
      }
    }
    return b;
  }
  function c(u, l, f, d, m) {
    if (u < 2 || u + l < 0) {
      for (var p = 0; p < m; p++)
        f[d + p] !== 0 && (f[d + p] = 1);
      u = 2;
    }
    return u;
  }
  function s(u, l) {
    return u !== l;
  }
});
function bIe(e, r, t, n, a, i, o) {
  var c, s, u = 0, l;
  if (e <= r || t[n + r] <= t[a + e])
    return -1;
  t[a + e] = t[n + r];
  var f = t[i + e];
  if (t[i + e] = r, f === -1)
    u = 1, l = e;
  else {
    for (u = 2, l = f; l !== t[o + l]; l = t[o + l]) ;
    for (c = f; c !== l; c = s)
      s = t[o + c], t[o + c] = l;
  }
  return {
    jleaf: u,
    q: l
  };
}
var SIe = "csCounts", CIe = ["transpose"], AIe = /* @__PURE__ */ Ce(SIe, CIe, (e) => {
  var {
    transpose: r
  } = e;
  return function(t, n, a, i) {
    if (!t || !n || !a)
      return null;
    var o = t._size, c = o[0], s = o[1], u, l, f, d, m, p, v, h = 4 * s + (i ? s + c + 1 : 0), y = [], C = 0, S = s, b = 2 * s, g = 3 * s, _ = 4 * s, A = 5 * s + 1;
    for (f = 0; f < h; f++)
      y[f] = -1;
    var M = [], P = r(t), T = P._index, x = P._ptr;
    for (f = 0; f < s; f++)
      for (l = a[f], M[l] = y[g + l] === -1 ? 1 : 0; l !== -1 && y[g + l] === -1; l = n[l])
        y[g + l] = f;
    if (i) {
      for (f = 0; f < s; f++)
        y[a[f]] = f;
      for (u = 0; u < c; u++) {
        for (f = s, p = x[u], v = x[u + 1], m = p; m < v; m++)
          f = Math.min(f, y[T[m]]);
        y[A + u] = y[_ + f], y[_ + f] = u;
      }
    }
    for (u = 0; u < s; u++)
      y[C + u] = u;
    for (f = 0; f < s; f++) {
      for (l = a[f], n[l] !== -1 && M[n[l]]--, d = i ? y[_ + f] : l; d !== -1; d = i ? y[A + d] : -1)
        for (m = x[d]; m < x[d + 1]; m++) {
          u = T[m];
          var w = bIe(u, l, y, g, S, b, C);
          w.jleaf >= 1 && M[l]++, w.jleaf === 2 && M[w.q]--;
        }
      n[l] !== -1 && (y[C + l] = n[l]);
    }
    for (l = 0; l < s; l++)
      n[l] !== -1 && (M[n[l]] += M[l]);
    return M;
  };
}), xIe = "csSqr", TIe = ["add", "multiply", "transpose"], PIe = /* @__PURE__ */ Ce(xIe, TIe, (e) => {
  var {
    add: r,
    multiply: t,
    transpose: n
  } = e, a = _Ie({
    add: r,
    multiply: t,
    transpose: n
  }), i = AIe({
    transpose: n
  });
  return function(s, u, l) {
    var f = u._ptr, d = u._size, m = d[1], p, v = {};
    if (v.q = a(s, u), s && !v.q)
      return null;
    if (l) {
      var h = s ? mIe(u, null, v.q) : u;
      v.parent = pIe(h);
      var y = vIe(v.parent, m);
      if (v.cp = i(h, v.parent, y, 1), h && v.parent && v.cp && o(h, v))
        for (v.unz = 0, p = 0; p < m; p++)
          v.unz += v.cp[p];
    } else
      v.unz = 4 * f[m] + m, v.lnz = v.unz;
    return v;
  };
  function o(c, s) {
    var u = c._ptr, l = c._index, f = c._size, d = f[0], m = f[1];
    s.pinv = [], s.leftmost = [];
    var p = s.parent, v = s.pinv, h = s.leftmost, y = [], C = 0, S = d, b = d + m, g = d + 2 * m, _, A, M, P, T;
    for (A = 0; A < m; A++)
      y[S + A] = -1, y[b + A] = -1, y[g + A] = 0;
    for (_ = 0; _ < d; _++)
      h[_] = -1;
    for (A = m - 1; A >= 0; A--)
      for (P = u[A], T = u[A + 1], M = P; M < T; M++)
        h[l[M]] = A;
    for (_ = d - 1; _ >= 0; _--)
      v[_] = -1, A = h[_], A !== -1 && (y[g + A]++ === 0 && (y[b + A] = _), y[C + _] = y[S + A], y[S + A] = _);
    for (s.lnz = 0, s.m2 = d, A = 0; A < m; A++)
      if (_ = y[S + A], s.lnz++, _ < 0 && (_ = s.m2++), v[_] = A, !(--g[A] <= 0)) {
        s.lnz += y[g + A];
        var x = p[A];
        x !== -1 && (y[g + x] === 0 && (y[b + x] = y[b + A]), y[C + y[b + A]] = y[S + x], y[S + x] = y[C + _], y[g + x] += y[g + A]);
      }
    for (_ = 0; _ < d; _++)
      v[_] < 0 && (v[_] = A++);
    return !0;
  }
});
function Ow(e, r) {
  return e[r] < 0;
}
function vY(e, r) {
  e[r] = Jc(e[r]);
}
function DL(e) {
  return e < 0 ? Jc(e) : e;
}
function MIe(e, r, t, n, a) {
  var i = r._index, o = r._ptr, c = r._size, s = c[1], u, l, f, d = 0;
  for (n[0] = e; d >= 0; ) {
    e = n[d];
    var m = a ? a[e] : e;
    Ow(o, e) || (vY(o, e), n[s + d] = m < 0 ? 0 : DL(o[m]));
    var p = 1;
    for (l = n[s + d], f = m < 0 ? 0 : DL(o[m + 1]); l < f; l++)
      if (u = i[l], !Ow(o, u)) {
        n[s + d] = l, n[++d] = u, p = 0;
        break;
      }
    p && (d--, n[--t] = e);
  }
  return t;
}
function wIe(e, r, t, n, a) {
  var i = e._ptr, o = e._size, c = r._index, s = r._ptr, u = o[1], l, f, d, m = u;
  for (f = s[t], d = s[t + 1], l = f; l < d; l++) {
    var p = c[l];
    Ow(i, p) || (m = MIe(p, e, m, n, a));
  }
  for (l = m; l < u; l++)
    vY(i, n[l]);
  return m;
}
var EIe = "csSpsolve", DIe = ["divideScalar", "multiply", "subtract"], IIe = /* @__PURE__ */ Ce(EIe, DIe, (e) => {
  var {
    divideScalar: r,
    multiply: t,
    subtract: n
  } = e;
  return function(i, o, c, s, u, l, f) {
    var d = i._values, m = i._index, p = i._ptr, v = i._size, h = v[1], y = o._values, C = o._index, S = o._ptr, b, g, _, A, M = wIe(i, o, c, s, l);
    for (b = M; b < h; b++)
      u[s[b]] = 0;
    for (g = S[c], _ = S[c + 1], b = g; b < _; b++)
      u[C[b]] = y[b];
    for (var P = M; P < h; P++) {
      var T = s[P], x = l ? l[T] : T;
      if (!(x < 0))
        for (g = p[x], _ = p[x + 1], u[T] = r(u[T], d[f ? g : _ - 1]), b = f ? g + 1 : g, A = f ? _ : _ - 1; b < A; b++) {
          var w = m[b];
          u[w] = n(u[w], t(d[b], u[T]));
        }
    }
    return M;
  };
}), BIe = "csLu", NIe = ["abs", "divideScalar", "multiply", "subtract", "larger", "largerEq", "SparseMatrix"], VIe = /* @__PURE__ */ Ce(BIe, NIe, (e) => {
  var {
    abs: r,
    divideScalar: t,
    multiply: n,
    subtract: a,
    larger: i,
    largerEq: o,
    SparseMatrix: c
  } = e, s = IIe({
    divideScalar: t,
    multiply: n,
    subtract: a
  });
  return function(l, f, d) {
    if (!l)
      return null;
    var m = l._size, p = m[1], v, h = 100, y = 100;
    f && (v = f.q, h = f.lnz || h, y = f.unz || y);
    var C = [], S = [], b = [], g = new c({
      values: C,
      index: S,
      ptr: b,
      size: [p, p]
    }), _ = [], A = [], M = [], P = new c({
      values: _,
      index: A,
      ptr: M,
      size: [p, p]
    }), T = [], x, w, E = [], I = [];
    for (x = 0; x < p; x++)
      E[x] = 0, T[x] = -1, b[x + 1] = 0;
    h = 0, y = 0;
    for (var B = 0; B < p; B++) {
      b[B] = h, M[B] = y;
      var D = v ? v[B] : B, N = s(g, l, D, I, E, T, 1), O = -1, V = -1;
      for (w = N; w < p; w++)
        if (x = I[w], T[x] < 0) {
          var k = r(E[x]);
          i(k, V) && (V = k, O = x);
        } else
          A[y] = T[x], _[y++] = E[x];
      if (O === -1 || V <= 0)
        return null;
      T[D] < 0 && o(r(E[D]), n(V, d)) && (O = D);
      var G = E[O];
      for (A[y] = B, _[y++] = G, T[O] = B, S[h] = O, C[h++] = 1, w = N; w < p; w++)
        x = I[w], T[x] < 0 && (S[h] = x, C[h++] = t(E[x], G)), E[x] = 0;
    }
    for (b[p] = h, M[p] = y, w = 0; w < h; w++)
      S[w] = T[S[w]];
    return C.splice(h, C.length - h), S.splice(h, S.length - h), _.splice(y, _.length - y), A.splice(y, A.length - y), {
      L: g,
      U: P,
      pinv: T
    };
  };
}), IL = "slu", RIe = ["typed", "abs", "add", "multiply", "transpose", "divideScalar", "subtract", "larger", "largerEq", "SparseMatrix"], OIe = /* @__PURE__ */ Ce(IL, RIe, (e) => {
  var {
    typed: r,
    abs: t,
    add: n,
    multiply: a,
    transpose: i,
    divideScalar: o,
    subtract: c,
    larger: s,
    largerEq: u,
    SparseMatrix: l
  } = e, f = PIe({
    add: n,
    multiply: a,
    transpose: i
  }), d = VIe({
    abs: t,
    divideScalar: o,
    multiply: a,
    subtract: c,
    larger: s,
    largerEq: u,
    SparseMatrix: l
  });
  return r(IL, {
    "SparseMatrix, number, number": function(p, v, h) {
      if (!lr(v) || v < 0 || v > 3)
        throw new Error("Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]");
      if (h < 0 || h > 1)
        throw new Error("Partial pivoting threshold must be a number from 0 to 1");
      var y = f(v, p, !1), C = d(p, y, h);
      return {
        L: C.L,
        U: C.U,
        p: C.pinv,
        q: y.q,
        toString: function() {
          return "L: " + this.L.toString() + `
U: ` + this.U.toString() + `
p: ` + this.p.toString() + (this.q ? `
q: ` + this.q.toString() : "") + `
`;
        }
      };
    }
  });
});
function BL(e, r) {
  var t, n = r.length, a = [];
  if (e)
    for (t = 0; t < n; t++)
      a[e[t]] = r[t];
  else
    for (t = 0; t < n; t++)
      a[t] = r[t];
  return a;
}
var NL = "lusolve", FIe = ["typed", "matrix", "lup", "slu", "usolve", "lsolve", "DenseMatrix"], LIe = /* @__PURE__ */ Ce(NL, FIe, (e) => {
  var {
    typed: r,
    matrix: t,
    lup: n,
    slu: a,
    usolve: i,
    lsolve: o,
    DenseMatrix: c
  } = e, s = $y({
    DenseMatrix: c
  });
  return r(NL, {
    "Array, Array | Matrix": function(d, m) {
      d = t(d);
      var p = n(d), v = l(p.L, p.U, p.p, null, m);
      return v.valueOf();
    },
    "DenseMatrix, Array | Matrix": function(d, m) {
      var p = n(d);
      return l(p.L, p.U, p.p, null, m);
    },
    "SparseMatrix, Array | Matrix": function(d, m) {
      var p = n(d);
      return l(p.L, p.U, p.p, null, m);
    },
    "SparseMatrix, Array | Matrix, number, number": function(d, m, p, v) {
      var h = a(d, p, v);
      return l(h.L, h.U, h.p, h.q, m);
    },
    "Object, Array | Matrix": function(d, m) {
      return l(d.L, d.U, d.p, d.q, m);
    }
  });
  function u(f) {
    if (gr(f))
      return f;
    if (dt(f))
      return t(f);
    throw new TypeError("Invalid Matrix LU decomposition");
  }
  function l(f, d, m, p, v) {
    f = u(f), d = u(d), m && (v = s(f, v, !0), v._data = BL(m, v._data));
    var h = o(f, v), y = i(d, h);
    return p && (y._data = BL(p, y._data)), y;
  }
}), VL = "polynomialRoot", kIe = ["typed", "isZero", "equalScalar", "add", "subtract", "multiply", "divide", "sqrt", "unaryMinus", "cbrt", "typeOf", "im", "re"], UIe = /* @__PURE__ */ Ce(VL, kIe, (e) => {
  var {
    typed: r,
    isZero: t,
    equalScalar: n,
    add: a,
    subtract: i,
    multiply: o,
    divide: c,
    sqrt: s,
    unaryMinus: u,
    cbrt: l,
    typeOf: f,
    im: d,
    re: m
  } = e;
  return r(VL, {
    "number|Complex, ...number|Complex": (p, v) => {
      for (var h = [p, ...v]; h.length > 0 && t(h[h.length - 1]); )
        h.pop();
      if (h.length < 2)
        throw new RangeError("Polynomial [".concat(p, ", ").concat(v, "] must have a non-zero non-constant coefficient"));
      switch (h.length) {
        case 2:
          return [u(c(h[0], h[1]))];
        case 3: {
          var [y, C, S] = h, b = o(2, S), g = o(C, C), _ = o(4, S, y);
          if (n(g, _)) return [c(u(C), b)];
          var A = s(i(g, _));
          return [c(i(A, C), b), c(i(u(A), C), b)];
        }
        case 4: {
          var [M, P, T, x] = h, w = u(o(3, x)), E = o(T, T), I = o(3, x, P), B = a(o(2, T, T, T), o(27, x, x, M)), D = o(9, x, T, P);
          if (n(E, I) && n(B, D))
            return [c(T, w)];
          var N = i(E, I), O = i(B, D), V = a(o(18, x, T, P, M), o(T, T, P, P)), k = a(o(4, T, T, T, M), o(4, x, P, P, P), o(27, x, x, M, M));
          if (n(V, k))
            return [
              c(i(o(4, x, T, P), a(o(9, x, x, M), o(T, T, T))), o(x, N)),
              // simple root
              c(i(o(9, x, M), o(T, P)), o(2, N))
              // double root
            ];
          var G;
          n(E, I) ? G = O : G = c(a(O, s(i(o(O, O), o(4, N, N, N)))), 2);
          var L = !0, R = l(G, L).toArray().map((F) => c(a(T, F, c(N, F)), w));
          return R.map((F) => f(F) === "Complex" && n(m(F), m(F) + d(F)) ? m(F) : F);
        }
        default:
          throw new RangeError("only implemented for cubic or lower-order polynomials, not ".concat(h));
      }
    }
  });
}), zIe = "Help", GIe = ["evaluate"], qIe = /* @__PURE__ */ Ce(zIe, GIe, (e) => {
  var {
    evaluate: r
  } = e;
  function t(n) {
    if (!(this instanceof t))
      throw new SyntaxError("Constructor must be called with the new operator");
    if (!n) throw new Error('Argument "doc" missing');
    this.doc = n;
  }
  return t.prototype.type = "Help", t.prototype.isHelp = !0, t.prototype.toString = function() {
    var n = this.doc || {}, a = `
`;
    if (n.name && (a += "Name: " + n.name + `

`), n.category && (a += "Category: " + n.category + `

`), n.description && (a += `Description:
    ` + n.description + `

`), n.syntax && (a += `Syntax:
    ` + n.syntax.join(`
    `) + `

`), n.examples) {
      a += `Examples:
`;
      for (var i = !1, o = r("config()"), c = {
        config: (f) => (i = !0, r("config(newConfig)", {
          newConfig: f
        }))
      }, s = 0; s < n.examples.length; s++) {
        var u = n.examples[s];
        a += "    " + u + `
`;
        var l = void 0;
        try {
          l = r(u, c);
        } catch (f) {
          l = f;
        }
        l !== void 0 && !bD(l) && (a += "        " + $r(l, {
          precision: 14
        }) + `
`);
      }
      a += `
`, i && r("config(originalConfig)", {
        originalConfig: o
      });
    }
    return n.mayThrow && n.mayThrow.length && (a += "Throws: " + n.mayThrow.join(", ") + `

`), n.seealso && n.seealso.length && (a += "See also: " + n.seealso.join(", ") + `
`), a;
  }, t.prototype.toJSON = function() {
    var n = Sr(this.doc);
    return n.mathjs = "Help", n;
  }, t.fromJSON = function(n) {
    var a = {};
    return Object.keys(n).filter((i) => i !== "mathjs").forEach((i) => {
      a[i] = n[i];
    }), new t(a);
  }, t.prototype.valueOf = t.prototype.toString, t;
}, {
  isClass: !0
}), HIe = "Chain", jIe = ["?on", "math", "typed"], $Ie = /* @__PURE__ */ Ce(HIe, jIe, (e) => {
  var {
    on: r,
    math: t,
    typed: n
  } = e;
  function a(u) {
    if (!(this instanceof a))
      throw new SyntaxError("Constructor must be called with the new operator");
    SD(u) ? this.value = u.value : this.value = u;
  }
  a.prototype.type = "Chain", a.prototype.isChain = !0, a.prototype.done = function() {
    return this.value;
  }, a.prototype.valueOf = function() {
    return this.value;
  }, a.prototype.toString = function() {
    return $r(this.value);
  }, a.prototype.toJSON = function() {
    return {
      mathjs: "Chain",
      value: this.value
    };
  }, a.fromJSON = function(u) {
    return new a(u.value);
  };
  function i(u, l) {
    typeof l == "function" && (a.prototype[u] = c(l));
  }
  function o(u, l) {
    mb(a.prototype, u, function() {
      var d = l();
      if (typeof d == "function")
        return c(d);
    });
  }
  function c(u) {
    return function() {
      if (arguments.length === 0)
        return new a(u(this.value));
      for (var l = [this.value], f = 0; f < arguments.length; f++)
        l[f + 1] = arguments[f];
      if (n.isTypedFunction(u)) {
        var d = n.resolve(u, l);
        if (d.params.length === 1)
          throw new Error("chain function " + u.name + " cannot match rest parameter between chain value and additional arguments.");
        return new a(d.implementation.apply(u, l));
      }
      return new a(u.apply(u, l));
    };
  }
  a.createProxy = function(u, l) {
    if (typeof u == "string")
      i(u, l);
    else {
      var f = function(p) {
        er(u, p) && s[p] === void 0 && o(p, () => u[p]);
      };
      for (var d in u)
        f(d);
    }
  };
  var s = {
    expression: !0,
    docs: !0,
    type: !0,
    classes: !0,
    json: !0,
    error: !0,
    isChain: !0
    // conflicts with the property isChain of a Chain instance
  };
  return a.createProxy(t), r && r("import", function(u, l, f) {
    f || o(u, l);
  }), a;
}, {
  isClass: !0
}), RL = {
  name: "e",
  category: "Constants",
  syntax: ["e"],
  description: "Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",
  examples: ["e", "e ^ 2", "exp(2)", "log(e)"],
  seealso: ["exp"]
}, KIe = {
  name: "false",
  category: "Constants",
  syntax: ["false"],
  description: "Boolean value false",
  examples: ["false"],
  seealso: ["true"]
}, WIe = {
  name: "i",
  category: "Constants",
  syntax: ["i"],
  description: "Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",
  examples: ["i", "i * i", "sqrt(-1)"],
  seealso: []
}, XIe = {
  name: "Infinity",
  category: "Constants",
  syntax: ["Infinity"],
  description: "Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",
  examples: ["Infinity", "1 / 0"],
  seealso: []
}, YIe = {
  name: "LN10",
  category: "Constants",
  syntax: ["LN10"],
  description: "Returns the natural logarithm of 10, approximately equal to 2.302",
  examples: ["LN10", "log(10)"],
  seealso: []
}, QIe = {
  name: "LN2",
  category: "Constants",
  syntax: ["LN2"],
  description: "Returns the natural logarithm of 2, approximately equal to 0.693",
  examples: ["LN2", "log(2)"],
  seealso: []
}, ZIe = {
  name: "LOG10E",
  category: "Constants",
  syntax: ["LOG10E"],
  description: "Returns the base-10 logarithm of E, approximately equal to 0.434",
  examples: ["LOG10E", "log(e, 10)"],
  seealso: []
}, JIe = {
  name: "LOG2E",
  category: "Constants",
  syntax: ["LOG2E"],
  description: "Returns the base-2 logarithm of E, approximately equal to 1.442",
  examples: ["LOG2E", "log(e, 2)"],
  seealso: []
}, e8e = {
  name: "NaN",
  category: "Constants",
  syntax: ["NaN"],
  description: "Not a number",
  examples: ["NaN", "0 / 0"],
  seealso: []
}, r8e = {
  name: "null",
  category: "Constants",
  syntax: ["null"],
  description: "Value null",
  examples: ["null"],
  seealso: ["true", "false"]
}, t8e = {
  name: "phi",
  category: "Constants",
  syntax: ["phi"],
  description: "Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",
  examples: ["phi"],
  seealso: []
}, OL = {
  name: "pi",
  category: "Constants",
  syntax: ["pi"],
  description: "The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",
  examples: ["pi", "sin(pi/2)"],
  seealso: ["tau"]
}, n8e = {
  name: "SQRT1_2",
  category: "Constants",
  syntax: ["SQRT1_2"],
  description: "Returns the square root of 1/2, approximately equal to 0.707",
  examples: ["SQRT1_2", "sqrt(1/2)"],
  seealso: []
}, a8e = {
  name: "SQRT2",
  category: "Constants",
  syntax: ["SQRT2"],
  description: "Returns the square root of 2, approximately equal to 1.414",
  examples: ["SQRT2", "sqrt(2)"],
  seealso: []
}, i8e = {
  name: "tau",
  category: "Constants",
  syntax: ["tau"],
  description: "Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",
  examples: ["tau", "2 * pi"],
  seealso: ["pi"]
}, o8e = {
  name: "true",
  category: "Constants",
  syntax: ["true"],
  description: "Boolean value true",
  examples: ["true"],
  seealso: ["false"]
}, u8e = {
  name: "version",
  category: "Constants",
  syntax: ["version"],
  description: "A string with the version number of math.js",
  examples: ["version"],
  seealso: []
}, s8e = {
  name: "bignumber",
  category: "Construction",
  syntax: ["bignumber(x)"],
  description: "Create a big number from a number or string.",
  examples: ["0.1 + 0.2", "bignumber(0.1) + bignumber(0.2)", 'bignumber("7.2")', 'bignumber("7.2e500")', "bignumber([0.1, 0.2, 0.3])"],
  seealso: ["boolean", "bigint", "complex", "fraction", "index", "matrix", "string", "unit"]
}, l8e = {
  name: "bigint",
  category: "Construction",
  syntax: ["bigint(x)"],
  description: "Create a bigint, an integer with an arbitrary number of digits, from a number or string.",
  examples: ["123123123123123123 # a large number will lose digits", 'bigint("123123123123123123")', 'bignumber(["1", "3", "5"])'],
  seealso: ["boolean", "bignumber", "number", "complex", "fraction", "index", "matrix", "string", "unit"]
}, c8e = {
  name: "boolean",
  category: "Construction",
  syntax: ["x", "boolean(x)"],
  description: "Convert a string or number into a boolean.",
  examples: ["boolean(0)", "boolean(1)", "boolean(3)", 'boolean("true")', 'boolean("false")', "boolean([1, 0, 1, 1])"],
  seealso: ["bignumber", "complex", "index", "matrix", "number", "string", "unit"]
}, d8e = {
  name: "complex",
  category: "Construction",
  syntax: ["complex()", "complex(re, im)", "complex(string)"],
  description: "Create a complex number.",
  examples: ["complex()", "complex(2, 3)", 'complex("7 - 2i")'],
  seealso: ["bignumber", "boolean", "index", "matrix", "number", "string", "unit"]
}, f8e = {
  name: "createUnit",
  category: "Construction",
  syntax: ["createUnit(definitions)", "createUnit(name, definition)"],
  description: "Create a user-defined unit and register it with the Unit type.",
  examples: ['createUnit("foo")', 'createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})', 'createUnit("mph", "1 mile/hour")'],
  seealso: ["unit", "splitUnit"]
}, m8e = {
  name: "fraction",
  category: "Construction",
  syntax: ["fraction(num)", "fraction(matrix)", "fraction(num,den)", "fraction({n: num, d: den})"],
  description: "Create a fraction from a number or from integer numerator and denominator.",
  examples: ["fraction(0.125)", "fraction(1, 3) + fraction(2, 5)", "fraction({n: 333, d: 53})", "fraction([sqrt(9), sqrt(10), sqrt(11)])"],
  seealso: ["bignumber", "boolean", "complex", "index", "matrix", "string", "unit"]
}, v8e = {
  name: "index",
  category: "Construction",
  syntax: ["[start]", "[start:end]", "[start:step:end]", "[start1, start 2, ...]", "[start1:end1, start2:end2, ...]", "[start1:step1:end1, start2:step2:end2, ...]"],
  description: "Create an index to get or replace a subset of a matrix",
  examples: ["A = [1, 2, 3; 4, 5, 6]", "A[1, :]", "A[1, 2] = 50", "A[1:2, 1:2] = 1", "B = [1, 2, 3]", "B[B>1 and B<3]"],
  seealso: ["bignumber", "boolean", "complex", "matrix,", "number", "range", "string", "unit"]
}, p8e = {
  name: "matrix",
  category: "Construction",
  syntax: ["[]", "[a1, b1, ...; a2, b2, ...]", "matrix()", 'matrix("dense")', "matrix([...])"],
  description: "Create a matrix.",
  examples: ["[]", "[1, 2, 3]", "[1, 2, 3; 4, 5, 6]", "matrix()", "matrix([3, 4])", 'matrix([3, 4; 5, 6], "sparse")', 'matrix([3, 4; 5, 6], "sparse", "number")'],
  seealso: ["bignumber", "boolean", "complex", "index", "number", "string", "unit", "sparse"]
}, h8e = {
  name: "number",
  category: "Construction",
  syntax: ["x", "number(x)", "number(unit, valuelessUnit)"],
  description: "Create a number or convert a string or boolean into a number.",
  examples: ["2", "2e3", "4.05", "number(2)", 'number("7.2")', "number(true)", "number([true, false, true, true])", 'number(unit("52cm"), "m")'],
  seealso: ["bignumber", "bigint", "boolean", "complex", "fraction", "index", "matrix", "string", "unit"]
}, g8e = {
  name: "sparse",
  category: "Construction",
  syntax: ["sparse()", "sparse([a1, b1, ...; a1, b2, ...])", 'sparse([a1, b1, ...; a1, b2, ...], "number")'],
  description: "Create a sparse matrix.",
  examples: ["sparse()", "sparse([3, 4; 5, 6])", 'sparse([3, 0; 5, 0], "number")'],
  seealso: ["bignumber", "boolean", "complex", "index", "number", "string", "unit", "matrix"]
}, y8e = {
  name: "splitUnit",
  category: "Construction",
  syntax: ["splitUnit(unit: Unit, parts: Unit[])"],
  description: "Split a unit in an array of units whose sum is equal to the original unit.",
  examples: ['splitUnit(1 m, ["feet", "inch"])'],
  seealso: ["unit", "createUnit"]
}, _8e = {
  name: "string",
  category: "Construction",
  syntax: ['"text"', "string(x)"],
  description: "Create a string or convert a value to a string",
  examples: ['"Hello World!"', "string(4.2)", "string(3 + 2i)"],
  seealso: ["bignumber", "boolean", "complex", "index", "matrix", "number", "unit"]
}, b8e = {
  name: "unit",
  category: "Construction",
  syntax: ["value unit", "unit(value, unit)", "unit(string)"],
  description: "Create a unit.",
  examples: ["5.5 mm", "3 inch", 'unit(7.1, "kilogram")', 'unit("23 deg")'],
  seealso: ["bignumber", "boolean", "complex", "index", "matrix", "number", "string"]
}, S8e = {
  name: "config",
  category: "Core",
  syntax: ["config()", "config(options)"],
  description: "Get configuration or change configuration.",
  examples: ["config()", "1/3 + 1/4", 'config({number: "Fraction"})', "1/3 + 1/4"],
  seealso: []
}, C8e = {
  name: "import",
  category: "Core",
  syntax: ["import(functions)", "import(functions, options)"],
  description: "Import functions or constants from an object.",
  examples: ["import({myFn: f(x)=x^2, myConstant: 32 })", "myFn(2)", "myConstant"],
  seealso: []
}, A8e = {
  name: "typed",
  category: "Core",
  syntax: ["typed(signatures)", "typed(name, signatures)"],
  description: "Create a typed function.",
  examples: ['double = typed({ "number": f(x)=x+x, "string": f(x)=concat(x,x) })', "double(2)", 'double("hello")'],
  seealso: []
}, x8e = {
  name: "derivative",
  category: "Algebra",
  syntax: ["derivative(expr, variable)", "derivative(expr, variable, {simplify: boolean})"],
  description: "Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.",
  examples: ['derivative("2x^3", "x")', 'derivative("2x^3", "x", {simplify: false})', 'derivative("2x^2 + 3x + 4", "x")', 'derivative("sin(2x)", "x")', 'f = parse("x^2 + x")', 'x = parse("x")', "df = derivative(f, x)", "df.evaluate({x: 3})"],
  seealso: ["simplify", "parse", "evaluate"]
}, T8e = {
  name: "leafCount",
  category: "Algebra",
  syntax: ["leafCount(expr)"],
  description: "Computes the number of leaves in the parse tree of the given expression",
  examples: ['leafCount("e^(i*pi)-1")', 'leafCount(parse("{a: 22/7, b: 10^(1/2)}"))'],
  seealso: ["simplify"]
}, P8e = {
  name: "lsolve",
  category: "Algebra",
  syntax: ["x=lsolve(L, b)"],
  description: "Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",
  examples: ["a = [-2, 3; 2, 1]", "b = [11, 9]", "x = lsolve(a, b)"],
  seealso: ["lsolveAll", "lup", "lusolve", "usolve", "matrix", "sparse"]
}, M8e = {
  name: "lsolveAll",
  category: "Algebra",
  syntax: ["x=lsolveAll(L, b)"],
  description: "Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.",
  examples: ["a = [-2, 3; 2, 1]", "b = [11, 9]", "x = lsolve(a, b)"],
  seealso: ["lsolve", "lup", "lusolve", "usolve", "matrix", "sparse"]
}, w8e = {
  name: "lup",
  category: "Algebra",
  syntax: ["lup(m)"],
  description: "Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U",
  examples: ["lup([[2, 1], [1, 4]])", "lup(matrix([[2, 1], [1, 4]]))", "lup(sparse([[2, 1], [1, 4]]))"],
  seealso: ["lusolve", "lsolve", "usolve", "matrix", "sparse", "slu", "qr"]
}, E8e = {
  name: "lusolve",
  category: "Algebra",
  syntax: ["x=lusolve(A, b)", "x=lusolve(lu, b)"],
  description: "Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.",
  examples: ["a = [-2, 3; 2, 1]", "b = [11, 9]", "x = lusolve(a, b)"],
  seealso: ["lup", "slu", "lsolve", "usolve", "matrix", "sparse"]
}, D8e = {
  name: "polynomialRoot",
  category: "Algebra",
  syntax: ["x=polynomialRoot(-6, 3)", "x=polynomialRoot(4, -4, 1)", "x=polynomialRoot(-8, 12, -6, 1)"],
  description: "Finds the roots of a univariate polynomial given by its coefficients starting from constant, linear, and so on, increasing in degree.",
  examples: ["a = polynomialRoot(-6, 11, -6, 1)"],
  seealso: ["cbrt", "sqrt"]
}, I8e = {
  name: "qr",
  category: "Algebra",
  syntax: ["qr(A)"],
  description: "Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",
  examples: ["qr([[1, -1,  4], [1,  4, -2], [1,  4,  2], [1,  -1, 0]])"],
  seealso: ["lup", "slu", "matrix"]
}, B8e = {
  name: "rationalize",
  category: "Algebra",
  syntax: ["rationalize(expr)", "rationalize(expr, scope)", "rationalize(expr, scope, detailed)"],
  description: "Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.",
  examples: ['rationalize("2x/y - y/(x+1)")', 'rationalize("2x/y - y/(x+1)", true)'],
  seealso: ["simplify"]
}, N8e = {
  name: "resolve",
  category: "Algebra",
  syntax: ["resolve(node, scope)"],
  description: "Recursively substitute variables in an expression tree.",
  examples: ['resolve(parse("1 + x"), { x: 7 })', 'resolve(parse("size(text)"), { text: "Hello World" })', 'resolve(parse("x + y"), { x: parse("3z") })', 'resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })'],
  seealso: ["simplify", "evaluate"],
  mayThrow: ["ReferenceError"]
}, V8e = {
  name: "simplify",
  category: "Algebra",
  syntax: ["simplify(expr)", "simplify(expr, rules)"],
  description: "Simplify an expression tree.",
  examples: ['simplify("3 + 2 / 4")', 'simplify("2x + x")', 'f = parse("x * (x + 2 + x)")', "simplified = simplify(f)", "simplified.evaluate({x: 2})"],
  seealso: ["simplifyCore", "derivative", "evaluate", "parse", "rationalize", "resolve"]
}, R8e = {
  name: "simplifyConstant",
  category: "Algebra",
  syntax: ["simplifyConstant(expr)", "simplifyConstant(expr, options)"],
  description: "Replace constant subexpressions of node with their values.",
  examples: ['simplifyConstant("(3-3)*x")', 'simplifyConstant(parse("z-cos(tau/8)"))'],
  seealso: ["simplify", "simplifyCore", "evaluate"]
}, O8e = {
  name: "simplifyCore",
  category: "Algebra",
  syntax: ["simplifyCore(node)"],
  description: "Perform simple one-pass simplifications on an expression tree.",
  examples: ['simplifyCore(parse("0*x"))', 'simplifyCore(parse("(x+0)*2"))'],
  seealso: ["simplify", "simplifyConstant", "evaluate"]
}, F8e = {
  name: "slu",
  category: "Algebra",
  syntax: ["slu(A, order, threshold)"],
  description: "Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U",
  examples: ["slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)"],
  seealso: ["lusolve", "lsolve", "usolve", "matrix", "sparse", "lup", "qr"]
}, L8e = {
  name: "symbolicEqual",
  category: "Algebra",
  syntax: ["symbolicEqual(expr1, expr2)", "symbolicEqual(expr1, expr2, options)"],
  description: "Returns true if the difference of the expressions simplifies to 0",
  examples: ['symbolicEqual("x*y","y*x")', 'symbolicEqual("abs(x^2)", "x^2")', 'symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})'],
  seealso: ["simplify", "evaluate"]
}, k8e = {
  name: "usolve",
  category: "Algebra",
  syntax: ["x=usolve(U, b)"],
  description: "Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",
  examples: ["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],
  seealso: ["usolveAll", "lup", "lusolve", "lsolve", "matrix", "sparse"]
}, U8e = {
  name: "usolveAll",
  category: "Algebra",
  syntax: ["x=usolve(U, b)"],
  description: "Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.",
  examples: ["x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])"],
  seealso: ["usolve", "lup", "lusolve", "lsolve", "matrix", "sparse"]
}, z8e = {
  name: "abs",
  category: "Arithmetic",
  syntax: ["abs(x)"],
  description: "Compute the absolute value.",
  examples: ["abs(3.5)", "abs(-4.2)"],
  seealso: ["sign"]
}, G8e = {
  name: "add",
  category: "Operators",
  syntax: ["x + y", "add(x, y)"],
  description: "Add two values.",
  examples: ["a = 2.1 + 3.6", "a - 3.6", "3 + 2i", "3 cm + 2 inch", '"2.3" + "4"'],
  seealso: ["subtract"]
}, q8e = {
  name: "cbrt",
  category: "Arithmetic",
  syntax: ["cbrt(x)", "cbrt(x, allRoots)"],
  description: "Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",
  examples: ["cbrt(64)", "cube(4)", "cbrt(-8)", "cbrt(2 + 3i)", "cbrt(8i)", "cbrt(8i, true)", "cbrt(27 m^3)"],
  seealso: ["square", "sqrt", "cube", "multiply"]
}, H8e = {
  name: "ceil",
  category: "Arithmetic",
  syntax: ["ceil(x)"],
  description: "Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.",
  examples: ["ceil(3.2)", "ceil(3.8)", "ceil(-4.2)"],
  seealso: ["floor", "fix", "round"]
}, j8e = {
  name: "cube",
  category: "Arithmetic",
  syntax: ["cube(x)"],
  description: "Compute the cube of a value. The cube of x is x * x * x.",
  examples: ["cube(2)", "2^3", "2 * 2 * 2"],
  seealso: ["multiply", "square", "pow"]
}, $8e = {
  name: "divide",
  category: "Operators",
  syntax: ["x / y", "divide(x, y)"],
  description: "Divide two values.",
  examples: ["a = 2 / 3", "a * 3", "4.5 / 2", "3 + 4 / 2", "(3 + 4) / 2", "18 km / 4.5"],
  seealso: ["multiply"]
}, K8e = {
  name: "dotDivide",
  category: "Operators",
  syntax: ["x ./ y", "dotDivide(x, y)"],
  description: "Divide two values element wise.",
  examples: ["a = [1, 2, 3; 4, 5, 6]", "b = [2, 1, 1; 3, 2, 5]", "a ./ b"],
  seealso: ["multiply", "dotMultiply", "divide"]
}, W8e = {
  name: "dotMultiply",
  category: "Operators",
  syntax: ["x .* y", "dotMultiply(x, y)"],
  description: "Multiply two values element wise.",
  examples: ["a = [1, 2, 3; 4, 5, 6]", "b = [2, 1, 1; 3, 2, 5]", "a .* b"],
  seealso: ["multiply", "divide", "dotDivide"]
}, X8e = {
  name: "dotPow",
  category: "Operators",
  syntax: ["x .^ y", "dotPow(x, y)"],
  description: "Calculates the power of x to y element wise.",
  examples: ["a = [1, 2, 3; 4, 5, 6]", "a .^ 2"],
  seealso: ["pow"]
}, Y8e = {
  name: "exp",
  category: "Arithmetic",
  syntax: ["exp(x)"],
  description: "Calculate the exponent of a value.",
  examples: ["exp(1.3)", "e ^ 1.3", "log(exp(1.3))", "x = 2.4", "(exp(i*x) == cos(x) + i*sin(x))   # Euler's formula"],
  seealso: ["expm", "expm1", "pow", "log"]
}, Q8e = {
  name: "expm",
  category: "Arithmetic",
  syntax: ["exp(x)"],
  description: "Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.",
  examples: ["expm([[0,2],[0,0]])"],
  seealso: ["exp"]
}, Z8e = {
  name: "expm1",
  category: "Arithmetic",
  syntax: ["expm1(x)"],
  description: "Calculate the value of subtracting 1 from the exponential value.",
  examples: ["expm1(2)", "pow(e, 2) - 1", "log(expm1(2) + 1)"],
  seealso: ["exp", "pow", "log"]
}, J8e = {
  name: "fix",
  category: "Arithmetic",
  syntax: ["fix(x)"],
  description: "Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.",
  examples: ["fix(3.2)", "fix(3.8)", "fix(-4.2)", "fix(-4.8)"],
  seealso: ["ceil", "floor", "round"]
}, e7e = {
  name: "floor",
  category: "Arithmetic",
  syntax: ["floor(x)"],
  description: "Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",
  examples: ["floor(3.2)", "floor(3.8)", "floor(-4.2)"],
  seealso: ["ceil", "fix", "round"]
}, r7e = {
  name: "gcd",
  category: "Arithmetic",
  syntax: ["gcd(a, b)", "gcd(a, b, c, ...)"],
  description: "Compute the greatest common divisor.",
  examples: ["gcd(8, 12)", "gcd(-4, 6)", "gcd(25, 15, -10)"],
  seealso: ["lcm", "xgcd"]
}, t7e = {
  name: "hypot",
  category: "Arithmetic",
  syntax: ["hypot(a, b, c, ...)", "hypot([a, b, c, ...])"],
  description: "Calculate the hypotenusa of a list with values. ",
  examples: ["hypot(3, 4)", "sqrt(3^2 + 4^2)", "hypot(-2)", "hypot([3, 4, 5])"],
  seealso: ["abs", "norm"]
}, n7e = {
  name: "invmod",
  category: "Arithmetic",
  syntax: ["invmod(a, b)"],
  description: "Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)",
  examples: ["invmod(8, 12)", "invmod(7, 13)", "invmod(15151, 15122)"],
  seealso: ["gcd", "xgcd"]
}, a7e = {
  name: "lcm",
  category: "Arithmetic",
  syntax: ["lcm(x, y)"],
  description: "Compute the least common multiple.",
  examples: ["lcm(4, 6)", "lcm(6, 21)", "lcm(6, 21, 5)"],
  seealso: ["gcd"]
}, i7e = {
  name: "log",
  category: "Arithmetic",
  syntax: ["log(x)", "log(x, base)"],
  description: "Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",
  examples: ["log(3.5)", "a = log(2.4)", "exp(a)", "10 ^ 4", "log(10000, 10)", "log(10000) / log(10)", "b = log(1024, 2)", "2 ^ b"],
  seealso: ["exp", "log1p", "log2", "log10"]
}, o7e = {
  name: "log10",
  category: "Arithmetic",
  syntax: ["log10(x)"],
  description: "Compute the 10-base logarithm of a value.",
  examples: ["log10(0.00001)", "log10(10000)", "10 ^ 4", "log(10000) / log(10)", "log(10000, 10)"],
  seealso: ["exp", "log"]
}, u7e = {
  name: "log1p",
  category: "Arithmetic",
  syntax: ["log1p(x)", "log1p(x, base)"],
  description: "Calculate the logarithm of a `value+1`",
  examples: ["log1p(2.5)", "exp(log1p(1.4))", "pow(10, 4)", "log1p(9999, 10)", "log1p(9999) / log(10)"],
  seealso: ["exp", "log", "log2", "log10"]
}, s7e = {
  name: "log2",
  category: "Arithmetic",
  syntax: ["log2(x)"],
  description: "Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",
  examples: ["log2(0.03125)", "log2(16)", "log2(16) / log2(2)", "pow(2, 4)"],
  seealso: ["exp", "log1p", "log", "log10"]
}, l7e = {
  name: "mod",
  category: "Operators",
  syntax: ["x % y", "x mod y", "mod(x, y)"],
  description: "Calculates the modulus, the remainder of an integer division.",
  examples: ["7 % 3", "11 % 2", "10 mod 4", "isOdd(x) = x % 2", "isOdd(2)", "isOdd(3)"],
  seealso: ["divide"]
}, c7e = {
  name: "multiply",
  category: "Operators",
  syntax: ["x * y", "multiply(x, y)"],
  description: "multiply two values.",
  examples: ["a = 2.1 * 3.4", "a / 3.4", "2 * 3 + 4", "2 * (3 + 4)", "3 * 2.1 km"],
  seealso: ["divide"]
}, d7e = {
  name: "norm",
  category: "Arithmetic",
  syntax: ["norm(x)", "norm(x, p)"],
  description: "Calculate the norm of a number, vector or matrix.",
  examples: ["abs(-3.5)", "norm(-3.5)", "norm(3 - 4i)", "norm([1, 2, -3], Infinity)", "norm([1, 2, -3], -Infinity)", "norm([3, 4], 2)", "norm([[1, 2], [3, 4]], 1)", 'norm([[1, 2], [3, 4]], "inf")', 'norm([[1, 2], [3, 4]], "fro")']
}, f7e = {
  name: "nthRoot",
  category: "Arithmetic",
  syntax: ["nthRoot(a)", "nthRoot(a, root)"],
  description: 'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',
  examples: ["4 ^ 3", "nthRoot(64, 3)", "nthRoot(9, 2)", "sqrt(9)"],
  seealso: ["nthRoots", "pow", "sqrt"]
}, m7e = {
  name: "nthRoots",
  category: "Arithmetic",
  syntax: ["nthRoots(A)", "nthRoots(A, root)"],
  description: 'Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.',
  examples: ["nthRoots(1)", "nthRoots(1, 3)"],
  seealso: ["sqrt", "pow", "nthRoot"]
}, v7e = {
  name: "pow",
  category: "Operators",
  syntax: ["x ^ y", "pow(x, y)"],
  description: "Calculates the power of x to y, x^y.",
  examples: ["2^3", "2*2*2", "1 + e ^ (pi * i)", "pow([[1, 2], [4, 3]], 2)", "pow([[1, 2], [4, 3]], -1)"],
  seealso: ["multiply", "nthRoot", "nthRoots", "sqrt"]
}, p7e = {
  name: "round",
  category: "Arithmetic",
  syntax: ["round(x)", "round(x, n)", "round(unit, valuelessUnit)", "round(unit, n, valuelessUnit)"],
  description: "round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",
  examples: ["round(3.2)", "round(3.8)", "round(-4.2)", "round(-4.8)", "round(pi, 3)", "round(123.45678, 2)", "round(3.241cm, 2, cm)", "round([3.2, 3.8, -4.7])"],
  seealso: ["ceil", "floor", "fix"]
}, h7e = {
  name: "sign",
  category: "Arithmetic",
  syntax: ["sign(x)"],
  description: "Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",
  examples: ["sign(3.5)", "sign(-4.2)", "sign(0)"],
  seealso: ["abs"]
}, g7e = {
  name: "sqrt",
  category: "Arithmetic",
  syntax: ["sqrt(x)"],
  description: "Compute the square root value. If x = y * y, then y is the square root of x.",
  examples: ["sqrt(25)", "5 * 5", "sqrt(-1)"],
  seealso: ["square", "sqrtm", "multiply", "nthRoot", "nthRoots", "pow"]
}, y7e = {
  name: "sqrtm",
  category: "Arithmetic",
  syntax: ["sqrtm(x)"],
  description: "Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",
  examples: ["sqrtm([[33, 24], [48, 57]])"],
  seealso: ["sqrt", "abs", "square", "multiply"]
}, _7e = {
  name: "sylvester",
  category: "Algebra",
  syntax: ["sylvester(A,B,C)"],
  description: "Solves the real-valued Sylvester equation AX+XB=C for X",
  examples: ["sylvester([[-1, -2], [1, 1]], [[-2, 1], [-1, 2]], [[-3, 2], [3, 0]])", "A = [[-1, -2], [1, 1]]; B = [[2, -1], [1, -2]]; C = [[-3, 2], [3, 0]]", "sylvester(A, B, C)"],
  seealso: ["schur", "lyap"]
}, b7e = {
  name: "schur",
  category: "Algebra",
  syntax: ["schur(A)"],
  description: "Performs a real Schur decomposition of the real matrix A = UTU'",
  examples: ["schur([[1, 0], [-4, 3]])", "A = [[1, 0], [-4, 3]]", "schur(A)"],
  seealso: ["lyap", "sylvester"]
}, S7e = {
  name: "lyap",
  category: "Algebra",
  syntax: ["lyap(A,Q)"],
  description: "Solves the Continuous-time Lyapunov equation AP+PA'+Q=0 for P",
  examples: ["lyap([[-2, 0], [1, -4]], [[3, 1], [1, 3]])", "A = [[-2, 0], [1, -4]]", "Q = [[3, 1], [1, 3]]", "lyap(A,Q)"],
  seealso: ["schur", "sylvester"]
}, C7e = {
  name: "square",
  category: "Arithmetic",
  syntax: ["square(x)"],
  description: "Compute the square of a value. The square of x is x * x.",
  examples: ["square(3)", "sqrt(9)", "3^2", "3 * 3"],
  seealso: ["multiply", "pow", "sqrt", "cube"]
}, A7e = {
  name: "subtract",
  category: "Operators",
  syntax: ["x - y", "subtract(x, y)"],
  description: "subtract two values.",
  examples: ["a = 5.3 - 2", "a + 2", "2/3 - 1/6", "2 * 3 - 3", "2.1 km - 500m"],
  seealso: ["add"]
}, x7e = {
  name: "unaryMinus",
  category: "Operators",
  syntax: ["-x", "unaryMinus(x)"],
  description: "Inverse the sign of a value. Converts booleans and strings to numbers.",
  examples: ["-4.5", "-(-5.6)", '-"22"'],
  seealso: ["add", "subtract", "unaryPlus"]
}, T7e = {
  name: "unaryPlus",
  category: "Operators",
  syntax: ["+x", "unaryPlus(x)"],
  description: "Converts booleans and strings to numbers.",
  examples: ["+true", '+"2"'],
  seealso: ["add", "subtract", "unaryMinus"]
}, P7e = {
  name: "xgcd",
  category: "Arithmetic",
  syntax: ["xgcd(a, b)"],
  description: "Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.",
  examples: ["xgcd(8, 12)", "gcd(8, 12)", "xgcd(36163, 21199)"],
  seealso: ["gcd", "lcm"]
}, M7e = {
  name: "bitAnd",
  category: "Bitwise",
  syntax: ["x & y", "bitAnd(x, y)"],
  description: "Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",
  examples: ["5 & 3", "bitAnd(53, 131)", "[1, 12, 31] & 42"],
  seealso: ["bitNot", "bitOr", "bitXor", "leftShift", "rightArithShift", "rightLogShift"]
}, w7e = {
  name: "bitNot",
  category: "Bitwise",
  syntax: ["~x", "bitNot(x)"],
  description: "Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",
  examples: ["~1", "~2", "bitNot([2, -3, 4])"],
  seealso: ["bitAnd", "bitOr", "bitXor", "leftShift", "rightArithShift", "rightLogShift"]
}, E7e = {
  name: "bitOr",
  category: "Bitwise",
  syntax: ["x | y", "bitOr(x, y)"],
  description: "Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",
  examples: ["5 | 3", "bitOr([1, 2, 3], 4)"],
  seealso: ["bitAnd", "bitNot", "bitXor", "leftShift", "rightArithShift", "rightLogShift"]
}, D7e = {
  name: "bitXor",
  category: "Bitwise",
  syntax: ["bitXor(x, y)"],
  description: "Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",
  examples: ["bitOr(1, 2)", "bitXor([2, 3, 4], 4)"],
  seealso: ["bitAnd", "bitNot", "bitOr", "leftShift", "rightArithShift", "rightLogShift"]
}, I7e = {
  name: "leftShift",
  category: "Bitwise",
  syntax: ["x << y", "leftShift(x, y)"],
  description: "Bitwise left logical shift of a value x by y number of bits.",
  examples: ["4 << 1", "8 >> 1"],
  seealso: ["bitAnd", "bitNot", "bitOr", "bitXor", "rightArithShift", "rightLogShift"]
}, B7e = {
  name: "rightArithShift",
  category: "Bitwise",
  syntax: ["x >> y", "rightArithShift(x, y)"],
  description: "Bitwise right arithmetic shift of a value x by y number of bits.",
  examples: ["8 >> 1", "4 << 1", "-12 >> 2"],
  seealso: ["bitAnd", "bitNot", "bitOr", "bitXor", "leftShift", "rightLogShift"]
}, N7e = {
  name: "rightLogShift",
  category: "Bitwise",
  syntax: ["x >>> y", "rightLogShift(x, y)"],
  description: "Bitwise right logical shift of a value x by y number of bits.",
  examples: ["8 >>> 1", "4 << 1", "-12 >>> 2"],
  seealso: ["bitAnd", "bitNot", "bitOr", "bitXor", "leftShift", "rightArithShift"]
}, V7e = {
  name: "bellNumbers",
  category: "Combinatorics",
  syntax: ["bellNumbers(n)"],
  description: "The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",
  examples: ["bellNumbers(3)", "bellNumbers(8)"],
  seealso: ["stirlingS2"]
}, R7e = {
  name: "catalan",
  category: "Combinatorics",
  syntax: ["catalan(n)"],
  description: "The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.",
  examples: ["catalan(3)", "catalan(8)"],
  seealso: ["bellNumbers"]
}, O7e = {
  name: "composition",
  category: "Combinatorics",
  syntax: ["composition(n, k)"],
  description: "The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.",
  examples: ["composition(5, 3)"],
  seealso: ["combinations"]
}, F7e = {
  name: "stirlingS2",
  category: "Combinatorics",
  syntax: ["stirlingS2(n, k)"],
  description: "he Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",
  examples: ["stirlingS2(5, 3)"],
  seealso: ["bellNumbers"]
}, L7e = {
  name: "arg",
  category: "Complex",
  syntax: ["arg(x)"],
  description: "Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",
  examples: ["arg(2 + 2i)", "atan2(3, 2)", "arg(2 + 3i)"],
  seealso: ["re", "im", "conj", "abs"]
}, k7e = {
  name: "conj",
  category: "Complex",
  syntax: ["conj(x)"],
  description: "Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",
  examples: ["conj(2 + 3i)", "conj(2 - 3i)", "conj(-5.2i)"],
  seealso: ["re", "im", "abs", "arg"]
}, U7e = {
  name: "im",
  category: "Complex",
  syntax: ["im(x)"],
  description: "Get the imaginary part of a complex number.",
  examples: ["im(2 + 3i)", "re(2 + 3i)", "im(-5.2i)", "im(2.4)"],
  seealso: ["re", "conj", "abs", "arg"]
}, z7e = {
  name: "re",
  category: "Complex",
  syntax: ["re(x)"],
  description: "Get the real part of a complex number.",
  examples: ["re(2 + 3i)", "im(2 + 3i)", "re(-5.2i)", "re(2.4)"],
  seealso: ["im", "conj", "abs", "arg"]
}, G7e = {
  name: "evaluate",
  category: "Expression",
  syntax: ["evaluate(expression)", "evaluate(expression, scope)", "evaluate([expr1, expr2, expr3, ...])", "evaluate([expr1, expr2, expr3, ...], scope)"],
  description: "Evaluate an expression or an array with expressions.",
  examples: ['evaluate("2 + 3")', 'evaluate("sqrt(16)")', 'evaluate("2 inch to cm")', 'evaluate("sin(x * pi)", { "x": 1/2 })', 'evaluate(["width=2", "height=4","width*height"])'],
  seealso: []
}, q7e = {
  name: "help",
  category: "Expression",
  syntax: ["help(object)", "help(string)"],
  description: "Display documentation on a function or data type.",
  examples: ["help(sqrt)", 'help("complex")'],
  seealso: []
}, H7e = {
  name: "distance",
  category: "Geometry",
  syntax: ["distance([x1, y1], [x2, y2])", "distance([[x1, y1], [x2, y2]])"],
  description: "Calculates the Euclidean distance between two points.",
  examples: ["distance([0,0], [4,4])", "distance([[0,0], [4,4]])"],
  seealso: []
}, j7e = {
  name: "intersect",
  category: "Geometry",
  syntax: ["intersect(expr1, expr2, expr3, expr4)", "intersect(expr1, expr2, expr3)"],
  description: "Computes the intersection point of lines and/or planes.",
  examples: ["intersect([0, 0], [10, 10], [10, 0], [0, 10])", "intersect([1, 0, 1],  [4, -2, 2], [1, 1, 1, 6])"],
  seealso: []
}, $7e = {
  name: "and",
  category: "Logical",
  syntax: ["x and y", "and(x, y)"],
  description: "Logical and. Test whether two values are both defined with a nonzero/nonempty value.",
  examples: ["true and false", "true and true", "2 and 4"],
  seealso: ["not", "or", "xor"]
}, K7e = {
  name: "not",
  category: "Logical",
  syntax: ["not x", "not(x)"],
  description: "Logical not. Flips the boolean value of given argument.",
  examples: ["not true", "not false", "not 2", "not 0"],
  seealso: ["and", "or", "xor"]
}, W7e = {
  name: "or",
  category: "Logical",
  syntax: ["x or y", "or(x, y)"],
  description: "Logical or. Test if at least one value is defined with a nonzero/nonempty value.",
  examples: ["true or false", "false or false", "0 or 4"],
  seealso: ["not", "and", "xor"]
}, X7e = {
  name: "xor",
  category: "Logical",
  syntax: ["x xor y", "xor(x, y)"],
  description: "Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",
  examples: ["true xor false", "false xor false", "true xor true", "0 xor 4"],
  seealso: ["not", "and", "or"]
}, Y7e = {
  name: "column",
  category: "Matrix",
  syntax: ["column(x, index)"],
  description: "Return a column from a matrix or array.",
  examples: ["A = [[1, 2], [3, 4]]", "column(A, 1)", "column(A, 2)"],
  seealso: ["row", "matrixFromColumns"]
}, Q7e = {
  name: "concat",
  category: "Matrix",
  syntax: ["concat(A, B, C, ...)", "concat(A, B, C, ..., dim)"],
  description: "Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",
  examples: ["A = [1, 2; 5, 6]", "B = [3, 4; 7, 8]", "concat(A, B)", "concat(A, B, 1)", "concat(A, B, 2)"],
  seealso: ["det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
}, Z7e = {
  name: "count",
  category: "Matrix",
  syntax: ["count(x)"],
  description: "Count the number of elements of a matrix, array or string.",
  examples: ["a = [1, 2; 3, 4; 5, 6]", "count(a)", "size(a)", 'count("hello world")'],
  seealso: ["size"]
}, J7e = {
  name: "cross",
  category: "Matrix",
  syntax: ["cross(A, B)"],
  description: "Calculate the cross product for two vectors in three dimensional space.",
  examples: ["cross([1, 1, 0],  [0, 1, 1])", "cross([3, -3, 1], [4, 9, 2])", "cross([2, 3, 4],  [5, 6, 7])"],
  seealso: ["multiply", "dot"]
}, e9e = {
  name: "ctranspose",
  category: "Matrix",
  syntax: ["x'", "ctranspose(x)"],
  description: "Complex Conjugate and Transpose a matrix",
  examples: ["a = [1, 2, 3; 4, 5, 6]", "a'", "ctranspose(a)"],
  seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "zeros"]
}, r9e = {
  name: "det",
  category: "Matrix",
  syntax: ["det(x)"],
  description: "Calculate the determinant of a matrix",
  examples: ["det([1, 2; 3, 4])", "det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],
  seealso: ["concat", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
}, t9e = {
  name: "diag",
  category: "Matrix",
  syntax: ["diag(x)", "diag(x, k)"],
  description: "Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",
  examples: ["diag(1:3)", "diag(1:3, 1)", "a = [1, 2, 3; 4, 5, 6; 7, 8, 9]", "diag(a)"],
  seealso: ["concat", "det", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
}, n9e = {
  name: "diff",
  category: "Matrix",
  syntax: ["diff(arr)", "diff(arr, dim)"],
  description: ["Create a new matrix or array with the difference of the passed matrix or array.", "Dim parameter is optional and used to indicant the dimension of the array/matrix to apply the difference", "If no dimension parameter is passed it is assumed as dimension 0", "Dimension is zero-based in javascript and one-based in the parser", "Arrays must be 'rectangular' meaning arrays like [1, 2]", "If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays"],
  examples: ["A = [1, 2, 4, 7, 0]", "diff(A)", "diff(A, 1)", "B = [[1, 2], [3, 4]]", "diff(B)", "diff(B, 1)", "diff(B, 2)", "diff(B, bignumber(2))", "diff([[1, 2], matrix([3, 4])], 2)"],
  seealso: ["subtract", "partitionSelect"]
}, a9e = {
  name: "dot",
  category: "Matrix",
  syntax: ["dot(A, B)", "A * B"],
  description: "Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",
  examples: ["dot([2, 4, 1], [2, 2, 3])", "[2, 4, 1] * [2, 2, 3]"],
  seealso: ["multiply", "cross"]
}, i9e = {
  name: "eigs",
  category: "Matrix",
  syntax: ["eigs(x)"],
  description: "Calculate the eigenvalues and optionally eigenvectors of a square matrix",
  examples: ["eigs([[5, 2.3], [2.3, 1]])", "eigs([[1, 2, 3], [4, 5, 6], [7, 8, 9]], { precision: 1e-6, eigenvectors: false })"],
  seealso: ["inv"]
}, o9e = {
  name: "filter",
  category: "Matrix",
  syntax: ["filter(x, test)"],
  description: "Filter items in a matrix.",
  examples: ["isPositive(x) = x > 0", "filter([6, -2, -1, 4, 3], isPositive)", "filter([6, -2, 0, 1, 0], x != 0)"],
  seealso: ["sort", "map", "forEach"]
}, u9e = {
  name: "flatten",
  category: "Matrix",
  syntax: ["flatten(x)"],
  description: "Flatten a multi dimensional matrix into a single dimensional matrix.",
  examples: ["a = [1, 2, 3; 4, 5, 6]", "size(a)", "b = flatten(a)", "size(b)"],
  seealso: ["concat", "resize", "size", "squeeze"]
}, s9e = {
  name: "forEach",
  category: "Matrix",
  syntax: ["forEach(x, callback)"],
  description: "Iterates over all elements of a matrix/array, and executes the given callback function.",
  examples: ["numberOfPets = {}", "addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;", 'forEach(["Dog","Cat","Cat"], addPet)', "numberOfPets"],
  seealso: ["map", "sort", "filter"]
}, l9e = {
  name: "getMatrixDataType",
  category: "Matrix",
  syntax: ["getMatrixDataType(x)"],
  description: 'Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".',
  examples: ["getMatrixDataType([1, 2, 3])", "getMatrixDataType([[5 cm], [2 inch]])", 'getMatrixDataType([1, "text"])', "getMatrixDataType([1, bignumber(4)])"],
  seealso: ["matrix", "sparse", "typeOf"]
}, c9e = {
  name: "identity",
  category: "Matrix",
  syntax: ["identity(n)", "identity(m, n)", "identity([m, n])"],
  description: "Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",
  examples: ["identity(3)", "identity(3, 5)", "a = [1, 2, 3; 4, 5, 6]", "identity(size(a))"],
  seealso: ["concat", "det", "diag", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
}, d9e = {
  name: "inv",
  category: "Matrix",
  syntax: ["inv(x)"],
  description: "Calculate the inverse of a matrix",
  examples: ["inv([1, 2; 3, 4])", "inv(4)", "1 / 4"],
  seealso: ["concat", "det", "diag", "identity", "ones", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
}, f9e = {
  name: "pinv",
  category: "Matrix",
  syntax: ["pinv(x)"],
  description: "Calculate the Moore–Penrose inverse of a matrix",
  examples: ["pinv([1, 2; 3, 4])", "pinv([[1, 0], [0, 1], [0, 1]])", "pinv(4)"],
  seealso: ["inv"]
}, m9e = {
  name: "kron",
  category: "Matrix",
  syntax: ["kron(x, y)"],
  description: "Calculates the kronecker product of 2 matrices or vectors.",
  examples: ["kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])", "kron([1,1], [2,3,4])"],
  seealso: ["multiply", "dot", "cross"]
}, v9e = {
  name: "map",
  category: "Matrix",
  syntax: ["map(x, callback)"],
  description: "Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array.",
  examples: ["map([1, 2, 3], square)"],
  seealso: ["filter", "forEach"]
}, p9e = {
  name: "matrixFromColumns",
  category: "Matrix",
  syntax: ["matrixFromColumns(...arr)", "matrixFromColumns(row1, row2)", "matrixFromColumns(row1, row2, row3)"],
  description: "Create a dense matrix from vectors as individual columns.",
  examples: ["matrixFromColumns([1, 2, 3], [[4],[5],[6]])"],
  seealso: ["matrix", "matrixFromRows", "matrixFromFunction", "zeros"]
}, h9e = {
  name: "matrixFromFunction",
  category: "Matrix",
  syntax: ["matrixFromFunction(size, fn)", "matrixFromFunction(size, fn, format)", "matrixFromFunction(size, fn, format, datatype)", "matrixFromFunction(size, format, fn)", "matrixFromFunction(size, format, datatype, fn)"],
  description: "Create a matrix by evaluating a generating function at each index.",
  examples: ["f(I) = I[1] - I[2]", "matrixFromFunction([3,3], f)", "g(I) = I[1] - I[2] == 1 ? 4 : 0", 'matrixFromFunction([100, 100], "sparse", g)', "matrixFromFunction([5], random)"],
  seealso: ["matrix", "matrixFromRows", "matrixFromColumns", "zeros"]
}, g9e = {
  name: "matrixFromRows",
  category: "Matrix",
  syntax: ["matrixFromRows(...arr)", "matrixFromRows(row1, row2)", "matrixFromRows(row1, row2, row3)"],
  description: "Create a dense matrix from vectors as individual rows.",
  examples: ["matrixFromRows([1, 2, 3], [[4],[5],[6]])"],
  seealso: ["matrix", "matrixFromColumns", "matrixFromFunction", "zeros"]
}, y9e = {
  name: "ones",
  category: "Matrix",
  syntax: ["ones(m)", "ones(m, n)", "ones(m, n, p, ...)", "ones([m])", "ones([m, n])", "ones([m, n, p, ...])"],
  description: "Create a matrix containing ones.",
  examples: ["ones(3)", "ones(3, 5)", "ones([2,3]) * 4.5", "a = [1, 2, 3; 4, 5, 6]", "ones(size(a))"],
  seealso: ["concat", "det", "diag", "identity", "inv", "range", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
}, _9e = {
  name: "partitionSelect",
  category: "Matrix",
  syntax: ["partitionSelect(x, k)", "partitionSelect(x, k, compare)"],
  description: "Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.",
  examples: ["partitionSelect([5, 10, 1], 2)", 'partitionSelect(["C", "B", "A", "D"], 1, compareText)', "arr = [5, 2, 1]", "partitionSelect(arr, 0) # returns 1, arr is now: [1, 2, 5]", "arr", "partitionSelect(arr, 1, 'desc') # returns 2, arr is now: [5, 2, 1]", "arr"],
  seealso: ["sort"]
}, b9e = {
  name: "range",
  category: "Type",
  syntax: ["start:end", "start:step:end", "range(start, end)", "range(start, end, step)", "range(string)"],
  description: "Create a range. Lower bound of the range is included, upper bound is excluded.",
  examples: ["1:5", "3:-1:-3", "range(3, 7)", "range(0, 12, 2)", 'range("4:10")', "range(1m, 1m, 3m)", "a = [1, 2, 3, 4; 5, 6, 7, 8]", "a[1:2, 1:2]"],
  seealso: ["concat", "det", "diag", "identity", "inv", "ones", "size", "squeeze", "subset", "trace", "transpose", "zeros"]
}, S9e = {
  name: "reshape",
  category: "Matrix",
  syntax: ["reshape(x, sizes)"],
  description: "Reshape a multi dimensional array to fit the specified dimensions.",
  examples: ["reshape([1, 2, 3, 4, 5, 6], [2, 3])", "reshape([[1, 2], [3, 4]], [1, 4])", "reshape([[1, 2], [3, 4]], [4])", "reshape([1, 2, 3, 4], [-1, 2])"],
  seealso: ["size", "squeeze", "resize"]
}, C9e = {
  name: "resize",
  category: "Matrix",
  syntax: ["resize(x, size)", "resize(x, size, defaultValue)"],
  description: "Resize a matrix.",
  examples: ["resize([1,2,3,4,5], [3])", "resize([1,2,3], [5])", "resize([1,2,3], [5], -1)", "resize(2, [2, 3])", 'resize("hello", [8], "!")'],
  seealso: ["size", "subset", "squeeze", "reshape"]
}, A9e = {
  name: "rotate",
  category: "Matrix",
  syntax: ["rotate(w, theta)", "rotate(w, theta, v)"],
  description: "Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",
  examples: ["rotate([1, 0], pi / 2)", 'rotate(matrix([1, 0]), unit("35deg"))', 'rotate([1, 0, 0], unit("90deg"), [0, 0, 1])', 'rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))'],
  seealso: ["matrix", "rotationMatrix"]
}, x9e = {
  name: "rotationMatrix",
  category: "Matrix",
  syntax: ["rotationMatrix(theta)", "rotationMatrix(theta, v)", "rotationMatrix(theta, v, format)"],
  description: "Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.",
  examples: ["rotationMatrix(pi / 2)", 'rotationMatrix(unit("45deg"), [0, 0, 1])', 'rotationMatrix(1, matrix([0, 0, 1]), "sparse")'],
  seealso: ["cos", "sin"]
}, T9e = {
  name: "row",
  category: "Matrix",
  syntax: ["row(x, index)"],
  description: "Return a row from a matrix or array.",
  examples: ["A = [[1, 2], [3, 4]]", "row(A, 1)", "row(A, 2)"],
  seealso: ["column", "matrixFromRows"]
}, P9e = {
  name: "size",
  category: "Matrix",
  syntax: ["size(x)"],
  description: "Calculate the size of a matrix.",
  examples: ["size(2.3)", 'size("hello world")', "a = [1, 2; 3, 4; 5, 6]", "size(a)", "size(1:6)"],
  seealso: ["concat", "count", "det", "diag", "identity", "inv", "ones", "range", "squeeze", "subset", "trace", "transpose", "zeros"]
}, M9e = {
  name: "sort",
  category: "Matrix",
  syntax: ["sort(x)", "sort(x, compare)"],
  description: 'Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.',
  examples: ["sort([5, 10, 1])", 'sort(["C", "B", "A", "D"], "natural")', "sortByLength(a, b) = size(a)[1] - size(b)[1]", 'sort(["Langdon", "Tom", "Sara"], sortByLength)', 'sort(["10", "1", "2"], "natural")'],
  seealso: ["map", "filter", "forEach"]
}, w9e = {
  name: "squeeze",
  category: "Matrix",
  syntax: ["squeeze(x)"],
  description: "Remove inner and outer singleton dimensions from a matrix.",
  examples: ["a = zeros(3,2,1)", "size(squeeze(a))", "b = zeros(1,1,3)", "size(squeeze(b))"],
  seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "subset", "trace", "transpose", "zeros"]
}, E9e = {
  name: "subset",
  category: "Matrix",
  syntax: ["value(index)", "value(index) = replacement", "subset(value, [index])", "subset(value, [index], replacement)"],
  description: "Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",
  examples: ["d = [1, 2; 3, 4]", "e = []", "e[1, 1:2] = [5, 6]", "e[2, :] = [7, 8]", "f = d * e", "f[2, 1]", "f[:, 1]", "f[[1,2], [1,3]] = [9, 10; 11, 12]", "f"],
  seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "trace", "transpose", "zeros"]
}, D9e = {
  name: "trace",
  category: "Matrix",
  syntax: ["trace(A)"],
  description: "Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",
  examples: ["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]", "trace(A)"],
  seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "transpose", "zeros"]
}, I9e = {
  name: "transpose",
  category: "Matrix",
  syntax: ["x'", "transpose(x)"],
  description: "Transpose a matrix",
  examples: ["a = [1, 2, 3; 4, 5, 6]", "a'", "transpose(a)"],
  seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "zeros"]
}, B9e = {
  name: "zeros",
  category: "Matrix",
  syntax: ["zeros(m)", "zeros(m, n)", "zeros(m, n, p, ...)", "zeros([m])", "zeros([m, n])", "zeros([m, n, p, ...])"],
  description: "Create a matrix containing zeros.",
  examples: ["zeros(3)", "zeros(3, 5)", "a = [1, 2, 3; 4, 5, 6]", "zeros(size(a))"],
  seealso: ["concat", "det", "diag", "identity", "inv", "ones", "range", "size", "squeeze", "subset", "trace", "transpose"]
}, N9e = {
  name: "fft",
  category: "Matrix",
  syntax: ["fft(x)"],
  description: "Calculate N-dimensional fourier transform",
  examples: ["fft([[1, 0], [1, 0]])"],
  seealso: ["ifft"]
}, V9e = {
  name: "ifft",
  category: "Matrix",
  syntax: ["ifft(x)"],
  description: "Calculate N-dimensional inverse fourier transform",
  examples: ["ifft([[2, 2], [0, 0]])"],
  seealso: ["fft"]
}, R9e = {
  name: "combinations",
  category: "Probability",
  syntax: ["combinations(n, k)"],
  description: "Compute the number of combinations of n items taken k at a time",
  examples: ["combinations(7, 5)"],
  seealso: ["combinationsWithRep", "permutations", "factorial"]
}, O9e = {
  name: "combinationsWithRep",
  category: "Probability",
  syntax: ["combinationsWithRep(n, k)"],
  description: "Compute the number of combinations of n items taken k at a time with replacements.",
  examples: ["combinationsWithRep(7, 5)"],
  seealso: ["combinations", "permutations", "factorial"]
}, F9e = {
  name: "factorial",
  category: "Probability",
  syntax: ["n!", "factorial(n)"],
  description: "Compute the factorial of a value",
  examples: ["5!", "5 * 4 * 3 * 2 * 1", "3!"],
  seealso: ["combinations", "combinationsWithRep", "permutations", "gamma"]
}, L9e = {
  name: "gamma",
  category: "Probability",
  syntax: ["gamma(n)"],
  description: "Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",
  examples: ["gamma(4)", "3!", "gamma(1/2)", "sqrt(pi)"],
  seealso: ["factorial"]
}, k9e = {
  name: "lgamma",
  category: "Probability",
  syntax: ["lgamma(n)"],
  description: "Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.",
  examples: ["lgamma(4)", "lgamma(1/2)", "lgamma(i)", "lgamma(complex(1.1, 2))"],
  seealso: ["gamma"]
}, U9e = {
  name: "kldivergence",
  category: "Probability",
  syntax: ["kldivergence(x, y)"],
  description: "Calculate the Kullback-Leibler (KL) divergence  between two distributions.",
  examples: ["kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],
  seealso: []
}, z9e = {
  name: "multinomial",
  category: "Probability",
  syntax: ["multinomial(A)"],
  description: "Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",
  examples: ["multinomial([1, 2, 1])"],
  seealso: ["combinations", "factorial"]
}, G9e = {
  name: "permutations",
  category: "Probability",
  syntax: ["permutations(n)", "permutations(n, k)"],
  description: "Compute the number of permutations of n items taken k at a time",
  examples: ["permutations(5)", "permutations(5, 3)"],
  seealso: ["combinations", "combinationsWithRep", "factorial"]
}, q9e = {
  name: "pickRandom",
  category: "Probability",
  syntax: ["pickRandom(array)", "pickRandom(array, number)", "pickRandom(array, weights)", "pickRandom(array, number, weights)", "pickRandom(array, weights, number)"],
  description: "Pick a random entry from a given array.",
  examples: ["pickRandom(0:10)", "pickRandom([1, 3, 1, 6])", "pickRandom([1, 3, 1, 6], 2)", "pickRandom([1, 3, 1, 6], [2, 3, 2, 1])", "pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])", "pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)"],
  seealso: ["random", "randomInt"]
}, H9e = {
  name: "random",
  category: "Probability",
  syntax: ["random()", "random(max)", "random(min, max)", "random(size)", "random(size, max)", "random(size, min, max)"],
  description: "Return a random number.",
  examples: ["random()", "random(10, 20)", "random([2, 3])"],
  seealso: ["pickRandom", "randomInt"]
}, j9e = {
  name: "randomInt",
  category: "Probability",
  syntax: ["randomInt(max)", "randomInt(min, max)", "randomInt(size)", "randomInt(size, max)", "randomInt(size, min, max)"],
  description: "Return a random integer number",
  examples: ["randomInt(10, 20)", "randomInt([2, 3], 10)"],
  seealso: ["pickRandom", "random"]
}, $9e = {
  name: "compare",
  category: "Relational",
  syntax: ["compare(x, y)"],
  description: "Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",
  examples: ["compare(2, 3)", "compare(3, 2)", "compare(2, 2)", "compare(5cm, 40mm)", "compare(2, [1, 2, 3])"],
  seealso: ["equal", "unequal", "smaller", "smallerEq", "largerEq", "compareNatural", "compareText"]
}, K9e = {
  name: "compareNatural",
  category: "Relational",
  syntax: ["compareNatural(x, y)"],
  description: "Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",
  examples: ["compareNatural(2, 3)", "compareNatural(3, 2)", "compareNatural(2, 2)", "compareNatural(5cm, 40mm)", 'compareNatural("2", "10")', "compareNatural(2 + 3i, 2 + 4i)", "compareNatural([1, 2, 4], [1, 2, 3])", "compareNatural([1, 5], [1, 2, 3])", "compareNatural([1, 2], [1, 2])", "compareNatural({a: 2}, {a: 4})"],
  seealso: ["equal", "unequal", "smaller", "smallerEq", "largerEq", "compare", "compareText"]
}, W9e = {
  name: "compareText",
  category: "Relational",
  syntax: ["compareText(x, y)"],
  description: "Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.",
  examples: ['compareText("B", "A")', 'compareText("A", "B")', 'compareText("A", "A")', 'compareText("2", "10")', 'compare("2", "10")', "compare(2, 10)", 'compareNatural("2", "10")', 'compareText("B", ["A", "B", "C"])'],
  seealso: ["compare", "compareNatural"]
}, X9e = {
  name: "deepEqual",
  category: "Relational",
  syntax: ["deepEqual(x, y)"],
  description: "Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",
  examples: ["deepEqual([1,3,4], [1,3,4])", "deepEqual([1,3,4], [1,3])"],
  seealso: ["equal", "unequal", "smaller", "larger", "smallerEq", "largerEq", "compare"]
}, Y9e = {
  name: "equal",
  category: "Relational",
  syntax: ["x == y", "equal(x, y)"],
  description: "Check equality of two values. Returns true if the values are equal, and false if not.",
  examples: ["2+2 == 3", "2+2 == 4", "a = 3.2", "b = 6-2.8", "a == b", "50cm == 0.5m"],
  seealso: ["unequal", "smaller", "larger", "smallerEq", "largerEq", "compare", "deepEqual", "equalText"]
}, Q9e = {
  name: "equalText",
  category: "Relational",
  syntax: ["equalText(x, y)"],
  description: "Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.",
  examples: ['equalText("Hello", "Hello")', 'equalText("a", "A")', 'equal("2e3", "2000")', 'equalText("2e3", "2000")', 'equalText("B", ["A", "B", "C"])'],
  seealso: ["compare", "compareNatural", "compareText", "equal"]
}, Z9e = {
  name: "larger",
  category: "Relational",
  syntax: ["x > y", "larger(x, y)"],
  description: "Check if value x is larger than y. Returns true if x is larger than y, and false if not.",
  examples: ["2 > 3", "5 > 2*2", "a = 3.3", "b = 6-2.8", "(a > b)", "(b < a)", "5 cm > 2 inch"],
  seealso: ["equal", "unequal", "smaller", "smallerEq", "largerEq", "compare"]
}, J9e = {
  name: "largerEq",
  category: "Relational",
  syntax: ["x >= y", "largerEq(x, y)"],
  description: "Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",
  examples: ["2 >= 1+1", "2 > 1+1", "a = 3.2", "b = 6-2.8", "(a >= b)"],
  seealso: ["equal", "unequal", "smallerEq", "smaller", "compare"]
}, eBe = {
  name: "smaller",
  category: "Relational",
  syntax: ["x < y", "smaller(x, y)"],
  description: "Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",
  examples: ["2 < 3", "5 < 2*2", "a = 3.3", "b = 6-2.8", "(a < b)", "5 cm < 2 inch"],
  seealso: ["equal", "unequal", "larger", "smallerEq", "largerEq", "compare"]
}, rBe = {
  name: "smallerEq",
  category: "Relational",
  syntax: ["x <= y", "smallerEq(x, y)"],
  description: "Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",
  examples: ["2 <= 1+1", "2 < 1+1", "a = 3.2", "b = 6-2.8", "(a <= b)"],
  seealso: ["equal", "unequal", "larger", "smaller", "largerEq", "compare"]
}, tBe = {
  name: "unequal",
  category: "Relational",
  syntax: ["x != y", "unequal(x, y)"],
  description: "Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",
  examples: ["2+2 != 3", "2+2 != 4", "a = 3.2", "b = 6-2.8", "a != b", "50cm != 0.5m", "5 cm != 2 inch"],
  seealso: ["equal", "smaller", "larger", "smallerEq", "largerEq", "compare", "deepEqual"]
}, nBe = {
  name: "setCartesian",
  category: "Set",
  syntax: ["setCartesian(set1, set2)"],
  description: "Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.",
  examples: ["setCartesian([1, 2], [3, 4])"],
  seealso: ["setUnion", "setIntersect", "setDifference", "setPowerset"]
}, aBe = {
  name: "setDifference",
  category: "Set",
  syntax: ["setDifference(set1, set2)"],
  description: "Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",
  examples: ["setDifference([1, 2, 3, 4], [3, 4, 5, 6])", "setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],
  seealso: ["setUnion", "setIntersect", "setSymDifference"]
}, iBe = {
  name: "setDistinct",
  category: "Set",
  syntax: ["setDistinct(set)"],
  description: "Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",
  examples: ["setDistinct([1, 1, 1, 2, 2, 3])"],
  seealso: ["setMultiplicity"]
}, oBe = {
  name: "setIntersect",
  category: "Set",
  syntax: ["setIntersect(set1, set2)"],
  description: "Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",
  examples: ["setIntersect([1, 2, 3, 4], [3, 4, 5, 6])", "setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],
  seealso: ["setUnion", "setDifference"]
}, uBe = {
  name: "setIsSubset",
  category: "Set",
  syntax: ["setIsSubset(set1, set2)"],
  description: "Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",
  examples: ["setIsSubset([1, 2], [3, 4, 5, 6])", "setIsSubset([3, 4], [3, 4, 5, 6])"],
  seealso: ["setUnion", "setIntersect", "setDifference"]
}, sBe = {
  name: "setMultiplicity",
  category: "Set",
  syntax: ["setMultiplicity(element, set)"],
  description: "Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.",
  examples: ["setMultiplicity(1, [1, 2, 2, 4])", "setMultiplicity(2, [1, 2, 2, 4])"],
  seealso: ["setDistinct", "setSize"]
}, lBe = {
  name: "setPowerset",
  category: "Set",
  syntax: ["setPowerset(set)"],
  description: "Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.",
  examples: ["setPowerset([1, 2, 3])"],
  seealso: ["setCartesian"]
}, cBe = {
  name: "setSize",
  category: "Set",
  syntax: ["setSize(set)", "setSize(set, unique)"],
  description: 'Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.',
  examples: ["setSize([1, 2, 2, 4])", "setSize([1, 2, 2, 4], true)"],
  seealso: ["setUnion", "setIntersect", "setDifference"]
}, dBe = {
  name: "setSymDifference",
  category: "Set",
  syntax: ["setSymDifference(set1, set2)"],
  description: "Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",
  examples: ["setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])", "setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],
  seealso: ["setUnion", "setIntersect", "setDifference"]
}, fBe = {
  name: "setUnion",
  category: "Set",
  syntax: ["setUnion(set1, set2)"],
  description: "Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.",
  examples: ["setUnion([1, 2, 3, 4], [3, 4, 5, 6])", "setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])"],
  seealso: ["setIntersect", "setDifference"]
}, mBe = {
  name: "zpk2tf",
  category: "Signal",
  syntax: ["zpk2tf(z, p, k)"],
  description: "Compute the transfer function of a zero-pole-gain model.",
  examples: ["zpk2tf([1, 2], [-1, -2], 1)", "zpk2tf([1, 2], [-1, -2])", "zpk2tf([1 - 3i, 2 + 2i], [-1, -2])"],
  seealso: []
}, vBe = {
  name: "freqz",
  category: "Signal",
  syntax: ["freqz(b, a)", "freqz(b, a, w)"],
  description: "Calculates the frequency response of a filter given its numerator and denominator coefficients.",
  examples: ["freqz([1, 2], [1, 2, 3])", "freqz([1, 2], [1, 2, 3], [0, 1])", "freqz([1, 2], [1, 2, 3], 512)"],
  seealso: []
}, pBe = {
  name: "erf",
  category: "Special",
  syntax: ["erf(x)"],
  description: "Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x",
  examples: ["erf(0.2)", "erf(-0.5)", "erf(4)"],
  seealso: []
}, hBe = {
  name: "zeta",
  category: "Special",
  syntax: ["zeta(s)"],
  description: "Compute the Riemann Zeta Function using an infinite series and Riemanns Functional Equation for the entire complex plane",
  examples: ["zeta(0.2)", "zeta(-0.5)", "zeta(4)"],
  seealso: []
}, gBe = {
  name: "mad",
  category: "Statistics",
  syntax: ["mad(a, b, c, ...)", "mad(A)"],
  description: "Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.",
  examples: ["mad(10, 20, 30)", "mad([1, 2, 3])"],
  seealso: ["mean", "median", "std", "abs"]
}, yBe = {
  name: "max",
  category: "Statistics",
  syntax: ["max(a, b, c, ...)", "max(A)", "max(A, dimension)"],
  description: "Compute the maximum value of a list of values.",
  examples: ["max(2, 3, 4, 1)", "max([2, 3, 4, 1])", "max([2, 5; 4, 3])", "max([2, 5; 4, 3], 1)", "max([2, 5; 4, 3], 2)", "max(2.7, 7.1, -4.5, 2.0, 4.1)", "min(2.7, 7.1, -4.5, 2.0, 4.1)"],
  seealso: ["mean", "median", "min", "prod", "std", "sum", "variance"]
}, _Be = {
  name: "mean",
  category: "Statistics",
  syntax: ["mean(a, b, c, ...)", "mean(A)", "mean(A, dimension)"],
  description: "Compute the arithmetic mean of a list of values.",
  examples: ["mean(2, 3, 4, 1)", "mean([2, 3, 4, 1])", "mean([2, 5; 4, 3])", "mean([2, 5; 4, 3], 1)", "mean([2, 5; 4, 3], 2)", "mean([1.0, 2.7, 3.2, 4.0])"],
  seealso: ["max", "median", "min", "prod", "std", "sum", "variance"]
}, bBe = {
  name: "median",
  category: "Statistics",
  syntax: ["median(a, b, c, ...)", "median(A)"],
  description: "Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",
  examples: ["median(5, 2, 7)", "median([3, -1, 5, 7])"],
  seealso: ["max", "mean", "min", "prod", "std", "sum", "variance", "quantileSeq"]
}, SBe = {
  name: "min",
  category: "Statistics",
  syntax: ["min(a, b, c, ...)", "min(A)", "min(A, dimension)"],
  description: "Compute the minimum value of a list of values.",
  examples: ["min(2, 3, 4, 1)", "min([2, 3, 4, 1])", "min([2, 5; 4, 3])", "min([2, 5; 4, 3], 1)", "min([2, 5; 4, 3], 2)", "min(2.7, 7.1, -4.5, 2.0, 4.1)", "max(2.7, 7.1, -4.5, 2.0, 4.1)"],
  seealso: ["max", "mean", "median", "prod", "std", "sum", "variance"]
}, CBe = {
  name: "mode",
  category: "Statistics",
  syntax: ["mode(a, b, c, ...)", "mode(A)", "mode(A, a, b, B, c, ...)"],
  description: "Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.",
  examples: ["mode(2, 1, 4, 3, 1)", "mode([1, 2.7, 3.2, 4, 2.7])", "mode(1, 4, 6, 1, 6)"],
  seealso: ["max", "mean", "min", "median", "prod", "std", "sum", "variance"]
}, ABe = {
  name: "prod",
  category: "Statistics",
  syntax: ["prod(a, b, c, ...)", "prod(A)"],
  description: "Compute the product of all values.",
  examples: ["prod(2, 3, 4)", "prod([2, 3, 4])", "prod([2, 5; 4, 3])"],
  seealso: ["max", "mean", "min", "median", "min", "std", "sum", "variance"]
}, xBe = {
  name: "quantileSeq",
  category: "Statistics",
  syntax: ["quantileSeq(A, prob[, sorted])", "quantileSeq(A, [prob1, prob2, ...][, sorted])", "quantileSeq(A, N[, sorted])"],
  description: `Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probablity are: Number, BigNumber. 

In case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.`,
  examples: ["quantileSeq([3, -1, 5, 7], 0.5)", "quantileSeq([3, -1, 5, 7], [1/3, 2/3])", "quantileSeq([3, -1, 5, 7], 2)", "quantileSeq([-1, 3, 5, 7], 0.5, true)"],
  seealso: ["mean", "median", "min", "max", "prod", "std", "sum", "variance"]
}, TBe = {
  name: "std",
  category: "Statistics",
  syntax: ["std(a, b, c, ...)", "std(A)", "std(A, dimension)", "std(A, normalization)", "std(A, dimension, normalization)"],
  description: 'Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',
  examples: ["std(2, 4, 6)", "std([2, 4, 6, 8])", 'std([2, 4, 6, 8], "uncorrected")', 'std([2, 4, 6, 8], "biased")', "std([1, 2, 3; 4, 5, 6])"],
  seealso: ["max", "mean", "min", "median", "prod", "sum", "variance"]
}, PBe = {
  name: "cumsum",
  category: "Statistics",
  syntax: ["cumsum(a, b, c, ...)", "cumsum(A)"],
  description: "Compute the cumulative sum of all values.",
  examples: ["cumsum(2, 3, 4, 1)", "cumsum([2, 3, 4, 1])", "cumsum([1, 2; 3, 4])", "cumsum([1, 2; 3, 4], 1)", "cumsum([1, 2; 3, 4], 2)"],
  seealso: ["max", "mean", "median", "min", "prod", "std", "sum", "variance"]
}, MBe = {
  name: "sum",
  category: "Statistics",
  syntax: ["sum(a, b, c, ...)", "sum(A)", "sum(A, dimension)"],
  description: "Compute the sum of all values.",
  examples: ["sum(2, 3, 4, 1)", "sum([2, 3, 4, 1])", "sum([2, 5; 4, 3])"],
  seealso: ["max", "mean", "median", "min", "prod", "std", "sum", "variance"]
}, wBe = {
  name: "variance",
  category: "Statistics",
  syntax: ["variance(a, b, c, ...)", "variance(A)", "variance(A, dimension)", "variance(A, normalization)", "variance(A, dimension, normalization)"],
  description: 'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',
  examples: ["variance(2, 4, 6)", "variance([2, 4, 6, 8])", 'variance([2, 4, 6, 8], "uncorrected")', 'variance([2, 4, 6, 8], "biased")', "variance([1, 2, 3; 4, 5, 6])"],
  seealso: ["max", "mean", "min", "median", "min", "prod", "std", "sum"]
}, EBe = {
  name: "corr",
  category: "Statistics",
  syntax: ["corr(A,B)"],
  description: "Compute the correlation coefficient of a two list with values, For matrices, the matrix correlation coefficient is calculated.",
  examples: ["corr([2, 4, 6, 8],[1, 2, 3, 6])", "corr(matrix([[1, 2.2, 3, 4.8, 5], [1, 2, 3, 4, 5]]), matrix([[4, 5.3, 6.6, 7, 8], [1, 2, 3, 4, 5]]))"],
  seealso: ["max", "mean", "min", "median", "min", "prod", "std", "sum"]
}, DBe = {
  name: "acos",
  category: "Trigonometry",
  syntax: ["acos(x)"],
  description: "Compute the inverse cosine of a value in radians.",
  examples: ["acos(0.5)", "acos(cos(2.3))"],
  seealso: ["cos", "atan", "asin"]
}, IBe = {
  name: "acosh",
  category: "Trigonometry",
  syntax: ["acosh(x)"],
  description: "Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",
  examples: ["acosh(1.5)"],
  seealso: ["cosh", "asinh", "atanh"]
}, BBe = {
  name: "acot",
  category: "Trigonometry",
  syntax: ["acot(x)"],
  description: "Calculate the inverse cotangent of a value.",
  examples: ["acot(0.5)", "acot(cot(0.5))", "acot(2)"],
  seealso: ["cot", "atan"]
}, NBe = {
  name: "acoth",
  category: "Trigonometry",
  syntax: ["acoth(x)"],
  description: "Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",
  examples: ["acoth(2)", "acoth(0.5)"],
  seealso: ["acsch", "asech"]
}, VBe = {
  name: "acsc",
  category: "Trigonometry",
  syntax: ["acsc(x)"],
  description: "Calculate the inverse cotangent of a value.",
  examples: ["acsc(2)", "acsc(csc(0.5))", "acsc(0.5)"],
  seealso: ["csc", "asin", "asec"]
}, RBe = {
  name: "acsch",
  category: "Trigonometry",
  syntax: ["acsch(x)"],
  description: "Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",
  examples: ["acsch(0.5)"],
  seealso: ["asech", "acoth"]
}, OBe = {
  name: "asec",
  category: "Trigonometry",
  syntax: ["asec(x)"],
  description: "Calculate the inverse secant of a value.",
  examples: ["asec(0.5)", "asec(sec(0.5))", "asec(2)"],
  seealso: ["acos", "acot", "acsc"]
}, FBe = {
  name: "asech",
  category: "Trigonometry",
  syntax: ["asech(x)"],
  description: "Calculate the inverse secant of a value.",
  examples: ["asech(0.5)"],
  seealso: ["acsch", "acoth"]
}, LBe = {
  name: "asin",
  category: "Trigonometry",
  syntax: ["asin(x)"],
  description: "Compute the inverse sine of a value in radians.",
  examples: ["asin(0.5)", "asin(sin(0.5))"],
  seealso: ["sin", "acos", "atan"]
}, kBe = {
  name: "asinh",
  category: "Trigonometry",
  syntax: ["asinh(x)"],
  description: "Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",
  examples: ["asinh(0.5)"],
  seealso: ["acosh", "atanh"]
}, UBe = {
  name: "atan",
  category: "Trigonometry",
  syntax: ["atan(x)"],
  description: "Compute the inverse tangent of a value in radians.",
  examples: ["atan(0.5)", "atan(tan(0.5))"],
  seealso: ["tan", "acos", "asin"]
}, zBe = {
  name: "atan2",
  category: "Trigonometry",
  syntax: ["atan2(y, x)"],
  description: "Computes the principal value of the arc tangent of y/x in radians.",
  examples: ["atan2(2, 2) / pi", "angle = 60 deg in rad", "x = cos(angle)", "y = sin(angle)", "atan2(y, x)"],
  seealso: ["sin", "cos", "tan"]
}, GBe = {
  name: "atanh",
  category: "Trigonometry",
  syntax: ["atanh(x)"],
  description: "Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",
  examples: ["atanh(0.5)"],
  seealso: ["acosh", "asinh"]
}, qBe = {
  name: "cos",
  category: "Trigonometry",
  syntax: ["cos(x)"],
  description: "Compute the cosine of x in radians.",
  examples: ["cos(2)", "cos(pi / 4) ^ 2", "cos(180 deg)", "cos(60 deg)", "sin(0.2)^2 + cos(0.2)^2"],
  seealso: ["acos", "sin", "tan"]
}, HBe = {
  name: "cosh",
  category: "Trigonometry",
  syntax: ["cosh(x)"],
  description: "Compute the hyperbolic cosine of x in radians.",
  examples: ["cosh(0.5)"],
  seealso: ["sinh", "tanh", "coth"]
}, jBe = {
  name: "cot",
  category: "Trigonometry",
  syntax: ["cot(x)"],
  description: "Compute the cotangent of x in radians. Defined as 1/tan(x)",
  examples: ["cot(2)", "1 / tan(2)"],
  seealso: ["sec", "csc", "tan"]
}, $Be = {
  name: "coth",
  category: "Trigonometry",
  syntax: ["coth(x)"],
  description: "Compute the hyperbolic cotangent of x in radians.",
  examples: ["coth(2)", "1 / tanh(2)"],
  seealso: ["sech", "csch", "tanh"]
}, KBe = {
  name: "csc",
  category: "Trigonometry",
  syntax: ["csc(x)"],
  description: "Compute the cosecant of x in radians. Defined as 1/sin(x)",
  examples: ["csc(2)", "1 / sin(2)"],
  seealso: ["sec", "cot", "sin"]
}, WBe = {
  name: "csch",
  category: "Trigonometry",
  syntax: ["csch(x)"],
  description: "Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",
  examples: ["csch(2)", "1 / sinh(2)"],
  seealso: ["sech", "coth", "sinh"]
}, XBe = {
  name: "sec",
  category: "Trigonometry",
  syntax: ["sec(x)"],
  description: "Compute the secant of x in radians. Defined as 1/cos(x)",
  examples: ["sec(2)", "1 / cos(2)"],
  seealso: ["cot", "csc", "cos"]
}, YBe = {
  name: "sech",
  category: "Trigonometry",
  syntax: ["sech(x)"],
  description: "Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",
  examples: ["sech(2)", "1 / cosh(2)"],
  seealso: ["coth", "csch", "cosh"]
}, QBe = {
  name: "sin",
  category: "Trigonometry",
  syntax: ["sin(x)"],
  description: "Compute the sine of x in radians.",
  examples: ["sin(2)", "sin(pi / 4) ^ 2", "sin(90 deg)", "sin(30 deg)", "sin(0.2)^2 + cos(0.2)^2"],
  seealso: ["asin", "cos", "tan"]
}, ZBe = {
  name: "sinh",
  category: "Trigonometry",
  syntax: ["sinh(x)"],
  description: "Compute the hyperbolic sine of x in radians.",
  examples: ["sinh(0.5)"],
  seealso: ["cosh", "tanh"]
}, JBe = {
  name: "tan",
  category: "Trigonometry",
  syntax: ["tan(x)"],
  description: "Compute the tangent of x in radians.",
  examples: ["tan(0.5)", "sin(0.5) / cos(0.5)", "tan(pi / 4)", "tan(45 deg)"],
  seealso: ["atan", "sin", "cos"]
}, eNe = {
  name: "tanh",
  category: "Trigonometry",
  syntax: ["tanh(x)"],
  description: "Compute the hyperbolic tangent of x in radians.",
  examples: ["tanh(0.5)", "sinh(0.5) / cosh(0.5)"],
  seealso: ["sinh", "cosh"]
}, rNe = {
  name: "to",
  category: "Units",
  syntax: ["x to unit", "to(x, unit)"],
  description: "Change the unit of a value.",
  examples: ["5 inch to cm", "3.2kg to g", "16 bytes in bits"],
  seealso: []
}, tNe = {
  name: "bin",
  category: "Utils",
  syntax: ["bin(value)"],
  description: "Format a number as binary",
  examples: ["bin(2)"],
  seealso: ["oct", "hex"]
}, nNe = {
  name: "clone",
  category: "Utils",
  syntax: ["clone(x)"],
  description: "Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",
  examples: ["clone(3.5)", "clone(2 - 4i)", "clone(45 deg)", "clone([1, 2; 3, 4])", 'clone("hello world")'],
  seealso: []
}, aNe = {
  name: "format",
  category: "Utils",
  syntax: ["format(value)", "format(value, precision)"],
  description: "Format a value of any type as string.",
  examples: ["format(2.3)", "format(3 - 4i)", "format([])", "format(pi, 3)"],
  seealso: ["print"]
}, iNe = {
  name: "hasNumericValue",
  category: "Utils",
  syntax: ["hasNumericValue(x)"],
  description: "Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.",
  examples: ["hasNumericValue(2)", 'hasNumericValue("2")', 'isNumeric("2")', "hasNumericValue(0)", "hasNumericValue(bignumber(500))", "hasNumericValue(fraction(0.125))", "hasNumericValue(2 + 3i)", 'hasNumericValue([2.3, "foo", false])'],
  seealso: ["isInteger", "isZero", "isNegative", "isPositive", "isNaN", "isNumeric"]
}, oNe = {
  name: "hex",
  category: "Utils",
  syntax: ["hex(value)"],
  description: "Format a number as hexadecimal",
  examples: ["hex(240)"],
  seealso: ["bin", "oct"]
}, uNe = {
  name: "isInteger",
  category: "Utils",
  syntax: ["isInteger(x)"],
  description: "Test whether a value is an integer number.",
  examples: ["isInteger(2)", "isInteger(3.5)", "isInteger([3, 0.5, -2])"],
  seealso: ["isNegative", "isNumeric", "isPositive", "isZero"]
}, sNe = {
  name: "isNaN",
  category: "Utils",
  syntax: ["isNaN(x)"],
  description: "Test whether a value is NaN (not a number)",
  examples: ["isNaN(2)", "isNaN(0 / 0)", "isNaN(NaN)", "isNaN(Infinity)"],
  seealso: ["isNegative", "isNumeric", "isPositive", "isZero"]
}, lNe = {
  name: "isNegative",
  category: "Utils",
  syntax: ["isNegative(x)"],
  description: "Test whether a value is negative: smaller than zero.",
  examples: ["isNegative(2)", "isNegative(0)", "isNegative(-4)", "isNegative([3, 0.5, -2])"],
  seealso: ["isInteger", "isNumeric", "isPositive", "isZero"]
}, cNe = {
  name: "isNumeric",
  category: "Utils",
  syntax: ["isNumeric(x)"],
  description: "Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.",
  examples: ["isNumeric(2)", 'isNumeric("2")', 'hasNumericValue("2")', "isNumeric(0)", "isNumeric(bignumber(500))", "isNumeric(fraction(0.125))", "isNumeric(2 + 3i)", 'isNumeric([2.3, "foo", false])'],
  seealso: ["isInteger", "isZero", "isNegative", "isPositive", "isNaN", "hasNumericValue"]
}, dNe = {
  name: "isPositive",
  category: "Utils",
  syntax: ["isPositive(x)"],
  description: "Test whether a value is positive: larger than zero.",
  examples: ["isPositive(2)", "isPositive(0)", "isPositive(-4)", "isPositive([3, 0.5, -2])"],
  seealso: ["isInteger", "isNumeric", "isNegative", "isZero"]
}, fNe = {
  name: "isPrime",
  category: "Utils",
  syntax: ["isPrime(x)"],
  description: "Test whether a value is prime: has no divisors other than itself and one.",
  examples: ["isPrime(3)", "isPrime(-2)", "isPrime([2, 17, 100])"],
  seealso: ["isInteger", "isNumeric", "isNegative", "isZero"]
}, mNe = {
  name: "isZero",
  category: "Utils",
  syntax: ["isZero(x)"],
  description: "Test whether a value is zero.",
  examples: ["isZero(2)", "isZero(0)", "isZero(-4)", "isZero([3, 0, -2, 0])"],
  seealso: ["isInteger", "isNumeric", "isNegative", "isPositive"]
}, vNe = {
  name: "numeric",
  category: "Utils",
  syntax: ["numeric(x)"],
  description: "Convert a numeric input to a specific numeric type: number, BigNumber, bigint, or Fraction.",
  examples: ['numeric("4")', 'numeric("4", "number")', 'numeric("4", "bigint")', 'numeric("4", "BigNumber")', 'numeric("4", "Fraction")', 'numeric(4, "Fraction")', 'numeric(fraction(2, 5), "number")'],
  seealso: ["number", "bigint", "fraction", "bignumber", "string", "format"]
}, pNe = {
  name: "oct",
  category: "Utils",
  syntax: ["oct(value)"],
  description: "Format a number as octal",
  examples: ["oct(56)"],
  seealso: ["bin", "hex"]
}, hNe = {
  name: "print",
  category: "Utils",
  syntax: ["print(template, values)", "print(template, values, precision)"],
  description: "Interpolate values into a string template.",
  examples: ['print("Lucy is $age years old", {age: 5})', 'print("The value of pi is $pi", {pi: pi}, 3)', 'print("Hello, $user.name!", {user: {name: "John"}})', 'print("Values: $1, $2, $3", [6, 9, 4])'],
  seealso: ["format"]
}, gNe = {
  name: "typeOf",
  category: "Utils",
  syntax: ["typeOf(x)"],
  description: "Get the type of a variable.",
  examples: ["typeOf(3.5)", "typeOf(2 - 4i)", "typeOf(45 deg)", 'typeOf("hello world")'],
  seealso: ["getMatrixDataType"]
}, yNe = {
  name: "solveODE",
  category: "Numeric",
  syntax: ["solveODE(func, tspan, y0)", "solveODE(func, tspan, y0, options)"],
  description: "Numerical Integration of Ordinary Differential Equations.",
  examples: ["f(t,y) = y", "tspan = [0, 4]", "solveODE(f, tspan, 1)", "solveODE(f, tspan, [1, 2])", 'solveODE(f, tspan, 1, { method:"RK23", maxStep:0.1 })'],
  seealso: ["derivative", "simplifyCore"]
}, _Ne = {
  // construction functions
  bignumber: s8e,
  bigint: l8e,
  boolean: c8e,
  complex: d8e,
  createUnit: f8e,
  fraction: m8e,
  index: v8e,
  matrix: p8e,
  number: h8e,
  sparse: g8e,
  splitUnit: y8e,
  string: _8e,
  unit: b8e,
  // constants
  e: RL,
  E: RL,
  false: KIe,
  i: WIe,
  Infinity: XIe,
  LN2: QIe,
  LN10: YIe,
  LOG2E: JIe,
  LOG10E: ZIe,
  NaN: e8e,
  null: r8e,
  pi: OL,
  PI: OL,
  phi: t8e,
  SQRT1_2: n8e,
  SQRT2: a8e,
  tau: i8e,
  true: o8e,
  version: u8e,
  // physical constants
  // TODO: more detailed docs for physical constants
  speedOfLight: {
    description: "Speed of light in vacuum",
    examples: ["speedOfLight"]
  },
  gravitationConstant: {
    description: "Newtonian constant of gravitation",
    examples: ["gravitationConstant"]
  },
  planckConstant: {
    description: "Planck constant",
    examples: ["planckConstant"]
  },
  reducedPlanckConstant: {
    description: "Reduced Planck constant",
    examples: ["reducedPlanckConstant"]
  },
  magneticConstant: {
    description: "Magnetic constant (vacuum permeability)",
    examples: ["magneticConstant"]
  },
  electricConstant: {
    description: "Electric constant (vacuum permeability)",
    examples: ["electricConstant"]
  },
  vacuumImpedance: {
    description: "Characteristic impedance of vacuum",
    examples: ["vacuumImpedance"]
  },
  coulomb: {
    description: "Coulomb's constant",
    examples: ["coulomb"]
  },
  elementaryCharge: {
    description: "Elementary charge",
    examples: ["elementaryCharge"]
  },
  bohrMagneton: {
    description: "Borh magneton",
    examples: ["bohrMagneton"]
  },
  conductanceQuantum: {
    description: "Conductance quantum",
    examples: ["conductanceQuantum"]
  },
  inverseConductanceQuantum: {
    description: "Inverse conductance quantum",
    examples: ["inverseConductanceQuantum"]
  },
  // josephson: {description: 'Josephson constant', examples: ['josephson']},
  magneticFluxQuantum: {
    description: "Magnetic flux quantum",
    examples: ["magneticFluxQuantum"]
  },
  nuclearMagneton: {
    description: "Nuclear magneton",
    examples: ["nuclearMagneton"]
  },
  klitzing: {
    description: "Von Klitzing constant",
    examples: ["klitzing"]
  },
  bohrRadius: {
    description: "Borh radius",
    examples: ["bohrRadius"]
  },
  classicalElectronRadius: {
    description: "Classical electron radius",
    examples: ["classicalElectronRadius"]
  },
  electronMass: {
    description: "Electron mass",
    examples: ["electronMass"]
  },
  fermiCoupling: {
    description: "Fermi coupling constant",
    examples: ["fermiCoupling"]
  },
  fineStructure: {
    description: "Fine-structure constant",
    examples: ["fineStructure"]
  },
  hartreeEnergy: {
    description: "Hartree energy",
    examples: ["hartreeEnergy"]
  },
  protonMass: {
    description: "Proton mass",
    examples: ["protonMass"]
  },
  deuteronMass: {
    description: "Deuteron Mass",
    examples: ["deuteronMass"]
  },
  neutronMass: {
    description: "Neutron mass",
    examples: ["neutronMass"]
  },
  quantumOfCirculation: {
    description: "Quantum of circulation",
    examples: ["quantumOfCirculation"]
  },
  rydberg: {
    description: "Rydberg constant",
    examples: ["rydberg"]
  },
  thomsonCrossSection: {
    description: "Thomson cross section",
    examples: ["thomsonCrossSection"]
  },
  weakMixingAngle: {
    description: "Weak mixing angle",
    examples: ["weakMixingAngle"]
  },
  efimovFactor: {
    description: "Efimov factor",
    examples: ["efimovFactor"]
  },
  atomicMass: {
    description: "Atomic mass constant",
    examples: ["atomicMass"]
  },
  avogadro: {
    description: "Avogadro's number",
    examples: ["avogadro"]
  },
  boltzmann: {
    description: "Boltzmann constant",
    examples: ["boltzmann"]
  },
  faraday: {
    description: "Faraday constant",
    examples: ["faraday"]
  },
  firstRadiation: {
    description: "First radiation constant",
    examples: ["firstRadiation"]
  },
  loschmidt: {
    description: "Loschmidt constant at T=273.15 K and p=101.325 kPa",
    examples: ["loschmidt"]
  },
  gasConstant: {
    description: "Gas constant",
    examples: ["gasConstant"]
  },
  molarPlanckConstant: {
    description: "Molar Planck constant",
    examples: ["molarPlanckConstant"]
  },
  molarVolume: {
    description: "Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",
    examples: ["molarVolume"]
  },
  sackurTetrode: {
    description: "Sackur-Tetrode constant at T=1 K and p=101.325 kPa",
    examples: ["sackurTetrode"]
  },
  secondRadiation: {
    description: "Second radiation constant",
    examples: ["secondRadiation"]
  },
  stefanBoltzmann: {
    description: "Stefan-Boltzmann constant",
    examples: ["stefanBoltzmann"]
  },
  wienDisplacement: {
    description: "Wien displacement law constant",
    examples: ["wienDisplacement"]
  },
  // spectralRadiance: {description: 'First radiation constant for spectral radiance', examples: ['spectralRadiance']},
  molarMass: {
    description: "Molar mass constant",
    examples: ["molarMass"]
  },
  molarMassC12: {
    description: "Molar mass constant of carbon-12",
    examples: ["molarMassC12"]
  },
  gravity: {
    description: "Standard acceleration of gravity (standard acceleration of free-fall on Earth)",
    examples: ["gravity"]
  },
  planckLength: {
    description: "Planck length",
    examples: ["planckLength"]
  },
  planckMass: {
    description: "Planck mass",
    examples: ["planckMass"]
  },
  planckTime: {
    description: "Planck time",
    examples: ["planckTime"]
  },
  planckCharge: {
    description: "Planck charge",
    examples: ["planckCharge"]
  },
  planckTemperature: {
    description: "Planck temperature",
    examples: ["planckTemperature"]
  },
  // functions - algebra
  derivative: x8e,
  lsolve: P8e,
  lsolveAll: M8e,
  lup: w8e,
  lusolve: E8e,
  leafCount: T8e,
  polynomialRoot: D8e,
  resolve: N8e,
  simplify: V8e,
  simplifyConstant: R8e,
  simplifyCore: O8e,
  symbolicEqual: L8e,
  rationalize: B8e,
  slu: F8e,
  usolve: k8e,
  usolveAll: U8e,
  qr: I8e,
  // functions - arithmetic
  abs: z8e,
  add: G8e,
  cbrt: q8e,
  ceil: H8e,
  cube: j8e,
  divide: $8e,
  dotDivide: K8e,
  dotMultiply: W8e,
  dotPow: X8e,
  exp: Y8e,
  expm: Q8e,
  expm1: Z8e,
  fix: J8e,
  floor: e7e,
  gcd: r7e,
  hypot: t7e,
  lcm: a7e,
  log: i7e,
  log2: s7e,
  log1p: u7e,
  log10: o7e,
  mod: l7e,
  multiply: c7e,
  norm: d7e,
  nthRoot: f7e,
  nthRoots: m7e,
  pow: v7e,
  round: p7e,
  sign: h7e,
  sqrt: g7e,
  sqrtm: y7e,
  square: C7e,
  subtract: A7e,
  unaryMinus: x7e,
  unaryPlus: T7e,
  xgcd: P7e,
  invmod: n7e,
  // functions - bitwise
  bitAnd: M7e,
  bitNot: w7e,
  bitOr: E7e,
  bitXor: D7e,
  leftShift: I7e,
  rightArithShift: B7e,
  rightLogShift: N7e,
  // functions - combinatorics
  bellNumbers: V7e,
  catalan: R7e,
  composition: O7e,
  stirlingS2: F7e,
  // functions - core
  config: S8e,
  import: C8e,
  typed: A8e,
  // functions - complex
  arg: L7e,
  conj: k7e,
  re: z7e,
  im: U7e,
  // functions - expression
  evaluate: G7e,
  help: q7e,
  // functions - geometry
  distance: H7e,
  intersect: j7e,
  // functions - logical
  and: $7e,
  not: K7e,
  or: W7e,
  xor: X7e,
  // functions - matrix
  concat: Q7e,
  count: Z7e,
  cross: J7e,
  column: Y7e,
  ctranspose: e9e,
  det: r9e,
  diag: t9e,
  diff: n9e,
  dot: a9e,
  getMatrixDataType: l9e,
  identity: c9e,
  filter: o9e,
  flatten: u9e,
  forEach: s9e,
  inv: d9e,
  pinv: f9e,
  eigs: i9e,
  kron: m9e,
  matrixFromFunction: h9e,
  matrixFromRows: g9e,
  matrixFromColumns: p9e,
  map: v9e,
  ones: y9e,
  partitionSelect: _9e,
  range: b9e,
  resize: C9e,
  reshape: S9e,
  rotate: A9e,
  rotationMatrix: x9e,
  row: T9e,
  size: P9e,
  sort: M9e,
  squeeze: w9e,
  subset: E9e,
  trace: D9e,
  transpose: I9e,
  zeros: B9e,
  fft: N9e,
  ifft: V9e,
  sylvester: _7e,
  schur: b7e,
  lyap: S7e,
  // functions - numeric
  solveODE: yNe,
  // functions - probability
  combinations: R9e,
  combinationsWithRep: O9e,
  // distribution: distributionDocs,
  factorial: F9e,
  gamma: L9e,
  kldivergence: U9e,
  lgamma: k9e,
  multinomial: z9e,
  permutations: G9e,
  pickRandom: q9e,
  random: H9e,
  randomInt: j9e,
  // functions - relational
  compare: $9e,
  compareNatural: K9e,
  compareText: W9e,
  deepEqual: X9e,
  equal: Y9e,
  equalText: Q9e,
  larger: Z9e,
  largerEq: J9e,
  smaller: eBe,
  smallerEq: rBe,
  unequal: tBe,
  // functions - set
  setCartesian: nBe,
  setDifference: aBe,
  setDistinct: iBe,
  setIntersect: oBe,
  setIsSubset: uBe,
  setMultiplicity: sBe,
  setPowerset: lBe,
  setSize: cBe,
  setSymDifference: dBe,
  setUnion: fBe,
  // functions - signal
  zpk2tf: mBe,
  freqz: vBe,
  // functions - special
  erf: pBe,
  zeta: hBe,
  // functions - statistics
  cumsum: PBe,
  mad: gBe,
  max: yBe,
  mean: _Be,
  median: bBe,
  min: SBe,
  mode: CBe,
  prod: ABe,
  quantileSeq: xBe,
  std: TBe,
  sum: MBe,
  variance: wBe,
  corr: EBe,
  // functions - trigonometry
  acos: DBe,
  acosh: IBe,
  acot: BBe,
  acoth: NBe,
  acsc: VBe,
  acsch: RBe,
  asec: OBe,
  asech: FBe,
  asin: LBe,
  asinh: kBe,
  atan: UBe,
  atanh: GBe,
  atan2: zBe,
  cos: qBe,
  cosh: HBe,
  cot: jBe,
  coth: $Be,
  csc: KBe,
  csch: WBe,
  sec: XBe,
  sech: YBe,
  sin: QBe,
  sinh: ZBe,
  tan: JBe,
  tanh: eNe,
  // functions - units
  to: rNe,
  // functions - utils
  clone: nNe,
  format: aNe,
  bin: tNe,
  oct: pNe,
  hex: oNe,
  isNaN: sNe,
  isInteger: uNe,
  isNegative: lNe,
  isNumeric: cNe,
  hasNumericValue: iNe,
  isPositive: dNe,
  isPrime: fNe,
  isZero: mNe,
  print: hNe,
  typeOf: gNe,
  numeric: vNe
}, FL = "help", bNe = ["typed", "mathWithTransform", "Help"], SNe = /* @__PURE__ */ Ce(FL, bNe, (e) => {
  var {
    typed: r,
    mathWithTransform: t,
    Help: n
  } = e;
  return r(FL, {
    any: function(i) {
      var o, c = i;
      if (typeof i != "string") {
        for (o in t)
          if (er(t, o) && i === t[o]) {
            c = o;
            break;
          }
      }
      var s = Ki(_Ne, c);
      if (!s) {
        var u = typeof c == "function" ? c.name : c;
        throw new Error('No documentation found on "' + u + '"');
      }
      return new n(s);
    }
  });
}), LL = "chain", CNe = ["typed", "Chain"], ANe = /* @__PURE__ */ Ce(LL, CNe, (e) => {
  var {
    typed: r,
    Chain: t
  } = e;
  return r(LL, {
    "": function() {
      return new t();
    },
    any: function(a) {
      return new t(a);
    }
  });
}), kL = "det", xNe = ["typed", "matrix", "subtractScalar", "multiply", "divideScalar", "isZero", "unaryMinus"], pY = /* @__PURE__ */ Ce(kL, xNe, (e) => {
  var {
    typed: r,
    matrix: t,
    subtractScalar: n,
    multiply: a,
    divideScalar: i,
    isZero: o,
    unaryMinus: c
  } = e;
  return r(kL, {
    any: function(l) {
      return Sr(l);
    },
    "Array | Matrix": function(l) {
      var f;
      switch (gr(l) ? f = l.size() : Array.isArray(l) ? (l = t(l), f = l.size()) : f = [], f.length) {
        case 0:
          return Sr(l);
        case 1:
          if (f[0] === 1)
            return Sr(l.valueOf()[0]);
          if (f[0] === 0)
            return 1;
          throw new RangeError("Matrix must be square (size: " + $r(f) + ")");
        case 2: {
          var d = f[0], m = f[1];
          if (d === m)
            return s(l.clone().valueOf(), d);
          if (m === 0)
            return 1;
          throw new RangeError("Matrix must be square (size: " + $r(f) + ")");
        }
        default:
          throw new RangeError("Matrix must be two dimensional (size: " + $r(f) + ")");
      }
    }
  });
  function s(u, l, f) {
    if (l === 1)
      return Sr(u[0][0]);
    if (l === 2)
      return n(a(u[0][0], u[1][1]), a(u[1][0], u[0][1]));
    for (var d = !1, m = new Array(l).fill(0).map((A, M) => M), p = 0; p < l; p++) {
      var v = m[p];
      if (o(u[v][p])) {
        var h = void 0;
        for (h = p + 1; h < l; h++)
          if (!o(u[m[h]][p])) {
            v = m[h], m[h] = m[p], m[p] = v, d = !d;
            break;
          }
        if (h === l) return u[v][p];
      }
      for (var y = u[v][p], C = p === 0 ? 1 : u[m[p - 1]][p - 1], S = p + 1; S < l; S++)
        for (var b = m[S], g = p + 1; g < l; g++)
          u[b][g] = i(n(a(u[b][g], y), a(u[b][p], u[v][g])), C);
    }
    var _ = u[m[l - 1]][l - 1];
    return d ? c(_) : _;
  }
}), UL = "inv", TNe = ["typed", "matrix", "divideScalar", "addScalar", "multiply", "unaryMinus", "det", "identity", "abs"], hY = /* @__PURE__ */ Ce(UL, TNe, (e) => {
  var {
    typed: r,
    matrix: t,
    divideScalar: n,
    addScalar: a,
    multiply: i,
    unaryMinus: o,
    det: c,
    identity: s,
    abs: u
  } = e;
  return r(UL, {
    "Array | Matrix": function(d) {
      var m = gr(d) ? d.size() : Fr(d);
      switch (m.length) {
        case 1:
          if (m[0] === 1)
            return gr(d) ? t([n(1, d.valueOf()[0])]) : [n(1, d[0])];
          throw new RangeError("Matrix must be square (size: " + $r(m) + ")");
        case 2: {
          var p = m[0], v = m[1];
          if (p === v)
            return gr(d) ? t(l(d.valueOf(), p, v), d.storage()) : l(d, p, v);
          throw new RangeError("Matrix must be square (size: " + $r(m) + ")");
        }
        default:
          throw new RangeError("Matrix must be two dimensional (size: " + $r(m) + ")");
      }
    },
    any: function(d) {
      return n(1, d);
    }
  });
  function l(f, d, m) {
    var p, v, h, y, C;
    if (d === 1) {
      if (y = f[0][0], y === 0)
        throw Error("Cannot calculate inverse, determinant is zero");
      return [[n(1, y)]];
    } else if (d === 2) {
      var S = c(f);
      if (S === 0)
        throw Error("Cannot calculate inverse, determinant is zero");
      return [[n(f[1][1], S), n(o(f[0][1]), S)], [n(o(f[1][0]), S), n(f[0][0], S)]];
    } else {
      var b = f.concat();
      for (p = 0; p < d; p++)
        b[p] = b[p].concat();
      for (var g = s(d).valueOf(), _ = 0; _ < m; _++) {
        var A = u(b[_][_]), M = _;
        for (p = _ + 1; p < d; )
          u(b[p][_]) > A && (A = u(b[p][_]), M = p), p++;
        if (A === 0)
          throw Error("Cannot calculate inverse, determinant is zero");
        p = M, p !== _ && (C = b[_], b[_] = b[p], b[p] = C, C = g[_], g[_] = g[p], g[p] = C);
        var P = b[_], T = g[_];
        for (p = 0; p < d; p++) {
          var x = b[p], w = g[p];
          if (p !== _) {
            if (x[_] !== 0) {
              for (h = n(o(x[_]), P[_]), v = _; v < m; v++)
                x[v] = a(x[v], i(h, P[v]));
              for (v = 0; v < m; v++)
                w[v] = a(w[v], i(h, T[v]));
            }
          } else {
            for (h = P[_], v = _; v < m; v++)
              x[v] = n(x[v], h);
            for (v = 0; v < m; v++)
              w[v] = n(w[v], h);
          }
        }
      }
      return g;
    }
  }
}), zL = "pinv", PNe = ["typed", "matrix", "inv", "deepEqual", "equal", "dotDivide", "dot", "ctranspose", "divideScalar", "multiply", "add", "Complex"], MNe = /* @__PURE__ */ Ce(zL, PNe, (e) => {
  var {
    typed: r,
    matrix: t,
    inv: n,
    deepEqual: a,
    equal: i,
    dotDivide: o,
    dot: c,
    ctranspose: s,
    divideScalar: u,
    multiply: l,
    add: f,
    Complex: d
  } = e;
  return r(zL, {
    "Array | Matrix": function(S) {
      var b = gr(S) ? S.size() : Fr(S);
      switch (b.length) {
        case 1:
          return y(S) ? s(S) : b[0] === 1 ? n(S) : o(s(S), c(S, S));
        case 2: {
          if (y(S)) return s(S);
          var g = b[0], _ = b[1];
          if (g === _)
            try {
              return n(S);
            } catch (A) {
              if (!(A instanceof Error && A.message.match(/Cannot calculate inverse, determinant is zero/))) throw A;
            }
          return gr(S) ? t(m(S.valueOf(), g, _), S.storage()) : m(S, g, _);
        }
        default:
          throw new RangeError("Matrix must be two dimensional (size: " + $r(b) + ")");
      }
    },
    any: function(S) {
      return i(S, 0) ? Sr(S) : u(1, S);
    }
  });
  function m(C, S, b) {
    var {
      C: g,
      F: _
    } = v(C, S, b), A = l(n(l(s(g), g)), s(g)), M = l(s(_), n(l(_, s(_))));
    return l(M, A);
  }
  function p(C, S, b) {
    for (var g = Sr(C), _ = 0, A = 0; A < S; A++) {
      if (b <= _)
        return g;
      for (var M = A; h(g[M][_]); )
        if (M++, S === M && (M = A, _++, b === _))
          return g;
      [g[M], g[A]] = [g[A], g[M]];
      for (var P = g[A][_], T = 0; T < b; T++)
        g[A][T] = o(g[A][T], P);
      for (var x = 0; x < S; x++)
        if (x !== A) {
          P = g[x][_];
          for (var w = 0; w < b; w++)
            g[x][w] = f(g[x][w], l(-1, l(P, g[A][w])));
        }
      _++;
    }
    return g;
  }
  function v(C, S, b) {
    var g = p(C, S, b), _ = C.map((M, P) => M.filter((T, x) => x < S && !h(c(g[x], g[x])))), A = g.filter((M, P) => !h(c(g[P], g[P])));
    return {
      C: _,
      F: A
    };
  }
  function h(C) {
    return i(f(C, d(1, 1)), f(0, d(1, 1)));
  }
  function y(C) {
    return a(f(C, d(1, 1)), f(l(C, 0), d(1, 1)));
  }
});
function wNe(e) {
  var {
    addScalar: r,
    subtract: t,
    flatten: n,
    multiply: a,
    multiplyScalar: i,
    divideScalar: o,
    sqrt: c,
    abs: s,
    bignumber: u,
    diag: l,
    size: f,
    reshape: d,
    inv: m,
    qr: p,
    usolve: v,
    usolveAll: h,
    equal: y,
    complex: C,
    larger: S,
    smaller: b,
    matrixFromColumns: g,
    dot: _
  } = e;
  function A(L, R, F, U) {
    var H = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, q = M(L, R, F, U, H);
    P(L, R, F, U, H, q);
    var {
      values: K,
      C: Y
    } = T(L, R, F, U, H);
    if (H) {
      var X = x(L, R, Y, q, K, F, U);
      return {
        values: K,
        eigenvectors: X
      };
    }
    return {
      values: K
    };
  }
  function M(L, R, F, U, H) {
    var q = U === "BigNumber", K = U === "Complex", Y = q ? u(0) : 0, X = q ? u(1) : K ? C(1) : 1, Z = q ? u(1) : 1, J = q ? u(10) : 2, $ = i(J, J), Q;
    H && (Q = Array(R).fill(X));
    for (var W = !1; !W; ) {
      W = !0;
      for (var te = 0; te < R; te++) {
        for (var oe = Y, z = Y, j = 0; j < R; j++)
          te !== j && (oe = r(oe, s(L[j][te])), z = r(z, s(L[te][j])));
        if (!y(oe, 0) && !y(z, 0)) {
          for (var ae = Z, le = oe, ie = o(z, J), re = i(z, J); b(le, ie); )
            le = i(le, $), ae = i(ae, J);
          for (; S(le, re); )
            le = o(le, $), ae = o(ae, J);
          var ee = b(o(r(le, z), ae), i(r(oe, z), 0.95));
          if (ee) {
            W = !1;
            for (var ne = o(1, ae), se = 0; se < R; se++)
              te !== se && (L[te][se] = i(L[te][se], ne), L[se][te] = i(L[se][te], ae));
            H && (Q[te] = i(Q[te], ne));
          }
        }
      }
    }
    return H ? l(Q) : null;
  }
  function P(L, R, F, U, H, q) {
    var K = U === "BigNumber", Y = U === "Complex", X = K ? u(0) : Y ? C(0) : 0;
    K && (F = u(F));
    for (var Z = 0; Z < R - 2; Z++) {
      for (var J = 0, $ = X, Q = Z + 1; Q < R; Q++) {
        var W = L[Q][Z];
        b(s($), s(W)) && ($ = W, J = Q);
      }
      if (!b(s($), F)) {
        if (J !== Z + 1) {
          var te = L[J];
          L[J] = L[Z + 1], L[Z + 1] = te;
          for (var oe = 0; oe < R; oe++) {
            var z = L[oe][J];
            L[oe][J] = L[oe][Z + 1], L[oe][Z + 1] = z;
          }
          if (H) {
            var j = q[J];
            q[J] = q[Z + 1], q[Z + 1] = j;
          }
        }
        for (var ae = Z + 2; ae < R; ae++) {
          var le = o(L[ae][Z], $);
          if (le !== 0) {
            for (var ie = 0; ie < R; ie++)
              L[ae][ie] = t(L[ae][ie], i(le, L[Z + 1][ie]));
            for (var re = 0; re < R; re++)
              L[re][Z + 1] = r(L[re][Z + 1], i(le, L[re][ae]));
            if (H)
              for (var ee = 0; ee < R; ee++)
                q[ae][ee] = t(q[ae][ee], i(le, q[Z + 1][ee]));
          }
        }
      }
    }
    return q;
  }
  function T(L, R, F, U, H) {
    var q = U === "BigNumber", K = U === "Complex", Y = q ? u(1) : K ? C(1) : 1;
    q && (F = u(F));
    for (var X = Sr(L), Z = [], J = R, $ = [], Q = H ? l(Array(R).fill(Y)) : void 0, W = H ? l(Array(J).fill(Y)) : void 0, te = 0; te <= 100; ) {
      te += 1;
      for (var oe = X[J - 1][J - 1], z = 0; z < J; z++)
        X[z][z] = t(X[z][z], oe);
      var {
        Q: j,
        R: ae
      } = p(X);
      X = a(ae, j);
      for (var le = 0; le < J; le++)
        X[le][le] = r(X[le][le], oe);
      if (H && (W = a(W, j)), J === 1 || b(s(X[J - 1][J - 2]), F)) {
        te = 0, Z.push(X[J - 1][J - 1]), H && ($.unshift([[1]]), I(W, R), Q = a(Q, W), J > 1 && (W = l(Array(J - 1).fill(Y)))), J -= 1, X.pop();
        for (var ie = 0; ie < J; ie++)
          X[ie].pop();
      } else if (J === 2 || b(s(X[J - 2][J - 3]), F)) {
        te = 0;
        var re = w(X[J - 2][J - 2], X[J - 2][J - 1], X[J - 1][J - 2], X[J - 1][J - 1]);
        Z.push(...re), H && ($.unshift(E(X[J - 2][J - 2], X[J - 2][J - 1], X[J - 1][J - 2], X[J - 1][J - 1], re[0], re[1], F, U)), I(W, R), Q = a(Q, W), J > 2 && (W = l(Array(J - 2).fill(Y)))), J -= 2, X.pop(), X.pop();
        for (var ee = 0; ee < J; ee++)
          X[ee].pop(), X[ee].pop();
      }
      if (J === 0)
        break;
    }
    if (Z.sort((ce, de) => +t(s(ce), s(de))), te > 100) {
      var ne = Error("The eigenvalues failed to converge. Only found these eigenvalues: " + Z.join(", "));
      throw ne.values = Z, ne.vectors = [], ne;
    }
    var se = H ? a(Q, B($, R)) : void 0;
    return {
      values: Z,
      C: se
    };
  }
  function x(L, R, F, U, H, q, K) {
    var Y = m(F), X = a(Y, L, F), Z = K === "BigNumber", J = K === "Complex", $ = Z ? u(0) : J ? C(0) : 0, Q = Z ? u(1) : J ? C(1) : 1, W = [], te = [];
    for (var oe of H) {
      var z = D(W, oe, y);
      z === -1 ? (W.push(oe), te.push(1)) : te[z] += 1;
    }
    for (var j = [], ae = W.length, le = Array(R).fill($), ie = l(Array(R).fill(Q)), re = function() {
      var se = W[ee], ce = t(X, a(se, ie)), de = h(ce, le);
      for (de.shift(); de.length < te[ee]; ) {
        var me = N(ce, R, de, q, K);
        if (me === null)
          break;
        de.push(me);
      }
      var he = a(m(U), F);
      de = de.map((_e) => a(he, _e)), j.push(...de.map((_e) => ({
        value: se,
        vector: n(_e)
      })));
    }, ee = 0; ee < ae; ee++)
      re();
    return j;
  }
  function w(L, R, F, U) {
    var H = r(L, U), q = t(i(L, U), i(R, F)), K = i(H, 0.5), Y = i(c(t(i(H, H), i(4, q))), 0.5);
    return [r(K, Y), t(K, Y)];
  }
  function E(L, R, F, U, H, q, K, Y) {
    var X = Y === "BigNumber", Z = Y === "Complex", J = X ? u(0) : Z ? C(0) : 0, $ = X ? u(1) : Z ? C(1) : 1;
    if (b(s(F), K))
      return [[$, J], [J, $]];
    if (S(s(t(H, q)), K))
      return [[t(H, U), t(q, U)], [F, F]];
    var Q = t(L, H), W = t(U, H);
    return b(s(R), K) && b(s(W), K) ? [[Q, $], [F, J]] : [[R, J], [W, $]];
  }
  function I(L, R) {
    for (var F = 0; F < L.length; F++)
      L[F].push(...Array(R - L[F].length).fill(0));
    for (var U = L.length; U < R; U++)
      L.push(Array(R).fill(0)), L[U][U] = 1;
    return L;
  }
  function B(L, R) {
    for (var F = [], U = 0; U < R; U++)
      F[U] = Array(R).fill(0);
    var H = 0;
    for (var q of L) {
      for (var K = q.length, Y = 0; Y < K; Y++)
        for (var X = 0; X < K; X++)
          F[H + Y][H + X] = q[Y][X];
      H += K;
    }
    return F;
  }
  function D(L, R, F) {
    for (var U = 0; U < L.length; U++)
      if (F(L[U], R))
        return U;
    return -1;
  }
  function N(L, R, F, U, H) {
    for (var q = H === "BigNumber" ? u(1e3) : 1e3, K, Y = 0; Y < 5; ++Y) {
      K = O(R, F, H);
      try {
        K = v(L, K);
      } catch {
        continue;
      }
      if (S(k(K), q))
        break;
    }
    if (Y >= 5)
      return null;
    for (Y = 0; ; ) {
      var X = v(L, K);
      if (b(k(V(K, [X])), U))
        break;
      if (++Y >= 10)
        return null;
      K = G(X);
    }
    return K;
  }
  function O(L, R, F) {
    var U = F === "BigNumber", H = F === "Complex", q = Array(L).fill(0).map((K) => 2 * Math.random() - 1);
    return U && (q = q.map((K) => u(K))), H && (q = q.map((K) => C(K))), q = V(q, R), G(q, F);
  }
  function V(L, R) {
    var F = f(L);
    for (var U of R)
      U = d(U, F), L = t(L, a(o(_(U, L), _(U, U)), U));
    return L;
  }
  function k(L) {
    return s(c(_(L, L)));
  }
  function G(L, R) {
    var F = R === "BigNumber", U = R === "Complex", H = F ? u(1) : U ? C(1) : 1;
    return a(o(H, k(L)), L);
  }
  return A;
}
function ENe(e) {
  var {
    config: r,
    addScalar: t,
    subtract: n,
    abs: a,
    atan: i,
    cos: o,
    sin: c,
    multiplyScalar: s,
    inv: u,
    bignumber: l,
    multiply: f,
    add: d
  } = e;
  function m(P, T) {
    var x = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : r.relTol, w = arguments.length > 3 ? arguments[3] : void 0, E = arguments.length > 4 ? arguments[4] : void 0;
    if (w === "number")
      return p(P, x, E);
    if (w === "BigNumber")
      return v(P, x, E);
    throw TypeError("Unsupported data type: " + w);
  }
  function p(P, T, x) {
    var w = P.length, E = Math.abs(T / w), I, B;
    if (x) {
      B = new Array(w);
      for (var D = 0; D < w; D++)
        B[D] = Array(w).fill(0), B[D][D] = 1;
    }
    for (var N = _(P); Math.abs(N[1]) >= Math.abs(E); ) {
      var O = N[0][0], V = N[0][1];
      I = h(P[O][O], P[V][V], P[O][V]), P = g(P, I, O, V), x && (B = C(B, I, O, V)), N = _(P);
    }
    for (var k = Array(w).fill(0), G = 0; G < w; G++)
      k[G] = P[G][G];
    return M(Sr(k), B, x);
  }
  function v(P, T, x) {
    var w = P.length, E = a(T / w), I, B;
    if (x) {
      B = new Array(w);
      for (var D = 0; D < w; D++)
        B[D] = Array(w).fill(0), B[D][D] = 1;
    }
    for (var N = A(P); a(N[1]) >= a(E); ) {
      var O = N[0][0], V = N[0][1];
      I = y(P[O][O], P[V][V], P[O][V]), P = b(P, I, O, V), x && (B = S(B, I, O, V)), N = A(P);
    }
    for (var k = Array(w).fill(0), G = 0; G < w; G++)
      k[G] = P[G][G];
    return M(Sr(k), B, x);
  }
  function h(P, T, x) {
    var w = T - P;
    return Math.abs(w) <= r.relTol ? Math.PI / 4 : 0.5 * Math.atan(2 * x / (T - P));
  }
  function y(P, T, x) {
    var w = n(T, P);
    return a(w) <= r.relTol ? l(-1).acos().div(4) : s(0.5, i(f(2, x, u(w))));
  }
  function C(P, T, x, w) {
    for (var E = P.length, I = Math.cos(T), B = Math.sin(T), D = Array(E).fill(0), N = Array(E).fill(0), O = 0; O < E; O++)
      D[O] = I * P[O][x] - B * P[O][w], N[O] = B * P[O][x] + I * P[O][w];
    for (var V = 0; V < E; V++)
      P[V][x] = D[V], P[V][w] = N[V];
    return P;
  }
  function S(P, T, x, w) {
    for (var E = P.length, I = o(T), B = c(T), D = Array(E).fill(l(0)), N = Array(E).fill(l(0)), O = 0; O < E; O++)
      D[O] = n(s(I, P[O][x]), s(B, P[O][w])), N[O] = t(s(B, P[O][x]), s(I, P[O][w]));
    for (var V = 0; V < E; V++)
      P[V][x] = D[V], P[V][w] = N[V];
    return P;
  }
  function b(P, T, x, w) {
    for (var E = P.length, I = l(o(T)), B = l(c(T)), D = s(I, I), N = s(B, B), O = Array(E).fill(l(0)), V = Array(E).fill(l(0)), k = f(l(2), I, B, P[x][w]), G = t(n(s(D, P[x][x]), k), s(N, P[w][w])), L = d(s(N, P[x][x]), k, s(D, P[w][w])), R = 0; R < E; R++)
      O[R] = n(s(I, P[x][R]), s(B, P[w][R])), V[R] = t(s(B, P[x][R]), s(I, P[w][R]));
    P[x][x] = G, P[w][w] = L, P[x][w] = l(0), P[w][x] = l(0);
    for (var F = 0; F < E; F++)
      F !== x && F !== w && (P[x][F] = O[F], P[F][x] = O[F], P[w][F] = V[F], P[F][w] = V[F]);
    return P;
  }
  function g(P, T, x, w) {
    for (var E = P.length, I = Math.cos(T), B = Math.sin(T), D = I * I, N = B * B, O = Array(E).fill(0), V = Array(E).fill(0), k = D * P[x][x] - 2 * I * B * P[x][w] + N * P[w][w], G = N * P[x][x] + 2 * I * B * P[x][w] + D * P[w][w], L = 0; L < E; L++)
      O[L] = I * P[x][L] - B * P[w][L], V[L] = B * P[x][L] + I * P[w][L];
    P[x][x] = k, P[w][w] = G, P[x][w] = 0, P[w][x] = 0;
    for (var R = 0; R < E; R++)
      R !== x && R !== w && (P[x][R] = O[R], P[R][x] = O[R], P[w][R] = V[R], P[R][w] = V[R]);
    return P;
  }
  function _(P) {
    for (var T = P.length, x = 0, w = [0, 1], E = 0; E < T; E++)
      for (var I = E + 1; I < T; I++)
        Math.abs(x) < Math.abs(P[E][I]) && (x = Math.abs(P[E][I]), w = [E, I]);
    return [w, x];
  }
  function A(P) {
    for (var T = P.length, x = 0, w = [0, 1], E = 0; E < T; E++)
      for (var I = E + 1; I < T; I++)
        a(x) < a(P[E][I]) && (x = a(P[E][I]), w = [E, I]);
    return [w, x];
  }
  function M(P, T, x) {
    var w = P.length, E = Array(w), I;
    if (x) {
      I = Array(w);
      for (var B = 0; B < w; B++)
        I[B] = Array(w);
    }
    for (var D = 0; D < w; D++) {
      for (var N = 0, O = P[0], V = 0; V < P.length; V++)
        a(P[V]) < a(O) && (N = V, O = P[N]);
      if (E[D] = P.splice(N, 1)[0], x)
        for (var k = 0; k < w; k++)
          I[D][k] = T[k][N], T[k].splice(N, 1);
    }
    if (!x) return {
      values: E
    };
    var G = I.map((L, R) => ({
      value: E[R],
      vector: L
    }));
    return {
      values: E,
      eigenvectors: G
    };
  }
  return m;
}
var DNe = "eigs", INe = ["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"], gY = /* @__PURE__ */ Ce(DNe, INe, (e) => {
  var {
    config: r,
    typed: t,
    matrix: n,
    addScalar: a,
    subtract: i,
    equal: o,
    abs: c,
    atan: s,
    cos: u,
    sin: l,
    multiplyScalar: f,
    divideScalar: d,
    inv: m,
    bignumber: p,
    multiply: v,
    add: h,
    larger: y,
    column: C,
    flatten: S,
    number: b,
    complex: g,
    sqrt: _,
    diag: A,
    size: M,
    reshape: P,
    qr: T,
    usolve: x,
    usolveAll: w,
    im: E,
    re: I,
    smaller: B,
    matrixFromColumns: D,
    dot: N
  } = e, O = ENe({
    config: r,
    addScalar: a,
    subtract: i,
    column: C,
    flatten: S,
    equal: o,
    abs: c,
    atan: s,
    cos: u,
    sin: l,
    multiplyScalar: f,
    inv: m,
    bignumber: p,
    complex: g,
    multiply: v,
    add: h
  }), V = wNe({
    config: r,
    addScalar: a,
    subtract: i,
    multiply: v,
    multiplyScalar: f,
    flatten: S,
    divideScalar: d,
    sqrt: _,
    abs: c,
    bignumber: p,
    diag: A,
    size: M,
    reshape: P,
    qr: T,
    inv: m,
    usolve: x,
    usolveAll: w,
    equal: o,
    complex: g,
    larger: y,
    smaller: B,
    matrixFromColumns: D,
    dot: N
  });
  return t("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(q) {
      return k(n(q));
    },
    "Array, number|BigNumber": function(q, K) {
      return k(n(q), {
        precision: K
      });
    },
    "Array, Object"(H, q) {
      return k(n(H), q);
    },
    Matrix: function(q) {
      return k(q, {
        matricize: !0
      });
    },
    "Matrix, number|BigNumber": function(q, K) {
      return k(q, {
        precision: K,
        matricize: !0
      });
    },
    "Matrix, Object": function(q, K) {
      var Y = {
        matricize: !0
      };
      return Xa(Y, K), k(q, Y);
    }
  });
  function k(H) {
    var q, K = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, Y = "eigenvectors" in K ? K.eigenvectors : !0, X = (q = K.precision) !== null && q !== void 0 ? q : r.relTol, Z = G(H, X, Y);
    return K.matricize && (Z.values = n(Z.values), Y && (Z.eigenvectors = Z.eigenvectors.map((J) => {
      var {
        value: $,
        vector: Q
      } = J;
      return {
        value: $,
        vector: n(Q)
      };
    }))), Y && Object.defineProperty(Z, "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");
      }
    }), Z;
  }
  function G(H, q, K) {
    var Y = H.toArray(), X = H.size();
    if (X.length !== 2 || X[0] !== X[1])
      throw new RangeError("Matrix must be square (size: ".concat($r(X), ")"));
    var Z = X[0];
    if (R(Y, Z, q) && (F(Y, Z), L(Y, Z, q))) {
      var J = U(H, Y, Z);
      return O(Y, Z, q, J, K);
    }
    var $ = U(H, Y, Z);
    return V(Y, Z, q, $, K);
  }
  function L(H, q, K) {
    for (var Y = 0; Y < q; Y++)
      for (var X = Y; X < q; X++)
        if (y(p(c(i(H[Y][X], H[X][Y]))), K))
          return !1;
    return !0;
  }
  function R(H, q, K) {
    for (var Y = 0; Y < q; Y++)
      for (var X = 0; X < q; X++)
        if (y(p(c(E(H[Y][X]))), K))
          return !1;
    return !0;
  }
  function F(H, q) {
    for (var K = 0; K < q; K++)
      for (var Y = 0; Y < q; Y++)
        H[K][Y] = I(H[K][Y]);
  }
  function U(H, q, K) {
    var Y = H.datatype();
    if (Y === "number" || Y === "BigNumber" || Y === "Complex")
      return Y;
    for (var X = !1, Z = !1, J = !1, $ = 0; $ < K; $++)
      for (var Q = 0; Q < K; Q++) {
        var W = q[$][Q];
        if (Or(W) || J0(W))
          X = !0;
        else if (Ir(W))
          Z = !0;
        else if (as(W))
          J = !0;
        else
          throw TypeError("Unsupported type in Matrix: " + Et(W));
      }
    if (Z && J && console.warn("Complex BigNumbers not supported, this operation will lose precission."), J) {
      for (var te = 0; te < K; te++)
        for (var oe = 0; oe < K; oe++)
          q[te][oe] = g(q[te][oe]);
      return "Complex";
    }
    if (Z) {
      for (var z = 0; z < K; z++)
        for (var j = 0; j < K; j++)
          q[z][j] = p(q[z][j]);
      return "BigNumber";
    }
    if (X) {
      for (var ae = 0; ae < K; ae++)
        for (var le = 0; le < K; le++)
          q[ae][le] = b(q[ae][le]);
      return "number";
    } else
      throw TypeError("Matrix contains unsupported types only.");
  }
}), GL = "expm", BNe = ["typed", "abs", "add", "identity", "inv", "multiply"], NNe = /* @__PURE__ */ Ce(GL, BNe, (e) => {
  var {
    typed: r,
    abs: t,
    add: n,
    identity: a,
    inv: i,
    multiply: o
  } = e;
  return r(GL, {
    Matrix: function(f) {
      var d = f.size();
      if (d.length !== 2 || d[0] !== d[1])
        throw new RangeError("Matrix must be square (size: " + $r(d) + ")");
      for (var m = d[0], p = 1e-15, v = c(f), h = s(v, p), y = h.q, C = h.j, S = o(f, Math.pow(2, -C)), b = a(m), g = a(m), _ = 1, A = S, M = -1, P = 1; P <= y; P++)
        P > 1 && (A = o(A, S), M = -M), _ = _ * (y - P + 1) / ((2 * y - P + 1) * P), b = n(b, o(_, A)), g = n(g, o(_ * M, A));
      for (var T = o(i(g), b), x = 0; x < C; x++)
        T = o(T, T);
      return dd(f) ? f.createSparseMatrix(T) : T;
    }
  });
  function c(l) {
    for (var f = l.size()[0], d = 0, m = 0; m < f; m++) {
      for (var p = 0, v = 0; v < f; v++)
        p += t(l.get([m, v]));
      d = Math.max(p, d);
    }
    return d;
  }
  function s(l, f) {
    for (var d = 30, m = 0; m < d; m++)
      for (var p = 0; p <= m; p++) {
        var v = m - p;
        if (u(l, p, v) < f)
          return {
            q: p,
            j: v
          };
      }
    throw new Error("Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)");
  }
  function u(l, f, d) {
    for (var m = 1, p = 2; p <= f; p++)
      m *= p;
    for (var v = m, h = f + 1; h <= 2 * f; h++)
      v *= h;
    var y = v * (2 * f + 1);
    return 8 * Math.pow(l / Math.pow(2, d), 2 * f) * m * m / (v * y);
  }
}), qL = "sqrtm", VNe = ["typed", "abs", "add", "multiply", "map", "sqrt", "subtract", "inv", "size", "max", "identity"], RNe = /* @__PURE__ */ Ce(qL, VNe, (e) => {
  var {
    typed: r,
    abs: t,
    add: n,
    multiply: a,
    map: i,
    sqrt: o,
    subtract: c,
    inv: s,
    size: u,
    max: l,
    identity: f
  } = e, d = 1e3, m = 1e-6;
  function p(v) {
    var h, y = 0, C = v, S = f(u(v));
    do {
      var b = C;
      if (C = a(0.5, n(b, s(S))), S = a(0.5, n(S, s(b))), h = l(t(c(C, b))), h > m && ++y > d)
        throw new Error("computing square root of matrix: iterative method could not converge");
    } while (h > m);
    return C;
  }
  return r(qL, {
    "Array | Matrix": function(h) {
      var y = gr(h) ? h.size() : Fr(h);
      switch (y.length) {
        case 1:
          if (y[0] === 1)
            return i(h, o);
          throw new RangeError("Matrix must be square (size: " + $r(y) + ")");
        case 2: {
          var C = y[0], S = y[1];
          if (C === S)
            return p(h);
          throw new RangeError("Matrix must be square (size: " + $r(y) + ")");
        }
        default:
          throw new RangeError("Matrix must be at most two dimensional (size: " + $r(y) + ")");
      }
    }
  });
}), HL = "sylvester", ONe = ["typed", "schur", "matrixFromColumns", "matrix", "multiply", "range", "concat", "transpose", "index", "subset", "add", "subtract", "identity", "lusolve", "abs"], FNe = /* @__PURE__ */ Ce(HL, ONe, (e) => {
  var {
    typed: r,
    schur: t,
    matrixFromColumns: n,
    matrix: a,
    multiply: i,
    range: o,
    concat: c,
    transpose: s,
    index: u,
    subset: l,
    add: f,
    subtract: d,
    identity: m,
    lusolve: p,
    abs: v
  } = e;
  return r(HL, {
    "Matrix, Matrix, Matrix": h,
    "Array, Matrix, Matrix": function(C, S, b) {
      return h(a(C), S, b);
    },
    "Array, Array, Matrix": function(C, S, b) {
      return h(a(C), a(S), b);
    },
    "Array, Matrix, Array": function(C, S, b) {
      return h(a(C), S, a(b));
    },
    "Matrix, Array, Matrix": function(C, S, b) {
      return h(C, a(S), b);
    },
    "Matrix, Array, Array": function(C, S, b) {
      return h(C, a(S), a(b));
    },
    "Matrix, Matrix, Array": function(C, S, b) {
      return h(C, S, a(b));
    },
    "Array, Array, Array": function(C, S, b) {
      return h(a(C), a(S), a(b)).toArray();
    }
  });
  function h(y, C, S) {
    for (var b = C.size()[0], g = y.size()[0], _ = t(y), A = _.T, M = _.U, P = t(i(-1, C)), T = P.T, x = P.U, w = i(i(s(M), S), x), E = o(0, g), I = [], B = (J, $) => c(J, $, 1), D = (J, $) => c(J, $, 0), N = 0; N < b; N++)
      if (N < b - 1 && v(l(T, u(N + 1, N))) > 1e-5) {
        for (var O = D(l(w, u(E, N)), l(w, u(E, N + 1))), V = 0; V < N; V++)
          O = f(O, D(i(I[V], l(T, u(V, N))), i(I[V], l(T, u(V, N + 1)))));
        var k = i(m(g), i(-1, l(T, u(N, N)))), G = i(m(g), i(-1, l(T, u(N + 1, N)))), L = i(m(g), i(-1, l(T, u(N, N + 1)))), R = i(m(g), i(-1, l(T, u(N + 1, N + 1)))), F = D(B(f(A, k), G), B(L, f(A, R))), U = p(F, O);
        I[N] = U.subset(u(o(0, g), 0)), I[N + 1] = U.subset(u(o(g, 2 * g), 0)), N++;
      } else {
        for (var H = l(w, u(E, N)), q = 0; q < N; q++)
          H = f(H, i(I[q], l(T, u(q, N))));
        var K = l(T, u(N, N)), Y = d(A, i(K, m(g)));
        I[N] = p(Y, H);
      }
    var X = a(n(...I)), Z = i(M, i(X, s(x)));
    return Z;
  }
}), jL = "schur", LNe = ["typed", "matrix", "identity", "multiply", "qr", "norm", "subtract"], kNe = /* @__PURE__ */ Ce(jL, LNe, (e) => {
  var {
    typed: r,
    matrix: t,
    identity: n,
    multiply: a,
    qr: i,
    norm: o,
    subtract: c
  } = e;
  return r(jL, {
    Array: function(l) {
      var f = s(t(l));
      return {
        U: f.U.valueOf(),
        T: f.T.valueOf()
      };
    },
    Matrix: function(l) {
      return s(l);
    }
  });
  function s(u) {
    var l = u.size()[0], f = u, d = n(l), m = 0, p;
    do {
      p = f;
      var v = i(f), h = v.Q, y = v.R;
      if (f = a(y, h), d = a(d, h), m++ > 100)
        break;
    } while (o(c(f, p)) > 1e-4);
    return {
      U: d,
      T: f
    };
  }
}), $L = "lyap", UNe = ["typed", "matrix", "sylvester", "multiply", "transpose"], zNe = /* @__PURE__ */ Ce($L, UNe, (e) => {
  var {
    typed: r,
    matrix: t,
    sylvester: n,
    multiply: a,
    transpose: i
  } = e;
  return r($L, {
    "Matrix, Matrix": function(c, s) {
      return n(c, i(c), a(-1, s));
    },
    "Array, Matrix": function(c, s) {
      return n(t(c), i(t(c)), a(-1, s));
    },
    "Matrix, Array": function(c, s) {
      return n(c, i(t(c)), t(a(-1, s)));
    },
    "Array, Array": function(c, s) {
      return n(t(c), i(t(c)), t(a(-1, s))).toArray();
    }
  });
}), GNe = "divide", qNe = ["typed", "matrix", "multiply", "equalScalar", "divideScalar", "inv"], yY = /* @__PURE__ */ Ce(GNe, qNe, (e) => {
  var {
    typed: r,
    matrix: t,
    multiply: n,
    equalScalar: a,
    divideScalar: i,
    inv: o
  } = e, c = li({
    typed: r,
    equalScalar: a
  }), s = xs({
    typed: r
  });
  return r("divide", vK({
    // we extend the signatures of divideScalar with signatures dealing with matrices
    "Array | Matrix, Array | Matrix": function(l, f) {
      return n(l, o(f));
    },
    "DenseMatrix, any": function(l, f) {
      return s(l, f, i, !1);
    },
    "SparseMatrix, any": function(l, f) {
      return c(l, f, i, !1);
    },
    "Array, any": function(l, f) {
      return s(t(l), f, i, !1).valueOf();
    },
    "any, Array | Matrix": function(l, f) {
      return n(l, o(f));
    }
  }, i.signatures));
}), KL = "distance", HNe = ["typed", "addScalar", "subtractScalar", "divideScalar", "multiplyScalar", "deepEqual", "sqrt", "abs"], jNe = /* @__PURE__ */ Ce(KL, HNe, (e) => {
  var {
    typed: r,
    addScalar: t,
    subtractScalar: n,
    multiplyScalar: a,
    divideScalar: i,
    deepEqual: o,
    sqrt: c,
    abs: s
  } = e;
  return r(KL, {
    "Array, Array, Array": function(g, _, A) {
      if (g.length === 2 && _.length === 2 && A.length === 2) {
        if (!l(g))
          throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");
        if (!l(_))
          throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");
        if (!l(A))
          throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");
        if (o(_, A))
          throw new TypeError("LinePoint1 should not be same with LinePoint2");
        var M = n(A[1], _[1]), P = n(_[0], A[0]), T = n(a(A[0], _[1]), a(_[0], A[1]));
        return h(g[0], g[1], M, P, T);
      } else
        throw new TypeError("Invalid Arguments: Try again");
    },
    "Object, Object, Object": function(g, _, A) {
      if (Object.keys(g).length === 2 && Object.keys(_).length === 2 && Object.keys(A).length === 2) {
        if (!l(g))
          throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");
        if (!l(_))
          throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers");
        if (!l(A))
          throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers");
        if (o(p(_), p(A)))
          throw new TypeError("LinePoint1 should not be same with LinePoint2");
        if ("pointX" in g && "pointY" in g && "lineOnePtX" in _ && "lineOnePtY" in _ && "lineTwoPtX" in A && "lineTwoPtY" in A) {
          var M = n(A.lineTwoPtY, _.lineOnePtY), P = n(_.lineOnePtX, A.lineTwoPtX), T = n(a(A.lineTwoPtX, _.lineOnePtY), a(_.lineOnePtX, A.lineTwoPtY));
          return h(g.pointX, g.pointY, M, P, T);
        } else
          throw new TypeError("Key names do not match");
      } else
        throw new TypeError("Invalid Arguments: Try again");
    },
    "Array, Array": function(g, _) {
      if (g.length === 2 && _.length === 3) {
        if (!l(g))
          throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");
        if (!f(_))
          throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");
        return h(g[0], g[1], _[0], _[1], _[2]);
      } else if (g.length === 3 && _.length === 6) {
        if (!f(g))
          throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");
        if (!m(_))
          throw new TypeError("Array with 6 numbers or BigNumbers expected for second argument");
        return y(g[0], g[1], g[2], _[0], _[1], _[2], _[3], _[4], _[5]);
      } else if (g.length === _.length && g.length > 0) {
        if (!d(g))
          throw new TypeError("All values of an array should be numbers or BigNumbers");
        if (!d(_))
          throw new TypeError("All values of an array should be numbers or BigNumbers");
        return C(g, _);
      } else
        throw new TypeError("Invalid Arguments: Try again");
    },
    "Object, Object": function(g, _) {
      if (Object.keys(g).length === 2 && Object.keys(_).length === 3) {
        if (!l(g))
          throw new TypeError("Values of pointX and pointY should be numbers or BigNumbers");
        if (!f(_))
          throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers");
        if ("pointX" in g && "pointY" in g && "xCoeffLine" in _ && "yCoeffLine" in _ && "constant" in _)
          return h(g.pointX, g.pointY, _.xCoeffLine, _.yCoeffLine, _.constant);
        throw new TypeError("Key names do not match");
      } else if (Object.keys(g).length === 3 && Object.keys(_).length === 6) {
        if (!f(g))
          throw new TypeError("Values of pointX, pointY and pointZ should be numbers or BigNumbers");
        if (!m(_))
          throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers or BigNumbers");
        if ("pointX" in g && "pointY" in g && "x0" in _ && "y0" in _ && "z0" in _ && "a" in _ && "b" in _ && "c" in _)
          return y(g.pointX, g.pointY, g.pointZ, _.x0, _.y0, _.z0, _.a, _.b, _.c);
        throw new TypeError("Key names do not match");
      } else if (Object.keys(g).length === 2 && Object.keys(_).length === 2) {
        if (!l(g))
          throw new TypeError("Values of pointOneX and pointOneY should be numbers or BigNumbers");
        if (!l(_))
          throw new TypeError("Values of pointTwoX and pointTwoY should be numbers or BigNumbers");
        if ("pointOneX" in g && "pointOneY" in g && "pointTwoX" in _ && "pointTwoY" in _)
          return C([g.pointOneX, g.pointOneY], [_.pointTwoX, _.pointTwoY]);
        throw new TypeError("Key names do not match");
      } else if (Object.keys(g).length === 3 && Object.keys(_).length === 3) {
        if (!f(g))
          throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers");
        if (!f(_))
          throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers");
        if ("pointOneX" in g && "pointOneY" in g && "pointOneZ" in g && "pointTwoX" in _ && "pointTwoY" in _ && "pointTwoZ" in _)
          return C([g.pointOneX, g.pointOneY, g.pointOneZ], [_.pointTwoX, _.pointTwoY, _.pointTwoZ]);
        throw new TypeError("Key names do not match");
      } else
        throw new TypeError("Invalid Arguments: Try again");
    },
    Array: function(g) {
      if (!v(g))
        throw new TypeError("Incorrect array format entered for pairwise distance calculation");
      return S(g);
    }
  });
  function u(b) {
    return typeof b == "number" || Ir(b);
  }
  function l(b) {
    return b.constructor !== Array && (b = p(b)), u(b[0]) && u(b[1]);
  }
  function f(b) {
    return b.constructor !== Array && (b = p(b)), u(b[0]) && u(b[1]) && u(b[2]);
  }
  function d(b) {
    return Array.isArray(b) || (b = p(b)), b.every(u);
  }
  function m(b) {
    return b.constructor !== Array && (b = p(b)), u(b[0]) && u(b[1]) && u(b[2]) && u(b[3]) && u(b[4]) && u(b[5]);
  }
  function p(b) {
    for (var g = Object.keys(b), _ = [], A = 0; A < g.length; A++)
      _.push(b[g[A]]);
    return _;
  }
  function v(b) {
    if (b[0].length === 2 && u(b[0][0]) && u(b[0][1])) {
      if (b.some((g) => g.length !== 2 || !u(g[0]) || !u(g[1])))
        return !1;
    } else if (b[0].length === 3 && u(b[0][0]) && u(b[0][1]) && u(b[0][2])) {
      if (b.some((g) => g.length !== 3 || !u(g[0]) || !u(g[1]) || !u(g[2])))
        return !1;
    } else
      return !1;
    return !0;
  }
  function h(b, g, _, A, M) {
    var P = s(t(t(a(_, b), a(A, g)), M)), T = c(t(a(_, _), a(A, A)));
    return i(P, T);
  }
  function y(b, g, _, A, M, P, T, x, w) {
    var E = [n(a(n(M, g), w), a(n(P, _), x)), n(a(n(P, _), T), a(n(A, b), w)), n(a(n(A, b), x), a(n(M, g), T))];
    E = c(t(t(a(E[0], E[0]), a(E[1], E[1])), a(E[2], E[2])));
    var I = c(t(t(a(T, T), a(x, x)), a(w, w)));
    return i(E, I);
  }
  function C(b, g) {
    for (var _ = b.length, A = 0, M = 0, P = 0; P < _; P++)
      M = n(b[P], g[P]), A = t(a(M, M), A);
    return c(A);
  }
  function S(b) {
    for (var g = [], _ = [], A = [], M = 0; M < b.length - 1; M++)
      for (var P = M + 1; P < b.length; P++)
        b[0].length === 2 ? (_ = [b[M][0], b[M][1]], A = [b[P][0], b[P][1]]) : b[0].length === 3 && (_ = [b[M][0], b[M][1], b[M][2]], A = [b[P][0], b[P][1], b[P][2]]), g.push(C(_, A));
    return g;
  }
}), $Ne = "intersect", KNe = ["typed", "config", "abs", "add", "addScalar", "matrix", "multiply", "multiplyScalar", "divideScalar", "subtract", "smaller", "equalScalar", "flatten", "isZero", "isNumeric"], WNe = /* @__PURE__ */ Ce($Ne, KNe, (e) => {
  var {
    typed: r,
    config: t,
    abs: n,
    add: a,
    addScalar: i,
    matrix: o,
    multiply: c,
    multiplyScalar: s,
    divideScalar: u,
    subtract: l,
    smaller: f,
    equalScalar: d,
    flatten: m,
    isZero: p,
    isNumeric: v
  } = e;
  return r("intersect", {
    "Array, Array, Array": h,
    "Array, Array, Array, Array": y,
    "Matrix, Matrix, Matrix": function(x, w, E) {
      var I = h(x.valueOf(), w.valueOf(), E.valueOf());
      return I === null ? null : o(I);
    },
    "Matrix, Matrix, Matrix, Matrix": function(x, w, E, I) {
      var B = y(x.valueOf(), w.valueOf(), E.valueOf(), I.valueOf());
      return B === null ? null : o(B);
    }
  });
  function h(T, x, w) {
    if (T = C(T), x = C(x), w = C(w), !b(T))
      throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");
    if (!b(x))
      throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");
    if (!g(w))
      throw new TypeError("Array with 4 numbers expected as third argument");
    return P(T[0], T[1], T[2], x[0], x[1], x[2], w[0], w[1], w[2], w[3]);
  }
  function y(T, x, w, E) {
    if (T = C(T), x = C(x), w = C(w), E = C(E), T.length === 2) {
      if (!S(T))
        throw new TypeError("Array with 2 numbers or BigNumbers expected for first argument");
      if (!S(x))
        throw new TypeError("Array with 2 numbers or BigNumbers expected for second argument");
      if (!S(w))
        throw new TypeError("Array with 2 numbers or BigNumbers expected for third argument");
      if (!S(E))
        throw new TypeError("Array with 2 numbers or BigNumbers expected for fourth argument");
      return _(T, x, w, E);
    } else if (T.length === 3) {
      if (!b(T))
        throw new TypeError("Array with 3 numbers or BigNumbers expected for first argument");
      if (!b(x))
        throw new TypeError("Array with 3 numbers or BigNumbers expected for second argument");
      if (!b(w))
        throw new TypeError("Array with 3 numbers or BigNumbers expected for third argument");
      if (!b(E))
        throw new TypeError("Array with 3 numbers or BigNumbers expected for fourth argument");
      return M(T[0], T[1], T[2], x[0], x[1], x[2], w[0], w[1], w[2], E[0], E[1], E[2]);
    } else
      throw new TypeError("Arrays with two or thee dimensional points expected");
  }
  function C(T) {
    return T.length === 1 ? T[0] : T.length > 1 && Array.isArray(T[0]) && T.every((x) => Array.isArray(x) && x.length === 1) ? m(T) : T;
  }
  function S(T) {
    return T.length === 2 && v(T[0]) && v(T[1]);
  }
  function b(T) {
    return T.length === 3 && v(T[0]) && v(T[1]) && v(T[2]);
  }
  function g(T) {
    return T.length === 4 && v(T[0]) && v(T[1]) && v(T[2]) && v(T[3]);
  }
  function _(T, x, w, E) {
    var I = T, B = w, D = l(I, x), N = l(B, E), O = l(s(D[0], N[1]), s(N[0], D[1]));
    if (p(O) || f(n(O), t.relTol))
      return null;
    var V = s(N[0], I[1]), k = s(N[1], I[0]), G = s(N[0], B[1]), L = s(N[1], B[0]), R = u(i(l(l(V, k), G), L), O);
    return a(c(D, R), I);
  }
  function A(T, x, w, E, I, B, D, N, O, V, k, G) {
    var L = s(l(T, x), l(w, E)), R = s(l(I, B), l(D, N)), F = s(l(O, V), l(k, G));
    return i(i(L, R), F);
  }
  function M(T, x, w, E, I, B, D, N, O, V, k, G) {
    var L = A(T, D, V, D, x, N, k, N, w, O, G, O), R = A(V, D, E, T, k, N, I, x, G, O, B, w), F = A(T, D, E, T, x, N, I, x, w, O, B, w), U = A(V, D, V, D, k, N, k, N, G, O, G, O), H = A(E, T, E, T, I, x, I, x, B, w, B, w), q = l(s(L, R), s(F, U)), K = l(s(H, U), s(R, R));
    if (p(K)) return null;
    var Y = u(q, K), X = u(i(L, s(Y, R)), U), Z = i(T, s(Y, l(E, T))), J = i(x, s(Y, l(I, x))), $ = i(w, s(Y, l(B, w))), Q = i(D, s(X, l(V, D))), W = i(N, s(X, l(k, N))), te = i(O, s(X, l(G, O)));
    return d(Z, Q) && d(J, W) && d($, te) ? [Z, J, $] : null;
  }
  function P(T, x, w, E, I, B, D, N, O, V) {
    var k = s(T, D), G = s(E, D), L = s(x, N), R = s(I, N), F = s(w, O), U = s(B, O), H = l(l(l(V, k), L), F), q = l(l(l(i(i(G, R), U), k), L), F), K = u(H, q), Y = i(T, s(K, l(E, T))), X = i(x, s(K, l(I, x))), Z = i(w, s(K, l(B, w)));
    return [Y, X, Z];
  }
}), WL = "sum", XNe = ["typed", "config", "add", "numeric"], _Y = /* @__PURE__ */ Ce(WL, XNe, (e) => {
  var {
    typed: r,
    config: t,
    add: n,
    numeric: a
  } = e;
  return r(WL, {
    // sum([a, b, c, d, ...])
    "Array | Matrix": i,
    // sum([a, b, c, d, ...], dim)
    "Array | Matrix, number | BigNumber": o,
    // sum(a, b, c, d, ...)
    "...": function(s) {
      if (Wp(s))
        throw new TypeError("Scalar values expected in function sum");
      return i(s);
    }
  });
  function i(c) {
    var s;
    return yc(c, function(u) {
      try {
        s = s === void 0 ? u : n(s, u);
      } catch (l) {
        throw Xi(l, "sum", u);
      }
    }), s === void 0 && (s = a(0, t.number)), typeof s == "string" && (s = a(s, rf(s, t))), s;
  }
  function o(c, s) {
    try {
      var u = sx(c, s, n);
      return u;
    } catch (l) {
      throw Xi(l, "sum");
    }
  }
}), q_ = "cumsum", YNe = ["typed", "add", "unaryPlus"], bY = /* @__PURE__ */ Ce(q_, YNe, (e) => {
  var {
    typed: r,
    add: t,
    unaryPlus: n
  } = e;
  return r(q_, {
    // sum([a, b, c, d, ...])
    Array: a,
    Matrix: function(u) {
      return u.create(a(u.valueOf()));
    },
    // sum([a, b, c, d, ...], dim)
    "Array, number | BigNumber": o,
    "Matrix, number | BigNumber": function(u, l) {
      return u.create(o(u.valueOf(), l));
    },
    // cumsum(a, b, c, d, ...)
    "...": function(u) {
      if (Wp(u))
        throw new TypeError("All values expected to be scalar in function cumsum");
      return a(u);
    }
  });
  function a(s) {
    try {
      return i(s);
    } catch (u) {
      throw Xi(u, q_);
    }
  }
  function i(s) {
    if (s.length === 0)
      return [];
    for (var u = [n(s[0])], l = 1; l < s.length; ++l)
      u.push(t(u[l - 1], s[l]));
    return u;
  }
  function o(s, u) {
    var l = Fr(s);
    if (u < 0 || u >= l.length)
      throw new Ru(u, l.length);
    try {
      return c(s, u);
    } catch (f) {
      throw Xi(f, q_);
    }
  }
  function c(s, u) {
    var l, f, d;
    if (u <= 0) {
      var m = s[0][0];
      if (Array.isArray(m)) {
        for (d = aW(s), f = [], l = 0; l < d.length; l++)
          f[l] = c(d[l], u - 1);
        return f;
      } else
        return i(s);
    } else {
      for (f = [], l = 0; l < s.length; l++)
        f[l] = c(s[l], u - 1);
      return f;
    }
  }
}), XL = "mean", QNe = ["typed", "add", "divide"], SY = /* @__PURE__ */ Ce(XL, QNe, (e) => {
  var {
    typed: r,
    add: t,
    divide: n
  } = e;
  return r(XL, {
    // mean([a, b, c, d, ...])
    "Array | Matrix": i,
    // mean([a, b, c, d, ...], dim)
    "Array | Matrix, number | BigNumber": a,
    // mean(a, b, c, d, ...)
    "...": function(c) {
      if (Wp(c))
        throw new TypeError("Scalar values expected in function mean");
      return i(c);
    }
  });
  function a(o, c) {
    try {
      var s = sx(o, c, t), u = Array.isArray(o) ? Fr(o) : o.size();
      return n(s, u[c]);
    } catch (l) {
      throw Xi(l, "mean");
    }
  }
  function i(o) {
    var c, s = 0;
    if (yc(o, function(u) {
      try {
        c = c === void 0 ? u : t(c, u), s++;
      } catch (l) {
        throw Xi(l, "mean", u);
      }
    }), s === 0)
      throw new Error("Cannot calculate the mean of an empty array");
    return n(c, s);
  }
}), YL = "median", ZNe = ["typed", "add", "divide", "compare", "partitionSelect"], JNe = /* @__PURE__ */ Ce(YL, ZNe, (e) => {
  var {
    typed: r,
    add: t,
    divide: n,
    compare: a,
    partitionSelect: i
  } = e;
  function o(u) {
    try {
      u = st(u.valueOf());
      var l = u.length;
      if (l === 0)
        throw new Error("Cannot calculate median of an empty array");
      if (l % 2 === 0) {
        for (var f = l / 2 - 1, d = i(u, f + 1), m = u[f], p = 0; p < f; ++p)
          a(u[p], m) > 0 && (m = u[p]);
        return s(m, d);
      } else {
        var v = i(u, (l - 1) / 2);
        return c(v);
      }
    } catch (h) {
      throw Xi(h, "median");
    }
  }
  var c = r({
    "number | BigNumber | Complex | Unit": function(l) {
      return l;
    }
  }), s = r({
    "number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit": function(l, f) {
      return n(t(l, f), 2);
    }
  });
  return r(YL, {
    // median([a, b, c, d, ...])
    "Array | Matrix": o,
    // median([a, b, c, d, ...], dim)
    "Array | Matrix, number | BigNumber": function(l, f) {
      throw new Error("median(A, dim) is not yet supported");
    },
    // median(a, b, c, d, ...)
    "...": function(l) {
      if (Wp(l))
        throw new TypeError("Scalar values expected in function median");
      return o(l);
    }
  });
}), QL = "mad", eVe = ["typed", "abs", "map", "median", "subtract"], rVe = /* @__PURE__ */ Ce(QL, eVe, (e) => {
  var {
    typed: r,
    abs: t,
    map: n,
    median: a,
    subtract: i
  } = e;
  return r(QL, {
    // mad([a, b, c, d, ...])
    "Array | Matrix": o,
    // mad(a, b, c, d, ...)
    "...": function(s) {
      return o(s);
    }
  });
  function o(c) {
    if (c = st(c.valueOf()), c.length === 0)
      throw new Error("Cannot calculate median absolute deviation (mad) of an empty array");
    try {
      var s = a(c);
      return a(n(c, function(u) {
        return t(i(u, s));
      }));
    } catch (u) {
      throw u instanceof TypeError && u.message.includes("median") ? new TypeError(u.message.replace("median", "mad")) : Xi(u, "mad");
    }
  }
}), MP = "unbiased", ZL = "variance", tVe = ["typed", "add", "subtract", "multiply", "divide", "apply", "isNaN"], CY = /* @__PURE__ */ Ce(ZL, tVe, (e) => {
  var {
    typed: r,
    add: t,
    subtract: n,
    multiply: a,
    divide: i,
    apply: o,
    isNaN: c
  } = e;
  return r(ZL, {
    // variance([a, b, c, d, ...])
    "Array | Matrix": function(f) {
      return s(f, MP);
    },
    // variance([a, b, c, d, ...], normalization)
    "Array | Matrix, string": s,
    // variance([a, b, c, c, ...], dim)
    "Array | Matrix, number | BigNumber": function(f, d) {
      return u(f, d, MP);
    },
    // variance([a, b, c, c, ...], dim, normalization)
    "Array | Matrix, number | BigNumber, string": u,
    // variance(a, b, c, d, ...)
    "...": function(f) {
      return s(f, MP);
    }
  });
  function s(l, f) {
    var d, m = 0;
    if (l.length === 0)
      throw new SyntaxError("Function variance requires one or more parameters (0 provided)");
    if (yc(l, function(h) {
      try {
        d = d === void 0 ? h : t(d, h), m++;
      } catch (y) {
        throw Xi(y, "variance", h);
      }
    }), m === 0) throw new Error("Cannot calculate variance of an empty array");
    var p = i(d, m);
    if (d = void 0, yc(l, function(h) {
      var y = n(h, p);
      d = d === void 0 ? a(y, y) : t(d, a(y, y));
    }), c(d))
      return d;
    switch (f) {
      case "uncorrected":
        return i(d, m);
      case "biased":
        return i(d, m + 1);
      case "unbiased": {
        var v = Ir(d) ? d.mul(0) : 0;
        return m === 1 ? v : i(d, m - 1);
      }
      default:
        throw new Error('Unknown normalization "' + f + '". Choose "unbiased" (default), "uncorrected", or "biased".');
    }
  }
  function u(l, f, d) {
    try {
      if (l.length === 0)
        throw new SyntaxError("Function variance requires one or more parameters (0 provided)");
      return o(l, f, (m) => s(m, d));
    } catch (m) {
      throw Xi(m, "variance");
    }
  }
}), JL = "quantileSeq", nVe = ["typed", "?bignumber", "add", "subtract", "divide", "multiply", "partitionSelect", "compare", "isInteger", "smaller", "smallerEq", "larger"], AY = /* @__PURE__ */ Ce(JL, nVe, (e) => {
  var {
    typed: r,
    bignumber: t,
    add: n,
    subtract: a,
    divide: i,
    multiply: o,
    partitionSelect: c,
    compare: s,
    isInteger: u,
    smaller: l,
    smallerEq: f,
    larger: d
  } = e, m = ED({
    typed: r,
    isInteger: u
  });
  return r(JL, {
    "Array | Matrix, number | BigNumber": (C, S) => v(C, S, !1),
    "Array | Matrix, number | BigNumber, number": (C, S, b) => p(C, S, !1, b, v),
    "Array | Matrix, number | BigNumber, boolean": v,
    "Array | Matrix, number | BigNumber, boolean, number": (C, S, b, g) => p(C, S, b, g, v),
    "Array | Matrix, Array | Matrix": (C, S) => h(C, S, !1),
    "Array | Matrix, Array | Matrix, number": (C, S, b) => p(C, S, !1, b, h),
    "Array | Matrix, Array | Matrix, boolean": h,
    "Array | Matrix, Array | Matrix, boolean, number": (C, S, b, g) => p(C, S, b, g, h)
  });
  function p(C, S, b, g, _) {
    return m(C, g, (A) => _(A, S, b));
  }
  function v(C, S, b) {
    var g, _ = C.valueOf();
    if (l(S, 0))
      throw new Error("N/prob must be non-negative");
    if (f(S, 1))
      return Or(S) ? y(_, S, b) : t(y(_, S, b));
    if (d(S, 1)) {
      if (!u(S))
        throw new Error("N must be a positive integer");
      if (d(S, 4294967295))
        throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");
      var A = n(S, 1);
      g = [];
      for (var M = 0; l(M, S); M++) {
        var P = i(M + 1, A);
        g.push(y(_, P, b));
      }
      return Or(S) ? g : t(g);
    }
  }
  function h(C, S, b) {
    for (var g = C.valueOf(), _ = S.valueOf(), A = [], M = 0; M < _.length; ++M)
      A.push(y(g, _[M], b));
    return A;
  }
  function y(C, S, b) {
    var g = st(C), _ = g.length;
    if (_ === 0)
      throw new Error("Cannot calculate quantile of an empty sequence");
    var A = Or(S) ? S * (_ - 1) : S.times(_ - 1), M = Or(S) ? Math.floor(A) : A.floor().toNumber(), P = Or(S) ? A % 1 : A.minus(M);
    if (u(A))
      return b ? g[A] : c(g, Or(S) ? A : A.valueOf());
    var T, x;
    if (b)
      T = g[M], x = g[M + 1];
    else {
      x = c(g, M + 1), T = g[M];
      for (var w = 0; w < M; ++w)
        s(g[w], T) > 0 && (T = g[w]);
    }
    return n(o(T, a(1, P)), o(x, P));
  }
}), ek = "std", aVe = ["typed", "map", "sqrt", "variance"], xY = /* @__PURE__ */ Ce(ek, aVe, (e) => {
  var {
    typed: r,
    map: t,
    sqrt: n,
    variance: a
  } = e;
  return r(ek, {
    // std([a, b, c, d, ...])
    "Array | Matrix": i,
    // std([a, b, c, d, ...], normalization)
    "Array | Matrix, string": i,
    // std([a, b, c, c, ...], dim)
    "Array | Matrix, number | BigNumber": i,
    // std([a, b, c, c, ...], dim, normalization)
    "Array | Matrix, number | BigNumber, string": i,
    // std(a, b, c, d, ...)
    "...": function(c) {
      return i(c);
    }
  });
  function i(o, c) {
    if (o.length === 0)
      throw new SyntaxError("Function std requires one or more parameters (0 provided)");
    try {
      var s = a.apply(null, arguments);
      return Xo(s) ? t(s, n) : n(s);
    } catch (u) {
      throw u instanceof TypeError && u.message.includes(" variance") ? new TypeError(u.message.replace(" variance", " std")) : u;
    }
  }
}), rk = "corr", iVe = ["typed", "matrix", "mean", "sqrt", "sum", "add", "subtract", "multiply", "pow", "divide"], oVe = /* @__PURE__ */ Ce(rk, iVe, (e) => {
  var {
    typed: r,
    matrix: t,
    sqrt: n,
    sum: a,
    add: i,
    subtract: o,
    multiply: c,
    pow: s,
    divide: u
  } = e;
  return r(rk, {
    "Array, Array": function(m, p) {
      return l(m, p);
    },
    "Matrix, Matrix": function(m, p) {
      var v = l(m.toArray(), p.toArray());
      return Array.isArray(v) ? t(v) : v;
    }
  });
  function l(d, m) {
    var p = [];
    if (Array.isArray(d[0]) && Array.isArray(m[0])) {
      if (d.length !== m.length)
        throw new SyntaxError("Dimension mismatch. Array A and B must have the same length.");
      for (var v = 0; v < d.length; v++) {
        if (d[v].length !== m[v].length)
          throw new SyntaxError("Dimension mismatch. Array A and B must have the same number of elements.");
        p.push(f(d[v], m[v]));
      }
      return p;
    } else {
      if (d.length !== m.length)
        throw new SyntaxError("Dimension mismatch. Array A and B must have the same number of elements.");
      return f(d, m);
    }
  }
  function f(d, m) {
    var p = d.length, v = a(d), h = a(m), y = d.reduce((_, A, M) => i(_, c(A, m[M])), 0), C = a(d.map((_) => s(_, 2))), S = a(m.map((_) => s(_, 2))), b = o(c(p, y), c(v, h)), g = n(c(o(c(p, C), s(v, 2)), o(c(p, S), s(h, 2))));
    return u(b, g);
  }
}), tk = "combinations", uVe = ["typed"], sVe = /* @__PURE__ */ Ce(tk, uVe, (e) => {
  var {
    typed: r
  } = e;
  return r(tk, {
    "number, number": wW,
    "BigNumber, BigNumber": function(n, a) {
      var i = n.constructor, o, c, s = n.minus(a), u = new i(1);
      if (!nk(n) || !nk(a))
        throw new TypeError("Positive integer value expected in function combinations");
      if (a.gt(n))
        throw new TypeError("k must be less than n in function combinations");
      if (o = u, a.lt(s))
        for (c = u; c.lte(s); c = c.plus(u))
          o = o.times(a.plus(c)).dividedBy(c);
      else
        for (c = u; c.lte(a); c = c.plus(u))
          o = o.times(s.plus(c)).dividedBy(c);
      return o;
    }
    // TODO: implement support for collection in combinations
  });
});
function nk(e) {
  return e.isInteger() && e.gte(0);
}
var ak = "combinationsWithRep", lVe = ["typed"], cVe = /* @__PURE__ */ Ce(ak, lVe, (e) => {
  var {
    typed: r
  } = e;
  return r(ak, {
    "number, number": function(n, a) {
      if (!lr(n) || n < 0)
        throw new TypeError("Positive integer value expected in function combinationsWithRep");
      if (!lr(a) || a < 0)
        throw new TypeError("Positive integer value expected in function combinationsWithRep");
      if (n < 1)
        throw new TypeError("k must be less than or equal to n + k - 1");
      if (a < n - 1) {
        var i = Zl(n, n + a - 1);
        return i / Zl(1, a);
      }
      var o = Zl(a + 1, n + a - 1);
      return o / Zl(1, n - 1);
    },
    "BigNumber, BigNumber": function(n, a) {
      var i = n.constructor, o, c, s = new i(1), u = n.minus(s);
      if (!ik(n) || !ik(a))
        throw new TypeError("Positive integer value expected in function combinationsWithRep");
      if (n.lt(s))
        throw new TypeError("k must be less than or equal to n + k - 1 in function combinationsWithRep");
      if (o = s, a.lt(u))
        for (c = s; c.lte(u); c = c.plus(s))
          o = o.times(a.plus(c)).dividedBy(c);
      else
        for (c = s; c.lte(a); c = c.plus(s))
          o = o.times(u.plus(c)).dividedBy(c);
      return o;
    }
  });
});
function ik(e) {
  return e.isInteger() && e.gte(0);
}
var ok = "gamma", dVe = ["typed", "config", "multiplyScalar", "pow", "BigNumber", "Complex"], fVe = /* @__PURE__ */ Ce(ok, dVe, (e) => {
  var {
    typed: r,
    config: t,
    multiplyScalar: n,
    pow: a,
    BigNumber: i,
    Complex: o
  } = e;
  function c(u) {
    if (u.im === 0)
      return A3(u.re);
    if (u.re < 0.5) {
      var l = new o(1 - u.re, -u.im), f = new o(Math.PI * u.re, Math.PI * u.im);
      return new o(Math.PI).div(f.sin()).div(c(l));
    }
    u = new o(u.re - 1, u.im);
    for (var d = new o(Sv[0], 0), m = 1; m < Sv.length; ++m) {
      var p = new o(Sv[m], 0);
      d = d.add(p.div(u.add(m)));
    }
    var v = new o(u.re + DW + 0.5, u.im), h = Math.sqrt(2 * Math.PI), y = v.pow(u.add(0.5)), C = v.neg().exp();
    return d.mul(h).mul(y).mul(C);
  }
  return r(ok, {
    number: A3,
    Complex: c,
    BigNumber: function(l) {
      if (l.isInteger())
        return l.isNegative() || l.isZero() ? new i(1 / 0) : s(l.minus(1));
      if (!l.isFinite())
        return new i(l.isNegative() ? NaN : 1 / 0);
      throw new Error("Integer BigNumber expected");
    }
  });
  function s(u) {
    if (u < 8)
      return new i([1, 1, 2, 6, 24, 120, 720, 5040][u]);
    var l = t.precision + (Math.log(u.toNumber()) | 0), f = i.clone({
      precision: l
    });
    if (u % 2 === 1)
      return u.times(s(new i(u - 1)));
    for (var d = u, m = new f(u), p = u.toNumber(); d > 2; )
      d -= 2, p += d, m = m.times(p);
    return new i(m.toPrecision(i.precision));
  }
}), uk = "lgamma", mVe = ["Complex", "typed"], vVe = /* @__PURE__ */ Ce(uk, mVe, (e) => {
  var {
    Complex: r,
    typed: t
  } = e, n = 7, a = 7, i = [-0.029550653594771242, 0.00641025641025641, -0.0019175269175269176, 8417508417508417e-19, -5952380952380953e-19, 7936507936507937e-19, -0.002777777777777778, 0.08333333333333333];
  return t(uk, {
    number: x3,
    Complex: o,
    BigNumber: function() {
      throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber");
    }
  });
  function o(u) {
    var l = 6.283185307179586, f = 1.1447298858494002, d = 0.1;
    if (u.isNaN())
      return new r(NaN, NaN);
    if (u.im === 0)
      return new r(x3(u.re), 0);
    if (u.re >= n || Math.abs(u.im) >= a)
      return c(u);
    if (u.re <= d) {
      var m = lAe(l, u.im) * Math.floor(0.5 * u.re + 0.25), p = u.mul(Math.PI).sin().log(), v = o(new r(1 - u.re, -u.im));
      return new r(f, m).sub(p).sub(v);
    } else return u.im >= 0 ? s(u) : s(u.conjugate()).conjugate();
  }
  function c(u) {
    for (var l = u.sub(0.5).mul(u.log()).sub(u).add(IW), f = new r(1, 0).div(u), d = f.div(u), m = i[0], p = i[1], v = 2 * d.re, h = d.re * d.re + d.im * d.im, y = 2; y < 8; y++) {
      var C = p;
      p = -h * m + i[y], m = v * m + C;
    }
    var S = f.mul(d.mul(m).add(p));
    return l.add(S);
  }
  function s(u) {
    var l = 0, f = 0, d = u;
    for (u = u.add(1); u.re <= n; ) {
      d = d.mul(u);
      var m = d.im < 0 ? 1 : 0;
      m !== 0 && f === 0 && l++, f = m, u = u.add(1);
    }
    return c(u).sub(d.log()).sub(new r(0, l * 2 * Math.PI * 1));
  }
}), sk = "factorial", pVe = ["typed", "gamma"], hVe = /* @__PURE__ */ Ce(sk, pVe, (e) => {
  var {
    typed: r,
    gamma: t
  } = e;
  return r(sk, {
    number: function(a) {
      if (a < 0)
        throw new Error("Value must be non-negative");
      return t(a + 1);
    },
    BigNumber: function(a) {
      if (a.isNegative())
        throw new Error("Value must be non-negative");
      return t(a.plus(1));
    },
    "Array | Matrix": r.referToSelf((n) => (a) => zr(a, n))
  });
}), lk = "kldivergence", gVe = ["typed", "matrix", "divide", "sum", "multiply", "map", "dotDivide", "log", "isNumeric"], yVe = /* @__PURE__ */ Ce(lk, gVe, (e) => {
  var {
    typed: r,
    matrix: t,
    divide: n,
    sum: a,
    multiply: i,
    map: o,
    dotDivide: c,
    log: s,
    isNumeric: u
  } = e;
  return r(lk, {
    "Array, Array": function(d, m) {
      return l(t(d), t(m));
    },
    "Matrix, Array": function(d, m) {
      return l(d, t(m));
    },
    "Array, Matrix": function(d, m) {
      return l(t(d), m);
    },
    "Matrix, Matrix": function(d, m) {
      return l(d, m);
    }
  });
  function l(f, d) {
    var m = d.size().length, p = f.size().length;
    if (m > 1)
      throw new Error("first object must be one dimensional");
    if (p > 1)
      throw new Error("second object must be one dimensional");
    if (m !== p)
      throw new Error("Length of two vectors must be equal");
    var v = a(f);
    if (v === 0)
      throw new Error("Sum of elements in first object must be non zero");
    var h = a(d);
    if (h === 0)
      throw new Error("Sum of elements in second object must be non zero");
    var y = n(f, a(f)), C = n(d, a(d)), S = a(i(y, o(c(y, C), (b) => s(b))));
    return u(S) ? S : Number.NaN;
  }
}), ck = "multinomial", _Ve = ["typed", "add", "divide", "multiply", "factorial", "isInteger", "isPositive"], bVe = /* @__PURE__ */ Ce(ck, _Ve, (e) => {
  var {
    typed: r,
    add: t,
    divide: n,
    multiply: a,
    factorial: i,
    isInteger: o,
    isPositive: c
  } = e;
  return r(ck, {
    "Array | Matrix": function(u) {
      var l = 0, f = 1;
      return yc(u, function(d) {
        if (!o(d) || !c(d))
          throw new TypeError("Positive integer value expected in function multinomial");
        l = t(l, d), f = a(f, i(d));
      }), n(i(l), f);
    }
  });
}), dk = "permutations", SVe = ["typed", "factorial"], CVe = /* @__PURE__ */ Ce(dk, SVe, (e) => {
  var {
    typed: r,
    factorial: t
  } = e;
  return r(dk, {
    "number | BigNumber": t,
    "number, number": function(a, i) {
      if (!lr(a) || a < 0)
        throw new TypeError("Positive integer value expected in function permutations");
      if (!lr(i) || i < 0)
        throw new TypeError("Positive integer value expected in function permutations");
      if (i > a)
        throw new TypeError("second argument k must be less than or equal to first argument n");
      return Zl(a - i + 1, a);
    },
    "BigNumber, BigNumber": function(a, i) {
      var o, c;
      if (!fk(a) || !fk(i))
        throw new TypeError("Positive integer value expected in function permutations");
      if (i.gt(a))
        throw new TypeError("second argument k must be less than or equal to first argument n");
      var s = a.mul(0).add(1);
      for (o = s, c = a.minus(i).plus(1); c.lte(a); c = c.plus(1))
        o = o.times(c);
      return o;
    }
    // TODO: implement support for collection in permutations
  });
});
function fk(e) {
  return e.isInteger() && e.gte(0);
}
var kD = { exports: {} };
kD.exports;
(function(e) {
  (function(r, t, n) {
    function a(s) {
      var u = this, l = c();
      u.next = function() {
        var f = 2091639 * u.s0 + u.c * 23283064365386963e-26;
        return u.s0 = u.s1, u.s1 = u.s2, u.s2 = f - (u.c = f | 0);
      }, u.c = 1, u.s0 = l(" "), u.s1 = l(" "), u.s2 = l(" "), u.s0 -= l(s), u.s0 < 0 && (u.s0 += 1), u.s1 -= l(s), u.s1 < 0 && (u.s1 += 1), u.s2 -= l(s), u.s2 < 0 && (u.s2 += 1), l = null;
    }
    function i(s, u) {
      return u.c = s.c, u.s0 = s.s0, u.s1 = s.s1, u.s2 = s.s2, u;
    }
    function o(s, u) {
      var l = new a(s), f = u && u.state, d = l.next;
      return d.int32 = function() {
        return l.next() * 4294967296 | 0;
      }, d.double = function() {
        return d() + (d() * 2097152 | 0) * 11102230246251565e-32;
      }, d.quick = d, f && (typeof f == "object" && i(f, l), d.state = function() {
        return i(l, {});
      }), d;
    }
    function c() {
      var s = 4022871197, u = function(l) {
        l = String(l);
        for (var f = 0; f < l.length; f++) {
          s += l.charCodeAt(f);
          var d = 0.02519603282416938 * s;
          s = d >>> 0, d -= s, d *= s, s = d >>> 0, d -= s, s += d * 4294967296;
        }
        return (s >>> 0) * 23283064365386963e-26;
      };
      return u;
    }
    t && t.exports ? t.exports = o : this.alea = o;
  })(
    cc,
    e
  );
})(kD);
var AVe = kD.exports, UD = { exports: {} };
UD.exports;
(function(e) {
  (function(r, t, n) {
    function a(c) {
      var s = this, u = "";
      s.x = 0, s.y = 0, s.z = 0, s.w = 0, s.next = function() {
        var f = s.x ^ s.x << 11;
        return s.x = s.y, s.y = s.z, s.z = s.w, s.w ^= s.w >>> 19 ^ f ^ f >>> 8;
      }, c === (c | 0) ? s.x = c : u += c;
      for (var l = 0; l < u.length + 64; l++)
        s.x ^= u.charCodeAt(l) | 0, s.next();
    }
    function i(c, s) {
      return s.x = c.x, s.y = c.y, s.z = c.z, s.w = c.w, s;
    }
    function o(c, s) {
      var u = new a(c), l = s && s.state, f = function() {
        return (u.next() >>> 0) / 4294967296;
      };
      return f.double = function() {
        do
          var d = u.next() >>> 11, m = (u.next() >>> 0) / 4294967296, p = (d + m) / (1 << 21);
        while (p === 0);
        return p;
      }, f.int32 = u.next, f.quick = f, l && (typeof l == "object" && i(l, u), f.state = function() {
        return i(u, {});
      }), f;
    }
    t && t.exports ? t.exports = o : this.xor128 = o;
  })(
    cc,
    e
  );
})(UD);
var xVe = UD.exports, zD = { exports: {} };
zD.exports;
(function(e) {
  (function(r, t, n) {
    function a(c) {
      var s = this, u = "";
      s.next = function() {
        var f = s.x ^ s.x >>> 2;
        return s.x = s.y, s.y = s.z, s.z = s.w, s.w = s.v, (s.d = s.d + 362437 | 0) + (s.v = s.v ^ s.v << 4 ^ (f ^ f << 1)) | 0;
      }, s.x = 0, s.y = 0, s.z = 0, s.w = 0, s.v = 0, c === (c | 0) ? s.x = c : u += c;
      for (var l = 0; l < u.length + 64; l++)
        s.x ^= u.charCodeAt(l) | 0, l == u.length && (s.d = s.x << 10 ^ s.x >>> 4), s.next();
    }
    function i(c, s) {
      return s.x = c.x, s.y = c.y, s.z = c.z, s.w = c.w, s.v = c.v, s.d = c.d, s;
    }
    function o(c, s) {
      var u = new a(c), l = s && s.state, f = function() {
        return (u.next() >>> 0) / 4294967296;
      };
      return f.double = function() {
        do
          var d = u.next() >>> 11, m = (u.next() >>> 0) / 4294967296, p = (d + m) / (1 << 21);
        while (p === 0);
        return p;
      }, f.int32 = u.next, f.quick = f, l && (typeof l == "object" && i(l, u), f.state = function() {
        return i(u, {});
      }), f;
    }
    t && t.exports ? t.exports = o : this.xorwow = o;
  })(
    cc,
    e
  );
})(zD);
var TVe = zD.exports, GD = { exports: {} };
GD.exports;
(function(e) {
  (function(r, t, n) {
    function a(c) {
      var s = this;
      s.next = function() {
        var l = s.x, f = s.i, d, m;
        return d = l[f], d ^= d >>> 7, m = d ^ d << 24, d = l[f + 1 & 7], m ^= d ^ d >>> 10, d = l[f + 3 & 7], m ^= d ^ d >>> 3, d = l[f + 4 & 7], m ^= d ^ d << 7, d = l[f + 7 & 7], d = d ^ d << 13, m ^= d ^ d << 9, l[f] = m, s.i = f + 1 & 7, m;
      };
      function u(l, f) {
        var d, m = [];
        if (f === (f | 0))
          m[0] = f;
        else
          for (f = "" + f, d = 0; d < f.length; ++d)
            m[d & 7] = m[d & 7] << 15 ^ f.charCodeAt(d) + m[d + 1 & 7] << 13;
        for (; m.length < 8; ) m.push(0);
        for (d = 0; d < 8 && m[d] === 0; ++d) ;
        for (d == 8 ? m[7] = -1 : m[d], l.x = m, l.i = 0, d = 256; d > 0; --d)
          l.next();
      }
      u(s, c);
    }
    function i(c, s) {
      return s.x = c.x.slice(), s.i = c.i, s;
    }
    function o(c, s) {
      c == null && (c = +/* @__PURE__ */ new Date());
      var u = new a(c), l = s && s.state, f = function() {
        return (u.next() >>> 0) / 4294967296;
      };
      return f.double = function() {
        do
          var d = u.next() >>> 11, m = (u.next() >>> 0) / 4294967296, p = (d + m) / (1 << 21);
        while (p === 0);
        return p;
      }, f.int32 = u.next, f.quick = f, l && (l.x && i(l, u), f.state = function() {
        return i(u, {});
      }), f;
    }
    t && t.exports ? t.exports = o : this.xorshift7 = o;
  })(
    cc,
    e
  );
})(GD);
var PVe = GD.exports, qD = { exports: {} };
qD.exports;
(function(e) {
  (function(r, t, n) {
    function a(c) {
      var s = this;
      s.next = function() {
        var l = s.w, f = s.X, d = s.i, m, p;
        return s.w = l = l + 1640531527 | 0, p = f[d + 34 & 127], m = f[d = d + 1 & 127], p ^= p << 13, m ^= m << 17, p ^= p >>> 15, m ^= m >>> 12, p = f[d] = p ^ m, s.i = d, p + (l ^ l >>> 16) | 0;
      };
      function u(l, f) {
        var d, m, p, v, h, y = [], C = 128;
        for (f === (f | 0) ? (m = f, f = null) : (f = f + "\0", m = 0, C = Math.max(C, f.length)), p = 0, v = -32; v < C; ++v)
          f && (m ^= f.charCodeAt((v + 32) % f.length)), v === 0 && (h = m), m ^= m << 10, m ^= m >>> 15, m ^= m << 4, m ^= m >>> 13, v >= 0 && (h = h + 1640531527 | 0, d = y[v & 127] ^= m + h, p = d == 0 ? p + 1 : 0);
        for (p >= 128 && (y[(f && f.length || 0) & 127] = -1), p = 127, v = 4 * 128; v > 0; --v)
          m = y[p + 34 & 127], d = y[p = p + 1 & 127], m ^= m << 13, d ^= d << 17, m ^= m >>> 15, d ^= d >>> 12, y[p] = m ^ d;
        l.w = h, l.X = y, l.i = p;
      }
      u(s, c);
    }
    function i(c, s) {
      return s.i = c.i, s.w = c.w, s.X = c.X.slice(), s;
    }
    function o(c, s) {
      c == null && (c = +/* @__PURE__ */ new Date());
      var u = new a(c), l = s && s.state, f = function() {
        return (u.next() >>> 0) / 4294967296;
      };
      return f.double = function() {
        do
          var d = u.next() >>> 11, m = (u.next() >>> 0) / 4294967296, p = (d + m) / (1 << 21);
        while (p === 0);
        return p;
      }, f.int32 = u.next, f.quick = f, l && (l.X && i(l, u), f.state = function() {
        return i(u, {});
      }), f;
    }
    t && t.exports ? t.exports = o : this.xor4096 = o;
  })(
    cc,
    // window object or global
    e
  );
})(qD);
var MVe = qD.exports, HD = { exports: {} };
HD.exports;
(function(e) {
  (function(r, t, n) {
    function a(c) {
      var s = this, u = "";
      s.next = function() {
        var f = s.b, d = s.c, m = s.d, p = s.a;
        return f = f << 25 ^ f >>> 7 ^ d, d = d - m | 0, m = m << 24 ^ m >>> 8 ^ p, p = p - f | 0, s.b = f = f << 20 ^ f >>> 12 ^ d, s.c = d = d - m | 0, s.d = m << 16 ^ d >>> 16 ^ p, s.a = p - f | 0;
      }, s.a = 0, s.b = 0, s.c = -1640531527, s.d = 1367130551, c === Math.floor(c) ? (s.a = c / 4294967296 | 0, s.b = c | 0) : u += c;
      for (var l = 0; l < u.length + 20; l++)
        s.b ^= u.charCodeAt(l) | 0, s.next();
    }
    function i(c, s) {
      return s.a = c.a, s.b = c.b, s.c = c.c, s.d = c.d, s;
    }
    function o(c, s) {
      var u = new a(c), l = s && s.state, f = function() {
        return (u.next() >>> 0) / 4294967296;
      };
      return f.double = function() {
        do
          var d = u.next() >>> 11, m = (u.next() >>> 0) / 4294967296, p = (d + m) / (1 << 21);
        while (p === 0);
        return p;
      }, f.int32 = u.next, f.quick = f, l && (typeof l == "object" && i(l, u), f.state = function() {
        return i(u, {});
      }), f;
    }
    t && t.exports ? t.exports = o : this.tychei = o;
  })(
    cc,
    e
  );
})(HD);
var wVe = HD.exports, TY = { exports: {} };
const EVe = {}, DVe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: EVe
}, Symbol.toStringTag, { value: "Module" })), IVe = /* @__PURE__ */ F3(DVe);
(function(e) {
  (function(r, t, n) {
    var a = 256, i = 6, o = 52, c = "random", s = n.pow(a, i), u = n.pow(2, o), l = u * 2, f = a - 1, d;
    function m(b, g, _) {
      var A = [];
      g = g == !0 ? { entropy: !0 } : g || {};
      var M = y(h(
        g.entropy ? [b, S(t)] : b ?? C(),
        3
      ), A), P = new p(A), T = function() {
        for (var x = P.g(i), w = s, E = 0; x < u; )
          x = (x + E) * a, w *= a, E = P.g(1);
        for (; x >= l; )
          x /= 2, w /= 2, E >>>= 1;
        return (x + E) / w;
      };
      return T.int32 = function() {
        return P.g(4) | 0;
      }, T.quick = function() {
        return P.g(4) / 4294967296;
      }, T.double = T, y(S(P.S), t), (g.pass || _ || function(x, w, E, I) {
        return I && (I.S && v(I, P), x.state = function() {
          return v(P, {});
        }), E ? (n[c] = x, w) : x;
      })(
        T,
        M,
        "global" in g ? g.global : this == n,
        g.state
      );
    }
    function p(b) {
      var g, _ = b.length, A = this, M = 0, P = A.i = A.j = 0, T = A.S = [];
      for (_ || (b = [_++]); M < a; )
        T[M] = M++;
      for (M = 0; M < a; M++)
        T[M] = T[P = f & P + b[M % _] + (g = T[M])], T[P] = g;
      (A.g = function(x) {
        for (var w, E = 0, I = A.i, B = A.j, D = A.S; x--; )
          w = D[I = f & I + 1], E = E * a + D[f & (D[I] = D[B = f & B + w]) + (D[B] = w)];
        return A.i = I, A.j = B, E;
      })(a);
    }
    function v(b, g) {
      return g.i = b.i, g.j = b.j, g.S = b.S.slice(), g;
    }
    function h(b, g) {
      var _ = [], A = typeof b, M;
      if (g && A == "object")
        for (M in b)
          try {
            _.push(h(b[M], g - 1));
          } catch {
          }
      return _.length ? _ : A == "string" ? b : b + "\0";
    }
    function y(b, g) {
      for (var _ = b + "", A, M = 0; M < _.length; )
        g[f & M] = f & (A ^= g[f & M] * 19) + _.charCodeAt(M++);
      return S(g);
    }
    function C() {
      try {
        var b;
        return d && (b = d.randomBytes) ? b = b(a) : (b = new Uint8Array(a), (r.crypto || r.msCrypto).getRandomValues(b)), S(b);
      } catch {
        var g = r.navigator, _ = g && g.plugins;
        return [+/* @__PURE__ */ new Date(), r, _, r.screen, S(t)];
      }
    }
    function S(b) {
      return String.fromCharCode.apply(0, b);
    }
    if (y(n.random(), t), e.exports) {
      e.exports = m;
      try {
        d = IVe;
      } catch {
      }
    } else
      n["seed" + c] = m;
  })(
    // global: `self` in browsers (including strict mode and web workers),
    // otherwise `this` in Node and other environments
    typeof self < "u" ? self : cc,
    [],
    // pool: entropy pool starts empty
    Math
    // math: package containing random, pow, and seedrandom
  );
})(TY);
var BVe = TY.exports, NVe = AVe, VVe = xVe, RVe = TVe, OVe = PVe, FVe = MVe, LVe = wVe, tm = BVe;
tm.alea = NVe;
tm.xor128 = VVe;
tm.xorwow = RVe;
tm.xorshift7 = OVe;
tm.xor4096 = FVe;
tm.tychei = LVe;
var kVe = tm;
const PY = /* @__PURE__ */ qg(kVe);
var UVe = /* @__PURE__ */ PY(Date.now());
function vp(e) {
  var r;
  function t(a) {
    r = a === null ? UVe : PY(String(a));
  }
  t(e);
  function n() {
    return r();
  }
  return n;
}
var mk = "pickRandom", zVe = ["typed", "config", "?on"], GVe = /* @__PURE__ */ Ce(mk, zVe, (e) => {
  var {
    typed: r,
    config: t,
    on: n
  } = e, a = vp(t.randomSeed);
  return n && n("config", function(o, c) {
    o.randomSeed !== c.randomSeed && (a = vp(o.randomSeed));
  }), r(mk, {
    "Array | Matrix": function(c) {
      return i(c, {});
    },
    "Array | Matrix, Object": function(c, s) {
      return i(c, s);
    },
    "Array | Matrix, number": function(c, s) {
      return i(c, {
        number: s
      });
    },
    "Array | Matrix, Array | Matrix": function(c, s) {
      return i(c, {
        weights: s
      });
    },
    "Array | Matrix, Array | Matrix, number": function(c, s, u) {
      return i(c, {
        number: u,
        weights: s
      });
    },
    "Array | Matrix, number, Array | Matrix": function(c, s, u) {
      return i(c, {
        number: s,
        weights: u
      });
    }
  });
  function i(o, c) {
    var {
      number: s,
      weights: u,
      elementWise: l = !0
    } = c, f = typeof s > "u";
    f && (s = 1);
    var d = gr(o) ? o.create : gr(u) ? u.create : null;
    o = o.valueOf(), u && (u = u.valueOf()), l === !0 && (o = st(o), u = st(u));
    var m = 0;
    if (typeof u < "u") {
      if (u.length !== o.length)
        throw new Error("Weights must have the same length as possibles");
      for (var p = 0, v = u.length; p < v; p++) {
        if (!Or(u[p]) || u[p] < 0)
          throw new Error("Weights must be an array of positive numbers");
        m += u[p];
      }
    }
    for (var h = o.length, y = [], C; y.length < s; ) {
      if (typeof u > "u")
        C = o[Math.floor(a() * h)];
      else
        for (var S = a() * m, b = 0, g = o.length; b < g; b++)
          if (S -= u[b], S < 0) {
            C = o[b];
            break;
          }
      y.push(C);
    }
    return f ? y[0] : d ? d(y) : y;
  }
});
function jD(e, r) {
  var t = [];
  if (e = e.slice(0), e.length > 1)
    for (var n = 0, a = e.shift(); n < a; n++)
      t.push(jD(e, r));
  else
    for (var i = 0, o = e.shift(); i < o; i++)
      t.push(r());
  return t;
}
var vk = "random", qVe = ["typed", "config", "?on"], HVe = /* @__PURE__ */ Ce(vk, qVe, (e) => {
  var {
    typed: r,
    config: t,
    on: n
  } = e, a = vp(t.randomSeed);
  return n && n("config", function(c, s) {
    c.randomSeed !== s.randomSeed && (a = vp(c.randomSeed));
  }), r(vk, {
    "": () => o(0, 1),
    number: (c) => o(0, c),
    "number, number": (c, s) => o(c, s),
    "Array | Matrix": (c) => i(c, 0, 1),
    "Array | Matrix, number": (c, s) => i(c, 0, s),
    "Array | Matrix, number, number": (c, s, u) => i(c, s, u)
  });
  function i(c, s, u) {
    var l = jD(c.valueOf(), () => o(s, u));
    return gr(c) ? c.create(l) : l;
  }
  function o(c, s) {
    return c + a() * (s - c);
  }
}), pk = "randomInt", jVe = ["typed", "config", "?on"], $Ve = /* @__PURE__ */ Ce(pk, jVe, (e) => {
  var {
    typed: r,
    config: t,
    on: n
  } = e, a = vp(t.randomSeed);
  return n && n("config", function(c, s) {
    c.randomSeed !== s.randomSeed && (a = vp(c.randomSeed));
  }), r(pk, {
    "": () => o(0, 1),
    number: (c) => o(0, c),
    "number, number": (c, s) => o(c, s),
    "Array | Matrix": (c) => i(c, 0, 1),
    "Array | Matrix, number": (c, s) => i(c, 0, s),
    "Array | Matrix, number, number": (c, s, u) => i(c, s, u)
  });
  function i(c, s, u) {
    var l = jD(c.valueOf(), () => o(s, u));
    return gr(c) ? c.create(l) : l;
  }
  function o(c, s) {
    return Math.floor(c + a() * (s - c));
  }
}), hk = "stirlingS2", KVe = ["typed", "addScalar", "subtractScalar", "multiplyScalar", "divideScalar", "pow", "factorial", "combinations", "isNegative", "isInteger", "number", "?bignumber", "larger"], WVe = /* @__PURE__ */ Ce(hk, KVe, (e) => {
  var {
    typed: r,
    addScalar: t,
    subtractScalar: n,
    multiplyScalar: a,
    divideScalar: i,
    pow: o,
    factorial: c,
    combinations: s,
    isNegative: u,
    isInteger: l,
    number: f,
    bignumber: d,
    larger: m
  } = e, p = [], v = [];
  return r(hk, {
    "number | BigNumber, number | BigNumber": function(y, C) {
      if (!l(y) || u(y) || !l(C) || u(C))
        throw new TypeError("Non-negative integer value expected in function stirlingS2");
      if (m(C, y))
        throw new TypeError("k must be less than or equal to n in function stirlingS2");
      var S = !(Or(y) && Or(C)), b = S ? v : p, g = S ? d : f, _ = f(y), A = f(C);
      if (b[_] && b[_].length > A)
        return b[_][A];
      for (var M = 0; M <= _; ++M)
        if (b[M] || (b[M] = [g(M === 0 ? 1 : 0)]), M !== 0)
          for (var P = b[M], T = b[M - 1], x = P.length; x <= M && x <= A; ++x)
            x === M ? P[x] = 1 : P[x] = t(a(g(x), T[x]), T[x - 1]);
      return b[_][A];
    }
  });
}), gk = "bellNumbers", XVe = ["typed", "addScalar", "isNegative", "isInteger", "stirlingS2"], YVe = /* @__PURE__ */ Ce(gk, XVe, (e) => {
  var {
    typed: r,
    addScalar: t,
    isNegative: n,
    isInteger: a,
    stirlingS2: i
  } = e;
  return r(gk, {
    "number | BigNumber": function(c) {
      if (!a(c) || n(c))
        throw new TypeError("Non-negative integer value expected in function bellNumbers");
      for (var s = 0, u = 0; u <= c; u++)
        s = t(s, i(c, u));
      return s;
    }
  });
}), yk = "catalan", QVe = ["typed", "addScalar", "divideScalar", "multiplyScalar", "combinations", "isNegative", "isInteger"], ZVe = /* @__PURE__ */ Ce(yk, QVe, (e) => {
  var {
    typed: r,
    addScalar: t,
    divideScalar: n,
    multiplyScalar: a,
    combinations: i,
    isNegative: o,
    isInteger: c
  } = e;
  return r(yk, {
    "number | BigNumber": function(u) {
      if (!c(u) || o(u))
        throw new TypeError("Non-negative integer value expected in function catalan");
      return n(i(a(u, 2), u), t(u, 1));
    }
  });
}), _k = "composition", JVe = ["typed", "addScalar", "combinations", "isNegative", "isPositive", "isInteger", "larger"], eRe = /* @__PURE__ */ Ce(_k, JVe, (e) => {
  var {
    typed: r,
    addScalar: t,
    combinations: n,
    isPositive: a,
    isNegative: i,
    isInteger: o,
    larger: c
  } = e;
  return r(_k, {
    "number | BigNumber, number | BigNumber": function(u, l) {
      if (!o(u) || !a(u) || !o(l) || !a(l))
        throw new TypeError("Positive integer value expected in function composition");
      if (c(l, u))
        throw new TypeError("k must be less than or equal to n in function composition");
      return n(t(u, -1), t(l, -1));
    }
  });
}), bk = "leafCount", rRe = ["parse", "typed"], tRe = /* @__PURE__ */ Ce(bk, rRe, (e) => {
  var {
    parse: r,
    typed: t
  } = e;
  function n(a) {
    var i = 0;
    return a.forEach((o) => {
      i += n(o);
    }), i || 1;
  }
  return t(bk, {
    Node: function(i) {
      return n(i);
    }
  });
});
function Sk(e) {
  return Jr(e) || Hn(e) && e.isUnary() && Jr(e.args[0]);
}
function V3(e) {
  return !!(Jr(e) || (hc(e) || Hn(e)) && e.args.every(V3) || sl(e) && V3(e.content));
}
function Ck(e, r) {
  var t = Object.keys(e);
  if (Object.getOwnPropertySymbols) {
    var n = Object.getOwnPropertySymbols(e);
    r && (n = n.filter(function(a) {
      return Object.getOwnPropertyDescriptor(e, a).enumerable;
    })), t.push.apply(t, n);
  }
  return t;
}
function wP(e) {
  for (var r = 1; r < arguments.length; r++) {
    var t = arguments[r] != null ? arguments[r] : {};
    r % 2 ? Ck(Object(t), !0).forEach(function(n) {
      ba(e, n, t[n]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : Ck(Object(t)).forEach(function(n) {
      Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(t, n));
    });
  }
  return e;
}
var nRe = "simplifyUtil", aRe = ["FunctionNode", "OperatorNode", "SymbolNode"], $D = /* @__PURE__ */ Ce(nRe, aRe, (e) => {
  var {
    FunctionNode: r,
    OperatorNode: t,
    SymbolNode: n
  } = e, a = !0, i = !1, o = "defaultF", c = {
    /*      */
    add: {
      trivial: a,
      total: a,
      commutative: a,
      associative: a
    },
    /**/
    unaryPlus: {
      trivial: a,
      total: a,
      commutative: a,
      associative: a
    },
    /* */
    subtract: {
      trivial: i,
      total: a,
      commutative: i,
      associative: i
    },
    /* */
    multiply: {
      trivial: a,
      total: a,
      commutative: a,
      associative: a
    },
    /*   */
    divide: {
      trivial: i,
      total: a,
      commutative: i,
      associative: i
    },
    /*    */
    paren: {
      trivial: a,
      total: a,
      commutative: a,
      associative: i
    },
    /* */
    defaultF: {
      trivial: i,
      total: a,
      commutative: i,
      associative: i
    }
  }, s = {
    divide: {
      total: i
    },
    log: {
      total: i
    }
  }, u = {
    subtract: {
      total: i
    },
    abs: {
      trivial: a
    },
    log: {
      total: a
    }
  };
  function l(S, b) {
    var g = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : c, _ = o;
    if (typeof S == "string" ? _ = S : Hn(S) ? _ = S.fn.toString() : hc(S) ? _ = S.name : sl(S) && (_ = "paren"), er(g, _)) {
      var A = g[_];
      if (er(A, b))
        return A[b];
      if (er(c, _))
        return c[_][b];
    }
    if (er(g, o)) {
      var M = g[o];
      return er(M, b) ? M[b] : c[o][b];
    }
    if (er(c, _)) {
      var P = c[_];
      if (er(P, b))
        return P[b];
    }
    return c[o][b];
  }
  function f(S) {
    var b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : c;
    return l(S, "commutative", b);
  }
  function d(S) {
    var b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : c;
    return l(S, "associative", b);
  }
  function m(S, b) {
    var g = wP({}, S);
    for (var _ in b)
      er(S, _) ? g[_] = wP(wP({}, b[_]), S[_]) : g[_] = b[_];
    return g;
  }
  function p(S, b) {
    if (!S.args || S.args.length === 0)
      return S;
    S.args = v(S, b);
    for (var g = 0; g < S.args.length; g++)
      p(S.args[g], b);
  }
  function v(S, b) {
    var g, _ = [], A = function M(P) {
      for (var T = 0; T < P.args.length; T++) {
        var x = P.args[T];
        Hn(x) && g === x.op ? M(x) : _.push(x);
      }
    };
    return d(S, b) ? (g = S.op, A(S), _) : S.args;
  }
  function h(S, b) {
    if (!(!S.args || S.args.length === 0)) {
      for (var g = C(S), _ = S.args.length, A = 0; A < _; A++)
        h(S.args[A], b);
      if (_ > 2 && d(S, b)) {
        for (var M = S.args.pop(); S.args.length > 0; )
          M = g([S.args.pop(), M]);
        S.args = M.args;
      }
    }
  }
  function y(S, b) {
    if (!(!S.args || S.args.length === 0)) {
      for (var g = C(S), _ = S.args.length, A = 0; A < _; A++)
        y(S.args[A], b);
      if (_ > 2 && d(S, b)) {
        for (var M = S.args.shift(); S.args.length > 0; )
          M = g([M, S.args.shift()]);
        S.args = M.args;
      }
    }
  }
  function C(S) {
    return Hn(S) ? function(b) {
      try {
        return new t(S.op, S.fn, b, S.implicit);
      } catch (g) {
        return console.error(g), [];
      }
    } : function(b) {
      return new r(new n(S.name), b);
    };
  }
  return {
    createMakeNodeFunction: C,
    hasProperty: l,
    isCommutative: f,
    isAssociative: d,
    mergeContext: m,
    flatten: p,
    allChildren: v,
    unflattenr: h,
    unflattenl: y,
    defaultContext: c,
    realContext: s,
    positiveContext: u
  };
}), iRe = "simplify", oRe = ["config", "typed", "parse", "add", "subtract", "multiply", "divide", "pow", "isZero", "equal", "resolve", "simplifyConstant", "simplifyCore", "?fraction", "?bignumber", "mathWithTransform", "matrix", "AccessorNode", "ArrayNode", "ConstantNode", "FunctionNode", "IndexNode", "ObjectNode", "OperatorNode", "ParenthesisNode", "SymbolNode"], uRe = /* @__PURE__ */ Ce(iRe, oRe, (e) => {
  var {
    config: r,
    typed: t,
    parse: n,
    add: a,
    subtract: i,
    multiply: o,
    divide: c,
    pow: s,
    isZero: u,
    equal: l,
    resolve: f,
    simplifyConstant: d,
    simplifyCore: m,
    fraction: p,
    bignumber: v,
    mathWithTransform: h,
    matrix: y,
    AccessorNode: C,
    ArrayNode: S,
    ConstantNode: b,
    FunctionNode: g,
    IndexNode: _,
    ObjectNode: A,
    OperatorNode: M,
    ParenthesisNode: P,
    SymbolNode: T
  } = e, {
    hasProperty: x,
    isCommutative: w,
    isAssociative: E,
    mergeContext: I,
    flatten: B,
    unflattenr: D,
    unflattenl: N,
    createMakeNodeFunction: O,
    defaultContext: V,
    realContext: k,
    positiveContext: G
  } = $D({
    FunctionNode: g,
    OperatorNode: M,
    SymbolNode: T
  });
  t.addConversion({
    from: "Object",
    to: "Map",
    convert: bv
  });
  var L = t("simplify", {
    Node: Y,
    "Node, Map": (z, j) => Y(z, !1, j),
    "Node, Map, Object": (z, j, ae) => Y(z, !1, j, ae),
    "Node, Array": Y,
    "Node, Array, Map": Y,
    "Node, Array, Map, Object": Y
  });
  t.removeConversion({
    from: "Object",
    to: "Map",
    convert: bv
  }), L.defaultContext = V, L.realContext = k, L.positiveContext = G;
  function R(z) {
    return z.transform(function(j, ae, le) {
      return sl(j) ? R(j.content) : j;
    });
  }
  var F = {
    true: !0,
    false: !0,
    e: !0,
    i: !0,
    Infinity: !0,
    LN2: !0,
    LN10: !0,
    LOG2E: !0,
    LOG10E: !0,
    NaN: !0,
    phi: !0,
    pi: !0,
    SQRT1_2: !0,
    SQRT2: !0,
    tau: !0
    // null: false,
    // undefined: false,
    // version: false,
  };
  L.rules = [
    m,
    // { l: 'n+0', r: 'n' },     // simplifyCore
    // { l: 'n^0', r: '1' },     // simplifyCore
    // { l: '0*n', r: '0' },     // simplifyCore
    // { l: 'n/n', r: '1'},      // simplifyCore
    // { l: 'n^1', r: 'n' },     // simplifyCore
    // { l: '+n1', r:'n1' },     // simplifyCore
    // { l: 'n--n1', r:'n+n1' }, // simplifyCore
    {
      l: "log(e)",
      r: "1"
    },
    // temporary rules
    // Note initially we tend constants to the right because like-term
    // collection prefers the left, and we would rather collect nonconstants
    {
      s: "n-n1 -> n+-n1",
      // temporarily replace 'subtract' so we can further flatten the 'add' operator
      assuming: {
        subtract: {
          total: !0
        }
      }
    },
    {
      s: "n-n -> 0",
      // partial alternative when we can't always subtract
      assuming: {
        subtract: {
          total: !1
        }
      }
    },
    {
      s: "-(cl*v) -> v * (-cl)",
      // make non-constant terms positive
      assuming: {
        multiply: {
          commutative: !0
        },
        subtract: {
          total: !0
        }
      }
    },
    {
      s: "-(cl*v) -> (-cl) * v",
      // non-commutative version, part 1
      assuming: {
        multiply: {
          commutative: !1
        },
        subtract: {
          total: !0
        }
      }
    },
    {
      s: "-(v*cl) -> v * (-cl)",
      // non-commutative version, part 2
      assuming: {
        multiply: {
          commutative: !1
        },
        subtract: {
          total: !0
        }
      }
    },
    {
      l: "-(n1/n2)",
      r: "-n1/n2"
    },
    {
      l: "-v",
      r: "v * (-1)"
    },
    // finish making non-constant terms positive
    {
      l: "(n1 + n2)*(-1)",
      r: "n1*(-1) + n2*(-1)",
      repeat: !0
    },
    // expand negations to achieve as much sign cancellation as possible
    {
      l: "n/n1^n2",
      r: "n*n1^-n2"
    },
    // temporarily replace 'divide' so we can further flatten the 'multiply' operator
    {
      l: "n/n1",
      r: "n*n1^-1"
    },
    {
      s: "(n1*n2)^n3 -> n1^n3 * n2^n3",
      assuming: {
        multiply: {
          commutative: !0
        }
      }
    },
    {
      s: "(n1*n2)^(-1) -> n2^(-1) * n1^(-1)",
      assuming: {
        multiply: {
          commutative: !1
        }
      }
    },
    // expand nested exponentiation
    {
      s: "(n ^ n1) ^ n2 -> n ^ (n1 * n2)",
      assuming: {
        divide: {
          total: !0
        }
      }
      // 1/(1/n) = n needs 1/n to exist
    },
    // collect like factors; into a sum, only do this for nonconstants
    {
      l: " vd   * ( vd   * n1 + n2)",
      r: "vd^2       * n1 +  vd   * n2"
    },
    {
      s: " vd   * (vd^n4 * n1 + n2)   ->  vd^(1+n4)  * n1 +  vd   * n2",
      assuming: {
        divide: {
          total: !0
        }
      }
      // v*1/v = v^(1+-1) needs 1/v
    },
    {
      s: "vd^n3 * ( vd   * n1 + n2)   ->  vd^(n3+1)  * n1 + vd^n3 * n2",
      assuming: {
        divide: {
          total: !0
        }
      }
    },
    {
      s: "vd^n3 * (vd^n4 * n1 + n2)   ->  vd^(n3+n4) * n1 + vd^n3 * n2",
      assuming: {
        divide: {
          total: !0
        }
      }
    },
    {
      l: "n*n",
      r: "n^2"
    },
    {
      s: "n * n^n1 -> n^(n1+1)",
      assuming: {
        divide: {
          total: !0
        }
      }
      // n*1/n = n^(-1+1) needs 1/n
    },
    {
      s: "n^n1 * n^n2 -> n^(n1+n2)",
      assuming: {
        divide: {
          total: !0
        }
      }
      // ditto for n^2*1/n^2
    },
    // Unfortunately, to deal with more complicated cancellations, it
    // becomes necessary to simplify constants twice per pass. It's not
    // terribly expensive compared to matching rules, so this should not
    // pose a performance problem.
    d,
    // First: before collecting like terms
    // collect like terms
    {
      s: "n+n -> 2*n",
      assuming: {
        add: {
          total: !0
        }
      }
      // 2 = 1 + 1 needs to exist
    },
    {
      l: "n+-n",
      r: "0"
    },
    {
      l: "vd*n + vd",
      r: "vd*(n+1)"
    },
    // NOTE: leftmost position is special:
    {
      l: "n3*n1 + n3*n2",
      r: "n3*(n1+n2)"
    },
    // All sub-monomials tried there.
    {
      l: "n3^(-n4)*n1 +   n3  * n2",
      r: "n3^(-n4)*(n1 + n3^(n4+1) *n2)"
    },
    {
      l: "n3^(-n4)*n1 + n3^n5 * n2",
      r: "n3^(-n4)*(n1 + n3^(n4+n5)*n2)"
    },
    // noncommutative additional cases (term collection & factoring)
    {
      s: "n*vd + vd -> (n+1)*vd",
      assuming: {
        multiply: {
          commutative: !1
        }
      }
    },
    {
      s: "vd + n*vd -> (1+n)*vd",
      assuming: {
        multiply: {
          commutative: !1
        }
      }
    },
    {
      s: "n1*n3 + n2*n3 -> (n1+n2)*n3",
      assuming: {
        multiply: {
          commutative: !1
        }
      }
    },
    {
      s: "n^n1 * n -> n^(n1+1)",
      assuming: {
        divide: {
          total: !0
        },
        multiply: {
          commutative: !1
        }
      }
    },
    {
      s: "n1*n3^(-n4) + n2 * n3    -> (n1 + n2*n3^(n4 +  1))*n3^(-n4)",
      assuming: {
        multiply: {
          commutative: !1
        }
      }
    },
    {
      s: "n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)",
      assuming: {
        multiply: {
          commutative: !1
        }
      }
    },
    {
      l: "n*cd + cd",
      r: "(n+1)*cd"
    },
    {
      s: "cd*n + cd -> cd*(n+1)",
      assuming: {
        multiply: {
          commutative: !1
        }
      }
    },
    {
      s: "cd + cd*n -> cd*(1+n)",
      assuming: {
        multiply: {
          commutative: !1
        }
      }
    },
    d,
    // Second: before returning expressions to "standard form"
    // make factors positive (and undo 'make non-constant terms positive')
    {
      s: "(-n)*n1 -> -(n*n1)",
      assuming: {
        subtract: {
          total: !0
        }
      }
    },
    {
      s: "n1*(-n) -> -(n1*n)",
      // in case * non-commutative
      assuming: {
        subtract: {
          total: !0
        },
        multiply: {
          commutative: !1
        }
      }
    },
    // final ordering of constants
    {
      s: "ce+ve -> ve+ce",
      assuming: {
        add: {
          commutative: !0
        }
      },
      imposeContext: {
        add: {
          commutative: !1
        }
      }
    },
    {
      s: "vd*cd -> cd*vd",
      assuming: {
        multiply: {
          commutative: !0
        }
      },
      imposeContext: {
        multiply: {
          commutative: !1
        }
      }
    },
    // undo temporary rules
    // { l: '(-1) * n', r: '-n' }, // #811 added test which proved this is redundant
    {
      l: "n+-n1",
      r: "n-n1"
    },
    // undo replace 'subtract'
    {
      l: "n+-(n1)",
      r: "n-(n1)"
    },
    {
      s: "n*(n1^-1) -> n/n1",
      // undo replace 'divide'; for * commutative
      assuming: {
        multiply: {
          commutative: !0
        }
      }
      // o.w. / not conventional
    },
    {
      s: "n*n1^-n2 -> n/n1^n2",
      assuming: {
        multiply: {
          commutative: !0
        }
      }
      // o.w. / not conventional
    },
    {
      s: "n^-1 -> 1/n",
      assuming: {
        multiply: {
          commutative: !0
        }
      }
      // o.w. / not conventional
    },
    {
      l: "n^1",
      r: "n"
    },
    // can be produced by power cancellation
    {
      s: "n*(n1/n2) -> (n*n1)/n2",
      // '*' before '/'
      assuming: {
        multiply: {
          associative: !0
        }
      }
    },
    {
      s: "n-(n1+n2) -> n-n1-n2",
      // '-' before '+'
      assuming: {
        addition: {
          associative: !0,
          commutative: !0
        }
      }
    },
    // { l: '(n1/n2)/n3', r: 'n1/(n2*n3)' },
    // { l: '(n*n1)/(n*n2)', r: 'n1/n2' },
    // simplifyConstant can leave an extra factor of 1, which can always
    // be eliminated, since the identity always commutes
    {
      l: "1*n",
      r: "n",
      imposeContext: {
        multiply: {
          commutative: !0
        }
      }
    },
    {
      s: "n1/(n2/n3) -> (n1*n3)/n2",
      assuming: {
        multiply: {
          associative: !0
        }
      }
    },
    {
      l: "n1/(-n2)",
      r: "-n1/n2"
    }
  ];
  function U(z, j) {
    var ae = {};
    if (z.s) {
      var le = z.s.split("->");
      if (le.length === 2)
        ae.l = le[0], ae.r = le[1];
      else
        throw SyntaxError("Could not parse rule: " + z.s);
    } else
      ae.l = z.l, ae.r = z.r;
    ae.l = R(n(ae.l)), ae.r = R(n(ae.r));
    for (var ie of ["imposeContext", "repeat", "assuming"])
      ie in z && (ae[ie] = z[ie]);
    if (z.evaluate && (ae.evaluate = n(z.evaluate)), E(ae.l, j)) {
      var re = !w(ae.l, j), ee;
      re && (ee = K());
      var ne = O(ae.l), se = K();
      ae.expanded = {}, ae.expanded.l = ne([ae.l, se]), B(ae.expanded.l, j), D(ae.expanded.l, j), ae.expanded.r = ne([ae.r, se]), re && (ae.expandedNC1 = {}, ae.expandedNC1.l = ne([ee, ae.l]), ae.expandedNC1.r = ne([ee, ae.r]), ae.expandedNC2 = {}, ae.expandedNC2.l = ne([ee, ae.expanded.l]), ae.expandedNC2.r = ne([ee, ae.expanded.r]));
    }
    return ae;
  }
  function H(z, j) {
    for (var ae = [], le = 0; le < z.length; le++) {
      var ie = z[le], re = void 0, ee = typeof ie;
      switch (ee) {
        case "string":
          ie = {
            s: ie
          };
        case "object":
          re = U(ie, j);
          break;
        case "function":
          re = ie;
          break;
        default:
          throw TypeError("Unsupported type of rule: " + ee);
      }
      ae.push(re);
    }
    return ae;
  }
  var q = 0;
  function K() {
    return new T("_p" + q++);
  }
  function Y(z, j) {
    var ae = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : Lg(), le = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}, ie = le.consoleDebug;
    j = H(j || L.rules, le.context);
    var re = f(z, ae);
    re = R(re);
    for (var ee = {}, ne = re.toString({
      parenthesis: "all"
    }); !ee[ne]; ) {
      ee[ne] = !0, q = 0;
      var se = ne;
      ie && console.log("Working on: ", ne);
      for (var ce = 0; ce < j.length; ce++) {
        var de = "";
        if (typeof j[ce] == "function" ? (re = j[ce](re, le), ie && (de = j[ce].name)) : (B(re, le.context), re = Z(re, j[ce], le.context), ie && (de = "".concat(j[ce].l.toString(), " -> ").concat(j[ce].r.toString()))), ie) {
          var me = re.toString({
            parenthesis: "all"
          });
          me !== se && (console.log("Applying", de, "produced", me), se = me);
        }
        N(re, le.context);
      }
      ne = re.toString({
        parenthesis: "all"
      });
    }
    return re;
  }
  function X(z, j, ae) {
    var le = z;
    if (z)
      for (var ie = 0; ie < z.length; ++ie) {
        var re = Z(z[ie], j, ae);
        re !== z[ie] && (le === z && (le = z.slice()), le[ie] = re);
      }
    return le;
  }
  function Z(z, j, ae) {
    if (j.assuming) {
      for (var le in j.assuming)
        for (var ie in j.assuming[le])
          if (x(le, ie, ae) !== j.assuming[le][ie])
            return z;
    }
    var re = I(j.imposeContext, ae), ee = z;
    if (ee instanceof M || ee instanceof g) {
      var ne = X(ee.args, j, ae);
      ne !== ee.args && (ee = ee.clone(), ee.args = ne);
    } else if (ee instanceof P) {
      if (ee.content) {
        var se = Z(ee.content, j, ae);
        se !== ee.content && (ee = new P(se));
      }
    } else if (ee instanceof S) {
      var ce = X(ee.items, j, ae);
      ce !== ee.items && (ee = new S(ce));
    } else if (ee instanceof C) {
      var de = ee.object;
      ee.object && (de = Z(ee.object, j, ae));
      var me = ee.index;
      ee.index && (me = Z(ee.index, j, ae)), (de !== ee.object || me !== ee.index) && (ee = new C(de, me));
    } else if (ee instanceof _) {
      var he = X(ee.dimensions, j, ae);
      he !== ee.dimensions && (ee = new _(he));
    } else if (ee instanceof A) {
      var _e = !1, Se = {};
      for (var Pe in ee.properties)
        Se[Pe] = Z(ee.properties[Pe], j, ae), Se[Pe] !== ee.properties[Pe] && (_e = !0);
      _e && (ee = new A(Se));
    }
    var De = j.r, Ee = te(j.l, ee, re)[0];
    if (!Ee && j.expanded && (De = j.expanded.r, Ee = te(j.expanded.l, ee, re)[0]), !Ee && j.expandedNC1 && (De = j.expandedNC1.r, Ee = te(j.expandedNC1.l, ee, re)[0], Ee || (De = j.expandedNC2.r, Ee = te(j.expandedNC2.l, ee, re)[0])), Ee) {
      var Me = ee.implicit;
      ee = De.clone(), Me && "implicit" in De && (ee.implicit = !0), ee = ee.transform(function(ue) {
        return ue.isSymbolNode && er(Ee.placeholders, ue.name) ? Ee.placeholders[ue.name].clone() : ue;
      });
    }
    return j.repeat && ee !== z && (ee = Z(ee, j, ae)), ee;
  }
  function J(z, j) {
    var ae = [], le, ie, re = O(z);
    if (w(z, j))
      for (var ee = 0; ee < z.args.length; ee++)
        ie = z.args.slice(0), ie.splice(ee, 1), le = ie.length === 1 ? ie[0] : re(ie), ae.push(re([z.args[ee], le]));
    else
      for (var ne = 1; ne < z.args.length; ne++) {
        var se = z.args[0];
        ne > 1 && (se = re(z.args.slice(0, ne))), ie = z.args.slice(ne), le = ie.length === 1 ? ie[0] : re(ie), ae.push(re([se, le]));
      }
    return ae;
  }
  function $(z, j) {
    var ae = {
      placeholders: {}
    };
    if (!z.placeholders && !j.placeholders)
      return ae;
    if (z.placeholders) {
      if (!j.placeholders)
        return z;
    } else return j;
    for (var le in z.placeholders)
      if (er(z.placeholders, le) && (ae.placeholders[le] = z.placeholders[le], er(j.placeholders, le) && !oe(z.placeholders[le], j.placeholders[le])))
        return null;
    for (var ie in j.placeholders)
      er(j.placeholders, ie) && (ae.placeholders[ie] = j.placeholders[ie]);
    return ae;
  }
  function Q(z, j) {
    var ae = [];
    if (z.length === 0 || j.length === 0)
      return ae;
    for (var le, ie = 0; ie < z.length; ie++)
      for (var re = 0; re < j.length; re++)
        le = $(z[ie], j[re]), le && ae.push(le);
    return ae;
  }
  function W(z) {
    if (z.length === 0)
      return z;
    for (var j = z.reduce(Q), ae = [], le = {}, ie = 0; ie < j.length; ie++) {
      var re = JSON.stringify(j[ie]);
      le[re] || (le[re] = !0, ae.push(j[ie]));
    }
    return ae;
  }
  function te(z, j, ae, le) {
    var ie = [{
      placeholders: {}
    }];
    if (z instanceof M && j instanceof M || z instanceof g && j instanceof g) {
      if (z instanceof M) {
        if (z.op !== j.op || z.fn !== j.fn)
          return [];
      } else if (z instanceof g && z.name !== j.name)
        return [];
      if (j.args.length === 1 && z.args.length === 1 || !E(j, ae) && j.args.length === z.args.length || le) {
        for (var re = [], ee = 0; ee < z.args.length; ee++) {
          var ne = te(z.args[ee], j.args[ee], ae);
          if (ne.length === 0)
            break;
          re.push(ne);
        }
        if (re.length !== z.args.length) {
          if (!w(j, ae) || // exact match in order needed
          z.args.length === 1)
            return [];
          if (z.args.length > 2)
            throw new Error("permuting >2 commutative non-associative rule arguments not yet implemented");
          var se = te(z.args[0], j.args[1], ae);
          if (se.length === 0)
            return [];
          var ce = te(z.args[1], j.args[0], ae);
          if (ce.length === 0)
            return [];
          re = [se, ce];
        }
        ie = W(re);
      } else if (j.args.length >= 2 && z.args.length === 2) {
        for (var de = J(j, ae), me = [], he = 0; he < de.length; he++) {
          var _e = te(z, de[he], ae, !0);
          me = me.concat(_e);
        }
        return me;
      } else {
        if (z.args.length > 2)
          throw Error("Unexpected non-binary associative function: " + z.toString());
        return [];
      }
    } else if (z instanceof T) {
      if (z.name.length === 0)
        throw new Error("Symbol in rule has 0 length...!?");
      if (F[z.name]) {
        if (z.name !== j.name)
          return [];
      } else
        switch (z.name[1] >= "a" && z.name[1] <= "z" ? z.name.substring(0, 2) : z.name[0]) {
          case "n":
          case "_p":
            ie[0].placeholders[z.name] = j;
            break;
          case "c":
          case "cl":
            if (Jr(j))
              ie[0].placeholders[z.name] = j;
            else
              return [];
            break;
          case "v":
            if (!Jr(j))
              ie[0].placeholders[z.name] = j;
            else
              return [];
            break;
          case "vl":
            if (_a(j))
              ie[0].placeholders[z.name] = j;
            else
              return [];
            break;
          case "cd":
            if (Sk(j))
              ie[0].placeholders[z.name] = j;
            else
              return [];
            break;
          case "vd":
            if (!Sk(j))
              ie[0].placeholders[z.name] = j;
            else
              return [];
            break;
          case "ce":
            if (V3(j))
              ie[0].placeholders[z.name] = j;
            else
              return [];
            break;
          case "ve":
            if (!V3(j))
              ie[0].placeholders[z.name] = j;
            else
              return [];
            break;
          default:
            throw new Error("Invalid symbol in rule: " + z.name);
        }
    } else if (z instanceof b) {
      if (!l(z.value, j.value))
        return [];
    } else
      return [];
    return ie;
  }
  function oe(z, j) {
    if (z instanceof b && j instanceof b) {
      if (!l(z.value, j.value))
        return !1;
    } else if (z instanceof T && j instanceof T) {
      if (z.name !== j.name)
        return !1;
    } else if (z instanceof M && j instanceof M || z instanceof g && j instanceof g) {
      if (z instanceof M) {
        if (z.op !== j.op || z.fn !== j.fn)
          return !1;
      } else if (z instanceof g && z.name !== j.name)
        return !1;
      if (z.args.length !== j.args.length)
        return !1;
      for (var ae = 0; ae < z.args.length; ae++)
        if (!oe(z.args[ae], j.args[ae]))
          return !1;
    } else
      return !1;
    return !0;
  }
  return L;
}), sRe = "simplifyConstant", lRe = ["typed", "config", "mathWithTransform", "matrix", "?fraction", "?bignumber", "AccessorNode", "ArrayNode", "ConstantNode", "FunctionNode", "IndexNode", "ObjectNode", "OperatorNode", "SymbolNode"], cRe = /* @__PURE__ */ Ce(sRe, lRe, (e) => {
  var {
    typed: r,
    config: t,
    mathWithTransform: n,
    matrix: a,
    fraction: i,
    bignumber: o,
    AccessorNode: c,
    ArrayNode: s,
    ConstantNode: u,
    FunctionNode: l,
    IndexNode: f,
    ObjectNode: d,
    OperatorNode: m,
    SymbolNode: p
  } = e, {
    isCommutative: v,
    isAssociative: h,
    allChildren: y,
    createMakeNodeFunction: C
  } = $D({
    FunctionNode: l,
    OperatorNode: m,
    SymbolNode: p
  }), S = r("simplifyConstant", {
    Node: (B) => A(I(B, {})),
    "Node, Object": function(D, N) {
      return A(I(D, N));
    }
  });
  function b(B) {
    return J0(B) ? B.valueOf() : B instanceof Array ? B.map(b) : gr(B) ? a(b(B.valueOf())) : B;
  }
  function g(B, D, N) {
    try {
      return n[B].apply(null, D);
    } catch {
      return D = D.map(b), P(n[B].apply(null, D), N);
    }
  }
  var _ = r({
    Fraction: x,
    number: function(D) {
      return D < 0 ? T(new u(-D)) : new u(D);
    },
    BigNumber: function(D) {
      return D < 0 ? T(new u(-D)) : new u(D);
    },
    bigint: function(D) {
      return D < 0n ? T(new u(-D)) : new u(D);
    },
    Complex: function(D) {
      throw new Error("Cannot convert Complex number to Node");
    },
    string: function(D) {
      return new u(D);
    },
    Matrix: function(D) {
      return new s(D.valueOf().map((N) => _(N)));
    }
  });
  function A(B) {
    return St(B) ? B : _(B);
  }
  function M(B, D) {
    var N = D && D.exactFractions !== !1;
    if (N && isFinite(B) && i) {
      var O = i(B), V = D && typeof D.fractionsLimit == "number" ? D.fractionsLimit : 1 / 0;
      if (O.valueOf() === B && O.n < V && O.d < V)
        return O;
    }
    return B;
  }
  var P = r({
    "string, Object": function(D, N) {
      var O = rf(D, t);
      if (O === "BigNumber")
        return o === void 0 && VD(), o(D);
      if (O === "bigint")
        return BigInt(D);
      if (O === "Fraction")
        return i === void 0 && IX(), i(D);
      var V = parseFloat(D);
      return M(V, N);
    },
    "Fraction, Object": function(D, N) {
      return D;
    },
    // we don't need options here
    "BigNumber, Object": function(D, N) {
      return D;
    },
    // we don't need options here
    "number, Object": function(D, N) {
      return M(D, N);
    },
    "bigint, Object": function(D, N) {
      return D;
    },
    "Complex, Object": function(D, N) {
      return D.im !== 0 ? D : M(D.re, N);
    },
    "Matrix, Object": function(D, N) {
      return a(M(D.valueOf()));
    },
    "Array, Object": function(D, N) {
      return D.map(M);
    }
  });
  function T(B) {
    return new m("-", "unaryMinus", [B]);
  }
  function x(B) {
    var D, N = B.s * B.n;
    return N < 0 ? D = new m("-", "unaryMinus", [new u(-N)]) : D = new u(N), B.d === 1 ? D : new m("/", "divide", [D, new u(B.d)]);
  }
  function w(B, D, N) {
    if (!em(D))
      return new c(A(B), A(D));
    if (jo(B) || gr(B)) {
      for (var O = Array.from(D.dimensions); O.length > 0; )
        if (Jr(O[0]) && typeof O[0].value != "string") {
          var V = P(O.shift().value, N);
          jo(B) ? B = B.items[V - 1] : (B = B.valueOf()[V - 1], B instanceof Array && (B = a(B)));
        } else if (O.length > 1 && Jr(O[1]) && typeof O[1].value != "string") {
          var k = P(O[1].value, N), G = [], L = jo(B) ? B.items : B.valueOf();
          for (var R of L)
            if (jo(R))
              G.push(R.items[k - 1]);
            else if (gr(B))
              G.push(R[k - 1]);
            else
              break;
          if (G.length === L.length)
            jo(B) ? B = new s(G) : B = a(G), O.splice(1, 1);
          else
            break;
        } else
          break;
      return O.length === D.dimensions.length ? new c(A(B), D) : O.length > 0 ? (D = new f(O), new c(A(B), D)) : B;
    }
    if (qy(B) && D.dimensions.length === 1 && Jr(D.dimensions[0])) {
      var F = D.dimensions[0].value;
      return F in B.properties ? B.properties[F] : new u();
    }
    return new c(A(B), D);
  }
  function E(B, D, N, O) {
    var V = D.shift(), k = D.reduce((G, L) => {
      if (!St(L)) {
        var R = G.pop();
        if (St(R))
          return [R, L];
        try {
          return G.push(g(B, [R, L], O)), G;
        } catch {
          G.push(R);
        }
      }
      G.push(A(G.pop()));
      var F = G.length === 1 ? G[0] : N(G);
      return [N([F, A(L)])];
    }, [V]);
    return k.length === 1 ? k[0] : N([k[0], _(k[1])]);
  }
  function I(B, D) {
    switch (B.type) {
      case "SymbolNode":
        return B;
      case "ConstantNode":
        switch (typeof B.value) {
          case "number":
            return P(B.value, D);
          case "bigint":
            return P(B.value, D);
          case "string":
            return B.value;
          default:
            if (!isNaN(B.value)) return P(B.value, D);
        }
        return B;
      case "FunctionNode":
        if (n[B.name] && n[B.name].rawArgs)
          return B;
        {
          var N = ["add", "multiply"];
          if (!N.includes(B.name)) {
            var O = B.args.map((Z) => I(Z, D));
            if (!O.some(St))
              try {
                return g(B.name, O, D);
              } catch {
              }
            if (B.name === "size" && O.length === 1 && jo(O[0])) {
              for (var V = [], k = O[0]; jo(k); )
                V.push(k.items.length), k = k.items[0];
              return a(V);
            }
            return new l(B.name, O.map(A));
          }
        }
      case "OperatorNode": {
        var G = B.fn.toString(), L, R, F = C(B);
        if (Hn(B) && B.isUnary())
          L = [I(B.args[0], D)], St(L[0]) ? R = F(L) : R = g(G, L, D);
        else if (h(B, D.context))
          if (L = y(B, D.context), L = L.map((Z) => I(Z, D)), v(G, D.context)) {
            for (var U = [], H = [], q = 0; q < L.length; q++)
              St(L[q]) ? H.push(L[q]) : U.push(L[q]);
            U.length > 1 ? (R = E(G, U, F, D), H.unshift(R), R = E(G, H, F, D)) : R = E(G, L, F, D);
          } else
            R = E(G, L, F, D);
        else
          L = B.args.map((Z) => I(Z, D)), R = E(G, L, F, D);
        return R;
      }
      case "ParenthesisNode":
        return I(B.content, D);
      case "AccessorNode":
        return w(I(B.object, D), I(B.index, D), D);
      case "ArrayNode": {
        var K = B.items.map((Z) => I(Z, D));
        return K.some(St) ? new s(K.map(A)) : a(K);
      }
      case "IndexNode":
        return new f(B.dimensions.map((Z) => S(Z, D)));
      case "ObjectNode": {
        var Y = {};
        for (var X in B.properties)
          Y[X] = S(B.properties[X], D);
        return new d(Y);
      }
      case "AssignmentNode":
      case "BlockNode":
      case "FunctionAssignmentNode":
      case "RangeNode":
      case "ConditionalNode":
      default:
        throw new Error("Unimplemented node type in simplifyConstant: ".concat(B.type));
    }
  }
  return S;
}), Ak = "simplifyCore", dRe = ["typed", "parse", "equal", "isZero", "add", "subtract", "multiply", "divide", "pow", "AccessorNode", "ArrayNode", "ConstantNode", "FunctionNode", "IndexNode", "ObjectNode", "OperatorNode", "ParenthesisNode", "SymbolNode"], fRe = /* @__PURE__ */ Ce(Ak, dRe, (e) => {
  var {
    typed: r,
    parse: t,
    equal: n,
    isZero: a,
    add: i,
    subtract: o,
    multiply: c,
    divide: s,
    pow: u,
    AccessorNode: l,
    ArrayNode: f,
    ConstantNode: d,
    FunctionNode: m,
    IndexNode: p,
    ObjectNode: v,
    OperatorNode: h,
    ParenthesisNode: y,
    SymbolNode: C
  } = e, S = new d(0), b = new d(1), g = new d(!0), _ = new d(!1);
  function A(x) {
    return Hn(x) && ["and", "not", "or"].includes(x.op);
  }
  var {
    hasProperty: M,
    isCommutative: P
  } = $D({
    FunctionNode: m,
    OperatorNode: h,
    SymbolNode: C
  });
  function T(x) {
    var w = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, E = w ? w.context : void 0;
    if (M(x, "trivial", E)) {
      if (hc(x) && x.args.length === 1)
        return T(x.args[0], w);
      var I = !1, B = 0;
      if (x.forEach((H) => {
        ++B, B === 1 && (I = T(H, w));
      }), B === 1)
        return I;
    }
    var D = x;
    if (hc(D)) {
      var N = _6e(D.name);
      if (N) {
        if (D.args.length > 2 && M(D, "associative", E))
          for (; D.args.length > 2; ) {
            var O = D.args.pop(), V = D.args.pop();
            D.args.push(new h(N, D.name, [O, V]));
          }
        D = new h(N, D.name, D.args);
      } else
        return new m(T(D.fn), D.args.map((H) => T(H, w)));
    }
    if (Hn(D) && D.isUnary()) {
      var k = T(D.args[0], w);
      if (D.op === "~" && Hn(k) && k.isUnary() && k.op === "~" || D.op === "not" && Hn(k) && k.isUnary() && k.op === "not" && A(k.args[0]))
        return k.args[0];
      var G = !0;
      if (D.op === "-" && Hn(k) && (k.isBinary() && k.fn === "subtract" && (D = new h("-", "subtract", [k.args[1], k.args[0]]), G = !1), k.isUnary() && k.op === "-"))
        return k.args[0];
      if (G) return new h(D.op, D.fn, [k]);
    }
    if (Hn(D) && D.isBinary()) {
      var L = T(D.args[0], w), R = T(D.args[1], w);
      if (D.op === "+") {
        if (Jr(L) && a(L.value))
          return R;
        if (Jr(R) && a(R.value))
          return L;
        Hn(R) && R.isUnary() && R.op === "-" && (R = R.args[0], D = new h("-", "subtract", [L, R]));
      }
      if (D.op === "-")
        return Hn(R) && R.isUnary() && R.op === "-" ? T(new h("+", "add", [L, R.args[0]]), w) : Jr(L) && a(L.value) ? T(new h("-", "unaryMinus", [R])) : Jr(R) && a(R.value) ? L : new h(D.op, D.fn, [L, R]);
      if (D.op === "*") {
        if (Jr(L)) {
          if (a(L.value))
            return S;
          if (n(L.value, 1))
            return R;
        }
        if (Jr(R)) {
          if (a(R.value))
            return S;
          if (n(R.value, 1))
            return L;
          if (P(D, E))
            return new h(D.op, D.fn, [R, L], D.implicit);
        }
        return new h(D.op, D.fn, [L, R], D.implicit);
      }
      if (D.op === "/")
        return Jr(L) && a(L.value) ? S : Jr(R) && n(R.value, 1) ? L : new h(D.op, D.fn, [L, R]);
      if (D.op === "^" && Jr(R)) {
        if (a(R.value))
          return b;
        if (n(R.value, 1))
          return L;
      }
      if (D.op === "and") {
        if (Jr(L))
          if (L.value) {
            if (A(R)) return R;
            if (Jr(R))
              return R.value ? g : _;
          } else
            return _;
        if (Jr(R))
          if (R.value) {
            if (A(L)) return L;
          } else
            return _;
      }
      if (D.op === "or") {
        if (Jr(L)) {
          if (L.value)
            return g;
          if (A(R)) return R;
        }
        if (Jr(R)) {
          if (R.value)
            return g;
          if (A(L)) return L;
        }
      }
      return new h(D.op, D.fn, [L, R]);
    }
    if (Hn(D))
      return new h(D.op, D.fn, D.args.map((H) => T(H, w)));
    if (jo(D))
      return new f(D.items.map((H) => T(H, w)));
    if (Fd(D))
      return new l(T(D.object, w), T(D.index, w));
    if (em(D))
      return new p(D.dimensions.map((H) => T(H, w)));
    if (qy(D)) {
      var F = {};
      for (var U in D.properties)
        F[U] = T(D.properties[U], w);
      return new v(F);
    }
    return D;
  }
  return r(Ak, {
    Node: T,
    "Node,Object": T
  });
}), mRe = "resolve", vRe = ["typed", "parse", "ConstantNode", "FunctionNode", "OperatorNode", "ParenthesisNode"], pRe = /* @__PURE__ */ Ce(mRe, vRe, (e) => {
  var {
    typed: r,
    parse: t,
    ConstantNode: n,
    FunctionNode: a,
    OperatorNode: i,
    ParenthesisNode: o
  } = e;
  function c(s, u) {
    var l = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : /* @__PURE__ */ new Set();
    if (!u)
      return s;
    if (_a(s)) {
      if (l.has(s.name)) {
        var f = Array.from(l).join(", ");
        throw new ReferenceError("recursive loop of variable definitions among {".concat(f, "}"));
      }
      var d = u.get(s.name);
      if (St(d)) {
        var m = new Set(l);
        return m.add(s.name), c(d, u, m);
      } else return typeof d == "number" ? t(String(d)) : d !== void 0 ? new n(d) : s;
    } else if (Hn(s)) {
      var p = s.args.map(function(h) {
        return c(h, u, l);
      });
      return new i(s.op, s.fn, p, s.implicit);
    } else {
      if (sl(s))
        return new o(c(s.content, u, l));
      if (hc(s)) {
        var v = s.args.map(function(h) {
          return c(h, u, l);
        });
        return new a(s.name, v);
      }
    }
    return s.map((h) => c(h, u, l));
  }
  return r("resolve", {
    Node: c,
    "Node, Map | null | undefined": c,
    "Node, Object": (s, u) => c(s, bv(u)),
    // For arrays and matrices, we map `self` rather than `_resolve`
    // because resolve is fairly expensive anyway, and this way
    // we get nice error messages if one entry in the array has wrong type.
    "Array | Matrix": r.referToSelf((s) => (u) => u.map((l) => s(l))),
    "Array | Matrix, null | undefined": r.referToSelf((s) => (u) => u.map((l) => s(l))),
    "Array, Object": r.referTo("Array,Map", (s) => (u, l) => s(u, bv(l))),
    "Matrix, Object": r.referTo("Matrix,Map", (s) => (u, l) => s(u, bv(l))),
    "Array | Matrix, Map": r.referToSelf((s) => (u, l) => u.map((f) => s(f, l)))
  });
}), xk = "symbolicEqual", hRe = ["parse", "simplify", "typed", "OperatorNode"], gRe = /* @__PURE__ */ Ce(xk, hRe, (e) => {
  var {
    parse: r,
    simplify: t,
    typed: n,
    OperatorNode: a
  } = e;
  function i(o, c) {
    var s = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, u = new a("-", "subtract", [o, c]), l = t(u, {}, s);
    return Jr(l) && !l.value;
  }
  return n(xk, {
    "Node, Node": i,
    "Node, Node, Object": i
  });
}), Tk = "derivative", yRe = ["typed", "config", "parse", "simplify", "equal", "isZero", "numeric", "ConstantNode", "FunctionNode", "OperatorNode", "ParenthesisNode", "SymbolNode"], _Re = /* @__PURE__ */ Ce(Tk, yRe, (e) => {
  var {
    typed: r,
    config: t,
    parse: n,
    simplify: a,
    equal: i,
    isZero: o,
    numeric: c,
    ConstantNode: s,
    FunctionNode: u,
    OperatorNode: l,
    ParenthesisNode: f,
    SymbolNode: d
  } = e;
  function m(S, b) {
    var g = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {
      simplify: !0
    }, _ = {};
    h(_, S, b.name);
    var A = y(S, _);
    return g.simplify ? a(A) : A;
  }
  r.addConversion({
    from: "identifier",
    to: "SymbolNode",
    convert: n
  });
  var p = r(Tk, {
    "Node, SymbolNode": m,
    "Node, SymbolNode, Object": m
    /* TODO: implement and test syntax with order of derivatives -> implement as an option {order: number}
    'Node, SymbolNode, ConstantNode': function (expr, variable, {order}) {
      let res = expr
      for (let i = 0; i < order; i++) {
        let constNodes = {}
        constTag(constNodes, expr, variable.name)
        res = _derivative(res, constNodes)
      }
      return res
    }
    */
  });
  r.removeConversion({
    from: "identifier",
    to: "SymbolNode",
    convert: n
  }), p._simplify = !0, p.toTex = function(S) {
    return v.apply(null, S.args);
  };
  var v = r("_derivTex", {
    "Node, SymbolNode": function(b, g) {
      return Jr(b) && Et(b.value) === "string" ? v(n(b.value).toString(), g.toString(), 1) : v(b.toTex(), g.toString(), 1);
    },
    "Node, ConstantNode": function(b, g) {
      if (Et(g.value) === "string")
        return v(b, n(g.value));
      throw new Error("The second parameter to 'derivative' is a non-string constant");
    },
    "Node, SymbolNode, ConstantNode": function(b, g, _) {
      return v(b.toString(), g.name, _.value);
    },
    "string, string, number": function(b, g, _) {
      var A;
      return _ === 1 ? A = "{d\\over d" + g + "}" : A = "{d^{" + _ + "}\\over d" + g + "^{" + _ + "}}", A + "\\left[".concat(b, "\\right]");
    }
  }), h = r("constTag", {
    "Object, ConstantNode, string": function(b, g) {
      return b[g] = !0, !0;
    },
    "Object, SymbolNode, string": function(b, g, _) {
      return g.name !== _ ? (b[g] = !0, !0) : !1;
    },
    "Object, ParenthesisNode, string": function(b, g, _) {
      return h(b, g.content, _);
    },
    "Object, FunctionAssignmentNode, string": function(b, g, _) {
      return g.params.includes(_) ? h(b, g.expr, _) : (b[g] = !0, !0);
    },
    "Object, FunctionNode | OperatorNode, string": function(b, g, _) {
      if (g.args.length > 0) {
        for (var A = h(b, g.args[0], _), M = 1; M < g.args.length; ++M)
          A = h(b, g.args[M], _) && A;
        if (A)
          return b[g] = !0, !0;
      }
      return !1;
    }
  }), y = r("_derivative", {
    "ConstantNode, Object": function(b) {
      return C(0);
    },
    "SymbolNode, Object": function(b, g) {
      return g[b] !== void 0 ? C(0) : C(1);
    },
    "ParenthesisNode, Object": function(b, g) {
      return new f(y(b.content, g));
    },
    "FunctionAssignmentNode, Object": function(b, g) {
      return g[b] !== void 0 ? C(0) : y(b.expr, g);
    },
    "FunctionNode, Object": function(b, g) {
      if (g[b] !== void 0)
        return C(0);
      var _ = b.args[0], A, M = !1, P = !1, T;
      switch (b.name) {
        case "cbrt":
          M = !0, T = new l("*", "multiply", [C(3), new l("^", "pow", [_, new l("/", "divide", [C(2), C(3)])])]);
          break;
        case "sqrt":
        case "nthRoot":
          if (b.args.length === 1)
            M = !0, T = new l("*", "multiply", [C(2), new u("sqrt", [_])]);
          else if (b.args.length === 2)
            return A = new l("/", "divide", [C(1), b.args[1]]), g[A] = g[b.args[1]], y(new l("^", "pow", [_, A]), g);
          break;
        case "log10":
          A = C(10);
        case "log":
          if (!A && b.args.length === 1)
            T = _.clone(), M = !0;
          else if (b.args.length === 1 && A || b.args.length === 2 && g[b.args[1]] !== void 0)
            T = new l("*", "multiply", [_.clone(), new u("log", [A || b.args[1]])]), M = !0;
          else if (b.args.length === 2)
            return y(new l("/", "divide", [new u("log", [_]), new u("log", [b.args[1]])]), g);
          break;
        case "pow":
          if (b.args.length === 2)
            return g[A] = g[b.args[1]], y(new l("^", "pow", [_, b.args[1]]), g);
          break;
        case "exp":
          T = new u("exp", [_.clone()]);
          break;
        case "sin":
          T = new u("cos", [_.clone()]);
          break;
        case "cos":
          T = new l("-", "unaryMinus", [new u("sin", [_.clone()])]);
          break;
        case "tan":
          T = new l("^", "pow", [new u("sec", [_.clone()]), C(2)]);
          break;
        case "sec":
          T = new l("*", "multiply", [b, new u("tan", [_.clone()])]);
          break;
        case "csc":
          P = !0, T = new l("*", "multiply", [b, new u("cot", [_.clone()])]);
          break;
        case "cot":
          P = !0, T = new l("^", "pow", [new u("csc", [_.clone()]), C(2)]);
          break;
        case "asin":
          M = !0, T = new u("sqrt", [new l("-", "subtract", [C(1), new l("^", "pow", [_.clone(), C(2)])])]);
          break;
        case "acos":
          M = !0, P = !0, T = new u("sqrt", [new l("-", "subtract", [C(1), new l("^", "pow", [_.clone(), C(2)])])]);
          break;
        case "atan":
          M = !0, T = new l("+", "add", [new l("^", "pow", [_.clone(), C(2)]), C(1)]);
          break;
        case "asec":
          M = !0, T = new l("*", "multiply", [new u("abs", [_.clone()]), new u("sqrt", [new l("-", "subtract", [new l("^", "pow", [_.clone(), C(2)]), C(1)])])]);
          break;
        case "acsc":
          M = !0, P = !0, T = new l("*", "multiply", [new u("abs", [_.clone()]), new u("sqrt", [new l("-", "subtract", [new l("^", "pow", [_.clone(), C(2)]), C(1)])])]);
          break;
        case "acot":
          M = !0, P = !0, T = new l("+", "add", [new l("^", "pow", [_.clone(), C(2)]), C(1)]);
          break;
        case "sinh":
          T = new u("cosh", [_.clone()]);
          break;
        case "cosh":
          T = new u("sinh", [_.clone()]);
          break;
        case "tanh":
          T = new l("^", "pow", [new u("sech", [_.clone()]), C(2)]);
          break;
        case "sech":
          P = !0, T = new l("*", "multiply", [b, new u("tanh", [_.clone()])]);
          break;
        case "csch":
          P = !0, T = new l("*", "multiply", [b, new u("coth", [_.clone()])]);
          break;
        case "coth":
          P = !0, T = new l("^", "pow", [new u("csch", [_.clone()]), C(2)]);
          break;
        case "asinh":
          M = !0, T = new u("sqrt", [new l("+", "add", [new l("^", "pow", [_.clone(), C(2)]), C(1)])]);
          break;
        case "acosh":
          M = !0, T = new u("sqrt", [new l("-", "subtract", [new l("^", "pow", [_.clone(), C(2)]), C(1)])]);
          break;
        case "atanh":
          M = !0, T = new l("-", "subtract", [C(1), new l("^", "pow", [_.clone(), C(2)])]);
          break;
        case "asech":
          M = !0, P = !0, T = new l("*", "multiply", [_.clone(), new u("sqrt", [new l("-", "subtract", [C(1), new l("^", "pow", [_.clone(), C(2)])])])]);
          break;
        case "acsch":
          M = !0, P = !0, T = new l("*", "multiply", [new u("abs", [_.clone()]), new u("sqrt", [new l("+", "add", [new l("^", "pow", [_.clone(), C(2)]), C(1)])])]);
          break;
        case "acoth":
          M = !0, P = !0, T = new l("-", "subtract", [C(1), new l("^", "pow", [_.clone(), C(2)])]);
          break;
        case "abs":
          T = new l("/", "divide", [new u(new d("abs"), [_.clone()]), _.clone()]);
          break;
        case "gamma":
        default:
          throw new Error('Cannot process function "' + b.name + '" in derivative: the function is not supported, undefined, or the number of arguments passed to it are not supported');
      }
      var x, w;
      M ? (x = "/", w = "divide") : (x = "*", w = "multiply");
      var E = y(_, g);
      return P && (E = new l("-", "unaryMinus", [E])), new l(x, w, [E, T]);
    },
    "OperatorNode, Object": function(b, g) {
      if (g[b] !== void 0)
        return C(0);
      if (b.op === "+")
        return new l(b.op, b.fn, b.args.map(function(B) {
          return y(B, g);
        }));
      if (b.op === "-") {
        if (b.isUnary())
          return new l(b.op, b.fn, [y(b.args[0], g)]);
        if (b.isBinary())
          return new l(b.op, b.fn, [y(b.args[0], g), y(b.args[1], g)]);
      }
      if (b.op === "*") {
        var _ = b.args.filter(function(B) {
          return g[B] !== void 0;
        });
        if (_.length > 0) {
          var A = b.args.filter(function(B) {
            return g[B] === void 0;
          }), M = A.length === 1 ? A[0] : new l("*", "multiply", A), P = _.concat(y(M, g));
          return new l("*", "multiply", P);
        }
        return new l("+", "add", b.args.map(function(B) {
          return new l("*", "multiply", b.args.map(function(D) {
            return D === B ? y(D, g) : D.clone();
          }));
        }));
      }
      if (b.op === "/" && b.isBinary()) {
        var T = b.args[0], x = b.args[1];
        return g[x] !== void 0 ? new l("/", "divide", [y(T, g), x]) : g[T] !== void 0 ? new l("*", "multiply", [new l("-", "unaryMinus", [T]), new l("/", "divide", [y(x, g), new l("^", "pow", [x.clone(), C(2)])])]) : new l("/", "divide", [new l("-", "subtract", [new l("*", "multiply", [y(T, g), x.clone()]), new l("*", "multiply", [T.clone(), y(x, g)])]), new l("^", "pow", [x.clone(), C(2)])]);
      }
      if (b.op === "^" && b.isBinary()) {
        var w = b.args[0], E = b.args[1];
        if (g[w] !== void 0)
          return Jr(w) && (o(w.value) || i(w.value, 1)) ? C(0) : new l("*", "multiply", [b, new l("*", "multiply", [new u("log", [w.clone()]), y(E.clone(), g)])]);
        if (g[E] !== void 0) {
          if (Jr(E)) {
            if (o(E.value))
              return C(0);
            if (i(E.value, 1))
              return y(w, g);
          }
          var I = new l("^", "pow", [w.clone(), new l("-", "subtract", [E, C(1)])]);
          return new l("*", "multiply", [E.clone(), new l("*", "multiply", [y(w, g), I])]);
        }
        return new l("*", "multiply", [new l("^", "pow", [w.clone(), E.clone()]), new l("+", "add", [new l("*", "multiply", [y(w, g), new l("/", "divide", [E.clone(), w.clone()])]), new l("*", "multiply", [y(E, g), new u("log", [w.clone()])])])]);
      }
      throw new Error('Cannot process operator "' + b.op + '" in derivative: the operator is not supported, undefined, or the number of arguments passed to it are not supported');
    }
  });
  function C(S, b) {
    return new s(c(S, rf(String(S), t)));
  }
  return p;
}), Pk = "rationalize", bRe = ["config", "typed", "equal", "isZero", "add", "subtract", "multiply", "divide", "pow", "parse", "simplifyConstant", "simplifyCore", "simplify", "?bignumber", "?fraction", "mathWithTransform", "matrix", "AccessorNode", "ArrayNode", "ConstantNode", "FunctionNode", "IndexNode", "ObjectNode", "OperatorNode", "SymbolNode", "ParenthesisNode"], SRe = /* @__PURE__ */ Ce(Pk, bRe, (e) => {
  var {
    config: r,
    typed: t,
    equal: n,
    isZero: a,
    add: i,
    subtract: o,
    multiply: c,
    divide: s,
    pow: u,
    parse: l,
    simplifyConstant: f,
    simplifyCore: d,
    simplify: m,
    fraction: p,
    bignumber: v,
    mathWithTransform: h,
    matrix: y,
    AccessorNode: C,
    ArrayNode: S,
    ConstantNode: b,
    FunctionNode: g,
    IndexNode: _,
    ObjectNode: A,
    OperatorNode: M,
    SymbolNode: P,
    ParenthesisNode: T
  } = e;
  function x(D) {
    var N = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, O = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1, V = E(), k = w(D, N, !0, V.firstRules), G = k.variables.length, L = {
      exactFractions: !1
    }, R = {
      exactFractions: !0
    };
    if (D = k.expression, G >= 1) {
      D = I(D);
      var F, U, H = !0, q = !1;
      D = m(D, V.firstRules, {}, L);
      for (var K; U = H ? V.distrDivRules : V.sucDivRules, D = m(D, U, {}, R), H = !H, K = D.toString(), K !== F; )
        q = !0, F = K;
      q && (D = m(D, V.firstRulesAgain, {}, L)), D = m(D, V.finalRules, {}, L);
    }
    var Y = [], X = {};
    return D.type === "OperatorNode" && D.isBinary() && D.op === "/" ? (G === 1 && (D.args[0] = B(D.args[0], Y), D.args[1] = B(D.args[1])), O && (X.numerator = D.args[0], X.denominator = D.args[1])) : (G === 1 && (D = B(D, Y)), O && (X.numerator = D, X.denominator = null)), O ? (X.coefficients = Y, X.variables = k.variables, X.expression = D, X) : D;
  }
  return t(Pk, {
    Node: x,
    "Node, boolean": (D, N) => x(D, {}, N),
    "Node, Object": x,
    "Node, Object, boolean": x
  });
  function w(D, N, O, V) {
    var k = [], G = m(D, V, N, {
      exactFractions: !1
    });
    O = !!O;
    var L = "+-*" + (O ? "/" : "");
    F(G);
    var R = {};
    return R.expression = G, R.variables = k, R;
    function F(U) {
      var H = U.type;
      if (H === "FunctionNode")
        throw new Error("There is an unsolved function call");
      if (H === "OperatorNode")
        if (U.op === "^") {
          if (U.args[1].type !== "ConstantNode" || !lr(parseFloat(U.args[1].value)))
            throw new Error("There is a non-integer exponent");
          F(U.args[0]);
        } else {
          if (!L.includes(U.op))
            throw new Error("Operator " + U.op + " invalid in polynomial expression");
          for (var q = 0; q < U.args.length; q++)
            F(U.args[q]);
        }
      else if (H === "SymbolNode") {
        var K = U.name, Y = k.indexOf(K);
        Y === -1 && k.push(K);
      } else if (H === "ParenthesisNode")
        F(U.content);
      else if (H !== "ConstantNode")
        throw new Error("type " + H + " is not allowed in polynomial expression");
    }
  }
  function E() {
    var D = [
      d,
      // sCore
      {
        l: "n+n",
        r: "2*n"
      },
      {
        l: "n+-n",
        r: "0"
      },
      f,
      // sConstant
      {
        l: "n*(n1^-1)",
        r: "n/n1"
      },
      {
        l: "n*n1^-n2",
        r: "n/n1^n2"
      },
      {
        l: "n1^-1",
        r: "1/n1"
      },
      {
        l: "n*(n1/n2)",
        r: "(n*n1)/n2"
      },
      {
        l: "1*n",
        r: "n"
      }
    ], N = [
      {
        l: "(-n1)/(-n2)",
        r: "n1/n2"
      },
      // Unary division
      {
        l: "(-n1)*(-n2)",
        r: "n1*n2"
      },
      // Unary multiplication
      {
        l: "n1--n2",
        r: "n1+n2"
      },
      // '--' elimination
      {
        l: "n1-n2",
        r: "n1+(-n2)"
      },
      // Subtraction turn into add with un�ry minus
      {
        l: "(n1+n2)*n3",
        r: "(n1*n3 + n2*n3)"
      },
      // Distributive 1
      {
        l: "n1*(n2+n3)",
        r: "(n1*n2+n1*n3)"
      },
      // Distributive 2
      {
        l: "c1*n + c2*n",
        r: "(c1+c2)*n"
      },
      // Joining constants
      {
        l: "c1*n + n",
        r: "(c1+1)*n"
      },
      // Joining constants
      {
        l: "c1*n - c2*n",
        r: "(c1-c2)*n"
      },
      // Joining constants
      {
        l: "c1*n - n",
        r: "(c1-1)*n"
      },
      // Joining constants
      {
        l: "v/c",
        r: "(1/c)*v"
      },
      // variable/constant (new!)
      {
        l: "v/-c",
        r: "-(1/c)*v"
      },
      // variable/constant (new!)
      {
        l: "-v*-c",
        r: "c*v"
      },
      // Inversion constant and variable 1
      {
        l: "-v*c",
        r: "-c*v"
      },
      // Inversion constant and variable 2
      {
        l: "v*-c",
        r: "-c*v"
      },
      // Inversion constant and variable 3
      {
        l: "v*c",
        r: "c*v"
      },
      // Inversion constant and variable 4
      {
        l: "-(-n1*n2)",
        r: "(n1*n2)"
      },
      // Unary propagation
      {
        l: "-(n1*n2)",
        r: "(-n1*n2)"
      },
      // Unary propagation
      {
        l: "-(-n1+n2)",
        r: "(n1-n2)"
      },
      // Unary propagation
      {
        l: "-(n1+n2)",
        r: "(-n1-n2)"
      },
      // Unary propagation
      {
        l: "(n1^n2)^n3",
        r: "(n1^(n2*n3))"
      },
      // Power to Power
      {
        l: "-(-n1/n2)",
        r: "(n1/n2)"
      },
      // Division and Unary
      {
        l: "-(n1/n2)",
        r: "(-n1/n2)"
      }
    ], O = [
      {
        l: "(n1/n2 + n3/n4)",
        r: "((n1*n4 + n3*n2)/(n2*n4))"
      },
      // Sum of fractions
      {
        l: "(n1/n2 + n3)",
        r: "((n1 + n3*n2)/n2)"
      },
      // Sum fraction with number 1
      {
        l: "(n1 + n2/n3)",
        r: "((n1*n3 + n2)/n3)"
      }
    ], V = [
      {
        l: "(n1/(n2/n3))",
        r: "((n1*n3)/n2)"
      },
      // Division simplification
      {
        l: "(n1/n2/n3)",
        r: "(n1/(n2*n3))"
      }
    ], k = {};
    return k.firstRules = D.concat(N, V), k.distrDivRules = O, k.sucDivRules = V, k.firstRulesAgain = D.concat(N), k.finalRules = [
      d,
      // simplify.rules[0]
      {
        l: "n*-n",
        r: "-n^2"
      },
      // Joining multiply with power 1
      {
        l: "n*n",
        r: "n^2"
      },
      // Joining multiply with power 2
      f,
      // simplify.rules[14] old 3rd index in oldRules
      {
        l: "n*-n^n1",
        r: "-n^(n1+1)"
      },
      // Joining multiply with power 3
      {
        l: "n*n^n1",
        r: "n^(n1+1)"
      },
      // Joining multiply with power 4
      {
        l: "n^n1*-n^n2",
        r: "-n^(n1+n2)"
      },
      // Joining multiply with power 5
      {
        l: "n^n1*n^n2",
        r: "n^(n1+n2)"
      },
      // Joining multiply with power 6
      {
        l: "n^n1*-n",
        r: "-n^(n1+1)"
      },
      // Joining multiply with power 7
      {
        l: "n^n1*n",
        r: "n^(n1+1)"
      },
      // Joining multiply with power 8
      {
        l: "n^n1/-n",
        r: "-n^(n1-1)"
      },
      // Joining multiply with power 8
      {
        l: "n^n1/n",
        r: "n^(n1-1)"
      },
      // Joining division with power 1
      {
        l: "n/-n^n1",
        r: "-n^(1-n1)"
      },
      // Joining division with power 2
      {
        l: "n/n^n1",
        r: "n^(1-n1)"
      },
      // Joining division with power 3
      {
        l: "n^n1/-n^n2",
        r: "n^(n1-n2)"
      },
      // Joining division with power 4
      {
        l: "n^n1/n^n2",
        r: "n^(n1-n2)"
      },
      // Joining division with power 5
      {
        l: "n1+(-n2*n3)",
        r: "n1-n2*n3"
      },
      // Solving useless parenthesis 1
      {
        l: "v*(-c)",
        r: "-c*v"
      },
      // Solving useless unary 2
      {
        l: "n1+-n2",
        r: "n1-n2"
      },
      // Solving +- together (new!)
      {
        l: "v*c",
        r: "c*v"
      },
      // inversion constant with variable
      {
        l: "(n1^n2)^n3",
        r: "(n1^(n2*n3))"
      }
      // Power to Power
    ], k;
  }
  function I(D, N, O) {
    var V = D.type, k = arguments.length > 1;
    if (V === "OperatorNode" && D.isBinary()) {
      var G = !1, L;
      if (D.op === "^" && (D.args[0].type === "ParenthesisNode" || D.args[0].type === "OperatorNode") && D.args[1].type === "ConstantNode" && (L = parseFloat(D.args[1].value), G = L >= 2 && lr(L)), G) {
        if (L > 2) {
          var R = D.args[0], F = new M("^", "pow", [D.args[0].cloneDeep(), new b(L - 1)]);
          D = new M("*", "multiply", [R, F]);
        } else
          D = new M("*", "multiply", [D.args[0], D.args[0].cloneDeep()]);
        k && (O === "content" ? N.content = D : N.args[O] = D);
      }
    }
    if (V === "ParenthesisNode")
      I(D.content, D, "content");
    else if (V !== "ConstantNode" && V !== "SymbolNode")
      for (var U = 0; U < D.args.length; U++)
        I(D.args[U], D, U);
    if (!k)
      return D;
  }
  function B(D, N) {
    N === void 0 && (N = []), N[0] = 0;
    var O = {};
    O.cte = 1, O.oper = "+", O.fire = "";
    var V = 0, k = "";
    K(D, null, O), V = N.length - 1;
    for (var G = !0, L, R = V; R >= 0; R--)
      if (N[R] !== 0) {
        var F = new b(G ? N[R] : Math.abs(N[R])), U = N[R] < 0 ? "-" : "+";
        if (R > 0) {
          var H = new P(k);
          if (R > 1) {
            var q = new b(R);
            H = new M("^", "pow", [H, q]);
          }
          N[R] === -1 && G ? F = new M("-", "unaryMinus", [H]) : Math.abs(N[R]) === 1 ? F = H : F = new M("*", "multiply", [F, H]);
        }
        G ? L = F : U === "+" ? L = new M("+", "add", [L, F]) : L = new M("-", "subtract", [L, F]), G = !1;
      }
    if (G)
      return new b(0);
    return L;
    function K(Y, X, Z) {
      var J = Y.type;
      if (J === "FunctionNode")
        throw new Error("There is an unsolved function call");
      if (J === "OperatorNode") {
        if (!"+-*^".includes(Y.op)) throw new Error("Operator " + Y.op + " invalid");
        if (X !== null) {
          if ((Y.fn === "unaryMinus" || Y.fn === "pow") && X.fn !== "add" && X.fn !== "subtract" && X.fn !== "multiply")
            throw new Error("Invalid " + Y.op + " placing");
          if ((Y.fn === "subtract" || Y.fn === "add" || Y.fn === "multiply") && X.fn !== "add" && X.fn !== "subtract")
            throw new Error("Invalid " + Y.op + " placing");
          if ((Y.fn === "subtract" || Y.fn === "add" || Y.fn === "unaryMinus") && Z.noFil !== 0)
            throw new Error("Invalid " + Y.op + " placing");
        }
        (Y.op === "^" || Y.op === "*") && (Z.fire = Y.op);
        for (var $ = 0; $ < Y.args.length; $++)
          Y.fn === "unaryMinus" && (Z.oper = "-"), (Y.op === "+" || Y.fn === "subtract") && (Z.fire = "", Z.cte = 1, Z.oper = $ === 0 ? "+" : Y.op), Z.noFil = $, K(Y.args[$], Y, Z);
      } else if (J === "SymbolNode") {
        if (Y.name !== k && k !== "")
          throw new Error("There is more than one variable");
        if (k = Y.name, X === null) {
          N[1] = 1;
          return;
        }
        if (X.op === "^" && Z.noFil !== 0)
          throw new Error("In power the variable should be the first parameter");
        if (X.op === "*" && Z.noFil !== 1)
          throw new Error("In multiply the variable should be the second parameter");
        (Z.fire === "" || Z.fire === "*") && (V < 1 && (N[1] = 0), N[1] += Z.cte * (Z.oper === "+" ? 1 : -1), V = Math.max(1, V));
      } else if (J === "ConstantNode") {
        var Q = parseFloat(Y.value);
        if (X === null) {
          N[0] = Q;
          return;
        }
        if (X.op === "^") {
          if (Z.noFil !== 1) throw new Error("Constant cannot be powered");
          if (!lr(Q) || Q <= 0)
            throw new Error("Non-integer exponent is not allowed");
          for (var W = V + 1; W < Q; W++) N[W] = 0;
          Q > V && (N[Q] = 0), N[Q] += Z.cte * (Z.oper === "+" ? 1 : -1), V = Math.max(Q, V);
          return;
        }
        Z.cte = Q, Z.fire === "" && (N[0] += Z.cte * (Z.oper === "+" ? 1 : -1));
      } else
        throw new Error("Type " + J + " is not allowed");
    }
  }
}), Mk = "zpk2tf", CRe = ["typed", "add", "multiply", "Complex", "number"], ARe = /* @__PURE__ */ Ce(Mk, CRe, (e) => {
  var {
    typed: r,
    add: t,
    multiply: n,
    Complex: a,
    number: i
  } = e;
  return r(Mk, {
    "Array,Array,number": function(u, l, f) {
      return o(u, l, f);
    },
    "Array,Array": function(u, l) {
      return o(u, l, 1);
    },
    "Matrix,Matrix,number": function(u, l, f) {
      return o(u.valueOf(), l.valueOf(), f);
    },
    "Matrix,Matrix": function(u, l) {
      return o(u.valueOf(), l.valueOf(), 1);
    }
  });
  function o(s, u, l) {
    s.some((C) => C.type === "BigNumber") && (s = s.map((C) => i(C))), u.some((C) => C.type === "BigNumber") && (u = u.map((C) => i(C)));
    for (var f = [a(1, 0)], d = [a(1, 0)], m = 0; m < s.length; m++) {
      var p = s[m];
      typeof p == "number" && (p = a(p, 0)), f = c(f, [a(1, 0), a(-p.re, -p.im)]);
    }
    for (var v = 0; v < u.length; v++) {
      var h = u[v];
      typeof h == "number" && (h = a(h, 0)), d = c(d, [a(1, 0), a(-h.re, -h.im)]);
    }
    for (var y = 0; y < f.length; y++)
      f[y] = n(f[y], l);
    return [f, d];
  }
  function c(s, u) {
    for (var l = [], f = 0; f < s.length + u.length - 1; f++) {
      l[f] = a(0, 0);
      for (var d = 0; d < s.length; d++)
        f - d >= 0 && f - d < u.length && (l[f] = t(l[f], n(s[d], u[f - d])));
    }
    return l;
  }
}), wk = "freqz", xRe = ["typed", "add", "multiply", "Complex", "divide", "matrix"], TRe = /* @__PURE__ */ Ce(wk, xRe, (e) => {
  var {
    typed: r,
    add: t,
    multiply: n,
    Complex: a,
    divide: i,
    matrix: o
  } = e;
  return r(wk, {
    "Array, Array": function(l, f) {
      var d = s(512);
      return c(l, f, d);
    },
    "Array, Array, Array": function(l, f, d) {
      return c(l, f, d);
    },
    "Array, Array, number": function(l, f, d) {
      if (d < 0)
        throw new Error("w must be a positive number");
      var m = s(d);
      return c(l, f, m);
    },
    "Matrix, Matrix": function(l, f) {
      var d = s(512), {
        w: m,
        h: p
      } = c(l.valueOf(), f.valueOf(), d);
      return {
        w: o(m),
        h: o(p)
      };
    },
    "Matrix, Matrix, Matrix": function(l, f, d) {
      var {
        h: m
      } = c(l.valueOf(), f.valueOf(), d.valueOf());
      return {
        h: o(m),
        w: o(d)
      };
    },
    "Matrix, Matrix, number": function(l, f, d) {
      if (d < 0)
        throw new Error("w must be a positive number");
      var m = s(d), {
        h: p
      } = c(l.valueOf(), f.valueOf(), m);
      return {
        h: o(p),
        w: o(m)
      };
    }
  });
  function c(u, l, f) {
    for (var d = [], m = [], p = 0; p < f.length; p++) {
      for (var v = a(0, 0), h = a(0, 0), y = 0; y < u.length; y++)
        v = t(v, n(u[y], a(Math.cos(-y * f[p]), Math.sin(-y * f[p]))));
      for (var C = 0; C < l.length; C++)
        h = t(h, n(l[C], a(Math.cos(-C * f[p]), Math.sin(-C * f[p]))));
      d.push(v), m.push(h);
    }
    for (var S = [], b = 0; b < d.length; b++)
      S.push(i(d[b], m[b]));
    return {
      h: S,
      w: f
    };
  }
  function s(u) {
    for (var l = [], f = 0; f < u; f++)
      l.push(f / u * Math.PI);
    return l;
  }
}), PRe = "reviver", MRe = ["classes"], wRe = /* @__PURE__ */ Ce(PRe, MRe, (e) => {
  var {
    classes: r
  } = e;
  return function(n, a) {
    var i = r[a && a.mathjs];
    return i && typeof i.fromJSON == "function" ? i.fromJSON(a) : a;
  };
}), ERe = "replacer", DRe = [], IRe = /* @__PURE__ */ Ce(ERe, DRe, () => function(r, t) {
  return typeof t == "number" && (!isFinite(t) || isNaN(t)) ? {
    mathjs: "number",
    value: String(t)
  } : typeof t == "bigint" ? {
    mathjs: "bigint",
    value: String(t)
  } : t;
}), BRe = "13.0.1", NRe = /* @__PURE__ */ Ce("true", [], () => !0), VRe = /* @__PURE__ */ Ce("false", [], () => !1), RRe = /* @__PURE__ */ Ce("null", [], () => null), ORe = /* @__PURE__ */ tu("Infinity", ["config", "?BigNumber"], (e) => {
  var {
    config: r,
    BigNumber: t
  } = e;
  return r.number === "BigNumber" ? new t(1 / 0) : 1 / 0;
}), FRe = /* @__PURE__ */ tu("NaN", ["config", "?BigNumber"], (e) => {
  var {
    config: r,
    BigNumber: t
  } = e;
  return r.number === "BigNumber" ? new t(NaN) : NaN;
}), MY = /* @__PURE__ */ tu("pi", ["config", "?BigNumber"], (e) => {
  var {
    config: r,
    BigNumber: t
  } = e;
  return r.number === "BigNumber" ? LD(t) : Xxe;
}), LRe = /* @__PURE__ */ tu("tau", ["config", "?BigNumber"], (e) => {
  var {
    config: r,
    BigNumber: t
  } = e;
  return r.number === "BigNumber" ? EEe(t) : Yxe;
}), kRe = /* @__PURE__ */ tu("e", ["config", "?BigNumber"], (e) => {
  var {
    config: r,
    BigNumber: t
  } = e;
  return r.number === "BigNumber" ? MEe(t) : Qxe;
}), URe = /* @__PURE__ */ tu("phi", ["config", "?BigNumber"], (e) => {
  var {
    config: r,
    BigNumber: t
  } = e;
  return r.number === "BigNumber" ? wEe(t) : Zxe;
}), zRe = /* @__PURE__ */ tu("LN2", ["config", "?BigNumber"], (e) => {
  var {
    config: r,
    BigNumber: t
  } = e;
  return r.number === "BigNumber" ? new t(2).ln() : Math.LN2;
}), GRe = /* @__PURE__ */ tu("LN10", ["config", "?BigNumber"], (e) => {
  var {
    config: r,
    BigNumber: t
  } = e;
  return r.number === "BigNumber" ? new t(10).ln() : Math.LN10;
}), qRe = /* @__PURE__ */ tu("LOG2E", ["config", "?BigNumber"], (e) => {
  var {
    config: r,
    BigNumber: t
  } = e;
  return r.number === "BigNumber" ? new t(1).div(new t(2).ln()) : Math.LOG2E;
}), HRe = /* @__PURE__ */ tu("LOG10E", ["config", "?BigNumber"], (e) => {
  var {
    config: r,
    BigNumber: t
  } = e;
  return r.number === "BigNumber" ? new t(1).div(new t(10).ln()) : Math.LOG10E;
}), jRe = /* @__PURE__ */ tu(
  // eslint-disable-line camelcase
  "SQRT1_2",
  ["config", "?BigNumber"],
  (e) => {
    var {
      config: r,
      BigNumber: t
    } = e;
    return r.number === "BigNumber" ? new t("0.5").sqrt() : Math.SQRT1_2;
  }
), $Re = /* @__PURE__ */ tu("SQRT2", ["config", "?BigNumber"], (e) => {
  var {
    config: r,
    BigNumber: t
  } = e;
  return r.number === "BigNumber" ? new t(2).sqrt() : Math.SQRT2;
}), KRe = /* @__PURE__ */ tu("i", ["Complex"], (e) => {
  var {
    Complex: r
  } = e;
  return r.I;
}), WRe = /* @__PURE__ */ Ce("PI", ["pi"], (e) => {
  var {
    pi: r
  } = e;
  return r;
}), XRe = /* @__PURE__ */ Ce("E", ["e"], (e) => {
  var {
    e: r
  } = e;
  return r;
}), YRe = /* @__PURE__ */ Ce("version", [], () => BRe);
function tu(e, r, t) {
  return Ce(e, r, t, {
    recreateOnConfigChange: !0
  });
}
var QRe = /* @__PURE__ */ Nr("speedOfLight", "299792458", "m s^-1"), ZRe = /* @__PURE__ */ Nr("gravitationConstant", "6.67430e-11", "m^3 kg^-1 s^-2"), JRe = /* @__PURE__ */ Nr("planckConstant", "6.62607015e-34", "J s"), eOe = /* @__PURE__ */ Nr("reducedPlanckConstant", "1.0545718176461565e-34", "J s"), rOe = /* @__PURE__ */ Nr("magneticConstant", "1.25663706212e-6", "N A^-2"), tOe = /* @__PURE__ */ Nr("electricConstant", "8.8541878128e-12", "F m^-1"), nOe = /* @__PURE__ */ Nr("vacuumImpedance", "376.730313667", "ohm"), aOe = /* @__PURE__ */ Nr("coulomb", "8.987551792261171e9", "N m^2 C^-2"), iOe = /* @__PURE__ */ Nr("elementaryCharge", "1.602176634e-19", "C"), oOe = /* @__PURE__ */ Nr("bohrMagneton", "9.2740100783e-24", "J T^-1"), uOe = /* @__PURE__ */ Nr("conductanceQuantum", "7.748091729863649e-5", "S"), sOe = /* @__PURE__ */ Nr("inverseConductanceQuantum", "12906.403729652257", "ohm"), lOe = /* @__PURE__ */ Nr("magneticFluxQuantum", "2.0678338484619295e-15", "Wb"), cOe = /* @__PURE__ */ Nr("nuclearMagneton", "5.0507837461e-27", "J T^-1"), dOe = /* @__PURE__ */ Nr("klitzing", "25812.807459304513", "ohm"), fOe = /* @__PURE__ */ Nr("bohrRadius", "5.29177210903e-11", "m"), mOe = /* @__PURE__ */ Nr("classicalElectronRadius", "2.8179403262e-15", "m"), vOe = /* @__PURE__ */ Nr("electronMass", "9.1093837015e-31", "kg"), pOe = /* @__PURE__ */ Nr("fermiCoupling", "1.1663787e-5", "GeV^-2"), hOe = fx("fineStructure", 0.0072973525693), gOe = /* @__PURE__ */ Nr("hartreeEnergy", "4.3597447222071e-18", "J"), yOe = /* @__PURE__ */ Nr("protonMass", "1.67262192369e-27", "kg"), _Oe = /* @__PURE__ */ Nr("deuteronMass", "3.3435830926e-27", "kg"), bOe = /* @__PURE__ */ Nr("neutronMass", "1.6749271613e-27", "kg"), SOe = /* @__PURE__ */ Nr("quantumOfCirculation", "3.6369475516e-4", "m^2 s^-1"), COe = /* @__PURE__ */ Nr("rydberg", "10973731.568160", "m^-1"), AOe = /* @__PURE__ */ Nr("thomsonCrossSection", "6.6524587321e-29", "m^2"), xOe = fx("weakMixingAngle", 0.2229), TOe = fx("efimovFactor", 22.7), POe = /* @__PURE__ */ Nr("atomicMass", "1.66053906660e-27", "kg"), MOe = /* @__PURE__ */ Nr("avogadro", "6.02214076e23", "mol^-1"), wOe = /* @__PURE__ */ Nr("boltzmann", "1.380649e-23", "J K^-1"), EOe = /* @__PURE__ */ Nr("faraday", "96485.33212331001", "C mol^-1"), DOe = /* @__PURE__ */ Nr("firstRadiation", "3.7417718521927573e-16", "W m^2"), IOe = /* @__PURE__ */ Nr("loschmidt", "2.686780111798444e25", "m^-3"), BOe = /* @__PURE__ */ Nr("gasConstant", "8.31446261815324", "J K^-1 mol^-1"), NOe = /* @__PURE__ */ Nr("molarPlanckConstant", "3.990312712893431e-10", "J s mol^-1"), VOe = /* @__PURE__ */ Nr("molarVolume", "0.022413969545014137", "m^3 mol^-1"), ROe = fx("sackurTetrode", -1.16487052358), OOe = /* @__PURE__ */ Nr("secondRadiation", "0.014387768775039337", "m K"), FOe = /* @__PURE__ */ Nr("stefanBoltzmann", "5.67037441918443e-8", "W m^-2 K^-4"), LOe = /* @__PURE__ */ Nr("wienDisplacement", "2.897771955e-3", "m K"), kOe = /* @__PURE__ */ Nr("molarMass", "0.99999999965e-3", "kg mol^-1"), UOe = /* @__PURE__ */ Nr("molarMassC12", "11.9999999958e-3", "kg mol^-1"), zOe = /* @__PURE__ */ Nr("gravity", "9.80665", "m s^-2"), GOe = /* @__PURE__ */ Nr("planckLength", "1.616255e-35", "m"), qOe = /* @__PURE__ */ Nr("planckMass", "2.176435e-8", "kg"), HOe = /* @__PURE__ */ Nr("planckTime", "5.391245e-44", "s"), jOe = /* @__PURE__ */ Nr("planckCharge", "1.87554603778e-18", "C"), $Oe = /* @__PURE__ */ Nr("planckTemperature", "1.416785e+32", "K");
function Nr(e, r, t) {
  var n = ["config", "Unit", "BigNumber"];
  return Ce(e, n, (a) => {
    var {
      config: i,
      Unit: o,
      BigNumber: c
    } = a, s = i.number === "BigNumber" ? new c(r) : parseFloat(r), u = new o(s, t);
    return u.fixPrefix = !0, u;
  });
}
function fx(e, r) {
  var t = ["config", "BigNumber"];
  return Ce(e, t, (n) => {
    var {
      config: a,
      BigNumber: i
    } = n;
    return a.number === "BigNumber" ? new i(r) : r;
  });
}
var KOe = "apply", WOe = ["typed", "isInteger"], XOe = /* @__PURE__ */ Ce(KOe, WOe, (e) => {
  var {
    typed: r,
    isInteger: t
  } = e, n = ED({
    typed: r,
    isInteger: t
  });
  return r("apply", {
    "...any": function(i) {
      var o = i[1];
      Or(o) ? i[1] = o - 1 : Ir(o) && (i[1] = o.minus(1));
      try {
        return n.apply(null, i);
      } catch (c) {
        throw Ji(c);
      }
    }
  });
}, {
  isTransformFunction: !0
}), YOe = "column", QOe = ["typed", "Index", "matrix", "range"], ZOe = /* @__PURE__ */ Ce(YOe, QOe, (e) => {
  var {
    typed: r,
    Index: t,
    matrix: n,
    range: a
  } = e, i = ND({
    typed: r,
    Index: t,
    matrix: n,
    range: a
  });
  return r("column", {
    "...any": function(c) {
      var s = c.length - 1, u = c[s];
      Or(u) && (c[s] = u - 1);
      try {
        return i.apply(null, c);
      } catch (l) {
        throw Ji(l);
      }
    }
  });
}, {
  isTransformFunction: !0
});
function KD(e, r, t) {
  var n = e.filter(function(s) {
    return _a(s) && !(s.name in r) && !t.has(s.name);
  })[0];
  if (!n)
    throw new Error('No undefined variable found in inline expression "' + e + '"');
  var a = n.name, i = /* @__PURE__ */ new Map(), o = new xK(t, i, /* @__PURE__ */ new Set([a])), c = e.compile();
  return function(u) {
    return i.set(a, u), c.evaluate(o);
  };
}
var JOe = "filter", eFe = ["typed"], rFe = /* @__PURE__ */ Ce(JOe, eFe, (e) => {
  var {
    typed: r
  } = e;
  function t(a, i, o) {
    var c, s;
    return a[0] && (c = a[0].compile().evaluate(o)), a[1] && (_a(a[1]) || Kp(a[1]) ? s = a[1].compile().evaluate(o) : s = KD(a[1], i, o)), n(c, s);
  }
  t.rawArgs = !0;
  var n = r("filter", {
    "Array, function": Ek,
    "Matrix, function": function(i, o) {
      return i.create(Ek(i.toArray(), o));
    },
    "Array, RegExp": b3,
    "Matrix, RegExp": function(i, o) {
      return i.create(b3(i.toArray(), o));
    }
  });
  return t;
}, {
  isTransformFunction: !0
});
function Ek(e, r) {
  return QK(e, function(t, n, a) {
    return Zp(r, t, [n + 1], a, "filter");
  });
}
var tFe = "forEach", nFe = ["typed"], aFe = /* @__PURE__ */ Ce(tFe, nFe, (e) => {
  var {
    typed: r
  } = e;
  function t(a, i, o) {
    var c, s;
    return a[0] && (c = a[0].compile().evaluate(o)), a[1] && (_a(a[1]) || Kp(a[1]) ? s = a[1].compile().evaluate(o) : s = KD(a[1], i, o)), n(c, s);
  }
  t.rawArgs = !0;
  var n = r("forEach", {
    "Array | Matrix, function": function(i, o) {
      var c = function s(u, l) {
        if (Array.isArray(u))
          ux(u, function(f, d) {
            s(f, l.concat(d + 1));
          });
        else
          return Zp(o, u, l, i, "forEach");
      };
      c(i.valueOf(), []);
    }
  });
  return t;
}, {
  isTransformFunction: !0
}), iFe = "index", oFe = ["Index", "getMatrixDataType"], uFe = /* @__PURE__ */ Ce(iFe, oFe, (e) => {
  var {
    Index: r,
    getMatrixDataType: t
  } = e;
  return function() {
    for (var a = [], i = 0, o = arguments.length; i < o; i++) {
      var c = arguments[i];
      if (rx(c))
        c.start--, c.end -= c.step > 0 ? 0 : 2;
      else if (c && c.isSet === !0)
        c = c.map(function(u) {
          return u - 1;
        });
      else if (dt(c) || gr(c))
        t(c) !== "boolean" && (c = c.map(function(u) {
          return u - 1;
        }));
      else if (Or(c))
        c--;
      else if (Ir(c))
        c = c.toNumber() - 1;
      else if (typeof c != "string") throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");
      a[i] = c;
    }
    var s = new r();
    return r.apply(s, a), s;
  };
}, {
  isTransformFunction: !0
}), sFe = "map", lFe = ["typed"], cFe = /* @__PURE__ */ Ce(sFe, lFe, (e) => {
  var {
    typed: r
  } = e;
  function t(a, i, o) {
    var c, s;
    return a[0] && (c = a[0].compile().evaluate(o)), a[1] && (_a(a[1]) || Kp(a[1]) ? s = a[1].compile().evaluate(o) : s = KD(a[1], i, o)), n(c, s);
  }
  t.rawArgs = !0;
  var n = r("map", {
    "Array, function": function(i, o) {
      return Dk(i, o, i);
    },
    "Matrix, function": function(i, o) {
      return i.create(Dk(i.valueOf(), o, i));
    }
  });
  return t;
}, {
  isTransformFunction: !0
});
function Dk(e, r, t) {
  function n(a, i) {
    return Array.isArray(a) ? lc(a, function(o, c) {
      return n(o, i.concat(c + 1));
    }) : Zp(r, a, i, t, "map");
  }
  return n(e, []);
}
function af(e) {
  if (e.length === 2 && Xo(e[0])) {
    e = e.slice();
    var r = e[1];
    Or(r) ? e[1] = r - 1 : Ir(r) && (e[1] = r.minus(1));
  }
  return e;
}
var dFe = "max", fFe = ["typed", "config", "numeric", "larger"], mFe = /* @__PURE__ */ Ce(dFe, fFe, (e) => {
  var {
    typed: r,
    config: t,
    numeric: n,
    larger: a
  } = e, i = JX({
    typed: r,
    config: t,
    numeric: n,
    larger: a
  });
  return r("max", {
    "...any": function(c) {
      c = af(c);
      try {
        return i.apply(null, c);
      } catch (s) {
        throw Ji(s);
      }
    }
  });
}, {
  isTransformFunction: !0
}), vFe = "mean", pFe = ["typed", "add", "divide"], hFe = /* @__PURE__ */ Ce(vFe, pFe, (e) => {
  var {
    typed: r,
    add: t,
    divide: n
  } = e, a = SY({
    typed: r,
    add: t,
    divide: n
  });
  return r("mean", {
    "...any": function(o) {
      o = af(o);
      try {
        return a.apply(null, o);
      } catch (c) {
        throw Ji(c);
      }
    }
  });
}, {
  isTransformFunction: !0
}), gFe = "min", yFe = ["typed", "config", "numeric", "smaller"], _Fe = /* @__PURE__ */ Ce(gFe, yFe, (e) => {
  var {
    typed: r,
    config: t,
    numeric: n,
    smaller: a
  } = e, i = eY({
    typed: r,
    config: t,
    numeric: n,
    smaller: a
  });
  return r("min", {
    "...any": function(c) {
      c = af(c);
      try {
        return i.apply(null, c);
      } catch (s) {
        throw Ji(s);
      }
    }
  });
}, {
  isTransformFunction: !0
}), bFe = "range", SFe = ["typed", "config", "?matrix", "?bignumber", "smaller", "smallerEq", "larger", "largerEq", "add", "isPositive"], CFe = /* @__PURE__ */ Ce(bFe, SFe, (e) => {
  var {
    typed: r,
    config: t,
    matrix: n,
    bignumber: a,
    smaller: i,
    smallerEq: o,
    larger: c,
    largerEq: s,
    add: u,
    isPositive: l
  } = e, f = RD({
    typed: r,
    config: t,
    matrix: n,
    bignumber: a,
    smaller: i,
    smallerEq: o,
    larger: c,
    largerEq: s,
    add: u,
    isPositive: l
  });
  return r("range", {
    "...any": function(m) {
      var p = m.length - 1, v = m[p];
      return typeof v != "boolean" && m.push(!0), f.apply(null, m);
    }
  });
}, {
  isTransformFunction: !0
}), AFe = "row", xFe = ["typed", "Index", "matrix", "range"], TFe = /* @__PURE__ */ Ce(AFe, xFe, (e) => {
  var {
    typed: r,
    Index: t,
    matrix: n,
    range: a
  } = e, i = VX({
    typed: r,
    Index: t,
    matrix: n,
    range: a
  });
  return r("row", {
    "...any": function(c) {
      var s = c.length - 1, u = c[s];
      Or(u) && (c[s] = u - 1);
      try {
        return i.apply(null, c);
      } catch (l) {
        throw Ji(l);
      }
    }
  });
}, {
  isTransformFunction: !0
}), PFe = "subset", MFe = ["typed", "matrix", "zeros", "add"], wFe = /* @__PURE__ */ Ce(PFe, MFe, (e) => {
  var {
    typed: r,
    matrix: t,
    zeros: n,
    add: a
  } = e, i = OX({
    typed: r,
    matrix: t,
    zeros: n,
    add: a
  });
  return r("subset", {
    "...any": function(c) {
      try {
        return i.apply(null, c);
      } catch (s) {
        throw Ji(s);
      }
    }
  });
}, {
  isTransformFunction: !0
}), EFe = "concat", DFe = ["typed", "matrix", "isInteger"], IFe = /* @__PURE__ */ Ce(EFe, DFe, (e) => {
  var {
    typed: r,
    matrix: t,
    isInteger: n
  } = e, a = BD({
    typed: r,
    matrix: t,
    isInteger: n
  });
  return r("concat", {
    "...any": function(o) {
      var c = o.length - 1, s = o[c];
      Or(s) ? o[c] = s - 1 : Ir(s) && (o[c] = s.minus(1));
      try {
        return a.apply(null, o);
      } catch (u) {
        throw Ji(u);
      }
    }
  });
}, {
  isTransformFunction: !0
}), Ik = "diff", BFe = ["typed", "matrix", "subtract", "number", "bignumber"], NFe = /* @__PURE__ */ Ce(Ik, BFe, (e) => {
  var {
    typed: r,
    matrix: t,
    subtract: n,
    number: a,
    bignumber: i
  } = e, o = DX({
    typed: r,
    matrix: t,
    subtract: n,
    number: a,
    bignumber: i
  });
  return r(Ik, {
    "...any": function(s) {
      s = af(s);
      try {
        return o.apply(null, s);
      } catch (u) {
        throw Ji(u);
      }
    }
  });
}, {
  isTransformFunction: !0
}), VFe = "std", RFe = ["typed", "map", "sqrt", "variance"], OFe = /* @__PURE__ */ Ce(VFe, RFe, (e) => {
  var {
    typed: r,
    map: t,
    sqrt: n,
    variance: a
  } = e, i = xY({
    typed: r,
    map: t,
    sqrt: n,
    variance: a
  });
  return r("std", {
    "...any": function(c) {
      c = af(c);
      try {
        return i.apply(null, c);
      } catch (s) {
        throw Ji(s);
      }
    }
  });
}, {
  isTransformFunction: !0
}), Bk = "sum", FFe = ["typed", "config", "add", "numeric"], LFe = /* @__PURE__ */ Ce(Bk, FFe, (e) => {
  var {
    typed: r,
    config: t,
    add: n,
    numeric: a
  } = e, i = _Y({
    typed: r,
    config: t,
    add: n,
    numeric: a
  });
  return r(Bk, {
    "...any": function(c) {
      c = af(c);
      try {
        return i.apply(null, c);
      } catch (s) {
        throw Ji(s);
      }
    }
  });
}, {
  isTransformFunction: !0
}), kFe = "quantileSeq", UFe = ["typed", "bignumber", "add", "subtract", "divide", "multiply", "partitionSelect", "compare", "isInteger", "smaller", "smallerEq", "larger"], zFe = /* @__PURE__ */ Ce(kFe, UFe, (e) => {
  var {
    typed: r,
    bignumber: t,
    add: n,
    subtract: a,
    divide: i,
    multiply: o,
    partitionSelect: c,
    compare: s,
    isInteger: u,
    smaller: l,
    smallerEq: f,
    larger: d
  } = e, m = AY({
    typed: r,
    bignumber: t,
    add: n,
    subtract: a,
    divide: i,
    multiply: o,
    partitionSelect: c,
    compare: s,
    isInteger: u,
    smaller: l,
    smallerEq: f,
    larger: d
  });
  return r("quantileSeq", {
    "Array | Matrix, number | BigNumber": m,
    "Array | Matrix, number | BigNumber, number": (v, h, y) => m(v, h, p(y)),
    "Array | Matrix, number | BigNumber, boolean": m,
    "Array | Matrix, number | BigNumber, boolean, number": (v, h, y, C) => m(v, h, y, p(C)),
    "Array | Matrix, Array | Matrix": m,
    "Array | Matrix, Array | Matrix, number": (v, h, y) => m(v, h, p(y)),
    "Array | Matrix, Array | Matrix, boolean": m,
    "Array | Matrix, Array | Matrix, boolean, number": (v, h, y, C) => m(v, h, y, p(C))
  });
  function p(v) {
    return af([[], v])[1];
  }
}, {
  isTransformFunction: !0
}), Nk = "cumsum", GFe = ["typed", "add", "unaryPlus"], qFe = /* @__PURE__ */ Ce(Nk, GFe, (e) => {
  var {
    typed: r,
    add: t,
    unaryPlus: n
  } = e, a = bY({
    typed: r,
    add: t,
    unaryPlus: n
  });
  return r(Nk, {
    "...any": function(o) {
      if (o.length === 2 && Xo(o[0])) {
        var c = o[1];
        Or(c) ? o[1] = c - 1 : Ir(c) && (o[1] = c.minus(1));
      }
      try {
        return a.apply(null, o);
      } catch (s) {
        throw Ji(s);
      }
    }
  });
}, {
  isTransformFunction: !0
}), Vk = "variance", HFe = ["typed", "add", "subtract", "multiply", "divide", "apply", "isNaN"], jFe = /* @__PURE__ */ Ce(Vk, HFe, (e) => {
  var {
    typed: r,
    add: t,
    subtract: n,
    multiply: a,
    divide: i,
    apply: o,
    isNaN: c
  } = e, s = CY({
    typed: r,
    add: t,
    subtract: n,
    multiply: a,
    divide: i,
    apply: o,
    isNaN: c
  });
  return r(Vk, {
    "...any": function(l) {
      l = af(l);
      try {
        return s.apply(null, l);
      } catch (f) {
        throw Ji(f);
      }
    }
  });
}, {
  isTransformFunction: !0
}), Rk = "print", $Fe = ["typed", "matrix", "zeros", "add"], KFe = /* @__PURE__ */ Ce(Rk, $Fe, (e) => {
  var {
    typed: r,
    matrix: t,
    zeros: n,
    add: a
  } = e, i = zX({
    typed: r,
    matrix: t,
    zeros: n,
    add: a
  });
  return r(Rk, {
    "string, Object | Array": function(s, u) {
      return i(o(s), u);
    },
    "string, Object | Array, number | Object": function(s, u, l) {
      return i(o(s), u, l);
    }
  });
  function o(c) {
    return c.replace(UX, (s) => {
      var u = s.slice(1).split("."), l = u.map(function(f) {
        return !isNaN(f) && f.length > 0 ? parseInt(f) - 1 : f;
      });
      return "$" + l.join(".");
    });
  }
}, {
  isTransformFunction: !0
}), WFe = "and", XFe = ["typed", "matrix", "zeros", "add", "equalScalar", "not", "concat"], YFe = /* @__PURE__ */ Ce(WFe, XFe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    zeros: a,
    not: i,
    concat: o
  } = e, c = KX({
    typed: r,
    matrix: t,
    equalScalar: n,
    zeros: a,
    not: i,
    concat: o
  });
  function s(u, l, f) {
    var d = u[0].compile().evaluate(f);
    if (!Xo(d) && !c(d, !0))
      return !1;
    var m = u[1].compile().evaluate(f);
    return c(d, m);
  }
  return s.rawArgs = !0, s;
}, {
  isTransformFunction: !0
}), QFe = "or", ZFe = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"], JFe = /* @__PURE__ */ Ce(QFe, ZFe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    DenseMatrix: a,
    concat: i
  } = e, o = xX({
    typed: r,
    matrix: t,
    equalScalar: n,
    DenseMatrix: a,
    concat: i
  });
  function c(s, u, l) {
    var f = s[0].compile().evaluate(l);
    if (!Xo(f) && o(f, !1))
      return !0;
    var d = s[1].compile().evaluate(l);
    return o(f, d);
  }
  return c.rawArgs = !0, c;
}, {
  isTransformFunction: !0
}), eLe = "bitAnd", rLe = ["typed", "matrix", "zeros", "add", "equalScalar", "not", "concat"], tLe = /* @__PURE__ */ Ce(eLe, rLe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    zeros: a,
    not: i,
    concat: o
  } = e, c = _X({
    typed: r,
    matrix: t,
    equalScalar: n,
    zeros: a,
    not: i,
    concat: o
  });
  function s(u, l, f) {
    var d = u[0].compile().evaluate(f);
    if (!Xo(d)) {
      if (isNaN(d))
        return NaN;
      if (d === 0 || d === !1)
        return 0;
    }
    var m = u[1].compile().evaluate(f);
    return c(d, m);
  }
  return s.rawArgs = !0, s;
}, {
  isTransformFunction: !0
}), nLe = "bitOr", aLe = ["typed", "matrix", "equalScalar", "DenseMatrix", "concat"], iLe = /* @__PURE__ */ Ce(nLe, aLe, (e) => {
  var {
    typed: r,
    matrix: t,
    equalScalar: n,
    DenseMatrix: a,
    concat: i
  } = e, o = bX({
    typed: r,
    matrix: t,
    equalScalar: n,
    DenseMatrix: a,
    concat: i
  });
  function c(s, u, l) {
    var f = s[0].compile().evaluate(l);
    if (!Xo(f)) {
      if (isNaN(f))
        return NaN;
      if (f === -1)
        return -1;
      if (f === !0)
        return 1;
    }
    var d = s[1].compile().evaluate(l);
    return o(f, d);
  }
  return c.rawArgs = !0, c;
}, {
  isTransformFunction: !0
});
const oLe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  createAbs: sX,
  createAccessorNode: p6e,
  createAcos: UEe,
  createAcosh: GEe,
  createAcot: HEe,
  createAcoth: $Ee,
  createAcsc: WEe,
  createAcsch: YEe,
  createAdd: oY,
  createAddScalar: lX,
  createAnd: KX,
  createAndTransform: YFe,
  createApply: ED,
  createApplyTransform: XOe,
  createArg: wPe,
  createArrayNode: g6e,
  createAsec: ZEe,
  createAsech: eDe,
  createAsin: tDe,
  createAsinh: iDe,
  createAssignmentNode: S6e,
  createAtan: nY,
  createAtan2: lDe,
  createAtanh: dDe,
  createAtomicMass: POe,
  createAvogadro: MOe,
  createBellNumbers: YVe,
  createBigNumberClass: UK,
  createBigint: x5e,
  createBignumber: tX,
  createBin: ZMe,
  createBitAnd: _X,
  createBitAndTransform: tLe,
  createBitNot: SPe,
  createBitOr: bX,
  createBitOrTransform: iLe,
  createBitXor: PPe,
  createBlockNode: A6e,
  createBohrMagneton: oOe,
  createBohrRadius: fOe,
  createBoltzmann: wOe,
  createBoolean: w5e,
  createCatalan: ZVe,
  createCbrt: Z5e,
  createCeil: uTe,
  createChain: ANe,
  createChainClass: $Ie,
  createClassicalElectronRadius: mOe,
  createClone: jxe,
  createColumn: ND,
  createColumnTransform: ZOe,
  createCombinations: sVe,
  createCombinationsWithRep: cVe,
  createCompare: Uwe,
  createCompareNatural: Hwe,
  createCompareText: Kwe,
  createCompile: tIe,
  createComplex: nX,
  createComplexClass: GK,
  createComposition: eRe,
  createConcat: BD,
  createConcatTransform: IFe,
  createConditionalNode: T6e,
  createConductanceQuantum: uOe,
  createConj: SX,
  createConstantNode: N6e,
  createCorr: oVe,
  createCos: aY,
  createCosh: vDe,
  createCot: hDe,
  createCoth: yDe,
  createCoulomb: aOe,
  createCount: UPe,
  createCreateUnit: LEe,
  createCross: TX,
  createCsc: bDe,
  createCsch: CDe,
  createCtranspose: LX,
  createCube: lTe,
  createCumSum: bY,
  createCumSumTransform: qFe,
  createDeepEqual: uEe,
  createDenseMatrixClass: nW,
  createDerivative: _Re,
  createDet: pY,
  createDeuteronMass: _Oe,
  createDiag: PX,
  createDiff: DX,
  createDiffTransform: NFe,
  createDistance: jNe,
  createDivide: yY,
  createDivideScalar: qX,
  createDot: sY,
  createDotDivide: Awe,
  createDotMultiply: mPe,
  createDotPow: Swe,
  createE: kRe,
  createEfimovFactor: TOe,
  createEigs: gY,
  createElectricConstant: tOe,
  createElectronMass: vOe,
  createElementaryCharge: iOe,
  createEqual: WX,
  createEqualScalar: JW,
  createEqualText: Qwe,
  createErf: kMe,
  createEvaluate: aIe,
  createExp: dTe,
  createExpm: NNe,
  createExpm1: mTe,
  createFactorial: hVe,
  createFalse: VRe,
  createFaraday: EOe,
  createFermiCoupling: pOe,
  createFft: wMe,
  createFibonacciHeapClass: AEe,
  createFilter: jPe,
  createFilterTransform: rFe,
  createFineStructure: hOe,
  createFirstRadiation: DOe,
  createFix: hTe,
  createFlatten: MX,
  createFloor: dX,
  createForEach: WPe,
  createForEachTransform: aFe,
  createFormat: YMe,
  createFraction: aX,
  createFractionClass: qK,
  createFreqz: TRe,
  createFunctionAssignmentNode: R6e,
  createFunctionNode: Z6e,
  createGamma: fVe,
  createGasConstant: BOe,
  createGcd: UTe,
  createGetMatrixDataType: wX,
  createGravitationConstant: ZRe,
  createGravity: zOe,
  createHartreeEnergy: gOe,
  createHasNumericValue: u5e,
  createHelp: SNe,
  createHelpClass: qIe,
  createHex: twe,
  createHypot: n6e,
  createI: KRe,
  createIdentity: EX,
  createIfft: DMe,
  createIm: CX,
  createImmutableDenseMatrixClass: rY,
  createIndex: c6e,
  createIndexClass: tY,
  createIndexNode: F6e,
  createIndexTransform: uFe,
  createInfinity: ORe,
  createIntersect: WNe,
  createInv: hY,
  createInverseConductanceQuantum: sOe,
  createInvmod: lPe,
  createIsInteger: iW,
  createIsNaN: d5e,
  createIsNegative: n5e,
  createIsNumeric: i5e,
  createIsPositive: QW,
  createIsPrime: uwe,
  createIsZero: ZW,
  createKldivergence: yVe,
  createKlitzing: dOe,
  createKron: JPe,
  createLN10: GRe,
  createLN2: zRe,
  createLOG10E: HRe,
  createLOG2E: qRe,
  createLarger: QX,
  createLargerEq: ZX,
  createLcm: HTe,
  createLeafCount: tRe,
  createLeftShift: Nwe,
  createLgamma: vVe,
  createLog: pwe,
  createLog10: $Te,
  createLog1p: gwe,
  createLog2: WTe,
  createLoschmidt: IOe,
  createLsolve: Twe,
  createLsolveAll: wwe,
  createLup: dIe,
  createLusolve: LIe,
  createLyap: zNe,
  createMad: rVe,
  createMagneticConstant: rOe,
  createMagneticFluxQuantum: lOe,
  createMap: rMe,
  createMapTransform: cFe,
  createMatrix: iX,
  createMatrixClass: HK,
  createMatrixFromColumns: oX,
  createMatrixFromFunction: F5e,
  createMatrixFromRows: k5e,
  createMax: JX,
  createMaxTransform: mFe,
  createMean: SY,
  createMeanTransform: hFe,
  createMedian: JNe,
  createMin: eY,
  createMinTransform: _Fe,
  createMod: fX,
  createMode: $Me,
  createMolarMass: kOe,
  createMolarMassC12: UOe,
  createMolarPlanckConstant: NOe,
  createMolarVolume: VOe,
  createMultinomial: bVe,
  createMultiply: vX,
  createMultiplyScalar: mX,
  createNaN: FRe,
  createNeutronMass: bOe,
  createNode: m6e,
  createNorm: uY,
  createNot: NPe,
  createNthRoot: JTe,
  createNthRoots: _we,
  createNuclearMagneton: cOe,
  createNull: RRe,
  createNumber: rX,
  createNumeric: GX,
  createObjectNode: k6e,
  createOct: ewe,
  createOnes: oMe,
  createOperatorNode: z6e,
  createOr: xX,
  createOrTransform: JFe,
  createParenthesisNode: q6e,
  createParse: eIe,
  createParser: lIe,
  createParserClass: uIe,
  createPartitionSelect: fEe,
  createPermutations: CVe,
  createPhi: URe,
  createPi: MY,
  createPickRandom: GVe,
  createPinv: MNe,
  createPlanckCharge: jOe,
  createPlanckConstant: JRe,
  createPlanckLength: GOe,
  createPlanckMass: qOe,
  createPlanckTemperature: $Oe,
  createPlanckTime: HOe,
  createPolynomialRoot: UIe,
  createPow: HX,
  createPrint: zX,
  createPrintTransform: KFe,
  createProd: WMe,
  createProtonMass: yOe,
  createQr: fY,
  createQuantileSeq: AY,
  createQuantileSeqTransform: zFe,
  createQuantumOfCirculation: SOe,
  createRandom: HVe,
  createRandomInt: $Ve,
  createRange: RD,
  createRangeClass: Exe,
  createRangeNode: j6e,
  createRangeTransform: CFe,
  createRationalize: SRe,
  createRe: AX,
  createReducedPlanckConstant: eOe,
  createRelationalNode: K6e,
  createReplacer: IRe,
  createReshape: NX,
  createResize: dMe,
  createResolve: pRe,
  createResultSet: SAe,
  createReviver: wRe,
  createRightArithShift: Rwe,
  createRightLogShift: Fwe,
  createRotate: mMe,
  createRotationMatrix: pMe,
  createRound: mwe,
  createRow: VX,
  createRowTransform: TFe,
  createRydberg: COe,
  createSQRT1_2: jRe,
  createSQRT2: $Re,
  createSackurTetrode: ROe,
  createSchur: kNe,
  createSec: xDe,
  createSech: PDe,
  createSecondRadiation: OOe,
  createSetCartesian: ODe,
  createSetDifference: LDe,
  createSetDistinct: UDe,
  createSetIntersect: GDe,
  createSetIsSubset: HDe,
  createSetMultiplicity: $De,
  createSetPowerset: WDe,
  createSetSize: YDe,
  createSetSymDifference: ZDe,
  createSetUnion: e6e,
  createSign: pX,
  createSimplify: uRe,
  createSimplifyConstant: cRe,
  createSimplifyCore: fRe,
  createSin: iY,
  createSinh: EDe,
  createSize: RX,
  createSlu: OIe,
  createSmaller: XX,
  createSmallerEq: YX,
  createSolveODE: OMe,
  createSort: vEe,
  createSpaClass: PEe,
  createSparse: OEe,
  createSparseMatrixClass: eX,
  createSpeedOfLight: QRe,
  createSplitUnit: G5e,
  createSqrt: hX,
  createSqrtm: RNe,
  createSquare: aPe,
  createSqueeze: _Me,
  createStd: xY,
  createStdTransform: OFe,
  createStefanBoltzmann: FOe,
  createStirlingS2: WVe,
  createString: P5e,
  createSubset: OX,
  createSubsetTransform: wFe,
  createSubtract: gX,
  createSubtractScalar: cX,
  createSum: _Y,
  createSumTransform: LFe,
  createSylvester: FNe,
  createSymbolNode: Y6e,
  createSymbolicEqual: gRe,
  createTan: IDe,
  createTanh: VDe,
  createTau: LRe,
  createThomsonCrossSection: AOe,
  createTo: iwe,
  createTrace: s6e,
  createTranspose: FX,
  createTrue: NRe,
  createTypeOf: m5e,
  createTyped: wK,
  createUnaryMinus: uX,
  createUnaryPlus: j5e,
  createUnequal: lEe,
  createUnitClass: BEe,
  createUnitFunction: VEe,
  createUppercaseE: XRe,
  createUppercasePi: WRe,
  createUsolve: jX,
  createUsolveAll: $X,
  createVacuumImpedance: nOe,
  createVariance: CY,
  createVarianceTransform: jFe,
  createVersion: YRe,
  createWeakMixingAngle: xOe,
  createWienDisplacement: LOe,
  createXgcd: uPe,
  createXor: OPe,
  createZeros: kX,
  createZeta: HMe,
  createZpk2tf: ARe
}, Symbol.toStringTag, { value: "Module" }));
var eh = /* @__PURE__ */ UK({
  config: wi
}), mx = /* @__PURE__ */ GK({}), WD = /* @__PURE__ */ qK({}), XD = /* @__PURE__ */ HK({}), Eo = /* @__PURE__ */ nW({
  Matrix: XD
}), H_ = /* @__PURE__ */ MY({
  BigNumber: eh,
  config: wi
}), pr = /* @__PURE__ */ wK({
  BigNumber: eh,
  Complex: mx,
  DenseMatrix: Eo,
  Fraction: WD
}), t0 = /* @__PURE__ */ sX({
  typed: pr
}), rh = /* @__PURE__ */ lX({
  typed: pr
}), uLe = /* @__PURE__ */ nY({
  typed: pr
}), YD = /* @__PURE__ */ nX({
  Complex: mx,
  typed: pr
}), vx = /* @__PURE__ */ SX({
  typed: pr
}), hb = /* @__PURE__ */ aY({
  typed: pr
}), Cl = /* @__PURE__ */ JW({
  config: wi,
  typed: pr
}), sLe = /* @__PURE__ */ wX({
  typed: pr
}), lLe = /* @__PURE__ */ CX({
  typed: pr
}), wY = /* @__PURE__ */ iW({
  typed: pr
}), cLe = /* @__PURE__ */ QW({
  config: wi,
  typed: pr
}), EY = /* @__PURE__ */ ZW({
  equalScalar: Cl,
  typed: pr
}), th = /* @__PURE__ */ mX({
  typed: pr
}), QD = /* @__PURE__ */ rX({
  typed: pr
}), dLe = /* @__PURE__ */ AX({
  typed: pr
}), fLe = /* @__PURE__ */ pX({
  BigNumber: eh,
  Fraction: WD,
  complex: YD,
  typed: pr
}), DY = /* @__PURE__ */ iY({
  typed: pr
}), px = /* @__PURE__ */ eX({
  Matrix: XD,
  equalScalar: Cl,
  typed: pr
}), Ky = /* @__PURE__ */ cX({
  typed: pr
}), ZD = /* @__PURE__ */ tX({
  BigNumber: eh,
  typed: pr
}), hx = /* @__PURE__ */ hX({
  Complex: mx,
  config: wi,
  typed: pr
}), gx = /* @__PURE__ */ uX({
  typed: pr
}), IY = /* @__PURE__ */ aX({
  Fraction: WD,
  typed: pr
}), Ct = /* @__PURE__ */ iX({
  DenseMatrix: Eo,
  Matrix: XD,
  SparseMatrix: px,
  typed: pr
}), mLe = /* @__PURE__ */ GX({
  bignumber: ZD,
  fraction: IY,
  number: QD
}), vLe = /* @__PURE__ */ NX({
  isInteger: wY,
  matrix: Ct,
  typed: pr
}), JD = /* @__PURE__ */ RX({
  matrix: Ct,
  config: wi,
  typed: pr
}), BY = /* @__PURE__ */ FX({
  matrix: Ct,
  typed: pr
}), pLe = /* @__PURE__ */ kX({
  BigNumber: eh,
  config: wi,
  matrix: Ct,
  typed: pr
}), nm = /* @__PURE__ */ BD({
  isInteger: wY,
  matrix: Ct,
  typed: pr
}), hLe = /* @__PURE__ */ LX({
  conj: vx,
  transpose: BY,
  typed: pr
}), gLe = /* @__PURE__ */ PX({
  DenseMatrix: Eo,
  SparseMatrix: px,
  matrix: Ct,
  typed: pr
}), am = /* @__PURE__ */ qX({
  numeric: mLe,
  typed: pr
}), NY = /* @__PURE__ */ WX({
  DenseMatrix: Eo,
  concat: nm,
  equalScalar: Cl,
  matrix: Ct,
  typed: pr
}), VY = /* @__PURE__ */ MX({
  matrix: Ct,
  typed: pr
}), e6 = /* @__PURE__ */ EX({
  BigNumber: eh,
  DenseMatrix: Eo,
  SparseMatrix: px,
  config: wi,
  matrix: Ct,
  typed: pr
}), yLe = /* @__PURE__ */ ZX({
  DenseMatrix: Eo,
  concat: nm,
  config: wi,
  matrix: Ct,
  typed: pr
}), _Le = /* @__PURE__ */ oX({
  flatten: VY,
  matrix: Ct,
  size: JD,
  typed: pr
}), bLe = /* @__PURE__ */ fY({
  addScalar: rh,
  complex: YD,
  conj: vx,
  divideScalar: am,
  equal: NY,
  identity: e6,
  isZero: EY,
  matrix: Ct,
  multiplyScalar: th,
  sign: fLe,
  sqrt: hx,
  subtractScalar: Ky,
  typed: pr,
  unaryMinus: gx,
  zeros: pLe
}), yx = /* @__PURE__ */ XX({
  DenseMatrix: Eo,
  concat: nm,
  config: wi,
  matrix: Ct,
  typed: pr
}), RY = /* @__PURE__ */ gX({
  DenseMatrix: Eo,
  concat: nm,
  equalScalar: Cl,
  matrix: Ct,
  subtractScalar: Ky,
  typed: pr,
  unaryMinus: gx
}), SLe = /* @__PURE__ */ jX({
  DenseMatrix: Eo,
  divideScalar: am,
  equalScalar: Cl,
  matrix: Ct,
  multiplyScalar: th,
  subtractScalar: Ky,
  typed: pr
}), r6 = /* @__PURE__ */ oY({
  DenseMatrix: Eo,
  SparseMatrix: px,
  addScalar: rh,
  concat: nm,
  equalScalar: Cl,
  matrix: Ct,
  typed: pr
}), t6 = /* @__PURE__ */ sY({
  addScalar: rh,
  conj: vx,
  multiplyScalar: th,
  size: JD,
  typed: pr
}), CLe = /* @__PURE__ */ rY({
  DenseMatrix: Eo,
  smaller: yx
}), ALe = /* @__PURE__ */ tY({
  ImmutableDenseMatrix: CLe,
  getMatrixDataType: sLe
}), n6 = /* @__PURE__ */ QX({
  DenseMatrix: Eo,
  concat: nm,
  config: wi,
  matrix: Ct,
  typed: pr
}), of = /* @__PURE__ */ vX({
  addScalar: rh,
  dot: t6,
  equalScalar: Cl,
  matrix: Ct,
  multiplyScalar: th,
  typed: pr
}), xLe = /* @__PURE__ */ $X({
  DenseMatrix: Eo,
  divideScalar: am,
  equalScalar: Cl,
  matrix: Ct,
  multiplyScalar: th,
  subtractScalar: Ky,
  typed: pr
}), Ok = /* @__PURE__ */ TX({
  matrix: Ct,
  multiply: of,
  subtract: RY,
  typed: pr
}), TLe = /* @__PURE__ */ pY({
  divideScalar: am,
  isZero: EY,
  matrix: Ct,
  multiply: of,
  subtractScalar: Ky,
  typed: pr,
  unaryMinus: gx
}), PLe = /* @__PURE__ */ YX({
  DenseMatrix: Eo,
  concat: nm,
  config: wi,
  matrix: Ct,
  typed: pr
}), MLe = /* @__PURE__ */ RD({
  bignumber: ZD,
  matrix: Ct,
  add: r6,
  config: wi,
  isPositive: cLe,
  larger: n6,
  largerEq: yLe,
  smaller: yx,
  smallerEq: PLe,
  typed: pr
}), wLe = /* @__PURE__ */ ND({
  Index: ALe,
  matrix: Ct,
  range: MLe,
  typed: pr
}), a6 = /* @__PURE__ */ hY({
  abs: t0,
  addScalar: rh,
  det: TLe,
  divideScalar: am,
  identity: e6,
  matrix: Ct,
  multiply: of,
  typed: pr,
  unaryMinus: gx
}), ELe = /* @__PURE__ */ HX({
  Complex: mx,
  config: wi,
  fraction: IY,
  identity: e6,
  inv: a6,
  matrix: Ct,
  multiply: of,
  number: QD,
  typed: pr
}), DLe = /* @__PURE__ */ yY({
  divideScalar: am,
  equalScalar: Cl,
  inv: a6,
  matrix: Ct,
  multiply: of,
  typed: pr
}), ILe = /* @__PURE__ */ gY({
  abs: t0,
  add: r6,
  addScalar: rh,
  atan: uLe,
  bignumber: ZD,
  column: wLe,
  complex: YD,
  config: wi,
  cos: hb,
  diag: gLe,
  divideScalar: am,
  dot: t6,
  equal: NY,
  flatten: VY,
  im: lLe,
  inv: a6,
  larger: n6,
  matrix: Ct,
  matrixFromColumns: _Le,
  multiply: of,
  multiplyScalar: th,
  number: QD,
  qr: bLe,
  re: dLe,
  reshape: vLe,
  sin: DY,
  size: JD,
  smaller: yx,
  sqrt: hx,
  subtract: RY,
  typed: pr,
  usolve: SLe,
  usolveAll: xLe
}), Fk = /* @__PURE__ */ uY({
  abs: t0,
  add: r6,
  conj: vx,
  ctranspose: hLe,
  eigs: ILe,
  equalScalar: Cl,
  larger: n6,
  matrix: Ct,
  multiply: of,
  pow: ELe,
  smaller: yx,
  sqrt: hx,
  typed: pr
}), BLe = oLe, i6 = { exports: {} };
function o6() {
}
o6.prototype = {
  on: function(e, r, t) {
    var n = this.e || (this.e = {});
    return (n[e] || (n[e] = [])).push({
      fn: r,
      ctx: t
    }), this;
  },
  once: function(e, r, t) {
    var n = this;
    function a() {
      n.off(e, a), r.apply(t, arguments);
    }
    return a._ = r, this.on(e, a, t);
  },
  emit: function(e) {
    var r = [].slice.call(arguments, 1), t = ((this.e || (this.e = {}))[e] || []).slice(), n = 0, a = t.length;
    for (n; n < a; n++)
      t[n].fn.apply(t[n].ctx, r);
    return this;
  },
  off: function(e, r) {
    var t = this.e || (this.e = {}), n = t[e], a = [];
    if (n && r)
      for (var i = 0, o = n.length; i < o; i++)
        n[i].fn !== r && n[i].fn._ !== r && a.push(n[i]);
    return a.length ? t[e] = a : delete t[e], this;
  }
};
i6.exports = o6;
i6.exports.TinyEmitter = o6;
var NLe = i6.exports;
const VLe = /* @__PURE__ */ qg(NLe);
function RLe(e) {
  var r = new VLe();
  return e.on = r.on.bind(r), e.off = r.off.bind(r), e.once = r.once.bind(r), e.emit = r.emit.bind(r), e;
}
function OLe(e, r, t, n) {
  function a(h, y) {
    var C = arguments.length;
    if (C !== 1 && C !== 2)
      throw new Ic("import", C, 1, 2);
    y || (y = {});
    function S(A, M, P) {
      if (Array.isArray(M))
        M.forEach((w) => S(A, w));
      else if (typeof M == "object")
        for (var T in M)
          er(M, T) && S(A, M[T], T);
      else if (ug(M) || P !== void 0) {
        var x = ug(M) ? p(M) ? M.fn + ".transform" : M.fn : P;
        if (er(A, x) && A[x] !== M && !y.silent)
          throw new Error('Cannot import "' + x + '" twice');
        A[x] = M;
      } else if (!y.silent)
        throw new TypeError("Factory, Object, or Array expected");
    }
    var b = {};
    S(b, h);
    for (var g in b)
      if (er(b, g)) {
        var _ = b[g];
        if (ug(_))
          u(_, y);
        else if (l(_))
          i(g, _, y);
        else if (!y.silent)
          throw new TypeError("Factory, Object, or Array expected");
      }
  }
  function i(h, y, C) {
    if (C.wrap && typeof y == "function" && (y = s(y)), f(y) && (y = e(h, {
      [y.signature]: y
    })), e.isTypedFunction(t[h]) && e.isTypedFunction(y)) {
      C.override ? y = e(h, y.signatures) : y = e(t[h], y), t[h] = y, delete n[h], o(h, y), t.emit("import", h, function() {
        return y;
      });
      return;
    }
    if (t[h] === void 0 || C.override) {
      t[h] = y, delete n[h], o(h, y), t.emit("import", h, function() {
        return y;
      });
      return;
    }
    if (!C.silent)
      throw new Error('Cannot import "' + h + '": already exists');
  }
  function o(h, y) {
    y && typeof y.transform == "function" ? (t.expression.transform[h] = y.transform, d(h) && (t.expression.mathWithTransform[h] = y.transform)) : (delete t.expression.transform[h], d(h) && (t.expression.mathWithTransform[h] = y));
  }
  function c(h) {
    delete t.expression.transform[h], d(h) ? t.expression.mathWithTransform[h] = t[h] : delete t.expression.mathWithTransform[h];
  }
  function s(h) {
    var y = function() {
      for (var S = [], b = 0, g = arguments.length; b < g; b++) {
        var _ = arguments[b];
        S[b] = _ && _.valueOf();
      }
      return h.apply(t, S);
    };
    return h.transform && (y.transform = h.transform), y;
  }
  function u(h, y) {
    var C = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : h.fn;
    if (C.includes("."))
      throw new Error("Factory name should not contain a nested path. Name: " + JSON.stringify(C));
    var S = p(h) ? t.expression.transform : t, b = C in t.expression.transform, g = er(S, C) ? S[C] : void 0, _ = function() {
      var M = {};
      h.dependencies.map(SK).forEach((T) => {
        if (T.includes("."))
          throw new Error("Factory dependency should not contain a nested path. Name: " + JSON.stringify(T));
        T === "math" ? M.math = t : T === "mathWithTransform" ? M.mathWithTransform = t.expression.mathWithTransform : T === "classes" ? M.classes = t : M[T] = t[T];
      });
      var P = /* @__PURE__ */ h(M);
      if (P && typeof P.transform == "function")
        throw new Error('Transforms cannot be attached to factory functions. Please create a separate function for it with export const path = "expression.transform"');
      if (g === void 0 || y.override)
        return P;
      if (e.isTypedFunction(g) && e.isTypedFunction(P))
        return e(g, P);
      if (y.silent)
        return g;
      throw new Error('Cannot import "' + C + '": already exists');
    };
    !h.meta || h.meta.lazy !== !1 ? (mb(S, C, _), g && b ? c(C) : (p(h) || m(h)) && mb(t.expression.mathWithTransform, C, () => S[C])) : (S[C] = _(), g && b ? c(C) : (p(h) || m(h)) && mb(t.expression.mathWithTransform, C, () => S[C])), n[C] = h, t.emit("import", C, _);
  }
  function l(h) {
    return typeof h == "function" || typeof h == "number" || typeof h == "string" || typeof h == "boolean" || h === null || ho(h) || as(h) || Ir(h) || J0(h) || gr(h) || Array.isArray(h);
  }
  function f(h) {
    return typeof h == "function" && typeof h.signature == "string";
  }
  function d(h) {
    return !er(v, h);
  }
  function m(h) {
    return !h.fn.includes(".") && // FIXME: make checking on path redundant, check on meta data instead
    !er(v, h.fn) && (!h.meta || !h.meta.isClass);
  }
  function p(h) {
    return h !== void 0 && h.meta !== void 0 && h.meta.isTransformFunction === !0 || !1;
  }
  var v = {
    expression: !0,
    type: !0,
    docs: !0,
    error: !0,
    json: !0,
    chain: !0
    // chain method not supported. Note that there is a unit chain too.
  };
  return a;
}
function OY(e, r) {
  var t = Xa({}, ex, r);
  if (typeof Object.create != "function")
    throw new Error("ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.");
  var n = RLe({
    // only here for backward compatibility for legacy factory functions
    isNumber: Or,
    isComplex: as,
    isBigNumber: Ir,
    isBigInt: rK,
    isFraction: J0,
    isUnit: ho,
    isString: Ya,
    isArray: dt,
    isMatrix: gr,
    isCollection: Xo,
    isDenseMatrix: Fg,
    isSparseMatrix: dd,
    isRange: rx,
    isIndex: zy,
    isBoolean: tK,
    isResultSet: nK,
    isHelp: bD,
    isFunction: aK,
    isDate: iK,
    isRegExp: oK,
    isObject: Gy,
    isNull: uK,
    isUndefined: sK,
    isAccessorNode: Fd,
    isArrayNode: jo,
    isAssignmentNode: lK,
    isBlockNode: cK,
    isConditionalNode: dK,
    isConstantNode: Jr,
    isFunctionAssignmentNode: Kp,
    isFunctionNode: hc,
    isIndexNode: em,
    isNode: St,
    isObjectNode: qy,
    isOperatorNode: Hn,
    isParenthesisNode: sl,
    isRangeNode: fK,
    isRelationalNode: mK,
    isSymbolNode: _a,
    isChain: SD
  });
  n.config = K4e(t, n.emit), n.expression = {
    transform: {},
    mathWithTransform: {
      config: n.config
    }
  };
  var a = [], i = [];
  function o(l) {
    if (ug(l))
      return l(n);
    var f = l[Object.keys(l)[0]];
    if (ug(f))
      return f(n);
    if (!j4e(l))
      throw console.warn("Factory object with properties `type`, `name`, and `factory` expected", l), new Error("Factory object with properties `type`, `name`, and `factory` expected");
    var d = a.indexOf(l), m;
    return d === -1 ? (l.math === !0 ? m = l.factory(n.type, t, o, n.typed, n) : m = l.factory(n.type, t, o, n.typed), a.push(l), i.push(m)) : m = i[d], m;
  }
  var c = {};
  function s() {
    for (var l = arguments.length, f = new Array(l), d = 0; d < l; d++)
      f[d] = arguments[d];
    return n.typed.apply(n.typed, f);
  }
  s.isTypedFunction = r0.isTypedFunction;
  var u = OLe(s, o, n, c);
  return n.import = u, n.on("config", () => {
    Object.values(c).forEach((l) => {
      l && l.meta && l.meta.recreateOnConfigChange && u(l, {
        override: !0
      });
    });
  }), n.create = OY.bind(null, e), n.factory = Ce, n.import(Object.values(H4e(e))), n.ArgumentsError = Ic, n.DimensionError = kr, n.IndexError = Ru, n;
}
const EP = OY(BLe), {
  SvelteComponent: FLe,
  append: Ka,
  attr: Da,
  destroy_each: LLe,
  detach: u6,
  element: ju,
  ensure_array_like: Lk,
  flush: R1,
  init: kLe,
  insert: s6,
  listen: j_,
  noop: kk,
  null_to_empty: R3,
  run_all: ULe,
  safe_not_equal: zLe,
  set_data: FY,
  space: $f,
  text: LY
} = window.__gradio__svelte__internal;
function Uk(e, r, t) {
  const n = e.slice();
  return n[34] = r[t], n;
}
function zk(e) {
  let r, t, n, a;
  return {
    c() {
      r = ju("div"), t = ju("div"), n = LY(
        /*tooltipText*/
        e[2]
      ), Da(t, "class", R3("tooltip-inner") + " svelte-gvaj6l"), Da(r, "class", "tooltip svelte-gvaj6l"), Da(r, "style", a = `top: ${/*mousePosition*/
      e[1].y - 45}px;left: ${/*mousePosition*/
      e[1].x - 8}px;`);
    },
    m(i, o) {
      s6(i, r, o), Ka(r, t), Ka(t, n);
    },
    p(i, o) {
      o[0] & /*tooltipText*/
      4 && FY(
        n,
        /*tooltipText*/
        i[2]
      ), o[0] & /*mousePosition*/
      2 && a !== (a = `top: ${/*mousePosition*/
      i[1].y - 45}px;left: ${/*mousePosition*/
      i[1].x - 8}px;`) && Da(r, "style", a);
    },
    d(i) {
      i && u6(r);
    }
  };
}
function Gk(e) {
  let r, t, n, a, i = (
    /*atom*/
    e[34] + ""
  ), o, c;
  return {
    c() {
      r = ju("div"), t = ju("div"), a = $f(), o = LY(i), c = $f(), Da(t, "style", n = `background-color: ${qk(Fb.VESTA_COLOR_TABLE[
        /*atom*/
        e[34].toUpperCase()
      ])}`), Da(t, "class", R3("atom-model-legend-item-ball") + " svelte-gvaj6l"), Da(r, "class", R3("atom-model-legend-item") + " svelte-gvaj6l");
    },
    m(s, u) {
      s6(s, r, u), Ka(r, t), Ka(r, a), Ka(r, o), Ka(r, c);
    },
    p(s, u) {
      u[0] & /*atomList*/
      16 && n !== (n = `background-color: ${qk(Fb.VESTA_COLOR_TABLE[
        /*atom*/
        s[34].toUpperCase()
      ])}`) && Da(t, "style", n), u[0] & /*atomList*/
      16 && i !== (i = /*atom*/
      s[34] + "") && FY(o, i);
    },
    d(s) {
      s && u6(r);
    }
  };
}
function GLe(e) {
  let r, t, n, a, i, o, c, s, u, l, f, d, m, p, v, h = !!/*tooltipText*/
  e[2] && zk(e), y = Lk(
    /*atomList*/
    e[4]
  ), C = [];
  for (let S = 0; S < y.length; S += 1)
    C[S] = Gk(Uk(e, y, S));
  return {
    c() {
      r = ju("div"), t = ju("div"), n = $f(), h && h.c(), a = $f(), i = ju("div");
      for (let S = 0; S < C.length; S += 1)
        C[S].c();
      o = $f(), c = ju("div"), s = ju("button"), s.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>', u = $f(), l = ju("button"), l.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 = $f(), d = ju("button"), d.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>', Da(t, "id", `material-viewer-canvas-${/*key*/
      e[5]}`), Da(t, "style", "width: 100%;height: 100%;min-height: 240px;"), Da(i, "class", R3("atom-model-legend-container") + " svelte-gvaj6l"), Da(s, "class", "material-viewer-toolbar-btn svelte-gvaj6l"), Da(l, "class", "material-viewer-toolbar-btn svelte-gvaj6l"), Da(d, "class", "material-viewer-toolbar-btn svelte-gvaj6l"), Da(c, "class", "material-viewer-toolbar svelte-gvaj6l"), Da(r, "class", "material-viewer-container svelte-gvaj6l"), Da(r, "style", m = `height: ${/*height*/
      e[0]}px;`);
    },
    m(S, b) {
      s6(S, r, b), Ka(r, t), Ka(r, n), h && h.m(r, null), Ka(r, a), Ka(r, i);
      for (let g = 0; g < C.length; g += 1)
        C[g] && C[g].m(i, null);
      Ka(r, o), Ka(r, c), Ka(c, s), Ka(c, u), Ka(c, l), Ka(c, f), Ka(c, d), p || (v = [
        j_(
          t,
          "mousemove",
          /*mousemove_handler*/
          e[10]
        ),
        j_(
          s,
          "click",
          /*click_handler*/
          e[11]
        ),
        j_(
          l,
          "click",
          /*click_handler_1*/
          e[12]
        ),
        j_(
          d,
          "click",
          /*click_handler_2*/
          e[13]
        )
      ], p = !0);
    },
    p(S, b) {
      if (/*tooltipText*/
      S[2] ? h ? h.p(S, b) : (h = zk(S), h.c(), h.m(r, a)) : h && (h.d(1), h = null), b[0] & /*atomList*/
      16) {
        y = Lk(
          /*atomList*/
          S[4]
        );
        let g;
        for (g = 0; g < y.length; g += 1) {
          const _ = Uk(S, y, g);
          C[g] ? C[g].p(_, b) : (C[g] = Gk(_), C[g].c(), C[g].m(i, null));
        }
        for (; g < C.length; g += 1)
          C[g].d(1);
        C.length = y.length;
      }
      b[0] & /*height*/
      1 && m !== (m = `height: ${/*height*/
      S[0]}px;`) && Da(r, "style", m);
    },
    i: kk,
    o: kk,
    d(S) {
      S && u6(r), h && h.d(), LLe(C, S), p = !1, ULe(v);
    }
  };
}
function qk(e) {
  let r = e.toString(16);
  for (; r.length < 6; )
    r = "0" + r;
  return "#" + r;
}
function O3(e, r = e.length, t = []) {
  if (r === 0) return [];
  if (r === 1) return [...t, ...e.map((n) => [n])];
  if (e.length === r) return O3(e, r - 1, [e.slice()]);
  for (let n = 0; n < e.length - 1; n++)
    for (let a = n + 1; a < e.length; a++)
      t.push([e[n], e[a]]);
  return O3(e, r - 1, t);
}
function qLe(e) {
  const r = [], t = [];
  return e.atoms.map((n) => {
    r.push(n.element), t.push(n.xyz);
  }), {
    elements: r,
    xyzs: t,
    lattice: e.lattice
  };
}
function HLe(e, r) {
  return e.every((t, n) => t === r[n]);
}
function Hk(e) {
  return HLe(e, [0, 0, 0]);
}
function jLe(e, r, t) {
  var n = this && this.__awaiter || function(O, V, k, G) {
    function L(R) {
      return R instanceof k ? R : new k(function(F) {
        F(R);
      });
    }
    return new (k || (k = Promise))(function(R, F) {
      function U(K) {
        try {
          q(G.next(K));
        } catch (Y) {
          F(Y);
        }
      }
      function H(K) {
        try {
          q(G.throw(K));
        } catch (Y) {
          F(Y);
        }
      }
      function q(K) {
        K.done ? R(K.value) : L(K.value).then(U, H);
      }
      q((G = G.apply(O, V || [])).next());
    });
  };
  let { gradio: a } = r, { materialFile: i = "" } = r, { value: o = "" } = r, { value_is_output: c = !1 } = r, { height: s } = r;
  window.process = {
    env: { NODE_ENV: "production", LANG: "" }
  };
  let u = new Gf.LightPlugin();
  const f = (() => {
    function O() {
      return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
    }
    return `${O() + O()}-${O()}-${O()}-${O()}-${O()}${O()}${O()}`;
  })();
  function d() {
    a.dispatch("change"), c || a.dispatch("input");
  }
  let m = { x: -1e3, y: -1e3 }, p = "", v = [];
  function h(O) {
    const { length: V, angle: k, spacegroup: G, atoms: L } = O[0], R = {
      expand: Re.Vec3.create(1, 1, 1),
      atoms: [],
      lattice: void 0
    }, F = (() => {
      if (!V || !k || !G)
        return;
      const [H, q, K] = V, [Y, X, Z] = k, J = {
        symbol: G[1],
        no: G[0]
      }, $ = P({ spacegroup: J, a: H, b: q, c: K, alpha: Y, beta: X, gamma: Z });
      return $.parent = R, $;
    })(), U = L.map((H, q) => {
      const K = {
        element: H.formula,
        xyz: H.cart_coord,
        abc: H.frac_coord
      }, Y = A(K, { lattice: F, order: q });
      return Y.parent = R, Y;
    });
    return R.lattice = F, R.atoms = U, R;
  }
  function y(O, V) {
    const G = [];
    return O.forEach((L, R) => {
      const { abc: F } = L;
      if (!(!F || F[0] === void 0)) {
        {
          const U = [];
          Math.abs(F[0]) <= 5e-3 && U.push(0), Math.abs(F[1]) <= 5e-3 && U.push(1), Math.abs(F[2]) <= 5e-3 && U.push(2), O3(U).map((K) => [
            Number(K.includes(0)),
            Number(K.includes(1)),
            Number(K.includes(2))
          ]).forEach((K) => {
            const Y = A(L, { order: R, lattice: V, symmetry: K });
            G.push(Y);
          });
        }
        {
          const U = [];
          Math.abs(1 - F[0]) <= 5e-3 && U.push(0), Math.abs(1 - F[1]) <= 5e-3 && U.push(1), Math.abs(1 - F[2]) <= 5e-3 && U.push(2), O3(U).map((K) => [
            -Number(K.includes(0)),
            -Number(K.includes(1)),
            -Number(K.includes(2))
          ]).forEach((K) => {
            const Y = A(L, { order: R, lattice: V, symmetry: K });
            G.push(Y);
          });
        }
      }
    }), G;
  }
  function C(O) {
    if (!O.lattice)
      return O;
    const V = b({
      lattice: O.lattice,
      atoms: O.atoms
    }), { atoms: k } = V, G = y(k, O.lattice);
    return V.atoms = [...V.atoms, ...G], V;
  }
  function S() {
    return n(this, void 0, void 0, function* () {
      if (!u.canvas3d) return;
      const [O] = yield u.managers.representation.createMolecular({
        format: Gf.Format.Material,
        reprType: Gf.RepresentationType.BallAndStick,
        data: qLe(C(h(JSON.parse(i)))),
        theme: {
          [Gf.ThemeC.ATOM]: {
            color: { name: "material-element-symbol" }
          }
        }
      }), V = /* @__PURE__ */ new Set(), k = yield u.managers.cell.getStructure(O);
      k && (G4e.traverseAtoms(k, (G) => {
        V.add(G.typeSymbol);
      }), t(4, v = new Array(...V.values())), u.managers.representation.createOther({
        data: u.managers.cell.getUnitCellData(O),
        type: Gf.RepresentationType.UnitCell
      }), u.managers.camera.updateAxes(O));
    });
  }
  function b(O) {
    const V = {
      expand: Re.Vec3.create(1, 1, 1),
      atoms: [],
      lattice: void 0
    }, k = O != null && O.lattice ? P(O == null ? void 0 : O.lattice) : void 0;
    k && (k.parent = V);
    const G = O.atoms.map((L, R) => {
      const F = A(L, { lattice: k, order: R });
      return F.parent = V, F;
    });
    return V.lattice = k, V.atoms = G, V;
  }
  function g(O, V) {
    const { vecA: k, vecB: G, vecC: L } = V, R = Re.Vec3.zero();
    return O[0] && Re.Vec3.scaleAndAdd(R, R, k, O[0]), O[1] && Re.Vec3.scaleAndAdd(R, R, G, O[1]), O[2] && Re.Vec3.scaleAndAdd(R, R, L, O[2]), Re.Mat4.fromTranslation(Re.Mat4.zero(), R);
  }
  function _(O) {
    const V = O.map((k) => k);
    return DLe(V, Fk(V));
  }
  function A(O, V) {
    const { element: k } = O, { order: G, lattice: L, symmetry: R } = V || {};
    if (!O.abc && !O.xyz)
      throw new Error("createAtom: Need xyz or abc!");
    if (!L && !O.xyz)
      throw new Error("createAtom: Need xyz or lattice!");
    let F = (() => {
      const { xyz: H, abc: q } = O;
      if (!L)
        return;
      if (!q)
        return Re.Vec3.create.apply(null, EP.multiply(H, L.invertMatrix));
      if (!R || Hk(R))
        return Re.Vec3.create(q[0], q[1], q[2]);
      const K = g(R, L);
      return Re.Vec3.transformMat4(Re.Vec3.zero(), Re.Vec3.create(q[0], q[1], q[2]), K);
    })(), U = (() => {
      const { xyz: H, abc: q } = O;
      if (!L)
        return Re.Vec3.create(H[0], H[1], H[2]);
      if (!H)
        return Re.Vec3.create.apply(null, EP.multiply(q, L.matrix));
      if (!R || Hk(R))
        return Re.Vec3.create(H[0], H[1], H[2]);
      const K = g(R, L);
      return Re.Vec3.transformMat4(Re.Vec3.zero(), Re.Vec3.create(H[0], H[1], H[2]), K);
    })();
    return { element: k, xyz: U, abc: F, order: G, symmetry: R };
  }
  function M(O, V = [0, 0, 1], k) {
    if (!k) {
      const se = Ok(V, [1, 0, 0]);
      Fk(se) < 1e-5 ? k = [0, 0, 1] : k = [1, 0, 0];
    }
    const G = k, L = _(V), R = _(G.map((se, ce) => se - t6(G, L) * L[ce])), F = Ok(L, R);
    let U = 90, H = 90, q = 90, K, Y, X;
    typeof O == "number" ? K = Y = X = O : O.length === 1 ? K = Y = X = O[0] : O.length === 3 ? [K, Y, X] = O : [K, Y, X, U, H, q] = O;
    const Z = 2 * Number.EPSILON;
    let J = t0(U - 90) < Z ? 0 : hb(U * H_ / 180), $ = t0(H - 90) < Z ? 0 : hb(H * H_ / 180), Q, W;
    t0(q - 90) < Z ? (Q = 0, W = 1) : t0(q + 90) < Z ? (Q = 0, W = -1) : (Q = hb(q * H_ / 180), W = DY(q * H_ / 180));
    const te = [K, 0, 0], oe = [Y * Q, Y * W, 0], z = $, j = (J - $ * Q) / W, ae = 1 - z * z - j * j;
    if (ae < 0) throw new Error("cz_sqr is negative, which is not possible");
    const le = hx(ae), ie = [X * z, X * j, X * le], re = Ct([te, oe, ie]), ee = Ct([R, F, L]);
    return of(re, BY(ee)).toArray();
  }
  function P(O) {
    const { a: V, b: k, c: G, alpha: L, beta: R, gamma: F, spacegroup: U } = O, H = O.matrix || M([V, k, G, L, R, F]), q = EP.inv(H), K = Re.Vec3.create.apply(null, H[0]), Y = Re.Vec3.create.apply(null, H[1]), X = Re.Vec3.create.apply(null, H[2]), Z = Math.abs(Re.Vec3.dot(K, K)) * G;
    return {
      spacegroup: U,
      a: V,
      b: k,
      c: G,
      volume: Z,
      alpha: L,
      beta: R,
      gamma: F,
      vecA: K,
      vecB: Y,
      vecC: X,
      matrix: H,
      invertMatrix: q
    };
  }
  function T() {
    t(3, u.managers.representation.showPolarHydrogenOnly = !1, u), u.createCanvas(document.getElementById(`material-viewer-canvas-${f}`), {
      renderer: {
        ambientIntensity: 0.4,
        backgroundColor: DZ.Color(15922682)
      }
    }), u.managers.selection.structure.setGranularity(Gf.Granularity.Atom), u.managers.events.setAllowSelect(!1), u.managers.highlight.info.subscribe((O) => {
      var V;
      if (((V = O.info) === null || V === void 0 ? void 0 : V.granularity) === Gf.Granularity.Atom) {
        const { atomName: k, x: G, y: L, z: R } = O.info;
        t(2, p = `${k} (${[G, L, R].map((F) => F.toFixed(3)).join(", ")})`);
      } else
        t(2, p = "");
    }), window.__material_viewer = u, setTimeout(() => u.refresh(), 50);
  }
  const x = setInterval(
    () => {
      var O;
      !((O = document.getElementById(`material-viewer-canvas-${f}`)) === null || O === void 0) && O.clientHeight && !u.canvas3d && (clearInterval(x), T(), console.log(i), S());
    },
    500
  );
  function w() {
    u.canvas3d && (u.clear(), S());
  }
  const E = () => {
    setTimeout(
      () => {
        u.refresh({ fixCamera: !0 });
      },
      0
    );
  }, I = (O) => {
    t(1, m = { x: O.offsetX, y: O.offsetY });
  }, B = () => u.managers.camera.zoomIn(), D = () => u.managers.camera.zoomOut(), N = () => u.managers.camera.reset();
  return e.$$set = (O) => {
    "gradio" in O && t(7, a = O.gradio), "materialFile" in O && t(8, i = O.materialFile), "value" in O && t(6, o = O.value), "value_is_output" in O && t(9, c = O.value_is_output), "height" in O && t(0, s = O.height);
  }, e.$$.update = () => {
    e.$$.dirty[0] & /*value*/
    64 && o === null && t(6, o = ""), e.$$.dirty[0] & /*value*/
    64 && d(), e.$$.dirty[0] & /*mousePosition*/
    2, e.$$.dirty[0] & /*tooltipText*/
    4, e.$$.dirty[0] & /*materialFile*/
    256 && w(), e.$$.dirty[0] & /*height*/
    1 && E();
  }, [
    s,
    m,
    p,
    u,
    v,
    f,
    o,
    a,
    i,
    c,
    I,
    B,
    D,
    N
  ];
}
class $Le extends FLe {
  constructor(r) {
    super(), kLe(
      this,
      r,
      jLe,
      GLe,
      zLe,
      {
        gradio: 7,
        materialFile: 8,
        value: 6,
        value_is_output: 9,
        height: 0
      },
      null,
      [-1, -1]
    );
  }
  get gradio() {
    return this.$$.ctx[7];
  }
  set gradio(r) {
    this.$$set({ gradio: r }), R1();
  }
  get materialFile() {
    return this.$$.ctx[8];
  }
  set materialFile(r) {
    this.$$set({ materialFile: r }), R1();
  }
  get value() {
    return this.$$.ctx[6];
  }
  set value(r) {
    this.$$set({ value: r }), R1();
  }
  get value_is_output() {
    return this.$$.ctx[9];
  }
  set value_is_output(r) {
    this.$$set({ value_is_output: r }), R1();
  }
  get height() {
    return this.$$.ctx[0];
  }
  set height(r) {
    this.$$set({ height: r }), R1();
  }
}
const {
  SvelteComponent: KLe,
  attr: DP,
  create_component: WLe,
  destroy_component: XLe,
  detach: YLe,
  element: QLe,
  flush: vi,
  init: ZLe,
  insert: JLe,
  mount_component: eke,
  safe_not_equal: rke,
  transition_in: tke,
  transition_out: nke
} = window.__gradio__svelte__internal;
function ake(e) {
  let r, t, n, a;
  return t = new $Le({
    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]
      )
    }
  }), {
    c() {
      r = QLe("div"), WLe(t.$$.fragment), DP(r, "class", "material-viewer-index-container svelte-1d67499"), DP(r, "style", n = `height: ${/*height*/
      e[4]}px;`);
    },
    m(i, o) {
      JLe(i, r, o), eke(t, r, null), a = !0;
    },
    p(i, [o]) {
      const c = {};
      o & /*gradio*/
      2 && (c.gradio = /*gradio*/
      i[1]), o & /*materialFile*/
      4 && (c.materialFile = /*materialFile*/
      i[2]), o & /*value*/
      1 && (c.value = /*value*/
      i[0]), o & /*value_is_output*/
      8 && (c.value_is_output = /*value_is_output*/
      i[3]), o & /*height*/
      16 && (c.height = /*height*/
      i[4]), t.$set(c), (!a || o & /*height*/
      16 && n !== (n = `height: ${/*height*/
      i[4]}px;`)) && DP(r, "style", n);
    },
    i(i) {
      a || (tke(t.$$.fragment, i), a = !0);
    },
    o(i) {
      nke(t.$$.fragment, i), a = !1;
    },
    d(i) {
      i && YLe(r), XLe(t);
    }
  };
}
function ike(e, r, t) {
  this && this.__awaiter;
  let { gradio: n } = r, { materialFile: a = "" } = r, { label: i = "Textbox" } = r, { elem_id: o = "" } = r, { elem_classes: c = [] } = r, { visible: s = !0 } = r, { value: u = "" } = r, { placeholder: l = "" } = r, { show_label: f } = r, { scale: d = null } = r, { min_width: m = void 0 } = r, { loading_status: p = void 0 } = r, { value_is_output: v = !1 } = r, { interactive: h } = r, { rtl: y = !1 } = r, { height: C } = r;
  window.process = {
    env: { NODE_ENV: "production", LANG: "" }
  };
  function S() {
    n.dispatch("change"), v || n.dispatch("input");
  }
  return e.$$set = (b) => {
    "gradio" in b && t(1, n = b.gradio), "materialFile" in b && t(2, a = b.materialFile), "label" in b && t(5, i = b.label), "elem_id" in b && t(6, o = b.elem_id), "elem_classes" in b && t(7, c = b.elem_classes), "visible" in b && t(8, s = b.visible), "value" in b && t(0, u = b.value), "placeholder" in b && t(9, l = b.placeholder), "show_label" in b && t(10, f = b.show_label), "scale" in b && t(11, d = b.scale), "min_width" in b && t(12, m = b.min_width), "loading_status" in b && t(13, p = b.loading_status), "value_is_output" in b && t(3, v = b.value_is_output), "interactive" in b && t(14, h = b.interactive), "rtl" in b && t(15, y = b.rtl), "height" in b && t(4, C = b.height);
  }, e.$$.update = () => {
    e.$$.dirty & /*value*/
    1 && u === null && t(0, u = ""), e.$$.dirty & /*value*/
    1 && S();
  }, [
    u,
    n,
    a,
    v,
    C,
    i,
    o,
    c,
    s,
    l,
    f,
    d,
    m,
    p,
    h,
    y
  ];
}
class oke extends KLe {
  constructor(r) {
    super(), ZLe(this, r, ike, ake, rke, {
      gradio: 1,
      materialFile: 2,
      label: 5,
      elem_id: 6,
      elem_classes: 7,
      visible: 8,
      value: 0,
      placeholder: 9,
      show_label: 10,
      scale: 11,
      min_width: 12,
      loading_status: 13,
      value_is_output: 3,
      interactive: 14,
      rtl: 15,
      height: 4
    });
  }
  get gradio() {
    return this.$$.ctx[1];
  }
  set gradio(r) {
    this.$$set({ gradio: r }), vi();
  }
  get materialFile() {
    return this.$$.ctx[2];
  }
  set materialFile(r) {
    this.$$set({ materialFile: r }), vi();
  }
  get label() {
    return this.$$.ctx[5];
  }
  set label(r) {
    this.$$set({ label: r }), vi();
  }
  get elem_id() {
    return this.$$.ctx[6];
  }
  set elem_id(r) {
    this.$$set({ elem_id: r }), vi();
  }
  get elem_classes() {
    return this.$$.ctx[7];
  }
  set elem_classes(r) {
    this.$$set({ elem_classes: r }), vi();
  }
  get visible() {
    return this.$$.ctx[8];
  }
  set visible(r) {
    this.$$set({ visible: r }), vi();
  }
  get value() {
    return this.$$.ctx[0];
  }
  set value(r) {
    this.$$set({ value: r }), vi();
  }
  get placeholder() {
    return this.$$.ctx[9];
  }
  set placeholder(r) {
    this.$$set({ placeholder: r }), vi();
  }
  get show_label() {
    return this.$$.ctx[10];
  }
  set show_label(r) {
    this.$$set({ show_label: r }), vi();
  }
  get scale() {
    return this.$$.ctx[11];
  }
  set scale(r) {
    this.$$set({ scale: r }), vi();
  }
  get min_width() {
    return this.$$.ctx[12];
  }
  set min_width(r) {
    this.$$set({ min_width: r }), vi();
  }
  get loading_status() {
    return this.$$.ctx[13];
  }
  set loading_status(r) {
    this.$$set({ loading_status: r }), vi();
  }
  get value_is_output() {
    return this.$$.ctx[3];
  }
  set value_is_output(r) {
    this.$$set({ value_is_output: r }), vi();
  }
  get interactive() {
    return this.$$.ctx[14];
  }
  set interactive(r) {
    this.$$set({ interactive: r }), vi();
  }
  get rtl() {
    return this.$$.ctx[15];
  }
  set rtl(r) {
    this.$$set({ rtl: r }), vi();
  }
  get height() {
    return this.$$.ctx[4];
  }
  set height(r) {
    this.$$set({ height: r }), vi();
  }
}
export {
  oke as default
};
